courthive-components 1.6.0 → 1.7.0
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.
- package/dist/components/competitivenessBar/aggregateCompetitiveness.d.ts +3 -0
- package/dist/components/competitivenessBar/buildCompetitivenessBar.d.ts +6 -0
- package/dist/components/competitivenessBar/buildCompetitivenessDonut.d.ts +6 -0
- package/dist/components/competitivenessBar/index.d.ts +7 -0
- package/dist/components/competitivenessBar/types.d.ts +6 -0
- package/dist/components/composition-editor/compositionEditorStore.d.ts +5 -3
- package/dist/components/composition-editor/compositionEditorTypes.d.ts +4 -2
- package/dist/components/composition-editor/sections/colorsSection.d.ts +3 -0
- package/dist/components/draw-card/buildDrawCard.d.ts +2 -0
- package/dist/components/draw-card/buildSkeletonCard.d.ts +2 -0
- package/dist/components/draw-card/defaultConfig.d.ts +3 -0
- package/dist/components/draw-card/index.d.ts +6 -0
- package/dist/components/draw-card/mapDraw.d.ts +18 -0
- package/dist/components/draw-card/styles.d.ts +18 -0
- package/dist/components/draw-card/types.d.ts +59 -0
- package/dist/compositions/resolvePublishedComposition.d.ts +12 -1
- package/dist/courthive-components.css +1 -1
- package/dist/courthive-components.es.js +5734 -5115
- package/dist/courthive-components.umd.js +32 -32
- package/dist/index.d.ts +4 -0
- package/dist/styles/applyCompositionColors.d.ts +9 -0
- package/dist/styles/themes/index.d.ts +1 -0
- package/dist/styles/themes/typtiTheme.d.ts +1 -0
- package/dist/types.d.ts +25 -0
- package/package.json +3 -3
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path>
|
|
80
80
|
</svg>
|
|
81
81
|
</div>
|
|
82
|
-
`}var{WALKOVER:Qn,DEFAULTED:$n,DOUBLE_WALKOVER:er,DOUBLE_DEFAULT:tr,RETIRED:nr,SUSPENDED:rr,CANCELLED:ir,IN_PROGRESS:ar,ABANDONED:or}=t.matchUpStatusConstants;function sr({configuration:e,matchUp:t,eventHandlers:n,sideNumber:r,winningSide:i,matchUpStatus:a,isWinningSide:o,gameScoreOnly:s,irregularEnding:c}){let l=document.createElement(`div`),u=e?.inlineScoring,d=t?.readyToScore;if(u&&d&&!(i||a===`COMPLETED`)&&(!a||a===`IN_PROGRESS`||a===`TO_BE_PLAYED`)){let e=Vn({matchUpStatus:ar});e.classList.add(`chc-live-chip`),e.addEventListener(`click`,e=>{e.stopPropagation(),n?.pillClick?.({pointerEvent:e,matchUp:t,sideNumber:r})}),l.appendChild(e)}else if(o&&!s){let e=Zn();typeof e==`string`?l.innerHTML=e:l.appendChild(e)}else if(c){let e=Vn({matchUpStatus:a});u&&(e.classList.add(`chc-live-chip`),e.addEventListener(`click`,e=>{e.stopPropagation(),n?.pillClick?.({pointerEvent:e,matchUp:t,sideNumber:r})})),l.appendChild(e)}return l}function cr({initialRoundNumber:e=1,eventHandlers:t,sideContainer:n,composition:r,participant:i,placeholder:a,sideNumber:o,matchUp:s}){let{winningSide:c,matchUpType:l,isRoundRobin:u,matchUpStatus:d}=s||{},f=r?.configuration,p,m=o?s?.sides?.find(e=>e.sideNumber===o):void 0;i||(i=m?.participant,p=f?.allDrawPositions||f?.drawPositions&&m?.drawPosition&&(s?.roundNumber===e||m?.participantFed||u)?m?.drawPosition:``);let h=l===`DOUBLES`,g=h?i?.individualParticipants?.[0]:i,b=h&&i?.individualParticipants?.[1],x=!!(c&&o===c||d===`BYE`&&i),S=f?.winnerChevron&&x,C=f?.teamLogo,w=[nr,Qn,$n,er,tr,rr,ir,ar,or].includes(d)&&!x,T=f?.gameScoreOnly,E=document.createElement(`div`);if(n&&(E.className=v({drawPosition:p,sideNumber:o}),p&&(E.dataset.drawPosition=String(p),f?.drawPositionColor&&E.style.setProperty(`--chc-draw-position-color`,f.drawPositionColor))),E.classList.add(`tmx-p`),E.setAttribute(`id`,i?.participantId||``),C){let e=qn({teamLogo:C,participantId:i?.participantId});E.appendChild(e)}let D=document.createElement(`div`);D.className=_(h?{variant:`doubles`}:{});let O=document.createElement(`div`);O.className=y({winnerChevron:S,isDoubles:h});let k=Nn({individualParticipant:g,eventHandlers:t,isWinningSide:x,composition:r,sideNumber:o,matchUp:s,side:m}).element;if(O.appendChild(k),b){let e=Nn({individualParticipant:b,eventHandlers:t,isWinningSide:x,composition:r,sideNumber:o,matchUp:s,side:m}).element;O.appendChild(e)}else h&&a&&Hn(a)&&O.appendChild(a);return D.appendChild(O),E.appendChild(D),n&&E.appendChild(sr({configuration:f,matchUp:s,eventHandlers:t,sideNumber:o,winningSide:c,matchUpStatus:d,isWinningSide:x,gameScoreOnly:T,irregularEnding:w})),E}var lr=()=>`chc-round-header`;function ur({eventHandlers:e,roundMatchUps:t,roundProfile:n,roundNumber:r,context:i}){let a=document.createElement(`div`);a.className=lr(),a.classList.add(`tmx-rh`),a.setAttribute(`roundNumber`,String(r));let o=j(e?.roundVisibilityClick),s=j(e?.roundHeaderClick);s&&(a.onclick=a=>e.roundHeaderClick({roundNumber:r,roundProfile:n,roundMatchUps:t,context:i,pointerEvent:a}));let c=n?.[r]?.roundName;if(!c)return a;let l=document.createElement(`div`);l.style.cssText=`display:flex; flex-direction:row; justify-content:space-between;`;let u=document.createElement(`div`);u.textContent=c,l.appendChild(u);let d=document.createElement(`div`);if(d.style.cssText=`display:flex; align-items:center; gap:4px;`,o){let a=i?.roundVisibilityState?.[r],o=a?.hidden===!0,s=a?.embargoed===!0,c=o?`fa-eye-slash`:s?`fa-clock`:`fa-eye`,l=o?`#e74c3c`:s?`#f39c12`:`inherit`,u=o||s?`0.85`:`0.7`,f=document.createElement(`i`);f.className=`fa-solid ${c} tmx-rh-vis`,f.style.cssText=`cursor:pointer; font-size:0.85rem; color:${l}; opacity:${u}; transition:opacity 0.15s;`,f.onmouseenter=()=>f.style.opacity=`1`,f.onmouseleave=()=>f.style.opacity=u,f.onclick=a=>{a.stopPropagation(),e.roundVisibilityClick({roundNumber:r,roundProfile:n,roundMatchUps:t,context:i,pointerEvent:a})},d.appendChild(f)}if(s){let e=document.createElement(`span`);e.style.cssText=`font-weight:bold; cursor:pointer;`,e.textContent=`⋮`,d.appendChild(e)}return l.appendChild(d),a.appendChild(l),a}var dr=()=>`chc-round-container`,fr=()=>`chc-structure`,pr=e=>(0,p.default)(`chc-round`,e?.variant===`adHoc`&&`chc-round--adhoc`);function mr({roundsNotPowerOf2:e,hasNoRoundPositions:t,roundNumbers:n,roundProfile:r}){return t?!0:e?!(n&&n.length>1&&r&&n.every((e,t)=>{if(t===0)return!0;let i=r[n[t-1]]?.matchUpsCount,a=r[e]?.matchUpsCount;return i&&a&&(a===i/2||a===i)})):!1}var hr=e=>(0,p.default)(`chc-group-separator`,e?.variant===0&&`chc-group-separator--0`,e?.roundOrder===`first`&&`chc-group-separator--round-first`,e?.roundOrder===`last`&&`chc-group-separator--round-last`),gr=()=>`chc-group-name`;function _r(){return`chc-selected-matchup`}var vr=()=>`chc-matchup-container`;function yr({configuration:e}){return e?.matchUpHover?`chc-matchup chc-matchup--custom-hover`:`chc-matchup`}function br({variant:e}){return(0,p.default)(`chc-center-info`,e!=null&&`chc-center-info--${e}`)}var xr=()=>`chc-column`,Sr=()=>`chc-entry`,Cr=()=>`chc-status`;function wr({eventHandlers:e,entryStatus:t,sideNumber:n,className:r,matchUp:i}){let a=document.createElement(`div`);j(e?.centerInfoClick)&&(a.onclick=t=>e.centerInfoClick({matchUp:i,sideNumber:n,pointerEvent:t})),a.className=(0,p.default)(br({variant:n}),r),a.classList.add(`tmx-ci`),a.setAttribute(`sideNumber`,String(n));let o=document.createElement(`div`);o.className=xr();let s=document.createElement(`div`);s.className=Sr();let c=document.createElement(`div`);c.className=Cr(),c.innerHTML=t?`Entry status: `:``,s.appendChild(c);let l=document.createElement(`div`);return l.className=Cr(),l.innerHTML=t||``,s.appendChild(l),o.appendChild(s),a.appendChild(o),{element:a}}var Tr={scheduleInfo:1.8,centerInfo:1.5,gameScore:2};function Er({composition:e,isDoubles:t,roundFactor:n=1}){let r=parseInt(window.getComputedStyle(document.body).getPropertyValue(`font-size`)),i=e?.configuration||{},a=i?.connectorWidth||16,o=i.centerInfo?Tr.centerInfo*r:0,s=i.scheduleInfo?Tr.scheduleInfo*r:0,c=(60+(i.showAddress?r:0))*(t?1.3:1)+o,l=c*n,u=(c+s)*n;return e=>{let t=(0,p.default)(`chc-link`,e.isFirstRound&&`chc-link--first-round`,e.link===`mr`&&`chc-link--no-link`,e.link===`m1`&&`chc-link--m1`,e.link===`m2`&&`chc-link--m2`,e.link===`m0`&&`chc-link--m0`,e.link===`noProgression`&&`chc-link--no-progression`);return{className:t,applyStyles(e){e.style.setProperty(`--chc-connector-w`,`${a}px`),e.style.setProperty(`--chc-link-m1-h`,`${l}px`),e.style.setProperty(`--chc-link-m2-h`,`${u}px`)},toString(){return t}}}}var Dr=e=>e=>(0,p.default)(`chc-score-wrapper`,(e?.sideNumber===1||String(e?.sideNumber)===`1`)&&`chc-score-wrapper--side1`,e?.fontSize===`small`&&`chc-score-wrapper--small`),Or=()=>`chc-tiebreak`,kr=e=>(0,p.default)(`chc-game-score`,e?.variant&&`chc-game-score--${e.variant}`),Ar=()=>`chc-game-wrapper`,jr=e=>(0,p.default)(`chc-point-score`,e?.inverted&&`chc-point-score--inverted`,e?.position===`leading`&&`chc-point-score--leading`,e?.position===`trailing`&&`chc-point-score--trailing`),Mr=e=>(0,p.default)(`chc-results-item`,e?.variant&&`chc-results-item--${e.variant}`);function Nr({value:e}={}){let t=document.createElement(`input`);return t.onclick=e=>e.target.select(),t.className=kr(),t.value=String(e||``),t}function Pr({gameScoreOnly:e,scoreStripes:t,set:n,sideNumber:r}){let i=r===n?.winningSide||n?.winningSide?`loser`:void 0,a=r===2?n.side2Score:n.side1Score,o=n.side2TiebreakScore!==void 0||n.side1TiebreakScore!==void 0,s=r===2?n.side2TiebreakScore:n.side1TiebreakScore,c=(a===void 0||n.tiebreakSet===!0)&&s!==void 0,l=c?s:a,u=t&&n.setNumber%2?`var(--chc-bg-secondary)`:`transparent`,d=n.editing?n.editing===r:void 0,f;if(d)f=Nr({value:l});else if(f=document.createElement(`p`),f.className=kr({variant:i}),f.classList.add(`tmx-st`),f.setAttribute(`setNumber`,n.setNumber),f.style.backgroundColor=u,f.innerHTML=l!=null&&!Number.isNaN(Number(l))?l:``,!e){let e=document.createElement(`span`);e.className=Or(),e.innerHTML=o&&!c?String(s):``,f.appendChild(e)}return f}function Fr(e,t,n,r,i,a){if(e.length===0)return;let o=e.at(-1);if(!(o.side1PointScore!=null||o.side2PointScore!=null))return;let s=t===2?o.side2PointScore:o.side1PointScore,c=n?.position||`trailing`,l=n?.inverted!==!1,u=document.createElement(`p`);return u.className=jr({inverted:l,position:c}),u.textContent=s==null?``:String(s),r?.configuration?.inlineScoring&&!o.winningSide&&(u.classList.add(`chc-inline-scoring-clickable`),u.style.cursor=`pointer`,u.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),i?.scoreIncrement?.({matchUpId:a.matchUpId,sideNumber:t,scoreType:`point`})})),u}function Ir(e,t,n,r,i){e.classList.add(`chc-inline-scoring-clickable`),e.style.cursor=`pointer`,e.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault();let a=t.mode===`games`?`game`:`point`;n?.scoreIncrement?.({matchUpId:r.matchUpId,sideNumber:i,scoreType:a})})}function Lr({participantHeight:e,eventHandlers:t,composition:n,sideNumber:r,matchUp:i}){let a=n?.configuration?.winnerChevron,o=n?.configuration?.gameScoreOnly,s=n?.configuration?.gameScore,c=i?.score?.sets||[],l=n?.configuration?.scoreBox,u=e?r===2?e:e-1:void 0,d=e=>{j(t?.scoreClick)&&(e.stopPropagation(),t.scoreClick({pointerEvent:e,matchUp:i}))},f=document.createElement(`div`);f.className=Dr()({...!l&&r===1&&{sideNumber:1},fontSize:`small`}),u&&(f.style.height=`${u}px`),f.classList.add(`sideScore`),f.classList.add(`tmx-scr`),f.onclick=d;let p=document.createElement(`div`);p.className=Ar();let m=Fr(c,r,s,n,t,i),h=n?.configuration?.resultsInfo&&r===1;h&&(p.style.alignSelf=`stretch`);let g=(e,t,n)=>{let r=document.createElement(`div`);r.style.cssText=`position:relative; align-self:stretch; display:flex; align-items:center;`,r.appendChild(e);let i=document.createElement(`div`);return i.className=Mr({variant:n}),i.textContent=t,r.appendChild(i),r},_=s?.position||`trailing`;m&&_===`leading`&&p.appendChild(h?g(m,`PTS`,`points`):m);let v=n?.configuration?.inlineScoring,y=i?.score?.scoreStringSide1?.split(/\s+/),b=i?.score?.scoreStringSide2?.split(/\s+/),x=(e,t)=>{if(!e.tiebreakSet||e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0)return e;let n=y?.[t]?.match(/^\[(\d+)-(\d+)\]$/),r=b?.[t]?.match(/^\[(\d+)-(\d+)\]$/);return!n&&!r?e:{...e,side1TiebreakScore:n?Number(n[1]):r?Number(r[2]):void 0,side2TiebreakScore:r?Number(r[1]):n?Number(n[2]):void 0}};for(let[e,n]of(c||[]).entries()){let s=x(n,e),c=Pr({gameScoreOnly:o,scoreStripes:a,sideNumber:r,set:s});v&&!s.winningSide&&Ir(c,v,t,i,r),p.appendChild(h?g(c,String(s.setNumber),`set`):c)}return m&&_!==`leading`&&p.appendChild(h?g(m,`PTS`,`points`):m),f.appendChild(p),f}var Rr=()=>`chc-scheduling`,zr=f(l(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){"use strict";var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))());function Br({matchUp:e,eventHandlers:n}){let{scheduledTime:r,scheduledDate:i,venueAbbreviation:a,courtName:o}=e?.schedule||{},{dateTime:{extractDate:s,extractTime:c}}=t.tools,l=c(r),u=s(i),d=`ddd D MMMM`;l&&(d+=`, hh:mm A`,u+=`T${l}`);let f=i?(0,zr.default)(u).format(d):`Not scheduled`,p=a&&o?.toString().startsWith(a)&&o||a&&o&&`${a} ${o}`||o||a||``,m=document.createElement(`div`);m.className=Rr(),m.classList.add(`tmx-sch`),j(n?.scheduleClick)&&(m.onclick=t=>n.scheduleClick({matchUp:e,pointerEvent:t}));let h=document.createElement(`div`);h.innerHTML=f,m.append(h);let g=t=>{j(n?.venueClick)&&(t.stopPropagation(),n.venueClick({pointerEvent:t,matchUp:e}))},_=document.createElement(`div`);_.style=`display: flex; flex-direction: row`;let v=document.createElement(`div`);if(v.style.paddingRight=`.2rem`,v.onclick=g,v.innerHTML=p,_.append(v),m.append(_),m.onclick){let e=document.createElement(`div`);e.innerHTML=`⋮`,_.append(e)}return m}var{completedMatchUpStatuses:Vr}=t.factoryConstants;function Hr({initialRoundNumber:e=1,eventHandlers:n,composition:r,sideNumber:i,className:a,matchUp:o}){let s=r?.configuration||{},c=s?.scheduleInfo,l=o?.score?.scoreStringSide1||o?.score?.sets?.length,u=r?.configuration?.scoreBox&&l,d=o?.matchUpStatus&&Vr.includes(o.matchUpStatus),f=o?.readyToScore&&n?.scoreClick&&!t.tournamentEngine.checkScoreHasValue({matchUp:o})&&!d,m=document.createElement(`div`);if(m.className=(0,p.default)(Jn(),a),m.classList.add(`tmx-sd`),m.setAttribute(`sideNumber`,String(i)),c&&i===1){let e=Br({matchUp:o,eventHandlers:n});m.appendChild(e)}let h=document.createElement(`div`);h.className=Yn();let g=cr({sideContainer:!0,initialRoundNumber:e,eventHandlers:n,composition:r,sideNumber:i,matchUp:o});if(h.appendChild(g),u){let e=document.createElement(`div`);e.style.border=`1px solid var(--chc-border-secondary)`,h.appendChild(e)}let _=s?.inlineScoring;if(l){let e=Lr({eventHandlers:n,composition:r,sideNumber:i,matchUp:o});h.appendChild(e)}else if(_&&o?.readyToScore&&!d){let e=Lr({eventHandlers:n,composition:r,sideNumber:i,matchUp:{...o,score:{sets:[{setNumber:1,side1Score:0,side2Score:0,..._.mode===`points`&&{side1PointScore:`0`,side2PointScore:`0`}}]}}});h.appendChild(e)}if(f&&!_){let e=e=>{j(n?.scoreClick)&&(e.stopPropagation(),n.scoreClick({pointerEvent:e,matchUp:o}))},t=document.createElement(`div`);t.className=Dr()({...!u&&i===1&&{sideNumber:1},fontSize:`small`}),t.onclick=e,t.innerHTML=`[Score]`,h.appendChild(t)}return m.appendChild(h),m}var{QUALIFYING:Ur}=t.drawDefinitionConstants;function Wr(e){let{composition:t,initialRoundNumber:n=1,matchUp:r,moiety:i,selectedMatchUpId:a,searchActive:o}=e,{roundFactor:s,roundNumber:c,finishingRound:l,matchUpType:u,preFeedRound:d,stage:f}=r,m=e.isFinalRound||(l?Number.parseInt(String(l))===1:!1),h=f===Ur&&m,g=m,_=c?Number.parseInt(String(c))===n:!1,v=u===`DOUBLES`,y=(o||r.isRoundRobin||r.collectionId||e.isLucky||e.isAdHoc)&&`mr`||g&&`noProgression`||(h||d)&&`m0`||i&&`m1`||`m2`,b=Er({composition:t,isDoubles:v,roundFactor:s})({isFirstRound:_,link:y}),x=b.className,S=t?.configuration||{},{centerInfo:C}=S||{},w=e.eventHandlers||{},T=e=>{j(w?.matchUpClick)&&w.matchUpClick({pointerEvent:e,matchUp:r})},E=document.createElement(`div`);E.className=(0,p.default)(t?.theme,e?.className,`matchup`,vr()),E.classList.add(`tmx-m`),E.setAttribute(`id`,r?.matchUpId),E.onclick=T;let D=document.createElement(`div`);D.className=yr({configuration:S});let O=({sideNumber:e})=>{let t=r?.sides?.find(t=>t.sideNumber===e)?.participant?.entryStatus?.replace(`_`,` `);return wr({eventHandlers:w,entryStatus:t,sideNumber:e,className:e===2?x:void 0,matchUp:r})},k=Hr({initialRoundNumber:n,eventHandlers:w,sideNumber:1,composition:t,matchUp:r}),A=Hr({className:!C&&x,initialRoundNumber:n,eventHandlers:w,sideNumber:2,composition:t,matchUp:r});if(D.appendChild(k),C){let e=O({sideNumber:1}),t=O({sideNumber:2});D.appendChild(e.element),t.element&&b.applyStyles(t.element),D.appendChild(t.element)}if(D.appendChild(A),C||b.applyStyles(A),S?.matchUpFooter){let e=document.createElement(`div`),t=S?.inlineScoring,n=r.sides?.length===2&&r.sides[0]?.participant&&r.sides[1]?.participant,i=t?.canUndo||t?.canRedo||t?.isComplete||t?.isDirty;if(t&&t.showFooter!==!1&&n&&(!r.winningSide||i)){e.className=`chc-matchup-footer chc-inline-scoring-footer-slot`;let n=document.createElement(`span`);n.className=`chc-matchup-footer-round`;let i=r.roundName||``,a=r.roundPosition;n.textContent=a?`${i} \u2022 M${a}`:i,e.appendChild(n);let o=document.createElement(`div`);o.className=`chc-inline-scoring-footer-buttons`;let s=(e,t,n)=>{let i=document.createElement(`button`);return i.textContent=e,i.className=`chc-inline-scoring-btn ${t}`,n&&(i.onclick=e=>{e.stopPropagation(),n({matchUpId:r.matchUpId})}),i},c=s(`Undo`,`chc-is-undo`,w.inlineUndo),l=s(`Redo`,`chc-is-redo`,w.inlineRedo),u=s(`Clear`,`chc-is-clear`,w.inlineClear),d=s(`Submit`,`chc-is-submit`,w.inlineSubmit);c.disabled=!t.canUndo,l.disabled=!t.canRedo,u.disabled=!t.canUndo&&!t.canRedo,d.disabled=!t.isDirty;let f=document.createElement(`div`);f.className=`chc-inline-scoring-buttons`,f.append(c,l,u,d),o.appendChild(f),e.appendChild(o)}else{e.className=`chc-matchup-footer`;let t=r.roundName||``,n=r.roundPosition;e.textContent=n?`${t} \u2022 Match ${n}`:t}D.appendChild(e)}if(E.appendChild(D),a===r.matchUpId){let e=document.createElement(`div`);e.className=_r(),E.appendChild(e)}return E}function Gr({initialRoundNumber:e=1,selectedMatchUpId:n,eventHandlers:r,isFinalRound:i,isRoundRobin:a,searchActive:o,composition:s,roundFactor:c,roundNumber:l,roundProfile:u,minWidth:d,matchUps:f,context:p,isLucky:m}){let h=f.filter(e=>e.roundNumber===l).sort((e,t)=>(e.roundPosition||0)-(t.roundPosition||0)),g=h.every(({roundPosition:e,drawPositions:t})=>!e&&!t),_=s?.configuration||{},v=document.createElement(`div`);if(v.className=dr(),v.classList.add(`tmx-rd`),v.setAttribute(`roundNumber`,String(l)),_.roundHeader){let e=ur({roundProfile:u,roundMatchUps:h,roundNumber:l,eventHandlers:r,context:p});v.appendChild(e)}let y=document.createElement(`div`);y.className=pr({variant:g?`adHoc`:void 0}),d&&(y.style.minWidth=d);let b,x,S;if(a){let e=e=>(e||[]).reduce((e,t)=>t+e,0);h.sort((t,n)=>{let r=e(t.drawPositions)-e(n.drawPositions),i=t.drawPositions||[],a=n.drawPositions||[],o=(i.length?Math.min.apply(null,i):0)-(a.length?Math.min.apply(null,a):0);return r||o});let n=h.reduce((e,t)=>(e[t.structureId]=t.structureName,e),{});b=Object.values(n),x=Object.keys(n),S=Object.keys(t.tools.instanceCount(h.map(({structureId:e})=>e))).length}else g&&h.sort((e,t)=>(e.roundOrder??0)-(t.roundOrder??0));let C=S&&h.length/S,w=Object.keys(u).map(e=>parseInt(e)),T=w.indexOf(l),E=T===0&&`first`||T===w.length-1&&`last`,D=null;return h.forEach((t,a)=>{let d=C&&!(a%C),f=C&&Math.floor(a/C),p=C&&b[f];if(d){D=document.createElement(`div`),D.className=`chc-rr-group`,D.setAttribute(`data-group-id`,x[f]),y.appendChild(D);let t=document.createElement(`div`);t.className=hr({...f===0&&{variant:0},...E&&{roundOrder:E}}),D.appendChild(t);let n=document.createElement(`div`);if(n.className=gr(),j(r?.groupHeaderClick)){let{drawId:e,containerStructureId:t}=h[0];D.onclick=n=>r.groupHeaderClick({structureId:x[f],containerStructureId:t,pointerEvent:n,drawId:e})}l===e&&(n.innerHTML=p),D.appendChild(n)}let _=a%2==0;if(c)t.roundFactor=c;else if(e>1&&t.roundFactor){let n=u?.[e]?.roundFactor||1;t.roundFactor/=n}else t.roundFactor||=2**(l-e);let v=Wr({initialRoundNumber:e,selectedMatchUpId:n,eventHandlers:r,isFinalRound:i,searchActive:o,composition:s,isAdHoc:g,isLucky:m,matchUp:t,moiety:_});(D||y).appendChild(v)}),v.appendChild(y),v}function Kr({initialRoundNumber:e=1,selectedMatchUpId:n,eventHandlers:r,searchActive:i,composition:a,structureId:o,finalColumn:s,matchUps:c,minWidth:l,context:u}){let{roundNumbers:d,roundProfile:f,roundsNotPowerOf2:p,hasNoRoundPositions:m}=t.tournamentEngine.getRoundMatchUps({matchUps:c});o=o||u?.structureId||c?.[0]?.structureId;let h=c.some(({isRoundRobin:e})=>e),g=mr({roundsNotPowerOf2:p,hasNoRoundPositions:m,roundNumbers:d,roundProfile:f}),_=document.createElement(`div`);_.className=fr(),_.classList.add(`tmx-str`),_.setAttribute(`id`,o||``);let v=d.length?Math.max.apply(null,d):0;for(let t of d){if(t<e)continue;let o=Gr({initialRoundNumber:e,selectedMatchUpId:n,eventHandlers:r,isFinalRound:t===v,isRoundRobin:h,searchActive:i,composition:a,roundNumber:t,roundProfile:f,matchUps:c,minWidth:l,context:u,isLucky:g});_.appendChild(o)}let y=null,b=(e,t)=>{_.querySelectorAll(`.tmx-i[id="${CSS.escape(e)}"]`).forEach(e=>{e.closest(`.tmx-p`)?.classList.toggle(`chc-participant-hover`,t)})};if(_.addEventListener(`mouseover`,e=>{let t=e.target.closest(`.tmx-i`)?.id;t&&t!==`undefined`&&t!==y?(y&&b(y,!1),y=t,b(t,!0)):(!t||t===`undefined`)&&y&&(b(y,!1),y=null)}),_.addEventListener(`mouseleave`,()=>{y&&=(b(y,!1),null)}),s&&typeof s!=`boolean`){let e=document.createElement(`div`);e.className=dr();let t=document.createElement(`div`);t.className=pr(),t.appendChild(s),e.appendChild(t),_.appendChild(e)}return _}var qr=()=>`chc-container`;function Jr({content:e,theme:t}){let n=document.createElement(`div`);return n.className=t?(0,p.default)(qr(),t):qr(),t&&n.classList.add(t),typeof e==`string`?n.innerHTML=e:n.appendChild(e),n}function Yr(e,t){return`chc-theme-${e.replace(`-theme`,``)}`}var Xr=Yr(`australian-theme`,{colors:{borderHover:`#0091d2`,connector:`#999`}}),Zr=Yr(`basiccard-theme`,{colors:{connector:`transparent`,border:`#ddd`,borderHover:`#0066cc`,matchupBoxShadow:`0 1px 4px rgba(0, 0, 0, 0.1)`}}),Qr=Yr(`wimbledon-theme`,{borderWidths:{},colors:{connector:`transparent`,border:`#00703c`,matchUp:`var(--chc-bg-elevated)`},participant:{textTransform:`uppercase`}}),$r=Yr(`french-theme`,{colors:{winnerName:`#01503d!important`,winner:`#01503d!important`,borderHover:`#0091d2`,border:`var(--chc-border-secondary)`},matchUp:{boxShadow:`0 0 30px 0 hsla(0,0%,89%,9)`}}),ei=Yr(`usopen-theme`,{colors:{matchUpBackgroundColor:`var(--chc-bg-secondary)`,internalDividers:`darkgray`,borderHover:`#0091d2`,connector:`#999`}}),ti=Yr(`basic-theme`,{colors:{internalDividers:`transparent`,winner:`#50B649!important`,loser:`#E61A1A!important`,connector:`#999`},space:{gameMarginInlineEnd:`0.75rem`},participant:{seed:`transparent`},fontSizes:{1:`1.5rem`}}),ni=Yr(`itf-theme`,{colors:{borderHover:`#0091d2`,connector:`#999`,matchUp:`var(--chc-bg-elevated)`},participant:{textTransform:`uppercase`,seed:`gray`}}),ri={Australian:{configuration:{flags:!0},theme:Xr},Basic:{configuration:{gameScoreOnly:!0,teamLogo:!1,roundHeader:!0,placeHolders:{tbd:`TBD`,bye:`Bye`}},theme:ti},DrawPositions:{configuration:{gameScoreOnly:!0,drawPositions:!0,teamLogo:!1},theme:ti},French:{configuration:{bracketedSeeds:!0,flags:!0},theme:$r},Wimbledon:{configuration:{resultsInfo:!0,flags:!0},theme:Qr},"US Open":{configuration:{scoreBox:!0,flags:!0},theme:ei},ITF:{configuration:{winnerChevron:!0,centerInfo:!0,flags:!0,roundHeader:!0},theme:ni},BasicCard:{configuration:{flags:!0,scheduleInfo:!0,matchUpFooter:!0,roundHeader:!0},theme:Zr},InlineScoring:{configuration:{matchUpFooter:!0,gameScore:{position:`trailing`,inverted:!0},inlineScoring:{mode:`games`,showFooter:!0,showSituation:!0}},theme:Zr},National:{configuration:{bracketedSeeds:`square`,allDrawPositions:!0,drawPositions:!0,scheduleInfo:!0,roundHeader:!0,showAddress:!0,scaleAttributes:{scaleColor:`red`,scaleType:`RATING`,scaleName:`WTN`,accessor:`wtnRating`}},theme:Xr}},ii=`National`;function ai(e,t=ii){let n=ri[e?.compositionName??t]??ri[t]??ri[ii];return{theme:e?.theme??n.theme,configuration:{...n.configuration,...e?.configuration}}}var{QUALIFYING:oi}=t.drawDefinitionConstants;function si({matchUp:e,moiety:t,isFirstRound:n,isFinalRound:r,isRoundRobin:i,isLucky:a}){let{stage:o,preFeedRound:s}=e,c=o===oi&&r,l=r,u=(i||e.collectionId||a)&&`mr`||l&&`noProgression`||(c||s)&&`m0`||t&&`m1`||`m2`,d=document.createElement(`div`);d.className=`chc-schematic-matchup`;let f=document.createElement(`div`);f.className=`chc-schematic-slot`;let m=document.createElement(`div`);m.className=`chc-schematic-divider`;let h=document.createElement(`div`);h.className=(0,p.default)(`chc-schematic-slot`,`chc-schematic-link`,n&&`chc-schematic-link--first-round`,u===`mr`&&`chc-schematic-link--no-link`,u===`m1`&&`chc-schematic-link--m1`,u===`m2`&&`chc-schematic-link--m2`,u===`m0`&&`chc-schematic-link--m0`,u===`noProgression`&&`chc-schematic-link--no-progression`);let g=e.roundFactor||1,_=11/2*g,v=11/2*g;return h.style.setProperty(`--chc-schematic-connector-w`,`8px`),h.style.setProperty(`--chc-schematic-m1-h`,`${_}px`),h.style.setProperty(`--chc-schematic-m2-h`,`${v}px`),d.appendChild(f),d.appendChild(m),d.appendChild(h),d}function ci({initialRoundFactor:e,initialRoundNumber:t=1,isFinalRound:n,isRoundRobin:r,roundNumber:i,matchUps:a,showHeader:o,isLucky:s}){let c=a.filter(e=>e.roundNumber===i).sort((e,t)=>(e.roundPosition||0)-(t.roundPosition||0)),l=document.createElement(`div`);if(l.className=`chc-schematic-round-container`,l.dataset.roundNumber=String(i),o){let e=document.createElement(`div`);e.className=`chc-schematic-round-header`,e.textContent=`R${i}`,l.appendChild(e)}let u=document.createElement(`div`);return u.className=`chc-schematic-round`,c.forEach((a,o)=>{e&&a.roundFactor?a.roundFactor/=e:a.roundFactor||=2**(i-t);let c=o%2==0,l=si({initialRoundNumber:t,isRoundRobin:r,isFinalRound:n,isFirstRound:i===t,isLucky:s,matchUp:a,moiety:c});u.appendChild(l)}),c.some(e=>e.preFeedRound)&&!n&&l.classList.add(`chc-schematic-round--pre-feed`),l.appendChild(u),l}function li({initialRoundNumber:e=1,showHeaders:n=!0,structureId:r,matchUps:i}){let{roundNumbers:a,roundProfile:o,roundsNotPowerOf2:s,hasNoRoundPositions:c}=t.tournamentEngine.getRoundMatchUps({matchUps:i}),l=i.some(e=>e.isRoundRobin),u=s||c,d=e>1?o?.[e]?.roundFactor||1:void 0,f=document.createElement(`div`);f.className=`chc-schematic-structure`,r&&f.setAttribute(`id`,`schematic-${r}`);let p=a.length?Math.max(...a):0;for(let t of a){if(t<e)continue;let r=ci({showHeader:n,initialRoundFactor:d,initialRoundNumber:e,isRoundRobin:l,isFinalRound:t===p,roundNumber:t,matchUps:i,isLucky:u});f.appendChild(r)}return f}function ui(e,t,n){let r=document.createElement(`div`);r.style.cssText=`display: flex; flex-direction: column; width: 100%;`,r.classList.add(`flexcol`);let i={},a={},o;for(let e of t){if((e.text||e.html)&&!e.field){o=fi(e,r,i,a,o);continue}if(e.divider){let e=document.createElement(`hr`);e.classList.add(`dropdown-divider`),r.appendChild(e);continue}if(e.spacer){let t=document.createElement(`div`),n=typeof e.spacer==`number`&&`${e.spacer}em`||typeof e.spacer==`string`&&e.spacer||`1em`;t.style.marginBlockEnd=n,r.appendChild(t);continue}!e.label&&!e.field||e.hide||e.field&&(o=pi(e,r,i,a,o))}return o&&setTimeout(()=>o.focus(),200),e.appendChild(r),n?.length&&mi(n,t,i,a),i}function di(e,t,n,r){let i=r,{field:a,inputElement:o,datepicker:s}=ln(e.fieldPair);return s&&(t[`${e.field}.date`]=s),o&&(t[e.fieldPair.field]=o,e.fieldPair.focus&&(i=o)),n[e.fieldPair.field]=a,i}function fi(e,t,n,r,i){let a=i,o=e.fieldPair&&document.createElement(`div`);o&&(o.className=`flexrow`);let s=document.createElement(`div`);s.className=`flexaligncenter`,s.style.cssText=e.style||e.header&&`font-weight: bold; font-size: larger;`||`height: 2.5em; padding-right: 1em;`;let c=document.createElement(`div`);return e.id&&(c.id=e.id),c.className=`content`,c.innerHTML=e.text,s.appendChild(c),o?(o.appendChild(s),a=di(e,n,r,a),o.appendChild(r[e.fieldPair.field]),t.appendChild(o)):t.appendChild(s),a}function pi(e,t,n,r,i){let a=i,o=e.fieldPair&&document.createElement(`div`);o&&(o.className=`flexrow`);let{field:s,inputElement:c,datepicker:l,subFields:u}=ln(e);return u&&u.forEach(e=>n[e.field]=e.input),l&&(n[`${e.field}.date`]=l),e.focus&&(a=c),n[e.field]=c,r[e.field]=s,o?(o.appendChild(s),a=di(e,n,r,a),o.appendChild(r[e.fieldPair.field]),t.appendChild(o)):t.appendChild(s),a}function mi(e,t,n,r){for(let i of e){if(i.dateRange&&Array.isArray(i.fields)){let[e,r]=i.fields;if(n[e]&&n[r]){let a=t.find(t=>t.field===e),o=new rn(n[e],{inputs:[n[e],n[r]],minDate:i.minDate,maxDate:i.maxDate,format:`yyyy-mm-dd`,language:a?.language||`en`,autohide:!0});n[`${e}.date`]=o}}i.control&&(B(i.onChange)&&n[i.control].addEventListener(`change`,e=>i.onChange({e,inputs:n,fields:r})),B(i.onInput)&&n[i.control]&&n[i.control].addEventListener(`input`,e=>i.onInput({e,inputs:n,fields:r})),B(i.onFocusOut)&&n[i.control]&&n[i.control].addEventListener(`focusout`,e=>i.onFocusOut({e,inputs:n,fields:r})))}}var{ratingsParameters:hi}=t.fixtures,{WTN:gi,UTR:_i}=t.factoryConstants.ratingConstants,{FEMALE:vi,MALE:yi,ANY:bi}=t.genderConstants;function xi(e={}){let{callback:n,consideredDate:r,title:i=`Generate mock participants`,labels:a={},defaults:o={},roleOptions:s}=e,c,l=s&&s.length>1,u=o.participantRole||s?.[0]?.value||`COMPETITOR`,d={role:a.role||`Participant role`,gender:a.gender||`Participant gender`,count:a.count||`Participant count`,ageRange:a.ageRange||`Participant Age Range`,minAge:a.minAge||`Min Age`,maxAge:a.maxAge||`Max Age`,ratings:a.ratings||`Generate Ratings`,countries:a.countries||`# of Countries`,cancel:a.cancel,generate:a.generate,genderAny:a.genderAny,genderFemale:a.genderFemale,genderMale:a.genderMale},f=o.ratings?[...o.ratings]:[...o.wtnRating?[gi]:[],...o.utrRating?[_i]:[]],p={gender:o.gender||bi,participantsCount:o.participantsCount||32,ageMin:o.ageMin,ageMax:o.ageMax,nationalityCodesCount:o.nationalityCodesCount},m=Object.entries(hi).filter(([,e])=>!e.deprecated).map(([e])=>({label:e,value:e,selected:f.includes(e)})),h=[{label:d.cancel||`Cancel`,intent:`none`,close:!0},{label:d.generate||`Generate`,intent:`is-info`,close:!0,onClick:()=>{let e=c.participantsCount.value,i=c.gender.value,a=i===bi?void 0:i,o=l?c.participantRole.value:u,s=c.ageMin?.value?Number.parseInt(c.ageMin.value):void 0,d=c.ageMax?.value?Number.parseInt(c.ageMax.value):void 0,f=c.nationalityCodesCount?.value?Number.parseInt(c.nationalityCodesCount.value):void 0,p=(c.ratings?.selectedValues||[]).map(e=>{let t=hi[e];if(!t)return null;let[n,r]=t.range||[0,100],i=Math.min(n,r),a=Math.max(n,r)-i;return{ratingType:e,ratingMin:i+a*.3,ratingMax:i+a*.7}}).filter(Boolean),m=s||d?{ageMin:s,ageMax:d}:void 0,{participants:h}=t.mocksEngine.generateParticipants({participantsCount:Number.parseInt(e),scaleAllParticipants:!0,nationalityCodesCount:f,participantRole:o,consideredDate:r,categories:p,category:m,sex:a});n&&n(h)}}],g=[{control:`ageMin`,onChange:({inputs:e})=>{let t=Number.parseInt(e.ageMin.value)||0,n=Number.parseInt(e.ageMax.value)||0;t>n&&n>0&&(e.ageMax.value=t)}},{control:`ageMax`,onChange:({inputs:e})=>{let t=Number.parseInt(e.ageMin.value)||0,n=Number.parseInt(e.ageMax.value)||0;n<t&&t>0&&n>0&&(e.ageMin.value=n)}}],_=l?[{options:s.map(e=>({label:e.label,value:e.value,selected:e.value===u})),label:d.role,field:`participantRole`,value:u}]:[];F.open({title:i,content:e=>c=ui(e,[..._,{options:[{label:d.genderAny||`Any`,value:bi,selected:p.gender===bi},{label:d.genderFemale||`Female`,value:vi,selected:p.gender===vi},{label:d.genderMale||`Male`,value:yi,selected:p.gender===yi}],label:d.gender,field:`gender`,value:p.gender},{options:[{label:`8`,value:8,selected:p.participantsCount===8},{label:`16`,value:16,selected:p.participantsCount===16},{label:`32`,value:32,selected:p.participantsCount===32},{label:`64`,value:64,selected:p.participantsCount===64},{label:`128`,value:128,selected:p.participantsCount===128},{label:`256`,value:256,selected:p.participantsCount===256}],label:d.count,field:`participantsCount`,value:p.participantsCount},{label:d.minAge,field:`ageMin`,placeholder:`e.g., 10`,type:`number`,value:p.ageMin,width:`50%`,fieldPair:{label:d.maxAge,field:`ageMax`,placeholder:`e.g., 18`,type:`number`,value:p.ageMax}},{label:d.countries,field:`nationalityCodesCount`,id:`nationalityCodesCount`,placeholder:`e.g., 10`,type:`number`,value:p.nationalityCodesCount},{label:d.ratings,field:`ratings`,id:`ratings`,multiple:!0,options:m}],g),buttons:h})}var{FEMALE:Si,MALE:Ci,ANY:wi}=t.genderConstants,{TEAM:Ti}=t.participantConstants;function Ei(e){if(!e?.collectionDefinitions?.length)return 8;let t=0;for(let n of e.collectionDefinitions){let e=n.matchUpCount||0,r=n.matchUpType===`DOUBLES`?2:1;t+=e*r}return t||8}function Di(e={}){let{callback:n,consideredDate:r,title:i=`Generate mock teams`,tieFormats:a=[],labels:o={}}=e,s,c=a.length>0,l=[{label:o.manualTeamSize||`Manual team size`,value:`-`,selected:!0},...a.map(e=>({label:e.label,value:e.value,selected:!1}))],u=[{label:o.cancel||`Cancel`,intent:`none`,close:!0},{label:o.generate||`Generate`,intent:`is-info`,close:!0,onClick:()=>{let e=Number.parseInt(s.teamsCount.value)||4,i=s.gender.value,o=i===wi?void 0:i,l,u=c?s.tieFormatSelect?.value:`-`;if(u&&u!==`-`){let e=a.find(e=>e.value===u);l=e?Ei(e.tieFormat):8;let t=s.teamSize?.value,n=t?Number.parseInt(t):0;n>l&&(l=n)}else l=Number.parseInt(s.teamSize?.value)||8;let d=s.nationalityCodesCount?.value?Number.parseInt(s.nationalityCodesCount.value):void 0,{participants:f}=t.mocksEngine.generateParticipants({participantsCount:e,participantType:Ti,nationalityCodesCount:d,consideredDate:r,teamSize:l,sex:o});n&&n(f)}}],d=c?[{control:`tieFormatSelect`,onChange:({inputs:e})=>{let t=e.tieFormatSelect.value;if(t&&t!==`-`){let n=a.find(e=>e.value===t),r=n?Ei(n.tieFormat):8;e.teamSize.value=r,e.teamSize.disabled=!0}else e.teamSize.disabled=!1}}]:[],f=c?[{options:l,label:o.tieFormatTemplate||`Tie format template`,field:`tieFormatSelect`,value:`-`}]:[];F.open({title:i,content:e=>s=ui(e,[{options:[{label:o.genderAny||`Any`,value:wi,selected:!0},{label:o.genderFemale||`Female`,value:Si},{label:o.genderMale||`Male`,value:Ci}],label:o.gender||`Gender`,field:`gender`,value:wi},{options:[{label:`2`,value:2},{label:`4`,value:4,selected:!0},{label:`8`,value:8},{label:`16`,value:16},{label:`32`,value:32}],label:o.teamsCount||`Number of teams`,field:`teamsCount`,value:4},...f,{label:o.playersPerTeam||`Players per team`,field:`teamSize`,placeholder:`e.g., 8`,type:`number`,value:8},{label:o.countries||`# of Countries`,field:`nationalityCodesCount`,placeholder:`e.g., 10`,type:`number`}],d),buttons:u})}var Oi=`grand-slam`,ki=`tour`,Ai=`itf`,ji=`national-federation`,Mi=[{id:Oi,name:`Grand Slam`,category:Oi,tier:1},{id:`wimbledon`,name:`Wimbledon`,category:Oi,tier:1},{id:`australian-open`,name:`Australian Open`,category:Oi,tier:2},{id:`wta-500`,name:`WTA 500`,category:ki,tier:2},{id:`wta-1000`,name:`WTA 1000`,category:ki,tier:2},{id:`atp-250`,name:`ATP 250`,category:ki,tier:2},{id:`atp-finals`,name:`ATP Finals`,category:ki,tier:3},{id:`itf-junior`,name:`ITF Junior`,category:Ai,tier:3},{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,category:Ai,tier:2},{id:ji,name:`National Federation`,category:`national`,tier:3},{id:`collegiate-ncaa`,name:`NCAA Collegiate`,category:`collegiate`,tier:1},{id:`club-basic`,name:`Club Basic`,category:`club`,tier:1}];function Ni(e={}){let t=`preset`,n={},r={},i={},a,o=t=>{i=ui(t,[{header:!0,text:`Composition Preset`},{spacer:.5},{field:`preset`,label:`Select Preset`,options:Mi.map(t=>({label:`${t.name} (${t.category}, Tier ${t.tier})`,value:t.id,selected:t.id===(e.initialPreset||`club-basic`)}))},{spacer:1},{text:`Select a preset to populate header and footer settings, then customize in the Header and Footer tabs.`,style:`color: var(--chc-text-muted); font-size: 13px;`}])},s=t=>{let r=e.initialHeader||{};n=ui(t,[{header:!0,text:`Header Configuration`},{spacer:.5},{field:`layout`,label:`Layout`,options:[{label:`Grand Slam`,value:Oi,selected:r.layout===Oi},{label:`ITF / Professional`,value:Ai,selected:r.layout===Ai},{label:`WTA / ATP Tour`,value:`wta-tour`,selected:r.layout===`wta-tour`},{label:`National Federation`,value:ji,selected:r.layout===ji},{label:`Minimal`,value:`minimal`,selected:r.layout===`minimal`||!r.layout},{label:`None`,value:`none`,selected:r.layout===`none`}]},{divider:!0},{field:`tournamentName`,label:`Tournament Name`,value:r.tournamentName||``,placeholder:`e.g., Australian Open 2026`},{field:`subtitle`,label:`Subtitle / Event`,value:r.subtitle||``,placeholder:`e.g., Womens Singles`},{divider:!0},{field:`startDate`,label:`Start Date`,value:r.startDate||``,placeholder:`e.g., 19 Jan 2026`,fieldPair:{field:`endDate`,label:`End Date`,value:r.endDate||``,placeholder:`e.g., 1 Feb 2026`}},{field:`city`,label:`City`,value:r.city||``,placeholder:`e.g., Melbourne`,fieldPair:{field:`country`,label:`Country`,value:r.country||``,placeholder:`e.g., AUS`}},{field:`surface`,label:`Surface`,value:r.surface||``,placeholder:`e.g., Hard`},{field:`prizeMoney`,label:`Prize Money`,value:r.prizeMoney||``,placeholder:`e.g., 1,520,600`},{divider:!0},{field:`supervisor`,label:`Supervisor`,value:r.supervisor||``},{field:`grade`,label:`Grade`,value:r.grade||``,placeholder:`e.g., J300`},{field:`sectionLabel`,label:`Section Label`,value:r.sectionLabel||``,placeholder:`e.g., SINGLES MAIN DRAW`}])},c=t=>{let n=e.initialFooter||{};r=ui(t,[{header:!0,text:`Footer Configuration`},{spacer:.5},{field:`layout`,label:`Layout`,options:[{label:`Standard (timestamp + page)`,value:`standard`,selected:n.layout===`standard`||!n.layout},{label:`Seedings Table`,value:`seedings-table`,selected:n.layout===`seedings-table`},{label:`Prize Money`,value:`prize-money`,selected:n.layout===`prize-money`},{label:`Officials Sign-off`,value:`officials-signoff`,selected:n.layout===`officials-signoff`},{label:`Combined Tour (WTA/ATP)`,value:`combined-tour`,selected:n.layout===`combined-tour`},{label:`None`,value:`none`,selected:n.layout===`none`}]},{divider:!0},{field:`showPageNumbers`,id:`comp-pagenums`,label:`Show Page Numbers`,checkbox:!0,checked:n.showPageNumbers!==!1},{field:`showTimestamp`,id:`comp-timestamp`,label:`Show Timestamp`,checkbox:!0,checked:n.showTimestamp!==!1},{divider:!0},{field:`releaseDate`,label:`Release Date`,value:n.releaseDate||``,placeholder:`e.g., 18 Jan 2026 at 15:30`},{field:`drawCeremonyDate`,label:`Draw Ceremony`,value:n.drawCeremonyDate||``,placeholder:`e.g., 18 Jan 2026 at 14:00`}])},l=()=>({layout:n.layout?.value||`minimal`,tournamentName:n.tournamentName?.value||``,subtitle:n.subtitle?.value||void 0,startDate:n.startDate?.value||void 0,endDate:n.endDate?.value||void 0,city:n.city?.value||void 0,country:n.country?.value||void 0,surface:n.surface?.value||void 0,prizeMoney:n.prizeMoney?.value||void 0,supervisor:n.supervisor?.value||void 0,grade:n.grade?.value||void 0,sectionLabel:n.sectionLabel?.value||void 0}),u=()=>({layout:r.layout?.value||`standard`,showPageNumbers:r.showPageNumbers?.checked??!0,showTimestamp:r.showTimestamp?.checked??!0,releaseDate:r.releaseDate?.value||void 0,drawCeremonyDate:r.drawCeremonyDate?.value||void 0}),d=[{label:`Preset`,active:!0,onClick:()=>{t=`preset`,f()}},{label:`Header`,active:!1,onClick:()=>{t=`header`,f()}},{label:`Footer`,active:!1,onClick:()=>{t=`footer`,f()}}],f=()=>{d.forEach(e=>e.active=e.label.toLowerCase()===t);let e=t===`preset`?o:t===`header`?s:c;a&&a.update({content:e,config:{menu:{menuItems:d},maxWidth:520}})};return a=F.open({title:`PDF Composition`,content:o,buttons:[{label:`Apply`,intent:`is-info`,onClick:()=>{let t={header:l(),footer:u(),preset:i.preset?.value};e.onApply?.(t),F.close()}},{label:`Cancel`,close:!0}],config:{menu:{menuItems:d},maxWidth:520}}),a}var Pi={showParticipantNames:!0,showNationality:!0,showSeedings:!0,showMatchNumber:!1,showEventRound:!0,showScheduledTime:!0,showMatchFormat:!1,showScore:!0,nameFormat:`full`,cellStyle:`detailed`};function Fi(e={}){let t={...Pi,...e.initial},n={},r=e=>{n=ui(e,[{header:!0,text:`Schedule Cell Content`},{text:`Select which information appears in each schedule grid cell.`,style:`color: var(--chc-text-muted); font-size: 13px;`},{spacer:.5},{field:`showNationality`,id:`scc-nationality`,label:`Nationality (country code)`,checkbox:!0,checked:t.showNationality},{field:`showSeedings`,id:`scc-seedings`,label:`Seedings`,checkbox:!0,checked:t.showSeedings},{field:`showEventRound`,id:`scc-eventround`,label:`Event & Round`,checkbox:!0,checked:t.showEventRound},{field:`showScheduledTime`,id:`scc-time`,label:`Scheduled Time / Not Before`,checkbox:!0,checked:t.showScheduledTime},{field:`showScore`,id:`scc-score`,label:`Score (for completed matches)`,checkbox:!0,checked:t.showScore},{field:`showMatchNumber`,id:`scc-matchnum`,label:`Match Number`,checkbox:!0,checked:t.showMatchNumber},{field:`showMatchFormat`,id:`scc-format`,label:`Match Format Code`,checkbox:!0,checked:t.showMatchFormat},{divider:!0},{field:`nameFormat`,label:`Name Format`,options:[{label:`Full (LASTNAME, First)`,value:`full`,selected:t.nameFormat===`full`},{label:`Abbreviated (F. LASTNAME)`,value:`abbreviated`,selected:t.nameFormat===`abbreviated`},{label:`Last Name Only`,value:`lastOnly`,selected:t.nameFormat===`lastOnly`}]},{field:`cellStyle`,label:`Cell Density`,options:[{label:`Detailed`,value:`detailed`,selected:t.cellStyle===`detailed`},{label:`Compact`,value:`compact`,selected:t.cellStyle===`compact`}]}])},i=()=>({showParticipantNames:!0,showNationality:n.showNationality?.checked??!0,showSeedings:n.showSeedings?.checked??!0,showMatchNumber:n.showMatchNumber?.checked??!1,showEventRound:n.showEventRound?.checked??!0,showScheduledTime:n.showScheduledTime?.checked??!0,showMatchFormat:n.showMatchFormat?.checked??!1,showScore:n.showScore?.checked??!0,nameFormat:n.nameFormat?.value||`full`,cellStyle:n.cellStyle?.value||`detailed`}),a=document.createElement(`div`);a.style.cssText=`display: flex; gap: 6px; margin-top: 4px;`;let o=[{label:`Detailed`,config:{...Pi}},{label:`Compact`,config:{...Pi,showNationality:!1,showScheduledTime:!1,showMatchFormat:!1,nameFormat:`abbreviated`,cellStyle:`compact`}},{label:`Broadcast`,config:{...Pi,showMatchNumber:!0,showMatchFormat:!0}},{label:`Minimal`,config:{...Pi,showNationality:!1,showSeedings:!1,showScheduledTime:!1,showMatchFormat:!1,showScore:!1,nameFormat:`lastOnly`,cellStyle:`compact`}}];for(let e of o){let t=document.createElement(`button`);t.textContent=e.label,t.className=`chc-button chc-button--sm`,t.style.cssText=`padding: 2px 8px; font-size: 11px; cursor: pointer; border: 1px solid var(--chc-border-primary); border-radius: 3px; background: var(--chc-bg-secondary);`,t.onclick=()=>{let t=e.config;n.showNationality&&(n.showNationality.checked=t.showNationality),n.showSeedings&&(n.showSeedings.checked=t.showSeedings),n.showMatchNumber&&(n.showMatchNumber.checked=t.showMatchNumber),n.showEventRound&&(n.showEventRound.checked=t.showEventRound),n.showScheduledTime&&(n.showScheduledTime.checked=t.showScheduledTime),n.showMatchFormat&&(n.showMatchFormat.checked=t.showMatchFormat),n.showScore&&(n.showScore.checked=t.showScore),n.nameFormat&&(n.nameFormat.value=t.nameFormat),n.cellStyle&&(n.cellStyle.value=t.cellStyle)},a.appendChild(t)}return F.open({title:`Schedule Cell Configuration`,content:e=>{r(e);let t=document.createElement(`div`);t.style.cssText=`font-size: 12px; color: var(--chc-text-muted); margin-top: 12px;`,t.textContent=`Quick presets:`,e.appendChild(t),e.appendChild(a)},buttons:[{label:`Apply`,intent:`is-info`,onClick:()=>{e.onApply?.(i()),F.close()}},{label:`Cancel`,close:!0}],config:{maxWidth:440}})}var Ii=`Timed set`,Li=`Tiebreak`,Ri=[`SET`,`HAL`,`QTR`,`PER`,`INN`,`RND`,`FRM`,`MAP`],zi={SET:`Set`,HAL:`Half`,QTR:`Quarter`,PER:`Period`,INN:`Inning`,RND:`Round`,FRM:`Frame`,MAP:`Map`};function Bi(e){return!e||e===`SET`?[1,3,5]:[1,2,3,4,5,6,7,8,9,10,11,12]}function Vi(e=!1){return{descriptor:e?`Final set`:`Best of`,bestOf:e?void 0:3,advantage:`Ad`,what:`Set`,setTo:6,tiebreakAt:6,tiebreakTo:7,winBy:2,minutes:10}}function Hi(){return{matchRoot:void 0,aggregate:void 0,gameFormat:void 0,setFormat:Vi(!1),finalSetFormat:Vi(!0)}}function Ui(e){return!!(e?.tiebreakSet?.tiebreakTo&&!e?.setTo)}function Wi(e,t){let{what:n,setTo:r,tiebreakAt:i,tiebreakTo:a,winBy:o,minutes:s,advantage:c,based:l,modifier:u}=e,d={setTo:r};return n===`Set`&&c===`No-Ad`&&(d.NoAD=!0),t&&n===`Set`&&(d.tiebreakAt=i,d.tiebreakFormat={tiebreakTo:a},o===1&&(d.tiebreakFormat.NoAD=!0),u&&(d.tiebreakFormat.modifier=u)),n===`Timed set`&&(d.minutes=s,d.timed=!0,l&&(d.based=l),u&&(d.modifier=u)),n===`Tiebreak`&&(d.tiebreakSet={tiebreakTo:a},o===1&&(d.tiebreakSet.NoAD=!0),u&&(d.tiebreakSet.modifier=u)),d}function Gi(e){return e<=1?[]:[e-1,e]}function Ki(e,t){return Gi(e).includes(t)?t:e}function qi(e){if(e)return e.tiebreakSet?.modifier||e.tiebreakFormat?.modifier||e.modifier||void 0}function Ji(e,t){let n=t(e);if(!n)return Hi();let r=Vi(!1),i=Vi(!0),a={matchRoot:n.matchRoot||void 0,aggregate:n.aggregate||void 0,gameFormat:n.gameFormat||void 0,setFormat:{...r,...n.setFormat},finalSetFormat:{...i,...n.finalSetFormat}};n.setFormat?.based&&(a.setFormat.based=n.setFormat.based),n.finalSetFormat?.based&&(a.finalSetFormat.based=n.finalSetFormat.based);let o=qi(n.setFormat);o&&(a.setFormat.modifier=o);let s=qi(n.finalSetFormat);return s&&(a.finalSetFormat.modifier=s),n.exactly?(a.setFormat.exactly=n.exactly,a.setFormat.descriptor=`Exactly`,delete a.setFormat.bestOf,a.setFormat.timed&&(a.setFormat.what=Ii)):(a.setFormat.bestOf=n.bestOf||3,a.setFormat.descriptor=`Best of`,delete a.setFormat.exactly),Ui(n.setFormat)&&(a.setFormat.what=Li,a.setFormat.tiebreakTo=n.setFormat.tiebreakSet.tiebreakTo,a.setFormat.winBy=n.setFormat.tiebreakSet.NoAD?1:2),n.setFormat?.timed&&(a.setFormat.what=Ii,a.setFormat.minutes=n.setFormat.minutes),Ui(n.finalSetFormat)&&(a.finalSetFormat.what=Li,a.finalSetFormat.tiebreakTo=n.finalSetFormat.tiebreakSet.tiebreakTo,a.finalSetFormat.winBy=n.finalSetFormat.tiebreakSet.NoAD?1:2),n.finalSetFormat?.timed&&(a.finalSetFormat.what=Ii,a.finalSetFormat.minutes=n.finalSetFormat.minutes),a}var Yi=[{key:`custom`,name:`Custom`,desc:``},{key:`standard`,name:`Standard Advantage`,format:`SET3-S:6/TB7`,desc:`Best of 3 Sets to 6 with Advantage`},{key:`atpd`,name:`Standard Doubles`,format:`SET3-S:6NOAD/TB7-F:TB10`,desc:`Best of 3 Sets to 6, no Ad`,desc2:`Final Set Tiebreak to 10`},{key:`standard1`,name:`One Standard Set`,format:`SET1-S:6/TB7`,desc:`1 Set to 6 Games, Tiebreak to 7`},{key:`wimbledon2018`,name:`Wimbledon 2018`,format:`SET5-S:6/TB7-F:6`,desc:`Best of 5 tiebreak sets, final set no tiebreak`},{key:`wimbledon2019`,name:`Wimbledon 2019`,format:`SET5-S:6/TB7-F:6/TB7@12`,desc:`Best of 5 tiebreak sets, final set tiebreak at 12`},{key:`Aus2019`,name:`Australian Open 2019`,format:`SET5-S:6/TB7-F:6/TB10`,desc:`Best of 5 tiebreak sets, final set tiebreak at 12`},{key:`short`,name:`Short Sets TB7@4`,format:`SET3-S:4/TB7`,desc:`Best of 3 Sets to 4, tiebreak to 7 at 4-4`},{key:`short1`,name:`Fast 4`,format:`SET3-S:4/TB5@3`,desc:`Best of 3 Sets to 4, tiebreak to 5 at 3-3`},{key:`short2`,name:`One Short Set TB7`,format:`SET1-S:4/TB7`,desc:`One Set to 4, tiebreak to 7 at 4-4`},{key:`short3`,name:`One Short Set TB5`,format:`SET1-S:4/TB5@3`,desc:`One Set to 4, tiebreak to 5 at 3-3`},{key:`short4`,name:`Short Sets w/ 3rd TB10`,format:`SET3-S:4/TB7-F:TB10`,desc:`Best of 3 Sets to 4 Games, tiebreak to 10`,desc2:`3rd Set Tiebreak to 7`},{key:`short5`,name:`Short Sets w/ 3rd TB7`,format:`SET3-S:4/TB7-F:TB7`,desc:`Best of 3 Sets to 4 Games, tiebreak to 7`,desc2:`3rd Set Tiebreak to 7`},{key:`pro`,name:`Pro Set`,format:`SET1-S:8/TB7`,desc:`One Set to 8 with Advantage, tiebreak at 8-8`},{key:`cps`,name:`College Pro Set`,format:`SET1-S:8/TB7@7`},{key:`tbsets1`,name:`Best of 3 TB7`,format:`SET3-S:TB7`,desc:`Two tiebreak sets`,desc2:`7-point match tiebreak at one set all`},{key:`tbsets2`,name:`Best of 3 TB10`,format:`SET3-S:TB10`,desc:`Best of 3 tiebreaks to 10`},{key:`tbsets3`,name:`One Tiebreak to 10`,format:`SET1-S:TB10`,desc:`One Match Tiebreak to 10 with Advantage`},{key:`tbsets4`,name:`Two TB7 w/ 3rd TB10`,format:`SET3-S:TB7-F:TB10`,desc:`Two 7 point tiebreak sets`,desc2:`10 point tiebreak at one set all`},{key:`timed10`,name:`Timed 10 minute game - game based`,format:`SET1-S:T10`},{key:`1pointslam`,name:`1 Point Slam`,format:`SET1-S:TB1NOAD`},{key:`pickleball`,name:`Pickleball Standard`,format:`SET3-S:TB11`,desc:`Best of 3 games to 11`},{key:`pickleballRally`,name:`Pickleball Rally`,format:`SET3-S:TB11@RALLY`,desc:`Best of 3 games to 11, rally scoring`},{key:`mlp`,name:`MLP Format`,format:`SET5-S:TB21@RALLY-F:TB15@RALLY`,desc:`Best of 5 to 21, final to 15, rally scoring`},{key:`padel`,name:`Padel Standard`,format:`SET3-S:6NOAD/TB7`,desc:`Best of 3 sets to 6, golden point`},{key:`padelStarPoint`,name:`Padel Star Point (2026)`,format:`SET3-S:6/TB7-G:TN3D`,desc:`Best of 3 sets to 6, golden point, Star Point deuce`},{key:`squash`,name:`Squash PAR-11`,format:`SET5-S:TB11`,desc:`Best of 5 games to 11`},{key:`badminton`,name:`Badminton BWF`,format:`SET3-S:TB21`,desc:`Best of 3 games to 21`},{key:`volleyball`,name:`Volleyball Indoor`,format:`SET5-S:TB25-F:TB15`,desc:`Best of 5 sets to 25, final to 15`},{key:`beachVolleyball`,name:`Beach Volleyball`,format:`SET3-S:TB21-F:TB15`,desc:`Best of 3 sets to 21, final to 15`},{key:`soccer`,name:`Soccer`,format:`HAL2A-S:T45`,desc:`2 halves of 45 minutes, aggregate`},{key:`basketball`,name:`Basketball NBA`,format:`QTR4A-S:T12`,desc:`4 quarters of 12 minutes, aggregate`},{key:`iceHockey`,name:`Ice Hockey`,format:`PER3A-S:T20`,desc:`3 periods of 20 minutes, aggregate`},{key:`boxing`,name:`Boxing Championship`,format:`RND12A-S:T3`,desc:`12 rounds of 3 minutes, aggregate`},{key:`mma`,name:`MMA Standard`,format:`RND3A-S:T5`,desc:`3 rounds of 5 minutes, aggregate`},{key:`blw`,name:`BLW Standard`,format:`INN4XA-S:O3-M:T50`,desc:`4 innings, 3 outs, 50 minute max match time`},{key:`typti`,name:`TYPTI Standard`,format:`SET5-S:5-G:3C`,desc:`Best of 5 sets to 5, 3 consecutive points/game`},{key:`intennse`,name:`INTENNSE`,format:`SET7XA-S:T10P`,desc:`Exactly 7 timed sets, aggregate, points-based`}],H=`none`,U=`▾`,Xi=`all .2s ease-in-out`,Zi=`var(--chc-text-primary)`,Qi=`var(--chc-dropdown-bg)`,$i=`var(--chc-hover-bg)`;function ea(e){return typeof e==`function`}var ta={labels:{title:`Match format`,setFormatLabel:`Set format`,finalSetLabel:`Final set`,tiebreakLabel:`Tiebreak`,finalSetToggleLabel:`Final set`,standardFormatsLabel:`Standard formats`,cancel:`Cancel`,select:`Select`,custom:`Custom`,aggregate:`Aggregate`,game:`Game`,gameType:`Game type`,deuceRule:`Deuce rule`,none:`None`,traditional:`Traditional`,consecutive2:`2 consecutive`,consecutive3:`3 consecutive`,consecutive4:`4 consecutive`,goldenPoint:`Golden point`,starPoint:`Star point`,games:`Games`,points:`Points`,descriptors:{bestOf:`Best of`,exactly:`Exactly`},what:{sets:`Set`,tiebreaks:`Tiebreak`,timedSets:`Timed set`},advantage:{ad:`Ad`,noAd:`No-Ad`}},options:{bestOf:[1,3,5],exactly:[1,2,3,4,5,6,7,8,9,10,11,12],setTo:[1,2,3,4,5,6,7,8,9],tiebreakTo:[1,3,5,7,9,10,11,12,13,15,21,25],tiebreakToExactly:[1,3],tiebreakAt:[3,4,5,6,7,8],minutes:[3,5,8,10,12,15,20,25,30,45,60,90,120],winBy:[1,2],matchRoots:[...Ri],gameFormats:[`None`,`TN`,`2C`,`3C`,`4C`],modifiers:[`None`,`RALLY`]}},W=ta,na,G,ra={};function K(e){return ra[e]||document.getElementById(e)||null}var ia=`Timed set`,aa=`Tiebreak`,oa=`No-Ad`,sa=`Set`,ca=`Ad`,la={Games:`G`,Points:`P`};function ua(){return{G:W.labels?.games||`Games`,P:W.labels?.points||`Points`}}function da(){return{None:W.labels?.none||`None`,TN:W.labels?.traditional||`Traditional`,"2C":W.labels?.consecutive2||`2 consecutive`,"3C":W.labels?.consecutive3||`3 consecutive`,"4C":W.labels?.consecutive4||`4 consecutive`}}function fa(){return{None:W.labels?.none||`None`,"1D":W.labels?.goldenPoint||`Golden point`,"3D":W.labels?.starPoint||`Star point`}}function pa(e){let t=da(),n=fa();if(!e)return W.labels?.none||`None`;let r;if(e.type===`TRADITIONAL`)r=t.TN||`Traditional`;else if(e.type===`CONSECUTIVE`)r=t[`${e.count}C`]||`${e.count} consecutive`;else return W.labels?.none||`None`;if(e.deuceAfter){let t=`${e.deuceAfter}D`;r+=` + ${n[t]||t}`}return r}var q={matchRoot:void 0,aggregate:void 0,gameFormat:void 0,setFormat:{descriptor:`Best of`,bestOf:3,advantage:ca,what:sa,setTo:6,tiebreakAt:6,tiebreakTo:7,winBy:2,minutes:10},finalSetFormat:{descriptor:`Final set`,advantage:ca,what:sa,setTo:6,tiebreakAt:6,tiebreakTo:7,winBy:2,minutes:10}};function ma(e){let t=q[e?`finalSetFormat`:`setFormat`];return Wi(t,K(e?`finalSetTiebreak`:`setTiebreak`)?.checked||!1)}function ha(){G={setFormat:ma()},q.matchRoot&&q.matchRoot!==`SET`&&(G.matchRoot=q.matchRoot),q.aggregate&&(G.aggregate=!0),q.gameFormat&&(G.gameFormat=q.gameFormat);let e=q.setFormat.descriptor,n=q.setFormat.exactly??q.setFormat.bestOf??3;e===`Exactly`?(G.exactly=n,delete G.bestOf):(G.bestOf=n,delete G.exactly),K(`finalSetOption`)?.checked&&(G.finalSetFormat=ma(1));let r=t.governors.scoreGovernor.stringifyMatchUpFormat(G),i=(W.preDefinedFormats?W.preDefinedFormats.map(e=>({value:e.code,label:e.text,format:e.code})):Yi).some(e=>e.format===r),a=K(`matchUpFormatSelector`);if(a){let e=a.value,t=i?r:`Custom`;if(e!==t){let e=a.onchange;a.onchange=null,a.value=t,a.onchange=e}}return r}function ga(e){let t=e||ha();na=t;let n=K(`matchUpFormatString`);n&&(n.innerHTML=t)}var _a=(e,t)=>t&&e.finalSetFormat||e.setFormat,va=[{getValue:e=>e.exactly?W.labels?.descriptors?.exactly||`Exactly`:W.labels?.descriptors?.bestOf||`Best of`,options:()=>[W.labels?.descriptors?.bestOf||`Best of`,W.labels?.descriptors?.exactly||`Exactly`],id:`descriptor`,value:W.labels?.descriptors?.bestOf||`Best of`,finalSet:!1,onChange:`changeDescriptor`},{getValue:e=>e.bestOf||e.exactly,finalSet:!1,id:`bestOf`,options:()=>q.setFormat.descriptor===(W.labels?.descriptors?.exactly||`Exactly`)?W.options?.exactly||ta.options.exactly:Bi(q.matchRoot),onChange:`pluralize`,onChangeCallback:`updateFinalSetVisibility`,value:3},{getValue:(e,t)=>{let n=_a(e,t),r=n?.NoAD?oa:ca;return n?.timed||n?.tiebreakSet?void 0:r},options:[ca,oa],onChange:`changeAdvantage`,defaultValue:ca,id:`advantage`,whats:[sa]},{getValue:(e,t)=>{let n=_a(e,t);return n||console.log({pmf:e}),n?.timed?ia:n?.tiebreakSet?aa:sa},options:[sa,aa,ia],finalSetLabel:`${sa}${U}`,onChange:`changeWhat`,onChangeCallback:`updateWhatValue`,pluralize:!0,id:`what`},{getValue:(e,t)=>_a(e,t).setTo,options:()=>W.options?.setTo||ta.options.setTo,onChange:`changeCount`,defaultValue:6,whats:[sa],prefix:`to `,id:`setTo`},{getValue:(e,t)=>{let n=_a(e,t);return n.tiebreakFormat?.tiebreakTo||n.tiebreakSet?.tiebreakTo},options:e=>{let t=q.setFormat.descriptor,n=W.options?.tiebreakTo||ta.options.tiebreakTo,r=W.options?.tiebreakToExactly||ta.options.tiebreakToExactly;return e&&t===`Exactly`?[...r,...n]:n},onChange:`changeTiebreakTo`,whats:[sa,aa],id:`tiebreakTo`,defaultValue:7,prefix:`TB to `,tbSet:!0,value:7,tb:!0},{getValue:(e,t)=>_a(e,t).tiebreakAt,options:e=>{let t=q[e?`finalSetFormat`:`setFormat`].setTo;return Gi(t)},onChange:`changeTiebreakAt`,id:`tiebreakAt`,defaultValue:6,whats:[sa],prefix:`@`,value:6,tb:!0},{getValue:(e,t)=>{let n=_a(e,t);if(!(!n.tiebreakFormat&&!n.tiebreakSet))return n.tiebreakFormat?.NoAD||n.tiebreakSet?.NoAD?1:2},whats:[sa,aa],onChange:`changeWinBy`,prefix:`Win by `,options:[1,2],defaultValue:2,tbSet:!0,id:`winBy`,tb:!0},{getValue:(e,t)=>{let n=_a(e,t);return n.timed&&n.minutes||void 0},options:()=>W.options?.minutes||ta.options.minutes,onChange:`changeMinutes`,whats:[ia],suffix:` Minutes`,defaultValue:10,id:`minutes`,timed:!0},{getValue:(e,t)=>{let n=_a(e,t);if(!n?.timed)return;let r=n.based||`G`;return ua()[r]||r},options:()=>[`Games`,`Points`],onChange:`changeBased`,whats:[ia],defaultValue:`Games`,id:`based`,timed:!0},{getValue:(e,t)=>{let n=_a(e,t);return n?.tiebreakSet?.modifier||n?.tiebreakFormat?.modifier||n?.modifier||void 0},options:()=>W.options?.modifiers||ta.options.modifiers,onChange:`changeModifier`,whats:[aa,ia],prefix:`@`,defaultValue:`None`,id:`modifier`,tb:!0}];function ya(e){if(q.setFormat.what!==ia){delete q.setFormat.setTo,delete q.setFormat.tiebreakAt,delete q.setFormat.tiebreakTo,delete q.setFormat.winBy,delete q.setFormat.tiebreakFormat,delete q.setFormat.NoAD,q.setFormat.what=ia,q.setFormat.minutes||(q.setFormat.minutes=10),Sa.changeWhat(new Event(`click`),void 0,ia);let t=K(`what`);t&&(t.innerHTML=`${ia}${e>1?`s`:``}${U}`);let n=K(`minutes`);n&&(n.innerHTML=`${q.setFormat.minutes} Minutes${U}`,n.style.display=``);let r=K(`based`);if(r){let e=q.setFormat.based||`G`;r.innerHTML=`${ua()[e]||e}${U}`,r.style.display=``}}q.setFormat.exactly=e,delete q.setFormat.bestOf}function ba(e){let t=e%2==0?e+1:e;q.setFormat.bestOf=t,delete q.setFormat.exactly;let n=K(`bestOf`);n&&(n.innerHTML=`${t}${U}`),t!==e&&Sa.pluralize(new Event(`click`),void 0,t)}function xa(){let e=K(`tiebreakTo-1`);if(!e||e.style.display===H)return;let t=q.finalSetFormat.tiebreakTo||7,n=va.find(e=>e.id===`tiebreakTo`);if(!n)return;let{prefix:r=``,suffix:i=``}=n,a=(ea(n.options)?n.options(1):n.options).includes(t)?t:7;a!==t&&(q.finalSetFormat.tiebreakTo=a),e.innerHTML=`${r}${a}${i}${U}`}var Sa={changeDescriptor:(e,t,n)=>{q.setFormat.descriptor=n;let r=q.setFormat.bestOf||q.setFormat.exactly||3;n===`Exactly`?ya(r):ba(r),xa(),ga()},changeWhat:(e,t,n)=>{let r=n===sa,i=K(t?`finalSetTiebreakToggle`:`setTiebreakToggle`);if(i&&(i.style.display=r?``:H),!t&&n!==ia&&q.setFormat.descriptor===`Exactly`){q.setFormat.descriptor=`Best of`;let e=q.setFormat.exactly||3,t=e%2==0?e+1:e;q.setFormat.bestOf=t,delete q.setFormat.exactly;let n=K(`descriptor`);n&&(n.innerHTML=`Best of${U}`);let r=K(`bestOf`);r&&(r.innerHTML=`${t}${U}`)}va.forEach(e=>{if(e.whats){let{prefix:r=``,suffix:i=``,pluralize:a}=e,o=e.whats.includes(n),s=K(t?`${e.id}-${t}`:e.id);if(!s)return;if(s.style.display===H&&o){let n=G.bestOf||G.exactly,o=!t&&a&&n>1?`s`:``,c=e.defaultValue;s.innerHTML=`${r}${c}${o}${i}${U}`;let l=c;if(e.id===`modifier`&&c===`None`&&(l=void 0),e.id===`based`){let e=la[c]||c;l=e===`G`?void 0:e}q[t?`finalSetFormat`:`setFormat`][e.id]=l}s.style.display=o?``:H}}),ga()},changeCount:(e,t,n)=>{let r=t?`finalSetFormat`:`setFormat`;q[r].setTo=n;let i=q[r].tiebreakAt,a=Ki(n,i);if(a!==i){q[r].tiebreakAt=a;let e=K(t?`tiebreakAt-${t}`:`tiebreakAt`);e&&(e.innerHTML=`@${a}${U}`)}ga()},changeTiebreakAt:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].tiebreakAt=n,ga()},updateWhatValue:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].what=n},changeAdvantage:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].advantage=n,ga()},changeTiebreakTo:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].tiebreakTo=n,ga()},changeWinBy:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].winBy=n,ga()},changeMinutes:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].minutes=n,ga()},changeBased:(e,t,n)=>{let r=t?`finalSetFormat`:`setFormat`,i=la[n]||n;if(q[r].based=i===`G`?void 0:i,!t){let e=K(`gameFormat`);e&&(i===`P`?(q.gameFormat=void 0,e.style.display=H):e.style.display=``)}ga()},changeModifier:(e,t,n)=>{let r=t?`finalSetFormat`:`setFormat`;q[r].modifier=n===`None`?void 0:n,ga()},changeMatchRoot:(e,t,n)=>{let r=q.matchRoot||`SET`;if(q.matchRoot=n===`SET`?void 0:n,r!==n){let e=Bi(q.matchRoot),t=q.setFormat.bestOf;if(t&&!e.includes(t)){let n=e[e.length-1]>=t?e.reduce((e,n)=>n<=t?n:e,e[0]):e[e.length-1];q.setFormat.bestOf=n;let r=K(`bestOf`);r&&(r.innerHTML=`${n}${U}`)}}ga()},changeAggregate:()=>{q.aggregate=K(`aggregateOption`)?.checked||void 0,ga()},changeGameFormat:(e,t,n)=>{q.gameFormat=n,ga()},pluralize:(e,t,n)=>{let r=q[t?`finalSetFormat`:`setFormat`].what,i=K(t?`what-${t}`:`what`);i&&(i.innerHTML=`${r}${n>1?`s`:``}${U}`),t||(q.setFormat.descriptor===`Exactly`?(q.setFormat.exactly=n,delete q.setFormat.bestOf):(q.setFormat.bestOf=n,delete q.setFormat.exactly)),ga()},updateFinalSetVisibility:(e,t,n)=>{let r=n>1,i=K(`finalSetOption`),a=K(`finalSetOptionLabel`);i&&a&&(r?(i.style.display=``,a.style.display=``):(i.checked&&(i.checked=!1,i.dispatchEvent(new Event(`change`))),i.style.display=`none`,a.style.display=`none`))}};function Ca({existingMatchUpFormat:e=`SET3-S:6/TB7`,callback:n,config:r,modalConfig:i}={}){W=r?{labels:{...ta.labels,...r.labels},options:{...ta.options,...r.options},preDefinedFormats:r.preDefinedFormats||ta.preDefinedFormats}:ta,na=e,ra={},G=t.matchUpFormatCode.parse(na),G||=(console.warn(`Invalid matchUpFormat:`,na),na=`SET3-S:6/TB7`,t.matchUpFormatCode.parse(na));let a=Ji(na,t.matchUpFormatCode.parse);q.matchRoot=a.matchRoot,q.aggregate=a.aggregate,q.gameFormat=a.gameFormat,q.setFormat={...a.setFormat},q.finalSetFormat={...a.finalSetFormat};let o=()=>{let e=K(`matchUpFormatSelector`),t=e?.value&&e.value!==`Custom`?na:ha();ea(n)&&n(t)},s=[{onClick:()=>{ka(),n?.(``)},label:W.labels?.cancel||`Cancel`,intent:`none`,footer:{className:`button`,style:`background-color: var(--chc-bg-primary); color: var(--chc-text-primary); border: 1px solid var(--chc-border-primary);`},close:!0},{label:W.labels?.select||`Select`,intent:`is-info`,close:!0,onClick:()=>{ka(),o()}}],c=`switch is-rounded is-danger`,l=document.createElement(`div`);l.addEventListener(`click`,e=>{let t=e.target;!t.closest(`.dropdown`)&&!t.classList.contains(`mfcButton`)&&ka()});let u=document.createElement(`div`);u.id=`matchUpFormatString`,u.innerHTML=na,u.style.fontSize=`1.5em`,u.style.color=`var(--chc-format-code-color)`,u.style.marginBottom=`1em`,ra.matchUpFormatString=u,l.appendChild(u);let d=document.createElement(`div`);d.style.marginBlockEnd=`1em`;let f=W.preDefinedFormats?W.preDefinedFormats.map(e=>({value:e.code,label:e.text,format:e.code})):Yi,p={id:`matchUpFormatSelector`,options:[{value:`Custom`,label:W.labels?.custom||`Custom`,selected:!1},...f.filter(e=>e.format).map(e=>({selected:e.format===na,value:e.format,label:(`label`in e?e.label:e.name)||``}))]},m=document.createElement(`select`);m.id=`matchUpFormatSelector`,m.className=`input`,m.style.width=`100%`,m.style.backgroundColor=`var(--chc-input-bg)`,m.style.color=Zi,m.style.border=`1px solid var(--chc-input-border)`;for(let e of p.options){let t=document.createElement(`option`);t.value=e.value||``,t.text=e.label||``,t.style.backgroundColor=`var(--chc-input-bg)`,t.style.color=Zi,e.selected&&(t.selected=!0),m.appendChild(t)}ra.matchUpFormatSelector=m;function h(e,t,n){if(!e.getValue)return;let r=e.getValue(G,n),i=K(t);if(i&&r!=null){let{prefix:t=``,suffix:n=``,pluralize:a}=e,o=G.bestOf||G.exactly;i.innerHTML=`${t}${r}${a&&o>1?`s`:``}${n}${U}`,i.style.display=``}else i&&(i.style.display=H)}function g(e,t,n,r,i){let a=K(`matchRoot`);if(a){let e=q.matchRoot||`SET`;a.innerHTML=`${zi[e]||e}${U}`}let o=K(`aggregateOption`);o&&(o.checked=!!q.aggregate);let s=K(`gameFormat`);s&&(s.innerHTML=`${W.labels?.game||`Game`}: ${pa(q.gameFormat)}${U}`,s.style.display=q.setFormat.based===`P`?H:``);let c=G.bestOf||G.exactly;Sa.updateFinalSetVisibility(null,0,c);let l=G.finalSetFormat;e.style.display=l?``:H,t.style.display=l?``:H,n.checked=!!l;let u=l?.tiebreakSet?.tiebreakTo&&!l?.setTo;i.checked=!!l?.tiebreakFormat,i.style.display=u?H:``;let d=K(`finalSetTiebreakToggle`);d&&(d.style.display=u?H:``);let f=q.setFormat.what,p=!!G.setFormat.tiebreakFormat;r.checked=p;let m=f===sa;r.style.display=m?``:H;let g=K(`setTiebreakToggle`);g&&(g.style.display=m?``:H),va.forEach(e=>{if(h(e,e.id,!1),e.tb&&f===sa){let t=K(e.id);t&&(t.style.display=p?t.style.display:H)}l&&h(e,`${e.id}-1`,!0)})}m.onchange=e=>{if(na=e.target.value,ga(na),G=t.matchUpFormatCode.parse(na),!G){console.warn(`Invalid matchUpFormat selected:`,na);return}let n=Ji(na,t.matchUpFormatCode.parse);q.matchRoot=n.matchRoot,q.aggregate=n.aggregate,q.gameFormat=n.gameFormat,q.setFormat={...n.setFormat},q.finalSetFormat={...n.finalSetFormat},g(j,M,k,E,P)},d.appendChild(m),l.appendChild(d);let _=document.createElement(`div`);_.style.display=`flex`,_.style.flexWrap=`wrap`,_.style.gap=`0.5em`,_.style.marginBottom=`0.5em`,_.style.alignItems=`center`;let v=q.matchRoot||`SET`,y=document.createElement(`button`);y.className=`mfcButton`,y.id=`matchRoot`,y.innerHTML=`${zi[v]||v}${U}`,y.style.transition=Xi,y.style.backgroundColor=`inherit`,y.style.border=`none`,y.style.color=`inherit`,y.style.padding=`.3em`,y.style.textAlign=`center`,y.style.textDecoration=`none`,y.style.fontSize=`1em`,y.style.cursor=`pointer`,y.onclick=e=>{ja(e,(W.options?.matchRoots||ta.options.matchRoots).map(t=>({text:`${zi[t]||t}`,onClick:()=>{y.innerHTML=`${zi[t]||t}${U}`,Sa.changeMatchRoot(e,void 0,t)}})))},_.appendChild(y);let b=document.createElement(`input`);b.type=`checkbox`,b.className=`switch is-rounded is-warning`,b.id=`aggregateOption`,b.name=`aggregateOption`,b.checked=!!q.aggregate,b.onchange=()=>{Sa.changeAggregate(new Event(`change`),void 0,void 0)},_.appendChild(b);let x=document.createElement(`label`);x.setAttribute(`for`,`aggregateOption`),x.innerHTML=W.labels?.aggregate||`Aggregate`,x.style.marginRight=`1em`,_.appendChild(x);let S=pa(q.gameFormat),C=document.createElement(`button`);C.className=`mfcButton`,C.id=`gameFormat`,C.innerHTML=`${W.labels?.game||`Game`}: ${S}${U}`,C.style.transition=Xi,C.style.backgroundColor=`inherit`,C.style.border=`none`,C.style.color=`inherit`,C.style.padding=`.3em`,C.style.textAlign=`center`,C.style.textDecoration=`none`,C.style.fontSize=`1em`,C.style.cursor=`pointer`,q.setFormat.based===`P`&&(C.style.display=H),C.onclick=e=>{Aa(e,q.gameFormat,e=>{q.gameFormat=e,C.innerHTML=`${W.labels?.game||`Game`}: ${pa(q.gameFormat)}${U}`,ga()})},_.appendChild(C),ra.matchRoot=y,ra.aggregateOption=b,ra.gameFormat=C,l.appendChild(_);let w=document.createElement(`div`);w.style.display=`flex`,w.style.flexWrap=`wrap`,w.style.gap=`0.5em`,w.style.marginBottom=`1em`,va.map(e=>{let t=e.getValue?e.getValue(G):void 0,n=Ta({...e,value:t});return ra[e.id]=n,n}).forEach(e=>w.appendChild(e)),w.id=`setFormat`,l.appendChild(w);let T=document.createElement(`div`);T.className=`field`,T.style.fontSize=`1em`;let E=document.createElement(`input`);E.className=c,E.name=`setTiebreak`,E.id=`setTiebreak`,E.type=`checkbox`,E.checked=!!G.setFormat.tiebreakFormat,ra.setTiebreak=E,E.onchange=e=>{let t=e.target.checked;va.filter(({tb:e})=>e).forEach(e=>{let n=K(e.id);if(n){if(n.style.display===H&&t){let{prefix:t=``,suffix:r=``,pluralize:i,defaultValue:a}=e,o=G.bestOf||G.exactly;n.innerHTML=`${t}${a}${i&&o>1?`s`:``}${r}${U}`}n.style.display=t?``:H}}),ga()},T.appendChild(E);let D=document.createElement(`label`);D.setAttribute(`for`,`setTiebreak`),D.id=`setTiebreakToggle`,D.innerHTML=W.labels?.tiebreakLabel||`Tiebreak`,D.style.marginRight=`1em`,ra.setTiebreakToggle=D,T.appendChild(D);let O=(G.bestOf||G.exactly)>1,k=document.createElement(`input`);k.className=`switch is-rounded is-info`,k.type=`checkbox`,k.name=`finalSetOption`,k.checked=!!G.finalSetFormat,k.id=`finalSetOption`,ra.finalSetOption=k,k.style.display=O?``:`none`,k.onchange=e=>{let t=e.target.checked;if(t){q.finalSetFormat={...q.setFormat,descriptor:`Final set`};let e=q.setFormat.what,t=q.setFormat.bestOf||q.setFormat.exactly||3,n=K(`what-1`);n&&(n.innerHTML=`${e}${t>1?`s`:``}${U}`),va.forEach(t=>{let n=K(`${t.id}-1`);if(n)if(!t.whats||t.whats.includes(e)){let e=q.finalSetFormat[t.id];if(e!==void 0){let{prefix:r=``,suffix:i=``}=t;n.innerHTML=`${r}${e}${i}${U}`}n.style.display=``}else n.style.display=H});let r=K(`finalSetTiebreakToggle`);if(r&&(r.style.display=e===sa?``:H),e===sa){let e=K(`setTiebreak`),t=K(`finalSetTiebreak`);e&&t&&(t.checked=e.checked)}}j.style.display=t?``:H,M.style.display=t?``:H,ga()},T.appendChild(k);let A=document.createElement(`label`);A.setAttribute(`for`,`finalSetOption`),A.innerHTML=W.labels?.finalSetLabel||`Final set`,A.style.display=O?``:`none`,ra.finalSetOptionLabel=A,T.appendChild(A),l.appendChild(T);let j=document.createElement(`div`);j.style.display=G.finalSetFormat?`flex`:H,j.style.flexWrap=`wrap`,j.style.gap=`0.5em`,j.style.marginBottom=`1em`,j.id=`finalSetFormat`,ra.finalSetFormatDiv=j,[{label:`<div style='font-weight: bold'>${W.labels?.finalSetLabel||`Final set`}</div>`,options:[],finalSet:!0}].concat(va.map(e=>{let t=e.getValue?e.getValue(G,!0):void 0;return{...e,value:t}})).filter(e=>e.finalSet!==!1).map(e=>{let t=Ta({...e,index:1});return e.id&&(ra[`${e.id}-1`]=t),t}).forEach(e=>j.appendChild(e)),l.appendChild(j);let M=document.createElement(`div`);M.id=`finalSetConfig`,ra.finalSetConfigDiv=M,M.style.display=G.finalSetFormat?``:H,M.className=`field`,M.style.fontSize=`1em`;let N=G.finalSetFormat?.tiebreakSet?.tiebreakTo&&!G.finalSetFormat?.setTo,P=document.createElement(`input`);P.className=c,P.name=`finalSetTiebreak`,P.id=`finalSetTiebreak`,ra.finalSetTiebreak=P,P.type=`checkbox`,P.checked=G.finalSetFormat?!!G.finalSetFormat.tiebreakFormat:!!G.setFormat.tiebreakFormat,P.style.display=N?H:``,M.onchange=e=>{let t=e.target.checked;va.filter(({tb:e})=>e).forEach(e=>{let n=K(`${e.id}-1`);if(n){if(n.style.display===H&&t){let{prefix:t=``,suffix:r=``,pluralize:i,defaultValue:a}=e,o=G.bestOf||G.exactly;n.innerHTML=`${t}${a}${i&&o>1?`s`:``}${r}${U}`}n.style.display=t?``:H}}),ga()},M.appendChild(P);let I=document.createElement(`label`);I.setAttribute(`for`,`finalSetTiebreak`),I.id=`finalSetTiebreakToggle`,I.innerHTML=W.labels?.tiebreakLabel||`Tiebreak`,I.style.marginRight=`1em`,I.style.display=N?H:``,ra.finalSetTiebreakToggle=I,M.appendChild(I),l.appendChild(M);let L={content:{padding:`1.5`},maxWidth:480,fontSize:`14px`,style:{backgroundColor:`var(--chc-bg-secondary)`,borderRadius:`8px`,boxShadow:`0 8px 16px rgba(0, 102, 204, 0.2)`}},R=i?.fontSize||i?.style?.fontSize||L.fontSize,z={...L,...i,fontSize:R,style:{...L.style,...r?.style||{},...i?.style||{}}},B=F.open({title:W.labels?.title||`Score format`,content:l,buttons:s,config:z});return setTimeout(()=>{if(G.finalSetFormat?.tiebreakSet?.tiebreakTo&&!G.finalSetFormat?.setTo){let e=K(`what-1`);e&&(e.innerHTML=`${aa}${U}`),Sa.changeWhat(new Event(`click`),1,aa)}let e=document.querySelector(`.modal.is-active`);if(e){let t=new MutationObserver(n=>{n.forEach(n=>{n.removedNodes.forEach(n=>{n===e&&(ka(),t.disconnect())})})});t.observe(document.body,{childList:!0})}},0),B}function wa({index:e,finalSetLabel:t,label:n,prefix:r=``,suffix:i=``,value:a,pluralize:o}){let s=q.setFormat.bestOf||q.setFormat.exactly||1;return n||e&&t||`${r}${a}${!e&&o&&s>1?`s`:``}${i}${U}`}function Ta(e){let{id:t,initiallyHidden:n,index:r,value:i}=e,a=document.createElement(`button`);return a.className=`mfcButton`,a.id=r?`${t}-${r}`:t,a.innerHTML=wa(e),a.onclick=t=>Ea({e:t,button:a,...e}),a.style.display=i||e.label?``:H,n&&(a.style.display=H),a.style.transition=Xi,a.style.backgroundColor=`inherit`,a.style.border=`none`,a.style.color=`inherit`,a.style.padding=`.3em`,a.style.textAlign=`center`,a.style.textDecoration=`none`,a.style.fontSize=`1em`,a.style.cursor=`pointer`,a}function Ea(e){let{e:t,id:n,button:r,pluralize:i,options:a,onChange:o,onChangeCallback:s,index:c,prefix:l=``,suffix:u=``}=e,d=q.setFormat.bestOf||q.setFormat.exactly||1,f=!c&&i&&d>1?`s`:``;ja(t,(ea(a)?a(c):a).map(e=>({text:`${e}${f}`,onClick:()=>{r.innerHTML=`${l}${e}${f}${u}${U}`,q[c?`finalSetFormat`:`setFormat`][n]=e,o&&ea(Sa[o])&&Sa[o](t,c,e),s&&ea(Sa[s])&&Sa[s](t,c,e),ga()}})))}var Da=null,Oa=null;function ka(){Da&&document.body.contains(Da)&&Da.remove(),Oa&&=(document.removeEventListener(`click`,Oa),null),Da=null}function Aa(e,t,n){ka();let r=document.createElement(`div`);r.className=`dropdown is-active`,r.style.position=`absolute`,r.style.zIndex=`10000`;let i=document.createElement(`div`);i.className=`dropdown-menu`,i.style.backgroundColor=Qi,i.style.border=`1px solid var(--chc-border-secondary)`,i.style.borderRadius=`4px`,i.style.boxShadow=`0 2px 8px rgba(0,0,0,0.15)`,i.style.padding=`0.25em 0`,i.style.minWidth=`180px`;let a=`none`,o=`none`;t?.type===`TRADITIONAL`?a=`TN`:t?.type===`CONSECUTIVE`&&(a=`${t.count}C`),t?.deuceAfter&&(o=`${t.deuceAfter}D`);function s(e,t){if(e===`none`&&t===`none`)return;let n={};return e===`TN`?n.type=`TRADITIONAL`:/^\d+C$/.test(e)?(n.type=`CONSECUTIVE`,n.count=Number(e.slice(0,-1))):n.type=`TRADITIONAL`,t!==`none`&&(n.deuceAfter=Number(t.slice(0,-1))),n}function c(){let e=r.querySelector(`input[name="gameType"]:checked`),t=r.querySelector(`input[name="deuceRule"]:checked`);n(s(e?.value||`none`,t?.value||`none`))}let l=`padding: 0.3em 1em; font-weight: bold; font-size: 0.85rem; color: var(--chc-text-muted); text-transform: uppercase; letter-spacing: 0.5px;`,u=`border-top: 1px solid #eee; margin: 0.25em 0;`,d=document.createElement(`div`);d.textContent=W.labels?.none||`None`,d.style.cssText=`padding: 0.4em 1em; cursor: pointer; background-color: var(--chc-dropdown-bg); color: var(--chc-text-primary); font-size: 1rem;`,d.onmouseenter=()=>{d.style.backgroundColor=$i},d.onmouseleave=()=>{d.style.backgroundColor=Qi},d.onclick=e=>{e.preventDefault(),e.stopPropagation(),n(void 0),ka()},i.appendChild(d);function f(e,t,n,r){let i=document.createElement(`label`);i.style.cssText=`display: flex; align-items: center; padding: 0.3em 1em; cursor: pointer; gap: 0.4em; font-size: 1rem; color: var(--chc-text-primary);`,i.onmouseenter=()=>{i.style.backgroundColor=$i},i.onmouseleave=()=>{i.style.backgroundColor=Qi};let a=document.createElement(`input`);a.type=`radio`,a.name=e,a.value=t,a.checked=r,a.style.margin=`0`,a.onchange=()=>c();let o=document.createElement(`span`);return o.textContent=n,i.appendChild(a),i.appendChild(o),i}let p=document.createElement(`div`);p.style.cssText=u,i.appendChild(p);let m=document.createElement(`div`);m.style.cssText=l,m.textContent=W.labels?.gameType||`Game type`,i.appendChild(m);let h=da(),g=[{value:`none`,label:W.labels?.none||`None`},{value:`TN`,label:h.TN},{value:`2C`,label:h[`2C`]},{value:`3C`,label:h[`3C`]},{value:`4C`,label:h[`4C`]}];for(let e of g)i.appendChild(f(`gameType`,e.value,e.label,a===e.value));let _=document.createElement(`div`);_.style.cssText=u,i.appendChild(_);let v=document.createElement(`div`);v.style.cssText=l,v.textContent=W.labels?.deuceRule||`Deuce rule`,i.appendChild(v);let y=fa(),b=[{value:`none`,label:W.labels?.none||`None`},{value:`1D`,label:y[`1D`]},{value:`3D`,label:y[`3D`]}];for(let e of b)i.appendChild(f(`deuceRule`,e.value,e.label,o===e.value));r.appendChild(i);let x=e.target.getBoundingClientRect();r.style.left=`${x.left}px`,r.style.top=`${x.bottom}px`,document.body.appendChild(r),Da=r,setTimeout(()=>{Oa=e=>{r.contains(e.target)||ka()},document.addEventListener(`click`,Oa)},100)}function ja(e,t){ka();let n=document.createElement(`div`);n.className=`dropdown is-active`,n.style.position=`absolute`,n.style.zIndex=`10000`;let r=document.createElement(`div`);r.className=`dropdown-menu`,r.style.backgroundColor=Qi,r.style.border=`1px solid var(--chc-border-secondary)`,r.style.borderRadius=`4px`,r.style.boxShadow=`0 2px 8px rgba(0,0,0,0.15)`;let i=()=>{ka()};t.forEach(e=>{let t=document.createElement(`div`);t.style.padding=`0.5em 1em`,t.style.cursor=`pointer`,t.style.backgroundColor=Qi,t.style.color=Zi,t.style.fontSize=`1rem`,t.style.lineHeight=`1.5`,t.textContent=e.text,t.onclick=t=>{t.preventDefault(),t.stopPropagation(),i(),e.onClick()},t.onmouseenter=()=>{t.style.backgroundColor=$i,t.style.color=Zi},t.onmouseleave=()=>{t.style.backgroundColor=Qi,t.style.color=Zi},r.appendChild(t)}),n.appendChild(r);let a=e.target.getBoundingClientRect();n.style.left=`${a.left}px`,n.style.top=`${a.bottom}px`,document.body.appendChild(n),Da=n,setTimeout(()=>{Oa=e=>{n.contains(e.target)||i()},document.addEventListener(`click`,Oa)},100)}var Ma=`Simple Under`,Na=`Simple Over`;function Pa(e){if(!e)return null;let t=e.trim().toUpperCase();if(t===`OPEN`)return{type:`open`};let n=t.match(/^C(\d{1,2})-(\d{1,2})$/);if(n){let[,e,t]=n;return{type:`combined`,ageMin:Number.parseInt(e,10),ageMax:Number.parseInt(t,10),isCombined:!0}}if(t.includes(`-`)){let e=La(t);if(e)return e}return Ra(t)}function Fa(e){if(!e.startsWith(`U`)&&!e.endsWith(`U`))return;let t=e.match(/^U?(\d{1,2})U?$/);if(t)return{age:Number.parseInt(t[1],10),position:e.startsWith(`U`)?`pre`:`post`}}function Ia(e){if(!e.startsWith(`O`)&&!e.endsWith(`O`))return;let t=e.match(/^O?(\d{1,2})O?$/);if(t)return{age:Number.parseInt(t[1],10),position:e.startsWith(`O`)?`pre`:`post`}}function La(e){let t=e.split(`-`);if(t.length!==2)return null;let[n,r]=t,i,a,o,s,c,l=Fa(n),u=Ia(n);l?(c=`max-min`,a=l.position===`pre`?l.age-1:l.age,o=l.position):u&&(c=`min-max`,i=u.position===`pre`?u.age+1:u.age,s=u.position);let d=Fa(r),f=Ia(r);return d?(a=d.position===`pre`?d.age-1:d.age,o=d.position):f&&(i=f.position===`pre`?f.age+1:f.age,s=f.position),i!==void 0||a!==void 0?{type:`range`,ageMin:i,ageMax:a,uPosition:o,oPosition:s,rangeOrder:c}:null}function Ra(e){let t=e.match(/^U(\d{1,2})$|^(\d{1,2})U$/);if(t)return{type:`under`,ageValue:Number.parseInt(t[1]||t[2],10),uPosition:t[1]?`pre`:`post`};let n=e.match(/^O(\d{1,2})$|^(\d{1,2})O$/);return n?{type:`over`,ageValue:Number.parseInt(n[1]||n[2],10),oPosition:n[1]?`pre`:`post`}:null}function za(e){let{type:t,ageValue:n,ageMin:r,ageMax:i,uPosition:a=`post`,oPosition:o=`post`,rangeOrder:s=`min-max`}=e;if(t===`open`)return`OPEN`;if(t===`combined`&&r!==void 0&&i!==void 0)return`C${r}-${i}`;if(t===`under`&&n!==void 0)return a===`pre`?`U${n}`:`${n}U`;if(t===`over`&&n!==void 0)return o===`pre`?`O${n}`:`${n}O`;if(t===`range`&&(r!==void 0||i!==void 0)){let e=i!==void 0&&a?(()=>{let e=a===`pre`?i+1:i;return a===`pre`?`U${e}`:`${e}U`})():null,t=r!==void 0&&o?(()=>{let e=o===`pre`?r-1:r;return o===`pre`?`O${e}`:`${e}O`})():null;return s===`max-min`?[e,t].filter(Boolean).join(`-`):[t,e].filter(Boolean).join(`-`)}return``}function Ba(){return[8,10,12,14,16,18,21,30,35,40,45,50,55,60,65,70,75,80,85,90]}function Va(){return[Ma,Na,`Range`,`Combined`,`Open`]}function Ha(e){switch(e){case Ma:return`under`;case Na:return`over`;case`Range`:return`range`;case`Combined`:return`combined`;case`Open`:return`open`;default:return`open`}}function Ua(e){switch(e){case`under`:return Ma;case`over`:return Na;case`range`:return`Range`;case`combined`:return`Combined`;case`open`:return`Open`;default:return`Open`}}function Wa(){return[{code:`OPEN`,text:`Open (No age limit)`},{code:`8U`,text:`8 and Under`},{code:`10U`,text:`10 and Under`},{code:`12U`,text:`12 and Under`},{code:`14U`,text:`14 and Under`},{code:`16U`,text:`16 and Under`},{code:`18U`,text:`18 and Under`},{code:`21U`,text:`21 and Under`},{code:`30O`,text:`30 and Over`},{code:`35O`,text:`35 and Over`},{code:`40O`,text:`40 and Over`},{code:`45O`,text:`45 and Over`},{code:`50O`,text:`50 and Over`},{code:`55O`,text:`55 and Over`},{code:`60O`,text:`60 and Over`},{code:`65O`,text:`65 and Over`},{code:`70O`,text:`70 and Over`},{code:`75O`,text:`75 and Over`},{code:`80O`,text:`80 and Over`}]}var Ga=`▾`,Ka=`1px solid var(--chc-border-secondary)`,qa=`var(--chc-text-primary)`,Ja=`var(--chc-dropdown-bg)`;function Ya(e){return typeof e==`function`}var Xa={labels:{title:`Age Category`,consideredDateLabel:`Considered Date`,typeLabel:`Category Type`,ageLabel:`Age`,standardCodesLabel:`Standard Categories`},options:{ages:Ba(),categoryTypes:Va()},defaultConsideredDate:new Date().toISOString().split(`T`)[0]},Za=Xa,Qa,$a,J={type:`open`},eo={};function to(){let e=za(J);if(!e||e===`OPEN`){eo={};return}try{let n=t.eventGovernor.getCategoryAgeDetails({category:{ageCategoryCode:e},consideredDate:$a});if(n.error){eo={errors:[typeof n.error==`string`?n.error:n.error.message||`Invalid category or date`]};return}eo={ageMin:n.ageMin,ageMax:n.ageMax,ageMinDate:n.ageMinDate,ageMaxDate:n.ageMaxDate,errors:n.errors}}catch(e){eo={errors:[`Failed to calculate age details: ${e instanceof Error?e.message:`Unknown error`}`]}}}function no(){let e=za(J);Qa=e;let t=document.getElementById(`ageCategoryCodeString`);t&&(t.innerHTML=e||`Invalid`),to(),ro()}function ro(){let e=document.getElementById(`calculatedDetailsPanel`);if(!e)return;if(J.type===`open`||!Qa){e.style.display=`none`;return}e.style.display=``;let{ageMin:t,ageMax:n,ageMinDate:r,ageMaxDate:i,errors:a}=eo,o=`<div style="margin-top: 1em; padding: 0.75em; background: var(--chc-bg-secondary); border-radius: 4px; color: var(--chc-text-primary);">`;a&&a.length>0&&(o+=`<div style="color: var(--chc-status-error); margin-bottom: 0.5em;"><strong style="color: var(--chc-text-primary);">Errors:</strong><ul style="margin: 0; padding-left: 1.5em; color: var(--chc-text-primary);">`,a.forEach(e=>{o+=`<li style="color: var(--chc-status-error);">${e}</li>`}),o+=`</ul></div>`),(t!==void 0||n!==void 0)&&(o+=`<div style="margin-bottom: 0.5em; color: var(--chc-text-primary);"><strong style="color: var(--chc-text-primary);">Age Range:</strong> `,t!==void 0&&n!==void 0?o+=`${t} - ${n}`:t===void 0?n!==void 0&&(o+=`${n} and under`):o+=`${t} and over`,o+=`</div>`),r&&(o+=`<div style="margin-bottom: 0.5em; color: var(--chc-text-primary);"><strong style="color: var(--chc-text-primary);">Min Birth Date:</strong> ${r}</div>`),i&&(o+=`<div style="margin-bottom: 0.5em; color: var(--chc-text-primary);"><strong style="color: var(--chc-text-primary);">Max Birth Date:</strong> ${i}</div>`),o+=`</div>`,e.innerHTML=o}function io(){let{type:e}=J,t=document.getElementById(`ageValue`),n=e===`under`||e===`over`;t&&(t.style.display=n?``:`none`);let r=document.getElementById(`positionToggle`),i=e===`under`||e===`over`;r&&(r.style.display=i?``:`none`);let a=document.getElementById(`ageMin`),o=e===`range`||e===`combined`;a&&(a.style.display=o?``:`none`);let s=document.getElementById(`ageMax`),c=e===`range`||e===`combined`;s&&(s.style.display=c?``:`none`);let l=document.getElementById(`combinedLabel`);l&&(l.style.display=e===`combined`?``:`none`)}function ao(e){let{id:t,label:n,onClick:r,initiallyHidden:i}=e,a=document.createElement(`button`);return a.className=`accButton`,a.id=t,a.innerHTML=n,r&&(a.onclick=r),i&&(a.style.display=`none`),a.style.transition=`all .2s ease-in-out`,a.style.backgroundColor=`inherit`,a.style.border=`none`,a.style.color=qa,a.style.padding=`.3em`,a.style.textAlign=`center`,a.style.textDecoration=`none`,a.style.fontSize=`1em`,a.style.cursor=`pointer`,a}var oo=null,so=null;function co(){oo&&document.body.contains(oo)&&oo.remove(),so&&=(document.removeEventListener(`click`,so),null),oo=null}function lo(e,t){co();let n=document.createElement(`div`);n.className=`dropdown is-active`,n.style.position=`absolute`,n.style.zIndex=`10000`;let r=document.createElement(`div`);r.className=`dropdown-menu`,r.style.backgroundColor=Ja,r.style.border=Ka,r.style.borderRadius=`4px`,r.style.boxShadow=`0 2px 8px rgba(0,0,0,0.15)`;let i=()=>{co()};t.forEach(e=>{let t=document.createElement(`div`);t.style.padding=`0.5em 1em`,t.style.cursor=`pointer`,t.style.backgroundColor=Ja,t.style.color=qa,t.style.fontSize=`1rem`,t.style.lineHeight=`1.5`,t.textContent=e.text,t.onclick=t=>{t.preventDefault(),t.stopPropagation(),i(),setTimeout(()=>{e.onClick()},0)},t.onmouseenter=()=>{t.style.backgroundColor=`var(--chc-hover-bg)`},t.onmouseleave=()=>{t.style.backgroundColor=Ja},r.appendChild(t)}),n.appendChild(r);let a=e.target.getBoundingClientRect();n.style.left=`${a.left}px`,n.style.top=`${a.bottom}px`,document.body.appendChild(n),oo=n,setTimeout(()=>{so=e=>{n.contains(e.target)||i()},document.addEventListener(`click`,so)},100)}function uo({existingAgeCategoryCode:e,existingCategory:t={},editorConfig:n,consideredDate:r,callback:i,config:a,modalConfig:o}={}){let s=n||a;Za=s?{labels:{...Xa.labels,...s.labels},options:{...Xa.options,...s.options},preDefinedCodes:s.preDefinedCodes||Wa(),defaultConsideredDate:s.defaultConsideredDate||Xa.defaultConsideredDate}:{...Xa,preDefinedCodes:Wa()},$a=r||Za.defaultConsideredDate||new Date().toISOString().split(`T`)[0];let c=e||t.ageCategoryCode||`OPEN`;Qa=c;let l=Pa(c);l?Object.assign(J,l):Object.assign(J,{type:`open`});let u=()=>{let e=za(J);Ya(i)&&i({...t,ageCategoryCode:e})},d=[{onClick:()=>{co(),i?.({...t,ageCategoryCode:``})},label:`Cancel`,intent:`none`,footer:{className:`button`,style:`background-color: var(--chc-bg-primary); color: var(--chc-text-primary); border: 1px solid var(--chc-border-primary);`},close:!0},{label:`Select`,intent:`is-info`,close:!0,onClick:()=>{co(),u()}}],f=document.createElement(`div`);f.addEventListener(`click`,e=>{let t=e.target;!t.closest(`.dropdown`)&&!t.classList.contains(`accButton`)&&co()});let p=document.createElement(`div`);p.id=`ageCategoryCodeString`,p.innerHTML=Qa,p.style.fontSize=`1.5em`,p.style.color=`var(--chc-format-code-color)`,p.style.marginBottom=`1em`,p.style.fontWeight=`bold`,f.appendChild(p);let m=document.createElement(`div`);m.style.marginBottom=`1em`,ui(m,[{label:Za.labels?.standardCodesLabel||`Standard Categories`,field:`standardCategory`,id:`ageCategorySelector`,options:[{label:`Custom`,value:`Custom`,selected:!Za.preDefinedCodes?.some(e=>e.code===Qa)},...(Za.preDefinedCodes||[]).map(e=>({selected:e.code===Qa,value:e.code,label:e.text}))],onChange:e=>{let t=e.target.value;if(t===`Custom`)return;Qa=t;let n=Pa(t);n&&(Object.assign(J,n),io(),k(),no())}},{label:Za.labels?.consideredDateLabel||`Considered Date`,field:`consideredDate`,id:`consideredDateInput`,value:$a,date:!0,onChange:e=>{$a=e.target.value,no()}}]),f.appendChild(m);let h=ao({id:`categoryType`,label:`${Ua(J.type)}${Ga}`,onClick:e=>{lo(e,(Za.options?.categoryTypes||Va()).map(e=>({text:e,onClick:()=>{let t=Ha(e);J.type=t,J.ageValue=void 0,J.ageMin=void 0,J.ageMax=void 0,t===`under`||t===`over`?(J.ageValue=18,J.uPosition=`post`,J.oPosition=`post`):(t===`range`||t===`combined`)&&(J.ageMin=10,J.ageMax=18,J.uPosition=`post`,J.oPosition=`post`,J.rangeOrder=`min-max`),t===`combined`?J.isCombined=!0:J.isCombined=!1,h.innerHTML=`${e}${Ga}`,io(),k(),no()}})))}}),g=document.createElement(`div`);g.style.display=`flex`,g.style.flexWrap=`wrap`,g.style.gap=`0.5em`,g.style.marginBottom=`1em`,g.appendChild(h);let _=document.createElement(`div`);_.id=`ageValue`,_.style.display=J.type!==`under`&&J.type!==`over`?`none`:``;let v=document.createElement(`input`);v.type=`number`,v.min=`1`,v.max=`120`,v.value=String(J.ageValue||18),v.style.width=`80px`,v.style.padding=`0.3em`,v.style.border=Ka,v.style.borderRadius=`4px`,v.oninput=()=>{let e=Number.parseInt(v.value,10);!Number.isNaN(e)&&e>=1&&e<=120&&(J.ageValue=e,no())},_.appendChild(v),g.appendChild(_);let y=ao({id:`positionToggle`,label:O(),onClick:()=>{J.type===`under`?J.uPosition=J.uPosition===`pre`?`post`:`pre`:J.type===`over`&&(J.oPosition=J.oPosition===`pre`?`post`:`pre`),y.innerHTML=O(),no()},initiallyHidden:J.type!==`under`&&J.type!==`over`});g.appendChild(y);let b=document.createElement(`div`);b.id=`ageMin`,b.style.display=J.type!==`range`&&J.type!==`combined`?`none`:``,b.style.display=`flex`,b.style.alignItems=`center`,b.style.gap=`0.5em`;let x=document.createElement(`span`);x.textContent=`Min:`,x.style.color=qa;let S=document.createElement(`input`);S.type=`number`,S.min=`1`,S.max=`120`,S.value=String(J.ageMin||10),S.style.width=`80px`,S.style.padding=`0.3em`,S.style.border=Ka,S.style.borderRadius=`4px`,S.oninput=()=>{let e=Number.parseInt(S.value,10);!Number.isNaN(e)&&e>=1&&e<=120&&(J.ageMin=e,J.ageMax!==void 0&&J.ageMax<e&&(J.ageMax=e,T.value=String(e)),no())},b.appendChild(x),b.appendChild(S),g.appendChild(b),J.type!==`range`&&J.type!==`combined`&&(b.style.display=`none`);let C=document.createElement(`div`);C.id=`ageMax`,C.style.display=J.type!==`range`&&J.type!==`combined`?`none`:``,C.style.display=`flex`,C.style.alignItems=`center`,C.style.gap=`0.5em`;let w=document.createElement(`span`);w.textContent=`Max:`,w.style.color=qa;let T=document.createElement(`input`);T.type=`number`,T.min=`1`,T.max=`120`,T.value=String(J.ageMax||18),T.style.width=`80px`,T.style.padding=`0.3em`,T.style.border=Ka,T.style.borderRadius=`4px`,T.oninput=()=>{let e=Number.parseInt(T.value,10);!Number.isNaN(e)&&e>=1&&e<=120&&(J.ageMax=e,J.ageMin!==void 0&&J.ageMin>e&&(J.ageMin=e,S.value=String(e)),no())},C.appendChild(w),C.appendChild(T),g.appendChild(C),J.type!==`range`&&J.type!==`combined`&&(C.style.display=`none`);let E=document.createElement(`div`);E.id=`combinedLabel`,E.innerHTML=`<em style="color: var(--chc-text-muted);">Combined age range</em>`,E.style.display=J.type===`combined`?``:`none`,E.style.padding=`0.3em`,g.appendChild(E),f.appendChild(g);let D=document.createElement(`div`);D.id=`calculatedDetailsPanel`,f.appendChild(D);function O(){if(J.type===`under`){let e=J.ageValue||18;return J.uPosition===`pre`?`U${e}`:`${e}U`}else if(J.type===`over`){let e=J.ageValue||10;return J.oPosition===`pre`?`O${e}`:`${e}O`}return``}function k(){let e=document.getElementById(`categoryType`);e&&(e.innerHTML=`${Ua(J.type)}${Ga}`),J.ageValue!==void 0&&(v.value=String(J.ageValue));let t=document.getElementById(`positionToggle`);t&&(t.innerHTML=O()),J.ageMin!==void 0&&(S.value=String(J.ageMin)),J.ageMax!==void 0&&(T.value=String(J.ageMax))}let A={content:{padding:`1.5`},maxWidth:480,fontSize:`14px`,style:{backgroundColor:`var(--chc-bg-secondary)`,borderRadius:`8px`,boxShadow:`0 8px 16px rgba(0, 102, 204, 0.2)`}},j=o?.fontSize||o?.style?.fontSize||A.fontSize,M={...A,...o,fontSize:j,style:{...A.style,...a?.style||{},...o?.style}},N=F.open({title:Za.labels?.title||`Age Category`,content:f,buttons:d,config:M});return setTimeout(()=>{io(),k(),no()},0),setTimeout(()=>{let e=document.querySelector(`.modal.is-active`);if(e){let t=new MutationObserver(n=>{n.forEach(n=>{n.removedNodes.forEach(n=>{n===e&&(co(),t.disconnect())})})});t.observe(document.body,{childList:!0})}},0),N}var fo={labels:{title:`Category`,categoryNameLabel:`Category Name`,typeLabel:`Category Type`,ageCategoryCodeLabel:`Age Category Code`,ratingTypeLabel:`Rating Type`,ratingMinLabel:`Minimum Rating`,ratingMaxLabel:`Maximum Rating`,ballTypeLabel:`Ball Type`,notesLabel:`Notes`},options:{types:[`AGE`,`RATING`,`BOTH`],ratingTypes:[`WTN`,`UTR`,`TRN`,`NTRP`,`DUPR`],ballTypes:[`HIGH_ALTITUDE`,`STAGE1GREEN`,`STAGE2ORANGE`,`STAGE3RED`,`T2STANDARD_PRESSURELESS`,`T2STANDARD_PRESSURISED`,`TYPE1FAST`,`TYPE3SLOW`]},defaultConsideredDate:new Date().toISOString().split(`T`)[0]};function po(e){return typeof e==`function`}function mo(e){let{existingCategory:n,editorConfig:r,callback:i}=e,a={labels:{...fo.labels,...r?.labels},options:{...fo.options,...r?.options},defaultConsideredDate:r?.defaultConsideredDate||fo.defaultConsideredDate,modalConfig:r?.modalConfig||{}},o={categoryName:n?.categoryName||``,type:n?.type,ageCategoryCode:n?.ageCategoryCode,ratingType:n?.ratingType,ratingMin:n?.ratingMin,ratingMax:n?.ratingMax,ballType:n?.ballType,notes:n?.notes||``,ageMin:n?.ageMin,ageMax:n?.ageMax,ageMinDate:n?.ageMinDate,ageMaxDate:n?.ageMaxDate},s=a.defaultConsideredDate,c=document.createElement(`div`);c.style.display=`flex`,c.style.flexDirection=`column`,c.style.gap=`1em`,c.style.minWidth=`400px`;let l=()=>{let e=c.querySelector(`#ageDetailsPanel`);if(e){if(!o.ageCategoryCode||o.ageCategoryCode===`OPEN`){e.style.display=`none`;return}try{let n=t.eventGovernor.getCategoryAgeDetails({category:{ageCategoryCode:o.ageCategoryCode},consideredDate:s});if(n.error){e.style.display=`block`,e.innerHTML=`
|
|
82
|
+
`}var{WALKOVER:Qn,DEFAULTED:$n,DOUBLE_WALKOVER:er,DOUBLE_DEFAULT:tr,RETIRED:nr,SUSPENDED:rr,CANCELLED:ir,IN_PROGRESS:ar,ABANDONED:or}=t.matchUpStatusConstants;function sr({configuration:e,matchUp:t,eventHandlers:n,sideNumber:r,winningSide:i,matchUpStatus:a,isWinningSide:o,gameScoreOnly:s,irregularEnding:c}){let l=document.createElement(`div`),u=e?.inlineScoring,d=t?.readyToScore;if(u&&d&&!(i||a===`COMPLETED`)&&(!a||a===`IN_PROGRESS`||a===`TO_BE_PLAYED`)){let e=Vn({matchUpStatus:ar});e.classList.add(`chc-live-chip`),e.addEventListener(`click`,e=>{e.stopPropagation(),n?.pillClick?.({pointerEvent:e,matchUp:t,sideNumber:r})}),l.appendChild(e)}else if(o&&!s){let e=Zn();typeof e==`string`?l.innerHTML=e:l.appendChild(e)}else if(c){let e=Vn({matchUpStatus:a});u&&(e.classList.add(`chc-live-chip`),e.addEventListener(`click`,e=>{e.stopPropagation(),n?.pillClick?.({pointerEvent:e,matchUp:t,sideNumber:r})})),l.appendChild(e)}return l}function cr({initialRoundNumber:e=1,eventHandlers:t,sideContainer:n,composition:r,participant:i,placeholder:a,sideNumber:o,matchUp:s}){let{winningSide:c,matchUpType:l,isRoundRobin:u,matchUpStatus:d}=s||{},f=r?.configuration,p,m=o?s?.sides?.find(e=>e.sideNumber===o):void 0;i||(i=m?.participant,p=f?.allDrawPositions||f?.drawPositions&&m?.drawPosition&&(s?.roundNumber===e||m?.participantFed||u)?m?.drawPosition:``);let h=l===`DOUBLES`,g=h?i?.individualParticipants?.[0]:i,b=h&&i?.individualParticipants?.[1],x=!!(c&&o===c||d===`BYE`&&i),S=f?.winnerChevron&&x,C=f?.teamLogo,w=[nr,Qn,$n,er,tr,rr,ir,ar,or].includes(d)&&!x,T=f?.gameScoreOnly,E=document.createElement(`div`);if(n&&(E.className=v({drawPosition:p,sideNumber:o}),p&&(E.dataset.drawPosition=String(p),f?.drawPositionColor&&E.style.setProperty(`--chc-draw-position-color`,f.drawPositionColor))),E.classList.add(`tmx-p`),E.setAttribute(`id`,i?.participantId||``),C){let e=qn({teamLogo:C,participantId:i?.participantId});E.appendChild(e)}let D=document.createElement(`div`);D.className=_(h?{variant:`doubles`}:{});let O=document.createElement(`div`);O.className=y({winnerChevron:S,isDoubles:h});let k=Nn({individualParticipant:g,eventHandlers:t,isWinningSide:x,composition:r,sideNumber:o,matchUp:s,side:m}).element;if(O.appendChild(k),b){let e=Nn({individualParticipant:b,eventHandlers:t,isWinningSide:x,composition:r,sideNumber:o,matchUp:s,side:m}).element;O.appendChild(e)}else h&&a&&Hn(a)&&O.appendChild(a);return D.appendChild(O),E.appendChild(D),n&&E.appendChild(sr({configuration:f,matchUp:s,eventHandlers:t,sideNumber:o,winningSide:c,matchUpStatus:d,isWinningSide:x,gameScoreOnly:T,irregularEnding:w})),E}var lr=()=>`chc-round-header`;function ur({eventHandlers:e,roundMatchUps:t,roundProfile:n,roundNumber:r,context:i}){let a=document.createElement(`div`);a.className=lr(),a.classList.add(`tmx-rh`),a.setAttribute(`roundNumber`,String(r));let o=j(e?.roundVisibilityClick),s=j(e?.roundHeaderClick);s&&(a.onclick=a=>e.roundHeaderClick({roundNumber:r,roundProfile:n,roundMatchUps:t,context:i,pointerEvent:a}));let c=n?.[r]?.roundName;if(!c)return a;let l=document.createElement(`div`);l.style.cssText=`display:flex; flex-direction:row; justify-content:space-between;`;let u=document.createElement(`div`);u.textContent=c,l.appendChild(u);let d=document.createElement(`div`);if(d.style.cssText=`display:flex; align-items:center; gap:4px;`,o){let a=i?.roundVisibilityState?.[r],o=a?.hidden===!0,s=a?.embargoed===!0,c=o?`fa-eye-slash`:s?`fa-clock`:`fa-eye`,l=o?`#e74c3c`:s?`#f39c12`:`inherit`,u=o||s?`0.85`:`0.7`,f=document.createElement(`i`);f.className=`fa-solid ${c} tmx-rh-vis`,f.style.cssText=`cursor:pointer; font-size:0.85rem; color:${l}; opacity:${u}; transition:opacity 0.15s;`,f.onmouseenter=()=>f.style.opacity=`1`,f.onmouseleave=()=>f.style.opacity=u,f.onclick=a=>{a.stopPropagation(),e.roundVisibilityClick({roundNumber:r,roundProfile:n,roundMatchUps:t,context:i,pointerEvent:a})},d.appendChild(f)}if(s){let e=document.createElement(`span`);e.style.cssText=`font-weight:bold; cursor:pointer;`,e.textContent=`⋮`,d.appendChild(e)}return l.appendChild(d),a.appendChild(l),a}var dr={border:`--chc-color-border`,borderHover:`--chc-color-border-hover`,borderInlineStart:`--chc-color-border-inline-start`,borderInlineStartWidth:`--chc-border-width-inline-start`,connector:`--chc-color-connector`,matchUpBackground:`--chc-color-matchup`,internalDividers:`--chc-color-internal-dividers`,score:`--chc-color-score`,roundHeader:`--chc-color-round-header`};function fr(e,t){if(t)for(let[n,r]of Object.entries(dr)){let i=t[n];i&&e.style.setProperty(r,i)}}function pr(e){for(let t of Object.values(dr))e.style.removeProperty(t)}var mr=()=>`chc-round-container`,hr=()=>`chc-structure`,gr=e=>(0,p.default)(`chc-round`,e?.variant===`adHoc`&&`chc-round--adhoc`);function _r({roundsNotPowerOf2:e,hasNoRoundPositions:t,roundNumbers:n,roundProfile:r}){return t?!0:e?!(n&&n.length>1&&r&&n.every((e,t)=>{if(t===0)return!0;let i=r[n[t-1]]?.matchUpsCount,a=r[e]?.matchUpsCount;return i&&a&&(a===i/2||a===i)})):!1}var vr=e=>(0,p.default)(`chc-group-separator`,e?.variant===0&&`chc-group-separator--0`,e?.roundOrder===`first`&&`chc-group-separator--round-first`,e?.roundOrder===`last`&&`chc-group-separator--round-last`),yr=()=>`chc-group-name`;function br(){return`chc-selected-matchup`}var xr=()=>`chc-matchup-container`;function Sr({configuration:e}){return e?.matchUpHover?`chc-matchup chc-matchup--custom-hover`:`chc-matchup`}function Cr({variant:e}){return(0,p.default)(`chc-center-info`,e!=null&&`chc-center-info--${e}`)}var wr=()=>`chc-column`,Tr=()=>`chc-entry`,Er=()=>`chc-status`;function Dr({eventHandlers:e,entryStatus:t,sideNumber:n,className:r,matchUp:i}){let a=document.createElement(`div`);j(e?.centerInfoClick)&&(a.onclick=t=>e.centerInfoClick({matchUp:i,sideNumber:n,pointerEvent:t})),a.className=(0,p.default)(Cr({variant:n}),r),a.classList.add(`tmx-ci`),a.setAttribute(`sideNumber`,String(n));let o=document.createElement(`div`);o.className=wr();let s=document.createElement(`div`);s.className=Tr();let c=document.createElement(`div`);c.className=Er(),c.innerHTML=t?`Entry status: `:``,s.appendChild(c);let l=document.createElement(`div`);return l.className=Er(),l.innerHTML=t||``,s.appendChild(l),o.appendChild(s),a.appendChild(o),{element:a}}var Or={scheduleInfo:1.8,centerInfo:1.5,gameScore:2};function kr({composition:e,isDoubles:t,roundFactor:n=1}){let r=parseInt(window.getComputedStyle(document.body).getPropertyValue(`font-size`)),i=e?.configuration||{},a=i?.connectorWidth||16,o=i.centerInfo?Or.centerInfo*r:0,s=i.scheduleInfo?Or.scheduleInfo*r:0,c=(60+(i.showAddress?r:0))*(t?1.3:1)+o,l=c*n,u=(c+s)*n;return e=>{let t=(0,p.default)(`chc-link`,e.isFirstRound&&`chc-link--first-round`,e.link===`mr`&&`chc-link--no-link`,e.link===`m1`&&`chc-link--m1`,e.link===`m2`&&`chc-link--m2`,e.link===`m0`&&`chc-link--m0`,e.link===`noProgression`&&`chc-link--no-progression`);return{className:t,applyStyles(e){e.style.setProperty(`--chc-connector-w`,`${a}px`),e.style.setProperty(`--chc-link-m1-h`,`${l}px`),e.style.setProperty(`--chc-link-m2-h`,`${u}px`)},toString(){return t}}}}var Ar=e=>e=>(0,p.default)(`chc-score-wrapper`,(e?.sideNumber===1||String(e?.sideNumber)===`1`)&&`chc-score-wrapper--side1`,e?.fontSize===`small`&&`chc-score-wrapper--small`),jr=()=>`chc-tiebreak`,Mr=e=>(0,p.default)(`chc-game-score`,e?.variant&&`chc-game-score--${e.variant}`),Nr=()=>`chc-game-wrapper`,Pr=e=>(0,p.default)(`chc-point-score`,e?.inverted&&`chc-point-score--inverted`,e?.position===`leading`&&`chc-point-score--leading`,e?.position===`trailing`&&`chc-point-score--trailing`),Fr=e=>(0,p.default)(`chc-results-item`,e?.variant&&`chc-results-item--${e.variant}`);function Ir({value:e}={}){let t=document.createElement(`input`);return t.onclick=e=>e.target.select(),t.className=Mr(),t.value=String(e||``),t}function Lr({gameScoreOnly:e,scoreStripes:t,set:n,sideNumber:r}){let i=r===n?.winningSide||n?.winningSide?`loser`:void 0,a=r===2?n.side2Score:n.side1Score,o=n.side2TiebreakScore!==void 0||n.side1TiebreakScore!==void 0,s=r===2?n.side2TiebreakScore:n.side1TiebreakScore,c=(a===void 0||n.tiebreakSet===!0)&&s!==void 0,l=c?s:a,u=t&&n.setNumber%2?`var(--chc-bg-secondary)`:`transparent`,d=n.editing?n.editing===r:void 0,f;if(d)f=Ir({value:l});else if(f=document.createElement(`p`),f.className=Mr({variant:i}),f.classList.add(`tmx-st`),f.setAttribute(`setNumber`,n.setNumber),f.style.backgroundColor=u,f.innerHTML=l!=null&&!Number.isNaN(Number(l))?l:``,!e){let e=document.createElement(`span`);e.className=jr(),e.innerHTML=o&&!c?String(s):``,f.appendChild(e)}return f}function Rr(e,t,n,r,i,a){if(e.length===0)return;let o=e.at(-1);if(!(o.side1PointScore!=null||o.side2PointScore!=null))return;let s=t===2?o.side2PointScore:o.side1PointScore,c=n?.position||`trailing`,l=n?.inverted!==!1,u=document.createElement(`p`);return u.className=Pr({inverted:l,position:c}),u.textContent=s==null?``:String(s),r?.configuration?.inlineScoring&&!o.winningSide&&(u.classList.add(`chc-inline-scoring-clickable`),u.style.cursor=`pointer`,u.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),i?.scoreIncrement?.({matchUpId:a.matchUpId,sideNumber:t,scoreType:`point`})})),u}function zr(e,t,n,r,i){e.classList.add(`chc-inline-scoring-clickable`),e.style.cursor=`pointer`,e.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault();let a=t.mode===`games`?`game`:`point`;n?.scoreIncrement?.({matchUpId:r.matchUpId,sideNumber:i,scoreType:a})})}function Br({participantHeight:e,eventHandlers:t,composition:n,sideNumber:r,matchUp:i}){let a=n?.configuration?.winnerChevron,o=n?.configuration?.gameScoreOnly,s=n?.configuration?.gameScore,c=i?.score?.sets||[],l=n?.configuration?.scoreBox,u=e?r===2?e:e-1:void 0,d=e=>{j(t?.scoreClick)&&(e.stopPropagation(),t.scoreClick({pointerEvent:e,matchUp:i}))},f=document.createElement(`div`);f.className=Ar()({...!l&&r===1&&{sideNumber:1},fontSize:`small`}),u&&(f.style.height=`${u}px`),f.classList.add(`sideScore`),f.classList.add(`tmx-scr`),f.onclick=d;let p=document.createElement(`div`);p.className=Nr();let m=Rr(c,r,s,n,t,i),h=n?.configuration?.resultsInfo&&r===1;h&&(p.style.alignSelf=`stretch`);let g=(e,t,n)=>{let r=document.createElement(`div`);r.style.cssText=`position:relative; align-self:stretch; display:flex; align-items:center;`,r.appendChild(e);let i=document.createElement(`div`);return i.className=Fr({variant:n}),i.textContent=t,r.appendChild(i),r},_=s?.position||`trailing`;m&&_===`leading`&&p.appendChild(h?g(m,`PTS`,`points`):m);let v=n?.configuration?.inlineScoring,y=i?.score?.scoreStringSide1?.split(/\s+/),b=i?.score?.scoreStringSide2?.split(/\s+/),x=(e,t)=>{if(!e.tiebreakSet||e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0)return e;let n=y?.[t]?.match(/^\[(\d+)-(\d+)\]$/),r=b?.[t]?.match(/^\[(\d+)-(\d+)\]$/);return!n&&!r?e:{...e,side1TiebreakScore:n?Number(n[1]):r?Number(r[2]):void 0,side2TiebreakScore:r?Number(r[1]):n?Number(n[2]):void 0}};for(let[e,n]of(c||[]).entries()){let s=x(n,e),c=Lr({gameScoreOnly:o,scoreStripes:a,sideNumber:r,set:s});v&&!s.winningSide&&zr(c,v,t,i,r),p.appendChild(h?g(c,String(s.setNumber),`set`):c)}return m&&_!==`leading`&&p.appendChild(h?g(m,`PTS`,`points`):m),f.appendChild(p),f}var Vr=()=>`chc-scheduling`,Hr=f(l(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){"use strict";var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))());function Ur({matchUp:e,eventHandlers:n}){let{scheduledTime:r,scheduledDate:i,venueAbbreviation:a,courtName:o}=e?.schedule||{},{dateTime:{extractDate:s,extractTime:c}}=t.tools,l=c(r),u=s(i),d=`ddd D MMMM`;l&&(d+=`, hh:mm A`,u+=`T${l}`);let f=i?(0,Hr.default)(u).format(d):`Not scheduled`,p=a&&o?.toString().startsWith(a)&&o||a&&o&&`${a} ${o}`||o||a||``,m=document.createElement(`div`);m.className=Vr(),m.classList.add(`tmx-sch`),j(n?.scheduleClick)&&(m.onclick=t=>n.scheduleClick({matchUp:e,pointerEvent:t}));let h=document.createElement(`div`);h.innerHTML=f,m.append(h);let g=t=>{j(n?.venueClick)&&(t.stopPropagation(),n.venueClick({pointerEvent:t,matchUp:e}))},_=document.createElement(`div`);_.style=`display: flex; flex-direction: row`;let v=document.createElement(`div`);if(v.style.paddingRight=`.2rem`,v.onclick=g,v.innerHTML=p,_.append(v),m.append(_),m.onclick){let e=document.createElement(`div`);e.innerHTML=`⋮`,_.append(e)}return m}var{completedMatchUpStatuses:Wr}=t.factoryConstants;function Gr({initialRoundNumber:e=1,eventHandlers:n,composition:r,sideNumber:i,className:a,matchUp:o}){let s=r?.configuration||{},c=s?.scheduleInfo,l=o?.score?.scoreStringSide1||o?.score?.sets?.length,u=r?.configuration?.scoreBox&&l,d=o?.matchUpStatus&&Wr.includes(o.matchUpStatus),f=o?.readyToScore&&n?.scoreClick&&!t.tournamentEngine.checkScoreHasValue({matchUp:o})&&!d,m=document.createElement(`div`);if(m.className=(0,p.default)(Jn(),a),m.classList.add(`tmx-sd`),m.setAttribute(`sideNumber`,String(i)),c&&i===1){let e=Ur({matchUp:o,eventHandlers:n});m.appendChild(e)}let h=document.createElement(`div`);h.className=Yn();let g=cr({sideContainer:!0,initialRoundNumber:e,eventHandlers:n,composition:r,sideNumber:i,matchUp:o});if(h.appendChild(g),u){let e=document.createElement(`div`);e.style.border=`1px solid var(--chc-border-secondary)`,h.appendChild(e)}let _=s?.inlineScoring;if(l){let e=Br({eventHandlers:n,composition:r,sideNumber:i,matchUp:o});h.appendChild(e)}else if(_&&o?.readyToScore&&!d){let e=Br({eventHandlers:n,composition:r,sideNumber:i,matchUp:{...o,score:{sets:[{setNumber:1,side1Score:0,side2Score:0,..._.mode===`points`&&{side1PointScore:`0`,side2PointScore:`0`}}]}}});h.appendChild(e)}if(f&&!_){let e=e=>{j(n?.scoreClick)&&(e.stopPropagation(),n.scoreClick({pointerEvent:e,matchUp:o}))},t=document.createElement(`div`);t.className=Ar()({...!u&&i===1&&{sideNumber:1},fontSize:`small`}),t.onclick=e,t.innerHTML=`[Score]`,h.appendChild(t)}return m.appendChild(h),m}var{QUALIFYING:Kr}=t.drawDefinitionConstants;function qr(e){let{composition:t,initialRoundNumber:n=1,matchUp:r,moiety:i,selectedMatchUpId:a,searchActive:o}=e,{roundFactor:s,roundNumber:c,finishingRound:l,matchUpType:u,preFeedRound:d,stage:f}=r,m=e.isFinalRound||(l?Number.parseInt(String(l))===1:!1),h=f===Kr&&m,g=m,_=c?Number.parseInt(String(c))===n:!1,v=u===`DOUBLES`,y=(o||r.isRoundRobin||r.collectionId||e.isLucky||e.isAdHoc)&&`mr`||g&&`noProgression`||(h||d)&&`m0`||i&&`m1`||`m2`,b=kr({composition:t,isDoubles:v,roundFactor:s})({isFirstRound:_,link:y}),x=b.className,S=t?.configuration||{},{centerInfo:C}=S||{},w=e.eventHandlers||{},T=e=>{j(w?.matchUpClick)&&w.matchUpClick({pointerEvent:e,matchUp:r})},E=document.createElement(`div`);E.className=(0,p.default)(t?.theme,e?.className,`matchup`,xr()),E.classList.add(`tmx-m`),E.setAttribute(`id`,r?.matchUpId),E.onclick=T;let D=document.createElement(`div`);D.className=Sr({configuration:S});let O=({sideNumber:e})=>{let t=r?.sides?.find(t=>t.sideNumber===e)?.participant?.entryStatus?.replace(`_`,` `);return Dr({eventHandlers:w,entryStatus:t,sideNumber:e,className:e===2?x:void 0,matchUp:r})},k=Gr({initialRoundNumber:n,eventHandlers:w,sideNumber:1,composition:t,matchUp:r}),A=Gr({className:!C&&x,initialRoundNumber:n,eventHandlers:w,sideNumber:2,composition:t,matchUp:r});if(D.appendChild(k),C){let e=O({sideNumber:1}),t=O({sideNumber:2});D.appendChild(e.element),t.element&&b.applyStyles(t.element),D.appendChild(t.element)}if(D.appendChild(A),C||b.applyStyles(A),S?.matchUpFooter){let e=document.createElement(`div`),t=S?.inlineScoring,n=r.sides?.length===2&&r.sides[0]?.participant&&r.sides[1]?.participant,i=t?.canUndo||t?.canRedo||t?.isComplete||t?.isDirty;if(t&&t.showFooter!==!1&&n&&(!r.winningSide||i)){e.className=`chc-matchup-footer chc-inline-scoring-footer-slot`;let n=document.createElement(`span`);n.className=`chc-matchup-footer-round`;let i=r.roundName||``,a=r.roundPosition;n.textContent=a?`${i} \u2022 M${a}`:i,e.appendChild(n);let o=document.createElement(`div`);o.className=`chc-inline-scoring-footer-buttons`;let s=(e,t,n)=>{let i=document.createElement(`button`);return i.textContent=e,i.className=`chc-inline-scoring-btn ${t}`,n&&(i.onclick=e=>{e.stopPropagation(),n({matchUpId:r.matchUpId})}),i},c=s(`Undo`,`chc-is-undo`,w.inlineUndo),l=s(`Redo`,`chc-is-redo`,w.inlineRedo),u=s(`Clear`,`chc-is-clear`,w.inlineClear),d=s(`Submit`,`chc-is-submit`,w.inlineSubmit);c.disabled=!t.canUndo,l.disabled=!t.canRedo,u.disabled=!t.canUndo&&!t.canRedo,d.disabled=!t.isDirty;let f=document.createElement(`div`);f.className=`chc-inline-scoring-buttons`,f.append(c,l,u,d),o.appendChild(f),e.appendChild(o)}else{e.className=`chc-matchup-footer`;let t=r.roundName||``,n=r.roundPosition;e.textContent=n?`${t} \u2022 Match ${n}`:t}D.appendChild(e)}if(E.appendChild(D),a===r.matchUpId){let e=document.createElement(`div`);e.className=br(),E.appendChild(e)}return E}function Jr({initialRoundNumber:e=1,selectedMatchUpId:n,eventHandlers:r,isFinalRound:i,isRoundRobin:a,searchActive:o,composition:s,roundFactor:c,roundNumber:l,roundProfile:u,minWidth:d,matchUps:f,context:p,isLucky:m}){let h=f.filter(e=>e.roundNumber===l).sort((e,t)=>(e.roundPosition||0)-(t.roundPosition||0)),g=h.every(({roundPosition:e,drawPositions:t})=>!e&&!t),_=s?.configuration||{},v=document.createElement(`div`);if(v.className=mr(),v.classList.add(`tmx-rd`),v.setAttribute(`roundNumber`,String(l)),_.roundHeader){let e=ur({roundProfile:u,roundMatchUps:h,roundNumber:l,eventHandlers:r,context:p});v.appendChild(e)}let y=document.createElement(`div`);y.className=gr({variant:g?`adHoc`:void 0}),d&&(y.style.minWidth=d);let b,x,S;if(a){let e=e=>(e||[]).reduce((e,t)=>t+e,0);h.sort((t,n)=>{let r=e(t.drawPositions)-e(n.drawPositions),i=t.drawPositions||[],a=n.drawPositions||[],o=(i.length?Math.min.apply(null,i):0)-(a.length?Math.min.apply(null,a):0);return r||o});let n=h.reduce((e,t)=>(e[t.structureId]=t.structureName,e),{});b=Object.values(n),x=Object.keys(n),S=Object.keys(t.tools.instanceCount(h.map(({structureId:e})=>e))).length}else g&&h.sort((e,t)=>(e.roundOrder??0)-(t.roundOrder??0));let C=S&&h.length/S,w=Object.keys(u).map(e=>parseInt(e)),T=w.indexOf(l),E=T===0&&`first`||T===w.length-1&&`last`,D=null;return h.forEach((t,a)=>{let d=C&&!(a%C),f=C&&Math.floor(a/C),p=C&&b[f];if(d){D=document.createElement(`div`),D.className=`chc-rr-group`,D.setAttribute(`data-group-id`,x[f]),y.appendChild(D);let t=document.createElement(`div`);t.className=vr({...f===0&&{variant:0},...E&&{roundOrder:E}}),D.appendChild(t);let n=document.createElement(`div`);if(n.className=yr(),j(r?.groupHeaderClick)){let{drawId:e,containerStructureId:t}=h[0];D.onclick=n=>r.groupHeaderClick({structureId:x[f],containerStructureId:t,pointerEvent:n,drawId:e})}l===e&&(n.innerHTML=p),D.appendChild(n)}let _=a%2==0;if(c)t.roundFactor=c;else if(e>1&&t.roundFactor){let n=u?.[e]?.roundFactor||1;t.roundFactor/=n}else t.roundFactor||=2**(l-e);let v=qr({initialRoundNumber:e,selectedMatchUpId:n,eventHandlers:r,isFinalRound:i,searchActive:o,composition:s,isAdHoc:g,isLucky:m,matchUp:t,moiety:_});(D||y).appendChild(v)}),v.appendChild(y),v}function Yr({initialRoundNumber:e=1,selectedMatchUpId:n,eventHandlers:r,searchActive:i,composition:a,structureId:o,finalColumn:s,matchUps:c,minWidth:l,context:u}){let{roundNumbers:d,roundProfile:f,roundsNotPowerOf2:p,hasNoRoundPositions:m}=t.tournamentEngine.getRoundMatchUps({matchUps:c});o=o||u?.structureId||c?.[0]?.structureId;let h=c.some(({isRoundRobin:e})=>e),g=_r({roundsNotPowerOf2:p,hasNoRoundPositions:m,roundNumbers:d,roundProfile:f}),_=document.createElement(`div`);_.className=hr(),_.classList.add(`tmx-str`),_.setAttribute(`id`,o||``),fr(_,a?.colors);let v=d.length?Math.max.apply(null,d):0;for(let t of d){if(t<e)continue;let o=Jr({initialRoundNumber:e,selectedMatchUpId:n,eventHandlers:r,isFinalRound:t===v,isRoundRobin:h,searchActive:i,composition:a,roundNumber:t,roundProfile:f,matchUps:c,minWidth:l,context:u,isLucky:g});_.appendChild(o)}let y=null,b=(e,t)=>{_.querySelectorAll(`.tmx-i[id="${CSS.escape(e)}"]`).forEach(e=>{e.closest(`.tmx-p`)?.classList.toggle(`chc-participant-hover`,t)})};if(_.addEventListener(`mouseover`,e=>{let t=e.target.closest(`.tmx-i`)?.id;t&&t!==`undefined`&&t!==y?(y&&b(y,!1),y=t,b(t,!0)):(!t||t===`undefined`)&&y&&(b(y,!1),y=null)}),_.addEventListener(`mouseleave`,()=>{y&&=(b(y,!1),null)}),s&&typeof s!=`boolean`){let e=document.createElement(`div`);e.className=mr();let t=document.createElement(`div`);t.className=gr(),t.appendChild(s),e.appendChild(t),_.appendChild(e)}return _}var Xr=()=>`chc-container`;function Zr({content:e,theme:t}){let n=document.createElement(`div`);return n.className=t?(0,p.default)(Xr(),t):Xr(),t&&n.classList.add(t),typeof e==`string`?n.innerHTML=e:n.appendChild(e),n}function Qr(e,t){return`chc-theme-${e.replace(`-theme`,``)}`}var $r=Qr(`australian-theme`,{colors:{borderHover:`#0091d2`,connector:`#999`}}),ei=Qr(`basiccard-theme`,{colors:{connector:`transparent`,border:`#ddd`,borderHover:`#0066cc`,matchupBoxShadow:`0 1px 4px rgba(0, 0, 0, 0.1)`}}),ti=Qr(`wimbledon-theme`,{borderWidths:{},colors:{connector:`transparent`,border:`#00703c`,matchUp:`var(--chc-bg-elevated)`},participant:{textTransform:`uppercase`}}),ni=Qr(`french-theme`,{colors:{winnerName:`#01503d!important`,winner:`#01503d!important`,borderHover:`#0091d2`,border:`var(--chc-border-secondary)`},matchUp:{boxShadow:`0 0 30px 0 hsla(0,0%,89%,9)`}}),ri=Qr(`usopen-theme`,{colors:{matchUpBackgroundColor:`var(--chc-bg-secondary)`,internalDividers:`darkgray`,borderHover:`#0091d2`,connector:`#999`}}),ii=Qr(`basic-theme`,{colors:{internalDividers:`transparent`,winner:`#50B649!important`,loser:`#E61A1A!important`,connector:`#999`},space:{gameMarginInlineEnd:`0.75rem`},participant:{seed:`transparent`},fontSizes:{1:`1.5rem`}}),ai=Qr(`typti-theme`,{colors:{border:`#ff6a00`,borderHover:`#ff6a00`,connector:`#ff6a00`,score:`#ff6a00`,roundHeader:`#ff6a00`,matchUp:`var(--chc-bg-elevated)`}}),oi=Qr(`itf-theme`,{colors:{borderHover:`#0091d2`,connector:`#999`,matchUp:`var(--chc-bg-elevated)`},participant:{textTransform:`uppercase`,seed:`gray`}}),si={Australian:{configuration:{flags:!0},theme:$r},Basic:{configuration:{gameScoreOnly:!0,teamLogo:!1,roundHeader:!0,placeHolders:{tbd:`TBD`,bye:`Bye`}},theme:ii},DrawPositions:{configuration:{gameScoreOnly:!0,drawPositions:!0,teamLogo:!1},theme:ii},French:{configuration:{bracketedSeeds:!0,flags:!0},theme:ni},Wimbledon:{configuration:{resultsInfo:!0,flags:!0},theme:ti},"US Open":{configuration:{scoreBox:!0,flags:!0},theme:ri},ITF:{configuration:{winnerChevron:!0,centerInfo:!0,flags:!0,roundHeader:!0},theme:oi},TYPTI:{configuration:{flags:!0,roundHeader:!0,placeHolders:{tbd:`TBD`,bye:`Bye`}},theme:ai},BasicCard:{configuration:{flags:!0,scheduleInfo:!0,matchUpFooter:!0,roundHeader:!0},theme:ei},InlineScoring:{configuration:{matchUpFooter:!0,gameScore:{position:`trailing`,inverted:!0},inlineScoring:{mode:`games`,showFooter:!0,showSituation:!0}},theme:ei},National:{configuration:{bracketedSeeds:`square`,allDrawPositions:!0,drawPositions:!0,scheduleInfo:!0,roundHeader:!0,showAddress:!0,scaleAttributes:{scaleColor:`red`,scaleType:`RATING`,scaleName:`WTN`,accessor:`wtnRating`}},theme:$r}},ci=`National`;function li(e,t=ci){let n=si[e?.compositionName??t]??si[t]??si[ci],r={theme:e?.theme??n.theme,configuration:{...n.configuration,...e?.configuration}};return e?.colors&&(r.colors={...e.colors}),r}var{QUALIFYING:ui}=t.drawDefinitionConstants;function di({matchUp:e,moiety:t,isFirstRound:n,isFinalRound:r,isRoundRobin:i,isLucky:a}){let{stage:o,preFeedRound:s}=e,c=o===ui&&r,l=r,u=(i||e.collectionId||a)&&`mr`||l&&`noProgression`||(c||s)&&`m0`||t&&`m1`||`m2`,d=document.createElement(`div`);d.className=`chc-schematic-matchup`;let f=document.createElement(`div`);f.className=`chc-schematic-slot`;let m=document.createElement(`div`);m.className=`chc-schematic-divider`;let h=document.createElement(`div`);h.className=(0,p.default)(`chc-schematic-slot`,`chc-schematic-link`,n&&`chc-schematic-link--first-round`,u===`mr`&&`chc-schematic-link--no-link`,u===`m1`&&`chc-schematic-link--m1`,u===`m2`&&`chc-schematic-link--m2`,u===`m0`&&`chc-schematic-link--m0`,u===`noProgression`&&`chc-schematic-link--no-progression`);let g=e.roundFactor||1,_=11/2*g,v=11/2*g;return h.style.setProperty(`--chc-schematic-connector-w`,`8px`),h.style.setProperty(`--chc-schematic-m1-h`,`${_}px`),h.style.setProperty(`--chc-schematic-m2-h`,`${v}px`),d.appendChild(f),d.appendChild(m),d.appendChild(h),d}function fi({initialRoundFactor:e,initialRoundNumber:t=1,isFinalRound:n,isRoundRobin:r,roundNumber:i,matchUps:a,showHeader:o,isLucky:s}){let c=a.filter(e=>e.roundNumber===i).sort((e,t)=>(e.roundPosition||0)-(t.roundPosition||0)),l=document.createElement(`div`);if(l.className=`chc-schematic-round-container`,l.dataset.roundNumber=String(i),o){let e=document.createElement(`div`);e.className=`chc-schematic-round-header`,e.textContent=`R${i}`,l.appendChild(e)}let u=document.createElement(`div`);return u.className=`chc-schematic-round`,c.forEach((a,o)=>{e&&a.roundFactor?a.roundFactor/=e:a.roundFactor||=2**(i-t);let c=o%2==0,l=di({initialRoundNumber:t,isRoundRobin:r,isFinalRound:n,isFirstRound:i===t,isLucky:s,matchUp:a,moiety:c});u.appendChild(l)}),c.some(e=>e.preFeedRound)&&!n&&l.classList.add(`chc-schematic-round--pre-feed`),l.appendChild(u),l}function pi({initialRoundNumber:e=1,showHeaders:n=!0,structureId:r,matchUps:i}){let{roundNumbers:a,roundProfile:o,roundsNotPowerOf2:s,hasNoRoundPositions:c}=t.tournamentEngine.getRoundMatchUps({matchUps:i}),l=i.some(e=>e.isRoundRobin),u=s||c,d=e>1?o?.[e]?.roundFactor||1:void 0,f=document.createElement(`div`);f.className=`chc-schematic-structure`,r&&f.setAttribute(`id`,`schematic-${r}`);let p=a.length?Math.max(...a):0;for(let t of a){if(t<e)continue;let r=fi({showHeader:n,initialRoundFactor:d,initialRoundNumber:e,isRoundRobin:l,isFinalRound:t===p,roundNumber:t,matchUps:i,isLucky:u});f.appendChild(r)}return f}function mi(e,t,n){let r=document.createElement(`div`);r.style.cssText=`display: flex; flex-direction: column; width: 100%;`,r.classList.add(`flexcol`);let i={},a={},o;for(let e of t){if((e.text||e.html)&&!e.field){o=gi(e,r,i,a,o);continue}if(e.divider){let e=document.createElement(`hr`);e.classList.add(`dropdown-divider`),r.appendChild(e);continue}if(e.spacer){let t=document.createElement(`div`),n=typeof e.spacer==`number`&&`${e.spacer}em`||typeof e.spacer==`string`&&e.spacer||`1em`;t.style.marginBlockEnd=n,r.appendChild(t);continue}!e.label&&!e.field||e.hide||e.field&&(o=_i(e,r,i,a,o))}return o&&setTimeout(()=>o.focus(),200),e.appendChild(r),n?.length&&vi(n,t,i,a),i}function hi(e,t,n,r){let i=r,{field:a,inputElement:o,datepicker:s}=ln(e.fieldPair);return s&&(t[`${e.field}.date`]=s),o&&(t[e.fieldPair.field]=o,e.fieldPair.focus&&(i=o)),n[e.fieldPair.field]=a,i}function gi(e,t,n,r,i){let a=i,o=e.fieldPair&&document.createElement(`div`);o&&(o.className=`flexrow`);let s=document.createElement(`div`);s.className=`flexaligncenter`,s.style.cssText=e.style||e.header&&`font-weight: bold; font-size: larger;`||`height: 2.5em; padding-right: 1em;`;let c=document.createElement(`div`);return e.id&&(c.id=e.id),c.className=`content`,c.innerHTML=e.text,s.appendChild(c),o?(o.appendChild(s),a=hi(e,n,r,a),o.appendChild(r[e.fieldPair.field]),t.appendChild(o)):t.appendChild(s),a}function _i(e,t,n,r,i){let a=i,o=e.fieldPair&&document.createElement(`div`);o&&(o.className=`flexrow`);let{field:s,inputElement:c,datepicker:l,subFields:u}=ln(e);return u&&u.forEach(e=>n[e.field]=e.input),l&&(n[`${e.field}.date`]=l),e.focus&&(a=c),n[e.field]=c,r[e.field]=s,o?(o.appendChild(s),a=hi(e,n,r,a),o.appendChild(r[e.fieldPair.field]),t.appendChild(o)):t.appendChild(s),a}function vi(e,t,n,r){for(let i of e){if(i.dateRange&&Array.isArray(i.fields)){let[e,r]=i.fields;if(n[e]&&n[r]){let a=t.find(t=>t.field===e),o=new rn(n[e],{inputs:[n[e],n[r]],minDate:i.minDate,maxDate:i.maxDate,format:`yyyy-mm-dd`,language:a?.language||`en`,autohide:!0});n[`${e}.date`]=o}}i.control&&(B(i.onChange)&&n[i.control].addEventListener(`change`,e=>i.onChange({e,inputs:n,fields:r})),B(i.onInput)&&n[i.control]&&n[i.control].addEventListener(`input`,e=>i.onInput({e,inputs:n,fields:r})),B(i.onFocusOut)&&n[i.control]&&n[i.control].addEventListener(`focusout`,e=>i.onFocusOut({e,inputs:n,fields:r})))}}var{ratingsParameters:yi}=t.fixtures,{WTN:bi,UTR:xi}=t.factoryConstants.ratingConstants,{FEMALE:Si,MALE:Ci,ANY:wi}=t.genderConstants;function Ti(e={}){let{callback:n,consideredDate:r,title:i=`Generate mock participants`,labels:a={},defaults:o={},roleOptions:s}=e,c,l=s&&s.length>1,u=o.participantRole||s?.[0]?.value||`COMPETITOR`,d={role:a.role||`Participant role`,gender:a.gender||`Participant gender`,count:a.count||`Participant count`,ageRange:a.ageRange||`Participant Age Range`,minAge:a.minAge||`Min Age`,maxAge:a.maxAge||`Max Age`,ratings:a.ratings||`Generate Ratings`,countries:a.countries||`# of Countries`,cancel:a.cancel,generate:a.generate,genderAny:a.genderAny,genderFemale:a.genderFemale,genderMale:a.genderMale},f=o.ratings?[...o.ratings]:[...o.wtnRating?[bi]:[],...o.utrRating?[xi]:[]],p={gender:o.gender||wi,participantsCount:o.participantsCount||32,ageMin:o.ageMin,ageMax:o.ageMax,nationalityCodesCount:o.nationalityCodesCount},m=Object.entries(yi).filter(([,e])=>!e.deprecated).map(([e])=>({label:e,value:e,selected:f.includes(e)})),h=[{label:d.cancel||`Cancel`,intent:`none`,close:!0},{label:d.generate||`Generate`,intent:`is-info`,close:!0,onClick:()=>{let e=c.participantsCount.value,i=c.gender.value,a=i===wi?void 0:i,o=l?c.participantRole.value:u,s=c.ageMin?.value?Number.parseInt(c.ageMin.value):void 0,d=c.ageMax?.value?Number.parseInt(c.ageMax.value):void 0,f=c.nationalityCodesCount?.value?Number.parseInt(c.nationalityCodesCount.value):void 0,p=(c.ratings?.selectedValues||[]).map(e=>{let t=yi[e];if(!t)return null;let[n,r]=t.range||[0,100],i=Math.min(n,r),a=Math.max(n,r)-i;return{ratingType:e,ratingMin:i+a*.3,ratingMax:i+a*.7}}).filter(Boolean),m=s||d?{ageMin:s,ageMax:d}:void 0,{participants:h}=t.mocksEngine.generateParticipants({participantsCount:Number.parseInt(e),scaleAllParticipants:!0,nationalityCodesCount:f,participantRole:o,consideredDate:r,categories:p,category:m,sex:a});n&&n(h)}}],g=[{control:`ageMin`,onChange:({inputs:e})=>{let t=Number.parseInt(e.ageMin.value)||0,n=Number.parseInt(e.ageMax.value)||0;t>n&&n>0&&(e.ageMax.value=t)}},{control:`ageMax`,onChange:({inputs:e})=>{let t=Number.parseInt(e.ageMin.value)||0,n=Number.parseInt(e.ageMax.value)||0;n<t&&t>0&&n>0&&(e.ageMin.value=n)}}],_=l?[{options:s.map(e=>({label:e.label,value:e.value,selected:e.value===u})),label:d.role,field:`participantRole`,value:u}]:[];F.open({title:i,content:e=>c=mi(e,[..._,{options:[{label:d.genderAny||`Any`,value:wi,selected:p.gender===wi},{label:d.genderFemale||`Female`,value:Si,selected:p.gender===Si},{label:d.genderMale||`Male`,value:Ci,selected:p.gender===Ci}],label:d.gender,field:`gender`,value:p.gender},{options:[{label:`8`,value:8,selected:p.participantsCount===8},{label:`16`,value:16,selected:p.participantsCount===16},{label:`32`,value:32,selected:p.participantsCount===32},{label:`64`,value:64,selected:p.participantsCount===64},{label:`128`,value:128,selected:p.participantsCount===128},{label:`256`,value:256,selected:p.participantsCount===256}],label:d.count,field:`participantsCount`,value:p.participantsCount},{label:d.minAge,field:`ageMin`,placeholder:`e.g., 10`,type:`number`,value:p.ageMin,width:`50%`,fieldPair:{label:d.maxAge,field:`ageMax`,placeholder:`e.g., 18`,type:`number`,value:p.ageMax}},{label:d.countries,field:`nationalityCodesCount`,id:`nationalityCodesCount`,placeholder:`e.g., 10`,type:`number`,value:p.nationalityCodesCount},{label:d.ratings,field:`ratings`,id:`ratings`,multiple:!0,options:m}],g),buttons:h})}var{FEMALE:Ei,MALE:Di,ANY:Oi}=t.genderConstants,{TEAM:ki}=t.participantConstants;function Ai(e){if(!e?.collectionDefinitions?.length)return 8;let t=0;for(let n of e.collectionDefinitions){let e=n.matchUpCount||0,r=n.matchUpType===`DOUBLES`?2:1;t+=e*r}return t||8}function ji(e={}){let{callback:n,consideredDate:r,title:i=`Generate mock teams`,tieFormats:a=[],labels:o={}}=e,s,c=a.length>0,l=[{label:o.manualTeamSize||`Manual team size`,value:`-`,selected:!0},...a.map(e=>({label:e.label,value:e.value,selected:!1}))],u=[{label:o.cancel||`Cancel`,intent:`none`,close:!0},{label:o.generate||`Generate`,intent:`is-info`,close:!0,onClick:()=>{let e=Number.parseInt(s.teamsCount.value)||4,i=s.gender.value,o=i===Oi?void 0:i,l,u=c?s.tieFormatSelect?.value:`-`;if(u&&u!==`-`){let e=a.find(e=>e.value===u);l=e?Ai(e.tieFormat):8;let t=s.teamSize?.value,n=t?Number.parseInt(t):0;n>l&&(l=n)}else l=Number.parseInt(s.teamSize?.value)||8;let d=s.nationalityCodesCount?.value?Number.parseInt(s.nationalityCodesCount.value):void 0,{participants:f}=t.mocksEngine.generateParticipants({participantsCount:e,participantType:ki,nationalityCodesCount:d,consideredDate:r,teamSize:l,sex:o});n&&n(f)}}],d=c?[{control:`tieFormatSelect`,onChange:({inputs:e})=>{let t=e.tieFormatSelect.value;if(t&&t!==`-`){let n=a.find(e=>e.value===t),r=n?Ai(n.tieFormat):8;e.teamSize.value=r,e.teamSize.disabled=!0}else e.teamSize.disabled=!1}}]:[],f=c?[{options:l,label:o.tieFormatTemplate||`Tie format template`,field:`tieFormatSelect`,value:`-`}]:[];F.open({title:i,content:e=>s=mi(e,[{options:[{label:o.genderAny||`Any`,value:Oi,selected:!0},{label:o.genderFemale||`Female`,value:Ei},{label:o.genderMale||`Male`,value:Di}],label:o.gender||`Gender`,field:`gender`,value:Oi},{options:[{label:`2`,value:2},{label:`4`,value:4,selected:!0},{label:`8`,value:8},{label:`16`,value:16},{label:`32`,value:32}],label:o.teamsCount||`Number of teams`,field:`teamsCount`,value:4},...f,{label:o.playersPerTeam||`Players per team`,field:`teamSize`,placeholder:`e.g., 8`,type:`number`,value:8},{label:o.countries||`# of Countries`,field:`nationalityCodesCount`,placeholder:`e.g., 10`,type:`number`}],d),buttons:u})}var Mi=`grand-slam`,Ni=`tour`,Pi=`itf`,Fi=`national-federation`,Ii=[{id:Mi,name:`Grand Slam`,category:Mi,tier:1},{id:`wimbledon`,name:`Wimbledon`,category:Mi,tier:1},{id:`australian-open`,name:`Australian Open`,category:Mi,tier:2},{id:`wta-500`,name:`WTA 500`,category:Ni,tier:2},{id:`wta-1000`,name:`WTA 1000`,category:Ni,tier:2},{id:`atp-250`,name:`ATP 250`,category:Ni,tier:2},{id:`atp-finals`,name:`ATP Finals`,category:Ni,tier:3},{id:`itf-junior`,name:`ITF Junior`,category:Pi,tier:3},{id:`itf-pro-circuit`,name:`ITF Pro Circuit`,category:Pi,tier:2},{id:Fi,name:`National Federation`,category:`national`,tier:3},{id:`collegiate-ncaa`,name:`NCAA Collegiate`,category:`collegiate`,tier:1},{id:`club-basic`,name:`Club Basic`,category:`club`,tier:1}];function Li(e={}){let t=`preset`,n={},r={},i={},a,o=t=>{i=mi(t,[{header:!0,text:`Composition Preset`},{spacer:.5},{field:`preset`,label:`Select Preset`,options:Ii.map(t=>({label:`${t.name} (${t.category}, Tier ${t.tier})`,value:t.id,selected:t.id===(e.initialPreset||`club-basic`)}))},{spacer:1},{text:`Select a preset to populate header and footer settings, then customize in the Header and Footer tabs.`,style:`color: var(--chc-text-muted); font-size: 13px;`}])},s=t=>{let r=e.initialHeader||{};n=mi(t,[{header:!0,text:`Header Configuration`},{spacer:.5},{field:`layout`,label:`Layout`,options:[{label:`Grand Slam`,value:Mi,selected:r.layout===Mi},{label:`ITF / Professional`,value:Pi,selected:r.layout===Pi},{label:`WTA / ATP Tour`,value:`wta-tour`,selected:r.layout===`wta-tour`},{label:`National Federation`,value:Fi,selected:r.layout===Fi},{label:`Minimal`,value:`minimal`,selected:r.layout===`minimal`||!r.layout},{label:`None`,value:`none`,selected:r.layout===`none`}]},{divider:!0},{field:`tournamentName`,label:`Tournament Name`,value:r.tournamentName||``,placeholder:`e.g., Australian Open 2026`},{field:`subtitle`,label:`Subtitle / Event`,value:r.subtitle||``,placeholder:`e.g., Womens Singles`},{divider:!0},{field:`startDate`,label:`Start Date`,value:r.startDate||``,placeholder:`e.g., 19 Jan 2026`,fieldPair:{field:`endDate`,label:`End Date`,value:r.endDate||``,placeholder:`e.g., 1 Feb 2026`}},{field:`city`,label:`City`,value:r.city||``,placeholder:`e.g., Melbourne`,fieldPair:{field:`country`,label:`Country`,value:r.country||``,placeholder:`e.g., AUS`}},{field:`surface`,label:`Surface`,value:r.surface||``,placeholder:`e.g., Hard`},{field:`prizeMoney`,label:`Prize Money`,value:r.prizeMoney||``,placeholder:`e.g., 1,520,600`},{divider:!0},{field:`supervisor`,label:`Supervisor`,value:r.supervisor||``},{field:`grade`,label:`Grade`,value:r.grade||``,placeholder:`e.g., J300`},{field:`sectionLabel`,label:`Section Label`,value:r.sectionLabel||``,placeholder:`e.g., SINGLES MAIN DRAW`}])},c=t=>{let n=e.initialFooter||{};r=mi(t,[{header:!0,text:`Footer Configuration`},{spacer:.5},{field:`layout`,label:`Layout`,options:[{label:`Standard (timestamp + page)`,value:`standard`,selected:n.layout===`standard`||!n.layout},{label:`Seedings Table`,value:`seedings-table`,selected:n.layout===`seedings-table`},{label:`Prize Money`,value:`prize-money`,selected:n.layout===`prize-money`},{label:`Officials Sign-off`,value:`officials-signoff`,selected:n.layout===`officials-signoff`},{label:`Combined Tour (WTA/ATP)`,value:`combined-tour`,selected:n.layout===`combined-tour`},{label:`None`,value:`none`,selected:n.layout===`none`}]},{divider:!0},{field:`showPageNumbers`,id:`comp-pagenums`,label:`Show Page Numbers`,checkbox:!0,checked:n.showPageNumbers!==!1},{field:`showTimestamp`,id:`comp-timestamp`,label:`Show Timestamp`,checkbox:!0,checked:n.showTimestamp!==!1},{divider:!0},{field:`releaseDate`,label:`Release Date`,value:n.releaseDate||``,placeholder:`e.g., 18 Jan 2026 at 15:30`},{field:`drawCeremonyDate`,label:`Draw Ceremony`,value:n.drawCeremonyDate||``,placeholder:`e.g., 18 Jan 2026 at 14:00`}])},l=()=>({layout:n.layout?.value||`minimal`,tournamentName:n.tournamentName?.value||``,subtitle:n.subtitle?.value||void 0,startDate:n.startDate?.value||void 0,endDate:n.endDate?.value||void 0,city:n.city?.value||void 0,country:n.country?.value||void 0,surface:n.surface?.value||void 0,prizeMoney:n.prizeMoney?.value||void 0,supervisor:n.supervisor?.value||void 0,grade:n.grade?.value||void 0,sectionLabel:n.sectionLabel?.value||void 0}),u=()=>({layout:r.layout?.value||`standard`,showPageNumbers:r.showPageNumbers?.checked??!0,showTimestamp:r.showTimestamp?.checked??!0,releaseDate:r.releaseDate?.value||void 0,drawCeremonyDate:r.drawCeremonyDate?.value||void 0}),d=[{label:`Preset`,active:!0,onClick:()=>{t=`preset`,f()}},{label:`Header`,active:!1,onClick:()=>{t=`header`,f()}},{label:`Footer`,active:!1,onClick:()=>{t=`footer`,f()}}],f=()=>{d.forEach(e=>e.active=e.label.toLowerCase()===t);let e=t===`preset`?o:t===`header`?s:c;a&&a.update({content:e,config:{menu:{menuItems:d},maxWidth:520}})};return a=F.open({title:`PDF Composition`,content:o,buttons:[{label:`Apply`,intent:`is-info`,onClick:()=>{let t={header:l(),footer:u(),preset:i.preset?.value};e.onApply?.(t),F.close()}},{label:`Cancel`,close:!0}],config:{menu:{menuItems:d},maxWidth:520}}),a}var Ri={showParticipantNames:!0,showNationality:!0,showSeedings:!0,showMatchNumber:!1,showEventRound:!0,showScheduledTime:!0,showMatchFormat:!1,showScore:!0,nameFormat:`full`,cellStyle:`detailed`};function zi(e={}){let t={...Ri,...e.initial},n={},r=e=>{n=mi(e,[{header:!0,text:`Schedule Cell Content`},{text:`Select which information appears in each schedule grid cell.`,style:`color: var(--chc-text-muted); font-size: 13px;`},{spacer:.5},{field:`showNationality`,id:`scc-nationality`,label:`Nationality (country code)`,checkbox:!0,checked:t.showNationality},{field:`showSeedings`,id:`scc-seedings`,label:`Seedings`,checkbox:!0,checked:t.showSeedings},{field:`showEventRound`,id:`scc-eventround`,label:`Event & Round`,checkbox:!0,checked:t.showEventRound},{field:`showScheduledTime`,id:`scc-time`,label:`Scheduled Time / Not Before`,checkbox:!0,checked:t.showScheduledTime},{field:`showScore`,id:`scc-score`,label:`Score (for completed matches)`,checkbox:!0,checked:t.showScore},{field:`showMatchNumber`,id:`scc-matchnum`,label:`Match Number`,checkbox:!0,checked:t.showMatchNumber},{field:`showMatchFormat`,id:`scc-format`,label:`Match Format Code`,checkbox:!0,checked:t.showMatchFormat},{divider:!0},{field:`nameFormat`,label:`Name Format`,options:[{label:`Full (LASTNAME, First)`,value:`full`,selected:t.nameFormat===`full`},{label:`Abbreviated (F. LASTNAME)`,value:`abbreviated`,selected:t.nameFormat===`abbreviated`},{label:`Last Name Only`,value:`lastOnly`,selected:t.nameFormat===`lastOnly`}]},{field:`cellStyle`,label:`Cell Density`,options:[{label:`Detailed`,value:`detailed`,selected:t.cellStyle===`detailed`},{label:`Compact`,value:`compact`,selected:t.cellStyle===`compact`}]}])},i=()=>({showParticipantNames:!0,showNationality:n.showNationality?.checked??!0,showSeedings:n.showSeedings?.checked??!0,showMatchNumber:n.showMatchNumber?.checked??!1,showEventRound:n.showEventRound?.checked??!0,showScheduledTime:n.showScheduledTime?.checked??!0,showMatchFormat:n.showMatchFormat?.checked??!1,showScore:n.showScore?.checked??!0,nameFormat:n.nameFormat?.value||`full`,cellStyle:n.cellStyle?.value||`detailed`}),a=document.createElement(`div`);a.style.cssText=`display: flex; gap: 6px; margin-top: 4px;`;let o=[{label:`Detailed`,config:{...Ri}},{label:`Compact`,config:{...Ri,showNationality:!1,showScheduledTime:!1,showMatchFormat:!1,nameFormat:`abbreviated`,cellStyle:`compact`}},{label:`Broadcast`,config:{...Ri,showMatchNumber:!0,showMatchFormat:!0}},{label:`Minimal`,config:{...Ri,showNationality:!1,showSeedings:!1,showScheduledTime:!1,showMatchFormat:!1,showScore:!1,nameFormat:`lastOnly`,cellStyle:`compact`}}];for(let e of o){let t=document.createElement(`button`);t.textContent=e.label,t.className=`chc-button chc-button--sm`,t.style.cssText=`padding: 2px 8px; font-size: 11px; cursor: pointer; border: 1px solid var(--chc-border-primary); border-radius: 3px; background: var(--chc-bg-secondary);`,t.onclick=()=>{let t=e.config;n.showNationality&&(n.showNationality.checked=t.showNationality),n.showSeedings&&(n.showSeedings.checked=t.showSeedings),n.showMatchNumber&&(n.showMatchNumber.checked=t.showMatchNumber),n.showEventRound&&(n.showEventRound.checked=t.showEventRound),n.showScheduledTime&&(n.showScheduledTime.checked=t.showScheduledTime),n.showMatchFormat&&(n.showMatchFormat.checked=t.showMatchFormat),n.showScore&&(n.showScore.checked=t.showScore),n.nameFormat&&(n.nameFormat.value=t.nameFormat),n.cellStyle&&(n.cellStyle.value=t.cellStyle)},a.appendChild(t)}return F.open({title:`Schedule Cell Configuration`,content:e=>{r(e);let t=document.createElement(`div`);t.style.cssText=`font-size: 12px; color: var(--chc-text-muted); margin-top: 12px;`,t.textContent=`Quick presets:`,e.appendChild(t),e.appendChild(a)},buttons:[{label:`Apply`,intent:`is-info`,onClick:()=>{e.onApply?.(i()),F.close()}},{label:`Cancel`,close:!0}],config:{maxWidth:440}})}var Bi=`Timed set`,Vi=`Tiebreak`,Hi=[`SET`,`HAL`,`QTR`,`PER`,`INN`,`RND`,`FRM`,`MAP`],Ui={SET:`Set`,HAL:`Half`,QTR:`Quarter`,PER:`Period`,INN:`Inning`,RND:`Round`,FRM:`Frame`,MAP:`Map`};function Wi(e){return!e||e===`SET`?[1,3,5]:[1,2,3,4,5,6,7,8,9,10,11,12]}function Gi(e=!1){return{descriptor:e?`Final set`:`Best of`,bestOf:e?void 0:3,advantage:`Ad`,what:`Set`,setTo:6,tiebreakAt:6,tiebreakTo:7,winBy:2,minutes:10}}function Ki(){return{matchRoot:void 0,aggregate:void 0,gameFormat:void 0,setFormat:Gi(!1),finalSetFormat:Gi(!0)}}function qi(e){return!!(e?.tiebreakSet?.tiebreakTo&&!e?.setTo)}function Ji(e,t){let{what:n,setTo:r,tiebreakAt:i,tiebreakTo:a,winBy:o,minutes:s,advantage:c,based:l,modifier:u}=e,d={setTo:r};return n===`Set`&&c===`No-Ad`&&(d.NoAD=!0),t&&n===`Set`&&(d.tiebreakAt=i,d.tiebreakFormat={tiebreakTo:a},o===1&&(d.tiebreakFormat.NoAD=!0),u&&(d.tiebreakFormat.modifier=u)),n===`Timed set`&&(d.minutes=s,d.timed=!0,l&&(d.based=l),u&&(d.modifier=u)),n===`Tiebreak`&&(d.tiebreakSet={tiebreakTo:a},o===1&&(d.tiebreakSet.NoAD=!0),u&&(d.tiebreakSet.modifier=u)),d}function Yi(e){return e<=1?[]:[e-1,e]}function Xi(e,t){return Yi(e).includes(t)?t:e}function Zi(e){if(e)return e.tiebreakSet?.modifier||e.tiebreakFormat?.modifier||e.modifier||void 0}function Qi(e,t){let n=t(e);if(!n)return Ki();let r=Gi(!1),i=Gi(!0),a={matchRoot:n.matchRoot||void 0,aggregate:n.aggregate||void 0,gameFormat:n.gameFormat||void 0,setFormat:{...r,...n.setFormat},finalSetFormat:{...i,...n.finalSetFormat}};n.setFormat?.based&&(a.setFormat.based=n.setFormat.based),n.finalSetFormat?.based&&(a.finalSetFormat.based=n.finalSetFormat.based);let o=Zi(n.setFormat);o&&(a.setFormat.modifier=o);let s=Zi(n.finalSetFormat);return s&&(a.finalSetFormat.modifier=s),n.exactly?(a.setFormat.exactly=n.exactly,a.setFormat.descriptor=`Exactly`,delete a.setFormat.bestOf,a.setFormat.timed&&(a.setFormat.what=Bi)):(a.setFormat.bestOf=n.bestOf||3,a.setFormat.descriptor=`Best of`,delete a.setFormat.exactly),qi(n.setFormat)&&(a.setFormat.what=Vi,a.setFormat.tiebreakTo=n.setFormat.tiebreakSet.tiebreakTo,a.setFormat.winBy=n.setFormat.tiebreakSet.NoAD?1:2),n.setFormat?.timed&&(a.setFormat.what=Bi,a.setFormat.minutes=n.setFormat.minutes),qi(n.finalSetFormat)&&(a.finalSetFormat.what=Vi,a.finalSetFormat.tiebreakTo=n.finalSetFormat.tiebreakSet.tiebreakTo,a.finalSetFormat.winBy=n.finalSetFormat.tiebreakSet.NoAD?1:2),n.finalSetFormat?.timed&&(a.finalSetFormat.what=Bi,a.finalSetFormat.minutes=n.finalSetFormat.minutes),a}var $i=[{key:`custom`,name:`Custom`,desc:``},{key:`standard`,name:`Standard Advantage`,format:`SET3-S:6/TB7`,desc:`Best of 3 Sets to 6 with Advantage`},{key:`atpd`,name:`Standard Doubles`,format:`SET3-S:6NOAD/TB7-F:TB10`,desc:`Best of 3 Sets to 6, no Ad`,desc2:`Final Set Tiebreak to 10`},{key:`standard1`,name:`One Standard Set`,format:`SET1-S:6/TB7`,desc:`1 Set to 6 Games, Tiebreak to 7`},{key:`wimbledon2018`,name:`Wimbledon 2018`,format:`SET5-S:6/TB7-F:6`,desc:`Best of 5 tiebreak sets, final set no tiebreak`},{key:`wimbledon2019`,name:`Wimbledon 2019`,format:`SET5-S:6/TB7-F:6/TB7@12`,desc:`Best of 5 tiebreak sets, final set tiebreak at 12`},{key:`Aus2019`,name:`Australian Open 2019`,format:`SET5-S:6/TB7-F:6/TB10`,desc:`Best of 5 tiebreak sets, final set tiebreak at 12`},{key:`short`,name:`Short Sets TB7@4`,format:`SET3-S:4/TB7`,desc:`Best of 3 Sets to 4, tiebreak to 7 at 4-4`},{key:`short1`,name:`Fast 4`,format:`SET3-S:4/TB5@3`,desc:`Best of 3 Sets to 4, tiebreak to 5 at 3-3`},{key:`short2`,name:`One Short Set TB7`,format:`SET1-S:4/TB7`,desc:`One Set to 4, tiebreak to 7 at 4-4`},{key:`short3`,name:`One Short Set TB5`,format:`SET1-S:4/TB5@3`,desc:`One Set to 4, tiebreak to 5 at 3-3`},{key:`short4`,name:`Short Sets w/ 3rd TB10`,format:`SET3-S:4/TB7-F:TB10`,desc:`Best of 3 Sets to 4 Games, tiebreak to 10`,desc2:`3rd Set Tiebreak to 7`},{key:`short5`,name:`Short Sets w/ 3rd TB7`,format:`SET3-S:4/TB7-F:TB7`,desc:`Best of 3 Sets to 4 Games, tiebreak to 7`,desc2:`3rd Set Tiebreak to 7`},{key:`pro`,name:`Pro Set`,format:`SET1-S:8/TB7`,desc:`One Set to 8 with Advantage, tiebreak at 8-8`},{key:`cps`,name:`College Pro Set`,format:`SET1-S:8/TB7@7`},{key:`tbsets1`,name:`Best of 3 TB7`,format:`SET3-S:TB7`,desc:`Two tiebreak sets`,desc2:`7-point match tiebreak at one set all`},{key:`tbsets2`,name:`Best of 3 TB10`,format:`SET3-S:TB10`,desc:`Best of 3 tiebreaks to 10`},{key:`tbsets3`,name:`One Tiebreak to 10`,format:`SET1-S:TB10`,desc:`One Match Tiebreak to 10 with Advantage`},{key:`tbsets4`,name:`Two TB7 w/ 3rd TB10`,format:`SET3-S:TB7-F:TB10`,desc:`Two 7 point tiebreak sets`,desc2:`10 point tiebreak at one set all`},{key:`timed10`,name:`Timed 10 minute game - game based`,format:`SET1-S:T10`},{key:`1pointslam`,name:`1 Point Slam`,format:`SET1-S:TB1NOAD`},{key:`pickleball`,name:`Pickleball Standard`,format:`SET3-S:TB11`,desc:`Best of 3 games to 11`},{key:`pickleballRally`,name:`Pickleball Rally`,format:`SET3-S:TB11@RALLY`,desc:`Best of 3 games to 11, rally scoring`},{key:`mlp`,name:`MLP Format`,format:`SET5-S:TB21@RALLY-F:TB15@RALLY`,desc:`Best of 5 to 21, final to 15, rally scoring`},{key:`padel`,name:`Padel Standard`,format:`SET3-S:6NOAD/TB7`,desc:`Best of 3 sets to 6, golden point`},{key:`padelStarPoint`,name:`Padel Star Point (2026)`,format:`SET3-S:6/TB7-G:TN3D`,desc:`Best of 3 sets to 6, golden point, Star Point deuce`},{key:`squash`,name:`Squash PAR-11`,format:`SET5-S:TB11`,desc:`Best of 5 games to 11`},{key:`badminton`,name:`Badminton BWF`,format:`SET3-S:TB21`,desc:`Best of 3 games to 21`},{key:`volleyball`,name:`Volleyball Indoor`,format:`SET5-S:TB25-F:TB15`,desc:`Best of 5 sets to 25, final to 15`},{key:`beachVolleyball`,name:`Beach Volleyball`,format:`SET3-S:TB21-F:TB15`,desc:`Best of 3 sets to 21, final to 15`},{key:`soccer`,name:`Soccer`,format:`HAL2A-S:T45`,desc:`2 halves of 45 minutes, aggregate`},{key:`basketball`,name:`Basketball NBA`,format:`QTR4A-S:T12`,desc:`4 quarters of 12 minutes, aggregate`},{key:`iceHockey`,name:`Ice Hockey`,format:`PER3A-S:T20`,desc:`3 periods of 20 minutes, aggregate`},{key:`boxing`,name:`Boxing Championship`,format:`RND12A-S:T3`,desc:`12 rounds of 3 minutes, aggregate`},{key:`mma`,name:`MMA Standard`,format:`RND3A-S:T5`,desc:`3 rounds of 5 minutes, aggregate`},{key:`blw`,name:`BLW Standard`,format:`INN4XA-S:O3-M:T50`,desc:`4 innings, 3 outs, 50 minute max match time`},{key:`typti`,name:`TYPTI Standard`,format:`SET5-S:5-G:3C`,desc:`Best of 5 sets to 5, 3 consecutive points/game`},{key:`intennse`,name:`INTENNSE`,format:`SET7XA-S:T10P`,desc:`Exactly 7 timed sets, aggregate, points-based`}],H=`none`,U=`▾`,ea=`all .2s ease-in-out`,ta=`var(--chc-text-primary)`,na=`var(--chc-dropdown-bg)`,ra=`var(--chc-hover-bg)`;function ia(e){return typeof e==`function`}var aa={labels:{title:`Match format`,setFormatLabel:`Set format`,finalSetLabel:`Final set`,tiebreakLabel:`Tiebreak`,finalSetToggleLabel:`Final set`,standardFormatsLabel:`Standard formats`,cancel:`Cancel`,select:`Select`,custom:`Custom`,aggregate:`Aggregate`,game:`Game`,gameType:`Game type`,deuceRule:`Deuce rule`,none:`None`,traditional:`Traditional`,consecutive2:`2 consecutive`,consecutive3:`3 consecutive`,consecutive4:`4 consecutive`,goldenPoint:`Golden point`,starPoint:`Star point`,games:`Games`,points:`Points`,descriptors:{bestOf:`Best of`,exactly:`Exactly`},what:{sets:`Set`,tiebreaks:`Tiebreak`,timedSets:`Timed set`},advantage:{ad:`Ad`,noAd:`No-Ad`}},options:{bestOf:[1,3,5],exactly:[1,2,3,4,5,6,7,8,9,10,11,12],setTo:[1,2,3,4,5,6,7,8,9],tiebreakTo:[1,3,5,7,9,10,11,12,13,15,21,25],tiebreakToExactly:[1,3],tiebreakAt:[3,4,5,6,7,8],minutes:[3,5,8,10,12,15,20,25,30,45,60,90,120],winBy:[1,2],matchRoots:[...Hi],gameFormats:[`None`,`TN`,`2C`,`3C`,`4C`],modifiers:[`None`,`RALLY`]}},W=aa,oa,G,sa={};function K(e){return sa[e]||document.getElementById(e)||null}var ca=`Timed set`,la=`Tiebreak`,ua=`No-Ad`,da=`Set`,fa=`Ad`,pa={Games:`G`,Points:`P`};function ma(){return{G:W.labels?.games||`Games`,P:W.labels?.points||`Points`}}function ha(){return{None:W.labels?.none||`None`,TN:W.labels?.traditional||`Traditional`,"2C":W.labels?.consecutive2||`2 consecutive`,"3C":W.labels?.consecutive3||`3 consecutive`,"4C":W.labels?.consecutive4||`4 consecutive`}}function ga(){return{None:W.labels?.none||`None`,"1D":W.labels?.goldenPoint||`Golden point`,"3D":W.labels?.starPoint||`Star point`}}function _a(e){let t=ha(),n=ga();if(!e)return W.labels?.none||`None`;let r;if(e.type===`TRADITIONAL`)r=t.TN||`Traditional`;else if(e.type===`CONSECUTIVE`)r=t[`${e.count}C`]||`${e.count} consecutive`;else return W.labels?.none||`None`;if(e.deuceAfter){let t=`${e.deuceAfter}D`;r+=` + ${n[t]||t}`}return r}var q={matchRoot:void 0,aggregate:void 0,gameFormat:void 0,setFormat:{descriptor:`Best of`,bestOf:3,advantage:fa,what:da,setTo:6,tiebreakAt:6,tiebreakTo:7,winBy:2,minutes:10},finalSetFormat:{descriptor:`Final set`,advantage:fa,what:da,setTo:6,tiebreakAt:6,tiebreakTo:7,winBy:2,minutes:10}};function va(e){let t=q[e?`finalSetFormat`:`setFormat`];return Ji(t,K(e?`finalSetTiebreak`:`setTiebreak`)?.checked||!1)}function ya(){G={setFormat:va()},q.matchRoot&&q.matchRoot!==`SET`&&(G.matchRoot=q.matchRoot),q.aggregate&&(G.aggregate=!0),q.gameFormat&&(G.gameFormat=q.gameFormat);let e=q.setFormat.descriptor,n=q.setFormat.exactly??q.setFormat.bestOf??3;e===`Exactly`?(G.exactly=n,delete G.bestOf):(G.bestOf=n,delete G.exactly),K(`finalSetOption`)?.checked&&(G.finalSetFormat=va(1));let r=t.governors.scoreGovernor.stringifyMatchUpFormat(G),i=(W.preDefinedFormats?W.preDefinedFormats.map(e=>({value:e.code,label:e.text,format:e.code})):$i).some(e=>e.format===r),a=K(`matchUpFormatSelector`);if(a){let e=a.value,t=i?r:`Custom`;if(e!==t){let e=a.onchange;a.onchange=null,a.value=t,a.onchange=e}}return r}function ba(e){let t=e||ya();oa=t;let n=K(`matchUpFormatString`);n&&(n.innerHTML=t)}var xa=(e,t)=>t&&e.finalSetFormat||e.setFormat,Sa=[{getValue:e=>e.exactly?W.labels?.descriptors?.exactly||`Exactly`:W.labels?.descriptors?.bestOf||`Best of`,options:()=>[W.labels?.descriptors?.bestOf||`Best of`,W.labels?.descriptors?.exactly||`Exactly`],id:`descriptor`,value:W.labels?.descriptors?.bestOf||`Best of`,finalSet:!1,onChange:`changeDescriptor`},{getValue:e=>e.bestOf||e.exactly,finalSet:!1,id:`bestOf`,options:()=>q.setFormat.descriptor===(W.labels?.descriptors?.exactly||`Exactly`)?W.options?.exactly||aa.options.exactly:Wi(q.matchRoot),onChange:`pluralize`,onChangeCallback:`updateFinalSetVisibility`,value:3},{getValue:(e,t)=>{let n=xa(e,t),r=n?.NoAD?ua:fa;return n?.timed||n?.tiebreakSet?void 0:r},options:[fa,ua],onChange:`changeAdvantage`,defaultValue:fa,id:`advantage`,whats:[da]},{getValue:(e,t)=>{let n=xa(e,t);return n||console.log({pmf:e}),n?.timed?ca:n?.tiebreakSet?la:da},options:[da,la,ca],finalSetLabel:`${da}${U}`,onChange:`changeWhat`,onChangeCallback:`updateWhatValue`,pluralize:!0,id:`what`},{getValue:(e,t)=>xa(e,t).setTo,options:()=>W.options?.setTo||aa.options.setTo,onChange:`changeCount`,defaultValue:6,whats:[da],prefix:`to `,id:`setTo`},{getValue:(e,t)=>{let n=xa(e,t);return n.tiebreakFormat?.tiebreakTo||n.tiebreakSet?.tiebreakTo},options:e=>{let t=q.setFormat.descriptor,n=W.options?.tiebreakTo||aa.options.tiebreakTo,r=W.options?.tiebreakToExactly||aa.options.tiebreakToExactly;return e&&t===`Exactly`?[...r,...n]:n},onChange:`changeTiebreakTo`,whats:[da,la],id:`tiebreakTo`,defaultValue:7,prefix:`TB to `,tbSet:!0,value:7,tb:!0},{getValue:(e,t)=>xa(e,t).tiebreakAt,options:e=>{let t=q[e?`finalSetFormat`:`setFormat`].setTo;return Yi(t)},onChange:`changeTiebreakAt`,id:`tiebreakAt`,defaultValue:6,whats:[da],prefix:`@`,value:6,tb:!0},{getValue:(e,t)=>{let n=xa(e,t);if(!(!n.tiebreakFormat&&!n.tiebreakSet))return n.tiebreakFormat?.NoAD||n.tiebreakSet?.NoAD?1:2},whats:[da,la],onChange:`changeWinBy`,prefix:`Win by `,options:[1,2],defaultValue:2,tbSet:!0,id:`winBy`,tb:!0},{getValue:(e,t)=>{let n=xa(e,t);return n.timed&&n.minutes||void 0},options:()=>W.options?.minutes||aa.options.minutes,onChange:`changeMinutes`,whats:[ca],suffix:` Minutes`,defaultValue:10,id:`minutes`,timed:!0},{getValue:(e,t)=>{let n=xa(e,t);if(!n?.timed)return;let r=n.based||`G`;return ma()[r]||r},options:()=>[`Games`,`Points`],onChange:`changeBased`,whats:[ca],defaultValue:`Games`,id:`based`,timed:!0},{getValue:(e,t)=>{let n=xa(e,t);return n?.tiebreakSet?.modifier||n?.tiebreakFormat?.modifier||n?.modifier||void 0},options:()=>W.options?.modifiers||aa.options.modifiers,onChange:`changeModifier`,whats:[la,ca],prefix:`@`,defaultValue:`None`,id:`modifier`,tb:!0}];function Ca(e){if(q.setFormat.what!==ca){delete q.setFormat.setTo,delete q.setFormat.tiebreakAt,delete q.setFormat.tiebreakTo,delete q.setFormat.winBy,delete q.setFormat.tiebreakFormat,delete q.setFormat.NoAD,q.setFormat.what=ca,q.setFormat.minutes||(q.setFormat.minutes=10),Ea.changeWhat(new Event(`click`),void 0,ca);let t=K(`what`);t&&(t.innerHTML=`${ca}${e>1?`s`:``}${U}`);let n=K(`minutes`);n&&(n.innerHTML=`${q.setFormat.minutes} Minutes${U}`,n.style.display=``);let r=K(`based`);if(r){let e=q.setFormat.based||`G`;r.innerHTML=`${ma()[e]||e}${U}`,r.style.display=``}}q.setFormat.exactly=e,delete q.setFormat.bestOf}function wa(e){let t=e%2==0?e+1:e;q.setFormat.bestOf=t,delete q.setFormat.exactly;let n=K(`bestOf`);n&&(n.innerHTML=`${t}${U}`),t!==e&&Ea.pluralize(new Event(`click`),void 0,t)}function Ta(){let e=K(`tiebreakTo-1`);if(!e||e.style.display===H)return;let t=q.finalSetFormat.tiebreakTo||7,n=Sa.find(e=>e.id===`tiebreakTo`);if(!n)return;let{prefix:r=``,suffix:i=``}=n,a=(ia(n.options)?n.options(1):n.options).includes(t)?t:7;a!==t&&(q.finalSetFormat.tiebreakTo=a),e.innerHTML=`${r}${a}${i}${U}`}var Ea={changeDescriptor:(e,t,n)=>{q.setFormat.descriptor=n;let r=q.setFormat.bestOf||q.setFormat.exactly||3;n===`Exactly`?Ca(r):wa(r),Ta(),ba()},changeWhat:(e,t,n)=>{let r=n===da,i=K(t?`finalSetTiebreakToggle`:`setTiebreakToggle`);if(i&&(i.style.display=r?``:H),!t&&n!==ca&&q.setFormat.descriptor===`Exactly`){q.setFormat.descriptor=`Best of`;let e=q.setFormat.exactly||3,t=e%2==0?e+1:e;q.setFormat.bestOf=t,delete q.setFormat.exactly;let n=K(`descriptor`);n&&(n.innerHTML=`Best of${U}`);let r=K(`bestOf`);r&&(r.innerHTML=`${t}${U}`)}Sa.forEach(e=>{if(e.whats){let{prefix:r=``,suffix:i=``,pluralize:a}=e,o=e.whats.includes(n),s=K(t?`${e.id}-${t}`:e.id);if(!s)return;if(s.style.display===H&&o){let n=G.bestOf||G.exactly,o=!t&&a&&n>1?`s`:``,c=e.defaultValue;s.innerHTML=`${r}${c}${o}${i}${U}`;let l=c;if(e.id===`modifier`&&c===`None`&&(l=void 0),e.id===`based`){let e=pa[c]||c;l=e===`G`?void 0:e}q[t?`finalSetFormat`:`setFormat`][e.id]=l}s.style.display=o?``:H}}),ba()},changeCount:(e,t,n)=>{let r=t?`finalSetFormat`:`setFormat`;q[r].setTo=n;let i=q[r].tiebreakAt,a=Xi(n,i);if(a!==i){q[r].tiebreakAt=a;let e=K(t?`tiebreakAt-${t}`:`tiebreakAt`);e&&(e.innerHTML=`@${a}${U}`)}ba()},changeTiebreakAt:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].tiebreakAt=n,ba()},updateWhatValue:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].what=n},changeAdvantage:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].advantage=n,ba()},changeTiebreakTo:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].tiebreakTo=n,ba()},changeWinBy:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].winBy=n,ba()},changeMinutes:(e,t,n)=>{q[t?`finalSetFormat`:`setFormat`].minutes=n,ba()},changeBased:(e,t,n)=>{let r=t?`finalSetFormat`:`setFormat`,i=pa[n]||n;if(q[r].based=i===`G`?void 0:i,!t){let e=K(`gameFormat`);e&&(i===`P`?(q.gameFormat=void 0,e.style.display=H):e.style.display=``)}ba()},changeModifier:(e,t,n)=>{let r=t?`finalSetFormat`:`setFormat`;q[r].modifier=n===`None`?void 0:n,ba()},changeMatchRoot:(e,t,n)=>{let r=q.matchRoot||`SET`;if(q.matchRoot=n===`SET`?void 0:n,r!==n){let e=Wi(q.matchRoot),t=q.setFormat.bestOf;if(t&&!e.includes(t)){let n=e[e.length-1]>=t?e.reduce((e,n)=>n<=t?n:e,e[0]):e[e.length-1];q.setFormat.bestOf=n;let r=K(`bestOf`);r&&(r.innerHTML=`${n}${U}`)}}ba()},changeAggregate:()=>{q.aggregate=K(`aggregateOption`)?.checked||void 0,ba()},changeGameFormat:(e,t,n)=>{q.gameFormat=n,ba()},pluralize:(e,t,n)=>{let r=q[t?`finalSetFormat`:`setFormat`].what,i=K(t?`what-${t}`:`what`);i&&(i.innerHTML=`${r}${n>1?`s`:``}${U}`),t||(q.setFormat.descriptor===`Exactly`?(q.setFormat.exactly=n,delete q.setFormat.bestOf):(q.setFormat.bestOf=n,delete q.setFormat.exactly)),ba()},updateFinalSetVisibility:(e,t,n)=>{let r=n>1,i=K(`finalSetOption`),a=K(`finalSetOptionLabel`);i&&a&&(r?(i.style.display=``,a.style.display=``):(i.checked&&(i.checked=!1,i.dispatchEvent(new Event(`change`))),i.style.display=`none`,a.style.display=`none`))}};function Da({existingMatchUpFormat:e=`SET3-S:6/TB7`,callback:n,config:r,modalConfig:i}={}){W=r?{labels:{...aa.labels,...r.labels},options:{...aa.options,...r.options},preDefinedFormats:r.preDefinedFormats||aa.preDefinedFormats}:aa,oa=e,sa={},G=t.matchUpFormatCode.parse(oa),G||=(console.warn(`Invalid matchUpFormat:`,oa),oa=`SET3-S:6/TB7`,t.matchUpFormatCode.parse(oa));let a=Qi(oa,t.matchUpFormatCode.parse);q.matchRoot=a.matchRoot,q.aggregate=a.aggregate,q.gameFormat=a.gameFormat,q.setFormat={...a.setFormat},q.finalSetFormat={...a.finalSetFormat};let o=()=>{let e=K(`matchUpFormatSelector`),t=e?.value&&e.value!==`Custom`?oa:ya();ia(n)&&n(t)},s=[{onClick:()=>{Na(),n?.(``)},label:W.labels?.cancel||`Cancel`,intent:`none`,footer:{className:`button`,style:`background-color: var(--chc-bg-primary); color: var(--chc-text-primary); border: 1px solid var(--chc-border-primary);`},close:!0},{label:W.labels?.select||`Select`,intent:`is-info`,close:!0,onClick:()=>{Na(),o()}}],c=`switch is-rounded is-danger`,l=document.createElement(`div`);l.addEventListener(`click`,e=>{let t=e.target;!t.closest(`.dropdown`)&&!t.classList.contains(`mfcButton`)&&Na()});let u=document.createElement(`div`);u.id=`matchUpFormatString`,u.innerHTML=oa,u.style.fontSize=`1.5em`,u.style.color=`var(--chc-format-code-color)`,u.style.marginBottom=`1em`,sa.matchUpFormatString=u,l.appendChild(u);let d=document.createElement(`div`);d.style.marginBlockEnd=`1em`;let f=W.preDefinedFormats?W.preDefinedFormats.map(e=>({value:e.code,label:e.text,format:e.code})):$i,p={id:`matchUpFormatSelector`,options:[{value:`Custom`,label:W.labels?.custom||`Custom`,selected:!1},...f.filter(e=>e.format).map(e=>({selected:e.format===oa,value:e.format,label:(`label`in e?e.label:e.name)||``}))]},m=document.createElement(`select`);m.id=`matchUpFormatSelector`,m.className=`input`,m.style.width=`100%`,m.style.backgroundColor=`var(--chc-input-bg)`,m.style.color=ta,m.style.border=`1px solid var(--chc-input-border)`;for(let e of p.options){let t=document.createElement(`option`);t.value=e.value||``,t.text=e.label||``,t.style.backgroundColor=`var(--chc-input-bg)`,t.style.color=ta,e.selected&&(t.selected=!0),m.appendChild(t)}sa.matchUpFormatSelector=m;function h(e,t,n){if(!e.getValue)return;let r=e.getValue(G,n),i=K(t);if(i&&r!=null){let{prefix:t=``,suffix:n=``,pluralize:a}=e,o=G.bestOf||G.exactly;i.innerHTML=`${t}${r}${a&&o>1?`s`:``}${n}${U}`,i.style.display=``}else i&&(i.style.display=H)}function g(e,t,n,r,i){let a=K(`matchRoot`);if(a){let e=q.matchRoot||`SET`;a.innerHTML=`${Ui[e]||e}${U}`}let o=K(`aggregateOption`);o&&(o.checked=!!q.aggregate);let s=K(`gameFormat`);s&&(s.innerHTML=`${W.labels?.game||`Game`}: ${_a(q.gameFormat)}${U}`,s.style.display=q.setFormat.based===`P`?H:``);let c=G.bestOf||G.exactly;Ea.updateFinalSetVisibility(null,0,c);let l=G.finalSetFormat;e.style.display=l?``:H,t.style.display=l?``:H,n.checked=!!l;let u=l?.tiebreakSet?.tiebreakTo&&!l?.setTo;i.checked=!!l?.tiebreakFormat,i.style.display=u?H:``;let d=K(`finalSetTiebreakToggle`);d&&(d.style.display=u?H:``);let f=q.setFormat.what,p=!!G.setFormat.tiebreakFormat;r.checked=p;let m=f===da;r.style.display=m?``:H;let g=K(`setTiebreakToggle`);g&&(g.style.display=m?``:H),Sa.forEach(e=>{if(h(e,e.id,!1),e.tb&&f===da){let t=K(e.id);t&&(t.style.display=p?t.style.display:H)}l&&h(e,`${e.id}-1`,!0)})}m.onchange=e=>{if(oa=e.target.value,ba(oa),G=t.matchUpFormatCode.parse(oa),!G){console.warn(`Invalid matchUpFormat selected:`,oa);return}let n=Qi(oa,t.matchUpFormatCode.parse);q.matchRoot=n.matchRoot,q.aggregate=n.aggregate,q.gameFormat=n.gameFormat,q.setFormat={...n.setFormat},q.finalSetFormat={...n.finalSetFormat},g(j,M,k,E,P)},d.appendChild(m),l.appendChild(d);let _=document.createElement(`div`);_.style.display=`flex`,_.style.flexWrap=`wrap`,_.style.gap=`0.5em`,_.style.marginBottom=`0.5em`,_.style.alignItems=`center`;let v=q.matchRoot||`SET`,y=document.createElement(`button`);y.className=`mfcButton`,y.id=`matchRoot`,y.innerHTML=`${Ui[v]||v}${U}`,y.style.transition=ea,y.style.backgroundColor=`inherit`,y.style.border=`none`,y.style.color=`inherit`,y.style.padding=`.3em`,y.style.textAlign=`center`,y.style.textDecoration=`none`,y.style.fontSize=`1em`,y.style.cursor=`pointer`,y.onclick=e=>{Fa(e,(W.options?.matchRoots||aa.options.matchRoots).map(t=>({text:`${Ui[t]||t}`,onClick:()=>{y.innerHTML=`${Ui[t]||t}${U}`,Ea.changeMatchRoot(e,void 0,t)}})))},_.appendChild(y);let b=document.createElement(`input`);b.type=`checkbox`,b.className=`switch is-rounded is-warning`,b.id=`aggregateOption`,b.name=`aggregateOption`,b.checked=!!q.aggregate,b.onchange=()=>{Ea.changeAggregate(new Event(`change`),void 0,void 0)},_.appendChild(b);let x=document.createElement(`label`);x.setAttribute(`for`,`aggregateOption`),x.innerHTML=W.labels?.aggregate||`Aggregate`,x.style.marginRight=`1em`,_.appendChild(x);let S=_a(q.gameFormat),C=document.createElement(`button`);C.className=`mfcButton`,C.id=`gameFormat`,C.innerHTML=`${W.labels?.game||`Game`}: ${S}${U}`,C.style.transition=ea,C.style.backgroundColor=`inherit`,C.style.border=`none`,C.style.color=`inherit`,C.style.padding=`.3em`,C.style.textAlign=`center`,C.style.textDecoration=`none`,C.style.fontSize=`1em`,C.style.cursor=`pointer`,q.setFormat.based===`P`&&(C.style.display=H),C.onclick=e=>{Pa(e,q.gameFormat,e=>{q.gameFormat=e,C.innerHTML=`${W.labels?.game||`Game`}: ${_a(q.gameFormat)}${U}`,ba()})},_.appendChild(C),sa.matchRoot=y,sa.aggregateOption=b,sa.gameFormat=C,l.appendChild(_);let w=document.createElement(`div`);w.style.display=`flex`,w.style.flexWrap=`wrap`,w.style.gap=`0.5em`,w.style.marginBottom=`1em`,Sa.map(e=>{let t=e.getValue?e.getValue(G):void 0,n=ka({...e,value:t});return sa[e.id]=n,n}).forEach(e=>w.appendChild(e)),w.id=`setFormat`,l.appendChild(w);let T=document.createElement(`div`);T.className=`field`,T.style.fontSize=`1em`;let E=document.createElement(`input`);E.className=c,E.name=`setTiebreak`,E.id=`setTiebreak`,E.type=`checkbox`,E.checked=!!G.setFormat.tiebreakFormat,sa.setTiebreak=E,E.onchange=e=>{let t=e.target.checked;Sa.filter(({tb:e})=>e).forEach(e=>{let n=K(e.id);if(n){if(n.style.display===H&&t){let{prefix:t=``,suffix:r=``,pluralize:i,defaultValue:a}=e,o=G.bestOf||G.exactly;n.innerHTML=`${t}${a}${i&&o>1?`s`:``}${r}${U}`}n.style.display=t?``:H}}),ba()},T.appendChild(E);let D=document.createElement(`label`);D.setAttribute(`for`,`setTiebreak`),D.id=`setTiebreakToggle`,D.innerHTML=W.labels?.tiebreakLabel||`Tiebreak`,D.style.marginRight=`1em`,sa.setTiebreakToggle=D,T.appendChild(D);let O=(G.bestOf||G.exactly)>1,k=document.createElement(`input`);k.className=`switch is-rounded is-info`,k.type=`checkbox`,k.name=`finalSetOption`,k.checked=!!G.finalSetFormat,k.id=`finalSetOption`,sa.finalSetOption=k,k.style.display=O?``:`none`,k.onchange=e=>{let t=e.target.checked;if(t){q.finalSetFormat={...q.setFormat,descriptor:`Final set`};let e=q.setFormat.what,t=q.setFormat.bestOf||q.setFormat.exactly||3,n=K(`what-1`);n&&(n.innerHTML=`${e}${t>1?`s`:``}${U}`),Sa.forEach(t=>{let n=K(`${t.id}-1`);if(n)if(!t.whats||t.whats.includes(e)){let e=q.finalSetFormat[t.id];if(e!==void 0){let{prefix:r=``,suffix:i=``}=t;n.innerHTML=`${r}${e}${i}${U}`}n.style.display=``}else n.style.display=H});let r=K(`finalSetTiebreakToggle`);if(r&&(r.style.display=e===da?``:H),e===da){let e=K(`setTiebreak`),t=K(`finalSetTiebreak`);e&&t&&(t.checked=e.checked)}}j.style.display=t?``:H,M.style.display=t?``:H,ba()},T.appendChild(k);let A=document.createElement(`label`);A.setAttribute(`for`,`finalSetOption`),A.innerHTML=W.labels?.finalSetLabel||`Final set`,A.style.display=O?``:`none`,sa.finalSetOptionLabel=A,T.appendChild(A),l.appendChild(T);let j=document.createElement(`div`);j.style.display=G.finalSetFormat?`flex`:H,j.style.flexWrap=`wrap`,j.style.gap=`0.5em`,j.style.marginBottom=`1em`,j.id=`finalSetFormat`,sa.finalSetFormatDiv=j,[{label:`<div style='font-weight: bold'>${W.labels?.finalSetLabel||`Final set`}</div>`,options:[],finalSet:!0}].concat(Sa.map(e=>{let t=e.getValue?e.getValue(G,!0):void 0;return{...e,value:t}})).filter(e=>e.finalSet!==!1).map(e=>{let t=ka({...e,index:1});return e.id&&(sa[`${e.id}-1`]=t),t}).forEach(e=>j.appendChild(e)),l.appendChild(j);let M=document.createElement(`div`);M.id=`finalSetConfig`,sa.finalSetConfigDiv=M,M.style.display=G.finalSetFormat?``:H,M.className=`field`,M.style.fontSize=`1em`;let N=G.finalSetFormat?.tiebreakSet?.tiebreakTo&&!G.finalSetFormat?.setTo,P=document.createElement(`input`);P.className=c,P.name=`finalSetTiebreak`,P.id=`finalSetTiebreak`,sa.finalSetTiebreak=P,P.type=`checkbox`,P.checked=G.finalSetFormat?!!G.finalSetFormat.tiebreakFormat:!!G.setFormat.tiebreakFormat,P.style.display=N?H:``,M.onchange=e=>{let t=e.target.checked;Sa.filter(({tb:e})=>e).forEach(e=>{let n=K(`${e.id}-1`);if(n){if(n.style.display===H&&t){let{prefix:t=``,suffix:r=``,pluralize:i,defaultValue:a}=e,o=G.bestOf||G.exactly;n.innerHTML=`${t}${a}${i&&o>1?`s`:``}${r}${U}`}n.style.display=t?``:H}}),ba()},M.appendChild(P);let I=document.createElement(`label`);I.setAttribute(`for`,`finalSetTiebreak`),I.id=`finalSetTiebreakToggle`,I.innerHTML=W.labels?.tiebreakLabel||`Tiebreak`,I.style.marginRight=`1em`,I.style.display=N?H:``,sa.finalSetTiebreakToggle=I,M.appendChild(I),l.appendChild(M);let L={content:{padding:`1.5`},maxWidth:480,fontSize:`14px`,style:{backgroundColor:`var(--chc-bg-secondary)`,borderRadius:`8px`,boxShadow:`0 8px 16px rgba(0, 102, 204, 0.2)`}},R=i?.fontSize||i?.style?.fontSize||L.fontSize,z={...L,...i,fontSize:R,style:{...L.style,...r?.style||{},...i?.style||{}}},B=F.open({title:W.labels?.title||`Score format`,content:l,buttons:s,config:z});return setTimeout(()=>{if(G.finalSetFormat?.tiebreakSet?.tiebreakTo&&!G.finalSetFormat?.setTo){let e=K(`what-1`);e&&(e.innerHTML=`${la}${U}`),Ea.changeWhat(new Event(`click`),1,la)}let e=document.querySelector(`.modal.is-active`);if(e){let t=new MutationObserver(n=>{n.forEach(n=>{n.removedNodes.forEach(n=>{n===e&&(Na(),t.disconnect())})})});t.observe(document.body,{childList:!0})}},0),B}function Oa({index:e,finalSetLabel:t,label:n,prefix:r=``,suffix:i=``,value:a,pluralize:o}){let s=q.setFormat.bestOf||q.setFormat.exactly||1;return n||e&&t||`${r}${a}${!e&&o&&s>1?`s`:``}${i}${U}`}function ka(e){let{id:t,initiallyHidden:n,index:r,value:i}=e,a=document.createElement(`button`);return a.className=`mfcButton`,a.id=r?`${t}-${r}`:t,a.innerHTML=Oa(e),a.onclick=t=>Aa({e:t,button:a,...e}),a.style.display=i||e.label?``:H,n&&(a.style.display=H),a.style.transition=ea,a.style.backgroundColor=`inherit`,a.style.border=`none`,a.style.color=`inherit`,a.style.padding=`.3em`,a.style.textAlign=`center`,a.style.textDecoration=`none`,a.style.fontSize=`1em`,a.style.cursor=`pointer`,a}function Aa(e){let{e:t,id:n,button:r,pluralize:i,options:a,onChange:o,onChangeCallback:s,index:c,prefix:l=``,suffix:u=``}=e,d=q.setFormat.bestOf||q.setFormat.exactly||1,f=!c&&i&&d>1?`s`:``;Fa(t,(ia(a)?a(c):a).map(e=>({text:`${e}${f}`,onClick:()=>{r.innerHTML=`${l}${e}${f}${u}${U}`,q[c?`finalSetFormat`:`setFormat`][n]=e,o&&ia(Ea[o])&&Ea[o](t,c,e),s&&ia(Ea[s])&&Ea[s](t,c,e),ba()}})))}var ja=null,Ma=null;function Na(){ja&&document.body.contains(ja)&&ja.remove(),Ma&&=(document.removeEventListener(`click`,Ma),null),ja=null}function Pa(e,t,n){Na();let r=document.createElement(`div`);r.className=`dropdown is-active`,r.style.position=`absolute`,r.style.zIndex=`10000`;let i=document.createElement(`div`);i.className=`dropdown-menu`,i.style.backgroundColor=na,i.style.border=`1px solid var(--chc-border-secondary)`,i.style.borderRadius=`4px`,i.style.boxShadow=`0 2px 8px rgba(0,0,0,0.15)`,i.style.padding=`0.25em 0`,i.style.minWidth=`180px`;let a=`none`,o=`none`;t?.type===`TRADITIONAL`?a=`TN`:t?.type===`CONSECUTIVE`&&(a=`${t.count}C`),t?.deuceAfter&&(o=`${t.deuceAfter}D`);function s(e,t){if(e===`none`&&t===`none`)return;let n={};return e===`TN`?n.type=`TRADITIONAL`:/^\d+C$/.test(e)?(n.type=`CONSECUTIVE`,n.count=Number(e.slice(0,-1))):n.type=`TRADITIONAL`,t!==`none`&&(n.deuceAfter=Number(t.slice(0,-1))),n}function c(){let e=r.querySelector(`input[name="gameType"]:checked`),t=r.querySelector(`input[name="deuceRule"]:checked`);n(s(e?.value||`none`,t?.value||`none`))}let l=`padding: 0.3em 1em; font-weight: bold; font-size: 0.85rem; color: var(--chc-text-muted); text-transform: uppercase; letter-spacing: 0.5px;`,u=`border-top: 1px solid #eee; margin: 0.25em 0;`,d=document.createElement(`div`);d.textContent=W.labels?.none||`None`,d.style.cssText=`padding: 0.4em 1em; cursor: pointer; background-color: var(--chc-dropdown-bg); color: var(--chc-text-primary); font-size: 1rem;`,d.onmouseenter=()=>{d.style.backgroundColor=ra},d.onmouseleave=()=>{d.style.backgroundColor=na},d.onclick=e=>{e.preventDefault(),e.stopPropagation(),n(void 0),Na()},i.appendChild(d);function f(e,t,n,r){let i=document.createElement(`label`);i.style.cssText=`display: flex; align-items: center; padding: 0.3em 1em; cursor: pointer; gap: 0.4em; font-size: 1rem; color: var(--chc-text-primary);`,i.onmouseenter=()=>{i.style.backgroundColor=ra},i.onmouseleave=()=>{i.style.backgroundColor=na};let a=document.createElement(`input`);a.type=`radio`,a.name=e,a.value=t,a.checked=r,a.style.margin=`0`,a.onchange=()=>c();let o=document.createElement(`span`);return o.textContent=n,i.appendChild(a),i.appendChild(o),i}let p=document.createElement(`div`);p.style.cssText=u,i.appendChild(p);let m=document.createElement(`div`);m.style.cssText=l,m.textContent=W.labels?.gameType||`Game type`,i.appendChild(m);let h=ha(),g=[{value:`none`,label:W.labels?.none||`None`},{value:`TN`,label:h.TN},{value:`2C`,label:h[`2C`]},{value:`3C`,label:h[`3C`]},{value:`4C`,label:h[`4C`]}];for(let e of g)i.appendChild(f(`gameType`,e.value,e.label,a===e.value));let _=document.createElement(`div`);_.style.cssText=u,i.appendChild(_);let v=document.createElement(`div`);v.style.cssText=l,v.textContent=W.labels?.deuceRule||`Deuce rule`,i.appendChild(v);let y=ga(),b=[{value:`none`,label:W.labels?.none||`None`},{value:`1D`,label:y[`1D`]},{value:`3D`,label:y[`3D`]}];for(let e of b)i.appendChild(f(`deuceRule`,e.value,e.label,o===e.value));r.appendChild(i);let x=e.target.getBoundingClientRect();r.style.left=`${x.left}px`,r.style.top=`${x.bottom}px`,document.body.appendChild(r),ja=r,setTimeout(()=>{Ma=e=>{r.contains(e.target)||Na()},document.addEventListener(`click`,Ma)},100)}function Fa(e,t){Na();let n=document.createElement(`div`);n.className=`dropdown is-active`,n.style.position=`absolute`,n.style.zIndex=`10000`;let r=document.createElement(`div`);r.className=`dropdown-menu`,r.style.backgroundColor=na,r.style.border=`1px solid var(--chc-border-secondary)`,r.style.borderRadius=`4px`,r.style.boxShadow=`0 2px 8px rgba(0,0,0,0.15)`;let i=()=>{Na()};t.forEach(e=>{let t=document.createElement(`div`);t.style.padding=`0.5em 1em`,t.style.cursor=`pointer`,t.style.backgroundColor=na,t.style.color=ta,t.style.fontSize=`1rem`,t.style.lineHeight=`1.5`,t.textContent=e.text,t.onclick=t=>{t.preventDefault(),t.stopPropagation(),i(),e.onClick()},t.onmouseenter=()=>{t.style.backgroundColor=ra,t.style.color=ta},t.onmouseleave=()=>{t.style.backgroundColor=na,t.style.color=ta},r.appendChild(t)}),n.appendChild(r);let a=e.target.getBoundingClientRect();n.style.left=`${a.left}px`,n.style.top=`${a.bottom}px`,document.body.appendChild(n),ja=n,setTimeout(()=>{Ma=e=>{n.contains(e.target)||i()},document.addEventListener(`click`,Ma)},100)}var Ia=`Simple Under`,La=`Simple Over`;function Ra(e){if(!e)return null;let t=e.trim().toUpperCase();if(t===`OPEN`)return{type:`open`};let n=t.match(/^C(\d{1,2})-(\d{1,2})$/);if(n){let[,e,t]=n;return{type:`combined`,ageMin:Number.parseInt(e,10),ageMax:Number.parseInt(t,10),isCombined:!0}}if(t.includes(`-`)){let e=Va(t);if(e)return e}return Ha(t)}function za(e){if(!e.startsWith(`U`)&&!e.endsWith(`U`))return;let t=e.match(/^U?(\d{1,2})U?$/);if(t)return{age:Number.parseInt(t[1],10),position:e.startsWith(`U`)?`pre`:`post`}}function Ba(e){if(!e.startsWith(`O`)&&!e.endsWith(`O`))return;let t=e.match(/^O?(\d{1,2})O?$/);if(t)return{age:Number.parseInt(t[1],10),position:e.startsWith(`O`)?`pre`:`post`}}function Va(e){let t=e.split(`-`);if(t.length!==2)return null;let[n,r]=t,i,a,o,s,c,l=za(n),u=Ba(n);l?(c=`max-min`,a=l.position===`pre`?l.age-1:l.age,o=l.position):u&&(c=`min-max`,i=u.position===`pre`?u.age+1:u.age,s=u.position);let d=za(r),f=Ba(r);return d?(a=d.position===`pre`?d.age-1:d.age,o=d.position):f&&(i=f.position===`pre`?f.age+1:f.age,s=f.position),i!==void 0||a!==void 0?{type:`range`,ageMin:i,ageMax:a,uPosition:o,oPosition:s,rangeOrder:c}:null}function Ha(e){let t=e.match(/^U(\d{1,2})$|^(\d{1,2})U$/);if(t)return{type:`under`,ageValue:Number.parseInt(t[1]||t[2],10),uPosition:t[1]?`pre`:`post`};let n=e.match(/^O(\d{1,2})$|^(\d{1,2})O$/);return n?{type:`over`,ageValue:Number.parseInt(n[1]||n[2],10),oPosition:n[1]?`pre`:`post`}:null}function Ua(e){let{type:t,ageValue:n,ageMin:r,ageMax:i,uPosition:a=`post`,oPosition:o=`post`,rangeOrder:s=`min-max`}=e;if(t===`open`)return`OPEN`;if(t===`combined`&&r!==void 0&&i!==void 0)return`C${r}-${i}`;if(t===`under`&&n!==void 0)return a===`pre`?`U${n}`:`${n}U`;if(t===`over`&&n!==void 0)return o===`pre`?`O${n}`:`${n}O`;if(t===`range`&&(r!==void 0||i!==void 0)){let e=i!==void 0&&a?(()=>{let e=a===`pre`?i+1:i;return a===`pre`?`U${e}`:`${e}U`})():null,t=r!==void 0&&o?(()=>{let e=o===`pre`?r-1:r;return o===`pre`?`O${e}`:`${e}O`})():null;return s===`max-min`?[e,t].filter(Boolean).join(`-`):[t,e].filter(Boolean).join(`-`)}return``}function Wa(){return[8,10,12,14,16,18,21,30,35,40,45,50,55,60,65,70,75,80,85,90]}function Ga(){return[Ia,La,`Range`,`Combined`,`Open`]}function Ka(e){switch(e){case Ia:return`under`;case La:return`over`;case`Range`:return`range`;case`Combined`:return`combined`;case`Open`:return`open`;default:return`open`}}function qa(e){switch(e){case`under`:return Ia;case`over`:return La;case`range`:return`Range`;case`combined`:return`Combined`;case`open`:return`Open`;default:return`Open`}}function Ja(){return[{code:`OPEN`,text:`Open (No age limit)`},{code:`8U`,text:`8 and Under`},{code:`10U`,text:`10 and Under`},{code:`12U`,text:`12 and Under`},{code:`14U`,text:`14 and Under`},{code:`16U`,text:`16 and Under`},{code:`18U`,text:`18 and Under`},{code:`21U`,text:`21 and Under`},{code:`30O`,text:`30 and Over`},{code:`35O`,text:`35 and Over`},{code:`40O`,text:`40 and Over`},{code:`45O`,text:`45 and Over`},{code:`50O`,text:`50 and Over`},{code:`55O`,text:`55 and Over`},{code:`60O`,text:`60 and Over`},{code:`65O`,text:`65 and Over`},{code:`70O`,text:`70 and Over`},{code:`75O`,text:`75 and Over`},{code:`80O`,text:`80 and Over`}]}var Ya=`▾`,Xa=`1px solid var(--chc-border-secondary)`,Za=`var(--chc-text-primary)`,Qa=`var(--chc-dropdown-bg)`;function $a(e){return typeof e==`function`}var eo={labels:{title:`Age Category`,consideredDateLabel:`Considered Date`,typeLabel:`Category Type`,ageLabel:`Age`,standardCodesLabel:`Standard Categories`},options:{ages:Wa(),categoryTypes:Ga()},defaultConsideredDate:new Date().toISOString().split(`T`)[0]},to=eo,no,ro,J={type:`open`},io={};function ao(){let e=Ua(J);if(!e||e===`OPEN`){io={};return}try{let n=t.eventGovernor.getCategoryAgeDetails({category:{ageCategoryCode:e},consideredDate:ro});if(n.error){io={errors:[typeof n.error==`string`?n.error:n.error.message||`Invalid category or date`]};return}io={ageMin:n.ageMin,ageMax:n.ageMax,ageMinDate:n.ageMinDate,ageMaxDate:n.ageMaxDate,errors:n.errors}}catch(e){io={errors:[`Failed to calculate age details: ${e instanceof Error?e.message:`Unknown error`}`]}}}function oo(){let e=Ua(J);no=e;let t=document.getElementById(`ageCategoryCodeString`);t&&(t.innerHTML=e||`Invalid`),ao(),so()}function so(){let e=document.getElementById(`calculatedDetailsPanel`);if(!e)return;if(J.type===`open`||!no){e.style.display=`none`;return}e.style.display=``;let{ageMin:t,ageMax:n,ageMinDate:r,ageMaxDate:i,errors:a}=io,o=`<div style="margin-top: 1em; padding: 0.75em; background: var(--chc-bg-secondary); border-radius: 4px; color: var(--chc-text-primary);">`;a&&a.length>0&&(o+=`<div style="color: var(--chc-status-error); margin-bottom: 0.5em;"><strong style="color: var(--chc-text-primary);">Errors:</strong><ul style="margin: 0; padding-left: 1.5em; color: var(--chc-text-primary);">`,a.forEach(e=>{o+=`<li style="color: var(--chc-status-error);">${e}</li>`}),o+=`</ul></div>`),(t!==void 0||n!==void 0)&&(o+=`<div style="margin-bottom: 0.5em; color: var(--chc-text-primary);"><strong style="color: var(--chc-text-primary);">Age Range:</strong> `,t!==void 0&&n!==void 0?o+=`${t} - ${n}`:t===void 0?n!==void 0&&(o+=`${n} and under`):o+=`${t} and over`,o+=`</div>`),r&&(o+=`<div style="margin-bottom: 0.5em; color: var(--chc-text-primary);"><strong style="color: var(--chc-text-primary);">Min Birth Date:</strong> ${r}</div>`),i&&(o+=`<div style="margin-bottom: 0.5em; color: var(--chc-text-primary);"><strong style="color: var(--chc-text-primary);">Max Birth Date:</strong> ${i}</div>`),o+=`</div>`,e.innerHTML=o}function co(){let{type:e}=J,t=document.getElementById(`ageValue`),n=e===`under`||e===`over`;t&&(t.style.display=n?``:`none`);let r=document.getElementById(`positionToggle`),i=e===`under`||e===`over`;r&&(r.style.display=i?``:`none`);let a=document.getElementById(`ageMin`),o=e===`range`||e===`combined`;a&&(a.style.display=o?``:`none`);let s=document.getElementById(`ageMax`),c=e===`range`||e===`combined`;s&&(s.style.display=c?``:`none`);let l=document.getElementById(`combinedLabel`);l&&(l.style.display=e===`combined`?``:`none`)}function lo(e){let{id:t,label:n,onClick:r,initiallyHidden:i}=e,a=document.createElement(`button`);return a.className=`accButton`,a.id=t,a.innerHTML=n,r&&(a.onclick=r),i&&(a.style.display=`none`),a.style.transition=`all .2s ease-in-out`,a.style.backgroundColor=`inherit`,a.style.border=`none`,a.style.color=Za,a.style.padding=`.3em`,a.style.textAlign=`center`,a.style.textDecoration=`none`,a.style.fontSize=`1em`,a.style.cursor=`pointer`,a}var uo=null,fo=null;function po(){uo&&document.body.contains(uo)&&uo.remove(),fo&&=(document.removeEventListener(`click`,fo),null),uo=null}function mo(e,t){po();let n=document.createElement(`div`);n.className=`dropdown is-active`,n.style.position=`absolute`,n.style.zIndex=`10000`;let r=document.createElement(`div`);r.className=`dropdown-menu`,r.style.backgroundColor=Qa,r.style.border=Xa,r.style.borderRadius=`4px`,r.style.boxShadow=`0 2px 8px rgba(0,0,0,0.15)`;let i=()=>{po()};t.forEach(e=>{let t=document.createElement(`div`);t.style.padding=`0.5em 1em`,t.style.cursor=`pointer`,t.style.backgroundColor=Qa,t.style.color=Za,t.style.fontSize=`1rem`,t.style.lineHeight=`1.5`,t.textContent=e.text,t.onclick=t=>{t.preventDefault(),t.stopPropagation(),i(),setTimeout(()=>{e.onClick()},0)},t.onmouseenter=()=>{t.style.backgroundColor=`var(--chc-hover-bg)`},t.onmouseleave=()=>{t.style.backgroundColor=Qa},r.appendChild(t)}),n.appendChild(r);let a=e.target.getBoundingClientRect();n.style.left=`${a.left}px`,n.style.top=`${a.bottom}px`,document.body.appendChild(n),uo=n,setTimeout(()=>{fo=e=>{n.contains(e.target)||i()},document.addEventListener(`click`,fo)},100)}function ho({existingAgeCategoryCode:e,existingCategory:t={},editorConfig:n,consideredDate:r,callback:i,config:a,modalConfig:o}={}){let s=n||a;to=s?{labels:{...eo.labels,...s.labels},options:{...eo.options,...s.options},preDefinedCodes:s.preDefinedCodes||Ja(),defaultConsideredDate:s.defaultConsideredDate||eo.defaultConsideredDate}:{...eo,preDefinedCodes:Ja()},ro=r||to.defaultConsideredDate||new Date().toISOString().split(`T`)[0];let c=e||t.ageCategoryCode||`OPEN`;no=c;let l=Ra(c);l?Object.assign(J,l):Object.assign(J,{type:`open`});let u=()=>{let e=Ua(J);$a(i)&&i({...t,ageCategoryCode:e})},d=[{onClick:()=>{po(),i?.({...t,ageCategoryCode:``})},label:`Cancel`,intent:`none`,footer:{className:`button`,style:`background-color: var(--chc-bg-primary); color: var(--chc-text-primary); border: 1px solid var(--chc-border-primary);`},close:!0},{label:`Select`,intent:`is-info`,close:!0,onClick:()=>{po(),u()}}],f=document.createElement(`div`);f.addEventListener(`click`,e=>{let t=e.target;!t.closest(`.dropdown`)&&!t.classList.contains(`accButton`)&&po()});let p=document.createElement(`div`);p.id=`ageCategoryCodeString`,p.innerHTML=no,p.style.fontSize=`1.5em`,p.style.color=`var(--chc-format-code-color)`,p.style.marginBottom=`1em`,p.style.fontWeight=`bold`,f.appendChild(p);let m=document.createElement(`div`);m.style.marginBottom=`1em`,mi(m,[{label:to.labels?.standardCodesLabel||`Standard Categories`,field:`standardCategory`,id:`ageCategorySelector`,options:[{label:`Custom`,value:`Custom`,selected:!to.preDefinedCodes?.some(e=>e.code===no)},...(to.preDefinedCodes||[]).map(e=>({selected:e.code===no,value:e.code,label:e.text}))],onChange:e=>{let t=e.target.value;if(t===`Custom`)return;no=t;let n=Ra(t);n&&(Object.assign(J,n),co(),k(),oo())}},{label:to.labels?.consideredDateLabel||`Considered Date`,field:`consideredDate`,id:`consideredDateInput`,value:ro,date:!0,onChange:e=>{ro=e.target.value,oo()}}]),f.appendChild(m);let h=lo({id:`categoryType`,label:`${qa(J.type)}${Ya}`,onClick:e=>{mo(e,(to.options?.categoryTypes||Ga()).map(e=>({text:e,onClick:()=>{let t=Ka(e);J.type=t,J.ageValue=void 0,J.ageMin=void 0,J.ageMax=void 0,t===`under`||t===`over`?(J.ageValue=18,J.uPosition=`post`,J.oPosition=`post`):(t===`range`||t===`combined`)&&(J.ageMin=10,J.ageMax=18,J.uPosition=`post`,J.oPosition=`post`,J.rangeOrder=`min-max`),t===`combined`?J.isCombined=!0:J.isCombined=!1,h.innerHTML=`${e}${Ya}`,co(),k(),oo()}})))}}),g=document.createElement(`div`);g.style.display=`flex`,g.style.flexWrap=`wrap`,g.style.gap=`0.5em`,g.style.marginBottom=`1em`,g.appendChild(h);let _=document.createElement(`div`);_.id=`ageValue`,_.style.display=J.type!==`under`&&J.type!==`over`?`none`:``;let v=document.createElement(`input`);v.type=`number`,v.min=`1`,v.max=`120`,v.value=String(J.ageValue||18),v.style.width=`80px`,v.style.padding=`0.3em`,v.style.border=Xa,v.style.borderRadius=`4px`,v.oninput=()=>{let e=Number.parseInt(v.value,10);!Number.isNaN(e)&&e>=1&&e<=120&&(J.ageValue=e,oo())},_.appendChild(v),g.appendChild(_);let y=lo({id:`positionToggle`,label:O(),onClick:()=>{J.type===`under`?J.uPosition=J.uPosition===`pre`?`post`:`pre`:J.type===`over`&&(J.oPosition=J.oPosition===`pre`?`post`:`pre`),y.innerHTML=O(),oo()},initiallyHidden:J.type!==`under`&&J.type!==`over`});g.appendChild(y);let b=document.createElement(`div`);b.id=`ageMin`,b.style.display=J.type!==`range`&&J.type!==`combined`?`none`:``,b.style.display=`flex`,b.style.alignItems=`center`,b.style.gap=`0.5em`;let x=document.createElement(`span`);x.textContent=`Min:`,x.style.color=Za;let S=document.createElement(`input`);S.type=`number`,S.min=`1`,S.max=`120`,S.value=String(J.ageMin||10),S.style.width=`80px`,S.style.padding=`0.3em`,S.style.border=Xa,S.style.borderRadius=`4px`,S.oninput=()=>{let e=Number.parseInt(S.value,10);!Number.isNaN(e)&&e>=1&&e<=120&&(J.ageMin=e,J.ageMax!==void 0&&J.ageMax<e&&(J.ageMax=e,T.value=String(e)),oo())},b.appendChild(x),b.appendChild(S),g.appendChild(b),J.type!==`range`&&J.type!==`combined`&&(b.style.display=`none`);let C=document.createElement(`div`);C.id=`ageMax`,C.style.display=J.type!==`range`&&J.type!==`combined`?`none`:``,C.style.display=`flex`,C.style.alignItems=`center`,C.style.gap=`0.5em`;let w=document.createElement(`span`);w.textContent=`Max:`,w.style.color=Za;let T=document.createElement(`input`);T.type=`number`,T.min=`1`,T.max=`120`,T.value=String(J.ageMax||18),T.style.width=`80px`,T.style.padding=`0.3em`,T.style.border=Xa,T.style.borderRadius=`4px`,T.oninput=()=>{let e=Number.parseInt(T.value,10);!Number.isNaN(e)&&e>=1&&e<=120&&(J.ageMax=e,J.ageMin!==void 0&&J.ageMin>e&&(J.ageMin=e,S.value=String(e)),oo())},C.appendChild(w),C.appendChild(T),g.appendChild(C),J.type!==`range`&&J.type!==`combined`&&(C.style.display=`none`);let E=document.createElement(`div`);E.id=`combinedLabel`,E.innerHTML=`<em style="color: var(--chc-text-muted);">Combined age range</em>`,E.style.display=J.type===`combined`?``:`none`,E.style.padding=`0.3em`,g.appendChild(E),f.appendChild(g);let D=document.createElement(`div`);D.id=`calculatedDetailsPanel`,f.appendChild(D);function O(){if(J.type===`under`){let e=J.ageValue||18;return J.uPosition===`pre`?`U${e}`:`${e}U`}else if(J.type===`over`){let e=J.ageValue||10;return J.oPosition===`pre`?`O${e}`:`${e}O`}return``}function k(){let e=document.getElementById(`categoryType`);e&&(e.innerHTML=`${qa(J.type)}${Ya}`),J.ageValue!==void 0&&(v.value=String(J.ageValue));let t=document.getElementById(`positionToggle`);t&&(t.innerHTML=O()),J.ageMin!==void 0&&(S.value=String(J.ageMin)),J.ageMax!==void 0&&(T.value=String(J.ageMax))}let A={content:{padding:`1.5`},maxWidth:480,fontSize:`14px`,style:{backgroundColor:`var(--chc-bg-secondary)`,borderRadius:`8px`,boxShadow:`0 8px 16px rgba(0, 102, 204, 0.2)`}},j=o?.fontSize||o?.style?.fontSize||A.fontSize,M={...A,...o,fontSize:j,style:{...A.style,...a?.style||{},...o?.style}},N=F.open({title:to.labels?.title||`Age Category`,content:f,buttons:d,config:M});return setTimeout(()=>{co(),k(),oo()},0),setTimeout(()=>{let e=document.querySelector(`.modal.is-active`);if(e){let t=new MutationObserver(n=>{n.forEach(n=>{n.removedNodes.forEach(n=>{n===e&&(po(),t.disconnect())})})});t.observe(document.body,{childList:!0})}},0),N}var go={labels:{title:`Category`,categoryNameLabel:`Category Name`,typeLabel:`Category Type`,ageCategoryCodeLabel:`Age Category Code`,ratingTypeLabel:`Rating Type`,ratingMinLabel:`Minimum Rating`,ratingMaxLabel:`Maximum Rating`,ballTypeLabel:`Ball Type`,notesLabel:`Notes`},options:{types:[`AGE`,`RATING`,`BOTH`],ratingTypes:[`WTN`,`UTR`,`TRN`,`NTRP`,`DUPR`],ballTypes:[`HIGH_ALTITUDE`,`STAGE1GREEN`,`STAGE2ORANGE`,`STAGE3RED`,`T2STANDARD_PRESSURELESS`,`T2STANDARD_PRESSURISED`,`TYPE1FAST`,`TYPE3SLOW`]},defaultConsideredDate:new Date().toISOString().split(`T`)[0]};function _o(e){return typeof e==`function`}function vo(e){let{existingCategory:n,editorConfig:r,callback:i}=e,a={labels:{...go.labels,...r?.labels},options:{...go.options,...r?.options},defaultConsideredDate:r?.defaultConsideredDate||go.defaultConsideredDate,modalConfig:r?.modalConfig||{}},o={categoryName:n?.categoryName||``,type:n?.type,ageCategoryCode:n?.ageCategoryCode,ratingType:n?.ratingType,ratingMin:n?.ratingMin,ratingMax:n?.ratingMax,ballType:n?.ballType,notes:n?.notes||``,ageMin:n?.ageMin,ageMax:n?.ageMax,ageMinDate:n?.ageMinDate,ageMaxDate:n?.ageMaxDate},s=a.defaultConsideredDate,c=document.createElement(`div`);c.style.display=`flex`,c.style.flexDirection=`column`,c.style.gap=`1em`,c.style.minWidth=`400px`;let l=()=>{let e=c.querySelector(`#ageDetailsPanel`);if(e){if(!o.ageCategoryCode||o.ageCategoryCode===`OPEN`){e.style.display=`none`;return}try{let n=t.eventGovernor.getCategoryAgeDetails({category:{ageCategoryCode:o.ageCategoryCode},consideredDate:s});if(n.error){e.style.display=`block`,e.innerHTML=`
|
|
83
83
|
<div style="padding: 0.75em; background-color: var(--chc-bg-secondary); border-left: 4px solid var(--chc-status-error); border-radius: 4px; color: var(--chc-text-primary);">
|
|
84
84
|
<strong style="color: var(--chc-text-primary);">Error:</strong> ${typeof n.error==`string`?n.error:n.error.message||`Invalid category`}
|
|
85
85
|
</div>
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
<div style="padding: 0.75em; background-color: var(--chc-bg-secondary); border-left: 4px solid var(--chc-status-error); border-radius: 4px; color: var(--chc-text-primary);">
|
|
94
94
|
<strong style="color: var(--chc-text-primary);">Error:</strong> ${t?.message||`Failed to calculate age details`}
|
|
95
95
|
</div>
|
|
96
|
-
`}}},u=document.createElement(`div`),d=e=>{if((e.categoryName?.value||``).trim().length<5)return!1;let t=e.type?.value;if(!t)return!1;let n=t===`AGE`||t===`BOTH`,r=t===`RATING`||t===`BOTH`;return n&&!r?!!o.ageCategoryCode:!n&&r?!!o.ratingType:n&&r?!!(o.ageCategoryCode||o.ratingType):!1},f=e=>{let t=document.getElementById(`categoryOkButton`);t&&(t.disabled=!d(e))},p=
|
|
96
|
+
`}}},u=document.createElement(`div`),d=e=>{if((e.categoryName?.value||``).trim().length<5)return!1;let t=e.type?.value;if(!t)return!1;let n=t===`AGE`||t===`BOTH`,r=t===`RATING`||t===`BOTH`;return n&&!r?!!o.ageCategoryCode:!n&&r?!!o.ratingType:n&&r?!!(o.ageCategoryCode||o.ratingType):!1},f=e=>{let t=document.getElementById(`categoryOkButton`);t&&(t.disabled=!d(e))},p=mi(u,[{label:a.labels?.categoryNameLabel||`Category Name`,validator:((e,t)=>n=>n?.trim().length>=e&&(!t||n?.trim().length<=t))(5),error:`Minimum 5 characters`,field:`categoryName`,placeholder:`e.g., Boys U18, Open Singles, 3.5-4.0`,value:o.categoryName,focus:!0,onChange:e=>{o.categoryName=e.target.value}},{label:a.labels?.typeLabel||`Category Type`,field:`type`,options:[{label:`Select type...`,value:``,selected:!o.type},...(a.options?.types||[]).map(e=>({label:e,value:e,selected:e===o.type}))],onChange:e=>{o.type=e.target.value,S()}},{label:a.labels?.ballTypeLabel||`Ball Type`,field:`ballType`,options:[{label:`None`,value:``,selected:!o.ballType},...(a.options?.ballTypes||[]).map(e=>({label:e,value:e,selected:e===o.ballType}))],onChange:e=>{o.ballType=e.target.value||void 0}},{label:a.labels?.notesLabel||`Notes`,field:`notes`,placeholder:`Additional information...`,value:o.notes,onChange:e=>{o.notes=e.target.value}}],[{control:`categoryName`,onInput:({inputs:e})=>{f(e)}},{control:`type`,onInput:({inputs:e})=>{f(e)}},{control:`ballType`,onInput:({inputs:e})=>{f(e)}},{control:`notes`,onInput:({inputs:e})=>{f(e)}}]);c.appendChild(u);let m=document.createElement(`div`);m.id=`ageCategorySection`,m.style.display=o.type===`AGE`||o.type===`BOTH`?`block`:`none`;let h=document.createElement(`label`);h.textContent=a.labels?.ageCategoryCodeLabel||`Age Category Code`,h.style.display=`block`,h.style.marginBottom=`0.5em`,h.style.fontWeight=`bold`,h.style.fontSize=`0.9em`,h.style.color=`var(--chc-text-primary)`,m.appendChild(h);let g=document.createElement(`div`);g.style.display=`flex`,g.style.alignItems=`center`,g.style.gap=`0.5em`;let _=document.createElement(`div`);_.id=`ageCategoryValue`,_.style.padding=`0.5em`,_.style.border=`1px solid var(--chc-input-border)`,_.style.borderRadius=`4px`,_.style.backgroundColor=`var(--chc-bg-secondary)`,_.style.flex=`1`,_.style.minHeight=`2.5em`,_.style.display=`flex`,_.style.alignItems=`center`,_.style.color=`var(--chc-text-primary)`,_.textContent=o.ageCategoryCode||`Not set`,g.appendChild(_);let v=document.createElement(`button`);v.className=`button is-info is-small`,v.textContent=o.ageCategoryCode?`Edit`:`Set`,v.onclick=()=>{ho({existingAgeCategoryCode:o.ageCategoryCode,editorConfig:{defaultConsideredDate:s},callback:e=>{o.ageCategoryCode=e.ageCategoryCode,_.textContent=e.ageCategoryCode||`Not set`,v.textContent=e.ageCategoryCode?`Edit`:`Set`,l(),f(p)}})},g.appendChild(v),m.appendChild(g);let y=document.createElement(`div`);y.id=`ageDetailsPanel`,y.style.marginTop=`0.5em`,y.style.display=`none`,m.appendChild(y),c.appendChild(m);let b=document.createElement(`div`);b.id=`ratingSection`,b.style.display=o.type===`RATING`||o.type===`BOTH`?`block`:`none`;let x=document.createElement(`div`);mi(x,[{label:a.labels?.ratingTypeLabel||`Rating Type`,field:`ratingType`,options:[{label:`Select rating type...`,value:``,selected:!o.ratingType},...(a.options?.ratingTypes||[]).map(e=>({label:e,value:e,selected:e===o.ratingType}))],onChange:e=>{o.ratingType=e.target.value||void 0}},{label:a.labels?.ratingMinLabel||`Minimum Rating`,field:`ratingMin`,type:`number`,placeholder:`Min`,value:o.ratingMin?.toString()||``,onChange:e=>{let t=e.target.value;o.ratingMin=t?Number.parseFloat(t):void 0},fieldPair:{label:a.labels?.ratingMaxLabel||`Maximum Rating`,field:`ratingMax`,type:`number`,placeholder:`Max`,value:o.ratingMax?.toString()||``,onChange:e=>{let t=e.target.value;o.ratingMax=t?Number.parseFloat(t):void 0}}}],[{control:`ratingType`,onInput:()=>{f(p)}},{control:`ratingMin`,onInput:()=>{f(p)}},{control:`ratingMax`,onInput:()=>{f(p)}}]),b.appendChild(x),c.appendChild(b);let S=()=>{let e=o.type===`AGE`||o.type===`BOTH`,t=o.type===`RATING`||o.type===`BOTH`;m.style.display=e?`block`:`none`,b.style.display=t?`block`:`none`,e&&l()};setTimeout(()=>{S(),l()},0);let C=[{label:`Cancel`,close:!0},{label:`OK`,id:`categoryOkButton`,intent:`is-success`,close:!0,disabled:!0,onClick:()=>{_o(i)&&i(o)}}],w={...a.modalConfig},T=F.open({title:a.labels?.title||`Category`,content:c,buttons:C,config:w});return setTimeout(()=>{f(p)},0),T}function yo(e){if(e===``||e==null)return!1;let t=Number(e);return!isNaN(t)&&Number.isInteger(t)&&t>=0}var bo=(e,t)=>n=>yo(n)&&Number(n)>=e&&Number(n)<=t,{WTN:xo,UTR:So,TRN:Co,NTRP:wo,DUPR:To}=t.factoryConstants.ratingConstants,{RATING:Eo}=t.factoryConstants.scaleConstants,Do=[`Blue`,`Red`,`Green`,`Orange`,`Purple`,`Yellow`,`Pink`,`Gold`,`Silver`,`Bronze`],Oo=[xo,So,Co,wo,To],ko=[{value:`WATERFALL`,label:`Waterfall`,description:`Distributes evenly: 1→2→3→1→2→3 (like dealing cards)`},{value:`LEVEL_BASED`,label:`Level Based`,description:`Groups by skill tiers: [1-5], [6-10], [11-15]`},{value:`SHUTTLE`,label:`Shuttle`,description:`Alternating direction: 1→2→3→3→2→1→1→2→3 (like a loom shuttle)`}];function Ao(e){let{flightsCount:t,namingType:n,customName:r,suffixType:i}=e,a=[];for(let e=0;e<t;e++)if(n===`colors`)a.push(Do[e]||`Flight ${e+1}`);else{let t=i===`letters`?String.fromCodePoint(65+e):(e+1).toString();a.push(`${r||`Flight`} ${t}`)}return a}function jo(e){let n={scaleType:e.scaleType};return e.eventType&&(n.eventType=e.eventType),e.scaleType===Eo&&e.scaleName&&(n.scaleName=e.scaleName,t.fixtures.ratingsParameters[e.scaleName]?(n.ascending=t.fixtures.ratingsParameters[e.scaleName].ascending,n.accessor=t.fixtures.ratingsParameters[e.scaleName].accessor):(delete n.ascending,delete n.accessor)),n}function Mo(e){return{WATERFALL:`splitWaterfall`,LEVEL_BASED:`splitLevelBased`,SHUTTLE:`splitShuttle`}[e]||`splitLevelBased`}function No(e){let t=[];return!e.flightsCount||Number.isNaN(e.flightsCount)||e.flightsCount<=0?t.push(`Number of flights must be a valid number greater than 0`):e.flightsCount<2?t.push(`Must have at least 2 flights`):e.flightsCount>10&&t.push(`Maximum 10 flights allowed`),e.scaleType===Eo&&!e.scaleName&&t.push(`Rating system must be selected`),t}var{RATING:Po,RANKING:Fo}=t.factoryConstants.scaleConstants,Io=`flightsCount`,Lo=`namingType`,Ro=`customName`,zo=`suffixType`,Bo=`scaleType`,Vo=`scaleName`,Ho=`splitMethod`;function Uo({existingProfile:e,editorConfig:t={}}={}){let n=!!e,r={flightsCount:2,namingType:`colors`,customName:`Flight`,suffixType:`numbers`,scaleType:Po,scaleName:`WTN`,splitMethod:`LEVEL_BASED`};if(n&&e){let{flights:t,scaleAttributes:n,splitMethod:i}=e;if(t&&t.length>0){r.flightsCount=t.length;let e=t[0].drawName;if(Do.includes(e))r.namingType=`colors`;else{let t=e.match(/^(.+?)\s+([A-Z]|\d+)$/);t&&(r.namingType=`custom`,r.customName=t[1],r.suffixType=/[A-Z]/.test(t[2])?`letters`:`numbers`)}}n&&(r.scaleType=n.scaleType||Po,r.scaleName=n.scaleName),i&&(r.splitMethod={splitWaterfall:`WATERFALL`,splitLevelBased:`LEVEL_BASED`,splitShuttle:`SHUTTLE`}[i]||`LEVEL_BASED`)}return[{error:`Must be in range 2-10`,placeholder:`2`,validator:bo(2,10),value:r.flightsCount,label:t.labels?.flightsCountLabel||`Number of Flights (2-10)`,field:Io,selectOnFocus:!0,hide:n,type:`number`,focus:!0},{options:[{label:`Color Names`,value:`colors`,selected:r.namingType===`colors`},{label:`Root Word`,value:`custom`,selected:r.namingType===`custom`}],label:t.labels?.namingTypeLabel||`Naming Strategy`,value:r.namingType,field:Lo,hide:n},{placeholder:`Flight`,label:t.labels?.customNameLabel||`Root Word`,visible:r.namingType===`custom`,value:r.customName,selectOnFocus:!0,field:Ro,hide:n,fieldPair:{options:[{label:`Letters (A, B, C)`,value:`letters`,selected:r.suffixType===`letters`},{label:`Numbers (1, 2, 3)`,value:`numbers`,selected:r.suffixType===`numbers`}],label:t.labels?.suffixTypeLabel||`Suffix Style`,visible:r.namingType===`custom`,value:r.suffixType,field:zo}},{options:[{label:`Rating`,value:Po,selected:r.scaleType===Po},{label:`Ranking`,value:Fo,selected:r.scaleType===Fo}],label:t.labels?.scaleTypeLabel||`Flighting Strategy`,field:Bo,value:r.scaleType,hide:n},{options:Oo.map(e=>({label:e,value:e,selected:e===r.scaleName})),label:t.labels?.scaleNameLabel||`Rating System`,field:Vo,value:r.scaleName,visible:r.scaleType===Po,hide:n},{label:t.labels?.splitMethodLabel||`Split Method`,field:Ho,value:r.splitMethod,radio:!0,options:ko.map(e=>({text:e.label,value:e.value,checked:e.value===r.splitMethod})),hide:n}]}var{RATING:Wo}=t.factoryConstants.scaleConstants,Go=`none`;function Ko(){let e=({inputs:e})=>{let t=document.getElementById(`flightProfileOk`);if(!t)return;let n=e[Io]?.value,r=bo(2,10)(n);t.disabled=!r,t.style.opacity=r?`1`:`0.5`,t.style.cursor=r?`pointer`:`not-allowed`};return[{onInput:({inputs:t})=>{e({inputs:t})},control:Io},{onChange:({e,fields:t})=>{let n=e.target.value;if(t){let e=n===`custom`;t[Ro].style.display=e?``:Go,t[zo].style.display=e?``:Go}},control:Lo},{onChange:({e,fields:t})=>{let n=e.target.value;if(t){let e=n===Wo;t[Vo].style.display=e?``:Go}},control:Bo}]}var{RATING:qo}=t.factoryConstants.scaleConstants;function Jo(e){return typeof e==`function`}function Yo(e){let{existingFlightProfile:t,editorConfig:n={},callback:r}=e,i=!!t,a,o=e=>{if(i){let t=document.createElement(`div`);t.className=`notification is-info is-light`,t.innerHTML=n.labels?.existingNote||`<strong style="color: #000;">Note:</strong> Flight split has already been performed. You can only rename the flights.`,e.appendChild(t)}let r=Uo({existingProfile:t,editorConfig:n}),o=Ko(),s=document.createElement(`div`);if(e.appendChild(s),a=mi(s,r,o),i&&t?.flights){let r=document.createElement(`div`);r.className=`field`,r.innerHTML=`
|
|
97
97
|
<label class="label">${n.labels?.flightNamesLabel||`Flight Names`}</label>
|
|
98
98
|
`,t.flights.forEach((e,n)=>{let i=document.createElement(`div`);i.className=`field`,i.innerHTML=`
|
|
99
99
|
<div class="control">
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
placeholder="Flight ${n+1}"
|
|
106
106
|
/>
|
|
107
107
|
</div>
|
|
108
|
-
`,i.querySelector(`input`).addEventListener(`input`,e=>{t.flights[n].drawName=e.target.value}),r.appendChild(i)}),e.appendChild(r)}},s=[{label:n.labels?.cancel||`Cancel`,close:!0},{label:n.labels?.ok||`OK`,id:`flightProfileOk`,intent:`is-success`,close:!0,onClick:()=>{if(i)return
|
|
109
|
-
`)),!1;let n=
|
|
108
|
+
`,i.querySelector(`input`).addEventListener(`input`,e=>{t.flights[n].drawName=e.target.value}),r.appendChild(i)}),e.appendChild(r)}},s=[{label:n.labels?.cancel||`Cancel`,close:!0},{label:n.labels?.ok||`OK`,id:`flightProfileOk`,intent:`is-success`,close:!0,onClick:()=>{if(i)return Jo(r)&&r({flights:t.flights}),!0;{let e={flightsCount:Number.parseInt(a.flightsCount?.value||`0`),namingType:a.namingType?.value||`colors`,customName:a.customName?.value||`Flight`,suffixType:a.suffixType?.value||`numbers`,scaleType:a.scaleType?.value||qo,scaleName:a.scaleName?.value,splitMethod:a.splitMethod?.value||`LEVEL_BASED`,isExisting:!1},t=No(e);if(t.length>0)return alert(t.join(`
|
|
109
|
+
`)),!1;let n=Ao(e),i=jo(e),o=Mo(e.splitMethod);return Jo(r)&&r({flightsCount:e.flightsCount,drawNames:n,scaleAttributes:i,splitMethod:o}),!0}}}],c={modalSize:`is-medium`};return i||(c.info=`
|
|
110
110
|
<div style="color: #000;">
|
|
111
111
|
<div style="margin-bottom: 1em;">
|
|
112
112
|
<strong style="color: #000;">Waterfall:</strong><br>
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
<span style="color: #666;">Alternating direction like a loom shuttle: 1→2→3→3→2→1→1→2→3</span>
|
|
122
122
|
</div>
|
|
123
123
|
</div>
|
|
124
|
-
`),F.open({title:n.labels?.title||`Flight Profile`,content:o,buttons:s,config:c})}var
|
|
124
|
+
`),F.open({title:n.labels?.title||`Flight Profile`,content:o,buttons:s,config:c})}var Xo=`chc-inline-scoring-active`;function Zo(e){let{composition:t,manager:n,matchUpFormat:r,eventHandlers:i}=e,a=t?.configuration?.inlineScoring,o=e.matchUp.matchUpId,s=a?.mode||`points`,c=r||e.matchUp.matchUpFormat||`SET3-S:6/TB7`;n.getOrCreate(o,c,e.matchUp);let l=!1,u=e.matchUp,d=document.createElement(`div`);d.className=`chc-inline-scoring-wrapper`,d.setAttribute(`data-matchup-id`,o),d.classList.add(Xo);function f(){d.innerHTML=``;let r=n.getMatchUp(o,u),c=n.isComplete(o),p={...t,configuration:{...t.configuration,inlineScoring:{...a,canUndo:n.canUndo(o),canRedo:n.canRedo(o),isComplete:c,isDirty:l}}},m={...i,scoreClick:({pointerEvent:e})=>{e.stopPropagation()},scoreIncrement:({matchUpId:e,sideNumber:t,scoreType:r})=>{if(n.isComplete(e)||u.matchUpStatus&&![`IN_PROGRESS`,`TO_BE_PLAYED`].includes(u.matchUpStatus))return;let i=t-1,a;r===`point`||s===`points`?a=n.addPoint(e,i,u):(r===`game`||s===`games`)&&(a=n.addGame(e,i,u)),a&&(l=!0,f())},pillClick:({pointerEvent:e,sideNumber:t})=>{e.stopPropagation();let r=u.matchUpStatus;Qo(e,t,r,e=>{if(e===`IN_PROGRESS`)u={...u,matchUpStatus:`IN_PROGRESS`,winningSide:void 0,readyToScore:!0};else{e===`WALKOVER`&&n.reset(o,u);let r=[`RETIRED`,`DEFAULTED`,`WALKOVER`,`DOUBLE_WALKOVER`,`DOUBLE_DEFAULT`].includes(e)?t===1?2:1:void 0;u={...u,matchUpStatus:e,winningSide:r,readyToScore:!1},n.callbacks?.onEndMatch?.({matchUpId:o,matchUpStatus:e,sideNumber:t,engine:n.get(o)?.engine})}l=!0,f()})},inlineUndo:()=>{n.undo(o,u)&&(l=!0,f())},inlineRedo:()=>{n.redo(o,u)&&(l=!0,f())},inlineClear:()=>{n.reset(o,u),u={...u,matchUpStatus:`IN_PROGRESS`,winningSide:void 0,readyToScore:!0,score:void 0},l=!0,f()},inlineSubmit:()=>{let e=n.get(o);if(e){let t=n.getMatchUp(o,u);n.callbacks?.onSubmit?.({matchUpId:o,matchUp:t,engine:e.engine}),l=!1,f()}}},h=qr({...e,composition:p,matchUp:r,eventHandlers:m});c&&d.classList.remove(Xo),d.appendChild(h)}return f(),d}function Qo(e,t,n,r){document.querySelectorAll(`.chc-live-chip-popover`).forEach(e=>e.remove());let i=e.currentTarget.getBoundingClientRect(),a=document.createElement(`div`);a.className=`chc-live-chip-popover`;let o=!!document.querySelector(`[data-theme="dark"]`),s=o?`#222244`:`#fff`,c=o?`#444`:`#dee2e6`,l=o?`0 2px 12px rgba(0,0,0,0.4), 0 0 0 1px rgba(91,155,213,0.3)`:`0 2px 8px rgba(0,0,0,0.12)`,u=t===2?`bottom: ${document.documentElement.clientHeight-i.top+4}px;`:`top: ${i.bottom+4}px;`;a.style.cssText=`
|
|
125
125
|
position: fixed;
|
|
126
126
|
${u}
|
|
127
127
|
right: ${document.documentElement.clientWidth-i.right}px;
|
|
@@ -135,19 +135,19 @@
|
|
|
135
135
|
border: 1px solid ${c};
|
|
136
136
|
border-radius: 6px;
|
|
137
137
|
box-shadow: ${l};
|
|
138
|
-
`;let d=n&&![`IN_PROGRESS`,`COMPLETED`,`TO_BE_PLAYED`].includes(n)?[`IN_PROGRESS`,`RETIRED`,`DEFAULTED`,`WALKOVER`,`SUSPENDED`,`CANCELLED`,`ABANDONED`]:[`RETIRED`,`DEFAULTED`,`WALKOVER`,`SUSPENDED`,`CANCELLED`,`ABANDONED`];for(let e of d){let t=Vn({matchUpStatus:e});t.classList.add(`chc-live-chip-popover-item`),t.onclick=t=>{t.stopPropagation(),a.remove(),document.removeEventListener(`click`,f),r(e)},a.appendChild(t)}document.body.appendChild(a);let f=e=>{a.contains(e.target)||(a.remove(),document.removeEventListener(`click`,f))};setTimeout(()=>document.addEventListener(`click`,f),0)}function Yo(e,t){let n=e.isComplete(),r=e.getInputMode();if(r===`none`&&t.score?.sets?.length)return{...t,matchUpStatus:n?`COMPLETED`:t.matchUpStatus||`IN_PROGRESS`,winningSide:e.getWinner()??t.winningSide??void 0};let i=e.getScore(),a=i.pointDisplay&&(r===`points`||r===`mixed`),o=(i.sets||[]).map((e,t)=>({setNumber:t+1,side1Score:e.side1Score,side2Score:e.side2Score,side1TiebreakScore:e.side1TiebreakScore,side2TiebreakScore:e.side2TiebreakScore,winningSide:e.winningSide,...a&&!e.winningSide&&!n&&{side1PointScore:i.pointDisplay[0],side2PointScore:i.pointDisplay[1]}})),s=t.matchUpStatus&&[`RETIRED`,`DEFAULTED`,`WALKOVER`,`DOUBLE_WALKOVER`,`DOUBLE_DEFAULT`].includes(t.matchUpStatus);if(!n&&!s){let e=o.length>0&&o.every(e=>e.winningSide);(o.length===0||e)&&o.push({setNumber:o.length+1,side1Score:0,side2Score:0})}if(!n&&!s&&o.length>0){let e=o[o.length-1];!e.winningSide&&e.side1PointScore==null&&e.side2PointScore==null&&(e.side1PointScore=`0`,e.side2PointScore=`0`)}let c=e.getWinner();return{...t,matchUpStatus:n?`COMPLETED`:t.matchUpStatus||`IN_PROGRESS`,winningSide:c??t.winningSide??void 0,score:{sets:o,scoreStringSide1:e.getScoreboard()||void 0}}}var{ScoringEngine:Xo}=t.scoreGovernor,Zo=class{constructor(e){this.engines=new Map,this.callbacks=e||{}}getOrCreate(e,t,n){let r=this.engines.get(e);if(r)return r;let i=new Xo({matchUpFormat:t});if(n?.score?.sets?.length)try{let e=n.score.sets,t=e.filter(e=>e.winningSide),r=e.find(e=>!e.winningSide),a;if(r?.side1PointScore!=null&&r?.side2PointScore!=null){let e=e=>{let t=String(e);if(t===`0`)return 0;if(t===`15`)return 1;if(t===`30`)return 2;if(t===`40`)return 3;if(t===`AD`)return 4;let n=Number(e);return isNaN(n)?0:n};a={side1Points:e(r.side1PointScore),side2Points:e(r.side2PointScore)}}i.setInitialScore({sets:t,...r&&{currentSetScore:{side1Score:r.side1Score||0,side2Score:r.side2Score||0}},...a&&{currentGameScore:a},matchUpStatus:n.matchUpStatus,winningSide:n.winningSide})}catch{}return r={engine:i,matchUpFormat:t,pointCount:0},this.engines.set(e,r),r}get(e){return this.engines.get(e)}has(e){return this.engines.has(e)}addPoint(e,t,n){let r=this.engines.get(e);if(!r||r.engine.isComplete())return;let i=r.pointCount%2;return r.engine.addPoint({winner:t,server:i,result:`Winner`}),r.pointCount++,this.notifyAndReturn(e,n)}addGame(e,t,n){let r=this.engines.get(e);if(!(!r||r.engine.isComplete()))return r.engine.addGame({winner:t}),this.notifyAndReturn(e,n)}addSet(e,t,n,r){let i=this.engines.get(e);if(!(!i||i.engine.isComplete()))return i.engine.addSet({side1Score:t,side2Score:n}),this.notifyAndReturn(e,r)}undo(e,t){let n=this.engines.get(e);if(!(!n||!n.engine.canUndo()))return n.engine.undo(),n.pointCount>0&&n.pointCount--,this.notifyAndReturn(e,t)}redo(e,t){let n=this.engines.get(e);if(!(!n||!n.engine.canRedo()))return n.engine.redo(),n.pointCount++,this.notifyAndReturn(e,t)}reset(e,t){let n=this.engines.get(e);if(n)return n.engine.reset(),n.pointCount=0,this.notifyAndReturn(e,t)}getMatchUp(e,t){let n=this.engines.get(e);return n?Yo(n.engine,t):t}getSituation(e){let t=this.engines.get(e);if(t)return t.engine.getScore()?.situation}canUndo(e){return this.engines.get(e)?.engine.canUndo()??!1}canRedo(e){return this.engines.get(e)?.engine.canRedo()??!1}isComplete(e){return this.engines.get(e)?.engine.isComplete()??!1}remove(e){this.engines.delete(e)}clear(){this.engines.clear()}notifyAndReturn(e,t){let n=this.engines.get(e),r=Yo(n.engine,t);if(this.callbacks.onScoreChange?.({matchUpId:e,matchUp:r,engine:n.engine}),n.engine.isComplete()){let t=n.engine.getWinner();t!=null&&this.callbacks.onMatchComplete?.({matchUpId:e,winningSide:t,engine:n.engine})}return r}},Qo={scoringApproach:`dynamicSets`,smartComplements:!0,composition:`Australian`,idiom:`en`,dateFormat:`YYYY-MM-DD`,timeFormat:`HH:mm`},$o={...Qo};function es(){return{...$o}}function ts(e){$o={...$o,...e}}function ns(){$o={...Qo}}function rs(){return{scoringApproach:$o.scoringApproach,smartComplements:$o.smartComplements,composition:$o.composition}}function is(e){let{matchUp:t,container:n,onScoreChange:r}=e;n.innerHTML=``,n.style.display=`flex`,n.style.flexDirection=`column`,n.style.gap=`0.5em`;let i=ri[es().composition||`Australian`]||ri.Australian,a={...i,configuration:{...i.configuration,matchUpFooter:!0,inlineScoring:{mode:`games`,showFooter:!0,showSituation:!0}}},o=t.matchUpFormat||`SET3-S:6/TB7`,s={...t,matchUpStatus:`IN_PROGRESS`,readyToScore:!0,winningSide:void 0},c=(e,t)=>{let n=e?.score?.sets||[];r({isValid:t||n.some(e=>e.side1Score||e.side2Score),sets:n,winningSide:e?.winningSide,matchUpStatus:e?.matchUpStatus,matchUpFormat:o,score:e?.score?.scoreStringSide1})},l=new Zo({onScoreChange:({matchUpId:e,matchUp:t})=>{c(t,l.isComplete(e))},onMatchComplete:({matchUpId:e})=>{c(l.getMatchUp(e,s),!0)},onEndMatch:({matchUpId:e,matchUpStatus:t})=>{c({...l.getMatchUp(e,s),matchUpStatus:t},!0)}}),u=qo({matchUp:s,composition:a,manager:l,matchUpFormat:o,isLucky:!0});n.appendChild(u),globalThis.resetInlineScoring=()=>{l.reset(t.matchUpId,s),n.innerHTML=``;let e=qo({matchUp:{...t,matchUpStatus:`IN_PROGRESS`,readyToScore:!0,winningSide:void 0},composition:a,manager:l,matchUpFormat:o,isLucky:!0});n.appendChild(e),r({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`})}}var{COMPLETED:as}=t.matchUpStatusConstants,{validateMatchUpScore:os,validateSetScore:ss}=t.governors.scoreGovernor;function cs(e,t,n,r,i){let a=n?.finalSetFormat?.tiebreakSet?.tiebreakTo&&!n?.finalSetFormat?.setTo,o=n?.setFormat?.tiebreakSet?.tiebreakTo&&!n?.setFormat?.setTo,s=n?.finalSetFormat?.tiebreakSet?.tiebreakTo===1,c=n?.setFormat?.tiebreakSet?.tiebreakTo===1;for(let n=0;n<e.length;n++){let l=e[n],u=n+1,d=u===t,f=l.startsWith(`[`)&&l.endsWith(`]`),p=(l===`1-0`||l===`0-1`)&&(d&&s||c),m=o||d&&a;if(!m&&f)return{isValid:!1,sets:r,scoreObject:i,error:`Set ${u}: Format expects regular set (e.g., 6-4), but got tiebreak-only set ${l}`};if(m&&!f&&!p)return{isValid:!1,sets:r,scoreObject:i,error:`Set ${u}: Format expects tiebreak-only set (e.g., [10-8]), but got regular set ${l}`}}return null}function ls(e,t,n,r,i){if(e||t===void 0)return!1;let a=!!i?.aggregate,o=!!i?.exactly;if(a)return n.filter(e=>e.side1Score!==void 0&&e.side2Score!==void 0).length>=r;{let e=Math.ceil(r/2),t={side1:0,side2:0};return n.forEach(e=>{e.winningSide===1?t.side1++:e.winningSide===2&&t.side2++}),!(!(t.side1>=e||t.side2>=e)||o&&n.length<r)}}function us(e,n,r){let{WALKOVER:i,CANCELLED:a,DEAD_RUBBER:o}=t.matchUpStatusConstants,s=[i,a,o];if(!e?.trim())return r&&s.includes(r)?{isValid:!0,sets:[],matchUpStatus:r,scoreObject:void 0}:{isValid:!1,sets:[],error:`Score is required`};try{let{outcome:i,error:a}=t.tournamentEngine.generateOutcomeFromScoreString({scoreString:e.trim(),matchUpFormat:n,preserveSideOrder:!0});if(a||!i?.score?.sets)return{isValid:!1,sets:[],error:a||`Invalid score format`};let o=i.score.sets,s=i.score,c=e.trim().split(/\s+/).filter(e=>e.length>0),l=t.matchUpFormatCode.parse(n),u=l?.exactly||l?.bestOf||3,d=cs(c,u,l,o,s);if(d)return d;let f=!1,p=o.map((e,t)=>{if(!ss(e,n,t+1===u,!1).isValid){f=!0;let{...t}=e;return t}return e}),m={...s,sets:p},h=os(p,n,r);if(!h.isValid)return{isValid:!1,sets:p,scoreObject:m,error:h.error};let g=Math.ceil(u/2),_=f?void 0:i.winningSide;return ls(f,_,p,u,l)?{isValid:!0,sets:p,scoreObject:m,winningSide:_,matchUpStatus:as,matchUpFormat:n,score:e.trim()}:{isValid:!1,sets:p,scoreObject:m,error:`Incomplete match - need ${g} sets to win`}}catch(e){return{isValid:!1,sets:[],error:e instanceof Error?e.message:`Invalid score format`}}}function ds(e,t,n){if(!e||e.length===0)return{isValid:!1,sets:[],error:`At least one set is required`};let r=e.map(e=>{let t=e.side1??``,n=e.side2??``;if((!t||t===0)&&(!n||n===0)&&e.side1TiebreakScore!==void 0&&e.side2TiebreakScore!==void 0)return`[${e.side1TiebreakScore}-${e.side2TiebreakScore}]`;if(t===``||n===``)return``;if(e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0){let r=e.side1TiebreakScore??0,i=e.side2TiebreakScore??0;return`${t}-${n}(${Number(t)>Number(n)?i:r})`}return`${t}-${n}`}).filter(e=>e!==``).join(` `);return r?us(r,t,n?void 0:as):{isValid:!1,sets:[],error:`At least one complete set is required`}}function fs(e){if(!e)return{bestOf:3,setsToWin:2,isTimed:!1,isExactlyFormat:!1};let n=t.matchUpFormatCode.parse(e);if(!n)return{bestOf:3,setsToWin:2,isTimed:!1,isExactlyFormat:!1};let r=!!(n.setFormat?.timed||n.finalSetFormat?.timed),i=!!n.exactly||n.bestOf===1,a=n.exactly||n.bestOf||3,o=Math.ceil(a/2);return{bestOf:n.bestOf||a,exactly:n.exactly,setsToWin:o,isTimed:r,isExactlyFormat:i}}function ps(e,n){if(!e||e.length===0)return!0;let r=fs(n),{bestOf:i,isExactlyFormat:a,setsToWin:o}=r,s=r.exactly||i;if(a){if(e.length>=s)return!1;let i=t.matchUpFormatCode.parse(n),a=!!i?.aggregate,o=i?.finalSetFormat?.tiebreakSet?.tiebreakTo!==void 0;if(a&&o&&r.isTimed){let t=s-1;if(e.length<t)return!0;if(e.length===t){let t=e.reduce((e,t)=>(t.side1Score!==void 0&&t.side1Score!==null&&(e.side1+=t.side1Score),t.side2Score!==void 0&&t.side2Score!==null&&(e.side2+=t.side2Score),e),{side1:0,side2:0});return t.side1===t.side2}else return!1}return!0}let c={side1:0,side2:0};return e.forEach(e=>{let t=e.side1Score??0,n=e.side2Score??0;t>n?c.side1++:n>t&&c.side2++}),c.side1>=o||c.side2>=o||e.length>=i?!1:e.every(e=>e.side1Score!==void 0&&e.side2Score!==void 0&&e.side1Score!==null&&e.side2Score!==null)}function ms(e,t){return(t.bestOf===1||e+1===t.bestOf)&&t.finalSetFormat?t.finalSetFormat:t.setFormat}function hs(e){return e?.tiebreakSet?.tiebreakTo!==void 0}function gs(e){return e?.timed===!0&&e?.minutes!==void 0}function _s(e,t,n,r){let i=ms(e,r);if(gs(i))return 1/0;let a=i?.setTo||6,o=i?.tiebreakAt||a,s=t===1?n.side2:n.side1,c=o===a?a+1:a;return s===0?c:s<o-1?a:s===o-1?o===a?a+1:a:s===o?c:s>o&&s<a?a:s===a?o===a?a+2:o:s>a?s+2:c}function vs(e,t,n){let r=ms(e,n);if(gs(r))return t.side1!==void 0&&t.side1!==null&&t.side2!==void 0&&t.side2!==null;if(hs(r))return t.side1>0&&t.side2>0&&t.side1!==t.side2;let i=r?.setTo||6,a=r?.tiebreakAt||i,o=Math.max(t.side1,t.side2),s=Math.min(t.side1,t.side2),c=Math.abs(t.side1-t.side2);return o>=i&&c>=2||(a===i?o===a+1&&s===a:o===i&&s===a)&&t.tiebreak!==void 0}function ys(e,t,n){if(vs(e,t,n)){if(t.side1>t.side2)return 1;if(t.side2>t.side1)return 2}}function bs(e,t,n){let r=Math.ceil(t/2),i=e.filter(e=>e.winningSide===1).length,a=e.filter(e=>e.winningSide===2).length;return i>=r||a>=r?n?e.filter(e=>e.side1Score!==void 0&&e.side2Score!==void 0).length>=n:!0:!1}function xs(e,t,n){if(!bs(e,t,n))return;let r=Math.ceil(t/2),i=e.filter(e=>e.winningSide===1).length,a=e.filter(e=>e.winningSide===2).length;if(i>=r)return 1;if(a>=r)return 2}function Ss(e,t){let n=t?.setTo||6;if(e>=n)return null;let r=t?.tiebreakAt||n;return e<n-1?n:r===n?n+1:n}function Cs(e,t,n,r,i,a,o){if(!o)return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Feature disabled in settings`};if(a.has(n))return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Already used for this set`};if(bs(r,i.bestOf,i.exactly))return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Match already complete`};let s=ms(n,i);if(hs(s))return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Tiebreak-only set`};if(gs(s))return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Timed set`};let c=Ss(e,s);return c===null?{field1Value:e,field2Value:0,shouldApply:!1,reason:`No predictable complement for this digit`}:t?{field1Value:c,field2Value:e,shouldApply:!0}:{field1Value:e,field2Value:c,shouldApply:!0}}function ws(e,t,n){let r=ms(e,n);if(gs(r)||hs(r))return!1;let i=r?.setTo||6,a=r?.tiebreakAt||i,o=Math.max(t.side1,t.side2),s=Math.min(t.side1,t.side2);return a===i?o===a+1&&s===a:o===i&&s===a}function Ts(e,t,n){if(e+1>=n.bestOf||bs(t,n.bestOf,n.exactly))return!1;let r=t[e];return r?r.winningSide!==void 0:!1}function Es(e,t,n,r,i){let a=Number.parseInt(t)||0,o=Number.parseInt(n)||0,s=r?Number.parseInt(r):void 0,c=ms(e,i);if(hs(c)){let t=a>0&&o>0&&a!==o?a>o?1:2:void 0;return{setNumber:e+1,side1Score:0,side2Score:0,side1TiebreakScore:a,side2TiebreakScore:o,winningSide:t}}let l=ys(e,{side1:a,side2:o,tiebreak:s},i),u={setNumber:e+1,side1Score:a,side2Score:o,winningSide:l};if(s!==void 0){let e=c?.tiebreakFormat?.tiebreakTo||7,t=c?.tiebreakFormat?.noAd,n;n=s<e-1?e:t?s+1:s+2,a>o?(u.side1TiebreakScore=n,u.side2TiebreakScore=s):(u.side1TiebreakScore=s,u.side2TiebreakScore=n)}return u}var{COMPLETED:Ds,RETIRED:Os,WALKOVER:ks,DEFAULTED:As,DOUBLE_WALKOVER:js,DOUBLE_DEFAULT:Ms}=t.matchUpStatusConstants,Ns=`var(--chc-text-secondary)`,Ps=`var(--chc-text-primary)`;function Fs(e){let t=e.side1Score===0&&e.side2Score===0&&(e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0),n=t?{side1TiebreakScore:e.side1TiebreakScore,side2TiebreakScore:e.side2TiebreakScore}:{side1:e.side1Score,side2:e.side2Score};return!t&&e.side1TiebreakScore!==void 0&&(n.side1TiebreakScore=e.side1TiebreakScore),!t&&e.side2TiebreakScore!==void 0&&(n.side2TiebreakScore=e.side2TiebreakScore),e.winningSide!==void 0&&(n.winningSide=e.winningSide),e.side1PointScore!==void 0&&(n.side1PointScore=e.side1PointScore),e.side2PointScore!==void 0&&(n.side2PointScore=e.side2PointScore),n}function Is(e,t){if(t.sets&&t.scoreObject?.sets)for(let n=0;n<e.length&&n<t.scoreObject.sets.length;n++){let r=e[n];r.side1PointScore!==void 0&&(t.scoreObject.sets[n].side1PointScore=r.side1PointScore),r.side2PointScore!==void 0&&(t.scoreObject.sets[n].side2PointScore=r.side2PointScore)}if(t.sets)for(let n=0;n<e.length&&n<t.sets.length;n++){let r=e[n];r.side1PointScore!==void 0&&(t.sets[n].side1PointScore=r.side1PointScore),r.side2PointScore!==void 0&&(t.sets[n].side2PointScore=r.side2PointScore)}}function Ls(e,t,n,r){e===Ds?(r.style.display=`none`,n.style.display=t?`none`:`block`):(n.style.display=`block`,r.style.display=`block`)}function Rs(e,t,n){t!==Ds&&(n?(e.matchUpStatus=t,e.winningSide=n,e.isValid=!0):t===ks?(e.matchUpStatus=js,e.isValid=!0):t===As?(e.matchUpStatus=Ms,e.isValid=!0):(e.matchUpStatus=t,e.isValid=!1))}function zs(e,t,n){if(t){let t=e.filter(e=>e.winningSide!==void 0).length;return Math.max(1,t)}let r=e.length-1;return r>=0&&e[r].winningSide!==void 0&&e.length<n?e.length+1:Math.max(1,e.length)}var Bs=`input[name="matchOutcome"]`,Vs=`input[name="irregularWinner"]`,Hs=`.tiebreak-container`;function Us(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.matchUpFormat||`SET3-S:6/TB7`,s=()=>{let e=fs(o),n=t.matchUpFormatCode.parse(o);return{bestOf:e.bestOf,exactly:n?.exactly,setFormat:n?.setFormat,finalSetFormat:n?.finalSetFormat}},c=s(),l=()=>c.bestOf,u=()=>c.exactly,d=e=>ms(e,c),f=document.createElement(`div`);if(f.style.marginBottom=`0.5em`,r.appendChild(f),n.matchUpFormat){let e=document.createElement(`div`);e.style.fontSize=`0.9em`,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=Ns,e.appendChild(t);let i=document.createElement(`button`);i.textContent=n.matchUpFormat,i.className=`button is-small is-white`,i.style.fontSize=`0.75em`,i.style.padding=`0.2em 0.5em`,i.style.cursor=`pointer`,i.title=`Click to edit format`,i.addEventListener(`click`,()=>{try{Ca({existingMatchUpFormat:n.matchUpFormat,callback:e=>{e&&e!==n.matchUpFormat&&(n.matchUpFormat=e,o=e,i.textContent=e,c=s(),globalThis.resetDynamicSets&&globalThis.resetDynamicSets())},modalConfig:{style:{fontSize:`12px`,border:`3px solid #0066cc`}}})}catch(e){console.error(`[DynamicSets] Error opening format selector:`,e)}}),e.appendChild(i),r.appendChild(e)}let p=Ds,m,h=new Set,g=n.score?{...n.score}:void 0,_=n.winningSide,v=n.matchUpStatus,y=document.createElement(`div`);y.style.marginBottom=`0.8em`;let b=document.createElement(`div`);b.textContent=(a.irregularEnding||`Irregular Ending`)+`:`,b.style.fontSize=`0.75em`,b.style.fontWeight=`500`,b.style.marginBottom=`0.3em`,b.style.color=Ps,y.appendChild(b);let x=document.createElement(`div`);x.style.display=`flex`,x.style.gap=`0.5em`,x.style.flexWrap=`wrap`,[{value:Os,label:a.retired||`Retired`},{value:ks,label:a.walkover||`Walkover`},{value:As,label:a.defaulted||`Defaulted`}].forEach(e=>{let t=document.createElement(`label`);t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`0.3em`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`radio`,n.name=`matchOutcome`,n.value=e.value,n.checked=!1,n.addEventListener(`change`,e=>{if(p=e.target.value,p===ks){O.querySelectorAll(`input`).forEach(e=>{e.value=``});let e=O.querySelectorAll(`.set-row`);for(let t=e.length-1;t>0;t--)e[t].remove();z=[],A=null,j=0,g=void 0}C.style.display=`block`,setTimeout(()=>{typeof V==`function`&&V()},0)});let r=document.createElement(`span`);r.textContent=e.label,r.style.fontSize=`0.75em`,t.appendChild(n),t.appendChild(r),x.appendChild(t)});let S=document.createElement(`button`);S.textContent=a.clear||`Clear`,S.className=`button`,S.style.fontSize=`0.7em`,S.style.padding=`0.2em 0.5em`,S.addEventListener(`click`,()=>{y.querySelectorAll(Bs).forEach(e=>e.checked=!1),p=Ds,m=void 0,C.style.display=`none`,v=void 0,_=void 0,y.querySelectorAll(Vs).forEach(e=>e.checked=!1),setTimeout(()=>{typeof V==`function`&&V()},0)}),x.appendChild(S),y.appendChild(x);let C=document.createElement(`div`);C.style.display=`none`,C.style.marginTop=`0.3em`,C.style.paddingLeft=`1em`,C.style.borderLeft=`3px solid var(--chc-clear-btn-bg)`;let w=document.createElement(`div`);w.textContent=(a.winner||`Winner`)+`:`,w.style.fontSize=`0.75em`,w.style.fontWeight=`500`,w.style.marginBottom=`0.2em`,w.style.color=Ps,C.appendChild(w);let T=document.createElement(`div`);T.style.display=`flex`,T.style.gap=`0.5em`;let E=n.sides?.[0],D=n.sides?.[1];[1,2].forEach(e=>{let t=document.createElement(`label`);t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`0.3em`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`radio`,n.name=`irregularWinner`,n.value=e.toString(),n.addEventListener(`change`,()=>{m=e,setTimeout(()=>{typeof V==`function`&&(N=!0,V(),N=!1)},0)});let r=document.createElement(`span`);r.textContent=(e===1?E:D)?.participant?.participantName||`Side ${e}`,r.style.fontSize=`0.75em`,t.appendChild(n),t.appendChild(r),T.appendChild(t)}),C.appendChild(T),y.appendChild(C),r.appendChild(y);let O=document.createElement(`div`);O.style.display=`flex`,O.style.flexDirection=`column`,O.style.gap=`0.5em`,r.appendChild(O);let{ScoringEngine:k}=t.scoreGovernor,A=null,j=0,M=!1,N=!1,P=e=>{if(!A)return;let t=j%2;A.addPoint({winner:e,server:t,result:`Winner`}),j++,N=!0,V(),N=!1},F=()=>{if(!n.matchUpFormat)return;A=new k({matchUpFormat:n.matchUpFormat}),j=0;let e=z.filter(e=>e.winningSide!==void 0).map(e=>({side1Score:e.side1Score,side2Score:e.side2Score,side1TiebreakScore:e.side1TiebreakScore,side2TiebreakScore:e.side2TiebreakScore,winningSide:e.winningSide})),t=z[z.length-1];if(t&&t.winningSide===void 0&&(t.side1Score||t.side2Score)&&e.push({side1Score:t.side1Score,side2Score:t.side2Score,side1TiebreakScore:t.side1TiebreakScore,side2TiebreakScore:t.side2TiebreakScore,winningSide:void 0}),e.length>0)try{A.setInitialScore({sets:e})}catch{}},I=()=>{if(!A)return{};let e=A.getScore()?.pointDisplay;return!e||e[0]===`0`&&e[1]===`0`&&j===0?{}:{side1:String(e[0]),side2:String(e[1])}},L=(e,t)=>{if(!A)return;let n={0:0,15:1,30:2,40:3,AD:4};if(e in n||t in n){let r=n[e]??0,i=n[t]??0;for(let e=0;e<r;e++){let e=j%2;A.addPoint({winner:0,server:e,result:`Winner`}),j++}for(let e=0;e<i;e++){let e=j%2;A.addPoint({winner:1,server:e,result:`Winner`}),j++}}else{let n=parseInt(e,10)||0,r=parseInt(t,10)||0;for(let e=0;e<n;e++){let e=j%2;A.addPoint({winner:0,server:e,result:`Winner`}),j++}for(let e=0;e<r;e++){let e=j%2;A.addPoint({winner:1,server:e,result:`Winner`}),j++}}},R=()=>{let e=p===Os||p===As,t=z[z.length-1],n=t&&t.winningSide===void 0;if(M=!!(e&&n),!M){A=null,j=0;return}N||F()},z=[];globalThis.resetDynamicSets=()=>{O.innerHTML=``,z=[],h.clear(),A=null,j=0,M=!1,p=Ds,m=void 0,g=void 0,_=void 0,v=void 0,y.querySelectorAll(Bs).forEach(e=>e.checked=!1),y.querySelectorAll(Vs).forEach(e=>e.checked=!1),y.style.display=`none`,C.style.display=`none`;let e=te(0);O.appendChild(e),e.querySelectorAll(`input`).forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)}),B({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`});let t=O.querySelector(`input`);t&&t.focus()};let B=e=>{f.innerHTML=``;let t;e?.clearAll?(t=void 0,g=void 0):e?.scoreObject?(t=e.scoreObject,g=e.scoreObject):z.length>0?(t={sets:z},g={sets:z}):t=g,e?.clearAll?(_=void 0,v=void 0):e&&(_=e.winningSide,v=e.matchUpStatus||void 0,[ks,Os,As,js,Ms].includes(v)&&z.length===0&&(t=void 0,g=void 0));let r=Wr({matchUp:{...n,score:t,winningSide:_,matchUpStatus:v},isLucky:!0,composition:ri[es().composition||`Australian`]||ri.Australian});if(M){let e=A?.isComplete(),t=r.querySelector(`.tmx-sd[sideNumber="1"] .sideScore`);if(t){let n=document.createElement(`button`);n.className=`chc-game-btn`,n.textContent=`+`,n.title=`Point for side 1`,n.disabled=e,n.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),P(0)}),t.appendChild(n)}let n=r.querySelector(`.tmx-sd[sideNumber="2"] .sideScore`);if(n){let t=document.createElement(`button`);t.className=`chc-game-btn`,t.textContent=`+`,t.title=`Point for side 2`,t.disabled=e,t.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),P(1)}),n.appendChild(t)}}f.appendChild(r),ee()},ee=()=>{requestAnimationFrame(()=>{let e=f.firstElementChild;if(!e)return;e.style.width=`fit-content`,e.style.minWidth=`100%`,e.style.transform=``,f.style.height=``;let t=f.clientWidth,n=e.scrollWidth;if(n>t&&t>0){let r=t/n;e.style.transformOrigin=`top left`,e.style.transform=`scale(${r})`,f.style.height=`${e.offsetHeight*r}px`}})},te=e=>{let t=document.createElement(`div`);t.className=`set-row`,t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`0.5em`,t.style.marginBottom=`0.25em`;let n=document.createElement(`div`);n.textContent=`Set ${e+1}:`,n.style.width=`3.5em`,n.style.fontSize=`0.9em`,n.style.fontWeight=`500`,n.style.color=Ps,t.appendChild(n);let r=document.createElement(`input`);r.type=`text`,r.className=`input`,r.style.width=`3em`,r.style.textAlign=`center`,r.placeholder=`0`,r.dataset.setIndex=e.toString(),r.dataset.side=`1`;let i=document.createElement(`input`);i.type=`text`,i.className=`input`,i.style.width=`3em`,i.style.textAlign=`center`,i.placeholder=`0`,i.dataset.setIndex=e.toString(),i.dataset.side=`2`;let a=document.createElement(`span`);a.textContent=`-`,a.style.fontWeight=`bold`,a.style.color=Ns,t.appendChild(r),t.appendChild(a),t.appendChild(i);let o=document.createElement(`span`);o.className=`tiebreak-container`,o.style.display=`none`,o.style.marginLeft=`0.5em`;let s=document.createElement(`span`);s.textContent=`(`,s.style.color=Ns;let c=document.createElement(`input`);c.type=`text`,c.className=`input tiebreak-input`,c.style.width=`2.5em`,c.style.textAlign=`center`,c.dataset.setIndex=e.toString(),c.dataset.type=`tiebreak`;let l=document.createElement(`span`);l.textContent=`)`,l.style.color=Ns,o.appendChild(s),o.appendChild(c),o.appendChild(l),t.appendChild(o);let u=document.createElement(`span`);return u.className=`set-indicator`,u.style.fontSize=`1.2em`,u.style.minWidth=`1.5em`,t.appendChild(u),t},ne=e=>{let t=O.querySelector(`input[data-set-index="${e}"][data-side="1"]`),n=O.querySelector(`input[data-set-index="${e}"][data-side="2"]`),r=O.querySelector(`input[data-set-index="${e}"][data-type="tiebreak"]`);if(!t||!n)return!1;let i=t.value.trim(),a=n.value.trim();return i===``||a===``?!1:vs(e,{side1:Number.parseInt(i)||0,side2:Number.parseInt(a)||0,tiebreak:r?.value.trim()?Number.parseInt(r.value):void 0},c)},V=()=>{p===Ds&&(C.style.display=`none`);let e=[];for(let t=0;t<l();t++){let n=O.querySelector(`input[data-set-index="${t}"][data-side="1"]`),r=O.querySelector(`input[data-set-index="${t}"][data-side="2"]`),i=O.querySelector(`input[data-set-index="${t}"][data-type="tiebreak"]`);if(!n||!r)break;let a=n.value.trim(),o=r.value.trim();if(a===``&&o===``)break;let s=i?.value.trim(),l=Es(t,a,o,s,c);e.push(l)}if(z=e,R(),M&&z.length>0){let e=z[z.length-1];if(e.winningSide===void 0){let t=I();(t.side1||t.side2)&&(e.side1PointScore=t.side1||`0`,e.side2PointScore=t.side2||`0`)}}let t=O.querySelectorAll(`.set-row`),r=bs(z,l(),u()),a=zs(z,r,l());for(let e=t.length-1;e>=a;e--)t[e].remove();if(z.length>0||p!==Ds){let e=z.some(e=>e.winningSide===void 0),t=(p!==Ds||e?z:z.filter(e=>e.winningSide!==void 0)).map(Fs),r=ds(t,n.matchUpFormat,p!==Ds);Is(t,r);let a=r.isValid&&r.winningSide!==void 0;Ls(p,a,y,C),Rs(r,p,m),B(r),i(r)}else y.style.display=`block`,B(),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`})},re=()=>{let e=document.getElementById(`clearScoreV2`);if(e){let t=O.querySelectorAll(`.set-row`),n=O.querySelector(`input[data-set-index="0"][data-side="1"]`),r=O.querySelector(`input[data-set-index="0"][data-side="2"]`);e.disabled=!(t.length>1||n?.value.trim()!==``||r?.value.trim()!==``)}},ie=e=>{let t=O.querySelector(`input[data-set-index="${e}"][data-side="1"]`),n=O.querySelector(`input[data-set-index="${e}"][data-side="2"]`),r=O.querySelector(`.set-row:nth-child(${e+1}) .tiebreak-container`),i=O.querySelector(`input[data-set-index="${e}"][data-type="tiebreak"]`);!t||!n||!r||(ws(e,{side1:Number.parseInt(t.value)||0,side2:Number.parseInt(n.value)||0},c)?r.style.display=`inline`:(r.style.display=`none`,i&&(i.value=``)))},ae=(e,t)=>{let n=t===`1`?`2`:`1`,r=O.querySelector(`input[data-set-index="${e}"][data-side="${n}"]`),i=O.querySelector(`input[data-set-index="${e}"][data-side="${t}"]`),a=Number.parseInt(i?.value)||0,o=Number.parseInt(r?.value)||0;return _s(e,t===`1`?1:2,{side1:t===`1`?a:o,side2:t===`2`?a:o},c)};function oe(){p=Ds,m=void 0,y.querySelectorAll(Bs).forEach(e=>e.checked=!1),C.style.display=`none`}function se(e,t,n,r){let i=d(n)?.tiebreakSet?.tiebreakTo!==void 0;if(t)e.value.length>2&&(e.value=e.value.slice(0,2));else if(i)e.value.length>3&&(e.value=e.value.slice(0,3));else{let t=ae(n,r);(Number.parseInt(e.value)||0)>t&&(e.value=t.toString())}}function ce(e,t){if(d(e)?.tiebreakSet?.tiebreakTo!==void 0)return;let n=t===`1`?`2`:`1`,r=O.querySelector(`input[data-set-index="${e}"][data-side="${n}"]`);if(r?.value.trim()){let t=Number.parseInt(r.value)||0,i=ae(e,n);t>i&&(r.value=i.toString())}}function le(e){if(!ne(e)||bs(z,l(),u())||!ps(z,n.matchUpFormat))return;let t=z.length,r=O.querySelector(`input[data-set-index="${t}"]`);if(t<l()&&!r){let e=te(t);O.appendChild(e),e.querySelectorAll(`input`).forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)}),re()}}let ue=e=>{let t=e.target,n=t.dataset.type===`tiebreak`;p!==Ds&&t.value&&oe();let r=t.value.replace(/\D/g,``);r!==t.value&&(t.value=r);let i=Number.parseInt(t.dataset.setIndex||`0`),a=t.dataset.side||`1`;se(t,n,i,a),n||(ie(i),ce(i,a)),V(),re(),le(i)},de=e=>{e.focus(),e.select()};function fe(e){let t=te(e);O.appendChild(t);let n=t.querySelectorAll(`input`);n.forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)});let r=n[0];r instanceof HTMLInputElement&&de(r),re()}function pe(e,t,n){let r=rs()?.smartComplements===!0,i=e.code.match(/^Digit(\d)$/);if(!i||t.value!==``)return!1;let a=Cs(Number.parseInt(i[1]),e.shiftKey,n,z,c,h,r);if(!a.shouldApply)return!1;e.preventDefault(),t.value=a.field1Value.toString();let o=O.querySelector(`input[data-set-index="${n}"][data-side="2"]`);return o&&(o.value=a.field2Value.toString()),h.add(n),t.dispatchEvent(new Event(`input`,{bubbles:!0})),setTimeout(()=>{if(V(),bs(z,l(),u()))return;let e=O.querySelector(`input[data-set-index="${n+1}"][data-side="1"]`);e?de(e):n+1<l()&&fe(n+1)},10),!0}function me(e,t,n){if(n){let t=O.querySelector(`input[data-set-index="${e}"][data-side="2"]`);t&&de(t)}else if(t===`2`){let t=O.querySelector(`input[data-set-index="${e}"][data-side="1"]`);t&&de(t)}else e>0&&he(e)}function he(e){let t=O.querySelector(`input[data-set-index="${e-1}"][data-type="tiebreak"]`),n=O.querySelector(`input[data-set-index="${e-1}"][data-side="2"]`),r=t?.closest(Hs);t&&r&&r.style.display!==`none`?de(t):n&&de(n)}function ge(e){let t=O.querySelector(`input[data-set-index="${e}"][data-type="tiebreak"]`),n=t?.closest(Hs);if(t&&n&&n.style.display!==`none`){de(t);return}let r=O.querySelector(`input[data-set-index="${e+1}"][data-side="1"]`);if(r)de(r);else if(e+1<l()){if(!ne(e)||bs(z,l(),u()))return;fe(e+1)}}function _e(e){let t=O.querySelector(`input[data-set-index="${e+1}"][data-side="1"]`);if(t)de(t);else if(e+1<l()){if(!ne(e)||(V(),bs(z,l(),u())))return;fe(e+1)}}let ve=e=>{let t=e.target,n=Number.parseInt(t.dataset.setIndex||`0`),r=t.dataset.side||`1`,i=t.dataset.type===`tiebreak`;if(!(r===`1`&&!i&&pe(e,t,n))){if(e.key===`Tab`)if(e.preventDefault(),e.shiftKey)me(n,r,i);else if(i)_e(n);else if(r===`1`){let e=O.querySelector(`input[data-set-index="${n}"][data-side="2"]`);e&&de(e)}else r===`2`&&(V(),ge(n));if(e.key===`Enter`){let e=document.getElementById(`submitScoreV2`);e&&!e.disabled&&e.click()}e.key===`Backspace`&&t.value===``&&(e.preventDefault(),me(n,r,i))}},ye=te(0);if(O.appendChild(ye),ye.querySelectorAll(`input`).forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)}),g?.sets&&g.sets.length>0){let e=Math.ceil(l()/2),t=0,n=0,r=!1;g.sets.forEach((i,a)=>{if(r)return;if(a>0){let e=te(a);O.appendChild(e),e.querySelectorAll(`input`).forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)})}let o=O.querySelector(`input[data-set-index="${a}"][data-side="1"]`),s=O.querySelector(`input[data-set-index="${a}"][data-side="2"]`),c=O.querySelector(`input[data-set-index="${a}"][data-type="tiebreak"]`);if(o&&s&&(o.value=i.side1Score?.toString()||``,s.value=i.side2Score?.toString()||``,ie(a),c&&(i.side1TiebreakScore!==void 0||i.side2TiebreakScore!==void 0)&&(i.winningSide===1&&i.side2TiebreakScore!==void 0?c.value=i.side2TiebreakScore.toString():i.winningSide===2&&i.side1TiebreakScore!==void 0?c.value=i.side1TiebreakScore.toString():i.side1TiebreakScore===void 0?i.side2TiebreakScore!==void 0&&(c.value=i.side2TiebreakScore.toString()):c.value=i.side1TiebreakScore.toString())),i.side1PointScore!==void 0||i.side2PointScore!==void 0){let e=i.side1PointScore?.toString()||`0`,t=i.side2PointScore?.toString()||`0`;setTimeout(()=>{R(),A&&(L(e,t),N=!0,V(),N=!1)},0)}i.winningSide===1&&t++,i.winningSide===2&&n++,r=(t>=e||n>=e)&&(!u()||a+1>=u())})}else B();n.matchUpStatus&&n.matchUpStatus!==Ds&&[Os,ks,As,js,Ms].includes(n.matchUpStatus)&&(n.matchUpStatus===js?(p=ks,m=void 0):n.matchUpStatus===Ms?(p=As,m=void 0):(p=n.matchUpStatus,m=n.winningSide),y.querySelectorAll(Bs).forEach(e=>{e.value===p&&(e.checked=!0)}),m&&(y.querySelectorAll(Vs).forEach(e=>{Number.parseInt(e.value)===m&&(e.checked=!0)}),C.style.display=`block`)),g?.sets&&g.sets.length>0?V():p===Ds?(y.style.display=`none`,C.style.display=`none`):B(),setTimeout(()=>{let e=O.querySelector(`input`);e&&e.focus()},100)}function Ws(e,n){let{matchUpFormat:r}=n;if(!e)return``;let i=t.matchUpFormatCode.parse(r),a=i?.setFormat?.bestOf||3,o=e=>e===a&&i?.finalSetFormat?i.finalSetFormat:i?.setFormat,s=``,c=0,l=e.split(/[\s/]+|--+/).filter(e=>e.length>0);for(let e of l){let t={pos:0};for(;t.pos<e.length&&c<a;){let n=Ys(e,t,c,a,o);if(s&&(s+=` `),s+=n.formatted,n.complete)c++;else break}}return s}function Gs(e,t,n){let r=n(e+1),i=r?.tiebreakSet?.tiebreakTo,a=r?.setTo,o=!!i&&!a,s=r?.timed===!0,c=s?999:i||a||6;return{isTiebreakOnly:o,isTimed:s,setTo:c,tiebreakAt:r?.tiebreakAt||c,maxScore:s?999:c+1}}function Ks(e,t,n,r,i){let a=``;for(;t.pos<e.length;){let o=e[t.pos];if(o===`-`){if(!n)break;if(a.length>0){t.pos++;break}break}if(n){a+=o,t.pos++;continue}if(Number.parseInt(a+o)>r+i||a.length>=2)break;a+=o,t.pos++;let s=Number.parseInt(a);if(a.length===1&&s!==1&&r<10){if(t.pos<e.length&&e[t.pos]===`-`)continue;break}}return a}function qs(e,t,n){let r=!1,i=e,a=t;return i>n+1&&(i=n,r=!0),a>n+1&&(a=n,r=!0),i===n+1&&a<n-1?(i=n,r=!0):a===n+1&&i<n-1&&(a=n,r=!0),{s1:i,s2:a,side1:i.toString(),side2:a.toString(),wasCoerced:r}}function Js(e,t){let n=``;for(;t.pos<e.length;){let r=e[t.pos];if(r===`-`){t.pos++;break}n+=r,t.pos++}return n}function Ys(e,t,n,r,i){let a=Gs(n,r,i),o=a.isTiebreakOnly||a.isTimed,s=Ks(e,t,o,a.maxScore,0);t.pos<e.length&&e[t.pos]===`-`&&t.pos++;let c=Ks(e,t,o,a.maxScore,3);if(!c)return{formatted:s,complete:!1};let l=Number.parseInt(s),u=Number.parseInt(c),d=s,f=c,p=!1;if(!a.isTiebreakOnly&&!a.isTimed){let e=qs(l,u,a.setTo);l=e.s1,u=e.s2,d=e.side1,f=e.side2,p=e.wasCoerced}let m=Math.abs(l-u),h=Math.max(l,u),g=a.isTimed||h>=a.setTo&&m>=2,_=t.pos<e.length,v=l===a.tiebreakAt&&u===a.tiebreakAt,y=l===a.tiebreakAt+1&&u===a.tiebreakAt||u===a.tiebreakAt+1&&l===a.tiebreakAt;if(!p&&(v||y&&_)){let n=Js(e,t);return n?{formatted:`${d}-${f}(${n})`,complete:!0}:{formatted:`${d}-${f}(`,complete:!1}}return a.isTiebreakOnly?{formatted:`[${d}-${f}]`,complete:g}:{formatted:`${d}-${f}`,complete:g}}var{COMPLETED:Xs,RETIRED:Zs,WALKOVER:Qs,DEFAULTED:$s,DOUBLE_WALKOVER:ec,DOUBLE_DEFAULT:tc}=t.matchUpStatusConstants,nc=`SET3-S:6/TB7`,rc=`var(--chc-text-secondary)`,ic=`var(--chc-bg-secondary)`,ac=`input[name="matchOutcome"]`,oc=`input[name="irregularWinner"]`;function sc(e){if(!e?.sets||e.sets.length===0)return``;let t=[];return e.sets.forEach((e,n)=>{if(n>0&&t.push(` `),t.push(e.side1Score?.toString()||`0`),t.push(e.side2Score?.toString()||`0`),e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0){let n=e.winningSide===1?e.side2TiebreakScore:e.side1TiebreakScore;n!==void 0&&(t.push(`-`),t.push(n.toString()))}}),t.join(``)}function cc(e){let{matchUp:n,container:r,onScoreChange:i,labels:a={}}=e;try{r.innerHTML=``,r.style.display=`flex`,r.style.flexDirection=`column`,r.style.gap=`1em`;let e=t.matchUpFormatCode.parse(n.matchUpFormat||nc),o=e?.setFormat?.setTo||6,s=e?.setFormat?.tiebreakAt||o,c=n.score?{...n.score}:void 0,l=n.winningSide,u=n.matchUpStatus,d={digits:``,setTo:o,tiebreakAt:s,isMatchComplete:!1};if(c){d.digits=sc(c);let e=Ws(d.digits,{matchUpFormat:n.matchUpFormat||nc});if(e&&e.includes(`-`)){let t=us(e,n.matchUpFormat);d.isMatchComplete=t.isValid&&t.winningSide!==void 0&&(t.matchUpStatus===Xs||t.matchUpStatus===void 0)}}let f=document.createElement(`div`);if(f.style.marginBottom=`0.5em`,r.appendChild(f),e?.aggregate){let e=document.createElement(`div`);e.style.fontSize=`0.75em`,e.style.color=rc,e.style.marginTop=`0.25em`,e.style.marginBottom=`0.5em`,e.style.padding=`0.25em 0.5em`,e.style.backgroundColor=ic,e.style.border=`1px solid var(--chc-status-warning)`,e.style.borderRadius=`3px`,e.textContent=`⚠️ Aggregate Scoring: Winner determined by total points across all sets`,r.appendChild(e)}if(n.matchUpFormat){let e=document.createElement(`div`);e.style.fontSize=`0.9em`,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=rc,e.appendChild(t);let o=document.createElement(`button`);o.textContent=n.matchUpFormat,o.className=`button is-small is-white`,o.style.fontSize=`0.75em`,o.style.padding=`0.2em 0.5em`,o.style.cursor=`pointer`,o.title=`Click to edit format`,o.addEventListener(`click`,()=>{try{Ca({existingMatchUpFormat:n.matchUpFormat,callback:e=>{e&&e!==n.matchUpFormat&&(n.matchUpFormat=e,o.textContent=e,d.digits=``,r.innerHTML=``,cc({matchUp:n,container:r,onScoreChange:i,labels:a}))},modalConfig:{style:{fontSize:`12px`,border:`3px solid #0066cc`}}})}catch(e){console.error(`Error opening format selector:`,e)}}),e.appendChild(o),r.appendChild(e)}let p=document.createElement(`div`);p.style.fontSize=`1.2em`,p.style.color=`#64B5F6`,p.style.textAlign=`center`,p.style.padding=`0.25em 0.5em`,p.style.fontWeight=`bold`,p.style.minHeight=`1.5em`,p.style.maxWidth=`300px`,p.style.margin=`0 auto`,p.textContent=`-`,r.appendChild(p);let m=Xs,h,g=document.createElement(`div`);g.style.display=`none`,g.style.marginBottom=`0.8em`,g.style.padding=`0.6em`,g.style.backgroundColor=ic,g.style.border=`2px solid var(--chc-status-warning)`,g.style.borderRadius=`4px`;let _=document.createElement(`div`);_.textContent=(a.irregularEnding||`Irregular Ending`)+`:`,_.style.fontSize=`0.8em`,_.style.fontWeight=`600`,_.style.marginBottom=`0.3em`,_.style.color=rc,g.appendChild(_);let v=document.createElement(`div`);v.style.display=`none`,v.style.marginTop=`0.3em`;let y=document.createElement(`div`);y.textContent=(a.winner||`Winner`)+`:`,y.style.fontSize=`0.75em`,y.style.fontWeight=`500`,y.style.marginBottom=`0.2em`,y.style.color=rc,v.appendChild(y);let b=document.createElement(`div`);b.style.display=`flex`,b.style.gap=`0.5em`,b.style.flexWrap=`wrap`;let x=n.sides?.[0],S=n.sides?.[1];[1,2].forEach(e=>{let t=document.createElement(`label`);t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`0.3em`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`radio`,n.name=`irregularWinner`,n.value=e.toString(),n.addEventListener(`change`,()=>{n.checked&&(h=e,E())});let r=document.createElement(`span`);r.textContent=(e===1?x:S)?.participant?.participantName||`Side ${e}`,r.style.fontSize=`0.75em`,r.style.color=rc,t.appendChild(n),t.appendChild(r),b.appendChild(t)}),v.appendChild(b),g.appendChild(v),r.appendChild(g);let C=document.createElement(`div`);C.style.display=`grid`,C.style.gridTemplateColumns=`repeat(4, 1fr)`,C.style.gap=`8px`,C.style.width=`100%`,C.style.maxWidth=`320px`,C.style.margin=`0 auto`,r.appendChild(C);let w=e=>Ws(e,{matchUpFormat:n.matchUpFormat||nc}),T=e=>{f.innerHTML=``;let t=e?.scoreObject?.sets?.length>0;e?.clearAll?(c=void 0,l=void 0,u=void 0):e!=null&&(t&&(c=e?.scoreObject),`winningSide`in e&&(l=e?.winningSide),`matchUpStatus`in e&&(u=e?.matchUpStatus));let r=Wr({matchUp:{...n,score:e?.clearAll?void 0:t?c:void 0,winningSide:l,matchUpStatus:u},isLucky:!0,composition:ri[es().composition||`Australian`]||ri.Australian});r&&f.appendChild(r)},E=(e=!1)=>{let t=w(d.digits);if(t?(p.style.display=`block`,p.textContent=t):(p.style.display=`block`,p.textContent=`-`),m===Zs||m===Qs||m===$s?(g.style.display=`block`,v.style.display=`block`):(g.style.display=`none`,v.style.display=`none`),e){T({clearAll:!0});return}let r=us(t,n.matchUpFormat);d.isMatchComplete=r.isValid&&r.winningSide!==void 0&&(r.matchUpStatus===Xs||r.matchUpStatus===void 0),m!==Xs&&(h?(r.matchUpStatus=m,r.winningSide=h,r.isValid=!0):m===Qs?(r.matchUpStatus=ec,r.isValid=!0):m===$s?(r.matchUpStatus=tc,r.isValid=!0):(r.matchUpStatus=m,r.isValid=!1),d.isMatchComplete=!1),T(r),i(r);let a=document.getElementById(`clearScoreV2`);a&&(a.disabled=d.digits.length===0&&m===Xs),A(),j()},D=e=>{m!==Xs&&typeof e==`number`&&(m=Xs,h=void 0,g.querySelectorAll(ac).forEach(e=>e.checked=!1),v.style.display=`none`),typeof e==`number`&&d.digits===``&&e>o&&(e=o);let r=w(d.digits),i=r.includes(`(`)&&!r.includes(`)`),a=d.digits.includes(`-`),s=(d.digits.match(/-/g)||[]).length,c=r.includes(`[`)&&a&&s===1,l=(r?us(r,n.matchUpFormat):null)?.sets?.length||0,u=t.matchUpFormatCode.parse(n.matchUpFormat),f=u?.setFormat?.bestOf||3,p=e=>{let t=e===f&&u?.finalSetFormat?u.finalSetFormat:u?.setFormat,n=t?.tiebreakSet?.tiebreakTo,r=t?.setTo;return!!n&&!r},_=l<f&&p(l+1),y=l>0&&p(l),b=i||c||_||y,x=w(e===`-`?d.digits+`-`:d.digits+e.toString());if(r){let t=us(r,n.matchUpFormat),i=t.sets?.[t.sets.length-1],a=r.includes(`(`),o=x.includes(`(`),s=a&&o&&x!==r&&x.startsWith(r.substring(0,r.lastIndexOf(`)`))),c=i&&(i.side1TiebreakScore===void 0&&i.side2TiebreakScore===void 0||i.side1TiebreakScore==null&&i.side2TiebreakScore==null||s)&&i.side1Score!==void 0&&i.side2Score!==void 0&&(i.side1Score===i.side2Score||Math.abs(i.side1Score-i.side2Score)===1);if(t.isValid&&t.winningSide&&!b&&!c||!b&&e!==`-`&&x===r)return}e===`-`?d.digits.endsWith(`-`)||(d.digits+=`-`):d.digits+=e.toString(),E()},O=()=>{d.digits.length>0&&(d.digits=d.digits.slice(0,-1),E())},k=()=>{d.digits=``,d.isMatchComplete=!1,m=Xs,h=void 0,c=void 0,l=void 0,u=void 0,g.querySelectorAll(oc).forEach(e=>e.checked=!1),g.querySelectorAll(ac).forEach(e=>e.checked=!1),g.style.display=`none`,v.style.display=`none`,p.style.display=`block`,p.textContent=`-`,T({clearAll:!0}),j(),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`})};globalThis.resetDialPad=k;let A=()=>{let e=C.querySelector(`[data-button="retired"]`),t=C.querySelector(`[data-button="defaulted"]`),n=w(d.digits),r=!(n.includes(`-`)&&n.length>2)||d.isMatchComplete;e&&(e.disabled=r),t&&(t.disabled=r)},j=()=>{let e=m!==Xs&&h!==void 0||d.isMatchComplete;C.querySelectorAll(`button`).forEach(t=>{let n=t.textContent||``;(n.match(/^[0-9]$/)||n===`-`)&&(t.disabled=e)})};[{label:`1`,value:1},{label:`2`,value:2},{label:`3`,value:3},{label:`RET`,value:`retired`,isSpecial:!0,requiresScore:!0},{label:`4`,value:4},{label:`5`,value:5},{label:`6`,value:6},{label:`WO`,value:`walkover`,isSpecial:!0},{label:`7`,value:7},{label:`8`,value:8},{label:`9`,value:9},{label:`DEF`,value:`defaulted`,isSpecial:!0,requiresScore:!0},{label:`⌫`,value:`delete`,isSpecial:!0},{label:`0`,value:0},{label:`-`,value:`minus`,isSpecial:!0},{label:``,value:`empty`,isSpecial:!0,disabled:!0}].forEach(e=>{let t=document.createElement(`button`);t.className=`button is-white`,t.textContent=e.label,t.style.cssText=`
|
|
138
|
+
`;let d=n&&![`IN_PROGRESS`,`COMPLETED`,`TO_BE_PLAYED`].includes(n)?[`IN_PROGRESS`,`RETIRED`,`DEFAULTED`,`WALKOVER`,`SUSPENDED`,`CANCELLED`,`ABANDONED`]:[`RETIRED`,`DEFAULTED`,`WALKOVER`,`SUSPENDED`,`CANCELLED`,`ABANDONED`];for(let e of d){let t=Vn({matchUpStatus:e});t.classList.add(`chc-live-chip-popover-item`),t.onclick=t=>{t.stopPropagation(),a.remove(),document.removeEventListener(`click`,f),r(e)},a.appendChild(t)}document.body.appendChild(a);let f=e=>{a.contains(e.target)||(a.remove(),document.removeEventListener(`click`,f))};setTimeout(()=>document.addEventListener(`click`,f),0)}function $o(e,t){let n=e.isComplete(),r=e.getInputMode();if(r===`none`&&t.score?.sets?.length)return{...t,matchUpStatus:n?`COMPLETED`:t.matchUpStatus||`IN_PROGRESS`,winningSide:e.getWinner()??t.winningSide??void 0};let i=e.getScore(),a=i.pointDisplay&&(r===`points`||r===`mixed`),o=(i.sets||[]).map((e,t)=>({setNumber:t+1,side1Score:e.side1Score,side2Score:e.side2Score,side1TiebreakScore:e.side1TiebreakScore,side2TiebreakScore:e.side2TiebreakScore,winningSide:e.winningSide,...a&&!e.winningSide&&!n&&{side1PointScore:i.pointDisplay[0],side2PointScore:i.pointDisplay[1]}})),s=t.matchUpStatus&&[`RETIRED`,`DEFAULTED`,`WALKOVER`,`DOUBLE_WALKOVER`,`DOUBLE_DEFAULT`].includes(t.matchUpStatus);if(!n&&!s){let e=o.length>0&&o.every(e=>e.winningSide);(o.length===0||e)&&o.push({setNumber:o.length+1,side1Score:0,side2Score:0})}if(!n&&!s&&o.length>0){let e=o[o.length-1];!e.winningSide&&e.side1PointScore==null&&e.side2PointScore==null&&(e.side1PointScore=`0`,e.side2PointScore=`0`)}let c=e.getWinner();return{...t,matchUpStatus:n?`COMPLETED`:t.matchUpStatus||`IN_PROGRESS`,winningSide:c??t.winningSide??void 0,score:{sets:o,scoreStringSide1:e.getScoreboard()||void 0}}}var{ScoringEngine:es}=t.scoreGovernor,ts=class{constructor(e){this.engines=new Map,this.callbacks=e||{}}getOrCreate(e,t,n){let r=this.engines.get(e);if(r)return r;let i=new es({matchUpFormat:t});if(n?.score?.sets?.length)try{let e=n.score.sets,t=e.filter(e=>e.winningSide),r=e.find(e=>!e.winningSide),a;if(r?.side1PointScore!=null&&r?.side2PointScore!=null){let e=e=>{let t=String(e);if(t===`0`)return 0;if(t===`15`)return 1;if(t===`30`)return 2;if(t===`40`)return 3;if(t===`AD`)return 4;let n=Number(e);return isNaN(n)?0:n};a={side1Points:e(r.side1PointScore),side2Points:e(r.side2PointScore)}}i.setInitialScore({sets:t,...r&&{currentSetScore:{side1Score:r.side1Score||0,side2Score:r.side2Score||0}},...a&&{currentGameScore:a},matchUpStatus:n.matchUpStatus,winningSide:n.winningSide})}catch{}return r={engine:i,matchUpFormat:t,pointCount:0},this.engines.set(e,r),r}get(e){return this.engines.get(e)}has(e){return this.engines.has(e)}addPoint(e,t,n){let r=this.engines.get(e);if(!r||r.engine.isComplete())return;let i=r.pointCount%2;return r.engine.addPoint({winner:t,server:i,result:`Winner`}),r.pointCount++,this.notifyAndReturn(e,n)}addGame(e,t,n){let r=this.engines.get(e);if(!(!r||r.engine.isComplete()))return r.engine.addGame({winner:t}),this.notifyAndReturn(e,n)}addSet(e,t,n,r){let i=this.engines.get(e);if(!(!i||i.engine.isComplete()))return i.engine.addSet({side1Score:t,side2Score:n}),this.notifyAndReturn(e,r)}undo(e,t){let n=this.engines.get(e);if(!(!n||!n.engine.canUndo()))return n.engine.undo(),n.pointCount>0&&n.pointCount--,this.notifyAndReturn(e,t)}redo(e,t){let n=this.engines.get(e);if(!(!n||!n.engine.canRedo()))return n.engine.redo(),n.pointCount++,this.notifyAndReturn(e,t)}reset(e,t){let n=this.engines.get(e);if(n)return n.engine.reset(),n.pointCount=0,this.notifyAndReturn(e,t)}getMatchUp(e,t){let n=this.engines.get(e);return n?$o(n.engine,t):t}getSituation(e){let t=this.engines.get(e);if(t)return t.engine.getScore()?.situation}canUndo(e){return this.engines.get(e)?.engine.canUndo()??!1}canRedo(e){return this.engines.get(e)?.engine.canRedo()??!1}isComplete(e){return this.engines.get(e)?.engine.isComplete()??!1}remove(e){this.engines.delete(e)}clear(){this.engines.clear()}notifyAndReturn(e,t){let n=this.engines.get(e),r=$o(n.engine,t);if(this.callbacks.onScoreChange?.({matchUpId:e,matchUp:r,engine:n.engine}),n.engine.isComplete()){let t=n.engine.getWinner();t!=null&&this.callbacks.onMatchComplete?.({matchUpId:e,winningSide:t,engine:n.engine})}return r}},ns={scoringApproach:`dynamicSets`,smartComplements:!0,composition:`Australian`,idiom:`en`,dateFormat:`YYYY-MM-DD`,timeFormat:`HH:mm`},rs={...ns};function is(){return{...rs}}function as(e){rs={...rs,...e}}function os(){rs={...ns}}function ss(){return{scoringApproach:rs.scoringApproach,smartComplements:rs.smartComplements,composition:rs.composition}}function cs(e){let{matchUp:t,container:n,onScoreChange:r}=e;n.innerHTML=``,n.style.display=`flex`,n.style.flexDirection=`column`,n.style.gap=`0.5em`;let i=si[is().composition||`Australian`]||si.Australian,a={...i,configuration:{...i.configuration,matchUpFooter:!0,inlineScoring:{mode:`games`,showFooter:!0,showSituation:!0}}},o=t.matchUpFormat||`SET3-S:6/TB7`,s={...t,matchUpStatus:`IN_PROGRESS`,readyToScore:!0,winningSide:void 0},c=(e,t)=>{let n=e?.score?.sets||[];r({isValid:t||n.some(e=>e.side1Score||e.side2Score),sets:n,winningSide:e?.winningSide,matchUpStatus:e?.matchUpStatus,matchUpFormat:o,score:e?.score?.scoreStringSide1})},l=new ts({onScoreChange:({matchUpId:e,matchUp:t})=>{c(t,l.isComplete(e))},onMatchComplete:({matchUpId:e})=>{c(l.getMatchUp(e,s),!0)},onEndMatch:({matchUpId:e,matchUpStatus:t})=>{c({...l.getMatchUp(e,s),matchUpStatus:t},!0)}}),u=Zo({matchUp:s,composition:a,manager:l,matchUpFormat:o,isLucky:!0});n.appendChild(u),globalThis.resetInlineScoring=()=>{l.reset(t.matchUpId,s),n.innerHTML=``;let e=Zo({matchUp:{...t,matchUpStatus:`IN_PROGRESS`,readyToScore:!0,winningSide:void 0},composition:a,manager:l,matchUpFormat:o,isLucky:!0});n.appendChild(e),r({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`})}}var{COMPLETED:ls}=t.matchUpStatusConstants,{validateMatchUpScore:us,validateSetScore:ds}=t.governors.scoreGovernor;function fs(e,t,n,r,i){let a=n?.finalSetFormat?.tiebreakSet?.tiebreakTo&&!n?.finalSetFormat?.setTo,o=n?.setFormat?.tiebreakSet?.tiebreakTo&&!n?.setFormat?.setTo,s=n?.finalSetFormat?.tiebreakSet?.tiebreakTo===1,c=n?.setFormat?.tiebreakSet?.tiebreakTo===1;for(let n=0;n<e.length;n++){let l=e[n],u=n+1,d=u===t,f=l.startsWith(`[`)&&l.endsWith(`]`),p=(l===`1-0`||l===`0-1`)&&(d&&s||c),m=o||d&&a;if(!m&&f)return{isValid:!1,sets:r,scoreObject:i,error:`Set ${u}: Format expects regular set (e.g., 6-4), but got tiebreak-only set ${l}`};if(m&&!f&&!p)return{isValid:!1,sets:r,scoreObject:i,error:`Set ${u}: Format expects tiebreak-only set (e.g., [10-8]), but got regular set ${l}`}}return null}function ps(e,t,n,r,i){if(e||t===void 0)return!1;let a=!!i?.aggregate,o=!!i?.exactly;if(a)return n.filter(e=>e.side1Score!==void 0&&e.side2Score!==void 0).length>=r;{let e=Math.ceil(r/2),t={side1:0,side2:0};return n.forEach(e=>{e.winningSide===1?t.side1++:e.winningSide===2&&t.side2++}),!(!(t.side1>=e||t.side2>=e)||o&&n.length<r)}}function ms(e,n,r){let{WALKOVER:i,CANCELLED:a,DEAD_RUBBER:o}=t.matchUpStatusConstants,s=[i,a,o];if(!e?.trim())return r&&s.includes(r)?{isValid:!0,sets:[],matchUpStatus:r,scoreObject:void 0}:{isValid:!1,sets:[],error:`Score is required`};try{let{outcome:i,error:a}=t.tournamentEngine.generateOutcomeFromScoreString({scoreString:e.trim(),matchUpFormat:n,preserveSideOrder:!0});if(a||!i?.score?.sets)return{isValid:!1,sets:[],error:a||`Invalid score format`};let o=i.score.sets,s=i.score,c=e.trim().split(/\s+/).filter(e=>e.length>0),l=t.matchUpFormatCode.parse(n),u=l?.exactly||l?.bestOf||3,d=fs(c,u,l,o,s);if(d)return d;let f=!1,p=o.map((e,t)=>{if(!ds(e,n,t+1===u,!1).isValid){f=!0;let{...t}=e;return t}return e}),m={...s,sets:p},h=us(p,n,r);if(!h.isValid)return{isValid:!1,sets:p,scoreObject:m,error:h.error};let g=Math.ceil(u/2),_=f?void 0:i.winningSide;return ps(f,_,p,u,l)?{isValid:!0,sets:p,scoreObject:m,winningSide:_,matchUpStatus:ls,matchUpFormat:n,score:e.trim()}:{isValid:!1,sets:p,scoreObject:m,error:`Incomplete match - need ${g} sets to win`}}catch(e){return{isValid:!1,sets:[],error:e instanceof Error?e.message:`Invalid score format`}}}function hs(e,t,n){if(!e||e.length===0)return{isValid:!1,sets:[],error:`At least one set is required`};let r=e.map(e=>{let t=e.side1??``,n=e.side2??``;if((!t||t===0)&&(!n||n===0)&&e.side1TiebreakScore!==void 0&&e.side2TiebreakScore!==void 0)return`[${e.side1TiebreakScore}-${e.side2TiebreakScore}]`;if(t===``||n===``)return``;if(e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0){let r=e.side1TiebreakScore??0,i=e.side2TiebreakScore??0;return`${t}-${n}(${Number(t)>Number(n)?i:r})`}return`${t}-${n}`}).filter(e=>e!==``).join(` `);return r?ms(r,t,n?void 0:ls):{isValid:!1,sets:[],error:`At least one complete set is required`}}function gs(e){if(!e)return{bestOf:3,setsToWin:2,isTimed:!1,isExactlyFormat:!1};let n=t.matchUpFormatCode.parse(e);if(!n)return{bestOf:3,setsToWin:2,isTimed:!1,isExactlyFormat:!1};let r=!!(n.setFormat?.timed||n.finalSetFormat?.timed),i=!!n.exactly||n.bestOf===1,a=n.exactly||n.bestOf||3,o=Math.ceil(a/2);return{bestOf:n.bestOf||a,exactly:n.exactly,setsToWin:o,isTimed:r,isExactlyFormat:i}}function _s(e,n){if(!e||e.length===0)return!0;let r=gs(n),{bestOf:i,isExactlyFormat:a,setsToWin:o}=r,s=r.exactly||i;if(a){if(e.length>=s)return!1;let i=t.matchUpFormatCode.parse(n),a=!!i?.aggregate,o=i?.finalSetFormat?.tiebreakSet?.tiebreakTo!==void 0;if(a&&o&&r.isTimed){let t=s-1;if(e.length<t)return!0;if(e.length===t){let t=e.reduce((e,t)=>(t.side1Score!==void 0&&t.side1Score!==null&&(e.side1+=t.side1Score),t.side2Score!==void 0&&t.side2Score!==null&&(e.side2+=t.side2Score),e),{side1:0,side2:0});return t.side1===t.side2}else return!1}return!0}let c={side1:0,side2:0};return e.forEach(e=>{let t=e.side1Score??0,n=e.side2Score??0;t>n?c.side1++:n>t&&c.side2++}),c.side1>=o||c.side2>=o||e.length>=i?!1:e.every(e=>e.side1Score!==void 0&&e.side2Score!==void 0&&e.side1Score!==null&&e.side2Score!==null)}function vs(e,t){return(t.bestOf===1||e+1===t.bestOf)&&t.finalSetFormat?t.finalSetFormat:t.setFormat}function ys(e){return e?.tiebreakSet?.tiebreakTo!==void 0}function bs(e){return e?.timed===!0&&e?.minutes!==void 0}function xs(e,t,n,r){let i=vs(e,r);if(bs(i))return 1/0;let a=i?.setTo||6,o=i?.tiebreakAt||a,s=t===1?n.side2:n.side1,c=o===a?a+1:a;return s===0?c:s<o-1?a:s===o-1?o===a?a+1:a:s===o?c:s>o&&s<a?a:s===a?o===a?a+2:o:s>a?s+2:c}function Ss(e,t,n){let r=vs(e,n);if(bs(r))return t.side1!==void 0&&t.side1!==null&&t.side2!==void 0&&t.side2!==null;if(ys(r))return t.side1>0&&t.side2>0&&t.side1!==t.side2;let i=r?.setTo||6,a=r?.tiebreakAt||i,o=Math.max(t.side1,t.side2),s=Math.min(t.side1,t.side2),c=Math.abs(t.side1-t.side2);return o>=i&&c>=2||(a===i?o===a+1&&s===a:o===i&&s===a)&&t.tiebreak!==void 0}function Cs(e,t,n){if(Ss(e,t,n)){if(t.side1>t.side2)return 1;if(t.side2>t.side1)return 2}}function ws(e,t,n){let r=Math.ceil(t/2),i=e.filter(e=>e.winningSide===1).length,a=e.filter(e=>e.winningSide===2).length;return i>=r||a>=r?n?e.filter(e=>e.side1Score!==void 0&&e.side2Score!==void 0).length>=n:!0:!1}function Ts(e,t,n){if(!ws(e,t,n))return;let r=Math.ceil(t/2),i=e.filter(e=>e.winningSide===1).length,a=e.filter(e=>e.winningSide===2).length;if(i>=r)return 1;if(a>=r)return 2}function Es(e,t){let n=t?.setTo||6;if(e>=n)return null;let r=t?.tiebreakAt||n;return e<n-1?n:r===n?n+1:n}function Ds(e,t,n,r,i,a,o){if(!o)return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Feature disabled in settings`};if(a.has(n))return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Already used for this set`};if(ws(r,i.bestOf,i.exactly))return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Match already complete`};let s=vs(n,i);if(ys(s))return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Tiebreak-only set`};if(bs(s))return{field1Value:e,field2Value:0,shouldApply:!1,reason:`Timed set`};let c=Es(e,s);return c===null?{field1Value:e,field2Value:0,shouldApply:!1,reason:`No predictable complement for this digit`}:t?{field1Value:c,field2Value:e,shouldApply:!0}:{field1Value:e,field2Value:c,shouldApply:!0}}function Os(e,t,n){let r=vs(e,n);if(bs(r)||ys(r))return!1;let i=r?.setTo||6,a=r?.tiebreakAt||i,o=Math.max(t.side1,t.side2),s=Math.min(t.side1,t.side2);return a===i?o===a+1&&s===a:o===i&&s===a}function ks(e,t,n){if(e+1>=n.bestOf||ws(t,n.bestOf,n.exactly))return!1;let r=t[e];return r?r.winningSide!==void 0:!1}function As(e,t,n,r,i){let a=Number.parseInt(t)||0,o=Number.parseInt(n)||0,s=r?Number.parseInt(r):void 0,c=vs(e,i);if(ys(c)){let t=a>0&&o>0&&a!==o?a>o?1:2:void 0;return{setNumber:e+1,side1Score:0,side2Score:0,side1TiebreakScore:a,side2TiebreakScore:o,winningSide:t}}let l=Cs(e,{side1:a,side2:o,tiebreak:s},i),u={setNumber:e+1,side1Score:a,side2Score:o,winningSide:l};if(s!==void 0){let e=c?.tiebreakFormat?.tiebreakTo||7,t=c?.tiebreakFormat?.noAd,n;n=s<e-1?e:t?s+1:s+2,a>o?(u.side1TiebreakScore=n,u.side2TiebreakScore=s):(u.side1TiebreakScore=s,u.side2TiebreakScore=n)}return u}var{COMPLETED:js,RETIRED:Ms,WALKOVER:Ns,DEFAULTED:Ps,DOUBLE_WALKOVER:Fs,DOUBLE_DEFAULT:Is}=t.matchUpStatusConstants,Ls=`var(--chc-text-secondary)`,Rs=`var(--chc-text-primary)`;function zs(e){let t=e.side1Score===0&&e.side2Score===0&&(e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0),n=t?{side1TiebreakScore:e.side1TiebreakScore,side2TiebreakScore:e.side2TiebreakScore}:{side1:e.side1Score,side2:e.side2Score};return!t&&e.side1TiebreakScore!==void 0&&(n.side1TiebreakScore=e.side1TiebreakScore),!t&&e.side2TiebreakScore!==void 0&&(n.side2TiebreakScore=e.side2TiebreakScore),e.winningSide!==void 0&&(n.winningSide=e.winningSide),e.side1PointScore!==void 0&&(n.side1PointScore=e.side1PointScore),e.side2PointScore!==void 0&&(n.side2PointScore=e.side2PointScore),n}function Bs(e,t){if(t.sets&&t.scoreObject?.sets)for(let n=0;n<e.length&&n<t.scoreObject.sets.length;n++){let r=e[n];r.side1PointScore!==void 0&&(t.scoreObject.sets[n].side1PointScore=r.side1PointScore),r.side2PointScore!==void 0&&(t.scoreObject.sets[n].side2PointScore=r.side2PointScore)}if(t.sets)for(let n=0;n<e.length&&n<t.sets.length;n++){let r=e[n];r.side1PointScore!==void 0&&(t.sets[n].side1PointScore=r.side1PointScore),r.side2PointScore!==void 0&&(t.sets[n].side2PointScore=r.side2PointScore)}}function Vs(e,t,n,r){e===js?(r.style.display=`none`,n.style.display=t?`none`:`block`):(n.style.display=`block`,r.style.display=`block`)}function Hs(e,t,n){t!==js&&(n?(e.matchUpStatus=t,e.winningSide=n,e.isValid=!0):t===Ns?(e.matchUpStatus=Fs,e.isValid=!0):t===Ps?(e.matchUpStatus=Is,e.isValid=!0):(e.matchUpStatus=t,e.isValid=!1))}function Us(e,t,n){if(t){let t=e.filter(e=>e.winningSide!==void 0).length;return Math.max(1,t)}let r=e.length-1;return r>=0&&e[r].winningSide!==void 0&&e.length<n?e.length+1:Math.max(1,e.length)}var Ws=`input[name="matchOutcome"]`,Gs=`input[name="irregularWinner"]`,Ks=`.tiebreak-container`;function qs(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.matchUpFormat||`SET3-S:6/TB7`,s=()=>{let e=gs(o),n=t.matchUpFormatCode.parse(o);return{bestOf:e.bestOf,exactly:n?.exactly,setFormat:n?.setFormat,finalSetFormat:n?.finalSetFormat}},c=s(),l=()=>c.bestOf,u=()=>c.exactly,d=e=>vs(e,c),f=document.createElement(`div`);if(f.style.marginBottom=`0.5em`,r.appendChild(f),n.matchUpFormat){let e=document.createElement(`div`);e.style.fontSize=`0.9em`,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=Ls,e.appendChild(t);let i=document.createElement(`button`);i.textContent=n.matchUpFormat,i.className=`button is-small is-white`,i.style.fontSize=`0.75em`,i.style.padding=`0.2em 0.5em`,i.style.cursor=`pointer`,i.title=`Click to edit format`,i.addEventListener(`click`,()=>{try{Da({existingMatchUpFormat:n.matchUpFormat,callback:e=>{e&&e!==n.matchUpFormat&&(n.matchUpFormat=e,o=e,i.textContent=e,c=s(),globalThis.resetDynamicSets&&globalThis.resetDynamicSets())},modalConfig:{style:{fontSize:`12px`,border:`3px solid #0066cc`}}})}catch(e){console.error(`[DynamicSets] Error opening format selector:`,e)}}),e.appendChild(i),r.appendChild(e)}let p=js,m,h=new Set,g=n.score?{...n.score}:void 0,_=n.winningSide,v=n.matchUpStatus,y=document.createElement(`div`);y.style.marginBottom=`0.8em`;let b=document.createElement(`div`);b.textContent=(a.irregularEnding||`Irregular Ending`)+`:`,b.style.fontSize=`0.75em`,b.style.fontWeight=`500`,b.style.marginBottom=`0.3em`,b.style.color=Rs,y.appendChild(b);let x=document.createElement(`div`);x.style.display=`flex`,x.style.gap=`0.5em`,x.style.flexWrap=`wrap`,[{value:Ms,label:a.retired||`Retired`},{value:Ns,label:a.walkover||`Walkover`},{value:Ps,label:a.defaulted||`Defaulted`}].forEach(e=>{let t=document.createElement(`label`);t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`0.3em`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`radio`,n.name=`matchOutcome`,n.value=e.value,n.checked=!1,n.addEventListener(`change`,e=>{if(p=e.target.value,p===Ns){O.querySelectorAll(`input`).forEach(e=>{e.value=``});let e=O.querySelectorAll(`.set-row`);for(let t=e.length-1;t>0;t--)e[t].remove();z=[],A=null,j=0,g=void 0}C.style.display=`block`,setTimeout(()=>{typeof V==`function`&&V()},0)});let r=document.createElement(`span`);r.textContent=e.label,r.style.fontSize=`0.75em`,t.appendChild(n),t.appendChild(r),x.appendChild(t)});let S=document.createElement(`button`);S.textContent=a.clear||`Clear`,S.className=`button`,S.style.fontSize=`0.7em`,S.style.padding=`0.2em 0.5em`,S.addEventListener(`click`,()=>{y.querySelectorAll(Ws).forEach(e=>e.checked=!1),p=js,m=void 0,C.style.display=`none`,v=void 0,_=void 0,y.querySelectorAll(Gs).forEach(e=>e.checked=!1),setTimeout(()=>{typeof V==`function`&&V()},0)}),x.appendChild(S),y.appendChild(x);let C=document.createElement(`div`);C.style.display=`none`,C.style.marginTop=`0.3em`,C.style.paddingLeft=`1em`,C.style.borderLeft=`3px solid var(--chc-clear-btn-bg)`;let w=document.createElement(`div`);w.textContent=(a.winner||`Winner`)+`:`,w.style.fontSize=`0.75em`,w.style.fontWeight=`500`,w.style.marginBottom=`0.2em`,w.style.color=Rs,C.appendChild(w);let T=document.createElement(`div`);T.style.display=`flex`,T.style.gap=`0.5em`;let E=n.sides?.[0],D=n.sides?.[1];[1,2].forEach(e=>{let t=document.createElement(`label`);t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`0.3em`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`radio`,n.name=`irregularWinner`,n.value=e.toString(),n.addEventListener(`change`,()=>{m=e,setTimeout(()=>{typeof V==`function`&&(N=!0,V(),N=!1)},0)});let r=document.createElement(`span`);r.textContent=(e===1?E:D)?.participant?.participantName||`Side ${e}`,r.style.fontSize=`0.75em`,t.appendChild(n),t.appendChild(r),T.appendChild(t)}),C.appendChild(T),y.appendChild(C),r.appendChild(y);let O=document.createElement(`div`);O.style.display=`flex`,O.style.flexDirection=`column`,O.style.gap=`0.5em`,r.appendChild(O);let{ScoringEngine:k}=t.scoreGovernor,A=null,j=0,M=!1,N=!1,P=e=>{if(!A)return;let t=j%2;A.addPoint({winner:e,server:t,result:`Winner`}),j++,N=!0,V(),N=!1},F=()=>{if(!n.matchUpFormat)return;A=new k({matchUpFormat:n.matchUpFormat}),j=0;let e=z.filter(e=>e.winningSide!==void 0).map(e=>({side1Score:e.side1Score,side2Score:e.side2Score,side1TiebreakScore:e.side1TiebreakScore,side2TiebreakScore:e.side2TiebreakScore,winningSide:e.winningSide})),t=z[z.length-1];if(t&&t.winningSide===void 0&&(t.side1Score||t.side2Score)&&e.push({side1Score:t.side1Score,side2Score:t.side2Score,side1TiebreakScore:t.side1TiebreakScore,side2TiebreakScore:t.side2TiebreakScore,winningSide:void 0}),e.length>0)try{A.setInitialScore({sets:e})}catch{}},I=()=>{if(!A)return{};let e=A.getScore()?.pointDisplay;return!e||e[0]===`0`&&e[1]===`0`&&j===0?{}:{side1:String(e[0]),side2:String(e[1])}},L=(e,t)=>{if(!A)return;let n={0:0,15:1,30:2,40:3,AD:4};if(e in n||t in n){let r=n[e]??0,i=n[t]??0;for(let e=0;e<r;e++){let e=j%2;A.addPoint({winner:0,server:e,result:`Winner`}),j++}for(let e=0;e<i;e++){let e=j%2;A.addPoint({winner:1,server:e,result:`Winner`}),j++}}else{let n=parseInt(e,10)||0,r=parseInt(t,10)||0;for(let e=0;e<n;e++){let e=j%2;A.addPoint({winner:0,server:e,result:`Winner`}),j++}for(let e=0;e<r;e++){let e=j%2;A.addPoint({winner:1,server:e,result:`Winner`}),j++}}},R=()=>{let e=p===Ms||p===Ps,t=z[z.length-1],n=t&&t.winningSide===void 0;if(M=!!(e&&n),!M){A=null,j=0;return}N||F()},z=[];globalThis.resetDynamicSets=()=>{O.innerHTML=``,z=[],h.clear(),A=null,j=0,M=!1,p=js,m=void 0,g=void 0,_=void 0,v=void 0,y.querySelectorAll(Ws).forEach(e=>e.checked=!1),y.querySelectorAll(Gs).forEach(e=>e.checked=!1),y.style.display=`none`,C.style.display=`none`;let e=te(0);O.appendChild(e),e.querySelectorAll(`input`).forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)}),B({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`});let t=O.querySelector(`input`);t&&t.focus()};let B=e=>{f.innerHTML=``;let t;e?.clearAll?(t=void 0,g=void 0):e?.scoreObject?(t=e.scoreObject,g=e.scoreObject):z.length>0?(t={sets:z},g={sets:z}):t=g,e?.clearAll?(_=void 0,v=void 0):e&&(_=e.winningSide,v=e.matchUpStatus||void 0,[Ns,Ms,Ps,Fs,Is].includes(v)&&z.length===0&&(t=void 0,g=void 0));let r=qr({matchUp:{...n,score:t,winningSide:_,matchUpStatus:v},isLucky:!0,composition:si[is().composition||`Australian`]||si.Australian});if(M){let e=A?.isComplete(),t=r.querySelector(`.tmx-sd[sideNumber="1"] .sideScore`);if(t){let n=document.createElement(`button`);n.className=`chc-game-btn`,n.textContent=`+`,n.title=`Point for side 1`,n.disabled=e,n.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),P(0)}),t.appendChild(n)}let n=r.querySelector(`.tmx-sd[sideNumber="2"] .sideScore`);if(n){let t=document.createElement(`button`);t.className=`chc-game-btn`,t.textContent=`+`,t.title=`Point for side 2`,t.disabled=e,t.addEventListener(`click`,e=>{e.stopPropagation(),e.preventDefault(),P(1)}),n.appendChild(t)}}f.appendChild(r),ee()},ee=()=>{requestAnimationFrame(()=>{let e=f.firstElementChild;if(!e)return;e.style.width=`fit-content`,e.style.minWidth=`100%`,e.style.transform=``,f.style.height=``;let t=f.clientWidth,n=e.scrollWidth;if(n>t&&t>0){let r=t/n;e.style.transformOrigin=`top left`,e.style.transform=`scale(${r})`,f.style.height=`${e.offsetHeight*r}px`}})},te=e=>{let t=document.createElement(`div`);t.className=`set-row`,t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`0.5em`,t.style.marginBottom=`0.25em`;let n=document.createElement(`div`);n.textContent=`Set ${e+1}:`,n.style.width=`3.5em`,n.style.fontSize=`0.9em`,n.style.fontWeight=`500`,n.style.color=Rs,t.appendChild(n);let r=document.createElement(`input`);r.type=`text`,r.className=`input`,r.style.width=`3em`,r.style.textAlign=`center`,r.placeholder=`0`,r.dataset.setIndex=e.toString(),r.dataset.side=`1`;let i=document.createElement(`input`);i.type=`text`,i.className=`input`,i.style.width=`3em`,i.style.textAlign=`center`,i.placeholder=`0`,i.dataset.setIndex=e.toString(),i.dataset.side=`2`;let a=document.createElement(`span`);a.textContent=`-`,a.style.fontWeight=`bold`,a.style.color=Ls,t.appendChild(r),t.appendChild(a),t.appendChild(i);let o=document.createElement(`span`);o.className=`tiebreak-container`,o.style.display=`none`,o.style.marginLeft=`0.5em`;let s=document.createElement(`span`);s.textContent=`(`,s.style.color=Ls;let c=document.createElement(`input`);c.type=`text`,c.className=`input tiebreak-input`,c.style.width=`2.5em`,c.style.textAlign=`center`,c.dataset.setIndex=e.toString(),c.dataset.type=`tiebreak`;let l=document.createElement(`span`);l.textContent=`)`,l.style.color=Ls,o.appendChild(s),o.appendChild(c),o.appendChild(l),t.appendChild(o);let u=document.createElement(`span`);return u.className=`set-indicator`,u.style.fontSize=`1.2em`,u.style.minWidth=`1.5em`,t.appendChild(u),t},ne=e=>{let t=O.querySelector(`input[data-set-index="${e}"][data-side="1"]`),n=O.querySelector(`input[data-set-index="${e}"][data-side="2"]`),r=O.querySelector(`input[data-set-index="${e}"][data-type="tiebreak"]`);if(!t||!n)return!1;let i=t.value.trim(),a=n.value.trim();return i===``||a===``?!1:Ss(e,{side1:Number.parseInt(i)||0,side2:Number.parseInt(a)||0,tiebreak:r?.value.trim()?Number.parseInt(r.value):void 0},c)},V=()=>{p===js&&(C.style.display=`none`);let e=[];for(let t=0;t<l();t++){let n=O.querySelector(`input[data-set-index="${t}"][data-side="1"]`),r=O.querySelector(`input[data-set-index="${t}"][data-side="2"]`),i=O.querySelector(`input[data-set-index="${t}"][data-type="tiebreak"]`);if(!n||!r)break;let a=n.value.trim(),o=r.value.trim();if(a===``&&o===``)break;let s=i?.value.trim(),l=As(t,a,o,s,c);e.push(l)}if(z=e,R(),M&&z.length>0){let e=z[z.length-1];if(e.winningSide===void 0){let t=I();(t.side1||t.side2)&&(e.side1PointScore=t.side1||`0`,e.side2PointScore=t.side2||`0`)}}let t=O.querySelectorAll(`.set-row`),r=ws(z,l(),u()),a=Us(z,r,l());for(let e=t.length-1;e>=a;e--)t[e].remove();if(z.length>0||p!==js){let e=z.some(e=>e.winningSide===void 0),t=(p!==js||e?z:z.filter(e=>e.winningSide!==void 0)).map(zs),r=hs(t,n.matchUpFormat,p!==js);Bs(t,r);let a=r.isValid&&r.winningSide!==void 0;Vs(p,a,y,C),Hs(r,p,m),B(r),i(r)}else y.style.display=`block`,B(),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`})},re=()=>{let e=document.getElementById(`clearScoreV2`);if(e){let t=O.querySelectorAll(`.set-row`),n=O.querySelector(`input[data-set-index="0"][data-side="1"]`),r=O.querySelector(`input[data-set-index="0"][data-side="2"]`);e.disabled=!(t.length>1||n?.value.trim()!==``||r?.value.trim()!==``)}},ie=e=>{let t=O.querySelector(`input[data-set-index="${e}"][data-side="1"]`),n=O.querySelector(`input[data-set-index="${e}"][data-side="2"]`),r=O.querySelector(`.set-row:nth-child(${e+1}) .tiebreak-container`),i=O.querySelector(`input[data-set-index="${e}"][data-type="tiebreak"]`);!t||!n||!r||(Os(e,{side1:Number.parseInt(t.value)||0,side2:Number.parseInt(n.value)||0},c)?r.style.display=`inline`:(r.style.display=`none`,i&&(i.value=``)))},ae=(e,t)=>{let n=t===`1`?`2`:`1`,r=O.querySelector(`input[data-set-index="${e}"][data-side="${n}"]`),i=O.querySelector(`input[data-set-index="${e}"][data-side="${t}"]`),a=Number.parseInt(i?.value)||0,o=Number.parseInt(r?.value)||0;return xs(e,t===`1`?1:2,{side1:t===`1`?a:o,side2:t===`2`?a:o},c)};function oe(){p=js,m=void 0,y.querySelectorAll(Ws).forEach(e=>e.checked=!1),C.style.display=`none`}function se(e,t,n,r){let i=d(n)?.tiebreakSet?.tiebreakTo!==void 0;if(t)e.value.length>2&&(e.value=e.value.slice(0,2));else if(i)e.value.length>3&&(e.value=e.value.slice(0,3));else{let t=ae(n,r);(Number.parseInt(e.value)||0)>t&&(e.value=t.toString())}}function ce(e,t){if(d(e)?.tiebreakSet?.tiebreakTo!==void 0)return;let n=t===`1`?`2`:`1`,r=O.querySelector(`input[data-set-index="${e}"][data-side="${n}"]`);if(r?.value.trim()){let t=Number.parseInt(r.value)||0,i=ae(e,n);t>i&&(r.value=i.toString())}}function le(e){if(!ne(e)||ws(z,l(),u())||!_s(z,n.matchUpFormat))return;let t=z.length,r=O.querySelector(`input[data-set-index="${t}"]`);if(t<l()&&!r){let e=te(t);O.appendChild(e),e.querySelectorAll(`input`).forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)}),re()}}let ue=e=>{let t=e.target,n=t.dataset.type===`tiebreak`;p!==js&&t.value&&oe();let r=t.value.replace(/\D/g,``);r!==t.value&&(t.value=r);let i=Number.parseInt(t.dataset.setIndex||`0`),a=t.dataset.side||`1`;se(t,n,i,a),n||(ie(i),ce(i,a)),V(),re(),le(i)},de=e=>{e.focus(),e.select()};function fe(e){let t=te(e);O.appendChild(t);let n=t.querySelectorAll(`input`);n.forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)});let r=n[0];r instanceof HTMLInputElement&&de(r),re()}function pe(e,t,n){let r=ss()?.smartComplements===!0,i=e.code.match(/^Digit(\d)$/);if(!i||t.value!==``)return!1;let a=Ds(Number.parseInt(i[1]),e.shiftKey,n,z,c,h,r);if(!a.shouldApply)return!1;e.preventDefault(),t.value=a.field1Value.toString();let o=O.querySelector(`input[data-set-index="${n}"][data-side="2"]`);return o&&(o.value=a.field2Value.toString()),h.add(n),t.dispatchEvent(new Event(`input`,{bubbles:!0})),setTimeout(()=>{if(V(),ws(z,l(),u()))return;let e=O.querySelector(`input[data-set-index="${n+1}"][data-side="1"]`);e?de(e):n+1<l()&&fe(n+1)},10),!0}function me(e,t,n){if(n){let t=O.querySelector(`input[data-set-index="${e}"][data-side="2"]`);t&&de(t)}else if(t===`2`){let t=O.querySelector(`input[data-set-index="${e}"][data-side="1"]`);t&&de(t)}else e>0&&he(e)}function he(e){let t=O.querySelector(`input[data-set-index="${e-1}"][data-type="tiebreak"]`),n=O.querySelector(`input[data-set-index="${e-1}"][data-side="2"]`),r=t?.closest(Ks);t&&r&&r.style.display!==`none`?de(t):n&&de(n)}function ge(e){let t=O.querySelector(`input[data-set-index="${e}"][data-type="tiebreak"]`),n=t?.closest(Ks);if(t&&n&&n.style.display!==`none`){de(t);return}let r=O.querySelector(`input[data-set-index="${e+1}"][data-side="1"]`);if(r)de(r);else if(e+1<l()){if(!ne(e)||ws(z,l(),u()))return;fe(e+1)}}function _e(e){let t=O.querySelector(`input[data-set-index="${e+1}"][data-side="1"]`);if(t)de(t);else if(e+1<l()){if(!ne(e)||(V(),ws(z,l(),u())))return;fe(e+1)}}let ve=e=>{let t=e.target,n=Number.parseInt(t.dataset.setIndex||`0`),r=t.dataset.side||`1`,i=t.dataset.type===`tiebreak`;if(!(r===`1`&&!i&&pe(e,t,n))){if(e.key===`Tab`)if(e.preventDefault(),e.shiftKey)me(n,r,i);else if(i)_e(n);else if(r===`1`){let e=O.querySelector(`input[data-set-index="${n}"][data-side="2"]`);e&&de(e)}else r===`2`&&(V(),ge(n));if(e.key===`Enter`){let e=document.getElementById(`submitScoreV2`);e&&!e.disabled&&e.click()}e.key===`Backspace`&&t.value===``&&(e.preventDefault(),me(n,r,i))}},ye=te(0);if(O.appendChild(ye),ye.querySelectorAll(`input`).forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)}),g?.sets&&g.sets.length>0){let e=Math.ceil(l()/2),t=0,n=0,r=!1;g.sets.forEach((i,a)=>{if(r)return;if(a>0){let e=te(a);O.appendChild(e),e.querySelectorAll(`input`).forEach(e=>{e.addEventListener(`input`,ue),e.addEventListener(`keydown`,ve)})}let o=O.querySelector(`input[data-set-index="${a}"][data-side="1"]`),s=O.querySelector(`input[data-set-index="${a}"][data-side="2"]`),c=O.querySelector(`input[data-set-index="${a}"][data-type="tiebreak"]`);if(o&&s&&(o.value=i.side1Score?.toString()||``,s.value=i.side2Score?.toString()||``,ie(a),c&&(i.side1TiebreakScore!==void 0||i.side2TiebreakScore!==void 0)&&(i.winningSide===1&&i.side2TiebreakScore!==void 0?c.value=i.side2TiebreakScore.toString():i.winningSide===2&&i.side1TiebreakScore!==void 0?c.value=i.side1TiebreakScore.toString():i.side1TiebreakScore===void 0?i.side2TiebreakScore!==void 0&&(c.value=i.side2TiebreakScore.toString()):c.value=i.side1TiebreakScore.toString())),i.side1PointScore!==void 0||i.side2PointScore!==void 0){let e=i.side1PointScore?.toString()||`0`,t=i.side2PointScore?.toString()||`0`;setTimeout(()=>{R(),A&&(L(e,t),N=!0,V(),N=!1)},0)}i.winningSide===1&&t++,i.winningSide===2&&n++,r=(t>=e||n>=e)&&(!u()||a+1>=u())})}else B();n.matchUpStatus&&n.matchUpStatus!==js&&[Ms,Ns,Ps,Fs,Is].includes(n.matchUpStatus)&&(n.matchUpStatus===Fs?(p=Ns,m=void 0):n.matchUpStatus===Is?(p=Ps,m=void 0):(p=n.matchUpStatus,m=n.winningSide),y.querySelectorAll(Ws).forEach(e=>{e.value===p&&(e.checked=!0)}),m&&(y.querySelectorAll(Gs).forEach(e=>{Number.parseInt(e.value)===m&&(e.checked=!0)}),C.style.display=`block`)),g?.sets&&g.sets.length>0?V():p===js?(y.style.display=`none`,C.style.display=`none`):B(),setTimeout(()=>{let e=O.querySelector(`input`);e&&e.focus()},100)}function Js(e,n){let{matchUpFormat:r}=n;if(!e)return``;let i=t.matchUpFormatCode.parse(r),a=i?.setFormat?.bestOf||3,o=e=>e===a&&i?.finalSetFormat?i.finalSetFormat:i?.setFormat,s=``,c=0,l=e.split(/[\s/]+|--+/).filter(e=>e.length>0);for(let e of l){let t={pos:0};for(;t.pos<e.length&&c<a;){let n=$s(e,t,c,a,o);if(s&&(s+=` `),s+=n.formatted,n.complete)c++;else break}}return s}function Ys(e,t,n){let r=n(e+1),i=r?.tiebreakSet?.tiebreakTo,a=r?.setTo,o=!!i&&!a,s=r?.timed===!0,c=s?999:i||a||6;return{isTiebreakOnly:o,isTimed:s,setTo:c,tiebreakAt:r?.tiebreakAt||c,maxScore:s?999:c+1}}function Xs(e,t,n,r,i){let a=``;for(;t.pos<e.length;){let o=e[t.pos];if(o===`-`){if(!n)break;if(a.length>0){t.pos++;break}break}if(n){a+=o,t.pos++;continue}if(Number.parseInt(a+o)>r+i||a.length>=2)break;a+=o,t.pos++;let s=Number.parseInt(a);if(a.length===1&&s!==1&&r<10){if(t.pos<e.length&&e[t.pos]===`-`)continue;break}}return a}function Zs(e,t,n){let r=!1,i=e,a=t;return i>n+1&&(i=n,r=!0),a>n+1&&(a=n,r=!0),i===n+1&&a<n-1?(i=n,r=!0):a===n+1&&i<n-1&&(a=n,r=!0),{s1:i,s2:a,side1:i.toString(),side2:a.toString(),wasCoerced:r}}function Qs(e,t){let n=``;for(;t.pos<e.length;){let r=e[t.pos];if(r===`-`){t.pos++;break}n+=r,t.pos++}return n}function $s(e,t,n,r,i){let a=Ys(n,r,i),o=a.isTiebreakOnly||a.isTimed,s=Xs(e,t,o,a.maxScore,0);t.pos<e.length&&e[t.pos]===`-`&&t.pos++;let c=Xs(e,t,o,a.maxScore,3);if(!c)return{formatted:s,complete:!1};let l=Number.parseInt(s),u=Number.parseInt(c),d=s,f=c,p=!1;if(!a.isTiebreakOnly&&!a.isTimed){let e=Zs(l,u,a.setTo);l=e.s1,u=e.s2,d=e.side1,f=e.side2,p=e.wasCoerced}let m=Math.abs(l-u),h=Math.max(l,u),g=a.isTimed||h>=a.setTo&&m>=2,_=t.pos<e.length,v=l===a.tiebreakAt&&u===a.tiebreakAt,y=l===a.tiebreakAt+1&&u===a.tiebreakAt||u===a.tiebreakAt+1&&l===a.tiebreakAt;if(!p&&(v||y&&_)){let n=Qs(e,t);return n?{formatted:`${d}-${f}(${n})`,complete:!0}:{formatted:`${d}-${f}(`,complete:!1}}return a.isTiebreakOnly?{formatted:`[${d}-${f}]`,complete:g}:{formatted:`${d}-${f}`,complete:g}}var{COMPLETED:ec,RETIRED:tc,WALKOVER:nc,DEFAULTED:rc,DOUBLE_WALKOVER:ic,DOUBLE_DEFAULT:ac}=t.matchUpStatusConstants,oc=`SET3-S:6/TB7`,sc=`var(--chc-text-secondary)`,cc=`var(--chc-bg-secondary)`,lc=`input[name="matchOutcome"]`,uc=`input[name="irregularWinner"]`;function dc(e){if(!e?.sets||e.sets.length===0)return``;let t=[];return e.sets.forEach((e,n)=>{if(n>0&&t.push(` `),t.push(e.side1Score?.toString()||`0`),t.push(e.side2Score?.toString()||`0`),e.side1TiebreakScore!==void 0||e.side2TiebreakScore!==void 0){let n=e.winningSide===1?e.side2TiebreakScore:e.side1TiebreakScore;n!==void 0&&(t.push(`-`),t.push(n.toString()))}}),t.join(``)}function fc(e){let{matchUp:n,container:r,onScoreChange:i,labels:a={}}=e;try{r.innerHTML=``,r.style.display=`flex`,r.style.flexDirection=`column`,r.style.gap=`1em`;let e=t.matchUpFormatCode.parse(n.matchUpFormat||oc),o=e?.setFormat?.setTo||6,s=e?.setFormat?.tiebreakAt||o,c=n.score?{...n.score}:void 0,l=n.winningSide,u=n.matchUpStatus,d={digits:``,setTo:o,tiebreakAt:s,isMatchComplete:!1};if(c){d.digits=dc(c);let e=Js(d.digits,{matchUpFormat:n.matchUpFormat||oc});if(e&&e.includes(`-`)){let t=ms(e,n.matchUpFormat);d.isMatchComplete=t.isValid&&t.winningSide!==void 0&&(t.matchUpStatus===ec||t.matchUpStatus===void 0)}}let f=document.createElement(`div`);if(f.style.marginBottom=`0.5em`,r.appendChild(f),e?.aggregate){let e=document.createElement(`div`);e.style.fontSize=`0.75em`,e.style.color=sc,e.style.marginTop=`0.25em`,e.style.marginBottom=`0.5em`,e.style.padding=`0.25em 0.5em`,e.style.backgroundColor=cc,e.style.border=`1px solid var(--chc-status-warning)`,e.style.borderRadius=`3px`,e.textContent=`⚠️ Aggregate Scoring: Winner determined by total points across all sets`,r.appendChild(e)}if(n.matchUpFormat){let e=document.createElement(`div`);e.style.fontSize=`0.9em`,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=sc,e.appendChild(t);let o=document.createElement(`button`);o.textContent=n.matchUpFormat,o.className=`button is-small is-white`,o.style.fontSize=`0.75em`,o.style.padding=`0.2em 0.5em`,o.style.cursor=`pointer`,o.title=`Click to edit format`,o.addEventListener(`click`,()=>{try{Da({existingMatchUpFormat:n.matchUpFormat,callback:e=>{e&&e!==n.matchUpFormat&&(n.matchUpFormat=e,o.textContent=e,d.digits=``,r.innerHTML=``,fc({matchUp:n,container:r,onScoreChange:i,labels:a}))},modalConfig:{style:{fontSize:`12px`,border:`3px solid #0066cc`}}})}catch(e){console.error(`Error opening format selector:`,e)}}),e.appendChild(o),r.appendChild(e)}let p=document.createElement(`div`);p.style.fontSize=`1.2em`,p.style.color=`#64B5F6`,p.style.textAlign=`center`,p.style.padding=`0.25em 0.5em`,p.style.fontWeight=`bold`,p.style.minHeight=`1.5em`,p.style.maxWidth=`300px`,p.style.margin=`0 auto`,p.textContent=`-`,r.appendChild(p);let m=ec,h,g=document.createElement(`div`);g.style.display=`none`,g.style.marginBottom=`0.8em`,g.style.padding=`0.6em`,g.style.backgroundColor=cc,g.style.border=`2px solid var(--chc-status-warning)`,g.style.borderRadius=`4px`;let _=document.createElement(`div`);_.textContent=(a.irregularEnding||`Irregular Ending`)+`:`,_.style.fontSize=`0.8em`,_.style.fontWeight=`600`,_.style.marginBottom=`0.3em`,_.style.color=sc,g.appendChild(_);let v=document.createElement(`div`);v.style.display=`none`,v.style.marginTop=`0.3em`;let y=document.createElement(`div`);y.textContent=(a.winner||`Winner`)+`:`,y.style.fontSize=`0.75em`,y.style.fontWeight=`500`,y.style.marginBottom=`0.2em`,y.style.color=sc,v.appendChild(y);let b=document.createElement(`div`);b.style.display=`flex`,b.style.gap=`0.5em`,b.style.flexWrap=`wrap`;let x=n.sides?.[0],S=n.sides?.[1];[1,2].forEach(e=>{let t=document.createElement(`label`);t.style.display=`flex`,t.style.alignItems=`center`,t.style.gap=`0.3em`,t.style.cursor=`pointer`;let n=document.createElement(`input`);n.type=`radio`,n.name=`irregularWinner`,n.value=e.toString(),n.addEventListener(`change`,()=>{n.checked&&(h=e,E())});let r=document.createElement(`span`);r.textContent=(e===1?x:S)?.participant?.participantName||`Side ${e}`,r.style.fontSize=`0.75em`,r.style.color=sc,t.appendChild(n),t.appendChild(r),b.appendChild(t)}),v.appendChild(b),g.appendChild(v),r.appendChild(g);let C=document.createElement(`div`);C.style.display=`grid`,C.style.gridTemplateColumns=`repeat(4, 1fr)`,C.style.gap=`8px`,C.style.width=`100%`,C.style.maxWidth=`320px`,C.style.margin=`0 auto`,r.appendChild(C);let w=e=>Js(e,{matchUpFormat:n.matchUpFormat||oc}),T=e=>{f.innerHTML=``;let t=e?.scoreObject?.sets?.length>0;e?.clearAll?(c=void 0,l=void 0,u=void 0):e!=null&&(t&&(c=e?.scoreObject),`winningSide`in e&&(l=e?.winningSide),`matchUpStatus`in e&&(u=e?.matchUpStatus));let r=qr({matchUp:{...n,score:e?.clearAll?void 0:t?c:void 0,winningSide:l,matchUpStatus:u},isLucky:!0,composition:si[is().composition||`Australian`]||si.Australian});r&&f.appendChild(r)},E=(e=!1)=>{let t=w(d.digits);if(t?(p.style.display=`block`,p.textContent=t):(p.style.display=`block`,p.textContent=`-`),m===tc||m===nc||m===rc?(g.style.display=`block`,v.style.display=`block`):(g.style.display=`none`,v.style.display=`none`),e){T({clearAll:!0});return}let r=ms(t,n.matchUpFormat);d.isMatchComplete=r.isValid&&r.winningSide!==void 0&&(r.matchUpStatus===ec||r.matchUpStatus===void 0),m!==ec&&(h?(r.matchUpStatus=m,r.winningSide=h,r.isValid=!0):m===nc?(r.matchUpStatus=ic,r.isValid=!0):m===rc?(r.matchUpStatus=ac,r.isValid=!0):(r.matchUpStatus=m,r.isValid=!1),d.isMatchComplete=!1),T(r),i(r);let a=document.getElementById(`clearScoreV2`);a&&(a.disabled=d.digits.length===0&&m===ec),A(),j()},D=e=>{m!==ec&&typeof e==`number`&&(m=ec,h=void 0,g.querySelectorAll(lc).forEach(e=>e.checked=!1),v.style.display=`none`),typeof e==`number`&&d.digits===``&&e>o&&(e=o);let r=w(d.digits),i=r.includes(`(`)&&!r.includes(`)`),a=d.digits.includes(`-`),s=(d.digits.match(/-/g)||[]).length,c=r.includes(`[`)&&a&&s===1,l=(r?ms(r,n.matchUpFormat):null)?.sets?.length||0,u=t.matchUpFormatCode.parse(n.matchUpFormat),f=u?.setFormat?.bestOf||3,p=e=>{let t=e===f&&u?.finalSetFormat?u.finalSetFormat:u?.setFormat,n=t?.tiebreakSet?.tiebreakTo,r=t?.setTo;return!!n&&!r},_=l<f&&p(l+1),y=l>0&&p(l),b=i||c||_||y,x=w(e===`-`?d.digits+`-`:d.digits+e.toString());if(r){let t=ms(r,n.matchUpFormat),i=t.sets?.[t.sets.length-1],a=r.includes(`(`),o=x.includes(`(`),s=a&&o&&x!==r&&x.startsWith(r.substring(0,r.lastIndexOf(`)`))),c=i&&(i.side1TiebreakScore===void 0&&i.side2TiebreakScore===void 0||i.side1TiebreakScore==null&&i.side2TiebreakScore==null||s)&&i.side1Score!==void 0&&i.side2Score!==void 0&&(i.side1Score===i.side2Score||Math.abs(i.side1Score-i.side2Score)===1);if(t.isValid&&t.winningSide&&!b&&!c||!b&&e!==`-`&&x===r)return}e===`-`?d.digits.endsWith(`-`)||(d.digits+=`-`):d.digits+=e.toString(),E()},O=()=>{d.digits.length>0&&(d.digits=d.digits.slice(0,-1),E())},k=()=>{d.digits=``,d.isMatchComplete=!1,m=ec,h=void 0,c=void 0,l=void 0,u=void 0,g.querySelectorAll(uc).forEach(e=>e.checked=!1),g.querySelectorAll(lc).forEach(e=>e.checked=!1),g.style.display=`none`,v.style.display=`none`,p.style.display=`block`,p.textContent=`-`,T({clearAll:!0}),j(),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`})};globalThis.resetDialPad=k;let A=()=>{let e=C.querySelector(`[data-button="retired"]`),t=C.querySelector(`[data-button="defaulted"]`),n=w(d.digits),r=!(n.includes(`-`)&&n.length>2)||d.isMatchComplete;e&&(e.disabled=r),t&&(t.disabled=r)},j=()=>{let e=m!==ec&&h!==void 0||d.isMatchComplete;C.querySelectorAll(`button`).forEach(t=>{let n=t.textContent||``;(n.match(/^[0-9]$/)||n===`-`)&&(t.disabled=e)})};[{label:`1`,value:1},{label:`2`,value:2},{label:`3`,value:3},{label:`RET`,value:`retired`,isSpecial:!0,requiresScore:!0},{label:`4`,value:4},{label:`5`,value:5},{label:`6`,value:6},{label:`WO`,value:`walkover`,isSpecial:!0},{label:`7`,value:7},{label:`8`,value:8},{label:`9`,value:9},{label:`DEF`,value:`defaulted`,isSpecial:!0,requiresScore:!0},{label:`⌫`,value:`delete`,isSpecial:!0},{label:`0`,value:0},{label:`-`,value:`minus`,isSpecial:!0},{label:``,value:`empty`,isSpecial:!0,disabled:!0}].forEach(e=>{let t=document.createElement(`button`);t.className=`button is-white`,t.textContent=e.label,t.style.cssText=`
|
|
139
139
|
height: 55px !important;
|
|
140
140
|
width: 100% !important;
|
|
141
141
|
padding: 0.5em !important;
|
|
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.3em`:e.isSpecial&&[`RET`,`WO`,`DEF`].includes(e.label)?(t.style.fontSize=`0.95em`,t.style.setProperty(`background-color`,ic,`important`)):e.isSpecial?(t.style.fontSize=`1.3em`,t.style.setProperty(`background-color`,ic,`important`)):t.style.fontSize=`1.3em`,(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`?O():e.value===`minus`?D(`-`):e.value===`retired`?(m=Zs,h=void 0,g.querySelectorAll(oc).forEach(e=>e.checked=!1),E()):e.value===`walkover`?(m=Qs,h=void 0,d.digits=``,g.querySelectorAll(oc).forEach(e=>e.checked=!1),E(),j()):e.value===`defaulted`?(m=$s,h=void 0,g.querySelectorAll(oc).forEach(e=>e.checked=!1),E()):e.value===`empty`||D(e.value)},C.appendChild(t)});let M=e=>{if(e.key>=`0`&&e.key<=`9`)e.preventDefault(),D(Number.parseInt(e.key));else if(e.key===`Backspace`||e.key===`Delete`)e.preventDefault(),O();else if(e.key===`-`||e.key===` `||e.key===`/`)e.preventDefault(),D(`-`);else if(e.key===`)`){e.preventDefault();let t=w(d.digits);t.includes(`(`)&&!t.includes(`)`)&&(d.digits+=`-`,E())}};r.setAttribute(`tabindex`,`-1`),r.style.outline=`none`,r.addEventListener(`keydown`,M),setTimeout(()=>r.focus(),100),globalThis.cleanupDialPad=()=>{r.removeEventListener(`keydown`,M)};let N=u===Zs||u===Qs||u===$s||u===ec||u===tc;N?(u===ec?(m=Qs,h=void 0):u===tc?(m=$s,h=void 0):(m=u,h=l),g.querySelectorAll(ac).forEach(e=>{e.value===m&&(e.checked=!0)}),h&&(g.querySelectorAll(oc).forEach(e=>{Number.parseInt(e.value)===h&&(e.checked=!0)}),v.style.display=`block`)):!c&&(!u||u===`TO_BE_PLAYED`)&&k(),d.digits||N?(E(),setTimeout(()=>{let e=document.getElementById(`clearScoreV2`);e&&(e.disabled=!1),j()},0)):(T(null),j())}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:lc,WALKOVER:uc,DEFAULTED:dc,SUSPENDED:fc,CANCELLED:pc,INCOMPLETE:mc,DEAD_RUBBER:hc,IN_PROGRESS:gc,AWAITING_RESULT:_c}=t.matchUpStatusConstants;function vc(e,t){let n=e.substring(t).trim().toLowerCase();return/^in(\s+p(rog(ress)?)?)?$/i.exec(n)?{ending:gc,endPos:e.length}:/^inc(omp(lete?)?)?/i.exec(n)?{ending:mc,endPos:e.length}:/^(dr|dead(\s*r(ubber)?)?)/i.exec(n)?{ending:hc,endPos:e.length}:/^r(et(ired?)?)?/i.exec(n)?{ending:lc,endPos:e.length}:/^(w(\/o|o|alk(over?)?)?)/i.exec(n)?{ending:uc,endPos:e.length}:/^d(ef(aulted?)?)?/i.exec(n)?{ending:dc,endPos:e.length}:/^s(usp(ended?)?)?/i.exec(n)?{ending:fc,endPos:e.length}:/^c(anc(ell?ed?)?)?/i.exec(n)?{ending:pc,endPos:e.length}:/^a(wait(ing(\s*r(esult)?)?)?)?/i.exec(n)?{ending:_c,endPos:e.length}:{endPos:t}}function yc(e,t){return t===(e.bestOf||3)-1&&e.finalSetFormat?e.finalSetFormat:e.setFormat}function bc(e){return!!e?.tiebreakSet?.tiebreakTo&&!e?.setTo}function xc(e){return bc(e)?0:(e?.setTo||6)+1}function Sc(e){let t=e?.tiebreakSet,n=e?.tiebreakFormat;return t?t.tiebreakTo||10:n&&n.tiebreakTo||7}function Cc(e){return e>=`0`&&e<=`9`}function wc(e){for(let t of e)if(!Cc(t))return!1;return!0}function Tc(e){return!Cc(e)&&!Ec(e)&&!Dc(e)}function Ec(e){return e===`(`||e===`[`}function Dc(e){return e===`)`||e===`]`}function Oc(e,t,n){let r=n?.tiebreakAt||n?.setTo||6;return e===r&&t===r}function kc(e,t,n){let r=n?.setTo||6,i=Math.max(e,t);return i<r?!1:i-Math.min(e,t)>=2?!0:(r+1,!1)}function Ac(e,t,n){let r=Sc(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 jc(e,t){let n=+(e===`1-0`),r=+(e===`0-1`);return{side1TiebreakScore:n,side2TiebreakScore:r,setNumber:t,winningSide:n>r?1:2}}function Mc(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||!wc(i)||!wc(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 Nc(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||!wc(i)||!wc(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 Pc(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 Fc(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=Pc(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 Ic(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(jc(o,s));else if(t&&c&&!l){let e=Nc(o,s,r);e&&i.push(e)}else{let e=Mc(o,s,r);e&&i.push(e)}}return i}function Lc(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 Rc(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 zc(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 Bc(e){return e.map(e=>e.side1TiebreakScore===void 0?`${e.side1Score}-${e.side2Score}`:`${e.side1TiebreakScore}-${e.side2TiebreakScore}`).join(` `)}function Vc(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 Lc(o,n);let s=r.split(/\s+/),c=[],l=o?n-1:n,u=Ic(s,o,n,c);o&&c.length===0&&Fc(u,l,c);let d=o?l:n,f=n;Rc(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=Bc(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:zc(p,o,d,u.length,n),incomplete:p,matchComplete:m}}function Hc(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 Vc(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(bc(yc(r,0))?(o.expectingTiebreakOnly=!0,o.inTiebreak=!0,o.state=`PARSING_TIEBREAK_SIDE1`):o.state=`PARSING_SIDE1`;o.position<e.length&&o.isValid;)Uc(o);ll(o);let s=o.sets,c;o.irregularEnding&&(c=o.irregularEnding,(o.irregularEnding===uc||o.irregularEnding===pc||o.irregularEnding===hc)&&(s=[]));let l=o.irregularEnding?!1:ul(o),u=dl(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 Uc(e){let t=e.input[e.position];if(!Cc(t)&&!Ec(t)&&!Dc(t)){let t=vc(e.input,e.position);if(t.ending){e.irregularEnding=t.ending,e.irregularEndingPosition=e.position,e.position=t.endPos;return}}if(Tc(t)){Wc(e);return}if(Ec(t)){Gc(e);return}if(Dc(t)){Kc(e);return}if(Cc(t)){qc(e,t);return}e.errors.push({position:e.position,message:`Unexpected character '${t}'`,got:t,context:fl(e)}),e.isValid=!1}function Wc(e){if(e.state===`PARSING_SIDE1`&&e.currentSide1Buffer){e.state=`PARSING_SIDE2`,e.position++;return}if(e.state===`PARSING_SIDE2`&&e.currentSide2Buffer){if(il(Number.parseInt(e.currentSide1Buffer),Number.parseInt(e.currentSide2Buffer),yc(e.parsedFormat,e.setIndex))){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}sl(e),e.position++;return}if(e.state===`PARSING_TIEBREAK_SIDE1`&&e.currentTiebreakSide1Buffer)if(e.currentSide1Buffer&&e.currentSide2Buffer){sl(e),e.position++;return}else{e.state=`PARSING_TIEBREAK_SIDE2`,e.position++;return}e.position++}function Gc(e){let t=yc(e.parsedFormat,e.setIndex);if(bc(t)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}if(e.currentSide1Buffer&&e.currentSide2Buffer&&Oc(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 Kc(e){if(e.inTiebreak){cl(e),e.inTiebreak=!1,e.position++;return}e.warnings.push(`Unexpected tiebreak closer at position ${e.position}`),e.position++}function qc(e,t){let n=yc(e.parsedFormat,e.setIndex);e.inTiebreak?el(e,t,n):Zc(e,t,n)}function Jc(e,t,n){return Number.parseInt(e+t)>n}function Yc(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&&Cc(e.input[i])){let t=e.input[i];Jc(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 Xc(e,t,n,r){e.currentSide2Buffer+=t;let i=Number.parseInt(e.currentSide1Buffer),a=Number.parseInt(e.currentSide2Buffer);if(il(i,a,n)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}let o=e.position+1;if(o<e.input.length&&Cc(e.input[o])){let t=e.input[o];Jc(e.currentSide2Buffer,t,r)&&(kc(i,a,n)||Oc(i,a,n)||e.warnings.push(`Set ${e.setIndex+1} may be incomplete: ${i}-${a}`),sl(e))}e.position++}function Zc(e,t,n){let r=xc(n);if(e.state===`PARSING_SIDE1`||e.state===`START`){Yc(e,t,r);return}if(e.state===`PARSING_SIDE2`){Xc(e,t,n,r);return}e.position++}function Qc(e,t){e.currentTiebreakSide1Buffer+=t,e.position++}function $c(e,t,n){e.currentTiebreakSide2Buffer+=t;let r=Number.parseInt(e.currentTiebreakSide2Buffer),i=e.position+1;if(i<e.input.length&&Cc(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;Ac(o,t,n)||e.warnings.push(`Tiebreak may be incomplete: ${o}-${t}`),sl(e)}}e.position++}function el(e,t,n){if(e.state===`PARSING_TIEBREAK_SIDE1`){Qc(e,t);return}if(e.state===`PARSING_TIEBREAK_SIDE2`){$c(e,t,n);return}e.position++}function tl(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 nl(e,t,n){let r=t.currentTiebreakSide1Buffer,i=t.currentTiebreakSide2Buffer;r&&i?(e.side1TiebreakScore=Number.parseInt(r),e.side2TiebreakScore=Number.parseInt(i)):(r||i)&&rl(e,r,i,n)}function rl(e,t,n,r){let i=Number.parseInt(t||n),a=Sc(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 il(e,t,n){let r=n.tiebreakAt||n.setTo||6;return e===r&&t===r+1||t===r&&e===r+1}function al(e,t){if(!e.currentSide1Buffer||!e.currentSide2Buffer)return null;let n=Number.parseInt(e.currentSide1Buffer),r=Number.parseInt(e.currentSide2Buffer);if(il(n,r,t)&&!e.currentTiebreakSide1Buffer&&!e.currentTiebreakSide2Buffer)return null;let i={side1Score:n,side2Score:r,setNumber:e.setIndex+1};return(e.currentTiebreakSide1Buffer||e.currentTiebreakSide2Buffer)&&nl(i,e,t),n>r?i.winningSide=1:r>n&&(i.winningSide=2),i}function ol(e){e.currentSide1Buffer=``,e.currentSide2Buffer=``,e.currentTiebreakSide1Buffer=``,e.currentTiebreakSide2Buffer=``,e.setIndex++,e.inTiebreak=!1,e.state=`PARSING_SIDE1`,bc(yc(e.parsedFormat,e.setIndex))&&(e.expectingTiebreakOnly=!0,e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`)}function sl(e){let t=yc(e.parsedFormat,e.setIndex),n=bc(t)?tl(e):al(e,t);n&&e.sets.push(n),ol(e)}function cl(e){sl(e)}function ll(e){(e.currentSide1Buffer||e.currentSide2Buffer||e.currentTiebreakSide1Buffer||e.currentTiebreakSide2Buffer)&&sl(e)}function ul(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 dl(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 fl(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:pl,WALKOVER:ml,DEFAULTED:hl,DOUBLE_WALKOVER:gl,DOUBLE_DEFAULT:_l,SUSPENDED:vl,CANCELLED:yl,INCOMPLETE:bl,DEAD_RUBBER:xl,IN_PROGRESS:Sl,AWAITING_RESULT:Cl,COMPLETED:wl,TO_BE_PLAYED:Tl}=t.matchUpStatusConstants;function El(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!==wl&&t!==Tl){let e=Dl(t);if(e)return n?`${n} ${e}`:e}return n}function Dl(e){return{[pl]:`ret`,[ml]:`wo`,[hl]:`def`,[gl]:`wo`,[_l]:`def`,[vl]:`susp`,[yl]:`canc`,[bl]:`inc`,[xl]:`dr`,[Sl]:`in`,[Cl]:`await`}[e]||``}var{RETIRED:Ol,WALKOVER:kl,DEFAULTED:Al,SUSPENDED:jl,CANCELLED:Ml,INCOMPLETE:Nl,DEAD_RUBBER:Pl,IN_PROGRESS:Fl,AWAITING_RESULT:Il,DOUBLE_WALKOVER:Ll,DOUBLE_DEFAULT:Rl}=t.matchUpStatusConstants,zl=`var(--chc-status-success)`;function Bl(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.75em`,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.75em`,g.appendChild(_),g.appendChild(v),f.appendChild(p),f.appendChild(g),r.appendChild(f);let y=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=Wr({matchUp:p,isLucky:!0,composition:ri[es().composition||`Australian`]||ri.Australian});d.appendChild(m)};if(y(),n.matchUpFormat){let e=document.createElement(`div`);e.style.fontSize=`0.9em`,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.75em`,i.style.padding=`0.2em 0.5em`,i.style.cursor=`pointer`,i.title=`Click to edit format`,i.addEventListener(`click`,()=>{try{Ca({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}))),w.textContent=`Score cleared - format changed`,w.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 b=document.createElement(`div`);b.style.display=`flex`,b.style.alignItems=`center`,b.style.gap=`0.5em`;let x=document.createElement(`input`);x.type=`text`,x.className=`input`,x.placeholder=``,x.style.flex=`1`,x.id=`scoreInputV2`,c&&(x.value=El(c,u));let S=document.createElement(`span`);S.style.fontSize=`1.2em`,S.style.minWidth=`1.5em`,b.appendChild(x),b.appendChild(S),r.appendChild(b);let C=document.createElement(`div`);C.style.fontSize=`0.9em`,C.style.color=`var(--chc-border-focus)`,C.style.fontFamily=`monospace`,C.style.minHeight=`1.5em`,C.style.padding=`0.25em`,r.appendChild(C);let w=document.createElement(`div`);w.style.fontSize=`0.9em`,w.style.minHeight=`1.5em`,r.appendChild(w);let T=l,E=()=>{m.checked?(T=1,p.style.fontWeight=`bold`,p.style.color=zl,g.style.fontWeight=``,g.style.color=``):_.checked&&(T=2,g.style.fontWeight=`bold`,g.style.color=zl,p.style.fontWeight=``,p.style.color=``),j()};m.addEventListener(`change`,E),_.addEventListener(`change`,E);function D(){f.style.display=`none`,m.checked=!1,_.checked=!1,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``,T=void 0}let O={[Ol]:a.retired||`RETIRED`,[kl]:a.walkover||`WALKOVER`,[Al]:a.defaulted||`DEFAULTED`,[jl]:`SUSPENDED`,[Ml]:`CANCELLED`,[Nl]:`INCOMPLETE`,[Pl]:`DEAD RUBBER`,[Fl]:`IN PROGRESS`,[Il]:`AWAITING RESULT`};function k(e){let t=a.validScore||`Valid score`,n=e&&O[e];return n?`${t} - ${n}`:t}function A(e,t,n){let r=e.matchUpStatus||t.matchUpStatus,a=[Ol,kl,Al].includes(r),o=[Ml,Pl,Il,Nl,Fl,jl].includes(r);if(a){f.style.display=`flex`;let a=T;if(!a){i(r===kl?{...e,isValid:!0,matchUpStatus:Ll,score:t.formattedScore||n}:r===Al?{...e,isValid:!0,matchUpStatus:Rl,score:t.formattedScore||n}:{...e,isValid:!1,error:`Winner must be selected for irregular ending`,matchUpStatus:r,score:t.formattedScore||n});return}return a}if(o){D();return}return D(),e.winningSide}let j=()=>{let e=x.value.trim();if(!e){S.textContent=``,C.textContent=``,w.textContent=``,w.style.color=``,D(),y({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`});return}let t=Hc(e,n.matchUpFormat);C.textContent=t.formattedScore||``;let r=new Set([Ol,kl,Al,jl,Ml,Nl,Pl,Fl,Il]),a=t.matchUpStatus&&r.has(t.matchUpStatus),o=t.formattedScore?us(t.formattedScore,n.matchUpFormat,t.matchUpStatus):{isValid:!1,sets:[],error:`No score to validate`},s=o.sets&&o.sets.length>0,c=T||o.winningSide;if((s&&o.scoreObject||a)&&y({scoreObject:o.scoreObject,winningSide:c,matchUpStatus:o.matchUpStatus||t.matchUpStatus}),o.isValid||a)if(S.textContent=`✓`,S.style.color=zl,w.textContent=k(o.matchUpStatus||t.matchUpStatus),w.style.color=zl,a){let n=A(o,t,e);if(n===void 0&&[Ol,kl,Al].includes(o.matchUpStatus||t.matchUpStatus)&&!T)return;i({...o,isValid:!0,winningSide:n,matchUpStatus:o.matchUpStatus||t.matchUpStatus,score:t.formattedScore||e})}else D(),i({...o,isValid:!0,winningSide:o.winningSide,matchUpStatus:o.matchUpStatus||t.matchUpStatus,score:t.formattedScore||e});else !o.isValid&&s?(S.textContent=`⋯`,S.style.color=`var(--chc-status-warning)`,w.textContent=o.error||`Score incomplete - continue typing`,w.style.color=`var(--chc-status-warning)`,D(),i(o)):(S.textContent=`✗`,S.style.color=`var(--chc-status-error)`,w.textContent=o.error||`Invalid score`,w.style.color=`var(--chc-status-error)`,D(),y({scoreObject:void 0,winningSide:void 0,matchUpStatus:void 0}),i(o))},M=!1;x.addEventListener(`input`,()=>{j();let e=x.value,r=e.trim();if(!M&&r){let i=Hc(r,n.matchUpFormat),a=i.formattedScore?us(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)&&(M=!0)}else if(M){let t=e.length>0&&/[\s-]$/.test(e);(r.length===0||!t)&&(M=!1)}}),x.addEventListener(`keydown`,e=>{M&&![`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`Tab`].includes(e.key)&&e.preventDefault()}),x.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=zl):l===2&&(_.checked=!0,g.style.fontWeight=`bold`,g.style.color=zl),setTimeout(()=>{x.focus(),u===Ll||u===Rl?(y({scoreObject:c,winningSide:l,matchUpStatus:u}),i({isValid:!0,sets:c?.sets||[],scoreObject:c,winningSide:l,matchUpStatus:u})):(x.value||u&&u!==`TO_BE_PLAYED`&&u!==`COMPLETED`)&&j()},100),globalThis.resetFreeScore=()=>{x.value=``,c=void 0,l=void 0,u=void 0,S.textContent=``,C.textContent=``,w.textContent=``,w.style.color=``,f.style.display=`none`,m.checked=!1,_.checked=!1,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``,T=void 0,M=!1,y({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`}),x.focus()}}var Vl=`Irregular Endings:`,Hl={dynamicSets:`Dynamic Sets`,freeScore:`Free Score`,dialPad:`Dial Pad`,inlineScoring:`Inline Scoring`},Ul=[`dynamicSets`,`freeScore`,`dialPad`,`inlineScoring`];function Wl(e){let{matchUp:t,callback:n,onClose:r,labels:i={}}=e,a=es().scoringApproach||`dynamicSets`,o=!!(t.score?.sets?.length||t.matchUpStatus),s=null,c=!1,l=e=>{s=e,c&&(e.sets?.length>0||e.score)&&(c=!1);let t=document.getElementById(`submitScoreV2`);t&&(t.disabled=!(a===`inlineScoring`||e.isValid||c&&o));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)}}},u=()=>{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)},d=e=>{let n=document.createElement(`div`);return n.style.padding=`1em`,e===`freeScore`?Bl({matchUp:t,container:n,onScoreChange:l,labels:i}):e===`dynamicSets`?Us({matchUp:t,container:n,onScoreChange:l,labels:i}):e===`dialPad`?cc({matchUp:t,container:n,onScoreChange:l,labels:i}):e===`inlineScoring`&&is({matchUp:t,container:n,onScoreChange:l,labels:i}),n},f={freeScore:`
|
|
145
|
+
`,e.label.length>1&&!e.isSpecial?t.style.fontSize=`1.3em`:e.isSpecial&&[`RET`,`WO`,`DEF`].includes(e.label)?(t.style.fontSize=`0.95em`,t.style.setProperty(`background-color`,cc,`important`)):e.isSpecial?(t.style.fontSize=`1.3em`,t.style.setProperty(`background-color`,cc,`important`)):t.style.fontSize=`1.3em`,(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`?O():e.value===`minus`?D(`-`):e.value===`retired`?(m=tc,h=void 0,g.querySelectorAll(uc).forEach(e=>e.checked=!1),E()):e.value===`walkover`?(m=nc,h=void 0,d.digits=``,g.querySelectorAll(uc).forEach(e=>e.checked=!1),E(),j()):e.value===`defaulted`?(m=rc,h=void 0,g.querySelectorAll(uc).forEach(e=>e.checked=!1),E()):e.value===`empty`||D(e.value)},C.appendChild(t)});let M=e=>{if(e.key>=`0`&&e.key<=`9`)e.preventDefault(),D(Number.parseInt(e.key));else if(e.key===`Backspace`||e.key===`Delete`)e.preventDefault(),O();else if(e.key===`-`||e.key===` `||e.key===`/`)e.preventDefault(),D(`-`);else if(e.key===`)`){e.preventDefault();let t=w(d.digits);t.includes(`(`)&&!t.includes(`)`)&&(d.digits+=`-`,E())}};r.setAttribute(`tabindex`,`-1`),r.style.outline=`none`,r.addEventListener(`keydown`,M),setTimeout(()=>r.focus(),100),globalThis.cleanupDialPad=()=>{r.removeEventListener(`keydown`,M)};let N=u===tc||u===nc||u===rc||u===ic||u===ac;N?(u===ic?(m=nc,h=void 0):u===ac?(m=rc,h=void 0):(m=u,h=l),g.querySelectorAll(lc).forEach(e=>{e.value===m&&(e.checked=!0)}),h&&(g.querySelectorAll(uc).forEach(e=>{Number.parseInt(e.value)===h&&(e.checked=!0)}),v.style.display=`block`)):!c&&(!u||u===`TO_BE_PLAYED`)&&k(),d.digits||N?(E(),setTimeout(()=>{let e=document.getElementById(`clearScoreV2`);e&&(e.disabled=!1),j()},0)):(T(null),j())}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:pc,WALKOVER:mc,DEFAULTED:hc,SUSPENDED:gc,CANCELLED:_c,INCOMPLETE:vc,DEAD_RUBBER:yc,IN_PROGRESS:bc,AWAITING_RESULT:xc}=t.matchUpStatusConstants;function Sc(e,t){let n=e.substring(t).trim().toLowerCase();return/^in(\s+p(rog(ress)?)?)?$/i.exec(n)?{ending:bc,endPos:e.length}:/^inc(omp(lete?)?)?/i.exec(n)?{ending:vc,endPos:e.length}:/^(dr|dead(\s*r(ubber)?)?)/i.exec(n)?{ending:yc,endPos:e.length}:/^r(et(ired?)?)?/i.exec(n)?{ending:pc,endPos:e.length}:/^(w(\/o|o|alk(over?)?)?)/i.exec(n)?{ending:mc,endPos:e.length}:/^d(ef(aulted?)?)?/i.exec(n)?{ending:hc,endPos:e.length}:/^s(usp(ended?)?)?/i.exec(n)?{ending:gc,endPos:e.length}:/^c(anc(ell?ed?)?)?/i.exec(n)?{ending:_c,endPos:e.length}:/^a(wait(ing(\s*r(esult)?)?)?)?/i.exec(n)?{ending:xc,endPos:e.length}:{endPos:t}}function Cc(e,t){return t===(e.bestOf||3)-1&&e.finalSetFormat?e.finalSetFormat:e.setFormat}function wc(e){return!!e?.tiebreakSet?.tiebreakTo&&!e?.setTo}function Tc(e){return wc(e)?0:(e?.setTo||6)+1}function Ec(e){let t=e?.tiebreakSet,n=e?.tiebreakFormat;return t?t.tiebreakTo||10:n&&n.tiebreakTo||7}function Dc(e){return e>=`0`&&e<=`9`}function Oc(e){for(let t of e)if(!Dc(t))return!1;return!0}function kc(e){return!Dc(e)&&!Ac(e)&&!jc(e)}function Ac(e){return e===`(`||e===`[`}function jc(e){return e===`)`||e===`]`}function Mc(e,t,n){let r=n?.tiebreakAt||n?.setTo||6;return e===r&&t===r}function Nc(e,t,n){let r=n?.setTo||6,i=Math.max(e,t);return i<r?!1:i-Math.min(e,t)>=2?!0:(r+1,!1)}function Pc(e,t,n){let r=Ec(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 Fc(e,t){let n=+(e===`1-0`),r=+(e===`0-1`);return{side1TiebreakScore:n,side2TiebreakScore:r,setNumber:t,winningSide:n>r?1:2}}function Ic(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||!Oc(i)||!Oc(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 Lc(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||!Oc(i)||!Oc(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 Rc(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 zc(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=Rc(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 Bc(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(Fc(o,s));else if(t&&c&&!l){let e=Lc(o,s,r);e&&i.push(e)}else{let e=Ic(o,s,r);e&&i.push(e)}}return i}function Vc(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 Hc(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 Uc(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 Wc(e){return e.map(e=>e.side1TiebreakScore===void 0?`${e.side1Score}-${e.side2Score}`:`${e.side1TiebreakScore}-${e.side2TiebreakScore}`).join(` `)}function Gc(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 Vc(o,n);let s=r.split(/\s+/),c=[],l=o?n-1:n,u=Bc(s,o,n,c);o&&c.length===0&&zc(u,l,c);let d=o?l:n,f=n;Hc(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=Wc(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:Uc(p,o,d,u.length,n),incomplete:p,matchComplete:m}}function Kc(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 Gc(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(wc(Cc(r,0))?(o.expectingTiebreakOnly=!0,o.inTiebreak=!0,o.state=`PARSING_TIEBREAK_SIDE1`):o.state=`PARSING_SIDE1`;o.position<e.length&&o.isValid;)qc(o);pl(o);let s=o.sets,c;o.irregularEnding&&(c=o.irregularEnding,(o.irregularEnding===mc||o.irregularEnding===_c||o.irregularEnding===yc)&&(s=[]));let l=o.irregularEnding?!1:ml(o),u=hl(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 qc(e){let t=e.input[e.position];if(!Dc(t)&&!Ac(t)&&!jc(t)){let t=Sc(e.input,e.position);if(t.ending){e.irregularEnding=t.ending,e.irregularEndingPosition=e.position,e.position=t.endPos;return}}if(kc(t)){Jc(e);return}if(Ac(t)){Yc(e);return}if(jc(t)){Xc(e);return}if(Dc(t)){Zc(e,t);return}e.errors.push({position:e.position,message:`Unexpected character '${t}'`,got:t,context:gl(e)}),e.isValid=!1}function Jc(e){if(e.state===`PARSING_SIDE1`&&e.currentSide1Buffer){e.state=`PARSING_SIDE2`,e.position++;return}if(e.state===`PARSING_SIDE2`&&e.currentSide2Buffer){if(cl(Number.parseInt(e.currentSide1Buffer),Number.parseInt(e.currentSide2Buffer),Cc(e.parsedFormat,e.setIndex))){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}dl(e),e.position++;return}if(e.state===`PARSING_TIEBREAK_SIDE1`&&e.currentTiebreakSide1Buffer)if(e.currentSide1Buffer&&e.currentSide2Buffer){dl(e),e.position++;return}else{e.state=`PARSING_TIEBREAK_SIDE2`,e.position++;return}e.position++}function Yc(e){let t=Cc(e.parsedFormat,e.setIndex);if(wc(t)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}if(e.currentSide1Buffer&&e.currentSide2Buffer&&Mc(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 Xc(e){if(e.inTiebreak){fl(e),e.inTiebreak=!1,e.position++;return}e.warnings.push(`Unexpected tiebreak closer at position ${e.position}`),e.position++}function Zc(e,t){let n=Cc(e.parsedFormat,e.setIndex);e.inTiebreak?il(e,t,n):tl(e,t,n)}function Qc(e,t,n){return Number.parseInt(e+t)>n}function $c(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&&Dc(e.input[i])){let t=e.input[i];Qc(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 el(e,t,n,r){e.currentSide2Buffer+=t;let i=Number.parseInt(e.currentSide1Buffer),a=Number.parseInt(e.currentSide2Buffer);if(cl(i,a,n)){e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`,e.position++;return}let o=e.position+1;if(o<e.input.length&&Dc(e.input[o])){let t=e.input[o];Qc(e.currentSide2Buffer,t,r)&&(Nc(i,a,n)||Mc(i,a,n)||e.warnings.push(`Set ${e.setIndex+1} may be incomplete: ${i}-${a}`),dl(e))}e.position++}function tl(e,t,n){let r=Tc(n);if(e.state===`PARSING_SIDE1`||e.state===`START`){$c(e,t,r);return}if(e.state===`PARSING_SIDE2`){el(e,t,n,r);return}e.position++}function nl(e,t){e.currentTiebreakSide1Buffer+=t,e.position++}function rl(e,t,n){e.currentTiebreakSide2Buffer+=t;let r=Number.parseInt(e.currentTiebreakSide2Buffer),i=e.position+1;if(i<e.input.length&&Dc(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;Pc(o,t,n)||e.warnings.push(`Tiebreak may be incomplete: ${o}-${t}`),dl(e)}}e.position++}function il(e,t,n){if(e.state===`PARSING_TIEBREAK_SIDE1`){nl(e,t);return}if(e.state===`PARSING_TIEBREAK_SIDE2`){rl(e,t,n);return}e.position++}function al(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 ol(e,t,n){let r=t.currentTiebreakSide1Buffer,i=t.currentTiebreakSide2Buffer;r&&i?(e.side1TiebreakScore=Number.parseInt(r),e.side2TiebreakScore=Number.parseInt(i)):(r||i)&&sl(e,r,i,n)}function sl(e,t,n,r){let i=Number.parseInt(t||n),a=Ec(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 cl(e,t,n){let r=n.tiebreakAt||n.setTo||6;return e===r&&t===r+1||t===r&&e===r+1}function ll(e,t){if(!e.currentSide1Buffer||!e.currentSide2Buffer)return null;let n=Number.parseInt(e.currentSide1Buffer),r=Number.parseInt(e.currentSide2Buffer);if(cl(n,r,t)&&!e.currentTiebreakSide1Buffer&&!e.currentTiebreakSide2Buffer)return null;let i={side1Score:n,side2Score:r,setNumber:e.setIndex+1};return(e.currentTiebreakSide1Buffer||e.currentTiebreakSide2Buffer)&&ol(i,e,t),n>r?i.winningSide=1:r>n&&(i.winningSide=2),i}function ul(e){e.currentSide1Buffer=``,e.currentSide2Buffer=``,e.currentTiebreakSide1Buffer=``,e.currentTiebreakSide2Buffer=``,e.setIndex++,e.inTiebreak=!1,e.state=`PARSING_SIDE1`,wc(Cc(e.parsedFormat,e.setIndex))&&(e.expectingTiebreakOnly=!0,e.inTiebreak=!0,e.state=`PARSING_TIEBREAK_SIDE1`)}function dl(e){let t=Cc(e.parsedFormat,e.setIndex),n=wc(t)?al(e):ll(e,t);n&&e.sets.push(n),ul(e)}function fl(e){dl(e)}function pl(e){(e.currentSide1Buffer||e.currentSide2Buffer||e.currentTiebreakSide1Buffer||e.currentTiebreakSide2Buffer)&&dl(e)}function ml(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 hl(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 gl(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:_l,WALKOVER:vl,DEFAULTED:yl,DOUBLE_WALKOVER:bl,DOUBLE_DEFAULT:xl,SUSPENDED:Sl,CANCELLED:Cl,INCOMPLETE:wl,DEAD_RUBBER:Tl,IN_PROGRESS:El,AWAITING_RESULT:Dl,COMPLETED:Ol,TO_BE_PLAYED:kl}=t.matchUpStatusConstants;function Al(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!==Ol&&t!==kl){let e=jl(t);if(e)return n?`${n} ${e}`:e}return n}function jl(e){return{[_l]:`ret`,[vl]:`wo`,[yl]:`def`,[bl]:`wo`,[xl]:`def`,[Sl]:`susp`,[Cl]:`canc`,[wl]:`inc`,[Tl]:`dr`,[El]:`in`,[Dl]:`await`}[e]||``}var{RETIRED:Ml,WALKOVER:Nl,DEFAULTED:Pl,SUSPENDED:Fl,CANCELLED:Il,INCOMPLETE:Ll,DEAD_RUBBER:Rl,IN_PROGRESS:zl,AWAITING_RESULT:Bl,DOUBLE_WALKOVER:Vl,DOUBLE_DEFAULT:Hl}=t.matchUpStatusConstants,Ul=`var(--chc-status-success)`;function Wl(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.75em`,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.75em`,g.appendChild(_),g.appendChild(v),f.appendChild(p),f.appendChild(g),r.appendChild(f);let y=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=qr({matchUp:p,isLucky:!0,composition:si[is().composition||`Australian`]||si.Australian});d.appendChild(m)};if(y(),n.matchUpFormat){let e=document.createElement(`div`);e.style.fontSize=`0.9em`,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.75em`,i.style.padding=`0.2em 0.5em`,i.style.cursor=`pointer`,i.title=`Click to edit format`,i.addEventListener(`click`,()=>{try{Da({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}))),w.textContent=`Score cleared - format changed`,w.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 b=document.createElement(`div`);b.style.display=`flex`,b.style.alignItems=`center`,b.style.gap=`0.5em`;let x=document.createElement(`input`);x.type=`text`,x.className=`input`,x.placeholder=``,x.style.flex=`1`,x.id=`scoreInputV2`,c&&(x.value=Al(c,u));let S=document.createElement(`span`);S.style.fontSize=`1.2em`,S.style.minWidth=`1.5em`,b.appendChild(x),b.appendChild(S),r.appendChild(b);let C=document.createElement(`div`);C.style.fontSize=`0.9em`,C.style.color=`var(--chc-border-focus)`,C.style.fontFamily=`monospace`,C.style.minHeight=`1.5em`,C.style.padding=`0.25em`,r.appendChild(C);let w=document.createElement(`div`);w.style.fontSize=`0.9em`,w.style.minHeight=`1.5em`,r.appendChild(w);let T=l,E=()=>{m.checked?(T=1,p.style.fontWeight=`bold`,p.style.color=Ul,g.style.fontWeight=``,g.style.color=``):_.checked&&(T=2,g.style.fontWeight=`bold`,g.style.color=Ul,p.style.fontWeight=``,p.style.color=``),j()};m.addEventListener(`change`,E),_.addEventListener(`change`,E);function D(){f.style.display=`none`,m.checked=!1,_.checked=!1,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``,T=void 0}let O={[Ml]:a.retired||`RETIRED`,[Nl]:a.walkover||`WALKOVER`,[Pl]:a.defaulted||`DEFAULTED`,[Fl]:`SUSPENDED`,[Il]:`CANCELLED`,[Ll]:`INCOMPLETE`,[Rl]:`DEAD RUBBER`,[zl]:`IN PROGRESS`,[Bl]:`AWAITING RESULT`};function k(e){let t=a.validScore||`Valid score`,n=e&&O[e];return n?`${t} - ${n}`:t}function A(e,t,n){let r=e.matchUpStatus||t.matchUpStatus,a=[Ml,Nl,Pl].includes(r),o=[Il,Rl,Bl,Ll,zl,Fl].includes(r);if(a){f.style.display=`flex`;let a=T;if(!a){i(r===Nl?{...e,isValid:!0,matchUpStatus:Vl,score:t.formattedScore||n}:r===Pl?{...e,isValid:!0,matchUpStatus:Hl,score:t.formattedScore||n}:{...e,isValid:!1,error:`Winner must be selected for irregular ending`,matchUpStatus:r,score:t.formattedScore||n});return}return a}if(o){D();return}return D(),e.winningSide}let j=()=>{let e=x.value.trim();if(!e){S.textContent=``,C.textContent=``,w.textContent=``,w.style.color=``,D(),y({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`});return}let t=Kc(e,n.matchUpFormat);C.textContent=t.formattedScore||``;let r=new Set([Ml,Nl,Pl,Fl,Il,Ll,Rl,zl,Bl]),a=t.matchUpStatus&&r.has(t.matchUpStatus),o=t.formattedScore?ms(t.formattedScore,n.matchUpFormat,t.matchUpStatus):{isValid:!1,sets:[],error:`No score to validate`},s=o.sets&&o.sets.length>0,c=T||o.winningSide;if((s&&o.scoreObject||a)&&y({scoreObject:o.scoreObject,winningSide:c,matchUpStatus:o.matchUpStatus||t.matchUpStatus}),o.isValid||a)if(S.textContent=`✓`,S.style.color=Ul,w.textContent=k(o.matchUpStatus||t.matchUpStatus),w.style.color=Ul,a){let n=A(o,t,e);if(n===void 0&&[Ml,Nl,Pl].includes(o.matchUpStatus||t.matchUpStatus)&&!T)return;i({...o,isValid:!0,winningSide:n,matchUpStatus:o.matchUpStatus||t.matchUpStatus,score:t.formattedScore||e})}else D(),i({...o,isValid:!0,winningSide:o.winningSide,matchUpStatus:o.matchUpStatus||t.matchUpStatus,score:t.formattedScore||e});else !o.isValid&&s?(S.textContent=`⋯`,S.style.color=`var(--chc-status-warning)`,w.textContent=o.error||`Score incomplete - continue typing`,w.style.color=`var(--chc-status-warning)`,D(),i(o)):(S.textContent=`✗`,S.style.color=`var(--chc-status-error)`,w.textContent=o.error||`Invalid score`,w.style.color=`var(--chc-status-error)`,D(),y({scoreObject:void 0,winningSide:void 0,matchUpStatus:void 0}),i(o))},M=!1;x.addEventListener(`input`,()=>{j();let e=x.value,r=e.trim();if(!M&&r){let i=Kc(r,n.matchUpFormat),a=i.formattedScore?ms(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)&&(M=!0)}else if(M){let t=e.length>0&&/[\s-]$/.test(e);(r.length===0||!t)&&(M=!1)}}),x.addEventListener(`keydown`,e=>{M&&![`Backspace`,`Delete`,`ArrowLeft`,`ArrowRight`,`Tab`].includes(e.key)&&e.preventDefault()}),x.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=Ul):l===2&&(_.checked=!0,g.style.fontWeight=`bold`,g.style.color=Ul),setTimeout(()=>{x.focus(),u===Vl||u===Hl?(y({scoreObject:c,winningSide:l,matchUpStatus:u}),i({isValid:!0,sets:c?.sets||[],scoreObject:c,winningSide:l,matchUpStatus:u})):(x.value||u&&u!==`TO_BE_PLAYED`&&u!==`COMPLETED`)&&j()},100),globalThis.resetFreeScore=()=>{x.value=``,c=void 0,l=void 0,u=void 0,S.textContent=``,C.textContent=``,w.textContent=``,w.style.color=``,f.style.display=`none`,m.checked=!1,_.checked=!1,p.style.fontWeight=``,p.style.color=``,g.style.fontWeight=``,g.style.color=``,T=void 0,M=!1,y({clearAll:!0}),i({isValid:!1,sets:[],matchUpStatus:`TO_BE_PLAYED`}),x.focus()}}var Gl=`Irregular Endings:`,Kl={dynamicSets:`Dynamic Sets`,freeScore:`Free Score`,dialPad:`Dial Pad`,inlineScoring:`Inline Scoring`},ql=[`dynamicSets`,`freeScore`,`dialPad`,`inlineScoring`];function Jl(e){let{matchUp:t,callback:n,onClose:r,labels:i={}}=e,a=is().scoringApproach||`dynamicSets`,o=!!(t.score?.sets?.length||t.matchUpStatus),s=null,c=!1,l=e=>{s=e,c&&(e.sets?.length>0||e.score)&&(c=!1);let t=document.getElementById(`submitScoreV2`);t&&(t.disabled=!(a===`inlineScoring`||e.isValid||c&&o));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)}}},u=()=>{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)},d=e=>{let n=document.createElement(`div`);return n.style.padding=`1em`,e===`freeScore`?Wl({matchUp:t,container:n,onScoreChange:l,labels:i}):e===`dynamicSets`?qs({matchUp:t,container:n,onScoreChange:l,labels:i}):e===`dialPad`?fc({matchUp:t,container:n,onScoreChange:l,labels:i}):e===`inlineScoring`&&cs({matchUp:t,container:n,onScoreChange:l,labels:i}),n},f={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>
|
|
149
149
|
<strong>${i.matchTiebreaks||`Match Tiebreaks:`}</strong> Use dash separator (e.g., "10-7")<br><br>
|
|
150
|
-
<strong>${i.irregularEndings||
|
|
150
|
+
<strong>${i.irregularEndings||Gl}</strong><br>
|
|
151
151
|
<strong>r</strong> = ${i.retired||`Retired`}<br>
|
|
152
152
|
<strong>w</strong> = ${i.walkover||`Walkover`}<br>
|
|
153
153
|
<strong>d</strong> = ${i.defaulted||`Defaulted`}<br>
|
|
@@ -161,20 +161,20 @@
|
|
|
161
161
|
<strong>${i.dynamicSetsTips||`Dynamic Sets Scoring:`}</strong><br><br>
|
|
162
162
|
Enter scores set by set using individual inputs.<br><br>
|
|
163
163
|
<strong>${i.tiebreaks||`Tiebreaks:`}</strong> Enter tiebreak score in the TB field when a set is tied<br><br>
|
|
164
|
-
<strong>${i.irregularEndings||
|
|
164
|
+
<strong>${i.irregularEndings||Gl}</strong> Click Retired, Walkover, Default.
|
|
165
165
|
`,dialPad:`
|
|
166
166
|
<strong>${i.dialPadTips||`Dial Pad Scoring:`}</strong><br><br>
|
|
167
167
|
Tap the number buttons to enter scores for each side.<br><br>
|
|
168
|
-
<strong>${i.irregularEndings||
|
|
168
|
+
<strong>${i.irregularEndings||Gl}</strong> Retired, Walkover, Default available for irregular endings.
|
|
169
169
|
`,inlineScoring:`
|
|
170
170
|
<strong>Inline Scoring:</strong><br><br>
|
|
171
171
|
Click on <strong>game scores</strong> to add a game for that side.<br><br>
|
|
172
172
|
Click on <strong>point scores</strong> to award a point.<br><br>
|
|
173
173
|
Use the <strong>LIVE</strong> pill to set an irregular ending (Retired, Walkover, etc.).<br><br>
|
|
174
174
|
<strong>Undo/Redo/Clear</strong> buttons control scoring history.
|
|
175
|
-
`},p=()=>
|
|
176
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function
|
|
177
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Au(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ju(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Au(Object(n),!0).forEach(function(t){Du(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Au(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Mu(e){return Tu(e)||Ou(e)||Fu(e)||ku()}function Nu(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Pu(e){var t=Nu(e,`string`);return typeof t==`symbol`?t:t+``}function Fu(e,t){if(e){if(typeof e==`string`)return wu(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wu(e,t):void 0}}var Iu={getActiveTrap:function(e){return e?.length>0?e[e.length-1]:null},activateTrap:function(e,t){t!==Iu.getActiveTrap(e)&&Iu.pauseTrap(e);var n=e.indexOf(t);n===-1||e.splice(n,1),e.push(t)},deactivateTrap:function(e,t){var n=e.indexOf(t);n!==-1&&e.splice(n,1),Iu.unpauseTrap(e)},pauseTrap:function(e){Iu.getActiveTrap(e)?._setPausedState(!0)},unpauseTrap:function(e){var t=Iu.getActiveTrap(e);t&&!t._isManuallyPaused()&&t._setPausedState(!1)}},Lu=function(e){return e.tagName&&e.tagName.toLowerCase()===`input`&&typeof e.select==`function`},Ru=function(e){return e?.key===`Escape`||e?.key===`Esc`||e?.keyCode===27},zu=function(e){return e?.key===`Tab`||e?.keyCode===9},Bu=function(e){return zu(e)&&!e.shiftKey},Vu=function(e){return zu(e)&&e.shiftKey},Hu=function(e){return setTimeout(e,0)},Uu=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return typeof e==`function`?e.apply(void 0,n):e},Wu=function(e){return e.target.shadowRoot&&typeof e.composedPath==`function`?e.composedPath()[0]:e.target},Gu=[],Ku=function(e,t){var n=t?.document||document,r=t?.trapStack||Gu,i=ju({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,delayReturnFocus:!0,isolateSubtrees:!1,isKeyForward:Bu,isKeyBackward:Vu},t),a={containers:[],containerGroups:[],tabbableGroups:[],adjacentElements:new Set,alreadySilent:new Set,nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},o,s=function(e,t,n){return e&&e[t]!==void 0?e[t]:i[n||t]},c=function(e,t){var n=typeof t?.composedPath==`function`?t.composedPath():void 0;return a.containerGroups.findIndex(function(t){var r=t.container,i=t.tabbableNodes;return r.contains(e)||n?.includes(r)||i.find(function(t){return t===e})})},l=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.hasFallback,a=r===void 0?!1:r,o=t.params,s=o===void 0?[]:o,c=i[e];if(typeof c==`function`&&(c=c.apply(void 0,Mu(s))),c===!0&&(c=void 0),!c){if(c===void 0||c===!1)return c;throw Error(`\`${e}\` was specified but was not a node, or did not return a node`)}var l=c;if(typeof c==`string`){try{l=n.querySelector(c)}catch(t){throw Error(`\`${e}\` appears to be an invalid selector; error="${t.message}"`)}if(!l&&!a)throw Error(`\`${e}\` as selector refers to no known node`)}return l},u=function(e){var t=e.activeElement;return t?t.shadowRoot&&t.shadowRoot.activeElement!==null?u(t.shadowRoot):t:null},d=function(){var e=l(`initialFocus`,{hasFallback:!0});if(e===!1)return!1;if(e===void 0||e&&!Cu(e,i.tabbableOptions)){var t=u(n);if(c(t)>=0)e=t;else{var r=a.tabbableGroups[0];e=r&&r.firstTabbableNode||l(`fallbackFocus`)}}else e===null&&(e=l(`fallbackFocus`));if(!e)throw Error(`Your focus-trap needs to have at least one focusable element`);return e},f=function(){if(a.containerGroups=a.containers.map(function(e){var t=yu(e,i.tabbableOptions),n=bu(e,i.tabbableOptions),r=t.length>0?t[0]:void 0,a=t.length>0?t[t.length-1]:void 0,o=n.find(function(e){return xu(e)}),s=n.slice().reverse().find(function(e){return xu(e)});return{container:e,tabbableNodes:t,focusableNodes:n,posTabIndexesFound:!!t.find(function(e){return tu(e)>0}),firstTabbableNode:r,lastTabbableNode:a,firstDomTabbableNode:o,lastDomTabbableNode:s,nextTabbableNode:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,i=t.indexOf(e);return i<0?r?n.slice(n.indexOf(e)+1).find(function(e){return xu(e)}):n.slice(0,n.indexOf(e)).reverse().find(function(e){return xu(e)}):t[i+(r?1:-1)]}}}),a.tabbableGroups=a.containerGroups.filter(function(e){return e.tabbableNodes.length>0}),a.tabbableGroups.length<=0&&!l(`fallbackFocus`))throw Error(`Your focus-trap must have at least one container with at least one tabbable node in it at all times`);if(a.containerGroups.find(function(e){return e.posTabIndexesFound})&&a.containerGroups.length>1)throw Error(`At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.`)},p=function(e){if(e!==!1&&e!==u(document)){if(!e||!e.focus){p(d());return}e.focus({preventScroll:!!i.preventScroll}),a.mostRecentlyFocusedNode=e,Lu(e)&&e.select()}},m=function(e){var t=l(`setReturnFocus`,{params:[e]});return t||(t===!1?!1:e)},h=function(e){var t=e.target,n=e.event,r=e.isBackward,o=r===void 0?!1:r;t||=Wu(n),f();var s=null;if(a.tabbableGroups.length>0){var u=c(t,n),d=u>=0?a.containerGroups[u]:void 0;if(u<0)s=o?a.tabbableGroups[a.tabbableGroups.length-1].lastTabbableNode:a.tabbableGroups[0].firstTabbableNode;else if(o){var p=a.tabbableGroups.findIndex(function(e){var n=e.firstTabbableNode;return t===n});if(p<0&&(d.container===t||Cu(t,i.tabbableOptions)&&!xu(t,i.tabbableOptions)&&!d.nextTabbableNode(t,!1))&&(p=u),p>=0){var m=p===0?a.tabbableGroups.length-1:p-1,h=a.tabbableGroups[m];s=tu(t)>=0?h.lastTabbableNode:h.lastDomTabbableNode}else zu(n)||(s=d.nextTabbableNode(t,!1))}else{var g=a.tabbableGroups.findIndex(function(e){var n=e.lastTabbableNode;return t===n});if(g<0&&(d.container===t||Cu(t,i.tabbableOptions)&&!xu(t,i.tabbableOptions)&&!d.nextTabbableNode(t))&&(g=u),g>=0){var _=g===a.tabbableGroups.length-1?0:g+1,v=a.tabbableGroups[_];s=tu(t)>=0?v.firstTabbableNode:v.firstDomTabbableNode}else zu(n)||(s=d.nextTabbableNode(t))}}else s=l(`fallbackFocus`);return s},g=function(e){if(!(c(Wu(e),e)>=0)){if(Uu(i.clickOutsideDeactivates,e)){o.deactivate({returnFocus:i.returnFocusOnDeactivate});return}Uu(i.allowOutsideClick,e)||e.preventDefault()}},_=function(e){var t=Wu(e),n=c(t,e)>=0;if(n||t instanceof Document)n&&(a.mostRecentlyFocusedNode=t);else{e.stopImmediatePropagation();var r,o=!0;if(a.mostRecentlyFocusedNode)if(tu(a.mostRecentlyFocusedNode)>0){var s=c(a.mostRecentlyFocusedNode),l=a.containerGroups[s].tabbableNodes;if(l.length>0){var u=l.findIndex(function(e){return e===a.mostRecentlyFocusedNode});u>=0&&(i.isKeyForward(a.recentNavEvent)?u+1<l.length&&(r=l[u+1],o=!1):u-1>=0&&(r=l[u-1],o=!1))}}else a.containerGroups.some(function(e){return e.tabbableNodes.some(function(e){return tu(e)>0})})||(o=!1);else o=!1;o&&(r=h({target:a.mostRecentlyFocusedNode,isBackward:i.isKeyBackward(a.recentNavEvent)})),p(r||a.mostRecentlyFocusedNode||d())}a.recentNavEvent=void 0},v=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;a.recentNavEvent=e;var n=h({event:e,isBackward:t});n&&(zu(e)&&e.preventDefault(),p(n))},y=function(e){(i.isKeyForward(e)||i.isKeyBackward(e))&&v(e,i.isKeyBackward(e))},b=function(e){Ru(e)&&Uu(i.escapeDeactivates,e)!==!1&&(e.preventDefault(),o.deactivate())},x=function(e){c(Wu(e),e)>=0||Uu(i.clickOutsideDeactivates,e)||Uu(i.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},S=function(){if(a.active){Iu.activateTrap(r,o);var e;return i.delayInitialFocus?e=new Promise(function(e){a.delayInitialFocusTimer=Hu(function(){p(d()),e()})}):p(d()),n.addEventListener(`focusin`,_,!0),n.addEventListener(`mousedown`,g,{capture:!0,passive:!1}),n.addEventListener(`touchstart`,g,{capture:!0,passive:!1}),n.addEventListener(`click`,x,{capture:!0,passive:!1}),n.addEventListener(`keydown`,y,{capture:!0,passive:!1}),n.addEventListener(`keydown`,b),e}},C=function(e){a.active&&!a.paused&&o._setSubtreeIsolation(!1),a.adjacentElements.clear(),a.alreadySilent.clear();var t=new Set,n=new Set,r=Eu(e),i;try{for(r.s();!(i=r.n()).done;){var s=i.value;t.add(s);for(var c=typeof ShadowRoot<`u`&&s.getRootNode()instanceof ShadowRoot,l=s;l;){t.add(l);var u=l.parentElement,d=[];u?d=u.children:!u&&c&&(d=l.getRootNode().children,u=l.getRootNode().host,c=typeof ShadowRoot<`u`&&u.getRootNode()instanceof ShadowRoot);var f=Eu(d),p;try{for(f.s();!(p=f.n()).done;){var m=p.value;n.add(m)}}catch(e){f.e(e)}finally{f.f()}l=u}}}catch(e){r.e(e)}finally{r.f()}t.forEach(function(e){n.delete(e)}),a.adjacentElements=n},w=function(){if(a.active)return n.removeEventListener(`focusin`,_,!0),n.removeEventListener(`mousedown`,g,!0),n.removeEventListener(`touchstart`,g,!0),n.removeEventListener(`click`,x,!0),n.removeEventListener(`keydown`,y,!0),n.removeEventListener(`keydown`,b),o},T=typeof window<`u`&&`MutationObserver`in window?new MutationObserver(function(e){var t=a.mostRecentlyFocusedNode;t&&e.some(function(e){return Array.from(e.removedNodes).some(function(e){return e===t||typeof e.contains==`function`&&e.contains(t)})})&&a.containers.some(function(e){return e?.isConnected})&&(f(),p(d()))}):void 0,E=function(){T&&(T.disconnect(),a.active&&!a.paused&&a.containers.map(function(e){T.observe(e,{subtree:!0,childList:!0})}))};return o={get active(){return a.active},get paused(){return a.paused},activate:function(e){if(a.active)return this;var t=s(e,`onActivate`),i=s(e,`onPostActivate`),c=s(e,`checkCanFocusTrap`),l=Iu.getActiveTrap(r),d=!1;if(l&&!l.paused){var p;(p=l._setSubtreeIsolation)==null||p.call(l,!1),d=!0}try{c||f(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=u(n),t?.({trap:o});var m=function(){c&&f();var e=function(){o._setSubtreeIsolation(!0),E(),i?.({trap:o})},t=S();t?t.then(e):e()};if(c)return c(a.containers.concat()).then(m,m),this;m()}catch(e){if(l===Iu.getActiveTrap(r)&&d){var h;(h=l._setSubtreeIsolation)==null||h.call(l,!0)}throw e}return this},deactivate:function(e){if(!a.active)return this;var t=ju({onDeactivate:i.onDeactivate,onPostDeactivate:i.onPostDeactivate,checkCanReturnFocus:i.checkCanReturnFocus},e);clearTimeout(a.delayInitialFocusTimer),a.delayInitialFocusTimer=void 0,a.paused||o._setSubtreeIsolation(!1),a.alreadySilent.clear(),w(),a.active=!1,a.paused=!1,E(),Iu.deactivateTrap(r,o);var n=s(t,`onDeactivate`),c=s(t,`onPostDeactivate`),l=s(t,`checkCanReturnFocus`),u=s(t,`delayReturnFocus`),d=s(t,`returnFocus`,`returnFocusOnDeactivate`);n?.({trap:o});var f=function(){d&&p(m(a.nodeFocusedBeforeActivation)),c?.({trap:o})},h=function(){u&&d?Hu(f):f()};return d&&l?(l(m(a.nodeFocusedBeforeActivation)).then(h,h),this):(h(),this)},pause:function(e){return a.active?(a.manuallyPaused=!0,this._setPausedState(!0,e)):this},unpause:function(e){return!a.active||(a.manuallyPaused=!1,r[r.length-1]!==this)?this:this._setPausedState(!1,e)},updateContainerElements:function(e){return a.containers=[].concat(e).filter(Boolean).map(function(e){return typeof e==`string`?n.querySelector(e):e}),i.isolateSubtrees&&C(a.containers),a.active&&(f(),a.paused||o._setSubtreeIsolation(!0)),E(),this}},Object.defineProperties(o,{_isManuallyPaused:{value:function(){return a.manuallyPaused}},_setPausedState:{value:function(e,t){if(a.paused===e)return this;if(a.paused=e,e){var n=s(t,`onPause`),r=s(t,`onPostPause`);n?.({trap:o}),w(),o._setSubtreeIsolation(!1),E(),r?.({trap:o})}else{var i=s(t,`onUnpause`),c=s(t,`onPostUnpause`);i?.({trap:o}),(function(){f();var e=function(){o._setSubtreeIsolation(!0),E(),c?.({trap:o})},t=S();t?t.then(e):e()})()}return this}},_setSubtreeIsolation:{value:function(e){i.isolateSubtrees&&a.adjacentElements.forEach(function(t){if(e)switch(i.isolateSubtrees){case`aria-hidden`:(t.ariaHidden===`true`||t.getAttribute(`aria-hidden`)?.toLowerCase()===`true`)&&a.alreadySilent.add(t),t.setAttribute(`aria-hidden`,`true`);break;default:(t.inert||t.hasAttribute(`inert`))&&a.alreadySilent.add(t),t.setAttribute(`inert`,!0);break}else if(!a.alreadySilent.has(t))switch(i.isolateSubtrees){case`aria-hidden`:t.removeAttribute(`aria-hidden`);break;default:t.removeAttribute(`inert`);break}})}}}),o.updateContainerElements(e),o},qu=`left`,Ju=`right`,Yu=`courthive-drawer`,Xu=e=>typeof e==`function`,Zu=e=>{for(;e.firstChild;)e.firstChild.remove()};function Qu(e,t){let n=t.parentNode;for(;n;){if(n===e)return!0;n=n.parentNode}return!1}var $u=null,ed=!1,td=(e=Yu)=>{if($u)return $u;let t={selectorTrigger:`[data-drawer-trigger]`,selectorTarget:`[data-drawer-target]`,selectorClose:`[data-drawer-close]`,leftAlignment:`drawer--left`,visibleClass:`is-visible`,activeClass:`is-active`,speedClose:350,speedOpen:50},n={},r=!1,i,a,o,s=!1,c=e=>a=e,l=()=>{Xu(a)&&(a?.(),a=void 0);let n=document.getElementById(e);n&&(n.classList.remove(t.visibleClass),document.documentElement.style.overflow=``,setTimeout(function(){i?(n.classList.add(t.visibleClass),document.documentElement.style.overflow=`hidden`,Xu(i?.callback)&&i.callback()):(n.classList.remove(t.activeClass),r=!1),i=!1,o?.deactivate()},t.speedClose))},u=n=>{if(!e)return;let r=document.getElementById(e);r&&(r.classList.contains(t.leftAlignment)||r.classList.add(t.leftAlignment),g(r,!1,n))},d=n=>{let r=document.getElementById(e);r&&(r.classList.remove(t.leftAlignment),g(r,!1,n))},f=t=>{let n=document.getElementById(e)?.querySelector(`.drawer__title`);n&&(n.innerHTML=t)},p=t=>{let r=document.getElementById(e)?.querySelector(`.drawer__footer`);r&&(Zu(r),Xu(t)?n.footer=t(r,l):r.innerHTML=t||``)},m=t=>{let r=document.getElementById(e)?.querySelector(`.drawer__content`);r&&(Zu(r),Xu(t)?n.content=t(r,l):r.innerHTML=t)},h=t=>{let n=document.getElementById(e)?.querySelector(`.drawer__wrapper`);n&&(n.style.width=t)},g=(e,n,i)=>{r=!0,s=!0,e.classList.add(t.activeClass),document.documentElement.style.overflow=`hidden`,n&&(o=Ku(e),o.activate()),Xu(i)&&i&&i(),setTimeout(function(){e.classList.add(t.visibleClass),setTimeout(()=>{s=!1},100)},t.speedOpen)};return ed||=(document.addEventListener(`click`,function(t){if(!e||!r||s)return;let n=t.target,i=document.querySelector(`.drawer__wrapper`);if(!i)return;let a=n.classList.contains(`drawer__close`)||n.closest(`.drawer__close`)||`drawerClose`in n.dataset||n.closest(`[data-drawer-close]`);(!Qu(i,n)||a)&&l()},!1),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&r&&l()},!1),!0),$u={settings:t,open:(t={})=>{let{title:n,content:a,side:o,width:s,footer:l,callback:_,onClose:v}=t;if(a&&m(a),v&&c(v),n&&f(n),s&&h(s),p(l),r)i={callback:_};else if(o){if(o===Ju)return d(_);if(o===qu)return u(_)}else{let t=document.getElementById(e);t&&g(t,l,_)}},close:l,setTitle:f,setContent:m,setFooter:p,attributes:n},$u};function nd(e=Yu){if(document.getElementById(e))return;let t=`
|
|
175
|
+
`},p=()=>ql.map(e=>({label:Kl[e],active:e===a,onClick:()=>_(e)})),m=()=>({info:f[a],menu:{menuItems:p()}}),h=()=>{setTimeout(()=>{let e=document.getElementById(`clearScoreV2`);e&&(e.style.backgroundColor=`var(--chc-clear-btn-bg)`,e.style.color=`var(--chc-clear-btn-text)`,o&&(e.disabled=!1)),s&&l(s)},0)},g,_=e=>{e!==a&&(u(),s=null,c=!1,a=e,as({scoringApproach:e}),g&&(g.update({content:d(e),config:m()}),h()))};g=F.open({title:i.title||`Score Entry`,content:d(a),config:m(),buttons:[{onClick:()=>{u()},label:i.cancel||`Cancel`,intent:`none`,footer:{className:`button`,style:`background-color: var(--chc-bg-primary); color: var(--chc-text-primary); border: 1px solid var(--chc-border-primary);`},close:!0},{id:`clearScoreV2`,label:i.clear||`Clear`,intent:`none`,disabled:!0,close:!1,onClick:()=>{if(c=!0,a===`freeScore`){let e=document.getElementById(`scoreInputV2`);e&&(e.value=``,e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.focus())}else a===`dynamicSets`&&window.resetDynamicSets?window.resetDynamicSets():a===`dialPad`&&window.resetDialPad?window.resetDialPad():a===`inlineScoring`&&window.resetInlineScoring&&window.resetInlineScoring()}},{id:`submitScoreV2`,label:i.submit||`Submit Score`,intent:`is-primary`,disabled:a!==`inlineScoring`,onClick:()=>{s&&(a===`inlineScoring`||s.isValid||c&&o)&&(u(),n(s))},close:!0}],onClose:r?()=>r():void 0}),h()}var Yl=[`input:not([inert]):not([inert] *)`,`select:not([inert]):not([inert] *)`,`textarea:not([inert]):not([inert] *)`,`a[href]:not([inert]):not([inert] *)`,`button:not([inert]):not([inert] *)`,`[tabindex]:not(slot):not([inert]):not([inert] *)`,`audio[controls]:not([inert]):not([inert] *)`,`video[controls]:not([inert]):not([inert] *)`,`[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)`,`details>summary:first-of-type:not([inert]):not([inert] *)`,`details:not([inert]):not([inert] *)`],Xl=Yl.join(`,`),Zl=typeof Element>`u`,Ql=Zl?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,$l=!Zl&&Element.prototype.getRootNode?function(e){return e?.getRootNode?.call(e)}:function(e){return e?.ownerDocument},eu=function(e,t){t===void 0&&(t=!0);var n=e?.getAttribute?.call(e,`inert`);return n===``||n===`true`||t&&e&&(typeof e.closest==`function`?e.closest(`[inert]`):eu(e.parentNode))},tu=function(e){var t=e?.getAttribute?.call(e,`contenteditable`);return t===``||t===`true`},nu=function(e,t,n){if(eu(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(Xl));return t&&Ql.call(e,Xl)&&r.unshift(e),r=r.filter(n),r},ru=function(e,t,n){for(var r=[],i=Array.from(e);i.length;){var a=i.shift();if(!eu(a,!1))if(a.tagName===`SLOT`){var o=a.assignedElements(),s=ru(o.length?o:a.children,!0,n);n.flatten?r.push.apply(r,s):r.push({scopeParent:a,candidates:s})}else{Ql.call(a,Xl)&&n.filter(a)&&(t||!e.includes(a))&&r.push(a);var c=a.shadowRoot||typeof n.getShadowRoot==`function`&&n.getShadowRoot(a),l=!eu(c,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(a));if(c&&l){var u=ru(c===!0?a.children:c.children,!0,n);n.flatten?r.push.apply(r,u):r.push({scopeParent:a,candidates:u})}else i.unshift.apply(i,a.children)}}return r},iu=function(e){return!isNaN(parseInt(e.getAttribute(`tabindex`),10))},au=function(e){if(!e)throw Error(`No node provided`);return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||tu(e))&&!iu(e)?0:e.tabIndex},ou=function(e,t){var n=au(e);return n<0&&t&&!iu(e)?0:n},su=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},cu=function(e){return e.tagName===`INPUT`},lu=function(e){return cu(e)&&e.type===`hidden`},uu=function(e){return e.tagName===`DETAILS`&&Array.prototype.slice.apply(e.children).some(function(e){return e.tagName===`SUMMARY`})},du=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]},fu=function(e){if(!e.name)return!0;var t=e.form||$l(e),n=function(e){return t.querySelectorAll(`input[type="radio"][name="`+e+`"]`)},r;if(typeof window<`u`&&window.CSS!==void 0&&typeof window.CSS.escape==`function`)r=n(window.CSS.escape(e.name));else try{r=n(e.name)}catch(e){return console.error(`Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s`,e.message),!1}var i=du(r,e.form);return!i||i===e},pu=function(e){return cu(e)&&e.type===`radio`},mu=function(e){return pu(e)&&!fu(e)},hu=function(e){var t=e&&$l(e),n=t?.host,r=!1;if(t&&t!==e){var i,a,o;for(r=!!((i=n)!=null&&(a=i.ownerDocument)!=null&&a.contains(n)||e!=null&&(o=e.ownerDocument)!=null&&o.contains(e));!r&&n;){var s,c;t=$l(n),n=t?.host,r=!!((s=n)!=null&&(c=s.ownerDocument)!=null&&c.contains(n))}}return r},gu=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return n===0&&r===0},_u=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if(n===`full-native`&&`checkVisibility`in e)return!e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});if(getComputedStyle(e).visibility===`hidden`)return!0;var i=Ql.call(e,`details>summary:first-of-type`)?e.parentElement:e;if(Ql.call(i,`details:not([open]) *`))return!0;if(!n||n===`full`||n===`full-native`||n===`legacy-full`){if(typeof r==`function`){for(var a=e;e;){var o=e.parentElement,s=$l(e);if(o&&!o.shadowRoot&&r(o)===!0)return gu(e);e=e.assignedSlot?e.assignedSlot:!o&&s!==e.ownerDocument?s.host:o}e=a}if(hu(e))return!e.getClientRects().length;if(n!==`legacy-full`)return!0}else if(n===`non-zero-area`)return gu(e);return!1},vu=function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if(t.tagName===`FIELDSET`&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if(r.tagName===`LEGEND`)return Ql.call(t,`fieldset[disabled] *`)?!0:!r.contains(e)}return!0}t=t.parentElement}return!1},yu=function(e,t){return!(t.disabled||lu(t)||_u(t,e)||uu(t)||vu(t))},bu=function(e,t){return!(mu(t)||au(t)<0||!yu(e,t))},xu=function(e){var t=parseInt(e.getAttribute(`tabindex`),10);return!!(isNaN(t)||t>=0)},Su=function(e){var t=[],n=[];return e.forEach(function(e,r){var i=!!e.scopeParent,a=i?e.scopeParent:e,o=ou(a,i),s=i?Su(e.candidates):a;o===0?i?t.push.apply(t,s):t.push(a):n.push({documentOrder:r,tabIndex:o,item:e,isScope:i,content:s})}),n.sort(su).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(t)},Cu=function(e,t){return t||={},Su(t.getShadowRoot?ru([e],t.includeContainer,{filter:bu.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:xu}):nu(e,t.includeContainer,bu.bind(null,t)))},wu=function(e,t){return t||={},t.getShadowRoot?ru([e],t.includeContainer,{filter:yu.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):nu(e,t.includeContainer,yu.bind(null,t))},Tu=function(e,t){if(t||={},!e)throw Error(`No node provided`);return Ql.call(e,Xl)===!1?!1:bu(t,e)},Eu=Yl.concat(`iframe:not([inert]):not([inert] *)`).join(`,`),Du=function(e,t){if(t||={},!e)throw Error(`No node provided`);return Ql.call(e,Eu)===!1?!1:yu(t,e)};function Ou(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ku(e){if(Array.isArray(e))return Ou(e)}function Au(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=zu(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
176
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function ju(e,t,n){return(t=Ru(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mu(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function Nu(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
177
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Fu(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pu(Object(n),!0).forEach(function(t){ju(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Iu(e){return ku(e)||Mu(e)||zu(e)||Nu()}function Lu(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ru(e){var t=Lu(e,`string`);return typeof t==`symbol`?t:t+``}function zu(e,t){if(e){if(typeof e==`string`)return Ou(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ou(e,t):void 0}}var Bu={getActiveTrap:function(e){return e?.length>0?e[e.length-1]:null},activateTrap:function(e,t){t!==Bu.getActiveTrap(e)&&Bu.pauseTrap(e);var n=e.indexOf(t);n===-1||e.splice(n,1),e.push(t)},deactivateTrap:function(e,t){var n=e.indexOf(t);n!==-1&&e.splice(n,1),Bu.unpauseTrap(e)},pauseTrap:function(e){Bu.getActiveTrap(e)?._setPausedState(!0)},unpauseTrap:function(e){var t=Bu.getActiveTrap(e);t&&!t._isManuallyPaused()&&t._setPausedState(!1)}},Vu=function(e){return e.tagName&&e.tagName.toLowerCase()===`input`&&typeof e.select==`function`},Hu=function(e){return e?.key===`Escape`||e?.key===`Esc`||e?.keyCode===27},Uu=function(e){return e?.key===`Tab`||e?.keyCode===9},Wu=function(e){return Uu(e)&&!e.shiftKey},Gu=function(e){return Uu(e)&&e.shiftKey},Ku=function(e){return setTimeout(e,0)},qu=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return typeof e==`function`?e.apply(void 0,n):e},Ju=function(e){return e.target.shadowRoot&&typeof e.composedPath==`function`?e.composedPath()[0]:e.target},Yu=[],Xu=function(e,t){var n=t?.document||document,r=t?.trapStack||Yu,i=Fu({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,delayReturnFocus:!0,isolateSubtrees:!1,isKeyForward:Wu,isKeyBackward:Gu},t),a={containers:[],containerGroups:[],tabbableGroups:[],adjacentElements:new Set,alreadySilent:new Set,nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,manuallyPaused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},o,s=function(e,t,n){return e&&e[t]!==void 0?e[t]:i[n||t]},c=function(e,t){var n=typeof t?.composedPath==`function`?t.composedPath():void 0;return a.containerGroups.findIndex(function(t){var r=t.container,i=t.tabbableNodes;return r.contains(e)||n?.includes(r)||i.find(function(t){return t===e})})},l=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.hasFallback,a=r===void 0?!1:r,o=t.params,s=o===void 0?[]:o,c=i[e];if(typeof c==`function`&&(c=c.apply(void 0,Iu(s))),c===!0&&(c=void 0),!c){if(c===void 0||c===!1)return c;throw Error(`\`${e}\` was specified but was not a node, or did not return a node`)}var l=c;if(typeof c==`string`){try{l=n.querySelector(c)}catch(t){throw Error(`\`${e}\` appears to be an invalid selector; error="${t.message}"`)}if(!l&&!a)throw Error(`\`${e}\` as selector refers to no known node`)}return l},u=function(e){var t=e.activeElement;return t?t.shadowRoot&&t.shadowRoot.activeElement!==null?u(t.shadowRoot):t:null},d=function(){var e=l(`initialFocus`,{hasFallback:!0});if(e===!1)return!1;if(e===void 0||e&&!Du(e,i.tabbableOptions)){var t=u(n);if(c(t)>=0)e=t;else{var r=a.tabbableGroups[0];e=r&&r.firstTabbableNode||l(`fallbackFocus`)}}else e===null&&(e=l(`fallbackFocus`));if(!e)throw Error(`Your focus-trap needs to have at least one focusable element`);return e},f=function(){if(a.containerGroups=a.containers.map(function(e){var t=Cu(e,i.tabbableOptions),n=wu(e,i.tabbableOptions),r=t.length>0?t[0]:void 0,a=t.length>0?t[t.length-1]:void 0,o=n.find(function(e){return Tu(e)}),s=n.slice().reverse().find(function(e){return Tu(e)});return{container:e,tabbableNodes:t,focusableNodes:n,posTabIndexesFound:!!t.find(function(e){return au(e)>0}),firstTabbableNode:r,lastTabbableNode:a,firstDomTabbableNode:o,lastDomTabbableNode:s,nextTabbableNode:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,i=t.indexOf(e);return i<0?r?n.slice(n.indexOf(e)+1).find(function(e){return Tu(e)}):n.slice(0,n.indexOf(e)).reverse().find(function(e){return Tu(e)}):t[i+(r?1:-1)]}}}),a.tabbableGroups=a.containerGroups.filter(function(e){return e.tabbableNodes.length>0}),a.tabbableGroups.length<=0&&!l(`fallbackFocus`))throw Error(`Your focus-trap must have at least one container with at least one tabbable node in it at all times`);if(a.containerGroups.find(function(e){return e.posTabIndexesFound})&&a.containerGroups.length>1)throw Error(`At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.`)},p=function(e){if(e!==!1&&e!==u(document)){if(!e||!e.focus){p(d());return}e.focus({preventScroll:!!i.preventScroll}),a.mostRecentlyFocusedNode=e,Vu(e)&&e.select()}},m=function(e){var t=l(`setReturnFocus`,{params:[e]});return t||(t===!1?!1:e)},h=function(e){var t=e.target,n=e.event,r=e.isBackward,o=r===void 0?!1:r;t||=Ju(n),f();var s=null;if(a.tabbableGroups.length>0){var u=c(t,n),d=u>=0?a.containerGroups[u]:void 0;if(u<0)s=o?a.tabbableGroups[a.tabbableGroups.length-1].lastTabbableNode:a.tabbableGroups[0].firstTabbableNode;else if(o){var p=a.tabbableGroups.findIndex(function(e){var n=e.firstTabbableNode;return t===n});if(p<0&&(d.container===t||Du(t,i.tabbableOptions)&&!Tu(t,i.tabbableOptions)&&!d.nextTabbableNode(t,!1))&&(p=u),p>=0){var m=p===0?a.tabbableGroups.length-1:p-1,h=a.tabbableGroups[m];s=au(t)>=0?h.lastTabbableNode:h.lastDomTabbableNode}else Uu(n)||(s=d.nextTabbableNode(t,!1))}else{var g=a.tabbableGroups.findIndex(function(e){var n=e.lastTabbableNode;return t===n});if(g<0&&(d.container===t||Du(t,i.tabbableOptions)&&!Tu(t,i.tabbableOptions)&&!d.nextTabbableNode(t))&&(g=u),g>=0){var _=g===a.tabbableGroups.length-1?0:g+1,v=a.tabbableGroups[_];s=au(t)>=0?v.firstTabbableNode:v.firstDomTabbableNode}else Uu(n)||(s=d.nextTabbableNode(t))}}else s=l(`fallbackFocus`);return s},g=function(e){if(!(c(Ju(e),e)>=0)){if(qu(i.clickOutsideDeactivates,e)){o.deactivate({returnFocus:i.returnFocusOnDeactivate});return}qu(i.allowOutsideClick,e)||e.preventDefault()}},_=function(e){var t=Ju(e),n=c(t,e)>=0;if(n||t instanceof Document)n&&(a.mostRecentlyFocusedNode=t);else{e.stopImmediatePropagation();var r,o=!0;if(a.mostRecentlyFocusedNode)if(au(a.mostRecentlyFocusedNode)>0){var s=c(a.mostRecentlyFocusedNode),l=a.containerGroups[s].tabbableNodes;if(l.length>0){var u=l.findIndex(function(e){return e===a.mostRecentlyFocusedNode});u>=0&&(i.isKeyForward(a.recentNavEvent)?u+1<l.length&&(r=l[u+1],o=!1):u-1>=0&&(r=l[u-1],o=!1))}}else a.containerGroups.some(function(e){return e.tabbableNodes.some(function(e){return au(e)>0})})||(o=!1);else o=!1;o&&(r=h({target:a.mostRecentlyFocusedNode,isBackward:i.isKeyBackward(a.recentNavEvent)})),p(r||a.mostRecentlyFocusedNode||d())}a.recentNavEvent=void 0},v=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;a.recentNavEvent=e;var n=h({event:e,isBackward:t});n&&(Uu(e)&&e.preventDefault(),p(n))},y=function(e){(i.isKeyForward(e)||i.isKeyBackward(e))&&v(e,i.isKeyBackward(e))},b=function(e){Hu(e)&&qu(i.escapeDeactivates,e)!==!1&&(e.preventDefault(),o.deactivate())},x=function(e){c(Ju(e),e)>=0||qu(i.clickOutsideDeactivates,e)||qu(i.allowOutsideClick,e)||(e.preventDefault(),e.stopImmediatePropagation())},S=function(){if(a.active){Bu.activateTrap(r,o);var e;return i.delayInitialFocus?e=new Promise(function(e){a.delayInitialFocusTimer=Ku(function(){p(d()),e()})}):p(d()),n.addEventListener(`focusin`,_,!0),n.addEventListener(`mousedown`,g,{capture:!0,passive:!1}),n.addEventListener(`touchstart`,g,{capture:!0,passive:!1}),n.addEventListener(`click`,x,{capture:!0,passive:!1}),n.addEventListener(`keydown`,y,{capture:!0,passive:!1}),n.addEventListener(`keydown`,b),e}},C=function(e){a.active&&!a.paused&&o._setSubtreeIsolation(!1),a.adjacentElements.clear(),a.alreadySilent.clear();var t=new Set,n=new Set,r=Au(e),i;try{for(r.s();!(i=r.n()).done;){var s=i.value;t.add(s);for(var c=typeof ShadowRoot<`u`&&s.getRootNode()instanceof ShadowRoot,l=s;l;){t.add(l);var u=l.parentElement,d=[];u?d=u.children:!u&&c&&(d=l.getRootNode().children,u=l.getRootNode().host,c=typeof ShadowRoot<`u`&&u.getRootNode()instanceof ShadowRoot);var f=Au(d),p;try{for(f.s();!(p=f.n()).done;){var m=p.value;n.add(m)}}catch(e){f.e(e)}finally{f.f()}l=u}}}catch(e){r.e(e)}finally{r.f()}t.forEach(function(e){n.delete(e)}),a.adjacentElements=n},w=function(){if(a.active)return n.removeEventListener(`focusin`,_,!0),n.removeEventListener(`mousedown`,g,!0),n.removeEventListener(`touchstart`,g,!0),n.removeEventListener(`click`,x,!0),n.removeEventListener(`keydown`,y,!0),n.removeEventListener(`keydown`,b),o},T=typeof window<`u`&&`MutationObserver`in window?new MutationObserver(function(e){var t=a.mostRecentlyFocusedNode;t&&e.some(function(e){return Array.from(e.removedNodes).some(function(e){return e===t||typeof e.contains==`function`&&e.contains(t)})})&&a.containers.some(function(e){return e?.isConnected})&&(f(),p(d()))}):void 0,E=function(){T&&(T.disconnect(),a.active&&!a.paused&&a.containers.map(function(e){T.observe(e,{subtree:!0,childList:!0})}))};return o={get active(){return a.active},get paused(){return a.paused},activate:function(e){if(a.active)return this;var t=s(e,`onActivate`),i=s(e,`onPostActivate`),c=s(e,`checkCanFocusTrap`),l=Bu.getActiveTrap(r),d=!1;if(l&&!l.paused){var p;(p=l._setSubtreeIsolation)==null||p.call(l,!1),d=!0}try{c||f(),a.active=!0,a.paused=!1,a.nodeFocusedBeforeActivation=u(n),t?.({trap:o});var m=function(){c&&f();var e=function(){o._setSubtreeIsolation(!0),E(),i?.({trap:o})},t=S();t?t.then(e):e()};if(c)return c(a.containers.concat()).then(m,m),this;m()}catch(e){if(l===Bu.getActiveTrap(r)&&d){var h;(h=l._setSubtreeIsolation)==null||h.call(l,!0)}throw e}return this},deactivate:function(e){if(!a.active)return this;var t=Fu({onDeactivate:i.onDeactivate,onPostDeactivate:i.onPostDeactivate,checkCanReturnFocus:i.checkCanReturnFocus},e);clearTimeout(a.delayInitialFocusTimer),a.delayInitialFocusTimer=void 0,a.paused||o._setSubtreeIsolation(!1),a.alreadySilent.clear(),w(),a.active=!1,a.paused=!1,E(),Bu.deactivateTrap(r,o);var n=s(t,`onDeactivate`),c=s(t,`onPostDeactivate`),l=s(t,`checkCanReturnFocus`),u=s(t,`delayReturnFocus`),d=s(t,`returnFocus`,`returnFocusOnDeactivate`);n?.({trap:o});var f=function(){d&&p(m(a.nodeFocusedBeforeActivation)),c?.({trap:o})},h=function(){u&&d?Ku(f):f()};return d&&l?(l(m(a.nodeFocusedBeforeActivation)).then(h,h),this):(h(),this)},pause:function(e){return a.active?(a.manuallyPaused=!0,this._setPausedState(!0,e)):this},unpause:function(e){return!a.active||(a.manuallyPaused=!1,r[r.length-1]!==this)?this:this._setPausedState(!1,e)},updateContainerElements:function(e){return a.containers=[].concat(e).filter(Boolean).map(function(e){return typeof e==`string`?n.querySelector(e):e}),i.isolateSubtrees&&C(a.containers),a.active&&(f(),a.paused||o._setSubtreeIsolation(!0)),E(),this}},Object.defineProperties(o,{_isManuallyPaused:{value:function(){return a.manuallyPaused}},_setPausedState:{value:function(e,t){if(a.paused===e)return this;if(a.paused=e,e){var n=s(t,`onPause`),r=s(t,`onPostPause`);n?.({trap:o}),w(),o._setSubtreeIsolation(!1),E(),r?.({trap:o})}else{var i=s(t,`onUnpause`),c=s(t,`onPostUnpause`);i?.({trap:o}),(function(){f();var e=function(){o._setSubtreeIsolation(!0),E(),c?.({trap:o})},t=S();t?t.then(e):e()})()}return this}},_setSubtreeIsolation:{value:function(e){i.isolateSubtrees&&a.adjacentElements.forEach(function(t){if(e)switch(i.isolateSubtrees){case`aria-hidden`:(t.ariaHidden===`true`||t.getAttribute(`aria-hidden`)?.toLowerCase()===`true`)&&a.alreadySilent.add(t),t.setAttribute(`aria-hidden`,`true`);break;default:(t.inert||t.hasAttribute(`inert`))&&a.alreadySilent.add(t),t.setAttribute(`inert`,!0);break}else if(!a.alreadySilent.has(t))switch(i.isolateSubtrees){case`aria-hidden`:t.removeAttribute(`aria-hidden`);break;default:t.removeAttribute(`inert`);break}})}}}),o.updateContainerElements(e),o},Zu=`left`,Qu=`right`,$u=`courthive-drawer`,ed=e=>typeof e==`function`,td=e=>{for(;e.firstChild;)e.firstChild.remove()};function nd(e,t){let n=t.parentNode;for(;n;){if(n===e)return!0;n=n.parentNode}return!1}var rd=null,id=!1,ad=(e=$u)=>{if(rd)return rd;let t={selectorTrigger:`[data-drawer-trigger]`,selectorTarget:`[data-drawer-target]`,selectorClose:`[data-drawer-close]`,leftAlignment:`drawer--left`,visibleClass:`is-visible`,activeClass:`is-active`,speedClose:350,speedOpen:50},n={},r=!1,i,a,o,s=!1,c=e=>a=e,l=()=>{ed(a)&&(a?.(),a=void 0);let n=document.getElementById(e);n&&(n.classList.remove(t.visibleClass),document.documentElement.style.overflow=``,setTimeout(function(){i?(n.classList.add(t.visibleClass),document.documentElement.style.overflow=`hidden`,ed(i?.callback)&&i.callback()):(n.classList.remove(t.activeClass),r=!1),i=!1,o?.deactivate()},t.speedClose))},u=n=>{if(!e)return;let r=document.getElementById(e);r&&(r.classList.contains(t.leftAlignment)||r.classList.add(t.leftAlignment),g(r,!1,n))},d=n=>{let r=document.getElementById(e);r&&(r.classList.remove(t.leftAlignment),g(r,!1,n))},f=t=>{let n=document.getElementById(e)?.querySelector(`.drawer__title`);n&&(n.innerHTML=t)},p=t=>{let r=document.getElementById(e)?.querySelector(`.drawer__footer`);r&&(td(r),ed(t)?n.footer=t(r,l):r.innerHTML=t||``)},m=t=>{let r=document.getElementById(e)?.querySelector(`.drawer__content`);r&&(td(r),ed(t)?n.content=t(r,l):r.innerHTML=t)},h=t=>{let n=document.getElementById(e)?.querySelector(`.drawer__wrapper`);n&&(n.style.width=t)},g=(e,n,i)=>{r=!0,s=!0,e.classList.add(t.activeClass),document.documentElement.style.overflow=`hidden`,n&&(o=Xu(e),o.activate()),ed(i)&&i&&i(),setTimeout(function(){e.classList.add(t.visibleClass),setTimeout(()=>{s=!1},100)},t.speedOpen)};return id||=(document.addEventListener(`click`,function(t){if(!e||!r||s)return;let n=t.target,i=document.querySelector(`.drawer__wrapper`);if(!i)return;let a=n.classList.contains(`drawer__close`)||n.closest(`.drawer__close`)||`drawerClose`in n.dataset||n.closest(`[data-drawer-close]`);(!nd(i,n)||a)&&l()},!1),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&r&&l()},!1),!0),rd={settings:t,open:(t={})=>{let{title:n,content:a,side:o,width:s,footer:l,callback:_,onClose:v}=t;if(a&&m(a),v&&c(v),n&&f(n),s&&h(s),p(l),r)i={callback:_};else if(o){if(o===Qu)return d(_);if(o===Zu)return u(_)}else{let t=document.getElementById(e);t&&g(t,l,_)}},close:l,setTitle:f,setContent:m,setFooter:p,attributes:n},rd};function od(e=$u){if(document.getElementById(e))return;let t=`
|
|
178
178
|
<div id="${e}" class="drawer" aria-hidden="true">
|
|
179
179
|
<div class="drawer__overlay" tabindex="-1" data-drawer-close></div>
|
|
180
180
|
<div class="drawer__wrapper" role="dialog" aria-modal="true">
|
|
@@ -191,43 +191,43 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
191
191
|
<div class="drawer__footer"></div>
|
|
192
192
|
</div>
|
|
193
193
|
</div>
|
|
194
|
-
`;document.body.insertAdjacentHTML(`beforeend`,t)}var rd=`bottom`,id=`right`,ad=`left`,od=`auto`,sd=[`top`,rd,id,ad],cd=`start`,ld=`clippingParents`,ud=`viewport`,dd=`popper`,fd=`reference`,pd=sd.reduce(function(e,t){return e.concat([t+`-`+cd,t+`-end`])},[]),md=[].concat(sd,[od]).reduce(function(e,t){return e.concat([t,t+`-`+cd,t+`-end`])},[]),hd=[`beforeRead`,`read`,`afterRead`,`beforeMain`,`main`,`afterMain`,`beforeWrite`,`write`,`afterWrite`];function gd(e){return e?(e.nodeName||``).toLowerCase():null}function _d(e){if(e==null)return window;if(e.toString()!==`[object Window]`){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function vd(e){return e instanceof _d(e).Element||e instanceof Element}function yd(e){return e instanceof _d(e).HTMLElement||e instanceof HTMLElement}function bd(e){return typeof ShadowRoot>`u`?!1:e instanceof _d(e).ShadowRoot||e instanceof ShadowRoot}function xd(e){var t=e.state;Object.keys(t.elements).forEach(function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];!yd(i)||!gd(i)||(Object.assign(i.style,n),Object.keys(r).forEach(function(e){var t=r[e];t===!1?i.removeAttribute(e):i.setAttribute(e,t===!0?``:t)}))})}function Sd(e){var t=e.state,n={popper:{position:t.options.strategy,left:`0`,top:`0`,margin:`0`},arrow:{position:`absolute`},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(e){var r=t.elements[e],i=t.attributes[e]||{},a=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce(function(e,t){return e[t]=``,e},{});!yd(r)||!gd(r)||(Object.assign(r.style,a),Object.keys(i).forEach(function(e){r.removeAttribute(e)}))})}}var Cd={name:`applyStyles`,enabled:!0,phase:`write`,fn:xd,effect:Sd,requires:[`computeStyles`]};function wd(e){return e.split(`-`)[0]}var Td=Math.max,Ed=Math.min,Dd=Math.round;function Od(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(e){return e.brand+`/`+e.version}).join(` `):navigator.userAgent}function kd(){return!/^((?!chrome|android).)*safari/i.test(Od())}function Ad(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),i=1,a=1;t&&yd(e)&&(i=e.offsetWidth>0&&Dd(r.width)/e.offsetWidth||1,a=e.offsetHeight>0&&Dd(r.height)/e.offsetHeight||1);var o=(vd(e)?_d(e):window).visualViewport,s=!kd()&&n,c=(r.left+(s&&o?o.offsetLeft:0))/i,l=(r.top+(s&&o?o.offsetTop:0))/a,u=r.width/i,d=r.height/a;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c,x:c,y:l}}function jd(e){var t=Ad(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Md(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&bd(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Nd(e){return _d(e).getComputedStyle(e)}function Pd(e){return[`table`,`td`,`th`].indexOf(gd(e))>=0}function Fd(e){return((vd(e)?e.ownerDocument:e.document)||window.document).documentElement}function Id(e){return gd(e)===`html`?e:e.assignedSlot||e.parentNode||(bd(e)?e.host:null)||Fd(e)}function Ld(e){return!yd(e)||Nd(e).position===`fixed`?null:e.offsetParent}function Rd(e){var t=/firefox/i.test(Od());if(/Trident/i.test(Od())&&yd(e)&&Nd(e).position===`fixed`)return null;var n=Id(e);for(bd(n)&&(n=n.host);yd(n)&&[`html`,`body`].indexOf(gd(n))<0;){var r=Nd(n);if(r.transform!==`none`||r.perspective!==`none`||r.contain===`paint`||[`transform`,`perspective`].indexOf(r.willChange)!==-1||t&&r.willChange===`filter`||t&&r.filter&&r.filter!==`none`)return n;n=n.parentNode}return null}function zd(e){for(var t=_d(e),n=Ld(e);n&&Pd(n)&&Nd(n).position===`static`;)n=Ld(n);return n&&(gd(n)===`html`||gd(n)===`body`&&Nd(n).position===`static`)?t:n||Rd(e)||t}function Bd(e){return[`top`,`bottom`].indexOf(e)>=0?`x`:`y`}function Vd(e,t,n){return Td(e,Ed(t,n))}function Hd(e,t,n){var r=Vd(e,t,n);return r>n?n:r}function Ud(){return{top:0,right:0,bottom:0,left:0}}function Wd(e){return Object.assign({},Ud(),e)}function Gd(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}var Kd=function(e,t){return e=typeof e==`function`?e(Object.assign({},t.rects,{placement:t.placement})):e,Wd(typeof e==`number`?Gd(e,sd):e)};function qd(e){var t,n=e.state,r=e.name,i=e.options,a=n.elements.arrow,o=n.modifiersData.popperOffsets,s=wd(n.placement),c=Bd(s),l=[`left`,`right`].indexOf(s)>=0?`height`:`width`;if(!(!a||!o)){var u=Kd(i.padding,n),d=jd(a),f=c===`y`?`top`:ad,p=c===`y`?rd:id,m=n.rects.reference[l]+n.rects.reference[c]-o[c]-n.rects.popper[l],h=o[c]-n.rects.reference[c],g=zd(a),_=g?c===`y`?g.clientHeight||0:g.clientWidth||0:0,v=m/2-h/2,y=u[f],b=_-d[l]-u[p],x=_/2-d[l]/2+v,S=Vd(y,x,b),C=c;n.modifiersData[r]=(t={},t[C]=S,t.centerOffset=S-x,t)}}function Jd(e){var t=e.state,n=e.options.element,r=n===void 0?`[data-popper-arrow]`:n;r!=null&&(typeof r==`string`&&(r=t.elements.popper.querySelector(r),!r)||Md(t.elements.popper,r)&&(t.elements.arrow=r))}var Yd={name:`arrow`,enabled:!0,phase:`main`,fn:qd,effect:Jd,requires:[`popperOffsets`],requiresIfExists:[`preventOverflow`]};function Xd(e){return e.split(`-`)[1]}var Zd={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};function Qd(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:Dd(n*i)/i||0,y:Dd(r*i)/i||0}}function $d(e){var t,n=e.popper,r=e.popperRect,i=e.placement,a=e.variation,o=e.offsets,s=e.position,c=e.gpuAcceleration,l=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=o.x,p=f===void 0?0:f,m=o.y,h=m===void 0?0:m,g=typeof u==`function`?u({x:p,y:h}):{x:p,y:h};p=g.x,h=g.y;var _=o.hasOwnProperty(`x`),v=o.hasOwnProperty(`y`),y=ad,b=`top`,x=window;if(l){var S=zd(n),C=`clientHeight`,w=`clientWidth`;if(S===_d(n)&&(S=Fd(n),Nd(S).position!==`static`&&s===`absolute`&&(C=`scrollHeight`,w=`scrollWidth`)),S=S,i===`top`||(i===`left`||i===`right`)&&a===`end`){b=rd;var T=d&&S===x&&x.visualViewport?x.visualViewport.height:S[C];h-=T-r.height,h*=c?1:-1}if(i===`left`||(i===`top`||i===`bottom`)&&a===`end`){y=id;var E=d&&S===x&&x.visualViewport?x.visualViewport.width:S[w];p-=E-r.width,p*=c?1:-1}}var D=Object.assign({position:s},l&&Zd),O=u===!0?Qd({x:p,y:h},_d(n)):{x:p,y:h};if(p=O.x,h=O.y,c){var k;return Object.assign({},D,(k={},k[b]=v?`0`:``,k[y]=_?`0`:``,k.transform=(x.devicePixelRatio||1)<=1?`translate(`+p+`px, `+h+`px)`:`translate3d(`+p+`px, `+h+`px, 0)`,k))}return Object.assign({},D,(t={},t[b]=v?h+`px`:``,t[y]=_?p+`px`:``,t.transform=``,t))}function ef(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=r===void 0?!0:r,a=n.adaptive,o=a===void 0?!0:a,s=n.roundOffsets,c=s===void 0?!0:s,l={placement:wd(t.placement),variation:Xd(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:t.options.strategy===`fixed`};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,$d(Object.assign({},l,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,$d(Object.assign({},l,{offsets:t.modifiersData.arrow,position:`absolute`,adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}var tf={name:`computeStyles`,enabled:!0,phase:`beforeWrite`,fn:ef,data:{}},nf={passive:!0};function rf(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,a=i===void 0?!0:i,o=r.resize,s=o===void 0?!0:o,c=_d(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&l.forEach(function(e){e.addEventListener(`scroll`,n.update,nf)}),s&&c.addEventListener(`resize`,n.update,nf),function(){a&&l.forEach(function(e){e.removeEventListener(`scroll`,n.update,nf)}),s&&c.removeEventListener(`resize`,n.update,nf)}}var af={name:`eventListeners`,enabled:!0,phase:`write`,fn:function(){},effect:rf,data:{}},of={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function sf(e){return e.replace(/left|right|bottom|top/g,function(e){return of[e]})}var cf={start:`end`,end:`start`};function lf(e){return e.replace(/start|end/g,function(e){return cf[e]})}function uf(e){var t=_d(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function df(e){return Ad(Fd(e)).left+uf(e).scrollLeft}function ff(e,t){var n=_d(e),r=Fd(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;var l=kd();(l||!l&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s+df(e),y:c}}function pf(e){var t=Fd(e),n=uf(e),r=e.ownerDocument?.body,i=Td(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=Td(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),o=-n.scrollLeft+df(e),s=-n.scrollTop;return Nd(r||t).direction===`rtl`&&(o+=Td(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:o,y:s}}function mf(e){var t=Nd(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function hf(e){return[`html`,`body`,`#document`].indexOf(gd(e))>=0?e.ownerDocument.body:yd(e)&&mf(e)?e:hf(Id(e))}function gf(e,t){t===void 0&&(t=[]);var n=hf(e),r=n===e.ownerDocument?.body,i=_d(n),a=r?[i].concat(i.visualViewport||[],mf(n)?n:[]):n,o=t.concat(a);return r?o:o.concat(gf(Id(a)))}function _f(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function vf(e,t){var n=Ad(e,!1,t===`fixed`);return n.top+=e.clientTop,n.left+=e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function yf(e,t,n){return t===`viewport`?_f(ff(e,n)):vd(t)?vf(t,n):_f(pf(Fd(e)))}function bf(e){var t=gf(Id(e)),n=[`absolute`,`fixed`].indexOf(Nd(e).position)>=0&&yd(e)?zd(e):e;return vd(n)?t.filter(function(e){return vd(e)&&Md(e,n)&&gd(e)!==`body`}):[]}function xf(e,t,n,r){var i=t===`clippingParents`?bf(e):[].concat(t),a=[].concat(i,[n]),o=a[0],s=a.reduce(function(t,n){var i=yf(e,n,r);return t.top=Td(i.top,t.top),t.right=Ed(i.right,t.right),t.bottom=Ed(i.bottom,t.bottom),t.left=Td(i.left,t.left),t},yf(e,o,r));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function Sf(e){var t=e.reference,n=e.element,r=e.placement,i=r?wd(r):null,a=r?Xd(r):null,o=t.x+t.width/2-n.width/2,s=t.y+t.height/2-n.height/2,c;switch(i){case`top`:c={x:o,y:t.y-n.height};break;case rd:c={x:o,y:t.y+t.height};break;case id:c={x:t.x+t.width,y:s};break;case ad:c={x:t.x-n.width,y:s};break;default:c={x:t.x,y:t.y}}var l=i?Bd(i):null;if(l!=null){var u=l===`y`?`height`:`width`;switch(a){case cd:c[l]=c[l]-(t[u]/2-n[u]/2);break;case`end`:c[l]=c[l]+(t[u]/2-n[u]/2);break;default:}}return c}function Cf(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=r===void 0?e.placement:r,a=n.strategy,o=a===void 0?e.strategy:a,s=n.boundary,c=s===void 0?ld:s,l=n.rootBoundary,u=l===void 0?ud:l,d=n.elementContext,f=d===void 0?dd:d,p=n.altBoundary,m=p===void 0?!1:p,h=n.padding,g=h===void 0?0:h,_=Wd(typeof g==`number`?Gd(g,sd):g),v=f===`popper`?fd:dd,y=e.rects.popper,b=e.elements[m?v:f],x=xf(vd(b)?b:b.contextElement||Fd(e.elements.popper),c,u,o),S=Ad(e.elements.reference),C=Sf({reference:S,element:y,strategy:`absolute`,placement:i}),w=_f(Object.assign({},y,C)),T=f===`popper`?w:S,E={top:x.top-T.top+_.top,bottom:T.bottom-x.bottom+_.bottom,left:x.left-T.left+_.left,right:T.right-x.right+_.right},D=e.modifiersData.offset;if(f===`popper`&&D){var O=D[i];Object.keys(E).forEach(function(e){var t=[`right`,`bottom`].indexOf(e)>=0?1:-1,n=[`top`,`bottom`].indexOf(e)>=0?`y`:`x`;E[e]+=O[n]*t})}return E}function wf(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=n.boundary,a=n.rootBoundary,o=n.padding,s=n.flipVariations,c=n.allowedAutoPlacements,l=c===void 0?md:c,u=Xd(r),d=u?s?pd:pd.filter(function(e){return Xd(e)===u}):sd,f=d.filter(function(e){return l.indexOf(e)>=0});f.length===0&&(f=d);var p=f.reduce(function(t,n){return t[n]=Cf(e,{placement:n,boundary:i,rootBoundary:a,padding:o})[wd(n)],t},{});return Object.keys(p).sort(function(e,t){return p[e]-p[t]})}function Tf(e){if(wd(e)===`auto`)return[];var t=sf(e);return[lf(e),t,lf(t)]}function Ef(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,a=i===void 0?!0:i,o=n.altAxis,s=o===void 0?!0:o,c=n.fallbackPlacements,l=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0?!0:p,h=n.allowedAutoPlacements,g=t.options.placement,_=wd(g)===g,v=c||(_||!m?[sf(g)]:Tf(g)),y=[g].concat(v).reduce(function(e,n){return e.concat(wd(n)===`auto`?wf(t,{placement:n,boundary:u,rootBoundary:d,padding:l,flipVariations:m,allowedAutoPlacements:h}):n)},[]),b=t.rects.reference,x=t.rects.popper,S=new Map,C=!0,w=y[0],T=0;T<y.length;T++){var E=y[T],D=wd(E),O=Xd(E)===cd,k=[`top`,rd].indexOf(D)>=0,A=k?`width`:`height`,j=Cf(t,{placement:E,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),M=k?O?id:ad:O?rd:`top`;b[A]>x[A]&&(M=sf(M));var N=sf(M),P=[];if(a&&P.push(j[D]<=0),s&&P.push(j[M]<=0,j[N]<=0),P.every(function(e){return e})){w=E,C=!1;break}S.set(E,P)}if(C)for(var F=m?3:1,I=function(e){var t=y.find(function(t){var n=S.get(t);if(n)return n.slice(0,e).every(function(e){return e})});if(t)return w=t,`break`},L=F;L>0&&I(L)!==`break`;L--);t.placement!==w&&(t.modifiersData[r]._skip=!0,t.placement=w,t.reset=!0)}}var Df={name:`flip`,enabled:!0,phase:`main`,fn:Ef,requiresIfExists:[`offset`],data:{_skip:!1}};function Of(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function kf(e){return[`top`,id,rd,ad].some(function(t){return e[t]>=0})}function Af(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,a=t.modifiersData.preventOverflow,o=Cf(t,{elementContext:`reference`}),s=Cf(t,{altBoundary:!0}),c=Of(o,r),l=Of(s,i,a),u=kf(c),d=kf(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}var jf={name:`hide`,enabled:!0,phase:`main`,requiresIfExists:[`preventOverflow`],fn:Af};function Mf(e,t,n){var r=wd(e),i=[`left`,`top`].indexOf(r)>=0?-1:1,a=typeof n==`function`?n(Object.assign({},t,{placement:e})):n,o=a[0],s=a[1];return o||=0,s=(s||0)*i,[`left`,`right`].indexOf(r)>=0?{x:s,y:o}:{x:o,y:s}}function Nf(e){var t=e.state,n=e.options,r=e.name,i=n.offset,a=i===void 0?[0,0]:i,o=md.reduce(function(e,n){return e[n]=Mf(n,t.rects,a),e},{}),s=o[t.placement],c=s.x,l=s.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[r]=o}var Pf={name:`offset`,enabled:!0,phase:`main`,requires:[`popperOffsets`],fn:Nf};function Ff(e){var t=e.state,n=e.name;t.modifiersData[n]=Sf({reference:t.rects.reference,element:t.rects.popper,strategy:`absolute`,placement:t.placement})}var If={name:`popperOffsets`,enabled:!0,phase:`read`,fn:Ff,data:{}};function Lf(e){return e===`x`?`y`:`x`}function Rf(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,a=i===void 0?!0:i,o=n.altAxis,s=o===void 0?!1:o,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0?!0:f,m=n.tetherOffset,h=m===void 0?0:m,g=Cf(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),_=wd(t.placement),v=Xd(t.placement),y=!v,b=Bd(_),x=Lf(b),S=t.modifiersData.popperOffsets,C=t.rects.reference,w=t.rects.popper,T=typeof h==`function`?h(Object.assign({},t.rects,{placement:t.placement})):h,E=typeof T==`number`?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),D=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(S){if(a){var k=b===`y`?`top`:ad,A=b===`y`?rd:id,j=b===`y`?`height`:`width`,M=S[b],N=M+g[k],P=M-g[A],F=p?-w[j]/2:0,I=v===`start`?C[j]:w[j],L=v===`start`?-w[j]:-C[j],R=t.elements.arrow,z=p&&R?jd(R):{width:0,height:0},B=t.modifiersData[`arrow#persistent`]?t.modifiersData[`arrow#persistent`].padding:Ud(),ee=B[k],te=B[A],ne=Vd(0,C[j],z[j]),V=y?C[j]/2-F-ne-ee-E.mainAxis:I-ne-ee-E.mainAxis,re=y?-C[j]/2+F+ne+te+E.mainAxis:L+ne+te+E.mainAxis,ie=t.elements.arrow&&zd(t.elements.arrow),ae=ie?b===`y`?ie.clientTop||0:ie.clientLeft||0:0,oe=D?.[b]??0,se=M+V-oe-ae,ce=M+re-oe,le=Vd(p?Ed(N,se):N,M,p?Td(P,ce):P);S[b]=le,O[b]=le-M}if(s){var ue=b===`x`?`top`:ad,de=b===`x`?rd:id,fe=S[x],pe=x===`y`?`height`:`width`,me=fe+g[ue],he=fe-g[de],ge=[`top`,ad].indexOf(_)!==-1,_e=D?.[x]??0,ve=ge?me:fe-C[pe]-w[pe]-_e+E.altAxis,ye=ge?fe+C[pe]+w[pe]-_e-E.altAxis:he,be=p&&ge?Hd(ve,fe,ye):Vd(p?ve:me,fe,p?ye:he);S[x]=be,O[x]=be-fe}t.modifiersData[r]=O}}var zf={name:`preventOverflow`,enabled:!0,phase:`main`,fn:Rf,requiresIfExists:[`offset`]};function Bf(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Vf(e){return e===_d(e)||!yd(e)?uf(e):Bf(e)}function Hf(e){var t=e.getBoundingClientRect(),n=Dd(t.width)/e.offsetWidth||1,r=Dd(t.height)/e.offsetHeight||1;return n!==1||r!==1}function Uf(e,t,n){n===void 0&&(n=!1);var r=yd(t),i=yd(t)&&Hf(t),a=Fd(t),o=Ad(e,i,n),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((gd(t)!==`body`||mf(a))&&(s=Vf(t)),yd(t)?(c=Ad(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=df(a))),{x:o.left+s.scrollLeft-c.x,y:o.top+s.scrollTop-c.y,width:o.width,height:o.height}}function Wf(e){var t=new Map,n=new Set,r=[];e.forEach(function(e){t.set(e.name,e)});function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}}),r.push(e)}return e.forEach(function(e){n.has(e.name)||i(e)}),r}function Gf(e){var t=Wf(e);return hd.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}function Kf(e){var t;return function(){return t||=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})}),t}}function qf(e){var t=e.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{});return Object.keys(t).map(function(e){return t[e]})}var Jf={placement:`bottom`,modifiers:[],strategy:`absolute`};function Yf(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(e){return!(e&&typeof e.getBoundingClientRect==`function`)})}function Xf(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,i=t.defaultOptions,a=i===void 0?Jf:i;return function(e,t,n){n===void 0&&(n=a);var i={placement:`bottom`,orderedModifiers:[],options:Object.assign({},Jf,a),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},o=[],s=!1,c={state:i,setOptions:function(n){var o=typeof n==`function`?n(i.options):n;u(),i.options=Object.assign({},a,i.options,o),i.scrollParents={reference:vd(e)?gf(e):e.contextElement?gf(e.contextElement):[],popper:gf(t)};var s=Gf(qf([].concat(r,i.options.modifiers)));return i.orderedModifiers=s.filter(function(e){return e.enabled}),l(),c.update()},forceUpdate:function(){if(!s){var e=i.elements,t=e.reference,n=e.popper;if(Yf(t,n)){i.rects={reference:Uf(t,zd(n),i.options.strategy===`fixed`),popper:jd(n)},i.reset=!1,i.placement=i.options.placement,i.orderedModifiers.forEach(function(e){return i.modifiersData[e.name]=Object.assign({},e.data)});for(var r=0;r<i.orderedModifiers.length;r++){if(i.reset===!0){i.reset=!1,r=-1;continue}var a=i.orderedModifiers[r],o=a.fn,l=a.options,u=l===void 0?{}:l,d=a.name;typeof o==`function`&&(i=o({state:i,options:u,name:d,instance:c})||i)}}}},update:Kf(function(){return new Promise(function(e){c.forceUpdate(),e(i)})}),destroy:function(){u(),s=!0}};if(!Yf(e,t))return c;c.setOptions(n).then(function(e){!s&&n.onFirstUpdate&&n.onFirstUpdate(e)});function l(){i.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,r=n===void 0?{}:n,a=e.effect;if(typeof a==`function`){var s=a({state:i,name:t,instance:c,options:r});o.push(s||function(){})}})}function u(){o.forEach(function(e){return e()}),o=[]}return c}}var Zf=Xf({defaultModifiers:[af,If,tf,Cd,Pf,Df,zf,Yd,jf]}),Qf=`tippy-box`,$f=`tippy-content`,ep=`tippy-backdrop`,tp=`tippy-arrow`,np=`tippy-svg-arrow`,rp={passive:!0,capture:!0},ip=function(){return document.body};function ap(e,t){return{}.hasOwnProperty.call(e,t)}function op(e,t,n){return Array.isArray(e)?e[t]??(Array.isArray(n)?n[t]:n):e}function sp(e,t){var n={}.toString.call(e);return n.indexOf(`[object`)===0&&n.indexOf(t+`]`)>-1}function cp(e,t){return typeof e==`function`?e.apply(void 0,t):e}function lp(e,t){if(t===0)return e;var n;return function(r){clearTimeout(n),n=setTimeout(function(){e(r)},t)}}function up(e,t){var n=Object.assign({},e);return t.forEach(function(e){delete n[e]}),n}function dp(e){return e.split(/\s+/).filter(Boolean)}function fp(e){return[].concat(e)}function pp(e,t){e.indexOf(t)===-1&&e.push(t)}function mp(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function hp(e){return e.split(`-`)[0]}function gp(e){return[].slice.call(e)}function _p(e){return Object.keys(e).reduce(function(t,n){return e[n]!==void 0&&(t[n]=e[n]),t},{})}function vp(){return document.createElement(`div`)}function yp(e){return[`Element`,`Fragment`].some(function(t){return sp(e,t)})}function bp(e){return sp(e,`NodeList`)}function xp(e){return sp(e,`MouseEvent`)}function Sp(e){return!!(e&&e._tippy&&e._tippy.reference===e)}function Cp(e){return yp(e)?[e]:bp(e)?gp(e):Array.isArray(e)?e:gp(document.querySelectorAll(e))}function wp(e,t){e.forEach(function(e){e&&(e.style.transitionDuration=t+`ms`)})}function Tp(e,t){e.forEach(function(e){e&&e.setAttribute(`data-state`,t)})}function Ep(e){var t,n=fp(e)[0];return n!=null&&(t=n.ownerDocument)!=null&&t.body?n.ownerDocument:document}function Dp(e,t){var n=t.clientX,r=t.clientY;return e.every(function(e){var t=e.popperRect,i=e.popperState,a=e.props.interactiveBorder,o=hp(i.placement),s=i.modifiersData.offset;if(!s)return!0;var c=o===`bottom`?s.top.y:0,l=o===`top`?s.bottom.y:0,u=o===`right`?s.left.x:0,d=o===`left`?s.right.x:0,f=t.top-r+c>a,p=r-t.bottom-l>a,m=t.left-n+u>a,h=n-t.right-d>a;return f||p||m||h})}function Op(e,t,n){var r=t+`EventListener`;[`transitionend`,`webkitTransitionEnd`].forEach(function(t){e[r](t,n)})}function kp(e,t){for(var n=t;n;){if(e.contains(n))return!0;n=n.getRootNode==null?void 0:n.getRootNode()?.host}return!1}var Ap={isTouch:!1},jp=0;function Mp(){Ap.isTouch||(Ap.isTouch=!0,window.performance&&document.addEventListener(`mousemove`,Np))}function Np(){var e=performance.now();e-jp<20&&(Ap.isTouch=!1,document.removeEventListener(`mousemove`,Np)),jp=e}function Pp(){var e=document.activeElement;if(Sp(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}function Fp(){document.addEventListener(`touchstart`,Mp,rp),window.addEventListener(`blur`,Pp)}var Ip=typeof window<`u`&&typeof document<`u`?!!window.msCrypto:!1;function Lp(e){var t=e===`destroy`?`n already-`:` `;return[e+`() was called on a`+t+`destroyed instance. This is a no-op but`,`indicates a potential memory leak.`].join(` `)}function Rp(e){return e.replace(/[ \t]{2,}/g,` `).replace(/^[ \t]*/gm,``).trim()}function zp(e){return Rp(`
|
|
194
|
+
`;document.body.insertAdjacentHTML(`beforeend`,t)}var sd=`bottom`,cd=`right`,ld=`left`,ud=`auto`,dd=[`top`,sd,cd,ld],fd=`start`,pd=`clippingParents`,md=`viewport`,hd=`popper`,gd=`reference`,_d=dd.reduce(function(e,t){return e.concat([t+`-`+fd,t+`-end`])},[]),vd=[].concat(dd,[ud]).reduce(function(e,t){return e.concat([t,t+`-`+fd,t+`-end`])},[]),yd=[`beforeRead`,`read`,`afterRead`,`beforeMain`,`main`,`afterMain`,`beforeWrite`,`write`,`afterWrite`];function bd(e){return e?(e.nodeName||``).toLowerCase():null}function xd(e){if(e==null)return window;if(e.toString()!==`[object Window]`){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Sd(e){return e instanceof xd(e).Element||e instanceof Element}function Cd(e){return e instanceof xd(e).HTMLElement||e instanceof HTMLElement}function wd(e){return typeof ShadowRoot>`u`?!1:e instanceof xd(e).ShadowRoot||e instanceof ShadowRoot}function Td(e){var t=e.state;Object.keys(t.elements).forEach(function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];!Cd(i)||!bd(i)||(Object.assign(i.style,n),Object.keys(r).forEach(function(e){var t=r[e];t===!1?i.removeAttribute(e):i.setAttribute(e,t===!0?``:t)}))})}function Ed(e){var t=e.state,n={popper:{position:t.options.strategy,left:`0`,top:`0`,margin:`0`},arrow:{position:`absolute`},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(e){var r=t.elements[e],i=t.attributes[e]||{},a=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce(function(e,t){return e[t]=``,e},{});!Cd(r)||!bd(r)||(Object.assign(r.style,a),Object.keys(i).forEach(function(e){r.removeAttribute(e)}))})}}var Dd={name:`applyStyles`,enabled:!0,phase:`write`,fn:Td,effect:Ed,requires:[`computeStyles`]};function Od(e){return e.split(`-`)[0]}var kd=Math.max,Ad=Math.min,jd=Math.round;function Md(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(e){return e.brand+`/`+e.version}).join(` `):navigator.userAgent}function Nd(){return!/^((?!chrome|android).)*safari/i.test(Md())}function Pd(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),i=1,a=1;t&&Cd(e)&&(i=e.offsetWidth>0&&jd(r.width)/e.offsetWidth||1,a=e.offsetHeight>0&&jd(r.height)/e.offsetHeight||1);var o=(Sd(e)?xd(e):window).visualViewport,s=!Nd()&&n,c=(r.left+(s&&o?o.offsetLeft:0))/i,l=(r.top+(s&&o?o.offsetTop:0))/a,u=r.width/i,d=r.height/a;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c,x:c,y:l}}function Fd(e){var t=Pd(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Id(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&wd(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Ld(e){return xd(e).getComputedStyle(e)}function Rd(e){return[`table`,`td`,`th`].indexOf(bd(e))>=0}function zd(e){return((Sd(e)?e.ownerDocument:e.document)||window.document).documentElement}function Bd(e){return bd(e)===`html`?e:e.assignedSlot||e.parentNode||(wd(e)?e.host:null)||zd(e)}function Vd(e){return!Cd(e)||Ld(e).position===`fixed`?null:e.offsetParent}function Hd(e){var t=/firefox/i.test(Md());if(/Trident/i.test(Md())&&Cd(e)&&Ld(e).position===`fixed`)return null;var n=Bd(e);for(wd(n)&&(n=n.host);Cd(n)&&[`html`,`body`].indexOf(bd(n))<0;){var r=Ld(n);if(r.transform!==`none`||r.perspective!==`none`||r.contain===`paint`||[`transform`,`perspective`].indexOf(r.willChange)!==-1||t&&r.willChange===`filter`||t&&r.filter&&r.filter!==`none`)return n;n=n.parentNode}return null}function Ud(e){for(var t=xd(e),n=Vd(e);n&&Rd(n)&&Ld(n).position===`static`;)n=Vd(n);return n&&(bd(n)===`html`||bd(n)===`body`&&Ld(n).position===`static`)?t:n||Hd(e)||t}function Wd(e){return[`top`,`bottom`].indexOf(e)>=0?`x`:`y`}function Gd(e,t,n){return kd(e,Ad(t,n))}function Kd(e,t,n){var r=Gd(e,t,n);return r>n?n:r}function qd(){return{top:0,right:0,bottom:0,left:0}}function Jd(e){return Object.assign({},qd(),e)}function Yd(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}var Xd=function(e,t){return e=typeof e==`function`?e(Object.assign({},t.rects,{placement:t.placement})):e,Jd(typeof e==`number`?Yd(e,dd):e)};function Zd(e){var t,n=e.state,r=e.name,i=e.options,a=n.elements.arrow,o=n.modifiersData.popperOffsets,s=Od(n.placement),c=Wd(s),l=[`left`,`right`].indexOf(s)>=0?`height`:`width`;if(!(!a||!o)){var u=Xd(i.padding,n),d=Fd(a),f=c===`y`?`top`:ld,p=c===`y`?sd:cd,m=n.rects.reference[l]+n.rects.reference[c]-o[c]-n.rects.popper[l],h=o[c]-n.rects.reference[c],g=Ud(a),_=g?c===`y`?g.clientHeight||0:g.clientWidth||0:0,v=m/2-h/2,y=u[f],b=_-d[l]-u[p],x=_/2-d[l]/2+v,S=Gd(y,x,b),C=c;n.modifiersData[r]=(t={},t[C]=S,t.centerOffset=S-x,t)}}function Qd(e){var t=e.state,n=e.options.element,r=n===void 0?`[data-popper-arrow]`:n;r!=null&&(typeof r==`string`&&(r=t.elements.popper.querySelector(r),!r)||Id(t.elements.popper,r)&&(t.elements.arrow=r))}var $d={name:`arrow`,enabled:!0,phase:`main`,fn:Zd,effect:Qd,requires:[`popperOffsets`],requiresIfExists:[`preventOverflow`]};function ef(e){return e.split(`-`)[1]}var tf={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};function nf(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:jd(n*i)/i||0,y:jd(r*i)/i||0}}function rf(e){var t,n=e.popper,r=e.popperRect,i=e.placement,a=e.variation,o=e.offsets,s=e.position,c=e.gpuAcceleration,l=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=o.x,p=f===void 0?0:f,m=o.y,h=m===void 0?0:m,g=typeof u==`function`?u({x:p,y:h}):{x:p,y:h};p=g.x,h=g.y;var _=o.hasOwnProperty(`x`),v=o.hasOwnProperty(`y`),y=ld,b=`top`,x=window;if(l){var S=Ud(n),C=`clientHeight`,w=`clientWidth`;if(S===xd(n)&&(S=zd(n),Ld(S).position!==`static`&&s===`absolute`&&(C=`scrollHeight`,w=`scrollWidth`)),S=S,i===`top`||(i===`left`||i===`right`)&&a===`end`){b=sd;var T=d&&S===x&&x.visualViewport?x.visualViewport.height:S[C];h-=T-r.height,h*=c?1:-1}if(i===`left`||(i===`top`||i===`bottom`)&&a===`end`){y=cd;var E=d&&S===x&&x.visualViewport?x.visualViewport.width:S[w];p-=E-r.width,p*=c?1:-1}}var D=Object.assign({position:s},l&&tf),O=u===!0?nf({x:p,y:h},xd(n)):{x:p,y:h};if(p=O.x,h=O.y,c){var k;return Object.assign({},D,(k={},k[b]=v?`0`:``,k[y]=_?`0`:``,k.transform=(x.devicePixelRatio||1)<=1?`translate(`+p+`px, `+h+`px)`:`translate3d(`+p+`px, `+h+`px, 0)`,k))}return Object.assign({},D,(t={},t[b]=v?h+`px`:``,t[y]=_?p+`px`:``,t.transform=``,t))}function af(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=r===void 0?!0:r,a=n.adaptive,o=a===void 0?!0:a,s=n.roundOffsets,c=s===void 0?!0:s,l={placement:Od(t.placement),variation:ef(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:t.options.strategy===`fixed`};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,rf(Object.assign({},l,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,rf(Object.assign({},l,{offsets:t.modifiersData.arrow,position:`absolute`,adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}var of={name:`computeStyles`,enabled:!0,phase:`beforeWrite`,fn:af,data:{}},sf={passive:!0};function cf(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,a=i===void 0?!0:i,o=r.resize,s=o===void 0?!0:o,c=xd(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&l.forEach(function(e){e.addEventListener(`scroll`,n.update,sf)}),s&&c.addEventListener(`resize`,n.update,sf),function(){a&&l.forEach(function(e){e.removeEventListener(`scroll`,n.update,sf)}),s&&c.removeEventListener(`resize`,n.update,sf)}}var lf={name:`eventListeners`,enabled:!0,phase:`write`,fn:function(){},effect:cf,data:{}},uf={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function df(e){return e.replace(/left|right|bottom|top/g,function(e){return uf[e]})}var ff={start:`end`,end:`start`};function pf(e){return e.replace(/start|end/g,function(e){return ff[e]})}function mf(e){var t=xd(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function hf(e){return Pd(zd(e)).left+mf(e).scrollLeft}function gf(e,t){var n=xd(e),r=zd(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;var l=Nd();(l||!l&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s+hf(e),y:c}}function _f(e){var t=zd(e),n=mf(e),r=e.ownerDocument?.body,i=kd(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=kd(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),o=-n.scrollLeft+hf(e),s=-n.scrollTop;return Ld(r||t).direction===`rtl`&&(o+=kd(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:o,y:s}}function vf(e){var t=Ld(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function yf(e){return[`html`,`body`,`#document`].indexOf(bd(e))>=0?e.ownerDocument.body:Cd(e)&&vf(e)?e:yf(Bd(e))}function bf(e,t){t===void 0&&(t=[]);var n=yf(e),r=n===e.ownerDocument?.body,i=xd(n),a=r?[i].concat(i.visualViewport||[],vf(n)?n:[]):n,o=t.concat(a);return r?o:o.concat(bf(Bd(a)))}function xf(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function Sf(e,t){var n=Pd(e,!1,t===`fixed`);return n.top+=e.clientTop,n.left+=e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function Cf(e,t,n){return t===`viewport`?xf(gf(e,n)):Sd(t)?Sf(t,n):xf(_f(zd(e)))}function wf(e){var t=bf(Bd(e)),n=[`absolute`,`fixed`].indexOf(Ld(e).position)>=0&&Cd(e)?Ud(e):e;return Sd(n)?t.filter(function(e){return Sd(e)&&Id(e,n)&&bd(e)!==`body`}):[]}function Tf(e,t,n,r){var i=t===`clippingParents`?wf(e):[].concat(t),a=[].concat(i,[n]),o=a[0],s=a.reduce(function(t,n){var i=Cf(e,n,r);return t.top=kd(i.top,t.top),t.right=Ad(i.right,t.right),t.bottom=Ad(i.bottom,t.bottom),t.left=kd(i.left,t.left),t},Cf(e,o,r));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function Ef(e){var t=e.reference,n=e.element,r=e.placement,i=r?Od(r):null,a=r?ef(r):null,o=t.x+t.width/2-n.width/2,s=t.y+t.height/2-n.height/2,c;switch(i){case`top`:c={x:o,y:t.y-n.height};break;case sd:c={x:o,y:t.y+t.height};break;case cd:c={x:t.x+t.width,y:s};break;case ld:c={x:t.x-n.width,y:s};break;default:c={x:t.x,y:t.y}}var l=i?Wd(i):null;if(l!=null){var u=l===`y`?`height`:`width`;switch(a){case fd:c[l]=c[l]-(t[u]/2-n[u]/2);break;case`end`:c[l]=c[l]+(t[u]/2-n[u]/2);break;default:}}return c}function Df(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=r===void 0?e.placement:r,a=n.strategy,o=a===void 0?e.strategy:a,s=n.boundary,c=s===void 0?pd:s,l=n.rootBoundary,u=l===void 0?md:l,d=n.elementContext,f=d===void 0?hd:d,p=n.altBoundary,m=p===void 0?!1:p,h=n.padding,g=h===void 0?0:h,_=Jd(typeof g==`number`?Yd(g,dd):g),v=f===`popper`?gd:hd,y=e.rects.popper,b=e.elements[m?v:f],x=Tf(Sd(b)?b:b.contextElement||zd(e.elements.popper),c,u,o),S=Pd(e.elements.reference),C=Ef({reference:S,element:y,strategy:`absolute`,placement:i}),w=xf(Object.assign({},y,C)),T=f===`popper`?w:S,E={top:x.top-T.top+_.top,bottom:T.bottom-x.bottom+_.bottom,left:x.left-T.left+_.left,right:T.right-x.right+_.right},D=e.modifiersData.offset;if(f===`popper`&&D){var O=D[i];Object.keys(E).forEach(function(e){var t=[`right`,`bottom`].indexOf(e)>=0?1:-1,n=[`top`,`bottom`].indexOf(e)>=0?`y`:`x`;E[e]+=O[n]*t})}return E}function Of(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=n.boundary,a=n.rootBoundary,o=n.padding,s=n.flipVariations,c=n.allowedAutoPlacements,l=c===void 0?vd:c,u=ef(r),d=u?s?_d:_d.filter(function(e){return ef(e)===u}):dd,f=d.filter(function(e){return l.indexOf(e)>=0});f.length===0&&(f=d);var p=f.reduce(function(t,n){return t[n]=Df(e,{placement:n,boundary:i,rootBoundary:a,padding:o})[Od(n)],t},{});return Object.keys(p).sort(function(e,t){return p[e]-p[t]})}function kf(e){if(Od(e)===`auto`)return[];var t=df(e);return[pf(e),t,pf(t)]}function Af(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,a=i===void 0?!0:i,o=n.altAxis,s=o===void 0?!0:o,c=n.fallbackPlacements,l=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0?!0:p,h=n.allowedAutoPlacements,g=t.options.placement,_=Od(g)===g,v=c||(_||!m?[df(g)]:kf(g)),y=[g].concat(v).reduce(function(e,n){return e.concat(Od(n)===`auto`?Of(t,{placement:n,boundary:u,rootBoundary:d,padding:l,flipVariations:m,allowedAutoPlacements:h}):n)},[]),b=t.rects.reference,x=t.rects.popper,S=new Map,C=!0,w=y[0],T=0;T<y.length;T++){var E=y[T],D=Od(E),O=ef(E)===fd,k=[`top`,sd].indexOf(D)>=0,A=k?`width`:`height`,j=Df(t,{placement:E,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),M=k?O?cd:ld:O?sd:`top`;b[A]>x[A]&&(M=df(M));var N=df(M),P=[];if(a&&P.push(j[D]<=0),s&&P.push(j[M]<=0,j[N]<=0),P.every(function(e){return e})){w=E,C=!1;break}S.set(E,P)}if(C)for(var F=m?3:1,I=function(e){var t=y.find(function(t){var n=S.get(t);if(n)return n.slice(0,e).every(function(e){return e})});if(t)return w=t,`break`},L=F;L>0&&I(L)!==`break`;L--);t.placement!==w&&(t.modifiersData[r]._skip=!0,t.placement=w,t.reset=!0)}}var jf={name:`flip`,enabled:!0,phase:`main`,fn:Af,requiresIfExists:[`offset`],data:{_skip:!1}};function Mf(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Nf(e){return[`top`,cd,sd,ld].some(function(t){return e[t]>=0})}function Pf(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,a=t.modifiersData.preventOverflow,o=Df(t,{elementContext:`reference`}),s=Df(t,{altBoundary:!0}),c=Mf(o,r),l=Mf(s,i,a),u=Nf(c),d=Nf(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}var Ff={name:`hide`,enabled:!0,phase:`main`,requiresIfExists:[`preventOverflow`],fn:Pf};function If(e,t,n){var r=Od(e),i=[`left`,`top`].indexOf(r)>=0?-1:1,a=typeof n==`function`?n(Object.assign({},t,{placement:e})):n,o=a[0],s=a[1];return o||=0,s=(s||0)*i,[`left`,`right`].indexOf(r)>=0?{x:s,y:o}:{x:o,y:s}}function Lf(e){var t=e.state,n=e.options,r=e.name,i=n.offset,a=i===void 0?[0,0]:i,o=vd.reduce(function(e,n){return e[n]=If(n,t.rects,a),e},{}),s=o[t.placement],c=s.x,l=s.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[r]=o}var Rf={name:`offset`,enabled:!0,phase:`main`,requires:[`popperOffsets`],fn:Lf};function zf(e){var t=e.state,n=e.name;t.modifiersData[n]=Ef({reference:t.rects.reference,element:t.rects.popper,strategy:`absolute`,placement:t.placement})}var Bf={name:`popperOffsets`,enabled:!0,phase:`read`,fn:zf,data:{}};function Vf(e){return e===`x`?`y`:`x`}function Hf(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,a=i===void 0?!0:i,o=n.altAxis,s=o===void 0?!1:o,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0?!0:f,m=n.tetherOffset,h=m===void 0?0:m,g=Df(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),_=Od(t.placement),v=ef(t.placement),y=!v,b=Wd(_),x=Vf(b),S=t.modifiersData.popperOffsets,C=t.rects.reference,w=t.rects.popper,T=typeof h==`function`?h(Object.assign({},t.rects,{placement:t.placement})):h,E=typeof T==`number`?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),D=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(S){if(a){var k=b===`y`?`top`:ld,A=b===`y`?sd:cd,j=b===`y`?`height`:`width`,M=S[b],N=M+g[k],P=M-g[A],F=p?-w[j]/2:0,I=v===`start`?C[j]:w[j],L=v===`start`?-w[j]:-C[j],R=t.elements.arrow,z=p&&R?Fd(R):{width:0,height:0},B=t.modifiersData[`arrow#persistent`]?t.modifiersData[`arrow#persistent`].padding:qd(),ee=B[k],te=B[A],ne=Gd(0,C[j],z[j]),V=y?C[j]/2-F-ne-ee-E.mainAxis:I-ne-ee-E.mainAxis,re=y?-C[j]/2+F+ne+te+E.mainAxis:L+ne+te+E.mainAxis,ie=t.elements.arrow&&Ud(t.elements.arrow),ae=ie?b===`y`?ie.clientTop||0:ie.clientLeft||0:0,oe=D?.[b]??0,se=M+V-oe-ae,ce=M+re-oe,le=Gd(p?Ad(N,se):N,M,p?kd(P,ce):P);S[b]=le,O[b]=le-M}if(s){var ue=b===`x`?`top`:ld,de=b===`x`?sd:cd,fe=S[x],pe=x===`y`?`height`:`width`,me=fe+g[ue],he=fe-g[de],ge=[`top`,ld].indexOf(_)!==-1,_e=D?.[x]??0,ve=ge?me:fe-C[pe]-w[pe]-_e+E.altAxis,ye=ge?fe+C[pe]+w[pe]-_e-E.altAxis:he,be=p&&ge?Kd(ve,fe,ye):Gd(p?ve:me,fe,p?ye:he);S[x]=be,O[x]=be-fe}t.modifiersData[r]=O}}var Uf={name:`preventOverflow`,enabled:!0,phase:`main`,fn:Hf,requiresIfExists:[`offset`]};function Wf(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Gf(e){return e===xd(e)||!Cd(e)?mf(e):Wf(e)}function Kf(e){var t=e.getBoundingClientRect(),n=jd(t.width)/e.offsetWidth||1,r=jd(t.height)/e.offsetHeight||1;return n!==1||r!==1}function qf(e,t,n){n===void 0&&(n=!1);var r=Cd(t),i=Cd(t)&&Kf(t),a=zd(t),o=Pd(e,i,n),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((bd(t)!==`body`||vf(a))&&(s=Gf(t)),Cd(t)?(c=Pd(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=hf(a))),{x:o.left+s.scrollLeft-c.x,y:o.top+s.scrollTop-c.y,width:o.width,height:o.height}}function Jf(e){var t=new Map,n=new Set,r=[];e.forEach(function(e){t.set(e.name,e)});function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}}),r.push(e)}return e.forEach(function(e){n.has(e.name)||i(e)}),r}function Yf(e){var t=Jf(e);return yd.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}function Xf(e){var t;return function(){return t||=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})}),t}}function Zf(e){var t=e.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{});return Object.keys(t).map(function(e){return t[e]})}var Qf={placement:`bottom`,modifiers:[],strategy:`absolute`};function $f(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some(function(e){return!(e&&typeof e.getBoundingClientRect==`function`)})}function ep(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,i=t.defaultOptions,a=i===void 0?Qf:i;return function(e,t,n){n===void 0&&(n=a);var i={placement:`bottom`,orderedModifiers:[],options:Object.assign({},Qf,a),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},o=[],s=!1,c={state:i,setOptions:function(n){var o=typeof n==`function`?n(i.options):n;u(),i.options=Object.assign({},a,i.options,o),i.scrollParents={reference:Sd(e)?bf(e):e.contextElement?bf(e.contextElement):[],popper:bf(t)};var s=Yf(Zf([].concat(r,i.options.modifiers)));return i.orderedModifiers=s.filter(function(e){return e.enabled}),l(),c.update()},forceUpdate:function(){if(!s){var e=i.elements,t=e.reference,n=e.popper;if($f(t,n)){i.rects={reference:qf(t,Ud(n),i.options.strategy===`fixed`),popper:Fd(n)},i.reset=!1,i.placement=i.options.placement,i.orderedModifiers.forEach(function(e){return i.modifiersData[e.name]=Object.assign({},e.data)});for(var r=0;r<i.orderedModifiers.length;r++){if(i.reset===!0){i.reset=!1,r=-1;continue}var a=i.orderedModifiers[r],o=a.fn,l=a.options,u=l===void 0?{}:l,d=a.name;typeof o==`function`&&(i=o({state:i,options:u,name:d,instance:c})||i)}}}},update:Xf(function(){return new Promise(function(e){c.forceUpdate(),e(i)})}),destroy:function(){u(),s=!0}};if(!$f(e,t))return c;c.setOptions(n).then(function(e){!s&&n.onFirstUpdate&&n.onFirstUpdate(e)});function l(){i.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,r=n===void 0?{}:n,a=e.effect;if(typeof a==`function`){var s=a({state:i,name:t,instance:c,options:r});o.push(s||function(){})}})}function u(){o.forEach(function(e){return e()}),o=[]}return c}}var tp=ep({defaultModifiers:[lf,Bf,of,Dd,Rf,jf,Uf,$d,Ff]}),np=`tippy-box`,rp=`tippy-content`,ip=`tippy-backdrop`,ap=`tippy-arrow`,op=`tippy-svg-arrow`,sp={passive:!0,capture:!0},cp=function(){return document.body};function lp(e,t){return{}.hasOwnProperty.call(e,t)}function up(e,t,n){return Array.isArray(e)?e[t]??(Array.isArray(n)?n[t]:n):e}function dp(e,t){var n={}.toString.call(e);return n.indexOf(`[object`)===0&&n.indexOf(t+`]`)>-1}function fp(e,t){return typeof e==`function`?e.apply(void 0,t):e}function pp(e,t){if(t===0)return e;var n;return function(r){clearTimeout(n),n=setTimeout(function(){e(r)},t)}}function mp(e,t){var n=Object.assign({},e);return t.forEach(function(e){delete n[e]}),n}function hp(e){return e.split(/\s+/).filter(Boolean)}function gp(e){return[].concat(e)}function _p(e,t){e.indexOf(t)===-1&&e.push(t)}function vp(e){return e.filter(function(t,n){return e.indexOf(t)===n})}function yp(e){return e.split(`-`)[0]}function bp(e){return[].slice.call(e)}function xp(e){return Object.keys(e).reduce(function(t,n){return e[n]!==void 0&&(t[n]=e[n]),t},{})}function Sp(){return document.createElement(`div`)}function Cp(e){return[`Element`,`Fragment`].some(function(t){return dp(e,t)})}function wp(e){return dp(e,`NodeList`)}function Tp(e){return dp(e,`MouseEvent`)}function Ep(e){return!!(e&&e._tippy&&e._tippy.reference===e)}function Dp(e){return Cp(e)?[e]:wp(e)?bp(e):Array.isArray(e)?e:bp(document.querySelectorAll(e))}function Op(e,t){e.forEach(function(e){e&&(e.style.transitionDuration=t+`ms`)})}function kp(e,t){e.forEach(function(e){e&&e.setAttribute(`data-state`,t)})}function Ap(e){var t,n=gp(e)[0];return n!=null&&(t=n.ownerDocument)!=null&&t.body?n.ownerDocument:document}function jp(e,t){var n=t.clientX,r=t.clientY;return e.every(function(e){var t=e.popperRect,i=e.popperState,a=e.props.interactiveBorder,o=yp(i.placement),s=i.modifiersData.offset;if(!s)return!0;var c=o===`bottom`?s.top.y:0,l=o===`top`?s.bottom.y:0,u=o===`right`?s.left.x:0,d=o===`left`?s.right.x:0,f=t.top-r+c>a,p=r-t.bottom-l>a,m=t.left-n+u>a,h=n-t.right-d>a;return f||p||m||h})}function Mp(e,t,n){var r=t+`EventListener`;[`transitionend`,`webkitTransitionEnd`].forEach(function(t){e[r](t,n)})}function Np(e,t){for(var n=t;n;){if(e.contains(n))return!0;n=n.getRootNode==null?void 0:n.getRootNode()?.host}return!1}var Pp={isTouch:!1},Fp=0;function Ip(){Pp.isTouch||(Pp.isTouch=!0,window.performance&&document.addEventListener(`mousemove`,Lp))}function Lp(){var e=performance.now();e-Fp<20&&(Pp.isTouch=!1,document.removeEventListener(`mousemove`,Lp)),Fp=e}function Rp(){var e=document.activeElement;if(Ep(e)){var t=e._tippy;e.blur&&!t.state.isVisible&&e.blur()}}function zp(){document.addEventListener(`touchstart`,Ip,sp),window.addEventListener(`blur`,Rp)}var Bp=typeof window<`u`&&typeof document<`u`?!!window.msCrypto:!1;function Vp(e){var t=e===`destroy`?`n already-`:` `;return[e+`() was called on a`+t+`destroyed instance. This is a no-op but`,`indicates a potential memory leak.`].join(` `)}function Hp(e){return e.replace(/[ \t]{2,}/g,` `).replace(/^[ \t]*/gm,``).trim()}function Up(e){return Hp(`
|
|
195
195
|
%ctippy.js
|
|
196
196
|
|
|
197
|
-
%c`+
|
|
197
|
+
%c`+Hp(e)+`
|
|
198
198
|
|
|
199
199
|
%c👷 This is a development-only message. It will be removed in production.
|
|
200
|
-
`)}function
|
|
200
|
+
`)}function Wp(e){return[Up(e),`color: #00C584; font-size: 1.3em; font-weight: bold;`,`line-height: 1.5`,`color: #a6a095;`]}var Gp;process.env.NODE_ENV!==`production`&&Kp();function Kp(){Gp=new Set}function qp(e,t){if(e&&!Gp.has(t)){var n;Gp.add(t),(n=console).warn.apply(n,Wp(t))}}function Jp(e,t){if(e&&!Gp.has(t)){var n;Gp.add(t),(n=console).error.apply(n,Wp(t))}}function Yp(e){var t=!e,n=Object.prototype.toString.call(e)===`[object Object]`&&!e.addEventListener;Jp(t,[`tippy() was passed`,"`"+String(e)+"`",`as its targets (first) argument. Valid types are: String, Element,`,`Element[], or NodeList.`].join(` `)),Jp(n,[`tippy() was passed a plain object which is not supported as an argument`,`for virtual positioning. Use props.getReferenceClientRect instead.`].join(` `))}var Xp={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Zp=Object.assign({appendTo:cp,aria:{content:`auto`,expanded:`auto`},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:``,offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:`top`,plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:`mouseenter focus`,triggerTarget:null},Xp,{allowHTML:!1,animation:`fade`,arrow:!0,content:``,inertia:!1,maxWidth:350,role:`tooltip`,theme:``,zIndex:9999}),Qp=Object.keys(Zp),$p=function(e){process.env.NODE_ENV!==`production`&&rm(e,[]),Object.keys(e).forEach(function(t){Zp[t]=e[t]})};function em(e){var t=(e.plugins||[]).reduce(function(t,n){var r=n.name,i=n.defaultValue;return r&&(t[r]=e[r]===void 0?Zp[r]??i:e[r]),t},{});return Object.assign({},e,t)}function tm(e,t){return(t?Object.keys(em(Object.assign({},Zp,{plugins:t}))):Qp).reduce(function(t,n){var r=(e.getAttribute(`data-tippy-`+n)||``).trim();if(!r)return t;if(n===`content`)t[n]=r;else try{t[n]=JSON.parse(r)}catch{t[n]=r}return t},{})}function nm(e,t){var n=Object.assign({},t,{content:fp(t.content,[e])},t.ignoreAttributes?{}:tm(e,t.plugins));return n.aria=Object.assign({},Zp.aria,n.aria),n.aria={expanded:n.aria.expanded===`auto`?t.interactive:n.aria.expanded,content:n.aria.content===`auto`?t.interactive?null:`describedby`:n.aria.content},n}function rm(e,t){e===void 0&&(e={}),t===void 0&&(t=[]),Object.keys(e).forEach(function(e){var n=!lp(mp(Zp,Object.keys(Xp)),e);n&&=t.filter(function(t){return t.name===e}).length===0,qp(n,["`"+e+"`",`is not a valid prop. You may have spelled it incorrectly, or if it's`,`a plugin, forgot to pass it in an array as props.plugins.`,`
|
|
201
201
|
|
|
202
202
|
`,`All props: https://atomiks.github.io/tippyjs/v6/all-props/
|
|
203
|
-
`,`Plugins: https://atomiks.github.io/tippyjs/v6/plugins/`].join(` `))})}var
|
|
203
|
+
`,`Plugins: https://atomiks.github.io/tippyjs/v6/plugins/`].join(` `))})}var im=function(){return`innerHTML`};function am(e,t){e[im()]=t}function om(e){var t=Sp();return e===!0?t.className=ap:(t.className=op,Cp(e)?t.appendChild(e):am(t,e)),t}function sm(e,t){Cp(t.content)?(am(e,``),e.appendChild(t.content)):typeof t.content!=`function`&&(t.allowHTML?am(e,t.content):e.textContent=t.content)}function cm(e){var t=e.firstElementChild,n=bp(t.children);return{box:t,content:n.find(function(e){return e.classList.contains(rp)}),arrow:n.find(function(e){return e.classList.contains(ap)||e.classList.contains(op)}),backdrop:n.find(function(e){return e.classList.contains(ip)})}}function lm(e){var t=Sp(),n=Sp();n.className=np,n.setAttribute(`data-state`,`hidden`),n.setAttribute(`tabindex`,`-1`);var r=Sp();r.className=rp,r.setAttribute(`data-state`,`hidden`),sm(r,e.props),t.appendChild(n),n.appendChild(r),i(e.props,e.props);function i(n,r){var i=cm(t),a=i.box,o=i.content,s=i.arrow;r.theme?a.setAttribute(`data-theme`,r.theme):a.removeAttribute(`data-theme`),typeof r.animation==`string`?a.setAttribute(`data-animation`,r.animation):a.removeAttribute(`data-animation`),r.inertia?a.setAttribute(`data-inertia`,``):a.removeAttribute(`data-inertia`),a.style.maxWidth=typeof r.maxWidth==`number`?r.maxWidth+`px`:r.maxWidth,r.role?a.setAttribute(`role`,r.role):a.removeAttribute(`role`),(n.content!==r.content||n.allowHTML!==r.allowHTML)&&sm(o,e.props),r.arrow?s?n.arrow!==r.arrow&&(a.removeChild(s),a.appendChild(om(r.arrow))):a.appendChild(om(r.arrow)):s&&a.removeChild(s)}return{popper:t,onUpdate:i}}lm.$$tippy=!0;var um=1,dm=[],fm=[];function pm(e,t){var n=nm(e,Object.assign({},Zp,em(xp(t)))),r,i,a,o=!1,s=!1,c=!1,l=!1,u,d,f,p=[],m=pp(se,n.interactiveDebounce),h,g=um++,_=null,v=vp(n.plugins),y={id:g,reference:e,popper:Sp(),popperInstance:_,props:n,state:{isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},plugins:v,clearDelayTimeouts:ye,setProps:be,setContent:xe,show:Se,hide:Ce,hideWithInteractivity:we,enable:_e,disable:ve,unmount:Te,destroy:Ee};if(!n.render)return process.env.NODE_ENV!==`production`&&Jp(!0,`render() function has not been supplied.`),y;var b=n.render(y),x=b.popper,S=b.onUpdate;x.setAttribute(`data-tippy-root`,``),x.id=`tippy-`+y.id,y.popper=x,e._tippy=y,x._tippy=y;var C=v.map(function(e){return e.fn(y)}),w=e.hasAttribute(`aria-expanded`);return ie(),F(),M(),N(`onCreate`,[y]),n.showOnCreate&&he(),x.addEventListener(`mouseenter`,function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),x.addEventListener(`mouseleave`,function(){y.props.interactive&&y.props.trigger.indexOf(`mouseenter`)>=0&&k().addEventListener(`mousemove`,m)}),y;function T(){var e=y.props.touch;return Array.isArray(e)?e:[e,0]}function E(){return T()[0]===`hold`}function D(){var e;return!!((e=y.props.render)!=null&&e.$$tippy)}function O(){return h||e}function k(){var e=O().parentNode;return e?Ap(e):document}function A(){return cm(x)}function j(e){return y.state.isMounted&&!y.state.isVisible||Pp.isTouch||u&&u.type===`focus`?0:up(y.props.delay,+!e,Zp.delay)}function M(e){e===void 0&&(e=!1),x.style.pointerEvents=y.props.interactive&&!e?``:`none`,x.style.zIndex=``+y.props.zIndex}function N(e,t,n){if(n===void 0&&(n=!0),C.forEach(function(n){n[e]&&n[e].apply(n,t)}),n){var r;(r=y.props)[e].apply(r,t)}}function P(){var t=y.props.aria;if(t.content){var n=`aria-`+t.content,r=x.id;gp(y.props.triggerTarget||e).forEach(function(e){var t=e.getAttribute(n);if(y.state.isVisible)e.setAttribute(n,t?t+` `+r:r);else{var i=t&&t.replace(r,``).trim();i?e.setAttribute(n,i):e.removeAttribute(n)}})}}function F(){w||!y.props.aria.expanded||gp(y.props.triggerTarget||e).forEach(function(e){y.props.interactive?e.setAttribute(`aria-expanded`,y.state.isVisible&&e===O()?`true`:`false`):e.removeAttribute(`aria-expanded`)})}function I(){k().removeEventListener(`mousemove`,m),dm=dm.filter(function(e){return e!==m})}function L(t){if(!(Pp.isTouch&&(c||t.type===`mousedown`))){var n=t.composedPath&&t.composedPath()[0]||t.target;if(!(y.props.interactive&&Np(x,n))){if(gp(y.props.triggerTarget||e).some(function(e){return Np(e,n)})){if(Pp.isTouch||y.state.isVisible&&y.props.trigger.indexOf(`click`)>=0)return}else N(`onClickOutside`,[y,t]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),s=!0,setTimeout(function(){s=!1}),y.state.isMounted||ee())}}}function R(){c=!0}function z(){c=!1}function B(){var e=k();e.addEventListener(`mousedown`,L,!0),e.addEventListener(`touchend`,L,sp),e.addEventListener(`touchstart`,z,sp),e.addEventListener(`touchmove`,R,sp)}function ee(){var e=k();e.removeEventListener(`mousedown`,L,!0),e.removeEventListener(`touchend`,L,sp),e.removeEventListener(`touchstart`,z,sp),e.removeEventListener(`touchmove`,R,sp)}function te(e,t){V(e,function(){!y.state.isVisible&&x.parentNode&&x.parentNode.contains(x)&&t()})}function ne(e,t){V(e,t)}function V(e,t){var n=A().box;function r(e){e.target===n&&(Mp(n,`remove`,r),t())}if(e===0)return t();Mp(n,`remove`,d),Mp(n,`add`,r),d=r}function re(t,n,r){r===void 0&&(r=!1),gp(y.props.triggerTarget||e).forEach(function(e){e.addEventListener(t,n,r),p.push({node:e,eventType:t,handler:n,options:r})})}function ie(){E()&&(re(`touchstart`,oe,{passive:!0}),re(`touchend`,ce,{passive:!0})),hp(y.props.trigger).forEach(function(e){if(e!==`manual`)switch(re(e,oe),e){case`mouseenter`:re(`mouseleave`,ce);break;case`focus`:re(Bp?`focusout`:`blur`,le);break;case`focusin`:re(`focusout`,le);break}})}function ae(){p.forEach(function(e){var t=e.node,n=e.eventType,r=e.handler,i=e.options;t.removeEventListener(n,r,i)}),p=[]}function oe(e){var t=!1;if(!(!y.state.isEnabled||ue(e)||s)){var n=u?.type===`focus`;u=e,h=e.currentTarget,F(),!y.state.isVisible&&Tp(e)&&dm.forEach(function(t){return t(e)}),e.type===`click`&&(y.props.trigger.indexOf(`mouseenter`)<0||o)&&y.props.hideOnClick!==!1&&y.state.isVisible?t=!0:he(e),e.type===`click`&&(o=!t),t&&!n&&ge(e)}}function se(e){var t=e.target,r=O().contains(t)||x.contains(t);e.type===`mousemove`&&r||jp(me().concat(x).map(function(e){var t=e._tippy.popperInstance?.state;return t?{popperRect:e.getBoundingClientRect(),popperState:t,props:n}:null}).filter(Boolean),e)&&(I(),ge(e))}function ce(e){if(!(ue(e)||y.props.trigger.indexOf(`click`)>=0&&o)){if(y.props.interactive){y.hideWithInteractivity(e);return}ge(e)}}function le(e){y.props.trigger.indexOf(`focusin`)<0&&e.target!==O()||y.props.interactive&&e.relatedTarget&&x.contains(e.relatedTarget)||ge(e)}function ue(e){return Pp.isTouch?E()!==e.type.indexOf(`touch`)>=0:!1}function de(){fe();var t=y.props,n=t.popperOptions,r=t.placement,i=t.offset,a=t.getReferenceClientRect,o=t.moveTransition,s=D()?cm(x).arrow:null,c=a?{getBoundingClientRect:a,contextElement:a.contextElement||O()}:e,l=[{name:`offset`,options:{offset:i}},{name:`preventOverflow`,options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:`flip`,options:{padding:5}},{name:`computeStyles`,options:{adaptive:!o}},{name:`$$tippy`,enabled:!0,phase:`beforeWrite`,requires:[`computeStyles`],fn:function(e){var t=e.state;if(D()){var n=A().box;[`placement`,`reference-hidden`,`escaped`].forEach(function(e){e===`placement`?n.setAttribute(`data-placement`,t.placement):t.attributes.popper[`data-popper-`+e]?n.setAttribute(`data-`+e,``):n.removeAttribute(`data-`+e)}),t.attributes.popper={}}}}];D()&&s&&l.push({name:`arrow`,options:{element:s,padding:3}}),l.push.apply(l,n?.modifiers||[]),y.popperInstance=tp(c,x,Object.assign({},n,{placement:r,onFirstUpdate:f,modifiers:l}))}function fe(){y.popperInstance&&=(y.popperInstance.destroy(),null)}function pe(){var e=y.props.appendTo,t,n=O();t=y.props.interactive&&e===cp||e===`parent`?n.parentNode:fp(e,[n]),t.contains(x)||t.appendChild(x),y.state.isMounted=!0,de(),process.env.NODE_ENV!==`production`&&qp(y.props.interactive&&e===Zp.appendTo&&n.nextElementSibling!==x,[`Interactive tippy element may not be accessible via keyboard`,`navigation because it is not directly after the reference element`,`in the DOM source order.`,`
|
|
204
204
|
|
|
205
205
|
`,`Using a wrapper <div> or <span> tag around the reference element`,`solves this by creating a new parentNode context.`,`
|
|
206
206
|
|
|
207
207
|
`,"Specifying `appendTo: document.body` silences this warning, but it",`assumes you are using a focus management solution to handle`,`keyboard navigation.`,`
|
|
208
208
|
|
|
209
|
-
`,`See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity`].join(` `))}function me(){return
|
|
209
|
+
`,`See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity`].join(` `))}function me(){return bp(x.querySelectorAll(`[data-tippy-root]`))}function he(e){y.clearDelayTimeouts(),e&&N(`onTrigger`,[y,e]),B();var t=j(!0),n=T(),i=n[0],a=n[1];Pp.isTouch&&i===`hold`&&a&&(t=a),t?r=setTimeout(function(){y.show()},t):y.show()}function ge(e){if(y.clearDelayTimeouts(),N(`onUntrigger`,[y,e]),!y.state.isVisible){ee();return}if(!(y.props.trigger.indexOf(`mouseenter`)>=0&&y.props.trigger.indexOf(`click`)>=0&&[`mouseleave`,`mousemove`].indexOf(e.type)>=0&&o)){var t=j(!1);t?i=setTimeout(function(){y.state.isVisible&&y.hide()},t):a=requestAnimationFrame(function(){y.hide()})}}function _e(){y.state.isEnabled=!0}function ve(){y.hide(),y.state.isEnabled=!1}function ye(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(a)}function be(t){if(process.env.NODE_ENV!==`production`&&qp(y.state.isDestroyed,Vp(`setProps`)),!y.state.isDestroyed){N(`onBeforeUpdate`,[y,t]),ae();var n=y.props,r=nm(e,Object.assign({},n,xp(t),{ignoreAttributes:!0}));y.props=r,ie(),n.interactiveDebounce!==r.interactiveDebounce&&(I(),m=pp(se,r.interactiveDebounce)),n.triggerTarget&&!r.triggerTarget?gp(n.triggerTarget).forEach(function(e){e.removeAttribute(`aria-expanded`)}):r.triggerTarget&&e.removeAttribute(`aria-expanded`),F(),M(),S&&S(n,r),y.popperInstance&&(de(),me().forEach(function(e){requestAnimationFrame(e._tippy.popperInstance.forceUpdate)})),N(`onAfterUpdate`,[y,t])}}function xe(e){y.setProps({content:e})}function Se(){process.env.NODE_ENV!==`production`&&qp(y.state.isDestroyed,Vp(`show`));var e=y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,r=Pp.isTouch&&!y.props.touch,i=up(y.props.duration,0,Zp.duration);if(!(e||t||n||r)&&!O().hasAttribute(`disabled`)&&(N(`onShow`,[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,D()&&(x.style.visibility=`visible`),M(),B(),y.state.isMounted||(x.style.transition=`none`),D()){var a=A(),o=a.box,s=a.content;Op([o,s],0)}f=function(){var e;if(!(!y.state.isVisible||l)){if(l=!0,x.offsetHeight,x.style.transition=y.props.moveTransition,D()&&y.props.animation){var t=A(),n=t.box,r=t.content;Op([n,r],i),kp([n,r],`visible`)}P(),F(),_p(fm,y),(e=y.popperInstance)==null||e.forceUpdate(),N(`onMount`,[y]),y.props.animation&&D()&&ne(i,function(){y.state.isShown=!0,N(`onShown`,[y])})}},pe()}}function Ce(){process.env.NODE_ENV!==`production`&&qp(y.state.isDestroyed,Vp(`hide`));var e=!y.state.isVisible,t=y.state.isDestroyed,n=!y.state.isEnabled,r=up(y.props.duration,1,Zp.duration);if(!(e||t||n)&&(N(`onHide`,[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,l=!1,o=!1,D()&&(x.style.visibility=`hidden`),I(),ee(),M(!0),D()){var i=A(),a=i.box,s=i.content;y.props.animation&&(Op([a,s],r),kp([a,s],`hidden`))}P(),F(),y.props.animation?D()&&te(r,y.unmount):y.unmount()}}function we(e){process.env.NODE_ENV!==`production`&&qp(y.state.isDestroyed,Vp(`hideWithInteractivity`)),k().addEventListener(`mousemove`,m),_p(dm,m),m(e)}function Te(){process.env.NODE_ENV!==`production`&&qp(y.state.isDestroyed,Vp(`unmount`)),y.state.isVisible&&y.hide(),y.state.isMounted&&(fe(),me().forEach(function(e){e._tippy.unmount()}),x.parentNode&&x.parentNode.removeChild(x),fm=fm.filter(function(e){return e!==y}),y.state.isMounted=!1,N(`onHidden`,[y]))}function Ee(){process.env.NODE_ENV!==`production`&&qp(y.state.isDestroyed,Vp(`destroy`)),!y.state.isDestroyed&&(y.clearDelayTimeouts(),y.unmount(),ae(),delete e._tippy,y.state.isDestroyed=!0,N(`onDestroy`,[y]))}}function mm(e,t){t===void 0&&(t={});var n=Zp.plugins.concat(t.plugins||[]);process.env.NODE_ENV!==`production`&&(Yp(e),rm(t,n)),zp();var r=Object.assign({},t,{plugins:n}),i=Dp(e);if(process.env.NODE_ENV!==`production`){var a=Cp(r.content),o=i.length>1;qp(a&&o,["tippy() was passed an Element as the `content` prop, but more than",`one tippy instance was created by this invocation. This means the`,`content element will only be appended to the last tippy instance.`,`
|
|
210
210
|
|
|
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&&lm(t,r);return n&&e.push(n),e},[]);return yp(e)?s[0]:s}um.defaultProps=qp,um.setDefaultProps=Yp,um.currentInput=Ap,Object.assign({},Cd,{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)}}),um.setDefaultProps({render:am});var dm=`#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(`.`),fm=`notes-toolbar-recent-colors`,pm=8;function mm(){try{return JSON.parse(localStorage.getItem(fm)||`[]`)}catch{return[]}}function hm(e){let t=mm().filter(t=>t!==e);t.unshift(e),t.length>pm&&(t=t.slice(0,pm)),localStorage.setItem(fm,JSON.stringify(t))}function gm(e={}){let t=document.createElement(`div`);return t.className=`notes-toolbar`,t.appendChild(xm(e)),t.appendChild(Sm(e)),t.appendChild(Cm(e)),t.appendChild(Dm(e)),t.appendChild(Am(e)),t.appendChild(jm(e)),t.appendChild(Nm(e)),t}function _m(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 vm(e,t){let n=e.querySelector(`[data-action="heading"]`);n&&(n.value=t===!1?`0`:String(t))}function ym(){let e=document.createElement(`div`);return e.className=`notes-toolbar-group`,e}function bm(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 xm(e){let t=ym(),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?!1:t)}),t.appendChild(n),t}function Sm(e){let t=ym();return t.appendChild(bm(`bold`,`<b>B</b>`,`Bold`,e.onBold)),t.appendChild(bm(`italic`,`<i>I</i>`,`Italic`,e.onItalic)),t.appendChild(bm(`underline`,`<u>U</u>`,`Underline`,e.onUnderline)),t.appendChild(bm(`strike`,`<s>S</s>`,`Strikethrough`,e.onStrike)),t}function Cm(e){let t=ym();return t.appendChild(wm(`color`,`A`,`Text color`,`#000000`,t=>{hm(t),e.onColor?.(t)})),t.appendChild(wm(`background`,`A`,`Background color`,`#ffff00`,t=>{hm(t),e.onBackground?.(t)})),t}function wm(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}c=um(a,{content:Tm(r,e=>{s.style.backgroundColor=e,i(e),c?.destroy(),c=void 0}),theme:`light-border`,trigger:`manual`,interactive:!0,placement:`bottom-start`,onHidden:()=>{c?.destroy(),c=void 0}}),c.show()}),a}function Tm(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 dm)r.appendChild(Em(n,n===e,t));n.appendChild(r);let i=mm();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(Em(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 Em(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 Dm(e){let t=ym();return t.appendChild(bm(`orderedList`,Om(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(bm(`bulletList`,Om(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 Om(e,t,n){return`<svg width="${e}" height="${t}" viewBox="0 0 ${e} ${t}" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}var km={alignLeft:Om(16,16,`<path d="M1 2h14v2H1zm0 4h9v2H1zm0 4h14v2H1zm0 4h9v2H1z" fill="currentColor"/>`),alignCenter:Om(16,16,`<path d="M1 2h14v2H1zm3.5 4h7v2h-7zM1 10h14v2H1zm3.5 4h7v2h-7z" fill="currentColor"/>`),alignRight:Om(16,16,`<path d="M1 2h14v2H1zm6 4h8v2H7zM1 10h14v2H1zm6 4h8v2H7z" fill="currentColor"/>`),alignJustify:Om(16,16,`<path d="M1 2h14v2H1zm0 4h14v2H1zm0 4h14v2H1zm0 4h14v2H1z" fill="currentColor"/>`)};function Am(e){let t=ym();return t.appendChild(bm(`alignLeft`,km.alignLeft,`Align left`,()=>e.onAlign?.(`left`))),t.appendChild(bm(`alignCenter`,km.alignCenter,`Align center`,()=>e.onAlign?.(`center`))),t.appendChild(bm(`alignRight`,km.alignRight,`Align right`,()=>e.onAlign?.(`right`))),t.appendChild(bm(`alignJustify`,km.alignJustify,`Justify`,()=>e.onAlign?.(`justify`))),t}function jm(e){let t=ym();t.appendChild(bm(`blockquote`,`“`,`Blockquote`,e.onBlockquote)),t.appendChild(bm(`codeBlock`,`</>`,`Code block`,e.onCodeBlock));let n=bm(`link`,`⇗`,`Insert link`);Mm(n,`Enter URL`,`https://`,t=>e.onLink?.(t)),t.appendChild(n);let r=bm(`video`,`▷`,`Insert video`);return Mm(r,`YouTube URL`,`https://youtube.com/...`,t=>e.onVideo?.(t)),t.appendChild(r),t}function Mm(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=um(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 Nm(e){let t=ym();return t.appendChild(bm(`clearFormatting`,`⊘`,`Clear formatting`,e.onClearFormatting)),t}function Pm(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}=ln(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 Fm(e){return typeof e==`function`}var Im;function Lm(e){Im&&=(Im?.destroy(!0),void 0),e?.remove&&e.remove()}function Rm(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;Lm();let l=document.createElement(`div`),u;return s||=i?.evt?.target,s&&(Im=um(s,{content:()=>(c=c?.filter(e=>!e.hide&&!e.disabled).map(e=>({...e,onClick:()=>{Lm(l),Fm(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?Im.setContent(`IMPLEMENT SUB MENU`):Fm(e.onClick)?(Lm(l),e.onClick()):Fm(a)&&a&&(Lm(l),a(typeof e==`object`?{...e,coords:i}:e))}})),u=Pm(l,[{text:t,items:c},...r]).focusElement,l),theme:`light-border`,trigger:`click`,onShown:()=>{u&&setTimeout(()=>u?.focus(),0)},...o}),Im.show(),Im.setProps({interactive:!0})),Im}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 zm(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 Bm(e){let t=zm(`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 Vm(e){let t=zm(`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 Hm(e){let t=zm(`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 Um(e){let t=zm(`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 Wm(e){let t=zm(`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 Gm(e){let t=zm(`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 Km(e){let t=zm(`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 qm=`COURT_SVG`,Jm={tennis:Bm,basketball:Vm,baseball:Hm,hockey:Um,pickleball:Wm,badminton:Gm,padel:Km},Ym={TENNIS:`tennis`,PADEL:`padel`,PICKLEBALL:`pickleball`,BADMINTON:`badminton`},Xm={HAL:`basketball`,INN:`baseball`,PER:`hockey`};function Zm(e){if(e){for(let[t,n]of Object.entries(Xm))if(e.startsWith(t))return n;if(e.startsWith(`SET`)||e.startsWith(`T`))return e.includes(`@RALLY`)?`pickleball`:`tennis`}}function Qm(e){let t=e?.competitionFormat?.sport;return t&&Ym[t]?Ym[t]:Zm(e?.matchUpFormat)}function $m(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 eh(e,t=``){let n=e?Jm[e]:void 0;if(n)return $m(n(t?`court--${e} ${t}`:`court--${e}`))}function th(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 nh(e){if(!e)return;let t=th(e);return t.length?t:void 0}function rh(e){let t=e?.find(Boolean);if(!t)return;let n=t.addresses?.find(Boolean);return n?nh(n)??t.venueName:t.venueName}function ih(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function ah(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}function oh(e,t){if(!e&&!t)return;let n=e?new Date(e):null,r=t?new Date(t):null,i=!!n&&!Number.isNaN(n.getTime()),a=!!r&&!Number.isNaN(r.getTime());if(!(!i&&!a))return i&&a&&n.getTime()===r.getTime()?ah(n):i&&a?n.getFullYear()===r.getFullYear()?`${ih(n)} – ${ih(r)}, ${r.getFullYear()}`:`${ah(n)} – ${ah(r)}`:ah(i?n:r)}var sh=`URL`;function ch(e,t){if(!Array.isArray(e))return;let n=e.find(e=>e?.name===t&&e?.resourceType===sh);return n?.url??n?.identifier}function lh(e,t){if(Array.isArray(e))return e.find(e=>e?.resourceSubType===`COURT_SVG`&&(t?e?.name===t:!0))?.identifier}function uh(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 dh={showImage:!0,cornerBadges:[`status`],body:[`title`,`location`,`dateRange`],footer:[`feeBadge`,`playerCount`]};function fh(e){return e?{showImage:e.showImage??dh.showImage,cornerBadges:e.cornerBadges??dh.cornerBadges,body:e.body??dh.body,footer:e.footer??dh.footer}:dh}var ph=()=>`chc-tc-card`,mh=()=>`chc-tc-card--clickable`,hh=()=>`chc-tc-card--offline`,gh=()=>`chc-tc-image`,_h=()=>`chc-tc-image-img`,vh=()=>`chc-tc-image-svg`,yh=()=>`chc-tc-image-placeholder`,bh=()=>`chc-tc-corner-badges`,xh=()=>`chc-tc-status-pill`,Sh=()=>`chc-tc-offline-badge`,Ch=()=>`chc-tc-body`,wh=()=>`chc-tc-title`,Th=()=>`chc-tc-location`,Eh=()=>`chc-tc-date-range`,Dh=()=>`chc-tc-organizer`,Oh=()=>`chc-tc-updated-at`,kh=()=>`chc-tc-footer`,Ah=()=>`chc-tc-fee-badge`,jh=()=>`chc-tc-player-count`,Mh=()=>`chc-tc-event-count`,Nh=()=>`chc-tc-card chc-tc-skeleton`,Ph=()=>`chc-tc-skeleton-line`,Fh=()=>`chc-tc-skeleton-block`;function Ih(e,t,n){let r=fh(t),i=document.createElement(`div`);return i.className=ph(),i.dataset.tournamentId=e.tournamentId,e.offline&&i.classList.add(hh()),n?.onClick&&(i.classList.add(mh()),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(Lh(e,r)),r.body.length&&i.appendChild(Hh(e,r)),r.footer.length&&i.appendChild(Yh(e,r)),i}function Lh(e,t){let n=document.createElement(`div`);if(n.className=gh(),e.tournamentImageURL){let t=document.createElement(`img`);t.className=_h(),t.src=e.tournamentImageURL,t.alt=e.tournamentName||``,t.loading=`lazy`,t.addEventListener(`error`,()=>zh(n,e)),n.appendChild(t)}else Rh(n,e);if(t.cornerBadges.length){let r=Bh(e,t.cornerBadges);r&&n.appendChild(r)}return n}function Rh(e,t){let n=eh(t.courtSvgSport,vh());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=yh(),e.appendChild(r)}function zh(e,t){e.querySelector(`.${_h()}`)?.remove(),Rh(e,t)}function Bh(e,t){let n=[];for(let r of t){let t=Vh(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=bh();for(let e of n)r.appendChild(e);return r}function Vh(e,t){if(e===`status`){if(!t.status)return null;let e=document.createElement(`div`);return e.className=xh(),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=Sh(),e.textContent=`Offline`,e}return null}function Hh(e,t){let n=document.createElement(`div`);n.className=Ch();for(let r of t.body){let t=Uh(r,e);t&&n.appendChild(t)}return n}function Uh(e,t){switch(e){case`title`:return Wh(t);case`location`:return Gh(t);case`dateRange`:return Kh(t);case`organizerName`:return qh(t);case`updatedAt`:return Jh(t);default:return null}}function Wh(e){if(!e.tournamentName)return null;let t=document.createElement(`div`);return t.className=wh(),t.textContent=e.tournamentName,t.title=e.tournamentName,t}function Gh(e){if(!e.location)return null;let t=document.createElement(`div`);return t.className=Th(),t.textContent=e.location,t.title=e.location,t}function Kh(e){if(!e.dateRangeFormatted)return null;let t=document.createElement(`div`);return t.className=Eh(),t.textContent=e.dateRangeFormatted,t}function qh(e){if(!e.organizerName)return null;let t=document.createElement(`div`);return t.className=Dh(),t.textContent=e.organizerName,t}function Jh(e){if(!e.updatedAt)return null;let t=document.createElement(`div`);t.className=Oh();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 Yh(e,t){let n=document.createElement(`div`);n.className=kh();for(let r of t.footer){let t=Xh(r,e);t&&n.appendChild(t)}return n}function Xh(e,t){switch(e){case`feeBadge`:return Zh(t);case`playerCount`:return Qh(t);case`eventCount`:return $h(t);default:return null}}function Zh(e){if(!e.feeFormatted)return null;let t=document.createElement(`div`);return t.className=Ah(),t.textContent=e.feeFormatted,t}function Qh(e){if(typeof e.participantCount!=`number`)return null;let t=document.createElement(`div`);return t.className=jh(),t.textContent=`${e.participantCount} ${e.participantCount===1?`player`:`players`}`,t}function $h(e){if(typeof e.eventCount!=`number`)return null;let t=document.createElement(`div`);return t.className=Mh(),t.textContent=`${e.eventCount} ${e.eventCount===1?`event`:`events`}`,t}function eg(e){let t=fh(e);return uh({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:Nh(),imageClass:gh(),bodyClass:Ch(),footerClass:kh(),blockClass:Fh(),lineClass:Ph()})}var tg=10080*60*1e3;function ng(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function rg(e,t,n){return!t||!n?!1:t.getTime()<=e.getTime()&&e.getTime()<=n.getTime()}function ig(e){return`Opens ${e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}`}function ag(e,t=new Date){let n=e.tournamentStatus?.toUpperCase();if(n===`CANCELLED`||n===`ABANDONDED`||n===`ABANDONED`)return{kind:`cancelled`,label:`Cancelled`};let r=ng(e.endDate);if(n===`COMPLETED`||r&&t.getTime()>r.getTime())return{kind:`completed`,label:`Completed`};if(rg(t,ng(e.startDate),r))return{kind:`live`,label:`Live`};let i=ng(e.entriesClose);if(i){let e=i.getTime()-t.getTime();if(e>0&&e<=tg)return{kind:`closing-soon`,label:`Closing Soon`}}let a=ng(e.entriesOpen);return a&&a.getTime()>t.getTime()?{kind:`registration-opens`,label:ig(a)}:null}var og=`USD`,sg=`–`;function cg(e,t){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}catch{return`$${e.toFixed(2)}`}}function lg(e){let t=new Set;for(let n of e)t.add(n.currencyCode||og);return[...t]}function ug(e){return[...e].sort((e,t)=>e.amount-t.amount).find(Boolean)}function dg(e){if(!e||e.length===0)return null;let t=e.filter(e=>typeof e.amount==`number`&&!Number.isNaN(e.amount));if(t.length===0)return null;if(t.length===1){let e=t[0],n=e.currencyCode||og;return`${n} ${cg(e.amount,n)}`}let n=lg(t);if(n.length>1){let e=ug(t);if(!e)return null;let n=e.currencyCode||og;return`From ${n} ${cg(e.amount,n)}`}let r=n[0],i=t.map(e=>e.amount).sort((e,t)=>e-t),a=i[0],o=i.at(-1)??a;return a===o?`${r} ${cg(a,r)}`:`${r} ${cg(a,r)} ${sg} ${cg(o,r)}`}var fg=`tournamentImage`;function pg(e){let t=e?.registrationProfile?.entryFees;return Array.isArray(t)?t.filter(e=>e&&typeof e.amount==`number`):[]}function mg(e){let t=e?.timeItems;if(Array.isArray(t))return t.find(e=>e?.itemType===`TMX`)?.itemValue?.offline}function hg(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?ag({tournamentStatus:e?.tournamentStatus,startDate:e?.startDate,endDate:e?.endDate,entriesOpen:e?.registrationProfile?.entriesOpen,entriesClose:e?.registrationProfile?.entriesClose},t?.now):t.statusOverride,s=e?.tournamentImageURL??ch(n,fg),c=e?.courtSvgSport??lh(n);return{tournamentId:e?.tournamentId??``,tournamentName:e?.tournamentName??``,startDate:e?.startDate,endDate:e?.endDate,dateRangeFormatted:oh(e?.startDate,e?.endDate),location:rh(r),tournamentImageURL:s,courtSvgSport:c,participantCount:i.length||void 0,eventCount:a.length||void 0,organizerName:e?.tournamentOrganizers?.find?.(Boolean)?.organizerName,status:o,feeFormatted:dg(pg(e)),updatedAt:e?.updatedAt,offline:mg(e)}}var gg={showImage:!0,showMap:!0,cornerBadges:[`primaryBadge`],body:[`title`,`address`,`courtBreakdown`],footer:[`amenityRow`]};function _g(e){return e?{showImage:e.showImage??gg.showImage,showMap:e.showMap??gg.showMap,cornerBadges:e.cornerBadges??gg.cornerBadges,body:e.body??gg.body,footer:e.footer??gg.footer}:gg}var vg=()=>`chc-vc-card`,yg=()=>`chc-vc-card--clickable`,bg=()=>`chc-vc-image`,xg=()=>`chc-vc-image-img`,Sg=()=>`chc-vc-image-svg`,Cg=()=>`chc-vc-image-map`,wg=()=>`chc-vc-image-placeholder`,Tg=()=>`chc-vc-corner-badges`,Eg=()=>`chc-vc-primary-badge`,Dg=()=>`chc-vc-body`,Og=()=>`chc-vc-title`,kg=()=>`chc-vc-address`,Ag=()=>`chc-vc-court-breakdown`,jg=()=>`chc-vc-footer`,Mg=()=>`chc-vc-amenity-row`,Ng=()=>`chc-vc-amenity`,Pg=()=>`chc-vc-card chc-vc-skeleton`,Fg=()=>`chc-vc-skeleton-line`,Ig=()=>`chc-vc-skeleton-block`;function Lg(e,t,n){let r=_g(t),i=document.createElement(`div`);return i.className=vg(),i.dataset.venueId=e.venueId,n?.onClick&&(i.classList.add(yg()),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(Vg(e,r)),r.body.length&&i.appendChild(Yg(e,r)),r.footer.length&&i.appendChild($g(e,r)),i}function Rg(e){return typeof e.latitude==`number`&&typeof e.longitude==`number`}function zg(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=Cg(),a.src=i,a.loading=`lazy`,a.title=`Map of ${e.venueName}`,a}function Bg(e,t){let n=eh(t.courtSvgSport,Sg());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=wg(),e.appendChild(r)}function Vg(e,t){let n=document.createElement(`div`);if(n.className=bg(),e.venueImageURL){let r=document.createElement(`img`);r.className=xg(),r.src=e.venueImageURL,r.alt=e.venueName||``,r.loading=`lazy`,r.addEventListener(`error`,()=>{r.remove(),t.showMap!==!1&&Rg(e)?n.appendChild(zg(e)):Bg(n,e)}),n.appendChild(r)}else t.showMap!==!1&&Rg(e)?n.appendChild(zg(e)):Bg(n,e);if(t.cornerBadges.length){let r=Ug(e,t.cornerBadges);r&&n.appendChild(r)}return n}function Hg(e,t){if(e===`primaryBadge`){if(!t.isPrimary)return null;let e=document.createElement(`div`);return e.className=Eg(),e.textContent=`Primary`,e}return null}function Ug(e,t){let n=[];for(let r of t){let t=Hg(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=Tg();for(let e of n)r.appendChild(e);return r}function Wg(e){if(!e.venueName)return null;let t=document.createElement(`div`);return t.className=Og(),t.textContent=e.venueName,t.title=e.notes?`${e.venueName}\n${e.notes}`:e.venueName,t}function Gg(e){if(!e.addressFormatted)return null;let t=document.createElement(`div`);return t.className=kg(),t.textContent=e.addressFormatted,t.title=e.addressFormatted,t}function Kg(e){if(!e.courtBreakdown)return null;let t=document.createElement(`div`);return t.className=Ag(),t.textContent=e.courtBreakdown,t}function qg(e){if(!e.venueAbbreviation)return null;let t=document.createElement(`div`);return t.className=Ag(),t.textContent=e.venueAbbreviation,t}function Jg(e,t){return e===`title`?Wg(t):e===`address`?Gg(t):e===`courtBreakdown`?Kg(t):e===`venueAbbreviation`?qg(t):null}function Yg(e,t){let n=document.createElement(`div`);n.className=Dg();for(let r of t.body){let t=Jg(r,e);t&&n.appendChild(t)}return n}function Xg(e){let t=document.createElement(`span`);return t.className=Ng(),t.textContent=e,t}function Zg(e){let t=[];if(typeof e.courtCount==`number`&&t.push(Xg(`${e.courtCount} ${e.courtCount===1?`court`:`courts`}`)),e.indoorCount&&t.push(Xg(`${e.indoorCount} indoor`)),e.outdoorCount&&t.push(Xg(`${e.outdoorCount} outdoor`)),e.floodlitCount&&t.push(Xg(`${e.floodlitCount} lit`)),!t.length)return null;let n=document.createElement(`div`);n.className=Mg();for(let e of t)n.appendChild(e);return n}function Qg(e,t){return e===`amenityRow`?Zg(t):e===`address`?Gg(t):e===`courtBreakdown`?Kg(t):null}function $g(e,t){let n=document.createElement(`div`);n.className=jg();for(let r of t.footer){let t=Qg(r,e);t&&n.appendChild(t)}return n}function e_(e){let t=_g(e);return uh({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:Pg(),imageClass:bg(),bodyClass:Dg(),footerClass:jg(),blockClass:Ig(),lineClass:Fg()})}var t_=`venueImage`;function n_(e){let t=[];return e.indoorOutdoor&&t.push(e.indoorOutdoor.toLowerCase()),e.surfaceCategory&&t.push(e.surfaceCategory.toLowerCase()),t.length?t.join(` `):`court`}function r_(e){if(!e.length)return;let t=new Map;for(let n of e){let e=n_(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 i_(e,t){let n=0;for(let r of e)t(r)&&(n+=1);return n}function a_(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:nh(i),latitude:typeof i?.latitude==`number`?i.latitude:void 0,longitude:typeof i?.longitude==`number`?i.longitude:void 0,courtCount:n.length||void 0,courtBreakdown:r_(n),indoorCount:i_(n,e=>e.indoorOutdoor===`INDOOR`)||void 0,outdoorCount:i_(n,e=>e.indoorOutdoor===`OUTDOOR`)||void 0,floodlitCount:i_(n,e=>!!e.floodlit)||void 0,isPrimary:!!e?.isPrimary,venueImageURL:e?.venueImageURL??ch(r,t_),courtSvgSport:e?.courtSvgSport??lh(r)??t?.sport,notes:e?.notes}}var o_={showImage:!0,cornerBadges:[`indoorOutdoor`,`floodlit`],body:[`title`,`surface`],footer:[`amenityRow`]};function s_(e){return e?{showImage:e.showImage??o_.showImage,cornerBadges:e.cornerBadges??o_.cornerBadges,body:e.body??o_.body,footer:e.footer??o_.footer}:o_}var c_=()=>`chc-cc-card`,l_=()=>`chc-cc-card--clickable`,u_=()=>`chc-cc-image`,d_=()=>`chc-cc-image-svg`,f_=()=>`chc-cc-image-placeholder`,p_=()=>`chc-cc-corner-badges`,m_=()=>`chc-cc-indoor-badge`,h_=()=>`chc-cc-floodlit-badge`,g_=()=>`chc-cc-body`,__=()=>`chc-cc-title`,v_=()=>`chc-cc-surface`,y_=()=>`chc-cc-availability`,b_=()=>`chc-cc-abbr`,x_=()=>`chc-cc-footer`,S_=()=>`chc-cc-amenity-row`,C_=()=>`chc-cc-card chc-cc-skeleton`,w_=()=>`chc-cc-skeleton-line`,T_=()=>`chc-cc-skeleton-block`;function E_(e,t,n){let r=s_(t),i=document.createElement(`div`);return i.className=c_(),i.dataset.courtId=e.courtId,n?.onClick&&(i.classList.add(l_()),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(O_(e,r)),r.body.length&&i.appendChild(R_(e,r)),r.footer.length&&i.appendChild(V_(e,r)),i}function D_(e,t){let n=eh(t.courtSvgSport,d_());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=f_(),e.appendChild(r)}function O_(e,t){let n=document.createElement(`div`);if(n.className=u_(),D_(n,e),t.cornerBadges.length){let r=M_(e,t.cornerBadges);r&&n.appendChild(r)}return n}function k_(e){if(!e.indoorOutdoor)return null;let t=document.createElement(`div`);return t.className=m_(),t.dataset.kind=e.indoorOutdoor,t.textContent=e.indoorOutdoor===`INDOOR`?`Indoor`:`Outdoor`,t}function A_(e){if(!e.floodlit)return null;let t=document.createElement(`div`);return t.className=h_(),t.textContent=`Lit`,t}function j_(e,t){return e===`indoorOutdoor`?k_(t):e===`floodlit`?A_(t):null}function M_(e,t){let n=[];for(let r of t){let t=j_(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=p_();for(let e of n)r.appendChild(e);return r}function N_(e){if(!e.courtName)return null;let t=document.createElement(`div`);return t.className=__(),t.textContent=e.courtName,t.title=e.notes?`${e.courtName}\n${e.notes}`:e.courtName,t}function P_(e){if(!e.surfaceLabel)return null;let t=document.createElement(`div`);return t.className=v_(),t.textContent=e.surfaceLabel,t}function F_(e){if(!e.availabilitySummary)return null;let t=document.createElement(`div`);return t.className=y_(),t.textContent=e.availabilitySummary,t}function I_(e){if(!e.courtAbbreviation)return null;let t=document.createElement(`div`);return t.className=b_(),t.textContent=e.courtAbbreviation,t}function L_(e,t){return e===`title`?N_(t):e===`surface`?P_(t):e===`availability`?F_(t):e===`abbreviation`?I_(t):null}function R_(e,t){let n=document.createElement(`div`);n.className=g_();for(let r of t.body){let t=L_(r,e);t&&n.appendChild(t)}return n}function z_(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=S_(),n.textContent=t.join(` · `),n}function B_(e,t){return e===`amenityRow`?z_(t):e===`availability`?F_(t):e===`surface`?P_(t):null}function V_(e,t){let n=document.createElement(`div`);n.className=x_();for(let r of t.footer){let t=B_(r,e);t&&n.appendChild(t)}return n}function H_(e){let t=s_(e);return uh({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:C_(),imageClass:u_(),bodyClass:g_(),footerClass:x_(),blockClass:T_(),lineClass:w_()})}var U_=`INDOOR`,W_=`OUTDOOR`;function G_(e){if(!e)return;let t=String(e).toUpperCase();if(t===U_)return U_;if(t===W_)return W_}function K_(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 q_(e,t){let n=G_(e?.indoorOutdoor),r=e?.surfaceCategory?String(e.surfaceCategory).toUpperCase():void 0;return{courtId:e?.courtId??``,courtName:e?.courtName??``,courtAbbreviation:e?.courtAbbreviation,surfaceLabel:K_(n,r),indoorOutdoor:n,surfaceCategory:r,floodlit:!!e?.floodlit,courtSvgSport:t?.sport,notes:e?.notes}}var J_={showImage:!0,cornerBadges:[`status`,`eventTypeBadge`],body:[`title`,`categoryLabel`,`drawSummary`],footer:[`playerCount`,`matchUpProgress`]},Y_=15;function X_(e){return e?{showImage:e.showImage??J_.showImage,cornerBadges:e.cornerBadges??J_.cornerBadges,body:e.body??J_.body,footer:e.footer??J_.footer}:J_}var Z_=()=>`chc-ec-card`,Q_=()=>`chc-ec-card--clickable`,$_=()=>`chc-ec-image`,ev=()=>`chc-ec-image-img`,tv=()=>`chc-ec-image-svg`,nv=()=>`chc-ec-image-placeholder`,rv=()=>`chc-ec-corner-badges`,iv=()=>`chc-ec-status-pill`,av=()=>`chc-ec-eventtype-badge`,ov=()=>`chc-ec-gender-badge`,sv=()=>`chc-ec-body`,cv=()=>`chc-ec-title`,lv=()=>`chc-ec-category`,uv=()=>`chc-ec-draw-summary`,dv=()=>`chc-ec-date-range`,fv=()=>`chc-ec-footer`,pv=()=>`chc-ec-player-count`,mv=()=>`chc-ec-matchup-progress`,hv=()=>`chc-ec-updated-at`,gv=()=>`chc-ec-card chc-ec-skeleton`,_v=()=>`chc-ec-skeleton-line`,vv=()=>`chc-ec-skeleton-block`;function yv(e,t,n){let r=X_(t),i=document.createElement(`div`);return i.className=Z_(),i.dataset.eventId=e.eventId,n?.onClick&&(i.classList.add(Q_()),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(xv(e,r)),r.body.length&&i.appendChild(Fv(e,r)),r.footer.length&&i.appendChild(Iv(e,r)),i}function bv(e,t){let n=eh(t.courtSvgSport,tv());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=nv(),e.appendChild(r)}function xv(e,t){let n=document.createElement(`div`);if(n.className=$_(),e.eventImageURL){let t=document.createElement(`img`);t.className=ev(),t.src=e.eventImageURL,t.alt=e.eventName||``,t.loading=`lazy`,t.addEventListener(`error`,()=>{t.remove(),bv(n,e)}),n.appendChild(t)}else bv(n,e);if(t.cornerBadges.length){let r=Ev(e,t.cornerBadges);r&&n.appendChild(r)}return n}function Sv(e){if(!e.status)return null;let t=document.createElement(`div`);return t.className=iv(),t.dataset.kind=e.status.kind,t.textContent=e.status.label,t}function Cv(e){if(!e.eventType)return null;let t=document.createElement(`div`);return t.className=av(),t.dataset.kind=e.eventType,t.textContent=e.eventType,t}function wv(e){if(!e.gender)return null;let t=document.createElement(`div`);return t.className=ov(),t.dataset.kind=e.gender,t.textContent=e.gender===`MALE`?`M`:e.gender===`FEMALE`?`W`:`X`,t}function Tv(e,t){return e===`status`?Sv(t):e===`eventTypeBadge`?Cv(t):e===`genderBadge`?wv(t):null}function Ev(e,t){let n=[];for(let r of t){let t=Tv(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=rv();for(let e of n)r.appendChild(e);return r}function Dv(e){if(!e.eventName)return null;let t=document.createElement(`div`);return t.className=cv(),t.textContent=e.eventName,t.title=e.eventName,t}function Ov(e){if(!e.categoryLabel)return null;let t=document.createElement(`div`);return t.className=lv(),t.textContent=e.categoryLabel,t}function kv(e){if(!e.drawSummary)return null;let t=document.createElement(`div`);return t.className=uv(),t.textContent=e.drawSummary,t}function Av(e){if(!e.dateRangeFormatted)return null;let t=document.createElement(`div`);return t.className=dv(),t.textContent=e.dateRangeFormatted,t}function jv(e){if(!e.updatedAt)return null;let t=document.createElement(`div`);t.className=hv();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 Mv(e){if(typeof e.entryCount!=`number`)return null;let t=document.createElement(`div`);return t.className=pv(),t.textContent=`${e.entryCount} ${e.entryCount===1?`player`:`players`}`,t}function Nv(e){if(!e.matchUpCounts||e.matchUpCounts.total===0)return null;let{total:t,completed:n}=e.matchUpCounts,r=document.createElement(`div`);return r.className=mv(),r.textContent=`${n}/${t} matches`,r}function Pv(e,t){return e===`title`?Dv(t):e===`categoryLabel`?Ov(t):e===`drawSummary`?kv(t):e===`dateRange`?Av(t):e===`updatedAt`?jv(t):e===`playerCount`?Mv(t):e===`matchUpProgress`?Nv(t):null}function Fv(e,t){let n=document.createElement(`div`);n.className=sv();for(let r of t.body){let t=Pv(r,e);t&&n.appendChild(t)}return n}function Iv(e,t){let n=document.createElement(`div`);n.className=fv();for(let r of t.footer){let t=Pv(r,e);t&&n.appendChild(t)}return n}function Lv(e){let t=X_(e);return uh({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:gv(),imageClass:$_(),bodyClass:sv(),footerClass:fv(),blockClass:vv(),lineClass:_v()})}function Rv(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function zv(e,t,n){return!t||!n?!1:t.getTime()<=e.getTime()&&e.getTime()<=n.getTime()}function Bv(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=Rv(e.startDate),i=Rv(e.endDate);if(n&&(n.inProgress>0||zv(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 Vv=`eventImage`,Hv=`DRAFT_STATE`;function Uv(e){if(!e)return;let t=String(e).toUpperCase();if(t===`SINGLES`||t===`DOUBLES`||t===`TEAM`||t===`HYBRID`)return t}function Wv(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 Gv(e){if(e){if(e.categoryName)return e.categoryName;if(typeof e.ageMin==`number`&&typeof e.ageMax==`number`)return e.ageMin===e.ageMax?`Age ${e.ageMin}`:`Age ${e.ageMin}–${e.ageMax}`;if(e.ageCategoryCode)return e.ageCategoryCode;if(e.ratingMin&&e.ratingMax)return`Rating ${e.ratingMin}–${e.ratingMax}`}}function Kv(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 qv(e){let t=0,n=0,r=0,i=0;for(let a of e)for(let e of a?.structures??[])for(let a of e?.matchUps??[])t+=1,a?.winningSide?n+=1:a?.schedule?.scheduledTime&&(r+=1),a?.matchUpStatus===`IN_PROGRESS`&&(i+=1);return{total:t,completed:n,scheduled:r,inProgress:i}}function Jv(e){let t=e?.extensions;return Array.isArray(t)?t.some(e=>e?.name===Hv):!1}function Yv(e){return e.some(e=>e?.automated?.seedsOnly===!0||Jv(e))}function Xv(e){return e.length===0?!1:e.every(e=>e?.drawStatus===`CANCELLED`)}var Zv=new Set([`DIRECT_ACCEPTANCE`,`DA`,`DIRECT_CONFIRMED`,`DC`,`ACCEPTED`,`A`,`ENTERED`,`PE`,`QUALIFIER`,`Q`,`WILDCARD`,`WC`]);function Qv(e){if(!e.length)return 0;let t=0;for(let n of e)Zv.has(String(n?.entryStatus))&&(t+=1);return t}function $v(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:qv(n)),o=t?.statusOverride===void 0?Bv({allDrawsCancelled:Xv(n),drawCount:n.length,entryCount:Qv(r),startDate:e?.startDate,endDate:e?.endDate,matchUpCounts:a,hasDraftState:n.some(Jv),hasSeedsOnlyDraw:Yv(n)},t?.now):t.statusOverride;return{eventId:e?.eventId??``,eventName:e?.eventName??``,eventAbbreviation:e?.eventAbbreviation,categoryLabel:Gv(e?.category),eventType:Uv(e?.eventType),gender:Wv(e?.gender),drawCount:n.length||void 0,drawSummary:Kv(n),entryCount:Qv(r)||void 0,matchUpCounts:a,startDate:e?.startDate,endDate:e?.endDate,dateRangeFormatted:oh(e?.startDate,e?.endDate),status:o,eventImageURL:e?.eventImageURL??ch(i,Vv),courtSvgSport:e?.courtSvgSport??lh(i)??t?.sport,updatedAt:e?.updatedAt}}var ey={name:`courthive-components`,packageManager:`pnpm@11.1.2`,version:`1.6.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:`vite build`,prepublishOnly:`npm run 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:`npm run build-storybook`,prebuild:`rm -rf dist/*`,lint:`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.0.1`,"@commitlint/config-conventional":`21.0.1`,"@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/vanillajs-datepicker":`^1.3.5`,"@typescript-eslint/eslint-plugin":`8.59.3`,"@typescript-eslint/parser":`8.59.3`,"@vitest/browser-playwright":`^4.0.16`,"@vitest/coverage-v8":`^4.0.16`,"@vitest/ui":`^4.0.16`,eslint:`10.4.0`,"eslint-plugin-sonarjs":`4.0.3`,"eslint-plugin-storybook":`^10.2.17`,"gh-pages":`6.3.0`,globals:`^17.3.0`,"happy-dom":`^20.8.3`,husky:`9.1.7`,"lint-staged":`17.0.5`,playwright:`^1.57.0`,prettier:`^3.8.1`,semver:`7.8.0`,storybook:`^10.2.17`,"tabulator-tables":`6.4.0`,typescript:`^6.0.2`,vite:`8.0.13`,"vite-plugin-dts":`^5.0.0`,vitest:`^4.0.16`},dependencies:{awesomplete:`1.1.7`,"class-variance-authority":`0.7.1`,classnames:`2.5.1`,d3:`^7.9.0`,dayjs:`1.11.20`,"focus-trap":`^8.0.0`,"timepicker-ui":`^4.1.2`,"tippy.js":`6.3.7`,"tods-competition-factory":`3.7.0`,"vanillajs-datepicker":`1.3.4`}};function ty(){return ey.version}var ny={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 ry(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&&B(i.onClick)&&i.onClick(),n&&B(n)&&n()},e.appendChild(t)}return{elements:r}}var iy=(e,t)=>n=>n?.trim().length>=e&&(!t||n?.trim().length<=t);function ay(e){return t.tools.isConvertableInteger(e)&&parseInt(e.toString())>=0}var oy=(e,t)=>n=>ay(n)&&Number(n)>=e&&Number(n)<=t,sy=e=>/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?\d)(?=.*?[#?!@$%^&*-]).{8,12}$/.test(e);function cy(e){return t.tools.dateTime.dateValidation.test(e)}var ly=(e,t)=>n=>{let r=(n||``).trim().split(` `).length;return r>=e&&(!t||r<=t)},uy=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,dy=e=>uy.exec(e),fy=u({dateValidator:()=>cy,emailValidator:()=>dy,nameValidator:()=>iy,numericRange:()=>oy,numericValidator:()=>ay,passwordValidator:()=>sy,wordValidator:()=>ly}),py=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}}},my=`<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>`,hy=new WeakMap;function gy(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=my,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),hy.set(n,i),n.appendChild(r),n}function _y(e){hy.get(e)?.()}function vy(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function yy(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function by(e){let t,n,r;e.length===2?(t=e===vy||e===yy?e:xy,n=e,r=e):(t=vy,n=(t,n)=>vy(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 xy(){return 0}function Sy(e){return e===null?NaN:+e}var Cy=by(vy),wy=Cy.right;Cy.left,by(Sy).center;var Ty=class extends Map{constructor(e,t=ky){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(Ey(this,e))}has(e){return super.has(Ey(this,e))}set(e,t){return super.set(Dy(this,e),t)}delete(e){return super.delete(Oy(this,e))}};function Ey({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Dy({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Oy({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function ky(e){return typeof e==`object`&&e?e.valueOf():e}var Ay=Math.sqrt(50),jy=Math.sqrt(10),My=Math.sqrt(2);function Ny(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=Ay?10:a>=jy?5:a>=My?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?Ny(e,t,n*2):[s,c,l]}function Py(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?Ny(t,e,n):Ny(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 Fy(e,t,n){return t=+t,e=+e,n=+n,Ny(e,t,n)[2]}function Iy(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Fy(t,e,n):Fy(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function Ly(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 Ry(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 zy(e){return e}var By=1,Vy=2,Hy=3,Uy=4,Wy=1e-6;function Gy(e){return`translate(`+e+`,0)`}function Ky(e){return`translate(0,`+e+`)`}function qy(e){return t=>+e(t)}function Jy(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function Yy(){return!this.__axis}function Xy(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===By||e===Uy?-1:1,u=e===Uy||e===Vy?`x`:`y`,d=e===By||e===Hy?Gy:Ky;function f(f){var p=r??(t.ticks?t.ticks.apply(t,n):t.domain()),m=i??(t.tickFormat?t.tickFormat.apply(t,n):zy),h=Math.max(a,0)+s,g=t.range(),_=+g[0]+c,v=+g[g.length-1]+c,y=(t.bandwidth?Jy:qy)(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===By?`0em`:e===Hy?`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`,Wy).attr(`transform`,function(e){return isFinite(e=y(e))?d(e+c):this.getAttribute(`transform`)}),w.attr(`opacity`,Wy).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===Uy||e===Vy?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(Yy).attr(`fill`,`none`).attr(`font-size`,10).attr(`font-family`,`sans-serif`).attr(`text-anchor`,e===Vy?`start`:e===Uy?`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 Zy(e){return Xy(Hy,e)}var Qy={value:()=>{}};function $y(){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 eb(n)}function eb(e){this._=e}function tb(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}})}eb.prototype=$y.prototype={constructor:eb,on:function(e,t){var n=this._,r=tb(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=nb(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]=rb(n[i],e.name,t);else if(t==null)for(i in n)n[i]=rb(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 eb(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 nb(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function rb(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Qy,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ib={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 ab(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),ib.hasOwnProperty(t)?{space:ib[t],local:e}:e}function ob(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 sb(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function cb(e){var t=ab(e);return(t.local?sb:ob)(t)}function lb(){}function ub(e){return e==null?lb:function(){return this.querySelector(e)}}function db(e){typeof e!=`function`&&(e=ub(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 $x(r,this._parents)}function fb(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function pb(){return[]}function mb(e){return e==null?pb:function(){return this.querySelectorAll(e)}}function hb(e){return function(){return fb(e.apply(this,arguments))}}function gb(e){e=typeof e==`function`?hb(e):mb(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 $x(r,i)}function _b(e){return function(){return this.matches(e)}}function vb(e){return function(t){return t.matches(e)}}var yb=Array.prototype.find;function bb(e){return function(){return yb.call(this.children,e)}}function xb(){return this.firstElementChild}function Sb(e){return this.select(e==null?xb:bb(typeof e==`function`?e:vb(e)))}var Cb=Array.prototype.filter;function wb(){return Array.from(this.children)}function Tb(e){return function(){return Cb.call(this.children,e)}}function Eb(e){return this.selectAll(e==null?wb:Tb(typeof e==`function`?e:vb(e)))}function Db(e){typeof e!=`function`&&(e=_b(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 $x(r,this._parents)}function Ob(e){return Array(e.length)}function kb(){return new $x(this._enter||this._groups.map(Ob),this._parents)}function Ab(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ab.prototype={constructor:Ab,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 jb(e){return function(){return e}}function Mb(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 Ab(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Nb(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 Ab(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Pb(e){return e.__data__}function Fb(e,t){if(!arguments.length)return Array.from(this,Pb);var n=t?Nb:Mb,r=this._parents,i=this._groups;typeof e!=`function`&&(e=jb(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=Ib(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 $x(o,r),o._enter=s,o._exit=c,o}function Ib(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Lb(){return new $x(this._exit||this._groups.map(Ob),this._parents)}function Rb(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 zb(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 $x(s,this._parents)}function Bb(){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 Vb(e){e||=Hb;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 $x(i,this._parents).order()}function Hb(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ub(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Wb(){return Array.from(this)}function Gb(){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 Kb(){let e=0;for(let t of this)++e;return e}function qb(){return!this.node()}function Jb(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 Yb(e){return function(){this.removeAttribute(e)}}function Xb(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zb(e,t){return function(){this.setAttribute(e,t)}}function Qb(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function $b(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ex(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 tx(e,t){var n=ab(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?Xb:Yb:typeof t==`function`?n.local?ex:$b:n.local?Qb:Zb)(n,t))}function nx(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function rx(e){return function(){this.style.removeProperty(e)}}function ix(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ax(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function ox(e,t,n){return arguments.length>1?this.each((t==null?rx:typeof t==`function`?ax:ix)(e,t,n??``)):sx(this.node(),e)}function sx(e,t){return e.style.getPropertyValue(t)||nx(e).getComputedStyle(e,null).getPropertyValue(t)}function cx(e){return function(){delete this[e]}}function lx(e,t){return function(){this[e]=t}}function ux(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function dx(e,t){return arguments.length>1?this.each((t==null?cx:typeof t==`function`?ux:lx)(e,t)):this.node()[e]}function fx(e){return e.trim().split(/^|\s+/)}function px(e){return e.classList||new mx(e)}function mx(e){this._node=e,this._names=fx(e.getAttribute(`class`)||``)}mx.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 hx(e,t){for(var n=px(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function gx(e,t){for(var n=px(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function _x(e){return function(){hx(this,e)}}function vx(e){return function(){gx(this,e)}}function yx(e,t){return function(){(t.apply(this,arguments)?hx:gx)(this,e)}}function bx(e,t){var n=fx(e+``);if(arguments.length<2){for(var r=px(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?yx:t?_x:vx)(n,t))}function xx(){this.textContent=``}function Sx(e){return function(){this.textContent=e}}function Cx(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function wx(e){return arguments.length?this.each(e==null?xx:(typeof e==`function`?Cx:Sx)(e)):this.node().textContent}function Tx(){this.innerHTML=``}function Ex(e){return function(){this.innerHTML=e}}function Dx(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function Ox(e){return arguments.length?this.each(e==null?Tx:(typeof e==`function`?Dx:Ex)(e)):this.node().innerHTML}function kx(){this.nextSibling&&this.parentNode.appendChild(this)}function Ax(){return this.each(kx)}function jx(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Mx(){return this.each(jx)}function Nx(e){var t=typeof e==`function`?e:cb(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Px(){return null}function Fx(e,t){var n=typeof e==`function`?e:cb(e),r=t==null?Px:typeof t==`function`?t:ub(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Ix(){var e=this.parentNode;e&&e.removeChild(this)}function Lx(){return this.each(Ix)}function Rx(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zx(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bx(e){return this.select(e?zx:Rx)}function Vx(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Hx(e){return function(t){e.call(this,t,this.__data__)}}function Ux(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 Wx(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 Gx(e,t,n){return function(){var r=this.__on,i,a=Hx(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 Kx(e,t,n){var r=Ux(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?Gx:Wx,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function qx(e,t,n){var r=nx(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 Jx(e,t){return function(){return qx(this,e,t)}}function Yx(e,t){return function(){return qx(this,e,t.apply(this,arguments))}}function Xx(e,t){return this.each((typeof t==`function`?Yx:Jx)(e,t))}function*Zx(){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 Qx=[null];function $x(e,t){this._groups=e,this._parents=t}function eS(){return new $x([[document.documentElement]],Qx)}function tS(){return this}$x.prototype=eS.prototype={constructor:$x,select:db,selectAll:gb,selectChild:Sb,selectChildren:Eb,filter:Db,data:Fb,enter:kb,exit:Lb,join:Rb,merge:zb,selection:tS,order:Bb,sort:Vb,call:Ub,nodes:Wb,node:Gb,size:Kb,empty:qb,each:Jb,attr:tx,style:ox,property:dx,classed:bx,text:wx,html:Ox,raise:Ax,lower:Mx,append:Nx,insert:Fx,remove:Lx,clone:Bx,datum:Vx,on:Kx,dispatch:Xx,[Symbol.iterator]:Zx};function nS(e){return typeof e==`string`?new $x([[document.querySelector(e)]],[document.documentElement]):new $x([[e]],Qx)}function rS(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function iS(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function aS(){}var oS=.7,sS=1/oS,cS=`\\s*([+-]?\\d+)\\s*`,lS=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,uS=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,dS=/^#([0-9a-f]{3,8})$/,fS=RegExp(`^rgb\\(${cS},${cS},${cS}\\)$`),pS=RegExp(`^rgb\\(${uS},${uS},${uS}\\)$`),mS=RegExp(`^rgba\\(${cS},${cS},${cS},${lS}\\)$`),hS=RegExp(`^rgba\\(${uS},${uS},${uS},${lS}\\)$`),gS=RegExp(`^hsl\\(${lS},${uS},${uS}\\)$`),_S=RegExp(`^hsla\\(${lS},${uS},${uS},${lS}\\)$`),vS={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};rS(aS,CS,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:yS,formatHex:yS,formatHex8:bS,formatHsl:xS,formatRgb:SS,toString:SS});function yS(){return this.rgb().formatHex()}function bS(){return this.rgb().formatHex8()}function xS(){return IS(this).formatHsl()}function SS(){return this.rgb().formatRgb()}function CS(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=dS.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?wS(t):n===3?new OS(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?TS(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?TS(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=fS.exec(e))?new OS(t[1],t[2],t[3],1):(t=pS.exec(e))?new OS(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=mS.exec(e))?TS(t[1],t[2],t[3],t[4]):(t=hS.exec(e))?TS(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=gS.exec(e))?FS(t[1],t[2]/100,t[3]/100,1):(t=_S.exec(e))?FS(t[1],t[2]/100,t[3]/100,t[4]):vS.hasOwnProperty(e)?wS(vS[e]):e===`transparent`?new OS(NaN,NaN,NaN,0):null}function wS(e){return new OS(e>>16&255,e>>8&255,e&255,1)}function TS(e,t,n,r){return r<=0&&(e=t=n=NaN),new OS(e,t,n,r)}function ES(e){return e instanceof aS||(e=CS(e)),e?(e=e.rgb(),new OS(e.r,e.g,e.b,e.opacity)):new OS}function DS(e,t,n,r){return arguments.length===1?ES(e):new OS(e,t,n,r??1)}function OS(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}rS(OS,DS,iS(aS,{brighter(e){return e=e==null?sS:sS**+e,new OS(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?oS:oS**+e,new OS(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new OS(NS(this.r),NS(this.g),NS(this.b),MS(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:kS,formatHex:kS,formatHex8:AS,formatRgb:jS,toString:jS}));function kS(){return`#${PS(this.r)}${PS(this.g)}${PS(this.b)}`}function AS(){return`#${PS(this.r)}${PS(this.g)}${PS(this.b)}${PS((isNaN(this.opacity)?1:this.opacity)*255)}`}function jS(){let e=MS(this.opacity);return`${e===1?`rgb(`:`rgba(`}${NS(this.r)}, ${NS(this.g)}, ${NS(this.b)}${e===1?`)`:`, ${e})`}`}function MS(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function NS(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function PS(e){return e=NS(e),(e<16?`0`:``)+e.toString(16)}function FS(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new RS(e,t,n,r)}function IS(e){if(e instanceof RS)return new RS(e.h,e.s,e.l,e.opacity);if(e instanceof aS||(e=CS(e)),!e)return new RS;if(e instanceof RS)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 RS(o,s,c,e.opacity)}function LS(e,t,n,r){return arguments.length===1?IS(e):new RS(e,t,n,r??1)}function RS(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}rS(RS,LS,iS(aS,{brighter(e){return e=e==null?sS:sS**+e,new RS(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?oS:oS**+e,new RS(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 OS(VS(e>=240?e-240:e+120,i,r),VS(e,i,r),VS(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new RS(zS(this.h),BS(this.s),BS(this.l),MS(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=MS(this.opacity);return`${e===1?`hsl(`:`hsla(`}${zS(this.h)}, ${BS(this.s)*100}%, ${BS(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function zS(e){return e=(e||0)%360,e<0?e+360:e}function BS(e){return Math.max(0,Math.min(1,e||0))}function VS(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 HS=e=>()=>e;function US(e,t){return function(n){return e+n*t}}function WS(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function GS(e){return(e=+e)==1?KS:function(t,n){return n-t?WS(t,n,e):HS(isNaN(t)?n:t)}}function KS(e,t){var n=t-e;return n?US(e,n):HS(isNaN(e)?t:e)}var qS=(function e(t){var n=GS(t);function r(e,t){var r=n((e=DS(e)).r,(t=DS(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=KS(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 JS(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 YS(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function XS(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=aC(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 ZS(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function QS(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function $S(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]=aC(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var eC=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,tC=new RegExp(eC.source,`g`);function nC(e){return function(){return e}}function rC(e){return function(t){return e(t)+``}}function iC(e,t){var n=eC.lastIndex=tC.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=eC.exec(e))&&(i=tC.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:QS(r,i)})),n=tC.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?rC(c[0].x):nC(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 aC(e,t){var n=typeof t,r;return t==null||n===`boolean`?HS(t):(n===`number`?QS:n===`string`?(r=CS(t))?(t=r,qS):iC:t instanceof CS?qS:t instanceof Date?ZS:YS(t)?JS:Array.isArray(t)?XS:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?$S:QS)(e,t)}function oC(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var sC=180/Math.PI,cC={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function lC(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)*sC,skewX:Math.atan(c)*sC,scaleX:o,scaleY:s}}var uC;function dC(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?cC:lC(t.a,t.b,t.c,t.d,t.e,t.f)}function fC(e){return e==null||(uC||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),uC.setAttribute(`transform`,e),!(e=uC.transform.baseVal.consolidate()))?cC:(e=e.matrix,lC(e.a,e.b,e.c,e.d,e.e,e.f))}function pC(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:QS(e,i)},{i:c-2,x:QS(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:QS(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:QS(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:QS(e,n)},{i:s-2,x:QS(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 mC=pC(dC,`px, `,`px)`,`deg)`),hC=pC(fC,`, `,`)`,`)`),gC=0,_C=0,vC=0,yC=1e3,bC,xC,SC=0,CC=0,wC=0,TC=typeof performance==`object`&&performance.now?performance:Date,EC=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function DC(){return CC||=(EC(OC),TC.now()+wC)}function OC(){CC=0}function kC(){this._call=this._time=this._next=null}kC.prototype=AC.prototype={constructor:kC,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?DC():+n)+(t==null?0:+t),!this._next&&xC!==this&&(xC?xC._next=this:bC=this,xC=this),this._call=e,this._time=n,FC()},stop:function(){this._call&&(this._call=null,this._time=1/0,FC())}};function AC(e,t,n){var r=new kC;return r.restart(e,t,n),r}function jC(){DC(),++gC;for(var e=bC,t;e;)(t=CC-e._time)>=0&&e._call.call(void 0,t),e=e._next;--gC}function MC(){CC=(SC=TC.now())+wC,gC=_C=0;try{jC()}finally{gC=0,PC(),CC=0}}function NC(){var e=TC.now(),t=e-SC;t>yC&&(wC-=t,SC=e)}function PC(){for(var e,t=bC,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:bC=n);xC=e,FC(r)}function FC(e){gC||(_C&&=clearTimeout(_C),e-CC>24?(e<1/0&&(_C=setTimeout(MC,e-TC.now()-wC)),vC&&=clearInterval(vC)):(vC||=(SC=TC.now(),setInterval(NC,yC)),gC=1,EC(MC)))}function IC(e,t,n){var r=new kC;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var LC=$y(`start`,`end`,`cancel`,`interrupt`),RC=[];function zC(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;UC(e,n,{name:t,index:r,group:i,on:LC,tween:RC,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function BC(e,t){var n=HC(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function VC(e,t){var n=HC(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function HC(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function UC(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=AC(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 IC(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(IC(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 WC(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 GC(e){return this.each(function(){WC(this,e)})}function KC(e,t){var n,r;return function(){var i=VC(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 qC(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=VC(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 JC(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=HC(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?KC:qC)(n,e,t))}function YC(e,t,n){var r=e._id;return e.each(function(){var e=VC(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return HC(e,r).value[t]}}function XC(e,t){var n;return(typeof t==`number`?QS:t instanceof CS?qS:(n=CS(t))?(t=n,qS):iC)(e,t)}function ZC(e){return function(){this.removeAttribute(e)}}function QC(e){return function(){this.removeAttributeNS(e.space,e.local)}}function $C(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 ew(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 tw(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 nw(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 rw(e,t){var n=ab(e),r=n===`transform`?hC:XC;return this.attrTween(e,typeof t==`function`?(n.local?nw:tw)(n,r,YC(this,`attr.`+e,t)):t==null?(n.local?QC:ZC)(n):(n.local?ew:$C)(n,r,t))}function iw(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function aw(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ow(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&aw(e,i)),n}return i._value=t,i}function sw(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&iw(e,i)),n}return i._value=t,i}function cw(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=ab(e);return this.tween(n,(r.local?ow:sw)(r,t))}function lw(e,t){return function(){BC(this,e).delay=+t.apply(this,arguments)}}function uw(e,t){return t=+t,function(){BC(this,e).delay=t}}function dw(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?lw:uw)(t,e)):HC(this.node(),t).delay}function fw(e,t){return function(){VC(this,e).duration=+t.apply(this,arguments)}}function pw(e,t){return t=+t,function(){VC(this,e).duration=t}}function mw(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?fw:pw)(t,e)):HC(this.node(),t).duration}function hw(e,t){if(typeof t!=`function`)throw Error();return function(){VC(this,e).ease=t}}function gw(e){var t=this._id;return arguments.length?this.each(hw(t,e)):HC(this.node(),t).ease}function _w(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();VC(this,e).ease=n}}function vw(e){if(typeof e!=`function`)throw Error();return this.each(_w(this._id,e))}function yw(e){typeof e!=`function`&&(e=_b(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 Jw(r,this._parents,this._name,this._id)}function bw(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 Jw(o,this._parents,this._name,this._id)}function xw(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 Sw(e,t,n){var r,i,a=xw(t)?BC:VC;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Cw(e,t){var n=this._id;return arguments.length<2?HC(this.node(),n).on.on(e):this.each(Sw(n,e,t))}function ww(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Tw(){return this.on(`end.remove`,ww(this._id))}function Ew(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=ub(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,zC(l[f],t,n,f,l,HC(u,n)));return new Jw(a,this._parents,t,n)}function Dw(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=mb(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=HC(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&zC(p,t,n,h,f,m);a.push(f),o.push(u)}return new Jw(a,o,t,n)}var Ow=eS.prototype.constructor;function kw(){return new Ow(this._groups,this._parents)}function Aw(e,t){var n,r,i;return function(){var a=sx(this,e),o=(this.style.removeProperty(e),sx(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function jw(e){return function(){this.style.removeProperty(e)}}function Mw(e,t,n){var r,i=n+``,a;return function(){var o=sx(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Nw(e,t,n){var r,i,a;return function(){var o=sx(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),sx(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Pw(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=VC(this,e),l=c.on,u=c.value[a]==null?s||=jw(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Fw(e,t,n){var r=(e+=``)==`transform`?mC:XC;return t==null?this.styleTween(e,Aw(e,r)).on(`end.style.`+e,jw(e)):typeof t==`function`?this.styleTween(e,Nw(e,r,YC(this,`style.`+e,t))).each(Pw(this._id,e)):this.styleTween(e,Mw(e,r,t),n).on(`end.style.`+e,null)}function Iw(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Lw(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Iw(e,a,n)),r}return a._value=t,a}function Rw(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,Lw(e,t,n??``))}function zw(e){return function(){this.textContent=e}}function Bw(e){return function(){var t=e(this);this.textContent=t??``}}function Vw(e){return this.tween(`text`,typeof e==`function`?Bw(YC(this,`text`,e)):zw(e==null?``:e+``))}function Hw(e){return function(t){this.textContent=e.call(this,t)}}function Uw(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Hw(r)),t}return r._value=e,r}function Ww(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,Uw(e))}function Gw(){for(var e=this._name,t=this._id,n=Xw(),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=HC(c,t);zC(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Jw(r,this._parents,e,n)}function Kw(){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=VC(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 qw=0;function Jw(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Yw(e){return eS().transition(e)}function Xw(){return++qw}var Zw=eS.prototype;Jw.prototype=Yw.prototype={constructor:Jw,select:Ew,selectAll:Dw,selectChild:Zw.selectChild,selectChildren:Zw.selectChildren,filter:yw,merge:bw,selection:kw,transition:Gw,call:Zw.call,nodes:Zw.nodes,node:Zw.node,size:Zw.size,empty:Zw.empty,each:Zw.each,on:Cw,attr:rw,attrTween:cw,style:Fw,styleTween:Rw,text:Vw,textTween:Ww,remove:Tw,tween:JC,delay:dw,duration:mw,ease:gw,easeVarying:vw,end:Kw,[Symbol.iterator]:Zw[Symbol.iterator]};function Qw(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var $w={time:null,delay:0,duration:250,ease:Qw};function eT(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function tT(e){var t,n;e instanceof Jw?(t=e._id,e=e._name):(t=Xw(),(n=$w).time=DC(),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])&&zC(c,e,t,l,o,n||eT(c,t));return new Jw(r,this._parents,e,t)}eS.prototype.interrupt=GC,eS.prototype.transition=tT;var{abs:nT,max:rT,min:iT}=Math;[`w`,`e`].map(aT),[`n`,`s`].map(aT),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(aT);function aT(e){return{type:e}}var oT=Math.PI,sT=2*oT,cT=1e-6,lT=sT-cT;function uT(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function dT(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return uT;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 fT=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?uT:dT(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>cT)if(!(Math.abs(u*s-c*l)>cT)||!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((oT-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>cT&&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)>cT||Math.abs(this._y1-l)>cT)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%sT+sT),d>lT?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>cT&&this._append`A${n},${n},0,${+(d>=oT)},${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._}};function pT(){return new fT}pT.prototype=fT.prototype;function mT(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function hT(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 gT(e){return e=hT(Math.abs(e)),e?e[1]:NaN}function _T(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 vT(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var yT=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function bT(e){if(!(t=yT.exec(e)))throw Error(`invalid format: `+e);var t;return new xT({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]})}bT.prototype=xT.prototype;function xT(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+``}xT.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 ST(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);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var CT;function wT(e,t){var n=hT(e,t);if(!n)return CT=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(CT=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`)+hT(e,Math.max(0,t+a-1))[0]}function TT(e,t){var n=hT(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 ET={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:mT,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)=>TT(e*100,t),r:TT,s:wT,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function DT(e){return e}var OT=Array.prototype.map,kT=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function AT(e){var t=e.grouping===void 0||e.thousands===void 0?DT:_T(OT.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?DT:vT(OT.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=bT(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`):ET[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=ET[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=ST(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&CT!==void 0?kT[8+CT/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;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(gT(t)/3)))*3,r=10**-n,i=l((e=bT(e),e.type=`f`,e),{suffix:kT[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var jT,MT,NT;PT({thousands:`,`,grouping:[3],currency:[`$`,``]});function PT(e){return jT=AT(e),MT=jT.format,NT=jT.formatPrefix,jT}function FT(e){return Math.max(0,-gT(Math.abs(e)))}function IT(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(gT(t)/3)))*3-gT(Math.abs(e)))}function LT(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,gT(t)-gT(e))+1}function RT(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 zT(){return this.eachAfter(RT)}function BT(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}function VT(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 HT(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 UT(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}function WT(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 GT(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function KT(e){for(var t=this,n=qT(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 qT(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 JT(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function YT(){return Array.from(this)}function XT(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function ZT(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*QT(){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 $T(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=nE)):t===void 0&&(t=tE);for(var n=new aE(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 aE(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(iE)}function eE(){return $T(this).eachBefore(rE)}function tE(e){return e.children}function nE(e){return Array.isArray(e)?e[1]:null}function rE(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function iE(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function aE(e){this.data=e,this.depth=this.height=0,this.parent=null}aE.prototype=$T.prototype={constructor:aE,count:zT,each:BT,eachAfter:HT,eachBefore:VT,find:UT,sum:WT,sort:GT,path:KT,ancestors:JT,descendants:YT,leaves:XT,links:ZT,copy:eE,[Symbol.iterator]:QT};function oE(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 sE(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 cE(){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(oE),i}function a(e,t){return function(r){r.children&&sE(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 lE(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}var uE=Symbol(`implicit`);function dE(){var e=new Ty,t=[],n=[],r=uE;function i(i){let a=e.get(i);if(a===void 0){if(r!==uE)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 Ty;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 dE(t,n).unknown(r)},lE.apply(i,arguments),i}function fE(){var e=dE().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=Ry(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 fE(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},lE.apply(d(),arguments)}function pE(e){return function(){return e}}function mE(e){return+e}var hE=[0,1];function gE(e){return e}function _E(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:pE(isNaN(t)?NaN:.5)}function vE(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function yE(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=_E(i,r),a=n(o,a)):(r=_E(r,i),a=n(a,o)),function(e){return a(r(e))}}function bE(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]=_E(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=wy(e,t,1,r)-1;return a[n](i[n](t))}}function xE(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function SE(){var e=hE,t=hE,n=aC,r,i,a,o=gE,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==gE&&(o=vE(e[0],e[n-1])),s=n>2?bE:yE,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),QS))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,mE),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=oC,u()},d.clamp=function(e){return arguments.length?(o=e?!0:gE,u()):o!==gE},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 CE(){return SE()(gE,gE)}function wE(e,t,n,r){var i=Iy(e,t,n),a;switch(r=bT(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=IT(i,o))&&(r.precision=a),NT(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=LT(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=FT(i))&&(r.precision=a-(r.type===`%`)*2);break}return MT(r)}function TE(e){var t=e.domain;return e.ticks=function(e){var n=t();return Py(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return wE(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=Fy(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 EE(){var e=CE();return e.copy=function(){return xE(e,EE())},lE.apply(e,arguments),TE(e)}function DE(e){return function(){return e}}var OE=Math.abs,kE=Math.atan2,AE=Math.cos,jE=Math.max,ME=Math.min,NE=Math.sin,PE=Math.sqrt,FE=Math.PI,IE=FE/2,LE=2*FE;function RE(e){return e>1?0:e<-1?FE:Math.acos(e)}function zE(e){return e>=1?IE:e<=-1?-IE:Math.asin(e)}function BE(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 fT(t)}function VE(e){return e.innerRadius}function HE(e){return e.outerRadius}function UE(e){return e.startAngle}function WE(e){return e.endAngle}function GE(e){return e&&e.padAngle}function KE(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 qE(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/PE(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)*PE(jE(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 JE(){var e=VE,t=HE,n=DE(0),r=null,i=UE,a=WE,o=GE,s=null,c=BE(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-IE,m=a.apply(this,arguments)-IE,h=OE(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>LE-1e-12)s.moveTo(f*AE(p),f*NE(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*AE(m),d*NE(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):PE(d*d+f*f)),T=ME(OE(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=zE(w/d*NE(C)),j=zE(w/f*NE(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*AE(_),N=f*NE(_),P=d*AE(b),F=d*NE(b);if(T>1e-12){var I=f*AE(v),L=f*NE(v),R=d*AE(y),z=d*NE(y),B;if(h<FE)if(B=KE(M,N,R,z,I,L,P,F)){var ee=M-B[0],te=N-B[1],ne=I-B[0],V=L-B[1],re=1/NE(RE((ee*ne+te*V)/(PE(ee*ee+te*te)*PE(ne*ne+V*V)))/2),ie=PE(B[0]*B[0]+B[1]*B[1]);E=ME(T,(d-ie)/(re-1)),D=ME(T,(f-ie)/(re+1))}else E=D=0}S>1e-12?D>1e-12?(O=qE(R,z,M,N,f,D,g),k=qE(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,kE(O.y01,O.x01),kE(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,D,kE(O.y01,O.x01),kE(O.y11,O.x11),!g),s.arc(0,0,f,kE(O.cy+O.y11,O.cx+O.x11),kE(k.cy+k.y11,k.cx+k.x11),!g),s.arc(k.cx,k.cy,D,kE(k.y11,k.x11),kE(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=qE(P,F,I,L,d,-E,g),k=qE(M,N,R,z,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),E<T?s.arc(O.cx,O.cy,E,kE(O.y01,O.x01),kE(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,E,kE(O.y01,O.x01),kE(O.y11,O.x11),!g),s.arc(0,0,d,kE(O.cy+O.y11,O.cx+O.x11),kE(k.cy+k.y11,k.cx+k.x11),g),s.arc(k.cx,k.cy,E,kE(k.y11,k.x11),kE(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-FE/2;return[AE(r)*n,NE(r)*n]},l.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:DE(+t),l):e},l.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:DE(+e),l):t},l.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:DE(+e),l):n},l.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:DE(+e),l):r},l.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:DE(+e),l):i},l.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:DE(+e),l):a},l.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:DE(+e),l):o},l.context=function(e){return arguments.length?(s=e??null,l):s},l}function YE(e,t,n){this.k=e,this.x=t,this.y=n}YE.prototype={constructor:YE,scale:function(e){return e===1?this:new YE(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new YE(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 XE=new YE(1,0,0);ZE.prototype=YE.prototype;function ZE(e){for(;!e.__zoom;)if(!(e=e.parentNode))return XE;return e.__zoom}function QE(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{WILDCARD:$E,QUALIFIER:eD,LUCKY_LOSER:tD}=t.entryStatusConstants,nD=`text-anchor`,rD=`dominant-baseline`,iD=`fill-opacity`,aD=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 oD(e){let t=Math.floor(e.length/2),n=e.slice(0,t),r=e.slice(t).reverse();return[...n,...r]}function sD(e){if(e)switch(e){case $E:return`WC`;case eD:return`Q`;case tD:return`LL`;default:return e}}function cD(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:sD(e.entryStatus),nationalityCode:e.nationalityCode,matchUp:r,depth:t,value:1})}return n}function lD(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 uD(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}=lD(e,r);return{name:s||``,participantName:s,drawPosition:l?.drawPosition??c?.drawPosition,seedNumber:c?.seedNumber??l?.seedNumber,entryStatus:sD(c?.entryStatus)??l?.entryStatus,nationalityCode:c?.nationalityCode??l?.nationalityCode,scoreString:e.scoreString,matchUpStatus:e.matchUpStatus,matchUp:e,depth:n,children:o.length>0?o:void 0}})}function dD(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=oD(cD(r,n.length)),a=new Map;for(let e of i)e.participantName&&e.participantName!==`BYE`&&a.set(e.participantName,e);let o=uD(oD(r),i,n.length-1,a);for(let e=1;e<n.length;e++)o=uD(oD(t[n[e]]),o,n.length-1-e,a);return o.length===1?o[0]:{name:`Tournament`,depth:0,children:o}}function fD(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=EE().domain([1,32]).range([`0`,`1`]);o=EE().domain(Ry(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=EE().domain(Ry(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=EE().domain(Ry(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),fD(n,t)})}function pD(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 mD(e,t){let n=e.find(e=>e.data.participantName&&e.data.participantName!==t);return n?.data.participantName?n.data:void 0}function hD(e,t){let n=[e.participantName],r;if(t.children&&t.children.length>0)e.scoreString&&n.push(e.scoreString),r=mD(t.children,e.participantName),r&&n.push(r.participantName);else{let r=pD(e,t.depth);r&&n.push(r)}return{messageLines:n,opponentData:r}}function gD(e,t){return-(e*t/2)+t/2}function _D(e,t,n){let r=nS(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 vD(e,t,n,r,i){let a=e.append(`text`).attr(`x`,t/2).attr(`y`,n/2).attr(nD,`middle`).attr(rD,`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(nD,`middle`).attr(rD,`middle`).attr(`font-size`,`${i}px`).style(`fill`,`var(--chc-text-secondary, #666)`).attr(`pointer-events`,`none`)}}function yD(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(nD,`middle`).attr(rD,`middle`).attr(`transform`,`translate(0, ${r*a})`).text(CD(n)))}function bD(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}))),p=dD(n),m=$T(p,e=>e.children).sum(e=>e.value||0),h=Math.min(a,o)/2,g=h/2,_=e=>e*h/200;cE().size([2*Math.PI,h-g])(m),fD(p,EE().domain([0,n.drawSize||128]).range([0,1]));let v=m.descendants(),y=JE().startAngle(e=>e.x0).endAngle(e=>e.x1).innerRadius(e=>e.y0+g).outerRadius(e=>e.y1+g),{svg:b,g:x,flagsGroup:S,winningFlagsGroup:C,losingFlagsGroup:w}=_D(e,a,o),T=new Set,E=e=>{e.nationalityCode&&T.add(e.nationalityCode),e.children&&e.children.forEach(E)};E(p);let D=Array.from(T),{centerText:O,centerText2:k}=vD(b,a,o,c,l);function A(){let e=QE(d,15);O.text(``),O.selectAll(`tspan`).remove(),k.text(``),k.selectAll(`tspan`).remove(),O.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;O.attr(`y`,o/2+t),O.style(`display`,`block`),k.style(`display`,`none`)}function j(){if(S.selectAll(`text`).remove(),C.selectAll(`text`).remove(),w.selectAll(`text`).remove(),D.length===0)return;let e=EE().domain([0,D.length]).range([0,Math.PI*2]),t=_(20),n=g-t+10;S.selectAll(`text`).data(D).join(`text`).attr(`font-size`,`${t}px`).attr(nD,`middle`).attr(rD,`middle`).attr(`transform`,(t,r)=>{let i=e(r);return`translate(${Math.cos(i)*n}, ${Math.sin(i)*n})`}).text(e=>CD(e)).style(`cursor`,`pointer`).on(`mouseover`,function(e,t){let n=f[t]||t;O.selectAll(`tspan`).remove(),O.attr(`y`,o/2),O.text(n).style(`display`,`block`),k.selectAll(`tspan`).remove(),k.text(``).style(`display`,`none`),N||x.selectAll(`path`).attr(iD,e=>e.data.nationalityCode===t?.9:.3)}).on(`mouseout`,function(){N||x.selectAll(`path`).attr(iD,.8),A()})}j(),A();let M=i.eventHandlers?.clickCenter;M&&x.insert(`circle`,`:first-child`).attr(`r`,g).attr(`fill`,`transparent`).style(`cursor`,`pointer`).on(`click`,M);let N=!1,P;function F(e,t){let n=t.data;if(n.participantName){let{messageLines:e,opponentData:r}=hD(n,t);r&&(n.opponent=r),O.selectAll(`tspan`).remove(),O.text(``),O.selectAll(`tspan`).data(e).join(`tspan`).attr(`x`,a/2).attr(`dy`,(e,t)=>t===0?0:u).text(e=>e);let i=gD(e.length,u);O.attr(`y`,o/2+i),O.style(`display`,`block`),k.style(`display`,`none`)}N?n.participantName?.toLowerCase()!==P?.toLowerCase()&&nS(e.currentTarget).attr(iD,.9):x.selectAll(`path`).attr(iD,e=>e.data.participantName===t.data.participantName?.9:.3);let r=_(30),i=g-r-10,s={flagsGroup:S,winningFlagsGroup:C,losingFlagsGroup:w};yD(C,s,n.nationalityCode,-1,!0,i,r),n.opponent&&yD(w,s,n.opponent.nationalityCode,1,!1,i,r)}function I(e,t){if(N){let n=t.data.participantName?.toLowerCase()===P?.toLowerCase();nS(e.currentTarget).attr(iD,n?1:.2)}else x.selectAll(`path`).attr(iD,.8);j(),A()}let L=i.eventHandlers?.clickSegment;function R(e,t){if(!L)return;let n=t.data;L({participantName:n.participantName,drawPosition:n.drawPosition,seedNumber:n.seedNumber,entryStatus:n.entryStatus,nationalityCode:n.nationalityCode,scoreString:n.scoreString,matchUpStatus:n.matchUpStatus,roundName:n.roundName,depth:n.depth,matchUp:n.matchUp})}let z=x.selectAll(`path`).data(v).join(`path`).attr(`d`,e=>y(e)).attr(`fill`,e=>e.data.color||`#ccc`).attr(iD,.8).attr(`stroke`,`#fff`).attr(`stroke-width`,1).on(`mouseover`,F).on(`mouseout`,I);L&&z.style(`cursor`,`pointer`).on(`click`,R),z.append(`title`).text(e=>{let t=e.data;return t.participantName?`${t.participantName}\nDraw: ${t.drawPosition||`N/A`}`:`${t.name}\nDepth: ${e.depth}`});function B(e){let t=0;return N=!!e,P=e,x.selectAll(`path`).attr(iD,n=>e?n.data.participantName?.toLowerCase()===e.toLowerCase()?(t+=1,1):.2:.8),t}function ee(e){b.style(`display`,e?`none`:`block`)}return{highlightPlayer:B,hide:ee}}function xD(e={}){return{render:(t,n,r)=>bD(t,n,r,e)}}function SD(e){return e?.length===2?e&&String.fromCodePoint!==void 0?e.toUpperCase().replaceAll(/./g,e=>String.fromCodePoint((e.codePointAt(0)??0)+127397)):e:``}function CD(e){return SD(aD[e]||e)}var{LUCKY_LOSER:wD,WILDCARD:TD,QUALIFIER:ED}=t.entryStatusConstants;function DD(e){let t={};for(let[n,r]of Object.entries(e.roundMatchUps))t[Number(n)]=r.map(e=>({...e,winningSide:e.winningSide,drawPositions:e.drawPositions||[],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 OD={LL:wD,WC:TD,Q:ED},kD=[`R128`,`R64`,`R32`,`R16`,`QF`,`SF`,`F`];function AD(e){let t=jD(e);if(t.length===0)return{drawSize:0,roundMatchUps:{}};let n=t[0].data,r=n.length,i=MD(n),a=ND(t,e),o={};o[1]=FD(n,a,t);for(let e=1;e<t.length;e++)o[e+1]=ID(e,t,a,i);return{drawSize:r,roundMatchUps:o}}function jD(e){let t=[],n=!1;for(let r of kD){let i=e[r];i&&i.length>0&&(n=!0),n&&i&&i.length>0&&t.push({key:r,data:i})}return t}function MD(e){let t=new Map;return e.forEach((e,n)=>{let r=LD(e.player);r&&r!==`BYE`&&t.set(r,{drawPosition:e.Draw??n+1,country:e.country,seed:e.seed,entry:e.entry})}),t}function ND(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=LD(e.player);t&&a.add(t)}n.set(e[r].key,a)}return n}function PD(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 FD(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=LD(a?.player),c=LD(o?.player),l=s===`BYE`||c===`BYE`,u=PD(s,c,i),d;if(!l&&n.length>1){let e=n[1].data,t=u===1?s:c;d=e.find(e=>LD(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],scoreString:d,sides:[zD(1,a,t+1),zD(2,o,t+2)]})}return r}function ID(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=LD(t?.player),l=LD(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],scoreString:d,sides:[BD(1,t,r),BD(2,n,r)]})}return s}function LD(e){if(!e)return``;let t=e.trim();return t.toUpperCase()===`BYE`?`BYE`:t}function RD(e){if(e)return OD[e.toUpperCase()]||e}function zD(e,t,n){if(!t)return{sideNumber:e,drawPosition:n};let r=LD(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:RD(t.entry)}}function BD(e,t,n){if(!t)return{sideNumber:e,drawPosition:0};let r=LD(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:RD(t.entry||i?.entry)}}var VD=480,HD=200,UD=280,WD={top:12,right:12,bottom:28,left:32},GD={top:12,right:12,bottom:12,left:12},KD=.6,qD=.9,JD=`http://www.w3.org/2000/svg`,YD=`middle`,XD=`text-anchor`,ZD=`dominant-baseline`,QD=[`var(--chc-rating-low, #5b8ff9)`,`var(--chc-rating-high, #00b894)`];function $D(e,t,n){let r=document.createElementNS(JD,`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 eO(e,t,n){return n<=1||t/(n-1)<.5?QD[0]:QD[1]}function tO(e,t,n,r){return r?r(e,t):eO(e,t,n)}function nO(e){return`${e.binStart.toFixed(1)}–${e.binEnd.toFixed(1)}`}function rO(e){let{stats:t,width:n,height:r,margin:i,showAxis:a,showCounts:o,showMean:s,binColor:c,ariaLabel:l}=e,u=$D(n,r,l),d=nS(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=fE().domain(t.histogram.map(nO)).range([0,f]).padding(.12),h=EE().domain([0,Ly(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(nO(e))??0).attr(`y`,e=>h(e.count)).attr(`width`,m.bandwidth()).attr(`height`,e=>p-h(e.count)).attr(`fill`,(e,t)=>tO(e,t,g,c)).append(`title`).text(e=>`${nO(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(nO(e))??0)+m.bandwidth()/2).attr(`y`,e=>h(e.count)-4).attr(XD,YD).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(nO),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(Zy(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 iO(e,t,n,r){return[e+n*Math.sin(r),t-n*Math.cos(r)]}function aO(e,t,n,r,i,a){let[o,s]=iO(e,t,n,i),[c,l]=iO(e,t,n,a),[u,d]=iO(e,t,r,a),[f,p]=iO(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 oO(e){let{stats:t,size:n,margin:r,showCounts:i,binColor:a,ariaLabel:o}=e,s=$D(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*qD,f=c*KD,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(JD,`path`);if(h.setAttribute(`class`,`chc-rdc-slice`),h.setAttribute(`d`,aO(l,u,d,f,o,c)),h.setAttribute(`fill`,tO(n,e,m,a)),s.appendChild(h),i){let e=o+r/2,[t,i]=iO(l,u,(d+f)/2,e),a=document.createElementNS(JD,`text`);a.setAttribute(`class`,`chc-rdc-slice-label`),a.setAttribute(`x`,String(t)),a.setAttribute(`y`,String(i)),a.setAttribute(XD,YD),a.setAttribute(ZD,YD),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(JD,`text`);return h.setAttribute(`class`,`chc-rdc-center-count`),h.setAttribute(`x`,String(l)),h.setAttribute(`y`,String(u)),h.setAttribute(XD,YD),h.setAttribute(ZD,YD),h.setAttribute(`font-size`,`20`),h.setAttribute(`font-weight`,`600`),h.textContent=String(t.count),s.appendChild(h),s}function sO(e,t={}){let n=t.mode??`HISTOGRAM`,r=t.ariaLabel??`Participant rating distribution`;return n===`DONUT`?oO({stats:e,size:t.width??t.height??UD,margin:t.margin??GD,showCounts:t.showCounts??!0,binColor:t.binColor,ariaLabel:r}):rO({stats:e,width:t.width??VD,height:t.height??HD,margin:t.margin??WD,showAxis:t.showAxis??!0,showCounts:t.showCounts??!0,showMean:t.showMean??!0,binColor:t.binColor,ariaLabel:r})}var cO=`right`,lO=`font-medium`;function uO({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===cO&&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`);B(t.onClick)&&(d.onclick=t.onClick),d.style.cssText=`margin-right: 1em`,d.innerHTML=t.label,u.appendChild(d);let f=document.createElement(`span`);B(t.onClick)&&(f.onclick=t.onClick),f.innerHTML=`
|
|
214
|
+
`,`2) content: () => element.cloneNode(true)`].join(` `))}var s=i.reduce(function(e,t){var n=t&&pm(t,r);return n&&e.push(n),e},[]);return Cp(e)?s[0]:s}mm.defaultProps=Zp,mm.setDefaultProps=$p,mm.currentInput=Pp,Object.assign({},Dd,{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)}}),mm.setDefaultProps({render:lm});var hm=`#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(`.`),gm=`notes-toolbar-recent-colors`,_m=8;function vm(){try{return JSON.parse(localStorage.getItem(gm)||`[]`)}catch{return[]}}function ym(e){let t=vm().filter(t=>t!==e);t.unshift(e),t.length>_m&&(t=t.slice(0,_m)),localStorage.setItem(gm,JSON.stringify(t))}function bm(e={}){let t=document.createElement(`div`);return t.className=`notes-toolbar`,t.appendChild(Tm(e)),t.appendChild(Em(e)),t.appendChild(Dm(e)),t.appendChild(jm(e)),t.appendChild(Pm(e)),t.appendChild(Fm(e)),t.appendChild(Lm(e)),t}function xm(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 Sm(e,t){let n=e.querySelector(`[data-action="heading"]`);n&&(n.value=t===!1?`0`:String(t))}function Cm(){let e=document.createElement(`div`);return e.className=`notes-toolbar-group`,e}function wm(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 Tm(e){let t=Cm(),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?!1:t)}),t.appendChild(n),t}function Em(e){let t=Cm();return t.appendChild(wm(`bold`,`<b>B</b>`,`Bold`,e.onBold)),t.appendChild(wm(`italic`,`<i>I</i>`,`Italic`,e.onItalic)),t.appendChild(wm(`underline`,`<u>U</u>`,`Underline`,e.onUnderline)),t.appendChild(wm(`strike`,`<s>S</s>`,`Strikethrough`,e.onStrike)),t}function Dm(e){let t=Cm();return t.appendChild(Om(`color`,`A`,`Text color`,`#000000`,t=>{ym(t),e.onColor?.(t)})),t.appendChild(Om(`background`,`A`,`Background color`,`#ffff00`,t=>{ym(t),e.onBackground?.(t)})),t}function Om(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}c=mm(a,{content:km(r,e=>{s.style.backgroundColor=e,i(e),c?.destroy(),c=void 0}),theme:`light-border`,trigger:`manual`,interactive:!0,placement:`bottom-start`,onHidden:()=>{c?.destroy(),c=void 0}}),c.show()}),a}function km(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 hm)r.appendChild(Am(n,n===e,t));n.appendChild(r);let i=vm();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(Am(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 Am(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 jm(e){let t=Cm();return t.appendChild(wm(`orderedList`,Mm(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(wm(`bulletList`,Mm(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 Mm(e,t,n){return`<svg width="${e}" height="${t}" viewBox="0 0 ${e} ${t}" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}var Nm={alignLeft:Mm(16,16,`<path d="M1 2h14v2H1zm0 4h9v2H1zm0 4h14v2H1zm0 4h9v2H1z" fill="currentColor"/>`),alignCenter:Mm(16,16,`<path d="M1 2h14v2H1zm3.5 4h7v2h-7zM1 10h14v2H1zm3.5 4h7v2h-7z" fill="currentColor"/>`),alignRight:Mm(16,16,`<path d="M1 2h14v2H1zm6 4h8v2H7zM1 10h14v2H1zm6 4h8v2H7z" fill="currentColor"/>`),alignJustify:Mm(16,16,`<path d="M1 2h14v2H1zm0 4h14v2H1zm0 4h14v2H1zm0 4h14v2H1z" fill="currentColor"/>`)};function Pm(e){let t=Cm();return t.appendChild(wm(`alignLeft`,Nm.alignLeft,`Align left`,()=>e.onAlign?.(`left`))),t.appendChild(wm(`alignCenter`,Nm.alignCenter,`Align center`,()=>e.onAlign?.(`center`))),t.appendChild(wm(`alignRight`,Nm.alignRight,`Align right`,()=>e.onAlign?.(`right`))),t.appendChild(wm(`alignJustify`,Nm.alignJustify,`Justify`,()=>e.onAlign?.(`justify`))),t}function Fm(e){let t=Cm();t.appendChild(wm(`blockquote`,`“`,`Blockquote`,e.onBlockquote)),t.appendChild(wm(`codeBlock`,`</>`,`Code block`,e.onCodeBlock));let n=wm(`link`,`⇗`,`Insert link`);Im(n,`Enter URL`,`https://`,t=>e.onLink?.(t)),t.appendChild(n);let r=wm(`video`,`▷`,`Insert video`);return Im(r,`YouTube URL`,`https://youtube.com/...`,t=>e.onVideo?.(t)),t.appendChild(r),t}function Im(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=mm(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 Lm(e){let t=Cm();return t.appendChild(wm(`clearFormatting`,`⊘`,`Clear formatting`,e.onClearFormatting)),t}function Rm(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}=ln(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 zm(e){return typeof e==`function`}var Bm;function Vm(e){Bm&&=(Bm?.destroy(!0),void 0),e?.remove&&e.remove()}function Hm(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;Vm();let l=document.createElement(`div`),u;return s||=i?.evt?.target,s&&(Bm=mm(s,{content:()=>(c=c?.filter(e=>!e.hide&&!e.disabled).map(e=>({...e,onClick:()=>{Vm(l),zm(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?Bm.setContent(`IMPLEMENT SUB MENU`):zm(e.onClick)?(Vm(l),e.onClick()):zm(a)&&a&&(Vm(l),a(typeof e==`object`?{...e,coords:i}:e))}})),u=Rm(l,[{text:t,items:c},...r]).focusElement,l),theme:`light-border`,trigger:`click`,onShown:()=>{u&&setTimeout(()=>u?.focus(),0)},...o}),Bm.show(),Bm.setProps({interactive:!0})),Bm}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 Um(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 Wm(e){let t=Um(`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 Gm(e){let t=Um(`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 Km(e){let t=Um(`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 qm(e){let t=Um(`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 Jm(e){let t=Um(`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 Ym(e){let t=Um(`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 Xm(e){let t=Um(`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 Zm=`COURT_SVG`,Qm={tennis:Wm,basketball:Gm,baseball:Km,hockey:qm,pickleball:Jm,badminton:Ym,padel:Xm},$m={TENNIS:`tennis`,PADEL:`padel`,PICKLEBALL:`pickleball`,BADMINTON:`badminton`},eh={HAL:`basketball`,INN:`baseball`,PER:`hockey`};function th(e){if(e){for(let[t,n]of Object.entries(eh))if(e.startsWith(t))return n;if(e.startsWith(`SET`)||e.startsWith(`T`))return e.includes(`@RALLY`)?`pickleball`:`tennis`}}function nh(e){let t=e?.competitionFormat?.sport;return t&&$m[t]?$m[t]:th(e?.matchUpFormat)}function rh(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 ih(e,t=``){let n=e?Qm[e]:void 0;if(n)return rh(n(t?`court--${e} ${t}`:`court--${e}`))}function ah(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 oh(e){if(!e)return;let t=ah(e);return t.length?t:void 0}function sh(e){let t=e?.find(Boolean);if(!t)return;let n=t.addresses?.find(Boolean);return n?oh(n)??t.venueName:t.venueName}function ch(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function lh(e){return e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}function uh(e,t){if(!e&&!t)return;let n=e?new Date(e):null,r=t?new Date(t):null,i=!!n&&!Number.isNaN(n.getTime()),a=!!r&&!Number.isNaN(r.getTime());if(!(!i&&!a))return i&&a&&n.getTime()===r.getTime()?lh(n):i&&a?n.getFullYear()===r.getFullYear()?`${ch(n)} – ${ch(r)}, ${r.getFullYear()}`:`${lh(n)} – ${lh(r)}`:lh(i?n:r)}var dh=`URL`;function fh(e,t){if(!Array.isArray(e))return;let n=e.find(e=>e?.name===t&&e?.resourceType===dh);return n?.url??n?.identifier}function ph(e,t){if(Array.isArray(e))return e.find(e=>e?.resourceSubType===`COURT_SVG`&&(t?e?.name===t:!0))?.identifier}function mh(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 hh={showImage:!0,cornerBadges:[`status`],body:[`title`,`location`,`dateRange`],footer:[`feeBadge`,`playerCount`]};function gh(e){return e?{showImage:e.showImage??hh.showImage,cornerBadges:e.cornerBadges??hh.cornerBadges,body:e.body??hh.body,footer:e.footer??hh.footer}:hh}var _h=()=>`chc-tc-card`,vh=()=>`chc-tc-card--clickable`,yh=()=>`chc-tc-card--offline`,bh=()=>`chc-tc-image`,xh=()=>`chc-tc-image-img`,Sh=()=>`chc-tc-image-svg`,Ch=()=>`chc-tc-image-placeholder`,wh=()=>`chc-tc-corner-badges`,Th=()=>`chc-tc-status-pill`,Eh=()=>`chc-tc-offline-badge`,Dh=()=>`chc-tc-body`,Oh=()=>`chc-tc-title`,kh=()=>`chc-tc-location`,Ah=()=>`chc-tc-date-range`,jh=()=>`chc-tc-organizer`,Mh=()=>`chc-tc-updated-at`,Nh=()=>`chc-tc-footer`,Ph=()=>`chc-tc-fee-badge`,Fh=()=>`chc-tc-player-count`,Ih=()=>`chc-tc-event-count`,Lh=()=>`chc-tc-card chc-tc-skeleton`,Rh=()=>`chc-tc-skeleton-line`,zh=()=>`chc-tc-skeleton-block`;function Bh(e,t,n){let r=gh(t),i=document.createElement(`div`);return i.className=_h(),i.dataset.tournamentId=e.tournamentId,e.offline&&i.classList.add(yh()),n?.onClick&&(i.classList.add(vh()),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(Vh(e,r)),r.body.length&&i.appendChild(Kh(e,r)),r.footer.length&&i.appendChild($h(e,r)),i}function Vh(e,t){let n=document.createElement(`div`);if(n.className=bh(),e.tournamentImageURL){let t=document.createElement(`img`);t.className=xh(),t.src=e.tournamentImageURL,t.alt=e.tournamentName||``,t.loading=`lazy`,t.addEventListener(`error`,()=>Uh(n,e)),n.appendChild(t)}else Hh(n,e);if(t.cornerBadges.length){let r=Wh(e,t.cornerBadges);r&&n.appendChild(r)}return n}function Hh(e,t){let n=ih(t.courtSvgSport,Sh());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=Ch(),e.appendChild(r)}function Uh(e,t){e.querySelector(`.${xh()}`)?.remove(),Hh(e,t)}function Wh(e,t){let n=[];for(let r of t){let t=Gh(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=wh();for(let e of n)r.appendChild(e);return r}function Gh(e,t){if(e===`status`){if(!t.status)return null;let e=document.createElement(`div`);return e.className=Th(),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=Eh(),e.textContent=`Offline`,e}return null}function Kh(e,t){let n=document.createElement(`div`);n.className=Dh();for(let r of t.body){let t=qh(r,e);t&&n.appendChild(t)}return n}function qh(e,t){switch(e){case`title`:return Jh(t);case`location`:return Yh(t);case`dateRange`:return Xh(t);case`organizerName`:return Zh(t);case`updatedAt`:return Qh(t);default:return null}}function Jh(e){if(!e.tournamentName)return null;let t=document.createElement(`div`);return t.className=Oh(),t.textContent=e.tournamentName,t.title=e.tournamentName,t}function Yh(e){if(!e.location)return null;let t=document.createElement(`div`);return t.className=kh(),t.textContent=e.location,t.title=e.location,t}function Xh(e){if(!e.dateRangeFormatted)return null;let t=document.createElement(`div`);return t.className=Ah(),t.textContent=e.dateRangeFormatted,t}function Zh(e){if(!e.organizerName)return null;let t=document.createElement(`div`);return t.className=jh(),t.textContent=e.organizerName,t}function Qh(e){if(!e.updatedAt)return null;let t=document.createElement(`div`);t.className=Mh();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 $h(e,t){let n=document.createElement(`div`);n.className=Nh();for(let r of t.footer){let t=eg(r,e);t&&n.appendChild(t)}return n}function eg(e,t){switch(e){case`feeBadge`:return tg(t);case`playerCount`:return ng(t);case`eventCount`:return rg(t);default:return null}}function tg(e){if(!e.feeFormatted)return null;let t=document.createElement(`div`);return t.className=Ph(),t.textContent=e.feeFormatted,t}function ng(e){if(typeof e.participantCount!=`number`)return null;let t=document.createElement(`div`);return t.className=Fh(),t.textContent=`${e.participantCount} ${e.participantCount===1?`player`:`players`}`,t}function rg(e){if(typeof e.eventCount!=`number`)return null;let t=document.createElement(`div`);return t.className=Ih(),t.textContent=`${e.eventCount} ${e.eventCount===1?`event`:`events`}`,t}function ig(e){let t=gh(e);return mh({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:Lh(),imageClass:bh(),bodyClass:Dh(),footerClass:Nh(),blockClass:zh(),lineClass:Rh()})}var ag=10080*60*1e3;function og(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function sg(e,t,n){return!t||!n?!1:t.getTime()<=e.getTime()&&e.getTime()<=n.getTime()}function cg(e){return`Opens ${e.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}`}function lg(e,t=new Date){let n=e.tournamentStatus?.toUpperCase();if(n===`CANCELLED`||n===`ABANDONDED`||n===`ABANDONED`)return{kind:`cancelled`,label:`Cancelled`};let r=og(e.endDate);if(n===`COMPLETED`||r&&t.getTime()>r.getTime())return{kind:`completed`,label:`Completed`};if(sg(t,og(e.startDate),r))return{kind:`live`,label:`Live`};let i=og(e.entriesClose);if(i){let e=i.getTime()-t.getTime();if(e>0&&e<=ag)return{kind:`closing-soon`,label:`Closing Soon`}}let a=og(e.entriesOpen);return a&&a.getTime()>t.getTime()?{kind:`registration-opens`,label:cg(a)}:null}var ug=`USD`,dg=`–`;function fg(e,t){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}catch{return`$${e.toFixed(2)}`}}function pg(e){let t=new Set;for(let n of e)t.add(n.currencyCode||ug);return[...t]}function mg(e){return[...e].sort((e,t)=>e.amount-t.amount).find(Boolean)}function hg(e){if(!e||e.length===0)return null;let t=e.filter(e=>typeof e.amount==`number`&&!Number.isNaN(e.amount));if(t.length===0)return null;if(t.length===1){let e=t[0],n=e.currencyCode||ug;return`${n} ${fg(e.amount,n)}`}let n=pg(t);if(n.length>1){let e=mg(t);if(!e)return null;let n=e.currencyCode||ug;return`From ${n} ${fg(e.amount,n)}`}let r=n[0],i=t.map(e=>e.amount).sort((e,t)=>e-t),a=i[0],o=i.at(-1)??a;return a===o?`${r} ${fg(a,r)}`:`${r} ${fg(a,r)} ${dg} ${fg(o,r)}`}var gg=`tournamentImage`;function _g(e){let t=e?.registrationProfile?.entryFees;return Array.isArray(t)?t.filter(e=>e&&typeof e.amount==`number`):[]}function vg(e){let t=e?.timeItems;if(Array.isArray(t))return t.find(e=>e?.itemType===`TMX`)?.itemValue?.offline}function yg(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?lg({tournamentStatus:e?.tournamentStatus,startDate:e?.startDate,endDate:e?.endDate,entriesOpen:e?.registrationProfile?.entriesOpen,entriesClose:e?.registrationProfile?.entriesClose},t?.now):t.statusOverride,s=e?.tournamentImageURL??fh(n,gg),c=e?.courtSvgSport??ph(n);return{tournamentId:e?.tournamentId??``,tournamentName:e?.tournamentName??``,startDate:e?.startDate,endDate:e?.endDate,dateRangeFormatted:uh(e?.startDate,e?.endDate),location:sh(r),tournamentImageURL:s,courtSvgSport:c,participantCount:i.length||void 0,eventCount:a.length||void 0,organizerName:e?.tournamentOrganizers?.find?.(Boolean)?.organizerName,status:o,feeFormatted:hg(_g(e)),updatedAt:e?.updatedAt,offline:vg(e)}}var bg={showImage:!0,showMap:!0,cornerBadges:[`primaryBadge`],body:[`title`,`address`,`courtBreakdown`],footer:[`amenityRow`]};function xg(e){return e?{showImage:e.showImage??bg.showImage,showMap:e.showMap??bg.showMap,cornerBadges:e.cornerBadges??bg.cornerBadges,body:e.body??bg.body,footer:e.footer??bg.footer}:bg}var Sg=()=>`chc-vc-card`,Cg=()=>`chc-vc-card--clickable`,wg=()=>`chc-vc-image`,Tg=()=>`chc-vc-image-img`,Eg=()=>`chc-vc-image-svg`,Dg=()=>`chc-vc-image-map`,Og=()=>`chc-vc-image-placeholder`,kg=()=>`chc-vc-corner-badges`,Ag=()=>`chc-vc-primary-badge`,jg=()=>`chc-vc-body`,Mg=()=>`chc-vc-title`,Ng=()=>`chc-vc-address`,Pg=()=>`chc-vc-court-breakdown`,Fg=()=>`chc-vc-footer`,Ig=()=>`chc-vc-amenity-row`,Lg=()=>`chc-vc-amenity`,Rg=()=>`chc-vc-card chc-vc-skeleton`,zg=()=>`chc-vc-skeleton-line`,Bg=()=>`chc-vc-skeleton-block`;function Vg(e,t,n){let r=xg(t),i=document.createElement(`div`);i.className=Sg(),i.dataset.venueId=e.venueId;let a=null;r.showImage!==!1&&(a=Gg(e,r,()=>f()),i.appendChild(a));let o=r.body.length?$g(e,r):null;o&&i.appendChild(o);let s=r.footer.length?r_(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(Cg()),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(Cg()),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 Hg(e){return typeof e.latitude==`number`&&typeof e.longitude==`number`}function Ug(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=Dg(),a.src=i,a.loading=`lazy`,a.title=`Map of ${e.venueName}`,a}function Wg(e,t){let n=ih(t.courtSvgSport,Eg());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=Og(),e.appendChild(r)}function Gg(e,t,n){let r=document.createElement(`div`);if(r.className=wg(),e.venueImageURL){let i=document.createElement(`img`);i.className=Tg(),i.src=e.venueImageURL,i.alt=e.venueName||``,i.loading=`lazy`,i.addEventListener(`error`,()=>{i.remove(),t.showMap!==!1&&Hg(e)?r.appendChild(Ug(e)):Wg(r,e),n?.()}),r.appendChild(i)}else t.showMap!==!1&&Hg(e)?r.appendChild(Ug(e)):Wg(r,e);if(t.cornerBadges.length){let n=qg(e,t.cornerBadges);n&&r.appendChild(n)}return r}function Kg(e,t){if(e===`primaryBadge`){if(!t.isPrimary)return null;let e=document.createElement(`div`);return e.className=Ag(),e.textContent=`Primary`,e}return null}function qg(e,t){let n=[];for(let r of t){let t=Kg(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=kg();for(let e of n)r.appendChild(e);return r}function Jg(e){if(!e.venueName)return null;let t=document.createElement(`div`);return t.className=Mg(),t.textContent=e.venueName,t.title=e.notes?`${e.venueName}\n${e.notes}`:e.venueName,t}function Yg(e){if(!e.addressFormatted)return null;let t=document.createElement(`div`);return t.className=Ng(),t.textContent=e.addressFormatted,t.title=e.addressFormatted,t}function Xg(e){if(!e.courtBreakdown)return null;let t=document.createElement(`div`);return t.className=Pg(),t.textContent=e.courtBreakdown,t}function Zg(e){if(!e.venueAbbreviation)return null;let t=document.createElement(`div`);return t.className=Pg(),t.textContent=e.venueAbbreviation,t}function Qg(e,t){return e===`title`?Jg(t):e===`address`?Yg(t):e===`courtBreakdown`?Xg(t):e===`venueAbbreviation`?Zg(t):null}function $g(e,t){let n=document.createElement(`div`);n.className=jg();for(let r of t.body){let t=Qg(r,e);t&&n.appendChild(t)}return n}function e_(e){let t=document.createElement(`span`);return t.className=Lg(),t.textContent=e,t}function t_(e){let t=[];if(typeof e.courtCount==`number`&&t.push(e_(`${e.courtCount} ${e.courtCount===1?`court`:`courts`}`)),e.indoorCount&&t.push(e_(`${e.indoorCount} indoor`)),e.outdoorCount&&t.push(e_(`${e.outdoorCount} outdoor`)),e.floodlitCount&&t.push(e_(`${e.floodlitCount} lit`)),!t.length)return null;let n=document.createElement(`div`);n.className=Ig();for(let e of t)n.appendChild(e);return n}function n_(e,t){return e===`amenityRow`?t_(t):e===`address`?Yg(t):e===`courtBreakdown`?Xg(t):null}function r_(e,t){let n=document.createElement(`div`);n.className=Fg();for(let r of t.footer){let t=n_(r,e);t&&n.appendChild(t)}return n}function i_(e){let t=xg(e);return mh({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:Rg(),imageClass:wg(),bodyClass:jg(),footerClass:Fg(),blockClass:Bg(),lineClass:zg()})}var a_=`venueImage`;function o_(e){let t=[];return e.indoorOutdoor&&t.push(e.indoorOutdoor.toLowerCase()),e.surfaceCategory&&t.push(e.surfaceCategory.toLowerCase()),t.length?t.join(` `):`court`}function s_(e){if(!e.length)return;let t=new Map;for(let n of e){let e=o_(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 c_(e,t){let n=0;for(let r of e)t(r)&&(n+=1);return n}function l_(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:oh(i),latitude:typeof i?.latitude==`number`?i.latitude:void 0,longitude:typeof i?.longitude==`number`?i.longitude:void 0,courtCount:n.length||void 0,courtBreakdown:s_(n),indoorCount:c_(n,e=>e.indoorOutdoor===`INDOOR`)||void 0,outdoorCount:c_(n,e=>e.indoorOutdoor===`OUTDOOR`)||void 0,floodlitCount:c_(n,e=>!!e.floodlit)||void 0,isPrimary:!!e?.isPrimary,venueImageURL:e?.venueImageURL??fh(r,a_),courtSvgSport:e?.courtSvgSport??ph(r)??t?.sport,notes:e?.notes}}var u_={showImage:!0,cornerBadges:[`indoorOutdoor`,`floodlit`],body:[`title`,`surface`],footer:[`amenityRow`]};function d_(e){return e?{showImage:e.showImage??u_.showImage,cornerBadges:e.cornerBadges??u_.cornerBadges,body:e.body??u_.body,footer:e.footer??u_.footer}:u_}var f_=()=>`chc-cc-card`,p_=()=>`chc-cc-card--clickable`,m_=()=>`chc-cc-image`,h_=()=>`chc-cc-image-svg`,g_=()=>`chc-cc-image-placeholder`,__=()=>`chc-cc-corner-badges`,v_=()=>`chc-cc-indoor-badge`,y_=()=>`chc-cc-floodlit-badge`,b_=()=>`chc-cc-body`,x_=()=>`chc-cc-title`,S_=()=>`chc-cc-surface`,C_=()=>`chc-cc-availability`,w_=()=>`chc-cc-abbr`,T_=()=>`chc-cc-footer`,E_=()=>`chc-cc-amenity-row`,D_=()=>`chc-cc-card chc-cc-skeleton`,O_=()=>`chc-cc-skeleton-line`,k_=()=>`chc-cc-skeleton-block`;function A_(e,t,n){let r=d_(t),i=document.createElement(`div`);return i.className=f_(),i.dataset.courtId=e.courtId,n?.onClick&&(i.classList.add(p_()),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(M_(e,r)),r.body.length&&i.appendChild(H_(e,r)),r.footer.length&&i.appendChild(G_(e,r)),i}function j_(e,t){let n=ih(t.courtSvgSport,h_());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=g_(),e.appendChild(r)}function M_(e,t){let n=document.createElement(`div`);if(n.className=m_(),e.surfaceCategory&&(n.dataset.surface=e.surfaceCategory),j_(n,e),t.cornerBadges.length){let r=I_(e,t.cornerBadges);r&&n.appendChild(r)}return n}function N_(e){if(!e.indoorOutdoor)return null;let t=document.createElement(`div`);return t.className=v_(),t.dataset.kind=e.indoorOutdoor,t.textContent=e.indoorOutdoor===`INDOOR`?`Indoor`:`Outdoor`,t}function P_(e){if(!e.floodlit)return null;let t=document.createElement(`div`);return t.className=y_(),t.textContent=`Lit`,t}function F_(e,t){return e===`indoorOutdoor`?N_(t):e===`floodlit`?P_(t):null}function I_(e,t){let n=[];for(let r of t){let t=F_(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=__();for(let e of n)r.appendChild(e);return r}function L_(e){if(!e.courtName)return null;let t=document.createElement(`div`);return t.className=x_(),t.textContent=e.courtName,t.title=e.notes?`${e.courtName}\n${e.notes}`:e.courtName,t}function R_(e){if(!e.surfaceLabel)return null;let t=document.createElement(`div`);return t.className=S_(),t.textContent=e.surfaceLabel,t}function z_(e){if(!e.availabilitySummary)return null;let t=document.createElement(`div`);return t.className=C_(),t.textContent=e.availabilitySummary,t}function B_(e){if(!e.courtAbbreviation)return null;let t=document.createElement(`div`);return t.className=w_(),t.textContent=e.courtAbbreviation,t}function V_(e,t){return e===`title`?L_(t):e===`surface`?R_(t):e===`availability`?z_(t):e===`abbreviation`?B_(t):null}function H_(e,t){let n=document.createElement(`div`);n.className=b_();for(let r of t.body){let t=V_(r,e);t&&n.appendChild(t)}return n}function U_(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=E_(),n.textContent=t.join(` · `),n}function W_(e,t){return e===`amenityRow`?U_(t):e===`availability`?z_(t):e===`surface`?R_(t):null}function G_(e,t){let n=document.createElement(`div`);n.className=T_();for(let r of t.footer){let t=W_(r,e);t&&n.appendChild(t)}return n}function K_(e){let t=d_(e);return mh({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:D_(),imageClass:m_(),bodyClass:b_(),footerClass:T_(),blockClass:k_(),lineClass:O_()})}var q_=`INDOOR`,J_=`OUTDOOR`,Y_=new Set([`HARD`,`CLAY`,`GRASS`,`ARTIFICIAL`,`CARPET`]);function X_(e){if(!e)return;let t=String(e).toUpperCase();if(t===q_)return q_;if(t===J_)return J_}function Z_(e){let t=e?.surfaceCategory?String(e.surfaceCategory).toUpperCase():void 0;if(t&&Y_.has(t))return t;let n=e?.surfaceType?String(e.surfaceType).toUpperCase():void 0;return n&&Y_.has(n)?n:t}function Q_(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 $_(e,t){let n=X_(e?.indoorOutdoor),r=Z_(e);return{courtId:e?.courtId??``,courtName:e?.courtName??``,courtAbbreviation:e?.courtAbbreviation,surfaceLabel:Q_(n,r),indoorOutdoor:n,surfaceCategory:r,floodlit:!!e?.floodlit,courtSvgSport:t?.sport,notes:e?.notes}}var ev=[`COMPETITIVE`,`ROUTINE`,`DECISIVE`,`WALKOVER`],tv=new Set([`WALKOVER`,`DOUBLE_WALKOVER`,`DEFAULTED`,`DOUBLE_DEFAULT`]);function nv(){return{COMPETITIVE:0,ROUTINE:0,DECISIVE:0,WALKOVER:0}}function rv(e){let t=nv();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&&tv.has(e.matchUpStatus)){t.WALKOVER+=1;continue}let r=e.competitiveProfile?.competitiveness;r&&r!==`WALKOVER`&&ev.includes(r)&&(t[r]+=1)}return t}function iv(e){return ev.reduce((t,n)=>t+e[n],0)}var av={COMPETITIVE:`Competitive`,ROUTINE:`Routine`,DECISIVE:`Decisive`,WALKOVER:`Walkover / Defaulted`};function ov(){let e=document.createElement(`div`);e.className=`chc-cb`;let t={};for(let n of ev){let r=document.createElement(`div`);r.className=`chc-cb__seg`,r.dataset.bucket=n,t[n]=r,e.appendChild(r)}return{element:e,update:n=>{let r=iv(n);if(e.style.display=r>0?`flex`:`none`,r)for(let e of ev){let r=t[e],i=n[e];i===0?(r.style.flex=`0 0 0`,r.style.padding=`0`,r.textContent=``,r.removeAttribute(`title`)):(r.style.flex=`${i} 1 0`,r.style.padding=`0 4px`,r.textContent=String(i),r.title=`${av[e]}: ${i}`)}}}}var sv={COMPETITIVE:`Competitive`,ROUTINE:`Routine`,DECISIVE:`Decisive`,WALKOVER:`Walkover / Defaulted`},cv=`http://www.w3.org/2000/svg`,lv=96,uv=16,dv=lv/2,fv=dv-1,pv=fv-uv;function mv(e,t){return{x:dv+t*Math.cos(e),y:dv+t*Math.sin(e)}}function hv(e,t){let n=mv(e,fv),r=mv(t,fv),i=mv(t,pv),a=mv(e,pv),o=+(t-e>Math.PI);return[`M ${n.x} ${n.y}`,`A ${fv} ${fv} 0 ${o} 1 ${r.x} ${r.y}`,`L ${i.x} ${i.y}`,`A ${pv} ${pv} 0 ${o} 0 ${a.x} ${a.y}`,`Z`].join(` `)}function gv(){let e=mv(-Math.PI/2,fv),t=mv(Math.PI/2,fv),n=mv(-Math.PI/2,pv),r=mv(Math.PI/2,pv);return[`M ${e.x} ${e.y}`,`A ${fv} ${fv} 0 1 1 ${t.x} ${t.y}`,`A ${fv} ${fv} 0 1 1 ${e.x} ${e.y}`,`L ${n.x} ${n.y}`,`A ${pv} ${pv} 0 1 0 ${r.x} ${r.y}`,`A ${pv} ${pv} 0 1 0 ${n.x} ${n.y}`,`Z`].join(` `)}function _v(){let e=document.createElement(`div`);e.className=`chc-cd`;let t=document.createElementNS(cv,`svg`);t.setAttribute(`viewBox`,`0 0 ${lv} ${lv}`),t.setAttribute(`class`,`chc-cd__svg`),t.setAttribute(`role`,`img`);let n={};for(let e of ev){let r=document.createElementNS(cv,`path`);r.setAttribute(`class`,`chc-cd__arc`),r.setAttribute(`data-bucket`,e),t.appendChild(r);let i=document.createElementNS(cv,`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=iv(i);if(e.style.display=a>0?`inline-flex`:`none`,!a)return;let o=ev.filter(e=>i[e]>0),s=-Math.PI/2;for(let e of ev){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`,gv());else{let e=t/a,n=s+e*Math.PI*2;r.setAttribute(`d`,hv(s,n)),s=n}c&&(c.textContent=`${sv[e]}: ${t}`)}r.textContent=String(a),t.setAttribute(`aria-label`,`Competitiveness across ${a} matches`)}}}var vv={cornerBadges:[`status`,`publishedBadge`,`embargoBadge`],body:[`title`,`drawTypeLabel`,`matchUpProgress`],footer:[`drawSize`,`entries`,`matchUpFormat`,`flightNumber`,`ratings`],showVisualization:!1};function yv(e){return e?{cornerBadges:e.cornerBadges??vv.cornerBadges,body:e.body??vv.body,footer:e.footer??vv.footer,showVisualization:e.showVisualization??vv.showVisualization}:vv}var bv=()=>`chc-dc-card`,xv=()=>`chc-dc-card--clickable`,Sv=()=>`chc-dc-corner-badges`,Cv=()=>`chc-dc-status-pill`,wv=()=>`chc-dc-secondary-badge`,Tv=()=>`chc-dc-body`,Ev=()=>`chc-dc-viz`,Dv=()=>`chc-dc-title-row`,Ov=()=>`chc-dc-title`,kv=()=>`chc-dc-draw-type`,Av=()=>`chc-dc-meta`,jv=()=>`chc-dc-footer`,Mv=()=>`chc-dc-chip`,Nv=()=>`chc-dc-progress`,Pv=()=>`chc-dc-progress-bar`,Fv=()=>`chc-dc-progress-fill`,Iv=()=>`chc-dc-card chc-dc-skeleton`,Lv=()=>`chc-dc-skeleton-line`;function Rv(e,t,n){let r=yv(t),i=document.createElement(`div`);if(i.className=bv(),i.dataset.drawId=e.drawId,e.eventId&&(i.dataset.eventId=e.eventId),n?.onClick&&(i.classList.add(xv()),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=Ev(),t.appendChild(e.visualization),i.appendChild(t)}return(r.body.length||r.cornerBadges.length)&&i.appendChild(ty(e,r)),r.footer.length&&i.appendChild(ny(e,r)),i}function zv(e){if(!e.status)return null;let t=document.createElement(`div`);return t.className=Cv(),t.dataset.kind=e.status.kind,t.textContent=e.status.label,t}function Bv(e){if(!e.published)return null;let t=document.createElement(`div`);return t.className=wv(),t.dataset.kind=`published`,t.textContent=`Published`,t}function Vv(e){if(!e.embargoActive)return null;let t=document.createElement(`div`);return t.className=wv(),t.dataset.kind=`embargo`,t.textContent=`Embargo`,t}function Hv(e,t){return e===`status`?zv(t):e===`publishedBadge`?Bv(t):e===`embargoBadge`?Vv(t):null}function Uv(e,t){let n=[];for(let r of t){let t=Hv(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=Sv();for(let e of n)r.appendChild(e);return r}function Wv(e){if(!e.drawName)return null;let t=document.createElement(`div`);return t.className=Ov(),t.textContent=e.drawName,t.title=e.drawName,t}function Gv(e){if(!e.drawTypeLabel)return null;let t=document.createElement(`div`);return t.className=kv(),t.textContent=e.drawTypeLabel,t}function Kv(e){let t=document.createElement(`span`);return t.className=Mv(),t.textContent=e,t}function qv(e){return typeof e.drawSize==`number`?Kv(`Size ${e.drawSize}`):null}function Jv(e){return typeof e.entryCount==`number`?Kv(`${e.entryCount} ${e.entryCount===1?`entry`:`entries`}`):null}function Yv(e){return e.matchUpFormat?Kv(e.matchUpFormat):null}function Xv(e){return typeof e.flightNumber==`number`?Kv(`Flight ${e.flightNumber}`):null}function Zv(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=Av(),n.textContent=t.join(` · `),n}function Qv(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=Nv();let a=document.createElement(`div`);a.className=Av(),a.textContent=`${n}/${t} matches · ${r}%`,i.appendChild(a);let o=document.createElement(`div`);o.className=Pv();let s=document.createElement(`div`);return s.className=Fv(),s.style.right=`${100-r}%`,o.appendChild(s),i.appendChild(o),i}function $v(e,t){return e===`title`?Wv(t):e===`drawTypeLabel`?Gv(t):e===`drawSize`?qv(t):e===`entries`?Jv(t):e===`matchUpFormat`?Yv(t):e===`flightNumber`?Xv(t):e===`ratings`?Zv(t):e===`matchUpProgress`?Qv(t):null}function ey(e,t){let n=document.createElement(`div`);n.className=Dv();let r=Wv(e);r&&n.appendChild(r);let i=Uv(e,t);return i&&n.appendChild(i),n}function ty(e,t){let n=document.createElement(`div`);n.className=Tv();let r=t.body.includes(`title`),i=t.cornerBadges.length>0;if(i&&!r){let r=Uv(e,t.cornerBadges);r&&n.appendChild(r)}for(let r of t.body){if(r===`title`&&i){n.appendChild(ey(e,t.cornerBadges));continue}let a=$v(r,e);a&&n.appendChild(a)}return n}function ny(e,t){let n=document.createElement(`div`);n.className=jv();for(let r of t.footer){let t=$v(r,e);t&&n.appendChild(t)}return n}function ry(){let e=document.createElement(`div`);e.className=Iv();let t=document.createElement(`div`);t.className=Tv();for(let e of[`70%`,`40%`,`85%`]){let n=document.createElement(`div`);n.className=Lv(),n.style.width=e,t.appendChild(n)}return e.appendChild(t),e}var iy={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 ay(e){if(e)return iy[e]?iy[e]:e.toLowerCase().split(`_`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function oy(e){let t=0,n=0,r=0,i=0;for(let a of e?.structures??[])for(let e of a?.matchUps??[])t+=1,e?.winningSide?n+=1:e?.schedule?.scheduledTime&&(r+=1),e?.matchUpStatus===`IN_PROGRESS`&&(i+=1);return{total:t,completed:n,scheduled:r,inProgress:i}}function sy(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 cy(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 ly(e,t){let n=Array.isArray(e?.structures)&&e.structures.length>0,r=t?.matchUpStats??(t?.lightMode||!n?void 0:oy(e)),i=e?.drawStatus===`CANCELLED`,a=t?.statusOverride===void 0?cy({generated:n,cancelled:i,matchUpCounts:r}):t.statusOverride;return{drawId:e?.drawId??``,drawName:e?.drawName??``,drawType:e?.drawType,drawTypeLabel:ay(e?.drawType),drawSize:sy(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 uy={showImage:!0,cornerBadges:[`status`,`eventTypeBadge`],body:[`title`,`categoryLabel`,`drawSummary`],footer:[`playerCount`,`matchUpProgress`]},dy=15;function fy(e){return e?{showImage:e.showImage??uy.showImage,cornerBadges:e.cornerBadges??uy.cornerBadges,body:e.body??uy.body,footer:e.footer??uy.footer}:uy}var py=()=>`chc-ec-card`,my=()=>`chc-ec-card--clickable`,hy=()=>`chc-ec-image`,gy=()=>`chc-ec-image-img`,_y=()=>`chc-ec-image-svg`,vy=()=>`chc-ec-image-placeholder`,yy=()=>`chc-ec-corner-badges`,by=()=>`chc-ec-status-pill`,xy=()=>`chc-ec-eventtype-badge`,Sy=()=>`chc-ec-gender-badge`,Cy=()=>`chc-ec-body`,wy=()=>`chc-ec-title`,Ty=()=>`chc-ec-category`,Ey=()=>`chc-ec-draw-summary`,Dy=()=>`chc-ec-date-range`,Oy=()=>`chc-ec-footer`,ky=()=>`chc-ec-player-count`,Ay=()=>`chc-ec-matchup-progress`,jy=()=>`chc-ec-updated-at`,My=()=>`chc-ec-card chc-ec-skeleton`,Ny=()=>`chc-ec-skeleton-line`,Py=()=>`chc-ec-skeleton-block`;function Fy(e,t,n){let r=fy(t),i=document.createElement(`div`);return i.className=py(),i.dataset.eventId=e.eventId,n?.onClick&&(i.classList.add(my()),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(Ly(e,r)),r.body.length&&i.appendChild(Zy(e,r)),r.footer.length&&i.appendChild(Qy(e,r)),i}function Iy(e,t){let n=ih(t.courtSvgSport,_y());if(n){e.appendChild(n);return}let r=document.createElement(`div`);r.className=vy(),e.appendChild(r)}function Ly(e,t){let n=document.createElement(`div`);if(n.className=hy(),e.eventImageURL){let t=document.createElement(`img`);t.className=gy(),t.src=e.eventImageURL,t.alt=e.eventName||``,t.loading=`lazy`,t.addEventListener(`error`,()=>{t.remove(),Iy(n,e)}),n.appendChild(t)}else Iy(n,e);if(t.cornerBadges.length){let r=Hy(e,t.cornerBadges);r&&n.appendChild(r)}return n}function Ry(e){if(!e.status)return null;let t=document.createElement(`div`);return t.className=by(),t.dataset.kind=e.status.kind,t.textContent=e.status.label,t}function zy(e){if(!e.eventType)return null;let t=document.createElement(`div`);return t.className=xy(),t.dataset.kind=e.eventType,t.textContent=e.eventType,t}function By(e){if(!e.gender)return null;let t=document.createElement(`div`);return t.className=Sy(),t.dataset.kind=e.gender,t.textContent=e.gender===`MALE`?`M`:e.gender===`FEMALE`?`W`:`X`,t}function Vy(e,t){return e===`status`?Ry(t):e===`eventTypeBadge`?zy(t):e===`genderBadge`?By(t):null}function Hy(e,t){let n=[];for(let r of t){let t=Vy(r,e);t&&n.push(t)}if(!n.length)return null;let r=document.createElement(`div`);r.className=yy();for(let e of n)r.appendChild(e);return r}function Uy(e){if(!e.eventName)return null;let t=document.createElement(`div`);return t.className=wy(),t.textContent=e.eventName,t.title=e.eventName,t}function Wy(e){if(!e.categoryLabel)return null;let t=document.createElement(`div`);return t.className=Ty(),t.textContent=e.categoryLabel,t}function Gy(e){if(!e.drawSummary)return null;let t=document.createElement(`div`);return t.className=Ey(),t.textContent=e.drawSummary,t}function Ky(e){if(!e.dateRangeFormatted)return null;let t=document.createElement(`div`);return t.className=Dy(),t.textContent=e.dateRangeFormatted,t}function qy(e){if(!e.updatedAt)return null;let t=document.createElement(`div`);t.className=jy();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 Jy(e){if(typeof e.entryCount!=`number`)return null;let t=document.createElement(`div`);return t.className=ky(),t.textContent=`${e.entryCount} ${e.entryCount===1?`player`:`players`}`,t}function Yy(e){if(!e.matchUpCounts||e.matchUpCounts.total===0)return null;let{total:t,completed:n}=e.matchUpCounts,r=document.createElement(`div`);return r.className=Ay(),r.textContent=`${n}/${t} matches`,r}function Xy(e,t){return e===`title`?Uy(t):e===`categoryLabel`?Wy(t):e===`drawSummary`?Gy(t):e===`dateRange`?Ky(t):e===`updatedAt`?qy(t):e===`playerCount`?Jy(t):e===`matchUpProgress`?Yy(t):null}function Zy(e,t){let n=document.createElement(`div`);n.className=Cy();for(let r of t.body){let t=Xy(r,e);t&&n.appendChild(t)}return n}function Qy(e,t){let n=document.createElement(`div`);n.className=Oy();for(let r of t.footer){let t=Xy(r,e);t&&n.appendChild(t)}return n}function $y(e){let t=fy(e);return mh({showImage:t.showImage!==!1,bodyLines:t.body.length,showFooter:t.footer.length>0,cardClass:My(),imageClass:hy(),bodyClass:Cy(),footerClass:Oy(),blockClass:Py(),lineClass:Ny()})}function eb(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function tb(e,t,n){return!t||!n?!1:t.getTime()<=e.getTime()&&e.getTime()<=n.getTime()}function nb(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=eb(e.startDate),i=eb(e.endDate);if(n&&(n.inProgress>0||tb(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 rb=`eventImage`,ib=`DRAFT_STATE`;function ab(e){if(!e)return;let t=String(e).toUpperCase();if(t===`SINGLES`||t===`DOUBLES`||t===`TEAM`||t===`HYBRID`)return t}function ob(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 sb(e){if(e){if(e.categoryName)return e.categoryName;if(typeof e.ageMin==`number`&&typeof e.ageMax==`number`)return e.ageMin===e.ageMax?`Age ${e.ageMin}`:`Age ${e.ageMin}–${e.ageMax}`;if(e.ageCategoryCode)return e.ageCategoryCode;if(e.ratingMin&&e.ratingMax)return`Rating ${e.ratingMin}–${e.ratingMax}`}}function cb(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 lb(e){let t=0,n=0,r=0,i=0;for(let a of e)for(let e of a?.structures??[])for(let a of e?.matchUps??[])t+=1,a?.winningSide?n+=1:a?.schedule?.scheduledTime&&(r+=1),a?.matchUpStatus===`IN_PROGRESS`&&(i+=1);return{total:t,completed:n,scheduled:r,inProgress:i}}function ub(e){let t=e?.extensions;return Array.isArray(t)?t.some(e=>e?.name===ib):!1}function db(e){return e.some(e=>e?.automated?.seedsOnly===!0||ub(e))}function fb(e){return e.length===0?!1:e.every(e=>e?.drawStatus===`CANCELLED`)}var pb=new Set([`DIRECT_ACCEPTANCE`,`DA`,`DIRECT_CONFIRMED`,`DC`,`ACCEPTED`,`A`,`ENTERED`,`PE`,`QUALIFIER`,`Q`,`WILDCARD`,`WC`]);function mb(e){if(!e.length)return 0;let t=0;for(let n of e)pb.has(String(n?.entryStatus))&&(t+=1);return t}function hb(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:lb(n)),o=t?.statusOverride===void 0?nb({allDrawsCancelled:fb(n),drawCount:n.length,entryCount:mb(r),startDate:e?.startDate,endDate:e?.endDate,matchUpCounts:a,hasDraftState:n.some(ub),hasSeedsOnlyDraw:db(n)},t?.now):t.statusOverride;return{eventId:e?.eventId??``,eventName:e?.eventName??``,eventAbbreviation:e?.eventAbbreviation,categoryLabel:sb(e?.category),eventType:ab(e?.eventType),gender:ob(e?.gender),drawCount:n.length||void 0,drawSummary:cb(n),entryCount:mb(r)||void 0,matchUpCounts:a,startDate:e?.startDate,endDate:e?.endDate,dateRangeFormatted:uh(e?.startDate,e?.endDate),status:o,eventImageURL:e?.eventImageURL??fh(i,rb),courtSvgSport:e?.courtSvgSport??ph(i)??t?.sport,updatedAt:e?.updatedAt}}var gb={name:`courthive-components`,packageManager:`pnpm@11.1.3`,version:`1.7.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:`vite build`,prepublishOnly:`npm run 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:`npm run build-storybook`,prebuild:`rm -rf dist/*`,lint:`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.0.1`,"@commitlint/config-conventional":`21.0.1`,"@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/vanillajs-datepicker":`^1.3.5`,"@typescript-eslint/eslint-plugin":`8.59.3`,"@typescript-eslint/parser":`8.59.3`,"@vitest/browser-playwright":`^4.0.16`,"@vitest/coverage-v8":`^4.0.16`,"@vitest/ui":`^4.0.16`,eslint:`10.4.0`,"eslint-plugin-sonarjs":`4.0.3`,"eslint-plugin-storybook":`^10.2.17`,"gh-pages":`6.3.0`,globals:`^17.3.0`,"happy-dom":`^20.8.3`,husky:`9.1.7`,"lint-staged":`17.0.5`,playwright:`^1.57.0`,prettier:`^3.8.1`,semver:`7.8.0`,storybook:`^10.2.17`,"tabulator-tables":`6.4.0`,typescript:`^6.0.2`,vite:`8.0.13`,"vite-plugin-dts":`^5.0.0`,vitest:`^4.0.16`},dependencies:{awesomplete:`1.1.7`,"class-variance-authority":`0.7.1`,classnames:`2.5.1`,d3:`^7.9.0`,dayjs:`1.11.20`,"focus-trap":`^8.0.0`,"timepicker-ui":`^4.1.2`,"tippy.js":`6.3.7`,"tods-competition-factory":`3.9.0`,"vanillajs-datepicker":`1.3.4`}};function _b(){return gb.version}var vb={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 yb(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&&B(i.onClick)&&i.onClick(),n&&B(n)&&n()},e.appendChild(t)}return{elements:r}}var bb=(e,t)=>n=>n?.trim().length>=e&&(!t||n?.trim().length<=t);function xb(e){return t.tools.isConvertableInteger(e)&&parseInt(e.toString())>=0}var Sb=(e,t)=>n=>xb(n)&&Number(n)>=e&&Number(n)<=t,Cb=e=>/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?\d)(?=.*?[#?!@$%^&*-]).{8,12}$/.test(e);function wb(e){return t.tools.dateTime.dateValidation.test(e)}var Tb=(e,t)=>n=>{let r=(n||``).trim().split(` `).length;return r>=e&&(!t||r<=t)},Eb=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i,Db=e=>Eb.exec(e),Ob=u({dateValidator:()=>wb,emailValidator:()=>Db,nameValidator:()=>bb,numericRange:()=>Sb,numericValidator:()=>xb,passwordValidator:()=>Cb,wordValidator:()=>Tb}),kb=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}}},Ab=`<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>`,jb=new WeakMap;function Mb(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=Ab,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),jb.set(n,i),n.appendChild(r),n}function Nb(e){jb.get(e)?.()}function Pb(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Fb(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Ib(e){let t,n,r;e.length===2?(t=e===Pb||e===Fb?e:Lb,n=e,r=e):(t=Pb,n=(t,n)=>Pb(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 Lb(){return 0}function Rb(e){return e===null?NaN:+e}var zb=Ib(Pb),Bb=zb.right;zb.left,Ib(Rb).center;var Vb=class extends Map{constructor(e,t=Gb){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(Hb(this,e))}has(e){return super.has(Hb(this,e))}set(e,t){return super.set(Ub(this,e),t)}delete(e){return super.delete(Wb(this,e))}};function Hb({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Ub({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Wb({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Gb(e){return typeof e==`object`&&e?e.valueOf():e}var Kb=Math.sqrt(50),qb=Math.sqrt(10),Jb=Math.sqrt(2);function Yb(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=Kb?10:a>=qb?5:a>=Jb?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?Yb(e,t,n*2):[s,c,l]}function Xb(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?Yb(t,e,n):Yb(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 Zb(e,t,n){return t=+t,e=+e,n=+n,Yb(e,t,n)[2]}function Qb(e,t,n){t=+t,e=+e,n=+n;let r=t<e,i=r?Zb(t,e,n):Zb(e,t,n);return(r?-1:1)*(i<0?1/-i:i)}function $b(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 ex(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 tx(e){return e}var nx=1,rx=2,ix=3,ax=4,ox=1e-6;function sx(e){return`translate(`+e+`,0)`}function cx(e){return`translate(0,`+e+`)`}function lx(e){return t=>+e(t)}function ux(e,t){return t=Math.max(0,e.bandwidth()-t*2)/2,e.round()&&(t=Math.round(t)),n=>+e(n)+t}function dx(){return!this.__axis}function fx(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===nx||e===ax?-1:1,u=e===ax||e===rx?`x`:`y`,d=e===nx||e===ix?sx:cx;function f(f){var p=r??(t.ticks?t.ticks.apply(t,n):t.domain()),m=i??(t.tickFormat?t.tickFormat.apply(t,n):tx),h=Math.max(a,0)+s,g=t.range(),_=+g[0]+c,v=+g[g.length-1]+c,y=(t.bandwidth?ux:lx)(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===nx?`0em`:e===ix?`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`,ox).attr(`transform`,function(e){return isFinite(e=y(e))?d(e+c):this.getAttribute(`transform`)}),w.attr(`opacity`,ox).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===ax||e===rx?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(dx).attr(`fill`,`none`).attr(`font-size`,10).attr(`font-family`,`sans-serif`).attr(`text-anchor`,e===rx?`start`:e===ax?`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 px(e){return fx(ix,e)}var mx={value:()=>{}};function hx(){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 gx(n)}function gx(e){this._=e}function _x(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}})}gx.prototype=hx.prototype={constructor:gx,on:function(e,t){var n=this._,r=_x(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=vx(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]=yx(n[i],e.name,t);else if(t==null)for(i in n)n[i]=yx(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 gx(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 vx(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function yx(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=mx,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var bx={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 xx(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),bx.hasOwnProperty(t)?{space:bx[t],local:e}:e}function Sx(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 Cx(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function wx(e){var t=xx(e);return(t.local?Cx:Sx)(t)}function Tx(){}function Ex(e){return e==null?Tx:function(){return this.querySelector(e)}}function Dx(e){typeof e!=`function`&&(e=Ex(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 hC(r,this._parents)}function Ox(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function kx(){return[]}function Ax(e){return e==null?kx:function(){return this.querySelectorAll(e)}}function jx(e){return function(){return Ox(e.apply(this,arguments))}}function Mx(e){e=typeof e==`function`?jx(e):Ax(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 hC(r,i)}function Nx(e){return function(){return this.matches(e)}}function Px(e){return function(t){return t.matches(e)}}var Fx=Array.prototype.find;function Ix(e){return function(){return Fx.call(this.children,e)}}function Lx(){return this.firstElementChild}function Rx(e){return this.select(e==null?Lx:Ix(typeof e==`function`?e:Px(e)))}var zx=Array.prototype.filter;function Bx(){return Array.from(this.children)}function Vx(e){return function(){return zx.call(this.children,e)}}function Hx(e){return this.selectAll(e==null?Bx:Vx(typeof e==`function`?e:Px(e)))}function Ux(e){typeof e!=`function`&&(e=Nx(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 hC(r,this._parents)}function Wx(e){return Array(e.length)}function Gx(){return new hC(this._enter||this._groups.map(Wx),this._parents)}function Kx(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kx.prototype={constructor:Kx,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 qx(e){return function(){return e}}function Jx(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 Kx(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Yx(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 Kx(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Xx(e){return e.__data__}function Zx(e,t){if(!arguments.length)return Array.from(this,Xx);var n=t?Yx:Jx,r=this._parents,i=this._groups;typeof e!=`function`&&(e=qx(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=Qx(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 hC(o,r),o._enter=s,o._exit=c,o}function Qx(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function $x(){return new hC(this._exit||this._groups.map(Wx),this._parents)}function eS(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 tS(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 hC(s,this._parents)}function nS(){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 rS(e){e||=iS;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 hC(i,this._parents).order()}function iS(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function aS(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function oS(){return Array.from(this)}function sS(){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 cS(){let e=0;for(let t of this)++e;return e}function lS(){return!this.node()}function uS(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 dS(e){return function(){this.removeAttribute(e)}}function fS(e){return function(){this.removeAttributeNS(e.space,e.local)}}function pS(e,t){return function(){this.setAttribute(e,t)}}function mS(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function hS(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function gS(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 _S(e,t){var n=xx(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?fS:dS:typeof t==`function`?n.local?gS:hS:n.local?mS:pS)(n,t))}function vS(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function yS(e){return function(){this.style.removeProperty(e)}}function bS(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xS(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function SS(e,t,n){return arguments.length>1?this.each((t==null?yS:typeof t==`function`?xS:bS)(e,t,n??``)):CS(this.node(),e)}function CS(e,t){return e.style.getPropertyValue(t)||vS(e).getComputedStyle(e,null).getPropertyValue(t)}function wS(e){return function(){delete this[e]}}function TS(e,t){return function(){this[e]=t}}function ES(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function DS(e,t){return arguments.length>1?this.each((t==null?wS:typeof t==`function`?ES:TS)(e,t)):this.node()[e]}function OS(e){return e.trim().split(/^|\s+/)}function kS(e){return e.classList||new AS(e)}function AS(e){this._node=e,this._names=OS(e.getAttribute(`class`)||``)}AS.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 jS(e,t){for(var n=kS(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function MS(e,t){for(var n=kS(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function NS(e){return function(){jS(this,e)}}function PS(e){return function(){MS(this,e)}}function FS(e,t){return function(){(t.apply(this,arguments)?jS:MS)(this,e)}}function IS(e,t){var n=OS(e+``);if(arguments.length<2){for(var r=kS(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?FS:t?NS:PS)(n,t))}function LS(){this.textContent=``}function RS(e){return function(){this.textContent=e}}function zS(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function BS(e){return arguments.length?this.each(e==null?LS:(typeof e==`function`?zS:RS)(e)):this.node().textContent}function VS(){this.innerHTML=``}function HS(e){return function(){this.innerHTML=e}}function US(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function WS(e){return arguments.length?this.each(e==null?VS:(typeof e==`function`?US:HS)(e)):this.node().innerHTML}function GS(){this.nextSibling&&this.parentNode.appendChild(this)}function KS(){return this.each(GS)}function qS(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function JS(){return this.each(qS)}function YS(e){var t=typeof e==`function`?e:wx(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function XS(){return null}function ZS(e,t){var n=typeof e==`function`?e:wx(e),r=t==null?XS:typeof t==`function`?t:Ex(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function QS(){var e=this.parentNode;e&&e.removeChild(this)}function $S(){return this.each(QS)}function eC(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tC(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function nC(e){return this.select(e?tC:eC)}function rC(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function iC(e){return function(t){e.call(this,t,this.__data__)}}function aC(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 oC(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 sC(e,t,n){return function(){var r=this.__on,i,a=iC(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 cC(e,t,n){var r=aC(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?sC:oC,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function lC(e,t,n){var r=vS(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 uC(e,t){return function(){return lC(this,e,t)}}function dC(e,t){return function(){return lC(this,e,t.apply(this,arguments))}}function fC(e,t){return this.each((typeof t==`function`?dC:uC)(e,t))}function*pC(){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 mC=[null];function hC(e,t){this._groups=e,this._parents=t}function gC(){return new hC([[document.documentElement]],mC)}function _C(){return this}hC.prototype=gC.prototype={constructor:hC,select:Dx,selectAll:Mx,selectChild:Rx,selectChildren:Hx,filter:Ux,data:Zx,enter:Gx,exit:$x,join:eS,merge:tS,selection:_C,order:nS,sort:rS,call:aS,nodes:oS,node:sS,size:cS,empty:lS,each:uS,attr:_S,style:SS,property:DS,classed:IS,text:BS,html:WS,raise:KS,lower:JS,append:YS,insert:ZS,remove:$S,clone:nC,datum:rC,on:cC,dispatch:fC,[Symbol.iterator]:pC};function vC(e){return typeof e==`string`?new hC([[document.querySelector(e)]],[document.documentElement]):new hC([[e]],mC)}function yC(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function bC(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function xC(){}var SC=.7,CC=1/SC,wC=`\\s*([+-]?\\d+)\\s*`,TC=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,EC=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,DC=/^#([0-9a-f]{3,8})$/,OC=RegExp(`^rgb\\(${wC},${wC},${wC}\\)$`),kC=RegExp(`^rgb\\(${EC},${EC},${EC}\\)$`),AC=RegExp(`^rgba\\(${wC},${wC},${wC},${TC}\\)$`),jC=RegExp(`^rgba\\(${EC},${EC},${EC},${TC}\\)$`),MC=RegExp(`^hsl\\(${TC},${EC},${EC}\\)$`),NC=RegExp(`^hsla\\(${TC},${EC},${EC},${TC}\\)$`),PC={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};yC(xC,zC,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:FC,formatHex:FC,formatHex8:IC,formatHsl:LC,formatRgb:RC,toString:RC});function FC(){return this.rgb().formatHex()}function IC(){return this.rgb().formatHex8()}function LC(){return QC(this).formatHsl()}function RC(){return this.rgb().formatRgb()}function zC(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=DC.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?BC(t):n===3?new WC(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?VC(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?VC(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=OC.exec(e))?new WC(t[1],t[2],t[3],1):(t=kC.exec(e))?new WC(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=AC.exec(e))?VC(t[1],t[2],t[3],t[4]):(t=jC.exec(e))?VC(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=MC.exec(e))?ZC(t[1],t[2]/100,t[3]/100,1):(t=NC.exec(e))?ZC(t[1],t[2]/100,t[3]/100,t[4]):PC.hasOwnProperty(e)?BC(PC[e]):e===`transparent`?new WC(NaN,NaN,NaN,0):null}function BC(e){return new WC(e>>16&255,e>>8&255,e&255,1)}function VC(e,t,n,r){return r<=0&&(e=t=n=NaN),new WC(e,t,n,r)}function HC(e){return e instanceof xC||(e=zC(e)),e?(e=e.rgb(),new WC(e.r,e.g,e.b,e.opacity)):new WC}function UC(e,t,n,r){return arguments.length===1?HC(e):new WC(e,t,n,r??1)}function WC(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}yC(WC,UC,bC(xC,{brighter(e){return e=e==null?CC:CC**+e,new WC(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?SC:SC**+e,new WC(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new WC(YC(this.r),YC(this.g),YC(this.b),JC(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:GC,formatHex:GC,formatHex8:KC,formatRgb:qC,toString:qC}));function GC(){return`#${XC(this.r)}${XC(this.g)}${XC(this.b)}`}function KC(){return`#${XC(this.r)}${XC(this.g)}${XC(this.b)}${XC((isNaN(this.opacity)?1:this.opacity)*255)}`}function qC(){let e=JC(this.opacity);return`${e===1?`rgb(`:`rgba(`}${YC(this.r)}, ${YC(this.g)}, ${YC(this.b)}${e===1?`)`:`, ${e})`}`}function JC(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function YC(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function XC(e){return e=YC(e),(e<16?`0`:``)+e.toString(16)}function ZC(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ew(e,t,n,r)}function QC(e){if(e instanceof ew)return new ew(e.h,e.s,e.l,e.opacity);if(e instanceof xC||(e=zC(e)),!e)return new ew;if(e instanceof ew)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 ew(o,s,c,e.opacity)}function $C(e,t,n,r){return arguments.length===1?QC(e):new ew(e,t,n,r??1)}function ew(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}yC(ew,$C,bC(xC,{brighter(e){return e=e==null?CC:CC**+e,new ew(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?SC:SC**+e,new ew(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 WC(rw(e>=240?e-240:e+120,i,r),rw(e,i,r),rw(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new ew(tw(this.h),nw(this.s),nw(this.l),JC(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=JC(this.opacity);return`${e===1?`hsl(`:`hsla(`}${tw(this.h)}, ${nw(this.s)*100}%, ${nw(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function tw(e){return e=(e||0)%360,e<0?e+360:e}function nw(e){return Math.max(0,Math.min(1,e||0))}function rw(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 iw=e=>()=>e;function aw(e,t){return function(n){return e+n*t}}function ow(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function sw(e){return(e=+e)==1?cw:function(t,n){return n-t?ow(t,n,e):iw(isNaN(t)?n:t)}}function cw(e,t){var n=t-e;return n?aw(e,n):iw(isNaN(e)?t:e)}var lw=(function e(t){var n=sw(t);function r(e,t){var r=n((e=UC(e)).r,(t=UC(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=cw(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 uw(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 dw(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function fw(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=xw(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 pw(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function mw(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function hw(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]=xw(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var gw=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,_w=new RegExp(gw.source,`g`);function vw(e){return function(){return e}}function yw(e){return function(t){return e(t)+``}}function bw(e,t){var n=gw.lastIndex=_w.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=gw.exec(e))&&(i=_w.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:mw(r,i)})),n=_w.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?yw(c[0].x):vw(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 xw(e,t){var n=typeof t,r;return t==null||n===`boolean`?iw(t):(n===`number`?mw:n===`string`?(r=zC(t))?(t=r,lw):bw:t instanceof zC?lw:t instanceof Date?pw:dw(t)?uw:Array.isArray(t)?fw:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?hw:mw)(e,t)}function Sw(e,t){return e=+e,t=+t,function(n){return Math.round(e*(1-n)+t*n)}}var Cw=180/Math.PI,ww={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Tw(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)*Cw,skewX:Math.atan(c)*Cw,scaleX:o,scaleY:s}}var Ew;function Dw(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?ww:Tw(t.a,t.b,t.c,t.d,t.e,t.f)}function Ow(e){return e==null||(Ew||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),Ew.setAttribute(`transform`,e),!(e=Ew.transform.baseVal.consolidate()))?ww:(e=e.matrix,Tw(e.a,e.b,e.c,e.d,e.e,e.f))}function kw(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:mw(e,i)},{i:c-2,x:mw(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:mw(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:mw(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:mw(e,n)},{i:s-2,x:mw(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 Aw=kw(Dw,`px, `,`px)`,`deg)`),jw=kw(Ow,`, `,`)`,`)`),Mw=0,Nw=0,Pw=0,Fw=1e3,Iw,Lw,Rw=0,zw=0,Bw=0,Vw=typeof performance==`object`&&performance.now?performance:Date,Hw=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Uw(){return zw||=(Hw(Ww),Vw.now()+Bw)}function Ww(){zw=0}function Gw(){this._call=this._time=this._next=null}Gw.prototype=Kw.prototype={constructor:Gw,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?Uw():+n)+(t==null?0:+t),!this._next&&Lw!==this&&(Lw?Lw._next=this:Iw=this,Lw=this),this._call=e,this._time=n,Zw()},stop:function(){this._call&&(this._call=null,this._time=1/0,Zw())}};function Kw(e,t,n){var r=new Gw;return r.restart(e,t,n),r}function qw(){Uw(),++Mw;for(var e=Iw,t;e;)(t=zw-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Mw}function Jw(){zw=(Rw=Vw.now())+Bw,Mw=Nw=0;try{qw()}finally{Mw=0,Xw(),zw=0}}function Yw(){var e=Vw.now(),t=e-Rw;t>Fw&&(Bw-=t,Rw=e)}function Xw(){for(var e,t=Iw,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:Iw=n);Lw=e,Zw(r)}function Zw(e){Mw||(Nw&&=clearTimeout(Nw),e-zw>24?(e<1/0&&(Nw=setTimeout(Jw,e-Vw.now()-Bw)),Pw&&=clearInterval(Pw)):(Pw||=(Rw=Vw.now(),setInterval(Yw,Fw)),Mw=1,Hw(Jw)))}function Qw(e,t,n){var r=new Gw;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var $w=hx(`start`,`end`,`cancel`,`interrupt`),eT=[];function tT(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;aT(e,n,{name:t,index:r,group:i,on:$w,tween:eT,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function nT(e,t){var n=iT(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function rT(e,t){var n=iT(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function iT(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function aT(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Kw(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 Qw(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(Qw(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 oT(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 sT(e){return this.each(function(){oT(this,e)})}function cT(e,t){var n,r;return function(){var i=rT(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 lT(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=rT(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 uT(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=iT(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?cT:lT)(n,e,t))}function dT(e,t,n){var r=e._id;return e.each(function(){var e=rT(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return iT(e,r).value[t]}}function fT(e,t){var n;return(typeof t==`number`?mw:t instanceof zC?lw:(n=zC(t))?(t=n,lw):bw)(e,t)}function pT(e){return function(){this.removeAttribute(e)}}function mT(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hT(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 gT(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 _T(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 vT(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 yT(e,t){var n=xx(e),r=n===`transform`?jw:fT;return this.attrTween(e,typeof t==`function`?(n.local?vT:_T)(n,r,dT(this,`attr.`+e,t)):t==null?(n.local?mT:pT)(n):(n.local?gT:hT)(n,r,t))}function bT(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function xT(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ST(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&xT(e,i)),n}return i._value=t,i}function CT(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&bT(e,i)),n}return i._value=t,i}function wT(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=xx(e);return this.tween(n,(r.local?ST:CT)(r,t))}function TT(e,t){return function(){nT(this,e).delay=+t.apply(this,arguments)}}function ET(e,t){return t=+t,function(){nT(this,e).delay=t}}function DT(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?TT:ET)(t,e)):iT(this.node(),t).delay}function OT(e,t){return function(){rT(this,e).duration=+t.apply(this,arguments)}}function kT(e,t){return t=+t,function(){rT(this,e).duration=t}}function AT(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?OT:kT)(t,e)):iT(this.node(),t).duration}function jT(e,t){if(typeof t!=`function`)throw Error();return function(){rT(this,e).ease=t}}function MT(e){var t=this._id;return arguments.length?this.each(jT(t,e)):iT(this.node(),t).ease}function NT(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();rT(this,e).ease=n}}function PT(e){if(typeof e!=`function`)throw Error();return this.each(NT(this._id,e))}function FT(e){typeof e!=`function`&&(e=Nx(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 uE(r,this._parents,this._name,this._id)}function IT(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 uE(o,this._parents,this._name,this._id)}function LT(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 RT(e,t,n){var r,i,a=LT(t)?nT:rT;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function zT(e,t){var n=this._id;return arguments.length<2?iT(this.node(),n).on.on(e):this.each(RT(n,e,t))}function BT(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function VT(){return this.on(`end.remove`,BT(this._id))}function HT(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ex(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,tT(l[f],t,n,f,l,iT(u,n)));return new uE(a,this._parents,t,n)}function UT(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Ax(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=iT(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&tT(p,t,n,h,f,m);a.push(f),o.push(u)}return new uE(a,o,t,n)}var WT=gC.prototype.constructor;function GT(){return new WT(this._groups,this._parents)}function KT(e,t){var n,r,i;return function(){var a=CS(this,e),o=(this.style.removeProperty(e),CS(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function qT(e){return function(){this.style.removeProperty(e)}}function JT(e,t,n){var r,i=n+``,a;return function(){var o=CS(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function YT(e,t,n){var r,i,a;return function(){var o=CS(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),CS(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function XT(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=rT(this,e),l=c.on,u=c.value[a]==null?s||=qT(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function ZT(e,t,n){var r=(e+=``)==`transform`?Aw:fT;return t==null?this.styleTween(e,KT(e,r)).on(`end.style.`+e,qT(e)):typeof t==`function`?this.styleTween(e,YT(e,r,dT(this,`style.`+e,t))).each(XT(this._id,e)):this.styleTween(e,JT(e,r,t),n).on(`end.style.`+e,null)}function QT(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function $T(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&QT(e,a,n)),r}return a._value=t,a}function eE(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,$T(e,t,n??``))}function tE(e){return function(){this.textContent=e}}function nE(e){return function(){var t=e(this);this.textContent=t??``}}function rE(e){return this.tween(`text`,typeof e==`function`?nE(dT(this,`text`,e)):tE(e==null?``:e+``))}function iE(e){return function(t){this.textContent=e.call(this,t)}}function aE(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&iE(r)),t}return r._value=e,r}function oE(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,aE(e))}function sE(){for(var e=this._name,t=this._id,n=fE(),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=iT(c,t);tT(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new uE(r,this._parents,e,n)}function cE(){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=rT(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 lE=0;function uE(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function dE(e){return gC().transition(e)}function fE(){return++lE}var pE=gC.prototype;uE.prototype=dE.prototype={constructor:uE,select:HT,selectAll:UT,selectChild:pE.selectChild,selectChildren:pE.selectChildren,filter:FT,merge:IT,selection:GT,transition:sE,call:pE.call,nodes:pE.nodes,node:pE.node,size:pE.size,empty:pE.empty,each:pE.each,on:zT,attr:yT,attrTween:wT,style:ZT,styleTween:eE,text:rE,textTween:oE,remove:VT,tween:uT,delay:DT,duration:AT,ease:MT,easeVarying:PT,end:cE,[Symbol.iterator]:pE[Symbol.iterator]};function mE(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var hE={time:null,delay:0,duration:250,ease:mE};function gE(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function _E(e){var t,n;e instanceof uE?(t=e._id,e=e._name):(t=fE(),(n=hE).time=Uw(),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])&&tT(c,e,t,l,o,n||gE(c,t));return new uE(r,this._parents,e,t)}gC.prototype.interrupt=sT,gC.prototype.transition=_E;var{abs:vE,max:yE,min:bE}=Math;[`w`,`e`].map(xE),[`n`,`s`].map(xE),[`n`,`w`,`e`,`s`,`nw`,`ne`,`sw`,`se`].map(xE);function xE(e){return{type:e}}var SE=Math.PI,CE=2*SE,wE=1e-6,TE=CE-wE;function EE(e){this._+=e[0];for(let t=1,n=e.length;t<n;++t)this._+=arguments[t]+e[t]}function DE(e){let t=Math.floor(e);if(!(t>=0))throw Error(`invalid digits: ${e}`);if(t>15)return EE;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 OE=class{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._=``,this._append=e==null?EE:DE(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>wE)if(!(Math.abs(u*s-c*l)>wE)||!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((SE-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>wE&&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)>wE||Math.abs(this._y1-l)>wE)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%CE+CE),d>TE?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>wE&&this._append`A${n},${n},0,${+(d>=SE)},${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._}};function kE(){return new OE}kE.prototype=OE.prototype;function AE(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function jE(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 ME(e){return e=jE(Math.abs(e)),e?e[1]:NaN}function NE(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 PE(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var FE=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function IE(e){if(!(t=FE.exec(e)))throw Error(`invalid format: `+e);var t;return new LE({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]})}IE.prototype=LE.prototype;function LE(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+``}LE.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 RE(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);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var zE;function BE(e,t){var n=jE(e,t);if(!n)return zE=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(zE=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`)+jE(e,Math.max(0,t+a-1))[0]}function VE(e,t){var n=jE(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 HE={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:AE,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)=>VE(e*100,t),r:VE,s:BE,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function UE(e){return e}var WE=Array.prototype.map,GE=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function KE(e){var t=e.grouping===void 0||e.thousands===void 0?UE:NE(WE.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?UE:PE(WE.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=IE(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`):HE[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=HE[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=RE(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&zE!==void 0?GE[8+zE/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;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(ME(t)/3)))*3,r=10**-n,i=l((e=IE(e),e.type=`f`,e),{suffix:GE[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var qE,JE,YE;XE({thousands:`,`,grouping:[3],currency:[`$`,``]});function XE(e){return qE=KE(e),JE=qE.format,YE=qE.formatPrefix,qE}function ZE(e){return Math.max(0,-ME(Math.abs(e)))}function QE(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ME(t)/3)))*3-ME(Math.abs(e)))}function $E(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,ME(t)-ME(e))+1}function eD(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 tD(){return this.eachAfter(eD)}function nD(e,t){let n=-1;for(let r of this)e.call(t,r,++n,this);return this}function rD(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 iD(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 aD(e,t){let n=-1;for(let r of this)if(e.call(t,r,++n,this))return r}function oD(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 sD(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function cD(e){for(var t=this,n=lD(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 lD(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 uD(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function dD(){return Array.from(this)}function fD(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function pD(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*mD(){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 hD(e,t){e instanceof Map?(e=[void 0,e],t===void 0&&(t=vD)):t===void 0&&(t=_D);for(var n=new xD(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 xD(o[s])),a.parent=r,a.depth=r.depth+1;return n.eachBefore(bD)}function gD(){return hD(this).eachBefore(yD)}function _D(e){return e.children}function vD(e){return Array.isArray(e)?e[1]:null}function yD(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function bD(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function xD(e){this.data=e,this.depth=this.height=0,this.parent=null}xD.prototype=hD.prototype={constructor:xD,count:tD,each:nD,eachAfter:iD,eachBefore:rD,find:aD,sum:oD,sort:sD,path:cD,ancestors:uD,descendants:dD,leaves:fD,links:pD,copy:gD,[Symbol.iterator]:mD};function SD(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 CD(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 wD(){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(SD),i}function a(e,t){return function(r){r.children&&CD(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 TD(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}var ED=Symbol(`implicit`);function DD(){var e=new Vb,t=[],n=[],r=ED;function i(i){let a=e.get(i);if(a===void 0){if(r!==ED)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 Vb;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 DD(t,n).unknown(r)},TD.apply(i,arguments),i}function OD(){var e=DD().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=ex(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 OD(t(),[r,i]).round(s).paddingInner(c).paddingOuter(l).align(u)},TD.apply(d(),arguments)}function kD(e){return function(){return e}}function AD(e){return+e}var jD=[0,1];function MD(e){return e}function ND(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:kD(isNaN(t)?NaN:.5)}function PD(e,t){var n;return e>t&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function FD(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i<r?(r=ND(i,r),a=n(o,a)):(r=ND(r,i),a=n(a,o)),function(e){return a(r(e))}}function ID(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]=ND(e[o],e[o+1]),a[o]=n(t[o],t[o+1]);return function(t){var n=Bb(e,t,1,r)-1;return a[n](i[n](t))}}function LD(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function RD(){var e=jD,t=jD,n=xw,r,i,a,o=MD,s,c,l;function u(){var n=Math.min(e.length,t.length);return o!==MD&&(o=PD(e[0],e[n-1])),s=n>2?ID:FD,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),mw))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,AD),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=Sw,u()},d.clamp=function(e){return arguments.length?(o=e?!0:MD,u()):o!==MD},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 zD(){return RD()(MD,MD)}function BD(e,t,n,r){var i=Qb(e,t,n),a;switch(r=IE(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=QE(i,o))&&(r.precision=a),YE(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=$E(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=ZE(i))&&(r.precision=a-(r.type===`%`)*2);break}return JE(r)}function VD(e){var t=e.domain;return e.ticks=function(e){var n=t();return Xb(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return BD(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=Zb(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 HD(){var e=zD();return e.copy=function(){return LD(e,HD())},TD.apply(e,arguments),VD(e)}function UD(e){return function(){return e}}var WD=Math.abs,GD=Math.atan2,KD=Math.cos,qD=Math.max,JD=Math.min,YD=Math.sin,XD=Math.sqrt,ZD=Math.PI,QD=ZD/2,$D=2*ZD;function eO(e){return e>1?0:e<-1?ZD:Math.acos(e)}function tO(e){return e>=1?QD:e<=-1?-QD:Math.asin(e)}function nO(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 OE(t)}function rO(e){return e.innerRadius}function iO(e){return e.outerRadius}function aO(e){return e.startAngle}function oO(e){return e.endAngle}function sO(e){return e&&e.padAngle}function cO(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 lO(e,t,n,r,i,a,o){var s=e-n,c=t-r,l=(o?a:-a)/XD(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)*XD(qD(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 uO(){var e=rO,t=iO,n=UD(0),r=null,i=aO,a=oO,o=sO,s=null,c=nO(l);function l(){var l,u,d=+e.apply(this,arguments),f=+t.apply(this,arguments),p=i.apply(this,arguments)-QD,m=a.apply(this,arguments)-QD,h=WD(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>$D-1e-12)s.moveTo(f*KD(p),f*YD(p)),s.arc(0,0,f,p,m,!g),d>1e-12&&(s.moveTo(d*KD(m),d*YD(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):XD(d*d+f*f)),T=JD(WD(f-d)/2,+n.apply(this,arguments)),E=T,D=T,O,k;if(w>1e-12){var A=tO(w/d*YD(C)),j=tO(w/f*YD(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*KD(_),N=f*YD(_),P=d*KD(b),F=d*YD(b);if(T>1e-12){var I=f*KD(v),L=f*YD(v),R=d*KD(y),z=d*YD(y),B;if(h<ZD)if(B=cO(M,N,R,z,I,L,P,F)){var ee=M-B[0],te=N-B[1],ne=I-B[0],V=L-B[1],re=1/YD(eO((ee*ne+te*V)/(XD(ee*ee+te*te)*XD(ne*ne+V*V)))/2),ie=XD(B[0]*B[0]+B[1]*B[1]);E=JD(T,(d-ie)/(re-1)),D=JD(T,(f-ie)/(re+1))}else E=D=0}S>1e-12?D>1e-12?(O=lO(R,z,M,N,f,D,g),k=lO(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,GD(O.y01,O.x01),GD(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,D,GD(O.y01,O.x01),GD(O.y11,O.x11),!g),s.arc(0,0,f,GD(O.cy+O.y11,O.cx+O.x11),GD(k.cy+k.y11,k.cx+k.x11),!g),s.arc(k.cx,k.cy,D,GD(k.y11,k.x11),GD(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=lO(P,F,I,L,d,-E,g),k=lO(M,N,R,z,d,-E,g),s.lineTo(O.cx+O.x01,O.cy+O.y01),E<T?s.arc(O.cx,O.cy,E,GD(O.y01,O.x01),GD(k.y01,k.x01),!g):(s.arc(O.cx,O.cy,E,GD(O.y01,O.x01),GD(O.y11,O.x11),!g),s.arc(0,0,d,GD(O.cy+O.y11,O.cx+O.x11),GD(k.cy+k.y11,k.cx+k.x11),g),s.arc(k.cx,k.cy,E,GD(k.y11,k.x11),GD(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-ZD/2;return[KD(r)*n,YD(r)*n]},l.innerRadius=function(t){return arguments.length?(e=typeof t==`function`?t:UD(+t),l):e},l.outerRadius=function(e){return arguments.length?(t=typeof e==`function`?e:UD(+e),l):t},l.cornerRadius=function(e){return arguments.length?(n=typeof e==`function`?e:UD(+e),l):n},l.padRadius=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:UD(+e),l):r},l.startAngle=function(e){return arguments.length?(i=typeof e==`function`?e:UD(+e),l):i},l.endAngle=function(e){return arguments.length?(a=typeof e==`function`?e:UD(+e),l):a},l.padAngle=function(e){return arguments.length?(o=typeof e==`function`?e:UD(+e),l):o},l.context=function(e){return arguments.length?(s=e??null,l):s},l}function dO(e,t,n){this.k=e,this.x=t,this.y=n}dO.prototype={constructor:dO,scale:function(e){return e===1?this:new dO(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new dO(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 fO=new dO(1,0,0);pO.prototype=dO.prototype;function pO(e){for(;!e.__zoom;)if(!(e=e.parentNode))return fO;return e.__zoom}function mO(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{WILDCARD:hO,QUALIFIER:gO,LUCKY_LOSER:_O}=t.entryStatusConstants,vO=`text-anchor`,yO=`dominant-baseline`,bO=`fill-opacity`,xO=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 SO(e){let t=Math.floor(e.length/2),n=e.slice(0,t),r=e.slice(t).reverse();return[...n,...r]}function CO(e){if(e)switch(e){case hO:return`WC`;case gO:return`Q`;case _O:return`LL`;default:return e}}function wO(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:CO(e.entryStatus),nationalityCode:e.nationalityCode,matchUp:r,depth:t,value:1})}return n}function TO(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 EO(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}=TO(e,r);return{name:s||``,participantName:s,drawPosition:l?.drawPosition??c?.drawPosition,seedNumber:c?.seedNumber??l?.seedNumber,entryStatus:CO(c?.entryStatus)??l?.entryStatus,nationalityCode:c?.nationalityCode??l?.nationalityCode,scoreString:e.scoreString,matchUpStatus:e.matchUpStatus,matchUp:e,depth:n,children:o.length>0?o:void 0}})}function DO(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=SO(wO(r,n.length)),a=new Map;for(let e of i)e.participantName&&e.participantName!==`BYE`&&a.set(e.participantName,e);let o=EO(SO(r),i,n.length-1,a);for(let e=1;e<n.length;e++)o=EO(SO(t[n[e]]),o,n.length-1-e,a);return o.length===1?o[0]:{name:`Tournament`,depth:0,children:o}}function OO(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=HD().domain([1,32]).range([`0`,`1`]);o=HD().domain(ex(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=HD().domain(ex(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=HD().domain(ex(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),OO(n,t)})}function kO(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 AO(e,t){let n=e.find(e=>e.data.participantName&&e.data.participantName!==t);return n?.data.participantName?n.data:void 0}function jO(e,t){let n=[e.participantName],r;if(t.children&&t.children.length>0)e.scoreString&&n.push(e.scoreString),r=AO(t.children,e.participantName),r&&n.push(r.participantName);else{let r=kO(e,t.depth);r&&n.push(r)}return{messageLines:n,opponentData:r}}function MO(e,t){return-(e*t/2)+t/2}function NO(e,t,n){let r=vC(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 PO(e,t,n,r,i){let a=e.append(`text`).attr(`x`,t/2).attr(`y`,n/2).attr(vO,`middle`).attr(yO,`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(vO,`middle`).attr(yO,`middle`).attr(`font-size`,`${i}px`).style(`fill`,`var(--chc-text-secondary, #666)`).attr(`pointer-events`,`none`)}}function FO(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(vO,`middle`).attr(yO,`middle`).attr(`transform`,`translate(0, ${r*a})`).text(zO(n)))}function IO(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}))),p=DO(n),m=hD(p,e=>e.children).sum(e=>e.value||0),h=Math.min(a,o)/2,g=h/2,_=e=>e*h/200;wD().size([2*Math.PI,h-g])(m),OO(p,HD().domain([0,n.drawSize||128]).range([0,1]));let v=m.descendants(),y=uO().startAngle(e=>e.x0).endAngle(e=>e.x1).innerRadius(e=>e.y0+g).outerRadius(e=>e.y1+g),{svg:b,g:x,flagsGroup:S,winningFlagsGroup:C,losingFlagsGroup:w}=NO(e,a,o),T=new Set,E=e=>{e.nationalityCode&&T.add(e.nationalityCode),e.children&&e.children.forEach(E)};E(p);let D=Array.from(T),{centerText:O,centerText2:k}=PO(b,a,o,c,l);function A(){let e=mO(d,15);O.text(``),O.selectAll(`tspan`).remove(),k.text(``),k.selectAll(`tspan`).remove(),O.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;O.attr(`y`,o/2+t),O.style(`display`,`block`),k.style(`display`,`none`)}function j(){if(S.selectAll(`text`).remove(),C.selectAll(`text`).remove(),w.selectAll(`text`).remove(),D.length===0)return;let e=HD().domain([0,D.length]).range([0,Math.PI*2]),t=_(20),n=g-t+10;S.selectAll(`text`).data(D).join(`text`).attr(`font-size`,`${t}px`).attr(vO,`middle`).attr(yO,`middle`).attr(`transform`,(t,r)=>{let i=e(r);return`translate(${Math.cos(i)*n}, ${Math.sin(i)*n})`}).text(e=>zO(e)).style(`cursor`,`pointer`).on(`mouseover`,function(e,t){let n=f[t]||t;O.selectAll(`tspan`).remove(),O.attr(`y`,o/2),O.text(n).style(`display`,`block`),k.selectAll(`tspan`).remove(),k.text(``).style(`display`,`none`),N||x.selectAll(`path`).attr(bO,e=>e.data.nationalityCode===t?.9:.3)}).on(`mouseout`,function(){N||x.selectAll(`path`).attr(bO,.8),A()})}j(),A();let M=i.eventHandlers?.clickCenter;M&&x.insert(`circle`,`:first-child`).attr(`r`,g).attr(`fill`,`transparent`).style(`cursor`,`pointer`).on(`click`,M);let N=!1,P;function F(e,t){let n=t.data;if(n.participantName){let{messageLines:e,opponentData:r}=jO(n,t);r&&(n.opponent=r),O.selectAll(`tspan`).remove(),O.text(``),O.selectAll(`tspan`).data(e).join(`tspan`).attr(`x`,a/2).attr(`dy`,(e,t)=>t===0?0:u).text(e=>e);let i=MO(e.length,u);O.attr(`y`,o/2+i),O.style(`display`,`block`),k.style(`display`,`none`)}N?n.participantName?.toLowerCase()!==P?.toLowerCase()&&vC(e.currentTarget).attr(bO,.9):x.selectAll(`path`).attr(bO,e=>e.data.participantName===t.data.participantName?.9:.3);let r=_(30),i=g-r-10,s={flagsGroup:S,winningFlagsGroup:C,losingFlagsGroup:w};FO(C,s,n.nationalityCode,-1,!0,i,r),n.opponent&&FO(w,s,n.opponent.nationalityCode,1,!1,i,r)}function I(e,t){if(N){let n=t.data.participantName?.toLowerCase()===P?.toLowerCase();vC(e.currentTarget).attr(bO,n?1:.2)}else x.selectAll(`path`).attr(bO,.8);j(),A()}let L=i.eventHandlers?.clickSegment;function R(e,t){if(!L)return;let n=t.data;L({participantName:n.participantName,drawPosition:n.drawPosition,seedNumber:n.seedNumber,entryStatus:n.entryStatus,nationalityCode:n.nationalityCode,scoreString:n.scoreString,matchUpStatus:n.matchUpStatus,roundName:n.roundName,depth:n.depth,matchUp:n.matchUp})}let z=x.selectAll(`path`).data(v).join(`path`).attr(`d`,e=>y(e)).attr(`fill`,e=>e.data.color||`#ccc`).attr(bO,.8).attr(`stroke`,`#fff`).attr(`stroke-width`,1).on(`mouseover`,F).on(`mouseout`,I);L&&z.style(`cursor`,`pointer`).on(`click`,R),z.append(`title`).text(e=>{let t=e.data;return t.participantName?`${t.participantName}\nDraw: ${t.drawPosition||`N/A`}`:`${t.name}\nDepth: ${e.depth}`});function B(e){let t=0;return N=!!e,P=e,x.selectAll(`path`).attr(bO,n=>e?n.data.participantName?.toLowerCase()===e.toLowerCase()?(t+=1,1):.2:.8),t}function ee(e){b.style(`display`,e?`none`:`block`)}return{highlightPlayer:B,hide:ee}}function LO(e={}){return{render:(t,n,r)=>IO(t,n,r,e)}}function RO(e){return e?.length===2?e&&String.fromCodePoint!==void 0?e.toUpperCase().replaceAll(/./g,e=>String.fromCodePoint((e.codePointAt(0)??0)+127397)):e:``}function zO(e){return RO(xO[e]||e)}var{LUCKY_LOSER:BO,WILDCARD:VO,QUALIFIER:HO}=t.entryStatusConstants;function UO(e){let t={};for(let[n,r]of Object.entries(e.roundMatchUps))t[Number(n)]=r.map(e=>({...e,winningSide:e.winningSide,drawPositions:e.drawPositions||[],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 WO={LL:BO,WC:VO,Q:HO},GO=[`R128`,`R64`,`R32`,`R16`,`QF`,`SF`,`F`];function KO(e){let t=qO(e);if(t.length===0)return{drawSize:0,roundMatchUps:{}};let n=t[0].data,r=n.length,i=JO(n),a=YO(t,e),o={};o[1]=ZO(n,a,t);for(let e=1;e<t.length;e++)o[e+1]=QO(e,t,a,i);return{drawSize:r,roundMatchUps:o}}function qO(e){let t=[],n=!1;for(let r of GO){let i=e[r];i&&i.length>0&&(n=!0),n&&i&&i.length>0&&t.push({key:r,data:i})}return t}function JO(e){let t=new Map;return e.forEach((e,n)=>{let r=$O(e.player);r&&r!==`BYE`&&t.set(r,{drawPosition:e.Draw??n+1,country:e.country,seed:e.seed,entry:e.entry})}),t}function YO(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=$O(e.player);t&&a.add(t)}n.set(e[r].key,a)}return n}function XO(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 ZO(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=$O(a?.player),c=$O(o?.player),l=s===`BYE`||c===`BYE`,u=XO(s,c,i),d;if(!l&&n.length>1){let e=n[1].data,t=u===1?s:c;d=e.find(e=>$O(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],scoreString:d,sides:[tk(1,a,t+1),tk(2,o,t+2)]})}return r}function QO(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=$O(t?.player),l=$O(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],scoreString:d,sides:[nk(1,t,r),nk(2,n,r)]})}return s}function $O(e){if(!e)return``;let t=e.trim();return t.toUpperCase()===`BYE`?`BYE`:t}function ek(e){if(e)return WO[e.toUpperCase()]||e}function tk(e,t,n){if(!t)return{sideNumber:e,drawPosition:n};let r=$O(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:ek(t.entry)}}function nk(e,t,n){if(!t)return{sideNumber:e,drawPosition:0};let r=$O(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:ek(t.entry||i?.entry)}}var rk=480,ik=200,ak=280,ok={top:12,right:12,bottom:28,left:32},sk={top:12,right:12,bottom:12,left:12},ck=.6,lk=.9,uk=`http://www.w3.org/2000/svg`,dk=`middle`,fk=`text-anchor`,pk=`dominant-baseline`,mk=[`var(--chc-rating-low, #5b8ff9)`,`var(--chc-rating-high, #00b894)`];function hk(e,t,n){let r=document.createElementNS(uk,`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 gk(e,t,n){return n<=1||t/(n-1)<.5?mk[0]:mk[1]}function _k(e,t,n,r){return r?r(e,t):gk(e,t,n)}function vk(e){return`${e.binStart.toFixed(1)}–${e.binEnd.toFixed(1)}`}function yk(e){let{stats:t,width:n,height:r,margin:i,showAxis:a,showCounts:o,showMean:s,binColor:c,ariaLabel:l}=e,u=hk(n,r,l),d=vC(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=OD().domain(t.histogram.map(vk)).range([0,f]).padding(.12),h=HD().domain([0,$b(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(vk(e))??0).attr(`y`,e=>h(e.count)).attr(`width`,m.bandwidth()).attr(`height`,e=>p-h(e.count)).attr(`fill`,(e,t)=>_k(e,t,g,c)).append(`title`).text(e=>`${vk(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(vk(e))??0)+m.bandwidth()/2).attr(`y`,e=>h(e.count)-4).attr(fk,dk).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(vk),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(px(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 bk(e,t,n,r){return[e+n*Math.sin(r),t-n*Math.cos(r)]}function xk(e,t,n,r,i,a){let[o,s]=bk(e,t,n,i),[c,l]=bk(e,t,n,a),[u,d]=bk(e,t,r,a),[f,p]=bk(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 Sk(e){let{stats:t,size:n,margin:r,showCounts:i,binColor:a,ariaLabel:o}=e,s=hk(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*lk,f=c*ck,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(uk,`path`);if(h.setAttribute(`class`,`chc-rdc-slice`),h.setAttribute(`d`,xk(l,u,d,f,o,c)),h.setAttribute(`fill`,_k(n,e,m,a)),s.appendChild(h),i){let e=o+r/2,[t,i]=bk(l,u,(d+f)/2,e),a=document.createElementNS(uk,`text`);a.setAttribute(`class`,`chc-rdc-slice-label`),a.setAttribute(`x`,String(t)),a.setAttribute(`y`,String(i)),a.setAttribute(fk,dk),a.setAttribute(pk,dk),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(uk,`text`);return h.setAttribute(`class`,`chc-rdc-center-count`),h.setAttribute(`x`,String(l)),h.setAttribute(`y`,String(u)),h.setAttribute(fk,dk),h.setAttribute(pk,dk),h.setAttribute(`font-size`,`20`),h.setAttribute(`font-weight`,`600`),h.textContent=String(t.count),s.appendChild(h),s}function Ck(e,t={}){let n=t.mode??`HISTOGRAM`,r=t.ariaLabel??`Participant rating distribution`;return n===`DONUT`?Sk({stats:e,size:t.width??t.height??ak,margin:t.margin??sk,showCounts:t.showCounts??!0,binColor:t.binColor,ariaLabel:r}):yk({stats:e,width:t.width??rk,height:t.height??ik,margin:t.margin??ok,showAxis:t.showAxis??!0,showCounts:t.showCounts??!0,showMean:t.showMean??!0,binColor:t.binColor,ariaLabel:r})}var wk=`right`,Tk=`font-medium`;function Ek({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===wk&&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`);B(t.onClick)&&(d.onclick=t.onClick),d.style.cssText=`margin-right: 1em`,d.innerHTML=t.label,u.appendChild(d);let f=document.createElement(`span`);B(t.onClick)&&(f.onclick=t.onClick),f.innerHTML=`
|
|
215
215
|
<span class="icon is-small font-medium">
|
|
216
216
|
<i class="fas fa-angle-down font-medium" aria-hidden="true"></i>
|
|
217
217
|
</span>
|
|
218
|
-
`,u.appendChild(f),l.appendChild(u),a.appendChild(l);let p=document.createElement(`div`);p.classList.add(`dropdown-menu`),p.setAttribute(`z-index`,`99998`);let m=document.createElement(`div`);m.classList.add(`dropdown-content`);let h=()=>{let e=p.querySelectorAll(`.dropdown-item`);for(let t of Array.from(e))t.classList.remove(`is-active`)},g=e=>{let r=document.createElement(`a`);r.className=
|
|
218
|
+
`,u.appendChild(f),l.appendChild(u),a.appendChild(l);let p=document.createElement(`div`);p.classList.add(`dropdown-menu`),p.setAttribute(`z-index`,`99998`);let m=document.createElement(`div`);m.classList.add(`dropdown-content`);let h=()=>{let e=p.querySelectorAll(`.dropdown-item`);for(let t of Array.from(e))t.classList.remove(`is-active`)},g=e=>{let r=document.createElement(`a`);r.className=Tk;let l=e.disabled?`0.4`:`1`;return r.style.cssText=`text-decoration: none; opacity: ${l};`,e.color&&(r.style.color=e.color),r.classList.add(`dropdown-item`),e.isActive&&r.classList.add(`is-active`),e.value&&(r.value=e.value),e.class&&r.classList.add(e.class),r.onclick=l=>{if(e.disabled)return;e.value&&(u.value=e.value,a.value=e.value),l.stopPropagation(),B(e.onClick)&&(B(n)&&n(),e.onClick(l)),e.close&&s();let f=o(r);h(),f?d.innerHTML=t.label:(t.selection&&c(r),t.modifyLabel&&e.modifyLabel!==!1&&(d.innerHTML=`${t.append?t.label+`: `:``}${e?.label||i()}`))},r.innerHTML=e?.label||i(),r};for(let e of t.options||[])if(e.heading){let t=document.createElement(`div`);t.style.cssText=`font-weight: bold`,t.classList.add(`dropdown-item`,Tk),t.innerHTML=e.heading,m.appendChild(t)}else if(e.divider){let e=document.createElement(`hr`);e.classList.add(`dropdown-divider`,Tk),m.appendChild(e)}else e.hide||m.appendChild(g(e));return t.options?.length&&(t.options[0].value&&(a.value=t.options[0].value),p.appendChild(m)),a.appendChild(p),e&&e.appendChild(a),a}var Dk=`left`;function Ok(e){let{title:t,placeholder:n,options:r,selectionLimit:i,createTable:a,createFilter:o}=e,s=`selectionControl`,c=`selectionTable`,l,u,d=[{label:`Cancel`,intent:`none`,close:!0}],f=()=>{u?u():l?.destroy&&l.destroy(),l=void 0},p=`
|
|
219
219
|
<div style='min-height: 420px'>
|
|
220
220
|
<div id='${s}'></div>
|
|
221
221
|
<div id='${c}'></div>
|
|
222
222
|
</div>
|
|
223
|
-
`;F.open({title:t,content:p,buttons:d,onClose:f});let m=e=>{e?.[0]?.onClick&&(e[0].onClick(),F.close())};if(a){let e=a({anchorId:c,data:r,selectionLimit:i,onSelected:m});l=e.table,u=e.destroy;let t=o?o(l):()=>{},d=[{onKeyDown:e=>e.keyCode===8&&e.target.value.length===1&&t(``),onChange:e=>t(e.target.value),onKeyUp:e=>t(e.target.value),clearSearch:()=>t(``),placeholder:n||`Search`,location:dO,search:!0}],f=document.getElementById(s)||void 0;NO({table:l,target:f,items:d})}else{let e=document.getElementById(c);if(e){pO({container:e,options:r,onSelected:m});let t=t=>{let n=e.querySelectorAll(`[data-select-item]`),r=t.toLowerCase();n.forEach(e=>{let n=e.textContent?.toLowerCase()||``;e.style.display=!t||n.includes(r)?``:`none`})},i=[{onKeyUp:e=>t(e.target.value),clearSearch:()=>t(``),placeholder:n||`Search`,location:dO,search:!0}];NO({target:document.getElementById(s)||void 0,items:i})}}}function pO({container:e,options:t,onSelected:n}){let r=document.createElement(`div`);r.style.cssText=`max-height: 380px; overflow-y: auto; padding: 0.5em 0;`;for(let e of t){let t=document.createElement(`a`);t.setAttribute(`data-select-item`,``),t.className=`panel-block font-medium`,t.style.cssText=`cursor: pointer; padding: 0.5em 1em; display: block; text-decoration: none; color: inherit;`,t.innerHTML=e.label,t.onmouseenter=()=>t.style.backgroundColor=`#f5f5f5`,t.onmouseleave=()=>t.style.backgroundColor=``,t.onclick=t=>{t.stopPropagation(),n([e])},r.appendChild(t)}e.appendChild(r)}var mO=`none`;function hO(e){let t=document.createElement(`button`);return t.className=`button font-medium`,e.disabled&&(t.disabled=!0),e.class&&t.classList.add(e.class),e.id&&(t.id=e.id),e.intent&&t.classList.add(e.intent),e.toolTip?.content&&um(t,e.toolTip),t.innerHTML=e.label,e.visible===!1&&(t.style.display=mO),t}var gO=`center`,_O=``,vO=`flex`,yO=`left`,bO=`none`,xO=`overlay`,SO=`right`,CO=({target:e})=>(t=[])=>{e.style.backgroundColor=t?.length?`var(--chc-hover-bg)`:_O;let n=(n,r,i)=>{let a=e.getElementsByClassName(`options_${n}`)[0];a&&(a.style.display=t?.length?r:i)};n(xO,vO,bO),n(yO,bO,vO),n(gO,bO,vO),n(SO,bO,vO)},wO=`center`,TO=`header`,EO=``,DO=`left`,OO=`none`,kO=`overlay`,AO=`right`,jO=`buttonBar`,MO=`top`;function NO(e){let{table:t,targetClassName:n,items:r=[],onSelection:i,selectItemFn:a}=e,{target:o}=e,s=!!o;if(!o&&n&&(o=document.getElementsByClassName(n)?.[0]),!o)return{elements:{},inputs:{}};let c=0,l=0,u={},d={},f;if(s){P(o);let e=VO();Object.assign(u,e.elements),o.appendChild(e.anchor)}let p=Object.assign({},...[kO,DO,wO,AO,TO].map(e=>{let t=o.getElementsByClassName(`options_${e}`)?.[0];return P(t),{[e]:t}}).filter(Boolean)),m=CO({table:t,target:o}),h=(e,n)=>{B(n.onClick)&&(e.stopPropagation(),n.disabled||n.onClick(e,t),n.stateChange&&m())},g={onClick:()=>{},location:AO};for(let e of r){let t={...g};ee(e)&&Object.assign(t,e);let n=p[t.location];if(!n){console.log(t.location,p);continue}t.location===kO&&(c+=1),t.location===TO&&(PO(t,o),l+=1);let r=FO(e,t,n,m,h,a,u,d);r?.focus&&(f=r.focus)}let _=o.getElementsByClassName(`panelHeader`)[0];_&&(_.style.display=l?EO:OO),t?._controlBarSelectionHandler&&t.off(`rowSelectionChanged`,t._controlBarSelectionHandler);let v=(e,t)=>{B(i)&&i(t),c&&m(t)};return t&&(t._controlBarSelectionHandler=v),t?.on(`rowSelectionChanged`,v),m(t?.getSelectedRows?.()??[]),f&&setTimeout(()=>f.focus(),200),{elements:u,inputs:d}}function PO(e,t){if(B(e.headerClick)){let n=t.getElementsByClassName(`panelHeader`)[0];n&&(n.onclick=e.headerClick)}}function FO(e,t,n,r,i,a,o,s){if(!t.hide&&(t.input||t.placeholder||t.search)){let r=IO(e,t);return t.id&&(s[t.id]=r.input),t.id&&(o[t.id]=r.elem,r.elem.id=t.id),n?.appendChild(r.elem),t.focus?{focus:r.input}:void 0}if(!t.hide&&t.text){let e=document.createElement(`div`);e.className=`font-medium`,t.id&&(o[t.id]=e,e.id=t.id),e.innerHTML=t.text,e.onclick=e=>i(e,t),n?.appendChild(e);return}!t.id&&(!t?.label||t.hide)||(RO(t,n,r,i,a,o),(!(t?.label||t.tabs)||t.hide)&&o[t.id]&&(o[t.id].style.display=OO))}function IO(e,t){let n=document.createElement(`p`);n.className=`control ${t.search?`has-icons-left has-icons-right`:``}`;let r=document.createElement(`input`);if(r.className=`input font-medium`,r.setAttribute(`type`,`text`),r.setAttribute(`autocomplete`,`off`),r.setAttribute(`placeholder`,e.placeholder||EO),t.id&&r.setAttribute(`id`,t.id),t.onKeyDown&&r.addEventListener(`keydown`,e=>t.onKeyDown(e,t)),t.onChange&&r.addEventListener(`change`,e=>t.onChange(e,t)),t.onKeyUp&&r.addEventListener(`keyup`,e=>{t.clearSearch&&e.key===`Escape`&&(e.stopPropagation(),r.value=``,t.clearSearch()),t.onKeyUp(e,t)}),t.class&&r.classList.add(t.class),t.visible===!1&&(n.style.display=OO),t.value&&(r.value=t.value),n.appendChild(r),t.search&&LO(n,r,t),e.validator){let t=document.createElement(`p`);t.className=`help font-medium`,n.appendChild(t),r.addEventListener(`input`,n=>an(e,n,r,t,e.validator))}return{elem:n,input:r}}function LO(e,t,n){let r=document.createElement(`span`);if(r.className=`icon is-small is-left font-medium`,r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16" fill="currentColor"><path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"/></svg>`,e.appendChild(r),B(n.clearSearch)){let r=document.createElement(`span`);r.className=`icon is-small is-right font-medium`,r.style.pointerEvents=`all`,r.style.cursor=`pointer`,r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16" fill="#dddada"><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>`,r.onclick=e=>{e.stopPropagation(),t.value=``,n.clearSearch(),i()};let i=()=>{r.style.display=t.value?``:`none`};t.addEventListener(`input`,i),i(),e.appendChild(r)}}function RO(e,t,n,r,i,a){if(e.options){let r=uO({target:t,button:e,stateChange:n});e.visible===!1&&(r.style.display=OO),e.id&&(a[e.id]=r)}else if(ee(e.selection))zO(e,t,n,i,a);else if(e.tabs)BO(e,t,a);else{let n=hO(e);n.onclick=t=>r(t,e),e.id&&(a[e.id]=n),t?.appendChild(n)}}function zO(e,t,n,r,i){let{selection:{options:a,actions:o},actionPlacement:s,threshold:c=8,...l}=e;if(a?.length<c){a.length&&(s===MO?a.unshift({divider:!0}):a.push({divider:!0})),o.forEach(e=>{let{label:t,...n}=e,r={...n,label:`<p style="font-weight: bold">${t}</p>`};s===MO?a.unshift(r):a.push(r)});let r={...l,options:a},c=uO({target:t,button:r,stateChange:n});r.visible===!1&&(c.style.display=OO),r.id&&(i[e.id]=c)}else{let n=hO(e),o=r||fO;n.onclick=t=>{t.stopPropagation(),o({title:e.selectionTitle||`Select`,options:a})},e.id&&(i[e.id]=n),t?.appendChild(n)}}function BO(e,t,n){let r=document.createElement(`div`);r.className=`tabs is-toggle is-toggle-rounded`;let i=document.createElement(`ul`);r.appendChild(i),e.tabs.forEach(t=>{let n=document.createElement(`li`);t.active&&n.classList.add(`is-active`);let r=document.createElement(`a`);n.appendChild(r),r.onclick=r=>{i.querySelectorAll(`li`).forEach(e=>e.classList.remove(`is-active`)),n.classList.add(`is-active`),B(t.onClick)&&t.onClick(r,e)};let a=document.createElement(`span`);a.innerHTML=t.label,r.appendChild(a),i.appendChild(n)}),e.id&&(n[e.id]=r),t.appendChild(r)}function VO(){let e=document.createElement(`div`);e.className=`panel_container flexcol flexcenter`;let t=document.createElement(`div`);t.className=`panelHeader options_header`,t.style.display=OO,e.appendChild(t);let n=document.createElement(`div`);n.className=jO;let r={optionsOverlay:document.createElement(`div`),optionsLeft:document.createElement(`div`),optionsCenter:document.createElement(`div`),optionsRight:document.createElement(`div`)};r.optionsOverlay.className=`options_overlay`,r.optionsCenter.className=`options_center`,r.optionsRight.className=`options_right`,r.optionsLeft.className=`options_left`;for(let e of Object.values(r))n.appendChild(e);return e.appendChild(n),{elements:r,anchor:e,header:t}}var HO=()=>`sp-layout`,UO=()=>`sp-column`,WO=()=>`sp-panel`,GO=()=>`sp-panel-header`,KO=()=>`sp-panel-title`,qO=()=>`sp-panel-meta`,JO=()=>`sp-panel-actions`,YO=()=>`sp-panel-leading`,XO=()=>`sp-date-strip`,ZO=()=>`sp-date-chip`,QO=()=>`sp-badges`,$O=()=>`sp-badge`,ek=()=>`sp-chips`,tk=()=>`sp-chip`,nk=()=>`sp-board`,rk=()=>`sp-venue`,ik=()=>`sp-venue-header`,ak=()=>`sp-venue-title`,ok=()=>`sp-venue-sub`,sk=()=>`sp-dropzone`,ck=()=>`sp-card`,lk=()=>`sp-card-title`,uk=()=>`sp-card-meta`,dk=()=>`sp-issues`,fk=()=>`sp-issue`,pk=()=>`sp-issue-code`,mk=()=>`sp-issue-msg`,hk=()=>`sp-issue-actions`,gk=()=>`sp-btn sp-btn--sm`,_k=()=>`sp-catalog`,vk=()=>`sp-catalog-toolbar`,yk=()=>`sp-input`,bk=()=>`sp-select`,xk=()=>`sp-group`,Sk=()=>`sp-group-header`,Ck=()=>`sp-group-body`,wk=()=>`sp-catalog-item`,Tk=()=>`sp-inspector`,Ek=()=>`sp-kv`,Dk=()=>`sp-kv-key`,Ok=()=>`sp-kv-value`,kk=()=>`sp-small`,Ak=()=>`sp-popover-item`,jk=()=>`sp-popover-delete`,Mk=()=>`sp-popover-divider`,Nk=()=>`sp-insertion-line`,Pk=()=>`sp-group-chevron`;function Fk(e,t){let n=!!t?.hideLeft,r=t?.catalogSide===`left`,i=document.createElement(`div`);if(i.className=HO(),n)r?i.classList.add(`sp-catalog-left`):i.classList.add(`sp-no-left`);else{let t=document.createElement(`div`);t.className=UO(),t.appendChild(e.dateStrip.element),e.issuesPanel.element.style.flex=`1`,e.issuesPanel.element.style.minHeight=`0`,t.appendChild(e.issuesPanel.element),i.appendChild(t)}let a=document.createElement(`div`);a.className=UO(),e.venueBoard.element.style.flex=`1`,e.venueBoard.element.style.minHeight=`0`,a.appendChild(e.venueBoard.element);let o=document.createElement(`div`);o.className=UO(),e.roundCatalog.element.style.flex=`1`,e.roundCatalog.element.style.minHeight=`0`,o.appendChild(e.roundCatalog.element),o.appendChild(e.inspectorPanel.element),r&&n?(i.appendChild(o),i.appendChild(a)):(i.appendChild(a),i.appendChild(o));function s(t){n||(e.dateStrip.update(t),e.issuesPanel.update(t)),e.venueBoard.update(t),e.roundCatalog.update(t),e.inspectorPanel.update(t)}return{element:i,update:s}}function Ik(e){let t=null,n=null;function r(e){return`${e.date}|${e.venueId}|${e.index}`}function i(){t&&(t.destroy(),t=null,n=null)}function a(t){let n=document.createElement(`div`);n.style.cssText=`font-family:sans-serif; font-size:13px; min-width:150px;`;let r=document.createElement(`div`);r.className=Ak(),r.textContent=`Set Not Before Time`,r.addEventListener(`click`,()=>{i(),e.onSetNotBeforeTime(t)}),n.appendChild(r);let a=document.createElement(`div`);a.className=Mk(),n.appendChild(a);let o=document.createElement(`div`);return o.className=jk(),o.textContent=`Remove Round`,o.addEventListener(`click`,()=>{i(),e.onDelete(t)}),n.appendChild(o),n}return{show(e,o){let s=r(o);if(n===s){i();return}i();let c=um(e,{content:a(o),allowHTML:!0,interactive:!0,trigger:`manual`,placement:`bottom`,appendTo:document.body,onHidden:()=>{t=null,n=null}});t=c,n=s,c.show()},destroy(){i()},isActiveFor(e){return n===r(e)}}}function Lk(e){return structuredClone(e)}function Rk(e,t,n){return Math.max(t,Math.min(n,e))}function zk(e){return`${e.tournamentId}|${e.eventId}|${e.drawId}|${e.structureId}|${e.roundNumber}`}function Bk(e){return`${e.eventName?`${e.eventName} \u2013 `:``}${e.roundName??`Round ${e.roundNumber}`}${e.roundSegment?` (seg ${e.roundSegment.segmentNumber}/${e.roundSegment.segmentsCount})`:``}`}function Vk(e,t){return!e||!t?!1:e.date===t.date&&e.venueId===t.venueId&&e.index===t.index}function Hk(e){return{tournamentId:e.tournamentId,eventId:e.eventId,drawId:e.drawId,structureId:e.structureId,roundNumber:e.roundNumber}}function Uk(e,t,n){return e.find(e=>e.scheduleDate===t)?.venues?.find(e=>e.venueId===n)?.rounds??[]}function Wk(e,t){return(e.find(e=>e.scheduleDate===t.date)?.venues?.find(e=>e.venueId===t.venueId))?.rounds?.[t.index]??null}function Gk(e,t){return e.filter(e=>Kk(e.context?.locator,t)||Kk(e.context?.prerequisite,t))}function Kk(e,t){return!!e&&e.date===t.date&&e.venueId===t.venueId&&e.index===t.index}function qk(e){return e.length?e.some(e=>e.severity===`ERROR`)?`ERROR`:e.some(e=>e.severity===`WARN`)?`WARN`:`INFO`:null}function Jk(e,t){let n=zk(t);for(let t of e)for(let e of t.venues)for(let r=0;r<e.rounds.length;r++){let i=e.rounds[r];if(zk(Hk(i))===n)return{date:t.scheduleDate,venueId:e.venueId,index:r,roundKey:Hk(i),roundSegment:i.roundSegment}}return null}function Yk(){let e=document.createElement(`div`);e.className=WO();let t=document.createElement(`div`);t.className=GO();let n=document.createElement(`div`);n.className=KO(),n.textContent=`Inspector`,t.appendChild(n),e.appendChild(t);let r=document.createElement(`div`);r.className=Tk(),e.appendChild(r);function i(e){r.innerHTML=``;let t=e.selectedLocator;if(!t){let e=document.createElement(`div`);e.className=kk(),e.textContent=`Select a round card on the board to see details and context.`,r.appendChild(e);return}let n=Wk(e.profileDraft,t);if(!n){let e=document.createElement(`div`);e.className=kk(),e.textContent=`Selection no longer exists.`,r.appendChild(e);return}let i=Gk(e.ruleResults,t),a=qk(i);if(Xk(r,`Event`,n.eventName??``),Xk(r,`Draw`,n.drawName||``),Xk(r,`Round`,n.roundName&&!/^rn=/.test(n.roundName)?n.roundName:`Round `+n.roundNumber),Xk(r,`Segment`,n.roundSegment?`${n.roundSegment.segmentNumber}/${n.roundSegment.segmentsCount}`:`—`),Xk(r,`Not before`,n.notBeforeTime??`—`),Xk(r,`Status`,a??`OK`),i.length){let e=document.createElement(`div`);e.className=kk(),e.style.marginTop=`8px`,e.textContent=`Issues for this item:`,r.appendChild(e);for(let e of i){let t=document.createElement(`div`);t.className=kk(),t.innerHTML=`\u2022 <b>${Zk(e.code)}</b>: ${Zk(e.message)}`,r.appendChild(t)}}else{let e=document.createElement(`div`);e.className=kk(),e.style.marginTop=`8px`,e.textContent=`No issues associated with this card.`,r.appendChild(e)}}return{element:e,update:i}}function Xk(e,t,n){let r=document.createElement(`div`);r.className=Ek();let i=document.createElement(`div`);i.className=Dk(),i.textContent=t;let a=document.createElement(`div`);a.className=Ok(),a.textContent=n,r.appendChild(i),r.appendChild(a),e.appendChild(r)}function Zk(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function Qk(e,t,n,r=`dim`){let i=t.toLowerCase().trim();return e.filter(e=>r===`hide`&&n.has(zk(e))?!1:i?`${e.eventName} ${e.drawName??``} ${e.roundName??``} ${e.drawId}`.toLowerCase().includes(i):!0).map(e=>({...e,isPlanned:n.has(zk(e))}))}function $k(e,t){let n=new Map,r=e=>t===`draw`?`${e.eventName} \u2014 ${e.drawName??e.drawId}`:t===`round`?e.roundName??`Round ${e.roundNumber}`:e.eventName;for(let t of e){let e=r(t),i=n.get(e);i?i.push(t):n.set(e,[t])}return new Map([...n.entries()].sort((e,t)=>e[0].localeCompare(t[0],void 0,{numeric:!0})))}function eA(e){let t=new Set;for(let n of e)for(let e of n.venues)for(let n of e.rounds)n.roundSegment||t.add(zk(n));return t}var tA=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function nA(e){return tA.test(e)}function rA(e){let t=document.createElement(`div`);t.className=WO(),t.style.overflowY=`auto`,t.style.scrollbarWidth=`thin`,t.style.scrollbarColor=`var(--sp-scrollbar) transparent`;let n=new Set,r=null,i=document.createElement(`div`);i.className=GO();let a=document.createElement(`div`);a.className=KO(),a.textContent=`Round Catalog`;let o=document.createElement(`div`);o.className=qO(),i.appendChild(a),i.appendChild(o),t.appendChild(i);let s=document.createElement(`div`);s.className=vk();let c=document.createElement(`input`);c.type=`text`,c.placeholder=`Search rounds...`,c.className=yk(),c.addEventListener(`input`,()=>e.onSearchChange(c.value));let l=gy(c,()=>{c.value=``,e.onSearchChange(``),c.focus()}),u=document.createElement(`select`);u.className=bk();for(let[e,t]of[[`event`,`By Event`],[`draw`,`By Draw`],[`round`,`By Round`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,u.appendChild(n)}u.addEventListener(`change`,()=>e.onGroupByChange(u.value)),s.appendChild(l),s.appendChild(u),t.appendChild(s);let d=document.createElement(`div`);d.className=_k(),t.appendChild(d),d.addEventListener(`dragover`,e=>{e.preventDefault(),d.classList.add(`over`),e.dataTransfer.dropEffect=`move`}),d.addEventListener(`dragleave`,e=>{d.contains(e.relatedTarget)||d.classList.remove(`over`)}),d.addEventListener(`drop`,t=>{if(d.classList.remove(`over`),t.preventDefault(),!e.onDropRemove)return;let n;try{n=JSON.parse(t.dataTransfer.getData(`application/json`))}catch{return}n.type===`PLANNED_ROUND`&&e.onDropRemove(n.locator)});function f(t,n){let r=document.createElement(`div`);r.className=wk(),t.isPlanned?(r.classList.add(n===`navigate`?`navigate`:`dimmed`),r.draggable=!1,n===`navigate`&&r.addEventListener(`click`,()=>{e.onNavigateToPlanned?.(t)})):(r.draggable=!0,r.addEventListener(`dragstart`,e=>{e.stopPropagation(),e.dataTransfer.setDragImage(r,r.offsetWidth/2,20),e.dataTransfer.setData(`application/json`,JSON.stringify({type:`CATALOG_ROUND`,roundRef:t})),e.dataTransfer.effectAllowed=`copyMove`}));let i=document.createElement(`div`);i.className=lk();let a=t.roundName&&!t.roundName.startsWith(`rn=`)?t.roundName:`Round `+t.roundNumber;i.textContent=`${t.eventName} \u2014 ${a}`;let o=document.createElement(`div`);o.className=uk();let s=t.matchCountEstimate?` · `+t.matchCountEstimate+` matches`:``,c=t.drawName&&!nA(t.drawName)?t.drawName:``;if(o.textContent=c?`${c}${s}`:s.replace(` · `,``)||``,r.appendChild(i),r.appendChild(o),t.isPlanned&&n!==`navigate`){let e=document.createElement(`span`);e.className=`sp-catalog-check`,e.textContent=`✓`,r.appendChild(e)}return r}function p(e){r=e;let t=e.plannedRoundBehavior,i=eA(e.profileDraft),a=Qk(e.roundCatalog,e.catalogSearchQuery,i,t),s=$k(a,e.catalogGroupBy);o.textContent=`${a.length} rounds`,c.value!==e.catalogSearchQuery&&(c.value=e.catalogSearchQuery,_y(l)),u.value!==e.catalogGroupBy&&(u.value=e.catalogGroupBy),d.innerHTML=``;for(let[e,i]of s){let a=document.createElement(`div`);a.className=xk();let o=n.has(e),s=document.createElement(`div`);s.className=Sk();let c=document.createElement(`span`);c.className=Pk(),c.textContent=o?`▶`:`▼`;let l=document.createElement(`span`);l.textContent=e,s.appendChild(c),s.appendChild(l),s.addEventListener(`click`,()=>{n.has(e)?n.delete(e):n.add(e),r&&p(r)});let u=document.createElement(`div`);u.className=Ck(),o&&(u.style.display=`none`);for(let e of i)u.appendChild(f(e,t));a.appendChild(s),a.appendChild(u),d.appendChild(a)}}return{element:t,update:p}}function iA(e){let t=document.createElement(`div`);t.className=WO();let n=document.createElement(`div`);n.className=GO();let r=document.createElement(`div`);r.className=KO(),r.textContent=`Issues`;let i=document.createElement(`div`);i.className=qO(),n.appendChild(r),n.appendChild(i),t.appendChild(n);let a=document.createElement(`div`);a.className=dk(),t.appendChild(a);function o(t){let n=t.issueIndex.all;if(i.textContent=`${n.length} total (${t.issueIndex.bySeverity.ERROR.length} errors)`,a.innerHTML=``,!n.length){let e=document.createElement(`div`);e.className=kk(),e.textContent=`No issues. Drag rounds into the board to build a profile.`,a.appendChild(e);return}for(let t of n.slice(0,30)){let n=document.createElement(`div`);n.className=fk(),t.severity===`ERROR`?n.classList.add(`error`):t.severity===`WARN`?n.classList.add(`warn`):n.classList.add(`info`);let r=document.createElement(`div`);r.className=pk(),r.textContent=`${t.severity} \u00b7 ${t.code}`;let i=document.createElement(`div`);if(i.className=mk(),i.textContent=t.message,n.appendChild(r),n.appendChild(i),t.fixActions?.length){let r=document.createElement(`div`);r.className=hk();for(let n of t.fixActions){let t=document.createElement(`button`);t.className=gk(),t.textContent=n.label??n.kind,t.addEventListener(`click`,()=>e.onFixAction(n)),r.appendChild(t)}n.appendChild(r)}a.appendChild(n)}}return{element:t,update:o}}var{ROUND_ROBIN:aA,ROUND_ROBIN_WITH_PLAYOFF:oA}=t.drawDefinitionConstants,sA=`Jump to prerequisite`;function cA({profile:e,temporal:t,dependencies:n,venueOrder:r}){let i=[];if(t?.isDateAvailable)for(let n of e){let e=t.isDateAvailable(n.scheduleDate);e.ok||i.push({code:`DATE_UNAVAILABLE`,severity:`ERROR`,message:`Can't schedule on ${n.scheduleDate} \u2014 day is unavailable${e.reason?`: `+e.reason:``}.`,context:{date:n.scheduleDate},fixActions:[{kind:`OPEN_TEMPORAL_GRID`,date:n.scheduleDate,label:`Open Temporal Grid`}]})}let a=gA(e);for(let e of a){let t=e.round.roundSegment;t&&(Number.isInteger(t.segmentNumber)&&Number.isInteger(t.segmentsCount)&&t.segmentsCount>=2&&t.segmentNumber>=1&&t.segmentNumber<=t.segmentsCount||i.push({code:`INVALID_SEGMENT_CONFIG`,severity:`ERROR`,message:`Invalid segment configuration for ${Bk(e.round)}.`,context:{locator:e.locator,date:e.locator.date,venueId:e.locator.venueId}}))}let o=new Map,s=new Map;for(let e of a){let t=e.round,n=zk(t);if(!t.roundSegment)o.has(n)?i.push({code:`DUPLICATE_ROUND`,severity:`ERROR`,message:`Round is planned more than once: ${Bk(t)}.`,context:{scope:`${t.drawId}|${t.structureId}`,locator:e.locator,date:e.locator.date,venueId:e.locator.venueId},fixActions:[{kind:`JUMP_TO_ITEM`,locator:o.get(n),label:`Jump to existing`}]}):o.set(n,e.locator);else{let r=`${n}|${t.roundSegment.segmentNumber}/${t.roundSegment.segmentsCount}`;s.has(r)?i.push({code:`DUPLICATE_SEGMENT`,severity:`ERROR`,message:`Segment planned more than once: ${Bk(t)}.`,context:{scope:`${t.drawId}|${t.structureId}`,locator:e.locator,date:e.locator.date,venueId:e.locator.venueId},fixActions:[{kind:`JUMP_TO_ITEM`,locator:s.get(r),label:`Jump to existing`}]}):s.set(r,e.locator)}}return i.push(...uA({profile:e,venueOrder:r})),n?.getRoundDependencies&&i.push(...mA(a,n)),i}var lA=new Set([aA,oA]);function uA({profile:e}){let t=gA(e),n=dA(t),r=fA(t);return vA([...n,...r])}function dA(e){let t=[],n=_A(e,e=>`${e.round.structureId}|${e.locator.date}|${e.locator.venueId}`);for(let[e,r]of n.entries()){let n=r[0]?.round.structureType;if(!(n&&lA.has(n))){r.sort((e,t)=>e.locator.index-t.locator.index);for(let n=0;n<r.length;n++){let i=r[n],a=null;for(let e=n-1;e>=0;e--)if(r[e].round.roundNumber>i.round.roundNumber){a=r[e];break}if(!a)continue;let o=hA(r,n,a);t.push({code:`ROUND_ORDER_VIOLATION`,severity:`ERROR`,message:`Cannot place ${Bk(i.round)} before ${Bk(a.round)} in this venue.`,context:{scope:e,drawId:i.round.drawId,structureId:i.round.structureId,date:i.locator.date,venueId:i.locator.venueId,locator:i.locator,prerequisite:a.locator},fixActions:[{kind:`JUMP_TO_ITEM`,locator:a.locator,label:sA},...o.moveOffenderAfter?[{kind:`MOVE_ITEM_AFTER`,locator:i.locator,after:o.moveOffenderAfter,label:`Move offending round after prerequisite set`}]:[],...o.movePrereqBefore?[{kind:`MOVE_ITEM_BEFORE`,locator:a.locator,before:o.movePrereqBefore,label:`Move prerequisite before offending round`}]:[]]})}}}return t}function fA(e){let t=[],n=_A(e,e=>e.round.structureId);for(let[e,r]of n.entries()){let n=r[0]?.round.structureType;if(n&&lA.has(n))continue;let i=new Map;for(let e of r){let t=e.locator.date,n=i.get(t);n?n.push(e):i.set(t,[e])}let a=[...i.keys()].sort();if(a.length<2)continue;let o=-1/0,s=null;for(let n of a){let r=i.get(n);for(let i of r)i.round.roundNumber<o&&s&&t.push({code:`ROUND_ORDER_VIOLATION`,severity:`ERROR`,message:`${Bk(s.round)} is scheduled on ${s.locator.date} but its prerequisite ${Bk(i.round)} is on the later date ${n}.`,context:{scope:`cross-date|${e}`,drawId:s.round.drawId,structureId:e,date:s.locator.date,venueId:s.locator.venueId,locator:s.locator,prerequisite:i.locator,reason:`cross-date`},fixActions:[{kind:`JUMP_TO_ITEM`,locator:i.locator,label:sA}]});for(let e of r)e.round.roundNumber>o&&(o=e.round.roundNumber,s=e)}}return t}function pA(e,t){if(!(e.round.structureId===t.round.structureId&&e.locator.date===t.locator.date&&e.locator.venueId===t.locator.venueId)){if(e.locator.date<t.locator.date)return{code:`DEPENDENCY_VIOLATION`,severity:`ERROR`,message:`${Bk(e.round)} is scheduled on ${e.locator.date} but depends on ${Bk(t.round)} which is on the later date ${t.locator.date}.`,context:{date:e.locator.date,venueId:e.locator.venueId,locator:e.locator,prerequisite:t.locator,reason:`cross-date`},fixActions:[{kind:`JUMP_TO_ITEM`,locator:t.locator,label:sA}]};if(e.locator.date===t.locator.date&&e.locator.venueId===t.locator.venueId&&e.locator.index<t.locator.index)return{code:`DEPENDENCY_VIOLATION`,severity:`ERROR`,message:`${Bk(e.round)} is listed before its prerequisite ${Bk(t.round)} in the same venue on ${e.locator.date}.`,context:{date:e.locator.date,venueId:e.locator.venueId,locator:e.locator,prerequisite:t.locator,reason:`cross-structure-same-day`},fixActions:[{kind:`JUMP_TO_ITEM`,locator:t.locator,label:sA},{kind:`MOVE_ITEM_AFTER`,locator:e.locator,after:t.locator,label:`Move after prerequisite`},{kind:`MOVE_ITEM_BEFORE`,locator:t.locator,before:e.locator,label:`Move prerequisite before`}]}}}function mA(e,t){let n=[],r=_A(e,e=>zk(e.round));for(let[e,i]of r.entries()){let a=t.getRoundDependencies(e);if(a.length)for(let e of a){let t=r.get(e);if(t)for(let e of i)for(let r of t){let t=pA(e,r);t&&n.push(t)}}}return vA(n)}function hA(e,t,n){let r=e[t],i=e.indexOf(n);for(let t=i+1;t<e.length;t++)e[t].round.roundNumber>=n.round.roundNumber&&(i=t);return{moveOffenderAfter:e[i].locator,movePrereqBefore:r.locator}}function gA(e){let t=[];for(let n of e)for(let e of n.venues)for(let r=0;r<e.rounds.length;r++){let i=e.rounds[r];t.push({round:i,locator:{date:n.scheduleDate,venueId:e.venueId,index:r,roundKey:Hk(i),roundSegment:i.roundSegment}})}return t}function _A(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i?i.push(r):n.set(e,[r])}return n}function vA(e){let t=new Set,n=[];for(let r of e){let e=r.code+`|`+r.message+`|`+(r.context?.scope??``)+`|`+JSON.stringify(r.context?.locator??{});t.has(e)||(t.add(e),n.push(r))}return n}function yA(e){let t={ERROR:[],WARN:[],INFO:[]},n={},r={},i={},a={total:e.length,ERROR:0,WARN:0,INFO:0,byDate:{},byVenue:{},byDraw:{}},o=e=>e===`ERROR`?0:e===`WARN`?1:2,s=(e,t)=>o(e.severity)-o(t.severity)||e.code.localeCompare(t.code)||e.message.localeCompare(t.message);for(let o of e){t[o.severity].push(o),a[o.severity]++;let e=o.context?.date??o.context?.locator?.date,s=o.context?.venueId??o.context?.locator?.venueId,c=o.context?.scope??(o.context?.drawId&&o.context?.structureId?`${o.context.drawId}|${o.context.structureId}`:void 0);e&&(n[e]??=[]).push(o),s&&(r[s]??=[]).push(o),c&&(i[c]??=[]).push(o),bA(a.byDate,e,o.severity),bA(a.byVenue,s,o.severity),bA(a.byDraw,c,o.severity)}for(let e of Object.keys(t))t[e].sort(s);for(let e of[n,r,i])for(let t of Object.keys(e))e[t].sort(s);return{all:e,bySeverity:t,byDate:n,byVenue:r,byDraw:i,counts:a}}function bA(e,t,n){if(!t)return;let r=e[t]??={total:0,ERROR:0,WARN:0,INFO:0};r.total++,r[n]++}function xA(e,t,n){let r=Lk(e),{date:i,venueId:a}=n,o=CA(SA(r,i),a);if(t.type===`CATALOG_ROUND`){let e={tournamentId:t.roundRef.tournamentId,eventId:t.roundRef.eventId,eventName:t.roundRef.eventName,drawId:t.roundRef.drawId,drawName:t.roundRef.drawName,structureId:t.roundRef.structureId,structureType:t.roundRef.structureType,roundNumber:t.roundRef.roundNumber,roundName:t.roundRef.roundName},i=Rk(n.index,0,o.rounds.length);return o.rounds.splice(i,0,e),wA(o.rounds),{ok:!0,profile:r}}if(t.type===`PLANNED_ROUND`){let{locator:e}=t,s=CA(SA(r,e.date),e.venueId),[c]=s.rounds.splice(e.index,1);wA(s.rounds);let l=n.index;return e.date===i&&e.venueId===a&&e.index<l&&--l,l=Rk(l,0,o.rounds.length),o.rounds.splice(l,0,c),wA(o.rounds),{ok:!0,profile:r}}return{ok:!1,profile:e}}function SA(e,t){let n=e.find(e=>e.scheduleDate===t);return n||(n={scheduleDate:t,venues:[]},e.push(n),e.sort((e,t)=>e.scheduleDate.localeCompare(t.scheduleDate))),n}function CA(e,t){let n=e.venues.find(e=>e.venueId===t);return n||(n={venueId:t,rounds:[]},e.venues.push(n)),n}function wA(e){for(let t=0;t<e.length;t++)e[t].sortOrder=t+1}var TA=class{constructor(e){this.listeners=new Set,this.config=e;let t={all:[],bySeverity:{ERROR:[],WARN:[],INFO:[]},byDate:{},byVenue:{},byDraw:{},counts:{total:0,ERROR:0,WARN:0,INFO:0,byDate:{},byVenue:{},byDraw:{}}};this.state={profileDraft:Lk(e.initialProfile??[]),venues:e.venues,roundCatalog:e.roundCatalog,schedulableDates:e.schedulableDates,activeDates:e.activeDates,selectedDate:e.selectedDate??e.schedulableDates[0]??null,selectedLocator:null,ruleResults:[],issueIndex:t,catalogSearchQuery:``,catalogGroupBy:`event`,plannedRoundBehavior:e.plannedRoundBehavior??`dim`},this.revalidate()}getState(){return this.state}getSchedulingProfile(){return Lk(this.state.profileDraft)}selectDate(e){this.state.selectedDate!==e&&this.setState({selectedDate:e,selectedLocator:null})}selectCard(e){this.setState({selectedLocator:e})}setCatalogSearch(e){this.setState({catalogSearchQuery:e})}setCatalogGroupBy(e){this.setState({catalogGroupBy:e})}navigateToRound(e){let t=Jk(this.state.profileDraft,{tournamentId:e.tournamentId,eventId:e.eventId,drawId:e.drawId,structureId:e.structureId,roundNumber:e.roundNumber});t&&this.setState({selectedDate:t.date,selectedLocator:t})}dropRound(e,t){try{let n=xA(this.state.profileDraft,e,t);if(!n.ok)return{ok:!1,errorMessage:`Invalid drop operation`};let r=new Set(this.state.ruleResults.filter(e=>e.severity===`ERROR`).map(EA)),i=cA({profile:n.profile,temporal:this.config.temporalAdapter,dependencies:this.config.dependencyAdapter,venueOrder:this.config.venueOrder}).filter(e=>e.severity===`ERROR`).filter(e=>!r.has(EA(e)));return i.length?(this.addRejectionNotice(i[0].message),{ok:!1,errorMessage:i[0].message}):(this.commitProfile(n.profile),{ok:!0})}catch(e){return{ok:!1,errorMessage:String(e)}}}removeRound(e){let t=Lk(this.state.profileDraft),n=t.find(t=>t.scheduleDate===e.date);if(!n)return;let r=n.venues.find(t=>t.venueId===e.venueId);if(r&&!(e.index<0||e.index>=r.rounds.length)){r.rounds.splice(e.index,1);for(let e=0;e<r.rounds.length;e++)r.rounds[e].sortOrder=e+1;this.commitProfile(t),this.state.selectedLocator?.date===e.date&&this.state.selectedLocator?.venueId===e.venueId&&this.state.selectedLocator?.index===e.index&&this.setState({selectedLocator:null})}}setNotBeforeTime(e,t){let n=Lk(this.state.profileDraft),r=n.find(t=>t.scheduleDate===e.date);if(!r)return;let i=r.venues.find(t=>t.venueId===e.venueId);if(!i)return;let a=i.rounds[e.index];a&&(t?a.notBeforeTime=t:delete a.notBeforeTime,this.commitProfile(n))}applyFixAction(e){if(e.kind===`JUMP_TO_ITEM`&&e.locator){this.setState({selectedDate:e.locator.date,selectedLocator:e.locator});return}if(e.kind===`OPEN_TEMPORAL_GRID`){this.config.onFixAction?.(e);return}if(e.kind===`MOVE_ITEM_AFTER`&&e.locator&&e.after){let t=DA(this.state.profileDraft,e.locator,e.after);this.commitProfile(t);return}if(e.kind===`MOVE_ITEM_BEFORE`&&e.locator&&e.before){let t=OA(this.state.profileDraft,e.locator,e.before);this.commitProfile(t);return}this.config.onFixAction?.(e)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state={...this.state,...e},this.emit()}commitProfile(e){this.state={...this.state,profileDraft:e},this.revalidate(),this.config.onProfileChanged?.(Lk(e))}addRejectionNotice(e){let t={code:`DROP_REJECTED`,severity:`WARN`,message:`Drop rejected: ${e}`,context:{}},n=[...this.state.ruleResults.filter(e=>e.code!==`DROP_REJECTED`),t],r=yA(n);this.state={...this.state,ruleResults:n,issueIndex:r},this.emit()}revalidate(){let e=cA({profile:this.state.profileDraft,temporal:this.config.temporalAdapter,dependencies:this.config.dependencyAdapter,venueOrder:this.config.venueOrder}),t=yA(e);this.state={...this.state,ruleResults:e,issueIndex:t},this.emit()}emit(){for(let e of this.listeners)e(this.state)}};function EA(e){return`${e.code}|${e.context?.scope??``}|${e.context?.structureId??``}|${e.context?.date??``}`}function DA(e,t,n){let r=Lk(e),i=kA(r,t);if(!i)return e;let a=AA(r,n.date,n.venueId),o=Math.min(a.length,n.index+1);return a.splice(o,0,i),r}function OA(e,t,n){let r=Lk(e),i=kA(r,t);if(!i)return e;let a=AA(r,n.date,n.venueId),o=Math.max(0,Math.min(a.length,n.index));return a.splice(o,0,i),r}function kA(e,t){let n=e.find(e=>e.scheduleDate===t.date);if(!n)return null;let r=n.venues.find(e=>e.venueId===t.venueId);return!r||t.index<0||t.index>=r.rounds.length?null:r.rounds.splice(t.index,1)[0]}function AA(e,t,n){let r=e.find(e=>e.scheduleDate===t);r||(r={scheduleDate:t,venues:[]},e.push(r));let i=r.venues.find(e=>e.venueId===n);return i||(i={venueId:n,rounds:[]},r.venues.push(i)),i.rounds}function jA(e,t){let{round:n,locator:r,isSelected:i,severity:a}=e,o=document.createElement(`div`);o.className=ck(),i&&o.classList.add(`selected`),a===`ERROR`?o.classList.add(`error`):a===`WARN`&&o.classList.add(`warn`),o.draggable=!0,o.addEventListener(`dragstart`,e=>{e.stopPropagation(),e.dataTransfer.setDragImage(o,o.offsetWidth/2,20),e.dataTransfer.setData(`application/json`,JSON.stringify({type:`PLANNED_ROUND`,locator:r})),e.dataTransfer.effectAllowed=`copyMove`}),o.addEventListener(`click`,e=>{e.stopPropagation(),t.onClick(r)}),t.onContextMenu&&o.addEventListener(`contextmenu`,e=>{e.preventDefault(),e.stopPropagation(),t.onContextMenu(r,o)});let s=document.createElement(`div`);s.className=lk();let c=n.roundName&&!n.roundName.startsWith(`rn=`)?n.roundName:`Round `+n.roundNumber;s.textContent=(n.eventName?n.eventName+` — `:``)+c,o.appendChild(s);let l=document.createElement(`div`);l.className=uk(),l.textContent=[n.drawName||``,n.matchCountEstimate?`${n.matchCountEstimate} matches`:``].filter(Boolean).join(` · `),o.appendChild(l);let u=document.createElement(`div`);return u.className=ek(),n.roundSegment&&u.appendChild(MA(`Seg ${n.roundSegment.segmentNumber}/${n.roundSegment.segmentsCount}`,`seg`)),n.notBeforeTime&&u.appendChild(MA(`NB ${n.notBeforeTime}`,`nb`)),a===`ERROR`?u.appendChild(MA(`Error`,`err`)):a===`WARN`&&u.appendChild(MA(`Warn`,`warn`)),u.children.length&&o.appendChild(u),o}function MA(e,t){let n=document.createElement(`div`);return n.className=tk()+` `+t,n.textContent=e,n}function NA(e,t){let n=document.createElement(`div`);n.className=WO();let r=document.createElement(`div`);r.className=GO();let i=t?.titleLeadingActions,a=document.createElement(`div`);if(a.className=KO(),a.textContent=`Day Plan`,i){let e=document.createElement(`div`);e.className=YO();let t=Array.isArray(i)?i:[i];for(let n of t)e.appendChild(n);e.appendChild(a),r.appendChild(e)}else r.appendChild(a);let o=t?.headerActions;if(o){let e=document.createElement(`div`);e.className=JO();let t=Array.isArray(o)?o:[o];for(let n of t)e.appendChild(n);r.appendChild(e)}n.appendChild(r);let s=document.createElement(`div`);s.className=nk(),n.appendChild(s);function c(t){let n=t.selectedDate;s.innerHTML=``;let r=Math.max(1,t.venues.length);r>4?(s.classList.add(`sp-board-scroll`),s.style.gridTemplateColumns=``):(s.classList.remove(`sp-board-scroll`),s.style.gridTemplateColumns=`repeat(${r}, 1fr)`);for(let r of t.venues){let i=document.createElement(`div`);i.className=rk();let a=document.createElement(`div`);a.className=ik();let o=document.createElement(`div`),c=document.createElement(`div`);c.className=ak(),c.textContent=r.name;let l=document.createElement(`div`);l.className=ok(),l.textContent=``,o.appendChild(c),o.appendChild(l);let u=t.issueIndex.counts.byVenue[r.venueId],d=document.createElement(`div`);d.className=$O(),u?.ERROR?(d.classList.add(`err`),d.textContent=`${u.ERROR} err`):u?.WARN?(d.classList.add(`warn`),d.textContent=`${u.WARN} warn`):(d.classList.add(`ok`),d.textContent=`OK`),a.appendChild(o),a.appendChild(d);let f=document.createElement(`div`);if(f.className=sk(),f.dataset.venue=r.venueId,n){let i=Uk(t.profileDraft,n,r.venueId);if(!i.length){let e=document.createElement(`div`);e.className=kk(),e.textContent=`Drop rounds here.`,f.appendChild(e)}i.forEach((i,a)=>{let o={date:n,venueId:r.venueId,index:a,roundKey:Hk(i),roundSegment:i.roundSegment},s=qk(Gk(t.ruleResults,o)),c=jA({round:i,locator:o,isSelected:Vk(t.selectedLocator,o),severity:s},{onClick:e.onCardClick,onContextMenu:e.onCardContextMenu});f.appendChild(c)})}else{let e=document.createElement(`div`);e.className=kk(),e.textContent=`Select a date to plan.`,f.appendChild(e)}let p=document.createElement(`div`);p.className=Nk(),p.style.display=`none`,f.addEventListener(`dragover`,e=>{if(!n)return;e.preventDefault(),f.classList.add(`over`),e.dataTransfer.dropEffect=`move`;let t=FA(f,e.clientY,p),r=PA(f,p);p.style.display=``,t<r.length?f.insertBefore(p,r[t]):f.appendChild(p)}),f.addEventListener(`dragleave`,e=>{f.contains(e.relatedTarget)||(f.classList.remove(`over`),p.style.display=`none`)}),f.addEventListener(`drop`,t=>{if(f.classList.remove(`over`),p.style.display=`none`,t.preventDefault(),!n)return;let i;try{i=JSON.parse(t.dataTransfer.getData(`application/json`))}catch{return}let a=FA(f,t.clientY,p),o={date:n,venueId:r.venueId,index:a};e.onDrop(i,o)}),i.appendChild(a),i.appendChild(f),s.appendChild(i)}}return{element:n,update:c}}function PA(e,t){return Array.from(e.querySelectorAll(`[draggable="true"]`)).filter(e=>e!==t)}function FA(e,t,n){let r=PA(e,n);for(let e=0;e<r.length;e++){let n=r[e].getBoundingClientRect();if(t<n.top+n.height/2)return e}return r.length}function IA(e){let t=document.createElement(`div`);t.className=WO();let n=document.createElement(`div`);n.className=GO();let r=document.createElement(`div`);r.className=KO(),r.textContent=`Dates`;let i=document.createElement(`div`);i.className=qO(),n.appendChild(r),n.appendChild(i),t.appendChild(n);let a=document.createElement(`div`);a.className=XO(),t.appendChild(a);function o(t){i.textContent=`${t.schedulableDates.length} schedulable`,a.innerHTML=``;let n=t.activeDates?new Set(t.activeDates):null;for(let r of t.schedulableDates){let i=!n||n.has(r),o=t.issueIndex.counts.byDate[r],s=document.createElement(`div`);s.className=ZO(),r===t.selectedDate&&s.classList.add(`selected`),i||s.classList.add(`inactive`),s.setAttribute(`data-date`,r);let c=document.createElement(`div`),l=document.createElement(`div`);l.style.cssText=`font-weight:800;font-size:12px`,l.textContent=r;let u=document.createElement(`div`);u.style.cssText=`font-size:11px;color:var(--sp-muted)`,u.textContent=i?`Active`:`Inactive`,c.appendChild(l),c.appendChild(u);let d=document.createElement(`div`);d.className=QO(),o?.ERROR&&d.appendChild(LA(`${o.ERROR} err`,`err`)),o?.WARN&&d.appendChild(LA(`${o.WARN} warn`,`warn`)),!o?.ERROR&&!o?.WARN&&d.appendChild(LA(`OK`,`ok`)),s.appendChild(c),s.appendChild(d),s.addEventListener(`click`,()=>e.onDateSelected(r)),a.appendChild(s)}}return{element:t,update:o}}function LA(e,t){let n=document.createElement(`div`);return n.className=$O()+` `+t,n.textContent=e,n}var RA=class{constructor(e){this.container=null,this.store=new TA(e),this.popover=Ik({onDelete:e=>{this.store.removeRound(e)},onSetNotBeforeTime:e=>{let t=prompt(`Enter not-before time (HH:MM):`,`10:00`);t!==null&&this.store.setNotBeforeTime(e,t||void 0)}});let t=IA({onDateSelected:e=>this.store.selectDate(e)}),n=iA({onFixAction:e=>this.store.applyFixAction(e)}),r=NA({onDrop:(e,t)=>{this.store.dropRound(e,t)},onCardClick:e=>this.store.selectCard(e),onCardContextMenu:(e,t)=>{this.popover.show(t,e)}},{headerActions:e.headerActions,titleLeadingActions:e.titleLeadingActions}),i=rA({onSearchChange:e=>this.store.setCatalogSearch(e),onGroupByChange:e=>this.store.setCatalogGroupBy(e),onDropRemove:e=>this.store.removeRound(e),onNavigateToPlanned:e=>this.store.navigateToRound(e)}),a=Yk();this.layout=Fk({dateStrip:t,issuesPanel:n,venueBoard:r,roundCatalog:i,inspectorPanel:a},{hideLeft:e.hideLeft,catalogSide:e.catalogSide}),this.unsubscribe=this.store.subscribe(e=>{this.layout.update(e)}),this.layout.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.layout.element)}destroy(){this.unsubscribe(),this.popover.destroy(),this.container&&this.layout.element.parentNode===this.container&&this.layout.element.remove(),this.container=null}getProfile(){return this.store.getSchedulingProfile()}getStore(){return this.store}};function zA(e,t){let n=new RA(e);return n.render(t),n}var BA=class{constructor(){this.selectedDay=null,this.selectedVenue=null,this.selectedCourt=null,this.layerVisibility=new Map,this.listeners=new Set}setSelectedDay(e){this.selectedDay!==e&&(this.selectedDay=e,this.emit({selectedDay:e}))}getSelectedDay(){return this.selectedDay}setSelectedVenue(e){this.selectedVenue!==e&&(this.selectedVenue=e,this.emit({selectedVenue:e}))}getSelectedVenue(){return this.selectedVenue}setSelectedCourt(e){this.selectedCourt!==e&&(this.selectedCourt=e,this.emit({selectedCourt:e}))}getSelectedCourt(){return this.selectedCourt}setLayerVisibility(e,t){this.layerVisibility.set(e,t),this.emit({layerVisibility:new Map(this.layerVisibility)})}getLayerVisibility(){return new Map(this.layerVisibility)}isLayerVisible(e){return this.layerVisibility.get(e)??!0}getSnapshot(){return{selectedDay:this.selectedDay,selectedVenue:this.selectedVenue,selectedCourt:this.selectedCourt,layerVisibility:new Map(this.layerVisibility)}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(e){let t={type:`VIEW_CHANGED`,payload:e};for(let e of this.listeners)e(t)}},VA={AVAILABLE:`rgba(33, 141, 141, 0.15)`,BLOCKED:`#95a5a6`,PRACTICE:`#9b59b6`,MAINTENANCE:`#f39c12`,RESERVED:`#3498db`,CLOSED:`#2c3e50`,SCHEDULED:`#27ae60`,SOFT_BLOCK:`#5dade2`,HARD_BLOCK:`#e74c3c`,LOCKED:`#34495e`,UNSPECIFIED:`#ecf0f1`};function HA(e,t,n={}){let r=[],i=new Map;for(let e of t){let t=KA(e.ref);i.set(t,e)}let a=new Set;for(let t of e)for(let e of t.rails)a.add(KA(e.court));for(let e of a){let t=i.get(e);if(!t)continue;let n={id:e,content:t.name,courtRef:t.ref,surface:t.surface,indoor:t.indoor,hasLights:t.hasLights,tags:t.tags};r.push(n)}return r}function UA(e,t={}){let{layerVisibility:n=new Map,showSegmentLabels:r=!1,colorScheme:i=VA}=t,a=[];for(let t of e)for(let e of t.rails){let t=KA(e.court);for(let o of e.segments){if(!(n.get(o.status)??!0))continue;let e=`${t}-${o.start}-${o.status}`,s=i[o.status];a.push({id:e,group:t,content:r?WA(o):``,start:o.start,end:o.end,type:`background`,className:`temporal-segment segment-${o.status.toLowerCase()}`,style:s===`transparent`?void 0:`background-color: ${s};`,title:`${o.status} segment`,editable:!1,selectable:!1,status:o.status,contributingBlocks:o.contributingBlocks,isSegment:!0})}}return a}function WA(e){let t=Math.round((new Date(e.end).getTime()-new Date(e.start).getTime())/(1e3*60));return`${e.status} (${t}m)`}function GA(e,t={}){let{colorScheme:n=VA}=t,r=[];for(let t of e){let e=KA(t.court),i=n[t.type],a=qA(i,-20);r.push({id:`block-${t.id}`,group:e,content:t.reason||t.type,start:t.start,end:t.end,type:`range`,className:`temporal-block block-${t.type.toLowerCase()}`,style:`background-color: ${i}; border-color: ${a};`,title:t.reason||t.type,editable:{updateTime:!0,updateGroup:!0,remove:!1},blockId:t.id,status:t.type,reason:t.reason,isBlock:!0})}return r}function KA(e){return`${e.tournamentId}|${e.venueId}|${e.courtId}`}function qA(e,t){if(!e||!e.startsWith(`#`))return e;let n=parseInt(e.replace(`#`,``),16),r=Math.round(2.55*t),i=(n>>16)+r,a=(n>>8&255)+r,o=(n&255)+r;return`#`+(16777216+(i<255?i<1?0:i:255)*65536+(a<255?a<1?0:a:255)*256+(o<255?o<1?0:o:255)).toString(16).slice(1)}function JA(e){let t=e.split(`|`);return t.length===3?{tournamentId:t[0],venueId:t[1],courtId:t[2]}:null}function YA(e){let t=String(e);return t.startsWith(`block-`)?t.slice(6):null}function XA(e){let t=new Date(`${e.day}T${e.dayStartTime}:00`),n=new Date(`${e.day}T${e.dayEndTime}:00`);return{start:t,end:n,min:t,max:n,zoomMin:e.slotMinutes*4*60*1e3,zoomMax:(n.getTime()-t.getTime())*1.5}}var ZA=u({EventEmitter:()=>CM,PluginRegistry:()=>yj,TimepickerUI:()=>OM,default:()=>kM});function QA(e){let t=e.target,n=t.hasAttribute(`data-md3-ripple`)?t:t.closest(`[data-md3-ripple]`);if(!n||e.button!==0&&e.pointerType===`mouse`)return;let r=n.getBoundingClientRect(),i=Math.max(r.width,r.height)*2,a=e.clientX-r.left,o=e.clientY-r.top;n.style.setProperty(`--ripple-size`,`${i}px`),n.style.setProperty(`--ripple-x`,`${a}px`),n.style.setProperty(`--ripple-y`,`${o}px`),n.classList.remove(_M,vM),n.offsetWidth,n.classList.add(_M,vM),n._rippleHold=!0,yM=n}function $A(e){let t=e.target,n=(t.hasAttribute(`data-md3-ripple`)?t:t.closest(`[data-md3-ripple]`))||yM;n&&(n._rippleHold=!1,n.classList.remove(vM),setTimeout(()=>{n.classList.remove(_M),yM===n&&(yM=null)},1e3))}function ej(e){let t=e.currentTarget;!t||!t._rippleHold||(t._rippleHold=!1,t.classList.remove(vM),setTimeout(()=>{t.classList.remove(_M),yM===t&&(yM=null)},1e3))}function tj(e){if(ij()===!1)return;let t=e||document;t.addEventListener(`pointerdown`,QA),t.addEventListener(`pointerup`,$A),t.addEventListener(`pointercancel`,$A),t.querySelectorAll(`[data-md3-ripple]`).forEach(e=>{e.addEventListener(`mouseleave`,ej)})}function nj(e={}){let t={clock:{...wM.clock,...e.clock},ui:{...wM.ui,...e.ui},labels:{...wM.labels,...e.labels},behavior:{...wM.behavior,...e.behavior},callbacks:{...wM.callbacks,...e.callbacks},timezone:{...wM.timezone,...e.timezone},range:{...wM.range,...e.range},wheel:{...wM.wheel,...e.wheel},clearBehavior:{...wM.clearBehavior,...e.clearBehavior}},n=t.ui.mode;return(n===`wheel`||n===`compact-wheel`)&&(t.wheel={placement:n===`compact-wheel`?`auto`:void 0,hideFooter:void 0,commitOnScroll:void 0,ignoreOutsideClick:void 0,...t.wheel}),t}var rj,ij,aj,oj,sj,cj,lj,uj,dj,fj,pj,mj,hj,gj,_j,vj,yj,bj,xj,Sj,Cj,wj,Tj,Ej,Dj,Oj,kj,Aj,jj,Mj,Nj,Pj,Fj,Ij,Lj,Rj,zj,Bj,Vj,Hj,Uj,Wj,Gj,Kj,qj,Jj,Yj,Xj,Zj,Qj,$j,eM,tM,nM,rM,iM,aM,oM,sM,cM,lM,uM,dM,fM,pM,mM,hM,gM,_M,vM,yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM=c((()=>{rj=()=>typeof window>`u`,ij=()=>typeof document<`u`,aj=class{state;constructor(e,t,n,r){this.state={degreesHours:null,degreesMinutes:null,options:t,element:e,instanceId:n,isMobileView:!1,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isOpen:!1,isInitialized:!1,customId:r,eventHandlersRegistered:!1,isDestroyed:!1}}get degreesHours(){return this.state.degreesHours}get degreesMinutes(){return this.state.degreesMinutes}get options(){return this.state.options}get element(){return this.state.element}get instanceId(){return this.state.instanceId}get isMobileView(){return this.state.isMobileView}get isTouchMouseMove(){return this.state.isTouchMouseMove}get disabledTime(){return this.state.disabledTime}get cloned(){return this.state.cloned}get isModalRemove(){return this.state.isModalRemove}get isOpen(){return this.state.isOpen}get isInitialized(){return this.state.isInitialized}get customId(){return this.state.customId}get eventHandlersRegistered(){return this.state.eventHandlersRegistered}get isDestroyed(){return this.state.isDestroyed}setDegreesHours(e){this.state={...this.state,degreesHours:e}}setDegreesMinutes(e){this.state={...this.state,degreesMinutes:e}}setOptions(e){this.state={...this.state,options:e}}setIsMobileView(e){this.state={...this.state,isMobileView:e}}setIsTouchMouseMove(e){this.state={...this.state,isTouchMouseMove:e}}setDisabledTime(e){this.state={...this.state,disabledTime:e}}setCloned(e){this.state={...this.state,cloned:e}}setIsModalRemove(e){this.state={...this.state,isModalRemove:e}}setIsOpen(e){this.state={...this.state,isOpen:e}}setIsInitialized(e){this.state={...this.state,isInitialized:e}}setEventHandlersRegistered(e){this.state={...this.state,eventHandlersRegistered:e}}setIsDestroyed(e){this.state={...this.state,isDestroyed:e}}updateOptions(e){this.state={...this.state,options:{...this.state.options,clock:{...this.state.options.clock,...e.clock||{}},ui:{...this.state.options.ui,...e.ui||{}},labels:{...this.state.options.labels,...e.labels||{}},behavior:{...this.state.options.behavior,...e.behavior||{}},callbacks:{...this.state.options.callbacks,...e.callbacks||{}}}}}reset(){this.state={...this.state,degreesHours:null,degreesMinutes:null,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isOpen:!1,isInitialized:!1,isDestroyed:!0,eventHandlersRegistered:!1}}getModalElement(){return ij()===!1?null:document.querySelector(`[data-owner-id="${this.state.instanceId}"]`)}getInput(){return this.state.element?.querySelector(`input`)}getClockFace(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-clock-face.mobile`):e.querySelector(`.tp-ui-clock-face:not(.mobile)`):null}getClockHand(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-mobile-clock-wrapper .tp-ui-clock-hand`):e.querySelector(`.tp-ui-clock-hand:not(.mobile)`):null}getCircle(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-mobile-clock-wrapper .tp-ui-circle-hand`):e.querySelector(`.tp-ui-circle-hand:not(.mobile)`):null}getTipsWrapper(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper`):e.querySelector(`.tp-ui-tips-wrapper:not(.mobile)`):null}getTipsWrapperFor24h(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper-24h`):e.querySelector(`.tp-ui-tips-wrapper-24h:not(.mobile)`):null}getMinutes(){return this.getModalElement()?.querySelector(`.tp-ui-minutes`)||null}getHour(){return this.getModalElement()?.querySelector(`.tp-ui-hour`)||null}getAM(){return this.getModalElement()?.querySelector(`.tp-ui-am`)||null}getPM(){return this.getModalElement()?.querySelector(`.tp-ui-pm`)||null}getHourText(){return this.getModalElement()?.querySelector(`.tp-ui-hour-text`)||null}getMinutesText(){return this.getModalElement()?.querySelector(`.tp-ui-minute-text`)||null}getHeader(){return this.getModalElement()?.querySelector(`.tp-ui-header`)||null}getInputWrappers(){return this.getModalElement()?.querySelectorAll(`.tp-ui-input-wrapper`)||null}getDots(){return this.getModalElement()?.querySelector(`.tp-ui-dots`)||null}getMinutesTips(){return this.getModalElement()?.querySelector(`.tp-ui-minutes-time`)||null}getHourTips(){return this.getModalElement()?.querySelector(`.tp-ui-hour-time-12`)||null}getAllValueTips(){let e=this.getModalElement();return e?[...e.querySelectorAll(`.tp-ui-value-tips`),...e.querySelectorAll(`.tp-ui-value-tips-24h`)]:[]}getOpenElementData(){let e=this.state.element?.querySelectorAll(`[data-open]`);if(e?.length>0){let t=[];return e.forEach(({dataset:e})=>t.push(e.open??``)),[...new Set(t)]}return null}getOpenElement(){let e=this.getInput(),t=this.getOpenElementData();return t===null?(e?.setAttribute(`data-open`,`tp-ui-input`),[e]):t.map(e=>this.state.element?.querySelectorAll(`[data-open='${e}']`))[0]??``}getCancelButton(){return this.getModalElement()?.querySelector(`.tp-ui-cancel-btn`)||null}getOkButton(){return this.getModalElement()?.querySelector(`.tp-ui-ok-btn`)||null}getActiveTypeMode(){return this.getModalElement()?.querySelector(`.tp-ui-type-mode.active`)||null}getKeyboardClockIcon(){return this.getModalElement()?.querySelector(`.tp-ui-keyboard-icon-wrapper`)||null}getFooter(){return this.getModalElement()?.querySelector(`.tp-ui-footer`)||null}getWrapper(){return this.getModalElement()?.querySelector(`.tp-ui-wrapper`)||null}},oj={DEFAULT_DELAY:300,MODAL_ANIMATION:150,SCROLLBAR_RESTORE:400,MODAL_REMOVE:300,CLOCK_ANIMATION:600,TIPS_ANIMATION:401,MOBILE_TOGGLE:450,CLOCK_SCALE_DELAY:150,WRAPPER_TRANSITION:400,DROPDOWN_CLICK_DELAY:10},sj=class{core;emitter;timeouts=[];constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on(`animation:clock`,()=>{this.handleAnimationSwitchTipsMode()})}runWithAnimation(e,t=oj.MODAL_ANIMATION){if(this.core.options.ui.animation){let n=setTimeout(e,t);this.timeouts.push(n)}else e()}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}setAnimationToOpen(){this.clearAllTimeouts(),this.core.getModalElement()?.classList.add(`opacity`),this.runWithAnimation(()=>{this.core.getModalElement()?.classList.add(`show`)})}removeAnimationToClose(){this.clearAllTimeouts(),this.core.getModalElement()&&this.runWithAnimation(()=>{let e=this.core.getModalElement();e?.classList.remove(`show`),e?.classList.remove(`opacity`)})}handleAnimationClock(){this.core.options.ui.animation&&this.runWithAnimation(()=>{this.core.getClockFace()?.classList.add(`tp-ui-clock-animation`);let e=setTimeout(()=>{this.core.getClockFace()?.classList.remove(`tp-ui-clock-animation`)},oj.CLOCK_ANIMATION);this.timeouts.push(e)})}handleAnimationSwitchTipsMode(){let e=this.core.getClockHand();if(!e)return;this.emitter.emit(`animation:start`,{}),e.classList.add(`tp-ui-tips-animation`);let t=setTimeout(()=>{this.core.getClockHand()?.classList.remove(`tp-ui-tips-animation`),this.emitter.emit(`animation:end`,{})},oj.TIPS_ANIMATION);this.timeouts.push(t)}destroy(){this.clearAllTimeouts()}},cj=()=>{if(ij()===!1)return 0;let e=document.createElement(`div`);e.className=`tp-ui-measure`,document.body.appendChild(e);let t=e.getBoundingClientRect().width-e.clientWidth;return document.body.removeChild(e),t},lj=(e,t)=>e?e.classList.contains(t):!1,uj=(e,t)=>Array.from({length:Number(t)-Number(e)+1},(t,n)=>Number(e)+n),dj=(e,t)=>Array.from({length:Number(t)-Number(e)+1},(e,n)=>Number(t)-n).reverse(),fj=(e=``)=>{let t=e.replace(/(AM|PM|am|pm)/,e=>` ${e}`),n=new Date(`September 20, 2000 ${t}`);return`${n.getHours().toString().padStart(2,`0`)}:${n.getMinutes().toString().padStart(2,`0`)}`},pj=e=>{let[t,n]=e.split(`:`);return`${t.padStart(2,`0`)}:${n.padStart(2,`0`)}`},mj=(e,t)=>{if(e.length<2)return!1;let n=e.map(e=>{let[n,r]=e.trim().split(`-`),i,a;if(t===`12h`){if(!/\s?(AM|PM|am|pm)\s?$/.test(n.trim())||!/\s?(AM|PM|am|pm)\s?$/.test(r.trim()))throw Error(`Invalid 12h format: "${e}"`);i=fj(n.trim()),a=fj(r.trim())}else{if(/\s?(AM|PM|am|pm)\s?/.test(n.trim())||/\s?(AM|PM|am|pm)\s?/.test(r.trim()))throw Error(`Invalid 24h format: "${e}"`);i=pj(n.trim()),a=pj(r.trim())}return{start:i,end:a,original:e}});for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){let r=n[e],i=n[t];if(r.start<=i.end&&r.end>=i.start||i.start<=r.end&&i.end>=r.start)throw Error(`Overlapping intervals: "${r.original}" and "${i.original}"`)}return!1},hj=()=>typeof window<`u`&&window.crypto&&typeof window.crypto.randomUUID==`function`?window.crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)}),gj=`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm0-80h640v-400H160v400Zm160-40h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM160-280v-400 400Z"/></svg>`,_j=`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"/></svg>`,vj=class{plugins=new Map;register(e){this.plugins.has(e.name)||this.plugins.set(e.name,e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get(e){return this.plugins.get(e)}getTemplateProvider(e){return this.plugins.get(e)?.templateProvider}getClearHandler(e){return this.plugins.get(e)?.clearHandler}},yj=new vj,bj=[`00`,`13`,`14`,`15`,`16`,`17`,`18`,`19`,`20`,`21`,`22`,`23`],xj=[`12`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`],Sj=[`00`,`05`,`10`,`15`,`20`,`25`,`30`,`35`,`40`,`45`,`50`,`55`],Cj=(e,t,n)=>{let{timezone:{enabled:r,label:i}}=e;return!r||!yj.has(`timezone`)?``:`<div class="tp-ui-timezone ${t}">
|
|
223
|
+
`;F.open({title:t,content:p,buttons:d,onClose:f});let m=e=>{e?.[0]?.onClick&&(e[0].onClick(),F.close())};if(a){let e=a({anchorId:c,data:r,selectionLimit:i,onSelected:m});l=e.table,u=e.destroy;let t=o?o(l):()=>{},d=[{onKeyDown:e=>e.keyCode===8&&e.target.value.length===1&&t(``),onChange:e=>t(e.target.value),onKeyUp:e=>t(e.target.value),clearSearch:()=>t(``),placeholder:n||`Search`,location:Dk,search:!0}],f=document.getElementById(s)||void 0;Yk({table:l,target:f,items:d})}else{let e=document.getElementById(c);if(e){kk({container:e,options:r,onSelected:m});let t=t=>{let n=e.querySelectorAll(`[data-select-item]`),r=t.toLowerCase();n.forEach(e=>{let n=e.textContent?.toLowerCase()||``;e.style.display=!t||n.includes(r)?``:`none`})},i=[{onKeyUp:e=>t(e.target.value),clearSearch:()=>t(``),placeholder:n||`Search`,location:Dk,search:!0}];Yk({target:document.getElementById(s)||void 0,items:i})}}}function kk({container:e,options:t,onSelected:n}){let r=document.createElement(`div`);r.style.cssText=`max-height: 380px; overflow-y: auto; padding: 0.5em 0;`;for(let e of t){let t=document.createElement(`a`);t.setAttribute(`data-select-item`,``),t.className=`panel-block font-medium`,t.style.cssText=`cursor: pointer; padding: 0.5em 1em; display: block; text-decoration: none; color: inherit;`,t.innerHTML=e.label,t.onmouseenter=()=>t.style.backgroundColor=`#f5f5f5`,t.onmouseleave=()=>t.style.backgroundColor=``,t.onclick=t=>{t.stopPropagation(),n([e])},r.appendChild(t)}e.appendChild(r)}var Ak=`none`;function jk(e){let t=document.createElement(`button`);return t.className=`button font-medium`,e.disabled&&(t.disabled=!0),e.class&&t.classList.add(e.class),e.id&&(t.id=e.id),e.intent&&t.classList.add(e.intent),e.toolTip?.content&&mm(t,e.toolTip),t.innerHTML=e.label,e.visible===!1&&(t.style.display=Ak),t}var Mk=`center`,Nk=``,Pk=`flex`,Fk=`left`,Ik=`none`,Lk=`overlay`,Rk=`right`,zk=({target:e})=>(t=[])=>{e.style.backgroundColor=t?.length?`var(--chc-hover-bg)`:Nk;let n=(n,r,i)=>{let a=e.getElementsByClassName(`options_${n}`)[0];a&&(a.style.display=t?.length?r:i)};n(Lk,Pk,Ik),n(Fk,Ik,Pk),n(Mk,Ik,Pk),n(Rk,Ik,Pk)},Bk=`center`,Vk=`header`,Hk=``,Uk=`left`,Wk=`none`,Gk=`overlay`,Kk=`right`,qk=`buttonBar`,Jk=`top`;function Yk(e){let{table:t,targetClassName:n,items:r=[],onSelection:i,selectItemFn:a}=e,{target:o}=e,s=!!o;if(!o&&n&&(o=document.getElementsByClassName(n)?.[0]),!o)return{elements:{},inputs:{}};let c=0,l=0,u={},d={},f;if(s){P(o);let e=rA();Object.assign(u,e.elements),o.appendChild(e.anchor)}let p=Object.assign({},...[Gk,Uk,Bk,Kk,Vk].map(e=>{let t=o.getElementsByClassName(`options_${e}`)?.[0];return P(t),{[e]:t}}).filter(Boolean)),m=zk({table:t,target:o}),h=(e,n)=>{B(n.onClick)&&(e.stopPropagation(),n.disabled||n.onClick(e,t),n.stateChange&&m())},g={onClick:()=>{},location:Kk};for(let e of r){let t={...g};ee(e)&&Object.assign(t,e);let n=p[t.location];if(!n){console.log(t.location,p);continue}t.location===Gk&&(c+=1),t.location===Vk&&(Xk(t,o),l+=1);let r=Zk(e,t,n,m,h,a,u,d);r?.focus&&(f=r.focus)}let _=o.getElementsByClassName(`panelHeader`)[0];_&&(_.style.display=l?Hk:Wk),t?._controlBarSelectionHandler&&t.off(`rowSelectionChanged`,t._controlBarSelectionHandler);let v=(e,t)=>{B(i)&&i(t),c&&m(t)};return t&&(t._controlBarSelectionHandler=v),t?.on(`rowSelectionChanged`,v),m(t?.getSelectedRows?.()??[]),f&&setTimeout(()=>f.focus(),200),{elements:u,inputs:d}}function Xk(e,t){if(B(e.headerClick)){let n=t.getElementsByClassName(`panelHeader`)[0];n&&(n.onclick=e.headerClick)}}function Zk(e,t,n,r,i,a,o,s){if(!t.hide&&(t.input||t.placeholder||t.search)){let r=Qk(e,t);return t.id&&(s[t.id]=r.input),t.id&&(o[t.id]=r.elem,r.elem.id=t.id),n?.appendChild(r.elem),t.focus?{focus:r.input}:void 0}if(!t.hide&&t.text){let e=document.createElement(`div`);e.className=`font-medium`,t.id&&(o[t.id]=e,e.id=t.id),e.innerHTML=t.text,e.onclick=e=>i(e,t),n?.appendChild(e);return}!t.id&&(!t?.label||t.hide)||(eA(t,n,r,i,a,o),(!(t?.label||t.tabs)||t.hide)&&o[t.id]&&(o[t.id].style.display=Wk))}function Qk(e,t){let n=document.createElement(`p`);n.className=`control ${t.search?`has-icons-left has-icons-right`:``}`;let r=document.createElement(`input`);if(r.className=`input font-medium`,r.setAttribute(`type`,`text`),r.setAttribute(`autocomplete`,`off`),r.setAttribute(`placeholder`,e.placeholder||Hk),t.id&&r.setAttribute(`id`,t.id),t.onKeyDown&&r.addEventListener(`keydown`,e=>t.onKeyDown(e,t)),t.onChange&&r.addEventListener(`change`,e=>t.onChange(e,t)),t.onKeyUp&&r.addEventListener(`keyup`,e=>{t.clearSearch&&e.key===`Escape`&&(e.stopPropagation(),r.value=``,t.clearSearch()),t.onKeyUp(e,t)}),t.class&&r.classList.add(t.class),t.visible===!1&&(n.style.display=Wk),t.value&&(r.value=t.value),n.appendChild(r),t.search&&$k(n,r,t),e.validator){let t=document.createElement(`p`);t.className=`help font-medium`,n.appendChild(t),r.addEventListener(`input`,n=>an(e,n,r,t,e.validator))}return{elem:n,input:r}}function $k(e,t,n){let r=document.createElement(`span`);if(r.className=`icon is-small is-left font-medium`,r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16" fill="currentColor"><path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"/></svg>`,e.appendChild(r),B(n.clearSearch)){let r=document.createElement(`span`);r.className=`icon is-small is-right font-medium`,r.style.pointerEvents=`all`,r.style.cursor=`pointer`,r.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="16" height="16" fill="#dddada"><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>`,r.onclick=e=>{e.stopPropagation(),t.value=``,n.clearSearch(),i()};let i=()=>{r.style.display=t.value?``:`none`};t.addEventListener(`input`,i),i(),e.appendChild(r)}}function eA(e,t,n,r,i,a){if(e.options){let r=Ek({target:t,button:e,stateChange:n});e.visible===!1&&(r.style.display=Wk),e.id&&(a[e.id]=r)}else if(ee(e.selection))tA(e,t,n,i,a);else if(e.tabs)nA(e,t,a);else{let n=jk(e);n.onclick=t=>r(t,e),e.id&&(a[e.id]=n),t?.appendChild(n)}}function tA(e,t,n,r,i){let{selection:{options:a,actions:o},actionPlacement:s,threshold:c=8,...l}=e;if(a?.length<c){a.length&&(s===Jk?a.unshift({divider:!0}):a.push({divider:!0})),o.forEach(e=>{let{label:t,...n}=e,r={...n,label:`<p style="font-weight: bold">${t}</p>`};s===Jk?a.unshift(r):a.push(r)});let r={...l,options:a},c=Ek({target:t,button:r,stateChange:n});r.visible===!1&&(c.style.display=Wk),r.id&&(i[e.id]=c)}else{let n=jk(e),o=r||Ok;n.onclick=t=>{t.stopPropagation(),o({title:e.selectionTitle||`Select`,options:a})},e.id&&(i[e.id]=n),t?.appendChild(n)}}function nA(e,t,n){let r=document.createElement(`div`);r.className=`tabs is-toggle is-toggle-rounded`;let i=document.createElement(`ul`);r.appendChild(i),e.tabs.forEach(t=>{let n=document.createElement(`li`);t.active&&n.classList.add(`is-active`);let r=document.createElement(`a`);n.appendChild(r),r.onclick=r=>{i.querySelectorAll(`li`).forEach(e=>e.classList.remove(`is-active`)),n.classList.add(`is-active`),B(t.onClick)&&t.onClick(r,e)};let a=document.createElement(`span`);a.innerHTML=t.label,r.appendChild(a),i.appendChild(n)}),e.id&&(n[e.id]=r),t.appendChild(r)}function rA(){let e=document.createElement(`div`);e.className=`panel_container flexcol flexcenter`;let t=document.createElement(`div`);t.className=`panelHeader options_header`,t.style.display=Wk,e.appendChild(t);let n=document.createElement(`div`);n.className=qk;let r={optionsOverlay:document.createElement(`div`),optionsLeft:document.createElement(`div`),optionsCenter:document.createElement(`div`),optionsRight:document.createElement(`div`)};r.optionsOverlay.className=`options_overlay`,r.optionsCenter.className=`options_center`,r.optionsRight.className=`options_right`,r.optionsLeft.className=`options_left`;for(let e of Object.values(r))n.appendChild(e);return e.appendChild(n),{elements:r,anchor:e,header:t}}var iA=()=>`sp-layout`,aA=()=>`sp-column`,oA=()=>`sp-panel`,sA=()=>`sp-panel-header`,cA=()=>`sp-panel-title`,lA=()=>`sp-panel-meta`,uA=()=>`sp-panel-actions`,dA=()=>`sp-panel-leading`,fA=()=>`sp-date-strip`,pA=()=>`sp-date-chip`,mA=()=>`sp-badges`,hA=()=>`sp-badge`,gA=()=>`sp-chips`,_A=()=>`sp-chip`,vA=()=>`sp-board`,yA=()=>`sp-venue`,bA=()=>`sp-venue-header`,xA=()=>`sp-venue-title`,SA=()=>`sp-venue-sub`,CA=()=>`sp-dropzone`,wA=()=>`sp-card`,TA=()=>`sp-card-title`,EA=()=>`sp-card-meta`,DA=()=>`sp-issues`,OA=()=>`sp-issue`,kA=()=>`sp-issue-code`,AA=()=>`sp-issue-msg`,jA=()=>`sp-issue-actions`,MA=()=>`sp-btn sp-btn--sm`,NA=()=>`sp-catalog`,PA=()=>`sp-catalog-toolbar`,FA=()=>`sp-input`,IA=()=>`sp-select`,LA=()=>`sp-group`,RA=()=>`sp-group-header`,zA=()=>`sp-group-body`,BA=()=>`sp-catalog-item`,VA=()=>`sp-inspector`,HA=()=>`sp-kv`,UA=()=>`sp-kv-key`,WA=()=>`sp-kv-value`,GA=()=>`sp-small`,KA=()=>`sp-popover-item`,qA=()=>`sp-popover-delete`,JA=()=>`sp-popover-divider`,YA=()=>`sp-insertion-line`,XA=()=>`sp-group-chevron`;function ZA(e,t){let n=!!t?.hideLeft,r=t?.catalogSide===`left`,i=document.createElement(`div`);if(i.className=iA(),n)r?i.classList.add(`sp-catalog-left`):i.classList.add(`sp-no-left`);else{let t=document.createElement(`div`);t.className=aA(),t.appendChild(e.dateStrip.element),e.issuesPanel.element.style.flex=`1`,e.issuesPanel.element.style.minHeight=`0`,t.appendChild(e.issuesPanel.element),i.appendChild(t)}let a=document.createElement(`div`);a.className=aA(),e.venueBoard.element.style.flex=`1`,e.venueBoard.element.style.minHeight=`0`,a.appendChild(e.venueBoard.element);let o=document.createElement(`div`);o.className=aA(),e.roundCatalog.element.style.flex=`1`,e.roundCatalog.element.style.minHeight=`0`,o.appendChild(e.roundCatalog.element),o.appendChild(e.inspectorPanel.element),r&&n?(i.appendChild(o),i.appendChild(a)):(i.appendChild(a),i.appendChild(o));function s(t){n||(e.dateStrip.update(t),e.issuesPanel.update(t)),e.venueBoard.update(t),e.roundCatalog.update(t),e.inspectorPanel.update(t)}return{element:i,update:s}}function QA(e){let t=null,n=null;function r(e){return`${e.date}|${e.venueId}|${e.index}`}function i(){t&&(t.destroy(),t=null,n=null)}function a(t){let n=document.createElement(`div`);n.style.cssText=`font-family:sans-serif; font-size:13px; min-width:150px;`;let r=document.createElement(`div`);r.className=KA(),r.textContent=`Set Not Before Time`,r.addEventListener(`click`,()=>{i(),e.onSetNotBeforeTime(t)}),n.appendChild(r);let a=document.createElement(`div`);a.className=JA(),n.appendChild(a);let o=document.createElement(`div`);return o.className=qA(),o.textContent=`Remove Round`,o.addEventListener(`click`,()=>{i(),e.onDelete(t)}),n.appendChild(o),n}return{show(e,o){let s=r(o);if(n===s){i();return}i();let c=mm(e,{content:a(o),allowHTML:!0,interactive:!0,trigger:`manual`,placement:`bottom`,appendTo:document.body,onHidden:()=>{t=null,n=null}});t=c,n=s,c.show()},destroy(){i()},isActiveFor(e){return n===r(e)}}}function $A(e){return structuredClone(e)}function ej(e,t,n){return Math.max(t,Math.min(n,e))}function tj(e){return`${e.tournamentId}|${e.eventId}|${e.drawId}|${e.structureId}|${e.roundNumber}`}function nj(e){return`${e.eventName?`${e.eventName} \u2013 `:``}${e.roundName??`Round ${e.roundNumber}`}${e.roundSegment?` (seg ${e.roundSegment.segmentNumber}/${e.roundSegment.segmentsCount})`:``}`}function rj(e,t){return!e||!t?!1:e.date===t.date&&e.venueId===t.venueId&&e.index===t.index}function ij(e){return{tournamentId:e.tournamentId,eventId:e.eventId,drawId:e.drawId,structureId:e.structureId,roundNumber:e.roundNumber}}function aj(e,t,n){return e.find(e=>e.scheduleDate===t)?.venues?.find(e=>e.venueId===n)?.rounds??[]}function oj(e,t){return(e.find(e=>e.scheduleDate===t.date)?.venues?.find(e=>e.venueId===t.venueId))?.rounds?.[t.index]??null}function sj(e,t){return e.filter(e=>cj(e.context?.locator,t)||cj(e.context?.prerequisite,t))}function cj(e,t){return!!e&&e.date===t.date&&e.venueId===t.venueId&&e.index===t.index}function lj(e){return e.length?e.some(e=>e.severity===`ERROR`)?`ERROR`:e.some(e=>e.severity===`WARN`)?`WARN`:`INFO`:null}function uj(e,t){let n=tj(t);for(let t of e)for(let e of t.venues)for(let r=0;r<e.rounds.length;r++){let i=e.rounds[r];if(tj(ij(i))===n)return{date:t.scheduleDate,venueId:e.venueId,index:r,roundKey:ij(i),roundSegment:i.roundSegment}}return null}function dj(){let e=document.createElement(`div`);e.className=oA();let t=document.createElement(`div`);t.className=sA();let n=document.createElement(`div`);n.className=cA(),n.textContent=`Inspector`,t.appendChild(n),e.appendChild(t);let r=document.createElement(`div`);r.className=VA(),e.appendChild(r);function i(e){r.innerHTML=``;let t=e.selectedLocator;if(!t){let e=document.createElement(`div`);e.className=GA(),e.textContent=`Select a round card on the board to see details and context.`,r.appendChild(e);return}let n=oj(e.profileDraft,t);if(!n){let e=document.createElement(`div`);e.className=GA(),e.textContent=`Selection no longer exists.`,r.appendChild(e);return}let i=sj(e.ruleResults,t),a=lj(i);if(fj(r,`Event`,n.eventName??``),fj(r,`Draw`,n.drawName||``),fj(r,`Round`,n.roundName&&!/^rn=/.test(n.roundName)?n.roundName:`Round `+n.roundNumber),fj(r,`Segment`,n.roundSegment?`${n.roundSegment.segmentNumber}/${n.roundSegment.segmentsCount}`:`—`),fj(r,`Not before`,n.notBeforeTime??`—`),fj(r,`Status`,a??`OK`),i.length){let e=document.createElement(`div`);e.className=GA(),e.style.marginTop=`8px`,e.textContent=`Issues for this item:`,r.appendChild(e);for(let e of i){let t=document.createElement(`div`);t.className=GA(),t.innerHTML=`\u2022 <b>${pj(e.code)}</b>: ${pj(e.message)}`,r.appendChild(t)}}else{let e=document.createElement(`div`);e.className=GA(),e.style.marginTop=`8px`,e.textContent=`No issues associated with this card.`,r.appendChild(e)}}return{element:e,update:i}}function fj(e,t,n){let r=document.createElement(`div`);r.className=HA();let i=document.createElement(`div`);i.className=UA(),i.textContent=t;let a=document.createElement(`div`);a.className=WA(),a.textContent=n,r.appendChild(i),r.appendChild(a),e.appendChild(r)}function pj(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}function mj(e,t,n,r=`dim`){let i=t.toLowerCase().trim();return e.filter(e=>r===`hide`&&n.has(tj(e))?!1:i?`${e.eventName} ${e.drawName??``} ${e.roundName??``} ${e.drawId}`.toLowerCase().includes(i):!0).map(e=>({...e,isPlanned:n.has(tj(e))}))}function hj(e,t){let n=new Map,r=e=>t===`draw`?`${e.eventName} \u2014 ${e.drawName??e.drawId}`:t===`round`?e.roundName??`Round ${e.roundNumber}`:e.eventName;for(let t of e){let e=r(t),i=n.get(e);i?i.push(t):n.set(e,[t])}return new Map([...n.entries()].sort((e,t)=>e[0].localeCompare(t[0],void 0,{numeric:!0})))}function gj(e){let t=new Set;for(let n of e)for(let e of n.venues)for(let n of e.rounds)n.roundSegment||t.add(tj(n));return t}var _j=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function vj(e){return _j.test(e)}function yj(e){let t=document.createElement(`div`);t.className=oA(),t.style.overflowY=`auto`,t.style.scrollbarWidth=`thin`,t.style.scrollbarColor=`var(--sp-scrollbar) transparent`;let n=new Set,r=null,i=document.createElement(`div`);i.className=sA();let a=document.createElement(`div`);a.className=cA(),a.textContent=`Round Catalog`;let o=document.createElement(`div`);o.className=lA(),i.appendChild(a),i.appendChild(o),t.appendChild(i);let s=document.createElement(`div`);s.className=PA();let c=document.createElement(`input`);c.type=`text`,c.placeholder=`Search rounds...`,c.className=FA(),c.addEventListener(`input`,()=>e.onSearchChange(c.value));let l=Mb(c,()=>{c.value=``,e.onSearchChange(``),c.focus()}),u=document.createElement(`select`);u.className=IA();for(let[e,t]of[[`event`,`By Event`],[`draw`,`By Draw`],[`round`,`By Round`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,u.appendChild(n)}u.addEventListener(`change`,()=>e.onGroupByChange(u.value)),s.appendChild(l),s.appendChild(u),t.appendChild(s);let d=document.createElement(`div`);d.className=NA(),t.appendChild(d),d.addEventListener(`dragover`,e=>{e.preventDefault(),d.classList.add(`over`),e.dataTransfer.dropEffect=`move`}),d.addEventListener(`dragleave`,e=>{d.contains(e.relatedTarget)||d.classList.remove(`over`)}),d.addEventListener(`drop`,t=>{if(d.classList.remove(`over`),t.preventDefault(),!e.onDropRemove)return;let n;try{n=JSON.parse(t.dataTransfer.getData(`application/json`))}catch{return}n.type===`PLANNED_ROUND`&&e.onDropRemove(n.locator)});function f(t,n){let r=document.createElement(`div`);r.className=BA(),t.isPlanned?(r.classList.add(n===`navigate`?`navigate`:`dimmed`),r.draggable=!1,n===`navigate`&&r.addEventListener(`click`,()=>{e.onNavigateToPlanned?.(t)})):(r.draggable=!0,r.addEventListener(`dragstart`,e=>{e.stopPropagation(),e.dataTransfer.setDragImage(r,r.offsetWidth/2,20),e.dataTransfer.setData(`application/json`,JSON.stringify({type:`CATALOG_ROUND`,roundRef:t})),e.dataTransfer.effectAllowed=`copyMove`}));let i=document.createElement(`div`);i.className=TA();let a=t.roundName&&!t.roundName.startsWith(`rn=`)?t.roundName:`Round `+t.roundNumber;i.textContent=`${t.eventName} \u2014 ${a}`;let o=document.createElement(`div`);o.className=EA();let s=t.matchCountEstimate?` · `+t.matchCountEstimate+` matches`:``,c=t.drawName&&!vj(t.drawName)?t.drawName:``;if(o.textContent=c?`${c}${s}`:s.replace(` · `,``)||``,r.appendChild(i),r.appendChild(o),t.isPlanned&&n!==`navigate`){let e=document.createElement(`span`);e.className=`sp-catalog-check`,e.textContent=`✓`,r.appendChild(e)}return r}function p(e){r=e;let t=e.plannedRoundBehavior,i=gj(e.profileDraft),a=mj(e.roundCatalog,e.catalogSearchQuery,i,t),s=hj(a,e.catalogGroupBy);o.textContent=`${a.length} rounds`,c.value!==e.catalogSearchQuery&&(c.value=e.catalogSearchQuery,Nb(l)),u.value!==e.catalogGroupBy&&(u.value=e.catalogGroupBy),d.innerHTML=``;for(let[e,i]of s){let a=document.createElement(`div`);a.className=LA();let o=n.has(e),s=document.createElement(`div`);s.className=RA();let c=document.createElement(`span`);c.className=XA(),c.textContent=o?`▶`:`▼`;let l=document.createElement(`span`);l.textContent=e,s.appendChild(c),s.appendChild(l),s.addEventListener(`click`,()=>{n.has(e)?n.delete(e):n.add(e),r&&p(r)});let u=document.createElement(`div`);u.className=zA(),o&&(u.style.display=`none`);for(let e of i)u.appendChild(f(e,t));a.appendChild(s),a.appendChild(u),d.appendChild(a)}}return{element:t,update:p}}function bj(e){let t=document.createElement(`div`);t.className=oA();let n=document.createElement(`div`);n.className=sA();let r=document.createElement(`div`);r.className=cA(),r.textContent=`Issues`;let i=document.createElement(`div`);i.className=lA(),n.appendChild(r),n.appendChild(i),t.appendChild(n);let a=document.createElement(`div`);a.className=DA(),t.appendChild(a);function o(t){let n=t.issueIndex.all;if(i.textContent=`${n.length} total (${t.issueIndex.bySeverity.ERROR.length} errors)`,a.innerHTML=``,!n.length){let e=document.createElement(`div`);e.className=GA(),e.textContent=`No issues. Drag rounds into the board to build a profile.`,a.appendChild(e);return}for(let t of n.slice(0,30)){let n=document.createElement(`div`);n.className=OA(),t.severity===`ERROR`?n.classList.add(`error`):t.severity===`WARN`?n.classList.add(`warn`):n.classList.add(`info`);let r=document.createElement(`div`);r.className=kA(),r.textContent=`${t.severity} \u00b7 ${t.code}`;let i=document.createElement(`div`);if(i.className=AA(),i.textContent=t.message,n.appendChild(r),n.appendChild(i),t.fixActions?.length){let r=document.createElement(`div`);r.className=jA();for(let n of t.fixActions){let t=document.createElement(`button`);t.className=MA(),t.textContent=n.label??n.kind,t.addEventListener(`click`,()=>e.onFixAction(n)),r.appendChild(t)}n.appendChild(r)}a.appendChild(n)}}return{element:t,update:o}}var{ROUND_ROBIN:xj,ROUND_ROBIN_WITH_PLAYOFF:Sj}=t.drawDefinitionConstants,Cj=`Jump to prerequisite`;function wj({profile:e,temporal:t,dependencies:n,venueOrder:r}){let i=[];if(t?.isDateAvailable)for(let n of e){let e=t.isDateAvailable(n.scheduleDate);e.ok||i.push({code:`DATE_UNAVAILABLE`,severity:`ERROR`,message:`Can't schedule on ${n.scheduleDate} \u2014 day is unavailable${e.reason?`: `+e.reason:``}.`,context:{date:n.scheduleDate},fixActions:[{kind:`OPEN_TEMPORAL_GRID`,date:n.scheduleDate,label:`Open Temporal Grid`}]})}let a=Mj(e);for(let e of a){let t=e.round.roundSegment;t&&(Number.isInteger(t.segmentNumber)&&Number.isInteger(t.segmentsCount)&&t.segmentsCount>=2&&t.segmentNumber>=1&&t.segmentNumber<=t.segmentsCount||i.push({code:`INVALID_SEGMENT_CONFIG`,severity:`ERROR`,message:`Invalid segment configuration for ${nj(e.round)}.`,context:{locator:e.locator,date:e.locator.date,venueId:e.locator.venueId}}))}let o=new Map,s=new Map;for(let e of a){let t=e.round,n=tj(t);if(!t.roundSegment)o.has(n)?i.push({code:`DUPLICATE_ROUND`,severity:`ERROR`,message:`Round is planned more than once: ${nj(t)}.`,context:{scope:`${t.drawId}|${t.structureId}`,locator:e.locator,date:e.locator.date,venueId:e.locator.venueId},fixActions:[{kind:`JUMP_TO_ITEM`,locator:o.get(n),label:`Jump to existing`}]}):o.set(n,e.locator);else{let r=`${n}|${t.roundSegment.segmentNumber}/${t.roundSegment.segmentsCount}`;s.has(r)?i.push({code:`DUPLICATE_SEGMENT`,severity:`ERROR`,message:`Segment planned more than once: ${nj(t)}.`,context:{scope:`${t.drawId}|${t.structureId}`,locator:e.locator,date:e.locator.date,venueId:e.locator.venueId},fixActions:[{kind:`JUMP_TO_ITEM`,locator:s.get(r),label:`Jump to existing`}]}):s.set(r,e.locator)}}return i.push(...Ej({profile:e,venueOrder:r})),n?.getRoundDependencies&&i.push(...Aj(a,n)),i}var Tj=new Set([xj,Sj]);function Ej({profile:e}){let t=Mj(e),n=Dj(t),r=Oj(t);return Pj([...n,...r])}function Dj(e){let t=[],n=Nj(e,e=>`${e.round.structureId}|${e.locator.date}|${e.locator.venueId}`);for(let[e,r]of n.entries()){let n=r[0]?.round.structureType;if(!(n&&Tj.has(n))){r.sort((e,t)=>e.locator.index-t.locator.index);for(let n=0;n<r.length;n++){let i=r[n],a=null;for(let e=n-1;e>=0;e--)if(r[e].round.roundNumber>i.round.roundNumber){a=r[e];break}if(!a)continue;let o=jj(r,n,a);t.push({code:`ROUND_ORDER_VIOLATION`,severity:`ERROR`,message:`Cannot place ${nj(i.round)} before ${nj(a.round)} in this venue.`,context:{scope:e,drawId:i.round.drawId,structureId:i.round.structureId,date:i.locator.date,venueId:i.locator.venueId,locator:i.locator,prerequisite:a.locator},fixActions:[{kind:`JUMP_TO_ITEM`,locator:a.locator,label:Cj},...o.moveOffenderAfter?[{kind:`MOVE_ITEM_AFTER`,locator:i.locator,after:o.moveOffenderAfter,label:`Move offending round after prerequisite set`}]:[],...o.movePrereqBefore?[{kind:`MOVE_ITEM_BEFORE`,locator:a.locator,before:o.movePrereqBefore,label:`Move prerequisite before offending round`}]:[]]})}}}return t}function Oj(e){let t=[],n=Nj(e,e=>e.round.structureId);for(let[e,r]of n.entries()){let n=r[0]?.round.structureType;if(n&&Tj.has(n))continue;let i=new Map;for(let e of r){let t=e.locator.date,n=i.get(t);n?n.push(e):i.set(t,[e])}let a=[...i.keys()].sort();if(a.length<2)continue;let o=-1/0,s=null;for(let n of a){let r=i.get(n);for(let i of r)i.round.roundNumber<o&&s&&t.push({code:`ROUND_ORDER_VIOLATION`,severity:`ERROR`,message:`${nj(s.round)} is scheduled on ${s.locator.date} but its prerequisite ${nj(i.round)} is on the later date ${n}.`,context:{scope:`cross-date|${e}`,drawId:s.round.drawId,structureId:e,date:s.locator.date,venueId:s.locator.venueId,locator:s.locator,prerequisite:i.locator,reason:`cross-date`},fixActions:[{kind:`JUMP_TO_ITEM`,locator:i.locator,label:Cj}]});for(let e of r)e.round.roundNumber>o&&(o=e.round.roundNumber,s=e)}}return t}function kj(e,t){if(!(e.round.structureId===t.round.structureId&&e.locator.date===t.locator.date&&e.locator.venueId===t.locator.venueId)){if(e.locator.date<t.locator.date)return{code:`DEPENDENCY_VIOLATION`,severity:`ERROR`,message:`${nj(e.round)} is scheduled on ${e.locator.date} but depends on ${nj(t.round)} which is on the later date ${t.locator.date}.`,context:{date:e.locator.date,venueId:e.locator.venueId,locator:e.locator,prerequisite:t.locator,reason:`cross-date`},fixActions:[{kind:`JUMP_TO_ITEM`,locator:t.locator,label:Cj}]};if(e.locator.date===t.locator.date&&e.locator.venueId===t.locator.venueId&&e.locator.index<t.locator.index)return{code:`DEPENDENCY_VIOLATION`,severity:`ERROR`,message:`${nj(e.round)} is listed before its prerequisite ${nj(t.round)} in the same venue on ${e.locator.date}.`,context:{date:e.locator.date,venueId:e.locator.venueId,locator:e.locator,prerequisite:t.locator,reason:`cross-structure-same-day`},fixActions:[{kind:`JUMP_TO_ITEM`,locator:t.locator,label:Cj},{kind:`MOVE_ITEM_AFTER`,locator:e.locator,after:t.locator,label:`Move after prerequisite`},{kind:`MOVE_ITEM_BEFORE`,locator:t.locator,before:e.locator,label:`Move prerequisite before`}]}}}function Aj(e,t){let n=[],r=Nj(e,e=>tj(e.round));for(let[e,i]of r.entries()){let a=t.getRoundDependencies(e);if(a.length)for(let e of a){let t=r.get(e);if(t)for(let e of i)for(let r of t){let t=kj(e,r);t&&n.push(t)}}}return Pj(n)}function jj(e,t,n){let r=e[t],i=e.indexOf(n);for(let t=i+1;t<e.length;t++)e[t].round.roundNumber>=n.round.roundNumber&&(i=t);return{moveOffenderAfter:e[i].locator,movePrereqBefore:r.locator}}function Mj(e){let t=[];for(let n of e)for(let e of n.venues)for(let r=0;r<e.rounds.length;r++){let i=e.rounds[r];t.push({round:i,locator:{date:n.scheduleDate,venueId:e.venueId,index:r,roundKey:ij(i),roundSegment:i.roundSegment}})}return t}function Nj(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i?i.push(r):n.set(e,[r])}return n}function Pj(e){let t=new Set,n=[];for(let r of e){let e=r.code+`|`+r.message+`|`+(r.context?.scope??``)+`|`+JSON.stringify(r.context?.locator??{});t.has(e)||(t.add(e),n.push(r))}return n}function Fj(e){let t={ERROR:[],WARN:[],INFO:[]},n={},r={},i={},a={total:e.length,ERROR:0,WARN:0,INFO:0,byDate:{},byVenue:{},byDraw:{}},o=e=>e===`ERROR`?0:e===`WARN`?1:2,s=(e,t)=>o(e.severity)-o(t.severity)||e.code.localeCompare(t.code)||e.message.localeCompare(t.message);for(let o of e){t[o.severity].push(o),a[o.severity]++;let e=o.context?.date??o.context?.locator?.date,s=o.context?.venueId??o.context?.locator?.venueId,c=o.context?.scope??(o.context?.drawId&&o.context?.structureId?`${o.context.drawId}|${o.context.structureId}`:void 0);e&&(n[e]??=[]).push(o),s&&(r[s]??=[]).push(o),c&&(i[c]??=[]).push(o),Ij(a.byDate,e,o.severity),Ij(a.byVenue,s,o.severity),Ij(a.byDraw,c,o.severity)}for(let e of Object.keys(t))t[e].sort(s);for(let e of[n,r,i])for(let t of Object.keys(e))e[t].sort(s);return{all:e,bySeverity:t,byDate:n,byVenue:r,byDraw:i,counts:a}}function Ij(e,t,n){if(!t)return;let r=e[t]??={total:0,ERROR:0,WARN:0,INFO:0};r.total++,r[n]++}function Lj(e,t,n){let r=$A(e),{date:i,venueId:a}=n,o=zj(Rj(r,i),a);if(t.type===`CATALOG_ROUND`){let e={tournamentId:t.roundRef.tournamentId,eventId:t.roundRef.eventId,eventName:t.roundRef.eventName,drawId:t.roundRef.drawId,drawName:t.roundRef.drawName,structureId:t.roundRef.structureId,structureType:t.roundRef.structureType,roundNumber:t.roundRef.roundNumber,roundName:t.roundRef.roundName},i=ej(n.index,0,o.rounds.length);return o.rounds.splice(i,0,e),Bj(o.rounds),{ok:!0,profile:r}}if(t.type===`PLANNED_ROUND`){let{locator:e}=t,s=zj(Rj(r,e.date),e.venueId),[c]=s.rounds.splice(e.index,1);Bj(s.rounds);let l=n.index;return e.date===i&&e.venueId===a&&e.index<l&&--l,l=ej(l,0,o.rounds.length),o.rounds.splice(l,0,c),Bj(o.rounds),{ok:!0,profile:r}}return{ok:!1,profile:e}}function Rj(e,t){let n=e.find(e=>e.scheduleDate===t);return n||(n={scheduleDate:t,venues:[]},e.push(n),e.sort((e,t)=>e.scheduleDate.localeCompare(t.scheduleDate))),n}function zj(e,t){let n=e.venues.find(e=>e.venueId===t);return n||(n={venueId:t,rounds:[]},e.venues.push(n)),n}function Bj(e){for(let t=0;t<e.length;t++)e[t].sortOrder=t+1}var Vj=class{constructor(e){this.listeners=new Set,this.config=e;let t={all:[],bySeverity:{ERROR:[],WARN:[],INFO:[]},byDate:{},byVenue:{},byDraw:{},counts:{total:0,ERROR:0,WARN:0,INFO:0,byDate:{},byVenue:{},byDraw:{}}};this.state={profileDraft:$A(e.initialProfile??[]),venues:e.venues,roundCatalog:e.roundCatalog,schedulableDates:e.schedulableDates,activeDates:e.activeDates,selectedDate:e.selectedDate??e.schedulableDates[0]??null,selectedLocator:null,ruleResults:[],issueIndex:t,catalogSearchQuery:``,catalogGroupBy:`event`,plannedRoundBehavior:e.plannedRoundBehavior??`dim`},this.revalidate()}getState(){return this.state}getSchedulingProfile(){return $A(this.state.profileDraft)}selectDate(e){this.state.selectedDate!==e&&this.setState({selectedDate:e,selectedLocator:null})}selectCard(e){this.setState({selectedLocator:e})}setCatalogSearch(e){this.setState({catalogSearchQuery:e})}setCatalogGroupBy(e){this.setState({catalogGroupBy:e})}navigateToRound(e){let t=uj(this.state.profileDraft,{tournamentId:e.tournamentId,eventId:e.eventId,drawId:e.drawId,structureId:e.structureId,roundNumber:e.roundNumber});t&&this.setState({selectedDate:t.date,selectedLocator:t})}dropRound(e,t){try{let n=Lj(this.state.profileDraft,e,t);if(!n.ok)return{ok:!1,errorMessage:`Invalid drop operation`};let r=new Set(this.state.ruleResults.filter(e=>e.severity===`ERROR`).map(Hj)),i=wj({profile:n.profile,temporal:this.config.temporalAdapter,dependencies:this.config.dependencyAdapter,venueOrder:this.config.venueOrder}).filter(e=>e.severity===`ERROR`).filter(e=>!r.has(Hj(e)));return i.length?(this.addRejectionNotice(i[0].message),{ok:!1,errorMessage:i[0].message}):(this.commitProfile(n.profile),{ok:!0})}catch(e){return{ok:!1,errorMessage:String(e)}}}removeRound(e){let t=$A(this.state.profileDraft),n=t.find(t=>t.scheduleDate===e.date);if(!n)return;let r=n.venues.find(t=>t.venueId===e.venueId);if(r&&!(e.index<0||e.index>=r.rounds.length)){r.rounds.splice(e.index,1);for(let e=0;e<r.rounds.length;e++)r.rounds[e].sortOrder=e+1;this.commitProfile(t),this.state.selectedLocator?.date===e.date&&this.state.selectedLocator?.venueId===e.venueId&&this.state.selectedLocator?.index===e.index&&this.setState({selectedLocator:null})}}setNotBeforeTime(e,t){let n=$A(this.state.profileDraft),r=n.find(t=>t.scheduleDate===e.date);if(!r)return;let i=r.venues.find(t=>t.venueId===e.venueId);if(!i)return;let a=i.rounds[e.index];a&&(t?a.notBeforeTime=t:delete a.notBeforeTime,this.commitProfile(n))}applyFixAction(e){if(e.kind===`JUMP_TO_ITEM`&&e.locator){this.setState({selectedDate:e.locator.date,selectedLocator:e.locator});return}if(e.kind===`OPEN_TEMPORAL_GRID`){this.config.onFixAction?.(e);return}if(e.kind===`MOVE_ITEM_AFTER`&&e.locator&&e.after){let t=Uj(this.state.profileDraft,e.locator,e.after);this.commitProfile(t);return}if(e.kind===`MOVE_ITEM_BEFORE`&&e.locator&&e.before){let t=Wj(this.state.profileDraft,e.locator,e.before);this.commitProfile(t);return}this.config.onFixAction?.(e)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state={...this.state,...e},this.emit()}commitProfile(e){this.state={...this.state,profileDraft:e},this.revalidate(),this.config.onProfileChanged?.($A(e))}addRejectionNotice(e){let t={code:`DROP_REJECTED`,severity:`WARN`,message:`Drop rejected: ${e}`,context:{}},n=[...this.state.ruleResults.filter(e=>e.code!==`DROP_REJECTED`),t],r=Fj(n);this.state={...this.state,ruleResults:n,issueIndex:r},this.emit()}revalidate(){let e=wj({profile:this.state.profileDraft,temporal:this.config.temporalAdapter,dependencies:this.config.dependencyAdapter,venueOrder:this.config.venueOrder}),t=Fj(e);this.state={...this.state,ruleResults:e,issueIndex:t},this.emit()}emit(){for(let e of this.listeners)e(this.state)}};function Hj(e){return`${e.code}|${e.context?.scope??``}|${e.context?.structureId??``}|${e.context?.date??``}`}function Uj(e,t,n){let r=$A(e),i=Gj(r,t);if(!i)return e;let a=Kj(r,n.date,n.venueId),o=Math.min(a.length,n.index+1);return a.splice(o,0,i),r}function Wj(e,t,n){let r=$A(e),i=Gj(r,t);if(!i)return e;let a=Kj(r,n.date,n.venueId),o=Math.max(0,Math.min(a.length,n.index));return a.splice(o,0,i),r}function Gj(e,t){let n=e.find(e=>e.scheduleDate===t.date);if(!n)return null;let r=n.venues.find(e=>e.venueId===t.venueId);return!r||t.index<0||t.index>=r.rounds.length?null:r.rounds.splice(t.index,1)[0]}function Kj(e,t,n){let r=e.find(e=>e.scheduleDate===t);r||(r={scheduleDate:t,venues:[]},e.push(r));let i=r.venues.find(e=>e.venueId===n);return i||(i={venueId:n,rounds:[]},r.venues.push(i)),i.rounds}function qj(e,t){let{round:n,locator:r,isSelected:i,severity:a}=e,o=document.createElement(`div`);o.className=wA(),i&&o.classList.add(`selected`),a===`ERROR`?o.classList.add(`error`):a===`WARN`&&o.classList.add(`warn`),o.draggable=!0,o.addEventListener(`dragstart`,e=>{e.stopPropagation(),e.dataTransfer.setDragImage(o,o.offsetWidth/2,20),e.dataTransfer.setData(`application/json`,JSON.stringify({type:`PLANNED_ROUND`,locator:r})),e.dataTransfer.effectAllowed=`copyMove`}),o.addEventListener(`click`,e=>{e.stopPropagation(),t.onClick(r)}),t.onContextMenu&&o.addEventListener(`contextmenu`,e=>{e.preventDefault(),e.stopPropagation(),t.onContextMenu(r,o)});let s=document.createElement(`div`);s.className=TA();let c=n.roundName&&!n.roundName.startsWith(`rn=`)?n.roundName:`Round `+n.roundNumber;s.textContent=(n.eventName?n.eventName+` — `:``)+c,o.appendChild(s);let l=document.createElement(`div`);l.className=EA(),l.textContent=[n.drawName||``,n.matchCountEstimate?`${n.matchCountEstimate} matches`:``].filter(Boolean).join(` · `),o.appendChild(l);let u=document.createElement(`div`);return u.className=gA(),n.roundSegment&&u.appendChild(Jj(`Seg ${n.roundSegment.segmentNumber}/${n.roundSegment.segmentsCount}`,`seg`)),n.notBeforeTime&&u.appendChild(Jj(`NB ${n.notBeforeTime}`,`nb`)),a===`ERROR`?u.appendChild(Jj(`Error`,`err`)):a===`WARN`&&u.appendChild(Jj(`Warn`,`warn`)),u.children.length&&o.appendChild(u),o}function Jj(e,t){let n=document.createElement(`div`);return n.className=_A()+` `+t,n.textContent=e,n}function Yj(e,t){let n=document.createElement(`div`);n.className=oA();let r=document.createElement(`div`);r.className=sA();let i=t?.titleLeadingActions,a=document.createElement(`div`);if(a.className=cA(),a.textContent=`Day Plan`,i){let e=document.createElement(`div`);e.className=dA();let t=Array.isArray(i)?i:[i];for(let n of t)e.appendChild(n);e.appendChild(a),r.appendChild(e)}else r.appendChild(a);let o=t?.headerActions;if(o){let e=document.createElement(`div`);e.className=uA();let t=Array.isArray(o)?o:[o];for(let n of t)e.appendChild(n);r.appendChild(e)}n.appendChild(r);let s=document.createElement(`div`);s.className=vA(),n.appendChild(s);function c(t){let n=t.selectedDate;s.innerHTML=``;let r=Math.max(1,t.venues.length);r>4?(s.classList.add(`sp-board-scroll`),s.style.gridTemplateColumns=``):(s.classList.remove(`sp-board-scroll`),s.style.gridTemplateColumns=`repeat(${r}, 1fr)`);for(let r of t.venues){let i=document.createElement(`div`);i.className=yA();let a=document.createElement(`div`);a.className=bA();let o=document.createElement(`div`),c=document.createElement(`div`);c.className=xA(),c.textContent=r.name;let l=document.createElement(`div`);l.className=SA(),l.textContent=``,o.appendChild(c),o.appendChild(l);let u=t.issueIndex.counts.byVenue[r.venueId],d=document.createElement(`div`);d.className=hA(),u?.ERROR?(d.classList.add(`err`),d.textContent=`${u.ERROR} err`):u?.WARN?(d.classList.add(`warn`),d.textContent=`${u.WARN} warn`):(d.classList.add(`ok`),d.textContent=`OK`),a.appendChild(o),a.appendChild(d);let f=document.createElement(`div`);if(f.className=CA(),f.dataset.venue=r.venueId,n){let i=aj(t.profileDraft,n,r.venueId);if(!i.length){let e=document.createElement(`div`);e.className=GA(),e.textContent=`Drop rounds here.`,f.appendChild(e)}i.forEach((i,a)=>{let o={date:n,venueId:r.venueId,index:a,roundKey:ij(i),roundSegment:i.roundSegment},s=lj(sj(t.ruleResults,o)),c=qj({round:i,locator:o,isSelected:rj(t.selectedLocator,o),severity:s},{onClick:e.onCardClick,onContextMenu:e.onCardContextMenu});f.appendChild(c)})}else{let e=document.createElement(`div`);e.className=GA(),e.textContent=`Select a date to plan.`,f.appendChild(e)}let p=document.createElement(`div`);p.className=YA(),p.style.display=`none`,f.addEventListener(`dragover`,e=>{if(!n)return;e.preventDefault(),f.classList.add(`over`),e.dataTransfer.dropEffect=`move`;let t=Zj(f,e.clientY,p),r=Xj(f,p);p.style.display=``,t<r.length?f.insertBefore(p,r[t]):f.appendChild(p)}),f.addEventListener(`dragleave`,e=>{f.contains(e.relatedTarget)||(f.classList.remove(`over`),p.style.display=`none`)}),f.addEventListener(`drop`,t=>{if(f.classList.remove(`over`),p.style.display=`none`,t.preventDefault(),!n)return;let i;try{i=JSON.parse(t.dataTransfer.getData(`application/json`))}catch{return}let a=Zj(f,t.clientY,p),o={date:n,venueId:r.venueId,index:a};e.onDrop(i,o)}),i.appendChild(a),i.appendChild(f),s.appendChild(i)}}return{element:n,update:c}}function Xj(e,t){return Array.from(e.querySelectorAll(`[draggable="true"]`)).filter(e=>e!==t)}function Zj(e,t,n){let r=Xj(e,n);for(let e=0;e<r.length;e++){let n=r[e].getBoundingClientRect();if(t<n.top+n.height/2)return e}return r.length}function Qj(e){let t=document.createElement(`div`);t.className=oA();let n=document.createElement(`div`);n.className=sA();let r=document.createElement(`div`);r.className=cA(),r.textContent=`Dates`;let i=document.createElement(`div`);i.className=lA(),n.appendChild(r),n.appendChild(i),t.appendChild(n);let a=document.createElement(`div`);a.className=fA(),t.appendChild(a);function o(t){i.textContent=`${t.schedulableDates.length} schedulable`,a.innerHTML=``;let n=t.activeDates?new Set(t.activeDates):null;for(let r of t.schedulableDates){let i=!n||n.has(r),o=t.issueIndex.counts.byDate[r],s=document.createElement(`div`);s.className=pA(),r===t.selectedDate&&s.classList.add(`selected`),i||s.classList.add(`inactive`),s.setAttribute(`data-date`,r);let c=document.createElement(`div`),l=document.createElement(`div`);l.style.cssText=`font-weight:800;font-size:12px`,l.textContent=r;let u=document.createElement(`div`);u.style.cssText=`font-size:11px;color:var(--sp-muted)`,u.textContent=i?`Active`:`Inactive`,c.appendChild(l),c.appendChild(u);let d=document.createElement(`div`);d.className=mA(),o?.ERROR&&d.appendChild($j(`${o.ERROR} err`,`err`)),o?.WARN&&d.appendChild($j(`${o.WARN} warn`,`warn`)),!o?.ERROR&&!o?.WARN&&d.appendChild($j(`OK`,`ok`)),s.appendChild(c),s.appendChild(d),s.addEventListener(`click`,()=>e.onDateSelected(r)),a.appendChild(s)}}return{element:t,update:o}}function $j(e,t){let n=document.createElement(`div`);return n.className=hA()+` `+t,n.textContent=e,n}var eM=class{constructor(e){this.container=null,this.store=new Vj(e),this.popover=QA({onDelete:e=>{this.store.removeRound(e)},onSetNotBeforeTime:e=>{let t=prompt(`Enter not-before time (HH:MM):`,`10:00`);t!==null&&this.store.setNotBeforeTime(e,t||void 0)}});let t=Qj({onDateSelected:e=>this.store.selectDate(e)}),n=bj({onFixAction:e=>this.store.applyFixAction(e)}),r=Yj({onDrop:(e,t)=>{this.store.dropRound(e,t)},onCardClick:e=>this.store.selectCard(e),onCardContextMenu:(e,t)=>{this.popover.show(t,e)}},{headerActions:e.headerActions,titleLeadingActions:e.titleLeadingActions}),i=yj({onSearchChange:e=>this.store.setCatalogSearch(e),onGroupByChange:e=>this.store.setCatalogGroupBy(e),onDropRemove:e=>this.store.removeRound(e),onNavigateToPlanned:e=>this.store.navigateToRound(e)}),a=dj();this.layout=ZA({dateStrip:t,issuesPanel:n,venueBoard:r,roundCatalog:i,inspectorPanel:a},{hideLeft:e.hideLeft,catalogSide:e.catalogSide}),this.unsubscribe=this.store.subscribe(e=>{this.layout.update(e)}),this.layout.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.layout.element)}destroy(){this.unsubscribe(),this.popover.destroy(),this.container&&this.layout.element.parentNode===this.container&&this.layout.element.remove(),this.container=null}getProfile(){return this.store.getSchedulingProfile()}getStore(){return this.store}};function tM(e,t){let n=new eM(e);return n.render(t),n}var nM=class{constructor(){this.selectedDay=null,this.selectedVenue=null,this.selectedCourt=null,this.layerVisibility=new Map,this.listeners=new Set}setSelectedDay(e){this.selectedDay!==e&&(this.selectedDay=e,this.emit({selectedDay:e}))}getSelectedDay(){return this.selectedDay}setSelectedVenue(e){this.selectedVenue!==e&&(this.selectedVenue=e,this.emit({selectedVenue:e}))}getSelectedVenue(){return this.selectedVenue}setSelectedCourt(e){this.selectedCourt!==e&&(this.selectedCourt=e,this.emit({selectedCourt:e}))}getSelectedCourt(){return this.selectedCourt}setLayerVisibility(e,t){this.layerVisibility.set(e,t),this.emit({layerVisibility:new Map(this.layerVisibility)})}getLayerVisibility(){return new Map(this.layerVisibility)}isLayerVisible(e){return this.layerVisibility.get(e)??!0}getSnapshot(){return{selectedDay:this.selectedDay,selectedVenue:this.selectedVenue,selectedCourt:this.selectedCourt,layerVisibility:new Map(this.layerVisibility)}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}emit(e){let t={type:`VIEW_CHANGED`,payload:e};for(let e of this.listeners)e(t)}},rM={AVAILABLE:`rgba(33, 141, 141, 0.15)`,BLOCKED:`#95a5a6`,PRACTICE:`#9b59b6`,MAINTENANCE:`#f39c12`,RESERVED:`#3498db`,CLOSED:`#2c3e50`,SCHEDULED:`#27ae60`,SOFT_BLOCK:`#5dade2`,HARD_BLOCK:`#e74c3c`,LOCKED:`#34495e`,UNSPECIFIED:`#ecf0f1`};function iM(e,t,n={}){let r=[],i=new Map;for(let e of t){let t=cM(e.ref);i.set(t,e)}let a=new Set;for(let t of e)for(let e of t.rails)a.add(cM(e.court));for(let e of a){let t=i.get(e);if(!t)continue;let n={id:e,content:t.name,courtRef:t.ref,surface:t.surface,indoor:t.indoor,hasLights:t.hasLights,tags:t.tags};r.push(n)}return r}function aM(e,t={}){let{layerVisibility:n=new Map,showSegmentLabels:r=!1,colorScheme:i=rM}=t,a=[];for(let t of e)for(let e of t.rails){let t=cM(e.court);for(let o of e.segments){if(!(n.get(o.status)??!0))continue;let e=`${t}-${o.start}-${o.status}`,s=i[o.status];a.push({id:e,group:t,content:r?oM(o):``,start:o.start,end:o.end,type:`background`,className:`temporal-segment segment-${o.status.toLowerCase()}`,style:s===`transparent`?void 0:`background-color: ${s};`,title:`${o.status} segment`,editable:!1,selectable:!1,status:o.status,contributingBlocks:o.contributingBlocks,isSegment:!0})}}return a}function oM(e){let t=Math.round((new Date(e.end).getTime()-new Date(e.start).getTime())/(1e3*60));return`${e.status} (${t}m)`}function sM(e,t={}){let{colorScheme:n=rM}=t,r=[];for(let t of e){let e=cM(t.court),i=n[t.type],a=lM(i,-20);r.push({id:`block-${t.id}`,group:e,content:t.reason||t.type,start:t.start,end:t.end,type:`range`,className:`temporal-block block-${t.type.toLowerCase()}`,style:`background-color: ${i}; border-color: ${a};`,title:t.reason||t.type,editable:{updateTime:!0,updateGroup:!0,remove:!1},blockId:t.id,status:t.type,reason:t.reason,isBlock:!0})}return r}function cM(e){return`${e.tournamentId}|${e.venueId}|${e.courtId}`}function lM(e,t){if(!e||!e.startsWith(`#`))return e;let n=parseInt(e.replace(`#`,``),16),r=Math.round(2.55*t),i=(n>>16)+r,a=(n>>8&255)+r,o=(n&255)+r;return`#`+(16777216+(i<255?i<1?0:i:255)*65536+(a<255?a<1?0:a:255)*256+(o<255?o<1?0:o:255)).toString(16).slice(1)}function uM(e){let t=e.split(`|`);return t.length===3?{tournamentId:t[0],venueId:t[1],courtId:t[2]}:null}function dM(e){let t=String(e);return t.startsWith(`block-`)?t.slice(6):null}function fM(e){let t=new Date(`${e.day}T${e.dayStartTime}:00`),n=new Date(`${e.day}T${e.dayEndTime}:00`);return{start:t,end:n,min:t,max:n,zoomMin:e.slotMinutes*4*60*1e3,zoomMax:(n.getTime()-t.getTime())*1.5}}var pM=u({EventEmitter:()=>zN,PluginRegistry:()=>FM,TimepickerUI:()=>WN,default:()=>GN});function mM(e){let t=e.target,n=t.hasAttribute(`data-md3-ripple`)?t:t.closest(`[data-md3-ripple]`);if(!n||e.button!==0&&e.pointerType===`mouse`)return;let r=n.getBoundingClientRect(),i=Math.max(r.width,r.height)*2,a=e.clientX-r.left,o=e.clientY-r.top;n.style.setProperty(`--ripple-size`,`${i}px`),n.style.setProperty(`--ripple-x`,`${a}px`),n.style.setProperty(`--ripple-y`,`${o}px`),n.classList.remove(NN,PN),n.offsetWidth,n.classList.add(NN,PN),n._rippleHold=!0,FN=n}function hM(e){let t=e.target,n=(t.hasAttribute(`data-md3-ripple`)?t:t.closest(`[data-md3-ripple]`))||FN;n&&(n._rippleHold=!1,n.classList.remove(PN),setTimeout(()=>{n.classList.remove(NN),FN===n&&(FN=null)},1e3))}function gM(e){let t=e.currentTarget;!t||!t._rippleHold||(t._rippleHold=!1,t.classList.remove(PN),setTimeout(()=>{t.classList.remove(NN),FN===t&&(FN=null)},1e3))}function _M(e){if(bM()===!1)return;let t=e||document;t.addEventListener(`pointerdown`,mM),t.addEventListener(`pointerup`,hM),t.addEventListener(`pointercancel`,hM),t.querySelectorAll(`[data-md3-ripple]`).forEach(e=>{e.addEventListener(`mouseleave`,gM)})}function vM(e={}){let t={clock:{...BN.clock,...e.clock},ui:{...BN.ui,...e.ui},labels:{...BN.labels,...e.labels},behavior:{...BN.behavior,...e.behavior},callbacks:{...BN.callbacks,...e.callbacks},timezone:{...BN.timezone,...e.timezone},range:{...BN.range,...e.range},wheel:{...BN.wheel,...e.wheel},clearBehavior:{...BN.clearBehavior,...e.clearBehavior}},n=t.ui.mode;return(n===`wheel`||n===`compact-wheel`)&&(t.wheel={placement:n===`compact-wheel`?`auto`:void 0,hideFooter:void 0,commitOnScroll:void 0,ignoreOutsideClick:void 0,...t.wheel}),t}var yM,bM,xM,SM,CM,wM,TM,EM,DM,OM,kM,AM,jM,MM,NM,PM,FM,IM,LM,RM,zM,BM,VM,HM,UM,WM,GM,KM,qM,JM,YM,XM,ZM,QM,$M,eN,tN,nN,rN,iN,aN,oN,sN,cN,lN,uN,dN,fN,pN,mN,hN,gN,_N,vN,yN,bN,xN,SN,CN,wN,TN,EN,DN,ON,kN,AN,jN,MN,NN,PN,FN,IN,LN,RN,zN,BN,VN,HN,UN,WN,GN,KN=c((()=>{yM=()=>typeof window>`u`,bM=()=>typeof document<`u`,xM=class{state;constructor(e,t,n,r){this.state={degreesHours:null,degreesMinutes:null,options:t,element:e,instanceId:n,isMobileView:!1,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isOpen:!1,isInitialized:!1,customId:r,eventHandlersRegistered:!1,isDestroyed:!1}}get degreesHours(){return this.state.degreesHours}get degreesMinutes(){return this.state.degreesMinutes}get options(){return this.state.options}get element(){return this.state.element}get instanceId(){return this.state.instanceId}get isMobileView(){return this.state.isMobileView}get isTouchMouseMove(){return this.state.isTouchMouseMove}get disabledTime(){return this.state.disabledTime}get cloned(){return this.state.cloned}get isModalRemove(){return this.state.isModalRemove}get isOpen(){return this.state.isOpen}get isInitialized(){return this.state.isInitialized}get customId(){return this.state.customId}get eventHandlersRegistered(){return this.state.eventHandlersRegistered}get isDestroyed(){return this.state.isDestroyed}setDegreesHours(e){this.state={...this.state,degreesHours:e}}setDegreesMinutes(e){this.state={...this.state,degreesMinutes:e}}setOptions(e){this.state={...this.state,options:e}}setIsMobileView(e){this.state={...this.state,isMobileView:e}}setIsTouchMouseMove(e){this.state={...this.state,isTouchMouseMove:e}}setDisabledTime(e){this.state={...this.state,disabledTime:e}}setCloned(e){this.state={...this.state,cloned:e}}setIsModalRemove(e){this.state={...this.state,isModalRemove:e}}setIsOpen(e){this.state={...this.state,isOpen:e}}setIsInitialized(e){this.state={...this.state,isInitialized:e}}setEventHandlersRegistered(e){this.state={...this.state,eventHandlersRegistered:e}}setIsDestroyed(e){this.state={...this.state,isDestroyed:e}}updateOptions(e){this.state={...this.state,options:{...this.state.options,clock:{...this.state.options.clock,...e.clock||{}},ui:{...this.state.options.ui,...e.ui||{}},labels:{...this.state.options.labels,...e.labels||{}},behavior:{...this.state.options.behavior,...e.behavior||{}},callbacks:{...this.state.options.callbacks,...e.callbacks||{}}}}}reset(){this.state={...this.state,degreesHours:null,degreesMinutes:null,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isOpen:!1,isInitialized:!1,isDestroyed:!0,eventHandlersRegistered:!1}}getModalElement(){return bM()===!1?null:document.querySelector(`[data-owner-id="${this.state.instanceId}"]`)}getInput(){return this.state.element?.querySelector(`input`)}getClockFace(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-clock-face.mobile`):e.querySelector(`.tp-ui-clock-face:not(.mobile)`):null}getClockHand(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-mobile-clock-wrapper .tp-ui-clock-hand`):e.querySelector(`.tp-ui-clock-hand:not(.mobile)`):null}getCircle(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-mobile-clock-wrapper .tp-ui-circle-hand`):e.querySelector(`.tp-ui-circle-hand:not(.mobile)`):null}getTipsWrapper(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper`):e.querySelector(`.tp-ui-tips-wrapper:not(.mobile)`):null}getTipsWrapperFor24h(){let e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(`.tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper-24h`):e.querySelector(`.tp-ui-tips-wrapper-24h:not(.mobile)`):null}getMinutes(){return this.getModalElement()?.querySelector(`.tp-ui-minutes`)||null}getHour(){return this.getModalElement()?.querySelector(`.tp-ui-hour`)||null}getAM(){return this.getModalElement()?.querySelector(`.tp-ui-am`)||null}getPM(){return this.getModalElement()?.querySelector(`.tp-ui-pm`)||null}getHourText(){return this.getModalElement()?.querySelector(`.tp-ui-hour-text`)||null}getMinutesText(){return this.getModalElement()?.querySelector(`.tp-ui-minute-text`)||null}getHeader(){return this.getModalElement()?.querySelector(`.tp-ui-header`)||null}getInputWrappers(){return this.getModalElement()?.querySelectorAll(`.tp-ui-input-wrapper`)||null}getDots(){return this.getModalElement()?.querySelector(`.tp-ui-dots`)||null}getMinutesTips(){return this.getModalElement()?.querySelector(`.tp-ui-minutes-time`)||null}getHourTips(){return this.getModalElement()?.querySelector(`.tp-ui-hour-time-12`)||null}getAllValueTips(){let e=this.getModalElement();return e?[...e.querySelectorAll(`.tp-ui-value-tips`),...e.querySelectorAll(`.tp-ui-value-tips-24h`)]:[]}getOpenElementData(){let e=this.state.element?.querySelectorAll(`[data-open]`);if(e?.length>0){let t=[];return e.forEach(({dataset:e})=>t.push(e.open??``)),[...new Set(t)]}return null}getOpenElement(){let e=this.getInput(),t=this.getOpenElementData();return t===null?(e?.setAttribute(`data-open`,`tp-ui-input`),[e]):t.map(e=>this.state.element?.querySelectorAll(`[data-open='${e}']`))[0]??``}getCancelButton(){return this.getModalElement()?.querySelector(`.tp-ui-cancel-btn`)||null}getOkButton(){return this.getModalElement()?.querySelector(`.tp-ui-ok-btn`)||null}getActiveTypeMode(){return this.getModalElement()?.querySelector(`.tp-ui-type-mode.active`)||null}getKeyboardClockIcon(){return this.getModalElement()?.querySelector(`.tp-ui-keyboard-icon-wrapper`)||null}getFooter(){return this.getModalElement()?.querySelector(`.tp-ui-footer`)||null}getWrapper(){return this.getModalElement()?.querySelector(`.tp-ui-wrapper`)||null}},SM={DEFAULT_DELAY:300,MODAL_ANIMATION:150,SCROLLBAR_RESTORE:400,MODAL_REMOVE:300,CLOCK_ANIMATION:600,TIPS_ANIMATION:401,MOBILE_TOGGLE:450,CLOCK_SCALE_DELAY:150,WRAPPER_TRANSITION:400,DROPDOWN_CLICK_DELAY:10},CM=class{core;emitter;timeouts=[];constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on(`animation:clock`,()=>{this.handleAnimationSwitchTipsMode()})}runWithAnimation(e,t=SM.MODAL_ANIMATION){if(this.core.options.ui.animation){let n=setTimeout(e,t);this.timeouts.push(n)}else e()}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}setAnimationToOpen(){this.clearAllTimeouts(),this.core.getModalElement()?.classList.add(`opacity`),this.runWithAnimation(()=>{this.core.getModalElement()?.classList.add(`show`)})}removeAnimationToClose(){this.clearAllTimeouts(),this.core.getModalElement()&&this.runWithAnimation(()=>{let e=this.core.getModalElement();e?.classList.remove(`show`),e?.classList.remove(`opacity`)})}handleAnimationClock(){this.core.options.ui.animation&&this.runWithAnimation(()=>{this.core.getClockFace()?.classList.add(`tp-ui-clock-animation`);let e=setTimeout(()=>{this.core.getClockFace()?.classList.remove(`tp-ui-clock-animation`)},SM.CLOCK_ANIMATION);this.timeouts.push(e)})}handleAnimationSwitchTipsMode(){let e=this.core.getClockHand();if(!e)return;this.emitter.emit(`animation:start`,{}),e.classList.add(`tp-ui-tips-animation`);let t=setTimeout(()=>{this.core.getClockHand()?.classList.remove(`tp-ui-tips-animation`),this.emitter.emit(`animation:end`,{})},SM.TIPS_ANIMATION);this.timeouts.push(t)}destroy(){this.clearAllTimeouts()}},wM=()=>{if(bM()===!1)return 0;let e=document.createElement(`div`);e.className=`tp-ui-measure`,document.body.appendChild(e);let t=e.getBoundingClientRect().width-e.clientWidth;return document.body.removeChild(e),t},TM=(e,t)=>e?e.classList.contains(t):!1,EM=(e,t)=>Array.from({length:Number(t)-Number(e)+1},(t,n)=>Number(e)+n),DM=(e,t)=>Array.from({length:Number(t)-Number(e)+1},(e,n)=>Number(t)-n).reverse(),OM=(e=``)=>{let t=e.replace(/(AM|PM|am|pm)/,e=>` ${e}`),n=new Date(`September 20, 2000 ${t}`);return`${n.getHours().toString().padStart(2,`0`)}:${n.getMinutes().toString().padStart(2,`0`)}`},kM=e=>{let[t,n]=e.split(`:`);return`${t.padStart(2,`0`)}:${n.padStart(2,`0`)}`},AM=(e,t)=>{if(e.length<2)return!1;let n=e.map(e=>{let[n,r]=e.trim().split(`-`),i,a;if(t===`12h`){if(!/\s?(AM|PM|am|pm)\s?$/.test(n.trim())||!/\s?(AM|PM|am|pm)\s?$/.test(r.trim()))throw Error(`Invalid 12h format: "${e}"`);i=OM(n.trim()),a=OM(r.trim())}else{if(/\s?(AM|PM|am|pm)\s?/.test(n.trim())||/\s?(AM|PM|am|pm)\s?/.test(r.trim()))throw Error(`Invalid 24h format: "${e}"`);i=kM(n.trim()),a=kM(r.trim())}return{start:i,end:a,original:e}});for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){let r=n[e],i=n[t];if(r.start<=i.end&&r.end>=i.start||i.start<=r.end&&i.end>=r.start)throw Error(`Overlapping intervals: "${r.original}" and "${i.original}"`)}return!1},jM=()=>typeof window<`u`&&window.crypto&&typeof window.crypto.randomUUID==`function`?window.crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)}),MM=`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm0-80h640v-400H160v400Zm160-40h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM160-280v-400 400Z"/></svg>`,NM=`<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"/></svg>`,PM=class{plugins=new Map;register(e){this.plugins.has(e.name)||this.plugins.set(e.name,e)}getAll(){return Array.from(this.plugins.values())}has(e){return this.plugins.has(e)}get(e){return this.plugins.get(e)}getTemplateProvider(e){return this.plugins.get(e)?.templateProvider}getClearHandler(e){return this.plugins.get(e)?.clearHandler}},FM=new PM,IM=[`00`,`13`,`14`,`15`,`16`,`17`,`18`,`19`,`20`,`21`,`22`,`23`],LM=[`12`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`11`],RM=[`00`,`05`,`10`,`15`,`20`,`25`,`30`,`35`,`40`,`45`,`50`,`55`],zM=(e,t,n)=>{let{timezone:{enabled:r,label:i}}=e;return!r||!FM.has(`timezone`)?``:`<div class="tp-ui-timezone ${t}">
|
|
224
224
|
<span class="tp-ui-timezone-label" id="tp-tz-label-${n}">${i}</span>
|
|
225
225
|
<div class="tp-ui-timezone-dropdown" role="combobox" aria-expanded="false" aria-haspopup="listbox" aria-labelledby="tp-tz-label-${n}" tabindex="0" data-tz-id="${n}">
|
|
226
226
|
<div class="tp-ui-timezone-selected" data-placeholder="${i}...">${i}...</div>
|
|
227
227
|
<svg class="tp-ui-timezone-arrow" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
|
228
228
|
<div class="tp-ui-timezone-menu" role="listbox" aria-labelledby="tp-tz-label-${n}"></div>
|
|
229
229
|
</div>
|
|
230
|
-
</div>`},wj=e=>{let{range:{enabled:t,fromLabel:n,toLabel:r}}=e;return!t||!yj.has(`range`)?``:`<div class="tp-ui-range-header" role="tablist" aria-label="Range selection"><button type="button" class="tp-ui-range-tab tp-ui-range-from active" role="tab" tabindex="0" aria-selected="true"><span class="tp-ui-range-tab-label">${n}</span><span class="tp-ui-range-tab-value tp-ui-range-from-time">--:--</span></button><button type="button" class="tp-ui-range-tab tp-ui-range-to" role="tab" tabindex="-1" aria-selected="false"><span class="tp-ui-range-tab-label">${r}</span><span class="tp-ui-range-tab-value tp-ui-range-to-time">--:--</span></button></div>`},Tj=(e,t)=>{let{ui:{clearButton:n},labels:{clear:r}}=e;return n?`<div class="tp-ui-clear-btn ${t} disabled" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${r}" aria-disabled="true">${r}</div>`:``},Ej=(e,t,n)=>{if(e.isWheelMode){let t=yj.getTemplateProvider(`wheel`);return t?`<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}">${t(n,e.instanceId)}</div>`:`<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}"></div>`}return`<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}"><div class="tp-ui-body ${e.mobileClass}"><div class="tp-ui-clock-face ${e.mobileClass}" role="group" aria-label="Clock"><div class="tp-ui-dot ${e.mobileClass}" aria-hidden="true"></div><div class="tp-ui-clock-hand ${e.mobileClass}" aria-hidden="true"><div class="tp-ui-circle-hand ${e.mobileClass}"></div></div><div class="tp-ui-tips-wrapper ${e.mobileClass}" role="listbox" aria-label="Time"></div>${e.clockType===`24h`?`<div class="tp-ui-tips-wrapper-24h ${e.mobileClass}" role="listbox" aria-label="24h"></div>`:``}</div></div></div>`},Dj=(e,t)=>{let{labels:{time:n,mobileTime:r,am:i,pm:a,mobileMinute:o,mobileHour:s},ui:{editable:c}}=e,{mobileClass:l,clockType:u,instanceId:d}=t,f=l?r:n,p=u===`24h`?``:`<div class="tp-ui-wrapper-type-time ${l}" role="group" aria-label="Period"><div class="tp-ui-type-mode tp-ui-am ${l?`mobile`:`tp-ui-ripple`}" data-md3-ripple tabindex="0" role="button" aria-label="${i}" aria-pressed="false" data-type="AM">${i}</div><div class="tp-ui-type-mode tp-ui-pm ${l?`mobile`:`tp-ui-ripple`}" data-md3-ripple tabindex="0" role="button" aria-label="${a}" aria-pressed="false" data-type="PM">${a}</div></div>`;return`<div class="tp-ui-select-time ${l}" id="tp-ui-label-${d}">${f}</div><div class="tp-ui-header ${l}"><div class="tp-ui-wrapper-time ${l} ${u===`24h`?`tp-ui-wrapper-time-24h`:``}" role="group" aria-label="${f}"><div class="tp-ui-input-wrapper ${l}"><div class="tp-ui-input-ripple-wrapper ${l}" data-md3-ripple><input name="hour" ${!c&&!l?`readonly`:``} class="tp-ui-hour ${l}" tabindex="0" type="number" min="0" max="${u===`12h`?`12`:`23`}" aria-label="${l?s:`Hour`}" role="spinbutton" aria-valuenow="12"></div><div class="tp-ui-hour-text ${l}">${s}</div></div><div class="tp-ui-dots ${l}" aria-hidden="true"><span></span><span></span></div><div class="tp-ui-input-wrapper ${l}"><div class="tp-ui-input-ripple-wrapper ${l}" data-md3-ripple><input name="minutes" ${!c&&!l?`readonly`:``} class="tp-ui-minutes ${l}" tabindex="0" type="number" min="0" max="59" aria-label="${l?o:`Minute`}" role="spinbutton" aria-valuenow="0"></div><div class="tp-ui-minute-text ${l}">${o}</div></div></div>${p}</div>`},Oj=(e,t)=>{let{ui:{enableSwitchIcon:n,iconTemplate:r,iconTemplateMobile:i},labels:{cancel:a,ok:o}}=e,s=`<button aria-label="Keyboard" type="button" class="tp-ui-keyboard-icon">${r||gj}</button>`,c=i||`<button aria-label="Clock" type="button" class="tp-ui-keyboard-icon">${i||_j}</button>`,l=n?`<div class="tp-ui-keyboard-icon-wrapper ${t}" tabindex="0" role="button" aria-pressed="false" aria-label="Toggle" data-view="desktop">${t?c:s}</div>`:``,u=Tj(e,t);return`<div class="tp-ui-footer ${t}" ${t?`data-view="mobile"`:``}>${l}<div class="tp-ui-wrapper-btn ${t}">${u}<div class="tp-ui-cancel-btn ${t}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${a}">${a}</div><div class="tp-ui-ok-btn ${t}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${o}">${o}</div></div></div>`},kj=(e,t)=>{let{ui:{mode:n,animation:r,theme:i,mobile:a},clock:{incrementMinutes:o}}=e,s=a?`mobile`:``,c=n===`compact-wheel`&&yj.has(`wheel`),l=(n===`wheel`||c)&&yj.has(`wheel`),u=!!e.range?.enabled&&yj.has(`range`),d=!!e.timezone?.enabled&&yj.has(`timezone`),f={mobileClass:s,clockType:e.clock.type||`12h`,instanceId:t,isWheelMode:l,isCompactWheel:c,isRangeMode:u},p=wj(e),m=Cj(e,s,t),h=c?``:Dj(e,f),g=Ej(f,o??1,e),_=c&&e.wheel?.hideFooter===!0?``:Oj(e,s),v;return v=c?` tp-ui-compact-wheel-mode`:l?` tp-ui-wheel-mode`:``,`<div class="tp-ui-modal normalize ${s}${u?` tp-ui-range-mode`:``}${d?` tp-ui-tz-mode`:``}${v}" data-theme="${i}" role="dialog" aria-modal="true" aria-labelledby="tp-ui-label-${t}" data-owner-id="${t}" style='transition:${r?`opacity 0.15s linear`:`none`}'><div class="tp-ui-wrapper ${s}" tabindex="0">${p}${h}${m}${g}${_}</div><div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div></div>`},Aj=class{core;emitter;timeouts=[];originalOverflow;originalPaddingRight;constructor(e,t){this.core=e,this.emitter=t}runWithTimeout(e,t=oj.DEFAULT_DELAY){let n=setTimeout(e,t);this.timeouts.push(n)}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}isPopoverMode(){return this.core.options.ui.mode===`compact-wheel`&&!!this.core.options.wheel?.placement}clearExistingModal(){if(ij()===!1)return;let e=this.core.getModalElement();e&&e.remove()}setModalTemplate(){if(ij()===!1)return;this.clearExistingModal();let e=kj(this.core.options,this.core.instanceId);if(this.core.options.ui.inline?.enabled){let t=document.getElementById(this.core.options.ui.inline.containerId);if(!t)return;t.innerHTML=``,t.insertAdjacentHTML(`beforeend`,e);let n=t.querySelector(`.tp-ui-modal`);if(n){n.classList.add(`tp-ui--inline`);let{showButtons:e}=this.core.options.ui.inline;(e===!1||e===void 0)&&n.querySelectorAll(`.tp-ui-wrapper-btn, .tp-ui-wrapper-btn.mobile`).forEach(e=>e.style.display=`none`)}return}let{appendModalSelector:t}=this.core.options.ui;t?document.querySelector(t)?.insertAdjacentHTML(`beforeend`,e):document.body.insertAdjacentHTML(`beforeend`,e)}setScrollbarOrNot(){ij()!==!1&&(this.core.options.ui.inline?.enabled||this.isPopoverMode()||(this.core.options.ui.enableScrollbar?this.runWithTimeout(()=>{rj()||this.runWithTimeout(()=>{typeof document<`u`&&(document.body.style.overflowY=this.originalOverflow||``,document.body.style.paddingRight=this.originalPaddingRight||``)},oj.SCROLLBAR_RESTORE)},400):(this.originalOverflow=document.body.style.overflowY,this.originalPaddingRight=document.body.style.paddingRight,document.body.style.paddingRight=`${cj()}px`,document.body.style.overflowY=`hidden`)))}removeBackdrop(){if(this.core.options.ui.inline?.enabled||this.core.options.ui.backdrop)return;let e=this.core.getModalElement(),t=this.core.getOpenElement();e?.classList.add(`removed`),t.forEach(e=>e?.classList.add(`disabled`))}setNormalizeClass(){let e=this.core.getModalElement();e&&(e.classList.add(`tp-ui-normalize`),e.querySelectorAll(`:scope > div`).forEach(e=>e.classList.add(`tp-ui-normalize`)))}setShowClassToBackdrop(){if(this.core.options.ui.inline?.enabled||this.isPopoverMode()){this.core.getModalElement()?.classList.add(`show`),this.setInitialFocus();return}this.core.options.ui.backdrop&&this.runWithTimeout(()=>{this.core.getModalElement()?.classList.add(`show`),this.setInitialFocus()},oj.MODAL_ANIMATION)}setInitialFocus(){if(!this.core.options.behavior.focusTrap)return;let e=this.core.getWrapper();e&&typeof requestAnimationFrame<`u`&&requestAnimationFrame(()=>{e.focus()})}setFlexEndToFooterIfNoKeyboardIcon(){let e=this.core.getFooter();!this.core.options.ui.enableSwitchIcon&&e&&(e.style.justifyContent=`flex-end`)}destroy(){this.clearAllTimeouts(),!rj()&&!this.core.options.ui.inline?.enabled&&(document.body.style.overflowY=this.originalOverflow||``,document.body.style.paddingRight=this.originalPaddingRight||``),this.clearExistingModal()}},jj=(e,t,n,r)=>{let i={hour:`12`,minutes:`00`,type:t===`24h`?void 0:`PM`};if(!e)return i;let a=e.value.trim();if(!n&&!a)return i;if(typeof n==`boolean`&&n){let[e,n]=new Date().toLocaleTimeString().split(`:`),r=e.padStart(2,`0`);if(/[a-z]/i.test(n)&&t===`12h`){let[e,t]=n.split(` `);return{hour:r,minutes:e,type:t}}return{hour:r,minutes:n,type:void 0}}if(typeof n==`object`){let{time:e,locales:i,preventClockType:a}=n,o=e??new Date;if(a&&r){let[e,t]=new Date(o).toLocaleTimeString().split(`:`);if(/[a-z]/i.test(t)){let[n,r]=t.split(` `);return{hour:e,minutes:n,type:r}}return{hour:e.padStart(2,`0`),minutes:t,type:void 0}}let[s,c]=new Date(o).toLocaleTimeString(i||`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:t===`12h`}).split(`:`);if(t===`12h`&&/[a-z]/i.test(c)){let e=c.trim().split(` `);return{hour:s,minutes:e[0],type:e[1]||`AM`}}return{hour:s,minutes:c.replace(/\D/g,``),type:void 0}}let[o,s]=a.split(` `),[c=``,l=``]=o.split(`:`),u=c.replace(/\D/g,``),d=l.replace(/\D/g,``),f={hour:u.padStart(2,`0`),minutes:d.padStart(2,`0`),type:t===`12h`?s:void 0};if(u.length>2||d.length>2)return{...f,error:`Invalid input: too many digits.`,currentHour:c,currentMin:l};if(/[a-z]/i.test(o))return{...f,error:`Input contains invalid letters.`};if(a.includes(` `)&&(!s||a.length>8||s!==`AM`&&s!==`PM`))return{...f,error:`Invalid AM/PM format or length.`,currentLength:a.length,currentType:s};let p=Number(u),m=Number(d);if(t===`12h`){if(p<1||p>12||m<0||m>59||s!==`AM`&&s!==`PM`)return{...f,error:`Invalid 12h time.`,currentHour:p,currentMin:m,currentType:s}}else if(p<0||p>23||m<0||m>59)return{...f,error:`Invalid 24h time.`,currentHour:p,currentMin:m};return f},Mj=(e,t,n)=>{let r=Number(e);if(Number.isNaN(r))return!1;switch(t){case`hour`:return n===`24h`?r>=0&&r<=23:r>0&&r<=12;case`minutes`:return r>=0&&r<=59;default:return}},Nj=`tp-ui`,Pj=`mousedown mouseup mousemove mouseleave mouseover touchstart touchmove touchend`,Fj=`active`,Ij=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}isCurrentTimeEnabled(e){let t=this.core.options.clock.currentTime;return typeof t==`boolean`?t:!!t?.[e]}preventClockTypeByCurrentTime(){if(!this.isCurrentTimeEnabled(`preventClockType`))return;let e=this.core.getInput();if(!e)return;let{currentTime:t,clockType:n}={currentTime:this.core.options.clock.currentTime,clockType:this.core.options.clock.type},{type:r}=jj(e,n,t,!0);this.core.updateOptions({clock:{type:r?`12h`:`24h`}})}updateInputValueWithCurrentTimeOnStart(){if(!this.isCurrentTimeEnabled(`updateInput`))return;let e=this.core.getInput();if(!e)return;let{hour:t,minutes:n,type:r}=jj(e,this.core.options.clock.type,this.core.options.clock.currentTime);e.value=r?`${t}:${n} ${r}`:`${t}:${n}`}getInputValueOnOpenAndSet(){let e=this.core.getInput();if(!e)return;let t=jj(e,this.core.options.clock.type,this.core.options.clock.currentTime),n=this.core.getHour(),r=this.core.getMinutes(),i=this.core.getActiveTypeMode(),a=this.core.getAM();if(t===void 0){n&&(n.value=`12`),r&&(r.value=`00`);let e={hour:n?.value||`12`,minutes:r?.value||`00`,type:i?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit(`open`,e);let t=this.core.options.range?.enabled===!0;this.core.options.clock.type!==`24h`&&a&&!t&&a.classList.add(Fj);return}let[o,s,c]=e.value.split(`:`).join(` `).split(` `);e.value.length===0&&(o=t.hour,s=t.minutes,c=t.type),this.core.options.clock.type!==`24h`&&!c&&(c=t.type||`AM`),n&&(n.value=o.padStart(2,`0`)),r&&(r.value=s.padStart(2,`0`));let l=this.core.getModalElement()?.querySelector(`[data-type='${c}']`);this.core.options.clock.type!==`24h`&&l&&l.classList.add(Fj);let u={...t,type:i?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit(`open`,u)}getInputValue(e,t,n){return jj(e,t,n)}destroy(){}},Lj=class{core;emitter;isAnimating=!1;constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on(`switch:view`,()=>{this.toggleMobileClockFace()})}checkMobileOption(){this.core.setIsMobileView(!!this.core.options.ui.mobile),this.core.options.ui.mobile&&this.core.updateOptions({ui:{editable:!0}})}toggleMobileClockFace(){if(this.isAnimating)return;let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(`.tp-ui-wrapper`),n=this.core.getKeyboardClockIcon(),r=e.querySelector(`.tp-ui-mobile-clock-wrapper`),i=e.querySelectorAll(`*`),a=e.querySelector(`.tp-ui-select-time`),o=this.core.getHour(),s=this.core.getMinutes(),c=this.core.getClockFace();if(!t)return;let l=t.classList.contains(`expanded`),u=this.core.isMobileView;l?this.collapseClockFace(t,r,i,n,a,o,s,c,u):this.expandClockFace(t,r,i,n,a,o,s,c)}collapseClockFace(e,t,n,r,i,a,o,s,c){if(this.isAnimating=!0,typeof requestAnimationFrame<`u`){let l=typeof window<`u`&&window.matchMedia(`(orientation: landscape) and (min-width: 320px) and (max-width: 825px)`).matches;requestAnimationFrame(()=>{l&&e instanceof HTMLElement?this.collapseLandscape(e,t,n,r,i,a,o,s,c):this.collapsePortrait(e,t,n,r,i,a,o,s,c)})}else this.switchView(i,r,a,o,!0),this.isAnimating=!1;r?.setAttribute(`aria-label`,`Show clock face`),r?.setAttribute(`aria-pressed`,`false`)}collapseLandscape(e,t,n,r,i,a,o,s,c){s?.classList.remove(`scale-in`);let l=this.core.getModalElement(),u=this.getMobileLandscapeHeight(l);e.style.width=`328px`,e.style.height=u,t instanceof HTMLElement&&(t.style.height=`0`,t.style.opacity=`0`,t.style.transform=`scale(0)`),setTimeout(()=>{this.applyMobileClasses(e,t,n,i,c),e.classList.add(`mobile`),t&&t.classList.add(`mobile`),this.switchView(i,r,a,o,!0),requestAnimationFrame(()=>{e.style.width=``,e.style.height=``,t instanceof HTMLElement&&(t.style.height=``,t.style.opacity=``,t.style.transform=``),this.isAnimating=!1})},oj.WRAPPER_TRANSITION)}collapsePortrait(e,t,n,r,i,a,o,s,c){c?s?.classList.remove(`scale-in`):s?.classList.add(`scale-in`),t?.classList.remove(`expanded`),c&&t?.classList.add(`mobile`),requestAnimationFrame(()=>{this.applyMobileClasses(e,t,n,i,c),this.switchView(i,r,a,o,!0),setTimeout(()=>{this.isAnimating=!1},oj.MOBILE_TOGGLE)})}applyMobileClasses(e,t,n,r,i){e.classList.remove(`expanded`),t?.classList.remove(`expanded`),i&&(e.classList.add(`mobile`),t?.classList.add(`mobile`)),n.forEach(n=>{n!==t&&n!==e&&n!==r&&(n.classList.remove(`expanded`),i&&n.classList.add(`mobile`))}),r&&(r.classList.remove(`expanded`),i&&r.classList.add(`mobile`))}expandClockFace(e,t,n,r,i,a,o,s){this.isAnimating=!0,o?.classList.contains(`active`)&&o?this.emitter.emit(`select:minute`,{minutes:o.value}):a&&this.emitter.emit(`select:hour`,{hour:a.value}),n.forEach(n=>{n!==t&&n!==e&&n!==i&&(n.classList.remove(`mobile`),n.classList.add(`expanded`))}),i&&(i.classList.remove(`mobile`),i.classList.add(`expanded`)),this.switchView(i,r,a,o,!1),typeof requestAnimationFrame<`u`?requestAnimationFrame(()=>{e.classList.remove(`mobile`),e.classList.add(`expanded`),requestAnimationFrame(()=>{t&&(t.classList.remove(`mobile`),t.classList.add(`expanded`)),s&&s.classList.remove(`scale-in`),setTimeout(()=>{s&&s.classList.add(`scale-in`)},oj.CLOCK_SCALE_DELAY),setTimeout(()=>{this.isAnimating=!1},oj.MOBILE_TOGGLE)})}):this.isAnimating=!1,r?.setAttribute(`aria-label`,`Hide clock face`),r?.setAttribute(`aria-pressed`,`true`)}switchView(e,t,n,r,i){let a=this.core.getModalElement(),o=a?.querySelector(`.tp-ui-hour-text`),s=a?.querySelector(`.tp-ui-minute-text`),c=t?.querySelector(`.tp-ui-keyboard-icon`),l=this.core.getInputWrappers(),u=this.core.getHeader(),d=a?.querySelector(`.tp-ui-wrapper-type-time`),f=a?.querySelector(`.tp-ui-am`),p=a?.querySelector(`.tp-ui-pm`),m=a?.querySelectorAll(`.tp-ui-input-ripple-wrapper`),{iconTemplate:h,iconTemplateMobile:g}=this.core.options.ui,{time:_,mobileTime:v}=this.core.options.labels;i?(e?.classList.add(`mobile`),t?.classList.add(`mobile`),n?.classList.add(`mobile`),n?.removeAttribute(`readonly`),r?.classList.add(`mobile`),r?.removeAttribute(`readonly`),o?.classList.add(`mobile`),s?.classList.add(`mobile`),u?.classList.add(`mobile`),d?.classList.add(`mobile`),f?.classList.add(`mobile`),f?.classList.remove(`tp-ui-ripple`),p?.classList.add(`mobile`),p?.classList.remove(`tp-ui-ripple`),l?.forEach(e=>{e.classList.add(`mobile`)}),m?.forEach(e=>{e.classList.add(`mobile`)}),e&&v&&(e.textContent=v),c&&(c.innerHTML=g||_j),this.updateClockFaceAccessibility(!0)):(e?.classList.remove(`mobile`),t?.classList.remove(`mobile`),n?.classList.remove(`mobile`),r?.classList.remove(`mobile`),this.core.options.ui.editable||(n?.setAttribute(`readonly`,``),r?.setAttribute(`readonly`,``)),o?.classList.remove(`mobile`),s?.classList.remove(`mobile`),u?.classList.remove(`mobile`),d?.classList.remove(`mobile`),f?.classList.remove(`mobile`),f?.classList.add(`tp-ui-ripple`),p?.classList.remove(`mobile`),p?.classList.add(`tp-ui-ripple`),l?.forEach(e=>{e.classList.remove(`mobile`)}),m?.forEach(e=>{e.classList.remove(`mobile`)}),e&&_&&(e.textContent=_),c&&(c.innerHTML=h||gj),this.updateClockFaceAccessibility(!1))}updateClockFaceAccessibility(e){let t=this.core.getClockFace();if(!t)return;let n=t.querySelector(`.tp-ui-tips-wrapper`),r=t.querySelector(`.tp-ui-tips-wrapper-24h`),i=t.querySelectorAll(`.tp-ui-tip`);e?(t.setAttribute(`aria-hidden`,`true`),n?.setAttribute(`aria-hidden`,`true`),r?.setAttribute(`aria-hidden`,`true`),i.forEach(e=>{e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-hidden`,`true`)})):(t.removeAttribute(`aria-hidden`),n?.removeAttribute(`aria-hidden`),r?.removeAttribute(`aria-hidden`),i.forEach(e=>{e.setAttribute(`tabindex`,`0`),e.removeAttribute(`aria-hidden`)}))}getMobileLandscapeHeight(e){return e?.classList.contains(`tp-ui-tz-mode`)?`326px`:e?.classList.contains(`tp-ui-range-mode`)?`287px`:`258px`}destroy(){}},Rj=e=>{if(!e)return;let{disabledTime:t,type:n}=e.clock;if(!t||!Object.keys(t).length)return;let{hours:r,minutes:i,interval:a}=t;if(a){delete t.hours,delete t.minutes;let e=Array.isArray(a)?a:[a];if(!n)throw Error(`clockType required for interval`);return mj(e,n),{value:e.map(e=>{let[t,r]=e.trim().split(`-`),{hour:i,minutes:a,type:o}=jj({value:t.trim()},n),{hour:s,minutes:c,type:l}=jj({value:r.trim()},n),u=uj(i,s).map(e=>Number(e)===0?`00`:String(Number(e))),d=[],f=Number(a),p=Number(c);if(l===o)return f>0&&p<=0?(d.push(u[0],u[u.length-1]),u=u.slice(1,-1)):p<59&&p>0&&f<=0?(d.push(void 0,u[u.length-1]),u=u.slice(0,-1)):p>0&&f>0?(d.push(u[0],u[u.length-1]),u=u.slice(1,-1)):p===0&&f===0&&(d.push(void 0,u[u.length-1]),u.pop()),{removedStartedHour:d[0]!==void 0&&Number(d[0])<=9?`0${d[0]}`:d[0],removedEndHour:d[1]!==void 0&&Number(d[1])<=9?`0${d[1]}`:d[1],rangeArrHour:u,startMinutes:uj(a,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:dj(0,c).map(e=>Number(e)<=9?`0${e}`:`${e}`),startType:o,endType:l};{let e=uj(i,12).map(String),t=dj(1,s).map(String),n=[],r=[];return f>0&&p<=0?(r.push(t[t.length-1]),n.push(e[0]),t.pop(),e.shift()):p<59&&p>0&&f<=0?(n.push(e[0]),r.push(t[t.length-1]),t.pop()):p>0&&f>0?(r.push(t[t.length-1]),n.push(e[0]),t.pop(),e.shift()):p===0&&f===0&&(r.push(t[t.length-1]),n.push(e[0]),t.pop()),{startType:o,endType:l,amHours:e,pmHours:t,removedAmHour:n[0]&&Number(n[0])<=9?`0${n[0]}`:n[0],removedPmHour:r[0]&&Number(r[0])<=9?`0${r[0]}`:r[0],startMinutes:Number(a)===0?[]:uj(a,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:dj(0,c).map(e=>Number(e)<=9?`0${e}`:`${e}`)}}}).reduce((e,t)=>(Object.entries(t).forEach(([t,n])=>{Array.isArray(n)?e[t]=Array.isArray(e[t])?[...e[t],...n]:[...n]:e[t]=n}),e),{isInterval:!0,clockType:n,intervals:e})}}return r?.forEach(e=>{if(n===`12h`&&Number(e)>12)throw Error(`The disabled hours value has to be less than 13`);if(n===`24h`&&Number(e)>23)throw Error(`The disabled hours value has to be less than 24`)}),i?.forEach(e=>{if(Number(e)>59)throw Error(`The disabled minutes value has to be less than 60`)}),{value:{hours:r?.map(e=>e===`00`||Number(e)===0?`0${Number(e)}`:`${Number(e)}`),minutes:i?.map(e=>Number(e)<=9?`0${e}`:`${e}`)}}},zj=(e,t,n,r)=>{if(e){if(Array.isArray(e)&&e.length>0)return!e.map(e=>Mj(e,t,n)).some(e=>e===!1);if(typeof e==`string`||typeof e==`number`){let i=Mj(e,t,n),a=r?.map(Number).includes(Number(e));return!!(i&&!a)}}},Bj=class{core;constructor(e){this.core=e}getDisableTime(){let e=Rj(this.core.options);this.core.setDisabledTime(e||null)}destroy(){}},Vj=class{inputValueHandler;mobileViewHandler;disabledTimeHandler;core;constructor(e,t){this.core=e,this.inputValueHandler=new Ij(e,t),this.mobileViewHandler=new Lj(e,t),this.disabledTimeHandler=new Bj(e)}preventClockTypeByCurrentTime(){this.inputValueHandler.preventClockTypeByCurrentTime()}updateInputValueWithCurrentTimeOnStart(){this.inputValueHandler.updateInputValueWithCurrentTimeOnStart()}getInputValueOnOpenAndSet(){this.inputValueHandler.getInputValueOnOpenAndSet()}getInputValue(e,t,n){return this.inputValueHandler.getInputValue(e,t,n)}checkMobileOption(){this.mobileViewHandler.checkMobileOption()}toggleMobileClockFace(){this.mobileViewHandler.toggleMobileClockFace()}updateClockFaceAccessibility(e){this.mobileViewHandler.updateClockFaceAccessibility(e)}getDisableTime(){this.disabledTimeHandler.getDisableTime()}destroy(){this.inputValueHandler.destroy(),this.mobileViewHandler.destroy(),this.disabledTimeHandler.destroy()}},Hj=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setTheme(){let e=this.core.getModalElement();if(!e)return;let{theme:t}=this.core.options.ui;t&&e.setAttribute(`data-theme`,t)}setInputClassToInputElement(){let e=this.core.getInput();e&&(lj(e,`tp-ui-input`)||e.classList.add(`tp-ui-input`))}setDataOpenToInputIfDoesntExistInWrapper(){let e=this.core.getOpenElementData(),t=this.core.getInput();e===null&&t&&t.setAttribute(`data-open`,`tp-ui-input`)}setClassTopOpenElement(){let e=this.core.getOpenElement();for(let t of e)t&&t.classList.add(`tp-ui-open-element`)}setTimepickerClassToElement(){let e=this.core.element;if(!e)return;e.classList.add(Nj);let t=this.core.options.ui.cssClass;t&&t!==Nj&&e.classList.add(t)}destroy(){let e=this.core.getModalElement();e&&e.removeAttribute(`data-theme`)}},Uj=class e extends Error{constructor(t,n){super(`[TimepickerUI] ${t}`),this.code=n,this.name=`TimepickerError`,Object.setPrototypeOf(this,e.prototype)}},Wj={ELEMENT_NOT_FOUND:`ELEMENT_NOT_FOUND`,INVALID_PARAMETER:`INVALID_PARAMETER`,NO_INPUT_ELEMENT:`NO_INPUT_ELEMENT`,INSTANCE_DESTROYED:`INSTANCE_DESTROYED`,NOT_INITIALIZED:`NOT_INITIALIZED`,INVALID_TIME_FORMAT:`INVALID_TIME_FORMAT`,INLINE_CONFIG_ERROR:`INLINE_CONFIG_ERROR`,CONTAINER_NOT_FOUND:`CONTAINER_NOT_FOUND`,SSR_ENVIRONMENT:`SSR_ENVIRONMENT`},Gj=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setErrorHandler(){let e=this.core.getInput();if(!e)return!0;let{error:t,currentHour:n,currentMin:r,currentType:i,currentLength:a}=jj(e,this.core.options.clock.type);if(this.removeErrorHandler(),t){if(ij()===!1)return!1;let o=document.createElement(`div`);o.classList.add(`tp-ui-invalid-text`),o.innerHTML=`<b>Invalid Time Format</b>`,e.classList.add(`tp-ui-invalid-format`),e.nextElementSibling?.classList.contains(`tp-ui-invalid-text`)||e.after(o);let s={error:t,rejectedHour:void 0,rejectedMinute:void 0,inputHour:n,inputMinute:r,inputType:i,inputLength:a};return this.emitter.emit(`error`,s),!1}return!0}removeErrorHandler(){let e=this.core.getInput();if(!e)return;e.classList.remove(`tp-ui-invalid-format`);let t=e.nextElementSibling;t?.classList.contains(`tp-ui-invalid-text`)&&t.remove()}checkDisabledValuesOnStart(){if(!this.core.options.clock.disabledTime)return;let{disabledTime:e,type:t}=this.core.options.clock;if(e.interval){if(!t)throw new Uj(`clockType is required when using disabledTime.interval`,Wj.INVALID_PARAMETER);let n=Array.isArray(e.interval)?e.interval:[e.interval];try{mj(n,t)}catch(e){throw new Uj(`Invalid disabledTime.interval: ${e.message}`,Wj.INVALID_PARAMETER)}return}let{hours:n,minutes:r}=e,i=n?zj(n,`hour`,t):!0,a=r?zj(r,`minutes`,t):!0;if(!i||!a)throw new Uj(`Invalid hours or minutes in disabledTime option`,Wj.INVALID_PARAMETER)}destroy(){this.removeErrorHandler()}},Kj=(e,t)=>{if(!e)return;let n=e.querySelector(`.timepicker-announcer`);n&&(n.textContent=``,setTimeout(()=>{n.textContent=t},100))},qj=(e,t)=>{e&&e.setAttribute(`aria-pressed`,String(t))},Jj=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleOpenOnClick(){let e=this.core.getOpenElement();if(!e)return;let t=e=>{this.core.isDestroyed||e.currentTarget?.classList.contains(`disabled`)||this.emitter.emit(`show`,{})};e.forEach(e=>{e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))})}handleCancelButton(){let e=this.core.getCancelButton();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit(`cancel`,{})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handleOkButton(){let e=this.core.getOkButton();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let e=this.core.getHour(),t=this.core.getMinutes();if(e&&t){let n=this.core.getActiveTypeMode();this.emitter.emit(`confirm`,{hour:e.value,minutes:t.value,type:n?.textContent||void 0});return}let n=this.core.getModalElement();if(n){let e=n.querySelector(`.tp-ui-wheel-hours .tp-ui-wheel-item.is-center`),t=n.querySelector(`.tp-ui-wheel-minutes .tp-ui-wheel-item.is-center`),r=n.querySelector(`.tp-ui-wheel-ampm .tp-ui-wheel-item.is-center`);this.emitter.emit(`confirm`,{hour:e?.getAttribute(`data-value`)??void 0,minutes:t?.getAttribute(`data-value`)??void 0,type:r?.getAttribute(`data-value`)??void 0})}};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handleAmClick(){let e=this.core.getAM();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let t=this.core.getPM();e.classList.add(`active`),t?.classList.remove(`active`),qj(e,!0),qj(t,!1),Kj(this.core.getModalElement(),`AM selected`),this.emitter.emit(`select:am`,{});let n=this.core.getHour(),r=this.core.getMinutes();this.emitter.emit(`update`,{hour:n?.value,minutes:r?.value,type:`AM`})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handlePmClick(){let e=this.core.getPM();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let t=this.core.getAM();e.classList.add(`active`),t?.classList.remove(`active`),qj(e,!0),qj(t,!1),Kj(this.core.getModalElement(),`PM selected`),this.emitter.emit(`select:pm`,{});let n=this.core.getHour(),r=this.core.getMinutes();this.emitter.emit(`update`,{hour:n?.value,minutes:r?.value,type:`PM`})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handleSwitchViewButton(){let e=this.core.getKeyboardClockIcon();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit(`switch:view`,{})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},Yj=(e,t,n)=>Math.max(t,Math.min(n,e)),Xj=(e,t)=>{if(e===``)return``;let n=parseInt(e,10);return Number.isNaN(n)?``:Yj(n,+!!t,t?12:23).toString().padStart(2,`0`)},Zj=e=>{if(e===``)return``;let t=parseInt(e,10);return Number.isNaN(t)?``:Yj(t,0,59).toString().padStart(2,`0`)},Qj=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleHourEvents(){let e=this.core.getHour();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;e.classList.add(`active`);let t=this.core.getMinutes();t?.classList.remove(`active`),this.emitter.emit(`select:hour`,{hour:e.value});let n=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:e.value,minutes:t?.value,type:n?.textContent||void 0})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t));let n=e.value,r=()=>{if(this.core.isDestroyed||e.hasAttribute(`readonly`))return;let t=this.core.options.clock.type===`12h`,r=Xj(e.value,t);if(e.value=r,e.setAttribute(`aria-valuenow`,r),e.value!==n){n=e.value,this.emitter.emit(`animation:clock`,{}),this.emitter.emit(`select:hour`,{hour:e.value});let t=this.core.getMinutes(),r=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:e.value,minutes:t?.value,type:r?.textContent||void 0})}};e.addEventListener(`blur`,r),this.cleanupHandlers.push(()=>e.removeEventListener(`blur`,r))}handleMinutesEvents(){let e=this.core.getMinutes();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;e.classList.add(`active`);let t=this.core.getHour();t?.classList.remove(`active`),this.emitter.emit(`select:minute`,{minutes:e.value});let n=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:t?.value,minutes:e.value,type:n?.textContent||void 0})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t));let n=e.value,r=()=>{if(this.core.isDestroyed||e.hasAttribute(`readonly`))return;let t=Zj(e.value);if(e.value=t,e.setAttribute(`aria-valuenow`,t),e.value!==n){n=e.value,this.emitter.emit(`animation:clock`,{}),this.emitter.emit(`select:minute`,{minutes:e.value});let t=this.core.getHour(),r=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:t?.value,minutes:e.value,type:r?.textContent||void 0})}};e.addEventListener(`blur`,r),this.cleanupHandlers.push(()=>e.removeEventListener(`blur`,r))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},$j=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleOpenOnEnterFocus(){let e=this.core.getInput();if(!e)return;let t=e=>{e.key===`Enter`&&!this.core.isDestroyed&&!this.core.isOpen&&this.emitter.emit(`show`,{})};e.addEventListener(`keydown`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`keydown`,t))}handleEscClick(){if(ij()===!1)return;let e=e=>{this.core.isDestroyed||e.key===`Escape`&&this.emitter.emit(`cancel`,{})};document.addEventListener(`keydown`,e),this.cleanupHandlers.push(()=>document.removeEventListener(`keydown`,e))}handleKeyboardInput(){let e=this.core.getHour(),t=this.core.getMinutes();if(e){let t=t=>{if(this.core.isDestroyed||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=parseInt(e.value)||0,r=parseInt(e.getAttribute(`max`)||`23`),i=this.core.options.clock.type===`12h`,a;a=t.key===`ArrowUp`?i?n>=12?1:n+1:n>=r?0:n+1:i?n<=1?12:n-1:n<=0?r:n-1,e.value=a.toString().padStart(2,`0`),e.setAttribute(`aria-valuenow`,e.value),Kj(this.core.getModalElement(),`Hour: ${e.value}`),this.emitter.emit(`animation:clock`,{}),this.emitter.emit(`select:hour`,{hour:e.value});let o=this.core.getMinutes(),s=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:e.value,minutes:o?.value,type:s?.textContent||void 0})};e.addEventListener(`keydown`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`keydown`,t))}if(t){let e=e=>{if(this.core.isDestroyed||e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let n=parseInt(t.value)||0,r;r=e.key===`ArrowUp`?n>=59?0:n+1:n<=0?59:n-1,t.value=r.toString().padStart(2,`0`),t.setAttribute(`aria-valuenow`,t.value),Kj(this.core.getModalElement(),`Minutes: ${t.value}`),this.emitter.emit(`animation:clock`,{}),this.emitter.emit(`select:minute`,{minutes:t.value});let i=this.core.getHour(),a=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:i?.value,minutes:t.value,type:a?.textContent||void 0})};t.addEventListener(`keydown`,e),this.cleanupHandlers.push(()=>t.removeEventListener(`keydown`,e))}}focusTrapHandler(){if(ij()===!1)return;let e=this.core.getWrapper();if(!e)return;let t=t=>{if(this.core.isDestroyed||t.key!==`Tab`)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`),r=n[0],i=n[n.length-1];t.shiftKey&&document.activeElement===r?(i?.focus(),t.preventDefault()):!t.shiftKey&&document.activeElement===i&&(r?.focus(),t.preventDefault())};e.addEventListener(`keydown`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`keydown`,t))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},eM=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleBackdropClick(){let e=this.core.getModalElement();if(!e)return;let t=t=>{this.core.isDestroyed||t.target===e&&this.emitter.emit(`cancel`,{})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handleMoveHand(){if(ij()===!1)return;let e=e=>{this.core.isDestroyed||e.preventDefault()};document.addEventListener(`mousedown`,e,!1),document.addEventListener(`touchstart`,e,{passive:!1}),this.cleanupHandlers.push(()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)})}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},tM=class{buttonHandlers;inputHandlers;keyboardHandlers;modalHandlers;constructor(e,t){this.buttonHandlers=new Jj(e,t),this.inputHandlers=new Qj(e,t),this.keyboardHandlers=new $j(e,t),this.modalHandlers=new eM(e,t)}handleOpenOnClick(){this.buttonHandlers.handleOpenOnClick()}handleOpenOnEnterFocus(){this.keyboardHandlers.handleOpenOnEnterFocus()}handleCancelButton(){this.buttonHandlers.handleCancelButton()}handleOkButton(){this.buttonHandlers.handleOkButton()}handleBackdropClick(){this.modalHandlers.handleBackdropClick()}handleEscClick(){this.keyboardHandlers.handleEscClick()}handleAmClick(){this.buttonHandlers.handleAmClick()}handlePmClick(){this.buttonHandlers.handlePmClick()}handleHourEvents(){this.inputHandlers.handleHourEvents()}handleMinutesEvents(){this.inputHandlers.handleMinutesEvents()}handleKeyboardInput(){this.keyboardHandlers.handleKeyboardInput()}focusTrapHandler(){this.keyboardHandlers.focusTrapHandler()}handleMoveHand(){this.modalHandlers.handleMoveHand()}handleSwitchViewButton(){this.buttonHandlers.handleSwitchViewButton()}destroy(){this.buttonHandlers.destroy(),this.inputHandlers.destroy(),this.keyboardHandlers.destroy(),this.modalHandlers.destroy()}},nM=class{emitter;getClockSystem;setHoursToClock;setMinutesToClock;updateAmPm;convertDisabledTime;constructor(e,t,n,r,i,a){this.emitter=e,this.getClockSystem=t,this.setHoursToClock=n,this.setMinutesToClock=r,this.updateAmPm=i,this.convertDisabledTime=a}setup(){this.emitter.on(`select:hour`,({hour:e})=>{this.emitter.emit(`animation:clock`,{}),this.setHoursToClock(e||null)}),this.emitter.on(`select:minute`,({minutes:e})=>{this.emitter.emit(`animation:clock`,{}),this.setMinutesToClock(e||null)}),this.emitter.on(`select:am`,()=>{this.updateAmPm()}),this.emitter.on(`select:pm`,()=>{this.updateAmPm()}),this.emitter.on(`animation:start`,()=>{this.getClockSystem()?.blockInteractions()}),this.emitter.on(`animation:end`,()=>{this.getClockSystem()?.unblockInteractions()}),this.emitter.on(`range:switch`,e=>{this.refreshDisabledTimeForRange(e.disabledTime)})}refreshDisabledTimeForRange(e){let t=this.getClockSystem();if(!t)return;let n=this.convertDisabledTime(),r=n;if(e){let t=[...n?.hours||[],...e.hours||[]],i=[...n?.minutes||[],...e.minutes||[]];r={...n,hours:t.length>0?t:void 0,minutes:i.length>0?i:void 0,rangeFromType:e.fromType,rangeFromHour:e.fromHour}}t.updateDisabledTime(r)}},rM=class{static angleToIndex(e,t,n){let r=Math.round(e/30)%12;if(t===`24h`)if(n){let e=r+12;return e===12?0:e}else return r===0?12:r;return r===0?12:r}static indexToValue(e,t){if(t===`24h`)return e.toString().padStart(2,`0`);let n=e;return n===0&&(n=12),n>12&&(n-=12),n.toString().padStart(2,`0`)}static indexToAngle(e,t){return t===`24h`?e>=12?(e-12)%12*30:e%12*30:(e===0?12:e)%12*30}static isDisabled(e,t,n){return n?n.isInterval&&n.intervals&&n.clockType?this.isDisabledByInterval(e,t,n):n.rangeFromType!==void 0&&n.rangeFromHour!==void 0?this.isDisabledForRange12h(e,t,n):n.hours?n.hours.some(t=>String(t)===e||Number(t)===Number(e)||t===e):!1:!1}static isDisabledForRange12h(e,t,n){let r=n.rangeFromType,i=n.rangeFromHour,a=parseInt(e,10);return r===null||i===void 0?!1:t===`AM`&&r===`PM`?!0:t===`AM`&&r===`AM`?i===12?!1:a===12?!0:a<i:t===`PM`&&r===`AM`?!1:t===`PM`&&r===`PM`?i===12?!1:a===12?!0:a<i:!1}static isDisabledByInterval(e,t,n){if(!n.intervals)return!1;for(let r=0;r<60;r++){let i=r.toString().padStart(2,`0`);if(!this.isTimeInIntervals(e,i,t,n.intervals,n.clockType))return!1}return!0}static isTimeInIntervals(e,t,n,r,i){let a=i===`12h`?`${e}:${t} ${n}`:`${e}:${t}`;for(let e of r){let[t,n]=e.split(`-`).map(e=>e.trim());if(this.isTimeBetween(a,t,n,i))return!0}return!1}static isTimeBetween(e,t,n,r){let i=this.timeToMinutes(e,r),a=this.timeToMinutes(t,r),o=this.timeToMinutes(n,r);return i>=a&&i<=o}static timeToMinutes(e,t){if(t===`12h`){let t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!t)return 0;let n=parseInt(t[1]),r=parseInt(t[2]),i=t[3].toUpperCase();return i===`PM`&&n!==12&&(n+=12),i===`AM`&&n===12&&(n=0),n*60+r}else{let[t,n]=e.split(`:`).map(Number);return t*60+n}}static findNearestValid(e,t,n,r){let i=t===`24h`?23:12;for(let a=0;a<=i;a++){let o=a===0?[e]:[e+a,e-a];for(let e of o){let a=e;a<0&&(a+=i+1),a>i&&(a%=i+1);let o=this.indexToValue(a,t);if(!this.isDisabled(o,n,r))return a}}return e}},iM=class{static angleToIndex(e){return Math.round(e/6)%60}static indexToValue(e){return e.toString().padStart(2,`0`)}static indexToAngle(e){return e%60*6}static isDisabled(e,t,n,r,i){return r?r.isInterval&&r.intervals?this.isDisabledByInterval(e,t,n,r,i):r.rangeFromType!==void 0&&r.rangeFromHour!==void 0?this.isDisabledForRange12h(e,t,n,r):r.rangeFromHour!==void 0&&parseInt(t,10)!==r.rangeFromHour?!1:r.minutes?r.minutes.some(t=>String(t)===e||Number(t)===Number(e)||t===e):!1:!1}static isDisabledForRange12h(e,t,n,r){let i=r.rangeFromType,a=r.rangeFromHour,o=parseInt(t,10),s=parseInt(e,10);if(i===null||a===void 0)return!1;let c=r.minutes||[],l=c.length>0?parseInt(c[c.length-1],10)+1:0;return n===`AM`&&i===`PM`?!0:n===`PM`&&i===`AM`?!1:o===a||o===12&&a===12||n===i&&o===a?s<l:!1}static isDisabledByInterval(e,t,n,r,i){if(!r.intervals)return!1;let a=i===`12h`?`${t}:${e} ${n}`:`${t}:${e}`;for(let e of r.intervals){let[t,n]=e.split(`-`).map(e=>e.trim());if(this.isTimeBetween(a,t,n,i))return!0}return!1}static isTimeBetween(e,t,n,r){let i=this.timeToMinutes(e,r),a=this.timeToMinutes(t,r),o=this.timeToMinutes(n,r);return i>=a&&i<=o}static timeToMinutes(e,t){if(t===`12h`){let t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!t)return 0;let n=parseInt(t[1]),r=parseInt(t[2]),i=t[3].toUpperCase();return i===`PM`&&n!==12&&(n+=12),i===`AM`&&n===12&&(n=0),n*60+r}else{let[t,n]=e.split(`:`).map(Number);return t*60+n}}static findNearestValid(e,t,n,r,i){for(let a=0;a<60;a++){let o=a===0?[e]:[e+a,e-a];for(let e of o){let a=e;a<0&&(a+=60),a>=60&&(a%=60);let o=this.indexToValue(a);if(!this.isDisabled(o,t,n,r,i))return a}}return e}},aM=class{static normalizeAngle(e){let t=e%360;return t<0&&(t+=360),t}static calculateRawAngle(e,t){let n=e.x-t.x,r=e.y-t.y,i=Math.atan2(r,n)*180/Math.PI+90;return this.normalizeAngle(i)}static snapToIncrement(e,t){let n=Math.round(e/t)*t;return this.normalizeAngle(n)}static calculateDistance(e,t){let n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}static isInnerCircle(e,t){return e<t*.75}static calculateShortestPath(e,t){let n=this.normalizeAngle(e),r=this.normalizeAngle(t)-n,i=r>=0?r:r+360,a=r<=0?r:r-360;return e+(Math.abs(i)<Math.abs(a)?i:a)}},oM=class{config;currentAngle=0;tipsCache=new Map;cachedDimensions=new Map;constructor(e){this.config=e}getCachedDimensions(e){let t=this.cachedDimensions.get(e);if(!t){let n=(e.offsetWidth-32)/2;t={width:n,height:(e.offsetHeight-32)/2,radius:n-9},this.cachedDimensions.set(e,t)}return t}setHandAngle(e){let t=aM.calculateShortestPath(this.currentAngle,e);Math.abs(this.currentAngle-t)<.01||(this.currentAngle=t,this.config.clockHand.style.transform=`rotateZ(${t}deg)`)}animateToAngle(e){let t=aM.calculateShortestPath(this.currentAngle,e);this.currentAngle=t,this.config.tipsWrapper.classList.add(`tp-ui-tips-animation`),this.config.clockHand.style.transform=`rotateZ(${t}deg)`,setTimeout(()=>{this.config.tipsWrapper.classList.remove(`tp-ui-tips-animation`)},401)}setActiveValue(e){let t=[this.config.tipsWrapper];this.config.tipsWrapperFor24h&&t.push(this.config.tipsWrapperFor24h),t.forEach(t=>{t.querySelectorAll(`.tp-ui-value-tips, .tp-ui-value-tips-24h`).forEach(t=>{let n=t;n.textContent===e||Number(n.textContent)===Number(e)?(n.classList.add(`active`),n.setAttribute(`aria-selected`,`true`)):(n.classList.remove(`active`),n.setAttribute(`aria-selected`,`false`))})})}renderTips(e,t,n,r,i,a=!0,o,s=``,c=`12`){if(ij()===!1)return;let l=o||this.config.tipsWrapper;a&&(l.innerHTML=``,this.tipsCache.clear());let{width:u,height:d,radius:f}=this.getCachedDimensions(l),p=document.createDocumentFragment(),m=`${t}-${this.config.theme||`default`}`;e.forEach((a,o)=>{let l=`${m}-${a}`,h=this.tipsCache.get(l);h||(h=this.createTip(a,t,i),this.tipsCache.set(l,h));let{wrapper:g,tip:_}=h;this.updateTipState(g,_,a,n,r,i,s,c);let v=o*(360/e.length)*(Math.PI/180);g.style.left=`${u+Math.sin(v)*f}px`,g.style.bottom=`${d+Math.cos(v)*f}px`,p.appendChild(g)}),l.appendChild(p)}createTip(e,t,n){if(ij()===!1){let e={};return{wrapper:e,tip:e}}let r=document.createElement(`span`),i=document.createElement(`span`);i.textContent=e,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.tabIndex=0;let a=n===`24h`&&t.includes(`24`)?`tp-ui-value-tips-24h`:`tp-ui-value-tips`;return i.classList.add(a),r.classList.add(t),this.config.theme&&(r.classList.add(this.config.theme),i.classList.add(this.config.theme)),r.appendChild(i),{wrapper:r,tip:i}}updateTipState(e,t,n,r,i,a,o,s){e.classList.remove(`tp-ui-tips-disabled`),t.classList.remove(`tp-ui-tips-disabled`),t.removeAttribute(`aria-disabled`),t.tabIndex=0,this.checkIfDisabled(n,r,i,a,o,s)&&(e.classList.add(`tp-ui-tips-disabled`),t.classList.add(`tp-ui-tips-disabled`),t.setAttribute(`aria-disabled`,`true`),t.tabIndex=-1)}checkIfDisabled(e,t,n,r,i,a){return n?t===`hours`?rM.isDisabled(e,i,n):t===`minutes`?iM.isDisabled(e,a,i,n,r):!1:!1}setCircleSize(e){e?this.config.circle.classList.remove(`small-circle`):this.config.circle.classList.add(`small-circle`)}setCircle24hMode(e){e?(this.config.circle.classList.add(`tp-ui-circle-hand-24h`),this.config.clockHand.classList.add(`tp-ui-clock-hand-24h`)):(this.config.circle.classList.remove(`tp-ui-circle-hand-24h`),this.config.clockHand.classList.remove(`tp-ui-clock-hand-24h`))}destroy(){this.tipsCache.clear(),this.cachedDimensions.clear(),this.config.tipsWrapper.innerHTML=``}},sM=class{static processPointerInput(e){let t=aM.calculateRawAngle(e.pointerPosition,e.clockCenter);return e.mode===`hours`?this.processHours(t,e):this.processMinutes(t,e)}static processHours(e,t){let n=t.smoothHourSnap??!0,r;if(n)r=e;else{let n=t.incrementHours*30;r=aM.snapToIncrement(e,n)}let i=aM.calculateDistance(t.pointerPosition,t.clockCenter),a=t.clockType===`24h`&&aM.isInnerCircle(i,t.clockRadius),o=rM.angleToIndex(r,t.clockType,a),s=rM.indexToValue(o,t.clockType),c=rM.isDisabled(s,t.amPm,t.disabledTime);c&&(o=rM.findNearestValid(o,t.clockType,t.amPm,t.disabledTime));let l=rM.indexToValue(o,t.clockType),u;return u=n?e:rM.indexToAngle(o,t.clockType),{angle:u,value:l,index:o,isValid:!c,isInnerCircle:t.clockType===`24h`?a:void 0}}static processMinutes(e,t){let n=t.incrementMinutes*6,r=aM.snapToIncrement(e,n),i=iM.angleToIndex(r),a=iM.indexToValue(i),o=t.currentHour||`00`,s=iM.isDisabled(a,o,t.amPm,t.disabledTime,t.clockType);s&&(i=iM.findNearestValid(i,o,t.amPm,t.disabledTime,t.clockType));let c=iM.indexToValue(i);return{angle:iM.indexToAngle(i),value:c,index:i,isValid:!s}}static valueToAngle(e,t,n){let r=parseInt(e,10);return t===`hours`?rM.indexToAngle(r,n):iM.indexToAngle(r)}},cM=class{state;renderer;clockType;disabledTime;incrementHours;incrementMinutes;smoothHourSnap;isDragging=!1;callbacks;lastProcessedX=null;lastProcessedY=null;constructor(e,t,n,r,i=1,a=1,o=!0,s={}){this.renderer=e,this.state={...t},this.clockType=n,this.disabledTime=r,this.incrementHours=i,this.incrementMinutes=a,this.smoothHourSnap=o,this.callbacks=s}handlePointerMove(e,t,n){if(this.isDragging=!0,this.lastProcessedX===e.x&&this.lastProcessedY===e.y)return;this.lastProcessedX=e.x,this.lastProcessedY=e.y;let r={pointerPosition:e,clockCenter:t,clockRadius:n,mode:this.state.mode,clockType:this.clockType,amPm:this.state.amPm,disabledTime:this.disabledTime,incrementHours:this.incrementHours,incrementMinutes:this.incrementMinutes,smoothHourSnap:this.smoothHourSnap,currentHour:this.state.hour},i=sM.processPointerInput(r);if(i.isValid){if(this.state.mode===`hours`){let e=this.state.hour;this.state.hour=i.value,this.state.hourAngle=i.angle,this.clockType===`24h`&&i.isInnerCircle!==void 0&&(this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(i.isInnerCircle)),this.callbacks.onHourChange&&e!==i.value&&this.callbacks.onHourChange(i.value)}else{let e=this.state.minute;this.state.minute=i.value,this.state.minuteAngle=i.angle,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1),this.callbacks.onMinuteChange&&e!==i.value&&this.callbacks.onMinuteChange(i.value)}this.renderer.setHandAngle(i.angle),this.renderer.setActiveValue(i.value)}}handlePointerUp(){this.isDragging=!1,this.lastProcessedX=null,this.lastProcessedY=null}snapToNearestHour(){if(this.state.mode!==`hours`)return;let e=sM.valueToAngle(this.state.hour,`hours`,this.clockType);this.state.hourAngle=e,this.renderer.animateToAngle(e)}switchMode(e){this.state.mode=e;let t=e===`hours`?this.state.hourAngle:this.state.minuteAngle,n=e===`hours`?this.state.hour:this.state.minute;if(e===`hours`&&this.clockType===`24h`){let e=parseInt(n,10),t=e===0||e>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(t)}else this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.renderer.setHandAngle(t),this.renderer.setActiveValue(n)}setValue(e,t){let n=sM.valueToAngle(t,e,this.clockType);if(e===`hours`)if(this.state.hour=t,this.state.hourAngle=n,this.clockType===`24h`){let e=parseInt(t,10),n=e===0||e>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(n)}else this.renderer.setCircle24hMode(!1);else this.state.minute=t,this.state.minuteAngle=n,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.state.mode===e&&(this.renderer.setHandAngle(n),this.renderer.setActiveValue(t))}setAmPm(e){this.state.amPm=e}getState(){return{...this.state}}getHour(){return this.state.hour}getMinute(){return this.state.minute}getAmPm(){return this.state.amPm}updateDisabledTime(e){this.disabledTime=e}destroy(){this.renderer.destroy()}},lM=class{controller;clockFace;isActive=!1;isBlocked=!1;config;cachedRect=null;cachedCenter=null;cachedRadius=null;rafId=null;constructor(e,t,n={}){this.controller=e,this.clockFace=t,this.config=n}attach(){this.clockFace.addEventListener(`mousedown`,this.handlePointerDown),this.clockFace.addEventListener(`touchstart`,this.handlePointerDown,{passive:!1})}detach(){this.clockFace.removeEventListener(`mousedown`,this.handlePointerDown),this.clockFace.removeEventListener(`touchstart`,this.handlePointerDown),this.removeGlobalListeners()}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}handlePointerDown=e=>{if(rj()||this.isBlocked)return;let t=e.target;t&&t.classList&&t.classList.contains(`tp-ui-tips-disabled`)||(e.preventDefault(),this.isActive=!0,this.cachedRect=this.clockFace.getBoundingClientRect(),this.cachedCenter=this.getClockCenter(),this.cachedRadius=this.getClockRadius(),this.processPointerEvent(e),document.addEventListener(`mousemove`,this.handlePointerMove),document.addEventListener(`touchmove`,this.handlePointerMove,{passive:!1}),document.addEventListener(`mouseup`,this.handlePointerUp),document.addEventListener(`touchend`,this.handlePointerUp))};handlePointerMove=e=>{if(!this.isActive||this.isBlocked)return;let t=this.getTargetElement(e);t&&t.classList&&t.classList.contains(`tp-ui-tips-disabled`)||(e.preventDefault(),this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.processPointerEvent(e)})))};handlePointerUp=()=>{if(!this.isActive)return;this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.isActive=!1,this.cachedRect=null,this.cachedCenter=null,this.cachedRadius=null,this.controller.handlePointerUp();let{autoSwitchToMinutes:e,isMobileView:t,smoothHourSnap:n,hourElement:r,minutesElement:i}=this.config;n&&r?.classList.contains(`active`)&&this.controller.snapToNearestHour(),this.removeGlobalListeners(),e&&r?.classList.contains(`active`)&&!t?(r.classList.remove(`active`),i?.classList.add(`active`),i?.click(),i?.focus(),r.blur()):i?.classList.contains(`active`)&&this.config.onMinuteCommit&&this.config.onMinuteCommit()};processPointerEvent(e){let t=this.getPointerPosition(e),n=this.cachedCenter||this.getClockCenter(),r=this.cachedRadius||this.getClockRadius();this.controller.handlePointerMove(t,n,r)}getPointerPosition(e){let t=this.cachedRect||this.clockFace.getBoundingClientRect();if(`touches`in e){let n=e.touches[0]||e.changedTouches[0];return{x:n.clientX-t.left,y:n.clientY-t.top}}else return{x:e.clientX-t.left,y:e.clientY-t.top}}getTargetElement(e){if(`touches`in e){let t=e.touches[0]||e.changedTouches[0];if(t&&!rj())return document.elementFromPoint(t.clientX,t.clientY)}return e.target}getClockCenter(){let e=this.clockFace.offsetWidth,t=this.clockFace.offsetHeight;return{x:e/2,y:t/2}}getClockRadius(){return this.clockFace.offsetWidth/2}removeGlobalListeners(){ij()!==!1&&(document.removeEventListener(`mousemove`,this.handlePointerMove),document.removeEventListener(`touchmove`,this.handlePointerMove),document.removeEventListener(`mouseup`,this.handlePointerUp),document.removeEventListener(`touchend`,this.handlePointerUp))}},uM=class{renderer;controller;dragHandlers;clockType;disabledTime;tipsWrapper;tipsWrapperFor24h;constructor(e){this.clockType=e.clockType,this.disabledTime=e.disabledTime,this.tipsWrapper=e.tipsWrapper,this.tipsWrapperFor24h=e.tipsWrapperFor24h;let t={clockFace:e.clockFace,tipsWrapper:e.tipsWrapper,tipsWrapperFor24h:e.tipsWrapperFor24h,clockHand:e.clockHand,circle:e.circle,theme:e.theme};this.renderer=new oM(t);let n={hour:e.initialHour,minute:e.initialMinute,amPm:e.initialAmPm,hourAngle:this.calculateInitialAngle(`hours`,e.initialHour),minuteAngle:this.calculateInitialAngle(`minutes`,e.initialMinute),mode:`hours`},r={onHourChange:e.onHourChange,onMinuteChange:e.onMinuteChange};this.controller=new cM(this.renderer,n,e.clockType,e.disabledTime,e.incrementHours||1,e.incrementMinutes||1,e.smoothHourSnap??!0,r),this.dragHandlers=new lM(this.controller,e.clockFace,e.dragConfig||{})}initialize(){this.dragHandlers.attach(),this.switchToHours()}switchToHours(){this.controller.switchMode(`hours`),this.clockType===`24h`&&this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.remove(`none`),this.renderHourTips();let e=this.controller.getState();this.renderer.setActiveValue(e.hour)}switchToMinutes(){this.controller.switchMode(`minutes`),this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.add(`none`),this.renderMinuteTips();let e=this.controller.getState();this.renderer.setActiveValue(e.minute)}setHour(e){this.controller.setValue(`hours`,e)}setMinute(e){this.controller.setValue(`minutes`,e)}setAmPm(e){this.controller.setAmPm(e);let t=this.controller.getState();t.mode===`hours`?(this.renderHourTips(),this.renderer.setHandAngle(t.hourAngle),this.renderer.setActiveValue(t.hour)):(this.renderMinuteTips(),this.renderer.setHandAngle(t.minuteAngle),this.renderer.setActiveValue(t.minute))}getHour(){return this.controller.getHour()}getMinute(){return this.controller.getMinute()}getAmPm(){return this.controller.getAmPm()}updateDisabledTime(e){this.disabledTime=e,this.controller.updateDisabledTime(e),this.controller.getState().mode===`hours`?this.renderHourTips():this.renderMinuteTips()}renderHourTips(){let e=this.controller.getState().amPm;this.clockType===`24h`?(this.renderer.renderTips(xj,`tp-ui-hour-time-12`,`hours`,this.disabledTime,this.clockType,!0,this.tipsWrapper,e),this.tipsWrapperFor24h&&this.renderer.renderTips(bj,`tp-ui-hour-time-24`,`hours`,this.disabledTime,this.clockType,!0,this.tipsWrapperFor24h,e)):this.renderer.renderTips(xj,`tp-ui-hour-time-12`,`hours`,this.disabledTime,this.clockType,!0,void 0,e)}renderMinuteTips(){let e=this.controller.getState(),t=e.amPm,n=e.hour;this.renderer.renderTips(Sj,`tp-ui-minutes-time`,`minutes`,this.disabledTime,this.clockType,!0,void 0,t,n)}calculateInitialAngle(e,t){let n=parseInt(t,10);return e===`hours`?n%12*30:n*6}destroy(){this.dragHandlers.detach(),this.controller.destroy()}blockInteractions(){this.dragHandlers.block()}unblockInteractions(){this.dragHandlers.unblock()}},dM=class{core;emitter;clockSystem=null;constructor(e,t){this.core=e,this.emitter=t}getClockSystem(){return this.clockSystem}initialize(){let e=this.core.getClockFace(),t=this.core.getClockHand(),n=this.core.getCircle();if(!e||!t||!n)return;let r=this.core.options.clock.type===`24h`,i=this.core.getTipsWrapper();if(!i)return;let a=this.core.getHour(),o=this.core.getMinutes(),s={clockFace:e,tipsWrapper:i,tipsWrapperFor24h:r&&this.core.getTipsWrapperFor24h()||void 0,clockHand:t,circle:n,clockType:this.core.options.clock.type||`12h`,disabledTime:this.convertDisabledTime(),initialHour:a?.value||`12`,initialMinute:o?.value||`00`,initialAmPm:this.getAmPmValue(),theme:this.core.options.ui.theme,incrementHours:this.core.options.clock.incrementHours||1,incrementMinutes:this.core.options.clock.incrementMinutes||1,smoothHourSnap:this.core.options.clock.smoothHourSnap??!0,timepicker:null,dragConfig:{autoSwitchToMinutes:this.core.options.clock.autoSwitchToMinutes,isMobileView:this.core.isMobileView,smoothHourSnap:this.core.options.clock.smoothHourSnap??!0,hourElement:a,minutesElement:o,onMinuteCommit:()=>{let e=this.core.getMinutes(),t=this.core.getHour(),n=this.core.getActiveTypeMode();this.emitter.emit(`range:minute:commit`,{hour:t?.value??`12`,minutes:e?.value??`00`,type:n?.textContent??void 0})}},onHourChange:e=>{let t=this.core.getHour();t&&(t.value=e,t.setAttribute(`aria-valuenow`,e)),Kj(this.core.getModalElement(),`Hour: ${e}`);let n=this.core.getMinutes(),r=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:e,minutes:n?.value,type:r?.textContent||void 0})},onMinuteChange:e=>{let t=this.core.getMinutes();t&&(t.value=e,t.setAttribute(`aria-valuenow`,e)),Kj(this.core.getModalElement(),`Minutes: ${e}`);let n=this.core.getHour(),r=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:n?.value,minutes:e,type:r?.textContent||void 0})}};this.clockSystem=new uM(s),this.clockSystem.initialize()}convertDisabledTime(){let e=this.core.disabledTime?.value;if(!e)return null;let t;return e.intervals&&(t=Array.isArray(e.intervals)?e.intervals:[e.intervals]),{hours:e.hours,minutes:e.minutes,isInterval:e.isInterval,intervals:t,clockType:e.clockType}}getAmPmValue(){if(this.core.options.clock.type===`24h`)return``;let e=this.core.getActiveTypeMode();if(e){let t=e.textContent?.trim();if(t===`AM`||t===`PM`)return t}let t=this.core.getAM();return this.core.options.range?.enabled===!0?t?.classList.contains(`active`)?`AM`:``:t?.classList.contains(`active`)?`AM`:`PM`}destroy(){this.clockSystem&&=(this.clockSystem.destroy(),null)}},fM=class{core;constructor(e){this.core=e}removeCircleClockClasses24h(){let e=this.core.getCircle(),t=this.core.getClockHand();e?.classList.remove(`tp-ui-circle-hand-24h`),t?.classList.remove(`tp-ui-clock-hand-24h`)}setCircleClockClasses24h(){let e=this.core.getCircle(),t=this.core.getClockHand();e&&e.classList.add(`tp-ui-circle-hand-24h`),t&&t.classList.add(`tp-ui-clock-hand-24h`)}setOnStartCSSClassesIfClockType24h(){if(this.core.options.clock.type===`24h`){let e=this.core.getInput();if(!e)return;let t;e.value.length>0&&(t=e.value.split(`:`)[0]),t&&(Number(t)>12||Number(t)===0)&&this.setCircleClockClasses24h()}}setBgColorToCircleWithMinutesTips(){let e=this.core.getMinutes(),t=this.core.getCircle();if(!(!e||!t)&&e.value&&Sj.includes(e.value)){let e=getComputedStyle(t).getPropertyValue(`--timepicker-primary`).trim();e&&(t.style.backgroundColor=e),t.classList.remove(`small-circle`)}}removeBgColorToCirleWithMinutesTips(){let e=this.core.getMinutes(),t=this.core.getCircle();!e||!t||e.value&&Sj.includes(e.value)||(t.style.backgroundColor=``,t.classList.add(`small-circle`))}setClassActiveToHourOnOpen(){this.core.options.ui.mobile||this.core.isMobileView||this.core.getHour()?.classList.add(Fj)}toggleClassActiveToValueTips(e,t){if(e)return;let n=this.core.getAllValueTips();if(!n)return;let r=n.find(e=>Number(e.innerText)===Number(t));n.forEach(e=>{e.classList.remove(Fj),e.setAttribute(`aria-selected`,`false`)}),r!==void 0&&(r.classList.add(Fj),r.setAttribute(`aria-selected`,`true`))}},pM=class{getClockSystem;styleHandler;getAmPmValue;clockType;constructor(e,t,n,r){this.getClockSystem=e,this.styleHandler=t,this.getAmPmValue=n,this.clockType=r}setMinutesToClock(e){let t=this.getClockSystem();t&&(this.styleHandler.removeBgColorToCirleWithMinutesTips(),e&&t.setMinute(e),t.switchToMinutes())}setHoursToClock(e){let t=this.getClockSystem();t&&(e&&t.setHour(e),t.switchToHours())}setTransformToCircleWithSwitchesHour(e){let t=this.getClockSystem();!t||!e||t.setHour(e)}setTransformToCircleWithSwitchesMinutes(e){let t=this.getClockSystem();!t||!e||t.setMinute(e)}updateAmPm(){let e=this.getClockSystem();if(!e||this.clockType===`24h`)return;let t=this.getAmPmValue();t!==``&&e.setAmPm(t)}},mM=class{systemInitializer;styleHandler;timeHandler;eventHandler;constructor(e,t){this.systemInitializer=new dM(e,t),this.styleHandler=new fM(e);let n=e.options.clock.type||`12h`;this.timeHandler=new pM(()=>this.systemInitializer.getClockSystem(),this.styleHandler,()=>this.systemInitializer.getAmPmValue(),n),this.eventHandler=new nM(t,()=>this.systemInitializer.getClockSystem(),e=>this.timeHandler.setHoursToClock(e),e=>this.timeHandler.setMinutesToClock(e),()=>this.timeHandler.updateAmPm(),()=>this.systemInitializer.convertDisabledTime()),this.eventHandler.setup()}initializeClockSystem(){this.systemInitializer.initialize()}destroyClockSystem(){this.systemInitializer.destroy()}removeCircleClockClasses24h(){this.styleHandler.removeCircleClockClasses24h()}setCircleClockClasses24h(){this.styleHandler.setCircleClockClasses24h()}setOnStartCSSClassesIfClockType24h(){this.styleHandler.setOnStartCSSClassesIfClockType24h()}setBgColorToCircleWithMinutesTips=()=>{this.styleHandler.setBgColorToCircleWithMinutesTips()};removeBgColorToCirleWithMinutesTips=()=>{this.styleHandler.removeBgColorToCirleWithMinutesTips()};setClassActiveToHourOnOpen=()=>{this.styleHandler.setClassActiveToHourOnOpen()};setMinutesToClock=e=>{this.timeHandler.setMinutesToClock(e)};setHoursToClock=e=>{this.timeHandler.setHoursToClock(e)};setTransformToCircleWithSwitchesHour=e=>{this.timeHandler.setTransformToCircleWithSwitchesHour(e)};setTransformToCircleWithSwitchesMinutes=e=>{this.timeHandler.setTransformToCircleWithSwitchesMinutes(e)};updateAmPm=()=>{this.timeHandler.updateAmPm()};toggleClassActiveToValueTips=e=>{let t=this.systemInitializer.getClockSystem()!==null;this.styleHandler.toggleClassActiveToValueTips(t,e)};destroy(){this.destroyClockSystem()}},hM=class{core;emitter;cleanupHandlers=[];wasCleared=!1;constructor(e,t){this.core=e,this.emitter=t}init(){if(!this.core.options.ui.clearButton)return;let e=this.getClearButton();if(!e)return;let t=()=>{this.core.isDestroyed||e.getAttribute(`aria-disabled`)!==`true`&&this.handleClearClick()};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t)),this.setupInternalEventListeners()}setupInternalEventListeners(){this.emitter.on(`update`,()=>{this.updateClearButtonState()}),this.emitter.on(`open`,()=>{this.updateClearButtonState()}),this.emitter.on(`select:hour`,()=>{this.updateClearButtonState(),this.reenableConfirmIfCleared()}),this.emitter.on(`select:minute`,()=>{this.updateClearButtonState(),this.reenableConfirmIfCleared()})}handleClearClick(){let e=this.core.getInput()?.value||null;this.clearTimeValue(),this.resetClockToNeutral(),this.disableConfirmButton(),this.wasCleared=!0,Kj(this.core.getModalElement(),`Time cleared`),this.emitter.emit(`clear`,{previousValue:e}),this.emitter.emit(`update`,{hour:void 0,minutes:void 0,type:void 0});let{callbacks:t}=this.core.options;t.onClear&&t.onClear({previousValue:e})}clearTimeValue(){let e=this.core.options.clearBehavior?.clearInput!==!1,t=this.core.getInput();t&&e&&(t.value=``),this.core.setDegreesHours(null),this.core.setDegreesMinutes(null);let n=yj.getClearHandler(`range`);n&&n(this.core,this.emitter);let r=yj.getClearHandler(`timezone`);r&&r(this.core,this.emitter)}resetClockToNeutral(){let e=this.core.options.clock.type,t=e===`12h`?`PM`:void 0,n=this.core.getHour(),r=this.core.getMinutes();n&&(n.value=`12`,n.removeAttribute(`aria-valuenow`)),r&&(r.value=`00`,r.removeAttribute(`aria-valuenow`));let i=this.core.getClockHand();if(i){let e=i.style.transition;i.style.transition=`none`,i.style.transform=`rotateZ(0deg)`,i.offsetHeight,requestAnimationFrame(()=>{i.style.transition=e})}if(this.removeActiveStates(),n&&n.click(),e===`12h`&&t){let e=this.core.getAM(),t=this.core.getPM();e?.classList.remove(`active`),t?.classList.remove(`active`),e?.setAttribute(`aria-pressed`,`false`),t?.setAttribute(`aria-pressed`,`false`),t?.classList.add(`active`),t?.setAttribute(`aria-pressed`,`true`)}this.emitter.emit(`animation:clock`,{})}removeActiveStates(){this.core.getAllValueTips().forEach(e=>{e.classList.remove(`active`),e.removeAttribute(`aria-selected`)});let e=this.core.getHour(),t=this.core.getMinutes();e?.removeAttribute(`aria-valuenow`),t?.removeAttribute(`aria-valuenow`)}disableConfirmButton(){let e=this.core.getOkButton();e&&(e.classList.add(`disabled`),e.setAttribute(`aria-disabled`,`true`))}updateClearButtonState(){let e=this.getClearButton();if(!e)return;let t=this.core.getInput(),n=t?.value&&t.value.trim()!==``,r=this.core.getHour(),i=this.core.getMinutes(),a=this.core.getActiveTypeMode(),o=this.core.options.clock.type,s=r?.value||``,c=i?.value||``,l=a?.textContent||``,u=n||!(o===`12h`?s===`12`&&c===`00`&&l===`PM`:s===`12`&&c===`00`);e.classList.toggle(`disabled`,!u),e.setAttribute(`aria-disabled`,String(!u))}reenableConfirmIfCleared(){if(!this.wasCleared)return;let e=this.core.getOkButton();e&&(e.classList.remove(`disabled`),e.setAttribute(`aria-disabled`,`false`),this.wasCleared=!1)}getClearButton(){return this.core.getModalElement()?.querySelector(`.tp-ui-clear-btn`)||null}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},gM=class{animation;modal;config;theme;validation;events;clock;clearButton;plugins=new Map;constructor(e,t){this.animation=new sj(e,t),this.modal=new Aj(e,t),this.config=new Vj(e,t),this.theme=new Hj(e,t),this.validation=new Gj(e,t),this.events=new tM(e,t),this.clock=new mM(e,t),this.clearButton=new hM(e,t),yj.getAll().forEach(n=>{let r=n.factory(e,t);this.plugins.set(n.name,r)})}getPlugin(e){return this.plugins.get(e)}destroy(){this.animation.destroy(),this.modal.destroy(),this.config.destroy(),this.theme.destroy(),this.validation.destroy(),this.events.destroy(),this.clock.destroy(),this.clearButton.destroy(),this.plugins.forEach(e=>e.destroy()),this.plugins.clear()}},_M=`is-rippling`,vM=`ripple-hold`,yM=null,bM=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}},xM=[`basic`,`crane-straight`,`crane`,`m2`,`m3-green`],SM=class{core;managers;emitter;eventsClickMobileHandler=()=>{};mutliEventsMoveHandler=()=>{};unmountTimeouts=[];constructor(e,t,n){this.core=e,this.managers=t,this.emitter=n}init(){if(!this.core.isDestroyed&&!this.core.isInitialized){try{this.managers.config.updateInputValueWithCurrentTimeOnStart(),this.managers.validation.checkDisabledValuesOnStart()}catch{this.core.setIsDestroyed(!0);return}this.managers.theme.setTimepickerClassToElement(),this.managers.theme.setInputClassToInputElement(),this.managers.theme.setDataOpenToInputIfDoesntExistInWrapper(),this.managers.theme.setClassTopOpenElement(),this.managers.config.getDisableTime(),this.core.options.ui.inline?.enabled||this.managers.events.handleOpenOnClick(),this.managers.events.handleOpenOnEnterFocus(),this.setupCallbackBridge(),this.core.setIsInitialized(!0)}}setupCallbackBridge(){let{callbacks:e}=this.core.options;e.onOpen&&this.emitter.on(`open`,e.onOpen),e.onCancel&&this.emitter.on(`cancel`,e.onCancel),e.onConfirm&&this.emitter.on(`confirm`,e.onConfirm),e.onUpdate&&this.emitter.on(`update`,e.onUpdate),e.onSelectHour&&this.emitter.on(`select:hour`,e.onSelectHour),e.onSelectMinute&&this.emitter.on(`select:minute`,e.onSelectMinute),e.onSelectAM&&this.emitter.on(`select:am`,e.onSelectAM),e.onSelectPM&&this.emitter.on(`select:pm`,e.onSelectPM),e.onError&&this.emitter.on(`error`,e.onError),e.onTimezoneChange&&this.emitter.on(`timezone:change`,e.onTimezoneChange),e.onRangeConfirm&&this.emitter.on(`range:confirm`,e.onRangeConfirm),e.onRangeSwitch&&this.emitter.on(`range:switch`,e.onRangeSwitch),e.onRangeValidation&&this.emitter.on(`range:validation`,e.onRangeValidation),e.onClear&&this.emitter.on(`clear`,e.onClear)}mount(){this.core.isDestroyed||this.core.isOpen||(this.core.isInitialized||this.init(),this.eventsBundle())}unmount(e){let t=bM((...e)=>{if(e.length>2)return;let[t]=e.filter(e=>typeof e==`boolean`),[n]=e.filter(e=>typeof e==`function`);this.core.setIsMobileView(!!this.core.options.ui.mobile);let r=this.core.getModalElement();if(t&&r&&this.core.getOkButton()?.click(),this.core.setIsTouchMouseMove(!1),this.core.setIsOpen(!1),this.removeEventListeners(),this.isPopoverMode()){let e=this.managers.getPlugin(`wheel`);e&&`detachPopover`in e&&e.detachPopover()}r&&this.managers.animation.removeAnimationToClose(),this.core.getOpenElement().forEach(e=>e?.classList.remove(`disabled`));let i=setTimeout(()=>{ij()&&(document.body.style.overflowY=``,document.body.style.paddingRight=``)},oj.SCROLLBAR_RESTORE);this.unmountTimeouts.push(i);let a=setTimeout(()=>{let e=this.core.getInput();this.core.options.behavior.focusInputAfterClose&&e?.focus();let t=this.core.getModalElement();t&&t.remove(),this.core.setIsModalRemove(!0)},oj.MODAL_REMOVE);this.unmountTimeouts.push(a),n&&n()},this.core.options.behavior.delayHandler||oj.DEFAULT_DELAY);e?t(e):t()}destroy(e){if(this.core.isDestroyed)return;this.clearUnmountTimeouts();let{keepInputValue:t=!1,callback:n}=typeof e==`function`?{callback:e}:e||{},r=this.core.getInput(),i=t?r?.value:null;this.removeEventListeners(),this.core.getModalElement()?.remove(),this.core.getOpenElement()?.forEach(e=>{e&&(e.classList.remove(`disabled`,`active`,`tp-ui-open-element`),e.classList.remove(...xM))}),r&&(r.classList.remove(`tp-ui-invalid-format`,`invalid-value`,`error`,`active`,`tp-ui-input`),r.removeAttribute(`data-open`),r.removeAttribute(`data-owner-id`),t&&i&&(r.value=i));let a=this.core.element;a&&(a.classList.remove(...xM),a.classList.remove(`error`,`active`,`disabled`),a.removeAttribute(`data-owner-id`),a.removeAttribute(`data-open`),this.core.options.ui.cssClass&&a.classList.remove(this.core.options.ui.cssClass)),a?.querySelectorAll(`.tp-ui-invalid-text`)?.forEach(e=>e.remove()),this.mutliEventsMoveHandler=()=>{},this.eventsClickMobileHandler=()=>{},this.core.reset(),this.managers.destroy(),this.emitter.clear(),rj()||(document.body.style.overflowY=``,document.body.style.paddingRight=``),n&&n()}eventsBundle(){if(this.core.isDestroyed||!this.core.isModalRemove)return;this.clearUnmountTimeouts(),this.core.setIsOpen(!0),this.core.setIsModalRemove(!1),this.setupValidation(),this.disableOpenElements(),this.setupModal(),this.applyExpandedState(),this.managers.modal.setFlexEndToFooterIfNoKeyboardIcon(),this.applyThemeDeferred(),this.managers.animation.setAnimationToOpen(),this.managers.config.getInputValueOnOpenAndSet();let e=this.resolveWheelMode();if(this.emitMissingPluginErrors(),this.initClockOrWheel(e),this.initOptionalPlugins(e),this.bindEventHandlers(e),this.finalizeModal(e),this.isPopoverMode()){let e=this.managers.getPlugin(`wheel`);e&&`attachPopover`in e&&e.attachPopover()}this.managers.modal.setShowClassToBackdrop()}setupValidation(){this.managers.validation.setErrorHandler(),this.managers.validation.removeErrorHandler()}disableOpenElements(){this.core.options.ui.inline?.enabled||(this.core.getOpenElement().forEach(e=>e?.classList.add(`disabled`)),this.isPopoverMode()||this.core.getInput()?.blur())}setupModal(){this.managers.modal.setScrollbarOrNot(),this.managers.modal.setModalTemplate(),this.managers.modal.setNormalizeClass(),this.managers.modal.removeBackdrop()}applyExpandedState(){if(this.core.isMobileView)this.managers.config.updateClockFaceAccessibility(!0);else{let e=this.core.getModalElement(),t=e?.querySelector(`.tp-ui-mobile-clock-wrapper`),n=e?.querySelector(`.tp-ui-wrapper`),r=e?.querySelectorAll(`*`);t?.classList.add(`expanded`),n?.classList.add(`expanded`),r?.forEach(e=>{!e.classList.contains(`tp-ui-select-time`)&&!e.classList.contains(`tp-ui-mobile-clock-wrapper`)&&!e.classList.contains(`tp-ui-wrapper`)&&e.classList.add(`expanded`)})}}applyThemeDeferred(){setTimeout(()=>{this.managers.theme.setTheme();let e=this.core.getWrapper();e&&this.core.options.ui.cssClass&&e.classList.add(this.core.options.ui.cssClass)},0)}isCompactWheelMode(){return this.core.options.ui.mode===`compact-wheel`}isPopoverMode(){return this.isCompactWheelMode()&&!!this.core.options.wheel?.placement}resolveWheelMode(){let e=this.core.options.ui.mode;return(e===`wheel`||e===`compact-wheel`)&&yj.has(`wheel`)}emitMissingPluginErrors(){let e=this.core.options.ui.mode;(e===`wheel`||e===`compact-wheel`)&&!yj.has(`wheel`)&&this.emitter.emit(`error`,{error:`WheelPlugin is not registered. Import and register it: PluginRegistry.register(WheelPlugin)`}),this.core.options.range?.enabled&&!yj.has(`range`)&&this.emitter.emit(`error`,{error:`RangePlugin is not registered. Import and register it: PluginRegistry.register(RangePlugin)`}),this.core.options.timezone?.enabled&&!yj.has(`timezone`)&&this.emitter.emit(`error`,{error:`TimezonePlugin is not registered. Import and register it: PluginRegistry.register(TimezonePlugin)`})}initClockOrWheel(e){if(e){let e=this.managers.getPlugin(`wheel`);e&&e.init()}else this.managers.clock.initializeClockSystem(),this.managers.clock.setOnStartCSSClassesIfClockType24h(),this.managers.clock.setClassActiveToHourOnOpen()}initOptionalPlugins(e){let t=this.managers.getPlugin(`timezone`);t&&t.init();let n=this.managers.getPlugin(`range`);n&&!e&&n.init()}bindEventHandlers(e){this.managers.events.handleCancelButton(),this.managers.events.handleOkButton(),this.managers.clearButton.init(),e||(this.managers.events.handleHourEvents(),this.managers.events.handleMinutesEvents()),this.managers.events.handleKeyboardInput(),this.core.options.ui.enableSwitchIcon&&!e&&this.managers.events.handleSwitchViewButton(),this.core.options.clock.type!==`24h`&&!this.isCompactWheelMode()&&(this.managers.events.handleAmClick(),this.managers.events.handlePmClick()),this.core.options.behavior.focusTrap&&this.managers.events.focusTrapHandler(),this.core.options.ui.inline?.enabled||(this.managers.events.handleEscClick(),this.isPopoverMode()||(this.core.options.ui.mode===`wheel`||this.core.options.ui.mode===`compact-wheel`)&&this.core.options.wheel?.ignoreOutsideClick||this.managers.events.handleBackdropClick())}finalizeModal(e){let t=this.core.getModalElement();if(t&&tj(t),!e){let e=this.core.getClockFace();e&&typeof requestAnimationFrame<`u`&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e?.classList.add(`scale-in`)})})}}clearUnmountTimeouts(){this.unmountTimeouts.forEach(clearTimeout),this.unmountTimeouts=[]}removeEventListeners(){ij()!==!1&&(Pj.split(` `).forEach(e=>{document.removeEventListener(e,this.mutliEventsMoveHandler,!1)}),document.removeEventListener(`mousedown`,this.eventsClickMobileHandler))}},CM=class{events=new Map;on(e,t){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t)}once(e,t){let n=r=>{t(r),this.off(e,n)};this.on(e,n)}off(e,t){t?this.events.get(e)?.delete(t):this.events.delete(e)}emit(e,t){this.events.get(e)?.forEach(e=>{e(t)})}clear(){this.events.clear()}hasListeners(e){return(this.events.get(e)?.size??0)>0}},wM={clock:{type:`12h`,incrementHours:1,incrementMinutes:1,autoSwitchToMinutes:!0,disabledTime:void 0,currentTime:void 0},ui:{mode:`clock`,theme:`basic`,animation:!0,backdrop:!0,mobile:!1,enableSwitchIcon:!1,editable:!1,enableScrollbar:!1,cssClass:void 0,appendModalSelector:``,iconTemplate:``,iconTemplateMobile:``,inline:void 0,clearButton:!1},labels:{am:`AM`,pm:`PM`,ok:`OK`,cancel:`Cancel`,time:`Select time`,mobileTime:`Enter Time`,mobileHour:`Hour`,mobileMinute:`Minute`,clear:`Clear`},behavior:{focusInputAfterClose:!1,focusTrap:!0,delayHandler:300,id:void 0},callbacks:{onOpen:void 0,onCancel:void 0,onConfirm:void 0,onUpdate:void 0,onSelectHour:void 0,onSelectMinute:void 0,onSelectAM:void 0,onSelectPM:void 0,onError:void 0,onTimezoneChange:void 0,onRangeConfirm:void 0,onRangeSwitch:void 0,onRangeValidation:void 0,onClear:void 0},timezone:{enabled:!1,default:void 0,whitelist:void 0,label:`Timezone`},range:{enabled:!1,minDuration:void 0,maxDuration:void 0,fromLabel:`From`,toLabel:`To`},wheel:{placement:void 0,hideFooter:void 0,commitOnScroll:void 0,hideDisabled:void 0,ignoreOutsideClick:void 0},clearBehavior:{clearInput:!0}},TM=e=>e.replace(/[^0-9:APMapm\s]/g,``),EM=new Map,DM=class{core;managers;lifecycle;emitter;constructor(e,t){if(rj())throw Error(`TimepickerUI requires browser environment`);let n=this.resolveInputElement(e);if(!n)throw Error(`Input element not found`);let r=t?.behavior?.id,i=r||`tp-ui-${hj()}`,a=this.createWrapperElement(n),o=nj(t||{});if(o.ui.inline?.enabled&&typeof t?.behavior?.focusTrap>`u`&&(o.behavior.focusTrap=!1),o.ui.inline?.enabled){if(!o.ui.inline.containerId)throw Error(`inline.containerId is required when inline mode is enabled`);if(!rj()&&!document.getElementById(o.ui.inline.containerId))throw Error(`Container element with id "${o.ui.inline.containerId}" not found`)}this.emitter=new CM,this.core=new aj(a,o,i,r);let s=this.core.getInput();if(s){let e=jj(s,o.clock.type),t=Number(e.hour)*30,n=Number(e.minutes)*6;this.core.setDegreesHours(t),this.core.setDegreesMinutes(n)}this.managers=new gM(this.core,this.emitter),this.lifecycle=new SM(this.core,this.managers,this.emitter),this.managers.config.checkMobileOption(),this.managers.config.preventClockTypeByCurrentTime(),this.setupInternalEventListeners(),EM.set(this.core.instanceId,this)}setupInternalEventListeners(){this.emitter.on(`show`,()=>{this.core.isDestroyed||this.lifecycle.mount()}),this.emitter.on(`cancel`,()=>{this.core.isDestroyed||this.lifecycle.unmount()}),this.emitter.on(`confirm`,e=>{if(!this.core.isDestroyed){if(this.core.options.range?.enabled)return;let t=this.core.getInput();if(t&&e.hour&&e.minutes){let n=e.type?` ${e.type}`:``;t.value=`${e.hour}:${e.minutes}${n}`}e.autoCommit||this.lifecycle.unmount()}}),this.emitter.on(`range:confirm`,e=>{if(this.core.isDestroyed)return;let t=this.core.getInput();t&&(t.value=`${e.from} - ${e.to}`),this.lifecycle.unmount()})}create(){this.lifecycle.init(),this.core.options.ui.inline?.enabled&&this.lifecycle.mount()}open(e){this.lifecycle.mount(),e&&e()}close(e,t){this.lifecycle.unmount(e?t:void 0),!e&&t&&t()}destroy(e){EM.delete(this.core.instanceId),this.lifecycle.destroy(e)}update(e,t){this.core.isDestroyed||(this.core.updateOptions(e.options),this.managers.config.checkMobileOption(),this.managers.config.getDisableTime(),e.create&&this.create(),t&&t())}getValue(){if(this.core.isDestroyed)return{hour:``,minutes:``,type:void 0,time:``,degreesHours:null,degreesMinutes:null};let e=this.core.getModalElement(),t=this.core.getInput(),n=`12`,r=`00`,i=this.core.options.clock.type===`24h`?void 0:`AM`,a=null,o=null;if(e){let e=this.core.getHour(),t=this.core.getMinutes(),s=this.core.getActiveTypeMode();n=e?.value||`12`,r=t?.value||`00`,i=this.core.options.clock.type===`24h`?void 0:s?.textContent||`AM`,a=this.core.degreesHours,o=this.core.degreesMinutes}else if(t){let e=jj(t,this.core.options.clock.type);n=e.hour,r=e.minutes,i=e.type,a=Number(n)*30,o=Number(r)*6}let s=``;return s=this.core.options.clock.type===`24h`?`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}`:`${n}:${r.padStart(2,`0`)} ${i}`,{hour:n,minutes:r,type:i,time:s,degreesHours:a,degreesMinutes:o}}setValue(e,t=!0){if(this.core.isDestroyed||!e||typeof e!=`string`)return;this.core.isInitialized||this.create();let n=TM(e.trim());try{let e=this.parseTimeString(n);if(this.applyParsedTime(e),this.syncPeriodIndicator(e.typeValue),t){let e=this.core.getInput();e&&(e.value=n)}this.syncClockVisual(e)}catch{return}}parseTimeString(e){if(this.core.options.clock.type===`24h`){let t=e.match(/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/);if(!t)throw Error(`Invalid 24h format. Expected HH:MM`);return{hourValue:t[1].padStart(2,`0`),minutesValue:t[2],typeValue:`AM`}}let t=e.match(/^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i);if(!t)throw Error(`Invalid 12h format. Expected HH:MM AM/PM`);return{hourValue:t[1],minutesValue:t[2],typeValue:t[3].toUpperCase()}}applyParsedTime(e){let t=this.core.getHour(),n=this.core.getMinutes();t&&(t.value=e.hourValue,t.setAttribute(`aria-valuenow`,e.hourValue),this.core.setDegreesHours(Number(e.hourValue)*30)),n&&(n.value=e.minutesValue,n.setAttribute(`aria-valuenow`,e.minutesValue),this.core.setDegreesMinutes(Number(e.minutesValue)*6))}syncPeriodIndicator(e){if(this.core.options.clock.type===`24h`)return;let t=this.core.getAM(),n=this.core.getPM();!t||!n||(e===`AM`?(t.classList.add(`active`),n.classList.remove(`active`)):(n.classList.add(`active`),t.classList.remove(`active`)))}syncClockVisual(e){let t=this.core.options.ui.mode;if(t===`wheel`||t===`compact-wheel`){let t=this.managers.getPlugin(`wheel`);t&&`scrollToValue`in t&&t.scrollToValue(e.hourValue,e.minutesValue,e.typeValue)}else{let e=this.core.getClockHand();e&&(e.style.transform=`rotateZ(${this.core.degreesHours||0}deg)`)}}getElement(){return this.core.element}get instanceId(){return this.core.instanceId}get options(){return this.core.options}get isInitialized(){return this.core.isInitialized}get isDestroyed(){return this.core.isDestroyed}get hour(){return this.core.getHour()}get minutes(){return this.core.getMinutes()}get okButton(){return this.core.getOkButton()}get cancelButton(){return this.core.getCancelButton()}get clockHand(){return this.core.getClockHand()}on(e,t){this.core.isDestroyed||this.emitter.on(e,t)}once(e,t){this.core.isDestroyed||this.emitter.once(e,t)}off(e,t){this.core.isDestroyed||this.emitter.off(e,t)}resolveInputElement(e){if(ij()===!1)return null;let t=null;if(typeof e==`string`){if(t=document.querySelector(e),!t)return null}else if(e instanceof HTMLElement)t=e;else return null;return t.tagName===`INPUT`?t:t.querySelector(`input`)}createWrapperElement(e){if(ij()===!1)return e;let t=e.parentElement;if(e.tagName===`INPUT`&&!t?.classList.contains(`tp-ui`)){let t=document.createElement(`div`);return t.className=`tp-ui`,e.parentNode?.insertBefore(t,e),t.appendChild(e),t}return t&&!t.classList.contains(`tp-ui`)&&t.classList.add(`tp-ui`),t||e}static getById(e){return EM.get(e)}static getAllInstances(){return Array.from(EM.values())}static isAvailable(e){return rj()?!1:typeof e==`string`?document.querySelector(e)!==null:e instanceof HTMLElement?document.contains(e):!1}static destroyAll(){Array.from(EM.values()).forEach(e=>e.destroy()),EM.clear()}},OM=DM,kM=OM})),jM=u({RangeManager:()=>BM,RangePlugin:()=>VM});function MM(e){if(!e||e===`--:--`)return null;let t=e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(t)return{hour:t[1],minutes:t[2],type:t[3].toUpperCase()};let n=e.match(/^(\d{1,2}):(\d{2})$/);return n?{hour:n[1],minutes:n[2]}:null}function NM(e){let t=e.minutes===`--`?`--`:e.minutes.padStart(2,`0`),n=`${e.hour}:${t}`;return e.type?`${n} ${e.type}`:n}function PM(e,t){if(!e)return 0;let n=parseInt(e.hour,10),r=parseInt(e.minutes,10);return t===`12h`&&e.type&&(e.type===`PM`&&n!==12&&(n+=12),e.type===`AM`&&n===12&&(n=0)),n*60+r}function FM(e,t,n){if(!e||!t)return 0;let r=PM(e,n);return PM(t,n)-r}function IM(e,t){return e?t===`12h`?!!(e.hour&&e.minutes&&e.type):!!(e.hour&&e.minutes):!1}function LM(e){if(!e||!e.includes(` - `))return{from:null,to:null};let t=e.split(` - `).map(e=>e.trim());return t.length!==2||t[0]===`--:--`||t[1]===`--:--`?{from:null,to:null}:{from:MM(t[0]),to:MM(t[1])}}var RM,zM,BM,VM,HM=c((()=>{RM=class{activePart=`from`;fromValue=null;toValue=null;previewValue=null;clockType;minDuration;maxDuration;emitter;constructor(e,t,n,r){this.clockType=e,this.minDuration=t,this.maxDuration=n,this.emitter=r}getActivePart(){return this.activePart}getFromValue(){return this.fromValue}getToValue(){return this.toValue}getPreviewValue(){return this.previewValue}setFromValue(e){this.fromValue=e}setToValue(e){this.toValue=e}setPreviewValue(e){this.previewValue=e}isFromComplete(){return IM(this.fromValue,this.clockType)}isToComplete(){return IM(this.toValue,this.clockType)}canSwitchToEnd(){return this.isFromComplete()}canConfirm(){return!this.isFromComplete()||!this.isToComplete()?!1:this.getDuration()>0}setActivePart(e){if(e===`to`&&!this.canSwitchToEnd())return!1;let t=this.activePart!==e;return this.activePart=e,t&&(this.previewValue=null),t}resetActivePart(){this.activePart=`from`,this.previewValue=null}getCurrentValue(){return this.previewValue?this.previewValue:this.activePart===`from`?this.fromValue:this.toValue}getSavedValue(){return this.activePart===`from`?this.fromValue:this.toValue}commitPreview(){this.previewValue&&=(this.activePart===`from`?this.fromValue=this.previewValue:this.toValue=this.previewValue,null)}getDuration(){return FM(this.fromValue,this.toValue,this.clockType)}validate(){if(!this.fromValue||!this.toValue)return{valid:!0,duration:0};let e=this.getDuration(),t=!0;return this.minDuration!==void 0&&e<this.minDuration&&(t=!1),this.maxDuration!==void 0&&e>this.maxDuration&&(t=!1),this.emitter.emit(`range:validation`,{valid:t,duration:e,minDuration:this.minDuration,maxDuration:this.maxDuration}),{valid:t,duration:e}}getDisabledTimeForEndPart(){if(this.activePart===`from`||!this.fromValue||!this.isFromComplete())return null;let e=[],t=[],n=parseInt(this.fromValue.hour,10),r=parseInt(this.fromValue.minutes,10),i=this.fromValue.type;if(this.clockType===`24h`){for(let t=0;t<n;t++)e.push(t.toString().padStart(2,`0`));for(let e=0;e<r;e++)t.push(e.toString().padStart(2,`0`));return{hours:e,minutes:t,fromHour:n}}for(let e=0;e<r;e++)t.push(e.toString().padStart(2,`0`));return{hours:e,minutes:t,fromType:i,fromHour:n}}reset(){this.activePart=`from`,this.fromValue=null,this.toValue=null,this.previewValue=null}},zM=class{core;state;constructor(e,t){this.core=e,this.state=t}updateTabs(){let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(`.tp-ui-range-tab.tp-ui-range-from`),n=e.querySelector(`.tp-ui-range-tab.tp-ui-range-to`),r=this.state.getActivePart()===`from`,i=this.state.isFromComplete();t?.classList.toggle(`active`,r),n?.classList.toggle(`active`,!r),n?.classList.toggle(`disabled`,!i),t?.setAttribute(`aria-selected`,String(r)),n?.setAttribute(`aria-selected`,String(!r)),n?.setAttribute(`aria-disabled`,String(!i)),t?.setAttribute(`tabindex`,r?`0`:`-1`),n?.setAttribute(`tabindex`,r||!i?`-1`:`0`)}updateTimeDisplay(){let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(`.tp-ui-range-from-time`),n=e.querySelector(`.tp-ui-range-to-time`),r=this.state.getActivePart(),i=this.state.getPreviewValue(),a=this.state.getFromValue(),o=this.state.getToValue(),s=`--:--`;r===`from`&&i?s=NM(i):a&&(s=NM(a));let c=`--:--`;r===`to`&&i?c=NM(i):o&&(c=NM(o)),t&&(t.textContent=s),n&&(n.textContent=c)}updateOkButton(){let e=this.core.getOkButton();if(!e)return;let t=this.state.canConfirm();e.classList.toggle(`disabled`,!t),e.setAttribute(`aria-disabled`,String(!t))}updateInputValue(){let e=this.core.getInput();if(!e)return;let t=this.state.getFromValue(),n=this.state.getToValue();e.value=`${t?NM(t):`--:--`} - ${n?NM(n):`--:--`}`}syncClockToActivePart(){let e=this.state.getSavedValue(),t=this.core.getHour(),n=this.core.getMinutes();if(t&&(t.value=e?.hour??`12`),n&&(n.value=e?.minutes??`00`),this.core.options.clock.type===`12h`){let t=this.core.getAM(),n=this.core.getPM();e?.type===`AM`?(t?.classList.add(`active`),n?.classList.remove(`active`)):e?.type===`PM`?(n?.classList.add(`active`),t?.classList.remove(`active`)):(t?.classList.remove(`active`),n?.classList.remove(`active`))}n&&(n.blur(),n.classList.remove(`active`)),t&&t.click()}updateAll(){this.updateTabs(),this.updateTimeDisplay(),this.updateOkButton()}},BM=class{core;emitter;state;ui;cleanupHandlers=[];isSyncingAmPm=!1;boundHandleMinuteCommit;boundHandleConfirm;boundHandleUpdate;boundHandleAmPm;boundHandleClear;constructor(e,t){this.core=e,this.emitter=t;let{range:n,clock:r}=e.options;this.state=new RM(r.type,n?.minDuration,n?.maxDuration,t),this.ui=new zM(e,this.state),this.boundHandleMinuteCommit=this.handleMinuteCommit.bind(this),this.boundHandleConfirm=this.handleConfirm.bind(this),this.boundHandleUpdate=this.handleUpdate.bind(this),this.boundHandleAmPm=this.handleAmPm.bind(this),this.boundHandleClear=this.handleClear.bind(this)}get isEnabled(){return this.core.options.range?.enabled===!0}init(){if(!this.isEnabled)return;let{from:e,to:t}=LM(this.core.getInput()?.value||``);this.state.setFromValue(e),this.state.setToValue(t),this.state.setActivePart(`from`),this.state.setPreviewValue(null),this.bindEvents(),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll()}getActivePart(){return this.state.getActivePart()}setActivePart(e){this.isEnabled&&(this.state.setActivePart(e)&&this.emitter.emit(`range:switch`,{active:e,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll())}getFromValue(){return this.state.getFromValue()}getToValue(){return this.state.getToValue()}getDisabledTimeForEndPart(){return this.isEnabled?this.state.getDisabledTimeForEndPart():null}getDuration(){return this.state.getDuration()}validateRange(){return this.isEnabled?this.state.validate():{valid:!0,duration:0}}canConfirm(){return this.isEnabled?this.state.canConfirm():!0}getFormattedRange(){let e=this.state.getFromValue(),t=this.state.getToValue();return!e||!t?null:{from:NM(e),to:NM(t)}}bindEvents(){let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(`.tp-ui-range-tab.tp-ui-range-from`),n=e.querySelector(`.tp-ui-range-tab.tp-ui-range-to`);if(t){let e=()=>this.setActivePart(`from`);t.addEventListener(`click`,e),this.cleanupHandlers.push(()=>t.removeEventListener(`click`,e))}if(n){let e=()=>this.setActivePart(`to`);n.addEventListener(`click`,e),this.cleanupHandlers.push(()=>n.removeEventListener(`click`,e))}this.emitter.on(`update`,this.boundHandleUpdate),this.cleanupHandlers.push(()=>this.emitter.off(`update`,this.boundHandleUpdate)),this.emitter.on(`range:minute:commit`,this.boundHandleMinuteCommit),this.cleanupHandlers.push(()=>this.emitter.off(`range:minute:commit`,this.boundHandleMinuteCommit)),this.emitter.on(`confirm`,this.boundHandleConfirm),this.cleanupHandlers.push(()=>this.emitter.off(`confirm`,this.boundHandleConfirm)),this.emitter.on(`select:am`,this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off(`select:am`,this.boundHandleAmPm)),this.emitter.on(`select:pm`,this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off(`select:pm`,this.boundHandleAmPm)),this.emitter.on(`clear`,this.boundHandleClear),this.cleanupHandlers.push(()=>this.emitter.off(`clear`,this.boundHandleClear))}handleClear(){this.isEnabled&&(this.state.setFromValue(null),this.state.setToValue(null),this.state.setPreviewValue(null),this.state.resetActivePart())}handleUpdate(){if(!this.isEnabled)return;let e=this.core.getHour(),t=this.core.getMinutes(),n=this.core.getActiveTypeMode(),r=e?.value??`12`,i=this.state.getSavedValue(),a=i?.minutes&&i.minutes!==`--`?t?.value??`--`:`--`,o=this.core.options.clock.type===`12h`?n?.textContent??void 0:void 0;this.state.setPreviewValue({hour:r,minutes:a,type:o}),this.ui.updateAll()}handleMinuteCommit(e){if(!this.isEnabled)return;let t={hour:e.hour,minutes:e.minutes,type:e.type??void 0};this.state.getActivePart()===`from`?(this.state.setFromValue(t),this.state.setPreviewValue(null),this.state.isFromComplete()&&(this.state.setActivePart(`to`),this.emitter.emit(`range:switch`,{active:`to`,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent())):(this.state.setToValue(t),this.state.setPreviewValue(null)),this.state.validate(),this.ui.updateAll()}handleAmPm(){if(!this.isEnabled||this.isSyncingAmPm||this.core.options.clock.type!==`12h`)return;let e=this.core.getActiveTypeMode()?.textContent;if(e){if(this.state.getActivePart()===`from`){let t=this.state.getFromValue();t&&(this.state.setFromValue({...t,type:e}),this.state.isFromComplete()&&(this.state.setActivePart(`to`),this.state.setPreviewValue(null),this.emitter.emit(`range:switch`,{active:`to`,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent()))}else{let t=this.state.getToValue();t&&this.state.setToValue({...t,type:e}),this.emitter.emit(`range:switch`,{active:`to`,disabledTime:this.state.getDisabledTimeForEndPart()})}this.state.validate(),this.ui.updateAll()}}emitAmPmSyncEvent(){if(this.core.options.clock.type!==`12h`)return;let e=this.state.getSavedValue();if(e?.type){this.isSyncingAmPm=!0;try{e.type===`AM`?this.emitter.emit(`select:am`,{}):e.type===`PM`&&this.emitter.emit(`select:pm`,{})}finally{this.isSyncingAmPm=!1}}}handleConfirm(e){if(!this.isEnabled)return;this.state.commitPreview();let t=this.state.getFromValue(),n=this.state.getToValue(),r=t?NM(t):`--:--`,i=n?NM(n):`--:--`,a=this.state.getDuration();this.ui.updateInputValue(),this.emitter.emit(`range:confirm`,{from:r,to:i,duration:a})}reset(){this.state.reset()}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[],this.reset()}},VM={name:`range`,factory:(e,t)=>new BM(e,t),clearHandler:(e,t)=>{if(!e.options.range?.enabled)return;let n=e.getModalElement();if(!n)return;let r=n.querySelector(`.tp-ui-range-from`),i=n.querySelector(`.tp-ui-range-to`),a=n.querySelector(`.tp-ui-range-from-time`),o=n.querySelector(`.tp-ui-range-to-time`);a&&(a.textContent=`--:--`),o&&(o.textContent=`--:--`),r?.classList.add(`active`),i?.classList.remove(`active`),r?.setAttribute(`aria-selected`,`true`),i?.setAttribute(`aria-selected`,`false`),r?.setAttribute(`tabindex`,`0`),i?.setAttribute(`tabindex`,`-1`),i?.classList.add(`disabled`),i?.setAttribute(`aria-disabled`,`true`);let s=e.getHour();s&&s.focus(),t.emit(`range:switch`,{active:`from`,disabledTime:null})}}})),UM,WM,GM,KM=!1;async function qM(){if(!UM){let e=await Promise.resolve().then(()=>(AM(),ZA));UM=e.TimepickerUI,WM=e.PluginRegistry,GM=(await Promise.resolve().then(()=>(HM(),jM))).RangePlugin,!KM&&WM&&GM&&(WM.register(GM),KM=!0)}}var JM=class{constructor(e){if(this.config={dayStartTime:`00:00`,dayEndTime:`23:59`,minuteIncrement:5,clockType:`12h`,...e},this.selectedStart=this.extractTimeAsHHMM(e.startTime),e.endTime)this.selectedEnd=this.extractTimeAsHHMM(e.endTime);else{let e=new Date(`2000-01-01T${this.selectedStart}:00Z`),n=new Date(e.getTime()+3600*1e3);this.selectedEnd=t.tools.dateTime.extractTime(n.toISOString())}this.inputElement=document.createElement(`input`),this.container=this.createUI()}extractTimeAsHHMM(e){return e.includes(`T`)?t.tools.dateTime.extractTime(e):e}createUI(){let e=document.createElement(`div`);return e.style.cssText=`
|
|
230
|
+
</div>`},BM=e=>{let{range:{enabled:t,fromLabel:n,toLabel:r}}=e;return!t||!FM.has(`range`)?``:`<div class="tp-ui-range-header" role="tablist" aria-label="Range selection"><button type="button" class="tp-ui-range-tab tp-ui-range-from active" role="tab" tabindex="0" aria-selected="true"><span class="tp-ui-range-tab-label">${n}</span><span class="tp-ui-range-tab-value tp-ui-range-from-time">--:--</span></button><button type="button" class="tp-ui-range-tab tp-ui-range-to" role="tab" tabindex="-1" aria-selected="false"><span class="tp-ui-range-tab-label">${r}</span><span class="tp-ui-range-tab-value tp-ui-range-to-time">--:--</span></button></div>`},VM=(e,t)=>{let{ui:{clearButton:n},labels:{clear:r}}=e;return n?`<div class="tp-ui-clear-btn ${t} disabled" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${r}" aria-disabled="true">${r}</div>`:``},HM=(e,t,n)=>{if(e.isWheelMode){let t=FM.getTemplateProvider(`wheel`);return t?`<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}">${t(n,e.instanceId)}</div>`:`<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}"></div>`}return`<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}"><div class="tp-ui-body ${e.mobileClass}"><div class="tp-ui-clock-face ${e.mobileClass}" role="group" aria-label="Clock"><div class="tp-ui-dot ${e.mobileClass}" aria-hidden="true"></div><div class="tp-ui-clock-hand ${e.mobileClass}" aria-hidden="true"><div class="tp-ui-circle-hand ${e.mobileClass}"></div></div><div class="tp-ui-tips-wrapper ${e.mobileClass}" role="listbox" aria-label="Time"></div>${e.clockType===`24h`?`<div class="tp-ui-tips-wrapper-24h ${e.mobileClass}" role="listbox" aria-label="24h"></div>`:``}</div></div></div>`},UM=(e,t)=>{let{labels:{time:n,mobileTime:r,am:i,pm:a,mobileMinute:o,mobileHour:s},ui:{editable:c}}=e,{mobileClass:l,clockType:u,instanceId:d}=t,f=l?r:n,p=u===`24h`?``:`<div class="tp-ui-wrapper-type-time ${l}" role="group" aria-label="Period"><div class="tp-ui-type-mode tp-ui-am ${l?`mobile`:`tp-ui-ripple`}" data-md3-ripple tabindex="0" role="button" aria-label="${i}" aria-pressed="false" data-type="AM">${i}</div><div class="tp-ui-type-mode tp-ui-pm ${l?`mobile`:`tp-ui-ripple`}" data-md3-ripple tabindex="0" role="button" aria-label="${a}" aria-pressed="false" data-type="PM">${a}</div></div>`;return`<div class="tp-ui-select-time ${l}" id="tp-ui-label-${d}">${f}</div><div class="tp-ui-header ${l}"><div class="tp-ui-wrapper-time ${l} ${u===`24h`?`tp-ui-wrapper-time-24h`:``}" role="group" aria-label="${f}"><div class="tp-ui-input-wrapper ${l}"><div class="tp-ui-input-ripple-wrapper ${l}" data-md3-ripple><input name="hour" ${!c&&!l?`readonly`:``} class="tp-ui-hour ${l}" tabindex="0" type="number" min="0" max="${u===`12h`?`12`:`23`}" aria-label="${l?s:`Hour`}" role="spinbutton" aria-valuenow="12"></div><div class="tp-ui-hour-text ${l}">${s}</div></div><div class="tp-ui-dots ${l}" aria-hidden="true"><span></span><span></span></div><div class="tp-ui-input-wrapper ${l}"><div class="tp-ui-input-ripple-wrapper ${l}" data-md3-ripple><input name="minutes" ${!c&&!l?`readonly`:``} class="tp-ui-minutes ${l}" tabindex="0" type="number" min="0" max="59" aria-label="${l?o:`Minute`}" role="spinbutton" aria-valuenow="0"></div><div class="tp-ui-minute-text ${l}">${o}</div></div></div>${p}</div>`},WM=(e,t)=>{let{ui:{enableSwitchIcon:n,iconTemplate:r,iconTemplateMobile:i},labels:{cancel:a,ok:o}}=e,s=`<button aria-label="Keyboard" type="button" class="tp-ui-keyboard-icon">${r||MM}</button>`,c=i||`<button aria-label="Clock" type="button" class="tp-ui-keyboard-icon">${i||NM}</button>`,l=n?`<div class="tp-ui-keyboard-icon-wrapper ${t}" tabindex="0" role="button" aria-pressed="false" aria-label="Toggle" data-view="desktop">${t?c:s}</div>`:``,u=VM(e,t);return`<div class="tp-ui-footer ${t}" ${t?`data-view="mobile"`:``}>${l}<div class="tp-ui-wrapper-btn ${t}">${u}<div class="tp-ui-cancel-btn ${t}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${a}">${a}</div><div class="tp-ui-ok-btn ${t}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${o}">${o}</div></div></div>`},GM=(e,t)=>{let{ui:{mode:n,animation:r,theme:i,mobile:a},clock:{incrementMinutes:o}}=e,s=a?`mobile`:``,c=n===`compact-wheel`&&FM.has(`wheel`),l=(n===`wheel`||c)&&FM.has(`wheel`),u=!!e.range?.enabled&&FM.has(`range`),d=!!e.timezone?.enabled&&FM.has(`timezone`),f={mobileClass:s,clockType:e.clock.type||`12h`,instanceId:t,isWheelMode:l,isCompactWheel:c,isRangeMode:u},p=BM(e),m=zM(e,s,t),h=c?``:UM(e,f),g=HM(f,o??1,e),_=c&&e.wheel?.hideFooter===!0?``:WM(e,s),v;return v=c?` tp-ui-compact-wheel-mode`:l?` tp-ui-wheel-mode`:``,`<div class="tp-ui-modal normalize ${s}${u?` tp-ui-range-mode`:``}${d?` tp-ui-tz-mode`:``}${v}" data-theme="${i}" role="dialog" aria-modal="true" aria-labelledby="tp-ui-label-${t}" data-owner-id="${t}" style='transition:${r?`opacity 0.15s linear`:`none`}'><div class="tp-ui-wrapper ${s}" tabindex="0">${p}${h}${m}${g}${_}</div><div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div></div>`},KM=class{core;emitter;timeouts=[];originalOverflow;originalPaddingRight;constructor(e,t){this.core=e,this.emitter=t}runWithTimeout(e,t=SM.DEFAULT_DELAY){let n=setTimeout(e,t);this.timeouts.push(n)}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}isPopoverMode(){return this.core.options.ui.mode===`compact-wheel`&&!!this.core.options.wheel?.placement}clearExistingModal(){if(bM()===!1)return;let e=this.core.getModalElement();e&&e.remove()}setModalTemplate(){if(bM()===!1)return;this.clearExistingModal();let e=GM(this.core.options,this.core.instanceId);if(this.core.options.ui.inline?.enabled){let t=document.getElementById(this.core.options.ui.inline.containerId);if(!t)return;t.innerHTML=``,t.insertAdjacentHTML(`beforeend`,e);let n=t.querySelector(`.tp-ui-modal`);if(n){n.classList.add(`tp-ui--inline`);let{showButtons:e}=this.core.options.ui.inline;(e===!1||e===void 0)&&n.querySelectorAll(`.tp-ui-wrapper-btn, .tp-ui-wrapper-btn.mobile`).forEach(e=>e.style.display=`none`)}return}let{appendModalSelector:t}=this.core.options.ui;t?document.querySelector(t)?.insertAdjacentHTML(`beforeend`,e):document.body.insertAdjacentHTML(`beforeend`,e)}setScrollbarOrNot(){bM()!==!1&&(this.core.options.ui.inline?.enabled||this.isPopoverMode()||(this.core.options.ui.enableScrollbar?this.runWithTimeout(()=>{yM()||this.runWithTimeout(()=>{typeof document<`u`&&(document.body.style.overflowY=this.originalOverflow||``,document.body.style.paddingRight=this.originalPaddingRight||``)},SM.SCROLLBAR_RESTORE)},400):(this.originalOverflow=document.body.style.overflowY,this.originalPaddingRight=document.body.style.paddingRight,document.body.style.paddingRight=`${wM()}px`,document.body.style.overflowY=`hidden`)))}removeBackdrop(){if(this.core.options.ui.inline?.enabled||this.core.options.ui.backdrop)return;let e=this.core.getModalElement(),t=this.core.getOpenElement();e?.classList.add(`removed`),t.forEach(e=>e?.classList.add(`disabled`))}setNormalizeClass(){let e=this.core.getModalElement();e&&(e.classList.add(`tp-ui-normalize`),e.querySelectorAll(`:scope > div`).forEach(e=>e.classList.add(`tp-ui-normalize`)))}setShowClassToBackdrop(){if(this.core.options.ui.inline?.enabled||this.isPopoverMode()){this.core.getModalElement()?.classList.add(`show`),this.setInitialFocus();return}this.core.options.ui.backdrop&&this.runWithTimeout(()=>{this.core.getModalElement()?.classList.add(`show`),this.setInitialFocus()},SM.MODAL_ANIMATION)}setInitialFocus(){if(!this.core.options.behavior.focusTrap)return;let e=this.core.getWrapper();e&&typeof requestAnimationFrame<`u`&&requestAnimationFrame(()=>{e.focus()})}setFlexEndToFooterIfNoKeyboardIcon(){let e=this.core.getFooter();!this.core.options.ui.enableSwitchIcon&&e&&(e.style.justifyContent=`flex-end`)}destroy(){this.clearAllTimeouts(),!yM()&&!this.core.options.ui.inline?.enabled&&(document.body.style.overflowY=this.originalOverflow||``,document.body.style.paddingRight=this.originalPaddingRight||``),this.clearExistingModal()}},qM=(e,t,n,r)=>{let i={hour:`12`,minutes:`00`,type:t===`24h`?void 0:`PM`};if(!e)return i;let a=e.value.trim();if(!n&&!a)return i;if(typeof n==`boolean`&&n){let[e,n]=new Date().toLocaleTimeString().split(`:`),r=e.padStart(2,`0`);if(/[a-z]/i.test(n)&&t===`12h`){let[e,t]=n.split(` `);return{hour:r,minutes:e,type:t}}return{hour:r,minutes:n,type:void 0}}if(typeof n==`object`){let{time:e,locales:i,preventClockType:a}=n,o=e??new Date;if(a&&r){let[e,t]=new Date(o).toLocaleTimeString().split(`:`);if(/[a-z]/i.test(t)){let[n,r]=t.split(` `);return{hour:e,minutes:n,type:r}}return{hour:e.padStart(2,`0`),minutes:t,type:void 0}}let[s,c]=new Date(o).toLocaleTimeString(i||`en-US`,{hour:`2-digit`,minute:`2-digit`,hour12:t===`12h`}).split(`:`);if(t===`12h`&&/[a-z]/i.test(c)){let e=c.trim().split(` `);return{hour:s,minutes:e[0],type:e[1]||`AM`}}return{hour:s,minutes:c.replace(/\D/g,``),type:void 0}}let[o,s]=a.split(` `),[c=``,l=``]=o.split(`:`),u=c.replace(/\D/g,``),d=l.replace(/\D/g,``),f={hour:u.padStart(2,`0`),minutes:d.padStart(2,`0`),type:t===`12h`?s:void 0};if(u.length>2||d.length>2)return{...f,error:`Invalid input: too many digits.`,currentHour:c,currentMin:l};if(/[a-z]/i.test(o))return{...f,error:`Input contains invalid letters.`};if(a.includes(` `)&&(!s||a.length>8||s!==`AM`&&s!==`PM`))return{...f,error:`Invalid AM/PM format or length.`,currentLength:a.length,currentType:s};let p=Number(u),m=Number(d);if(t===`12h`){if(p<1||p>12||m<0||m>59||s!==`AM`&&s!==`PM`)return{...f,error:`Invalid 12h time.`,currentHour:p,currentMin:m,currentType:s}}else if(p<0||p>23||m<0||m>59)return{...f,error:`Invalid 24h time.`,currentHour:p,currentMin:m};return f},JM=(e,t,n)=>{let r=Number(e);if(Number.isNaN(r))return!1;switch(t){case`hour`:return n===`24h`?r>=0&&r<=23:r>0&&r<=12;case`minutes`:return r>=0&&r<=59;default:return}},YM=`tp-ui`,XM=`mousedown mouseup mousemove mouseleave mouseover touchstart touchmove touchend`,ZM=`active`,QM=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}isCurrentTimeEnabled(e){let t=this.core.options.clock.currentTime;return typeof t==`boolean`?t:!!t?.[e]}preventClockTypeByCurrentTime(){if(!this.isCurrentTimeEnabled(`preventClockType`))return;let e=this.core.getInput();if(!e)return;let{currentTime:t,clockType:n}={currentTime:this.core.options.clock.currentTime,clockType:this.core.options.clock.type},{type:r}=qM(e,n,t,!0);this.core.updateOptions({clock:{type:r?`12h`:`24h`}})}updateInputValueWithCurrentTimeOnStart(){if(!this.isCurrentTimeEnabled(`updateInput`))return;let e=this.core.getInput();if(!e)return;let{hour:t,minutes:n,type:r}=qM(e,this.core.options.clock.type,this.core.options.clock.currentTime);e.value=r?`${t}:${n} ${r}`:`${t}:${n}`}getInputValueOnOpenAndSet(){let e=this.core.getInput();if(!e)return;let t=qM(e,this.core.options.clock.type,this.core.options.clock.currentTime),n=this.core.getHour(),r=this.core.getMinutes(),i=this.core.getActiveTypeMode(),a=this.core.getAM();if(t===void 0){n&&(n.value=`12`),r&&(r.value=`00`);let e={hour:n?.value||`12`,minutes:r?.value||`00`,type:i?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit(`open`,e);let t=this.core.options.range?.enabled===!0;this.core.options.clock.type!==`24h`&&a&&!t&&a.classList.add(ZM);return}let[o,s,c]=e.value.split(`:`).join(` `).split(` `);e.value.length===0&&(o=t.hour,s=t.minutes,c=t.type),this.core.options.clock.type!==`24h`&&!c&&(c=t.type||`AM`),n&&(n.value=o.padStart(2,`0`)),r&&(r.value=s.padStart(2,`0`));let l=this.core.getModalElement()?.querySelector(`[data-type='${c}']`);this.core.options.clock.type!==`24h`&&l&&l.classList.add(ZM);let u={...t,type:i?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit(`open`,u)}getInputValue(e,t,n){return qM(e,t,n)}destroy(){}},$M=class{core;emitter;isAnimating=!1;constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on(`switch:view`,()=>{this.toggleMobileClockFace()})}checkMobileOption(){this.core.setIsMobileView(!!this.core.options.ui.mobile),this.core.options.ui.mobile&&this.core.updateOptions({ui:{editable:!0}})}toggleMobileClockFace(){if(this.isAnimating)return;let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(`.tp-ui-wrapper`),n=this.core.getKeyboardClockIcon(),r=e.querySelector(`.tp-ui-mobile-clock-wrapper`),i=e.querySelectorAll(`*`),a=e.querySelector(`.tp-ui-select-time`),o=this.core.getHour(),s=this.core.getMinutes(),c=this.core.getClockFace();if(!t)return;let l=t.classList.contains(`expanded`),u=this.core.isMobileView;l?this.collapseClockFace(t,r,i,n,a,o,s,c,u):this.expandClockFace(t,r,i,n,a,o,s,c)}collapseClockFace(e,t,n,r,i,a,o,s,c){if(this.isAnimating=!0,typeof requestAnimationFrame<`u`){let l=typeof window<`u`&&window.matchMedia(`(orientation: landscape) and (min-width: 320px) and (max-width: 825px)`).matches;requestAnimationFrame(()=>{l&&e instanceof HTMLElement?this.collapseLandscape(e,t,n,r,i,a,o,s,c):this.collapsePortrait(e,t,n,r,i,a,o,s,c)})}else this.switchView(i,r,a,o,!0),this.isAnimating=!1;r?.setAttribute(`aria-label`,`Show clock face`),r?.setAttribute(`aria-pressed`,`false`)}collapseLandscape(e,t,n,r,i,a,o,s,c){s?.classList.remove(`scale-in`);let l=this.core.getModalElement(),u=this.getMobileLandscapeHeight(l);e.style.width=`328px`,e.style.height=u,t instanceof HTMLElement&&(t.style.height=`0`,t.style.opacity=`0`,t.style.transform=`scale(0)`),setTimeout(()=>{this.applyMobileClasses(e,t,n,i,c),e.classList.add(`mobile`),t&&t.classList.add(`mobile`),this.switchView(i,r,a,o,!0),requestAnimationFrame(()=>{e.style.width=``,e.style.height=``,t instanceof HTMLElement&&(t.style.height=``,t.style.opacity=``,t.style.transform=``),this.isAnimating=!1})},SM.WRAPPER_TRANSITION)}collapsePortrait(e,t,n,r,i,a,o,s,c){c?s?.classList.remove(`scale-in`):s?.classList.add(`scale-in`),t?.classList.remove(`expanded`),c&&t?.classList.add(`mobile`),requestAnimationFrame(()=>{this.applyMobileClasses(e,t,n,i,c),this.switchView(i,r,a,o,!0),setTimeout(()=>{this.isAnimating=!1},SM.MOBILE_TOGGLE)})}applyMobileClasses(e,t,n,r,i){e.classList.remove(`expanded`),t?.classList.remove(`expanded`),i&&(e.classList.add(`mobile`),t?.classList.add(`mobile`)),n.forEach(n=>{n!==t&&n!==e&&n!==r&&(n.classList.remove(`expanded`),i&&n.classList.add(`mobile`))}),r&&(r.classList.remove(`expanded`),i&&r.classList.add(`mobile`))}expandClockFace(e,t,n,r,i,a,o,s){this.isAnimating=!0,o?.classList.contains(`active`)&&o?this.emitter.emit(`select:minute`,{minutes:o.value}):a&&this.emitter.emit(`select:hour`,{hour:a.value}),n.forEach(n=>{n!==t&&n!==e&&n!==i&&(n.classList.remove(`mobile`),n.classList.add(`expanded`))}),i&&(i.classList.remove(`mobile`),i.classList.add(`expanded`)),this.switchView(i,r,a,o,!1),typeof requestAnimationFrame<`u`?requestAnimationFrame(()=>{e.classList.remove(`mobile`),e.classList.add(`expanded`),requestAnimationFrame(()=>{t&&(t.classList.remove(`mobile`),t.classList.add(`expanded`)),s&&s.classList.remove(`scale-in`),setTimeout(()=>{s&&s.classList.add(`scale-in`)},SM.CLOCK_SCALE_DELAY),setTimeout(()=>{this.isAnimating=!1},SM.MOBILE_TOGGLE)})}):this.isAnimating=!1,r?.setAttribute(`aria-label`,`Hide clock face`),r?.setAttribute(`aria-pressed`,`true`)}switchView(e,t,n,r,i){let a=this.core.getModalElement(),o=a?.querySelector(`.tp-ui-hour-text`),s=a?.querySelector(`.tp-ui-minute-text`),c=t?.querySelector(`.tp-ui-keyboard-icon`),l=this.core.getInputWrappers(),u=this.core.getHeader(),d=a?.querySelector(`.tp-ui-wrapper-type-time`),f=a?.querySelector(`.tp-ui-am`),p=a?.querySelector(`.tp-ui-pm`),m=a?.querySelectorAll(`.tp-ui-input-ripple-wrapper`),{iconTemplate:h,iconTemplateMobile:g}=this.core.options.ui,{time:_,mobileTime:v}=this.core.options.labels;i?(e?.classList.add(`mobile`),t?.classList.add(`mobile`),n?.classList.add(`mobile`),n?.removeAttribute(`readonly`),r?.classList.add(`mobile`),r?.removeAttribute(`readonly`),o?.classList.add(`mobile`),s?.classList.add(`mobile`),u?.classList.add(`mobile`),d?.classList.add(`mobile`),f?.classList.add(`mobile`),f?.classList.remove(`tp-ui-ripple`),p?.classList.add(`mobile`),p?.classList.remove(`tp-ui-ripple`),l?.forEach(e=>{e.classList.add(`mobile`)}),m?.forEach(e=>{e.classList.add(`mobile`)}),e&&v&&(e.textContent=v),c&&(c.innerHTML=g||NM),this.updateClockFaceAccessibility(!0)):(e?.classList.remove(`mobile`),t?.classList.remove(`mobile`),n?.classList.remove(`mobile`),r?.classList.remove(`mobile`),this.core.options.ui.editable||(n?.setAttribute(`readonly`,``),r?.setAttribute(`readonly`,``)),o?.classList.remove(`mobile`),s?.classList.remove(`mobile`),u?.classList.remove(`mobile`),d?.classList.remove(`mobile`),f?.classList.remove(`mobile`),f?.classList.add(`tp-ui-ripple`),p?.classList.remove(`mobile`),p?.classList.add(`tp-ui-ripple`),l?.forEach(e=>{e.classList.remove(`mobile`)}),m?.forEach(e=>{e.classList.remove(`mobile`)}),e&&_&&(e.textContent=_),c&&(c.innerHTML=h||MM),this.updateClockFaceAccessibility(!1))}updateClockFaceAccessibility(e){let t=this.core.getClockFace();if(!t)return;let n=t.querySelector(`.tp-ui-tips-wrapper`),r=t.querySelector(`.tp-ui-tips-wrapper-24h`),i=t.querySelectorAll(`.tp-ui-tip`);e?(t.setAttribute(`aria-hidden`,`true`),n?.setAttribute(`aria-hidden`,`true`),r?.setAttribute(`aria-hidden`,`true`),i.forEach(e=>{e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-hidden`,`true`)})):(t.removeAttribute(`aria-hidden`),n?.removeAttribute(`aria-hidden`),r?.removeAttribute(`aria-hidden`),i.forEach(e=>{e.setAttribute(`tabindex`,`0`),e.removeAttribute(`aria-hidden`)}))}getMobileLandscapeHeight(e){return e?.classList.contains(`tp-ui-tz-mode`)?`326px`:e?.classList.contains(`tp-ui-range-mode`)?`287px`:`258px`}destroy(){}},eN=e=>{if(!e)return;let{disabledTime:t,type:n}=e.clock;if(!t||!Object.keys(t).length)return;let{hours:r,minutes:i,interval:a}=t;if(a){delete t.hours,delete t.minutes;let e=Array.isArray(a)?a:[a];if(!n)throw Error(`clockType required for interval`);return AM(e,n),{value:e.map(e=>{let[t,r]=e.trim().split(`-`),{hour:i,minutes:a,type:o}=qM({value:t.trim()},n),{hour:s,minutes:c,type:l}=qM({value:r.trim()},n),u=EM(i,s).map(e=>Number(e)===0?`00`:String(Number(e))),d=[],f=Number(a),p=Number(c);if(l===o)return f>0&&p<=0?(d.push(u[0],u[u.length-1]),u=u.slice(1,-1)):p<59&&p>0&&f<=0?(d.push(void 0,u[u.length-1]),u=u.slice(0,-1)):p>0&&f>0?(d.push(u[0],u[u.length-1]),u=u.slice(1,-1)):p===0&&f===0&&(d.push(void 0,u[u.length-1]),u.pop()),{removedStartedHour:d[0]!==void 0&&Number(d[0])<=9?`0${d[0]}`:d[0],removedEndHour:d[1]!==void 0&&Number(d[1])<=9?`0${d[1]}`:d[1],rangeArrHour:u,startMinutes:EM(a,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:DM(0,c).map(e=>Number(e)<=9?`0${e}`:`${e}`),startType:o,endType:l};{let e=EM(i,12).map(String),t=DM(1,s).map(String),n=[],r=[];return f>0&&p<=0?(r.push(t[t.length-1]),n.push(e[0]),t.pop(),e.shift()):p<59&&p>0&&f<=0?(n.push(e[0]),r.push(t[t.length-1]),t.pop()):p>0&&f>0?(r.push(t[t.length-1]),n.push(e[0]),t.pop(),e.shift()):p===0&&f===0&&(r.push(t[t.length-1]),n.push(e[0]),t.pop()),{startType:o,endType:l,amHours:e,pmHours:t,removedAmHour:n[0]&&Number(n[0])<=9?`0${n[0]}`:n[0],removedPmHour:r[0]&&Number(r[0])<=9?`0${r[0]}`:r[0],startMinutes:Number(a)===0?[]:EM(a,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:DM(0,c).map(e=>Number(e)<=9?`0${e}`:`${e}`)}}}).reduce((e,t)=>(Object.entries(t).forEach(([t,n])=>{Array.isArray(n)?e[t]=Array.isArray(e[t])?[...e[t],...n]:[...n]:e[t]=n}),e),{isInterval:!0,clockType:n,intervals:e})}}return r?.forEach(e=>{if(n===`12h`&&Number(e)>12)throw Error(`The disabled hours value has to be less than 13`);if(n===`24h`&&Number(e)>23)throw Error(`The disabled hours value has to be less than 24`)}),i?.forEach(e=>{if(Number(e)>59)throw Error(`The disabled minutes value has to be less than 60`)}),{value:{hours:r?.map(e=>e===`00`||Number(e)===0?`0${Number(e)}`:`${Number(e)}`),minutes:i?.map(e=>Number(e)<=9?`0${e}`:`${e}`)}}},tN=(e,t,n,r)=>{if(e){if(Array.isArray(e)&&e.length>0)return!e.map(e=>JM(e,t,n)).some(e=>e===!1);if(typeof e==`string`||typeof e==`number`){let i=JM(e,t,n),a=r?.map(Number).includes(Number(e));return!!(i&&!a)}}},nN=class{core;constructor(e){this.core=e}getDisableTime(){let e=eN(this.core.options);this.core.setDisabledTime(e||null)}destroy(){}},rN=class{inputValueHandler;mobileViewHandler;disabledTimeHandler;core;constructor(e,t){this.core=e,this.inputValueHandler=new QM(e,t),this.mobileViewHandler=new $M(e,t),this.disabledTimeHandler=new nN(e)}preventClockTypeByCurrentTime(){this.inputValueHandler.preventClockTypeByCurrentTime()}updateInputValueWithCurrentTimeOnStart(){this.inputValueHandler.updateInputValueWithCurrentTimeOnStart()}getInputValueOnOpenAndSet(){this.inputValueHandler.getInputValueOnOpenAndSet()}getInputValue(e,t,n){return this.inputValueHandler.getInputValue(e,t,n)}checkMobileOption(){this.mobileViewHandler.checkMobileOption()}toggleMobileClockFace(){this.mobileViewHandler.toggleMobileClockFace()}updateClockFaceAccessibility(e){this.mobileViewHandler.updateClockFaceAccessibility(e)}getDisableTime(){this.disabledTimeHandler.getDisableTime()}destroy(){this.inputValueHandler.destroy(),this.mobileViewHandler.destroy(),this.disabledTimeHandler.destroy()}},iN=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setTheme(){let e=this.core.getModalElement();if(!e)return;let{theme:t}=this.core.options.ui;t&&e.setAttribute(`data-theme`,t)}setInputClassToInputElement(){let e=this.core.getInput();e&&(TM(e,`tp-ui-input`)||e.classList.add(`tp-ui-input`))}setDataOpenToInputIfDoesntExistInWrapper(){let e=this.core.getOpenElementData(),t=this.core.getInput();e===null&&t&&t.setAttribute(`data-open`,`tp-ui-input`)}setClassTopOpenElement(){let e=this.core.getOpenElement();for(let t of e)t&&t.classList.add(`tp-ui-open-element`)}setTimepickerClassToElement(){let e=this.core.element;if(!e)return;e.classList.add(YM);let t=this.core.options.ui.cssClass;t&&t!==YM&&e.classList.add(t)}destroy(){let e=this.core.getModalElement();e&&e.removeAttribute(`data-theme`)}},aN=class e extends Error{constructor(t,n){super(`[TimepickerUI] ${t}`),this.code=n,this.name=`TimepickerError`,Object.setPrototypeOf(this,e.prototype)}},oN={ELEMENT_NOT_FOUND:`ELEMENT_NOT_FOUND`,INVALID_PARAMETER:`INVALID_PARAMETER`,NO_INPUT_ELEMENT:`NO_INPUT_ELEMENT`,INSTANCE_DESTROYED:`INSTANCE_DESTROYED`,NOT_INITIALIZED:`NOT_INITIALIZED`,INVALID_TIME_FORMAT:`INVALID_TIME_FORMAT`,INLINE_CONFIG_ERROR:`INLINE_CONFIG_ERROR`,CONTAINER_NOT_FOUND:`CONTAINER_NOT_FOUND`,SSR_ENVIRONMENT:`SSR_ENVIRONMENT`},sN=class{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setErrorHandler(){let e=this.core.getInput();if(!e)return!0;let{error:t,currentHour:n,currentMin:r,currentType:i,currentLength:a}=qM(e,this.core.options.clock.type);if(this.removeErrorHandler(),t){if(bM()===!1)return!1;let o=document.createElement(`div`);o.classList.add(`tp-ui-invalid-text`),o.innerHTML=`<b>Invalid Time Format</b>`,e.classList.add(`tp-ui-invalid-format`),e.nextElementSibling?.classList.contains(`tp-ui-invalid-text`)||e.after(o);let s={error:t,rejectedHour:void 0,rejectedMinute:void 0,inputHour:n,inputMinute:r,inputType:i,inputLength:a};return this.emitter.emit(`error`,s),!1}return!0}removeErrorHandler(){let e=this.core.getInput();if(!e)return;e.classList.remove(`tp-ui-invalid-format`);let t=e.nextElementSibling;t?.classList.contains(`tp-ui-invalid-text`)&&t.remove()}checkDisabledValuesOnStart(){if(!this.core.options.clock.disabledTime)return;let{disabledTime:e,type:t}=this.core.options.clock;if(e.interval){if(!t)throw new aN(`clockType is required when using disabledTime.interval`,oN.INVALID_PARAMETER);let n=Array.isArray(e.interval)?e.interval:[e.interval];try{AM(n,t)}catch(e){throw new aN(`Invalid disabledTime.interval: ${e.message}`,oN.INVALID_PARAMETER)}return}let{hours:n,minutes:r}=e,i=n?tN(n,`hour`,t):!0,a=r?tN(r,`minutes`,t):!0;if(!i||!a)throw new aN(`Invalid hours or minutes in disabledTime option`,oN.INVALID_PARAMETER)}destroy(){this.removeErrorHandler()}},cN=(e,t)=>{if(!e)return;let n=e.querySelector(`.timepicker-announcer`);n&&(n.textContent=``,setTimeout(()=>{n.textContent=t},100))},lN=(e,t)=>{e&&e.setAttribute(`aria-pressed`,String(t))},uN=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleOpenOnClick(){let e=this.core.getOpenElement();if(!e)return;let t=e=>{this.core.isDestroyed||e.currentTarget?.classList.contains(`disabled`)||this.emitter.emit(`show`,{})};e.forEach(e=>{e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))})}handleCancelButton(){let e=this.core.getCancelButton();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit(`cancel`,{})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handleOkButton(){let e=this.core.getOkButton();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let e=this.core.getHour(),t=this.core.getMinutes();if(e&&t){let n=this.core.getActiveTypeMode();this.emitter.emit(`confirm`,{hour:e.value,minutes:t.value,type:n?.textContent||void 0});return}let n=this.core.getModalElement();if(n){let e=n.querySelector(`.tp-ui-wheel-hours .tp-ui-wheel-item.is-center`),t=n.querySelector(`.tp-ui-wheel-minutes .tp-ui-wheel-item.is-center`),r=n.querySelector(`.tp-ui-wheel-ampm .tp-ui-wheel-item.is-center`);this.emitter.emit(`confirm`,{hour:e?.getAttribute(`data-value`)??void 0,minutes:t?.getAttribute(`data-value`)??void 0,type:r?.getAttribute(`data-value`)??void 0})}};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handleAmClick(){let e=this.core.getAM();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let t=this.core.getPM();e.classList.add(`active`),t?.classList.remove(`active`),lN(e,!0),lN(t,!1),cN(this.core.getModalElement(),`AM selected`),this.emitter.emit(`select:am`,{});let n=this.core.getHour(),r=this.core.getMinutes();this.emitter.emit(`update`,{hour:n?.value,minutes:r?.value,type:`AM`})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handlePmClick(){let e=this.core.getPM();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;let t=this.core.getAM();e.classList.add(`active`),t?.classList.remove(`active`),lN(e,!0),lN(t,!1),cN(this.core.getModalElement(),`PM selected`),this.emitter.emit(`select:pm`,{});let n=this.core.getHour(),r=this.core.getMinutes();this.emitter.emit(`update`,{hour:n?.value,minutes:r?.value,type:`PM`})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handleSwitchViewButton(){let e=this.core.getKeyboardClockIcon();if(!e)return;let t=()=>{this.core.isDestroyed||this.emitter.emit(`switch:view`,{})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},dN=(e,t,n)=>Math.max(t,Math.min(n,e)),fN=(e,t)=>{if(e===``)return``;let n=parseInt(e,10);return Number.isNaN(n)?``:dN(n,+!!t,t?12:23).toString().padStart(2,`0`)},pN=e=>{if(e===``)return``;let t=parseInt(e,10);return Number.isNaN(t)?``:dN(t,0,59).toString().padStart(2,`0`)},mN=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleHourEvents(){let e=this.core.getHour();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;e.classList.add(`active`);let t=this.core.getMinutes();t?.classList.remove(`active`),this.emitter.emit(`select:hour`,{hour:e.value});let n=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:e.value,minutes:t?.value,type:n?.textContent||void 0})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t));let n=e.value,r=()=>{if(this.core.isDestroyed||e.hasAttribute(`readonly`))return;let t=this.core.options.clock.type===`12h`,r=fN(e.value,t);if(e.value=r,e.setAttribute(`aria-valuenow`,r),e.value!==n){n=e.value,this.emitter.emit(`animation:clock`,{}),this.emitter.emit(`select:hour`,{hour:e.value});let t=this.core.getMinutes(),r=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:e.value,minutes:t?.value,type:r?.textContent||void 0})}};e.addEventListener(`blur`,r),this.cleanupHandlers.push(()=>e.removeEventListener(`blur`,r))}handleMinutesEvents(){let e=this.core.getMinutes();if(!e)return;let t=()=>{if(this.core.isDestroyed)return;e.classList.add(`active`);let t=this.core.getHour();t?.classList.remove(`active`),this.emitter.emit(`select:minute`,{minutes:e.value});let n=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:t?.value,minutes:e.value,type:n?.textContent||void 0})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t));let n=e.value,r=()=>{if(this.core.isDestroyed||e.hasAttribute(`readonly`))return;let t=pN(e.value);if(e.value=t,e.setAttribute(`aria-valuenow`,t),e.value!==n){n=e.value,this.emitter.emit(`animation:clock`,{}),this.emitter.emit(`select:minute`,{minutes:e.value});let t=this.core.getHour(),r=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:t?.value,minutes:e.value,type:r?.textContent||void 0})}};e.addEventListener(`blur`,r),this.cleanupHandlers.push(()=>e.removeEventListener(`blur`,r))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},hN=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleOpenOnEnterFocus(){let e=this.core.getInput();if(!e)return;let t=e=>{e.key===`Enter`&&!this.core.isDestroyed&&!this.core.isOpen&&this.emitter.emit(`show`,{})};e.addEventListener(`keydown`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`keydown`,t))}handleEscClick(){if(bM()===!1)return;let e=e=>{this.core.isDestroyed||e.key===`Escape`&&this.emitter.emit(`cancel`,{})};document.addEventListener(`keydown`,e),this.cleanupHandlers.push(()=>document.removeEventListener(`keydown`,e))}handleKeyboardInput(){let e=this.core.getHour(),t=this.core.getMinutes();if(e){let t=t=>{if(this.core.isDestroyed||t.key!==`ArrowUp`&&t.key!==`ArrowDown`)return;t.preventDefault();let n=parseInt(e.value)||0,r=parseInt(e.getAttribute(`max`)||`23`),i=this.core.options.clock.type===`12h`,a;a=t.key===`ArrowUp`?i?n>=12?1:n+1:n>=r?0:n+1:i?n<=1?12:n-1:n<=0?r:n-1,e.value=a.toString().padStart(2,`0`),e.setAttribute(`aria-valuenow`,e.value),cN(this.core.getModalElement(),`Hour: ${e.value}`),this.emitter.emit(`animation:clock`,{}),this.emitter.emit(`select:hour`,{hour:e.value});let o=this.core.getMinutes(),s=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:e.value,minutes:o?.value,type:s?.textContent||void 0})};e.addEventListener(`keydown`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`keydown`,t))}if(t){let e=e=>{if(this.core.isDestroyed||e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;e.preventDefault();let n=parseInt(t.value)||0,r;r=e.key===`ArrowUp`?n>=59?0:n+1:n<=0?59:n-1,t.value=r.toString().padStart(2,`0`),t.setAttribute(`aria-valuenow`,t.value),cN(this.core.getModalElement(),`Minutes: ${t.value}`),this.emitter.emit(`animation:clock`,{}),this.emitter.emit(`select:minute`,{minutes:t.value});let i=this.core.getHour(),a=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:i?.value,minutes:t.value,type:a?.textContent||void 0})};t.addEventListener(`keydown`,e),this.cleanupHandlers.push(()=>t.removeEventListener(`keydown`,e))}}focusTrapHandler(){if(bM()===!1)return;let e=this.core.getWrapper();if(!e)return;let t=t=>{if(this.core.isDestroyed||t.key!==`Tab`)return;let n=e.querySelectorAll(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`),r=n[0],i=n[n.length-1];t.shiftKey&&document.activeElement===r?(i?.focus(),t.preventDefault()):!t.shiftKey&&document.activeElement===i&&(r?.focus(),t.preventDefault())};e.addEventListener(`keydown`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`keydown`,t))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},gN=class{core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleBackdropClick(){let e=this.core.getModalElement();if(!e)return;let t=t=>{this.core.isDestroyed||t.target===e&&this.emitter.emit(`cancel`,{})};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t))}handleMoveHand(){if(bM()===!1)return;let e=e=>{this.core.isDestroyed||e.preventDefault()};document.addEventListener(`mousedown`,e,!1),document.addEventListener(`touchstart`,e,{passive:!1}),this.cleanupHandlers.push(()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)})}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},_N=class{buttonHandlers;inputHandlers;keyboardHandlers;modalHandlers;constructor(e,t){this.buttonHandlers=new uN(e,t),this.inputHandlers=new mN(e,t),this.keyboardHandlers=new hN(e,t),this.modalHandlers=new gN(e,t)}handleOpenOnClick(){this.buttonHandlers.handleOpenOnClick()}handleOpenOnEnterFocus(){this.keyboardHandlers.handleOpenOnEnterFocus()}handleCancelButton(){this.buttonHandlers.handleCancelButton()}handleOkButton(){this.buttonHandlers.handleOkButton()}handleBackdropClick(){this.modalHandlers.handleBackdropClick()}handleEscClick(){this.keyboardHandlers.handleEscClick()}handleAmClick(){this.buttonHandlers.handleAmClick()}handlePmClick(){this.buttonHandlers.handlePmClick()}handleHourEvents(){this.inputHandlers.handleHourEvents()}handleMinutesEvents(){this.inputHandlers.handleMinutesEvents()}handleKeyboardInput(){this.keyboardHandlers.handleKeyboardInput()}focusTrapHandler(){this.keyboardHandlers.focusTrapHandler()}handleMoveHand(){this.modalHandlers.handleMoveHand()}handleSwitchViewButton(){this.buttonHandlers.handleSwitchViewButton()}destroy(){this.buttonHandlers.destroy(),this.inputHandlers.destroy(),this.keyboardHandlers.destroy(),this.modalHandlers.destroy()}},vN=class{emitter;getClockSystem;setHoursToClock;setMinutesToClock;updateAmPm;convertDisabledTime;constructor(e,t,n,r,i,a){this.emitter=e,this.getClockSystem=t,this.setHoursToClock=n,this.setMinutesToClock=r,this.updateAmPm=i,this.convertDisabledTime=a}setup(){this.emitter.on(`select:hour`,({hour:e})=>{this.emitter.emit(`animation:clock`,{}),this.setHoursToClock(e||null)}),this.emitter.on(`select:minute`,({minutes:e})=>{this.emitter.emit(`animation:clock`,{}),this.setMinutesToClock(e||null)}),this.emitter.on(`select:am`,()=>{this.updateAmPm()}),this.emitter.on(`select:pm`,()=>{this.updateAmPm()}),this.emitter.on(`animation:start`,()=>{this.getClockSystem()?.blockInteractions()}),this.emitter.on(`animation:end`,()=>{this.getClockSystem()?.unblockInteractions()}),this.emitter.on(`range:switch`,e=>{this.refreshDisabledTimeForRange(e.disabledTime)})}refreshDisabledTimeForRange(e){let t=this.getClockSystem();if(!t)return;let n=this.convertDisabledTime(),r=n;if(e){let t=[...n?.hours||[],...e.hours||[]],i=[...n?.minutes||[],...e.minutes||[]];r={...n,hours:t.length>0?t:void 0,minutes:i.length>0?i:void 0,rangeFromType:e.fromType,rangeFromHour:e.fromHour}}t.updateDisabledTime(r)}},yN=class{static angleToIndex(e,t,n){let r=Math.round(e/30)%12;if(t===`24h`)if(n){let e=r+12;return e===12?0:e}else return r===0?12:r;return r===0?12:r}static indexToValue(e,t){if(t===`24h`)return e.toString().padStart(2,`0`);let n=e;return n===0&&(n=12),n>12&&(n-=12),n.toString().padStart(2,`0`)}static indexToAngle(e,t){return t===`24h`?e>=12?(e-12)%12*30:e%12*30:(e===0?12:e)%12*30}static isDisabled(e,t,n){return n?n.isInterval&&n.intervals&&n.clockType?this.isDisabledByInterval(e,t,n):n.rangeFromType!==void 0&&n.rangeFromHour!==void 0?this.isDisabledForRange12h(e,t,n):n.hours?n.hours.some(t=>String(t)===e||Number(t)===Number(e)||t===e):!1:!1}static isDisabledForRange12h(e,t,n){let r=n.rangeFromType,i=n.rangeFromHour,a=parseInt(e,10);return r===null||i===void 0?!1:t===`AM`&&r===`PM`?!0:t===`AM`&&r===`AM`?i===12?!1:a===12?!0:a<i:t===`PM`&&r===`AM`?!1:t===`PM`&&r===`PM`?i===12?!1:a===12?!0:a<i:!1}static isDisabledByInterval(e,t,n){if(!n.intervals)return!1;for(let r=0;r<60;r++){let i=r.toString().padStart(2,`0`);if(!this.isTimeInIntervals(e,i,t,n.intervals,n.clockType))return!1}return!0}static isTimeInIntervals(e,t,n,r,i){let a=i===`12h`?`${e}:${t} ${n}`:`${e}:${t}`;for(let e of r){let[t,n]=e.split(`-`).map(e=>e.trim());if(this.isTimeBetween(a,t,n,i))return!0}return!1}static isTimeBetween(e,t,n,r){let i=this.timeToMinutes(e,r),a=this.timeToMinutes(t,r),o=this.timeToMinutes(n,r);return i>=a&&i<=o}static timeToMinutes(e,t){if(t===`12h`){let t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!t)return 0;let n=parseInt(t[1]),r=parseInt(t[2]),i=t[3].toUpperCase();return i===`PM`&&n!==12&&(n+=12),i===`AM`&&n===12&&(n=0),n*60+r}else{let[t,n]=e.split(`:`).map(Number);return t*60+n}}static findNearestValid(e,t,n,r){let i=t===`24h`?23:12;for(let a=0;a<=i;a++){let o=a===0?[e]:[e+a,e-a];for(let e of o){let a=e;a<0&&(a+=i+1),a>i&&(a%=i+1);let o=this.indexToValue(a,t);if(!this.isDisabled(o,n,r))return a}}return e}},bN=class{static angleToIndex(e){return Math.round(e/6)%60}static indexToValue(e){return e.toString().padStart(2,`0`)}static indexToAngle(e){return e%60*6}static isDisabled(e,t,n,r,i){return r?r.isInterval&&r.intervals?this.isDisabledByInterval(e,t,n,r,i):r.rangeFromType!==void 0&&r.rangeFromHour!==void 0?this.isDisabledForRange12h(e,t,n,r):r.rangeFromHour!==void 0&&parseInt(t,10)!==r.rangeFromHour?!1:r.minutes?r.minutes.some(t=>String(t)===e||Number(t)===Number(e)||t===e):!1:!1}static isDisabledForRange12h(e,t,n,r){let i=r.rangeFromType,a=r.rangeFromHour,o=parseInt(t,10),s=parseInt(e,10);if(i===null||a===void 0)return!1;let c=r.minutes||[],l=c.length>0?parseInt(c[c.length-1],10)+1:0;return n===`AM`&&i===`PM`?!0:n===`PM`&&i===`AM`?!1:o===a||o===12&&a===12||n===i&&o===a?s<l:!1}static isDisabledByInterval(e,t,n,r,i){if(!r.intervals)return!1;let a=i===`12h`?`${t}:${e} ${n}`:`${t}:${e}`;for(let e of r.intervals){let[t,n]=e.split(`-`).map(e=>e.trim());if(this.isTimeBetween(a,t,n,i))return!0}return!1}static isTimeBetween(e,t,n,r){let i=this.timeToMinutes(e,r),a=this.timeToMinutes(t,r),o=this.timeToMinutes(n,r);return i>=a&&i<=o}static timeToMinutes(e,t){if(t===`12h`){let t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!t)return 0;let n=parseInt(t[1]),r=parseInt(t[2]),i=t[3].toUpperCase();return i===`PM`&&n!==12&&(n+=12),i===`AM`&&n===12&&(n=0),n*60+r}else{let[t,n]=e.split(`:`).map(Number);return t*60+n}}static findNearestValid(e,t,n,r,i){for(let a=0;a<60;a++){let o=a===0?[e]:[e+a,e-a];for(let e of o){let a=e;a<0&&(a+=60),a>=60&&(a%=60);let o=this.indexToValue(a);if(!this.isDisabled(o,t,n,r,i))return a}}return e}},xN=class{static normalizeAngle(e){let t=e%360;return t<0&&(t+=360),t}static calculateRawAngle(e,t){let n=e.x-t.x,r=e.y-t.y,i=Math.atan2(r,n)*180/Math.PI+90;return this.normalizeAngle(i)}static snapToIncrement(e,t){let n=Math.round(e/t)*t;return this.normalizeAngle(n)}static calculateDistance(e,t){let n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}static isInnerCircle(e,t){return e<t*.75}static calculateShortestPath(e,t){let n=this.normalizeAngle(e),r=this.normalizeAngle(t)-n,i=r>=0?r:r+360,a=r<=0?r:r-360;return e+(Math.abs(i)<Math.abs(a)?i:a)}},SN=class{config;currentAngle=0;tipsCache=new Map;cachedDimensions=new Map;constructor(e){this.config=e}getCachedDimensions(e){let t=this.cachedDimensions.get(e);if(!t){let n=(e.offsetWidth-32)/2;t={width:n,height:(e.offsetHeight-32)/2,radius:n-9},this.cachedDimensions.set(e,t)}return t}setHandAngle(e){let t=xN.calculateShortestPath(this.currentAngle,e);Math.abs(this.currentAngle-t)<.01||(this.currentAngle=t,this.config.clockHand.style.transform=`rotateZ(${t}deg)`)}animateToAngle(e){let t=xN.calculateShortestPath(this.currentAngle,e);this.currentAngle=t,this.config.tipsWrapper.classList.add(`tp-ui-tips-animation`),this.config.clockHand.style.transform=`rotateZ(${t}deg)`,setTimeout(()=>{this.config.tipsWrapper.classList.remove(`tp-ui-tips-animation`)},401)}setActiveValue(e){let t=[this.config.tipsWrapper];this.config.tipsWrapperFor24h&&t.push(this.config.tipsWrapperFor24h),t.forEach(t=>{t.querySelectorAll(`.tp-ui-value-tips, .tp-ui-value-tips-24h`).forEach(t=>{let n=t;n.textContent===e||Number(n.textContent)===Number(e)?(n.classList.add(`active`),n.setAttribute(`aria-selected`,`true`)):(n.classList.remove(`active`),n.setAttribute(`aria-selected`,`false`))})})}renderTips(e,t,n,r,i,a=!0,o,s=``,c=`12`){if(bM()===!1)return;let l=o||this.config.tipsWrapper;a&&(l.innerHTML=``,this.tipsCache.clear());let{width:u,height:d,radius:f}=this.getCachedDimensions(l),p=document.createDocumentFragment(),m=`${t}-${this.config.theme||`default`}`;e.forEach((a,o)=>{let l=`${m}-${a}`,h=this.tipsCache.get(l);h||(h=this.createTip(a,t,i),this.tipsCache.set(l,h));let{wrapper:g,tip:_}=h;this.updateTipState(g,_,a,n,r,i,s,c);let v=o*(360/e.length)*(Math.PI/180);g.style.left=`${u+Math.sin(v)*f}px`,g.style.bottom=`${d+Math.cos(v)*f}px`,p.appendChild(g)}),l.appendChild(p)}createTip(e,t,n){if(bM()===!1){let e={};return{wrapper:e,tip:e}}let r=document.createElement(`span`),i=document.createElement(`span`);i.textContent=e,i.setAttribute(`role`,`option`),i.setAttribute(`aria-selected`,`false`),i.tabIndex=0;let a=n===`24h`&&t.includes(`24`)?`tp-ui-value-tips-24h`:`tp-ui-value-tips`;return i.classList.add(a),r.classList.add(t),this.config.theme&&(r.classList.add(this.config.theme),i.classList.add(this.config.theme)),r.appendChild(i),{wrapper:r,tip:i}}updateTipState(e,t,n,r,i,a,o,s){e.classList.remove(`tp-ui-tips-disabled`),t.classList.remove(`tp-ui-tips-disabled`),t.removeAttribute(`aria-disabled`),t.tabIndex=0,this.checkIfDisabled(n,r,i,a,o,s)&&(e.classList.add(`tp-ui-tips-disabled`),t.classList.add(`tp-ui-tips-disabled`),t.setAttribute(`aria-disabled`,`true`),t.tabIndex=-1)}checkIfDisabled(e,t,n,r,i,a){return n?t===`hours`?yN.isDisabled(e,i,n):t===`minutes`?bN.isDisabled(e,a,i,n,r):!1:!1}setCircleSize(e){e?this.config.circle.classList.remove(`small-circle`):this.config.circle.classList.add(`small-circle`)}setCircle24hMode(e){e?(this.config.circle.classList.add(`tp-ui-circle-hand-24h`),this.config.clockHand.classList.add(`tp-ui-clock-hand-24h`)):(this.config.circle.classList.remove(`tp-ui-circle-hand-24h`),this.config.clockHand.classList.remove(`tp-ui-clock-hand-24h`))}destroy(){this.tipsCache.clear(),this.cachedDimensions.clear(),this.config.tipsWrapper.innerHTML=``}},CN=class{static processPointerInput(e){let t=xN.calculateRawAngle(e.pointerPosition,e.clockCenter);return e.mode===`hours`?this.processHours(t,e):this.processMinutes(t,e)}static processHours(e,t){let n=t.smoothHourSnap??!0,r;if(n)r=e;else{let n=t.incrementHours*30;r=xN.snapToIncrement(e,n)}let i=xN.calculateDistance(t.pointerPosition,t.clockCenter),a=t.clockType===`24h`&&xN.isInnerCircle(i,t.clockRadius),o=yN.angleToIndex(r,t.clockType,a),s=yN.indexToValue(o,t.clockType),c=yN.isDisabled(s,t.amPm,t.disabledTime);c&&(o=yN.findNearestValid(o,t.clockType,t.amPm,t.disabledTime));let l=yN.indexToValue(o,t.clockType),u;return u=n?e:yN.indexToAngle(o,t.clockType),{angle:u,value:l,index:o,isValid:!c,isInnerCircle:t.clockType===`24h`?a:void 0}}static processMinutes(e,t){let n=t.incrementMinutes*6,r=xN.snapToIncrement(e,n),i=bN.angleToIndex(r),a=bN.indexToValue(i),o=t.currentHour||`00`,s=bN.isDisabled(a,o,t.amPm,t.disabledTime,t.clockType);s&&(i=bN.findNearestValid(i,o,t.amPm,t.disabledTime,t.clockType));let c=bN.indexToValue(i);return{angle:bN.indexToAngle(i),value:c,index:i,isValid:!s}}static valueToAngle(e,t,n){let r=parseInt(e,10);return t===`hours`?yN.indexToAngle(r,n):bN.indexToAngle(r)}},wN=class{state;renderer;clockType;disabledTime;incrementHours;incrementMinutes;smoothHourSnap;isDragging=!1;callbacks;lastProcessedX=null;lastProcessedY=null;constructor(e,t,n,r,i=1,a=1,o=!0,s={}){this.renderer=e,this.state={...t},this.clockType=n,this.disabledTime=r,this.incrementHours=i,this.incrementMinutes=a,this.smoothHourSnap=o,this.callbacks=s}handlePointerMove(e,t,n){if(this.isDragging=!0,this.lastProcessedX===e.x&&this.lastProcessedY===e.y)return;this.lastProcessedX=e.x,this.lastProcessedY=e.y;let r={pointerPosition:e,clockCenter:t,clockRadius:n,mode:this.state.mode,clockType:this.clockType,amPm:this.state.amPm,disabledTime:this.disabledTime,incrementHours:this.incrementHours,incrementMinutes:this.incrementMinutes,smoothHourSnap:this.smoothHourSnap,currentHour:this.state.hour},i=CN.processPointerInput(r);if(i.isValid){if(this.state.mode===`hours`){let e=this.state.hour;this.state.hour=i.value,this.state.hourAngle=i.angle,this.clockType===`24h`&&i.isInnerCircle!==void 0&&(this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(i.isInnerCircle)),this.callbacks.onHourChange&&e!==i.value&&this.callbacks.onHourChange(i.value)}else{let e=this.state.minute;this.state.minute=i.value,this.state.minuteAngle=i.angle,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1),this.callbacks.onMinuteChange&&e!==i.value&&this.callbacks.onMinuteChange(i.value)}this.renderer.setHandAngle(i.angle),this.renderer.setActiveValue(i.value)}}handlePointerUp(){this.isDragging=!1,this.lastProcessedX=null,this.lastProcessedY=null}snapToNearestHour(){if(this.state.mode!==`hours`)return;let e=CN.valueToAngle(this.state.hour,`hours`,this.clockType);this.state.hourAngle=e,this.renderer.animateToAngle(e)}switchMode(e){this.state.mode=e;let t=e===`hours`?this.state.hourAngle:this.state.minuteAngle,n=e===`hours`?this.state.hour:this.state.minute;if(e===`hours`&&this.clockType===`24h`){let e=parseInt(n,10),t=e===0||e>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(t)}else this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.renderer.setHandAngle(t),this.renderer.setActiveValue(n)}setValue(e,t){let n=CN.valueToAngle(t,e,this.clockType);if(e===`hours`)if(this.state.hour=t,this.state.hourAngle=n,this.clockType===`24h`){let e=parseInt(t,10),n=e===0||e>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(n)}else this.renderer.setCircle24hMode(!1);else this.state.minute=t,this.state.minuteAngle=n,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.state.mode===e&&(this.renderer.setHandAngle(n),this.renderer.setActiveValue(t))}setAmPm(e){this.state.amPm=e}getState(){return{...this.state}}getHour(){return this.state.hour}getMinute(){return this.state.minute}getAmPm(){return this.state.amPm}updateDisabledTime(e){this.disabledTime=e}destroy(){this.renderer.destroy()}},TN=class{controller;clockFace;isActive=!1;isBlocked=!1;config;cachedRect=null;cachedCenter=null;cachedRadius=null;rafId=null;constructor(e,t,n={}){this.controller=e,this.clockFace=t,this.config=n}attach(){this.clockFace.addEventListener(`mousedown`,this.handlePointerDown),this.clockFace.addEventListener(`touchstart`,this.handlePointerDown,{passive:!1})}detach(){this.clockFace.removeEventListener(`mousedown`,this.handlePointerDown),this.clockFace.removeEventListener(`touchstart`,this.handlePointerDown),this.removeGlobalListeners()}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}handlePointerDown=e=>{if(yM()||this.isBlocked)return;let t=e.target;t&&t.classList&&t.classList.contains(`tp-ui-tips-disabled`)||(e.preventDefault(),this.isActive=!0,this.cachedRect=this.clockFace.getBoundingClientRect(),this.cachedCenter=this.getClockCenter(),this.cachedRadius=this.getClockRadius(),this.processPointerEvent(e),document.addEventListener(`mousemove`,this.handlePointerMove),document.addEventListener(`touchmove`,this.handlePointerMove,{passive:!1}),document.addEventListener(`mouseup`,this.handlePointerUp),document.addEventListener(`touchend`,this.handlePointerUp))};handlePointerMove=e=>{if(!this.isActive||this.isBlocked)return;let t=this.getTargetElement(e);t&&t.classList&&t.classList.contains(`tp-ui-tips-disabled`)||(e.preventDefault(),this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.processPointerEvent(e)})))};handlePointerUp=()=>{if(!this.isActive)return;this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.isActive=!1,this.cachedRect=null,this.cachedCenter=null,this.cachedRadius=null,this.controller.handlePointerUp();let{autoSwitchToMinutes:e,isMobileView:t,smoothHourSnap:n,hourElement:r,minutesElement:i}=this.config;n&&r?.classList.contains(`active`)&&this.controller.snapToNearestHour(),this.removeGlobalListeners(),e&&r?.classList.contains(`active`)&&!t?(r.classList.remove(`active`),i?.classList.add(`active`),i?.click(),i?.focus(),r.blur()):i?.classList.contains(`active`)&&this.config.onMinuteCommit&&this.config.onMinuteCommit()};processPointerEvent(e){let t=this.getPointerPosition(e),n=this.cachedCenter||this.getClockCenter(),r=this.cachedRadius||this.getClockRadius();this.controller.handlePointerMove(t,n,r)}getPointerPosition(e){let t=this.cachedRect||this.clockFace.getBoundingClientRect();if(`touches`in e){let n=e.touches[0]||e.changedTouches[0];return{x:n.clientX-t.left,y:n.clientY-t.top}}else return{x:e.clientX-t.left,y:e.clientY-t.top}}getTargetElement(e){if(`touches`in e){let t=e.touches[0]||e.changedTouches[0];if(t&&!yM())return document.elementFromPoint(t.clientX,t.clientY)}return e.target}getClockCenter(){let e=this.clockFace.offsetWidth,t=this.clockFace.offsetHeight;return{x:e/2,y:t/2}}getClockRadius(){return this.clockFace.offsetWidth/2}removeGlobalListeners(){bM()!==!1&&(document.removeEventListener(`mousemove`,this.handlePointerMove),document.removeEventListener(`touchmove`,this.handlePointerMove),document.removeEventListener(`mouseup`,this.handlePointerUp),document.removeEventListener(`touchend`,this.handlePointerUp))}},EN=class{renderer;controller;dragHandlers;clockType;disabledTime;tipsWrapper;tipsWrapperFor24h;constructor(e){this.clockType=e.clockType,this.disabledTime=e.disabledTime,this.tipsWrapper=e.tipsWrapper,this.tipsWrapperFor24h=e.tipsWrapperFor24h;let t={clockFace:e.clockFace,tipsWrapper:e.tipsWrapper,tipsWrapperFor24h:e.tipsWrapperFor24h,clockHand:e.clockHand,circle:e.circle,theme:e.theme};this.renderer=new SN(t);let n={hour:e.initialHour,minute:e.initialMinute,amPm:e.initialAmPm,hourAngle:this.calculateInitialAngle(`hours`,e.initialHour),minuteAngle:this.calculateInitialAngle(`minutes`,e.initialMinute),mode:`hours`},r={onHourChange:e.onHourChange,onMinuteChange:e.onMinuteChange};this.controller=new wN(this.renderer,n,e.clockType,e.disabledTime,e.incrementHours||1,e.incrementMinutes||1,e.smoothHourSnap??!0,r),this.dragHandlers=new TN(this.controller,e.clockFace,e.dragConfig||{})}initialize(){this.dragHandlers.attach(),this.switchToHours()}switchToHours(){this.controller.switchMode(`hours`),this.clockType===`24h`&&this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.remove(`none`),this.renderHourTips();let e=this.controller.getState();this.renderer.setActiveValue(e.hour)}switchToMinutes(){this.controller.switchMode(`minutes`),this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.add(`none`),this.renderMinuteTips();let e=this.controller.getState();this.renderer.setActiveValue(e.minute)}setHour(e){this.controller.setValue(`hours`,e)}setMinute(e){this.controller.setValue(`minutes`,e)}setAmPm(e){this.controller.setAmPm(e);let t=this.controller.getState();t.mode===`hours`?(this.renderHourTips(),this.renderer.setHandAngle(t.hourAngle),this.renderer.setActiveValue(t.hour)):(this.renderMinuteTips(),this.renderer.setHandAngle(t.minuteAngle),this.renderer.setActiveValue(t.minute))}getHour(){return this.controller.getHour()}getMinute(){return this.controller.getMinute()}getAmPm(){return this.controller.getAmPm()}updateDisabledTime(e){this.disabledTime=e,this.controller.updateDisabledTime(e),this.controller.getState().mode===`hours`?this.renderHourTips():this.renderMinuteTips()}renderHourTips(){let e=this.controller.getState().amPm;this.clockType===`24h`?(this.renderer.renderTips(LM,`tp-ui-hour-time-12`,`hours`,this.disabledTime,this.clockType,!0,this.tipsWrapper,e),this.tipsWrapperFor24h&&this.renderer.renderTips(IM,`tp-ui-hour-time-24`,`hours`,this.disabledTime,this.clockType,!0,this.tipsWrapperFor24h,e)):this.renderer.renderTips(LM,`tp-ui-hour-time-12`,`hours`,this.disabledTime,this.clockType,!0,void 0,e)}renderMinuteTips(){let e=this.controller.getState(),t=e.amPm,n=e.hour;this.renderer.renderTips(RM,`tp-ui-minutes-time`,`minutes`,this.disabledTime,this.clockType,!0,void 0,t,n)}calculateInitialAngle(e,t){let n=parseInt(t,10);return e===`hours`?n%12*30:n*6}destroy(){this.dragHandlers.detach(),this.controller.destroy()}blockInteractions(){this.dragHandlers.block()}unblockInteractions(){this.dragHandlers.unblock()}},DN=class{core;emitter;clockSystem=null;constructor(e,t){this.core=e,this.emitter=t}getClockSystem(){return this.clockSystem}initialize(){let e=this.core.getClockFace(),t=this.core.getClockHand(),n=this.core.getCircle();if(!e||!t||!n)return;let r=this.core.options.clock.type===`24h`,i=this.core.getTipsWrapper();if(!i)return;let a=this.core.getHour(),o=this.core.getMinutes(),s={clockFace:e,tipsWrapper:i,tipsWrapperFor24h:r&&this.core.getTipsWrapperFor24h()||void 0,clockHand:t,circle:n,clockType:this.core.options.clock.type||`12h`,disabledTime:this.convertDisabledTime(),initialHour:a?.value||`12`,initialMinute:o?.value||`00`,initialAmPm:this.getAmPmValue(),theme:this.core.options.ui.theme,incrementHours:this.core.options.clock.incrementHours||1,incrementMinutes:this.core.options.clock.incrementMinutes||1,smoothHourSnap:this.core.options.clock.smoothHourSnap??!0,timepicker:null,dragConfig:{autoSwitchToMinutes:this.core.options.clock.autoSwitchToMinutes,isMobileView:this.core.isMobileView,smoothHourSnap:this.core.options.clock.smoothHourSnap??!0,hourElement:a,minutesElement:o,onMinuteCommit:()=>{let e=this.core.getMinutes(),t=this.core.getHour(),n=this.core.getActiveTypeMode();this.emitter.emit(`range:minute:commit`,{hour:t?.value??`12`,minutes:e?.value??`00`,type:n?.textContent??void 0})}},onHourChange:e=>{let t=this.core.getHour();t&&(t.value=e,t.setAttribute(`aria-valuenow`,e)),cN(this.core.getModalElement(),`Hour: ${e}`);let n=this.core.getMinutes(),r=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:e,minutes:n?.value,type:r?.textContent||void 0})},onMinuteChange:e=>{let t=this.core.getMinutes();t&&(t.value=e,t.setAttribute(`aria-valuenow`,e)),cN(this.core.getModalElement(),`Minutes: ${e}`);let n=this.core.getHour(),r=this.core.getActiveTypeMode();this.emitter.emit(`update`,{hour:n?.value,minutes:e,type:r?.textContent||void 0})}};this.clockSystem=new EN(s),this.clockSystem.initialize()}convertDisabledTime(){let e=this.core.disabledTime?.value;if(!e)return null;let t;return e.intervals&&(t=Array.isArray(e.intervals)?e.intervals:[e.intervals]),{hours:e.hours,minutes:e.minutes,isInterval:e.isInterval,intervals:t,clockType:e.clockType}}getAmPmValue(){if(this.core.options.clock.type===`24h`)return``;let e=this.core.getActiveTypeMode();if(e){let t=e.textContent?.trim();if(t===`AM`||t===`PM`)return t}let t=this.core.getAM();return this.core.options.range?.enabled===!0?t?.classList.contains(`active`)?`AM`:``:t?.classList.contains(`active`)?`AM`:`PM`}destroy(){this.clockSystem&&=(this.clockSystem.destroy(),null)}},ON=class{core;constructor(e){this.core=e}removeCircleClockClasses24h(){let e=this.core.getCircle(),t=this.core.getClockHand();e?.classList.remove(`tp-ui-circle-hand-24h`),t?.classList.remove(`tp-ui-clock-hand-24h`)}setCircleClockClasses24h(){let e=this.core.getCircle(),t=this.core.getClockHand();e&&e.classList.add(`tp-ui-circle-hand-24h`),t&&t.classList.add(`tp-ui-clock-hand-24h`)}setOnStartCSSClassesIfClockType24h(){if(this.core.options.clock.type===`24h`){let e=this.core.getInput();if(!e)return;let t;e.value.length>0&&(t=e.value.split(`:`)[0]),t&&(Number(t)>12||Number(t)===0)&&this.setCircleClockClasses24h()}}setBgColorToCircleWithMinutesTips(){let e=this.core.getMinutes(),t=this.core.getCircle();if(!(!e||!t)&&e.value&&RM.includes(e.value)){let e=getComputedStyle(t).getPropertyValue(`--timepicker-primary`).trim();e&&(t.style.backgroundColor=e),t.classList.remove(`small-circle`)}}removeBgColorToCirleWithMinutesTips(){let e=this.core.getMinutes(),t=this.core.getCircle();!e||!t||e.value&&RM.includes(e.value)||(t.style.backgroundColor=``,t.classList.add(`small-circle`))}setClassActiveToHourOnOpen(){this.core.options.ui.mobile||this.core.isMobileView||this.core.getHour()?.classList.add(ZM)}toggleClassActiveToValueTips(e,t){if(e)return;let n=this.core.getAllValueTips();if(!n)return;let r=n.find(e=>Number(e.innerText)===Number(t));n.forEach(e=>{e.classList.remove(ZM),e.setAttribute(`aria-selected`,`false`)}),r!==void 0&&(r.classList.add(ZM),r.setAttribute(`aria-selected`,`true`))}},kN=class{getClockSystem;styleHandler;getAmPmValue;clockType;constructor(e,t,n,r){this.getClockSystem=e,this.styleHandler=t,this.getAmPmValue=n,this.clockType=r}setMinutesToClock(e){let t=this.getClockSystem();t&&(this.styleHandler.removeBgColorToCirleWithMinutesTips(),e&&t.setMinute(e),t.switchToMinutes())}setHoursToClock(e){let t=this.getClockSystem();t&&(e&&t.setHour(e),t.switchToHours())}setTransformToCircleWithSwitchesHour(e){let t=this.getClockSystem();!t||!e||t.setHour(e)}setTransformToCircleWithSwitchesMinutes(e){let t=this.getClockSystem();!t||!e||t.setMinute(e)}updateAmPm(){let e=this.getClockSystem();if(!e||this.clockType===`24h`)return;let t=this.getAmPmValue();t!==``&&e.setAmPm(t)}},AN=class{systemInitializer;styleHandler;timeHandler;eventHandler;constructor(e,t){this.systemInitializer=new DN(e,t),this.styleHandler=new ON(e);let n=e.options.clock.type||`12h`;this.timeHandler=new kN(()=>this.systemInitializer.getClockSystem(),this.styleHandler,()=>this.systemInitializer.getAmPmValue(),n),this.eventHandler=new vN(t,()=>this.systemInitializer.getClockSystem(),e=>this.timeHandler.setHoursToClock(e),e=>this.timeHandler.setMinutesToClock(e),()=>this.timeHandler.updateAmPm(),()=>this.systemInitializer.convertDisabledTime()),this.eventHandler.setup()}initializeClockSystem(){this.systemInitializer.initialize()}destroyClockSystem(){this.systemInitializer.destroy()}removeCircleClockClasses24h(){this.styleHandler.removeCircleClockClasses24h()}setCircleClockClasses24h(){this.styleHandler.setCircleClockClasses24h()}setOnStartCSSClassesIfClockType24h(){this.styleHandler.setOnStartCSSClassesIfClockType24h()}setBgColorToCircleWithMinutesTips=()=>{this.styleHandler.setBgColorToCircleWithMinutesTips()};removeBgColorToCirleWithMinutesTips=()=>{this.styleHandler.removeBgColorToCirleWithMinutesTips()};setClassActiveToHourOnOpen=()=>{this.styleHandler.setClassActiveToHourOnOpen()};setMinutesToClock=e=>{this.timeHandler.setMinutesToClock(e)};setHoursToClock=e=>{this.timeHandler.setHoursToClock(e)};setTransformToCircleWithSwitchesHour=e=>{this.timeHandler.setTransformToCircleWithSwitchesHour(e)};setTransformToCircleWithSwitchesMinutes=e=>{this.timeHandler.setTransformToCircleWithSwitchesMinutes(e)};updateAmPm=()=>{this.timeHandler.updateAmPm()};toggleClassActiveToValueTips=e=>{let t=this.systemInitializer.getClockSystem()!==null;this.styleHandler.toggleClassActiveToValueTips(t,e)};destroy(){this.destroyClockSystem()}},jN=class{core;emitter;cleanupHandlers=[];wasCleared=!1;constructor(e,t){this.core=e,this.emitter=t}init(){if(!this.core.options.ui.clearButton)return;let e=this.getClearButton();if(!e)return;let t=()=>{this.core.isDestroyed||e.getAttribute(`aria-disabled`)!==`true`&&this.handleClearClick()};e.addEventListener(`click`,t),this.cleanupHandlers.push(()=>e.removeEventListener(`click`,t)),this.setupInternalEventListeners()}setupInternalEventListeners(){this.emitter.on(`update`,()=>{this.updateClearButtonState()}),this.emitter.on(`open`,()=>{this.updateClearButtonState()}),this.emitter.on(`select:hour`,()=>{this.updateClearButtonState(),this.reenableConfirmIfCleared()}),this.emitter.on(`select:minute`,()=>{this.updateClearButtonState(),this.reenableConfirmIfCleared()})}handleClearClick(){let e=this.core.getInput()?.value||null;this.clearTimeValue(),this.resetClockToNeutral(),this.disableConfirmButton(),this.wasCleared=!0,cN(this.core.getModalElement(),`Time cleared`),this.emitter.emit(`clear`,{previousValue:e}),this.emitter.emit(`update`,{hour:void 0,minutes:void 0,type:void 0});let{callbacks:t}=this.core.options;t.onClear&&t.onClear({previousValue:e})}clearTimeValue(){let e=this.core.options.clearBehavior?.clearInput!==!1,t=this.core.getInput();t&&e&&(t.value=``),this.core.setDegreesHours(null),this.core.setDegreesMinutes(null);let n=FM.getClearHandler(`range`);n&&n(this.core,this.emitter);let r=FM.getClearHandler(`timezone`);r&&r(this.core,this.emitter)}resetClockToNeutral(){let e=this.core.options.clock.type,t=e===`12h`?`PM`:void 0,n=this.core.getHour(),r=this.core.getMinutes();n&&(n.value=`12`,n.removeAttribute(`aria-valuenow`)),r&&(r.value=`00`,r.removeAttribute(`aria-valuenow`));let i=this.core.getClockHand();if(i){let e=i.style.transition;i.style.transition=`none`,i.style.transform=`rotateZ(0deg)`,i.offsetHeight,requestAnimationFrame(()=>{i.style.transition=e})}if(this.removeActiveStates(),n&&n.click(),e===`12h`&&t){let e=this.core.getAM(),t=this.core.getPM();e?.classList.remove(`active`),t?.classList.remove(`active`),e?.setAttribute(`aria-pressed`,`false`),t?.setAttribute(`aria-pressed`,`false`),t?.classList.add(`active`),t?.setAttribute(`aria-pressed`,`true`)}this.emitter.emit(`animation:clock`,{})}removeActiveStates(){this.core.getAllValueTips().forEach(e=>{e.classList.remove(`active`),e.removeAttribute(`aria-selected`)});let e=this.core.getHour(),t=this.core.getMinutes();e?.removeAttribute(`aria-valuenow`),t?.removeAttribute(`aria-valuenow`)}disableConfirmButton(){let e=this.core.getOkButton();e&&(e.classList.add(`disabled`),e.setAttribute(`aria-disabled`,`true`))}updateClearButtonState(){let e=this.getClearButton();if(!e)return;let t=this.core.getInput(),n=t?.value&&t.value.trim()!==``,r=this.core.getHour(),i=this.core.getMinutes(),a=this.core.getActiveTypeMode(),o=this.core.options.clock.type,s=r?.value||``,c=i?.value||``,l=a?.textContent||``,u=n||!(o===`12h`?s===`12`&&c===`00`&&l===`PM`:s===`12`&&c===`00`);e.classList.toggle(`disabled`,!u),e.setAttribute(`aria-disabled`,String(!u))}reenableConfirmIfCleared(){if(!this.wasCleared)return;let e=this.core.getOkButton();e&&(e.classList.remove(`disabled`),e.setAttribute(`aria-disabled`,`false`),this.wasCleared=!1)}getClearButton(){return this.core.getModalElement()?.querySelector(`.tp-ui-clear-btn`)||null}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}},MN=class{animation;modal;config;theme;validation;events;clock;clearButton;plugins=new Map;constructor(e,t){this.animation=new CM(e,t),this.modal=new KM(e,t),this.config=new rN(e,t),this.theme=new iN(e,t),this.validation=new sN(e,t),this.events=new _N(e,t),this.clock=new AN(e,t),this.clearButton=new jN(e,t),FM.getAll().forEach(n=>{let r=n.factory(e,t);this.plugins.set(n.name,r)})}getPlugin(e){return this.plugins.get(e)}destroy(){this.animation.destroy(),this.modal.destroy(),this.config.destroy(),this.theme.destroy(),this.validation.destroy(),this.events.destroy(),this.clock.destroy(),this.clearButton.destroy(),this.plugins.forEach(e=>e.destroy()),this.plugins.clear()}},NN=`is-rippling`,PN=`ripple-hold`,FN=null,IN=(e,t)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e(...r)},t)}},LN=[`basic`,`crane-straight`,`crane`,`m2`,`m3-green`],RN=class{core;managers;emitter;eventsClickMobileHandler=()=>{};mutliEventsMoveHandler=()=>{};unmountTimeouts=[];constructor(e,t,n){this.core=e,this.managers=t,this.emitter=n}init(){if(!this.core.isDestroyed&&!this.core.isInitialized){try{this.managers.config.updateInputValueWithCurrentTimeOnStart(),this.managers.validation.checkDisabledValuesOnStart()}catch{this.core.setIsDestroyed(!0);return}this.managers.theme.setTimepickerClassToElement(),this.managers.theme.setInputClassToInputElement(),this.managers.theme.setDataOpenToInputIfDoesntExistInWrapper(),this.managers.theme.setClassTopOpenElement(),this.managers.config.getDisableTime(),this.core.options.ui.inline?.enabled||this.managers.events.handleOpenOnClick(),this.managers.events.handleOpenOnEnterFocus(),this.setupCallbackBridge(),this.core.setIsInitialized(!0)}}setupCallbackBridge(){let{callbacks:e}=this.core.options;e.onOpen&&this.emitter.on(`open`,e.onOpen),e.onCancel&&this.emitter.on(`cancel`,e.onCancel),e.onConfirm&&this.emitter.on(`confirm`,e.onConfirm),e.onUpdate&&this.emitter.on(`update`,e.onUpdate),e.onSelectHour&&this.emitter.on(`select:hour`,e.onSelectHour),e.onSelectMinute&&this.emitter.on(`select:minute`,e.onSelectMinute),e.onSelectAM&&this.emitter.on(`select:am`,e.onSelectAM),e.onSelectPM&&this.emitter.on(`select:pm`,e.onSelectPM),e.onError&&this.emitter.on(`error`,e.onError),e.onTimezoneChange&&this.emitter.on(`timezone:change`,e.onTimezoneChange),e.onRangeConfirm&&this.emitter.on(`range:confirm`,e.onRangeConfirm),e.onRangeSwitch&&this.emitter.on(`range:switch`,e.onRangeSwitch),e.onRangeValidation&&this.emitter.on(`range:validation`,e.onRangeValidation),e.onClear&&this.emitter.on(`clear`,e.onClear)}mount(){this.core.isDestroyed||this.core.isOpen||(this.core.isInitialized||this.init(),this.eventsBundle())}unmount(e){let t=IN((...e)=>{if(e.length>2)return;let[t]=e.filter(e=>typeof e==`boolean`),[n]=e.filter(e=>typeof e==`function`);this.core.setIsMobileView(!!this.core.options.ui.mobile);let r=this.core.getModalElement();if(t&&r&&this.core.getOkButton()?.click(),this.core.setIsTouchMouseMove(!1),this.core.setIsOpen(!1),this.removeEventListeners(),this.isPopoverMode()){let e=this.managers.getPlugin(`wheel`);e&&`detachPopover`in e&&e.detachPopover()}r&&this.managers.animation.removeAnimationToClose(),this.core.getOpenElement().forEach(e=>e?.classList.remove(`disabled`));let i=setTimeout(()=>{bM()&&(document.body.style.overflowY=``,document.body.style.paddingRight=``)},SM.SCROLLBAR_RESTORE);this.unmountTimeouts.push(i);let a=setTimeout(()=>{let e=this.core.getInput();this.core.options.behavior.focusInputAfterClose&&e?.focus();let t=this.core.getModalElement();t&&t.remove(),this.core.setIsModalRemove(!0)},SM.MODAL_REMOVE);this.unmountTimeouts.push(a),n&&n()},this.core.options.behavior.delayHandler||SM.DEFAULT_DELAY);e?t(e):t()}destroy(e){if(this.core.isDestroyed)return;this.clearUnmountTimeouts();let{keepInputValue:t=!1,callback:n}=typeof e==`function`?{callback:e}:e||{},r=this.core.getInput(),i=t?r?.value:null;this.removeEventListeners(),this.core.getModalElement()?.remove(),this.core.getOpenElement()?.forEach(e=>{e&&(e.classList.remove(`disabled`,`active`,`tp-ui-open-element`),e.classList.remove(...LN))}),r&&(r.classList.remove(`tp-ui-invalid-format`,`invalid-value`,`error`,`active`,`tp-ui-input`),r.removeAttribute(`data-open`),r.removeAttribute(`data-owner-id`),t&&i&&(r.value=i));let a=this.core.element;a&&(a.classList.remove(...LN),a.classList.remove(`error`,`active`,`disabled`),a.removeAttribute(`data-owner-id`),a.removeAttribute(`data-open`),this.core.options.ui.cssClass&&a.classList.remove(this.core.options.ui.cssClass)),a?.querySelectorAll(`.tp-ui-invalid-text`)?.forEach(e=>e.remove()),this.mutliEventsMoveHandler=()=>{},this.eventsClickMobileHandler=()=>{},this.core.reset(),this.managers.destroy(),this.emitter.clear(),yM()||(document.body.style.overflowY=``,document.body.style.paddingRight=``),n&&n()}eventsBundle(){if(this.core.isDestroyed||!this.core.isModalRemove)return;this.clearUnmountTimeouts(),this.core.setIsOpen(!0),this.core.setIsModalRemove(!1),this.setupValidation(),this.disableOpenElements(),this.setupModal(),this.applyExpandedState(),this.managers.modal.setFlexEndToFooterIfNoKeyboardIcon(),this.applyThemeDeferred(),this.managers.animation.setAnimationToOpen(),this.managers.config.getInputValueOnOpenAndSet();let e=this.resolveWheelMode();if(this.emitMissingPluginErrors(),this.initClockOrWheel(e),this.initOptionalPlugins(e),this.bindEventHandlers(e),this.finalizeModal(e),this.isPopoverMode()){let e=this.managers.getPlugin(`wheel`);e&&`attachPopover`in e&&e.attachPopover()}this.managers.modal.setShowClassToBackdrop()}setupValidation(){this.managers.validation.setErrorHandler(),this.managers.validation.removeErrorHandler()}disableOpenElements(){this.core.options.ui.inline?.enabled||(this.core.getOpenElement().forEach(e=>e?.classList.add(`disabled`)),this.isPopoverMode()||this.core.getInput()?.blur())}setupModal(){this.managers.modal.setScrollbarOrNot(),this.managers.modal.setModalTemplate(),this.managers.modal.setNormalizeClass(),this.managers.modal.removeBackdrop()}applyExpandedState(){if(this.core.isMobileView)this.managers.config.updateClockFaceAccessibility(!0);else{let e=this.core.getModalElement(),t=e?.querySelector(`.tp-ui-mobile-clock-wrapper`),n=e?.querySelector(`.tp-ui-wrapper`),r=e?.querySelectorAll(`*`);t?.classList.add(`expanded`),n?.classList.add(`expanded`),r?.forEach(e=>{!e.classList.contains(`tp-ui-select-time`)&&!e.classList.contains(`tp-ui-mobile-clock-wrapper`)&&!e.classList.contains(`tp-ui-wrapper`)&&e.classList.add(`expanded`)})}}applyThemeDeferred(){setTimeout(()=>{this.managers.theme.setTheme();let e=this.core.getWrapper();e&&this.core.options.ui.cssClass&&e.classList.add(this.core.options.ui.cssClass)},0)}isCompactWheelMode(){return this.core.options.ui.mode===`compact-wheel`}isPopoverMode(){return this.isCompactWheelMode()&&!!this.core.options.wheel?.placement}resolveWheelMode(){let e=this.core.options.ui.mode;return(e===`wheel`||e===`compact-wheel`)&&FM.has(`wheel`)}emitMissingPluginErrors(){let e=this.core.options.ui.mode;(e===`wheel`||e===`compact-wheel`)&&!FM.has(`wheel`)&&this.emitter.emit(`error`,{error:`WheelPlugin is not registered. Import and register it: PluginRegistry.register(WheelPlugin)`}),this.core.options.range?.enabled&&!FM.has(`range`)&&this.emitter.emit(`error`,{error:`RangePlugin is not registered. Import and register it: PluginRegistry.register(RangePlugin)`}),this.core.options.timezone?.enabled&&!FM.has(`timezone`)&&this.emitter.emit(`error`,{error:`TimezonePlugin is not registered. Import and register it: PluginRegistry.register(TimezonePlugin)`})}initClockOrWheel(e){if(e){let e=this.managers.getPlugin(`wheel`);e&&e.init()}else this.managers.clock.initializeClockSystem(),this.managers.clock.setOnStartCSSClassesIfClockType24h(),this.managers.clock.setClassActiveToHourOnOpen()}initOptionalPlugins(e){let t=this.managers.getPlugin(`timezone`);t&&t.init();let n=this.managers.getPlugin(`range`);n&&!e&&n.init()}bindEventHandlers(e){this.managers.events.handleCancelButton(),this.managers.events.handleOkButton(),this.managers.clearButton.init(),e||(this.managers.events.handleHourEvents(),this.managers.events.handleMinutesEvents()),this.managers.events.handleKeyboardInput(),this.core.options.ui.enableSwitchIcon&&!e&&this.managers.events.handleSwitchViewButton(),this.core.options.clock.type!==`24h`&&!this.isCompactWheelMode()&&(this.managers.events.handleAmClick(),this.managers.events.handlePmClick()),this.core.options.behavior.focusTrap&&this.managers.events.focusTrapHandler(),this.core.options.ui.inline?.enabled||(this.managers.events.handleEscClick(),this.isPopoverMode()||(this.core.options.ui.mode===`wheel`||this.core.options.ui.mode===`compact-wheel`)&&this.core.options.wheel?.ignoreOutsideClick||this.managers.events.handleBackdropClick())}finalizeModal(e){let t=this.core.getModalElement();if(t&&_M(t),!e){let e=this.core.getClockFace();e&&typeof requestAnimationFrame<`u`&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e?.classList.add(`scale-in`)})})}}clearUnmountTimeouts(){this.unmountTimeouts.forEach(clearTimeout),this.unmountTimeouts=[]}removeEventListeners(){bM()!==!1&&(XM.split(` `).forEach(e=>{document.removeEventListener(e,this.mutliEventsMoveHandler,!1)}),document.removeEventListener(`mousedown`,this.eventsClickMobileHandler))}},zN=class{events=new Map;on(e,t){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t)}once(e,t){let n=r=>{t(r),this.off(e,n)};this.on(e,n)}off(e,t){t?this.events.get(e)?.delete(t):this.events.delete(e)}emit(e,t){this.events.get(e)?.forEach(e=>{e(t)})}clear(){this.events.clear()}hasListeners(e){return(this.events.get(e)?.size??0)>0}},BN={clock:{type:`12h`,incrementHours:1,incrementMinutes:1,autoSwitchToMinutes:!0,disabledTime:void 0,currentTime:void 0},ui:{mode:`clock`,theme:`basic`,animation:!0,backdrop:!0,mobile:!1,enableSwitchIcon:!1,editable:!1,enableScrollbar:!1,cssClass:void 0,appendModalSelector:``,iconTemplate:``,iconTemplateMobile:``,inline:void 0,clearButton:!1},labels:{am:`AM`,pm:`PM`,ok:`OK`,cancel:`Cancel`,time:`Select time`,mobileTime:`Enter Time`,mobileHour:`Hour`,mobileMinute:`Minute`,clear:`Clear`},behavior:{focusInputAfterClose:!1,focusTrap:!0,delayHandler:300,id:void 0},callbacks:{onOpen:void 0,onCancel:void 0,onConfirm:void 0,onUpdate:void 0,onSelectHour:void 0,onSelectMinute:void 0,onSelectAM:void 0,onSelectPM:void 0,onError:void 0,onTimezoneChange:void 0,onRangeConfirm:void 0,onRangeSwitch:void 0,onRangeValidation:void 0,onClear:void 0},timezone:{enabled:!1,default:void 0,whitelist:void 0,label:`Timezone`},range:{enabled:!1,minDuration:void 0,maxDuration:void 0,fromLabel:`From`,toLabel:`To`},wheel:{placement:void 0,hideFooter:void 0,commitOnScroll:void 0,hideDisabled:void 0,ignoreOutsideClick:void 0},clearBehavior:{clearInput:!0}},VN=e=>e.replace(/[^0-9:APMapm\s]/g,``),HN=new Map,UN=class{core;managers;lifecycle;emitter;constructor(e,t){if(yM())throw Error(`TimepickerUI requires browser environment`);let n=this.resolveInputElement(e);if(!n)throw Error(`Input element not found`);let r=t?.behavior?.id,i=r||`tp-ui-${jM()}`,a=this.createWrapperElement(n),o=vM(t||{});if(o.ui.inline?.enabled&&typeof t?.behavior?.focusTrap>`u`&&(o.behavior.focusTrap=!1),o.ui.inline?.enabled){if(!o.ui.inline.containerId)throw Error(`inline.containerId is required when inline mode is enabled`);if(!yM()&&!document.getElementById(o.ui.inline.containerId))throw Error(`Container element with id "${o.ui.inline.containerId}" not found`)}this.emitter=new zN,this.core=new xM(a,o,i,r);let s=this.core.getInput();if(s){let e=qM(s,o.clock.type),t=Number(e.hour)*30,n=Number(e.minutes)*6;this.core.setDegreesHours(t),this.core.setDegreesMinutes(n)}this.managers=new MN(this.core,this.emitter),this.lifecycle=new RN(this.core,this.managers,this.emitter),this.managers.config.checkMobileOption(),this.managers.config.preventClockTypeByCurrentTime(),this.setupInternalEventListeners(),HN.set(this.core.instanceId,this)}setupInternalEventListeners(){this.emitter.on(`show`,()=>{this.core.isDestroyed||this.lifecycle.mount()}),this.emitter.on(`cancel`,()=>{this.core.isDestroyed||this.lifecycle.unmount()}),this.emitter.on(`confirm`,e=>{if(!this.core.isDestroyed){if(this.core.options.range?.enabled)return;let t=this.core.getInput();if(t&&e.hour&&e.minutes){let n=e.type?` ${e.type}`:``;t.value=`${e.hour}:${e.minutes}${n}`}e.autoCommit||this.lifecycle.unmount()}}),this.emitter.on(`range:confirm`,e=>{if(this.core.isDestroyed)return;let t=this.core.getInput();t&&(t.value=`${e.from} - ${e.to}`),this.lifecycle.unmount()})}create(){this.lifecycle.init(),this.core.options.ui.inline?.enabled&&this.lifecycle.mount()}open(e){this.lifecycle.mount(),e&&e()}close(e,t){this.lifecycle.unmount(e?t:void 0),!e&&t&&t()}destroy(e){HN.delete(this.core.instanceId),this.lifecycle.destroy(e)}update(e,t){this.core.isDestroyed||(this.core.updateOptions(e.options),this.managers.config.checkMobileOption(),this.managers.config.getDisableTime(),e.create&&this.create(),t&&t())}getValue(){if(this.core.isDestroyed)return{hour:``,minutes:``,type:void 0,time:``,degreesHours:null,degreesMinutes:null};let e=this.core.getModalElement(),t=this.core.getInput(),n=`12`,r=`00`,i=this.core.options.clock.type===`24h`?void 0:`AM`,a=null,o=null;if(e){let e=this.core.getHour(),t=this.core.getMinutes(),s=this.core.getActiveTypeMode();n=e?.value||`12`,r=t?.value||`00`,i=this.core.options.clock.type===`24h`?void 0:s?.textContent||`AM`,a=this.core.degreesHours,o=this.core.degreesMinutes}else if(t){let e=qM(t,this.core.options.clock.type);n=e.hour,r=e.minutes,i=e.type,a=Number(n)*30,o=Number(r)*6}let s=``;return s=this.core.options.clock.type===`24h`?`${n.padStart(2,`0`)}:${r.padStart(2,`0`)}`:`${n}:${r.padStart(2,`0`)} ${i}`,{hour:n,minutes:r,type:i,time:s,degreesHours:a,degreesMinutes:o}}setValue(e,t=!0){if(this.core.isDestroyed||!e||typeof e!=`string`)return;this.core.isInitialized||this.create();let n=VN(e.trim());try{let e=this.parseTimeString(n);if(this.applyParsedTime(e),this.syncPeriodIndicator(e.typeValue),t){let e=this.core.getInput();e&&(e.value=n)}this.syncClockVisual(e)}catch{return}}parseTimeString(e){if(this.core.options.clock.type===`24h`){let t=e.match(/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/);if(!t)throw Error(`Invalid 24h format. Expected HH:MM`);return{hourValue:t[1].padStart(2,`0`),minutesValue:t[2],typeValue:`AM`}}let t=e.match(/^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i);if(!t)throw Error(`Invalid 12h format. Expected HH:MM AM/PM`);return{hourValue:t[1],minutesValue:t[2],typeValue:t[3].toUpperCase()}}applyParsedTime(e){let t=this.core.getHour(),n=this.core.getMinutes();t&&(t.value=e.hourValue,t.setAttribute(`aria-valuenow`,e.hourValue),this.core.setDegreesHours(Number(e.hourValue)*30)),n&&(n.value=e.minutesValue,n.setAttribute(`aria-valuenow`,e.minutesValue),this.core.setDegreesMinutes(Number(e.minutesValue)*6))}syncPeriodIndicator(e){if(this.core.options.clock.type===`24h`)return;let t=this.core.getAM(),n=this.core.getPM();!t||!n||(e===`AM`?(t.classList.add(`active`),n.classList.remove(`active`)):(n.classList.add(`active`),t.classList.remove(`active`)))}syncClockVisual(e){let t=this.core.options.ui.mode;if(t===`wheel`||t===`compact-wheel`){let t=this.managers.getPlugin(`wheel`);t&&`scrollToValue`in t&&t.scrollToValue(e.hourValue,e.minutesValue,e.typeValue)}else{let e=this.core.getClockHand();e&&(e.style.transform=`rotateZ(${this.core.degreesHours||0}deg)`)}}getElement(){return this.core.element}get instanceId(){return this.core.instanceId}get options(){return this.core.options}get isInitialized(){return this.core.isInitialized}get isDestroyed(){return this.core.isDestroyed}get hour(){return this.core.getHour()}get minutes(){return this.core.getMinutes()}get okButton(){return this.core.getOkButton()}get cancelButton(){return this.core.getCancelButton()}get clockHand(){return this.core.getClockHand()}on(e,t){this.core.isDestroyed||this.emitter.on(e,t)}once(e,t){this.core.isDestroyed||this.emitter.once(e,t)}off(e,t){this.core.isDestroyed||this.emitter.off(e,t)}resolveInputElement(e){if(bM()===!1)return null;let t=null;if(typeof e==`string`){if(t=document.querySelector(e),!t)return null}else if(e instanceof HTMLElement)t=e;else return null;return t.tagName===`INPUT`?t:t.querySelector(`input`)}createWrapperElement(e){if(bM()===!1)return e;let t=e.parentElement;if(e.tagName===`INPUT`&&!t?.classList.contains(`tp-ui`)){let t=document.createElement(`div`);return t.className=`tp-ui`,e.parentNode?.insertBefore(t,e),t.appendChild(e),t}return t&&!t.classList.contains(`tp-ui`)&&t.classList.add(`tp-ui`),t||e}static getById(e){return HN.get(e)}static getAllInstances(){return Array.from(HN.values())}static isAvailable(e){return yM()?!1:typeof e==`string`?document.querySelector(e)!==null:e instanceof HTMLElement?document.contains(e):!1}static destroyAll(){Array.from(HN.values()).forEach(e=>e.destroy()),HN.clear()}},WN=UN,GN=WN})),qN=u({RangeManager:()=>nP,RangePlugin:()=>rP});function JN(e){if(!e||e===`--:--`)return null;let t=e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i);if(t)return{hour:t[1],minutes:t[2],type:t[3].toUpperCase()};let n=e.match(/^(\d{1,2}):(\d{2})$/);return n?{hour:n[1],minutes:n[2]}:null}function YN(e){let t=e.minutes===`--`?`--`:e.minutes.padStart(2,`0`),n=`${e.hour}:${t}`;return e.type?`${n} ${e.type}`:n}function XN(e,t){if(!e)return 0;let n=parseInt(e.hour,10),r=parseInt(e.minutes,10);return t===`12h`&&e.type&&(e.type===`PM`&&n!==12&&(n+=12),e.type===`AM`&&n===12&&(n=0)),n*60+r}function ZN(e,t,n){if(!e||!t)return 0;let r=XN(e,n);return XN(t,n)-r}function QN(e,t){return e?t===`12h`?!!(e.hour&&e.minutes&&e.type):!!(e.hour&&e.minutes):!1}function $N(e){if(!e||!e.includes(` - `))return{from:null,to:null};let t=e.split(` - `).map(e=>e.trim());return t.length!==2||t[0]===`--:--`||t[1]===`--:--`?{from:null,to:null}:{from:JN(t[0]),to:JN(t[1])}}var eP,tP,nP,rP,iP=c((()=>{eP=class{activePart=`from`;fromValue=null;toValue=null;previewValue=null;clockType;minDuration;maxDuration;emitter;constructor(e,t,n,r){this.clockType=e,this.minDuration=t,this.maxDuration=n,this.emitter=r}getActivePart(){return this.activePart}getFromValue(){return this.fromValue}getToValue(){return this.toValue}getPreviewValue(){return this.previewValue}setFromValue(e){this.fromValue=e}setToValue(e){this.toValue=e}setPreviewValue(e){this.previewValue=e}isFromComplete(){return QN(this.fromValue,this.clockType)}isToComplete(){return QN(this.toValue,this.clockType)}canSwitchToEnd(){return this.isFromComplete()}canConfirm(){return!this.isFromComplete()||!this.isToComplete()?!1:this.getDuration()>0}setActivePart(e){if(e===`to`&&!this.canSwitchToEnd())return!1;let t=this.activePart!==e;return this.activePart=e,t&&(this.previewValue=null),t}resetActivePart(){this.activePart=`from`,this.previewValue=null}getCurrentValue(){return this.previewValue?this.previewValue:this.activePart===`from`?this.fromValue:this.toValue}getSavedValue(){return this.activePart===`from`?this.fromValue:this.toValue}commitPreview(){this.previewValue&&=(this.activePart===`from`?this.fromValue=this.previewValue:this.toValue=this.previewValue,null)}getDuration(){return ZN(this.fromValue,this.toValue,this.clockType)}validate(){if(!this.fromValue||!this.toValue)return{valid:!0,duration:0};let e=this.getDuration(),t=!0;return this.minDuration!==void 0&&e<this.minDuration&&(t=!1),this.maxDuration!==void 0&&e>this.maxDuration&&(t=!1),this.emitter.emit(`range:validation`,{valid:t,duration:e,minDuration:this.minDuration,maxDuration:this.maxDuration}),{valid:t,duration:e}}getDisabledTimeForEndPart(){if(this.activePart===`from`||!this.fromValue||!this.isFromComplete())return null;let e=[],t=[],n=parseInt(this.fromValue.hour,10),r=parseInt(this.fromValue.minutes,10),i=this.fromValue.type;if(this.clockType===`24h`){for(let t=0;t<n;t++)e.push(t.toString().padStart(2,`0`));for(let e=0;e<r;e++)t.push(e.toString().padStart(2,`0`));return{hours:e,minutes:t,fromHour:n}}for(let e=0;e<r;e++)t.push(e.toString().padStart(2,`0`));return{hours:e,minutes:t,fromType:i,fromHour:n}}reset(){this.activePart=`from`,this.fromValue=null,this.toValue=null,this.previewValue=null}},tP=class{core;state;constructor(e,t){this.core=e,this.state=t}updateTabs(){let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(`.tp-ui-range-tab.tp-ui-range-from`),n=e.querySelector(`.tp-ui-range-tab.tp-ui-range-to`),r=this.state.getActivePart()===`from`,i=this.state.isFromComplete();t?.classList.toggle(`active`,r),n?.classList.toggle(`active`,!r),n?.classList.toggle(`disabled`,!i),t?.setAttribute(`aria-selected`,String(r)),n?.setAttribute(`aria-selected`,String(!r)),n?.setAttribute(`aria-disabled`,String(!i)),t?.setAttribute(`tabindex`,r?`0`:`-1`),n?.setAttribute(`tabindex`,r||!i?`-1`:`0`)}updateTimeDisplay(){let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(`.tp-ui-range-from-time`),n=e.querySelector(`.tp-ui-range-to-time`),r=this.state.getActivePart(),i=this.state.getPreviewValue(),a=this.state.getFromValue(),o=this.state.getToValue(),s=`--:--`;r===`from`&&i?s=YN(i):a&&(s=YN(a));let c=`--:--`;r===`to`&&i?c=YN(i):o&&(c=YN(o)),t&&(t.textContent=s),n&&(n.textContent=c)}updateOkButton(){let e=this.core.getOkButton();if(!e)return;let t=this.state.canConfirm();e.classList.toggle(`disabled`,!t),e.setAttribute(`aria-disabled`,String(!t))}updateInputValue(){let e=this.core.getInput();if(!e)return;let t=this.state.getFromValue(),n=this.state.getToValue();e.value=`${t?YN(t):`--:--`} - ${n?YN(n):`--:--`}`}syncClockToActivePart(){let e=this.state.getSavedValue(),t=this.core.getHour(),n=this.core.getMinutes();if(t&&(t.value=e?.hour??`12`),n&&(n.value=e?.minutes??`00`),this.core.options.clock.type===`12h`){let t=this.core.getAM(),n=this.core.getPM();e?.type===`AM`?(t?.classList.add(`active`),n?.classList.remove(`active`)):e?.type===`PM`?(n?.classList.add(`active`),t?.classList.remove(`active`)):(t?.classList.remove(`active`),n?.classList.remove(`active`))}n&&(n.blur(),n.classList.remove(`active`)),t&&t.click()}updateAll(){this.updateTabs(),this.updateTimeDisplay(),this.updateOkButton()}},nP=class{core;emitter;state;ui;cleanupHandlers=[];isSyncingAmPm=!1;boundHandleMinuteCommit;boundHandleConfirm;boundHandleUpdate;boundHandleAmPm;boundHandleClear;constructor(e,t){this.core=e,this.emitter=t;let{range:n,clock:r}=e.options;this.state=new eP(r.type,n?.minDuration,n?.maxDuration,t),this.ui=new tP(e,this.state),this.boundHandleMinuteCommit=this.handleMinuteCommit.bind(this),this.boundHandleConfirm=this.handleConfirm.bind(this),this.boundHandleUpdate=this.handleUpdate.bind(this),this.boundHandleAmPm=this.handleAmPm.bind(this),this.boundHandleClear=this.handleClear.bind(this)}get isEnabled(){return this.core.options.range?.enabled===!0}init(){if(!this.isEnabled)return;let{from:e,to:t}=$N(this.core.getInput()?.value||``);this.state.setFromValue(e),this.state.setToValue(t),this.state.setActivePart(`from`),this.state.setPreviewValue(null),this.bindEvents(),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll()}getActivePart(){return this.state.getActivePart()}setActivePart(e){this.isEnabled&&(this.state.setActivePart(e)&&this.emitter.emit(`range:switch`,{active:e,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent(),this.ui.updateAll())}getFromValue(){return this.state.getFromValue()}getToValue(){return this.state.getToValue()}getDisabledTimeForEndPart(){return this.isEnabled?this.state.getDisabledTimeForEndPart():null}getDuration(){return this.state.getDuration()}validateRange(){return this.isEnabled?this.state.validate():{valid:!0,duration:0}}canConfirm(){return this.isEnabled?this.state.canConfirm():!0}getFormattedRange(){let e=this.state.getFromValue(),t=this.state.getToValue();return!e||!t?null:{from:YN(e),to:YN(t)}}bindEvents(){let e=this.core.getModalElement();if(!e)return;let t=e.querySelector(`.tp-ui-range-tab.tp-ui-range-from`),n=e.querySelector(`.tp-ui-range-tab.tp-ui-range-to`);if(t){let e=()=>this.setActivePart(`from`);t.addEventListener(`click`,e),this.cleanupHandlers.push(()=>t.removeEventListener(`click`,e))}if(n){let e=()=>this.setActivePart(`to`);n.addEventListener(`click`,e),this.cleanupHandlers.push(()=>n.removeEventListener(`click`,e))}this.emitter.on(`update`,this.boundHandleUpdate),this.cleanupHandlers.push(()=>this.emitter.off(`update`,this.boundHandleUpdate)),this.emitter.on(`range:minute:commit`,this.boundHandleMinuteCommit),this.cleanupHandlers.push(()=>this.emitter.off(`range:minute:commit`,this.boundHandleMinuteCommit)),this.emitter.on(`confirm`,this.boundHandleConfirm),this.cleanupHandlers.push(()=>this.emitter.off(`confirm`,this.boundHandleConfirm)),this.emitter.on(`select:am`,this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off(`select:am`,this.boundHandleAmPm)),this.emitter.on(`select:pm`,this.boundHandleAmPm),this.cleanupHandlers.push(()=>this.emitter.off(`select:pm`,this.boundHandleAmPm)),this.emitter.on(`clear`,this.boundHandleClear),this.cleanupHandlers.push(()=>this.emitter.off(`clear`,this.boundHandleClear))}handleClear(){this.isEnabled&&(this.state.setFromValue(null),this.state.setToValue(null),this.state.setPreviewValue(null),this.state.resetActivePart())}handleUpdate(){if(!this.isEnabled)return;let e=this.core.getHour(),t=this.core.getMinutes(),n=this.core.getActiveTypeMode(),r=e?.value??`12`,i=this.state.getSavedValue(),a=i?.minutes&&i.minutes!==`--`?t?.value??`--`:`--`,o=this.core.options.clock.type===`12h`?n?.textContent??void 0:void 0;this.state.setPreviewValue({hour:r,minutes:a,type:o}),this.ui.updateAll()}handleMinuteCommit(e){if(!this.isEnabled)return;let t={hour:e.hour,minutes:e.minutes,type:e.type??void 0};this.state.getActivePart()===`from`?(this.state.setFromValue(t),this.state.setPreviewValue(null),this.state.isFromComplete()&&(this.state.setActivePart(`to`),this.emitter.emit(`range:switch`,{active:`to`,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent())):(this.state.setToValue(t),this.state.setPreviewValue(null)),this.state.validate(),this.ui.updateAll()}handleAmPm(){if(!this.isEnabled||this.isSyncingAmPm||this.core.options.clock.type!==`12h`)return;let e=this.core.getActiveTypeMode()?.textContent;if(e){if(this.state.getActivePart()===`from`){let t=this.state.getFromValue();t&&(this.state.setFromValue({...t,type:e}),this.state.isFromComplete()&&(this.state.setActivePart(`to`),this.state.setPreviewValue(null),this.emitter.emit(`range:switch`,{active:`to`,disabledTime:this.state.getDisabledTimeForEndPart()}),this.ui.syncClockToActivePart(),this.emitAmPmSyncEvent()))}else{let t=this.state.getToValue();t&&this.state.setToValue({...t,type:e}),this.emitter.emit(`range:switch`,{active:`to`,disabledTime:this.state.getDisabledTimeForEndPart()})}this.state.validate(),this.ui.updateAll()}}emitAmPmSyncEvent(){if(this.core.options.clock.type!==`12h`)return;let e=this.state.getSavedValue();if(e?.type){this.isSyncingAmPm=!0;try{e.type===`AM`?this.emitter.emit(`select:am`,{}):e.type===`PM`&&this.emitter.emit(`select:pm`,{})}finally{this.isSyncingAmPm=!1}}}handleConfirm(e){if(!this.isEnabled)return;this.state.commitPreview();let t=this.state.getFromValue(),n=this.state.getToValue(),r=t?YN(t):`--:--`,i=n?YN(n):`--:--`,a=this.state.getDuration();this.ui.updateInputValue(),this.emitter.emit(`range:confirm`,{from:r,to:i,duration:a})}reset(){this.state.reset()}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[],this.reset()}},rP={name:`range`,factory:(e,t)=>new nP(e,t),clearHandler:(e,t)=>{if(!e.options.range?.enabled)return;let n=e.getModalElement();if(!n)return;let r=n.querySelector(`.tp-ui-range-from`),i=n.querySelector(`.tp-ui-range-to`),a=n.querySelector(`.tp-ui-range-from-time`),o=n.querySelector(`.tp-ui-range-to-time`);a&&(a.textContent=`--:--`),o&&(o.textContent=`--:--`),r?.classList.add(`active`),i?.classList.remove(`active`),r?.setAttribute(`aria-selected`,`true`),i?.setAttribute(`aria-selected`,`false`),r?.setAttribute(`tabindex`,`0`),i?.setAttribute(`tabindex`,`-1`),i?.classList.add(`disabled`),i?.setAttribute(`aria-disabled`,`true`);let s=e.getHour();s&&s.focus(),t.emit(`range:switch`,{active:`from`,disabledTime:null})}}})),aP,oP,sP,cP=!1;async function lP(){if(!aP){let e=await Promise.resolve().then(()=>(KN(),pM));aP=e.TimepickerUI,oP=e.PluginRegistry,sP=(await Promise.resolve().then(()=>(iP(),qN))).RangePlugin,!cP&&oP&&sP&&(oP.register(sP),cP=!0)}}var uP=class{constructor(e){if(this.config={dayStartTime:`00:00`,dayEndTime:`23:59`,minuteIncrement:5,clockType:`12h`,...e},this.selectedStart=this.extractTimeAsHHMM(e.startTime),e.endTime)this.selectedEnd=this.extractTimeAsHHMM(e.endTime);else{let e=new Date(`2000-01-01T${this.selectedStart}:00Z`),n=new Date(e.getTime()+3600*1e3);this.selectedEnd=t.tools.dateTime.extractTime(n.toISOString())}this.inputElement=document.createElement(`input`),this.container=this.createUI()}extractTimeAsHHMM(e){return e.includes(`T`)?t.tools.dateTime.extractTime(e):e}createUI(){let e=document.createElement(`div`);return e.style.cssText=`
|
|
231
231
|
position: fixed;
|
|
232
232
|
left: -9999px;
|
|
233
233
|
top: -9999px;
|
|
@@ -237,14 +237,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
237
237
|
position: absolute;
|
|
238
238
|
left: 0;
|
|
239
239
|
top: 0;
|
|
240
|
-
`,e.appendChild(this.inputElement),e}async initTimePicker(){await
|
|
240
|
+
`,e.appendChild(this.inputElement),e}async initTimePicker(){await lP();let e=this.config.clockType??`12h`,[t,n]=this.selectedStart.split(`:`).map(Number),[r,i]=this.selectedEnd.split(`:`).map(Number);if(e===`24h`){let e=`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`,a=`${String(r).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`;this.inputElement.value=`${e} - ${a}`,this.inputElement.dataset.timeFrom=e,this.inputElement.dataset.timeTo=a}else{let e=t>=12?`PM`:`AM`,a=t===0?12:t>12?t-12:t,o=`${String(a).padStart(2,`0`)}:${String(n).padStart(2,`0`)} ${e}`,s=r>=12?`PM`:`AM`,c=r===0?12:r>12?r-12:r,l=`${String(c).padStart(2,`0`)}:${String(i).padStart(2,`0`)} ${s}`;this.inputElement.value=`${o} - ${l}`,this.inputElement.dataset.timeFrom=`${String(a).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`,this.inputElement.dataset.timeTo=`${String(c).padStart(2,`0`)}:${String(i).padStart(2,`0`)}`,this.inputElement.dataset.typeFrom=e,this.inputElement.dataset.typeTo=s}let a={enabled:!0,fromLabel:`Start`,toLabel:`End`};this.config.minDuration!==void 0&&(a.minDuration=this.config.minDuration),this.config.maxDuration!==void 0&&(a.maxDuration=this.config.maxDuration),this.picker=new aP(this.inputElement,{range:a,clock:{type:e,incrementMinutes:this.config.minuteIncrement||5},ui:{theme:`crane`},callbacks:{onRangeConfirm:e=>{try{let t=e.from,n=e.to;if(t&&n){let e=e=>{let t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(t){let e=parseInt(t[1],10),n=t[2],r=t[3].toUpperCase();return r===`PM`&&e!==12?e+=12:r===`AM`&&e===12&&(e=0),`${String(e).padStart(2,`0`)}:${n}`}let n=e.match(/(\d{1,2}):(\d{2})/);return n?`${n[1].padStart(2,`0`)}:${n[2]}`:`00:00`};this.selectedStart=e(t),this.selectedEnd=e(n),this.config.onConfirm(this.selectedStart,this.selectedEnd),this.destroy()}}catch(e){console.error(`[ModernTimePicker] Error in onRangeConfirm:`,e)}},onCancel:()=>{try{this.config.onCancel(),this.destroy()}catch(e){console.error(`[ModernTimePicker] Error in onCancel:`,e)}}}}),this.picker.create(),setTimeout(()=>{this.picker&&this.picker.open()},100)}async show(){document.body.appendChild(this.container),await this.initTimePicker()}destroy(){this.picker&&this.picker.destroy&&this.picker.destroy(),this.container.parentNode&&this.container.parentNode.removeChild(this.container)}};async function dP(e){let t=new uP(e);return await t.show(),t}var{BLOCK_TYPES:fP}=t.temporal,pP=`padding:6px 12px; cursor:pointer; display:flex; align-items:center; gap:8px;`,mP=`var(--chc-hover-bg)`,hP=`var(--chc-text-primary)`,gP=[[fP.MAINTENANCE,`Maintenance`],[fP.PRACTICE,`Practice`],[fP.RESERVED,`Reserved`],[fP.BLOCKED,`Blocked`]];function _P(){let e=null,t=null;function n(){e&&(e.destroy(),e=null,t=null)}function r(e){let t=document.createElement(`div`);t.style.cssText=`font-family:sans-serif; font-size:13px; min-width:150px;`;for(let r of e.blockTypes){let i=document.createElement(`div`);i.style.cssText=pP,i.innerHTML=`
|
|
241
241
|
<span style="width:10px;height:10px;border-radius:2px;background:${r.color};display:inline-block;"></span>
|
|
242
242
|
${r.label}
|
|
243
|
-
`,i.addEventListener(`mouseenter`,()=>{i.style.background=
|
|
243
|
+
`,i.addEventListener(`mouseenter`,()=>{i.style.background=mP,i.style.color=hP}),i.addEventListener(`mouseleave`,()=>{i.style.background=`transparent`,i.style.color=``}),i.addEventListener(`click`,()=>{e.onTypeSelected(r.type),n()}),t.appendChild(i)}if(e.onAdjustTime||e.onDelete){let e=document.createElement(`div`);e.style.cssText=`border-top:1px solid var(--chc-border-primary); margin:4px 0;`,t.appendChild(e)}if(e.onAdjustTime){let r=document.createElement(`div`);r.style.cssText=pP,r.innerHTML=`<span style="font-size:14px;">🕓</span> Adjust Time`,r.addEventListener(`mouseenter`,()=>{r.style.background=mP,r.style.color=hP}),r.addEventListener(`mouseleave`,()=>{r.style.background=`transparent`,r.style.color=``}),r.addEventListener(`click`,()=>{let t=e.onAdjustTime;n(),e.startTime&&e.endTime&&dP({startTime:e.startTime,endTime:e.endTime,dayStartTime:`06:00`,dayEndTime:`22:00`,minuteIncrement:5,onConfirm:(e,n)=>t(e,n),onCancel:()=>{}})}),t.appendChild(r)}if(e.onDelete){let r=document.createElement(`div`);r.style.cssText=`padding:6px 12px; cursor:pointer; display:flex; align-items:center; gap:8px; color:#e74c3c;`,r.innerHTML=`<span style="font-size:14px;">🗑</span> Delete`,r.addEventListener(`mouseenter`,()=>{r.style.background=`#fdecea`}),r.addEventListener(`mouseleave`,()=>{r.style.background=`transparent`}),r.addEventListener(`click`,()=>{let t=e.onDelete;n(),t()}),t.appendChild(r)}return t}function i(e){let{blockId:t,engine:r,day:i,onBlockChanged:a}=e,o=document.createElement(`div`);o.style.cssText=`font-family:sans-serif; font-size:13px; min-width:150px;`;for(let[e,s]of gP){let c=rM[e],l=document.createElement(`div`);l.style.cssText=pP,l.innerHTML=`
|
|
244
244
|
<span style="width:10px;height:10px;border-radius:2px;background:${c};display:inline-block;"></span>
|
|
245
245
|
${s}
|
|
246
|
-
`,l.addEventListener(`mouseenter`,()=>{l.style.background=QM,l.style.color=$M}),l.addEventListener(`mouseleave`,()=>{l.style.background=`transparent`,l.style.color=``}),l.addEventListener(`click`,()=>{let o=r.getDayBlocks(i).find(e=>e.id===t);o&&(r.removeBlock(t),r.applyBlock({courts:[o.court],timeRange:{start:o.start,end:o.end},type:e,reason:s}),a()),n()}),o.appendChild(l)}let s=document.createElement(`div`);s.style.cssText=`border-top:1px solid var(--chc-border-primary); margin:4px 0;`,o.appendChild(s);let c=document.createElement(`div`);c.style.cssText=ZM,c.innerHTML=`<span style="font-size:14px;">🕓</span> Adjust Time`,c.addEventListener(`mouseenter`,()=>{c.style.background=QM,c.style.color=$M}),c.addEventListener(`mouseleave`,()=>{c.style.background=`transparent`,c.style.color=``}),c.addEventListener(`click`,()=>{n();let e=r.getDayBlocks(i).find(e=>e.id===t);e&&YM({startTime:e.start,endTime:e.end,dayStartTime:`06:00`,dayEndTime:`22:00`,minuteIncrement:5,onConfirm:(n,i)=>{let o=e.start.slice(0,10);r.resizeBlock({blockId:t,newTimeRange:{start:`${o}T${n}:00`,end:`${o}T${i}:00`}}),a()},onCancel:()=>{}})}),o.appendChild(c);let l=document.createElement(`div`);return l.style.cssText=`padding:6px 12px; cursor:pointer; display:flex; align-items:center; gap:8px; color:#e74c3c;`,l.innerHTML=`<span style="font-size:14px;">🗑</span> Delete`,l.addEventListener(`mouseenter`,()=>{l.style.background=`#fdecea`}),l.addEventListener(`mouseleave`,()=>{l.style.background=`transparent`}),l.addEventListener(`click`,()=>{r.removeBlock(t),a(),n()}),o.appendChild(l),o}function a(r,i,a){n();let o=um(r,{content:i,allowHTML:!0,interactive:!0,trigger:`manual`,placement:`bottom`,appendTo:document.body,onHidden:()=>{e=null,t=null}});e=o,t=a,o.show()}return{show(e,i){if(t===i.itemId){n();return}a(e,r(i),i.itemId)},showForEngineBlock(e,r){if(t===r.itemId){n();return}a(e,i(r),r.itemId)},destroy(){n()},isActiveFor(e){return t===e}}}var nN={day:{label:`1 Day`,days:1,timeAxis:{scale:`hour`,step:1}},days3:{label:`3 Days`,days:3,timeAxis:{scale:`hour`,step:3}},week:{label:`Week`,days:7,timeAxis:{scale:`hour`,step:6}},all:{label:`Tournament`,days:0,timeAxis:{scale:`hour`,step:6}}};function rN(e,t,n,r){let i=r?.labels,a=document.createElement(`div`);a.className=`tg-view-toolbar`;let o=document.createElement(`span`);o.textContent=(i?.view??`View`)+`:`,o.className=`tg-view-toolbar-label`,a.appendChild(o);let s=document.createElement(`input`);s.type=`text`,s.readOnly=!0,s.className=`tg-view-toolbar-date`,n&&s.addEventListener(`changeDate`,()=>{let e=s.value;e&&n(e)}),a.appendChild(s);let c={day:i?.day1??`1 Day`,days3:i?.days3??`3 Days`,week:i?.week??`Week`,all:i?.tournament??`Tournament`},l=[],u=[],d=t||`day`,f=e=>{l.forEach((t,n)=>{u[n]===e?t.className=`sp-btn sp-btn--active`:t.className=`sp-btn`})};for(let[t]of Object.entries(nN)){let n=document.createElement(`button`);n.textContent=c[t],n.className=t===d?`sp-btn sp-btn--active`:`sp-btn`,n.addEventListener(`click`,()=>{f(t),e(t)}),l.push(n),u.push(t),a.appendChild(n)}if(r?.onSetDefaultAvailability||r?.onSave){let e=document.createElement(`div`);e.className=`tg-view-toolbar-spacer`,a.appendChild(e)}if(r?.onSetDefaultAvailability){let e=document.createElement(`button`);e.textContent=i?.setDefaultAvailability??`Set Default Availability`,e.className=`sp-btn sp-btn--fill-muted`,e.addEventListener(`click`,r.onSetDefaultAvailability),a.appendChild(e)}let p=null;return r?.onSave&&(p=document.createElement(`button`),p.textContent=i?.saveToTournament??`Save to Tournament`,p.className=`sp-btn sp-btn--fill`,p.disabled=!0,p.addEventListener(`click`,r.onSave),a.appendChild(p)),{element:a,dateInput:s,setActiveView:f,setDate:e=>{s.value=e},setSaveEnabled:e=>{p&&(p.disabled=!e)}}}var iN=class{constructor(e,t,n){this._dailyStartMin=0,this._dailyEndMin=1440,this._useDailyBounds=!1,this._visibleDays=null,this._visibleDayMs=null,this._start=e.getTime(),this._end=t.getTime(),this._width=Math.max(n,1),this._min=this._start,this._max=this._end,this._zoomMin=900*1e3,this._zoomMax=(this._end-this._start)*2}get start(){return new Date(this._start)}get end(){return new Date(this._end)}get width(){return this._width}get duration(){return this._end-this._start}get msPerPx(){if(!this._useDailyBounds)return this.duration/this._width;let e=this.toCollapsedMin(new Date(this._start)),t=this.toCollapsedMin(new Date(this._end))-e;return t<=0?1:t*60*1e3/this._width}getDailyBounds(){return this._useDailyBounds?{startMin:this._dailyStartMin,endMin:this._dailyEndMin}:null}getVisibleDays(){return this._visibleDays}timeToX(e){if(!this._useDailyBounds)return(e.getTime()-this._start)/this.duration*this._width;let t=this.toCollapsedMin(e),n=this.toCollapsedMin(new Date(this._start)),r=this.toCollapsedMin(new Date(this._end))-n;return r<=0?0:(t-n)/r*this._width}xToTime(e){if(!this._useDailyBounds){let t=e/this._width*this.duration;return new Date(this._start+t)}let t=this.toCollapsedMin(new Date(this._start)),n=this.toCollapsedMin(new Date(this._end))-t;if(n<=0)return new Date(this._start);let r=t+e/this._width*n;return this.fromCollapsedMin(r)}snap(e,t){let n=e.getTime(),r=t*60*1e3;return new Date(Math.round(n/r)*r)}setWindow(e,t){this._start=e.getTime(),this._end=t.getTime(),this.clampBounds()}setLimits(e){e.min!==void 0&&(this._min=e.min.getTime()),e.max!==void 0&&(this._max=e.max.getTime()),e.zoomMin!==void 0&&(this._zoomMin=e.zoomMin),e.zoomMax!==void 0&&(this._zoomMax=e.zoomMax)}setWidth(e){this._width=Math.max(e,1)}setDailyBounds(e,t){let[n,r]=e.split(`:`).map(Number),[i,a]=t.split(`:`).map(Number);this._dailyStartMin=n*60+r,this._dailyEndMin=i*60+a,this._useDailyBounds=!0}clearDailyBounds(){this._useDailyBounds=!1,this._dailyStartMin=0,this._dailyEndMin=1440,this._visibleDays=null,this._visibleDayMs=null}setVisibleDays(e){this._visibleDays=e,this._visibleDayMs=e.map(e=>new Date(e+`T00:00:00`).getTime())}clearVisibleDays(){this._visibleDays=null,this._visibleDayMs=null}pan(e){if(this._visibleDays)return;if(this._useDailyBounds){let t=this.toCollapsedMin(new Date(this._start)),n=this.toCollapsedMin(new Date(this._end)),r=n-t;if(r<=0)return;let i=e/this._width*r,a=this.fromCollapsedMin(t+i),o=this.fromCollapsedMin(n+i);this._start=a.getTime(),this._end=o.getTime(),this.clampBounds();return}let t=e*this.msPerPx,n=this._start+t,r=this._end+t;if(n<this._min){let e=this._min-n;n+=e,r+=e}if(r>this._max){let e=r-this._max;n-=e,r-=e}this._start=n,this._end=r}zoom(e,t){if(this._visibleDays)return;if(this._useDailyBounds){let n=this.toCollapsedMin(new Date(this._start)),r=this.toCollapsedMin(new Date(this._end))-n,i=n+t/this._width*r,a=r*e,o=this._zoomMin/(60*1e3),s=this._zoomMax/(60*1e3);a=Math.max(o,Math.min(s,a));let c=t/this._width,l=this.fromCollapsedMin(i-a*c),u=this.fromCollapsedMin(i+a*(1-c));this._start=l.getTime(),this._end=u.getTime(),this.clampBounds();return}let n=this._start+t/this._width*this.duration,r=this.duration*e;r=Math.max(this._zoomMin,Math.min(this._zoomMax,r));let i=t/this._width;this._start=n-r*i,this._end=n+r*(1-i),this.clampBounds()}toCollapsedMin(e){let t=this._dailyEndMin-this._dailyStartMin;if(t<=0)return 0;let n=e.getHours()*60+e.getMinutes()+e.getSeconds()/60,r=Math.max(this._dailyStartMin,Math.min(this._dailyEndMin,n))-this._dailyStartMin;if(this._visibleDays&&this._visibleDayMs){let n=new Date(e);n.setHours(0,0,0,0);let i=n.getTime(),a=-1;for(let e=0;e<this._visibleDayMs.length;e++)if(this._visibleDayMs[e]===i){a=e;break}if(a===-1){if(i<this._visibleDayMs[0])return 0;if(i>this._visibleDayMs[this._visibleDayMs.length-1])return this._visibleDayMs.length*t;for(let e=0;e<this._visibleDayMs.length-1;e++)if(i>this._visibleDayMs[e]&&i<this._visibleDayMs[e+1])return(e+1)*t;return 0}return a*t+r}let i=new Date(this._start);i.setHours(0,0,0,0);let a=new Date(e);return a.setHours(0,0,0,0),Math.round((a.getTime()-i.getTime())/(1440*60*1e3))*t+r}fromCollapsedMin(e){let t=this._dailyEndMin-this._dailyStartMin;if(t<=0)return new Date(this._start);let n=Math.floor(e/t),r=e-n*t;if(this._visibleDays&&this._visibleDayMs){let e=Math.max(0,Math.min(n,this._visibleDayMs.length-1)),t=new Date(this._visibleDayMs[e]),i=this._dailyStartMin+r;return t.setHours(Math.floor(i/60),Math.round(i%60),0,0),t}let i=new Date(this._start);i.setHours(0,0,0,0);let a=new Date(i);a.setDate(a.getDate()+n);let o=this._dailyStartMin+r;return a.setHours(Math.floor(o/60),Math.round(o%60),0,0),a}clampBounds(){let e=this._end-this._start;this._start<this._min&&(this._start=this._min,this._end=this._min+e),this._end>this._max&&(this._end=this._max,this._start=this._max-e),this._start<this._min&&(this._start=this._min),this._end>this._max&&(this._end=this._max)}},aN=`tg-tick-day`,oN=`tg-tick-hour`,sN=class{constructor(e,t){this.scale=e,this.tickConfig=cN(t),this.dayEl=document.createElement(`div`),this.dayEl.className=`tg-day-axis`,this.dayEl.setAttribute(`role`,`presentation`),this.hourEl=document.createElement(`div`),this.hourEl.className=`tg-hour-axis`,this.hourEl.setAttribute(`role`,`presentation`),this.dayEl.addEventListener(`click`,e=>{let t=(e.target.closest?.(`.${aN}`))?.dataset.day;t&&this.onDayClick&&this.onDayClick(t)})}getDayElement(){return this.dayEl}getHourElement(){return this.hourEl}setTimeAxisOptions(e){this.tickConfig=cN(e)}render(){this.renderDayLabels(),this.renderHourTicks()}renderDayLabels(){this.dayEl.innerHTML=``;let{dayFormat:e}=this.tickConfig,t=this.tickConfig.scale,n=this.scale.getDailyBounds();if(n&&t===`hour`){this.renderDayLabelsWithBounds(n,e);return}if(t===`hour`){let t=this.scale.start.getTime(),n=uN(t,this.scale.end.getTime());if(n.length===0){let n=new Date(t);n.setHours(0,0,0,0);let r=document.createElement(`div`);r.className=aN,r.style.left=`0px`,r.style.maxWidth=`${this.scale.width}px`,r.dataset.day=lN(n),r.textContent=e.format(n),this.dayEl.appendChild(r);return}for(let t of n){let n=this.scale.timeToX(t),r=document.createElement(`div`);r.className=aN,r.style.left=`${n}px`,r.dataset.day=lN(t),r.textContent=e.format(t),this.dayEl.appendChild(r)}}else if(t===`day`){let e=fN(this.scale.start.getTime(),this.scale.end.getTime());for(let t of e){let e=this.scale.timeToX(t),n=document.createElement(`div`);n.className=aN,n.style.left=`${e}px`,n.dataset.day=lN(t),n.textContent=this.tickConfig.dayFormat.format(t),this.dayEl.appendChild(n)}}}renderDayLabelsWithBounds(e,t){let n=this.getVisibleDayDates(e),r=this.scale.getVisibleDays(),i=n.length,a=i>0?this.scale.width/i:this.scale.width,o=a<150?new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`}):t;if(r&&r.length>0)for(let t of n){let n=new Date(t);n.setHours(0,0,0,0),n.setMinutes(e.startMin);let r=this.scale.timeToX(n),i=document.createElement(`div`);i.className=aN,i.style.left=`${r}px`,i.style.maxWidth=`${Math.floor(a)-4}px`,i.dataset.day=lN(t),i.textContent=o.format(n),this.dayEl.appendChild(i)}else{let t=this.scale.width;for(let r of n){let n=new Date(r);n.setHours(0,0,0,0),n.setMinutes(e.startMin);let i=new Date(r);i.setHours(0,0,0,0),i.setDate(i.getDate()+1),i.setMinutes(e.startMin);let a=this.scale.timeToX(n),s=this.scale.timeToX(i),c=Math.max(a,0),l=Math.min(s,t)-c;if(l<=0)continue;let u=document.createElement(`div`);u.className=aN,u.style.left=`${c}px`,u.style.maxWidth=`${l}px`,u.dataset.day=lN(r),u.textContent=o.format(n),this.dayEl.appendChild(u)}}}renderHourTicks(){this.hourEl.innerHTML=``;let{hourFormat:e}=this.tickConfig,t=this.tickConfig.scale,n=this.tickConfig.step,r=this.scale.getDailyBounds();if(r&&t===`hour`){this.renderHourTicksWithBounds(r,n,e);return}let i=this.scale.start.getTime(),a=this.scale.end.getTime();if(t===`hour`){let t=new Set(uN(i,a).map(e=>e.getTime())),r=dN(i,a,n);for(let n of r){if(t.has(n.getTime()))continue;let r=this.scale.timeToX(n),i=document.createElement(`div`);i.className=oN,i.style.left=`${r}px`,i.textContent=e.format(n),this.hourEl.appendChild(i)}}else if(t===`day`){let e=new Set(fN(i,a).map(e=>e.getTime())),t=uN(i,a);for(let n of t){if(e.has(n.getTime()))continue;let t=this.scale.timeToX(n),r=document.createElement(`div`);r.className=oN,r.style.left=`${t}px`,r.textContent=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`}).format(n),this.hourEl.appendChild(r)}}}renderHourTicksWithBounds(e,t,n){let r=this.getVisibleDayDates(e);for(let i of r){let r=new Date(i);r.setHours(0,0,0,0),r.setMinutes(e.startMin);let a=new Date(i);a.setHours(0,0,0,0),a.setMinutes(e.endMin);let o=Math.ceil(e.startMin/60),s=new Date(i);for(s.setHours(o,0,0,0),s.getHours()%t!==0&&s.setHours(s.getHours()+(t-s.getHours()%t));s.getTime()<=a.getTime();){if(s.getTime()!==r.getTime()){let e=this.scale.timeToX(s),t=document.createElement(`div`);t.className=oN,t.style.left=`${e}px`,t.textContent=n.format(s),this.hourEl.appendChild(t)}s.setHours(s.getHours()+t)}}}getVisibleDayDates(e){let t=this.scale.getVisibleDays();if(t&&t.length>0)return t.map(e=>new Date(e+`T00:00:00`));let n=this.scale.start.getTime(),r=this.scale.end.getTime(),i=[],a=new Date(n);for(a.setHours(0,0,0,0);;){let t=new Date(a);if(t.setHours(0,0,0,0),t.setMinutes(e.endMin),t.getTime()<n){a.setDate(a.getDate()+1);continue}let o=new Date(a);if(o.setHours(0,0,0,0),o.setMinutes(e.startMin),o.getTime()>r)break;i.push(new Date(a)),a.setDate(a.getDate()+1)}return i}renderGridlines(e,t){e.querySelectorAll(`.tg-gridline`).forEach(e=>e.remove());let n=this.computeTickPositions();for(let{x:r,isMajor:i}of n){let n=document.createElement(`div`);n.className=i?`tg-gridline tg-gridline-major`:`tg-gridline`,n.style.left=`${r}px`,n.style.height=`${t}px`,e.appendChild(n)}}computeTickPositions(){let e=[],t=this.tickConfig.scale,n=this.tickConfig.step,r=this.scale.getDailyBounds(),i=this.scale.start.getTime(),a=this.scale.end.getTime();if(r&&t===`hour`){let t=this.getVisibleDayDates(r);for(let i of t){let t=new Date(i);t.setHours(0,0,0,0),t.setMinutes(r.startMin);let a=new Date(i);a.setHours(0,0,0,0),a.setMinutes(r.endMin),e.push({x:this.scale.timeToX(t),isMajor:!0});let o=Math.ceil(r.startMin/60),s=new Date(i);for(s.setHours(o,0,0,0),s.getHours()%n!==0&&s.setHours(s.getHours()+(n-s.getHours()%n));s.getTime()<=a.getTime();)s.getTime()!==t.getTime()&&e.push({x:this.scale.timeToX(s),isMajor:!1}),s.setHours(s.getHours()+n)}}else if(t===`hour`){let t=uN(i,a),r=new Set(t.map(e=>e.getTime()));for(let n of t)e.push({x:this.scale.timeToX(n),isMajor:!0});for(let t of dN(i,a,n))r.has(t.getTime())||e.push({x:this.scale.timeToX(t),isMajor:!1})}else if(t===`day`){let t=fN(i,a),n=new Set(t.map(e=>e.getTime()));for(let n of t)e.push({x:this.scale.timeToX(n),isMajor:!0});for(let t of uN(i,a))n.has(t.getTime())||e.push({x:this.scale.timeToX(t),isMajor:!1})}return e}destroy(){this.dayEl.remove(),this.hourEl.remove()}};function cN(e){let t=e?.scale??`hour`,n=e?.step??1;switch(t){case`hour`:return{scale:t,step:n,hourFormat:new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),dayFormat:new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`})};case`day`:return{scale:t,step:n,hourFormat:new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`}),dayFormat:new Intl.DateTimeFormat(void 0,{month:`long`,year:`numeric`})};default:return{scale:`hour`,step:1,hourFormat:new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),dayFormat:new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`})}}}function lN(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function uN(e,t){let n=[],r=new Date(e);for(r.setHours(0,0,0,0);r.getTime()<=t;)r.getTime()>=e&&n.push(new Date(r)),r.setDate(r.getDate()+1);return n}function dN(e,t,n){let r=[],i=new Date(e);i.setMinutes(0,0,0);let a=i.getHours();for(i.setHours(a-a%n);i.getTime()<=t;)i.getTime()>=e&&r.push(new Date(i)),i.setHours(i.getHours()+n);return r}function fN(e,t){let n=[],r=new Date(e);r.setHours(0,0,0,0);let i=r.getDay(),a=i===0?6:i-1;for(r.setDate(r.getDate()-a);r.getTime()<=t;)r.getTime()>=e&&n.push(new Date(r)),r.setDate(r.getDate()+7);return n}var pN=class{constructor(e=40){this.groups=[],this.groupIndex=new Map,this.rowHeight=e,this.labelPanel=document.createElement(`div`),this.labelPanel.className=`tg-label-panel`,this.labelPanel.setAttribute(`role`,`rowheader`),this.contentArea=document.createElement(`div`),this.contentArea.className=`tg-content`,this.contentArea.setAttribute(`role`,`grid`)}getLabelPanel(){return this.labelPanel}getContentArea(){return this.contentArea}getRowHeight(){return this.rowHeight}getGroups(){return this.groups}getGroupCount(){return this.groups.length}getGroupAtIndex(e){return this.groups[e]}yToGroupId(e){let t=Math.floor(e/this.rowHeight);return t<0||t>=this.groups.length?null:this.groups[t].id}groupIdToRowIndex(e){return this.groupIndex.get(e)??-1}getRowRange(e,t){let n=Math.max(0,Math.floor(Math.min(e,t)/this.rowHeight)),r=Math.min(this.groups.length-1,Math.floor(Math.max(e,t)/this.rowHeight)),i=[];for(let e=n;e<=r;e++)i.push(this.groups[e].id);return i}getRowTop(e){return e*this.rowHeight}setGroups(e){this.groups=e.slice().sort((e,t)=>e.order!==void 0&&t.order!==void 0?e.order-t.order:e.order===void 0?t.order===void 0?e.content.localeCompare(t.content,void 0,{numeric:!0}):1:-1),this.groupIndex.clear();for(let e=0;e<this.groups.length;e++)this.groupIndex.set(this.groups[e].id,e)}render(){this.renderLabels(),this.renderRows()}renderLabels(){this.labelPanel.innerHTML=``;for(let e of this.groups){let t=document.createElement(`div`);t.className=`tg-label`,t.style.height=`${this.rowHeight}px`,t.textContent=e.content,t.title=e.content,t.dataset.groupId=e.id,this.labelPanel.appendChild(t)}}renderRows(){this.contentArea.querySelectorAll(`.tg-row`).forEach(e=>e.remove());for(let e=0;e<this.groups.length;e++){let t=document.createElement(`div`);t.className=`tg-row`,t.style.height=`${this.rowHeight}px`,t.style.top=`${e*this.rowHeight}px`,t.dataset.groupId=this.groups[e].id,this.contentArea.appendChild(t)}this.contentArea.style.height=`${this.groups.length*this.rowHeight}px`}destroy(){this.labelPanel.remove(),this.contentArea.remove()}},mN=class{constructor(e,t){this.items=[],this.itemElements=new Map,this.ghostEl=null,this.ghostCountBadge=null,this.scale=e,this.layout=t,this.contentArea=t.getContentArea()}setItems(e){this.items=e}render(){for(let e of this.itemElements.values())e.remove();this.itemElements.clear(),this.contentArea.querySelectorAll(`[data-item-id]`).forEach(e=>{e.dataset.itemId!==`__ghost__`&&e.remove()});for(let e of this.items){let t=this.renderItem(e);t&&(this.contentArea.appendChild(t),this.itemElements.set(e.id,t))}}renderItem(e){let t=this.layout.groupIdToRowIndex(e.group);if(t===-1)return null;let n=e.start instanceof Date?e.start:new Date(e.start),r=e.end?e.end instanceof Date?e.end:new Date(e.end):n,i=this.scale.timeToX(n),a=this.scale.timeToX(r)-i,o=this.layout.getRowTop(t),s=this.layout.getRowHeight();if(a<.5)return null;let c=document.createElement(`div`);if(c.dataset.itemId=e.id,c.title=e.title||e.content,e.type===`background`||e.isSegment)c.className=`tg-item-background ${e.className||``}`.trim(),e.style&&(c.style.cssText=e.style),c.style.position=`absolute`,c.style.left=`${i}px`,c.style.top=`${o}px`,c.style.width=`${a}px`,c.style.height=`${s}px`,c.style.pointerEvents=`none`;else{c.className=`tg-item tg-item-range ${e.className||``}`.trim(),e.style&&(c.style.cssText+=e.style),c.style.position=`absolute`,c.style.left=`${i}px`,c.style.top=`${o+2}px`,c.style.width=`${a}px`,c.style.height=`${s-4}px`,c.style.cursor=`move`;let t=document.createElement(`span`);t.className=`tg-item-content`,t.textContent=e.content,c.appendChild(t);let n=document.createElement(`div`);n.className=`tg-resize-handle tg-resize-left`,n.dataset.handle=`left`,c.appendChild(n);let r=document.createElement(`div`);r.className=`tg-resize-handle tg-resize-right`,r.dataset.handle=`right`,c.appendChild(r)}return c}updateItemPosition(e,t,n,r){let i=this.itemElements.get(e);i&&(i.style.left=`${t}px`,i.style.top=`${n+2}px`,i.style.width=`${r}px`)}showGhost(e){if(!this.ghostEl){this.ghostEl=document.createElement(`div`),this.ghostEl.className=`tg-ghost`,this.ghostEl.dataset.itemId=`__ghost__`;for(let e of[`left`,`right`,`top`,`bottom`]){let t=document.createElement(`div`);t.className=`tg-resize-handle tg-resize-${e}`,t.dataset.handle=e,this.ghostEl.appendChild(t)}this.ghostCountBadge=document.createElement(`div`),this.ghostCountBadge.className=`tg-ghost-count`,this.ghostEl.appendChild(this.ghostCountBadge),this.contentArea.appendChild(this.ghostEl)}let t=this.scale.timeToX(e.startTime),n=this.scale.timeToX(e.endTime)-t,r=this.layout.getRowHeight(),i=e.topRowIndex*r,a=(e.bottomRowIndex-e.topRowIndex+1)*r,o=e.bottomRowIndex-e.topRowIndex+1;this.ghostEl.style.left=`${t}px`,this.ghostEl.style.top=`${i}px`,this.ghostEl.style.width=`${n}px`,this.ghostEl.style.height=`${a}px`,this.ghostEl.style.display=`block`,this.ghostCountBadge&&(this.ghostCountBadge.textContent=`${o} court${o>1?`s`:``}`,this.ghostCountBadge.style.display=o>1?`flex`:`none`)}clearGhost(){this.ghostEl&&(this.ghostEl.remove(),this.ghostEl=null,this.ghostCountBadge=null)}isGhostVisible(){return this.ghostEl!==null&&this.ghostEl.style.display!==`none`}highlightRows(e){this.clearHighlights();for(let t of e){let e=this.contentArea.querySelectorAll(`.tg-row`);e[t]&&e[t].classList.add(`tg-row-highlight`)}}clearHighlights(){this.contentArea.querySelectorAll(`.tg-row-highlight`).forEach(e=>{e.classList.remove(`tg-row-highlight`)})}static hitTest(e){if(!(e instanceof HTMLElement))return{itemId:null,handle:null};let t=e.closest(`.tg-resize-handle`)?.dataset.handle??null;return{itemId:e.closest(`[data-item-id]`)?.dataset.itemId??null,handle:t}}destroy(){this.clearGhost(),this.clearHighlights();for(let e of this.itemElements.values())e.remove();this.itemElements.clear()}},hN=3,gN=30,_N=8,vN=3600*1e3,yN=class{constructor(e,t,n,r,i=5,a=!1){this.mode=`IDLE`,this.gesture=null,this.items=[],this.ghostStartTime=null,this.ghostEndTime=null,this.ghostTopRow=0,this.ghostBottomRow=0,this.justDragged=!1,this.autoScrollRaf=null,this.autoScrollDelta=0,this.scrollContainer=null,this.onPointerDown=e=>{if(e.button!==0)return;let{itemId:t,handle:n}=mN.hitTest(e.target);if(this.mode===`GHOST_EDITING`){if(t===`__ghost__`&&n){this.startGesture(e,`__ghost__`,n===`left`?`RESIZING_LEFT`:n===`right`?`RESIZING_RIGHT`:n===`top`?`RESIZING_TOP`:`RESIZING_BOTTOM`);return}if(t===`__ghost__`&&!n){this.confirmGhost();return}this.cancelGhost();return}if(t)if(n===`left`)this.startGesture(e,t,`RESIZING_LEFT`);else if(n===`right`)this.startGesture(e,t,`RESIZING_RIGHT`);else{let n=this.items.find(e=>e.id===t);if(!n||n.isSegment||n.type===`background`)return;this.startGesture(e,t,`DRAGGING`)}},this.onPointerMove=e=>{if(this.gesture){if(this.gesture.currentX=e.clientX,this.gesture.currentY=e.clientY,!this.gesture.thresholdExceeded){let t=Math.abs(e.clientX-this.gesture.startX),n=Math.abs(e.clientY-this.gesture.startY);if(t<hN&&n<hN)return;this.gesture.thresholdExceeded=!0}switch(this.checkAutoScroll(e),this.mode){case`DRAGGING`:this.handleDragMove(e);break;case`RESIZING_LEFT`:case`RESIZING_RIGHT`:this.gesture.itemId===`__ghost__`?this.handleGhostTimeResize(e):this.handleResizeMove(e);break;case`RESIZING_TOP`:case`RESIZING_BOTTOM`:this.handleGhostRowResize(e);break}}},this.onPointerUp=e=>{if(document.removeEventListener(`pointermove`,this.onPointerMove),document.removeEventListener(`pointerup`,this.onPointerUp),this.stopAutoScroll(),!this.gesture){this.mode=`IDLE`;return}let t=this.gesture.itemId===`__ghost__`;if(!this.gesture.thresholdExceeded&&!t){this.gesture.itemId&&this.callbacks.onItemClick?.(this.gesture.itemId,e),this.gesture=null,this.mode=`IDLE`,this.renderer.clearHighlights();return}if(t){this.gesture=null,this.mode=`GHOST_EDITING`;return}if(this.gesture.itemId&&this.gesture.thresholdExceeded){this.justDragged=!0,setTimeout(()=>this.justDragged=!1,300);let t=(e.clientX-this.gesture.startX)*this.scale.msPerPx,n=this.gesture.originalEnd.getTime()-this.gesture.originalStart.getTime(),r,i,a=this.gesture.originalGroup;if(this.mode===`DRAGGING`){r=this.scale.snap(new Date(this.gesture.originalStart.getTime()+t),this.snapMinutes),i=new Date(r.getTime()+n);let o=this.contentArea.getBoundingClientRect(),s=e.clientY-o.top+this.contentArea.scrollTop;a=this.layout.yToGroupId(s)||this.gesture.originalGroup}else this.mode===`RESIZING_LEFT`?(r=this.scale.snap(new Date(this.gesture.originalStart.getTime()+t),this.snapMinutes),i=this.gesture.originalEnd,r>=i&&(r=new Date(i.getTime()-this.snapMinutes*60*1e3))):(r=this.gesture.originalStart,i=this.scale.snap(new Date(this.gesture.originalEnd.getTime()+t),this.snapMinutes),i<=r&&(i=new Date(r.getTime()+this.snapMinutes*60*1e3)));this.callbacks.onMove?.({id:this.gesture.itemId,group:a,start:r,end:i})}this.gesture=null,this.mode=`IDLE`,this.renderer.clearHighlights()},this.onDblClick=e=>{if(this.justDragged)return;let{itemId:t}=mN.hitTest(e.target);if(t)return;let n=this.contentArea.getBoundingClientRect(),r=e.clientX-n.left+this.contentArea.scrollLeft,i=e.clientY-n.top+this.contentArea.scrollTop,a=this.scale.xToTime(r),o=this.scale.snap(a,this.snapMinutes),s=new Date(o.getTime()+vN),c=this.layout.yToGroupId(i);if(!c)return;let l=this.layout.groupIdToRowIndex(c);l<0||(this.ghostStartTime=o,this.ghostEndTime=s,this.ghostTopRow=l,this.ghostBottomRow=l,this.mode=`GHOST_EDITING`,this.renderer.showGhost({startTime:o,endTime:s,topRowIndex:l,bottomRowIndex:l}),this.renderer.highlightRows([l]))},this.onWheel=e=>{if(!((e.ctrlKey||e.metaKey)&&!this.enablePinchZoom)){if(e.preventDefault(),(e.ctrlKey||e.metaKey)&&this.enablePinchZoom){let t=e.deltaY>0?1.15:.87,n=this.contentArea.getBoundingClientRect(),r=e.clientX-n.left;this.scale.zoom(t,r)}else if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)){let t=e.deltaX||e.deltaY;this.scale.pan(t)}else{this.scrollContainer&&(this.scrollContainer.scrollTop+=e.deltaY);return}this.onScaleChanged?.()}},this.onScaleChanged=null,this.onKeyDown=e=>{e.key===`Escape`&&this.mode===`GHOST_EDITING`&&this.cancelGhost()},this.scale=e,this.layout=t,this.renderer=n,this.contentArea=t.getContentArea(),this.wheelTarget=this.contentArea,this.callbacks=r,this.snapMinutes=i,this.enablePinchZoom=a}setItems(e){this.items=e}setScrollContainer(e){this.scrollContainer=e}setWheelTarget(e){this.wheelTarget=e}attach(){this.contentArea.addEventListener(`pointerdown`,this.onPointerDown),this.contentArea.addEventListener(`dblclick`,this.onDblClick),this.wheelTarget.addEventListener(`wheel`,this.onWheel,{passive:!1}),document.addEventListener(`keydown`,this.onKeyDown)}detach(){this.contentArea.removeEventListener(`pointerdown`,this.onPointerDown),this.contentArea.removeEventListener(`dblclick`,this.onDblClick),this.wheelTarget.removeEventListener(`wheel`,this.onWheel),document.removeEventListener(`keydown`,this.onKeyDown),document.removeEventListener(`pointermove`,this.onPointerMove),document.removeEventListener(`pointerup`,this.onPointerUp),this.stopAutoScroll()}getMode(){return this.mode}startGesture(e,t,n){e.preventDefault();let r=this.items.find(e=>e.id===t),i,a,o;if(t===`__ghost__`)i=this.ghostStartTime,a=this.ghostEndTime,o=``;else if(r)i=r.start instanceof Date?r.start:new Date(r.start),a=r.end?r.end instanceof Date?r.end:new Date(r.end):i,o=r.group;else return;this.gesture={mode:n,itemId:t,startX:e.clientX,startY:e.clientY,originalStart:i,originalEnd:a,originalGroup:o,currentX:e.clientX,currentY:e.clientY,thresholdExceeded:!1},this.mode=n,this.contentArea.setPointerCapture(e.pointerId),document.addEventListener(`pointermove`,this.onPointerMove),document.addEventListener(`pointerup`,this.onPointerUp)}handleDragMove(e){if(!this.gesture||!this.gesture.itemId)return;let t=(e.clientX-this.gesture.startX)*this.scale.msPerPx,n=this.gesture.originalEnd.getTime()-this.gesture.originalStart.getTime(),r=this.scale.snap(new Date(this.gesture.originalStart.getTime()+t),this.snapMinutes),i=new Date(r.getTime()+n),a=this.contentArea.getBoundingClientRect(),o=e.clientY-a.top+this.contentArea.scrollTop,s=this.layout.yToGroupId(o)||this.gesture.originalGroup;if(this.callbacks.onMoving){let e=this.callbacks.onMoving({id:this.gesture.itemId,group:s,start:r,end:i});if(e===null)return;r=e.start,i=e.end}let c=this.scale.timeToX(r),l=this.scale.timeToX(i)-c,u=this.layout.groupIdToRowIndex(s),d=this.layout.getRowTop(u>=0?u:0);this.renderer.updateItemPosition(this.gesture.itemId,c,d,l),u>=0&&this.renderer.highlightRows([u])}handleResizeMove(e){if(!this.gesture||!this.gesture.itemId)return;let t=(e.clientX-this.gesture.startX)*this.scale.msPerPx,n=this.gesture.originalStart,r=this.gesture.originalEnd;if(this.mode===`RESIZING_LEFT`?(n=this.scale.snap(new Date(this.gesture.originalStart.getTime()+t),this.snapMinutes),n>=r&&(n=new Date(r.getTime()-this.snapMinutes*60*1e3))):(r=this.scale.snap(new Date(this.gesture.originalEnd.getTime()+t),this.snapMinutes),r<=n&&(r=new Date(n.getTime()+this.snapMinutes*60*1e3))),this.callbacks.onMoving){let e=this.callbacks.onMoving({id:this.gesture.itemId,group:this.gesture.originalGroup,start:n,end:r});if(e===null)return;n=e.start,r=e.end}let i=this.scale.timeToX(n),a=this.scale.timeToX(r)-i,o=this.layout.groupIdToRowIndex(this.gesture.originalGroup),s=this.layout.getRowTop(o>=0?o:0);this.renderer.updateItemPosition(this.gesture.itemId,i,s,a)}handleGhostTimeResize(e){if(!this.gesture)return;let t=this.contentArea.getBoundingClientRect(),n=e.clientX-t.left+this.contentArea.scrollLeft,r=this.scale.snap(this.scale.xToTime(n),this.snapMinutes);this.mode===`RESIZING_LEFT`?r<this.ghostEndTime&&(this.ghostStartTime=r):r>this.ghostStartTime&&(this.ghostEndTime=r),this.updateGhostDisplay()}handleGhostRowResize(e){if(!this.gesture)return;let t=this.contentArea.getBoundingClientRect(),n=e.clientY-t.top+this.contentArea.scrollTop,r=Math.floor(n/this.layout.getRowHeight()),i=Math.max(0,Math.min(this.layout.getGroupCount()-1,r));this.mode===`RESIZING_TOP`?i<=this.ghostBottomRow&&(this.ghostTopRow=i):i>=this.ghostTopRow&&(this.ghostBottomRow=i),this.updateGhostDisplay()}updateGhostDisplay(){this.renderer.showGhost({startTime:this.ghostStartTime,endTime:this.ghostEndTime,topRowIndex:this.ghostTopRow,bottomRowIndex:this.ghostBottomRow});let e=[];for(let t=this.ghostTopRow;t<=this.ghostBottomRow;t++)e.push(t);this.renderer.highlightRows(e)}confirmGhost(){if(!this.ghostStartTime||!this.ghostEndTime){this.cancelGhost();return}let e=[];for(let t=this.ghostTopRow;t<=this.ghostBottomRow;t++){let n=this.layout.getGroupAtIndex(t);n&&e.push(n.id)}if(e.length===0){this.cancelGhost();return}let t={groupIds:e,topRowIndex:this.ghostTopRow,bottomRowIndex:this.ghostBottomRow,startTime:this.ghostStartTime,endTime:this.ghostEndTime};this.renderer.clearGhost(),this.renderer.clearHighlights(),this.mode=`IDLE`,this.callbacks.onMultiRowCreate?.(t),this.ghostStartTime=null,this.ghostEndTime=null}cancelGhost(){this.renderer.clearGhost(),this.renderer.clearHighlights(),this.mode=`IDLE`,this.ghostStartTime=null,this.ghostEndTime=null}checkAutoScroll(e){if(!this.scrollContainer)return;let t=this.scrollContainer.getBoundingClientRect(),n=t.bottom-e.clientY,r=e.clientY-t.top;n<gN?(this.autoScrollDelta=_N*(1-n/gN),this.startAutoScroll()):r<gN?(this.autoScrollDelta=-_N*(1-r/gN),this.startAutoScroll()):this.stopAutoScroll()}startAutoScroll(){if(this.autoScrollRaf!==null)return;let e=()=>{this.scrollContainer&&(this.scrollContainer.scrollTop+=this.autoScrollDelta,this.autoScrollRaf=requestAnimationFrame(e))};this.autoScrollRaf=requestAnimationFrame(e)}stopAutoScroll(){this.autoScrollRaf!==null&&(cancelAnimationFrame(this.autoScrollRaf),this.autoScrollRaf=null),this.autoScrollDelta=0}},bN=class{constructor(e,t,n,r={}){this.callbacks={},this.resizeObserver=null,this._batchUpdating=!1,this.eventListeners=new Map,this.options={rowHeight:40,...r};let i=new Date,a=r.start||i,o=r.end||new Date(i.getTime()+720*60*1e3),s=e.clientWidth||800;this.scale=new iN(a,o,s),(r.min||r.max||r.zoomMin||r.zoomMax)&&this.scale.setLimits({min:r.min,max:r.max,zoomMin:r.zoomMin,zoomMax:r.zoomMax}),this.timeAxis=new sN(this.scale,r.timeAxis),this.layout=new pN(this.options.rowHeight),this.renderer=new mN(this.scale,this.layout),this.interaction=new yN(this.scale,this.layout,this.renderer,this.callbacks,5,r.enablePinchZoom??!1),this.rootEl=document.createElement(`div`),this.rootEl.className=`tg-timeline`,r.height&&(this.rootEl.style.height=r.height);let c=document.createElement(`div`);c.className=`tg-axis-header`;let l=document.createElement(`div`);l.className=`tg-axis-spacer`,c.appendChild(l),c.appendChild(this.timeAxis.getDayElement()),c.appendChild(this.timeAxis.getHourElement()),this.rootEl.appendChild(c),this.bodyEl=document.createElement(`div`),this.bodyEl.className=`tg-body`,this.bodyEl.appendChild(this.layout.getLabelPanel());let u=document.createElement(`div`);u.className=`tg-scroll-wrapper`,u.appendChild(this.layout.getContentArea()),this.bodyEl.appendChild(u),this.rootEl.appendChild(this.bodyEl),e.appendChild(this.rootEl),u.addEventListener(`scroll`,()=>{this.layout.getLabelPanel().scrollTop=u.scrollTop}),this.interaction.setScrollContainer(u),this.interaction.setWheelTarget(this.rootEl),this.interaction.onScaleChanged=()=>this.renderAll(),this.layout.setGroups(n),this.renderer.setItems(t),this.interaction.setItems(t),this.interaction.attach(),this.renderAll(),this.resizeObserver=new ResizeObserver(()=>{let t=u.clientWidth||e.clientWidth;this.scale.setWidth(t),this.renderAll()}),this.resizeObserver.observe(u)}setGroups(e){this.layout.setGroups(e),this.renderAll()}setItems(e){this.renderer.setItems(e),this.interaction.setItems(e),this.renderAll()}setWindow(e,t,n){this.scale.setWindow(e,t),this.renderAll()}setOptions(e){(e.min!==void 0||e.max!==void 0||e.zoomMin!==void 0||e.zoomMax!==void 0)&&this.scale.setLimits({min:e.min,max:e.max,zoomMin:e.zoomMin,zoomMax:e.zoomMax}),e.timeAxis&&this.timeAxis.setTimeAxisOptions(e.timeAxis),e.rowHeight!==void 0&&(this.options.rowHeight=e.rowHeight),Object.assign(this.options,e),this.renderAll()}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(t),e===`click`&&(this.callbacks.onItemClick=(e,t)=>{this.emit(`click`,{item:e,event:t})})}off(e,t){this.eventListeners.get(e)?.delete(t)}emit(e,t){let n=this.eventListeners.get(e);if(n)for(let e of n)e(t)}onMultiRowCreate(e){this.callbacks.onMultiRowCreate=e}onAdd(e){this.callbacks.onAdd=e}onMove(e){this.callbacks.onMove=e}onMoving(e){this.callbacks.onMoving=e}onDayClick(e){this.timeAxis.onDayClick=e}getContentElement(){return this.layout.getContentArea()}setDailyBounds(e,t){this.scale.setDailyBounds(e,t),this.renderAll()}clearDailyBounds(){this.scale.clearDailyBounds(),this.renderAll()}setVisibleDays(e){this.scale.setVisibleDays(e),this.renderAll()}clearVisibleDays(){this.scale.clearVisibleDays(),this.renderAll()}beginBatchUpdate(){this._batchUpdating=!0}endBatchUpdate(){this._batchUpdating=!1,this.renderAll()}renderAll(){if(this._batchUpdating)return;this.timeAxis.render(),this.layout.render(),this.renderer.render();let e=this.layout.getContentArea(),t=this.layout.getGroupCount()*(this.options.rowHeight??40);this.timeAxis.renderGridlines(e,t)}destroy(){this.interaction.detach(),this.resizeObserver?.disconnect(),this.timeAxis.destroy(),this.layout.destroy(),this.renderer.destroy(),this.rootEl.remove(),this.eventListeners.clear()}},{BLOCK_TYPES:xN}=t.temporal,SN=class{constructor(e,t){this.timeline=null,this.unsubscribe=null,this.currentItems=new Map,this.isRendering=!1,this.popoverManager=tN(),this.viewState=new BA,this.currentDay=null,this.currentView=`day`,this.selectedCourts=new Set,this.visibleCourts=null,this.handleOnMove=e=>{let t=YA(e.id);if(!t)return!1;let n=JA(e.group),r=this.toLocalISO(e.start),i=this.toLocalISO(e.end),a=this.engine.moveBlock({blockId:t,newTimeRange:{start:r,end:i},newCourt:n||void 0});return a.conflicts.some(e=>e.severity===`ERROR`)?(this.showConflictDialog(a.conflicts),!1):(this.render(),!0)},this.handleOnMoving=e=>{this.popoverManager.destroy();let t=this.currentItems.get(e.id);if(t&&(t.isSegment||t.type===`background`))return null;let{start:n,end:r}=e,i=JA(e.group);if(i){let e=n.toISOString().slice(0,10),t=this.engine.getCourtAvailability(i,e),a=new Date(`${e}T${t.startTime}:00`),o=new Date(`${e}T${t.endTime}:00`);n<a&&(n=a),r>o&&(r=o)}return{start:n,end:r}},this.handleTimelineClick=e=>{let t=e.item;if(!t){this.popoverManager.destroy();return}let n=this.currentItems.get(t);if(!n){this.popoverManager.destroy();return}if(n.isSegment||n.type===`background`){this.popoverManager.destroy();return}if(this.popoverManager.isActiveFor(t)){this.popoverManager.destroy();return}let r=YA(t);if(!r)return;let i=(e.event?.target)?.closest?.(`.tg-item`)??this.config.container.querySelector(`[data-item-id="${t}"]`);if(i){let e=String(n.start).slice(0,10);this.popoverManager.showForEngineBlock(i,{itemId:t,blockId:r,engine:this.engine,day:e,onBlockChanged:()=>this.render()})}this.config.onBlockSelected&&this.config.onBlockSelected(r)},this.handleMultiRowCreate=e=>{let t=[];for(let n of e.groupIds){let e=JA(n);e&&t.push(e)}if(t.length===0)return;let n=this.toLocalISO(e.startTime),r=this.toLocalISO(e.endTime),i=this.engine.applyBlock({courts:t,timeRange:{start:n,end:r},type:xN.BLOCKED,reason:`New Block`});if(this.render(),i.applied.length>0){let e=i.applied[0].block.id,t=`block-${e}`,r=n.slice(0,10);setTimeout(()=>{let n=this.config.container.querySelector(`[data-item-id="${t}"]`);n&&this.popoverManager.showForEngineBlock(n,{itemId:t,blockId:e,engine:this.engine,day:r,onBlockChanged:()=>this.render()})},50)}this.config.onTimeRangeSelected&&this.config.onTimeRangeSelected({courts:t,start:n,end:r})},this.handleEngineEvent=e=>{switch(e.type){case`STATE_CHANGED`:case`BLOCKS_CHANGED`:this.render(),e.type===`BLOCKS_CHANGED`&&this.config.onBlocksChanged&&this.config.onBlocksChanged();break;case`CONFLICTS_CHANGED`:this.config.showConflicts&&this.render();break;case`AVAILABILITY_CHANGED`:this.updateTimelineWindow(),this.render();break}},this.engine=e,this.config={groupingMode:`BY_VENUE`,showConflicts:!0,showSegmentLabels:!1,colorScheme:VA,...t},this.initialize()}initialize(){if(this.config.initialDay)this.currentDay=this.config.initialDay;else{let e=this.engine.getActiveDays();this.currentDay=e.length>0?e[0]:t.tools.dateTime.extractDate(new Date().toISOString())}this.viewState.setSelectedDay(this.currentDay),this.config.initialView&&(this.currentView=this.config.initialView),this.unsubscribe=this.engine.subscribe(this.handleEngineEvent),this.ensureTimeline()}ensureTimeline(){this.timeline||setTimeout(()=>{this.timeline||this.createTimelineWithData()},0)}getViewDays(){if(!this.currentDay)return[];let e=nN[this.currentView],t=e?e.days:1;if(t<=0)return this.engine.getActiveDays();if(t<=1)return[this.currentDay];let n=this.engine.getActiveDays(),r=n.indexOf(this.currentDay);return r===-1?[this.currentDay]:n.slice(r,r+t)}buildViewData(){if(!this.currentDay)return{groups:[],items:[]};let e=this.getViewDays(),t=this.engine.listCourtMeta(),n=this.viewState.getLayerVisibility(),r={groupingMode:this.config.groupingMode,layerVisibility:n,showSegmentLabels:this.config.showSegmentLabels,colorScheme:this.config.colorScheme},i=HA(this.engine.getDayTimeline(e[0]),t,r);this.visibleCourts!==null&&this.visibleCourts.size>0&&(i=i.filter(e=>this.visibleCourts.has(String(e.id))));let a=this.visibleCourts!==null&&this.visibleCourts.size>0&&i.length>0?new Set(i.map(e=>String(e.id))):null,o=e.length<=1?this.engine.getActiveDays():e,s=[],c=[];for(let e of o){let t=this.engine.getDayTimeline(e);s.push(...UA(t,r)),c.push(...GA(this.engine.getDayBlocks(e),r))}let l=a?s.filter(e=>a.has(String(e.group))):s,u=a?c.filter(e=>a.has(String(e.group))):c,d=[...l,...u];return{groups:i.map((e,t)=>({id:String(e.id),content:typeof e.content==`string`?e.content:``,order:t,courtRef:e.courtRef,surface:e.surface,indoor:e.indoor,hasLights:e.hasLights,tags:e.tags})),items:d.map(e=>({id:String(e.id),group:String(e.group),content:e.content,start:e.start,end:e.end,type:e.type===`background`?`background`:`range`,className:e.className,style:e.style,title:e.title,editable:e.editable,blockId:e.blockId,status:e.status,reason:e.reason,isBlock:e.isBlock,isSegment:e.isSegment,isConflict:e.isConflict}))}}createTimelineWithData(){let e=this.engine.getConfig(),n=this.currentDay||t.tools.dateTime.extractDate(new Date().toISOString()),r=this.getViewDays(),i=r[0]||n,a=r[r.length-1]||n,o=this.engine.getVisibleTimeRange(i),s=this.engine.getVisibleTimeRange(a),c=XA({dayStartTime:o.startTime,dayEndTime:o.endTime,slotMinutes:e.slotMinutes,day:i}),l=nN[this.currentView],u=r.length>1?new Date(`${a}T${s.endTime}:00`):c.end,d=this.engine.getActiveDays(),f=d[0]||i,p=d[d.length-1]||a,m=this.engine.getVisibleTimeRange(f),h=this.engine.getVisibleTimeRange(p),g=new Date(`${f}T${m.startTime}:00`),_=new Date(`${p}T${h.endTime}:00`),{groups:v,items:y}=this.buildViewData();this.currentItems.clear();for(let e of y)this.currentItems.set(e.id,e);this.timeline=new bN(this.config.container,y,v,{start:c.start,end:u,min:g,max:_,zoomMin:c.zoomMin,zoomMax:_.getTime()-g.getTime(),snap:e=>this.snapToMinutes(e,5),rowHeight:40,height:`100%`,timeAxis:l?l.timeAxis:{scale:`hour`,step:1},showTooltips:!0}),this.timeline.setDailyBounds(o.startTime,o.endTime),r.length>1&&this.timeline.setVisibleDays(r),this.timeline.on(`click`,this.handleTimelineClick),this.timeline.onMove(this.handleOnMove),this.timeline.onMoving(this.handleOnMoving),this.timeline.onMultiRowCreate(this.handleMultiRowCreate),this.timeline.onDayClick(e=>{this.setDay(e),this.setViewPreset(`day`),this.config.onDayNavigate?.(e)}),this.config.onBlocksChanged?.()}setDay(e){this.currentDay!==e&&(this.currentDay=e,this.viewState.setSelectedDay(e),this.updateTimelineWindow(),this.render())}getDay(){return this.currentDay}setView(e){this.currentView=e,this.updateTimelineWindow()}setViewPreset(e){let t=nN[e];if(!t||!this.timeline||!this.currentDay)return;this.currentView=e;let n=this.getViewDays(),r=n[0],i=n[n.length-1],a=this.engine.getVisibleTimeRange(r),o=this.engine.getVisibleTimeRange(i);this.timeline.beginBatchUpdate();let s=t.days===0||t.days>1;this.timeline.setDailyBounds(a.startTime,a.endTime),s?this.timeline.setVisibleDays(n):this.timeline.clearVisibleDays();let c=new Date(`${r}T${a.startTime}:00`),l=new Date(`${i}T${o.endTime}:00`);this.timeline.setWindow(c,l,{animation:!1}),this.timeline.setOptions({timeAxis:t.timeAxis});let{groups:u,items:d}=this.buildViewData();this.currentItems.clear();for(let e of d)this.currentItems.set(e.id,e);this.timeline.setGroups(u),this.timeline.setItems(d),this.timeline.endBatchUpdate(),this.config.onBlocksChanged?.()}setSelectedCourts(e){this.selectedCourts=new Set(e)}getSelectedCourts(){return Array.from(this.selectedCourts)}setVisibleCourts(e){e&&e.size===0?this.visibleCourts=null:this.visibleCourts=e,this.render()}setLayerVisibility(e,t){this.viewState.setLayerVisibility(e,t),this.render()}refresh(){this.updateTimelineWindow(),this.render()}destroy(){this.popoverManager.destroy(),this.unsubscribe&&this.unsubscribe(),this.timeline&&=(this.timeline.destroy(),null)}updateTimelineWindow(){if(!this.timeline||!this.currentDay)return;let e=this.engine.getConfig(),t=this.getViewDays(),n=t[0]||this.currentDay,r=t[t.length-1]||this.currentDay,i=this.engine.getVisibleTimeRange(n),a=this.engine.getVisibleTimeRange(r),o=XA({dayStartTime:i.startTime,dayEndTime:i.endTime,slotMinutes:e.slotMinutes,day:n}),s=nN[this.currentView],c=t.length>1?new Date(`${r}T${a.endTime}:00`):o.end,l=this.engine.getActiveDays(),u=l[0]||n,d=l[l.length-1]||r,f=this.engine.getVisibleTimeRange(u),p=this.engine.getVisibleTimeRange(d),m=new Date(`${u}T${f.startTime}:00`),h=new Date(`${d}T${p.endTime}:00`);this.timeline.beginBatchUpdate(),this.timeline.setDailyBounds(i.startTime,i.endTime),t.length>1?this.timeline.setVisibleDays(t):this.timeline.clearVisibleDays(),this.timeline.setOptions({min:m,max:h}),this.timeline.setWindow(o.start,c,{animation:!1}),s&&this.timeline.setOptions({timeAxis:s.timeAxis}),this.timeline.endBatchUpdate()}render(){if(this.currentDay&&!this.isRendering){if(!this.timeline){this.ensureTimeline();return}this.isRendering=!0;try{let{groups:e,items:t}=this.buildViewData();this.currentItems.clear();for(let e of t)this.currentItems.set(e.id,e);this.timeline.setGroups(e),this.timeline.setItems(t)}finally{this.isRendering=!1}}}getPopoverManager(){return this.popoverManager}snapToMinutes(e,t){let n=e.getTime(),r=t*60*1e3,i=Math.round(n/r)*r;return new Date(i)}toLocalISO(e){let t=e=>e.toString().padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}showConflictDialog(e){let t=e.filter(e=>e.severity===`ERROR`).map(e=>e.message).join(`
|
|
247
|
-
`);alert(`Cannot complete operation:\n\n${t}`)}getTimeline(){return this.timeline}getEngine(){return this.engine}getViewState(){return this.viewState}};function
|
|
246
|
+
`,l.addEventListener(`mouseenter`,()=>{l.style.background=mP,l.style.color=hP}),l.addEventListener(`mouseleave`,()=>{l.style.background=`transparent`,l.style.color=``}),l.addEventListener(`click`,()=>{let o=r.getDayBlocks(i).find(e=>e.id===t);o&&(r.removeBlock(t),r.applyBlock({courts:[o.court],timeRange:{start:o.start,end:o.end},type:e,reason:s}),a()),n()}),o.appendChild(l)}let s=document.createElement(`div`);s.style.cssText=`border-top:1px solid var(--chc-border-primary); margin:4px 0;`,o.appendChild(s);let c=document.createElement(`div`);c.style.cssText=pP,c.innerHTML=`<span style="font-size:14px;">🕓</span> Adjust Time`,c.addEventListener(`mouseenter`,()=>{c.style.background=mP,c.style.color=hP}),c.addEventListener(`mouseleave`,()=>{c.style.background=`transparent`,c.style.color=``}),c.addEventListener(`click`,()=>{n();let e=r.getDayBlocks(i).find(e=>e.id===t);e&&dP({startTime:e.start,endTime:e.end,dayStartTime:`06:00`,dayEndTime:`22:00`,minuteIncrement:5,onConfirm:(n,i)=>{let o=e.start.slice(0,10);r.resizeBlock({blockId:t,newTimeRange:{start:`${o}T${n}:00`,end:`${o}T${i}:00`}}),a()},onCancel:()=>{}})}),o.appendChild(c);let l=document.createElement(`div`);return l.style.cssText=`padding:6px 12px; cursor:pointer; display:flex; align-items:center; gap:8px; color:#e74c3c;`,l.innerHTML=`<span style="font-size:14px;">🗑</span> Delete`,l.addEventListener(`mouseenter`,()=>{l.style.background=`#fdecea`}),l.addEventListener(`mouseleave`,()=>{l.style.background=`transparent`}),l.addEventListener(`click`,()=>{r.removeBlock(t),a(),n()}),o.appendChild(l),o}function a(r,i,a){n();let o=mm(r,{content:i,allowHTML:!0,interactive:!0,trigger:`manual`,placement:`bottom`,appendTo:document.body,onHidden:()=>{e=null,t=null}});e=o,t=a,o.show()}return{show(e,i){if(t===i.itemId){n();return}a(e,r(i),i.itemId)},showForEngineBlock(e,r){if(t===r.itemId){n();return}a(e,i(r),r.itemId)},destroy(){n()},isActiveFor(e){return t===e}}}var vP={day:{label:`1 Day`,days:1,timeAxis:{scale:`hour`,step:1}},days3:{label:`3 Days`,days:3,timeAxis:{scale:`hour`,step:3}},week:{label:`Week`,days:7,timeAxis:{scale:`hour`,step:6}},all:{label:`Tournament`,days:0,timeAxis:{scale:`hour`,step:6}}};function yP(e,t,n,r){let i=r?.labels,a=document.createElement(`div`);a.className=`tg-view-toolbar`;let o=document.createElement(`span`);o.textContent=(i?.view??`View`)+`:`,o.className=`tg-view-toolbar-label`,a.appendChild(o);let s=document.createElement(`input`);s.type=`text`,s.readOnly=!0,s.className=`tg-view-toolbar-date`,n&&s.addEventListener(`changeDate`,()=>{let e=s.value;e&&n(e)}),a.appendChild(s);let c={day:i?.day1??`1 Day`,days3:i?.days3??`3 Days`,week:i?.week??`Week`,all:i?.tournament??`Tournament`},l=[],u=[],d=t||`day`,f=e=>{l.forEach((t,n)=>{u[n]===e?t.className=`sp-btn sp-btn--active`:t.className=`sp-btn`})};for(let[t]of Object.entries(vP)){let n=document.createElement(`button`);n.textContent=c[t],n.className=t===d?`sp-btn sp-btn--active`:`sp-btn`,n.addEventListener(`click`,()=>{f(t),e(t)}),l.push(n),u.push(t),a.appendChild(n)}if(r?.onSetDefaultAvailability||r?.onSave){let e=document.createElement(`div`);e.className=`tg-view-toolbar-spacer`,a.appendChild(e)}if(r?.onSetDefaultAvailability){let e=document.createElement(`button`);e.textContent=i?.setDefaultAvailability??`Set Default Availability`,e.className=`sp-btn sp-btn--fill-muted`,e.addEventListener(`click`,r.onSetDefaultAvailability),a.appendChild(e)}let p=null;return r?.onSave&&(p=document.createElement(`button`),p.textContent=i?.saveToTournament??`Save to Tournament`,p.className=`sp-btn sp-btn--fill`,p.disabled=!0,p.addEventListener(`click`,r.onSave),a.appendChild(p)),{element:a,dateInput:s,setActiveView:f,setDate:e=>{s.value=e},setSaveEnabled:e=>{p&&(p.disabled=!e)}}}var bP=class{constructor(e,t,n){this._dailyStartMin=0,this._dailyEndMin=1440,this._useDailyBounds=!1,this._visibleDays=null,this._visibleDayMs=null,this._start=e.getTime(),this._end=t.getTime(),this._width=Math.max(n,1),this._min=this._start,this._max=this._end,this._zoomMin=900*1e3,this._zoomMax=(this._end-this._start)*2}get start(){return new Date(this._start)}get end(){return new Date(this._end)}get width(){return this._width}get duration(){return this._end-this._start}get msPerPx(){if(!this._useDailyBounds)return this.duration/this._width;let e=this.toCollapsedMin(new Date(this._start)),t=this.toCollapsedMin(new Date(this._end))-e;return t<=0?1:t*60*1e3/this._width}getDailyBounds(){return this._useDailyBounds?{startMin:this._dailyStartMin,endMin:this._dailyEndMin}:null}getVisibleDays(){return this._visibleDays}timeToX(e){if(!this._useDailyBounds)return(e.getTime()-this._start)/this.duration*this._width;let t=this.toCollapsedMin(e),n=this.toCollapsedMin(new Date(this._start)),r=this.toCollapsedMin(new Date(this._end))-n;return r<=0?0:(t-n)/r*this._width}xToTime(e){if(!this._useDailyBounds){let t=e/this._width*this.duration;return new Date(this._start+t)}let t=this.toCollapsedMin(new Date(this._start)),n=this.toCollapsedMin(new Date(this._end))-t;if(n<=0)return new Date(this._start);let r=t+e/this._width*n;return this.fromCollapsedMin(r)}snap(e,t){let n=e.getTime(),r=t*60*1e3;return new Date(Math.round(n/r)*r)}setWindow(e,t){this._start=e.getTime(),this._end=t.getTime(),this.clampBounds()}setLimits(e){e.min!==void 0&&(this._min=e.min.getTime()),e.max!==void 0&&(this._max=e.max.getTime()),e.zoomMin!==void 0&&(this._zoomMin=e.zoomMin),e.zoomMax!==void 0&&(this._zoomMax=e.zoomMax)}setWidth(e){this._width=Math.max(e,1)}setDailyBounds(e,t){let[n,r]=e.split(`:`).map(Number),[i,a]=t.split(`:`).map(Number);this._dailyStartMin=n*60+r,this._dailyEndMin=i*60+a,this._useDailyBounds=!0}clearDailyBounds(){this._useDailyBounds=!1,this._dailyStartMin=0,this._dailyEndMin=1440,this._visibleDays=null,this._visibleDayMs=null}setVisibleDays(e){this._visibleDays=e,this._visibleDayMs=e.map(e=>new Date(e+`T00:00:00`).getTime())}clearVisibleDays(){this._visibleDays=null,this._visibleDayMs=null}pan(e){if(this._visibleDays)return;if(this._useDailyBounds){let t=this.toCollapsedMin(new Date(this._start)),n=this.toCollapsedMin(new Date(this._end)),r=n-t;if(r<=0)return;let i=e/this._width*r,a=this.fromCollapsedMin(t+i),o=this.fromCollapsedMin(n+i);this._start=a.getTime(),this._end=o.getTime(),this.clampBounds();return}let t=e*this.msPerPx,n=this._start+t,r=this._end+t;if(n<this._min){let e=this._min-n;n+=e,r+=e}if(r>this._max){let e=r-this._max;n-=e,r-=e}this._start=n,this._end=r}zoom(e,t){if(this._visibleDays)return;if(this._useDailyBounds){let n=this.toCollapsedMin(new Date(this._start)),r=this.toCollapsedMin(new Date(this._end))-n,i=n+t/this._width*r,a=r*e,o=this._zoomMin/(60*1e3),s=this._zoomMax/(60*1e3);a=Math.max(o,Math.min(s,a));let c=t/this._width,l=this.fromCollapsedMin(i-a*c),u=this.fromCollapsedMin(i+a*(1-c));this._start=l.getTime(),this._end=u.getTime(),this.clampBounds();return}let n=this._start+t/this._width*this.duration,r=this.duration*e;r=Math.max(this._zoomMin,Math.min(this._zoomMax,r));let i=t/this._width;this._start=n-r*i,this._end=n+r*(1-i),this.clampBounds()}toCollapsedMin(e){let t=this._dailyEndMin-this._dailyStartMin;if(t<=0)return 0;let n=e.getHours()*60+e.getMinutes()+e.getSeconds()/60,r=Math.max(this._dailyStartMin,Math.min(this._dailyEndMin,n))-this._dailyStartMin;if(this._visibleDays&&this._visibleDayMs){let n=new Date(e);n.setHours(0,0,0,0);let i=n.getTime(),a=-1;for(let e=0;e<this._visibleDayMs.length;e++)if(this._visibleDayMs[e]===i){a=e;break}if(a===-1){if(i<this._visibleDayMs[0])return 0;if(i>this._visibleDayMs[this._visibleDayMs.length-1])return this._visibleDayMs.length*t;for(let e=0;e<this._visibleDayMs.length-1;e++)if(i>this._visibleDayMs[e]&&i<this._visibleDayMs[e+1])return(e+1)*t;return 0}return a*t+r}let i=new Date(this._start);i.setHours(0,0,0,0);let a=new Date(e);return a.setHours(0,0,0,0),Math.round((a.getTime()-i.getTime())/(1440*60*1e3))*t+r}fromCollapsedMin(e){let t=this._dailyEndMin-this._dailyStartMin;if(t<=0)return new Date(this._start);let n=Math.floor(e/t),r=e-n*t;if(this._visibleDays&&this._visibleDayMs){let e=Math.max(0,Math.min(n,this._visibleDayMs.length-1)),t=new Date(this._visibleDayMs[e]),i=this._dailyStartMin+r;return t.setHours(Math.floor(i/60),Math.round(i%60),0,0),t}let i=new Date(this._start);i.setHours(0,0,0,0);let a=new Date(i);a.setDate(a.getDate()+n);let o=this._dailyStartMin+r;return a.setHours(Math.floor(o/60),Math.round(o%60),0,0),a}clampBounds(){let e=this._end-this._start;this._start<this._min&&(this._start=this._min,this._end=this._min+e),this._end>this._max&&(this._end=this._max,this._start=this._max-e),this._start<this._min&&(this._start=this._min),this._end>this._max&&(this._end=this._max)}},xP=`tg-tick-day`,SP=`tg-tick-hour`,CP=class{constructor(e,t){this.scale=e,this.tickConfig=wP(t),this.dayEl=document.createElement(`div`),this.dayEl.className=`tg-day-axis`,this.dayEl.setAttribute(`role`,`presentation`),this.hourEl=document.createElement(`div`),this.hourEl.className=`tg-hour-axis`,this.hourEl.setAttribute(`role`,`presentation`),this.dayEl.addEventListener(`click`,e=>{let t=(e.target.closest?.(`.${xP}`))?.dataset.day;t&&this.onDayClick&&this.onDayClick(t)})}getDayElement(){return this.dayEl}getHourElement(){return this.hourEl}setTimeAxisOptions(e){this.tickConfig=wP(e)}render(){this.renderDayLabels(),this.renderHourTicks()}renderDayLabels(){this.dayEl.innerHTML=``;let{dayFormat:e}=this.tickConfig,t=this.tickConfig.scale,n=this.scale.getDailyBounds();if(n&&t===`hour`){this.renderDayLabelsWithBounds(n,e);return}if(t===`hour`){let t=this.scale.start.getTime(),n=EP(t,this.scale.end.getTime());if(n.length===0){let n=new Date(t);n.setHours(0,0,0,0);let r=document.createElement(`div`);r.className=xP,r.style.left=`0px`,r.style.maxWidth=`${this.scale.width}px`,r.dataset.day=TP(n),r.textContent=e.format(n),this.dayEl.appendChild(r);return}for(let t of n){let n=this.scale.timeToX(t),r=document.createElement(`div`);r.className=xP,r.style.left=`${n}px`,r.dataset.day=TP(t),r.textContent=e.format(t),this.dayEl.appendChild(r)}}else if(t===`day`){let e=OP(this.scale.start.getTime(),this.scale.end.getTime());for(let t of e){let e=this.scale.timeToX(t),n=document.createElement(`div`);n.className=xP,n.style.left=`${e}px`,n.dataset.day=TP(t),n.textContent=this.tickConfig.dayFormat.format(t),this.dayEl.appendChild(n)}}}renderDayLabelsWithBounds(e,t){let n=this.getVisibleDayDates(e),r=this.scale.getVisibleDays(),i=n.length,a=i>0?this.scale.width/i:this.scale.width,o=a<150?new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`}):t;if(r&&r.length>0)for(let t of n){let n=new Date(t);n.setHours(0,0,0,0),n.setMinutes(e.startMin);let r=this.scale.timeToX(n),i=document.createElement(`div`);i.className=xP,i.style.left=`${r}px`,i.style.maxWidth=`${Math.floor(a)-4}px`,i.dataset.day=TP(t),i.textContent=o.format(n),this.dayEl.appendChild(i)}else{let t=this.scale.width;for(let r of n){let n=new Date(r);n.setHours(0,0,0,0),n.setMinutes(e.startMin);let i=new Date(r);i.setHours(0,0,0,0),i.setDate(i.getDate()+1),i.setMinutes(e.startMin);let a=this.scale.timeToX(n),s=this.scale.timeToX(i),c=Math.max(a,0),l=Math.min(s,t)-c;if(l<=0)continue;let u=document.createElement(`div`);u.className=xP,u.style.left=`${c}px`,u.style.maxWidth=`${l}px`,u.dataset.day=TP(r),u.textContent=o.format(n),this.dayEl.appendChild(u)}}}renderHourTicks(){this.hourEl.innerHTML=``;let{hourFormat:e}=this.tickConfig,t=this.tickConfig.scale,n=this.tickConfig.step,r=this.scale.getDailyBounds();if(r&&t===`hour`){this.renderHourTicksWithBounds(r,n,e);return}let i=this.scale.start.getTime(),a=this.scale.end.getTime();if(t===`hour`){let t=new Set(EP(i,a).map(e=>e.getTime())),r=DP(i,a,n);for(let n of r){if(t.has(n.getTime()))continue;let r=this.scale.timeToX(n),i=document.createElement(`div`);i.className=SP,i.style.left=`${r}px`,i.textContent=e.format(n),this.hourEl.appendChild(i)}}else if(t===`day`){let e=new Set(OP(i,a).map(e=>e.getTime())),t=EP(i,a);for(let n of t){if(e.has(n.getTime()))continue;let t=this.scale.timeToX(n),r=document.createElement(`div`);r.className=SP,r.style.left=`${t}px`,r.textContent=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`}).format(n),this.hourEl.appendChild(r)}}}renderHourTicksWithBounds(e,t,n){let r=this.getVisibleDayDates(e);for(let i of r){let r=new Date(i);r.setHours(0,0,0,0),r.setMinutes(e.startMin);let a=new Date(i);a.setHours(0,0,0,0),a.setMinutes(e.endMin);let o=Math.ceil(e.startMin/60),s=new Date(i);for(s.setHours(o,0,0,0),s.getHours()%t!==0&&s.setHours(s.getHours()+(t-s.getHours()%t));s.getTime()<=a.getTime();){if(s.getTime()!==r.getTime()){let e=this.scale.timeToX(s),t=document.createElement(`div`);t.className=SP,t.style.left=`${e}px`,t.textContent=n.format(s),this.hourEl.appendChild(t)}s.setHours(s.getHours()+t)}}}getVisibleDayDates(e){let t=this.scale.getVisibleDays();if(t&&t.length>0)return t.map(e=>new Date(e+`T00:00:00`));let n=this.scale.start.getTime(),r=this.scale.end.getTime(),i=[],a=new Date(n);for(a.setHours(0,0,0,0);;){let t=new Date(a);if(t.setHours(0,0,0,0),t.setMinutes(e.endMin),t.getTime()<n){a.setDate(a.getDate()+1);continue}let o=new Date(a);if(o.setHours(0,0,0,0),o.setMinutes(e.startMin),o.getTime()>r)break;i.push(new Date(a)),a.setDate(a.getDate()+1)}return i}renderGridlines(e,t){e.querySelectorAll(`.tg-gridline`).forEach(e=>e.remove());let n=this.computeTickPositions();for(let{x:r,isMajor:i}of n){let n=document.createElement(`div`);n.className=i?`tg-gridline tg-gridline-major`:`tg-gridline`,n.style.left=`${r}px`,n.style.height=`${t}px`,e.appendChild(n)}}computeTickPositions(){let e=[],t=this.tickConfig.scale,n=this.tickConfig.step,r=this.scale.getDailyBounds(),i=this.scale.start.getTime(),a=this.scale.end.getTime();if(r&&t===`hour`){let t=this.getVisibleDayDates(r);for(let i of t){let t=new Date(i);t.setHours(0,0,0,0),t.setMinutes(r.startMin);let a=new Date(i);a.setHours(0,0,0,0),a.setMinutes(r.endMin),e.push({x:this.scale.timeToX(t),isMajor:!0});let o=Math.ceil(r.startMin/60),s=new Date(i);for(s.setHours(o,0,0,0),s.getHours()%n!==0&&s.setHours(s.getHours()+(n-s.getHours()%n));s.getTime()<=a.getTime();)s.getTime()!==t.getTime()&&e.push({x:this.scale.timeToX(s),isMajor:!1}),s.setHours(s.getHours()+n)}}else if(t===`hour`){let t=EP(i,a),r=new Set(t.map(e=>e.getTime()));for(let n of t)e.push({x:this.scale.timeToX(n),isMajor:!0});for(let t of DP(i,a,n))r.has(t.getTime())||e.push({x:this.scale.timeToX(t),isMajor:!1})}else if(t===`day`){let t=OP(i,a),n=new Set(t.map(e=>e.getTime()));for(let n of t)e.push({x:this.scale.timeToX(n),isMajor:!0});for(let t of EP(i,a))n.has(t.getTime())||e.push({x:this.scale.timeToX(t),isMajor:!1})}return e}destroy(){this.dayEl.remove(),this.hourEl.remove()}};function wP(e){let t=e?.scale??`hour`,n=e?.step??1;switch(t){case`hour`:return{scale:t,step:n,hourFormat:new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),dayFormat:new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`})};case`day`:return{scale:t,step:n,hourFormat:new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`}),dayFormat:new Intl.DateTimeFormat(void 0,{month:`long`,year:`numeric`})};default:return{scale:`hour`,step:1,hourFormat:new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),dayFormat:new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`,month:`short`})}}}function TP(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function EP(e,t){let n=[],r=new Date(e);for(r.setHours(0,0,0,0);r.getTime()<=t;)r.getTime()>=e&&n.push(new Date(r)),r.setDate(r.getDate()+1);return n}function DP(e,t,n){let r=[],i=new Date(e);i.setMinutes(0,0,0);let a=i.getHours();for(i.setHours(a-a%n);i.getTime()<=t;)i.getTime()>=e&&r.push(new Date(i)),i.setHours(i.getHours()+n);return r}function OP(e,t){let n=[],r=new Date(e);r.setHours(0,0,0,0);let i=r.getDay(),a=i===0?6:i-1;for(r.setDate(r.getDate()-a);r.getTime()<=t;)r.getTime()>=e&&n.push(new Date(r)),r.setDate(r.getDate()+7);return n}var kP=class{constructor(e=40){this.groups=[],this.groupIndex=new Map,this.rowHeight=e,this.labelPanel=document.createElement(`div`),this.labelPanel.className=`tg-label-panel`,this.labelPanel.setAttribute(`role`,`rowheader`),this.contentArea=document.createElement(`div`),this.contentArea.className=`tg-content`,this.contentArea.setAttribute(`role`,`grid`)}getLabelPanel(){return this.labelPanel}getContentArea(){return this.contentArea}getRowHeight(){return this.rowHeight}getGroups(){return this.groups}getGroupCount(){return this.groups.length}getGroupAtIndex(e){return this.groups[e]}yToGroupId(e){let t=Math.floor(e/this.rowHeight);return t<0||t>=this.groups.length?null:this.groups[t].id}groupIdToRowIndex(e){return this.groupIndex.get(e)??-1}getRowRange(e,t){let n=Math.max(0,Math.floor(Math.min(e,t)/this.rowHeight)),r=Math.min(this.groups.length-1,Math.floor(Math.max(e,t)/this.rowHeight)),i=[];for(let e=n;e<=r;e++)i.push(this.groups[e].id);return i}getRowTop(e){return e*this.rowHeight}setGroups(e){this.groups=e.slice().sort((e,t)=>e.order!==void 0&&t.order!==void 0?e.order-t.order:e.order===void 0?t.order===void 0?e.content.localeCompare(t.content,void 0,{numeric:!0}):1:-1),this.groupIndex.clear();for(let e=0;e<this.groups.length;e++)this.groupIndex.set(this.groups[e].id,e)}render(){this.renderLabels(),this.renderRows()}renderLabels(){this.labelPanel.innerHTML=``;for(let e of this.groups){let t=document.createElement(`div`);t.className=`tg-label`,t.style.height=`${this.rowHeight}px`,t.textContent=e.content,t.title=e.content,t.dataset.groupId=e.id,this.labelPanel.appendChild(t)}}renderRows(){this.contentArea.querySelectorAll(`.tg-row`).forEach(e=>e.remove());for(let e=0;e<this.groups.length;e++){let t=document.createElement(`div`);t.className=`tg-row`,t.style.height=`${this.rowHeight}px`,t.style.top=`${e*this.rowHeight}px`,t.dataset.groupId=this.groups[e].id,this.contentArea.appendChild(t)}this.contentArea.style.height=`${this.groups.length*this.rowHeight}px`}destroy(){this.labelPanel.remove(),this.contentArea.remove()}},AP=class{constructor(e,t){this.items=[],this.itemElements=new Map,this.ghostEl=null,this.ghostCountBadge=null,this.scale=e,this.layout=t,this.contentArea=t.getContentArea()}setItems(e){this.items=e}render(){for(let e of this.itemElements.values())e.remove();this.itemElements.clear(),this.contentArea.querySelectorAll(`[data-item-id]`).forEach(e=>{e.dataset.itemId!==`__ghost__`&&e.remove()});for(let e of this.items){let t=this.renderItem(e);t&&(this.contentArea.appendChild(t),this.itemElements.set(e.id,t))}}renderItem(e){let t=this.layout.groupIdToRowIndex(e.group);if(t===-1)return null;let n=e.start instanceof Date?e.start:new Date(e.start),r=e.end?e.end instanceof Date?e.end:new Date(e.end):n,i=this.scale.timeToX(n),a=this.scale.timeToX(r)-i,o=this.layout.getRowTop(t),s=this.layout.getRowHeight();if(a<.5)return null;let c=document.createElement(`div`);if(c.dataset.itemId=e.id,c.title=e.title||e.content,e.type===`background`||e.isSegment)c.className=`tg-item-background ${e.className||``}`.trim(),e.style&&(c.style.cssText=e.style),c.style.position=`absolute`,c.style.left=`${i}px`,c.style.top=`${o}px`,c.style.width=`${a}px`,c.style.height=`${s}px`,c.style.pointerEvents=`none`;else{c.className=`tg-item tg-item-range ${e.className||``}`.trim(),e.style&&(c.style.cssText+=e.style),c.style.position=`absolute`,c.style.left=`${i}px`,c.style.top=`${o+2}px`,c.style.width=`${a}px`,c.style.height=`${s-4}px`,c.style.cursor=`move`;let t=document.createElement(`span`);t.className=`tg-item-content`,t.textContent=e.content,c.appendChild(t);let n=document.createElement(`div`);n.className=`tg-resize-handle tg-resize-left`,n.dataset.handle=`left`,c.appendChild(n);let r=document.createElement(`div`);r.className=`tg-resize-handle tg-resize-right`,r.dataset.handle=`right`,c.appendChild(r)}return c}updateItemPosition(e,t,n,r){let i=this.itemElements.get(e);i&&(i.style.left=`${t}px`,i.style.top=`${n+2}px`,i.style.width=`${r}px`)}showGhost(e){if(!this.ghostEl){this.ghostEl=document.createElement(`div`),this.ghostEl.className=`tg-ghost`,this.ghostEl.dataset.itemId=`__ghost__`;for(let e of[`left`,`right`,`top`,`bottom`]){let t=document.createElement(`div`);t.className=`tg-resize-handle tg-resize-${e}`,t.dataset.handle=e,this.ghostEl.appendChild(t)}this.ghostCountBadge=document.createElement(`div`),this.ghostCountBadge.className=`tg-ghost-count`,this.ghostEl.appendChild(this.ghostCountBadge),this.contentArea.appendChild(this.ghostEl)}let t=this.scale.timeToX(e.startTime),n=this.scale.timeToX(e.endTime)-t,r=this.layout.getRowHeight(),i=e.topRowIndex*r,a=(e.bottomRowIndex-e.topRowIndex+1)*r,o=e.bottomRowIndex-e.topRowIndex+1;this.ghostEl.style.left=`${t}px`,this.ghostEl.style.top=`${i}px`,this.ghostEl.style.width=`${n}px`,this.ghostEl.style.height=`${a}px`,this.ghostEl.style.display=`block`,this.ghostCountBadge&&(this.ghostCountBadge.textContent=`${o} court${o>1?`s`:``}`,this.ghostCountBadge.style.display=o>1?`flex`:`none`)}clearGhost(){this.ghostEl&&(this.ghostEl.remove(),this.ghostEl=null,this.ghostCountBadge=null)}isGhostVisible(){return this.ghostEl!==null&&this.ghostEl.style.display!==`none`}highlightRows(e){this.clearHighlights();for(let t of e){let e=this.contentArea.querySelectorAll(`.tg-row`);e[t]&&e[t].classList.add(`tg-row-highlight`)}}clearHighlights(){this.contentArea.querySelectorAll(`.tg-row-highlight`).forEach(e=>{e.classList.remove(`tg-row-highlight`)})}static hitTest(e){if(!(e instanceof HTMLElement))return{itemId:null,handle:null};let t=e.closest(`.tg-resize-handle`)?.dataset.handle??null;return{itemId:e.closest(`[data-item-id]`)?.dataset.itemId??null,handle:t}}destroy(){this.clearGhost(),this.clearHighlights();for(let e of this.itemElements.values())e.remove();this.itemElements.clear()}},jP=3,MP=30,NP=8,PP=3600*1e3,FP=class{constructor(e,t,n,r,i=5,a=!1){this.mode=`IDLE`,this.gesture=null,this.items=[],this.ghostStartTime=null,this.ghostEndTime=null,this.ghostTopRow=0,this.ghostBottomRow=0,this.justDragged=!1,this.autoScrollRaf=null,this.autoScrollDelta=0,this.scrollContainer=null,this.onPointerDown=e=>{if(e.button!==0)return;let{itemId:t,handle:n}=AP.hitTest(e.target);if(this.mode===`GHOST_EDITING`){if(t===`__ghost__`&&n){this.startGesture(e,`__ghost__`,n===`left`?`RESIZING_LEFT`:n===`right`?`RESIZING_RIGHT`:n===`top`?`RESIZING_TOP`:`RESIZING_BOTTOM`);return}if(t===`__ghost__`&&!n){this.confirmGhost();return}this.cancelGhost();return}if(t)if(n===`left`)this.startGesture(e,t,`RESIZING_LEFT`);else if(n===`right`)this.startGesture(e,t,`RESIZING_RIGHT`);else{let n=this.items.find(e=>e.id===t);if(!n||n.isSegment||n.type===`background`)return;this.startGesture(e,t,`DRAGGING`)}},this.onPointerMove=e=>{if(this.gesture){if(this.gesture.currentX=e.clientX,this.gesture.currentY=e.clientY,!this.gesture.thresholdExceeded){let t=Math.abs(e.clientX-this.gesture.startX),n=Math.abs(e.clientY-this.gesture.startY);if(t<jP&&n<jP)return;this.gesture.thresholdExceeded=!0}switch(this.checkAutoScroll(e),this.mode){case`DRAGGING`:this.handleDragMove(e);break;case`RESIZING_LEFT`:case`RESIZING_RIGHT`:this.gesture.itemId===`__ghost__`?this.handleGhostTimeResize(e):this.handleResizeMove(e);break;case`RESIZING_TOP`:case`RESIZING_BOTTOM`:this.handleGhostRowResize(e);break}}},this.onPointerUp=e=>{if(document.removeEventListener(`pointermove`,this.onPointerMove),document.removeEventListener(`pointerup`,this.onPointerUp),this.stopAutoScroll(),!this.gesture){this.mode=`IDLE`;return}let t=this.gesture.itemId===`__ghost__`;if(!this.gesture.thresholdExceeded&&!t){this.gesture.itemId&&this.callbacks.onItemClick?.(this.gesture.itemId,e),this.gesture=null,this.mode=`IDLE`,this.renderer.clearHighlights();return}if(t){this.gesture=null,this.mode=`GHOST_EDITING`;return}if(this.gesture.itemId&&this.gesture.thresholdExceeded){this.justDragged=!0,setTimeout(()=>this.justDragged=!1,300);let t=(e.clientX-this.gesture.startX)*this.scale.msPerPx,n=this.gesture.originalEnd.getTime()-this.gesture.originalStart.getTime(),r,i,a=this.gesture.originalGroup;if(this.mode===`DRAGGING`){r=this.scale.snap(new Date(this.gesture.originalStart.getTime()+t),this.snapMinutes),i=new Date(r.getTime()+n);let o=this.contentArea.getBoundingClientRect(),s=e.clientY-o.top+this.contentArea.scrollTop;a=this.layout.yToGroupId(s)||this.gesture.originalGroup}else this.mode===`RESIZING_LEFT`?(r=this.scale.snap(new Date(this.gesture.originalStart.getTime()+t),this.snapMinutes),i=this.gesture.originalEnd,r>=i&&(r=new Date(i.getTime()-this.snapMinutes*60*1e3))):(r=this.gesture.originalStart,i=this.scale.snap(new Date(this.gesture.originalEnd.getTime()+t),this.snapMinutes),i<=r&&(i=new Date(r.getTime()+this.snapMinutes*60*1e3)));this.callbacks.onMove?.({id:this.gesture.itemId,group:a,start:r,end:i})}this.gesture=null,this.mode=`IDLE`,this.renderer.clearHighlights()},this.onDblClick=e=>{if(this.justDragged)return;let{itemId:t}=AP.hitTest(e.target);if(t)return;let n=this.contentArea.getBoundingClientRect(),r=e.clientX-n.left+this.contentArea.scrollLeft,i=e.clientY-n.top+this.contentArea.scrollTop,a=this.scale.xToTime(r),o=this.scale.snap(a,this.snapMinutes),s=new Date(o.getTime()+PP),c=this.layout.yToGroupId(i);if(!c)return;let l=this.layout.groupIdToRowIndex(c);l<0||(this.ghostStartTime=o,this.ghostEndTime=s,this.ghostTopRow=l,this.ghostBottomRow=l,this.mode=`GHOST_EDITING`,this.renderer.showGhost({startTime:o,endTime:s,topRowIndex:l,bottomRowIndex:l}),this.renderer.highlightRows([l]))},this.onWheel=e=>{if(!((e.ctrlKey||e.metaKey)&&!this.enablePinchZoom)){if(e.preventDefault(),(e.ctrlKey||e.metaKey)&&this.enablePinchZoom){let t=e.deltaY>0?1.15:.87,n=this.contentArea.getBoundingClientRect(),r=e.clientX-n.left;this.scale.zoom(t,r)}else if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY)){let t=e.deltaX||e.deltaY;this.scale.pan(t)}else{this.scrollContainer&&(this.scrollContainer.scrollTop+=e.deltaY);return}this.onScaleChanged?.()}},this.onScaleChanged=null,this.onKeyDown=e=>{e.key===`Escape`&&this.mode===`GHOST_EDITING`&&this.cancelGhost()},this.scale=e,this.layout=t,this.renderer=n,this.contentArea=t.getContentArea(),this.wheelTarget=this.contentArea,this.callbacks=r,this.snapMinutes=i,this.enablePinchZoom=a}setItems(e){this.items=e}setScrollContainer(e){this.scrollContainer=e}setWheelTarget(e){this.wheelTarget=e}attach(){this.contentArea.addEventListener(`pointerdown`,this.onPointerDown),this.contentArea.addEventListener(`dblclick`,this.onDblClick),this.wheelTarget.addEventListener(`wheel`,this.onWheel,{passive:!1}),document.addEventListener(`keydown`,this.onKeyDown)}detach(){this.contentArea.removeEventListener(`pointerdown`,this.onPointerDown),this.contentArea.removeEventListener(`dblclick`,this.onDblClick),this.wheelTarget.removeEventListener(`wheel`,this.onWheel),document.removeEventListener(`keydown`,this.onKeyDown),document.removeEventListener(`pointermove`,this.onPointerMove),document.removeEventListener(`pointerup`,this.onPointerUp),this.stopAutoScroll()}getMode(){return this.mode}startGesture(e,t,n){e.preventDefault();let r=this.items.find(e=>e.id===t),i,a,o;if(t===`__ghost__`)i=this.ghostStartTime,a=this.ghostEndTime,o=``;else if(r)i=r.start instanceof Date?r.start:new Date(r.start),a=r.end?r.end instanceof Date?r.end:new Date(r.end):i,o=r.group;else return;this.gesture={mode:n,itemId:t,startX:e.clientX,startY:e.clientY,originalStart:i,originalEnd:a,originalGroup:o,currentX:e.clientX,currentY:e.clientY,thresholdExceeded:!1},this.mode=n,this.contentArea.setPointerCapture(e.pointerId),document.addEventListener(`pointermove`,this.onPointerMove),document.addEventListener(`pointerup`,this.onPointerUp)}handleDragMove(e){if(!this.gesture||!this.gesture.itemId)return;let t=(e.clientX-this.gesture.startX)*this.scale.msPerPx,n=this.gesture.originalEnd.getTime()-this.gesture.originalStart.getTime(),r=this.scale.snap(new Date(this.gesture.originalStart.getTime()+t),this.snapMinutes),i=new Date(r.getTime()+n),a=this.contentArea.getBoundingClientRect(),o=e.clientY-a.top+this.contentArea.scrollTop,s=this.layout.yToGroupId(o)||this.gesture.originalGroup;if(this.callbacks.onMoving){let e=this.callbacks.onMoving({id:this.gesture.itemId,group:s,start:r,end:i});if(e===null)return;r=e.start,i=e.end}let c=this.scale.timeToX(r),l=this.scale.timeToX(i)-c,u=this.layout.groupIdToRowIndex(s),d=this.layout.getRowTop(u>=0?u:0);this.renderer.updateItemPosition(this.gesture.itemId,c,d,l),u>=0&&this.renderer.highlightRows([u])}handleResizeMove(e){if(!this.gesture||!this.gesture.itemId)return;let t=(e.clientX-this.gesture.startX)*this.scale.msPerPx,n=this.gesture.originalStart,r=this.gesture.originalEnd;if(this.mode===`RESIZING_LEFT`?(n=this.scale.snap(new Date(this.gesture.originalStart.getTime()+t),this.snapMinutes),n>=r&&(n=new Date(r.getTime()-this.snapMinutes*60*1e3))):(r=this.scale.snap(new Date(this.gesture.originalEnd.getTime()+t),this.snapMinutes),r<=n&&(r=new Date(n.getTime()+this.snapMinutes*60*1e3))),this.callbacks.onMoving){let e=this.callbacks.onMoving({id:this.gesture.itemId,group:this.gesture.originalGroup,start:n,end:r});if(e===null)return;n=e.start,r=e.end}let i=this.scale.timeToX(n),a=this.scale.timeToX(r)-i,o=this.layout.groupIdToRowIndex(this.gesture.originalGroup),s=this.layout.getRowTop(o>=0?o:0);this.renderer.updateItemPosition(this.gesture.itemId,i,s,a)}handleGhostTimeResize(e){if(!this.gesture)return;let t=this.contentArea.getBoundingClientRect(),n=e.clientX-t.left+this.contentArea.scrollLeft,r=this.scale.snap(this.scale.xToTime(n),this.snapMinutes);this.mode===`RESIZING_LEFT`?r<this.ghostEndTime&&(this.ghostStartTime=r):r>this.ghostStartTime&&(this.ghostEndTime=r),this.updateGhostDisplay()}handleGhostRowResize(e){if(!this.gesture)return;let t=this.contentArea.getBoundingClientRect(),n=e.clientY-t.top+this.contentArea.scrollTop,r=Math.floor(n/this.layout.getRowHeight()),i=Math.max(0,Math.min(this.layout.getGroupCount()-1,r));this.mode===`RESIZING_TOP`?i<=this.ghostBottomRow&&(this.ghostTopRow=i):i>=this.ghostTopRow&&(this.ghostBottomRow=i),this.updateGhostDisplay()}updateGhostDisplay(){this.renderer.showGhost({startTime:this.ghostStartTime,endTime:this.ghostEndTime,topRowIndex:this.ghostTopRow,bottomRowIndex:this.ghostBottomRow});let e=[];for(let t=this.ghostTopRow;t<=this.ghostBottomRow;t++)e.push(t);this.renderer.highlightRows(e)}confirmGhost(){if(!this.ghostStartTime||!this.ghostEndTime){this.cancelGhost();return}let e=[];for(let t=this.ghostTopRow;t<=this.ghostBottomRow;t++){let n=this.layout.getGroupAtIndex(t);n&&e.push(n.id)}if(e.length===0){this.cancelGhost();return}let t={groupIds:e,topRowIndex:this.ghostTopRow,bottomRowIndex:this.ghostBottomRow,startTime:this.ghostStartTime,endTime:this.ghostEndTime};this.renderer.clearGhost(),this.renderer.clearHighlights(),this.mode=`IDLE`,this.callbacks.onMultiRowCreate?.(t),this.ghostStartTime=null,this.ghostEndTime=null}cancelGhost(){this.renderer.clearGhost(),this.renderer.clearHighlights(),this.mode=`IDLE`,this.ghostStartTime=null,this.ghostEndTime=null}checkAutoScroll(e){if(!this.scrollContainer)return;let t=this.scrollContainer.getBoundingClientRect(),n=t.bottom-e.clientY,r=e.clientY-t.top;n<MP?(this.autoScrollDelta=NP*(1-n/MP),this.startAutoScroll()):r<MP?(this.autoScrollDelta=-NP*(1-r/MP),this.startAutoScroll()):this.stopAutoScroll()}startAutoScroll(){if(this.autoScrollRaf!==null)return;let e=()=>{this.scrollContainer&&(this.scrollContainer.scrollTop+=this.autoScrollDelta,this.autoScrollRaf=requestAnimationFrame(e))};this.autoScrollRaf=requestAnimationFrame(e)}stopAutoScroll(){this.autoScrollRaf!==null&&(cancelAnimationFrame(this.autoScrollRaf),this.autoScrollRaf=null),this.autoScrollDelta=0}},IP=class{constructor(e,t,n,r={}){this.callbacks={},this.resizeObserver=null,this._batchUpdating=!1,this.eventListeners=new Map,this.options={rowHeight:40,...r};let i=new Date,a=r.start||i,o=r.end||new Date(i.getTime()+720*60*1e3),s=e.clientWidth||800;this.scale=new bP(a,o,s),(r.min||r.max||r.zoomMin||r.zoomMax)&&this.scale.setLimits({min:r.min,max:r.max,zoomMin:r.zoomMin,zoomMax:r.zoomMax}),this.timeAxis=new CP(this.scale,r.timeAxis),this.layout=new kP(this.options.rowHeight),this.renderer=new AP(this.scale,this.layout),this.interaction=new FP(this.scale,this.layout,this.renderer,this.callbacks,5,r.enablePinchZoom??!1),this.rootEl=document.createElement(`div`),this.rootEl.className=`tg-timeline`,r.height&&(this.rootEl.style.height=r.height);let c=document.createElement(`div`);c.className=`tg-axis-header`;let l=document.createElement(`div`);l.className=`tg-axis-spacer`,c.appendChild(l),c.appendChild(this.timeAxis.getDayElement()),c.appendChild(this.timeAxis.getHourElement()),this.rootEl.appendChild(c),this.bodyEl=document.createElement(`div`),this.bodyEl.className=`tg-body`,this.bodyEl.appendChild(this.layout.getLabelPanel());let u=document.createElement(`div`);u.className=`tg-scroll-wrapper`,u.appendChild(this.layout.getContentArea()),this.bodyEl.appendChild(u),this.rootEl.appendChild(this.bodyEl),e.appendChild(this.rootEl),u.addEventListener(`scroll`,()=>{this.layout.getLabelPanel().scrollTop=u.scrollTop}),this.interaction.setScrollContainer(u),this.interaction.setWheelTarget(this.rootEl),this.interaction.onScaleChanged=()=>this.renderAll(),this.layout.setGroups(n),this.renderer.setItems(t),this.interaction.setItems(t),this.interaction.attach(),this.renderAll(),this.resizeObserver=new ResizeObserver(()=>{let t=u.clientWidth||e.clientWidth;this.scale.setWidth(t),this.renderAll()}),this.resizeObserver.observe(u)}setGroups(e){this.layout.setGroups(e),this.renderAll()}setItems(e){this.renderer.setItems(e),this.interaction.setItems(e),this.renderAll()}setWindow(e,t,n){this.scale.setWindow(e,t),this.renderAll()}setOptions(e){(e.min!==void 0||e.max!==void 0||e.zoomMin!==void 0||e.zoomMax!==void 0)&&this.scale.setLimits({min:e.min,max:e.max,zoomMin:e.zoomMin,zoomMax:e.zoomMax}),e.timeAxis&&this.timeAxis.setTimeAxisOptions(e.timeAxis),e.rowHeight!==void 0&&(this.options.rowHeight=e.rowHeight),Object.assign(this.options,e),this.renderAll()}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e).add(t),e===`click`&&(this.callbacks.onItemClick=(e,t)=>{this.emit(`click`,{item:e,event:t})})}off(e,t){this.eventListeners.get(e)?.delete(t)}emit(e,t){let n=this.eventListeners.get(e);if(n)for(let e of n)e(t)}onMultiRowCreate(e){this.callbacks.onMultiRowCreate=e}onAdd(e){this.callbacks.onAdd=e}onMove(e){this.callbacks.onMove=e}onMoving(e){this.callbacks.onMoving=e}onDayClick(e){this.timeAxis.onDayClick=e}getContentElement(){return this.layout.getContentArea()}setDailyBounds(e,t){this.scale.setDailyBounds(e,t),this.renderAll()}clearDailyBounds(){this.scale.clearDailyBounds(),this.renderAll()}setVisibleDays(e){this.scale.setVisibleDays(e),this.renderAll()}clearVisibleDays(){this.scale.clearVisibleDays(),this.renderAll()}beginBatchUpdate(){this._batchUpdating=!0}endBatchUpdate(){this._batchUpdating=!1,this.renderAll()}renderAll(){if(this._batchUpdating)return;this.timeAxis.render(),this.layout.render(),this.renderer.render();let e=this.layout.getContentArea(),t=this.layout.getGroupCount()*(this.options.rowHeight??40);this.timeAxis.renderGridlines(e,t)}destroy(){this.interaction.detach(),this.resizeObserver?.disconnect(),this.timeAxis.destroy(),this.layout.destroy(),this.renderer.destroy(),this.rootEl.remove(),this.eventListeners.clear()}},{BLOCK_TYPES:LP}=t.temporal,RP=class{constructor(e,t){this.timeline=null,this.unsubscribe=null,this.currentItems=new Map,this.isRendering=!1,this.popoverManager=_P(),this.viewState=new nM,this.currentDay=null,this.currentView=`day`,this.selectedCourts=new Set,this.visibleCourts=null,this.handleOnMove=e=>{let t=dM(e.id);if(!t)return!1;let n=uM(e.group),r=this.toLocalISO(e.start),i=this.toLocalISO(e.end),a=this.engine.moveBlock({blockId:t,newTimeRange:{start:r,end:i},newCourt:n||void 0});return a.conflicts.some(e=>e.severity===`ERROR`)?(this.showConflictDialog(a.conflicts),!1):(this.render(),!0)},this.handleOnMoving=e=>{this.popoverManager.destroy();let t=this.currentItems.get(e.id);if(t&&(t.isSegment||t.type===`background`))return null;let{start:n,end:r}=e,i=uM(e.group);if(i){let e=n.toISOString().slice(0,10),t=this.engine.getCourtAvailability(i,e),a=new Date(`${e}T${t.startTime}:00`),o=new Date(`${e}T${t.endTime}:00`);n<a&&(n=a),r>o&&(r=o)}return{start:n,end:r}},this.handleTimelineClick=e=>{let t=e.item;if(!t){this.popoverManager.destroy();return}let n=this.currentItems.get(t);if(!n){this.popoverManager.destroy();return}if(n.isSegment||n.type===`background`){this.popoverManager.destroy();return}if(this.popoverManager.isActiveFor(t)){this.popoverManager.destroy();return}let r=dM(t);if(!r)return;let i=(e.event?.target)?.closest?.(`.tg-item`)??this.config.container.querySelector(`[data-item-id="${t}"]`);if(i){let e=String(n.start).slice(0,10);this.popoverManager.showForEngineBlock(i,{itemId:t,blockId:r,engine:this.engine,day:e,onBlockChanged:()=>this.render()})}this.config.onBlockSelected&&this.config.onBlockSelected(r)},this.handleMultiRowCreate=e=>{let t=[];for(let n of e.groupIds){let e=uM(n);e&&t.push(e)}if(t.length===0)return;let n=this.toLocalISO(e.startTime),r=this.toLocalISO(e.endTime),i=this.engine.applyBlock({courts:t,timeRange:{start:n,end:r},type:LP.BLOCKED,reason:`New Block`});if(this.render(),i.applied.length>0){let e=i.applied[0].block.id,t=`block-${e}`,r=n.slice(0,10);setTimeout(()=>{let n=this.config.container.querySelector(`[data-item-id="${t}"]`);n&&this.popoverManager.showForEngineBlock(n,{itemId:t,blockId:e,engine:this.engine,day:r,onBlockChanged:()=>this.render()})},50)}this.config.onTimeRangeSelected&&this.config.onTimeRangeSelected({courts:t,start:n,end:r})},this.handleEngineEvent=e=>{switch(e.type){case`STATE_CHANGED`:case`BLOCKS_CHANGED`:this.render(),e.type===`BLOCKS_CHANGED`&&this.config.onBlocksChanged&&this.config.onBlocksChanged();break;case`CONFLICTS_CHANGED`:this.config.showConflicts&&this.render();break;case`AVAILABILITY_CHANGED`:this.updateTimelineWindow(),this.render();break}},this.engine=e,this.config={groupingMode:`BY_VENUE`,showConflicts:!0,showSegmentLabels:!1,colorScheme:rM,...t},this.initialize()}initialize(){if(this.config.initialDay)this.currentDay=this.config.initialDay;else{let e=this.engine.getActiveDays();this.currentDay=e.length>0?e[0]:t.tools.dateTime.extractDate(new Date().toISOString())}this.viewState.setSelectedDay(this.currentDay),this.config.initialView&&(this.currentView=this.config.initialView),this.unsubscribe=this.engine.subscribe(this.handleEngineEvent),this.ensureTimeline()}ensureTimeline(){this.timeline||setTimeout(()=>{this.timeline||this.createTimelineWithData()},0)}getViewDays(){if(!this.currentDay)return[];let e=vP[this.currentView],t=e?e.days:1;if(t<=0)return this.engine.getActiveDays();if(t<=1)return[this.currentDay];let n=this.engine.getActiveDays(),r=n.indexOf(this.currentDay);return r===-1?[this.currentDay]:n.slice(r,r+t)}buildViewData(){if(!this.currentDay)return{groups:[],items:[]};let e=this.getViewDays(),t=this.engine.listCourtMeta(),n=this.viewState.getLayerVisibility(),r={groupingMode:this.config.groupingMode,layerVisibility:n,showSegmentLabels:this.config.showSegmentLabels,colorScheme:this.config.colorScheme},i=iM(this.engine.getDayTimeline(e[0]),t,r);this.visibleCourts!==null&&this.visibleCourts.size>0&&(i=i.filter(e=>this.visibleCourts.has(String(e.id))));let a=this.visibleCourts!==null&&this.visibleCourts.size>0&&i.length>0?new Set(i.map(e=>String(e.id))):null,o=e.length<=1?this.engine.getActiveDays():e,s=[],c=[];for(let e of o){let t=this.engine.getDayTimeline(e);s.push(...aM(t,r)),c.push(...sM(this.engine.getDayBlocks(e),r))}let l=a?s.filter(e=>a.has(String(e.group))):s,u=a?c.filter(e=>a.has(String(e.group))):c,d=[...l,...u];return{groups:i.map((e,t)=>({id:String(e.id),content:typeof e.content==`string`?e.content:``,order:t,courtRef:e.courtRef,surface:e.surface,indoor:e.indoor,hasLights:e.hasLights,tags:e.tags})),items:d.map(e=>({id:String(e.id),group:String(e.group),content:e.content,start:e.start,end:e.end,type:e.type===`background`?`background`:`range`,className:e.className,style:e.style,title:e.title,editable:e.editable,blockId:e.blockId,status:e.status,reason:e.reason,isBlock:e.isBlock,isSegment:e.isSegment,isConflict:e.isConflict}))}}createTimelineWithData(){let e=this.engine.getConfig(),n=this.currentDay||t.tools.dateTime.extractDate(new Date().toISOString()),r=this.getViewDays(),i=r[0]||n,a=r[r.length-1]||n,o=this.engine.getVisibleTimeRange(i),s=this.engine.getVisibleTimeRange(a),c=fM({dayStartTime:o.startTime,dayEndTime:o.endTime,slotMinutes:e.slotMinutes,day:i}),l=vP[this.currentView],u=r.length>1?new Date(`${a}T${s.endTime}:00`):c.end,d=this.engine.getActiveDays(),f=d[0]||i,p=d[d.length-1]||a,m=this.engine.getVisibleTimeRange(f),h=this.engine.getVisibleTimeRange(p),g=new Date(`${f}T${m.startTime}:00`),_=new Date(`${p}T${h.endTime}:00`),{groups:v,items:y}=this.buildViewData();this.currentItems.clear();for(let e of y)this.currentItems.set(e.id,e);this.timeline=new IP(this.config.container,y,v,{start:c.start,end:u,min:g,max:_,zoomMin:c.zoomMin,zoomMax:_.getTime()-g.getTime(),snap:e=>this.snapToMinutes(e,5),rowHeight:40,height:`100%`,timeAxis:l?l.timeAxis:{scale:`hour`,step:1},showTooltips:!0}),this.timeline.setDailyBounds(o.startTime,o.endTime),r.length>1&&this.timeline.setVisibleDays(r),this.timeline.on(`click`,this.handleTimelineClick),this.timeline.onMove(this.handleOnMove),this.timeline.onMoving(this.handleOnMoving),this.timeline.onMultiRowCreate(this.handleMultiRowCreate),this.timeline.onDayClick(e=>{this.setDay(e),this.setViewPreset(`day`),this.config.onDayNavigate?.(e)}),this.config.onBlocksChanged?.()}setDay(e){this.currentDay!==e&&(this.currentDay=e,this.viewState.setSelectedDay(e),this.updateTimelineWindow(),this.render())}getDay(){return this.currentDay}setView(e){this.currentView=e,this.updateTimelineWindow()}setViewPreset(e){let t=vP[e];if(!t||!this.timeline||!this.currentDay)return;this.currentView=e;let n=this.getViewDays(),r=n[0],i=n[n.length-1],a=this.engine.getVisibleTimeRange(r),o=this.engine.getVisibleTimeRange(i);this.timeline.beginBatchUpdate();let s=t.days===0||t.days>1;this.timeline.setDailyBounds(a.startTime,a.endTime),s?this.timeline.setVisibleDays(n):this.timeline.clearVisibleDays();let c=new Date(`${r}T${a.startTime}:00`),l=new Date(`${i}T${o.endTime}:00`);this.timeline.setWindow(c,l,{animation:!1}),this.timeline.setOptions({timeAxis:t.timeAxis});let{groups:u,items:d}=this.buildViewData();this.currentItems.clear();for(let e of d)this.currentItems.set(e.id,e);this.timeline.setGroups(u),this.timeline.setItems(d),this.timeline.endBatchUpdate(),this.config.onBlocksChanged?.()}setSelectedCourts(e){this.selectedCourts=new Set(e)}getSelectedCourts(){return Array.from(this.selectedCourts)}setVisibleCourts(e){e&&e.size===0?this.visibleCourts=null:this.visibleCourts=e,this.render()}setLayerVisibility(e,t){this.viewState.setLayerVisibility(e,t),this.render()}refresh(){this.updateTimelineWindow(),this.render()}destroy(){this.popoverManager.destroy(),this.unsubscribe&&this.unsubscribe(),this.timeline&&=(this.timeline.destroy(),null)}updateTimelineWindow(){if(!this.timeline||!this.currentDay)return;let e=this.engine.getConfig(),t=this.getViewDays(),n=t[0]||this.currentDay,r=t[t.length-1]||this.currentDay,i=this.engine.getVisibleTimeRange(n),a=this.engine.getVisibleTimeRange(r),o=fM({dayStartTime:i.startTime,dayEndTime:i.endTime,slotMinutes:e.slotMinutes,day:n}),s=vP[this.currentView],c=t.length>1?new Date(`${r}T${a.endTime}:00`):o.end,l=this.engine.getActiveDays(),u=l[0]||n,d=l[l.length-1]||r,f=this.engine.getVisibleTimeRange(u),p=this.engine.getVisibleTimeRange(d),m=new Date(`${u}T${f.startTime}:00`),h=new Date(`${d}T${p.endTime}:00`);this.timeline.beginBatchUpdate(),this.timeline.setDailyBounds(i.startTime,i.endTime),t.length>1?this.timeline.setVisibleDays(t):this.timeline.clearVisibleDays(),this.timeline.setOptions({min:m,max:h}),this.timeline.setWindow(o.start,c,{animation:!1}),s&&this.timeline.setOptions({timeAxis:s.timeAxis}),this.timeline.endBatchUpdate()}render(){if(this.currentDay&&!this.isRendering){if(!this.timeline){this.ensureTimeline();return}this.isRendering=!0;try{let{groups:e,items:t}=this.buildViewData();this.currentItems.clear();for(let e of t)this.currentItems.set(e.id,e);this.timeline.setGroups(e),this.timeline.setItems(t)}finally{this.isRendering=!1}}}getPopoverManager(){return this.popoverManager}snapToMinutes(e,t){let n=e.getTime(),r=t*60*1e3,i=Math.round(n/r)*r;return new Date(i)}toLocalISO(e){let t=e=>e.toString().padStart(2,`0`);return`${e.getFullYear()}-${t(e.getMonth()+1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}:${t(e.getSeconds())}`}showConflictDialog(e){let t=e.filter(e=>e.severity===`ERROR`).map(e=>e.message).join(`
|
|
247
|
+
`);alert(`Cannot complete operation:\n\n${t}`)}getTimeline(){return this.timeline}getEngine(){return this.engine}getViewState(){return this.viewState}};function zP(e){let t=e?.totalHours??`Total Hours`,n=e?.blocked??`Blocked`,r=e?.available??`Available`,i=e?.avgPerCourt??`Avg Avail/Court`,a=document.createElement(`div`);a.className=`tg-stats-bar`;let o=e=>{let t=document.createElement(`span`);return t.innerHTML=`${e}: <b>—</b>`,a.appendChild(t),t},s=o(t),c=o(n),l=o(r),u=o(i);return{element:a,update:e=>{s.innerHTML=`${t}: <b>${e.totalHours.toFixed(1)}h</b>`,c.innerHTML=`${n}: <b>${e.blockedHours.toFixed(1)}h</b>`,l.innerHTML=`${r}: <b>${e.availableHours.toFixed(1)}h</b>`,u.innerHTML=`${i}: <b>${e.avgPerCourt.toFixed(1)}h</b>`}}}var BP,VP,HP,UP=!1;async function WP(){if(!BP){let e=await Promise.resolve().then(()=>(KN(),pM));BP=e.TimepickerUI,VP=e.PluginRegistry,HP=(await Promise.resolve().then(()=>(iP(),qN))).RangePlugin,!UP&&VP&&HP&&(VP.register(HP),UP=!0)}}var GP=0;async function KP(e){let{title:t,currentDay:n,currentStartTime:r,currentEndTime:i,showScopeToggle:a=!0,venueBounds:o,onConfirm:s,onCancel:c,labels:l={}}=e;await WP();let u=new Date(n+`T12:00:00`).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`}),d=`tp-court-avail-${++GP}`,f=a?`current-day`:`all-days`,p=document.createElement(`div`);p.className=`tg-modal`,p.style.cssText=`
|
|
248
248
|
position: fixed; top: 0; left: 0; right: 0; bottom: 0;
|
|
249
249
|
background: var(--chc-bg-overlay); z-index: 10000;
|
|
250
250
|
display: flex; align-items: center; justify-content: center;
|
|
@@ -259,14 +259,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
259
259
|
display: none; padding: 8px 12px; margin-bottom: 12px; border-radius: 6px;
|
|
260
260
|
background: #fef3c7; border: 1px solid #f59e0b; color: #92400e;
|
|
261
261
|
font-size: 12px; line-height: 1.4;
|
|
262
|
-
`,v.appendChild(e),v.dataset.venueBoundsStart=o.startTime,v.dataset.venueBoundsEnd=o.endTime}if(a){let e=document.createElement(`div`);e.style.cssText=`margin-bottom: 8px;`;let t=document.createElement(`div`);t.textContent=(l.applyTo||`Apply to`)+`:`,t.style.cssText=`font-size: 12px; color: var(--chc-text-secondary); margin-bottom: 6px; font-weight: 500;`,e.appendChild(t);let n=`availability-scope-${d}`,r=(t,r,i)=>{let a=document.createElement(`label`);a.style.cssText=`display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; font-size: 13px; color: var(--chc-text-primary);`;let o=document.createElement(`input`);o.type=`radio`,o.name=n,o.value=t,o.checked=i,o.style.cursor=`pointer`,o.addEventListener(`change`,()=>{o.checked&&(f=t)});let s=document.createElement(`span`);s.textContent=r,a.appendChild(o),a.appendChild(s),e.appendChild(a)};r(`current-day`,l.currentDayOnly?l.currentDayOnly.replace("${day}",u):`Current day only (${u})`,!0),r(`all-days`,l.allDays||`All tournament days`,!1),v.appendChild(e)}p.appendChild(m),p.addEventListener(`click`,e=>{e.target===p&&(C(),c?.())}),document.body.appendChild(p);let y=new
|
|
262
|
+
`,v.appendChild(e),v.dataset.venueBoundsStart=o.startTime,v.dataset.venueBoundsEnd=o.endTime}if(a){let e=document.createElement(`div`);e.style.cssText=`margin-bottom: 8px;`;let t=document.createElement(`div`);t.textContent=(l.applyTo||`Apply to`)+`:`,t.style.cssText=`font-size: 12px; color: var(--chc-text-secondary); margin-bottom: 6px; font-weight: 500;`,e.appendChild(t);let n=`availability-scope-${d}`,r=(t,r,i)=>{let a=document.createElement(`label`);a.style.cssText=`display: flex; align-items: center; gap: 8px; padding: 3px 0; cursor: pointer; font-size: 13px; color: var(--chc-text-primary);`;let o=document.createElement(`input`);o.type=`radio`,o.name=n,o.value=t,o.checked=i,o.style.cursor=`pointer`,o.addEventListener(`change`,()=>{o.checked&&(f=t)});let s=document.createElement(`span`);s.textContent=r,a.appendChild(o),a.appendChild(s),e.appendChild(a)};r(`current-day`,l.currentDayOnly?l.currentDayOnly.replace("${day}",u):`Current day only (${u})`,!0),r(`all-days`,l.allDays||`All tournament days`,!1),v.appendChild(e)}p.appendChild(m),p.addEventListener(`click`,e=>{e.target===p&&(C(),c?.())}),document.body.appendChild(p);let y=new BP(g,{range:{enabled:!0,fromLabel:l.startTime||`Start`,toLabel:l.endTime||`End`},clock:{type:`12h`,incrementMinutes:5},ui:{theme:`crane`,inline:{enabled:!0,containerId:d,showButtons:!0}},labels:{ok:l.apply||`Apply`,cancel:l.cancel||`Cancel`},callbacks:{onRangeConfirm:e=>{let t=e.from||r,n=e.to||i;C(),s({startTime:t,endTime:n,scope:f})},onCancel:()=>{C(),c?.()}}});y.create();let b=_.querySelector(`.tp-ui-wrapper`),x=b?.querySelector(`.tp-ui-footer`),S=document.createElement(`div`);if(S.textContent=t,S.style.cssText=`
|
|
263
263
|
text-align: center; font-size: 16px; font-weight: 600;
|
|
264
264
|
padding: 12px 24px 4px;
|
|
265
265
|
background: var(--tp-bg); color: var(--tp-text);
|
|
266
|
-
`,b?b.prepend(S):_.prepend(S),x&&b?x.before(v):m.appendChild(v),o){let e=v.querySelector(`.tp-court-avail-warning`);((t,n)=>{if(!e||!t||!n||t===`--:--`||n===`--:--`)return;let r=t<o.startTime,i=n>o.endTime;r||i?(e.textContent=(l.venueWarning||"Venue hours are ${startTime}–${endTime}. The venue will be widened to accommodate this change.").replace("${startTime}",o.startTime).replace("${endTime}",o.endTime),e.style.display=`block`):e.style.display=`none`})(r,i)}function C(){y?.destroy&&y.destroy(),p.remove()}}var{calculateCapacityStats:
|
|
266
|
+
`,b?b.prepend(S):_.prepend(S),x&&b?x.before(v):m.appendChild(v),o){let e=v.querySelector(`.tp-court-avail-warning`);((t,n)=>{if(!e||!t||!n||t===`--:--`||n===`--:--`)return;let r=t<o.startTime,i=n>o.endTime;r||i?(e.textContent=(l.venueWarning||"Venue hours are ${startTime}–${endTime}. The venue will be widened to accommodate this change.").replace("${startTime}",o.startTime).replace("${endTime}",o.endTime),e.style.display=`block`):e.style.display=`none`})(r,i)}function C(){y?.destroy&&y.destroy(),p.remove()}}var{calculateCapacityStats:qP}=t.temporal,JP=class{constructor(e){this.control=null,this.rootElement=null,this.venueTreeElement=null,this.calendarElement=null,this.capacityElement=null,this.statsBarInstance=null,this.viewToolbarResult=null,this.datepicker=null,this.visibleCourts=new Set,this.initialSnapshot=``,this.isDirty=!1,this.handleEngineEvent=e=>{e.type===`BLOCKS_CHANGED`&&(this.updateCapacityStats(),this.updateStatsBar(),this.checkDirtyState(),this.config.onMutationsApplied&&this.config.onMutationsApplied(e.payload.mutations)),e.type===`AVAILABILITY_CHANGED`&&this.checkDirtyState()},this.handleBlockSelected=e=>{},this.handleCourtSelected=e=>{},this.handleTimeRangeSelected=e=>{},this.handleCourtCheckboxChange=e=>{let t=e.target,n=t.dataset.courtId,r=t.dataset.venueId,i=t.dataset.tournamentId;if(!n||!r||!i)return;let a=`${i}|${r}|${n}`;t.checked?this.visibleCourts.add(a):this.visibleCourts.delete(a),this.updateVenueCheckboxState(r);let o=new Set(this.visibleCourts);this.control?.setVisibleCourts(o)},this.handleVenueCheckboxChange=e=>{let t=e.target,n=t.dataset.venue,r=t.dataset.tournamentId;if(!n||!r)return;this.engine.listCourtMeta().filter(e=>e.ref.venueId===n).forEach(e=>{let n=`${e.ref.tournamentId}|${e.ref.venueId}|${e.ref.courtId}`;t.checked?this.visibleCourts.add(n):this.visibleCourts.delete(n)}),(this.venueTreeElement?.querySelectorAll(`.court-checkbox[data-venue-id="${n}"]`))?.forEach(e=>{e.checked=t.checked});let i=new Set(this.visibleCourts);this.control?.setVisibleCourts(i)},this.config={showVenueTree:!0,showCapacity:!0,showToolbar:!0,groupingMode:`BY_VENUE`,showConflicts:!0,showSegmentLabels:!1,...e},this.engine=new t.TemporalEngine,this.engine.init(e.tournamentRecord,e.engineConfig),this.initialSnapshot=this.takeSnapshot(),this.engine.subscribe(this.handleEngineEvent)}render(e){e.innerHTML=``,this.rootElement=this.createRootElement(),e.appendChild(this.rootElement),this.config.showToolbar&&this.renderToolbar(),this.config.showCapacity&&this.renderCapacityIndicator();let t=this.rootElement.querySelector(`.temporal-grid-main`);if(!t)return;let n=document.createElement(`div`);n.className=`temporal-grid-layout`,t.appendChild(n),this.config.showVenueTree&&this.renderVenueTree(n),this.renderCalendar(n),this.calendarElement&&(this.control=new RP(this.engine,{container:this.calendarElement,initialDay:this.config.initialDay,initialView:this.config.initialView,groupingMode:this.config.groupingMode,showConflicts:this.config.showConflicts,showSegmentLabels:this.config.showSegmentLabels,onBlockSelected:this.handleBlockSelected,onCourtSelected:this.handleCourtSelected,onTimeRangeSelected:this.handleTimeRangeSelected,onBlocksChanged:()=>{this.updateCapacityStats(),this.updateStatsBar()},onDayNavigate:e=>{this.viewToolbarResult?.setActiveView(`day`),this.viewToolbarResult?.setDate(e),this.datepicker&&this.datepicker.setDate(e,{clear:!0}),this.updateCapacityStats(),this.updateStatsBar()}}),this.config.showToolbar&&this.initDatepicker())}destroy(){this.datepicker&&=(this.datepicker.destroy(),null),this.control&&=(this.control.destroy(),null),this.rootElement&&this.rootElement.parentNode&&this.rootElement.parentNode.removeChild(this.rootElement),this.rootElement=null,this.venueTreeElement=null,this.calendarElement=null,this.capacityElement=null,this.viewToolbarResult=null}createRootElement(){let e=document.createElement(`div`);return e.className=`temporal-grid-root`,e.innerHTML=`
|
|
267
267
|
<div class="temporal-grid-header"></div>
|
|
268
268
|
<div class="temporal-grid-main"></div>
|
|
269
|
-
`,e}renderToolbar(){let e=this.rootElement?.querySelector(`.temporal-grid-header`);if(!e)return;let t=this.config.labels;this.viewToolbarResult=
|
|
269
|
+
`,e}renderToolbar(){let e=this.rootElement?.querySelector(`.temporal-grid-header`);if(!e)return;let t=this.config.labels;this.viewToolbarResult=yP(e=>this.control?.setViewPreset(e),this.config.initialView||`day`,e=>this.handleDateChange(e),{labels:t,onSetDefaultAvailability:this.config.onSetDefaultAvailability,onSave:this.config.onSave}),e.appendChild(this.viewToolbarResult.element);let n=this.engine.getActiveDays(),r=this.config.initialDay||(n.length>0?n[0]:``);r&&this.viewToolbarResult.setDate(r),this.statsBarInstance=zP(t),e.appendChild(this.statsBarInstance.element)}initDatepicker(){if(this.datepicker||!this.viewToolbarResult)return;let e=this.engine.getActiveDays(),t=new Set(e);this.datepicker=new $t(this.viewToolbarResult.dateInput,{format:`yyyy-mm-dd`,language:this.config.language||`en`,autohide:!0,beforeShowDay:e=>{let n=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,`0`),i=String(e.getDate()).padStart(2,`0`);return t.has(`${n}-${r}-${i}`)?{classes:`tg-datepicker-active-day`}:{}}});let n=this.config.initialDay||(e.length>0?e[0]:``);n&&this.datepicker.setDate(n,{clear:!0})}handleDateChange(e){let t=this.engine.getActiveDays();if(t.length===0)return;let n=e;t.includes(e)||(n=t.reduce((t,n)=>Math.abs(new Date(n).getTime()-new Date(e).getTime())<Math.abs(new Date(t).getTime()-new Date(e).getTime())?n:t,t[0])),this.control?.setDay(n),this.updateCapacityStats(),this.updateStatsBar(),this.viewToolbarResult&&this.viewToolbarResult.setDate(n),this.datepicker&&this.datepicker.setDate(n,{clear:!0})}renderCapacityIndicator(){let e=this.rootElement?.querySelector(`.temporal-grid-header`);if(!e)return;let t=this.config.labels,n=t?.courtAvailability??`Court Availability`,r=t?.totalHours??`Total Hours`,i=t?.avgPerCourt??`Avg/Court`,a=document.createElement(`div`);a.className=`temporal-grid-capacity`,a.innerHTML=`
|
|
270
270
|
<div class="capacity-label">${n}:</div>
|
|
271
271
|
<div class="capacity-stats">
|
|
272
272
|
<div class="stat">
|
|
@@ -285,7 +285,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
285
285
|
<div class="tree-content" id="venue-tree-content">
|
|
286
286
|
<!-- Tree will be populated dynamically -->
|
|
287
287
|
</div>
|
|
288
|
-
`,e.appendChild(t),this.venueTreeElement=t,this.updateVenueTree()}renderCalendar(e){let t=document.createElement(`div`);t.className=`temporal-grid-calendar`,e.appendChild(t),this.calendarElement=t}takeSnapshot(){let e=this.engine.getActiveDays(),t=this.engine.listCourtMeta(),n=[];for(let r of e){let e=this.engine.getDayBlocks(r).map(e=>({id:e.id,type:e.type,start:e.start,end:e.end,court:`${e.court?.venueId}|${e.court?.courtId}`})),i=t.map(e=>{let t=this.engine.getCourtAvailability(e.ref,r);return{ref:`${e.ref.venueId}|${e.ref.courtId}`,s:t.startTime,e:t.endTime}});n.push({day:r,blocks:e,avails:i})}return JSON.stringify(n)}checkDirtyState(){let e=this.takeSnapshot(),t=this.isDirty;this.isDirty=e!==this.initialSnapshot,this.isDirty!==t&&(this.viewToolbarResult?.setSaveEnabled(this.isDirty),this.config.onDirtyChange&&this.config.onDirtyChange(this.isDirty))}resetDirtyState(){this.initialSnapshot=this.takeSnapshot(),this.isDirty=!1,this.viewToolbarResult?.setSaveEnabled(!1),this.config.onDirtyChange&&this.config.onDirtyChange(!1)}updateStatsBar(){if(!this.statsBarInstance||!this.control)return;let e=this.control.getViewDays();if(e.length===0)return;let t=0,n=0,r=0,i=0;for(let a of e){let e=
|
|
288
|
+
`,e.appendChild(t),this.venueTreeElement=t,this.updateVenueTree()}renderCalendar(e){let t=document.createElement(`div`);t.className=`temporal-grid-calendar`,e.appendChild(t),this.calendarElement=t}takeSnapshot(){let e=this.engine.getActiveDays(),t=this.engine.listCourtMeta(),n=[];for(let r of e){let e=this.engine.getDayBlocks(r).map(e=>({id:e.id,type:e.type,start:e.start,end:e.end,court:`${e.court?.venueId}|${e.court?.courtId}`})),i=t.map(e=>{let t=this.engine.getCourtAvailability(e.ref,r);return{ref:`${e.ref.venueId}|${e.ref.courtId}`,s:t.startTime,e:t.endTime}});n.push({day:r,blocks:e,avails:i})}return JSON.stringify(n)}checkDirtyState(){let e=this.takeSnapshot(),t=this.isDirty;this.isDirty=e!==this.initialSnapshot,this.isDirty!==t&&(this.viewToolbarResult?.setSaveEnabled(this.isDirty),this.config.onDirtyChange&&this.config.onDirtyChange(this.isDirty))}resetDirtyState(){this.initialSnapshot=this.takeSnapshot(),this.isDirty=!1,this.viewToolbarResult?.setSaveEnabled(!1),this.config.onDirtyChange&&this.config.onDirtyChange(!1)}updateStatsBar(){if(!this.statsBarInstance||!this.control)return;let e=this.control.getViewDays();if(e.length===0)return;let t=0,n=0,r=0,i=0;for(let a of e){let e=qP(this.engine.getCapacityCurve(a));t+=e.totalCourtHours,n+=e.totalUnavailableHours??0,r+=e.totalAvailableHours??0,i=e.totalCourts??0}let a=i||1;this.statsBarInstance.update({totalHours:t,blockedHours:n,availableHours:r,avgPerCourt:r/a})}updateCapacityStats(){if(!this.capacityElement||!this.control)return;let e=this.control.getViewDays();if(e.length===0)return;let t=0,n=0;for(let r of e){let e=qP(this.engine.getCapacityCurve(r));t+=e.totalAvailableHours??0,n=e.totalCourts??0}let r=this.capacityElement.querySelector(`#total-hours`),i=this.capacityElement.querySelector(`#avg-hours`);r&&(r.textContent=`${t.toFixed(1)}h`);let a=n>0?t/n:0;i&&(i.textContent=`${a.toFixed(1)}h`)}updateVenueTree(){if(!this.venueTreeElement)return;let e=this.venueTreeElement.querySelector(`#venue-tree-content`);if(!e)return;let t=this.engine.listCourtMeta(),n=this.engine.getConfig().tournamentId;this.visibleCourts.size===0&&t.forEach(e=>{let t=`${e.ref.tournamentId}|${e.ref.venueId}|${e.ref.courtId}`;this.visibleCourts.add(t)});let r=new Map;for(let e of this.config.tournamentRecord?.venues||[]){let t=e.venueId;t&&r.set(t,e.venueName||e.venueAbbreviation||t)}let i=new Map;for(let e of t){let t=e.ref.venueId;i.has(t)||i.set(t,[]),i.get(t).push(e)}let a=``;for(let[e,t]of i){let i=t.every(e=>{let t=`${e.ref.tournamentId}|${e.ref.venueId}|${e.ref.courtId}`;return this.visibleCourts.has(t)}),o=r.get(e)||e;a+=`
|
|
289
289
|
<div class="venue-group">
|
|
290
290
|
<div class="venue-header">
|
|
291
291
|
<input type="checkbox" class="venue-checkbox"
|
|
@@ -317,5 +317,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
317
317
|
`}).join(``)}
|
|
318
318
|
</div>
|
|
319
319
|
</div>
|
|
320
|
-
`}e.innerHTML=a,e.querySelectorAll(`.court-checkbox`).forEach(e=>{e.addEventListener(`change`,this.handleCourtCheckboxChange)}),e.querySelectorAll(`.venue-checkbox`).forEach(e=>{e.addEventListener(`change`,this.handleVenueCheckboxChange)}),e.querySelectorAll(`.venue-edit-icon`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation();let t=e.currentTarget,n=t.dataset.venue,r=t.dataset.tournamentId,i=t.dataset.venueName||n,a=this.control?.getDay()||this.engine.getActiveDays()[0]||`2026-01-01`,o=this.engine.getVenueAvailability(r,n),s=this.engine.getConfig();AN({title:`Venue Defaults \u2014 ${i}`,currentDay:a,currentStartTime:o?.startTime||s.dayStartTime,currentEndTime:o?.endTime||s.dayEndTime,showScopeToggle:!1,onConfirm:({startTime:e,endTime:t})=>{this.engine.setVenueDefaultAvailability(r,n,{startTime:e,endTime:t}),this.engine.clearCourtAvailabilityForVenue(r,n),this.control?.refresh()}})})}),e.querySelectorAll(`.court-edit-icon`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation();let t=e.currentTarget,n=t.dataset.courtId,r=t.dataset.venueId,i=t.dataset.tournamentId,a=t.dataset.courtName||n,o={tournamentId:i,venueId:r,courtId:n},s=this.control?.getDay()||this.engine.getActiveDays()[0]||`2026-01-01`,c=this.engine.getCourtAvailability(o,s);AN({title:`Court \u2014 ${a}`,currentDay:s,currentStartTime:c.startTime,currentEndTime:c.endTime,showScopeToggle:!0,onConfirm:({startTime:e,endTime:t,scope:n})=>{n===`all-days`?this.engine.setCourtAvailabilityAllDays(o,{startTime:e,endTime:t}):this.engine.setCourtAvailability(o,s,{startTime:e,endTime:t}),this.control?.refresh()}})})})}updateVenueCheckboxState(e){let t=this.engine.listCourtMeta().filter(t=>t.ref.venueId===e),n=t.filter(e=>{let t=`${e.ref.tournamentId}|${e.ref.venueId}|${e.ref.courtId}`;return this.visibleCourts.has(t)}).length,r=this.venueTreeElement?.querySelector(`.venue-checkbox[data-venue="${e}"]`);r&&(n===0?(r.checked=!1,r.indeterminate=!1):n===t.length?(r.checked=!0,r.indeterminate=!1):(r.checked=!1,r.indeterminate=!0))}getEngine(){return this.engine}getControl(){return this.control}setDay(e){this.control?.setDay(e),this.updateCapacityStats()}refresh(){this.control?.refresh(),this.updateCapacityStats(),this.updateVenueTree()}};function NN(e,t){let n=new MN(e);return n.render(t),n}var{LUCKY_DRAW:PN,ROUND_ROBIN:FN,AD_HOC:IN}=t.drawDefinitionConstants;function LN(e){let t=Math.max(2,e),n=2**Math.floor(Math.log2(t)),r=t-n;if(r<=0)return new Map;let i=new Map,a=0,o=n/2;for(;o>=1;)a++,r&o&&(a++,i.set(a,o)),o=Math.floor(o/2);return i}function RN(e){let t=Math.max(2,e),n=2**Math.floor(Math.log2(t)),r=t-n,i=0,a=n/2;for(;a>=1;)i++,r&a&&i++,a=Math.floor(a/2);return i}function zN(e){let t=Math.max(2,e),n=t%2?t+1:t,r=!!(Math.ceil(n/2)%2),i=[{participantsCount:n,preFeedRound:r}];for(;n>2;){let e=Math.ceil(n/2),t=e===1,r=!!(!t&&e%2);n=!t&&r?e+1:e;let a=!!(n!==2&&Math.ceil(n/2)%2);i.push({participantsCount:n,preFeedRound:a,feedRound:r})}return i}function BN(e){let t=Math.max(2,e);return t&t-1?zN(e).length:Math.ceil(Math.log2(t))}function VN(e,t){let n=Math.max(2,e);if(!(n&n-1))return Math.floor(n/2**t);let r=zN(e),i=t-1;if(i<0||i>=r.length)return 0;let{participantsCount:a,preFeedRound:o}=r[i],s=a/2,c=o?s-1:s;if(t===1&&n%2!=0){let e=a-n;c-=e}return c}function HN(e,t,n){return e===FN?(n?.groupSize||Math.min(t,4))-1:e===IN?n?.roundsCount||1:e===PN?BN(t):RN(t)}function UN(e,t,n){return e===PN?VN(t,n):Math.floor(t/2**n)}var{ROUND_ROBIN:WN,AD_HOC:GN,LUCKY_DRAW:KN}=t.drawDefinitionConstants,qN=0;function JN({structureType:e,drawSize:t,stage:n,structureId:r,qualifyingPositions:i,structureOptions:a}){return e===WN?XN({drawSize:t,stage:n,structureId:r,structureOptions:a}):e===GN?QN({drawSize:t,stage:n,structureId:r,roundsCount:a?.roundsCount||1}):e===KN?ZN({drawSize:t,stage:n,structureId:r}):YN({drawSize:t,stage:n,structureId:r,qualifyingPositions:i})}function YN({drawSize:e,stage:t,structureId:n,qualifyingPositions:r}){let i=Math.max(2,e),a=2**Math.floor(Math.log2(i)),o=i-a,s=[],c=a/2;for(;c>=1;)s.push({count:c,isFeed:!1}),o&c&&s.push({count:c,isFeed:!0}),c=Math.floor(c/2);if(r&&r>0&&e>r){let t=Math.round(Math.log2(e/r));t>0&&s.length>t&&(s.length=t)}let l=s.length,u=[],d=1,f=0,p=new Set;for(let e=0;e<l-1;e++)!s[e].isFeed&&s[e+1].isFeed&&p.add(e);for(let e=0;e<l;e++){let{count:r,isFeed:i}=s[e],a=e+1,o=i?2**Math.max(0,f-1):2**f,c=i||p.has(e);for(let s=1;s<=r;s++){let r=a===1&&!i;u.push({matchUpId:`preview-${++qN}`,roundNumber:a,roundPosition:s,drawPositions:r?[(s-1)*2+1,(s-1)*2+2]:i?[d++]:[],finishingRound:l-e,roundFactor:o,preFeedRound:c,stage:t,structureId:n})}i||f++}return u}function XN({drawSize:e,stage:t,structureId:n,structureOptions:r}){let i=[],a=r?.groupSize||Math.min(e,4),o=Math.ceil(e/a),s=a-1;for(let e=0;e<o;e++)for(let r=1;r<=s;r++){let o=Math.floor(a/2);for(let a=1;a<=o;a++)i.push({matchUpId:`preview-${++qN}`,roundNumber:r,roundPosition:e*o+a,isRoundRobin:!0,stage:t,structureId:`${n}-g${e}`})}return i}function ZN({drawSize:e,stage:t,structureId:n}){let r=Math.max(2,e);if(!(r&r-1))return YN({drawSize:e,stage:t,structureId:n});let i=zN(r),a=i.length,o=[],s=1;for(let e=0;e<a;e++){let{participantsCount:r,preFeedRound:c}=i[e],l=r/2,u=e+1;for(let r=1;r<=l;r++){let i=u===1;o.push({matchUpId:`preview-${++qN}`,roundNumber:u,roundPosition:r,drawPositions:i?[s++,s++]:[],finishingRound:a-e,roundFactor:1,preFeedRound:!!c,stage:t,structureId:n})}}return o}function QN({drawSize:e,stage:t,structureId:n,roundsCount:r=1}){let i=[];if(e<2)return i;let a=Math.floor(e/2);for(let e=1;e<=r;e++)for(let r=1;r<=a;r++)i.push({matchUpId:`preview-${++qN}`,roundNumber:e,roundPosition:r,finishingRound:1,stage:t,structureId:n});return i}var{ROUND_ROBIN:$N}=t.drawDefinitionConstants,eP=new Map;function tP(e,n,r){let i=`${e}:${n}:${r||``}`,a=eP.get(i);if(a)return a;try{let a={drawSize:n,drawType:e};r&&(a.structureOptions={groupSize:r});let{tournamentRecord:o}=t.mocksEngine.generateTournamentRecord({drawProfiles:[a]}),s=o?.events?.[0]?.drawDefinitions?.[0];if(!s)return nP(i,{});let c=(s.structures||[])[0];if(!c)return nP(i,{});let l=c.structureType===`CONTAINER`,u={};if(l||e===$N){let{availablePlayoffProfiles:e}=t.drawsGovernor.getAvailablePlayoffProfiles({drawDefinition:s}),n=e?.[0];n&&(u={playoffFinishingPositionRanges:n.playoffFinishingPositionRanges,finishingPositionsAvailable:n.finishingPositionsAvailable})}else{let e=c.structureId,{playoffRounds:n,playoffRoundsRanges:r}=t.drawsGovernor.getAvailablePlayoffProfiles({drawDefinition:s,structureId:e});u={playoffRounds:n,playoffRoundsRanges:r}}return nP(i,u)}catch{return nP(i,{})}}function nP(e,t){return eP.set(e,t),t}var{MAIN:rP,QUALIFYING:iP,CONSOLATION:aP,PLAY_OFF:oP,ROUND_ROBIN:sP,AD_HOC:cP,LUCKY_DRAW:lP,WINNER:uP,LOSER:dP}=t.drawDefinitionConstants,fP=240,pP=48,mP=16;function hP(e){if(e.structureType===sP)return(e.structureOptions?.groupSize||Math.min(e.drawSize,4))-1;if(e.structureType===cP)return e.structureOptions?.roundsCount||1;if(e.structureType===lP)return BN(e.drawSize);let t=Math.max(2,e.drawSize),n=2**Math.floor(Math.log2(t)),r=t-n,i=0,a=n/2;for(;a>=1;)i++,r&a&&i++,a=Math.floor(a/2);if(e.qualifyingPositions&&e.qualifyingPositions>0&&e.drawSize>e.qualifyingPositions){let t=Math.round(Math.log2(e.drawSize/e.qualifyingPositions));t>0&&t<i&&(i=t)}return i}function gP(e){let t=hP(e);return Math.max(fP,t*pP+mP)}var _P={[rP]:`tb-card-badge--main`,[iP]:`tb-card-badge--qualifying`,[aP]:`tb-card-badge--consolation`,[oP]:`tb-card-badge--playoff`};function vP(e,t,n,r,i,a,o,s){let c=a&&a.length>0,l=document.createElement(`div`);l.className=`tb-card${n?` tb-card--selected`:``}${c?` tb-card--warning`:``}`,l.style.left=`${e.position.x}px`,l.style.top=`${e.position.y}px`,l.style.minWidth=`${gP(e)}px`,l.setAttribute(`data-node-id`,e.id);let u=document.createElement(`div`);u.className=`tb-card-header`;let d=document.createElement(`span`);d.className=`tb-card-badge ${_P[e.stage]||`tb-card-badge--main`}`,d.textContent=e.stage.substring(0,4);let f=document.createElement(`span`);f.className=`tb-card-name`,f.textContent=e.structureName;let p=document.createElement(`span`);if(p.className=`tb-card-size`,p.textContent=`\u00d7${e.drawSize}`,u.appendChild(d),u.appendChild(f),u.appendChild(p),o){let e=document.createElement(`div`);e.className=`tb-card-advance`,e.textContent=o,u.appendChild(e)}let m=document.createElement(`div`);m.className=`tb-card-preview`;let h=e.matchUps||JN({structureType:e.structureType,drawSize:e.drawSize,stage:e.stage,structureId:e.id,qualifyingPositions:e.qualifyingPositions,structureOptions:e.structureOptions});if(h.length>0)try{let t=li({matchUps:h,structureId:e.id,showHeaders:!1});t.style.transform=`scale(0.8)`,t.style.transformOrigin=`top left`,m.appendChild(t)}catch{m.textContent=`${e.structureType} \u00d7${e.drawSize}`,m.style.cssText+=`font-size:11px;color:var(--chc-text-muted);display:flex;align-items:center;justify-content:center;`}if(i?.length&&m.querySelector(`.chc-schematic-structure`)){let e=m.querySelectorAll(`.chc-schematic-round-container[data-round-number]`);for(let n of e){let e=parseInt(n.getAttribute(`data-round-number`)||`0`),r=i.filter(t=>t.roundNumber===e);if(!r.length)continue;let a=r.find(e=>e.isSelected)||r.find(e=>e.linkType===dP)||r.find(e=>e.linkType===uP)||r[0];n.classList.add(`tb-round-linked`),n.classList.add(`tb-round-linked--${a.linkType.toLowerCase()}`),n.classList.add(`tb-round-linked--${a.direction}`),a.isSelected&&n.classList.add(`tb-round-linked--active`),n.style.cursor=`pointer`,n.addEventListener(`click`,e=>{e.stopPropagation(),t.onSelectEdge(a.edgeId)}),n.title=r.map(t=>`R${e} ${t.linkType} ${t.direction===`source`?`out`:`in`}`).join(`, `)}}let g=tP(e.structureType,e.drawSize,e.structureOptions?.groupSize),_=null;g.playoffRoundsRanges?.length?(_=document.createElement(`div`),_.className=`tb-card-rounds`,_.textContent=g.playoffRoundsRanges.map(e=>`R${e.roundNumber}:${e.finishingPositionRange}`).join(` `)):g.playoffFinishingPositionRanges?.length&&(_=document.createElement(`div`),_.className=`tb-card-rounds`,_.textContent=g.playoffFinishingPositionRanges.map(e=>`P${e.finishingPosition}:${e.finishingPositionRange}`).join(` `));let v=document.createElement(`div`);v.className=`tb-card-ports`;let y=document.createElement(`div`);y.className=`tb-port tb-port--input`,y.title=`Input`,y.addEventListener(`mouseup`,()=>{t.onPortMouseUp(e.id)});let b=document.createElement(`div`);b.className=`tb-port-group`;let x=document.createElement(`div`);x.className=`tb-port tb-port--winner${r?` tb-port--connected`:``}`,x.title=r?`Winner linked`:`Winner output`,r||x.addEventListener(`mousedown`,n=>{n.stopPropagation(),t.onPortMouseDown(e.id,`winner`)});let S=document.createElement(`div`);if(S.className=`tb-port tb-port--loser`,S.title=`Loser output`,S.addEventListener(`mousedown`,n=>{n.stopPropagation(),t.onPortMouseDown(e.id,`loser`)}),b.appendChild(x),b.appendChild(S),v.appendChild(y),v.appendChild(b),l.appendChild(u),l.appendChild(m),s?.length){let e=document.createElement(`div`);e.className=`tb-card-chips`;for(let n of s){let r=document.createElement(`span`);r.className=`tb-card-chip`,r.textContent=`P${n.position}`,r.title=`Position ${n.position} → ${n.targetName}`,r.addEventListener(`click`,e=>{e.stopPropagation(),t.onSelectEdge(n.edgeId)}),e.appendChild(r)}l.appendChild(e)}if(_&&l.appendChild(_),c){let e=document.createElement(`div`);e.className=`tb-card-warning`,e.textContent=`⚠ Issue`;let t=document.createElement(`div`);t.className=`tb-card-warning-detail`,t.textContent=a.join(`; `),e.appendChild(t),e.addEventListener(`click`,t=>{t.stopPropagation(),e.classList.toggle(`tb-card-warning--open`)}),l.appendChild(e)}return l.appendChild(v),l.addEventListener(`mouseup`,()=>{t.onPortMouseUp(e.id)}),l.addEventListener(`click`,n=>{n.stopPropagation(),t.onSelect(e.id)}),t.onDoubleClick&&l.addEventListener(`dblclick`,n=>{n.stopPropagation(),t.onDoubleClick(e.id)}),l.addEventListener(`mousedown`,n=>{n.target.classList.contains(`tb-port`)||t.onDragStart(e.id,n.clientX,n.clientY)}),l}function yP(e,t){let n=gP(e);switch(t){case`input`:return{x:e.position.x,y:e.position.y+160/2};case`winner`:return{x:e.position.x+n,y:e.position.y+160/2-8};case`loser`:return{x:e.position.x+n,y:e.position.y+160/2+8}}}var{MAIN:bP,QUALIFYING:xP,CONSOLATION:SP,WINNER:CP,LOSER:wP,ROUND_ROBIN:TP}=t.drawDefinitionConstants,EP=`POSITION`,DP=0;function OP(e){return`${e}-${++DP}-${Date.now().toString(36)}`}function kP(e){let t=2;for(;t*2<=e;)t*=2;return t}var AP=160,jP=60,MP=30,NP=class{constructor(e){this.listeners=new Set,this.state={nodes:[],edges:[],selectedNodeId:null,selectedEdgeId:null,drawName:`New Draw`,...e}}getState(){return{...this.state}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){let e=this.getState();for(let t of this.listeners)t(e)}setDrawName(e){this.state.drawName=e,this.notify()}addNode(e){let t={...e,id:OP(`node`),position:this.nextNodePosition()};return this.state.nodes.push(t),this.state.templateName=void 0,this.notify(),t}updateNode(e,t){let n=this.state.nodes.find(t=>t.id===e);n&&(Object.keys(t).some(e=>e!==`position`)&&(this.state.templateName=void 0),Object.assign(n,t),this.notify())}removeNode(e){let t=this.state.edges.filter(t=>t.sourceNodeId===e).map(e=>e.targetNodeId);this.state.nodes=this.state.nodes.filter(t=>t.id!==e),this.state.edges=this.state.edges.filter(t=>t.sourceNodeId!==e&&t.targetNodeId!==e),this.state.selectedNodeId===e&&(this.state.selectedNodeId=null),this.state.templateName=void 0;for(let e of t)this.clampConsolationDrawSize(e);this.notify()}addEdge(e){if(e.linkType===CP&&this.state.edges.find(t=>t.sourceNodeId===e.sourceNodeId&&t.linkType===CP))return null;let t=this.state.nodes.find(t=>t.id===e.sourceNodeId),n=this.state.nodes.find(t=>t.id===e.targetNodeId);if(t?.structureType===TP&&e.linkType!==EP||t?.stage===xP&&n&&n.stage!==xP&&n.stage!==bP||n?.stage===xP&&t&&t.stage!==xP)return null;let r={...e,id:OP(`edge`),targetRoundNumber:e.targetRoundNumber||1,label:this.computeEdgeLabel(e)};return this.state.edges.push(r),this.state.templateName=void 0,this.clampConsolationDrawSize(r.targetNodeId),this.notify(),r}updateEdge(e,t){let n=this.state.edges.find(t=>t.id===e);n&&(Object.assign(n,t),n.label=this.computeEdgeLabel(n),this.state.templateName=void 0,this.notify())}removeEdge(e){let t=this.state.edges.find(t=>t.id===e);this.state.edges=this.state.edges.filter(t=>t.id!==e),this.state.selectedEdgeId===e&&(this.state.selectedEdgeId=null),this.state.templateName=void 0,t&&this.clampConsolationDrawSize(t.targetNodeId),this.notify()}selectNode(e){this.state.selectedNodeId=e,this.state.selectedEdgeId=null,this.notify()}selectEdge(e){this.state.selectedEdgeId=e,this.state.selectedNodeId=null,this.notify()}clampConsolationDrawSize(e){let t=this.state.nodes.find(t=>t.id===e);if(!t||t.stage!==SP)return;let n=this.inboundCapacity(e);n>0&&t.drawSize>n&&(t.drawSize=kP(n))}inboundCapacity(e){let t=this.state.edges.filter(t=>t.targetNodeId===e),n=0;for(let e of t){let t=this.state.nodes.find(t=>t.id===e.sourceNodeId);if(t)if(e.linkType===wP){let r=e.sourceRoundNumber||1;n+=UN(t.structureType,t.drawSize,r)}else n+=t.qualifyingPositions||Math.floor(t.drawSize/2)}return n}nextNodePosition(){if(this.state.nodes.length===0)return{x:40,y:40};let e=0;for(let t of this.state.nodes)e=Math.max(e,t.position.x+gP(t));return{x:e+jP,y:40}}autoLayout(){let e=this.state.nodes,t=this.state.edges;if(!e.length)return;let n=new Map,r=new Map;for(let e of t)r.has(e.sourceNodeId)||r.set(e.sourceNodeId,[]),r.get(e.sourceNodeId).push(e.targetNodeId),n.has(e.targetNodeId)||n.set(e.targetNodeId,[]),n.get(e.targetNodeId).push(e.sourceNodeId);let i=e.filter(e=>!n.has(e.id)||n.get(e.id).length===0);if(!i.length){let t=e.filter(e=>e.stage===bP);i.push(...t.length?t:[e[0]])}let a=new Map,o=new Set(e.filter(e=>e.stage===xP).map(e=>e.id)),s=[];for(let e of i)o.has(e.id)?a.set(e.id,-1):a.set(e.id,0),s.push(e.id);let c=e.length*(e.length-1)+e.length,l=0;for(;s.length&&l<c;){l++;let e=s.shift(),t=a.get(e),n=r.get(e)||[];for(let e of n){let n=t+1,r=a.get(e);(r===void 0||n>r)&&(a.set(e,n),s.push(e))}}for(let t of e)a.has(t.id)||a.set(t.id,0);let u=Math.min(...a.values());if(u<0)for(let[e,t]of a)a.set(e,t-u);let d=new Map;for(let t of e){let e=a.get(t.id);d.has(e)||d.set(e,[]),d.get(e).push(t)}let f=[...d.keys()].sort((e,t)=>e-t),p=40;for(let e of f){let t=d.get(e),n=Math.max(...t.map(e=>gP(e)));t.forEach((e,t)=>{e.position={x:p,y:t*(AP+MP)+40}}),p+=n+jP}}loadState(e){this.state={...e},this.notify()}computeEdgeLabel(e){let t=e.linkType||`LINK`,n=``;return e.sourceRoundNumber&&(n+=`R${e.sourceRoundNumber} `),n+=t.toLowerCase(),e.targetRoundNumber&&(n+=` \u2192 R${e.targetRoundNumber}`),e.qualifyingPositions&&(n+=` (${e.qualifyingPositions}Q)`),e.finishingPositions?.length&&(n+=` [${e.finishingPositions.join(`,`)}]`),n}},{WINNER:PP,LOSER:FP,QUALIFYING:IP,CONSOLATION:LP,ROUND_ROBIN:RP}=t.drawDefinitionConstants,zP=`POSITION`,BP=e=>e===RP;function VP(e,t){if(!BP(e.structureType))return;let n=t.edges.filter(t=>t.sourceNodeId===e.id&&t.linkType===zP);if(!n.length)return;let r=new Set(n.flatMap(e=>e.finishingPositions||[])),i=e.structureOptions?.groupSize||4;return`${r.size} of ${i} advance`}var HP=`http://www.w3.org/2000/svg`,UP={[PP]:`tb-edge--winner`,[FP]:`tb-edge--loser`,[zP]:`tb-edge--position`};function WP(e){let t=document.createElement(`div`);t.className=`tb-canvas`;let n=document.createElementNS(HP,`svg`);n.classList.add(`tb-canvas-svg`);let r=document.createElementNS(HP,`defs`);for(let[e,t]of Object.entries(UP)){let n=document.createElementNS(HP,`marker`);n.setAttribute(`id`,`arrowhead-${e}`),n.setAttribute(`markerWidth`,`8`),n.setAttribute(`markerHeight`,`6`),n.setAttribute(`refX`,`8`),n.setAttribute(`refY`,`3`),n.setAttribute(`orient`,`auto`);let i=document.createElementNS(HP,`polygon`);i.setAttribute(`points`,`0 0, 8 3, 0 6`),i.setAttribute(`class`,t),i.style.fill=`currentColor`,n.appendChild(i),r.appendChild(n)}n.appendChild(r);let i=document.createElement(`div`);i.className=`tb-canvas-nodes`;let a=document.createElement(`div`);a.className=`tb-canvas-spacer`,t.appendChild(n),t.appendChild(i),t.appendChild(a);let o=null,s=null,c=null,l=!1,u=null;t.addEventListener(`click`,()=>{l||(e.onSelectNode(null),e.onSelectEdge(null))}),t.addEventListener(`mousemove`,n=>{if(s&&!c){let e=n.clientX-s.startX,t=n.clientY-s.startY;Math.abs(e)+Math.abs(t)>=4&&(c=s,s=null)}if(c&&u){let t=n.clientX-c.startX,r=n.clientY-c.startY;e.onMoveNode(c.nodeId,Math.max(0,c.origX+t),Math.max(0,c.origY+r))}if(o?.tempLine){let e=t.getBoundingClientRect();o.tempLine.setAttribute(`x2`,String(n.clientX-e.left+t.scrollLeft)),o.tempLine.setAttribute(`y2`,String(n.clientY-e.top+t.scrollTop))}}),t.addEventListener(`mouseup`,()=>{c&&(l=!0,c=null,setTimeout(()=>{l=!1},0)),s=null,o?.tempLine&&(n.removeChild(o.tempLine),o=null)});function d(e){return new Set(e.edges.filter(e=>e.linkType===PP).map(e=>e.sourceNodeId).filter(t=>{let n=e.nodes.find(e=>e.id===t);return n&&n.stage===IP&&!BP(n.structureType)}))}function f(e){let t=new Map;for(let n of e.edges){let r=n.sourceRoundNumber,i=n.targetRoundNumber,a=n.id===e.selectedEdgeId;if(!r&&n.linkType===PP){let t=e.nodes.find(e=>e.id===n.sourceNodeId);t&&(r=hP(t))}r&&(t.has(n.sourceNodeId)||t.set(n.sourceNodeId,[]),t.get(n.sourceNodeId).push({roundNumber:r,linkType:n.linkType,direction:`source`,edgeId:n.id,isSelected:a})),i&&(t.has(n.targetNodeId)||t.set(n.targetNodeId,[]),t.get(n.targetNodeId).push({roundNumber:i,linkType:n.linkType,direction:`target`,edgeId:n.id,isSelected:a}))}return t}function p(e){let t=new Map;for(let n of e.edges){if(n.linkType!==PP)continue;let r=n.targetRoundNumber||1;if(r<=1)continue;let i=e.nodes.find(e=>e.id===n.sourceNodeId);if(!i||i.stage!==IP)continue;t.has(n.targetNodeId)||t.set(n.targetNodeId,[]);let a=i.qualifyingPositions||Math.floor(i.drawSize/4);t.get(n.targetNodeId).push({targetRound:r,qp:a,warning:`Round ${r} needs fed drawPositions to accommodate ${i.structureName} link`})}let n=new Map;for(let[r,i]of t){let t=e.nodes.find(e=>e.id===r);if(!t)continue;let a=LN(t.drawSize),o=new Map;for(let e of i)o.set(e.targetRound,(o.get(e.targetRound)||0)+e.qp);let s=[];for(let e of i)(a.get(e.targetRound)||0)<(o.get(e.targetRound)||0)&&s.push(e.warning);s.length>0&&n.set(r,s)}return n}function m(e){let t=new Map;for(let n of e.nodes){if(!BP(n.structureType))continue;let r=e.edges.filter(e=>e.sourceNodeId===n.id&&e.linkType===zP);if(!r.length)continue;let i=[];for(let t of r){let n=e.nodes.find(e=>e.id===t.targetNodeId);for(let e of t.finishingPositions||[])i.push({position:e,edgeId:t.id,targetName:n?.structureName||`?`})}i.sort((e,t)=>e.position-t.position),t.set(n.id,i)}return t}function h(e,t,n){return e&&BP(e.structureType)?zP:n===`loser`||t?.stage===LP?FP:PP}function g(t){return{onSelect:t=>{e.onSelectNode(t)},onSelectEdge:t=>{e.onSelectEdge(t)},onDoubleClick:e.onDoubleClickNode?t=>e.onDoubleClickNode(t):void 0,onPortMouseDown:(e,r)=>{let i=t.nodes.find(t=>t.id===e);if(!i)return;let a=yP(i,r),s=document.createElementNS(HP,`line`);s.setAttribute(`x1`,String(a.x)),s.setAttribute(`y1`,String(a.y)),s.setAttribute(`x2`,String(a.x)),s.setAttribute(`y2`,String(a.y)),s.setAttribute(`stroke`,r===`winner`?`green`:`red`),s.setAttribute(`stroke-width`,`2`),s.setAttribute(`stroke-dasharray`,`4 2`),n.appendChild(s),o={sourceNodeId:e,portType:r,tempLine:s}},onPortMouseUp:r=>{if(o&&o.sourceNodeId!==r){let n=h(t.nodes.find(e=>e.id===o.sourceNodeId),t.nodes.find(e=>e.id===r),o.portType);e.onCreateEdge(o.sourceNodeId,r,n)}o?.tempLine&&n.removeChild(o.tempLine),o=null},onDragStart:(e,n,r)=>{let i=t.nodes.find(t=>t.id===e);i&&(s={nodeId:e,startX:n,startY:r,origX:i.position.x,origY:i.position.y})}}}function _(e){u=e,i.innerHTML=``;let t=d(e),r=f(e),o=p(e),s=m(e),c=g(e);for(let n of e.nodes){let a=vP(n,c,e.selectedNodeId===n.id,t.has(n.id),r.get(n.id),o.get(n.id),VP(n,e),s.get(n.id));i.appendChild(a)}n.querySelectorAll(`path, text.tb-edge-label, path.tb-edge-hit`).forEach(e=>n.removeChild(e));let l=new Map;for(let t of e.edges){let e=`${t.sourceNodeId}:${t.targetNodeId}`;l.has(e)||l.set(e,[]),l.get(e).push(t)}for(let t of l.values()){let r=t.length;t.forEach((t,i)=>{v(n,t,e,r>1?(i-(r-1)/2)*14:0)})}let h=600,_=400;for(let t of e.nodes)h=Math.max(h,t.position.x+gP(t)+40),_=Math.max(_,t.position.y+180);n.setAttribute(`width`,String(h)),n.setAttribute(`height`,String(_)),i.style.width=`${h}px`,i.style.height=`${_}px`,a.style.width=`${h}px`,a.style.height=`${_}px`}function v(t,n,r,i=0){let a=r.nodes.find(e=>e.id===n.sourceNodeId),o=r.nodes.find(e=>e.id===n.targetNodeId);if(!a||!o)return;let s=yP(a,n.linkType===FP?`loser`:`winner`),c=yP(o,`input`),l=s.y+i,u=c.y+i,d=c.x-s.x,f=`M ${s.x},${l} C ${s.x+d/2},${l} ${s.x+d/2},${u} ${c.x},${u}`,p=document.createElementNS(HP,`path`);p.setAttribute(`d`,f),p.classList.add(`tb-edge-hit`),p.addEventListener(`click`,t=>{t.stopPropagation(),e.onSelectEdge(n.id)}),t.appendChild(p);let m=document.createElementNS(HP,`path`);if(m.setAttribute(`d`,f),m.classList.add(UP[n.linkType]||`tb-edge--winner`),r.selectedEdgeId===n.id&&m.classList.add(`tb-edge--selected`),m.setAttribute(`marker-end`,`url(#arrowhead-${n.linkType})`),m.addEventListener(`click`,t=>{t.stopPropagation(),e.onSelectEdge(n.id)}),t.appendChild(m),n.label){let e=(s.x+c.x)/2,r=(l+u)/2-8,i=document.createElementNS(HP,`text`);i.classList.add(`tb-edge-label`),i.setAttribute(`x`,String(e)),i.setAttribute(`y`,String(r)),i.setAttribute(`text-anchor`,`middle`),i.textContent=n.label,t.appendChild(i)}}return{element:t,update:_}}var{SINGLE_ELIMINATION:GP,ROUND_ROBIN:KP,FEED_IN:qP,FEED_IN_CHAMPIONSHIP:JP,FIRST_MATCH_LOSER_CONSOLATION:YP,COMPASS:XP,OLYMPIC:ZP,AD_HOC:QP,LUCKY_DRAW:$P,MAIN:eF,QUALIFYING:tF,CONSOLATION:nF,PLAY_OFF:rF,WINNER:iF}=t.drawDefinitionConstants,aF=`POSITION`,oF=[{label:`Single Elimination`,value:GP},{label:`Round Robin`,value:KP},{label:`Feed-In Championship`,value:JP},{label:`FMLC`,value:YP},{label:`Compass`,value:XP},{label:`Olympic`,value:ZP},{label:`Ad-hoc`,value:QP}],sF=[{label:`Single Elimination`,value:GP},{label:`Round Robin`,value:KP},{label:`Lucky Draw`,value:$P},{label:`Staggered Entry`,value:qP},{label:`Ad-hoc`,value:QP}],cF=[{label:`Main`,value:eF},{label:`Qualifying`,value:tF},{label:`Consolation`,value:nF},{label:`Playoff`,value:rF}];function lF(e){let t=[],n=Math.floor(e/2);for(;n>=1;)t.push(n),n=Math.floor(n/2);return t}function uF(e,t=8){let n=[];for(let r=3;r<=t;r++){let t=Math.ceil(e/r),i=t*r-e,a=Math.ceil(e/t),o=Math.ceil(i/t);(!i||i<r)&&a===r&&a>=3&&o<2&&n.push(r)}return n}function dF(e,t,n,r,i,a){let o=uF(e.drawSize),s=e.structureOptions?.groupSize||4,c=o.includes(s)?o:[s,...o].sort((e,t)=>e-t),l=Math.ceil(e.drawSize/s);i.push({label:`Group Size`,field:`groupSize`,value:String(s),disabled:n,options:c.map(e=>({label:String(e),value:String(e),selected:e===s}))}),i.push({label:`Groups`,field:`groupCount`,value:String(l),disabled:!0}),n||a.push({control:`groupSize`,onChange:({e:t})=>{let n=parseInt(t.target.value);r.onUpdateNode(e.id,{structureOptions:{...e.structureOptions,groupSize:n}})}});let u=t.edges.filter(t=>t.sourceNodeId===e.id&&t.linkType===aF),d=new Set(u.flatMap(e=>e.finishingPositions||[])),f=d.size||0,p=Array.from({length:s},(e,t)=>t+1);i.push({label:`Advance Per Group`,field:`advancePerGroup`,value:String(f),disabled:n||u.length===0,options:p.map(e=>({label:String(e),value:String(e),selected:e===f}))}),!n&&u.length>0&&a.push({control:`advancePerGroup`,onChange:({e})=>{let t=parseInt(e.target.value),n=d.size;if(t!==n)if(t>n){let e=u.at(-1),n=[];for(let e=1;e<=s&&d.size+n.length<t;e++)d.has(e)||n.push(e);n.length>0&&r.onUpdateEdge(e.id,{finishingPositions:[...e.finishingPositions||[],...n].sort((e,t)=>e-t)})}else{let e=[...d].sort((e,t)=>t-e),i=new Set(e.slice(0,n-t));for(let e of u){let t=(e.finishingPositions||[]).filter(e=>!i.has(e));t.length!==(e.finishingPositions||[]).length&&r.onUpdateEdge(e.id,{finishingPositions:t})}}}}),u.length>0&&f>0&&fF(u,t,l,i)}function fF(e,t,n,r){let i=new Map;for(let t of e)i.has(t.targetNodeId)||i.set(t.targetNodeId,[]),i.get(t.targetNodeId).push(...t.finishingPositions||[]);let a=[];for(let[e,r]of i){let i=t.nodes.find(t=>t.id===e),o=[...new Set(r)].sort((e,t)=>e-t),s=o.length===1?`P${o[0]}`:`P${o.join(`,`)}`;a.push(`${s} → ${i?.structureName||`?`} (${o.length*n})`)}a.length>0&&r.push({label:`Playoff Groups`,field:`playoffSummary`,value:a.join(`
|
|
321
|
-
`),disabled:!0})}function pF(e,t,n,r,i,a){let o=t.edges.find(t=>t.targetNodeId===e.id&&t.linkType===aF);if(!o||t.nodes.find(e=>e.id===o.sourceNodeId)?.structureType!==KP)return;let s=e.structureOptions?.playoffDrawType||GP;if(i.push({label:`Playoff Draw Type`,field:`playoffDrawType`,value:s,disabled:n,options:oF.map(e=>({...e,selected:e.value===s}))}),n||a.push({control:`playoffDrawType`,onChange:({e:t})=>r.onUpdateNode(e.id,{structureOptions:{...e.structureOptions,playoffDrawType:t.target.value}})}),s===KP){let t=e.structureOptions?.groupSize||4;i.push({label:`Playoff Group Size`,field:`playoffGroupSize`,value:String(t),disabled:n,options:[3,4,5,6,8].map(e=>({label:String(e),value:String(e),selected:e===t}))}),n||a.push({control:`playoffGroupSize`,onChange:({e:t})=>r.onUpdateNode(e.id,{structureOptions:{...e.structureOptions,groupSize:parseInt(t.target.value)}})})}}function mF(e,t,n,r,i){let a=lF(e.drawSize),o=e.qualifyingPositions??a[0];r.push({label:`Qualifying Positions`,field:`qualifyingPositions`,value:String(o),disabled:t,options:a.map(e=>({label:String(e),value:String(e),selected:e===o}))}),t||i.push({control:`qualifyingPositions`,onChange:({e:t})=>n.onUpdateNode(e.id,{qualifyingPositions:parseInt(t.target.value)})})}function hF(e,t,n){let r=LN(e.drawSize),i=new Map,a=[];for(let n of t.edges){if(n.linkType!==iF||n.targetNodeId!==e.id)continue;let r=n.targetRoundNumber||1;if(r<=1)continue;let o=t.nodes.find(e=>e.id===n.sourceNodeId);if(!o||o.stage!==tF)continue;let s=o.qualifyingPositions||Math.floor(o.drawSize/4);i.set(r,(i.get(r)||0)+s),a.push({targetRound:r,qp:s,sourceName:o.structureName})}let o=[];for(let e of a){let t=r.get(e.targetRound)||0;t>=(i.get(e.targetRound)||0)||(t===0?o.push(`Round ${e.targetRound} is not a feed round — ${e.sourceName} sends ${e.qp} qualifiers`):o.push(`Round ${e.targetRound} has ${t} feed positions but ${e.sourceName} sends ${e.qp} qualifiers`))}if(o.length>0){let e=document.createElement(`div`);e.className=`tb-editor-warning`;for(let t of o){let n=document.createElement(`div`);n.textContent=`\u26a0 ${t}`,e.appendChild(n)}let t=document.createElement(`div`);t.style.marginTop=`6px`,t.textContent=`Change the target round to a feed round, or increase the draw size to create feed positions at that round.`,e.appendChild(t),n.appendChild(e)}}function gF(e){let t=document.createElement(`div`),n=!!e.readOnly;function r(r){t.innerHTML=``;let i=r.selectedNodeId?r.nodes.find(e=>e.id===r.selectedNodeId):null;if(!i)return;let a=document.createElement(`div`);a.className=`tb-editor-header`,a.textContent=`Structure Properties`,t.appendChild(a);let o=document.createElement(`div`);o.className=`tb-editor-body`;let s=[{label:`Name`,field:`structureName`,value:i.structureName,...n?{disabled:!0}:{validator:iy(1),error:`Name required`}},{label:`Stage`,field:`stage`,value:i.stage,disabled:n,options:cF.map(e=>({...e,selected:e.value===i.stage}))},{label:`Structure Type`,field:`structureType`,value:i.structureType,disabled:n,options:sF.map(e=>({...e,selected:e.value===i.structureType}))},{label:i.stage===eF?`Draw Size`:`Structure Size`,field:`drawSize`,type:`number`,value:String(i.drawSize),...n?{disabled:!0}:i.structureType===QP?{validator:oy(0,256),error:`Must be 0-256`}:{validator:oy(2,256),error:`Must be 2-256`}}],c=n?[]:[{control:`structureName`,onChange:({inputs:t})=>e.onUpdateNode(i.id,{structureName:t.structureName.value})},{control:`stage`,onChange:({e:t})=>e.onUpdateNode(i.id,{stage:t.target.value})},{control:`structureType`,onChange:({e:t})=>e.onUpdateNode(i.id,{structureType:t.target.value})},{control:`drawSize`,onChange:({inputs:t})=>{let n=parseInt(t.drawSize.value);if(n<(i.structureType===QP?0:2))return;let r={drawSize:n};if(i.structureType===KP){let e=i.structureOptions?.groupSize||4,t=uF(n);!t.includes(e)&&t.length>0&&(r.structureOptions={...i.structureOptions,groupSize:t[0]})}e.onUpdateNode(i.id,r)}}];i.structureType===KP&&dF(i,r,n,e,s,c),i.stage===rF&&pF(i,r,n,e,s,c),i.stage===tF&&mF(i,n,e,s,c),ui(o,s,c);let l=document.createElement(`div`);l.className=`field font-medium`,l.style.cssText=`flex-grow: 1`;let u=document.createElement(`label`);u.style.cssText=`font-weight: bold; font-size: larger;`,u.textContent=`MatchUp Format`,l.appendChild(u);let d=document.createElement(`div`);if(d.className=`tb-format-trigger`,d.textContent=i.matchUpFormat||`Not set`,n?(d.style.cursor=`default`,d.style.opacity=`0.7`):d.onclick=()=>{Ca({existingMatchUpFormat:i.matchUpFormat,callback:t=>{e.onUpdateNode(i.id,{matchUpFormat:t||void 0}),d.textContent=t||`Not set`}})},l.appendChild(d),o.appendChild(l),hF(i,r,o),!n&&!e.hideDelete){let t=document.createElement(`button`);t.className=`sp-btn sp-btn--danger sp-btn--full`,t.style.marginTop=`12px`,t.textContent=`Delete Structure`,t.onclick=()=>e.onDeleteNode(i.id),o.appendChild(t)}t.appendChild(o)}return{element:t,update:r}}var{WINNER:_F,LOSER:vF,TOP_DOWN:yF,BOTTOM_UP:bF,QUALIFYING:xF,ROUND_ROBIN:SF}=t.drawDefinitionConstants,CF=`POSITION`,wF=`ALTERNATING`,TF=e=>e===SF,EF=[{label:`Winner`,value:_F},{label:`Loser`,value:vF},{label:`Position`,value:CF}],DF=[{label:`Top-Down`,value:yF},{label:`Bottom-Up`,value:bF},{label:`Alternating`,value:wF}];function OF(e){let t=document.createElement(`div`),n=!!e.readOnly;function r(t,r,i,a,o,s){let c=[],l=[],u=r?tP(r.structureType,r.drawSize,r.structureOptions?.groupSize):{},d=u.playoffRoundsRanges&&u.playoffRoundsRanges.length>0;if(d){let e=u.playoffRoundsRanges.map(e=>({label:`R${e.roundNumber} (${e.finishingPositionRange})`,value:String(e.roundNumber),selected:e.roundNumber===(t.sourceRoundNumber||a)}));c.push({label:`Source Round`,field:`sourceRoundNumber`,value:String(t.sourceRoundNumber||a),disabled:n,options:e})}else c.push({label:`Source Round`,field:`sourceRoundNumber`,type:`number`,value:String(t.sourceRoundNumber||a),disabled:n});return c.push({label:s?`Enter at Round`:`Target Round`,field:`targetRoundNumber`,type:`number`,value:String(t.targetRoundNumber||0),disabled:n}),n||(d?l.push({control:`sourceRoundNumber`,onChange:({e:n})=>{let r=Number.parseInt(n.target.value)||0;e.onUpdateEdge(t.id,{sourceRoundNumber:r||void 0})}}):l.push({control:`sourceRoundNumber`,onChange:({inputs:n})=>{let r=Number.parseInt(n.sourceRoundNumber.value)||0,i=Math.max(0,Math.min(r,a));e.onUpdateEdge(t.id,{sourceRoundNumber:i||void 0})}}),l.push({control:`targetRoundNumber`,onChange:({inputs:n})=>{let r=Number.parseInt(n.targetRoundNumber.value)||0,i=Math.max(0,Math.min(r,o));e.onUpdateEdge(t.id,{targetRoundNumber:i||void 0})}})),{items:c,relationships:l}}function i(t,r,i){let a=r.structureOptions?.groupSize||4,o=new Set(t.finishingPositions||[]),s=i.edges.filter(e=>e.id!==t.id&&e.sourceNodeId===t.sourceNodeId&&e.linkType===CF),c=new Set;for(let e of s)for(let t of e.finishingPositions||[])c.add(t);let l=document.createElement(`div`);l.className=`field`,l.style.marginBottom=`10px`;let u=document.createElement(`label`);u.style.cssText=`font-size:11px;font-weight:600;color:var(--chc-text-secondary);margin-bottom:3px;display:block;`,u.textContent=`Finishing Positions`,l.appendChild(u);for(let r=1;r<=a;r++){let i=document.createElement(`label`);i.style.cssText=`display:flex;align-items:center;gap:4px;font-size:12px;padding:2px 0;cursor:pointer;`;let a=document.createElement(`input`);a.type=`checkbox`,a.checked=o.has(r);let s=c.has(r);n||s?a.disabled=!0:a.addEventListener(`change`,()=>{let n=new Set(o);a.checked?n.add(r):n.delete(r),e.onUpdateEdge(t.id,{finishingPositions:Array.from(n).sort((e,t)=>e-t)})});let u=document.createElement(`span`);u.textContent=`Position ${r}`,s&&(u.style.color=`var(--chc-text-muted, #999)`,u.title=`Used by another link`,i.style.opacity=`0.5`,i.style.cursor=`not-allowed`),i.appendChild(a),i.appendChild(u),l.appendChild(i)}return l}function a(a){t.innerHTML=``;let o=a.selectedEdgeId?a.edges.find(e=>e.id===a.selectedEdgeId):null;if(!o)return;let s=a.nodes.find(e=>e.id===o.sourceNodeId),c=a.nodes.find(e=>e.id===o.targetNodeId),l=document.createElement(`div`);l.className=`tb-editor-header`,l.textContent=`Link Properties`,t.appendChild(l);let u=document.createElement(`div`);u.className=`tb-editor-body`;let d=document.createElement(`div`);d.style.cssText=`font-size:11px;color:var(--chc-text-muted);margin-bottom:8px;`,d.textContent=`${s?.structureName||`Source`} → ${c?.structureName||`Target`}`,u.appendChild(d);let f=o.linkType===_F&&s?.stage===xF,p=s?HN(s.structureType,s.drawSize,s.structureOptions):8,m=c?HN(c.structureType,c.drawSize,c.structureOptions):8,h=o.linkType===CF&&s&&TF(s.structureType),g=[{label:`Link Type`,field:`linkType`,value:o.linkType,disabled:n,options:EF.map(e=>({...e,selected:e.value===o.linkType}))}],_=n?[]:[{control:`linkType`,onChange:({e:t})=>e.onUpdateEdge(o.id,{linkType:t.target.value})}];if(!h){let e=r(o,s,c,p,m,f);g.push(...e.items),_.push(...e.relationships)}if(f&&s){let t=Math.floor(s.drawSize/2),r=Math.floor(s.drawSize/4),i=o.qualifyingPositions||r;g.push({label:`Qualifying Positions`,field:`qualifyingPositions`,type:`number`,value:String(i),disabled:n}),n||_.push({control:`qualifyingPositions`,onChange:({inputs:n})=>{let r=Number.parseInt(n.qualifyingPositions.value)||1,i=Math.max(1,Math.min(r,t));e.onUpdateEdge(o.id,{qualifyingPositions:i})}})}if(o.linkType===vF&&(g.push({label:`Feed Profile`,field:`feedProfile`,value:o.feedProfile||yF,disabled:n,options:DF.map(e=>({...e,selected:e.value===(o.feedProfile||yF)}))}),n||_.push({control:`feedProfile`,onChange:({e:t})=>e.onUpdateEdge(o.id,{feedProfile:t.target.value})})),o.linkType===CF&&!h&&(g.push({label:`Finishing Positions`,field:`finishingPositions`,value:(o.finishingPositions||[]).join(`, `),placeholder:`e.g., 1, 2`,disabled:n}),n||_.push({control:`finishingPositions`,onChange:({inputs:t})=>{let n=t.finishingPositions.value.split(`,`).map(e=>Number.parseInt(e.trim())).filter(e=>!Number.isNaN(e));e.onUpdateEdge(o.id,{finishingPositions:n})}})),ui(u,g,_),h&&s&&u.appendChild(i(o,s,a)),!n){let t=document.createElement(`button`);t.className=`sp-btn sp-btn--danger sp-btn--full`,t.style.marginTop=`12px`,t.textContent=`Delete Link`,t.onclick=()=>e.onDeleteEdge(o.id),u.appendChild(t)}t.appendChild(u)}return{element:t,update:a}}var{MAIN:kF,QUALIFYING:AF,CONSOLATION:jF,WINNER:MF,LOSER:NF,SINGLE_ELIMINATION:PF,ROUND_ROBIN:FF,AD_HOC:IF}=t.drawDefinitionConstants,LF=`POSITION`;function RF(e){let t=[],n=zF(e,t);return VF(e,BF(e),t),HF(e,t),UF(e,t),WF(e,t),GF(e,n,t),KF(e,t),qF(e,t),YF(e,t),XF(e,t),ZF(e)&&t.push({severity:`error`,message:`Circular dependency detected between structures`}),t}function zF(e,t){let n=e.nodes.filter(e=>e.stage===kF);return n.length===0?t.push({severity:`error`,message:`A main draw structure is required`}):n.length>1&&t.push({severity:`error`,message:`Only one main draw structure is allowed`}),n}function BF(e){let t=new Set;for(let n of e.edges)n.linkType===MF&&(n.targetRoundNumber||1)>1&&e.nodes.find(e=>e.id===n.sourceNodeId)?.stage===AF&&t.add(n.targetNodeId);let n=new Map;for(let t of e.edges)t.linkType===NF&&n.set(t.targetNodeId,(n.get(t.targetNodeId)||0)+1);for(let[e,r]of n)r>1&&t.add(e);return t}function VF(e,t,n){for(let r of e.nodes){if(r.structureType===PF&&!t.has(r.id)){let t=e.edges.some(e=>e.targetNodeId===r.id);(r.stage===kF||r.stage===AF)&&!t&&(r.drawSize>0&&!(r.drawSize&r.drawSize-1)||n.push({severity:`error`,message:`"${r.structureName}" draw size must be a power of 2`,nodeId:r.id}))}let i=r.structureType===IF?0:2;r.drawSize<i&&n.push({message:`"${r.structureName}" draw size must be at least ${i}`,severity:`error`,nodeId:r.id})}}function HF(e,t){for(let n of e.edges){let r=e.nodes.find(e=>e.id===n.sourceNodeId),i=e.nodes.find(e=>e.id===n.targetNodeId);if(r||t.push({severity:`error`,message:`Edge references missing source node`,edgeId:n.id}),i||t.push({severity:`error`,message:`Edge references missing target node`,edgeId:n.id}),r&&n.sourceRoundNumber){let e=HN(r.structureType,r.drawSize,r.structureOptions);(n.sourceRoundNumber>e||n.sourceRoundNumber<1)&&t.push({severity:`warning`,message:`Edge source round ${n.sourceRoundNumber} is outside "${r.structureName}" range (1-${e})`,edgeId:n.id})}if(i&&n.targetRoundNumber){let e=HN(i.structureType,i.drawSize,i.structureOptions);(n.targetRoundNumber>e||n.targetRoundNumber<1)&&t.push({severity:`warning`,message:`Edge target round ${n.targetRoundNumber} is outside "${i.structureName}" range (1-${e})`,edgeId:n.id})}}}function UF(e,t){let n=new Map;for(let t of e.edges)t.linkType===MF&&(n.has(t.sourceNodeId)||n.set(t.sourceNodeId,[]),n.get(t.sourceNodeId).push(t.id));for(let[r,i]of n)if(i.length>1){let n=e.nodes.find(e=>e.id===r)?.structureName||`Unknown`;for(let e of i)t.push({severity:`error`,message:`"${n}" has multiple winner links (only one allowed)`,edgeId:e})}}function WF(e,t){let n=new Map;for(let t of e.edges)t.sourceRoundNumber&&(n.has(t.sourceNodeId)||n.set(t.sourceNodeId,[]),n.get(t.sourceNodeId).push({round:t.sourceRoundNumber,edgeId:t.id}));for(let[r,i]of n){let n=new Map,a=e.nodes.find(e=>e.id===r)?.structureName||`Unknown`;for(let{round:e,edgeId:r}of i)n.has(e)?t.push({severity:`error`,message:`"${a}" has multiple links from round ${e}`,edgeId:r}):n.set(e,r)}}function GF(e,t,n){let r=e.nodes.filter(e=>e.stage===AF);for(let i of r){let r=e.edges.find(e=>e.sourceNodeId===i.id&&e.linkType===MF&&t.some(t=>t.id===e.targetNodeId));if(r||n.push({severity:`warning`,message:`Qualifying structure "${i.structureName}" has no winner link to a main structure`,nodeId:i.id}),r?.qualifyingPositions){let e=Math.floor(i.drawSize/2);r.qualifyingPositions>e&&n.push({severity:`warning`,message:`Qualifying positions (${r.qualifyingPositions}) exceeds half of "${i.structureName}" draw size (${e})`,edgeId:r.id})}}}function KF(e,t){let n=new Map;for(let t of e.edges){if(t.linkType!==MF)continue;let r=t.targetRoundNumber||1;if(r<=1)continue;let i=e.nodes.find(e=>e.id===t.sourceNodeId);if(!i||i.stage!==AF)continue;n.has(t.targetNodeId)||n.set(t.targetNodeId,[]);let a=i.qualifyingPositions||Math.floor(i.drawSize/4);n.get(t.targetNodeId).push({edgeId:t.id,targetRound:r,qp:a,sourceName:i.structureName})}for(let[r,i]of n){let n=e.nodes.find(e=>e.id===r);if(!n)continue;let a=LN(n.drawSize),o=new Map;for(let e of i)o.set(e.targetRound,(o.get(e.targetRound)||0)+e.qp);for(let{edgeId:e,targetRound:s,sourceName:c}of i)(a.get(s)||0)<(o.get(s)||0)&&t.push({severity:`warning`,message:`"${n.structureName}" round ${s} is not a feed round or has insufficient capacity for ${c} link`,nodeId:r,edgeId:e})}}function qF(e,t){for(let n of e.edges){if(n.linkType!==NF)continue;let r=e.nodes.find(e=>e.id===n.sourceNodeId),i=e.nodes.find(e=>e.id===n.targetNodeId);if(!r||!i)continue;let a=n.sourceRoundNumber||1,o=n.targetRoundNumber||1,s=UN(r.structureType,r.drawSize,a),c=LN(i.drawSize);o!==1&&JF(c,o,s,r,i,a,n.id,t)}}function JF(e,t,n,r,i,a,o,s){let c=e.get(t);c===void 0?s.push({severity:`error`,message:`"${i.structureName}" R${t} is not a feed round — cannot receive ${n} losers from "${r.structureName}" R${a}`,edgeId:o}):n>c?s.push({severity:`error`,message:`"${r.structureName}" R${a} produces ${n} losers but "${i.structureName}" R${t} only has ${c} feed positions`,edgeId:o}):n<c&&s.push({severity:`warning`,message:`"${r.structureName}" R${a} produces ${n} losers but "${i.structureName}" R${t} has ${c} feed positions — ${c-n} will be empty`,edgeId:o})}function YF(e,t){let n=e.nodes.filter(e=>e.stage===jF);for(let r of n){let n=e.edges.filter(e=>e.targetNodeId===r.id);if(n.length===0)continue;let i=0;for(let t of n){let n=e.nodes.find(e=>e.id===t.sourceNodeId);if(n)if(t.linkType===NF){let e=t.sourceRoundNumber||1;i+=UN(n.structureType,n.drawSize,e)}else i+=n.qualifyingPositions||Math.floor(n.drawSize/2)}i>0&&r.drawSize>i&&t.push({severity:`warning`,message:`"${r.structureName}" draw size (${r.drawSize}) exceeds inbound capacity (${i})`,nodeId:r.id}),i>0&&i>r.drawSize&&t.push({severity:`error`,message:`"${r.structureName}" receives ${i} participants but only has ${r.drawSize} positions`,nodeId:r.id})}}function XF(e,t){let n=new Map;for(let r of e.edges){if(r.linkType!==LF)continue;n.has(r.sourceNodeId)||n.set(r.sourceNodeId,[]),n.get(r.sourceNodeId).push({edgeId:r.id,positions:r.finishingPositions||[]});let i=e.nodes.find(e=>e.id===r.sourceNodeId);if(i&&i.structureType===FF){let e=i.structureOptions?.groupSize||4;for(let n of r.finishingPositions||[])(n<1||n>e)&&t.push({severity:`error`,message:`Position ${n} is outside valid range (1-${e}) for "${i.structureName}"`,edgeId:r.id})}}for(let[r,i]of n){if(i.length<2)continue;let n=e.nodes.find(e=>e.id===r)?.structureName||`Unknown`,a=new Map;for(let{edgeId:e,positions:r}of i)for(let i of r)a.has(i)?t.push({severity:`warning`,message:`Position ${i} from "${n}" is used by multiple POSITION links`,edgeId:e}):a.set(i,e)}}function ZF(e){let t=new Map;for(let n of e.nodes)t.set(n.id,[]);for(let n of e.edges){let e=t.get(n.sourceNodeId);e&&e.push(n.targetNodeId)}let n=new Set,r=new Set;function i(e){if(r.has(e))return!0;if(n.has(e))return!1;n.add(e),r.add(e);for(let n of t.get(e)||[])if(i(n))return!0;return r.delete(e),!1}for(let t of e.nodes)if(i(t.id))return!0;return!1}var{MAIN:QF,QUALIFYING:$F,CONSOLATION:eI,PLAY_OFF:tI,LUCKY_DRAW:nI}=t.drawDefinitionConstants;function rI(e,t,n={}){let r=document.createElement(`div`);r.className=`tb-toolbar-wrapper`;let i=document.createElement(`div`);i.className=`tb-toolbar-row`;let a=document.createElement(`div`);a.style.flex=`1`,a.style.minWidth=`0`,i.appendChild(a),r.appendChild(i);let o=document.createElement(`div`);o.className=`tb-validation`,o.style.display=`none`,r.appendChild(o);let s=null,c=()=>{if(!s)return;let e=RF(s);if(o.innerHTML=``,e.length===0){o.style.display=`block`;let e=document.createElement(`div`);e.className=`tb-validation-item`,e.innerHTML=`<span style="color:var(--chc-status-success)">✓ Valid topology</span>`,o.appendChild(e)}else{o.style.display=`block`;for(let t of e){let e=document.createElement(`div`);e.className=`tb-validation-item`;let n=document.createElement(`span`);n.className=`tb-validation-icon tb-validation-icon--${t.severity}`,n.textContent=t.severity===`error`?`!`:`?`;let r=document.createElement(`span`);r.textContent=t.message,e.appendChild(n),e.appendChild(r),o.appendChild(e)}}setTimeout(()=>{o.style.display=`none`},5e3)},l=[];if(!n.readOnly){let t=[{label:`Main`,value:QF,onClick:()=>e.onAddStructure(QF),close:!0},{label:`Lucky Draw`,value:nI,onClick:()=>e.onAddStructure(QF,nI),close:!0},{label:`Qualifying`,value:$F,onClick:()=>e.onAddStructure($F),close:!0},{label:`Consolation`,value:eI,onClick:()=>e.onAddStructure(eI),close:!0},{label:`Playoff`,value:tI,onClick:()=>e.onAddStructure(tI),close:!0}];l.push({label:`Add Structure`,location:`right`,options:t})}if(!n.hideTemplates&&t.length>0){let n=t.map(n=>({label:n.name,value:n.name,onClick:()=>{let r=t.find(e=>e.name===n.name);r&&e.onLoadTemplate(r)},close:!0}));l.push({label:`Templates`,location:`right`,options:n})}!n.readOnly&&e.onClear&&l.push({label:`Clear`,location:`right`,onClick:()=>e.onClear()}),n.readOnly||l.push({label:`Auto Layout`,location:`right`,onClick:()=>e.onAutoLayout()},{label:`Validate`,location:`right`,onClick:()=>c()}),!n.readOnly&&e.onSaveTemplate&&l.push({label:`Save Template`,location:`right`,intent:`is-success`,onClick:()=>e.onSaveTemplate()}),!n.readOnly&&!n.hideGenerate&&l.push({label:`Generate Draw`,location:`right`,intent:`is-success`,onClick:()=>e.onGenerate()}),NO({target:a,items:l});function u(e){s=e}return{element:r,update:u}}function iI({toolbar:e,canvas:t,nodeEditor:n,edgeEditor:r}){let i=document.createElement(`div`);i.className=`tb-layout`,i.appendChild(e.element);let a=document.createElement(`div`);a.className=`tb-body`,a.appendChild(t.element);let o=document.createElement(`div`);o.className=`tb-editor`,o.appendChild(n.element),o.appendChild(r.element),a.appendChild(o),i.appendChild(a);function s(i){if(e.update(i),t.update(i),n.element.style.display=i.selectedNodeId?``:`none`,r.element.style.display=i.selectedEdgeId?``:`none`,!i.selectedNodeId&&!i.selectedEdgeId){if(!o.querySelector(`.tb-editor-empty`)){let e=document.createElement(`div`);e.className=`tb-editor-empty`,e.textContent=`Select a structure or link to view properties`,o.appendChild(e)}}else{let e=o.querySelector(`.tb-editor-empty`);e&&e.remove()}n.update(i),r.update(i)}function c(){e.destroy?.(),t.destroy?.(),n.destroy?.(),r.destroy?.()}return{element:i,update:s,destroy:c}}var{SINGLE_ELIMINATION:aI,FEED_IN:oI,ROUND_ROBIN:sI,LUCKY_DRAW:cI,MAIN:lI,QUALIFYING:uI,CONSOLATION:dI,PLAY_OFF:fI}=t.drawDefinitionConstants,pI=`WINNER`,mI=`LOSER`,hI=`POSITION`,gI=`tpl-edge-1`,_I=`tpl-edge-2`,vI=`tpl-edge-3`,yI=`tpl-edge-4`,bI=`tpl-edge-5`,xI=`tpl-edge-6`,SI=`tpl-edge-7`,CI=`R1 losers → R1`,wI=[{name:`Single Elimination + Qualifying`,description:`Standard SE main draw with one qualifying structure`,state:{drawName:`SE + Qualifying`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:lI,structureType:aI,drawSize:32,position:{x:320,y:40}},{id:`tpl-qual`,structureName:`Qualifying`,stage:uI,structureType:aI,drawSize:16,qualifyingPositions:4,position:{x:40,y:40}}],edges:[{id:gI,sourceNodeId:`tpl-qual`,targetNodeId:`tpl-main`,linkType:pI,targetRoundNumber:1,qualifyingPositions:4,label:`winners → R1 (4Q)`}]}},{name:`FMLC (First Match Loser Consolation)`,description:`Main draw with first match loser consolation`,state:{drawName:`FMLC`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:lI,structureType:aI,drawSize:32,position:{x:40,y:40}},{id:`tpl-cons`,structureName:`Consolation`,stage:dI,structureType:aI,drawSize:16,position:{x:320,y:40}}],edges:[{id:gI,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:CI}]}},{name:`Feed-In Championship (FIC)`,description:`Main draw with multi-round fed consolation`,state:{drawName:`FIC`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:lI,structureType:aI,drawSize:32,position:{x:40,y:40}},{id:`tpl-cons`,structureName:`Consolation`,stage:dI,structureType:oI,drawSize:31,position:{x:460,y:40}}],edges:[{id:gI,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:CI},{id:_I,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:mI,sourceRoundNumber:2,targetRoundNumber:2,label:`R2 losers → R2`},{id:vI,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:mI,sourceRoundNumber:3,targetRoundNumber:4,label:`R3 losers → R4`},{id:yI,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:mI,sourceRoundNumber:4,targetRoundNumber:6,label:`R4 losers → R6`},{id:bI,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:mI,sourceRoundNumber:5,targetRoundNumber:8,label:`R5 losers → R8`}]}},{name:`Compass`,description:`8-draw compass structure`,state:{drawName:`Compass`,nodes:[{id:`tpl-east`,structureName:`East`,stage:lI,structureType:aI,drawSize:32,position:{x:40,y:40}},{id:`tpl-west`,structureName:`West`,stage:dI,structureType:aI,drawSize:16,position:{x:400,y:40}},{id:`tpl-north`,structureName:`North`,stage:dI,structureType:aI,drawSize:8,position:{x:400,y:210}},{id:`tpl-ne`,structureName:`Northeast`,stage:dI,structureType:aI,drawSize:4,position:{x:400,y:380}},{id:`tpl-south`,structureName:`South`,stage:dI,structureType:aI,drawSize:8,position:{x:680,y:40}},{id:`tpl-sw`,structureName:`Southwest`,stage:dI,structureType:aI,drawSize:4,position:{x:680,y:210}},{id:`tpl-nw`,structureName:`Northwest`,stage:dI,structureType:aI,drawSize:4,position:{x:680,y:380}},{id:`tpl-se`,structureName:`Southeast`,stage:dI,structureType:aI,drawSize:4,position:{x:960,y:40}}],edges:[{id:gI,sourceNodeId:`tpl-east`,targetNodeId:`tpl-west`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:CI},{id:_I,sourceNodeId:`tpl-east`,targetNodeId:`tpl-north`,linkType:mI,sourceRoundNumber:2,targetRoundNumber:1,label:`R2 losers → R1`},{id:vI,sourceNodeId:`tpl-east`,targetNodeId:`tpl-ne`,linkType:mI,sourceRoundNumber:3,targetRoundNumber:1,label:`R3 losers → R1`},{id:yI,sourceNodeId:`tpl-west`,targetNodeId:`tpl-south`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:CI},{id:bI,sourceNodeId:`tpl-west`,targetNodeId:`tpl-sw`,linkType:mI,sourceRoundNumber:2,targetRoundNumber:1,label:`R2 losers → R1`},{id:xI,sourceNodeId:`tpl-north`,targetNodeId:`tpl-nw`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:CI},{id:SI,sourceNodeId:`tpl-south`,targetNodeId:`tpl-se`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:CI}]}},{name:`Round Robin + Playoff`,description:`Round robin groups with winners and consolation playoffs`,state:{drawName:`RR + Playoff`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:lI,structureType:sI,drawSize:16,structureOptions:{groupSize:4},position:{x:40,y:40}},{id:`tpl-playoff-gold`,structureName:`Gold Flight`,stage:fI,structureType:aI,drawSize:8,position:{x:320,y:40}},{id:`tpl-playoff-silver`,structureName:`Silver Flight`,stage:fI,structureType:aI,drawSize:8,position:{x:320,y:220}}],edges:[{id:gI,sourceNodeId:`tpl-main`,targetNodeId:`tpl-playoff-gold`,linkType:hI,finishingPositions:[1,2],label:`positions 1,2`},{id:_I,sourceNodeId:`tpl-main`,targetNodeId:`tpl-playoff-silver`,linkType:hI,finishingPositions:[3,4],label:`positions 3,4`}]}},{name:`Lucky Draw + Consolation`,description:`Lucky draw main with consolation receiving R1 losers`,state:{drawName:`Lucky + Consolation`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:lI,structureType:cI,drawSize:11,position:{x:40,y:40}},{id:`tpl-cons`,structureName:`Consolation`,stage:dI,structureType:aI,drawSize:4,position:{x:340,y:40}}],edges:[{id:gI,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:CI}]}},{name:`Lucky Draw → Round Robin`,description:`Lucky draw main with R1 losers feeding into round robin consolation`,state:{drawName:`Lucky → RR`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:lI,structureType:cI,drawSize:25,position:{x:40,y:40}},{id:`tpl-cons-rr`,structureName:`Consolation RR`,stage:dI,structureType:sI,drawSize:12,structureOptions:{groupSize:4},position:{x:500,y:40}}],edges:[{id:gI,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons-rr`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:CI}]}},{name:`Adaptive (drawSize 11)`,description:`Compass-like multi-structure topology with lucky draw structures`,state:{drawName:`Adaptive`,nodes:[{id:`tpl-east`,structureName:`East`,stage:lI,structureType:cI,drawSize:11,position:{x:40,y:40}},{id:`tpl-west`,structureName:`West`,stage:dI,structureType:cI,drawSize:6,position:{x:340,y:40}},{id:`tpl-north`,structureName:`North`,stage:dI,structureType:aI,drawSize:2,position:{x:340,y:250}},{id:`tpl-south`,structureName:`South`,stage:dI,structureType:aI,drawSize:2,position:{x:600,y:40}}],edges:[{id:gI,sourceNodeId:`tpl-east`,targetNodeId:`tpl-west`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:`R1 losers → R1 (6 losers)`},{id:_I,sourceNodeId:`tpl-east`,targetNodeId:`tpl-north`,linkType:mI,sourceRoundNumber:2,targetRoundNumber:1,label:`R2 losers → R1 (2 losers)`},{id:vI,sourceNodeId:`tpl-west`,targetNodeId:`tpl-south`,linkType:mI,sourceRoundNumber:1,targetRoundNumber:1,label:`R1 losers → R1 (2 losers)`}]}}],{MAIN:TI,QUALIFYING:EI,CONSOLATION:DI,PLAY_OFF:OI,SINGLE_ELIMINATION:kI,LUCKY_DRAW:AI,WINNER:jI,LOSER:MI}=t.drawDefinitionConstants,NI=`POSITION`,PI=class{constructor(e={}){this.config=e,this.store=new NP(e.initialState);let t=[...wI,...e.templates||[]],n=!!e.readOnly,r=this.buildToolbarPanel(t,n),i=this.buildCanvasPanel(n),a=gF({onUpdateNode:n?()=>{}:(e,t)=>this.store.updateNode(e,t),onUpdateEdge:n?()=>{}:(e,t)=>this.store.updateEdge(e,t),onDeleteNode:n?()=>{}:e=>this.store.removeNode(e),readOnly:n,hideDelete:e.hideDelete}),o=OF({onUpdateEdge:n?()=>{}:(e,t)=>this.store.updateEdge(e,t),onDeleteEdge:n?()=>{}:e=>this.store.removeEdge(e),readOnly:n});this.layout=iI({toolbar:r,canvas:i,nodeEditor:a,edgeEditor:o}),this.unsubscribe=this.store.subscribe(e=>{this.layout.update(e)}),this.layout.update(this.store.getState())}buildToolbarPanel(e,t){return rI({onAddStructure:(e,t)=>this.addDefaultStructure(e,t),onLoadTemplate:e=>{this.store.loadState({...e.state,selectedNodeId:null,selectedEdgeId:null,templateName:e.name})},onAutoLayout:()=>{this.store.autoLayout();let e=this.store.getState();this.store.loadState(e)},onGenerate:()=>this.handleGenerate(),onSaveTemplate:this.config.onSaveTemplate?()=>this.config.onSaveTemplate(this.store.getState()):void 0,onClear:this.config.onClear},e,{hideTemplates:this.config.hideTemplates,hideGenerate:this.config.hideGenerate,readOnly:t})}buildCanvasPanel(e){return WP({onSelectNode:e=>this.store.selectNode(e),onSelectEdge:e=>this.store.selectEdge(e),onDoubleClickNode:this.config.onDoubleClickNode?e=>{let t=this.store.getState(),n=t.nodes.find(t=>t.id===e);n&&this.config.onDoubleClickNode(n,t)}:void 0,onMoveNode:(e,t,n)=>this.store.updateNode(e,{position:{x:t,y:n}}),onCreateEdge:e?()=>{}:(e,t,n)=>{this.handleCreateEdge(e,t,n)},onPortMouseDown:()=>{}})}handleCreateEdge(e,t,n){let r=this.store.getState().nodes.find(t=>t.id===e);if(n===NI){let i=this.store.getState().edges.filter(t=>t.sourceNodeId===e&&t.linkType===NI),a=new Set(i.flatMap(e=>e.finishingPositions||[])),o=r?.structureOptions?.groupSize||4,s=1;for(let e=1;e<=o;e++)if(!a.has(e)){s=e;break}this.store.addEdge({sourceNodeId:e,targetNodeId:t,linkType:n,finishingPositions:[s]})}else if(n===MI){let i=this.store.getState().edges.filter(t=>t.sourceNodeId===e&&t.linkType===MI),a=new Set(i.map(e=>e.sourceRoundNumber)),o=r?HN(r.structureType,r.drawSize,r.structureOptions):1,s=1;for(let e=1;e<=o;e++)if(!a.has(e)){s=e;break}this.store.addEdge({sourceNodeId:e,targetNodeId:t,linkType:n,sourceRoundNumber:s})}else{let i=n===jI&&r?.stage===EI;this.store.addEdge({sourceNodeId:e,targetNodeId:t,linkType:n,...i&&{targetRoundNumber:1}})}}render(e){e.appendChild(this.layout.element)}destroy(){this.unsubscribe(),this.layout.destroy?.(),this.layout.element.remove()}autoLayout(){this.store.autoLayout();let e=this.store.getState();this.store.loadState(e)}getState(){return this.store.getState()}loadState(e){this.store.loadState(e)}addDefaultStructure(e,t){let n=t===AI,r=this.store.getState().nodes.filter(t=>t.stage===e).length,i={[TI]:n?`Lucky Draw`:`Main Draw`,[EI]:`Qualifying ${r+1}`,[DI]:`Consolation`,[OI]:`Playoff ${r+1}`},a={[TI]:n?11:32,[EI]:16,[DI]:16,[OI]:4}[e]||16,o=this.store.addNode({structureName:i[e]||e,stage:e,structureType:t||kI,drawSize:a,...e===EI&&{qualifyingPositions:Math.floor(a/4)}});this.scrollCanvasToNode(o)}scrollCanvasToNode(e){let t=this.layout.element.querySelector(`.tb-canvas`);t&&requestAnimationFrame(()=>{let n=e.position.x+gP(e)+40;n>t.scrollLeft+t.clientWidth&&t.scrollTo({left:n-t.clientWidth,behavior:`smooth`})})}handleGenerate(){let e=this.store.getState(),t=RF(e);t.some(e=>e.severity===`error`)&&console.warn(`Topology validation errors:`,t),this.config.onGenerate&&this.config.onGenerate(e)}},{MAIN:FI,CONSOLATION:II,QUALIFYING:LI,PLAY_OFF:RI,SINGLE_ELIMINATION:zI,FEED_IN:BI,FIRST_MATCH_LOSER_CONSOLATION:VI,FEED_IN_CHAMPIONSHIP:HI,COMPASS:UI,WINNER:WI,LOSER:GI,ROUND_ROBIN:KI,AD_HOC:qI,LUCKY_DRAW:JI}=t.drawDefinitionConstants,YI=`POSITION`;function XI(e,t){let n=e.nodes.filter(e=>e.stage===II),r=e.nodes.filter(e=>e.stage===LI),i=e.nodes.filter(e=>e.stage===RI);if(t.structureType===KI)return e.edges.some(n=>n.sourceNodeId===t.id&&n.linkType===YI&&e.nodes.some(e=>e.id===n.targetNodeId&&e.stage===RI))?`ROUND_ROBIN_WITH_PLAYOFF`:KI;if(t.structureType===qI)return qI;if(t.structureType===BI)return BI;if(t.structureType===JI)return JI;if(n.length===7&&r.length===0&&i.length===0){let n=e.edges.filter(e=>e.linkType===GI&&e.sourceNodeId===t.id),r=new Set(n.map(e=>e.sourceRoundNumber));if(r.has(1)&&r.has(2)&&r.has(3))return UI}if(n.length===1&&r.length===0&&i.length===0){let r=n[0],i=e.edges.filter(e=>e.linkType===GI&&e.sourceNodeId===t.id&&e.targetNodeId===r.id);if(r.structureType===BI||i.length>1)return HI;if(i.length===1&&i[0].sourceRoundNumber===1)return VI}return zI}function ZI(e){let t=e.nodes.find(e=>e.stage===FI);if(!t)throw Error(`No main structure node found`);let n=e.nodes.filter(e=>e.stage===LI),r=e.nodes.filter(e=>e.stage===RI),i=XI(e,t);i===zI&&!nL(t.drawSize)&&(i=BI);let a={drawName:e.drawName,drawType:i,drawSize:t.drawSize,matchUpFormat:t.matchUpFormat||void 0,structureOptions:t.structureOptions||void 0,automated:!0};n.length>0&&eL(a,n,e.edges);let o=[];return QI(e,t,i,o),$I(e,t,r,a),{drawOptions:a,postGenerationMethods:o}}function QI(e,t,n,r){let i=e.nodes.filter(e=>e.stage===II),a=e.edges.filter(e=>e.linkType===GI&&e.sourceNodeId===t.id&&i.some(t=>t.id===e.targetNodeId)),o=[VI,HI,UI];if(a.length===0||o.includes(n))return;let s=new Map;for(let e of a)s.has(e.targetNodeId)||s.set(e.targetNodeId,[]),s.get(e.targetNodeId).push(e);for(let[e,t]of s){let n=i.find(t=>t.id===e);if(!n)continue;let a=t.map(e=>({sourceRoundNumber:e.sourceRoundNumber||1,targetRoundNumber:e.targetRoundNumber||1}));r.push({method:`attachConsolationStructures`,params:{structureName:n.structureName,structureType:n.structureType,drawSize:n.drawSize,matchUpFormat:n.matchUpFormat||void 0,structureOptions:n.structureOptions||void 0,links:a}})}}function $I(e,t,n,r){let i=t.structureType===KI,a=i?e.edges.filter(e=>e.sourceNodeId===t.id&&e.linkType===YI&&n.some(t=>t.id===e.targetNodeId)):[];if(i&&a.length>0){let e=new Map;for(let t of a)e.has(t.targetNodeId)||e.set(t.targetNodeId,[]),e.get(t.targetNodeId).push(t);let t=[];for(let[r,i]of e){let e=n.find(e=>e.id===r);if(!e)continue;let a=Array.from(new Set(i.flatMap(e=>e.finishingPositions||[]))).sort((e,t)=>e-t),o=e.structureOptions?.playoffDrawType||zI,s={finishingPositions:a,structureName:e.structureName,drawType:o};o===KI&&e.structureOptions?.groupSize&&(s.structureOptions={groupSize:e.structureOptions.groupSize}),t.push(s)}t.length>0&&(r.structureOptions={...r.structureOptions,playoffGroups:t})}else if(n.length>0){let i=tL(t.id,n,e.edges);i&&(r.withPlayoffs=i)}}function eL(e,t,n){let r=n.filter(e=>e.linkType===WI&&t.some(t=>t.id===e.sourceNodeId)),i={};for(let e of t){let t=r.find(t=>t.sourceNodeId===e.id),n=t?.targetRoundNumber||1;i[n]||(i[n]=[]),i[n].push({node:e,edge:t})}let a=0;e.qualifyingProfiles=Object.entries(i).map(([e,t])=>{let n=t.map(({node:e,edge:t})=>{let n=e.qualifyingPositions||t?.qualifyingPositions||Math.floor(e.drawSize/4);return a+=n,{structureName:e.structureName,drawType:e.structureType,drawSize:e.drawSize,qualifyingPositions:n,seedsCount:0}});return{roundTarget:Number(e),structureProfiles:n}}),e.qualifiersCount=a,e.qualifyingPlaceholder=!0}function tL(e,t,n){let r=n.filter(n=>n.sourceNodeId===e&&n.linkType===GI&&t.some(e=>e.id===n.targetNodeId));if(!r.length)return;let i=[],a={},o={};for(let e of r){if(!e.sourceRoundNumber)continue;let r=t.find(t=>t.id===e.targetNodeId);if(!r)continue;i.push({[e.sourceRoundNumber]:1});let s=`0-${i.length}`;a[s]={name:r.structureName,abbreviation:r.structureName.substring(0,3)};let c=tL(r.id,t,n);c&&(o[e.sourceRoundNumber]=c)}if(i.length)return{roundProfiles:i,...Object.keys(a).length>0&&{playoffAttributes:a},...Object.keys(o).length>0&&{roundPlayoffs:o}}}function nL(e){return e>0&&(e&e-1)==0}var{MAIN:rL}=t.drawDefinitionConstants,iL=()=>`spl-layout`,aL=()=>`spl-left`,oL=()=>`spl-toggle`,sL=()=>`spl-center`,cL=()=>`spl-center-header`,lL=()=>`spl-center-title`,uL=()=>`spl-center-actions`,dL=()=>`spl-center-leading`,fL=()=>`spl-grid-slot`,pL=()=>`spl-right`,mL=()=>`spl-matchup-card`,hL=()=>`spl-card-title`,gL=()=>`spl-card-sides`,_L=()=>`spl-card-meta`,vL=()=>`spl-card-chips`,yL=()=>`spl-card-chip`,bL=()=>`sp-panel`,xL=()=>`sp-panel-header`,SL=()=>`sp-panel-title`,CL=()=>`sp-panel-meta`,wL=()=>`sp-date-strip`,TL=()=>`sp-date-chip`,EL=()=>`sp-badges`,DL=()=>`sp-catalog`,OL=()=>`sp-catalog-toolbar`,kL=()=>`sp-input`,AL=()=>`sp-select`,jL=()=>`sp-group`,ML=()=>`sp-group-header`,NL=()=>`sp-group-body`,PL=()=>`sp-group-chevron`,FL=()=>`sp-issues`,IL=()=>`sp-issue`,LL=()=>`sp-issue-code`,RL=()=>`sp-issue-msg`,zL=()=>`sp-inspector`,BL=()=>`sp-kv`,VL=()=>`sp-kv-key`,HL=()=>`sp-kv-value`,UL=()=>`sp-small`;function WL(e,t,n){let r=!!n?.hideLeft,i=n?.catalogSide===`left`,a=document.createElement(`div`);a.className=iL();let o=null,s=null;if(r)i?a.classList.add(`spl-catalog-left`):a.classList.add(`spl-no-left`);else{o=document.createElement(`div`),o.className=aL(),s=document.createElement(`button`),s.className=oL(),s.textContent=`◀`,s.title=`Toggle sidebar`,s.addEventListener(`click`,()=>t.onToggleLeft()),o.appendChild(s);let n=document.createElement(`div`);n.className=`spl-left-content`,n.style.cssText=`display:flex;flex-direction:column;gap:12px;flex:1;min-height:0`,e.dateStrip.element.style.flex=`1`,e.dateStrip.element.style.minHeight=`0`,e.dateStrip.element.style.overflow=`auto`,n.appendChild(e.dateStrip.element),e.issuesPanel.element.style.flex=`1`,e.issuesPanel.element.style.minHeight=`0`,e.issuesPanel.element.style.overflow=`auto`,n.appendChild(e.issuesPanel.element),o.appendChild(n)}let c=e.courtGridSlot.element,l=document.createElement(`div`);l.className=pL(),e.matchUpCatalog.element.style.flex=`3`,e.matchUpCatalog.element.style.minHeight=`0`,e.matchUpCatalog.element.style.overflow=`auto`,l.appendChild(e.matchUpCatalog.element),e.inspectorPanel.element.style.flex=`1`,e.inspectorPanel.element.style.minHeight=`120px`,e.inspectorPanel.element.style.overflow=`auto`,l.appendChild(e.inspectorPanel.element),o&&a.appendChild(o),i&&r?(a.appendChild(l),a.appendChild(c)):(a.appendChild(c),a.appendChild(l));function u(t){r||(t.leftCollapsed?(a.classList.add(`spl-left-collapsed`),s&&(s.textContent=`▶`)):(a.classList.remove(`spl-left-collapsed`),s&&(s.textContent=`◀`)),e.dateStrip.update(t),e.issuesPanel.update(t)),e.courtGridSlot.update(t),e.matchUpCatalog.update(t),e.inspectorPanel.update(t)}return{element:a,update:u}}function GL(e){let t=e.sides;if(t?.length===2){let e=KL(t[0]),n=KL(t[1]);if(e&&n)return`${e} vs ${n}`;if(e)return`${e} vs TBD`;if(n)return`TBD vs ${n}`}return`TBD vs TBD`}function KL(e){return e?`${e.participantName??``}${e.seedNumber?` [${e.seedNumber}]`:``}`:``}function qL(e){let t=[e.eventName,e.drawName??``,e.roundName??``];if(e.sides)for(let n of e.sides)n.participantName&&t.push(n.participantName);return t.join(` `).toLowerCase()}function JL(){let e=document.createElement(`div`);e.className=bL();let t=document.createElement(`div`);t.className=xL();let n=document.createElement(`div`);n.className=SL(),n.textContent=`Inspector`,t.appendChild(n),e.appendChild(t);let r=document.createElement(`div`);r.className=zL(),e.appendChild(r);function i(e){r.innerHTML=``;let t=e.selectedMatchUp;if(!t){let e=document.createElement(`div`);e.className=UL(),e.textContent=`Select a matchUp in the catalog to see details.`,r.appendChild(e);return}if(YL(r,`Event`,t.eventName),YL(r,`Draw`,t.drawName??t.drawId),YL(r,`Round`,t.roundName??`Round ${t.roundNumber}`),YL(r,`Type`,t.matchUpType??`—`),YL(r,`Format`,t.matchUpFormat??`—`),YL(r,`Scheduled`,t.isScheduled?`Yes`:`No`),t.scheduledTime&&YL(r,`Time`,t.scheduledTime),t.scheduledCourtName&&YL(r,`Court`,t.scheduledCourtName),t.sides?.length){let e=document.createElement(`div`);e.className=UL(),e.style.marginTop=`8px`,e.textContent=`Participants:`,r.appendChild(e);let n=document.createElement(`div`);n.className=`spl-inspector-sides`;for(let e of t.sides){let t=document.createElement(`div`);t.className=`spl-inspector-side`;let r=document.createElement(`span`);if(r.textContent=KL(e)||`TBD`,t.appendChild(r),e.ranking){let n=document.createElement(`span`);n.className=`spl-inspector-seed`,n.textContent=`#${e.ranking}`,t.appendChild(n)}n.appendChild(t)}r.appendChild(n)}}return{element:e,update:i}}function YL(e,t,n){let r=document.createElement(`div`);r.className=BL();let i=document.createElement(`div`);i.className=VL(),i.textContent=t;let a=document.createElement(`div`);a.className=HL(),a.textContent=n,r.appendChild(i),r.appendChild(a),e.appendChild(r)}var XL=new Set([`COMPLETED`,`RETIRED`,`WALKOVER`,`DEFAULTED`,`DOUBLE_WALKOVER`,`DOUBLE_DEFAULT`,`CANCELLED`,`ABANDONED`,`DEAD_RUBBER`]);function ZL(e){return!!e&&XL.has(e)}function QL(e,t,n=`dim`,r,i=!1){let a=t.toLowerCase().trim();return e.filter(e=>n===`hide`&&e.isScheduled||!i&&ZL(e.matchUpStatus)||r&&(r.eventType&&e.matchUpType!==r.eventType||r.eventName&&e.eventName!==r.eventName||r.drawName&&(e.drawName??e.drawId)!==r.drawName||r.gender&&e.gender!==r.gender||r.roundName&&e.roundName!==r.roundName)?!1:a?qL(e).includes(a):!0)}function $L(e,t){let n=new Map,r=e=>t===`draw`?`${e.eventName} \u2014 ${e.drawName??e.drawId}`:t===`round`?e.roundName??`Round ${e.roundNumber}`:t===`structure`?`${e.eventName} \u2014 ${e.structureId}`:e.eventName;for(let t of e){let e=r(t),i=n.get(e);i?i.push(t):n.set(e,[t])}return new Map([...n.entries()].sort((e,t)=>e[0].localeCompare(t[0],void 0,{numeric:!0})))}function eR(e,t){let n=document.createElement(`div`);n.className=mL(),n.setAttribute(`data-matchup-id`,e.matchUpId);let r=ZL(e.matchUpStatus);e.isScheduled?(n.classList.add(`scheduled`),n.draggable=!1):r?(n.classList.add(`completed`),n.draggable=!1):(n.draggable=!0,n.addEventListener(`dragstart`,t=>{t.stopPropagation(),t.dataTransfer.setDragImage(n,n.offsetWidth/2,20),t.dataTransfer.setData(`application/json`,JSON.stringify({type:`CATALOG_MATCHUP`,matchUp:e})),t.dataTransfer.effectAllowed=`copyMove`})),t.onClick&&n.addEventListener(`click`,n=>{n.stopPropagation(),t.onClick(e)});let i=document.createElement(`div`);i.className=hL(),i.textContent=`${e.eventName} \u2014 ${e.roundName??`Round `+e.roundNumber}`,n.appendChild(i);let a=document.createElement(`div`);a.className=gL(),a.textContent=GL(e),n.appendChild(a);let o=document.createElement(`div`);o.className=_L();let s=[];e.drawName&&s.push(e.drawName),e.matchUpType&&s.push(e.matchUpType.toLowerCase()),o.textContent=s.join(` · `),n.appendChild(o);let c=document.createElement(`div`);if(c.className=vL(),e.scheduledTime&&c.appendChild(tR(e.scheduledTime,`time`)),e.scheduledCourtName&&c.appendChild(tR(e.scheduledCourtName,`court`)),e.matchUpFormat&&c.appendChild(tR(e.matchUpFormat,`type`)),r&&e.matchUpStatus){let t=e.matchUpStatus.replace(/_/g,` `);c.appendChild(tR(t,`status`))}if(c.children.length&&n.appendChild(c),e.isScheduled){let e=document.createElement(`span`);e.className=`spl-matchup-check`,e.textContent=`✓`,n.appendChild(e)}return n}function tR(e,t){let n=document.createElement(`div`);return n.className=yL()+` `+t,n.textContent=e,n}function nR(e,t){let n=new Set;for(let r of e){let e=t(r);e&&n.add(e)}return[...n].sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0}))}function rR(e){let t=document.createElement(`div`);t.className=bL();let n=`spl-catalog-drop-over`,r=`is-filtering`,i=new Set,a=null,o,s={};t.addEventListener(`dragover`,e=>{e.preventDefault(),t.classList.add(n),e.dataTransfer.dropEffect=`move`}),t.addEventListener(`dragleave`,e=>{t.contains(e.relatedTarget)||t.classList.remove(n)}),t.addEventListener(`drop`,r=>{if(t.classList.remove(n),r.preventDefault(),!e.onDropRemove)return;let i;try{i=JSON.parse(r.dataTransfer.getData(`application/json`))}catch{return}(i.type===`CATALOG_MATCHUP`||i.type===`GRID_MATCHUP`)&&e.onDropRemove(i.matchUp.matchUpId)});let c=document.createElement(`div`);c.className=xL();let l=document.createElement(`div`);l.className=`spl-catalog-title-row`;let u=document.createElement(`div`);u.className=SL(),u.textContent=`MatchUp Catalog`;let d=document.createElement(`button`);d.className=`spl-catalog-filter-btn`,d.title=`Filter matchUps`,d.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>`,l.appendChild(u),l.appendChild(d);let f=document.createElement(`div`);f.className=CL(),c.appendChild(l),c.appendChild(f),t.appendChild(c);let p=document.createElement(`div`);p.className=OL();let m=document.createElement(`input`);m.type=`text`,m.placeholder=`Search matchUps...`,m.className=kL(),m.addEventListener(`input`,()=>e.onSearchChange(m.value));let h=gy(m,()=>{m.value=``,e.onSearchChange(``),m.focus()}),g=document.createElement(`select`);g.className=AL();for(let[e,t]of[[`event`,`By Event`],[`draw`,`By Draw`],[`round`,`By Round`],[`structure`,`By Structure`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,g.appendChild(n)}g.addEventListener(`change`,()=>e.onGroupByChange(g.value)),p.appendChild(h),p.appendChild(g),t.appendChild(p);function _(){o&&=(o.destroy(),void 0)}function v(){return!!(s.eventType||s.eventName||s.drawName||s.gender||s.roundName)}function y(){d.classList.toggle(`active`,v())}function b(){let t=a?.matchUpCatalog??[],n=document.createElement(`div`);n.className=`spl-filter-popover`;let i=document.createElement(`div`);i.className=`spl-filter-header`;let o=document.createElement(`button`);o.className=`spl-filter-clear-btn`,o.textContent=`Clear All`,o.addEventListener(`click`,t=>{t.stopPropagation(),s={},e.onFilterChange(s),y();for(let e of n.querySelectorAll(`select`)){e.value=``,e.classList.remove(r);let t=e.previousElementSibling;t?.classList.contains(`spl-filter-label`)&&t.classList.remove(r)}}),i.appendChild(o);let c=document.createElement(`button`);c.className=`spl-filter-close-btn`,c.textContent=`×`,c.addEventListener(`click`,e=>{e.stopPropagation(),_()}),i.appendChild(c),n.appendChild(i);let l=[{label:`All Event Types`,key:`eventType`,values:nR(t,e=>e.matchUpType)},{label:`All Events`,key:`eventName`,values:nR(t,e=>e.eventName)},{label:`All Flights`,key:`drawName`,values:nR(t,e=>e.drawName)},{label:`All Genders`,key:`gender`,values:nR(t,e=>e.gender)},{label:`All Rounds`,key:`roundName`,values:nR(t,e=>e.roundName)}];for(let t of l){if(t.values.length<2)continue;let i=document.createElement(`label`);i.className=`spl-filter-label`,i.textContent=t.label,n.appendChild(i);let a=document.createElement(`select`);a.className=`spl-filter-select`;let o=document.createElement(`option`);o.value=``,o.textContent=t.label,a.appendChild(o);for(let e of t.values){let t=document.createElement(`option`);t.value=e,t.textContent=e,a.appendChild(t)}a.value=s[t.key]??``;let c=()=>{let e=a.value!==``;a.classList.toggle(r,e),i.classList.toggle(r,e)};c(),a.addEventListener(`change`,()=>{s={...s,[t.key]:a.value||void 0},e.onFilterChange(s),y(),c()}),n.appendChild(a)}let u=document.createElement(`label`);u.className=`spl-filter-toggle`;let d=document.createElement(`input`);d.type=`checkbox`,d.checked=a?.showScheduled??!1,d.addEventListener(`change`,()=>{e.onShowScheduledChange?.(d.checked)}),u.appendChild(d),u.appendChild(document.createTextNode(` Show assigned`)),n.appendChild(u);let f=document.createElement(`label`);f.className=`spl-filter-toggle`;let p=document.createElement(`input`);return p.type=`checkbox`,p.checked=a?.showCompleted??!1,p.addEventListener(`change`,()=>{e.onShowCompletedChange(p.checked)}),f.appendChild(p),f.appendChild(document.createTextNode(` Show completed`)),n.appendChild(f),n}d.addEventListener(`click`,()=>{_(),o=um(d,{content:b(),placement:`bottom-start`,interactive:!0,trigger:`manual`,appendTo:()=>t,onClickOutside:()=>_(),theme:``}),o.show()});let x=document.createElement(`div`);x.className=DL(),t.appendChild(x);function S(t){a=t,s=t.catalogFilters??{},y();let n=t.showScheduled?t.scheduledBehavior:`hide`,r=QL(t.matchUpCatalog,t.catalogSearchQuery,n,t.catalogFilters,t.showCompleted),o=$L(r,t.catalogGroupBy);f.textContent=`${r.filter(e=>!e.isScheduled).length} unscheduled`,m.value!==t.catalogSearchQuery&&(m.value=t.catalogSearchQuery,_y(h)),g.value!==t.catalogGroupBy&&(g.value=t.catalogGroupBy),x.innerHTML=``;for(let[n,r]of o){let o=document.createElement(`div`);o.className=jL();let s=i.has(n),c=document.createElement(`div`);c.className=ML();let l=document.createElement(`span`);l.className=PL(),l.textContent=s?`▶`:`▼`;let u=document.createElement(`span`);u.textContent=`${n} (${r.length})`,c.appendChild(l),c.appendChild(u),c.addEventListener(`click`,()=>{i.has(n)?i.delete(n):i.add(n),a&&S(a)});let d=document.createElement(`div`);d.className=NL(),s&&(d.style.display=`none`);for(let n of r){let r=eR(n,{onClick:t=>e.onMatchUpSelected?.(t)});t.selectedMatchUp?.matchUpId===n.matchUpId&&r.classList.add(`selected`),d.appendChild(r)}o.appendChild(c),o.appendChild(d),x.appendChild(o)}}return{element:t,update:S}}function iR(e){let t={ERROR:[],WARN:[],INFO:[]},n={},r={total:e.length,ERROR:0,WARN:0,INFO:0},i={},a=e=>e===`ERROR`?0:e===`WARN`?1:2;for(let a of e)if(t[a.severity].push(a),r[a.severity]++,a.date){(n[a.date]??=[]).push(a);let e=i[a.date]??={total:0,ERROR:0,WARN:0,INFO:0};e.total++,e[a.severity]++}let o=(e,t)=>a(e.severity)-a(t.severity)||e.message.localeCompare(t.message),s=[...e].sort(o);for(let e of Object.keys(t))t[e].sort(o);for(let e of Object.keys(n))n[e].sort(o);return{all:s,bySeverity:t,byDate:n,counts:r,countsByDate:i}}var aR=`spl-cell--issue-pulse`;function oR(){let e=document.createElement(`div`);e.className=bL();let t=document.createElement(`div`);t.className=xL();let n=document.createElement(`div`);n.className=SL(),n.textContent=`Issues`;let r=document.createElement(`div`);r.className=CL(),t.appendChild(n),t.appendChild(r),e.appendChild(t);let i=document.createElement(`div`);i.className=FL(),e.appendChild(i);function a(e){let t=iR(e.issues);if(r.textContent=`${t.counts.total} total (${t.counts.ERROR} errors)`,i.innerHTML=``,!t.all.length){let e=document.createElement(`div`);e.className=UL(),e.textContent=`No scheduling conflicts.`,i.appendChild(e);return}for(let e of t.all.slice(0,30)){let t=document.createElement(`div`);t.className=IL(),e.severity===`ERROR`?t.classList.add(`error`):e.severity===`WARN`?t.classList.add(`warn`):t.classList.add(`info`);let n=document.createElement(`div`);n.className=LL(),n.textContent=e.severity;let r=document.createElement(`div`);if(r.className=RL(),e.participants){if(e.prefix){let t=document.createElement(`span`);t.textContent=e.prefix,t.style.opacity=`0.7`,r.appendChild(t)}let t=document.createElement(`span`);t.textContent=(e.issueType||``)+`: `,t.style.opacity=`0.7`,r.appendChild(t);let n=document.createElement(`span`);if(n.textContent=e.participants,n.style.color=`var(--spl-issue-participant1, #4fc3f7)`,n.style.fontWeight=`600`,r.appendChild(n),e.conflictParticipants?.length){let t=document.createElement(`span`);t.textContent=` conflicts with `,t.style.opacity=`0.7`,r.appendChild(t),e.conflictParticipants.forEach((e,t)=>{if(t>0){let e=document.createElement(`span`);e.textContent=`, `,e.style.opacity=`0.7`,r.appendChild(e)}let n=document.createElement(`span`);n.textContent=e,n.style.color=`var(--spl-issue-participant2, #ffb74d)`,n.style.fontWeight=`600`,r.appendChild(n)})}}else r.textContent=e.message;if(e.matchUpId){t.style.cursor=`pointer`;let n=e.matchUpId;t.addEventListener(`click`,()=>{console.log(`[issuesPanel] clicked issue row, matchUpId:`,n),o(n)})}else console.log(`[issuesPanel] issue has no matchUpId:`,e.message);t.appendChild(n),t.appendChild(r),i.appendChild(t)}}function o(e){let t=`.spl-grid-cell[data-matchup-id="${e}"]`,n=document.querySelector(t);console.log(`[issuesPanel] scrollToMatchUp selector:`,t,`found:`,!!n),n&&(n.scrollIntoView({behavior:`smooth`,block:`center`,inline:`center`}),n.classList.remove(aR),n.offsetWidth,n.classList.add(aR),n.addEventListener(`animationend`,()=>n.classList.remove(aR),{once:!0}))}return{element:e,update:a}}function sR(e){let t=document.createElement(`div`);t.className=bL();let n=document.createElement(`div`);n.className=xL();let r=document.createElement(`div`);r.className=SL(),r.textContent=`Dates`;let i=document.createElement(`div`);i.className=CL(),n.appendChild(r),n.appendChild(i),t.appendChild(n);let a=document.createElement(`div`);a.className=wL(),t.appendChild(a);function o(t){let n=t.scheduleDates;i.textContent=`${n.length} dates`,a.innerHTML=``;for(let r of n){let n=document.createElement(`div`);n.className=TL(),r.date===t.selectedDate&&n.classList.add(`selected`),r.isActive||n.classList.add(`inactive`),n.setAttribute(`data-date`,r.date);let i=document.createElement(`div`),o=document.createElement(`div`);o.style.cssText=`font-weight:800;font-size:0.75rem`,o.textContent=r.date;let s=document.createElement(`div`);s.style.cssText=`font-size:0.6875rem;color:var(--sp-muted)`,s.textContent=r.isActive?`Active`:`Inactive`,i.appendChild(o),i.appendChild(s);let c=document.createElement(`div`);if(c.className=EL(),r.matchUpCount!=null){let e=document.createElement(`div`);e.className=`spl-date-badge matchups`,e.textContent=`${r.matchUpCount} matchUps`,c.appendChild(e)}if(r.issueCount&&r.issueCount>0){let e=document.createElement(`div`);e.className=`spl-date-badge issues`,e.textContent=`${r.issueCount} issues`,c.appendChild(e)}n.appendChild(i),n.appendChild(c),n.addEventListener(`click`,()=>e.onDateSelected(r.date)),a.appendChild(n)}}return{element:t,update:o}}function cR(e,t,n){let r=document.createElement(`div`);r.className=sL();let i=document.createElement(`div`);i.className=cL();let a=n?.titleLeadingActions,o;if(n?.titleSlot?o=n.titleSlot:(o=document.createElement(`div`),o.className=lL(),o.textContent=`Court Grid`),a){let e=document.createElement(`div`);e.className=dL();let t=Array.isArray(a)?a:[a];for(let n of t)e.appendChild(n);e.appendChild(o),i.appendChild(e)}else i.appendChild(o);let s=n?.headerActions;if(s){let e=document.createElement(`div`);e.className=uL();let t=Array.isArray(s)?s:[s];for(let n of t)e.appendChild(n);i.appendChild(e)}r.appendChild(i);let c=document.createElement(`div`);c.className=fL(),n?.gridMaxHeight&&(c.style.maxHeight=n.gridMaxHeight),e&&c.appendChild(e),c.addEventListener(`dragover`,e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}),c.addEventListener(`drop`,e=>{if(e.preventDefault(),!t.onMatchUpDrop)return;let n;try{n=JSON.parse(e.dataTransfer.getData(`application/json`))}catch{return}(n.type===`CATALOG_MATCHUP`||n.type===`GRID_MATCHUP`)&&t.onMatchUpDrop(n,e)}),r.appendChild(c);function l(e){}return{element:r,update:l}}var lR=class{constructor(e){this.listeners=new Set,this.config=e;let t=e.initialCatalogState??{};this.state={matchUpCatalog:e.matchUpCatalog,scheduleDates:e.scheduleDates,issues:e.issues??[],selectedDate:e.scheduleDates[0]?.date??null,selectedMatchUp:null,catalogSearchQuery:t.catalogSearchQuery??``,catalogGroupBy:t.catalogGroupBy??`event`,catalogFilters:t.catalogFilters??{},showCompleted:t.showCompleted??!1,showScheduled:t.showScheduled??!1,scheduledBehavior:e.scheduledBehavior??`dim`,schedulingMode:e.schedulingMode??`immediate`,pendingActions:[],hasUnsavedChanges:!1,leftCollapsed:!!e.hideLeft,hideLeft:!!e.hideLeft,activeStripVisible:e.activeStripVisible??!0}}getState(){return this.state}setMatchUpCatalog(e){this.setState({matchUpCatalog:e}),this.state.selectedMatchUp&&(e.some(e=>e.matchUpId===this.state.selectedMatchUp?.matchUpId)||this.setState({selectedMatchUp:null}))}setScheduleDates(e){this.setState({scheduleDates:e})}setIssues(e){this.setState({issues:e})}handleMatchUpDrop(e,t){if(this.state.schedulingMode===`immediate`)this.config.onMatchUpDrop?.(e,t);else{let n={kind:`schedule`,matchUpId:e.matchUp.matchUpId,matchUp:e.matchUp,event:t};this.setState({pendingActions:[...this.state.pendingActions,n],hasUnsavedChanges:!0})}}handleMatchUpRemove(e){if(this.state.schedulingMode===`immediate`)this.config.onMatchUpRemove?.(e);else{let t=this.state.pendingActions.findIndex(t=>t.kind===`schedule`&&t.matchUpId===e);if(t>=0){let e=[...this.state.pendingActions];e.splice(t,1),this.setState({pendingActions:e,hasUnsavedChanges:e.length>0})}else{let t={kind:`unschedule`,matchUpId:e};this.setState({pendingActions:[...this.state.pendingActions,t],hasUnsavedChanges:!0})}}}save(){let e=this.state.pendingActions;return e.length?(this.config.onBulkSave?.(e),this.setState({pendingActions:[],hasUnsavedChanges:!1}),e):[]}discardPending(){this.setState({pendingActions:[],hasUnsavedChanges:!1})}getPendingActions(){return this.state.pendingActions}selectDate(e){this.state.selectedDate!==e&&(this.setState({selectedDate:e}),this.config.onDateSelected?.(e))}selectMatchUp(e){this.setState({selectedMatchUp:e}),this.config.onMatchUpSelected?.(e)}setCatalogSearch(e){this.setState({catalogSearchQuery:e})}setCatalogGroupBy(e){this.setState({catalogGroupBy:e})}setCatalogFilters(e){this.setState({catalogFilters:e})}setShowCompleted(e){this.setState({showCompleted:e})}setShowScheduled(e){this.setState({showScheduled:e})}toggleLeftPanel(){this.setState({leftCollapsed:!this.state.leftCollapsed})}setActiveStripVisible(e){this.state.activeStripVisible!==e&&this.setState({activeStripVisible:e})}toggleActiveStrip(){this.setState({activeStripVisible:!this.state.activeStripVisible})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state={...this.state,...e},this.emit()}emit(){for(let e of this.listeners)e(this.state)}},uR=class{constructor(e){this.container=null,this.store=new lR(e);let t=sR({onDateSelected:e=>this.store.selectDate(e)}),n=oR(),r=cR(e.courtGridElement,{onMatchUpDrop:(e,t)=>{this.store.handleMatchUpDrop(e,t)}},{gridMaxHeight:e.gridMaxHeight,headerActions:e.headerActions,titleLeadingActions:e.titleLeadingActions,titleSlot:e.titleSlot}),i=rR({onSearchChange:e=>this.store.setCatalogSearch(e),onGroupByChange:e=>this.store.setCatalogGroupBy(e),onFilterChange:e=>this.store.setCatalogFilters(e),onShowCompletedChange:e=>this.store.setShowCompleted(e),onShowScheduledChange:e=>this.store.setShowScheduled(e),onMatchUpSelected:e=>this.store.selectMatchUp(e),onDropRemove:e=>{this.store.handleMatchUpRemove(e)}}),a=JL();this.layout=WL({dateStrip:t,issuesPanel:n,courtGridSlot:r,matchUpCatalog:i,inspectorPanel:a},{onToggleLeft:()=>this.store.toggleLeftPanel()},{hideLeft:e.hideLeft,catalogSide:e.catalogSide}),this.unsubscribe=this.store.subscribe(e=>{this.layout.update(e)}),this.layout.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.layout.element)}destroy(){this.unsubscribe(),this.container&&this.layout.element.parentNode===this.container&&this.layout.element.remove(),this.container=null}setMatchUpCatalog(e){this.store.setMatchUpCatalog(e)}setScheduleDates(e){this.store.setScheduleDates(e)}setIssues(e){this.store.setIssues(e)}setActiveStripVisible(e){this.store.setActiveStripVisible(e)}toggleActiveStrip(){this.store.toggleActiveStrip()}get activeStripVisible(){return this.store.getState().activeStripVisible}save(){return this.store.save()}discardPending(){this.store.discardPending()}get hasUnsavedChanges(){return this.store.getState().hasUnsavedChanges}getStore(){return this.store}},dR=new Set([`IN_PROGRESS`,`SUSPENDED`]),fR=new Set([`CANCELLED`,`ABANDONED`,`COMPLETED`,`DEAD_RUBBER`,`DEFAULTED`,`DOUBLE_WALKOVER`,`DOUBLE_DEFAULT`,`RETIRED`,`WALKOVER`]),pR=`in-progress`,mR=`pending`,hR=`completed`;function gR(e,t,n){let r=e.matchUpStatus;return r&&t.has(r)||e.hasScore&&e.winningSide===void 0&&(!r||!n.has(r))?pR:r&&n.has(r)||e.winningSide!==void 0?hR:mR}function _R(e,t){let n=t?.inProgressStatuses??dR,r=t?.completedStatuses??fR,i=e.cells,a=-1;for(let t=0;t<i.length;t++){let o=i[t];if(!o)continue;let s=gR(o,n,r);if(s===pR)return{courtId:e.courtId,state:pR,matchUp:o,rowIndex:t};s===mR&&a===-1&&(a=t)}return a===-1?{courtId:e.courtId,state:`free`}:{courtId:e.courtId,state:`next`,matchUp:i[a],rowIndex:a}}function vR(e,t){return e.columns.map(e=>_R(e,t))}function yR(e,t){if(t.size===0)return!1;for(let n of e.participantIds)if(t.has(n))return!0;return!1}function bR(e,t){return t.roundNumber!==void 0&&t.drawId!==void 0&&e.drawId===t.drawId&&e.roundNumber!==void 0&&e.roundNumber<t.roundNumber}function xR(e,t){let n=new Set(t.participantIds??[]),r=-1,i=-1;for(let a of e.columns)for(let e=0;e<a.cells.length;e++){let o=a.cells[e];!o||o.matchUpId===t.matchUpId||(e>r&&yR(o,n)&&(r=e),e>i&&bR(o,t)&&(i=e))}return{participantFloor:r,earlierRoundFloor:i}}function SR(e,t,n){let r=t;for(;r<e.cells.length;){let t=e.cells[r];if(!t||t.matchUpId===n)return r;r++}return r}function CR(e,t,n){let r=e.columns.find(e=>e.courtId===t);if(!r)throw Error(`computeActiveStripDropTarget: court "${t}" not present in grid`);let{participantFloor:i,earlierRoundFloor:a}=xR(e,n);return{courtId:t,rowIndex:SR(r,Math.max(0,i+1,a+1),n.matchUpId)}}var wR=`drop-over`;function TR(e,t,n,r){e.addEventListener(`dragover`,t=>{t.preventDefault(),e.classList.add(wR),t.dataTransfer&&(t.dataTransfer.dropEffect=`move`)}),e.addEventListener(`dragleave`,()=>{e.classList.remove(wR)}),e.addEventListener(`drop`,i=>{if(e.classList.remove(wR),i.preventDefault(),!n.onMatchUpDrop)return;let a;try{a=JSON.parse(i.dataTransfer?.getData(`application/json`)??``)}catch{return}if(a.type!==`CATALOG_MATCHUP`&&a.type!==`GRID_MATCHUP`)return;let o={matchUpId:a.matchUp.matchUpId,drawId:a.matchUp.drawId,roundNumber:a.matchUp.roundNumber,participantIds:(a.matchUp.sides??[]).map(e=>e.participantId).filter(e=>!!e)},s=CR(r(),t.courtId,o);n.onMatchUpDrop(a,s,i)})}function ER(e){return e===`in-progress`?`LIVE`:e===`next`?`NEXT`:null}function DR(e,t,n,r){let i=document.createElement(`div`);if(i.className=`spl-active-strip-cell state-${e.state}`,i.dataset.courtId=e.courtId,e.rowIndex!==void 0&&(i.dataset.rowIndex=String(e.rowIndex)),r.cellHeight&&(i.style.minHeight=r.cellHeight),e.state!==`free`&&e.matchUp){let t=r.renderCell?.(e.matchUp);if(t)i.appendChild(t);else{let t=document.createElement(`div`);t.className=`spl-active-strip-body`,t.textContent=e.matchUp.participantIds.join(` – `)||e.matchUp.matchUpId,i.appendChild(t)}}let a=ER(e.state);if(a){let e=document.createElement(`span`);e.className=`spl-active-strip-state-pill`,e.textContent=a,i.appendChild(e)}return TR(i,e,t,n),i}function OR(e){let t=document.createElement(`div`);if(t.className=`spl-active-strip-spacer`,e.cellHeight&&(t.style.minHeight=e.cellHeight),e.spacerLabel){let n=document.createElement(`span`);n.className=`spl-active-strip-spacer-label`,n.textContent=e.spacerLabel,t.appendChild(n)}return t}function kR(e={},t={}){let n=document.createElement(`div`);n.className=`spl-active-strip`;let r={grid:{columns:[]},courts:[]};function i(){return r.grid}function a(){n.innerHTML=``,r.gridTemplateColumns?(n.style.display=`grid`,n.style.gridTemplateColumns=r.gridTemplateColumns):(n.style.display=``,n.style.gridTemplateColumns=``),n.style.minWidth=r.minWidth??``,n.appendChild(OR(t));let a=vR(r.grid,t.statusOptions);for(let r of a)n.appendChild(DR(r,e,i,t))}function o(e){r=e,a()}function s(e){n.hidden=!e.activeStripVisible}return{element:n,setData:o,update:s}}var AR=`spl-cell--conflict-highlight`,jR=`spl-cell--complete`,MR={header:[`time`],body:[`eventRound`,`participants`],footer:[`score`],participantDisplay:{nameFormat:`full`,showSeed:!1,showRanking:!1,showNationality:!1,boldWinner:!0,showPotentials:!0}};function NR(e,t){let n=t??MR;return e.isBlocked?PR(e):e.matchUpId?IR(e,n):FR()}function PR(e){let t=document.createElement(`div`);t.className=`spl-grid-cell spl-cell--blocked`;let n=e.booking?.bookingType||`BLOCKED`;t.dataset.bookingType=n;let r=document.createElement(`div`);r.className=`spl-grid-cell__block-label`;let i=document.createElement(`div`);if(i.className=`spl-grid-cell__block-type`,i.textContent=n,r.appendChild(i),e.booking?.rowCount){let t=document.createElement(`div`);t.className=`spl-grid-cell__block-rows`,t.textContent=`${e.booking.rowCount} rows`,r.appendChild(t)}if(e.booking?.notes){let t=document.createElement(`div`);t.className=`spl-grid-cell__block-notes`,t.textContent=e.booking.notes,r.appendChild(t)}return t.appendChild(r),t}function FR(){let e=document.createElement(`div`);return e.className=`spl-grid-cell spl-cell--empty`,e}function IR(e,t){let n=document.createElement(`div`);if(n.className=`spl-grid-cell`,n.dataset.matchupId=e.matchUpId,e.drawId&&(n.dataset.drawId=e.drawId),e.gender&&(n.dataset.gender=e.gender),LR(n,e),t.header.length){let r=document.createElement(`div`);r.className=`spl-grid-cell__header`,RR(r,t.header,e,t),n.appendChild(r)}if(t.body.length){let r=document.createElement(`div`);r.className=`spl-grid-cell__body`,RR(r,t.body,e,t),n.appendChild(r)}if(t.footer.length){let r=document.createElement(`div`);r.className=`spl-grid-cell__footer`,RR(r,t.footer,e,t),n.appendChild(r)}return e.issueIds?.length&&(n.addEventListener(`mouseenter`,()=>{n.classList.add(AR);for(let t of e.issueIds)document.querySelectorAll(`[data-matchup-id="${t}"]`).forEach(e=>e.classList.add(AR))}),n.addEventListener(`mouseleave`,()=>{n.classList.remove(AR);for(let t of e.issueIds)document.querySelectorAll(`[data-matchup-id="${t}"]`).forEach(e=>e.classList.remove(AR))})),n}function LR(e,t){let n=t.matchUpStatus?.toUpperCase();n===`COMPLETED`||n===`RETIRED`||n===`DEFAULTED`||n===`WALKOVER`?e.classList.add(jR):n===`IN_PROGRESS`?e.classList.add(`spl-cell--inprogress`):n===`ABANDONED`?e.classList.add(`spl-cell--abandoned`):n===`CANCELLED`?e.classList.add(`spl-cell--cancelled`):n===`DOUBLE_WALKOVER`&&e.classList.add(`spl-cell--double-walkover`);let r=t.scheduleState?.toUpperCase();r===`SCHEDULE_ERROR`||r===`ERROR`?e.classList.add(`spl-cell--error`):r===`SCHEDULE_CONFLICT`||r===`CONFLICT`?e.classList.add(`spl-cell--conflict`):r===`SCHEDULE_WARNING`||r===`WARNING`?e.classList.add(`spl-cell--warning`):(r===`SCHEDULE_ISSUE`||r===`ISSUE`)&&e.classList.add(`spl-cell--issue`),(t.issueType===`DOUBLE_BOOKING`||t.issueType===`courtDoubleBooking`)&&e.classList.add(`spl-cell--double-booking`)}function RR(e,t,n,r){for(let i of t){let t=zR(i,n,r);t&&e.appendChild(t)}}function zR(e,t,n){switch(e){case`time`:return BR(t);case`eventRound`:return VR(t);case`participants`:return HR(t,n.participantDisplay);case`score`:return qR(t);case`matchUpStatus`:return JR(t);case`matchUpFormat`:return YR(t);case`umpire`:return XR(t);default:return null}}function BR(e){let t=e.schedule?.scheduledTime||e.schedule?.startTime,n=e.schedule?.timeModifiers,r=e.schedule?.courtAnnotation;if(!t&&!n?.length&&!r)return null;let i=document.createElement(`div`);i.className=`spl-grid-cell__time`;let a=[];if(n?.length&&a.push(n.join(` `)),t&&a.push(t),i.textContent=a.join(` `)||``,r){let e=document.createElement(`span`);e.className=`spl-grid-cell__court-annotation`,e.textContent=` ${r}`,i.appendChild(e)}return i}function VR(e){let t=[e.eventName,e.roundName].filter(Boolean);if(!t.length)return null;let n=document.createElement(`div`);return n.className=`spl-grid-cell__event-round`,n.textContent=t.join(` `),n}function HR(e,t){let n=t??MR.participantDisplay,r=document.createElement(`div`);r.className=`spl-grid-cell__participants`;let i=e.sides||[],a=e.matchUpStatus?.toUpperCase()===`BYE`,o=i.some(e=>e.bye);if(i.length===0&&n.showPotentials!==!1&&e.potentialParticipants?.length){for(let t=0;t<e.potentialParticipants.length;t++){t>0&&r.appendChild(GR());let n=e.potentialParticipants[t].map(e=>e?.participantName||`TBD`).join(` / `),i=document.createElement(`div`);i.className=`spl-grid-cell__side spl-grid-cell__potential`,i.textContent=n||`TBD`,r.appendChild(i)}return r}if(i.length===0)return null;for(let t=0;t<i.length;t++){let a=i[t];a.bye?r.appendChild(WR()):(t>0&&!i[t-1]?.bye&&r.appendChild(GR()),r.appendChild(UR(a,e,n,a.sideNumber??t+1)))}return(a||o)&&i.length===1&&!i[0].bye&&r.appendChild(WR()),r}function UR(e,t,n,r){let i=document.createElement(`div`);i.className=`spl-grid-cell__side`;let a=document.createElement(`span`);a.className=`spl-grid-cell__name`;let o=KR(e.participantName,n.nameFormat)||`TBD`;if(n.showSeed&&e.seedNumber&&(o+=` [${e.seedNumber}]`),n.showRanking&&e.ranking&&(o+=` (#${e.ranking})`),n.showNationality&&e.nationality&&(o+=` ${e.nationality}`),a.textContent=o,n.boldWinner!==!1&&t.winningSide===r&&(a.style.fontWeight=`bold`),i.appendChild(a),e.teamName){let t=document.createElement(`div`);t.className=`spl-grid-cell__team-name`,t.textContent=e.teamName,i.appendChild(t)}return i}function WR(){let e=document.createElement(`div`);return e.className=`spl-grid-cell__bye`,e.textContent=`BYE`,e}function GR(){let e=document.createElement(`div`);return e.className=`spl-grid-cell__vs`,e.textContent=`vs.`,e}function KR(e,t){if(!e)return``;switch(t){case`last`:return e.includes(`,`)?e.split(`,`)[0].trim():e.trim().split(/\s+/).at(-1);case`lastFirst`:{if(e.includes(`,`))return e.trim();let t=e.trim().split(/\s+/);return t.length<2?e:`${t.at(-1)}, ${t.slice(0,-1).join(` `)}`}case`firstLast`:{if(!e.includes(`,`))return e.trim();let[t,...n]=e.split(`,`);return`${n.join(`,`).trim()} ${t.trim()}`}default:return e}}function qR(e){let t=e.score?.scoreStringSide1,n=e.matchUpStatus?.toUpperCase(),r=n===`WALKOVER`?`WALKOVER`:n===`DEFAULTED`?`DEFAULT`:n===`RETIRED`?`RET.`:n===`DOUBLE_WALKOVER`?`D.W/O`:n===`ABANDONED`?`ABN.`:null;if(!t&&!r)return null;let i=document.createElement(`div`);return i.className=`spl-grid-cell__score`,i.textContent=t||r||``,i}function JR(e){if(!e.matchUpStatus)return null;let t=document.createElement(`div`);t.className=`spl-grid-cell__status-badge`;let n=e.matchUpStatus.toUpperCase();return n===`IN_PROGRESS`?(t.textContent=`LIVE`,t.classList.add(`spl-grid-cell__status-badge--live`)):n===`COMPLETED`||n===`RETIRED`||n===`DEFAULTED`||n===`WALKOVER`?(t.textContent=`DONE`,t.classList.add(`spl-grid-cell__status-badge--done`)):t.textContent=e.matchUpStatus.replaceAll(`_`,` `),t}function YR(e){if(!e.matchUpFormat)return null;let t=document.createElement(`div`);return t.className=`spl-grid-cell__format`,t.textContent=e.matchUpFormat,t}function XR(e){if(!e.umpire)return null;let t=document.createElement(`div`);return t.className=`spl-grid-cell__umpire`,t.textContent=e.umpire,t}function ZR(e){if(!e)return{matchUpId:``};if(e.isBlocked)return{matchUpId:``,isBlocked:!0,booking:e.booking};let t=(e.sides||[]).map((e,t)=>({sideNumber:e.sideNumber??t+1,participantName:e.participant?.participantName??e.participantName,participantId:e.participantId??e.participant?.participantId,seedNumber:e.seedValue??e.seedNumber,ranking:e.ranking,nationality:e.participant?.nationalityCode??e.participant?.person?.nationalityCode??e.nationalityCode,teamName:e.teamParticipant?.participantName??e.teamName,bye:e.bye||void 0}));return{matchUpId:e.matchUpId,drawId:e.drawId,eventName:e.eventName,roundName:e.roundName,matchUpFormat:e.matchUpFormat,matchUpType:e.matchUpType,matchUpStatus:e.matchUpStatus,winningSide:e.winningSide,gender:e.gender??e.eventGender,sides:t,potentialParticipants:e.potentialParticipants,schedule:e.schedule?{scheduledTime:e.schedule.scheduledTime,startTime:e.schedule.startTime,timeModifiers:e.schedule.timeModifiers,courtAnnotation:e.schedule.courtAnnotation,courtId:e.schedule.courtId,courtOrder:e.schedule.courtOrder,venueId:e.schedule.venueId}:void 0,score:e.score?{scoreStringSide1:e.score.scoreStringSide1,scoreStringSide2:e.score.scoreStringSide2}:void 0,umpire:e.umpire?.participantName??e.umpireName,scheduleState:e.scheduleState,issueType:e.issueType,issueIds:e.issueIds}}function QR({cell:e,listProvider:t,onSelect:n,onCancel:r}){let i=e.innerHTML,a=[],o=!1,s=!1;e.classList.add(`spl-cell--typeahead`),e.innerHTML=``;let c=document.createElement(`div`);c.className=`spl-cell--typeahead-wrapper`,e.appendChild(c);let l=document.createElement(`input`);l.type=`text`,l.placeholder=`Search matchUps...`,l.setAttribute(`inputmode`,`search`),l.setAttribute(`autocapitalize`,`off`),l.setAttribute(`enterkeyhint`,`search`),l.setAttribute(`autocomplete`,`off`),c.appendChild(l);let u=e,d=0;for(;u&&d<10;){let e=window.getComputedStyle(u);(e.overflow!==`visible`||e.overflowX!==`visible`||e.overflowY!==`visible`)&&(a.push({el:u,overflow:u.style.overflow,overflowX:u.style.overflowX,overflowY:u.style.overflowY}),u.style.setProperty(`overflow`,`visible`,`important`),u.style.setProperty(`overflow-x`,`visible`,`important`),u.style.setProperty(`overflow-y`,`visible`,`important`)),u=u.parentElement,d++}ne({list:t(),element:l,listProvider:t,callback:e=>{e&&!s&&(o=!0,p(),n(e))}}),l.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p(),r?.())}),l.addEventListener(`blur`,()=>{setTimeout(()=>{!o&&!s&&(p(),r?.())},200)});let f=e=>{e.target!==l&&!c.contains(e.target)&&(e.preventDefault(),l.blur())};e.addEventListener(`mousedown`,f),c.addEventListener(`click`,e=>{e.stopPropagation()}),setTimeout(()=>l.focus(),0);function p(){if(!s){s=!0,e.removeEventListener(`mousedown`,f),e.classList.remove(`spl-cell--typeahead`),e.innerHTML=i;for(let{el:e,overflow:t,overflowX:n,overflowY:r}of a)t?e.style.overflow=t:e.style.removeProperty(`overflow`),n?e.style.overflowX=n:e.style.removeProperty(`overflow-x`),r?e.style.overflowY=r:e.style.removeProperty(`overflow-y`)}}return{destroy:p}}function $R(e,t){let n=new uR(e);return n.render(t),n}var ez=class{constructor(e){this.listeners=new Set,this.config=e,this.state={compositionName:e.compositionName||`Custom`,theme:e.composition?.theme||``,configuration:{...e.composition?.configuration||{}},expandedSections:new Set([`theme`,`display`]),isDirty:!1,readOnly:e.readOnly||!1}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}toggleSection(e){let t=new Set(this.state.expandedSections);t.has(e)?t.delete(e):t.add(e),this.setState({expandedSections:t})}setTheme(e){this.setState({theme:e,isDirty:!0}),this.notifyChange()}setCompositionName(e){this.setState({compositionName:e,isDirty:!0})}setConfigField(e,t){let n={...this.state.configuration,[e]:t};this.setState({configuration:n,isDirty:!0}),this.notifyChange()}setConfigNestedField(e,t,n){let r={...this.state.configuration[e]||{},[t]:n};this.setConfigField(e,r)}setConfiguration(e){this.setState({configuration:{...e},isDirty:!0}),this.notifyChange()}loadComposition(e,t,n){this.setState({compositionName:e,theme:t,configuration:{...n},isDirty:!1}),this.notifyChange()}resetToInitial(){this.setState({compositionName:this.config.compositionName||`Custom`,theme:this.config.composition?.theme||``,configuration:{...this.config.composition?.configuration||{}},isDirty:!1}),this.notifyChange()}setState(e){this.state={...this.state,...e},this.emit()}emit(){for(let e of this.listeners)e(this.state)}notifyChange(){this.config.onChange?.({theme:this.state.theme,configuration:this.state.configuration})}},tz=()=>`ce-layout`,nz=()=>`ce-left`,rz=()=>`ce-right`,iz=()=>`ce-name-row`,az=()=>`ce-name-label`,oz=()=>`ce-name-input`,sz=()=>`ce-section`,cz=()=>`ce-section-header`,lz=()=>`ce-section-chevron`,uz=()=>`ce-section-body`,dz=()=>`ce-field`,fz=()=>`ce-field-label`,pz=()=>`ce-field-control`,mz=()=>`ce-select`,hz=()=>`ce-text-input`,gz=()=>`ce-color-input`,_z=()=>`ce-toggle`,vz=()=>`ce-toggle-track`,yz=()=>`ce-preview`,bz=()=>`ce-preview-header`,xz=()=>`ce-preview-body`,Sz=()=>`ce-preview-matchup`,Cz=()=>`ce-subgroup`,wz=()=>`ce-subgroup-title`;function Tz(e,t){let n=document.createElement(`div`);n.className=sz();let r=document.createElement(`div`);r.className=cz();let i=document.createElement(`span`);i.className=lz();let a=document.createElement(`span`);a.textContent=e.label,r.appendChild(i),r.appendChild(a),r.addEventListener(`click`,()=>t.toggleSection(e.id));let o=document.createElement(`div`);o.className=uz();let s=e.factory(t);o.appendChild(s.element),n.appendChild(r),n.appendChild(o);function c(t){let n=t.expandedSections.has(e.id);i.textContent=n?`▼`:`▶`,o.style.display=n?`block`:`none`,n&&s.update(t)}return{element:n,update:c}}function Ez(e,t,n,r=!1){let i=document.createElement(`div`);i.className=dz();let a=document.createElement(`span`);a.className=fz(),a.textContent=e,i.appendChild(a);let o=document.createElement(`label`);o.className=_z();let s=document.createElement(`input`);s.type=`checkbox`,s.checked=t,s.disabled=r,s.addEventListener(`change`,()=>n(s.checked));let c=document.createElement(`span`);c.className=vz(),o.appendChild(s),o.appendChild(c);let l=document.createElement(`div`);return l.className=pz(),l.appendChild(o),i.appendChild(l),{element:i,setChecked:e=>{s.checked=e},setDisabled:e=>{s.disabled=e}}}function Dz(e,t,n,r,i=!1){let a=document.createElement(`div`);a.className=dz();let o=document.createElement(`span`);o.className=fz(),o.textContent=e,a.appendChild(o);let s=document.createElement(`select`);s.className=mz(),s.disabled=i;for(let e of t){let t=document.createElement(`option`);t.value=e.value,t.textContent=e.label,e.value===n&&(t.selected=!0),s.appendChild(t)}s.addEventListener(`change`,()=>r(s.value));let c=document.createElement(`div`);return c.className=pz(),c.appendChild(s),a.appendChild(c),{element:a,setValue:e=>{s.value=e}}}function Oz(e,t,n,r=``,i=!1){let a=document.createElement(`div`);a.className=dz();let o=document.createElement(`span`);o.className=fz(),o.textContent=e,a.appendChild(o);let s=document.createElement(`input`);s.type=`text`,s.className=hz(),s.value=t,s.placeholder=r,s.disabled=i,s.addEventListener(`input`,()=>n(s.value));let c=document.createElement(`div`);return c.className=pz(),c.appendChild(s),a.appendChild(c),{element:a,setValue:e=>{s.value=e}}}function kz(e,t,n,r=!1){let i=document.createElement(`div`);i.className=dz();let a=document.createElement(`span`);a.className=fz(),a.textContent=e,i.appendChild(a);let o=document.createElement(`input`);o.type=`color`,o.className=gz(),o.value=t||`#000000`,o.disabled=r,o.addEventListener(`input`,()=>n(o.value));let s=document.createElement(`div`);return s.className=pz(),s.appendChild(o),i.appendChild(s),{element:i,setValue:e=>{o.value=e||`#000000`}}}var Az=[],jz=new Set;for(let[,e]of Object.entries(ri))if(!jz.has(e.theme)){jz.add(e.theme);let t=e.theme.replace(`chc-theme-`,``).replace(/-/g,` `).replace(/\b\w/g,e=>e.toUpperCase());Az.push({value:e.theme,label:t})}function Mz(e){let t=document.createElement(`div`),n=Dz(`Load preset`,[{value:``,label:`— Load preset —`},...Object.keys(ri).map(e=>({value:e,label:e}))],``,t=>{if(!t)return;let r=ri[t];r&&e.loadComposition(t,r.theme,r.configuration||{}),n.setValue(``)},e.getState().readOnly);t.appendChild(n.element);let r=document.createElement(`div`);r.style.cssText=`font-size:0.7rem; color:var(--chc-text-secondary, #999); padding:0 0 0.3rem; line-height:1.3;`,r.textContent=`Replaces all settings with a built-in composition.`,t.appendChild(r);let i=Dz(`Color theme`,Az,e.getState().theme,t=>e.setTheme(t),e.getState().readOnly);t.appendChild(i.element);let a=document.createElement(`div`);a.style.cssText=`font-size:0.7rem; color:var(--chc-text-secondary, #999); padding:0 0 0.3rem; line-height:1.3;`,a.textContent=`Changes only the color scheme, not the display settings.`,t.appendChild(a);function o(e){i.setValue(e.theme)}return{element:t,update:o}}function Nz(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=Ez(`Nationality flags`,!!r.flags,t=>e.setConfigField(`flags`,t),n),a=Dz(`Seeding style`,[{value:``,label:`None`},{value:`true`,label:`Parentheses`},{value:`square`,label:`Square brackets`}],r.bracketedSeeds===`square`?`square`:r.bracketedSeeds?`true`:``,t=>{t===`square`?e.setConfigField(`bracketedSeeds`,`square`):t===`true`?e.setConfigField(`bracketedSeeds`,!0):e.setConfigField(`bracketedSeeds`,void 0)},n),o=Dz(`Seed element`,[{value:``,label:`Default`},{value:`sup`,label:`Superscript`},{value:`span`,label:`Inline`}],r.seedingElement||``,t=>e.setConfigField(`seedingElement`,t||void 0),n),s=Ez(`Draw positions (1st round)`,!!r.drawPositions,t=>e.setConfigField(`drawPositions`,t),n),c=Ez(`Draw positions (all rounds)`,!!r.allDrawPositions,t=>e.setConfigField(`allDrawPositions`,t),n),l=Ez(`Team logo`,r.teamLogo!==!1,t=>e.setConfigField(`teamLogo`,t),n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element),t.appendChild(s.element),t.appendChild(c.element),t.appendChild(l.element);function u(e){let t=e.configuration;i.setChecked(!!t.flags),a.setValue(t.bracketedSeeds===`square`?`square`:t.bracketedSeeds?`true`:``),o.setValue(t.seedingElement||``),s.setChecked(!!t.drawPositions),c.setChecked(!!t.allDrawPositions),l.setChecked(t.teamLogo!==!1)}return{element:t,update:u}}function Pz(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=Ez(`Score box`,!!r.scoreBox,t=>e.setConfigField(`scoreBox`,t),n),a=Ez(`Game score only`,!!r.gameScoreOnly,t=>e.setConfigField(`gameScoreOnly`,t),n);t.appendChild(i.element),t.appendChild(a.element);let o=document.createElement(`div`);o.className=Cz();let s=document.createElement(`div`);s.className=wz(),s.textContent=`Game Score Display`,o.appendChild(s);let c=Dz(`Position`,[{value:``,label:`Default`},{value:`leading`,label:`Leading`},{value:`trailing`,label:`Trailing`}],r.gameScore?.position||``,t=>e.setConfigNestedField(`gameScore`,`position`,t||void 0),n),l=Ez(`Inverted`,!!r.gameScore?.inverted,t=>e.setConfigNestedField(`gameScore`,`inverted`,t),n);o.appendChild(c.element),o.appendChild(l.element),t.appendChild(o);function u(e){let t=e.configuration;i.setChecked(!!t.scoreBox),a.setChecked(!!t.gameScoreOnly),c.setValue(t.gameScore?.position||``),l.setChecked(!!t.gameScore?.inverted)}return{element:t,update:u}}function Fz(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=Ez(`Gender color`,!!r.genderColor,t=>e.setConfigField(`genderColor`,t),n),a=Ez(`Winner color`,!!r.winnerColor,t=>e.setConfigField(`winnerColor`,t),n),o=Dz(`Detail`,[{value:``,label:`Default`},{value:`TEAM`,label:`Team`},{value:`ADDRESS`,label:`Address`}],r.participantDetail||``,t=>{e.setConfigField(`participantDetail`,t||void 0),e.setConfigField(`showAddress`,t===`ADDRESS`)},n),s=Oz(`Position color`,r.drawPositionColor||``,t=>e.setConfigField(`drawPositionColor`,t||void 0),`#999`,n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element),t.appendChild(s.element);function c(e){let t=e.configuration;i.setChecked(!!t.genderColor),a.setChecked(!!t.winnerColor),o.setValue(t.participantDetail||``),s.setValue(t.drawPositionColor||``)}return{element:t,update:c}}function Iz(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=Oz(`TBD text`,r.placeHolders?.tbd||``,t=>e.setConfigNestedField(`placeHolders`,`tbd`,t||void 0),`TBD`,n),a=Oz(`Bye text`,r.placeHolders?.bye||``,t=>e.setConfigNestedField(`placeHolders`,`bye`,t||void 0),`Bye`,n),o=Oz(`Qualifier text`,r.placeHolders?.qualifier||``,t=>e.setConfigNestedField(`placeHolders`,`qualifier`,t||void 0),`Qualifier`,n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element);function s(e){let t=e.configuration;i.setValue(t.placeHolders?.tbd||``),a.setValue(t.placeHolders?.bye||``),o.setValue(t.placeHolders?.qualifier||``)}return{element:t,update:s}}var Lz=[{scaleName:`WTN`,accessor:`wtnRating`,label:`WTN`},{scaleName:`UTR`,accessor:`utrRating`,label:`UTR`},{scaleName:`NTRP`,accessor:`ntrpRating`,label:`NTRP`},{scaleName:`ELO`,accessor:`eloRating`,label:`ELO`}];function Rz(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration.scaleAttributes||{},i=Dz(`Scale type`,[{value:``,label:`None`},{value:`RATING`,label:`Rating`},{value:`RANKING`,label:`Ranking`},{value:`SEEDING`,label:`Seeding`}],r.scaleType||``,t=>e.setConfigNestedField(`scaleAttributes`,`scaleType`,t||void 0),n),a=Dz(`Scale name`,[{value:``,label:`None`},...Lz.map(e=>({value:e.scaleName,label:e.label}))],r.scaleName||``,t=>{e.setConfigNestedField(`scaleAttributes`,`scaleName`,t||void 0);let n=Lz.find(e=>e.scaleName===t);e.setConfigNestedField(`scaleAttributes`,`accessor`,n?.accessor||void 0)},n),o=kz(`Color`,r.scaleColor||`#ff0000`,t=>e.setConfigNestedField(`scaleAttributes`,`scaleColor`,t),n),s=Dz(`Event type`,[{value:``,label:`Any`},{value:`SINGLES`,label:`Singles`},{value:`DOUBLES`,label:`Doubles`}],r.eventType||``,t=>e.setConfigNestedField(`scaleAttributes`,`eventType`,t||void 0),n),c=Ez(`Fallback`,!!r.fallback,t=>e.setConfigNestedField(`scaleAttributes`,`fallback`,t),n),l=Ez(`Right of name`,r.scalePosition===`right`,t=>e.setConfigNestedField(`scaleAttributes`,`scalePosition`,t?`right`:`left`),n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element),t.appendChild(s.element),t.appendChild(c.element),t.appendChild(l.element);function u(e){let t=e.configuration.scaleAttributes||{},n=!!e.configuration.flags;i.setValue(t.scaleType||``),a.setValue(t.scaleName||``),o.setValue(t.scaleColor||`#ff0000`),s.setValue(t.eventType||``),c.setChecked(!!t.fallback),n?(l.setChecked(!0),l.setDisabled(!0)):(l.setChecked(t.scalePosition===`right`),l.setDisabled(!1))}return{element:t,update:u}}function zz(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=Ez(`Schedule info`,!!r.scheduleInfo,t=>e.setConfigField(`scheduleInfo`,t),n),a=Ez(`MatchUp footer`,!!r.matchUpFooter,t=>e.setConfigField(`matchUpFooter`,t),n),o=Ez(`Center info`,!!r.centerInfo,t=>e.setConfigField(`centerInfo`,t),n),s=Ez(`Set number`,!!r.resultsInfo,t=>e.setConfigField(`resultsInfo`,t),n),c=Ez(`Winner chevron`,!!r.winnerChevron,t=>e.setConfigField(`winnerChevron`,t),n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element),t.appendChild(s.element),t.appendChild(c.element);function l(e){let t=e.configuration;i.setChecked(!!t.scheduleInfo),a.setChecked(!!t.matchUpFooter),o.setChecked(!!t.centerInfo),s.setChecked(!!t.resultsInfo),c.setChecked(!!t.winnerChevron)}return{element:t,update:l}}var{DOUBLES:Bz,SINGLES:Vz}=t.eventConstants,{AD_HOC:Hz}=t.drawDefinitionConstants,{INDIVIDUAL:Uz}=t.participantConstants;function Wz({matchUpFormat:e=`SET5-S:6/TB7`,randomWinningSide:n=!0,qualifyingProfiles:r,participantsCount:i,completionGoal:a,drawSize:o=4,eventType:s,outcomes:c,drawType:l,withRatings:u,withAllRatings:d}={}){let f=a<100?Math.floor(o*.01*a):void 0,p=`venueId`,m=[{venueName:`Challenge Courts`,venueAbbreviation:`CC`,startTime:`08:00`,endTime:`20:00`,venueId:p,courtNames:[1,2,3,4,5,6,7,8],courtIds:[`c1`,`c2`,`c3`,`c4`],courtsCount:8}],h={eventType:s===Bz?Bz:Vz,completionGoal:f,qualifyingProfiles:r,participantsCount:i,seedsCount:8,matchUpFormat:e,drawSize:o,drawType:l,outcomes:c};l===Hz&&Object.assign(h,{drawMatic:!0,roundsCount:3});let{tournamentRecord:g}=t.mocksEngine.generateTournamentRecord({drawProfiles:[h],completeAllMatchUps:!0,randomWinningSide:n,venueProfiles:m});t.tournamentEngine.setState(g),t.tournamentEngine.createTeamsFromParticipantAttributes({personAttribute:`nationalityCode`,addParticipants:!0});let _=d||(u?[{...u,accessor:u.scaleName}]:[]);if(_.length>0){let{participants:e}=t.tournamentEngine.getParticipants({participantFilters:{participantTypes:[Uz]}});for(let n of _)e.forEach(e=>{let r=+(10+Math.random()*6).toFixed(2);t.tournamentEngine.setParticipantScaleItem({participantId:e.participantId,scaleItem:{scaleValue:{[n.accessor]:r},scaleName:n.scaleName,scaleType:n.scaleType||`RATING`,eventType:n.eventType||Vz}})})}let{matchUps:v}=t.tournamentEngine.allTournamentMatchUps({participantsProfile:{withGroupings:!0}}),y=v.map(({matchUpId:e})=>e),b={startTime:`08:00`,endTime:`10:00`,scheduledTime:`07:00`,scheduledDate:`2021-01-01`,courtId:`c1`,venueId:p};t.tournamentEngine.bulkScheduleMatchUps({matchUpIds:y,schedule:b});let{matchUps:x}=t.tournamentEngine.allTournamentMatchUps({participantsProfile:{withISO2:!0,withIOC:!0,withScaleValues:!!(u||d)}});return{matchUps:x}}var Gz=null;function Kz(){if(!Gz){let{matchUps:e}=Wz({drawSize:8,eventType:`SINGLES`,randomWinningSide:!0,matchUpFormat:`SET3-S:6/TB7`,withAllRatings:Lz.map(e=>({scaleName:e.scaleName,accessor:e.accessor}))}),t=e.filter(e=>e.roundNumber===1).slice(0,2),n=t[0]?.sides?.[0]?.participant,r=t[0]?.sides?.[1]?.participant,i={matchUpId:`preview-in-progress`,matchUpType:`SINGLES`,matchUpStatus:`IN_PROGRESS`,roundNumber:1,sides:[{sideNumber:1,drawPosition:5,seedNumber:3,seedValue:`3`,participant:n},{sideNumber:2,drawPosition:6,seedNumber:6,seedValue:`6`,participant:r}],score:{scoreStringSide1:`6-4 3-2`,scoreStringSide2:`4-6 2-3`,sets:[{setNumber:1,side1Score:6,side2Score:4,winningSide:1},{setNumber:2,side1Score:3,side2Score:2,side1PointScore:`30`,side2PointScore:`15`}]}},a={matchUpId:`preview-bye`,matchUpType:`SINGLES`,matchUpStatus:`BYE`,roundNumber:1,sides:[{sideNumber:1,drawPosition:7,seedNumber:2,seedValue:`2`,participant:n},{sideNumber:2,drawPosition:8,bye:!0}]},o={matchUpId:`preview-tbd`,matchUpType:`SINGLES`,matchUpStatus:`TO_BE_PLAYED`,roundNumber:1,sides:[{sideNumber:1,drawPosition:9,seedNumber:3,seedValue:`3`,participant:n},{sideNumber:2,drawPosition:10}]},s={matchUpId:`preview-qualifier`,matchUpType:`SINGLES`,matchUpStatus:`TO_BE_PLAYED`,roundNumber:1,sides:[{sideNumber:1,drawPosition:11,qualifier:!0},{sideNumber:2,drawPosition:12,seedNumber:4,seedValue:`4`,participant:n}]};Gz=[...t,i,a,o,s]}return Gz}function qz(){let e=document.createElement(`div`);e.className=yz();let t=document.createElement(`div`);t.className=bz(),t.textContent=`Preview`,e.appendChild(t);let n=document.createElement(`div`);n.className=xz(),e.appendChild(n);let r=``,i=``;function a(e){let t=JSON.stringify(e.configuration);if(e.theme===r&&t===i)return;r=e.theme,i=t,n.innerHTML=``;let a={theme:e.theme,configuration:{...e.configuration}},o=Kz();for(let e of o){let t=document.createElement(`div`);t.className=Sz();let r=Wr({matchUp:e,composition:a,isLucky:!0});t.appendChild(r),n.appendChild(t)}}return{element:e,update:a}}var Jz=[{id:`theme`,label:`Theme & Preset`,factory:Mz},{id:`display`,label:`Display`,factory:Nz},{id:`score`,label:`Score`,factory:Pz},{id:`participant`,label:`Participant`,factory:Fz},{id:`placeholder`,label:`Placeholders`,factory:Iz},{id:`scale`,label:`Scale Attributes`,factory:Rz},{id:`layout`,label:`Layout & Info`,factory:zz}];function Yz(e,t){let n=new ez(t),r=document.createElement(`div`);r.className=tz();let i=document.createElement(`div`);i.className=nz();let a=document.createElement(`div`);a.className=iz();let o=document.createElement(`span`);o.className=az(),o.textContent=`Name`;let s=document.createElement(`input`);s.type=`text`,s.className=oz(),s.value=n.getState().compositionName,s.disabled=n.getState().readOnly,s.addEventListener(`input`,()=>n.setCompositionName(s.value)),a.appendChild(o),a.appendChild(s),i.appendChild(a);let c=Jz.map(e=>{let t=Tz(e,n);return i.appendChild(t.element),t}),l=document.createElement(`div`);l.className=rz();let u=qz();l.appendChild(u.element),r.appendChild(i),r.appendChild(l),e.appendChild(r);let d=n.subscribe(e=>{s.value=e.compositionName;for(let t of c)t.update(e);u.update(e)}),f=n.getState();for(let e of c)e.update(f);return u.update(f),{destroy:()=>{d(),e.contains(r)&&e.removeChild(r)},getComposition:()=>{let e=n.getState(),{participantProvider:t,persistInputFields:r,inlineAssignment:i,...a}=e.configuration;return{compositionName:e.compositionName,theme:e.theme,configuration:a,version:1}}}}var Xz=[`grand-slam`,`itf`,`minimal`,`none`],Zz=[`standard`,`seedings`,`officials`,`none`],Qz=[`a4`,`letter`],$z=[`auto`,`portrait`,`landscape`],eB={page:{pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}},header:{layout:`itf`,tournamentName:``},footer:{layout:`standard`,showTimestamp:!0,showPageNumbers:!0},content:{}};function tB(e,t){let n=mB(eB,t.config??{}),r=!!t.readOnly,i=Z(`div`,`pce-root`),a=Z(`div`,`pce-form`),o=Z(`div`,`pce-aside`);i.appendChild(a),i.appendChild(o);let s=null;function c(){a.innerHTML=``,a.appendChild(nB(n,r,l)),a.appendChild(rB(n,r,l)),a.appendChild(iB(n,r,l)),a.appendChild(aB(n,r,t.printType,l)),!r&&t.onSave&&a.appendChild(oB(()=>t.onSave?.(hB(n)))),o.innerHTML=``;let e=Z(`div`,`pce-aside-title`);e.textContent=`Print Type`,o.appendChild(e);let i=Z(`span`,`pce-print-type-pill`);i.textContent=t.printType,o.appendChild(i);let c=Z(`div`,`pce-aside-title`);c.textContent=`Resolved Config`,c.style.marginTop=`8px`,o.appendChild(c),s=Z(`div`,`pce-preview-stub`),s.textContent=JSON.stringify(n,null,2),o.appendChild(s);let u=Z(`div`,`pce-preview-note`);u.textContent=`Live PDF preview not yet wired — see admin-client integration.`,o.appendChild(u)}function l(){s&&(s.textContent=JSON.stringify(n,null,2)),t.onChange?.(hB(n))}return c(),e.appendChild(i),{destroy:()=>{i.parentNode&&i.parentNode.removeChild(i)},getConfig:()=>hB(n),setConfig:e=>{Object.assign(n,mB(eB,e)),c()}}}function nB(e,t,n){let{section:r,body:i}=dB(`Page`);i.appendChild(sB(`Size`,Qz,e.page?.pageSize??`a4`,t,t=>{pB(e,`page`).pageSize=t,n()})),i.appendChild(sB(`Orientation`,$z,e.page?.orientation??`auto`,t,t=>{pB(e,`page`).orientation=t,n()}));let a=Z(`div`,`pce-field pce-field-full`);a.appendChild(fB(`Margins (mm)`));let o=Z(`div`);return o.style.display=`grid`,o.style.gridTemplateColumns=`repeat(4, 1fr)`,o.style.gap=`6px`,[`top`,`right`,`bottom`,`left`].forEach(r=>{o.appendChild(lB(r,e.page?.margins?.[r]??10,t,t=>{let i=pB(pB(e,`page`),`margins`);i[r]=t,n()}))}),a.appendChild(o),i.appendChild(a),r}function rB(e,t,n){let{section:r,body:i}=dB(`Header`);return i.appendChild(sB(`Layout`,Xz,e.header?.layout??`itf`,t,t=>{pB(e,`header`).layout=t,n()})),i.appendChild(cB(`Tournament name`,e.header?.tournamentName??``,t,t=>{pB(e,`header`).tournamentName=t,n()})),i.appendChild(cB(`Subtitle`,e.header?.subtitle??``,t,t=>{pB(e,`header`).subtitle=t||void 0,n()})),r}function iB(e,t,n){let{section:r,body:i}=dB(`Footer`);return i.appendChild(sB(`Layout`,Zz,e.footer?.layout??`standard`,t,t=>{pB(e,`footer`).layout=t,n()})),i.appendChild(uB(`Show timestamp`,e.footer?.showTimestamp??!0,t,t=>{pB(e,`footer`).showTimestamp=t,n()})),i.appendChild(uB(`Show page numbers`,e.footer?.showPageNumbers??!0,t,t=>{pB(e,`footer`).showPageNumbers=t,n()})),r}function aB(e,t,n,r){let{section:i,body:a}=dB(`Content — ${n}`);if(n===`draw`){let n=pB(pB(e,`content`),`draw`);a.appendChild(uB(`Include seedings`,!!n.includeSeedings,t,e=>{n.includeSeedings=e,r()})),a.appendChild(uB(`Include scores`,!!n.includeScores,t,e=>{n.includeScores=e,r()})),a.appendChild(uB(`Show byes`,!!n.showByes,t,e=>{n.showByes=e,r()})),a.appendChild(uB(`Show draw positions`,!!n.showDrawPositions,t,e=>{n.showDrawPositions=e,r()}))}else if(n===`schedule`){let n=pB(pB(e,`content`),`schedule`);a.appendChild(sB(`Cell style`,[`detailed`,`compact`],n.cellStyle??`detailed`,t,e=>{n.cellStyle=e,r()})),a.appendChild(uB(`Show match numbers`,!!n.showMatchNumbers,t,e=>{n.showMatchNumbers=e,r()})),a.appendChild(cB(`Alert banner`,n.alertBanner??``,t,e=>{n.alertBanner=e||void 0,r()}))}else{let e=Z(`div`,`pce-field pce-field-full`),t=Z(`div`,`pce-preview-note`);t.textContent=`Content options for "${n}" not yet implemented.`,e.appendChild(t),a.appendChild(e)}return i}function oB(e){let t=Z(`div`,`pce-actions`),n=Z(`button`,`pce-button pce-button-primary`);return n.type=`button`,n.textContent=`Save`,n.addEventListener(`click`,e),t.appendChild(n),t}function sB(e,t,n,r,i){let a=Z(`div`,`pce-field`);a.appendChild(fB(e));let o=Z(`select`,`pce-select`);return o.disabled=r,t.forEach(e=>{let t=document.createElement(`option`);t.value=e,t.textContent=e,e===n&&(t.selected=!0),o.appendChild(t)}),o.addEventListener(`change`,()=>i(o.value)),a.appendChild(o),a}function cB(e,t,n,r){let i=Z(`div`,`pce-field`);i.appendChild(fB(e));let a=Z(`input`,`pce-input`);return a.type=`text`,a.value=t,a.disabled=n,a.addEventListener(`input`,()=>r(a.value)),i.appendChild(a),i}function lB(e,t,n,r){let i=Z(`div`,`pce-field`);i.appendChild(fB(e));let a=Z(`input`,`pce-input`);return a.type=`number`,a.value=String(t),a.disabled=n,a.addEventListener(`input`,()=>{let e=parseFloat(a.value);Number.isNaN(e)||r(e)}),i.appendChild(a),i}function uB(e,t,n,r){let i=Z(`div`,`pce-field pce-checkbox-row pce-field-full`),a=Z(`input`);a.type=`checkbox`,a.checked=t,a.disabled=n,a.addEventListener(`change`,()=>r(a.checked)),i.appendChild(a);let o=fB(e);return o.style.fontSize=`13px`,o.style.color=`var(--chc-text-primary, #222)`,i.appendChild(o),i}function dB(e){let t=Z(`div`,`pce-section`),n=Z(`div`,`pce-section-header`);n.textContent=e;let r=Z(`div`,`pce-section-body`);return t.appendChild(n),t.appendChild(r),{section:t,body:r}}function Z(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function fB(e){let t=Z(`label`,`pce-field-label`);return t.textContent=e,t}function pB(e,t){return(e[t]===void 0||e[t]===null)&&(e[t]={}),e[t]}function mB(e,t){return{name:t.name??e.name,page:{...e.page,...t.page,margins:{...e.page?.margins,...t.page?.margins}},header:{...e.header,...t.header},footer:{...e.footer,...t.footer},content:{...e.content,...t.content}}}function hB(e){return JSON.parse(JSON.stringify(e))}var gB=`chc-scorecard-side-score--winner`;function _B({matchUp:e,composition:t,eventHandlers:n,swapSides:r}){let i=document.createElement(`div`);i.className=`chc-scorecard`;let a=r?2:1,o=r?1:2,s=EB(e,a)||``,c=EB(e,o)||``,l=r?CB(e.winningSide):e.winningSide,u=vB({side1Name:s,side2Name:c,sets:r?wB(e.score?.sets):e.score?.sets,winningSide:l,side1Id:`chc-sc-side1`,side2Id:`chc-sc-side2`});i.appendChild(u);let d=e.tieFormat?.collectionDefinitions?.slice().sort((e,t)=>(e.collectionOrder||0)-(t.collectionOrder||0))||[];for(let a of d){let o=SB({collectionDefinition:a,collectionMatchUps:(e.tieMatchUps||[]).filter(e=>e.collectionId===a.collectionId).sort((e,t)=>(e.collectionPosition||0)-(t.collectionPosition||0)),composition:t,eventHandlers:n,swapSides:r});i.appendChild(o)}return i}function vB({side1Name:e,side2Name:t,sets:n,winningSide:r,side1Id:i,side2Id:a}){let o=document.createElement(`div`);o.className=`chc-scorecard-header`;let s=document.createElement(`div`);s.className=`chc-scorecard-header-body`;let c=bB(e,`end`),l=bB(t,`start`),u=xB(n,1,r,i),d=xB(n,2,r,a),f=document.createElement(`div`);f.className=`chc-scorecard-score-box`;let p=document.createElement(`div`);p.className=`chc-scorecard-score-flex`;let m=document.createElement(`div`);return m.className=`chc-scorecard-vs`,m.textContent=`vs`,p.appendChild(u),p.appendChild(m),p.appendChild(d),f.appendChild(p),s.appendChild(c),s.appendChild(f),s.appendChild(l),o.appendChild(s),o}function yB(e,t=`chc-sc-side1`,n=`chc-sc-side2`,r){let i=e?.score?.sets?.[0];if(!i)return;let a=document.getElementById(t),o=document.getElementById(n);if(!a||!o)return;a.classList.remove(gB),o.classList.remove(gB);let s=r?`side2Score`:`side1Score`,c=r?`side1Score`:`side2Score`;a.textContent=String(i[s]??0),o.textContent=String(i[c]??0);let l=r?CB(e.winningSide):e.winningSide;l===1&&a.classList.add(gB),l===2&&o.classList.add(gB)}function bB(e,t){let n=document.createElement(`div`);n.className=`chc-scorecard-side chc-scorecard-side--${t}`;let r=document.createElement(`div`);return r.className=`chc-scorecard-side-name`,r.textContent=e,n.appendChild(r),n}function xB(e,t,n,r){let i=e?.[0]?.[`side${t}Score`]??0,a=document.createElement(`span`);return a.className=`chc-scorecard-side-score`,r&&(a.id=r),t===1?a.style.paddingLeft=`1rem`:a.style.paddingRight=`1rem`,t===n&&a.classList.add(gB),a.textContent=String(i),a}function SB({collectionDefinition:e,collectionMatchUps:t,composition:n,eventHandlers:r,swapSides:i}){let a=document.createElement(`div`);a.className=`chc-scorecard-panel`;let o=document.createElement(`div`);o.className=`chc-scorecard-panel-header`;let s=document.createElement(`div`);s.className=`chc-scorecard-panel-name`,s.textContent=e.collectionName||`Collection`;let c=document.createElement(`div`);c.className=`chc-scorecard-panel-meta`;let l=(e.matchUpType||``).toUpperCase(),u=document.createElement(`span`);u.className=`chc-scorecard-type-badge chc-scorecard-type-badge--${l===`DOUBLES`?`doubles`:`singles`}`,u.textContent=l===`DOUBLES`?`D`:`S`;let d=document.createElement(`span`);d.className=`chc-scorecard-count-badge`,d.textContent=String(t.length),c.appendChild(u),c.appendChild(d),o.appendChild(s),o.appendChild(c),a.appendChild(o);let f=document.createElement(`div`);f.className=`chc-scorecard-grid`;for(let e of t){let t=Wr({matchUp:i?TB(e):e,isLucky:!0,eventHandlers:r,composition:n});t.classList.add(`chc-scorecard-card`),f.appendChild(t)}return a.appendChild(f),a}function CB(e){if(e===1)return 2;if(e===2)return 1}function wB(e){if(e)return e.map(e=>({...e,side1Score:e.side2Score,side2Score:e.side1Score,side1TiebreakScore:e.side2TiebreakScore,side2TiebreakScore:e.side1TiebreakScore}))}function TB(e){let t=e.sides?.map(e=>({...e,sideNumber:e.sideNumber===1?2:1}));return{...e,sides:t,score:e.score?{...e.score,sets:wB(e.score.sets)}:e.score,winningSide:CB(e.winningSide)}}function EB(e,t){return e.sides?.find(e=>e.sideNumber===t)?.participant?.participantName}function DB(e){let{matchUpId:t,manager:n,baseMatchUp:r,onUpdate:i,showSituation:a}=e,o=document.createElement(`div`);o.className=`chc-inline-scoring-footer`;let s=document.createElement(`div`);s.className=`chc-inline-scoring-buttons`;let c=(e,t)=>{let n=document.createElement(`button`);return n.textContent=e,n.className=`chc-inline-scoring-btn ${t}`,n},l=c(`Undo`,`chc-is-undo`),u=c(`Redo`,`chc-is-redo`),d=c(`Clear`,`chc-is-clear`),f=c(`Submit`,`chc-is-submit`),p;a&&(p=document.createElement(`span`),p.className=`chc-inline-scoring-situation`),l.onclick=e=>{e.stopPropagation();let a=n.undo(t,r);a&&(i(a),m())},u.onclick=e=>{e.stopPropagation();let a=n.redo(t,r);a&&(i(a),m())},d.onclick=e=>{e.stopPropagation();let a=n.reset(t,r);a&&(i(a),m())},f.onclick=e=>{e.stopPropagation();let i=n.get(t);if(i){let e=n.getMatchUp(t,r);n.callbacks?.onSubmit?.({matchUpId:t,matchUp:e,engine:i.engine})}},s.append(l,u,d,f),o.appendChild(s),p&&o.appendChild(p);function m(){let e=n.canUndo(t),r=n.canRedo(t),i=n.isComplete(t);if(l.disabled=!e,u.disabled=!r,d.disabled=!e&&!r,p){let e=n.getSituation(t);if(e&&!i){let t=[e.isTiebreak&&`TB`,e.isBreakPoint&&`Break`,e.isGamePoint&&`Game`,e.isSetPoint&&`Set`,e.isMatchPoint&&`Match`].filter(Boolean);p.textContent=t.length?t.join(` • `):``}else p.textContent=i?`Complete`:``}}return m(),{element:o,update:m}}var OB=`chc-iss-score-cell`;function kB(e){if(!e?.matchUpId)throw Error(`buildInteractiveScoringShell: matchUpId is required`);if(!e?.matchUpFormat)throw Error(`buildInteractiveScoringShell: matchUpFormat is required`);let t=e.initialMatchUp??AB(e),n=new Set,r=new Zo({onScoreChange:({matchUp:e})=>{a(e,!1)},onMatchComplete:({winningSide:n})=>{a(r.getMatchUp(e.matchUpId,t),!0,n)}});r.getOrCreate(e.matchUpId,e.matchUpFormat,t);let i=document.createElement(`div`);i.className=`chc-interactive-scoring-shell`,i.dataset.matchupId=e.matchUpId,i.dataset.tournamentId=e.tournamentId,l();function a(t,r,i){let a={matchUpId:e.matchUpId,matchUp:t,isComplete:r,winningSide:i??t.winningSide},o=new CustomEvent(`stateChanged`,{detail:a});n.forEach(e=>{try{e(o)}catch(e){console.warn(`[interactive-scoring] listener threw`,e)}})}function o(n){r.isComplete(e.matchUpId)||(r.addPoint(e.matchUpId,n,t),l())}function s(){r.canUndo(e.matchUpId)&&(r.undo(e.matchUpId,t),l(),a(r.getMatchUp(e.matchUpId,t),r.isComplete(e.matchUpId)))}function c(){FB()&&(r.reset(e.matchUpId,t),l(),a(r.getMatchUp(e.matchUpId,t),!1))}function l(){i.innerHTML=``,i.append(jB(e),MB(r,e,t),NB(r,e,o),PB(r,e,s,c))}return{element:i,getState:()=>r.getMatchUp(e.matchUpId,t),reset:()=>{r.reset(e.matchUpId,t),l(),a(r.getMatchUp(e.matchUpId,t),!1)},destroy:()=>{n.clear(),r.remove(e.matchUpId),i.innerHTML=``},addEventListener:(e,t)=>{e===`stateChanged`&&n.add(t)},removeEventListener:(e,t)=>{e===`stateChanged`&&n.delete(t)}}}function AB(e){return{matchUpId:e.matchUpId,tournamentId:e.tournamentId,matchUpFormat:e.matchUpFormat,matchUpStatus:`TO_BE_PLAYED`,score:{sets:[]},sides:[{sideNumber:1,participant:{participantName:e.side1Name}},{sideNumber:2,participant:{participantName:e.side2Name}}]}}function jB(e){let t=document.createElement(`div`);t.className=`chc-iss-header`;let n=document.createElement(`div`);n.className=`chc-iss-header-side chc-iss-header-side1`,n.textContent=e.side1Name||`Side 1`;let r=document.createElement(`div`);r.className=`chc-iss-header-vs`,r.textContent=`vs`;let i=document.createElement(`div`);return i.className=`chc-iss-header-side chc-iss-header-side2`,i.textContent=e.side2Name||`Side 2`,t.append(n,r,i),t}function MB(e,t,n){let r=document.createElement(`div`);r.className=`chc-iss-score-display`;let i=e.getMatchUp(t.matchUpId,n),a=i.score?.sets??[],o=document.createElement(`div`);o.className=`chc-iss-score-grid`,o.style.setProperty(`--sets`,String(Math.max(a.length,1)));let s=document.createElement(`div`);s.className=`chc-iss-score-row chc-iss-score-row-side1`;let c=document.createElement(`div`);c.className=`chc-iss-score-row chc-iss-score-row-side2`;for(let e of a){let t=document.createElement(`div`);t.className=OB,t.textContent=String(e.side1Score??0),e.winningSide===1&&t.classList.add(`chc-iss-score-cell-won`),s.append(t);let n=document.createElement(`div`);n.className=OB,n.textContent=String(e.side2Score??0),e.winningSide===2&&n.classList.add(`chc-iss-score-cell-won`),c.append(n)}if(a.length===0){let e=document.createElement(`div`);e.className=OB,e.textContent=`0`,s.append(e);let t=document.createElement(`div`);t.className=OB,t.textContent=`0`,c.append(t)}o.append(s,c),r.append(o);let l=a.at(-1);if(l&&!l.winningSide&&l.side1PointScore!=null){let e=document.createElement(`div`);e.className=`chc-iss-game-score`;let t=document.createElement(`span`);t.className=`chc-iss-game-score-side1`,t.textContent=String(l.side1PointScore);let n=document.createElement(`span`);n.className=`chc-iss-game-score-sep`,n.textContent=` — `;let i=document.createElement(`span`);i.className=`chc-iss-game-score-side2`,i.textContent=String(l.side2PointScore),e.append(t,n,i),r.append(e)}if(e.isComplete(t.matchUpId)){let e=document.createElement(`div`);e.className=`chc-iss-match-complete`,e.textContent=`${(i.winningSide===1?t.side1Name:t.side2Name)||`Match`} wins`,r.append(e)}return r}function NB(e,t,n){let r=document.createElement(`div`);r.className=`chc-iss-point-buttons`;let i=e.isComplete(t.matchUpId),a=document.createElement(`button`);a.type=`button`,a.className=`chc-iss-point-button chc-iss-point-button-side1`,a.disabled=i,a.setAttribute(`aria-label`,`${t.side1Name} won the point`);let o=document.createElement(`span`);o.className=`chc-iss-point-button-label`,o.textContent=t.side1Name||`Side 1`;let s=document.createElement(`span`);s.className=`chc-iss-point-button-hint`,s.textContent=`won the point`,a.append(o,s),a.addEventListener(`click`,()=>n(0));let c=document.createElement(`button`);c.type=`button`,c.className=`chc-iss-point-button chc-iss-point-button-side2`,c.disabled=i,c.setAttribute(`aria-label`,`${t.side2Name} won the point`);let l=document.createElement(`span`);l.className=`chc-iss-point-button-label`,l.textContent=t.side2Name||`Side 2`;let u=document.createElement(`span`);return u.className=`chc-iss-point-button-hint`,u.textContent=`won the point`,c.append(l,u),c.addEventListener(`click`,()=>n(1)),r.append(a,c),r}function PB(e,t,n,r){let i=document.createElement(`div`);i.className=`chc-iss-control-bar`;let a=document.createElement(`button`);a.type=`button`,a.className=`chc-iss-control-button chc-iss-control-undo`,a.textContent=`Undo`,a.disabled=!e.canUndo(t.matchUpId),a.addEventListener(`click`,n);let o=document.createElement(`button`);return o.type=`button`,o.className=`chc-iss-control-button chc-iss-control-reset`,o.textContent=`Reset`,o.addEventListener(`click`,r),i.append(a,o),i}function FB(){return typeof globalThis>`u`||typeof globalThis.confirm!=`function`?!1:globalThis.confirm(`Reset the scoring session? This will clear all points.`)}function IB(){return{policyName:`New Ranking Policy`,policyVersion:`1.0`,awardProfiles:[{profileName:`Default`,finishingPositionRanges:{1:100,2:70,4:50,8:30,16:15,32:8}}],requireWinForPoints:!0,doublesAttribution:`fullToEach`}}function Q(e){return structuredClone(e)}var LB=class{constructor(e){this.listeners=new Set,this.config=e;let t=Q(e.initialPolicy??IB()),n=t.awardProfiles?.length??0;this.state={draft:t,expandedSections:new Set(n>5?[`awardProfiles`]:[`metadata`,`awardProfiles`,`qualityWinProfiles`,`aggregationRules`]),expandedProfiles:new Set(n<=5?Array.from({length:n},(e,t)=>t):[]),profileFilter:``,dirty:!1,readonly:e.readonly??!1}}getState(){return this.state}getData(){return Q(this.state.draft)}setData(e){let t=e.awardProfiles?.length??0;this.state={...this.state,draft:Q(e),expandedProfiles:new Set(t<=5?Array.from({length:t},(e,t)=>t):[]),profileFilter:``,dirty:!1},this.emit()}toggleSection(e){let t=new Set(this.state.expandedSections);t.has(e)?t.delete(e):t.add(e),this.state={...this.state,expandedSections:t},this.emit()}toggleProfile(e){let t=new Set(this.state.expandedProfiles);t.has(e)?t.delete(e):t.add(e),this.state={...this.state,expandedProfiles:t},this.emit()}setProfileFilter(e){this.state={...this.state,profileFilter:e},this.emit()}setPolicyName(e){let t=Q(this.state.draft);t.policyName=e,this.commitDraft(t)}setPolicyVersion(e){let t=Q(this.state.draft);t.policyVersion=e,this.commitDraft(t)}setValidDateRange(e,t){let n=Q(this.state.draft);n.validDateRange||={},n.validDateRange[e]=t||void 0,this.commitDraft(n)}setGlobalFlag(e,t){let n=Q(this.state.draft);n[e]=t,this.commitDraft(n)}setDoublesAttribution(e){let t=Q(this.state.draft);t.doublesAttribution=e||void 0,this.commitDraft(t)}setCategoryResolution(e){let t=Q(this.state.draft);t.categoryResolution=e||void 0,this.commitDraft(t)}addProfile(){let e=Q(this.state.draft);e.awardProfiles||=[],e.awardProfiles.push({profileName:`Profile ${e.awardProfiles.length+1}`,finishingPositionRanges:{1:100,2:70,4:50,8:30}});let t=new Set(this.state.expandedProfiles);t.add(e.awardProfiles.length-1),this.state={...this.state,expandedProfiles:t},this.commitDraft(e)}removeProfile(e){let t=Q(this.state.draft);if(!t.awardProfiles||e<0||e>=t.awardProfiles.length)return;t.awardProfiles.splice(e,1);let n=new Set;for(let t of this.state.expandedProfiles)t<e?n.add(t):t>e&&n.add(t-1);this.state={...this.state,expandedProfiles:n},this.commitDraft(t)}duplicateProfile(e){let t=Q(this.state.draft);if(!t.awardProfiles||e<0||e>=t.awardProfiles.length)return;let n=Q(t.awardProfiles[e]);n.profileName=`${n.profileName??`Profile`} (Copy)`,t.awardProfiles.splice(e+1,0,n);let r=new Set;for(let t of this.state.expandedProfiles)t<=e?r.add(t):r.add(t+1);r.add(e+1),this.state={...this.state,expandedProfiles:r},this.commitDraft(t)}moveProfile(e,t){let n=Q(this.state.draft);if(!n.awardProfiles||e<0||e>=n.awardProfiles.length||t<0||t>=n.awardProfiles.length)return;let[r]=n.awardProfiles.splice(e,1);n.awardProfiles.splice(t,0,r),this.commitDraft(n)}setProfileName(e,t){let n=Q(this.state.draft);n.awardProfiles?.[e]&&(n.awardProfiles[e].profileName=t,this.commitDraft(n))}setProfileFlag(e,t,n){let r=Q(this.state.draft);r.awardProfiles?.[e]&&(n===void 0?delete r.awardProfiles[e][t]:r.awardProfiles[e][t]=n,this.commitDraft(r))}setFlatPositionPoints(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e];i&&(i.finishingPositionRanges||={},i.finishingPositionRanges[t]=n,this.commitDraft(r))}addPositionRow(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];r&&(r.finishingPositionRanges||={},r.finishingPositionRanges[t]===void 0&&(r.finishingPositionRanges[t]=0,this.commitDraft(n)))}removePositionRow(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];r?.finishingPositionRanges&&(delete r.finishingPositionRanges[t],this.commitDraft(n))}setPointsPerWin(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];r&&(t===void 0?delete r.pointsPerWin:r.pointsPerWin=t,this.commitDraft(n))}addBonusPoint(e){let t=Q(this.state.draft),n=t.awardProfiles?.[e];n&&(n.bonusPoints||=[],n.bonusPoints.push({finishingPositions:[1],value:0}),this.commitDraft(t))}removeBonusPoint(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];r?.bonusPoints&&(r.bonusPoints.splice(t,1),r.bonusPoints.length||delete r.bonusPoints,this.commitDraft(n))}setBonusPointPositions(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e]?.bonusPoints?.[t];i&&(i.finishingPositions=n,this.commitDraft(r))}setBonusPointValue(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e]?.bonusPoints?.[t];i&&(i.value=n,this.commitDraft(r))}setLevelPositionPoints(e,t,n,r){let i=Q(this.state.draft),a=i.awardProfiles?.[e];if(!a)return;a.finishingPositionRanges||={};let o=a.finishingPositionRanges[t];o&&typeof o==`object`&&o.level&&(o.level[n]=r),this.commitDraft(i)}addLevel(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];if(r?.finishingPositionRanges){for(let e of Object.keys(r.finishingPositionRanges)){let n=r.finishingPositionRanges[e];n&&typeof n==`object`&&n.level&&n.level[t]===void 0&&(n.level[t]=0)}r.levels&&!r.levels.includes(t)&&(r.levels.push(t),r.levels.sort((e,t)=>e-t)),this.commitDraft(n)}}removeLevel(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];if(r?.finishingPositionRanges){for(let e of Object.keys(r.finishingPositionRanges)){let n=r.finishingPositionRanges[e];n&&typeof n==`object`&&n.level&&delete n.level[t]}r.levels&&=r.levels.filter(e=>e!==t),this.commitDraft(n)}}setProfileScope(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e];i&&(n.length?i[t]=n:delete i[t],this.commitDraft(r))}setProfileField(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e];i&&(n===void 0||n===``?delete i[t]:i[t]=n,this.commitDraft(r))}addQualityWinProfile(){let e=Q(this.state.draft);e.qualityWinProfiles||=[],e.qualityWinProfiles.push({rankingScaleName:`New Profile`,rankingRanges:[{rankRange:[1,10],value:10}]}),this.commitDraft(e)}removeQualityWinProfile(e){let t=Q(this.state.draft);t.qualityWinProfiles&&(t.qualityWinProfiles.splice(e,1),t.qualityWinProfiles.length||delete t.qualityWinProfiles,this.commitDraft(t))}setQualityWinField(e,t,n){let r=Q(this.state.draft),i=r.qualityWinProfiles?.[e];i&&(n===void 0||n===``?delete i[t]:i[t]=n,this.commitDraft(r))}addQualityWinRange(e){let t=Q(this.state.draft),n=t.qualityWinProfiles?.[e];if(!n)return;let r=n.rankingRanges.at(-1),i=r?r.rankRange[1]+1:1;n.rankingRanges.push({rankRange:[i,i+9],value:0}),this.commitDraft(t)}removeQualityWinRange(e,t){let n=Q(this.state.draft),r=n.qualityWinProfiles?.[e];r&&(r.rankingRanges.splice(t,1),this.commitDraft(n))}setQualityWinRange(e,t,n,r){let i=Q(this.state.draft),a=i.qualityWinProfiles?.[e]?.rankingRanges?.[t];a&&(n===`rankRange`?a.rankRange=r:a.value=r,this.commitDraft(i))}setAggregationField(e,t){let n=Q(this.state.draft);n.aggregationRules||={},t===void 0||t===``?delete n.aggregationRules[e]:n.aggregationRules[e]=t,this.commitDraft(n)}addTiebreakCriterion(e){let t=Q(this.state.draft);t.aggregationRules||={},t.aggregationRules.tiebreakCriteria||(t.aggregationRules.tiebreakCriteria=[]),t.aggregationRules.tiebreakCriteria.push(e),this.commitDraft(t)}removeTiebreakCriterion(e){let t=Q(this.state.draft);t.aggregationRules?.tiebreakCriteria&&(t.aggregationRules.tiebreakCriteria.splice(e,1),t.aggregationRules.tiebreakCriteria.length||delete t.aggregationRules.tiebreakCriteria,this.commitDraft(t))}addCountingBucket(){let e=Q(this.state.draft);e.aggregationRules||={},e.aggregationRules.countingBuckets||(e.aggregationRules.countingBuckets=[]),e.aggregationRules.countingBuckets.push({bucketName:`New Bucket`}),this.commitDraft(e)}removeCountingBucket(e){let t=Q(this.state.draft);t.aggregationRules?.countingBuckets&&(t.aggregationRules.countingBuckets.splice(e,1),t.aggregationRules.countingBuckets.length||delete t.aggregationRules.countingBuckets,this.commitDraft(t))}setCountingBucketField(e,t,n){let r=Q(this.state.draft),i=r.aggregationRules?.countingBuckets?.[e];i&&(n===void 0||n===``?delete i[t]:i[t]=n,this.commitDraft(r))}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}commitDraft(e){this.state={...this.state,draft:e,dirty:!0},this.emit(),this.config.onChange?.(Q(e))}emit(){for(let e of this.listeners)e(this.state)}},RB=()=>`re-section`,zB=()=>`re-section-header`,BB=()=>`re-section-chevron`,VB=()=>`re-section-count`,HB=()=>`re-section-body`,UB=()=>`re-field-row`,WB=()=>`re-field-label`,GB=()=>`re-field-input re-field-input--text`,KB=()=>`re-field-input re-field-input--number`,qB=()=>`re-field-input re-field-input--date`,JB=()=>`re-field-select`,YB=()=>`re-checkbox-row`,XB=()=>`re-points-input`,ZB=()=>`re-profile-card`,QB=()=>`re-profile-header`,$B=()=>`re-profile-name-input`,eV=()=>`re-profile-body`,tV=()=>`re-profile-actions`,nV=()=>`re-icon-btn`,rV=()=>`re-icon-btn re-icon-btn--danger`,iV=()=>`re-empty`,aV=()=>`re-editor`,oV=[`totalPoints`,`bestResult`,`headToHead`,`numberOfWins`,`recentResults`,`drawSize`,`numberOfResults`];function sV(e){let t=document.createElement(`div`),n=``;function r(t,n,r,i,a,o){let s=document.createElement(`div`);s.className=UB();let c=document.createElement(`div`);if(c.className=WB(),c.textContent=n,s.appendChild(c),o){let e=document.createElement(`span`);e.style.cssText=`font-size:0.85rem;color:var(--sp-text)`,e.textContent=String(i),s.appendChild(e)}else if(r===`select`){let n=document.createElement(`select`);n.className=JB();let r=document.createElement(`option`);r.value=``,r.textContent=`(none)`,n.appendChild(r);for(let e of a??[]){let t=document.createElement(`option`);t.value=e,t.textContent=e,n.appendChild(t)}n.value=i??``,n.addEventListener(`change`,()=>e.setAggregationField(t,n.value||void 0)),s.appendChild(n)}else{let n=document.createElement(`input`);n.type=`number`,n.className=KB(),n.value=i===void 0?``:String(i),n.placeholder=`—`,n.addEventListener(`change`,()=>{let r=n.value.trim();e.setAggregationField(t,r?Number.parseInt(r,10):void 0)}),s.appendChild(n)}return s}function i(n,r){let i=document.createElement(`div`);if(i.style.cssText=`font-weight:600;font-size:0.8rem;margin:0.5rem 0 0.3rem;color:var(--sp-text)`,i.textContent=`Tiebreak Order`,t.appendChild(i),n.length){let i=document.createElement(`ol`);i.style.cssText=`font-size:0.8rem;margin:0;padding-left:1.5rem;color:var(--sp-text)`;for(let t=0;t<n.length;t++){let a=document.createElement(`li`);a.style.cssText=`display:flex;align-items:center;gap:6px;margin-bottom:2px`;let o=document.createElement(`span`);if(o.textContent=n[t],a.appendChild(o),!r){let n=document.createElement(`span`);n.className=rV(),n.textContent=`×`,n.style.cursor=`pointer`,n.addEventListener(`click`,()=>e.removeTiebreakCriterion(t)),a.appendChild(n)}i.appendChild(a)}t.appendChild(i)}else if(r){let e=document.createElement(`div`);e.className=iV(),e.textContent=`No tiebreak criteria`,t.appendChild(e)}if(!r){let r=document.createElement(`div`);r.style.cssText=`display:flex;align-items:center;gap:4px;margin-top:4px`;let i=document.createElement(`select`);i.className=JB(),i.style.fontSize=`0.75rem`;let a=new Set(n),o=oV.filter(e=>!a.has(e));for(let e of o){let t=document.createElement(`option`);t.value=e,t.textContent=e,i.appendChild(t)}let s=document.createElement(`button`);s.className=`sp-btn sp-btn--sm sp-btn--outline`,s.textContent=`+ Add`,s.addEventListener(`click`,()=>{i.value&&e.addTiebreakCriterion(i.value)}),o.length&&(r.appendChild(i),r.appendChild(s),t.appendChild(r))}}function a(t,n,r){let i=document.createElement(`div`);i.style.cssText=`border:1px solid var(--sp-border);border-radius:8px;padding:0.4rem;margin-bottom:0.4rem;font-size:0.8rem`;let a=document.createElement(`div`);if(a.style.cssText=`display:flex;align-items:center;gap:6px;margin-bottom:0.2rem`,r){let e=document.createElement(`span`);e.style.cssText=`font-weight:600;color:var(--sp-text)`,e.textContent=t.bucketName||`Bucket`,a.appendChild(e)}else{let r=document.createElement(`input`);r.type=`text`,r.className=`re-field-input re-field-input--text`,r.style.cssText=`width:120px;font-size:0.75rem;font-weight:600`,r.value=t.bucketName||``,r.placeholder=`Bucket name`,r.addEventListener(`change`,()=>e.setCountingBucketField(n,`bucketName`,r.value)),a.appendChild(r);let i=document.createElement(`div`);i.style.flexGrow=`1`,a.appendChild(i);let o=document.createElement(`span`);o.className=rV(),o.textContent=`✕`,o.style.cursor=`pointer`,o.addEventListener(`click`,()=>e.removeCountingBucket(n)),a.appendChild(o)}i.appendChild(a);let o=[];if(t.eventTypes?.length&&o.push(`Events: ${t.eventTypes.join(`, `)}`),t.bestOfCount!==void 0&&o.push(`Best of: ${t.bestOfCount}`),t.levels?.length&&o.push(`Levels: ${t.levels.join(`, `)}`),t.minResults!==void 0&&o.push(`Min: ${t.minResults}`),r&&o.length){let e=document.createElement(`div`);e.style.cssText=`color:var(--sp-muted);font-size:0.75rem`,e.textContent=o.join(` | `),i.appendChild(e)}else if(!r){let r=document.createElement(`div`);r.className=UB();let a=document.createElement(`div`);a.className=WB(),a.style.cssText=`min-width:70px;font-size:0.75rem`,a.textContent=`Best of`,r.appendChild(a);let o=document.createElement(`input`);o.type=`number`,o.className=KB(),o.style.fontSize=`0.75rem`,o.value=t.bestOfCount===void 0?``:String(t.bestOfCount),o.addEventListener(`change`,()=>{let t=o.value.trim();e.setCountingBucketField(n,`bestOfCount`,t?Number.parseInt(t,10):void 0)}),r.appendChild(o),i.appendChild(r)}return i}function o(n){let o=n.draft.aggregationRules;if(t.innerHTML=``,!o&&n.readonly){let e=document.createElement(`div`);e.className=iV(),e.textContent=`No aggregation rules defined (all results summed)`,t.appendChild(e);return}let s=[[`rollingPeriodDays`,`Rolling period (days)`,`number`,o?.rollingPeriodDays],[`bestOfCount`,`Best of count`,`number`,o?.bestOfCount],[`minCountableResults`,`Min countable results`,`number`,o?.minCountableResults],[`decayFunction`,`Decay function`,`select`,o?.decayFunction,[`none`,`linear`,`exponential`,`step`]]];for(let[e,i,a,o,c]of s)o===void 0&&n.readonly||t.appendChild(r(e,i,a,o,c,n.readonly));let c=[[`separateByGender`,`Separate by gender`,o?.separateByGender],[`perCategory`,`Per category`,o?.perCategory]];for(let[r,i,a]of c){if(a===void 0&&n.readonly)continue;let o=document.createElement(`div`);o.className=YB();let s=document.createElement(`input`);s.type=`checkbox`,s.checked=a??!1,s.disabled=n.readonly,s.addEventListener(`change`,()=>e.setAggregationField(r,s.checked));let c=document.createElement(`label`);c.textContent=i,o.appendChild(s),o.appendChild(c),t.appendChild(o)}i(o?.tiebreakCriteria??[],n.readonly);let l=o?.countingBuckets??[];if(l.length||!n.readonly){let r=document.createElement(`div`);r.style.cssText=`font-weight:600;font-size:0.8rem;margin:0.5rem 0 0.3rem;color:var(--sp-text)`,r.textContent=`Counting Buckets`,t.appendChild(r);for(let e=0;e<l.length;e++)t.appendChild(a(l[e],e,n.readonly));if(!n.readonly){let n=document.createElement(`button`);n.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,n.textContent=`+ Add Bucket`,n.addEventListener(`click`,()=>e.addCountingBucket()),t.appendChild(n)}}}function s(e){let t=JSON.stringify(e.draft.aggregationRules??{});t!==n&&(n=t,o(e))}return{element:t,update:s}}function cV(e){let t=document.createElement(`div`),n=``;function r(t,n,r){let i=document.createElement(`div`);if(i.style.cssText=`display:flex;align-items:center;gap:0.5rem;margin-bottom:0.4rem`,r){let e=document.createElement(`span`);e.style.cssText=`font-weight:600;font-size:0.85rem;color:var(--sp-text)`,e.textContent=n.rankingScaleName,i.appendChild(e)}else{let r=document.createElement(`input`);r.type=`text`,r.className=GB(),r.style.cssText=`width:150px;font-weight:600`,r.value=n.rankingScaleName,r.addEventListener(`change`,()=>e.setQualityWinField(t,`rankingScaleName`,r.value)),i.appendChild(r);let a=document.createElement(`div`);a.style.flexGrow=`1`,i.appendChild(a);let o=document.createElement(`span`);o.className=rV(),o.textContent=`✕`,o.title=`Delete profile`,o.style.cursor=`pointer`,o.addEventListener(`click`,()=>e.removeQualityWinProfile(t)),i.appendChild(o)}return i}let i=`text-align:right;padding:2px 4px`,a=`text-align:right;width:4rem`;function o(t,n,r,a){let o=document.createElement(`tr`);if(a)for(let e of[r.rankRange[0],r.rankRange[1],r.value]){let t=document.createElement(`td`);t.style.cssText=`text-align:right;font-variant-numeric:tabular-nums;padding:2px 4px`,t.textContent=e.toLocaleString(),o.appendChild(t)}else{let a=document.createElement(`td`);a.style.cssText=i,a.appendChild(lV(r.rankRange[0],i=>{e.setQualityWinRange(t,n,`rankRange`,[i,r.rankRange[1]])})),o.appendChild(a);let s=document.createElement(`td`);s.style.cssText=i,s.appendChild(lV(r.rankRange[1],i=>{e.setQualityWinRange(t,n,`rankRange`,[r.rankRange[0],i])})),o.appendChild(s);let c=document.createElement(`td`);c.style.cssText=i,c.appendChild(lV(r.value,r=>{e.setQualityWinRange(t,n,`value`,r)})),o.appendChild(c);let l=document.createElement(`td`);l.style.cssText=`text-align:center;padding:2px`;let u=document.createElement(`span`);u.className=rV(),u.textContent=`×`,u.style.cursor=`pointer`,u.addEventListener(`click`,()=>e.removeQualityWinRange(t,n)),l.appendChild(u),o.appendChild(l)}return o}function s(e,t,n){let r=document.createElement(`table`);r.style.cssText=`font-size:0.8rem;margin-bottom:0.3rem;border-collapse:collapse`;let i=document.createElement(`thead`),s=document.createElement(`tr`);for(let[e,t]of[[`From`,a],[`To`,a],[`Bonus`,a]]){let n=document.createElement(`th`);n.textContent=e,n.style.cssText=t+`;padding:2px 4px`,s.appendChild(n)}if(!n){let e=document.createElement(`th`);e.style.cssText=`width:2rem;padding:2px`,s.appendChild(e)}i.appendChild(s),r.appendChild(i);let c=document.createElement(`tbody`);for(let r=0;r<t.rankingRanges.length;r++)c.appendChild(o(e,r,t.rankingRanges[r],n));return r.appendChild(c),r}function c(t,n,r,i,a){let o=document.createElement(`div`);o.className=UB();let s=document.createElement(`div`);if(s.className=WB(),s.style.minWidth=`100px`,s.style.fontSize=`0.75rem`,s.textContent=r,o.appendChild(s),a){let e=document.createElement(`span`);e.style.cssText=`font-size:0.75rem;color:var(--sp-muted)`,e.textContent=String(i),o.appendChild(e)}else{let r=document.createElement(`input`);r.type=typeof i==`number`?`number`:`text`,r.className=typeof i==`number`?KB():GB(),r.style.fontSize=`0.75rem`,r.value=i===void 0?``:String(i),r.addEventListener(`change`,()=>{let a=r.value.trim();typeof i==`number`||n===`maxBonusPerTournament`?e.setQualityWinField(t,n,a?Number.parseFloat(a):void 0):e.setQualityWinField(t,n,a||void 0)}),o.appendChild(r)}return o}function l(n){let i=n.draft.qualityWinProfiles;if(t.innerHTML=``,!i?.length){let r=document.createElement(`div`);if(r.className=iV(),r.textContent=`No quality win profiles defined`,t.appendChild(r),!n.readonly){let n=document.createElement(`button`);n.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,n.textContent=`+ Add Quality Win Profile`,n.addEventListener(`click`,()=>e.addQualityWinProfile()),t.appendChild(n)}return}for(let a=0;a<i.length;a++){let o=i[a],l=document.createElement(`div`);if(l.style.cssText=`border:1px solid var(--sp-border);border-radius:10px;padding:0.5rem;margin-bottom:0.5rem`,l.appendChild(r(a,o,n.readonly)),o.rankingRanges?.length&&(l.appendChild(s(a,o,n.readonly)),!n.readonly)){let t=document.createElement(`button`);t.className=`sp-btn sp-btn--sm sp-btn--outline`,t.textContent=`+ Range`,t.style.marginBottom=`0.3rem`,t.addEventListener(`click`,()=>e.addQualityWinRange(a)),l.appendChild(t)}let u=[[`maxBonusPerTournament`,`Max bonus/tournament`,o.maxBonusPerTournament],[`rankingSnapshot`,`Ranking snapshot`,o.rankingSnapshot]];for(let[e,t,r]of u)r===void 0&&n.readonly||l.appendChild(c(a,e,t,r,n.readonly));if(o.includeWalkovers!==void 0||!n.readonly){let t=document.createElement(`div`);t.className=YB();let r=document.createElement(`input`);r.type=`checkbox`,r.checked=o.includeWalkovers??!1,r.disabled=n.readonly,r.addEventListener(`change`,()=>e.setQualityWinField(a,`includeWalkovers`,r.checked));let i=document.createElement(`label`);i.textContent=`Include walkovers`,i.style.fontSize=`0.75rem`,t.appendChild(r),t.appendChild(i),l.appendChild(t)}t.appendChild(l)}if(!n.readonly){let n=document.createElement(`button`);n.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,n.textContent=`+ Add Quality Win Profile`,n.addEventListener(`click`,()=>e.addQualityWinProfile()),t.appendChild(n)}}function u(e){let t=JSON.stringify(e.draft.qualityWinProfiles??[]);t!==n&&(n=t,l(e))}return{element:t,update:u}}function lV(e,t){let n=document.createElement(`input`);return n.type=`number`,n.className=XB(),n.value=String(e),n.addEventListener(`change`,()=>{let e=Number.parseFloat(n.value);Number.isNaN(e)||t(e)}),n}function uV(e){let t=document.createElement(`div`),n=document.createElement(`div`);n.className=UB();let r=document.createElement(`div`);r.className=WB(),r.textContent=`Name`;let i=document.createElement(`input`);i.type=`text`,i.className=GB(),i.placeholder=`Policy name`,i.addEventListener(`change`,()=>e.setPolicyName(i.value)),n.appendChild(r),n.appendChild(i),t.appendChild(n);let a=document.createElement(`div`);a.className=UB();let o=document.createElement(`div`);o.className=WB(),o.textContent=`Version`;let s=document.createElement(`input`);s.type=`text`,s.className=GB(),s.placeholder=`1.0`,s.style.width=`80px`,s.addEventListener(`change`,()=>e.setPolicyVersion(s.value)),a.appendChild(o),a.appendChild(s),t.appendChild(a);let c=document.createElement(`div`);c.className=UB();let l=document.createElement(`div`);l.className=WB(),l.textContent=`Valid from`;let u=document.createElement(`input`);u.type=`date`,u.className=qB(),u.addEventListener(`change`,()=>e.setValidDateRange(`startDate`,u.value)),c.appendChild(l),c.appendChild(u),t.appendChild(c);let d=document.createElement(`div`);d.className=UB();let f=document.createElement(`div`);f.className=WB(),f.textContent=`Valid until`;let p=document.createElement(`input`);p.type=`date`,p.className=qB(),p.addEventListener(`change`,()=>e.setValidDateRange(`endDate`,p.value)),d.appendChild(f),d.appendChild(p),t.appendChild(d);let m=document.createElement(`div`);m.className=UB();let h=document.createElement(`div`);h.className=WB(),h.textContent=`Doubles attribution`;let g=document.createElement(`select`);g.className=JB();for(let[e,t]of[[``,`(none)`],[`fullToEach`,`Full to each`],[`halfToEach`,`Half to each`],[`split`,`Split`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,g.appendChild(n)}g.addEventListener(`change`,()=>e.setDoublesAttribution(g.value)),m.appendChild(h),m.appendChild(g),t.appendChild(m);let _=document.createElement(`div`);_.className=UB();let v=document.createElement(`div`);v.className=WB(),v.textContent=`Category resolution`;let y=document.createElement(`select`);y.className=JB();for(let[e,t]of[[``,`(none)`],[`matchCategory`,`Match category`],[`eventCategory`,`Event category`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,y.appendChild(n)}y.addEventListener(`change`,()=>e.setCategoryResolution(y.value)),_.appendChild(v),_.appendChild(y),t.appendChild(_);let b=document.createElement(`div`);b.className=YB();let x=document.createElement(`input`);x.type=`checkbox`,x.id=`re-require-win`;let S=document.createElement(`label`);S.htmlFor=`re-require-win`,S.textContent=`Require win for points`,x.addEventListener(`change`,()=>e.setGlobalFlag(`requireWinForPoints`,x.checked)),b.appendChild(x),b.appendChild(S),t.appendChild(b);let C=document.createElement(`div`);C.className=YB();let w=document.createElement(`input`);w.type=`checkbox`,w.id=`re-require-win-r1`;let T=document.createElement(`label`);T.htmlFor=`re-require-win-r1`,T.textContent=`Require win in first round`,w.addEventListener(`change`,()=>e.setGlobalFlag(`requireWinFirstRound`,w.checked)),C.appendChild(w),C.appendChild(T),t.appendChild(C);let E=[i,s,u,p],D=[g,y],O=[x,w];function k(e){let{draft:t}=e;document.activeElement!==i&&(i.value=t.policyName??``),document.activeElement!==s&&(s.value=t.policyVersion??``),document.activeElement!==u&&(u.value=t.validDateRange?.startDate??``),document.activeElement!==p&&(p.value=t.validDateRange?.endDate??``),document.activeElement!==g&&(g.value=t.doublesAttribution??``),document.activeElement!==y&&(y.value=t.categoryResolution??``),x.checked=t.requireWinForPoints??!1,w.checked=t.requireWinFirstRound??!1;let n=e.readonly;for(let e of E)e.disabled=n;for(let e of D)e.disabled=n;for(let e of O)e.disabled=n}return{element:t,update:k}}var dV={1:`W`,2:`F`,4:`SF`,8:`QF`,16:`R16`,32:`R32`,64:`R64`,128:`R128`,256:`R256`},fV=`level-keyed`;function pV(e){return dV[e]??`R${e}`}function mV(e){if(!e)return{type:`flat`};let t=Object.values(e);if(!t.length||t.every(e=>typeof e==`number`))return{type:`flat`};let n=hV(t);return n.hasConditionalArray?{type:`conditional`}:n.hasLevelFlightNesting?gV(t,n.allLevels):n.allLevels.size>0?{type:`level-columns`,levels:[...n.allLevels].sort((e,t)=>e-t)}:n.allFlights.size>0?{type:`flight-columns`,flights:[...n.allFlights].sort((e,t)=>e-t)}:{type:`flat`}}function hV(e){let t=new Set,n=new Set,r=!1,i=!1;for(let a of e){let e=_V(a);if(e.type===fV){for(let n of e.levels)t.add(n);e.hasFlightNesting&&(i=!0)}else if(e.type===`flight-keyed`)for(let t=0;t<e.flightCount;t++)n.add(t+1);else e.type===`conditional-array`&&(r=!0)}return{allLevels:t,allFlights:n,hasConditionalArray:r,hasLevelFlightNesting:i}}function gV(e,t){let n={},r=[...t].sort((e,t)=>e-t);for(let t of e){let e=_V(t);if(e.type===fV&&e.flightDetails)for(let[t,r]of Object.entries(e.flightDetails)){let e=Number(t);n[e]||(n[e]=[]);for(let t of r)n[e].includes(t)||n[e].push(t)}}return{type:`level-flight-tabs`,levels:r,flightsPerLevel:n}}function _V(e){if(typeof e==`number`)return{type:`flat`,levels:[],flightCount:0,hasFlightNesting:!1};if(Array.isArray(e))return{type:`conditional-array`,levels:[],flightCount:0,hasFlightNesting:!1};if(typeof e!=`object`||!e)return{type:`flat`,levels:[],flightCount:0,hasFlightNesting:!1};if(e.level!==void 0){if(Array.isArray(e.level))return{type:fV,levels:e.level.map((e,t)=>t+1),flightCount:0,hasFlightNesting:!1};if(typeof e.level==`object`){let t=Object.keys(e.level).map(Number).filter(e=>!Number.isNaN(e)),n=!1,r={};for(let[t,i]of Object.entries(e.level))typeof i==`object`&&i&&i.flights&&(n=!0,r[Number(t)]=i.flights.map((e,t)=>t+1));return{type:fV,levels:t,flightCount:0,hasFlightNesting:n,flightDetails:r}}}return e.flights!==void 0||e.f!==void 0?{type:`flight-keyed`,levels:[],flightCount:(e.flights??e.f??[]).length,hasFlightNesting:!1}:e.value===void 0?{type:`flat`,levels:[],flightCount:0,hasFlightNesting:!1}:{type:`explicit-flat`,levels:[],flightCount:0,hasFlightNesting:!1}}function vV(e,t={}){if(typeof e==`number`)return e;if(e!=null){if(Array.isArray(e))return yV(e,t);if(typeof e==`object`){if(e.level!==void 0&&t.level!==void 0)return bV(e,t);if(t.flight!==void 0){let n=e.flights??e.f;if(Array.isArray(n))return n[t.flight-1]}if(e.value!==void 0)return e.value}}}function yV(e,t){for(let n of e){if(n.drawSizes&&t.drawSize&&n.drawSizes.includes(t.drawSize))return vV(n,t);if(n.drawSize!==void 0&&t.drawSize!==void 0&&(n.threshold?t.drawSize>=n.drawSize:t.drawSize===n.drawSize))return vV({...n,drawSize:void 0,drawSizes:void 0,threshold:void 0},t);if(n.drawSize===void 0&&n.drawSizes===void 0)return vV(n,t)}}function bV(e,t){let n=Array.isArray(e.level)?e.level[t.level-1]:e.level[t.level];if(n!==void 0)return typeof n==`object`&&n?vV(n,t):typeof n==`number`?n:void 0}function xV(e){let t=[],n=Object.keys(e.finishingPositionRanges??{}).length;return n&&t.push(`${n} positions`),(e.perWinPoints||e.pointsPerWin)&&t.push(`per-win`),e.bonusPoints?.length&&t.push(`${e.bonusPoints.length} bonus`),t.join(`, `)||`empty`}function SV(e){let t=[];for(let n of e.eventTypes??[])t.push({label:n,intent:`re-badge--accent`});for(let n of e.stages??[])t.push({label:n,intent:`re-badge--success`});for(let n of e.levels??[])t.push({label:`L${n}`,intent:`re-badge--warn`});for(let n of e.drawTypes??[])t.push({label:n.replaceAll(`_`,` `),intent:`re-badge--primary`});return e.participationOrder!==void 0&&t.push({label:`PO:${e.participationOrder}`,intent:`re-badge--info`}),t}function CV(e){return e==null?`--`:e.toLocaleString()}var wV=[1,2,4,8,16,32,64,128],TV=`font-size:0.8rem;margin-bottom:0;border-collapse:collapse`,EV=`width:3.5rem;text-align:center`;function DV(e,t){let n=document.createElement(`div`);n.style.cssText=`overflow-x:auto`;let r=``;function i(r){let i=r.draft.awardProfiles?.[t]?.finishingPositionRanges;if(n.innerHTML=``,!i||!Object.keys(i).length){let i=document.createElement(`div`);if(i.className=iV(),i.textContent=`No finishing position points defined`,!r.readonly){let n=document.createElement(`button`);n.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,n.textContent=`+ Add position`,n.style.marginLeft=`8px`,n.addEventListener(`click`,()=>e.addPositionRow(t,1)),i.appendChild(n)}n.appendChild(i);return}let a=mV(i),o=Object.keys(i).map(Number).sort((e,t)=>e-t);a.type===`flat`?OV(n,o,i,r.readonly,e,t):a.type===`level-columns`?kV(n,o,i,a.levels,r.readonly,e,t):AV(n,o,i,a)}function a(e){let n=e.draft.awardProfiles?.[t],a=JSON.stringify(n?.finishingPositionRanges??{});a!==r&&(r=a,i(e))}return{element:n,update:a}}function OV(e,t,n,r,i,a){let o=document.createElement(`table`);o.style.cssText=TV;let s=document.createElement(`thead`),c=document.createElement(`tr`);jV(c,`Pos`,EV),jV(c,`Points`,`text-align:right`),r||jV(c,``,`width:2rem`),s.appendChild(c),o.appendChild(s);let l=document.createElement(`tbody`);for(let e of t){let t=document.createElement(`tr`);MV(t,e);let o=document.createElement(`td`);o.style.cssText=`text-align:right;padding:2px 4px`,r?(o.style.fontVariantNumeric=`tabular-nums`,o.textContent=CV(typeof n[e]==`number`?n[e]:vV(n[e]))):o.appendChild(PV(typeof n[e]==`number`?n[e]:vV(n[e])??0,t=>i.setFlatPositionPoints(a,e,t))),t.appendChild(o),r||NV(t,()=>i.removePositionRow(a,e)),l.appendChild(t)}o.appendChild(l),e.appendChild(o),r||FV(e,t,i,a)}function kV(e,t,n,r,i,a,o){let s=document.createElement(`table`);s.style.cssText=TV;let c=document.createElement(`thead`),l=document.createElement(`tr`);jV(l,`Pos`,EV);for(let e of r){let t=document.createElement(`th`);if(t.style.cssText=`text-align:right;min-width:3.5rem;padding:2px 4px`,i)t.textContent=`L${e}`;else{let n=document.createElement(`div`);n.style.cssText=`display:flex;align-items:center;justify-content:flex-end;gap:4px`;let r=document.createElement(`span`);r.textContent=`L${e}`,n.appendChild(r);let i=document.createElement(`span`);i.className=rV(),i.textContent=`×`,i.title=`Remove level ${e}`,i.style.cssText=`cursor:pointer;font-size:0.65rem`,i.addEventListener(`click`,()=>a.removeLevel(o,e)),n.appendChild(i),t.appendChild(n)}l.appendChild(t)}i||jV(l,``,`width:2rem`),c.appendChild(l),s.appendChild(c);let u=document.createElement(`tbody`);for(let e of t){let t=document.createElement(`tr`);MV(t,e);for(let s of r){let r=document.createElement(`td`);r.style.cssText=`text-align:right;padding:2px 4px`;let c=vV(n[e],{level:s});i?(r.style.fontVariantNumeric=`tabular-nums`,r.textContent=CV(c),c===void 0&&(r.style.color=`var(--sp-muted)`)):r.appendChild(PV(c??0,t=>a.setLevelPositionPoints(o,e,s,t))),t.appendChild(r)}i||NV(t,()=>a.removePositionRow(o,e)),u.appendChild(t)}if(s.appendChild(u),e.appendChild(s),!i){let n=document.createElement(`div`);n.style.cssText=`display:flex;gap:8px;margin-top:6px;flex-wrap:wrap`;let i=document.createElement(`div`);i.style.cssText=`display:flex;align-items:center;gap:4px`;let s=document.createElement(`input`);s.type=`number`,s.className=XB(),s.style.width=`50px`,s.placeholder=`L#`,s.min=`1`;let c=document.createElement(`button`);c.className=`sp-btn sp-btn--sm sp-btn--outline`,c.textContent=`+ Level`,c.addEventListener(`click`,()=>{let e=Number.parseInt(s.value,10);!Number.isNaN(e)&&e>0&&!r.includes(e)&&(a.addLevel(o,e),s.value=``)}),i.appendChild(s),i.appendChild(c),n.appendChild(i),IV(n,t,a,o),e.appendChild(n)}}function AV(e,t,n,r){let i=document.createElement(`div`);i.style.cssText=`font-size:0.7rem;color:var(--sp-muted);margin-bottom:4px;font-style:italic`,i.textContent=`(${r.type} layout — view only)`,e.appendChild(i);let a=document.createElement(`table`);a.style.cssText=TV;let o=document.createElement(`thead`),s=document.createElement(`tr`);if(jV(s,`Pos`,EV),r.type===`flight-columns`)for(let e of r.flights)jV(s,`F${e}`,`text-align:right;min-width:3.5rem`);else jV(s,`Points`,`text-align:right`);o.appendChild(s),a.appendChild(o);let c=document.createElement(`tbody`);for(let e of t){let t=document.createElement(`tr`);MV(t,e);let i=n[e];if(r.type===`flight-columns`)for(let e of r.flights){let n=document.createElement(`td`);n.style.cssText=`text-align:right;font-variant-numeric:tabular-nums;padding:2px 4px`;let r=vV(i,{flight:e});n.textContent=CV(r),r===void 0&&(n.style.color=`var(--sp-muted)`),t.appendChild(n)}else{let e=document.createElement(`td`);if(e.style.cssText=`text-align:right;font-variant-numeric:tabular-nums;padding:2px 4px`,e.textContent=CV(vV(i)),Array.isArray(i)){let t=document.createElement(`span`);t.style.cssText=`margin-left:0.3rem;font-size:0.65rem;color:var(--sp-muted)`,t.textContent=`${i.length} variants`,t.title=JSON.stringify(i,null,2),e.appendChild(t)}t.appendChild(e)}c.appendChild(t)}a.appendChild(c),e.appendChild(a)}function jV(e,t,n){let r=document.createElement(`th`);r.textContent=t,r.style.cssText=n+`;padding:2px 4px`,e.appendChild(r)}function MV(e,t){let n=document.createElement(`td`);n.style.cssText=`text-align:center;font-weight:600;color:var(--sp-text);padding:2px 4px`,n.textContent=pV(t),e.appendChild(n)}function NV(e,t){let n=document.createElement(`td`);n.style.cssText=`text-align:center;vertical-align:middle;padding:2px`;let r=document.createElement(`span`);r.className=rV(),r.textContent=`×`,r.title=`Remove position`,r.style.cursor=`pointer`,r.addEventListener(`click`,t),n.appendChild(r),e.appendChild(n)}function PV(e,t){let n=document.createElement(`input`);return n.type=`number`,n.className=XB(),n.value=String(e),n.addEventListener(`change`,()=>{let e=Number.parseFloat(n.value);Number.isNaN(e)||t(e)}),n}function FV(e,t,n,r){let i=document.createElement(`div`);i.style.cssText=`display:flex;gap:8px;margin-top:6px;flex-wrap:wrap`,IV(i,t,n,r),e.appendChild(i)}function IV(e,t,n,r){let i=new Set(t),a=wV.filter(e=>!i.has(e));if(!a.length)return;let o=document.createElement(`div`);o.style.cssText=`display:flex;align-items:center;gap:4px`;let s=document.createElement(`select`);s.className=`re-field-select`,s.style.cssText=`min-width:80px;font-size:11px;padding:4px 6px`;for(let e of a){let t=document.createElement(`option`);t.value=String(e),t.textContent=pV(e),s.appendChild(t)}let c=document.createElement(`button`);c.className=`sp-btn sp-btn--sm sp-btn--outline`,c.textContent=`+ Position`,c.addEventListener(`click`,()=>{let e=Number.parseInt(s.value,10);Number.isNaN(e)||n.addPositionRow(r,e)}),o.appendChild(s),o.appendChild(c),e.appendChild(o)}function LV(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:0.25rem 0;font-size:0.8rem`;let r=document.createElement(`div`);r.className=UB();let i=document.createElement(`div`);i.className=WB(),i.textContent=`Per-Win`,i.style.minWidth=`80px`;let a=document.createElement(`input`);a.type=`number`,a.className=XB(),a.placeholder=`—`,a.addEventListener(`change`,()=>{let n=a.value.trim();e.setPointsPerWin(t,n===``?void 0:parseFloat(n))});let o=document.createElement(`div`);o.style.cssText=`font-size:0.75rem;color:var(--sp-muted)`,r.appendChild(i),r.appendChild(a),n.appendChild(r),n.appendChild(o);function s(e){let r=e.draft.awardProfiles?.[t];if(!r){n.style.display=`none`;return}let i=r.perWinPoints,s=r.pointsPerWin;if(!i&&s===void 0){n.style.display=`none`;return}if(n.style.display=``,a.disabled=e.readonly,s!==void 0&&typeof s==`number`?(a.style.display=``,o.style.display=`none`,document.activeElement!==a&&(a.value=String(s))):s===void 0?i&&(a.style.display=`none`,o.style.display=``,o.textContent=(Array.isArray(i)?i:[i]).map(e=>{let t=[];return e.participationOrders?.length&&t.push(`PO:${e.participationOrders.join(`,`)}`),e.value!==void 0&&t.push(`${e.value} pts/win`),e.limit!==void 0&&t.push(`limit: ${e.limit}`),t.join(` | `)}).join(`; `)):(a.style.display=`none`,o.style.display=``,o.textContent=`${CV(vV(s))} pts/win (complex)`),r.maxCountableMatches!==void 0){let e=typeof r.maxCountableMatches==`number`?r.maxCountableMatches:`level-keyed`;o.style.display=``;let t=o.textContent;o.textContent=t?`${t} — max countable: ${e}`:`Max countable: ${e}`}}return{element:n,update:s}}function RV(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:0.25rem 0;font-size:0.8rem`;let r=``;function i(r){let i=r.draft.awardProfiles?.[t]?.bonusPoints;if(n.innerHTML=``,!i?.length&&r.readonly){n.style.display=`none`;return}n.style.display=``;let a=document.createElement(`div`);if(a.style.cssText=`font-weight:600;color:var(--sp-text);margin-bottom:4px`,a.textContent=`Bonus Points`,n.appendChild(a),i?.length)for(let a=0;a<i.length;a++){let o=i[a],s=document.createElement(`div`);if(s.style.cssText=`display:flex;align-items:center;gap:6px;margin-bottom:4px;padding-left:0.5rem`,r.readonly){let e=o.finishingPositions.map(pV).join(`, `),t=document.createElement(`span`);t.textContent=`${e}: `,s.appendChild(t);let n=document.createElement(`span`);n.style.fontVariantNumeric=`tabular-nums`,n.textContent=typeof o.value==`number`?o.value.toLocaleString():String(o.value??`—`),s.appendChild(n)}else{let n=document.createElement(`span`);n.style.cssText=`font-size:0.75rem;color:var(--sp-muted);min-width:30px`,n.textContent=`Pos:`,s.appendChild(n);let r=document.createElement(`input`);r.type=`text`,r.className=XB(),r.style.width=`80px`,r.value=o.finishingPositions.join(`, `),r.title=`Comma-separated positions (e.g. 1, 2)`,r.addEventListener(`change`,()=>{let n=r.value.split(`,`).map(e=>Number.parseInt(e.trim(),10)).filter(e=>!Number.isNaN(e)&&e>0);n.length&&e.setBonusPointPositions(t,a,n)}),s.appendChild(r);let i=document.createElement(`span`);i.style.cssText=`font-size:0.75rem;color:var(--sp-muted)`,i.textContent=`Pts:`,s.appendChild(i);let c=document.createElement(`input`);c.type=`number`,c.className=XB(),c.value=typeof o.value==`number`?String(o.value):``,c.addEventListener(`change`,()=>{let n=Number.parseFloat(c.value);Number.isNaN(n)||e.setBonusPointValue(t,a,n)}),s.appendChild(c);let l=document.createElement(`span`);l.className=rV(),l.textContent=`×`,l.title=`Remove bonus`,l.style.cursor=`pointer`,l.addEventListener(`click`,()=>e.removeBonusPoint(t,a)),s.appendChild(l)}n.appendChild(s)}if(!r.readonly){let r=document.createElement(`button`);r.className=`sp-btn sp-btn--sm sp-btn--outline`,r.textContent=`+ Add bonus`,r.style.cssText=`margin-top:4px;margin-left:0.5rem`,r.addEventListener(`click`,()=>e.addBonusPoint(t)),n.appendChild(r)}}function a(e){let n=e.draft.awardProfiles?.[t],a=JSON.stringify(n?.bonusPoints??[]);a!==r&&(r=a,i(e))}return{element:n,update:a}}function zV(e){let t=document.createElement(`div`);t.style.cssText=`display:inline-flex;gap:0.25rem;flex-wrap:wrap;margin-bottom:0`;let n=SV(e);if(!n.length){let e=document.createElement(`span`);return e.className=`re-badge re-badge--neutral`,e.textContent=`All`,t.appendChild(e),t}for(let e of n){let n=document.createElement(`span`);n.className=`re-badge ${e.intent}`,n.textContent=e.label,t.appendChild(n)}return t}var BV=[{field:`eventTypes`,label:`Event types`,options:[`SINGLES`,`DOUBLES`,`TEAM`]},{field:`drawTypes`,label:`Draw types`,options:[`SINGLE_ELIMINATION`,`DOUBLE_ELIMINATION`,`ROUND_ROBIN`,`COMPASS`,`FEED_IN`,`AD_HOC`,`LUCKY_DRAW`]},{field:`stages`,label:`Stages`,options:[`MAIN`,`QUALIFYING`,`CONSOLATION`,`PLAY_OFF`]},{field:`levels`,label:`Levels`,options:[],isNumeric:!0}],VV=[[`maxDrawSize`,`Max draw size`],[`maxLevel`,`Max level`],[`priority`,`Priority`],[`participationOrder`,`Participation order`]];function HV(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:0.25rem 0`;let r=document.createElement(`div`);r.style.cssText=`font-weight:600;font-size:0.8rem;color:var(--sp-text);margin-bottom:4px`,r.textContent=`Scope`,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i);let a=``;function o(n,r){if(n.isNumeric){let i=document.createElement(`input`);return i.type=`number`,i.min=`1`,i.placeholder=`+`,i.style.cssText=`width:36px;font-size:0.7rem;padding:2px 4px;border:1px dashed var(--sp-border);border-radius:4px;background:transparent;color:var(--sp-text);outline:none;text-align:center`,i.addEventListener(`keydown`,a=>{if(a.key===`Enter`){let a=Number.parseInt(i.value,10);!Number.isNaN(a)&&a>0&&!r.includes(a)&&(e.setProfileScope(t,n.field,[...r,a].sort((e,t)=>e-t)),i.value=``)}}),i}let i=n.options.filter(e=>!r.includes(e));if(!i.length)return;let a=document.createElement(`select`);a.style.cssText=`font-size:0.65rem;padding:2px 4px;border:1px dashed var(--sp-border);border-radius:4px;background:transparent;color:var(--sp-muted);outline:none;cursor:pointer`;let o=document.createElement(`option`);o.value=``,o.textContent=`+`,a.appendChild(o);for(let e of i){let t=document.createElement(`option`);t.value=e,t.textContent=e,a.appendChild(t)}return a.addEventListener(`change`,()=>{a.value&&e.setProfileScope(t,n.field,[...r,a.value])}),a}function s(n,r,i){let a=document.createElement(`div`);a.style.cssText=`margin-bottom:6px`;let s=document.createElement(`div`);s.style.cssText=`font-size:0.7rem;color:var(--sp-muted);margin-bottom:2px`,s.textContent=n.label,a.appendChild(s);let c=document.createElement(`div`);c.style.cssText=`display:flex;flex-wrap:wrap;gap:4px;align-items:center`;for(let a of r){let o=document.createElement(`span`);if(o.className=`re-badge re-badge--accent`,o.style.cssText=`display:inline-flex;align-items:center;gap:3px`,o.textContent=n.isNumeric?`L${a}`:String(a),!i){let i=document.createElement(`span`);i.style.cssText=`cursor:pointer;font-size:0.6rem;opacity:0.7`,i.textContent=`×`,i.addEventListener(`click`,()=>{e.setProfileScope(t,n.field,r.filter(e=>e!==a))}),o.appendChild(i)}c.appendChild(o)}if(!i){let e=o(n,r);e&&c.appendChild(e)}return a.appendChild(c),a}function c(r){i.innerHTML=``;let a=r.draft.awardProfiles?.[t];if(!a)return;let o=r.readonly;for(let e of BV){let t=a[e.field]??[];o&&!t.length||i.appendChild(s(e,t,o))}for(let[n,r]of VV){let s=a[n];if(o&&s===void 0)continue;let c=document.createElement(`div`);c.className=UB();let l=document.createElement(`div`);if(l.className=WB(),l.style.cssText=`min-width:110px;font-size:0.75rem`,l.textContent=r,c.appendChild(l),o){let e=document.createElement(`span`);e.style.cssText=`font-size:0.75rem;color:var(--sp-text)`,e.textContent=String(s),c.appendChild(e)}else{let r=document.createElement(`input`);r.type=`number`,r.className=KB(),r.style.fontSize=`0.75rem`,r.value=s===void 0?``:String(s),r.placeholder=`—`,r.addEventListener(`change`,()=>{let i=r.value.trim();e.setProfileField(t,n,i?Number.parseInt(i,10):void 0)}),c.appendChild(r)}i.appendChild(c)}let c=i.children.length>0;n.style.display=c?``:`none`}function l(e){let n=e.draft.awardProfiles?.[t],r=BV.map(e=>n?.[e.field]??[]),i=VV.map(([e])=>n?.[e]),o=JSON.stringify([r,i,e.readonly]);o!==a&&(a=o,c(e))}return{element:n,update:l}}function UV(e,t){let n=document.createElement(`div`);n.className=ZB();let r=document.createElement(`div`);r.className=QB();let i=document.createElement(`span`);i.className=BB(),i.style.flexShrink=`0`,r.appendChild(i);let a=document.createElement(`input`);a.type=`text`,a.className=$B(),a.addEventListener(`click`,e=>e.stopPropagation()),a.addEventListener(`change`,()=>e.setProfileName(t,a.value)),r.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`flex-grow:1;display:inline-flex;gap:0.25rem;flex-wrap:wrap`,r.appendChild(o);let s=document.createElement(`span`);s.style.cssText=`font-size:0.75rem;color:var(--sp-muted);white-space:nowrap;flex-shrink:0`,r.appendChild(s);let c=document.createElement(`div`);c.className=tV();let l=document.createElement(`button`);l.className=nV(),l.textContent=`⎘`,l.title=`Duplicate profile`,l.addEventListener(`click`,n=>{n.stopPropagation(),e.duplicateProfile(t)});let u=document.createElement(`button`);u.className=rV(),u.textContent=`✕`,u.title=`Delete profile`,u.addEventListener(`click`,n=>{n.stopPropagation(),e.removeProfile(t)}),c.appendChild(l),c.appendChild(u),r.appendChild(c),r.addEventListener(`click`,()=>e.toggleProfile(t)),n.appendChild(r);let d=document.createElement(`div`);d.className=eV();let f=document.createElement(`div`);f.style.cssText=`font-weight:600;font-size:0.85rem;color:var(--sp-text);margin-bottom:6px`,d.appendChild(f);let p=DV(e,t);d.appendChild(p.element);let m=LV(e,t);d.appendChild(m.element);let h=RV(e,t);d.appendChild(h.element);let g=HV(e,t);d.appendChild(g.element);let _=document.createElement(`div`);_.style.cssText=`padding:0.25rem 0;font-size:0.75rem;color:var(--sp-muted)`,d.appendChild(_),n.appendChild(d);function v(e){let r=e.draft.awardProfiles?.[t];if(!r){n.style.display=`none`;return}n.style.display=``;let l=e.expandedProfiles.has(t),u=e.readonly;i.textContent=l?`▼`:`▶`;let v=r.profileName||`Profile ${t+1}`;document.activeElement!==a&&(a.value=v),a.title=v,a.disabled=u,o.innerHTML=``;let y=zV(r);if(y.style.flexGrow=`1`,o.appendChild(y),s.textContent=l?``:xV(r),c.style.display=u?`none`:`flex`,d.style.display=l?``:`none`,l){f.textContent=v,p.update(e),m.update(e),h.update(e),g.update(e);let t=[];r.requireWinForPoints!==void 0&&t.push(`requireWin: ${r.requireWinForPoints}`),r.requireWinFirstRound!==void 0&&t.push(`requireWinR1: ${r.requireWinFirstRound}`),_.textContent=t.join(` | `),_.style.display=t.length?``:`none`}}return{element:n,update:v}}function WV(e,t){let n=document.createElement(`div`);n.className=aV();let r=uV(e),i=cV(e),a=sV(e),o=[{id:`metadata`,label:`Metadata`},{id:`awardProfiles`,label:`Award Profiles`,countFn:e=>e.draft.awardProfiles?.length??0},{id:`qualityWinProfiles`,label:`Quality Win Profiles`,countFn:e=>e.draft.qualityWinProfiles?.length??0},{id:`aggregationRules`,label:`Aggregation Rules`}],s=[];for(let t of o){let o=document.createElement(`div`);o.className=RB();let c=document.createElement(`div`);c.className=zB();let l=document.createElement(`span`);l.className=BB();let u=document.createElement(`span`);u.textContent=t.label;let d=document.createElement(`span`);d.className=VB(),c.appendChild(l),c.appendChild(u),c.appendChild(d),c.addEventListener(`click`,()=>e.toggleSection(t.id));let f=document.createElement(`div`);f.className=HB(),t.id===`metadata`&&f.appendChild(r.element),t.id===`qualityWinProfiles`&&f.appendChild(i.element),t.id===`aggregationRules`&&f.appendChild(a.element),o.appendChild(c),o.appendChild(f),n.appendChild(o),s.push({id:t.id,chevron:l,countEl:d,bodyEl:f})}let c=[],l=-1,u=``,d=null;function f(e,t){for(let n=0;n<o.length;n++){let r=o[n],i=s[n],a=e.has(r.id);if(i.chevron.textContent=a?`▼`:`▶`,i.bodyEl.style.display=a?`block`:`none`,r.countFn){let e=r.countFn(t);i.countEl.textContent=e?`(${e})`:``}}}function p(t,n){let r=s[1].bodyEl;r.innerHTML=``,c=[];let i=t.draft.awardProfiles??[],a=0;for(let t=0;t<i.length;t++){let o=i[t];if(n&&![o.profileName??``,...o.eventTypes??[],...o.stages??[],...(o.levels??[]).map(e=>`L${e}`),...o.drawTypes??[]].join(` `).toLowerCase().includes(n))continue;let s=UV(e,t);c.push(s),r.appendChild(s.element),a++}if(!a){let e=document.createElement(`div`);e.className=iV(),e.textContent=n?`No profiles match filter`:`No award profiles defined`,r.appendChild(e)}t.readonly||(d=document.createElement(`button`),d.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,d.textContent=`+ Add Profile`,d.addEventListener(`click`,()=>e.addProfile()),r.appendChild(d))}return{element:n,update:e=>{let{draft:t,expandedSections:n,profileFilter:o}=e;if(f(n,e),n.has(`metadata`)&&r.update(e),n.has(`awardProfiles`)){let n=t.awardProfiles?.length??0,r=o.toLowerCase();(n!==l||r!==u)&&(l=n,u=r,p(e,r));for(let t of c)t.update(e);d&&(d.style.display=e.readonly?`none`:``)}n.has(`qualityWinProfiles`)&&i.update(e),n.has(`aggregationRules`)&&a.update(e)}}}var GV=class e{constructor(e){this.container=null,this.store=new LB(e),this.panel=WV(this.store,e),this.unsubscribe=this.store.subscribe(e=>{this.panel.update(e)}),this.panel.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.panel.element)}destroy(){this.unsubscribe(),this.container&&this.panel.element.parentNode===this.container&&this.panel.element.remove(),this.container=null}getData(){return this.store.getData()}setData(e){this.store.setData(e)}getStore(){return this.store}static createEditorInstance(t){let n=new e({initialPolicy:t.initialData,onChange:e=>t.onChange(e),readonly:t.readonly});return{element:n.panel.element,setData(e){n.setData(e)},getData(){return n.getData()},destroy(){n.destroy()}}}};function KV(e){return qV[e]??e}var qV={"SET3-S:6/TB7":`Best of 3 TB sets`,"SET3-S:6/TB7-F:TB10":`2 TB sets, MTB10`,"SET3-S:6/TB7-F:TB7":`2 TB sets, MTB7`,"SET3-S:4NOAD-F:TB7":`2 short sets (4, NOAD), MTB7`,"SET3-S:4/TB7":`Best of 3 short sets (4)`,"SET3-S:4/TB7-F:TB7":`2 short sets (4), MTB7`,"SET3-S:4/TB7-F:TB10":`2 short sets (4), MTB10`,"SET3-S:4/TB5@3":`3 short sets (4), TB5@3`,"SET1-S:8/TB7":`8-game pro-set, TB7`,"SET1-S:8/TB7@7":`8-game pro-set, TB7@7`,"SET1-S:5/TB9@4":`1 set to 5, TB9@4`,"SET1-S:6/TB7":`1 TB set`,"SET1-S:6NOAD":`1 set to 6, NOAD`,"SET1-S:4/TB7":`1 short set (4), TB7`,"SET1-S:4/TB5@3":`1 short set (4), TB5@3`,"SET1-S:4NOAD":`1 short set (4), NOAD`,"SET3-S:TB10":`Best of 3 TB10 games`,"SET1-S:T20":`Timed 20 min`,"SET1-S:TB10":`1 TB10 game`,"SET5-S:6/TB7":`Best of 5 TB sets`,"SET5-S:6/TB7-F:TB10":`5 sets, MTB10`,"SET1-S:6/TB10":`1 set, TB10`,"SET1-S:8":`Pro-set to 8`,"SET1-S:10":`Pro-set to 10`,"SET1-S:T7":`TB7 only`,"SET1-S:T21":`TB21 only`};function JV(){return{allowModificationWhenMatchUpsScheduled:{courts:!1,venues:!1},defaultTimes:{averageTimes:[{categoryNames:[],minutes:{default:90}}],recoveryTimes:[{minutes:{default:60}}]},defaultDailyLimits:{SINGLES:2,DOUBLES:2,total:3},matchUpAverageTimes:[],matchUpRecoveryTimes:[],matchUpDailyLimits:[]}}function $(e){return structuredClone(e)}var YV=class{constructor(e){this.listeners=new Set,this.config=e,this.state={draft:$(e.initialPolicy??JV()),expandedSections:new Set([`modificationFlags`,`dailyLimits`,`defaultTimes`,`averageTimes`,`recoveryTimes`]),dirty:!1}}getState(){return this.state}getData(){return $(this.state.draft)}setData(e){this.state={...this.state,draft:$(e),dirty:!1},this.emit()}toggleSection(e){let t=new Set(this.state.expandedSections);t.has(e)?t.delete(e):t.add(e),this.state={...this.state,expandedSections:t},this.emit()}setModificationFlag(e,t){let n=$(this.state.draft);n.allowModificationWhenMatchUpsScheduled||={courts:!1,venues:!1},n.allowModificationWhenMatchUpsScheduled[e]=t,this.commitDraft(n)}setDailyLimit(e,t){let n=$(this.state.draft);n.defaultDailyLimits||={},n.defaultDailyLimits[e]=t,this.commitDraft(n)}setDefaultAverageTime(e,t,n){let r=$(this.state.draft);r.defaultTimes||={},r.defaultTimes.averageTimes||(r.defaultTimes.averageTimes=[{categoryNames:[],minutes:{default:90}}]);let i=r.defaultTimes.averageTimes[e];i&&(t===`DOUBLES`?n===void 0?delete i.minutes.DOUBLES:i.minutes.DOUBLES=n:i.minutes.default=n??0,this.commitDraft(r))}setDefaultRecoveryTime(e,t,n){let r=$(this.state.draft);r.defaultTimes||={},r.defaultTimes.recoveryTimes||(r.defaultTimes.recoveryTimes=[{minutes:{default:60}}]);let i=r.defaultTimes.recoveryTimes[e];i&&(t===`DOUBLES`?n===void 0?delete i.minutes.DOUBLES:i.minutes.DOUBLES=n:i.minutes.default=n??0,this.commitDraft(r))}addAverageFormatGroup(){let e=$(this.state.draft);e.matchUpAverageTimes||=[],e.matchUpAverageTimes.push({matchUpFormatCodes:[],averageTimes:[{categoryNames:[],minutes:{default:60}}]}),this.commitDraft(e)}removeAverageFormatGroup(e){let t=$(this.state.draft);t.matchUpAverageTimes&&(t.matchUpAverageTimes.splice(e,1),this.commitDraft(t))}setAverageFormatCodes(e,t){let n=$(this.state.draft),r=n.matchUpAverageTimes?.[e];r&&(r.matchUpFormatCodes=t,this.commitDraft(n))}setAverageTime(e,t,n,r){let i=$(this.state.draft),a=i.matchUpAverageTimes?.[e]?.averageTimes?.[t];a&&(n===`DOUBLES`?r===void 0?delete a.minutes.DOUBLES:a.minutes.DOUBLES=r:a.minutes.default=r??0,this.commitDraft(i))}addAverageCategoryOverride(e){let t=$(this.state.draft),n=t.matchUpAverageTimes?.[e];n&&(n.averageTimes.push({categoryTypes:[],minutes:{default:60}}),this.commitDraft(t))}removeAverageCategoryOverride(e,t){let n=$(this.state.draft),r=n.matchUpAverageTimes?.[e];r&&(r.averageTimes.splice(t,1),this.commitDraft(n))}setAverageOverrideCategories(e,t,n,r){let i=$(this.state.draft),a=i.matchUpAverageTimes?.[e]?.averageTimes?.[t];a&&(n===`categoryNames`?(delete a.categoryTypes,a.categoryNames=r):(delete a.categoryNames,a.categoryTypes=r),this.commitDraft(i))}addRecoveryFormatGroup(){let e=$(this.state.draft);e.matchUpRecoveryTimes||=[],e.matchUpRecoveryTimes.push({matchUpFormatCodes:[],recoveryTimes:[{categoryNames:[],minutes:{default:30}}]}),this.commitDraft(e)}removeRecoveryFormatGroup(e){let t=$(this.state.draft);t.matchUpRecoveryTimes&&(t.matchUpRecoveryTimes.splice(e,1),this.commitDraft(t))}setRecoveryFormatCodes(e,t){let n=$(this.state.draft),r=n.matchUpRecoveryTimes?.[e];r&&(r.matchUpFormatCodes=t,this.commitDraft(n))}setRecoveryTime(e,t,n,r){let i=$(this.state.draft),a=i.matchUpRecoveryTimes?.[e]?.recoveryTimes?.[t];a&&(n===`DOUBLES`?r===void 0?delete a.minutes.DOUBLES:a.minutes.DOUBLES=r:a.minutes.default=r??0,this.commitDraft(i))}addRecoveryCategoryOverride(e){let t=$(this.state.draft),n=t.matchUpRecoveryTimes?.[e];n&&(n.recoveryTimes.push({categoryTypes:[],minutes:{default:30}}),this.commitDraft(t))}removeRecoveryCategoryOverride(e,t){let n=$(this.state.draft),r=n.matchUpRecoveryTimes?.[e];r&&(r.recoveryTimes.splice(t,1),this.commitDraft(n))}setRecoveryOverrideCategories(e,t,n,r){let i=$(this.state.draft),a=i.matchUpRecoveryTimes?.[e]?.recoveryTimes?.[t];a&&(n===`categoryNames`?(delete a.categoryTypes,a.categoryNames=r):(delete a.categoryNames,a.categoryTypes=r),this.commitDraft(i))}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}commitDraft(e){this.state={...this.state,draft:e,dirty:!0},this.emit(),this.config.onChange?.($(e))}emit(){for(let e of this.listeners)e(this.state)}},XV=()=>`se-section`,ZV=()=>`se-section-header`,QV=()=>`se-section-chevron`,$V=()=>`se-section-body`,eH=()=>`se-field-row`,tH=()=>`se-field-label`,nH=()=>`se-field-input`,rH=()=>`se-field-unit`,iH=()=>`se-checkbox-row`,aH=()=>`se-format-group`,oH=()=>`se-format-group-header`,sH=()=>`se-format-group-label`,cH=()=>`se-tag-picker`,lH=()=>`sp-chip`,uH=()=>`sp-chip__remove`,dH=()=>`se-tag-add-wrap`,fH=()=>`sp-btn-icon`,pH=()=>`se-override-row`,mH=()=>`se-override-categories`,hH=()=>`se-override-remove`,gH=()=>`sp-btn sp-btn--sm sp-btn--outline se-add-btn`,_H=()=>`sp-btn-icon sp-btn-icon--danger`,vH=()=>`se-editor`;function yH(e){let t=document.createElement(`div`),n=document.createElement(`div`);n.className=iH();let r=document.createElement(`input`);r.type=`checkbox`,r.id=`se-mod-courts`;let i=document.createElement(`label`);i.htmlFor=`se-mod-courts`,i.textContent=`Allow court modifications when matchUps scheduled`,r.addEventListener(`change`,()=>{e.setModificationFlag(`courts`,r.checked)}),n.appendChild(r),n.appendChild(i);let a=document.createElement(`div`);a.className=iH();let o=document.createElement(`input`);o.type=`checkbox`,o.id=`se-mod-venues`;let s=document.createElement(`label`);s.htmlFor=`se-mod-venues`,s.textContent=`Allow venue modifications when matchUps scheduled`,o.addEventListener(`change`,()=>{e.setModificationFlag(`venues`,o.checked)}),a.appendChild(o),a.appendChild(s),t.appendChild(n),t.appendChild(a);function c(e){let t=e.draft.allowModificationWhenMatchUpsScheduled;r.checked=t?.courts??!1,o.checked=t?.venues??!1}return{element:t,update:c}}var bH=`is-success`,xH=`is-danger`;function SH(e){if(e===``)return!0;let t=parseInt(e,10);return!isNaN(t)&&t>=0&&String(t)===e.trim()}function CH(e,t){if(t===``){e.classList.remove(bH,xH);return}SH(t)?(e.classList.remove(xH),e.classList.add(bH)):(e.classList.remove(bH),e.classList.add(xH))}function wH(e){let t=document.createElement(`div`),n=[];for(let[r,i]of[[`SINGLES`,`Singles limit`],[`DOUBLES`,`Doubles limit`],[`total`,`Total limit`]]){let a=document.createElement(`div`);a.className=eH();let o=document.createElement(`div`);o.className=tH(),o.textContent=i;let s=document.createElement(`input`);s.type=`text`,s.className=nH(),s.placeholder=`0`,s.addEventListener(`input`,()=>{CH(s,s.value)}),s.addEventListener(`change`,()=>{let t=parseInt(s.value,10);!isNaN(t)&&t>=0&&e.setDailyLimit(r,t)}),a.appendChild(o),a.appendChild(s),t.appendChild(a),n.push({key:r,label:i,input:s})}function r(e){let t=e.draft.defaultDailyLimits;for(let e of n){let n=t?.[e.key];document.activeElement!==e.input&&(e.input.value=n===void 0?``:String(n))}}return{element:t,update:r}}var TH=`is-success`,EH=`is-danger`;function DH(e){if(e===``)return!0;let t=parseInt(e,10);return!isNaN(t)&&t>=0&&String(t)===e.trim()}function OH(e,t,n){if(t===``&&n){e.classList.remove(TH,EH);return}DH(t)&&(t!==``||n)?(e.classList.remove(EH),e.classList.add(TH)):(e.classList.remove(TH),e.classList.add(EH))}function kH(e){let t=document.createElement(`div`),n=document.createElement(`div`);n.style.cssText=`font-size:11px;font-weight:700;color:var(--sp-muted);margin-bottom:6px;`,n.textContent=`Default Average Times`,t.appendChild(n);let r=AH(`Default`,`min`,!1),i=AH(`Doubles override`,`min`,!0);t.appendChild(r.row),t.appendChild(i.row),r.input.addEventListener(`input`,()=>{OH(r.input,r.input.value,!1)}),r.input.addEventListener(`change`,()=>{let t=parseInt(r.input.value,10);!isNaN(t)&&t>=0&&e.setDefaultAverageTime(0,`default`,t)}),i.input.addEventListener(`input`,()=>{OH(i.input,i.input.value,!0)}),i.input.addEventListener(`change`,()=>{let t=i.input.value.trim();if(t===``||t===`-`)e.setDefaultAverageTime(0,`DOUBLES`,void 0);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&e.setDefaultAverageTime(0,`DOUBLES`,n)}});let a=document.createElement(`div`);a.style.height=`12px`,t.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`font-size:11px;font-weight:700;color:var(--sp-muted);margin-bottom:6px;`,o.textContent=`Default Recovery Times`,t.appendChild(o);let s=AH(`Default`,`min`,!1),c=AH(`Doubles override`,`min`,!0);t.appendChild(s.row),t.appendChild(c.row),s.input.addEventListener(`input`,()=>{OH(s.input,s.input.value,!1)}),s.input.addEventListener(`change`,()=>{let t=parseInt(s.input.value,10);!isNaN(t)&&t>=0&&e.setDefaultRecoveryTime(0,`default`,t)}),c.input.addEventListener(`input`,()=>{OH(c.input,c.input.value,!0)}),c.input.addEventListener(`change`,()=>{let t=c.input.value.trim();if(t===``||t===`-`)e.setDefaultRecoveryTime(0,`DOUBLES`,void 0);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&e.setDefaultRecoveryTime(0,`DOUBLES`,n)}});function l(e){let t=e.draft.defaultTimes?.averageTimes?.[0];document.activeElement!==r.input&&(r.input.value=t?String(t.minutes.default):``),document.activeElement!==i.input&&(i.input.value=t?.minutes.DOUBLES===void 0?``:String(t.minutes.DOUBLES)),i.input.placeholder=`—`;let n=e.draft.defaultTimes?.recoveryTimes?.[0];document.activeElement!==s.input&&(s.input.value=n?String(n.minutes.default):``),document.activeElement!==c.input&&(c.input.value=n?.minutes.DOUBLES===void 0?``:String(n.minutes.DOUBLES)),c.input.placeholder=`—`}return{element:t,update:l}}function AH(e,t,n){let r=document.createElement(`div`);r.className=eH();let i=document.createElement(`div`);i.className=tH(),i.textContent=e;let a=document.createElement(`input`);a.type=`text`,a.className=nH(),a.placeholder=n?`—`:`0`;let o=document.createElement(`div`);return o.className=rH(),o.textContent=t,r.appendChild(i),r.appendChild(a),r.appendChild(o),{row:r,input:a}}var jH=`is-success`,MH=`is-danger`;function NH(e){if(e===``)return!0;let t=parseInt(e,10);return!isNaN(t)&&t>=0&&String(t)===e.trim()}function PH(e,t,n){if(t===``&&n){e.classList.remove(jH,MH);return}NH(t)&&(t!==``||n)?(e.classList.remove(MH),e.classList.add(jH)):(e.classList.remove(jH),e.classList.add(MH))}function FH(e){let t=document.createElement(`div`);t.className=aH();let n=document.createElement(`div`);n.className=oH();let r=document.createElement(`div`);r.style.flex=`1`;let i=document.createElement(`div`);i.className=sH(),i.textContent=`Formats`,r.appendChild(i);let a=document.createElement(`div`);a.className=cH();for(let t of e.formatCodes){let n=document.createElement(`span`);n.className=lH(),n.title=`${t} — click to edit`;let r=document.createElement(`span`);r.textContent=KV(t),n.addEventListener(`click`,()=>{Ca({existingMatchUpFormat:t,callback:n=>{if(!n||n===t)return;let r=e.formatCodes.map(e=>e===t?n:e);e.onFormatCodesChange(r)}})});let i=document.createElement(`span`);i.className=uH(),i.textContent=`×`,i.addEventListener(`click`,n=>{n.stopPropagation(),e.onFormatCodesChange(e.formatCodes.filter(e=>e!==t))}),n.appendChild(r),n.appendChild(i),a.appendChild(n)}let o=document.createElement(`div`);o.className=dH();let s=document.createElement(`button`);s.className=fH(),s.textContent=`+`,s.type=`button`,s.title=`Add format code`,s.addEventListener(`click`,t=>{t.stopPropagation(),Ca({existingMatchUpFormat:`SET3-S:6/TB7`,callback:t=>{t&&!e.formatCodes.includes(t)&&e.onFormatCodesChange([...e.formatCodes,t])}})}),o.appendChild(s),a.appendChild(o),r.appendChild(a);let c=document.createElement(`button`);c.className=_H(),c.textContent=`×`,c.type=`button`,c.title=`Remove format group`,c.addEventListener(`click`,()=>e.onRemoveGroup()),n.appendChild(r),n.appendChild(c),t.appendChild(n);for(let n=0;n<e.overrides.length;n++){let r=e.overrides[n],i=document.createElement(`div`);i.className=pH();let a=document.createElement(`div`);a.className=`${mH()}${r.isDefault?` all`:``}`,a.textContent=r.categoryLabel;let o=document.createElement(`input`);o.type=`text`,o.className=nH(),o.value=String(r.defaultMinutes),o.placeholder=`0`;let s=n;o.addEventListener(`input`,()=>{PH(o,o.value,!1)}),o.addEventListener(`change`,()=>{let t=parseInt(o.value,10);!isNaN(t)&&t>=0&&e.onTimeChange(s,`default`,t)});let c=document.createElement(`span`);c.className=rH(),c.textContent=`min`;let l=document.createElement(`span`);l.style.cssText=`font-size:11px;color:var(--sp-muted);margin-left:8px;`,l.textContent=`Doubles:`;let u=document.createElement(`input`);if(u.type=`text`,u.className=nH(),u.value=r.doublesMinutes===void 0?``:String(r.doublesMinutes),u.placeholder=`—`,u.addEventListener(`input`,()=>{PH(u,u.value,!0)}),u.addEventListener(`change`,()=>{let t=u.value.trim();if(t===``||t===`-`)e.onTimeChange(s,`DOUBLES`,void 0);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&e.onTimeChange(s,`DOUBLES`,n)}}),i.appendChild(a),i.appendChild(o),i.appendChild(c),i.appendChild(l),i.appendChild(u),!r.isDefault){let t=document.createElement(`span`);t.className=hH(),t.textContent=`×`,t.addEventListener(`click`,()=>e.onRemoveOverride(s)),i.appendChild(t)}t.appendChild(i)}let l=document.createElement(`button`);return l.className=gH(),l.textContent=`+ Add Override`,l.type=`button`,l.addEventListener(`click`,()=>e.onAddOverride()),t.appendChild(l),t}function IH(e,t){let n=document.createElement(`div`),r=document.createElement(`div`);n.appendChild(r);let i=document.createElement(`button`);i.className=gH(),i.textContent=`+ Add Format Group`,i.type=`button`,i.addEventListener(`click`,()=>e.addAverageFormatGroup()),n.appendChild(i);function a(n){r.innerHTML=``;let i=n.draft.matchUpAverageTimes??[];for(let n=0;n<i.length;n++){let a=i[n],o=a.averageTimes.map((e,t)=>{let n=e.categoryTypes??e.categoryNames??[];return{categoryLabel:n.length===0&&t===0?`All categories`:n.join(`, `)||`All categories`,isDefault:n.length===0&&t===0,defaultMinutes:e.minutes.default,doublesMinutes:e.minutes.DOUBLES}}),s=n,c=FH({formatCodes:a.matchUpFormatCodes,overrides:o,availableFormats:t.matchUpFormatCodes??LH(),onFormatCodesChange:t=>e.setAverageFormatCodes(s,t),onTimeChange:(t,n,r)=>e.setAverageTime(s,t,n,r),onAddOverride:()=>e.addAverageCategoryOverride(s),onRemoveOverride:t=>e.removeAverageCategoryOverride(s,t),onRemoveGroup:()=>e.removeAverageFormatGroup(s)});r.appendChild(c)}if(i.length===0){let e=document.createElement(`div`);e.style.cssText=`font-size:12px;color:var(--sp-muted);padding:8px 0;`,e.textContent=`No format-specific average times configured. Add a format group to set per-format times.`,r.appendChild(e)}}return{element:n,update:a}}function LH(){return[`SET3-S:6/TB7`,`SET3-S:6/TB7-F:TB10`,`SET3-S:6/TB7-F:TB7`,`SET3-S:4NOAD-F:TB7`,`SET3-S:4/TB7`,`SET3-S:4/TB7-F:TB7`,`SET3-S:4/TB7-F:TB10`,`SET3-S:4/TB5@3`,`SET1-S:8/TB7`,`SET1-S:8/TB7@7`,`SET1-S:5/TB9@4`,`SET1-S:6/TB7`,`SET1-S:6NOAD`,`SET1-S:4/TB7`,`SET1-S:4/TB5@3`,`SET1-S:4NOAD`,`SET3-S:TB10`,`SET1-S:T20`,`SET1-S:TB10`]}function RH(e,t){let n=document.createElement(`div`),r=document.createElement(`div`);n.appendChild(r);let i=document.createElement(`button`);i.className=gH(),i.textContent=`+ Add Format Group`,i.type=`button`,i.addEventListener(`click`,()=>e.addRecoveryFormatGroup()),n.appendChild(i);function a(n){r.innerHTML=``;let i=n.draft.matchUpRecoveryTimes??[];for(let n=0;n<i.length;n++){let a=i[n],o=a.recoveryTimes.map((e,t)=>{let n=e.categoryTypes??e.categoryNames??[];return{categoryLabel:n.length===0&&t===0?`All categories`:n.join(`, `)||`All categories`,isDefault:n.length===0&&t===0,defaultMinutes:e.minutes.default,doublesMinutes:e.minutes.DOUBLES}}),s=n,c=FH({formatCodes:a.matchUpFormatCodes,overrides:o,availableFormats:t.matchUpFormatCodes??zH(),onFormatCodesChange:t=>e.setRecoveryFormatCodes(s,t),onTimeChange:(t,n,r)=>e.setRecoveryTime(s,t,n,r),onAddOverride:()=>e.addRecoveryCategoryOverride(s),onRemoveOverride:t=>e.removeRecoveryCategoryOverride(s,t),onRemoveGroup:()=>e.removeRecoveryFormatGroup(s)});r.appendChild(c)}if(i.length===0){let e=document.createElement(`div`);e.style.cssText=`font-size:12px;color:var(--sp-muted);padding:8px 0;`,e.textContent=`No format-specific recovery times configured. Add a format group to set per-format recovery.`,r.appendChild(e)}}return{element:n,update:a}}function zH(){return[`SET3-S:6/TB7`,`SET3-S:6/TB7-F:TB10`,`SET3-S:6/TB7-F:TB7`,`SET3-S:4NOAD-F:TB7`,`SET3-S:4/TB7`,`SET3-S:4/TB7-F:TB7`,`SET3-S:4/TB7-F:TB10`,`SET3-S:4/TB5@3`,`SET1-S:8/TB7`,`SET1-S:8/TB7@7`,`SET1-S:5/TB9@4`,`SET1-S:6/TB7`,`SET1-S:6NOAD`,`SET1-S:4/TB7`,`SET1-S:4/TB5@3`,`SET1-S:4NOAD`,`SET3-S:TB10`,`SET1-S:T20`,`SET1-S:TB10`]}function BH(e,t){let n=document.createElement(`div`);n.className=vH();let r=[{id:`modificationFlags`,label:`Modification Flags`,factory:()=>yH(e)},{id:`dailyLimits`,label:`Daily Limits`,factory:()=>wH(e)},{id:`defaultTimes`,label:`Default Times`,factory:()=>kH(e)},{id:`averageTimes`,label:`Match Average Times`,factory:()=>IH(e,t)},{id:`recoveryTimes`,label:`Match Recovery Times`,factory:()=>RH(e,t)}],i=[];for(let t of r){let r=document.createElement(`div`);r.className=XV();let a=document.createElement(`div`);a.className=ZV();let o=document.createElement(`span`);o.className=QV();let s=document.createElement(`span`);s.textContent=t.label,a.appendChild(o),a.appendChild(s),a.addEventListener(`click`,()=>e.toggleSection(t.id));let c=document.createElement(`div`);c.className=$V();let l=t.factory();c.appendChild(l.element),r.appendChild(a),r.appendChild(c),n.appendChild(r),i.push({id:t.id,chevron:o,bodyEl:c,inner:l})}function a(e){for(let t of i){let n=e.expandedSections.has(t.id);t.chevron.textContent=n?`▼`:`▶`,t.bodyEl.style.display=n?`block`:`none`,n&&t.inner.update(e)}}return{element:n,update:a}}var VH=class e{constructor(e){this.container=null,this.store=new YV(e),this.panel=BH(this.store,e),this.unsubscribe=this.store.subscribe(e=>{this.panel.update(e)}),this.panel.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.panel.element)}destroy(){this.unsubscribe(),this.container&&this.panel.element.parentNode===this.container&&this.container.removeChild(this.panel.element),this.container=null}getData(){return this.store.getData()}setData(e){this.store.setData(e)}getStore(){return this.store}static createEditorInstance(t){let n=new e({initialPolicy:t.initialData,onChange:e=>t.onChange(e)});return{element:n.panel.element,setData(e){n.setData(e)},getData(){return n.getData()},destroy(){n.destroy()}}}};function HH(e,t){let n=new VH(e);return n.render(t),n}var UH=()=>`pc-layout`,WH=()=>`pc-panel`,GH=()=>`pc-panel-header`,KH=()=>`pc-panel-title`,qH=()=>`pc-panel-meta`,JH=()=>`pc-toolbar`,YH=()=>`pc-input`,XH=()=>`pc-select`,ZH=()=>`pc-catalog`,QH=()=>`pc-group`,$H=()=>`pc-group-header`,eU=()=>`pc-group-chevron`,tU=()=>`pc-group-body`,nU=()=>`pc-card`,rU=()=>`pc-card-title`,iU=()=>`pc-card-meta`,aU=()=>`pc-type-badge`,oU=()=>`pc-editor`,sU=()=>`pc-editor-header`,cU=()=>`pc-editor-header-left`,lU=()=>`pc-editor-actions`,uU=()=>`sp-btn sp-btn--sm`,dU=()=>`sp-btn sp-btn--sm sp-btn--accent`,fU=()=>`pc-dirty-dot`,pU=()=>`pc-editor-body`,mU=()=>`pc-empty`,hU=()=>`pc-json-editor`,gU=()=>`pc-json-error`;function _U(e){let t=document.createElement(`div`);t.className=UH(),t.appendChild(e.catalogPanel.element),t.appendChild(e.editorShell.element);function n(t){e.catalogPanel.update(t),e.editorShell.update(t)}return{element:t,update:n}}var vU=`scheduling`,yU=`scoring`,bU=`seeding`,xU=`draws`,SU=`avoidance`,CU=`feedIn`,wU=`progression`,TU=`roundNaming`,EU=`positionActions`,DU=`matchUpActions`,OU=`roundRobinTally`,kU=`rankingPoints`,AU=`competitiveBands`,jU=`voluntaryConsolation`,MU=`participant`,NU=`display`,PU=`audit`,FU=`Tournament Operations`,IU=`Scoring & Results`,LU=`Ranking Points`,RU=`Draw Configuration`,zU=`Participants`,BU=`Display & Audit`,VU=(e,t,n,r,i)=>({policyType:e,label:t,description:n,group:r,hasEditor:i}),HU=[VU(vU,`Scheduling`,`Match scheduling, average times, recovery times, daily limits`,FU,!0),VU(EU,`Position Actions`,`Allowed position actions (alternates, walkovers, withdrawals)`,FU,!1),VU(DU,`MatchUp Actions`,`Allowed matchUp status transitions and actions`,FU,!1),VU(SU,`Avoidance`,`Draw placement avoidance rules (club, nationality, region)`,FU,!1),VU(yU,`Scoring`,`Score entry validation and completion rules`,IU,!1),VU(OU,`Round Robin Tally`,`Round-robin group standing calculation method`,IU,!1),VU(kU,`Ranking Points`,`Point allocation by draw size, round, and result`,LU,!0),VU(AU,`Competitive Bands`,`Rating/ranking band definitions for competitive grouping`,IU,!1),VU(xU,`Draws`,`Draw generation rules and structure options`,RU,!1),VU(bU,`Seeding`,`Seeding thresholds and placement rules by draw size`,RU,!1),VU(CU,`Feed-In`,`Feed-in consolation structure rules`,RU,!1),VU(wU,`Progression`,`Player progression between draw structures`,RU,!1),VU(jU,`Voluntary Consolation`,`Voluntary consolation entry rules`,RU,!1),VU(TU,`Round Naming`,`Custom round name labels (QF, SF, F, etc.)`,RU,!1),VU(MU,`Participant`,`Participant display and data rules`,zU,!1),VU(NU,`Display`,`Client display configuration (public vs admin views)`,BU,!1),VU(PU,`Audit`,`Audit trail and change logging configuration`,BU,!1)];function UU(e){return HU.find(t=>t.policyType===e)}function WU(e){return e===`rankingPoints`?IB():e===`scheduling`?JV():{}}var GU=[FU,IU,LU,RU,zU,BU];function KU(e,t){let n=t.toLowerCase().trim();return n?e.filter(e=>{let t=UU(e.policyType);return[e.name,e.description,e.policyType,t?.label??``,e.source].join(` `).toLowerCase().includes(n)}):e}function qU(e,t){let n=new Map;if(t===`type`){for(let e of GU)n.set(e,[]);for(let t of e){let e=UU(t.policyType)?.group??`Display & Audit`,r=n.get(e);r?r.push(t):n.set(e,[t])}for(let[e,t]of n)t.length===0&&n.delete(e)}else for(let t of e){let e=t.source===`builtin`?`Built-in Policies`:`User Policies`,r=n.get(e);r?r.push(t):n.set(e,[t])}return n}function JU(e){let t=document.createElement(`div`);t.className=WH(),t.style.overflowY=`auto`,t.style.scrollbarWidth=`thin`,t.style.scrollbarColor=`var(--sp-scrollbar) transparent`;let n=new Set,r=null,i=document.createElement(`div`);i.className=GH();let a=document.createElement(`div`);a.className=KH(),a.textContent=`Policy Catalog`;let o=document.createElement(`div`);o.className=qH(),i.appendChild(a),i.appendChild(o),t.appendChild(i);let s=document.createElement(`div`);s.className=JH();let c=document.createElement(`input`);c.type=`text`,c.placeholder=`Search policies...`,c.className=YH(),c.addEventListener(`input`,()=>e.onSearchChange(c.value));let l=document.createElement(`select`);l.className=XH();for(let[e,t]of[[`type`,`By Type`],[`source`,`By Source`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,l.appendChild(n)}l.addEventListener(`change`,()=>e.onGroupByChange(l.value));let u=document.createElement(`div`);u.style.cssText=`position:relative;flex-shrink:0`;let d=document.createElement(`button`);d.className=`sp-btn-icon`,d.textContent=`+`,d.title=`New policy`,d.style.cssText=`font-size:1rem;font-weight:700`;let f=document.createElement(`div`);f.style.cssText=`display:none;position:absolute;top:100%;right:0;z-index:100;min-width:180px;background:var(--sp-panel-bg);border:1px solid var(--sp-border);border-radius:12px;box-shadow:var(--sp-panel-shadow);padding:4px;margin-top:4px`;let p=HU.filter(e=>e.hasEditor);for(let t of p){let n=document.createElement(`div`);n.style.cssText=`padding:6px 10px;font-size:12px;border-radius:8px;cursor:pointer;color:var(--sp-text)`,n.textContent=t.label,n.addEventListener(`mouseenter`,()=>{n.style.background=`var(--sp-hover-bg)`}),n.addEventListener(`mouseleave`,()=>{n.style.background=``}),n.addEventListener(`click`,n=>{n.stopPropagation(),f.style.display=`none`,e.onNewPolicy?.(t.policyType)}),f.appendChild(n)}d.addEventListener(`click`,e=>{e.stopPropagation(),f.style.display=f.style.display===`none`?`block`:`none`}),document.addEventListener(`click`,()=>{f.style.display=`none`}),u.appendChild(d),u.appendChild(f),s.appendChild(c),s.appendChild(l),s.appendChild(u),t.appendChild(s);let m=document.createElement(`div`);m.className=ZH(),t.appendChild(m);function h(t){r=t;let i=KU(t.catalog,t.searchQuery),a=qU(i,t.groupBy);o.textContent=`${i.length} policies`,c.value!==t.searchQuery&&(c.value=t.searchQuery),l.value!==t.groupBy&&(l.value=t.groupBy),m.innerHTML=``;for(let[i,o]of a){let a=document.createElement(`div`);a.className=QH();let s=n.has(i),c=document.createElement(`div`);c.className=$H();let l=document.createElement(`span`);l.className=eU(),l.textContent=s?`▶`:`▼`;let u=document.createElement(`span`);u.textContent=`${i} (${o.length})`,c.appendChild(l),c.appendChild(u),c.addEventListener(`click`,()=>{n.has(i)?n.delete(i):n.add(i),r&&h(r)});let d=document.createElement(`div`);d.className=tU(),s&&(d.style.display=`none`);for(let n of o){let r=document.createElement(`div`);r.className=nU(),n.id===t.selectedId&&r.classList.add(`active`),r.addEventListener(`click`,()=>e.onSelectPolicy(n.id));let i=document.createElement(`div`);i.style.cssText=`display:flex;align-items:center;gap:4px`;let a=document.createElement(`div`);if(a.className=rU(),a.style.flex=`1`,a.textContent=n.name,i.appendChild(a),e.onDuplicatePolicy){let t=document.createElement(`span`);t.style.cssText=`font-size:10px;cursor:pointer;color:var(--sp-muted);padding:2px`,t.textContent=`⎘`,t.title=`Duplicate`,t.addEventListener(`click`,t=>{t.stopPropagation(),e.onDuplicatePolicy?.(n.id)}),i.appendChild(t)}if(n.source===`user`&&e.onDeletePolicy){let t=document.createElement(`span`);t.style.cssText=`font-size:10px;cursor:pointer;color:var(--sp-muted);padding:2px`,t.textContent=`✕`,t.title=`Delete`,t.addEventListener(`click`,t=>{t.stopPropagation(),e.onDeletePolicy?.(n.id)}),i.appendChild(t)}r.appendChild(i);let o=document.createElement(`div`);o.className=iU();let s=UU(n.policyType),c=document.createElement(`span`);c.className=aU(),c.textContent=s?.label??n.policyType;let l=document.createElement(`span`);l.className=`${aU()} ${n.source}`,l.textContent=n.source,o.appendChild(c),o.appendChild(l),r.appendChild(o),d.appendChild(r)}a.appendChild(c),a.appendChild(d),m.appendChild(a)}}return{element:t,update:h}}function YU(e){return structuredClone(e)}var XU=class{constructor(e){this.listeners=new Set,this.config=e;let t=new Set((e.builtinPolicies??[]).map(e=>e.id)),n=[...e.builtinPolicies??[],...(e.userPolicies??[]).filter(e=>!t.has(e.id))];this.state={catalog:n,searchQuery:``,groupBy:`type`,selectedId:null,editorDraft:null,dirty:!1}}getState(){return this.state}getSelectedItem(){return this.state.selectedId?this.state.catalog.find(e=>e.id===this.state.selectedId)??null:null}setCatalogSearch(e){this.setState({searchQuery:e})}setCatalogGroupBy(e){this.setState({groupBy:e})}selectPolicy(e){if(this.state.selectedId===e)return;let t=this.state.catalog.find(t=>t.id===e);t&&(this.setState({selectedId:e,editorDraft:YU(t.policyData),dirty:!1}),this.config.onSelectionChanged?.(t))}clearSelection(){this.state.selectedId&&(this.setState({selectedId:null,editorDraft:null,dirty:!1}),this.config.onSelectionChanged?.(null))}updateEditorDraft(e){this.setState({editorDraft:e,dirty:!0})}markDirty(){this.state.dirty||this.setState({dirty:!0})}markClean(){this.state.dirty&&this.setState({dirty:!1})}savePolicy(){let e=this.getSelectedItem();if(!e||!this.state.editorDraft)return;let t={...e,policyData:YU(this.state.editorDraft)},n=this.state.catalog.map(e=>e.id===t.id?t:e);this.state={...this.state,catalog:n,dirty:!1},this.emit(),this.config.onPolicySaved?.(t)}resetDraft(){let e=this.getSelectedItem();e&&this.setState({editorDraft:YU(e.policyData),dirty:!1})}applyPolicy(){let e=this.getSelectedItem();if(!e)return;let t={...e,policyData:this.state.editorDraft?YU(this.state.editorDraft):YU(e.policyData)};this.config.onPolicyApplied?.(t)}addNewPolicy(e){let t=`user-${e}-${Date.now()}`,n={id:t,name:`New ${e} policy`,policyType:e,source:`user`,description:``,policyData:WU(e)},r=[...this.state.catalog,n];return this.state={...this.state,catalog:r,selectedId:t,editorDraft:YU(n.policyData),dirty:!1},this.emit(),this.config.onPolicyCreated?.(n),this.config.onSelectionChanged?.(n),t}duplicatePolicy(e){let t=this.state.catalog.find(t=>t.id===e);if(!t)return null;let n=`user-${t.policyType}-${Date.now()}`,r={id:n,name:`${t.name} (Copy)`,policyType:t.policyType,source:`user`,description:t.description,policyData:YU(t.policyData)},i=[...this.state.catalog,r];return this.state={...this.state,catalog:i,selectedId:n,editorDraft:YU(r.policyData),dirty:!1},this.emit(),this.config.onPolicyCreated?.(r),this.config.onSelectionChanged?.(r),n}deletePolicy(e){let t=this.state.catalog.find(t=>t.id===e);if(!t||t.source===`builtin`)return;let n=this.state.catalog.filter(t=>t.id!==e),r=this.state.selectedId===e;this.state={...this.state,catalog:n,...r?{selectedId:null,editorDraft:null,dirty:!1}:{}},this.emit(),this.config.onPolicyDeleted?.(e),r&&this.config.onSelectionChanged?.(null)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state={...this.state,...e},this.emit()}emit(){for(let e of this.listeners)e(this.state)}};function ZU(e){let t=document.createElement(`div`);t.className=WH();let n=document.createElement(`div`);n.className=oU();let r=document.createElement(`div`);r.className=sU();let i=document.createElement(`div`);i.className=cU();let a=document.createElement(`div`);a.className=KH();let o=document.createElement(`span`);o.className=aU();let s=document.createElement(`span`);s.className=aU(),s.textContent=`read-only`,s.style.display=`none`;let c=document.createElement(`div`);c.className=fU(),c.style.display=`none`,c.title=`Unsaved changes`,i.appendChild(c),i.appendChild(a),i.appendChild(o),i.appendChild(s);let l=document.createElement(`div`);l.className=lU();let u=document.createElement(`button`);u.className=uU(),u.textContent=`Reset`,u.addEventListener(`click`,()=>e.onReset());let d=document.createElement(`button`);d.className=dU(),d.textContent=`Save`,d.addEventListener(`click`,()=>e.onSave());let f=document.createElement(`button`);f.className=uU(),f.textContent=`Apply`,f.addEventListener(`click`,()=>e.onApply());let p=document.createElement(`button`);p.className=uU(),p.textContent=`Duplicate`,p.addEventListener(`click`,()=>e.onDuplicate()),l.appendChild(u),l.appendChild(d),l.appendChild(f),l.appendChild(p);let m=document.createElement(`div`);m.className=lU();let h=document.createElement(`button`);h.className=dU(),h.textContent=`Use as Template`,h.addEventListener(`click`,()=>e.onDuplicate()),m.appendChild(h),r.appendChild(i),r.appendChild(l),r.appendChild(m);let g=document.createElement(`div`);g.className=pU(),n.appendChild(r),n.appendChild(g);let _=document.createElement(`div`);_.className=mU(),_.textContent=`Select a policy to edit`,t.appendChild(n),t.appendChild(_);function v(e){let t=e.selectedId!==null;if(n.style.display=t?`flex`:`none`,_.style.display=t?`none`:`flex`,!t)return;let r=e.catalog.find(t=>t.id===e.selectedId);if(!r)return;let i=r.source===`builtin`;a.textContent=r.name,o.textContent=UU(r.policyType)?.label??r.policyType,s.style.display=i?``:`none`,l.style.display=i?`none`:`flex`,m.style.display=i?`flex`:`none`,c.style.display=!i&&e.dirty?`block`:`none`}return{element:t,update:v,bodyElement:g}}function QU(e){let t=document.createElement(`div`);t.className=hU();let n=document.createElement(`textarea`);n.value=JSON.stringify(e.initialData,null,2);let r=document.createElement(`div`);r.className=gU(),r.style.display=`none`;let i={...e.initialData};return n.addEventListener(`input`,()=>{try{let t=JSON.parse(n.value);i=t,r.style.display=`none`,e.onChange(t)}catch(e){r.style.display=`block`,r.textContent=`Invalid JSON: ${e.message}`}}),t.appendChild(n),t.appendChild(r),{element:t,setData(e){i={...e},n.value=JSON.stringify(e,null,2),r.style.display=`none`},getData(){return{...i}},destroy(){t.remove()}}}var $U=class{constructor(e){this.currentEditor=null,this.container=null,this.store=new XU(e);let t=JU({onSearchChange:e=>this.store.setCatalogSearch(e),onGroupByChange:e=>this.store.setCatalogGroupBy(e),onSelectPolicy:e=>this.handleSelectPolicy(e),onNewPolicy:e=>{this.store.addNewPolicy(e),this.mountEditorForSelection()},onDuplicatePolicy:e=>{this.store.duplicatePolicy(e),this.mountEditorForSelection()},onDeletePolicy:e=>{this.store.deletePolicy(e),this.store.getSelectedItem()||this.destroyCurrentEditor()}});this.editorShell=ZU({onSave:()=>this.store.savePolicy(),onReset:()=>{this.store.resetDraft(),this.syncEditorFromStore()},onApply:()=>this.store.applyPolicy(),onDuplicate:()=>{let e=this.store.getSelectedItem();e&&(this.store.duplicatePolicy(e.id),this.mountEditorForSelection())}}),this.layout=_U({catalogPanel:t,editorShell:this.editorShell}),this.unsubscribe=this.store.subscribe(e=>{this.layout.update(e)}),this.layout.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.layout.element)}destroy(){this.destroyCurrentEditor(),this.unsubscribe(),this.container&&this.layout.element.parentNode===this.container&&this.layout.element.remove(),this.container=null}getStore(){return this.store}handleSelectPolicy(e){this.store.selectPolicy(e),this.mountEditorForSelection()}mountEditorForSelection(){this.destroyCurrentEditor();let e=this.store.getSelectedItem();if(!e)return;let t=e.source===`builtin`,n={initialData:{...e.policyData},onChange:e=>{this.store.updateEditorDraft(e)},readonly:t};e.policyType===`scheduling`?this.currentEditor=VH.createEditorInstance(n):e.policyType===`rankingPoints`?this.currentEditor=GV.createEditorInstance(n):this.currentEditor=QU(n),this.editorShell.bodyElement.innerHTML=``,this.editorShell.bodyElement.appendChild(this.currentEditor.element)}syncEditorFromStore(){let e=this.store.getState();this.currentEditor&&e.editorDraft&&this.currentEditor.setData(e.editorDraft)}destroyCurrentEditor(){this.currentEditor&&=(this.currentEditor.destroy(),null),this.editorShell.bodyElement.innerHTML=``}};function eW(e,t,n,r){e!==void 0&&e<0&&r.push({severity:`error`,path:t,message:n})}function tW(e,t){if(!e.defaultTimes)return;let n=e.defaultTimes.averageTimes;if(n)for(let e=0;e<n.length;e++)eW(n[e].minutes.default,`defaultTimes.averageTimes[${e}].minutes.default`,`Default average time must be non-negative`,t),eW(n[e].minutes.DOUBLES,`defaultTimes.averageTimes[${e}].minutes.DOUBLES`,`Doubles average time must be non-negative`,t);let r=e.defaultTimes.recoveryTimes;if(r)for(let e=0;e<r.length;e++)eW(r[e].minutes.default,`defaultTimes.recoveryTimes[${e}].minutes.default`,`Default recovery time must be non-negative`,t)}function nW(e,t){if(!e.defaultDailyLimits)return;let n=e.defaultDailyLimits;eW(n.SINGLES,`defaultDailyLimits.SINGLES`,`Singles daily limit must be non-negative`,t),eW(n.DOUBLES,`defaultDailyLimits.DOUBLES`,`Doubles daily limit must be non-negative`,t),eW(n.total,`defaultDailyLimits.total`,`Total daily limit must be non-negative`,t)}function rW(e){let t=[];return tW(e,t),nW(e,t),e.matchUpAverageTimes&&iW(e.matchUpAverageTimes,`matchUpAverageTimes`,`averageTimes`,t),e.matchUpRecoveryTimes&&aW(e.matchUpRecoveryTimes,`matchUpRecoveryTimes`,t),oW(e,t),t}function iW(e,t,n,r){for(let i=0;i<e.length;i++){let a=e[i];a.matchUpFormatCodes.length||r.push({severity:`error`,path:`${t}[${i}].matchUpFormatCodes`,message:`At least one format code is required per format group`});let o=a[n];if(o)for(let e=0;e<o.length;e++)eW(o[e].minutes.default,`${t}[${i}].${n}[${e}].minutes.default`,`Time must be non-negative`,r),eW(o[e].minutes.DOUBLES,`${t}[${i}].${n}[${e}].minutes.DOUBLES`,`Doubles time must be non-negative`,r)}}function aW(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];i.matchUpFormatCodes.length||n.push({severity:`error`,path:`${t}[${r}].matchUpFormatCodes`,message:`At least one format code is required per format group`});for(let e=0;e<i.recoveryTimes.length;e++)eW(i.recoveryTimes[e].minutes.default,`${t}[${r}].recoveryTimes[${e}].minutes.default`,`Recovery time must be non-negative`,n),eW(i.recoveryTimes[e].minutes.DOUBLES,`${t}[${r}].recoveryTimes[${e}].minutes.DOUBLES`,`Doubles recovery time must be non-negative`,n)}}function oW(e,t){let n=(e,n)=>{if(!e)return;let r=new Map;for(let i=0;i<e.length;i++)for(let a of e[i].matchUpFormatCodes)r.has(a)?t.push({severity:`warning`,path:`${n}[${i}].matchUpFormatCodes`,message:`Format code "${a}" also appears in group ${r.get(a)}`}):r.set(a,i)};n(e.matchUpAverageTimes,`matchUpAverageTimes`),n(e.matchUpRecoveryTimes,`matchUpRecoveryTimes`)}function sW(e,t){let n=new $U(e);return n.render(t),n}e.COURT_SVG_RESOURCE_SUB_TYPE=qm,e.CompositionEditorStore=ez,e.DEFAULT_COURT_CARD_CONFIG=o_,e.DEFAULT_EVENT_CARD_CONFIG=J_,e.DEFAULT_SCHEDULE_CELL_CONFIG=MR,e.DEFAULT_TOURNAMENT_CARD_CONFIG=dh,e.DEFAULT_VENUE_CARD_CONFIG=gg,e.DrawStateManager=py,e.EVENT_CARD_LIGHT_MODE_THRESHOLD=Y_,e.InlineScoringManager=Zo,e.MATCH_FORMATS=ny,e.POLICY_TYPE_GROUPS=GU,e.POLICY_TYPE_METADATA=HU,e.PolicyCatalogControl=$U,e.PolicyCatalogStore=XU,e.ProfileStore=TA,e.SchedulePageControl=uR,e.SchedulePageStore=lR,e.SchedulingEditorControl=VH,e.SchedulingEditorStore=YV,e.SchedulingProfileControl=RA,e.TemporalGrid=MN,e.TopologyBuilderControl=PI,e.TopologyStore=NP,e.activateScheduleCellTypeAhead=QR,e.applyDropCommit=xA,e.badmintonCourt=Gm,e.barButton=hO,e.baseballDiamond=Hm,e.basketballCourt=Vm,e.buildActiveStripPanel=kR,e.buildCardSkeleton=uh,e.buildCourtCard=E_,e.buildCourtGridSlot=cR,e.buildCourtSkeletonCard=H_,e.buildDateStrip=IA,e.buildEdgeEditor=OF,e.buildEditorShell=ZU,e.buildEventCard=yv,e.buildEventSkeletonCard=Lv,e.buildInspectorPanel=Yk,e.buildInteractiveScoringShell=kB,e.buildIssueIndex=yA,e.buildIssuesPanel=iA,e.buildJsonEditor=QU,e.buildMatchUpCard=eR,e.buildMatchUpCatalog=rR,e.buildNodeEditor=gF,e.buildPolicyCatalogLayout=_U,e.buildPolicyCatalogPanel=JU,e.buildRatingDistributionChart=sO,e.buildRoundCard=jA,e.buildRoundCatalog=rA,e.buildScheduleDateStrip=sR,e.buildScheduleGridCell=NR,e.buildScheduleInspectorPanel=JL,e.buildScheduleIssueIndex=iR,e.buildScheduleIssuesPanel=oR,e.buildSchedulePageLayout=WL,e.buildSchedulingEditorPanel=BH,e.buildSchedulingProfileLayout=Fk,e.buildSetScore=Es,e.buildSkeletonCard=eg,e.buildStructureCard=vP,e.buildToolbar=rI,e.buildTopologyBuilderLayout=iI,e.buildTopologyCanvas=WP,e.buildTournamentCard=Ih,e.buildVenueBoard=NA,e.buildVenueCard=Lg,e.buildVenueSkeletonCard=e_,e.burstChart=xD,e.cModal=F,e.calculateComplement=Ss,e.compositions=ri,e.controlBar=NO,e.courthiveComponentsVersion=ty,e.createCardPopoverManager=Ik,e.createCompositionEditor=Yz,e.createCourtSvg=eh,e.createInlineScoringFooter=DB,e.createPolicyCatalog=sW,e.createPrintCompositionEditor=tB,e.createSchedulePage=$R,e.createSchedulingEditor=HH,e.createSchedulingProfile=zA,e.createTemporalGrid=NN,e.destroyTipster=Lm,e.drawer=td,e.dropDownButton=uO,e.emptySchedulingPolicy=JV,e.engineToMatchUp=Yo,e.extractCourtSvgSport=lh,e.extractImageURL=ch,e.filterCatalog=Qk,e.filterMatchUpCatalog=QL,e.filterPolicyCatalog=KU,e.findIssuesForLocator=Gk,e.formatAddress=nh,e.formatCodeLabel=KV,e.formatDateRange=oh,e.formatFeeRange=dg,e.formatVenueLocation=rh,e.fromFactoryDrawData=DD,e.fromLegacyDraw=AD,e.generatePreviewMatchUps=JN,e.getAgeCategoryModal=uo,e.getCategoryModal=mo,e.getFlightProfileModal=Go,e.getGenerateTeamsModal=Di,e.getMatchUpFormatModal=Ca,e.getMatchWinner=xs,e.getMaxAllowedScore=_s,e.getMockParticipantsModal=xi,e.getPlannedRoundKeys=eA,e.getPolicyTypeMeta=UU,e.getPortPosition=yP,e.getRoundAt=Wk,e.getScoringConfig=es,e.getSetFormatForIndex=ms,e.getSetWinner=ys,e.getVenueRounds=Uk,e.groupCatalog=$k,e.groupMatchUpCatalog=$L,e.groupPolicyCatalog=qU,e.hockeyRink=Um,e.initDrawer=nd,e.isCompletedStatus=ZL,e.isMatchComplete=bs,e.isSetComplete=vs,e.isSetTiebreakOnly=hs,e.isSetTimed=gs,e.mapCourtToCardData=q_,e.mapEventToCardData=$v,e.mapMatchUpToCellData=ZR,e.mapTournamentToCardData=hg,e.mapVenueToCardData=a_,e.matchUpLabel=GL,e.matchUpSearchKey=qL,e.maxSeverity=qk,e.mergeCourtCardConfig=s_,e.mergeEventCardConfig=X_,e.mergeTournamentCardConfig=fh,e.mergeVenueCardConfig=_g,e.notesToolbar=gm,e.openCompositionEditorModal=Ni,e.openScheduleCellConfigModal=Fi,e.padelCourt=Km,e.participantLabel=KL,e.pickleballCourt=Wm,e.renderButtons=ry,e.renderContainer=Jr,e.renderField=ln,e.renderForm=ui,e.renderInlineMatchUp=qo,e.renderMatchUp=Wr,e.renderMenu=Pm,e.renderOptions=cn,e.renderParticipant=cr,e.renderParticipantInput=gn,e.renderRound=Gr,e.renderRoundHeader=ur,e.renderSchematicMatchUp=si,e.renderSchematicRound=ci,e.renderSchematicStructure=li,e.renderScorecard=_B,e.renderStructure=Kr,e.renderTeamVsHeader=vB,e.resetScoringConfig=ns,e.resolveCourtSport=Qm,e.resolveEventStatus=Bv,e.resolvePublishedComposition=ai,e.resolveTournamentStatus=ag,e.scoringModal=Wl,e.selectItem=fO,e.setScoringConfig=ts,e.shouldApplySmartComplement=Cs,e.shouldCreateNextSet=Ts,e.shouldShowTiebreak=ws,e.showCourtAvailabilityModal=AN,e.sportFromMatchUpFormat=Zm,e.standardTemplates=wI,e.syncClearVisibility=_y,e.tennisCourt=Bm,e.tipster=Rm,e.toggleOverlay=CO,e.topologyToDrawOptions=ZI,e.updateHeadingSelect=vm,e.updateTieScore=yB,e.updateToolbarState=_m,e.validateProfile=cA,e.validateSchedulingPolicy=rW,e.validateTopology=RF,e.validator=an,Object.defineProperty(e,`validators`,{enumerable:!0,get:function(){return fy}}),e.wrapSearchWithClear=gy});
|
|
320
|
+
`}e.innerHTML=a,e.querySelectorAll(`.court-checkbox`).forEach(e=>{e.addEventListener(`change`,this.handleCourtCheckboxChange)}),e.querySelectorAll(`.venue-checkbox`).forEach(e=>{e.addEventListener(`change`,this.handleVenueCheckboxChange)}),e.querySelectorAll(`.venue-edit-icon`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation();let t=e.currentTarget,n=t.dataset.venue,r=t.dataset.tournamentId,i=t.dataset.venueName||n,a=this.control?.getDay()||this.engine.getActiveDays()[0]||`2026-01-01`,o=this.engine.getVenueAvailability(r,n),s=this.engine.getConfig();KP({title:`Venue Defaults \u2014 ${i}`,currentDay:a,currentStartTime:o?.startTime||s.dayStartTime,currentEndTime:o?.endTime||s.dayEndTime,showScopeToggle:!1,onConfirm:({startTime:e,endTime:t})=>{this.engine.setVenueDefaultAvailability(r,n,{startTime:e,endTime:t}),this.engine.clearCourtAvailabilityForVenue(r,n),this.control?.refresh()}})})}),e.querySelectorAll(`.court-edit-icon`).forEach(e=>{e.addEventListener(`click`,e=>{e.stopPropagation();let t=e.currentTarget,n=t.dataset.courtId,r=t.dataset.venueId,i=t.dataset.tournamentId,a=t.dataset.courtName||n,o={tournamentId:i,venueId:r,courtId:n},s=this.control?.getDay()||this.engine.getActiveDays()[0]||`2026-01-01`,c=this.engine.getCourtAvailability(o,s);KP({title:`Court \u2014 ${a}`,currentDay:s,currentStartTime:c.startTime,currentEndTime:c.endTime,showScopeToggle:!0,onConfirm:({startTime:e,endTime:t,scope:n})=>{n===`all-days`?this.engine.setCourtAvailabilityAllDays(o,{startTime:e,endTime:t}):this.engine.setCourtAvailability(o,s,{startTime:e,endTime:t}),this.control?.refresh()}})})})}updateVenueCheckboxState(e){let t=this.engine.listCourtMeta().filter(t=>t.ref.venueId===e),n=t.filter(e=>{let t=`${e.ref.tournamentId}|${e.ref.venueId}|${e.ref.courtId}`;return this.visibleCourts.has(t)}).length,r=this.venueTreeElement?.querySelector(`.venue-checkbox[data-venue="${e}"]`);r&&(n===0?(r.checked=!1,r.indeterminate=!1):n===t.length?(r.checked=!0,r.indeterminate=!1):(r.checked=!1,r.indeterminate=!0))}getEngine(){return this.engine}getControl(){return this.control}setDay(e){this.control?.setDay(e),this.updateCapacityStats()}refresh(){this.control?.refresh(),this.updateCapacityStats(),this.updateVenueTree()}};function YP(e,t){let n=new JP(e);return n.render(t),n}var{LUCKY_DRAW:XP,ROUND_ROBIN:ZP,AD_HOC:QP}=t.drawDefinitionConstants;function $P(e){let t=Math.max(2,e),n=2**Math.floor(Math.log2(t)),r=t-n;if(r<=0)return new Map;let i=new Map,a=0,o=n/2;for(;o>=1;)a++,r&o&&(a++,i.set(a,o)),o=Math.floor(o/2);return i}function eF(e){let t=Math.max(2,e),n=2**Math.floor(Math.log2(t)),r=t-n,i=0,a=n/2;for(;a>=1;)i++,r&a&&i++,a=Math.floor(a/2);return i}function tF(e){let t=Math.max(2,e),n=t%2?t+1:t,r=!!(Math.ceil(n/2)%2),i=[{participantsCount:n,preFeedRound:r}];for(;n>2;){let e=Math.ceil(n/2),t=e===1,r=!!(!t&&e%2);n=!t&&r?e+1:e;let a=!!(n!==2&&Math.ceil(n/2)%2);i.push({participantsCount:n,preFeedRound:a,feedRound:r})}return i}function nF(e){let t=Math.max(2,e);return t&t-1?tF(e).length:Math.ceil(Math.log2(t))}function rF(e,t){let n=Math.max(2,e);if(!(n&n-1))return Math.floor(n/2**t);let r=tF(e),i=t-1;if(i<0||i>=r.length)return 0;let{participantsCount:a,preFeedRound:o}=r[i],s=a/2,c=o?s-1:s;if(t===1&&n%2!=0){let e=a-n;c-=e}return c}function iF(e,t,n){return e===ZP?(n?.groupSize||Math.min(t,4))-1:e===QP?n?.roundsCount||1:e===XP?nF(t):eF(t)}function aF(e,t,n){return e===XP?rF(t,n):Math.floor(t/2**n)}var{ROUND_ROBIN:oF,AD_HOC:sF,LUCKY_DRAW:cF}=t.drawDefinitionConstants,lF=0;function uF({structureType:e,drawSize:t,stage:n,structureId:r,qualifyingPositions:i,structureOptions:a}){return e===oF?fF({drawSize:t,stage:n,structureId:r,structureOptions:a}):e===sF?mF({drawSize:t,stage:n,structureId:r,roundsCount:a?.roundsCount||1}):e===cF?pF({drawSize:t,stage:n,structureId:r}):dF({drawSize:t,stage:n,structureId:r,qualifyingPositions:i})}function dF({drawSize:e,stage:t,structureId:n,qualifyingPositions:r}){let i=Math.max(2,e),a=2**Math.floor(Math.log2(i)),o=i-a,s=[],c=a/2;for(;c>=1;)s.push({count:c,isFeed:!1}),o&c&&s.push({count:c,isFeed:!0}),c=Math.floor(c/2);if(r&&r>0&&e>r){let t=Math.round(Math.log2(e/r));t>0&&s.length>t&&(s.length=t)}let l=s.length,u=[],d=1,f=0,p=new Set;for(let e=0;e<l-1;e++)!s[e].isFeed&&s[e+1].isFeed&&p.add(e);for(let e=0;e<l;e++){let{count:r,isFeed:i}=s[e],a=e+1,o=i?2**Math.max(0,f-1):2**f,c=i||p.has(e);for(let s=1;s<=r;s++){let r=a===1&&!i;u.push({matchUpId:`preview-${++lF}`,roundNumber:a,roundPosition:s,drawPositions:r?[(s-1)*2+1,(s-1)*2+2]:i?[d++]:[],finishingRound:l-e,roundFactor:o,preFeedRound:c,stage:t,structureId:n})}i||f++}return u}function fF({drawSize:e,stage:t,structureId:n,structureOptions:r}){let i=[],a=r?.groupSize||Math.min(e,4),o=Math.ceil(e/a),s=a-1;for(let e=0;e<o;e++)for(let r=1;r<=s;r++){let o=Math.floor(a/2);for(let a=1;a<=o;a++)i.push({matchUpId:`preview-${++lF}`,roundNumber:r,roundPosition:e*o+a,isRoundRobin:!0,stage:t,structureId:`${n}-g${e}`})}return i}function pF({drawSize:e,stage:t,structureId:n}){let r=Math.max(2,e);if(!(r&r-1))return dF({drawSize:e,stage:t,structureId:n});let i=tF(r),a=i.length,o=[],s=1;for(let e=0;e<a;e++){let{participantsCount:r,preFeedRound:c}=i[e],l=r/2,u=e+1;for(let r=1;r<=l;r++){let i=u===1;o.push({matchUpId:`preview-${++lF}`,roundNumber:u,roundPosition:r,drawPositions:i?[s++,s++]:[],finishingRound:a-e,roundFactor:1,preFeedRound:!!c,stage:t,structureId:n})}}return o}function mF({drawSize:e,stage:t,structureId:n,roundsCount:r=1}){let i=[];if(e<2)return i;let a=Math.floor(e/2);for(let e=1;e<=r;e++)for(let r=1;r<=a;r++)i.push({matchUpId:`preview-${++lF}`,roundNumber:e,roundPosition:r,finishingRound:1,stage:t,structureId:n});return i}var{ROUND_ROBIN:hF}=t.drawDefinitionConstants,gF=new Map;function _F(e,n,r){let i=`${e}:${n}:${r||``}`,a=gF.get(i);if(a)return a;try{let a={drawSize:n,drawType:e};r&&(a.structureOptions={groupSize:r});let{tournamentRecord:o}=t.mocksEngine.generateTournamentRecord({drawProfiles:[a]}),s=o?.events?.[0]?.drawDefinitions?.[0];if(!s)return vF(i,{});let c=(s.structures||[])[0];if(!c)return vF(i,{});let l=c.structureType===`CONTAINER`,u={};if(l||e===hF){let{availablePlayoffProfiles:e}=t.drawsGovernor.getAvailablePlayoffProfiles({drawDefinition:s}),n=e?.[0];n&&(u={playoffFinishingPositionRanges:n.playoffFinishingPositionRanges,finishingPositionsAvailable:n.finishingPositionsAvailable})}else{let e=c.structureId,{playoffRounds:n,playoffRoundsRanges:r}=t.drawsGovernor.getAvailablePlayoffProfiles({drawDefinition:s,structureId:e});u={playoffRounds:n,playoffRoundsRanges:r}}return vF(i,u)}catch{return vF(i,{})}}function vF(e,t){return gF.set(e,t),t}var{MAIN:yF,QUALIFYING:bF,CONSOLATION:xF,PLAY_OFF:SF,ROUND_ROBIN:CF,AD_HOC:wF,LUCKY_DRAW:TF,WINNER:EF,LOSER:DF}=t.drawDefinitionConstants,OF=240,kF=48,AF=16;function jF(e){if(e.structureType===CF)return(e.structureOptions?.groupSize||Math.min(e.drawSize,4))-1;if(e.structureType===wF)return e.structureOptions?.roundsCount||1;if(e.structureType===TF)return nF(e.drawSize);let t=Math.max(2,e.drawSize),n=2**Math.floor(Math.log2(t)),r=t-n,i=0,a=n/2;for(;a>=1;)i++,r&a&&i++,a=Math.floor(a/2);if(e.qualifyingPositions&&e.qualifyingPositions>0&&e.drawSize>e.qualifyingPositions){let t=Math.round(Math.log2(e.drawSize/e.qualifyingPositions));t>0&&t<i&&(i=t)}return i}function MF(e){let t=jF(e);return Math.max(OF,t*kF+AF)}var NF={[yF]:`tb-card-badge--main`,[bF]:`tb-card-badge--qualifying`,[xF]:`tb-card-badge--consolation`,[SF]:`tb-card-badge--playoff`};function PF(e,t,n,r,i,a,o,s){let c=a&&a.length>0,l=document.createElement(`div`);l.className=`tb-card${n?` tb-card--selected`:``}${c?` tb-card--warning`:``}`,l.style.left=`${e.position.x}px`,l.style.top=`${e.position.y}px`,l.style.minWidth=`${MF(e)}px`,l.setAttribute(`data-node-id`,e.id);let u=document.createElement(`div`);u.className=`tb-card-header`;let d=document.createElement(`span`);d.className=`tb-card-badge ${NF[e.stage]||`tb-card-badge--main`}`,d.textContent=e.stage.substring(0,4);let f=document.createElement(`span`);f.className=`tb-card-name`,f.textContent=e.structureName;let p=document.createElement(`span`);if(p.className=`tb-card-size`,p.textContent=`\u00d7${e.drawSize}`,u.appendChild(d),u.appendChild(f),u.appendChild(p),o){let e=document.createElement(`div`);e.className=`tb-card-advance`,e.textContent=o,u.appendChild(e)}let m=document.createElement(`div`);m.className=`tb-card-preview`;let h=e.matchUps||uF({structureType:e.structureType,drawSize:e.drawSize,stage:e.stage,structureId:e.id,qualifyingPositions:e.qualifyingPositions,structureOptions:e.structureOptions});if(h.length>0)try{let t=pi({matchUps:h,structureId:e.id,showHeaders:!1});t.style.transform=`scale(0.8)`,t.style.transformOrigin=`top left`,m.appendChild(t)}catch{m.textContent=`${e.structureType} \u00d7${e.drawSize}`,m.style.cssText+=`font-size:11px;color:var(--chc-text-muted);display:flex;align-items:center;justify-content:center;`}if(i?.length&&m.querySelector(`.chc-schematic-structure`)){let e=m.querySelectorAll(`.chc-schematic-round-container[data-round-number]`);for(let n of e){let e=parseInt(n.getAttribute(`data-round-number`)||`0`),r=i.filter(t=>t.roundNumber===e);if(!r.length)continue;let a=r.find(e=>e.isSelected)||r.find(e=>e.linkType===DF)||r.find(e=>e.linkType===EF)||r[0];n.classList.add(`tb-round-linked`),n.classList.add(`tb-round-linked--${a.linkType.toLowerCase()}`),n.classList.add(`tb-round-linked--${a.direction}`),a.isSelected&&n.classList.add(`tb-round-linked--active`),n.style.cursor=`pointer`,n.addEventListener(`click`,e=>{e.stopPropagation(),t.onSelectEdge(a.edgeId)}),n.title=r.map(t=>`R${e} ${t.linkType} ${t.direction===`source`?`out`:`in`}`).join(`, `)}}let g=_F(e.structureType,e.drawSize,e.structureOptions?.groupSize),_=null;g.playoffRoundsRanges?.length?(_=document.createElement(`div`),_.className=`tb-card-rounds`,_.textContent=g.playoffRoundsRanges.map(e=>`R${e.roundNumber}:${e.finishingPositionRange}`).join(` `)):g.playoffFinishingPositionRanges?.length&&(_=document.createElement(`div`),_.className=`tb-card-rounds`,_.textContent=g.playoffFinishingPositionRanges.map(e=>`P${e.finishingPosition}:${e.finishingPositionRange}`).join(` `));let v=document.createElement(`div`);v.className=`tb-card-ports`;let y=document.createElement(`div`);y.className=`tb-port tb-port--input`,y.title=`Input`,y.addEventListener(`mouseup`,()=>{t.onPortMouseUp(e.id)});let b=document.createElement(`div`);b.className=`tb-port-group`;let x=document.createElement(`div`);x.className=`tb-port tb-port--winner${r?` tb-port--connected`:``}`,x.title=r?`Winner linked`:`Winner output`,r||x.addEventListener(`mousedown`,n=>{n.stopPropagation(),t.onPortMouseDown(e.id,`winner`)});let S=document.createElement(`div`);if(S.className=`tb-port tb-port--loser`,S.title=`Loser output`,S.addEventListener(`mousedown`,n=>{n.stopPropagation(),t.onPortMouseDown(e.id,`loser`)}),b.appendChild(x),b.appendChild(S),v.appendChild(y),v.appendChild(b),l.appendChild(u),l.appendChild(m),s?.length){let e=document.createElement(`div`);e.className=`tb-card-chips`;for(let n of s){let r=document.createElement(`span`);r.className=`tb-card-chip`,r.textContent=`P${n.position}`,r.title=`Position ${n.position} → ${n.targetName}`,r.addEventListener(`click`,e=>{e.stopPropagation(),t.onSelectEdge(n.edgeId)}),e.appendChild(r)}l.appendChild(e)}if(_&&l.appendChild(_),c){let e=document.createElement(`div`);e.className=`tb-card-warning`,e.textContent=`⚠ Issue`;let t=document.createElement(`div`);t.className=`tb-card-warning-detail`,t.textContent=a.join(`; `),e.appendChild(t),e.addEventListener(`click`,t=>{t.stopPropagation(),e.classList.toggle(`tb-card-warning--open`)}),l.appendChild(e)}return l.appendChild(v),l.addEventListener(`mouseup`,()=>{t.onPortMouseUp(e.id)}),l.addEventListener(`click`,n=>{n.stopPropagation(),t.onSelect(e.id)}),t.onDoubleClick&&l.addEventListener(`dblclick`,n=>{n.stopPropagation(),t.onDoubleClick(e.id)}),l.addEventListener(`mousedown`,n=>{n.target.classList.contains(`tb-port`)||t.onDragStart(e.id,n.clientX,n.clientY)}),l}function FF(e,t){let n=MF(e);switch(t){case`input`:return{x:e.position.x,y:e.position.y+160/2};case`winner`:return{x:e.position.x+n,y:e.position.y+160/2-8};case`loser`:return{x:e.position.x+n,y:e.position.y+160/2+8}}}var{MAIN:IF,QUALIFYING:LF,CONSOLATION:RF,WINNER:zF,LOSER:BF,ROUND_ROBIN:VF}=t.drawDefinitionConstants,HF=`POSITION`,UF=0;function WF(e){return`${e}-${++UF}-${Date.now().toString(36)}`}function GF(e){let t=2;for(;t*2<=e;)t*=2;return t}var KF=160,qF=60,JF=30,YF=class{constructor(e){this.listeners=new Set,this.state={nodes:[],edges:[],selectedNodeId:null,selectedEdgeId:null,drawName:`New Draw`,...e}}getState(){return{...this.state}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){let e=this.getState();for(let t of this.listeners)t(e)}setDrawName(e){this.state.drawName=e,this.notify()}addNode(e){let t={...e,id:WF(`node`),position:this.nextNodePosition()};return this.state.nodes.push(t),this.state.templateName=void 0,this.notify(),t}updateNode(e,t){let n=this.state.nodes.find(t=>t.id===e);n&&(Object.keys(t).some(e=>e!==`position`)&&(this.state.templateName=void 0),Object.assign(n,t),this.notify())}removeNode(e){let t=this.state.edges.filter(t=>t.sourceNodeId===e).map(e=>e.targetNodeId);this.state.nodes=this.state.nodes.filter(t=>t.id!==e),this.state.edges=this.state.edges.filter(t=>t.sourceNodeId!==e&&t.targetNodeId!==e),this.state.selectedNodeId===e&&(this.state.selectedNodeId=null),this.state.templateName=void 0;for(let e of t)this.clampConsolationDrawSize(e);this.notify()}addEdge(e){if(e.linkType===zF&&this.state.edges.find(t=>t.sourceNodeId===e.sourceNodeId&&t.linkType===zF))return null;let t=this.state.nodes.find(t=>t.id===e.sourceNodeId),n=this.state.nodes.find(t=>t.id===e.targetNodeId);if(t?.structureType===VF&&e.linkType!==HF||t?.stage===LF&&n&&n.stage!==LF&&n.stage!==IF||n?.stage===LF&&t&&t.stage!==LF)return null;let r={...e,id:WF(`edge`),targetRoundNumber:e.targetRoundNumber||1,label:this.computeEdgeLabel(e)};return this.state.edges.push(r),this.state.templateName=void 0,this.clampConsolationDrawSize(r.targetNodeId),this.notify(),r}updateEdge(e,t){let n=this.state.edges.find(t=>t.id===e);n&&(Object.assign(n,t),n.label=this.computeEdgeLabel(n),this.state.templateName=void 0,this.notify())}removeEdge(e){let t=this.state.edges.find(t=>t.id===e);this.state.edges=this.state.edges.filter(t=>t.id!==e),this.state.selectedEdgeId===e&&(this.state.selectedEdgeId=null),this.state.templateName=void 0,t&&this.clampConsolationDrawSize(t.targetNodeId),this.notify()}selectNode(e){this.state.selectedNodeId=e,this.state.selectedEdgeId=null,this.notify()}selectEdge(e){this.state.selectedEdgeId=e,this.state.selectedNodeId=null,this.notify()}clampConsolationDrawSize(e){let t=this.state.nodes.find(t=>t.id===e);if(!t||t.stage!==RF)return;let n=this.inboundCapacity(e);n>0&&t.drawSize>n&&(t.drawSize=GF(n))}inboundCapacity(e){let t=this.state.edges.filter(t=>t.targetNodeId===e),n=0;for(let e of t){let t=this.state.nodes.find(t=>t.id===e.sourceNodeId);if(t)if(e.linkType===BF){let r=e.sourceRoundNumber||1;n+=aF(t.structureType,t.drawSize,r)}else n+=t.qualifyingPositions||Math.floor(t.drawSize/2)}return n}nextNodePosition(){if(this.state.nodes.length===0)return{x:40,y:40};let e=0;for(let t of this.state.nodes)e=Math.max(e,t.position.x+MF(t));return{x:e+qF,y:40}}autoLayout(){let e=this.state.nodes,t=this.state.edges;if(!e.length)return;let n=new Map,r=new Map;for(let e of t)r.has(e.sourceNodeId)||r.set(e.sourceNodeId,[]),r.get(e.sourceNodeId).push(e.targetNodeId),n.has(e.targetNodeId)||n.set(e.targetNodeId,[]),n.get(e.targetNodeId).push(e.sourceNodeId);let i=e.filter(e=>!n.has(e.id)||n.get(e.id).length===0);if(!i.length){let t=e.filter(e=>e.stage===IF);i.push(...t.length?t:[e[0]])}let a=new Map,o=new Set(e.filter(e=>e.stage===LF).map(e=>e.id)),s=[];for(let e of i)o.has(e.id)?a.set(e.id,-1):a.set(e.id,0),s.push(e.id);let c=e.length*(e.length-1)+e.length,l=0;for(;s.length&&l<c;){l++;let e=s.shift(),t=a.get(e),n=r.get(e)||[];for(let e of n){let n=t+1,r=a.get(e);(r===void 0||n>r)&&(a.set(e,n),s.push(e))}}for(let t of e)a.has(t.id)||a.set(t.id,0);let u=Math.min(...a.values());if(u<0)for(let[e,t]of a)a.set(e,t-u);let d=new Map;for(let t of e){let e=a.get(t.id);d.has(e)||d.set(e,[]),d.get(e).push(t)}let f=[...d.keys()].sort((e,t)=>e-t),p=40;for(let e of f){let t=d.get(e),n=Math.max(...t.map(e=>MF(e)));t.forEach((e,t)=>{e.position={x:p,y:t*(KF+JF)+40}}),p+=n+qF}}loadState(e){this.state={...e},this.notify()}computeEdgeLabel(e){let t=e.linkType||`LINK`,n=``;return e.sourceRoundNumber&&(n+=`R${e.sourceRoundNumber} `),n+=t.toLowerCase(),e.targetRoundNumber&&(n+=` \u2192 R${e.targetRoundNumber}`),e.qualifyingPositions&&(n+=` (${e.qualifyingPositions}Q)`),e.finishingPositions?.length&&(n+=` [${e.finishingPositions.join(`,`)}]`),n}},{WINNER:XF,LOSER:ZF,QUALIFYING:QF,CONSOLATION:$F,ROUND_ROBIN:eI}=t.drawDefinitionConstants,tI=`POSITION`,nI=e=>e===eI;function rI(e,t){if(!nI(e.structureType))return;let n=t.edges.filter(t=>t.sourceNodeId===e.id&&t.linkType===tI);if(!n.length)return;let r=new Set(n.flatMap(e=>e.finishingPositions||[])),i=e.structureOptions?.groupSize||4;return`${r.size} of ${i} advance`}var iI=`http://www.w3.org/2000/svg`,aI={[XF]:`tb-edge--winner`,[ZF]:`tb-edge--loser`,[tI]:`tb-edge--position`};function oI(e){let t=document.createElement(`div`);t.className=`tb-canvas`;let n=document.createElementNS(iI,`svg`);n.classList.add(`tb-canvas-svg`);let r=document.createElementNS(iI,`defs`);for(let[e,t]of Object.entries(aI)){let n=document.createElementNS(iI,`marker`);n.setAttribute(`id`,`arrowhead-${e}`),n.setAttribute(`markerWidth`,`8`),n.setAttribute(`markerHeight`,`6`),n.setAttribute(`refX`,`8`),n.setAttribute(`refY`,`3`),n.setAttribute(`orient`,`auto`);let i=document.createElementNS(iI,`polygon`);i.setAttribute(`points`,`0 0, 8 3, 0 6`),i.setAttribute(`class`,t),i.style.fill=`currentColor`,n.appendChild(i),r.appendChild(n)}n.appendChild(r);let i=document.createElement(`div`);i.className=`tb-canvas-nodes`;let a=document.createElement(`div`);a.className=`tb-canvas-spacer`,t.appendChild(n),t.appendChild(i),t.appendChild(a);let o=null,s=null,c=null,l=!1,u=null;t.addEventListener(`click`,()=>{l||(e.onSelectNode(null),e.onSelectEdge(null))}),t.addEventListener(`mousemove`,n=>{if(s&&!c){let e=n.clientX-s.startX,t=n.clientY-s.startY;Math.abs(e)+Math.abs(t)>=4&&(c=s,s=null)}if(c&&u){let t=n.clientX-c.startX,r=n.clientY-c.startY;e.onMoveNode(c.nodeId,Math.max(0,c.origX+t),Math.max(0,c.origY+r))}if(o?.tempLine){let e=t.getBoundingClientRect();o.tempLine.setAttribute(`x2`,String(n.clientX-e.left+t.scrollLeft)),o.tempLine.setAttribute(`y2`,String(n.clientY-e.top+t.scrollTop))}}),t.addEventListener(`mouseup`,()=>{c&&(l=!0,c=null,setTimeout(()=>{l=!1},0)),s=null,o?.tempLine&&(n.removeChild(o.tempLine),o=null)});function d(e){return new Set(e.edges.filter(e=>e.linkType===XF).map(e=>e.sourceNodeId).filter(t=>{let n=e.nodes.find(e=>e.id===t);return n&&n.stage===QF&&!nI(n.structureType)}))}function f(e){let t=new Map;for(let n of e.edges){let r=n.sourceRoundNumber,i=n.targetRoundNumber,a=n.id===e.selectedEdgeId;if(!r&&n.linkType===XF){let t=e.nodes.find(e=>e.id===n.sourceNodeId);t&&(r=jF(t))}r&&(t.has(n.sourceNodeId)||t.set(n.sourceNodeId,[]),t.get(n.sourceNodeId).push({roundNumber:r,linkType:n.linkType,direction:`source`,edgeId:n.id,isSelected:a})),i&&(t.has(n.targetNodeId)||t.set(n.targetNodeId,[]),t.get(n.targetNodeId).push({roundNumber:i,linkType:n.linkType,direction:`target`,edgeId:n.id,isSelected:a}))}return t}function p(e){let t=new Map;for(let n of e.edges){if(n.linkType!==XF)continue;let r=n.targetRoundNumber||1;if(r<=1)continue;let i=e.nodes.find(e=>e.id===n.sourceNodeId);if(!i||i.stage!==QF)continue;t.has(n.targetNodeId)||t.set(n.targetNodeId,[]);let a=i.qualifyingPositions||Math.floor(i.drawSize/4);t.get(n.targetNodeId).push({targetRound:r,qp:a,warning:`Round ${r} needs fed drawPositions to accommodate ${i.structureName} link`})}let n=new Map;for(let[r,i]of t){let t=e.nodes.find(e=>e.id===r);if(!t)continue;let a=$P(t.drawSize),o=new Map;for(let e of i)o.set(e.targetRound,(o.get(e.targetRound)||0)+e.qp);let s=[];for(let e of i)(a.get(e.targetRound)||0)<(o.get(e.targetRound)||0)&&s.push(e.warning);s.length>0&&n.set(r,s)}return n}function m(e){let t=new Map;for(let n of e.nodes){if(!nI(n.structureType))continue;let r=e.edges.filter(e=>e.sourceNodeId===n.id&&e.linkType===tI);if(!r.length)continue;let i=[];for(let t of r){let n=e.nodes.find(e=>e.id===t.targetNodeId);for(let e of t.finishingPositions||[])i.push({position:e,edgeId:t.id,targetName:n?.structureName||`?`})}i.sort((e,t)=>e.position-t.position),t.set(n.id,i)}return t}function h(e,t,n){return e&&nI(e.structureType)?tI:n===`loser`||t?.stage===$F?ZF:XF}function g(t){return{onSelect:t=>{e.onSelectNode(t)},onSelectEdge:t=>{e.onSelectEdge(t)},onDoubleClick:e.onDoubleClickNode?t=>e.onDoubleClickNode(t):void 0,onPortMouseDown:(e,r)=>{let i=t.nodes.find(t=>t.id===e);if(!i)return;let a=FF(i,r),s=document.createElementNS(iI,`line`);s.setAttribute(`x1`,String(a.x)),s.setAttribute(`y1`,String(a.y)),s.setAttribute(`x2`,String(a.x)),s.setAttribute(`y2`,String(a.y)),s.setAttribute(`stroke`,r===`winner`?`green`:`red`),s.setAttribute(`stroke-width`,`2`),s.setAttribute(`stroke-dasharray`,`4 2`),n.appendChild(s),o={sourceNodeId:e,portType:r,tempLine:s}},onPortMouseUp:r=>{if(o&&o.sourceNodeId!==r){let n=h(t.nodes.find(e=>e.id===o.sourceNodeId),t.nodes.find(e=>e.id===r),o.portType);e.onCreateEdge(o.sourceNodeId,r,n)}o?.tempLine&&n.removeChild(o.tempLine),o=null},onDragStart:(e,n,r)=>{let i=t.nodes.find(t=>t.id===e);i&&(s={nodeId:e,startX:n,startY:r,origX:i.position.x,origY:i.position.y})}}}function _(e){u=e,i.innerHTML=``;let t=d(e),r=f(e),o=p(e),s=m(e),c=g(e);for(let n of e.nodes){let a=PF(n,c,e.selectedNodeId===n.id,t.has(n.id),r.get(n.id),o.get(n.id),rI(n,e),s.get(n.id));i.appendChild(a)}n.querySelectorAll(`path, text.tb-edge-label, path.tb-edge-hit`).forEach(e=>n.removeChild(e));let l=new Map;for(let t of e.edges){let e=`${t.sourceNodeId}:${t.targetNodeId}`;l.has(e)||l.set(e,[]),l.get(e).push(t)}for(let t of l.values()){let r=t.length;t.forEach((t,i)=>{v(n,t,e,r>1?(i-(r-1)/2)*14:0)})}let h=600,_=400;for(let t of e.nodes)h=Math.max(h,t.position.x+MF(t)+40),_=Math.max(_,t.position.y+180);n.setAttribute(`width`,String(h)),n.setAttribute(`height`,String(_)),i.style.width=`${h}px`,i.style.height=`${_}px`,a.style.width=`${h}px`,a.style.height=`${_}px`}function v(t,n,r,i=0){let a=r.nodes.find(e=>e.id===n.sourceNodeId),o=r.nodes.find(e=>e.id===n.targetNodeId);if(!a||!o)return;let s=FF(a,n.linkType===ZF?`loser`:`winner`),c=FF(o,`input`),l=s.y+i,u=c.y+i,d=c.x-s.x,f=`M ${s.x},${l} C ${s.x+d/2},${l} ${s.x+d/2},${u} ${c.x},${u}`,p=document.createElementNS(iI,`path`);p.setAttribute(`d`,f),p.classList.add(`tb-edge-hit`),p.addEventListener(`click`,t=>{t.stopPropagation(),e.onSelectEdge(n.id)}),t.appendChild(p);let m=document.createElementNS(iI,`path`);if(m.setAttribute(`d`,f),m.classList.add(aI[n.linkType]||`tb-edge--winner`),r.selectedEdgeId===n.id&&m.classList.add(`tb-edge--selected`),m.setAttribute(`marker-end`,`url(#arrowhead-${n.linkType})`),m.addEventListener(`click`,t=>{t.stopPropagation(),e.onSelectEdge(n.id)}),t.appendChild(m),n.label){let e=(s.x+c.x)/2,r=(l+u)/2-8,i=document.createElementNS(iI,`text`);i.classList.add(`tb-edge-label`),i.setAttribute(`x`,String(e)),i.setAttribute(`y`,String(r)),i.setAttribute(`text-anchor`,`middle`),i.textContent=n.label,t.appendChild(i)}}return{element:t,update:_}}var{SINGLE_ELIMINATION:sI,ROUND_ROBIN:cI,FEED_IN:lI,FEED_IN_CHAMPIONSHIP:uI,FIRST_MATCH_LOSER_CONSOLATION:dI,COMPASS:fI,OLYMPIC:pI,AD_HOC:mI,LUCKY_DRAW:hI,MAIN:gI,QUALIFYING:_I,CONSOLATION:vI,PLAY_OFF:yI,WINNER:bI}=t.drawDefinitionConstants,xI=`POSITION`,SI=[{label:`Single Elimination`,value:sI},{label:`Round Robin`,value:cI},{label:`Feed-In Championship`,value:uI},{label:`FMLC`,value:dI},{label:`Compass`,value:fI},{label:`Olympic`,value:pI},{label:`Ad-hoc`,value:mI}],CI=[{label:`Single Elimination`,value:sI},{label:`Round Robin`,value:cI},{label:`Lucky Draw`,value:hI},{label:`Staggered Entry`,value:lI},{label:`Ad-hoc`,value:mI}],wI=[{label:`Main`,value:gI},{label:`Qualifying`,value:_I},{label:`Consolation`,value:vI},{label:`Playoff`,value:yI}];function TI(e){let t=[],n=Math.floor(e/2);for(;n>=1;)t.push(n),n=Math.floor(n/2);return t}function EI(e,t=8){let n=[];for(let r=3;r<=t;r++){let t=Math.ceil(e/r),i=t*r-e,a=Math.ceil(e/t),o=Math.ceil(i/t);(!i||i<r)&&a===r&&a>=3&&o<2&&n.push(r)}return n}function DI(e,t,n,r,i,a){let o=EI(e.drawSize),s=e.structureOptions?.groupSize||4,c=o.includes(s)?o:[s,...o].sort((e,t)=>e-t),l=Math.ceil(e.drawSize/s);i.push({label:`Group Size`,field:`groupSize`,value:String(s),disabled:n,options:c.map(e=>({label:String(e),value:String(e),selected:e===s}))}),i.push({label:`Groups`,field:`groupCount`,value:String(l),disabled:!0}),n||a.push({control:`groupSize`,onChange:({e:t})=>{let n=parseInt(t.target.value);r.onUpdateNode(e.id,{structureOptions:{...e.structureOptions,groupSize:n}})}});let u=t.edges.filter(t=>t.sourceNodeId===e.id&&t.linkType===xI),d=new Set(u.flatMap(e=>e.finishingPositions||[])),f=d.size||0,p=Array.from({length:s},(e,t)=>t+1);i.push({label:`Advance Per Group`,field:`advancePerGroup`,value:String(f),disabled:n||u.length===0,options:p.map(e=>({label:String(e),value:String(e),selected:e===f}))}),!n&&u.length>0&&a.push({control:`advancePerGroup`,onChange:({e})=>{let t=parseInt(e.target.value),n=d.size;if(t!==n)if(t>n){let e=u.at(-1),n=[];for(let e=1;e<=s&&d.size+n.length<t;e++)d.has(e)||n.push(e);n.length>0&&r.onUpdateEdge(e.id,{finishingPositions:[...e.finishingPositions||[],...n].sort((e,t)=>e-t)})}else{let e=[...d].sort((e,t)=>t-e),i=new Set(e.slice(0,n-t));for(let e of u){let t=(e.finishingPositions||[]).filter(e=>!i.has(e));t.length!==(e.finishingPositions||[]).length&&r.onUpdateEdge(e.id,{finishingPositions:t})}}}}),u.length>0&&f>0&&OI(u,t,l,i)}function OI(e,t,n,r){let i=new Map;for(let t of e)i.has(t.targetNodeId)||i.set(t.targetNodeId,[]),i.get(t.targetNodeId).push(...t.finishingPositions||[]);let a=[];for(let[e,r]of i){let i=t.nodes.find(t=>t.id===e),o=[...new Set(r)].sort((e,t)=>e-t),s=o.length===1?`P${o[0]}`:`P${o.join(`,`)}`;a.push(`${s} → ${i?.structureName||`?`} (${o.length*n})`)}a.length>0&&r.push({label:`Playoff Groups`,field:`playoffSummary`,value:a.join(`
|
|
321
|
+
`),disabled:!0})}function kI(e,t,n,r,i,a){let o=t.edges.find(t=>t.targetNodeId===e.id&&t.linkType===xI);if(!o||t.nodes.find(e=>e.id===o.sourceNodeId)?.structureType!==cI)return;let s=e.structureOptions?.playoffDrawType||sI;if(i.push({label:`Playoff Draw Type`,field:`playoffDrawType`,value:s,disabled:n,options:SI.map(e=>({...e,selected:e.value===s}))}),n||a.push({control:`playoffDrawType`,onChange:({e:t})=>r.onUpdateNode(e.id,{structureOptions:{...e.structureOptions,playoffDrawType:t.target.value}})}),s===cI){let t=e.structureOptions?.groupSize||4;i.push({label:`Playoff Group Size`,field:`playoffGroupSize`,value:String(t),disabled:n,options:[3,4,5,6,8].map(e=>({label:String(e),value:String(e),selected:e===t}))}),n||a.push({control:`playoffGroupSize`,onChange:({e:t})=>r.onUpdateNode(e.id,{structureOptions:{...e.structureOptions,groupSize:parseInt(t.target.value)}})})}}function AI(e,t,n,r,i){let a=TI(e.drawSize),o=e.qualifyingPositions??a[0];r.push({label:`Qualifying Positions`,field:`qualifyingPositions`,value:String(o),disabled:t,options:a.map(e=>({label:String(e),value:String(e),selected:e===o}))}),t||i.push({control:`qualifyingPositions`,onChange:({e:t})=>n.onUpdateNode(e.id,{qualifyingPositions:parseInt(t.target.value)})})}function jI(e,t,n){let r=$P(e.drawSize),i=new Map,a=[];for(let n of t.edges){if(n.linkType!==bI||n.targetNodeId!==e.id)continue;let r=n.targetRoundNumber||1;if(r<=1)continue;let o=t.nodes.find(e=>e.id===n.sourceNodeId);if(!o||o.stage!==_I)continue;let s=o.qualifyingPositions||Math.floor(o.drawSize/4);i.set(r,(i.get(r)||0)+s),a.push({targetRound:r,qp:s,sourceName:o.structureName})}let o=[];for(let e of a){let t=r.get(e.targetRound)||0;t>=(i.get(e.targetRound)||0)||(t===0?o.push(`Round ${e.targetRound} is not a feed round — ${e.sourceName} sends ${e.qp} qualifiers`):o.push(`Round ${e.targetRound} has ${t} feed positions but ${e.sourceName} sends ${e.qp} qualifiers`))}if(o.length>0){let e=document.createElement(`div`);e.className=`tb-editor-warning`;for(let t of o){let n=document.createElement(`div`);n.textContent=`\u26a0 ${t}`,e.appendChild(n)}let t=document.createElement(`div`);t.style.marginTop=`6px`,t.textContent=`Change the target round to a feed round, or increase the draw size to create feed positions at that round.`,e.appendChild(t),n.appendChild(e)}}function MI(e){let t=document.createElement(`div`),n=!!e.readOnly;function r(r){t.innerHTML=``;let i=r.selectedNodeId?r.nodes.find(e=>e.id===r.selectedNodeId):null;if(!i)return;let a=document.createElement(`div`);a.className=`tb-editor-header`,a.textContent=`Structure Properties`,t.appendChild(a);let o=document.createElement(`div`);o.className=`tb-editor-body`;let s=[{label:`Name`,field:`structureName`,value:i.structureName,...n?{disabled:!0}:{validator:bb(1),error:`Name required`}},{label:`Stage`,field:`stage`,value:i.stage,disabled:n,options:wI.map(e=>({...e,selected:e.value===i.stage}))},{label:`Structure Type`,field:`structureType`,value:i.structureType,disabled:n,options:CI.map(e=>({...e,selected:e.value===i.structureType}))},{label:i.stage===gI?`Draw Size`:`Structure Size`,field:`drawSize`,type:`number`,value:String(i.drawSize),...n?{disabled:!0}:i.structureType===mI?{validator:Sb(0,256),error:`Must be 0-256`}:{validator:Sb(2,256),error:`Must be 2-256`}}],c=n?[]:[{control:`structureName`,onChange:({inputs:t})=>e.onUpdateNode(i.id,{structureName:t.structureName.value})},{control:`stage`,onChange:({e:t})=>e.onUpdateNode(i.id,{stage:t.target.value})},{control:`structureType`,onChange:({e:t})=>e.onUpdateNode(i.id,{structureType:t.target.value})},{control:`drawSize`,onChange:({inputs:t})=>{let n=parseInt(t.drawSize.value);if(n<(i.structureType===mI?0:2))return;let r={drawSize:n};if(i.structureType===cI){let e=i.structureOptions?.groupSize||4,t=EI(n);!t.includes(e)&&t.length>0&&(r.structureOptions={...i.structureOptions,groupSize:t[0]})}e.onUpdateNode(i.id,r)}}];i.structureType===cI&&DI(i,r,n,e,s,c),i.stage===yI&&kI(i,r,n,e,s,c),i.stage===_I&&AI(i,n,e,s,c),mi(o,s,c);let l=document.createElement(`div`);l.className=`field font-medium`,l.style.cssText=`flex-grow: 1`;let u=document.createElement(`label`);u.style.cssText=`font-weight: bold; font-size: larger;`,u.textContent=`MatchUp Format`,l.appendChild(u);let d=document.createElement(`div`);if(d.className=`tb-format-trigger`,d.textContent=i.matchUpFormat||`Not set`,n?(d.style.cursor=`default`,d.style.opacity=`0.7`):d.onclick=()=>{Da({existingMatchUpFormat:i.matchUpFormat,callback:t=>{e.onUpdateNode(i.id,{matchUpFormat:t||void 0}),d.textContent=t||`Not set`}})},l.appendChild(d),o.appendChild(l),jI(i,r,o),!n&&!e.hideDelete){let t=document.createElement(`button`);t.className=`sp-btn sp-btn--danger sp-btn--full`,t.style.marginTop=`12px`,t.textContent=`Delete Structure`,t.onclick=()=>e.onDeleteNode(i.id),o.appendChild(t)}t.appendChild(o)}return{element:t,update:r}}var{WINNER:NI,LOSER:PI,TOP_DOWN:FI,BOTTOM_UP:II,QUALIFYING:LI,ROUND_ROBIN:RI}=t.drawDefinitionConstants,zI=`POSITION`,BI=`ALTERNATING`,VI=e=>e===RI,HI=[{label:`Winner`,value:NI},{label:`Loser`,value:PI},{label:`Position`,value:zI}],UI=[{label:`Top-Down`,value:FI},{label:`Bottom-Up`,value:II},{label:`Alternating`,value:BI}];function WI(e){let t=document.createElement(`div`),n=!!e.readOnly;function r(t,r,i,a,o,s){let c=[],l=[],u=r?_F(r.structureType,r.drawSize,r.structureOptions?.groupSize):{},d=u.playoffRoundsRanges&&u.playoffRoundsRanges.length>0;if(d){let e=u.playoffRoundsRanges.map(e=>({label:`R${e.roundNumber} (${e.finishingPositionRange})`,value:String(e.roundNumber),selected:e.roundNumber===(t.sourceRoundNumber||a)}));c.push({label:`Source Round`,field:`sourceRoundNumber`,value:String(t.sourceRoundNumber||a),disabled:n,options:e})}else c.push({label:`Source Round`,field:`sourceRoundNumber`,type:`number`,value:String(t.sourceRoundNumber||a),disabled:n});return c.push({label:s?`Enter at Round`:`Target Round`,field:`targetRoundNumber`,type:`number`,value:String(t.targetRoundNumber||0),disabled:n}),n||(d?l.push({control:`sourceRoundNumber`,onChange:({e:n})=>{let r=Number.parseInt(n.target.value)||0;e.onUpdateEdge(t.id,{sourceRoundNumber:r||void 0})}}):l.push({control:`sourceRoundNumber`,onChange:({inputs:n})=>{let r=Number.parseInt(n.sourceRoundNumber.value)||0,i=Math.max(0,Math.min(r,a));e.onUpdateEdge(t.id,{sourceRoundNumber:i||void 0})}}),l.push({control:`targetRoundNumber`,onChange:({inputs:n})=>{let r=Number.parseInt(n.targetRoundNumber.value)||0,i=Math.max(0,Math.min(r,o));e.onUpdateEdge(t.id,{targetRoundNumber:i||void 0})}})),{items:c,relationships:l}}function i(t,r,i){let a=r.structureOptions?.groupSize||4,o=new Set(t.finishingPositions||[]),s=i.edges.filter(e=>e.id!==t.id&&e.sourceNodeId===t.sourceNodeId&&e.linkType===zI),c=new Set;for(let e of s)for(let t of e.finishingPositions||[])c.add(t);let l=document.createElement(`div`);l.className=`field`,l.style.marginBottom=`10px`;let u=document.createElement(`label`);u.style.cssText=`font-size:11px;font-weight:600;color:var(--chc-text-secondary);margin-bottom:3px;display:block;`,u.textContent=`Finishing Positions`,l.appendChild(u);for(let r=1;r<=a;r++){let i=document.createElement(`label`);i.style.cssText=`display:flex;align-items:center;gap:4px;font-size:12px;padding:2px 0;cursor:pointer;`;let a=document.createElement(`input`);a.type=`checkbox`,a.checked=o.has(r);let s=c.has(r);n||s?a.disabled=!0:a.addEventListener(`change`,()=>{let n=new Set(o);a.checked?n.add(r):n.delete(r),e.onUpdateEdge(t.id,{finishingPositions:Array.from(n).sort((e,t)=>e-t)})});let u=document.createElement(`span`);u.textContent=`Position ${r}`,s&&(u.style.color=`var(--chc-text-muted, #999)`,u.title=`Used by another link`,i.style.opacity=`0.5`,i.style.cursor=`not-allowed`),i.appendChild(a),i.appendChild(u),l.appendChild(i)}return l}function a(a){t.innerHTML=``;let o=a.selectedEdgeId?a.edges.find(e=>e.id===a.selectedEdgeId):null;if(!o)return;let s=a.nodes.find(e=>e.id===o.sourceNodeId),c=a.nodes.find(e=>e.id===o.targetNodeId),l=document.createElement(`div`);l.className=`tb-editor-header`,l.textContent=`Link Properties`,t.appendChild(l);let u=document.createElement(`div`);u.className=`tb-editor-body`;let d=document.createElement(`div`);d.style.cssText=`font-size:11px;color:var(--chc-text-muted);margin-bottom:8px;`,d.textContent=`${s?.structureName||`Source`} → ${c?.structureName||`Target`}`,u.appendChild(d);let f=o.linkType===NI&&s?.stage===LI,p=s?iF(s.structureType,s.drawSize,s.structureOptions):8,m=c?iF(c.structureType,c.drawSize,c.structureOptions):8,h=o.linkType===zI&&s&&VI(s.structureType),g=[{label:`Link Type`,field:`linkType`,value:o.linkType,disabled:n,options:HI.map(e=>({...e,selected:e.value===o.linkType}))}],_=n?[]:[{control:`linkType`,onChange:({e:t})=>e.onUpdateEdge(o.id,{linkType:t.target.value})}];if(!h){let e=r(o,s,c,p,m,f);g.push(...e.items),_.push(...e.relationships)}if(f&&s){let t=Math.floor(s.drawSize/2),r=Math.floor(s.drawSize/4),i=o.qualifyingPositions||r;g.push({label:`Qualifying Positions`,field:`qualifyingPositions`,type:`number`,value:String(i),disabled:n}),n||_.push({control:`qualifyingPositions`,onChange:({inputs:n})=>{let r=Number.parseInt(n.qualifyingPositions.value)||1,i=Math.max(1,Math.min(r,t));e.onUpdateEdge(o.id,{qualifyingPositions:i})}})}if(o.linkType===PI&&(g.push({label:`Feed Profile`,field:`feedProfile`,value:o.feedProfile||FI,disabled:n,options:UI.map(e=>({...e,selected:e.value===(o.feedProfile||FI)}))}),n||_.push({control:`feedProfile`,onChange:({e:t})=>e.onUpdateEdge(o.id,{feedProfile:t.target.value})})),o.linkType===zI&&!h&&(g.push({label:`Finishing Positions`,field:`finishingPositions`,value:(o.finishingPositions||[]).join(`, `),placeholder:`e.g., 1, 2`,disabled:n}),n||_.push({control:`finishingPositions`,onChange:({inputs:t})=>{let n=t.finishingPositions.value.split(`,`).map(e=>Number.parseInt(e.trim())).filter(e=>!Number.isNaN(e));e.onUpdateEdge(o.id,{finishingPositions:n})}})),mi(u,g,_),h&&s&&u.appendChild(i(o,s,a)),!n){let t=document.createElement(`button`);t.className=`sp-btn sp-btn--danger sp-btn--full`,t.style.marginTop=`12px`,t.textContent=`Delete Link`,t.onclick=()=>e.onDeleteEdge(o.id),u.appendChild(t)}t.appendChild(u)}return{element:t,update:a}}var{MAIN:GI,QUALIFYING:KI,CONSOLATION:qI,WINNER:JI,LOSER:YI,SINGLE_ELIMINATION:XI,ROUND_ROBIN:ZI,AD_HOC:QI}=t.drawDefinitionConstants,$I=`POSITION`;function eL(e){let t=[],n=tL(e,t);return rL(e,nL(e),t),iL(e,t),aL(e,t),oL(e,t),sL(e,n,t),cL(e,t),lL(e,t),dL(e,t),fL(e,t),pL(e)&&t.push({severity:`error`,message:`Circular dependency detected between structures`}),t}function tL(e,t){let n=e.nodes.filter(e=>e.stage===GI);return n.length===0?t.push({severity:`error`,message:`A main draw structure is required`}):n.length>1&&t.push({severity:`error`,message:`Only one main draw structure is allowed`}),n}function nL(e){let t=new Set;for(let n of e.edges)n.linkType===JI&&(n.targetRoundNumber||1)>1&&e.nodes.find(e=>e.id===n.sourceNodeId)?.stage===KI&&t.add(n.targetNodeId);let n=new Map;for(let t of e.edges)t.linkType===YI&&n.set(t.targetNodeId,(n.get(t.targetNodeId)||0)+1);for(let[e,r]of n)r>1&&t.add(e);return t}function rL(e,t,n){for(let r of e.nodes){if(r.structureType===XI&&!t.has(r.id)){let t=e.edges.some(e=>e.targetNodeId===r.id);(r.stage===GI||r.stage===KI)&&!t&&(r.drawSize>0&&!(r.drawSize&r.drawSize-1)||n.push({severity:`error`,message:`"${r.structureName}" draw size must be a power of 2`,nodeId:r.id}))}let i=r.structureType===QI?0:2;r.drawSize<i&&n.push({message:`"${r.structureName}" draw size must be at least ${i}`,severity:`error`,nodeId:r.id})}}function iL(e,t){for(let n of e.edges){let r=e.nodes.find(e=>e.id===n.sourceNodeId),i=e.nodes.find(e=>e.id===n.targetNodeId);if(r||t.push({severity:`error`,message:`Edge references missing source node`,edgeId:n.id}),i||t.push({severity:`error`,message:`Edge references missing target node`,edgeId:n.id}),r&&n.sourceRoundNumber){let e=iF(r.structureType,r.drawSize,r.structureOptions);(n.sourceRoundNumber>e||n.sourceRoundNumber<1)&&t.push({severity:`warning`,message:`Edge source round ${n.sourceRoundNumber} is outside "${r.structureName}" range (1-${e})`,edgeId:n.id})}if(i&&n.targetRoundNumber){let e=iF(i.structureType,i.drawSize,i.structureOptions);(n.targetRoundNumber>e||n.targetRoundNumber<1)&&t.push({severity:`warning`,message:`Edge target round ${n.targetRoundNumber} is outside "${i.structureName}" range (1-${e})`,edgeId:n.id})}}}function aL(e,t){let n=new Map;for(let t of e.edges)t.linkType===JI&&(n.has(t.sourceNodeId)||n.set(t.sourceNodeId,[]),n.get(t.sourceNodeId).push(t.id));for(let[r,i]of n)if(i.length>1){let n=e.nodes.find(e=>e.id===r)?.structureName||`Unknown`;for(let e of i)t.push({severity:`error`,message:`"${n}" has multiple winner links (only one allowed)`,edgeId:e})}}function oL(e,t){let n=new Map;for(let t of e.edges)t.sourceRoundNumber&&(n.has(t.sourceNodeId)||n.set(t.sourceNodeId,[]),n.get(t.sourceNodeId).push({round:t.sourceRoundNumber,edgeId:t.id}));for(let[r,i]of n){let n=new Map,a=e.nodes.find(e=>e.id===r)?.structureName||`Unknown`;for(let{round:e,edgeId:r}of i)n.has(e)?t.push({severity:`error`,message:`"${a}" has multiple links from round ${e}`,edgeId:r}):n.set(e,r)}}function sL(e,t,n){let r=e.nodes.filter(e=>e.stage===KI);for(let i of r){let r=e.edges.find(e=>e.sourceNodeId===i.id&&e.linkType===JI&&t.some(t=>t.id===e.targetNodeId));if(r||n.push({severity:`warning`,message:`Qualifying structure "${i.structureName}" has no winner link to a main structure`,nodeId:i.id}),r?.qualifyingPositions){let e=Math.floor(i.drawSize/2);r.qualifyingPositions>e&&n.push({severity:`warning`,message:`Qualifying positions (${r.qualifyingPositions}) exceeds half of "${i.structureName}" draw size (${e})`,edgeId:r.id})}}}function cL(e,t){let n=new Map;for(let t of e.edges){if(t.linkType!==JI)continue;let r=t.targetRoundNumber||1;if(r<=1)continue;let i=e.nodes.find(e=>e.id===t.sourceNodeId);if(!i||i.stage!==KI)continue;n.has(t.targetNodeId)||n.set(t.targetNodeId,[]);let a=i.qualifyingPositions||Math.floor(i.drawSize/4);n.get(t.targetNodeId).push({edgeId:t.id,targetRound:r,qp:a,sourceName:i.structureName})}for(let[r,i]of n){let n=e.nodes.find(e=>e.id===r);if(!n)continue;let a=$P(n.drawSize),o=new Map;for(let e of i)o.set(e.targetRound,(o.get(e.targetRound)||0)+e.qp);for(let{edgeId:e,targetRound:s,sourceName:c}of i)(a.get(s)||0)<(o.get(s)||0)&&t.push({severity:`warning`,message:`"${n.structureName}" round ${s} is not a feed round or has insufficient capacity for ${c} link`,nodeId:r,edgeId:e})}}function lL(e,t){for(let n of e.edges){if(n.linkType!==YI)continue;let r=e.nodes.find(e=>e.id===n.sourceNodeId),i=e.nodes.find(e=>e.id===n.targetNodeId);if(!r||!i)continue;let a=n.sourceRoundNumber||1,o=n.targetRoundNumber||1,s=aF(r.structureType,r.drawSize,a),c=$P(i.drawSize);o!==1&&uL(c,o,s,r,i,a,n.id,t)}}function uL(e,t,n,r,i,a,o,s){let c=e.get(t);c===void 0?s.push({severity:`error`,message:`"${i.structureName}" R${t} is not a feed round — cannot receive ${n} losers from "${r.structureName}" R${a}`,edgeId:o}):n>c?s.push({severity:`error`,message:`"${r.structureName}" R${a} produces ${n} losers but "${i.structureName}" R${t} only has ${c} feed positions`,edgeId:o}):n<c&&s.push({severity:`warning`,message:`"${r.structureName}" R${a} produces ${n} losers but "${i.structureName}" R${t} has ${c} feed positions — ${c-n} will be empty`,edgeId:o})}function dL(e,t){let n=e.nodes.filter(e=>e.stage===qI);for(let r of n){let n=e.edges.filter(e=>e.targetNodeId===r.id);if(n.length===0)continue;let i=0;for(let t of n){let n=e.nodes.find(e=>e.id===t.sourceNodeId);if(n)if(t.linkType===YI){let e=t.sourceRoundNumber||1;i+=aF(n.structureType,n.drawSize,e)}else i+=n.qualifyingPositions||Math.floor(n.drawSize/2)}i>0&&r.drawSize>i&&t.push({severity:`warning`,message:`"${r.structureName}" draw size (${r.drawSize}) exceeds inbound capacity (${i})`,nodeId:r.id}),i>0&&i>r.drawSize&&t.push({severity:`error`,message:`"${r.structureName}" receives ${i} participants but only has ${r.drawSize} positions`,nodeId:r.id})}}function fL(e,t){let n=new Map;for(let r of e.edges){if(r.linkType!==$I)continue;n.has(r.sourceNodeId)||n.set(r.sourceNodeId,[]),n.get(r.sourceNodeId).push({edgeId:r.id,positions:r.finishingPositions||[]});let i=e.nodes.find(e=>e.id===r.sourceNodeId);if(i&&i.structureType===ZI){let e=i.structureOptions?.groupSize||4;for(let n of r.finishingPositions||[])(n<1||n>e)&&t.push({severity:`error`,message:`Position ${n} is outside valid range (1-${e}) for "${i.structureName}"`,edgeId:r.id})}}for(let[r,i]of n){if(i.length<2)continue;let n=e.nodes.find(e=>e.id===r)?.structureName||`Unknown`,a=new Map;for(let{edgeId:e,positions:r}of i)for(let i of r)a.has(i)?t.push({severity:`warning`,message:`Position ${i} from "${n}" is used by multiple POSITION links`,edgeId:e}):a.set(i,e)}}function pL(e){let t=new Map;for(let n of e.nodes)t.set(n.id,[]);for(let n of e.edges){let e=t.get(n.sourceNodeId);e&&e.push(n.targetNodeId)}let n=new Set,r=new Set;function i(e){if(r.has(e))return!0;if(n.has(e))return!1;n.add(e),r.add(e);for(let n of t.get(e)||[])if(i(n))return!0;return r.delete(e),!1}for(let t of e.nodes)if(i(t.id))return!0;return!1}var{MAIN:mL,QUALIFYING:hL,CONSOLATION:gL,PLAY_OFF:_L,LUCKY_DRAW:vL}=t.drawDefinitionConstants;function yL(e,t,n={}){let r=document.createElement(`div`);r.className=`tb-toolbar-wrapper`;let i=document.createElement(`div`);i.className=`tb-toolbar-row`;let a=document.createElement(`div`);a.style.flex=`1`,a.style.minWidth=`0`,i.appendChild(a),r.appendChild(i);let o=document.createElement(`div`);o.className=`tb-validation`,o.style.display=`none`,r.appendChild(o);let s=null,c=()=>{if(!s)return;let e=eL(s);if(o.innerHTML=``,e.length===0){o.style.display=`block`;let e=document.createElement(`div`);e.className=`tb-validation-item`,e.innerHTML=`<span style="color:var(--chc-status-success)">✓ Valid topology</span>`,o.appendChild(e)}else{o.style.display=`block`;for(let t of e){let e=document.createElement(`div`);e.className=`tb-validation-item`;let n=document.createElement(`span`);n.className=`tb-validation-icon tb-validation-icon--${t.severity}`,n.textContent=t.severity===`error`?`!`:`?`;let r=document.createElement(`span`);r.textContent=t.message,e.appendChild(n),e.appendChild(r),o.appendChild(e)}}setTimeout(()=>{o.style.display=`none`},5e3)},l=[];if(!n.readOnly){let t=[{label:`Main`,value:mL,onClick:()=>e.onAddStructure(mL),close:!0},{label:`Lucky Draw`,value:vL,onClick:()=>e.onAddStructure(mL,vL),close:!0},{label:`Qualifying`,value:hL,onClick:()=>e.onAddStructure(hL),close:!0},{label:`Consolation`,value:gL,onClick:()=>e.onAddStructure(gL),close:!0},{label:`Playoff`,value:_L,onClick:()=>e.onAddStructure(_L),close:!0}];l.push({label:`Add Structure`,location:`right`,options:t})}if(!n.hideTemplates&&t.length>0){let n=t.map(n=>({label:n.name,value:n.name,onClick:()=>{let r=t.find(e=>e.name===n.name);r&&e.onLoadTemplate(r)},close:!0}));l.push({label:`Templates`,location:`right`,options:n})}!n.readOnly&&e.onClear&&l.push({label:`Clear`,location:`right`,onClick:()=>e.onClear()}),n.readOnly||l.push({label:`Auto Layout`,location:`right`,onClick:()=>e.onAutoLayout()},{label:`Validate`,location:`right`,onClick:()=>c()}),!n.readOnly&&e.onSaveTemplate&&l.push({label:`Save Template`,location:`right`,intent:`is-success`,onClick:()=>e.onSaveTemplate()}),!n.readOnly&&!n.hideGenerate&&l.push({label:`Generate Draw`,location:`right`,intent:`is-success`,onClick:()=>e.onGenerate()}),Yk({target:a,items:l});function u(e){s=e}return{element:r,update:u}}function bL({toolbar:e,canvas:t,nodeEditor:n,edgeEditor:r}){let i=document.createElement(`div`);i.className=`tb-layout`,i.appendChild(e.element);let a=document.createElement(`div`);a.className=`tb-body`,a.appendChild(t.element);let o=document.createElement(`div`);o.className=`tb-editor`,o.appendChild(n.element),o.appendChild(r.element),a.appendChild(o),i.appendChild(a);function s(i){if(e.update(i),t.update(i),n.element.style.display=i.selectedNodeId?``:`none`,r.element.style.display=i.selectedEdgeId?``:`none`,!i.selectedNodeId&&!i.selectedEdgeId){if(!o.querySelector(`.tb-editor-empty`)){let e=document.createElement(`div`);e.className=`tb-editor-empty`,e.textContent=`Select a structure or link to view properties`,o.appendChild(e)}}else{let e=o.querySelector(`.tb-editor-empty`);e&&e.remove()}n.update(i),r.update(i)}function c(){e.destroy?.(),t.destroy?.(),n.destroy?.(),r.destroy?.()}return{element:i,update:s,destroy:c}}var{SINGLE_ELIMINATION:xL,FEED_IN:SL,ROUND_ROBIN:CL,LUCKY_DRAW:wL,MAIN:TL,QUALIFYING:EL,CONSOLATION:DL,PLAY_OFF:OL}=t.drawDefinitionConstants,kL=`WINNER`,AL=`LOSER`,jL=`POSITION`,ML=`tpl-edge-1`,NL=`tpl-edge-2`,PL=`tpl-edge-3`,FL=`tpl-edge-4`,IL=`tpl-edge-5`,LL=`tpl-edge-6`,RL=`tpl-edge-7`,zL=`R1 losers → R1`,BL=[{name:`Single Elimination + Qualifying`,description:`Standard SE main draw with one qualifying structure`,state:{drawName:`SE + Qualifying`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:TL,structureType:xL,drawSize:32,position:{x:320,y:40}},{id:`tpl-qual`,structureName:`Qualifying`,stage:EL,structureType:xL,drawSize:16,qualifyingPositions:4,position:{x:40,y:40}}],edges:[{id:ML,sourceNodeId:`tpl-qual`,targetNodeId:`tpl-main`,linkType:kL,targetRoundNumber:1,qualifyingPositions:4,label:`winners → R1 (4Q)`}]}},{name:`FMLC (First Match Loser Consolation)`,description:`Main draw with first match loser consolation`,state:{drawName:`FMLC`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:TL,structureType:xL,drawSize:32,position:{x:40,y:40}},{id:`tpl-cons`,structureName:`Consolation`,stage:DL,structureType:xL,drawSize:16,position:{x:320,y:40}}],edges:[{id:ML,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:zL}]}},{name:`Feed-In Championship (FIC)`,description:`Main draw with multi-round fed consolation`,state:{drawName:`FIC`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:TL,structureType:xL,drawSize:32,position:{x:40,y:40}},{id:`tpl-cons`,structureName:`Consolation`,stage:DL,structureType:SL,drawSize:31,position:{x:460,y:40}}],edges:[{id:ML,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:zL},{id:NL,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:AL,sourceRoundNumber:2,targetRoundNumber:2,label:`R2 losers → R2`},{id:PL,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:AL,sourceRoundNumber:3,targetRoundNumber:4,label:`R3 losers → R4`},{id:FL,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:AL,sourceRoundNumber:4,targetRoundNumber:6,label:`R4 losers → R6`},{id:IL,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:AL,sourceRoundNumber:5,targetRoundNumber:8,label:`R5 losers → R8`}]}},{name:`Compass`,description:`8-draw compass structure`,state:{drawName:`Compass`,nodes:[{id:`tpl-east`,structureName:`East`,stage:TL,structureType:xL,drawSize:32,position:{x:40,y:40}},{id:`tpl-west`,structureName:`West`,stage:DL,structureType:xL,drawSize:16,position:{x:400,y:40}},{id:`tpl-north`,structureName:`North`,stage:DL,structureType:xL,drawSize:8,position:{x:400,y:210}},{id:`tpl-ne`,structureName:`Northeast`,stage:DL,structureType:xL,drawSize:4,position:{x:400,y:380}},{id:`tpl-south`,structureName:`South`,stage:DL,structureType:xL,drawSize:8,position:{x:680,y:40}},{id:`tpl-sw`,structureName:`Southwest`,stage:DL,structureType:xL,drawSize:4,position:{x:680,y:210}},{id:`tpl-nw`,structureName:`Northwest`,stage:DL,structureType:xL,drawSize:4,position:{x:680,y:380}},{id:`tpl-se`,structureName:`Southeast`,stage:DL,structureType:xL,drawSize:4,position:{x:960,y:40}}],edges:[{id:ML,sourceNodeId:`tpl-east`,targetNodeId:`tpl-west`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:zL},{id:NL,sourceNodeId:`tpl-east`,targetNodeId:`tpl-north`,linkType:AL,sourceRoundNumber:2,targetRoundNumber:1,label:`R2 losers → R1`},{id:PL,sourceNodeId:`tpl-east`,targetNodeId:`tpl-ne`,linkType:AL,sourceRoundNumber:3,targetRoundNumber:1,label:`R3 losers → R1`},{id:FL,sourceNodeId:`tpl-west`,targetNodeId:`tpl-south`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:zL},{id:IL,sourceNodeId:`tpl-west`,targetNodeId:`tpl-sw`,linkType:AL,sourceRoundNumber:2,targetRoundNumber:1,label:`R2 losers → R1`},{id:LL,sourceNodeId:`tpl-north`,targetNodeId:`tpl-nw`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:zL},{id:RL,sourceNodeId:`tpl-south`,targetNodeId:`tpl-se`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:zL}]}},{name:`Round Robin + Playoff`,description:`Round robin groups with winners and consolation playoffs`,state:{drawName:`RR + Playoff`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:TL,structureType:CL,drawSize:16,structureOptions:{groupSize:4},position:{x:40,y:40}},{id:`tpl-playoff-gold`,structureName:`Gold Flight`,stage:OL,structureType:xL,drawSize:8,position:{x:320,y:40}},{id:`tpl-playoff-silver`,structureName:`Silver Flight`,stage:OL,structureType:xL,drawSize:8,position:{x:320,y:220}}],edges:[{id:ML,sourceNodeId:`tpl-main`,targetNodeId:`tpl-playoff-gold`,linkType:jL,finishingPositions:[1,2],label:`positions 1,2`},{id:NL,sourceNodeId:`tpl-main`,targetNodeId:`tpl-playoff-silver`,linkType:jL,finishingPositions:[3,4],label:`positions 3,4`}]}},{name:`Lucky Draw + Consolation`,description:`Lucky draw main with consolation receiving R1 losers`,state:{drawName:`Lucky + Consolation`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:TL,structureType:wL,drawSize:11,position:{x:40,y:40}},{id:`tpl-cons`,structureName:`Consolation`,stage:DL,structureType:xL,drawSize:4,position:{x:340,y:40}}],edges:[{id:ML,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:zL}]}},{name:`Lucky Draw → Round Robin`,description:`Lucky draw main with R1 losers feeding into round robin consolation`,state:{drawName:`Lucky → RR`,nodes:[{id:`tpl-main`,structureName:`Main Draw`,stage:TL,structureType:wL,drawSize:25,position:{x:40,y:40}},{id:`tpl-cons-rr`,structureName:`Consolation RR`,stage:DL,structureType:CL,drawSize:12,structureOptions:{groupSize:4},position:{x:500,y:40}}],edges:[{id:ML,sourceNodeId:`tpl-main`,targetNodeId:`tpl-cons-rr`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:zL}]}},{name:`Adaptive (drawSize 11)`,description:`Compass-like multi-structure topology with lucky draw structures`,state:{drawName:`Adaptive`,nodes:[{id:`tpl-east`,structureName:`East`,stage:TL,structureType:wL,drawSize:11,position:{x:40,y:40}},{id:`tpl-west`,structureName:`West`,stage:DL,structureType:wL,drawSize:6,position:{x:340,y:40}},{id:`tpl-north`,structureName:`North`,stage:DL,structureType:xL,drawSize:2,position:{x:340,y:250}},{id:`tpl-south`,structureName:`South`,stage:DL,structureType:xL,drawSize:2,position:{x:600,y:40}}],edges:[{id:ML,sourceNodeId:`tpl-east`,targetNodeId:`tpl-west`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:`R1 losers → R1 (6 losers)`},{id:NL,sourceNodeId:`tpl-east`,targetNodeId:`tpl-north`,linkType:AL,sourceRoundNumber:2,targetRoundNumber:1,label:`R2 losers → R1 (2 losers)`},{id:PL,sourceNodeId:`tpl-west`,targetNodeId:`tpl-south`,linkType:AL,sourceRoundNumber:1,targetRoundNumber:1,label:`R1 losers → R1 (2 losers)`}]}}],{MAIN:VL,QUALIFYING:HL,CONSOLATION:UL,PLAY_OFF:WL,SINGLE_ELIMINATION:GL,LUCKY_DRAW:KL,WINNER:qL,LOSER:JL}=t.drawDefinitionConstants,YL=`POSITION`,XL=class{constructor(e={}){this.config=e,this.store=new YF(e.initialState);let t=[...BL,...e.templates||[]],n=!!e.readOnly,r=this.buildToolbarPanel(t,n),i=this.buildCanvasPanel(n),a=MI({onUpdateNode:n?()=>{}:(e,t)=>this.store.updateNode(e,t),onUpdateEdge:n?()=>{}:(e,t)=>this.store.updateEdge(e,t),onDeleteNode:n?()=>{}:e=>this.store.removeNode(e),readOnly:n,hideDelete:e.hideDelete}),o=WI({onUpdateEdge:n?()=>{}:(e,t)=>this.store.updateEdge(e,t),onDeleteEdge:n?()=>{}:e=>this.store.removeEdge(e),readOnly:n});this.layout=bL({toolbar:r,canvas:i,nodeEditor:a,edgeEditor:o}),this.unsubscribe=this.store.subscribe(e=>{this.layout.update(e)}),this.layout.update(this.store.getState())}buildToolbarPanel(e,t){return yL({onAddStructure:(e,t)=>this.addDefaultStructure(e,t),onLoadTemplate:e=>{this.store.loadState({...e.state,selectedNodeId:null,selectedEdgeId:null,templateName:e.name})},onAutoLayout:()=>{this.store.autoLayout();let e=this.store.getState();this.store.loadState(e)},onGenerate:()=>this.handleGenerate(),onSaveTemplate:this.config.onSaveTemplate?()=>this.config.onSaveTemplate(this.store.getState()):void 0,onClear:this.config.onClear},e,{hideTemplates:this.config.hideTemplates,hideGenerate:this.config.hideGenerate,readOnly:t})}buildCanvasPanel(e){return oI({onSelectNode:e=>this.store.selectNode(e),onSelectEdge:e=>this.store.selectEdge(e),onDoubleClickNode:this.config.onDoubleClickNode?e=>{let t=this.store.getState(),n=t.nodes.find(t=>t.id===e);n&&this.config.onDoubleClickNode(n,t)}:void 0,onMoveNode:(e,t,n)=>this.store.updateNode(e,{position:{x:t,y:n}}),onCreateEdge:e?()=>{}:(e,t,n)=>{this.handleCreateEdge(e,t,n)},onPortMouseDown:()=>{}})}handleCreateEdge(e,t,n){let r=this.store.getState().nodes.find(t=>t.id===e);if(n===YL){let i=this.store.getState().edges.filter(t=>t.sourceNodeId===e&&t.linkType===YL),a=new Set(i.flatMap(e=>e.finishingPositions||[])),o=r?.structureOptions?.groupSize||4,s=1;for(let e=1;e<=o;e++)if(!a.has(e)){s=e;break}this.store.addEdge({sourceNodeId:e,targetNodeId:t,linkType:n,finishingPositions:[s]})}else if(n===JL){let i=this.store.getState().edges.filter(t=>t.sourceNodeId===e&&t.linkType===JL),a=new Set(i.map(e=>e.sourceRoundNumber)),o=r?iF(r.structureType,r.drawSize,r.structureOptions):1,s=1;for(let e=1;e<=o;e++)if(!a.has(e)){s=e;break}this.store.addEdge({sourceNodeId:e,targetNodeId:t,linkType:n,sourceRoundNumber:s})}else{let i=n===qL&&r?.stage===HL;this.store.addEdge({sourceNodeId:e,targetNodeId:t,linkType:n,...i&&{targetRoundNumber:1}})}}render(e){e.appendChild(this.layout.element)}destroy(){this.unsubscribe(),this.layout.destroy?.(),this.layout.element.remove()}autoLayout(){this.store.autoLayout();let e=this.store.getState();this.store.loadState(e)}getState(){return this.store.getState()}loadState(e){this.store.loadState(e)}addDefaultStructure(e,t){let n=t===KL,r=this.store.getState().nodes.filter(t=>t.stage===e).length,i={[VL]:n?`Lucky Draw`:`Main Draw`,[HL]:`Qualifying ${r+1}`,[UL]:`Consolation`,[WL]:`Playoff ${r+1}`},a={[VL]:n?11:32,[HL]:16,[UL]:16,[WL]:4}[e]||16,o=this.store.addNode({structureName:i[e]||e,stage:e,structureType:t||GL,drawSize:a,...e===HL&&{qualifyingPositions:Math.floor(a/4)}});this.scrollCanvasToNode(o)}scrollCanvasToNode(e){let t=this.layout.element.querySelector(`.tb-canvas`);t&&requestAnimationFrame(()=>{let n=e.position.x+MF(e)+40;n>t.scrollLeft+t.clientWidth&&t.scrollTo({left:n-t.clientWidth,behavior:`smooth`})})}handleGenerate(){let e=this.store.getState(),t=eL(e);t.some(e=>e.severity===`error`)&&console.warn(`Topology validation errors:`,t),this.config.onGenerate&&this.config.onGenerate(e)}},{MAIN:ZL,CONSOLATION:QL,QUALIFYING:$L,PLAY_OFF:eR,SINGLE_ELIMINATION:tR,FEED_IN:nR,FIRST_MATCH_LOSER_CONSOLATION:rR,FEED_IN_CHAMPIONSHIP:iR,COMPASS:aR,WINNER:oR,LOSER:sR,ROUND_ROBIN:cR,AD_HOC:lR,LUCKY_DRAW:uR}=t.drawDefinitionConstants,dR=`POSITION`;function fR(e,t){let n=e.nodes.filter(e=>e.stage===QL),r=e.nodes.filter(e=>e.stage===$L),i=e.nodes.filter(e=>e.stage===eR);if(t.structureType===cR)return e.edges.some(n=>n.sourceNodeId===t.id&&n.linkType===dR&&e.nodes.some(e=>e.id===n.targetNodeId&&e.stage===eR))?`ROUND_ROBIN_WITH_PLAYOFF`:cR;if(t.structureType===lR)return lR;if(t.structureType===nR)return nR;if(t.structureType===uR)return uR;if(n.length===7&&r.length===0&&i.length===0){let n=e.edges.filter(e=>e.linkType===sR&&e.sourceNodeId===t.id),r=new Set(n.map(e=>e.sourceRoundNumber));if(r.has(1)&&r.has(2)&&r.has(3))return aR}if(n.length===1&&r.length===0&&i.length===0){let r=n[0],i=e.edges.filter(e=>e.linkType===sR&&e.sourceNodeId===t.id&&e.targetNodeId===r.id);if(r.structureType===nR||i.length>1)return iR;if(i.length===1&&i[0].sourceRoundNumber===1)return rR}return tR}function pR(e){let t=e.nodes.find(e=>e.stage===ZL);if(!t)throw Error(`No main structure node found`);let n=e.nodes.filter(e=>e.stage===$L),r=e.nodes.filter(e=>e.stage===eR),i=fR(e,t);i===tR&&!vR(t.drawSize)&&(i=nR);let a={drawName:e.drawName,drawType:i,drawSize:t.drawSize,matchUpFormat:t.matchUpFormat||void 0,structureOptions:t.structureOptions||void 0,automated:!0};n.length>0&&gR(a,n,e.edges);let o=[];return mR(e,t,i,o),hR(e,t,r,a),{drawOptions:a,postGenerationMethods:o}}function mR(e,t,n,r){let i=e.nodes.filter(e=>e.stage===QL),a=e.edges.filter(e=>e.linkType===sR&&e.sourceNodeId===t.id&&i.some(t=>t.id===e.targetNodeId)),o=[rR,iR,aR];if(a.length===0||o.includes(n))return;let s=new Map;for(let e of a)s.has(e.targetNodeId)||s.set(e.targetNodeId,[]),s.get(e.targetNodeId).push(e);for(let[e,t]of s){let n=i.find(t=>t.id===e);if(!n)continue;let a=t.map(e=>({sourceRoundNumber:e.sourceRoundNumber||1,targetRoundNumber:e.targetRoundNumber||1}));r.push({method:`attachConsolationStructures`,params:{structureName:n.structureName,structureType:n.structureType,drawSize:n.drawSize,matchUpFormat:n.matchUpFormat||void 0,structureOptions:n.structureOptions||void 0,links:a}})}}function hR(e,t,n,r){let i=t.structureType===cR,a=i?e.edges.filter(e=>e.sourceNodeId===t.id&&e.linkType===dR&&n.some(t=>t.id===e.targetNodeId)):[];if(i&&a.length>0){let e=new Map;for(let t of a)e.has(t.targetNodeId)||e.set(t.targetNodeId,[]),e.get(t.targetNodeId).push(t);let t=[];for(let[r,i]of e){let e=n.find(e=>e.id===r);if(!e)continue;let a=Array.from(new Set(i.flatMap(e=>e.finishingPositions||[]))).sort((e,t)=>e-t),o=e.structureOptions?.playoffDrawType||tR,s={finishingPositions:a,structureName:e.structureName,drawType:o};o===cR&&e.structureOptions?.groupSize&&(s.structureOptions={groupSize:e.structureOptions.groupSize}),t.push(s)}t.length>0&&(r.structureOptions={...r.structureOptions,playoffGroups:t})}else if(n.length>0){let i=_R(t.id,n,e.edges);i&&(r.withPlayoffs=i)}}function gR(e,t,n){let r=n.filter(e=>e.linkType===oR&&t.some(t=>t.id===e.sourceNodeId)),i={};for(let e of t){let t=r.find(t=>t.sourceNodeId===e.id),n=t?.targetRoundNumber||1;i[n]||(i[n]=[]),i[n].push({node:e,edge:t})}let a=0;e.qualifyingProfiles=Object.entries(i).map(([e,t])=>{let n=t.map(({node:e,edge:t})=>{let n=e.qualifyingPositions||t?.qualifyingPositions||Math.floor(e.drawSize/4);return a+=n,{structureName:e.structureName,drawType:e.structureType,drawSize:e.drawSize,qualifyingPositions:n,seedsCount:0}});return{roundTarget:Number(e),structureProfiles:n}}),e.qualifiersCount=a,e.qualifyingPlaceholder=!0}function _R(e,t,n){let r=n.filter(n=>n.sourceNodeId===e&&n.linkType===sR&&t.some(e=>e.id===n.targetNodeId));if(!r.length)return;let i=[],a={},o={};for(let e of r){if(!e.sourceRoundNumber)continue;let r=t.find(t=>t.id===e.targetNodeId);if(!r)continue;i.push({[e.sourceRoundNumber]:1});let s=`0-${i.length}`;a[s]={name:r.structureName,abbreviation:r.structureName.substring(0,3)};let c=_R(r.id,t,n);c&&(o[e.sourceRoundNumber]=c)}if(i.length)return{roundProfiles:i,...Object.keys(a).length>0&&{playoffAttributes:a},...Object.keys(o).length>0&&{roundPlayoffs:o}}}function vR(e){return e>0&&(e&e-1)==0}var{MAIN:yR}=t.drawDefinitionConstants,bR=()=>`spl-layout`,xR=()=>`spl-left`,SR=()=>`spl-toggle`,CR=()=>`spl-center`,wR=()=>`spl-center-header`,TR=()=>`spl-center-title`,ER=()=>`spl-center-actions`,DR=()=>`spl-center-leading`,OR=()=>`spl-grid-slot`,kR=()=>`spl-right`,AR=()=>`spl-matchup-card`,jR=()=>`spl-card-title`,MR=()=>`spl-card-sides`,NR=()=>`spl-card-meta`,PR=()=>`spl-card-chips`,FR=()=>`spl-card-chip`,IR=()=>`sp-panel`,LR=()=>`sp-panel-header`,RR=()=>`sp-panel-title`,zR=()=>`sp-panel-meta`,BR=()=>`sp-date-strip`,VR=()=>`sp-date-chip`,HR=()=>`sp-badges`,UR=()=>`sp-catalog`,WR=()=>`sp-catalog-toolbar`,GR=()=>`sp-input`,KR=()=>`sp-select`,qR=()=>`sp-group`,JR=()=>`sp-group-header`,YR=()=>`sp-group-body`,XR=()=>`sp-group-chevron`,ZR=()=>`sp-issues`,QR=()=>`sp-issue`,$R=()=>`sp-issue-code`,ez=()=>`sp-issue-msg`,tz=()=>`sp-inspector`,nz=()=>`sp-kv`,rz=()=>`sp-kv-key`,iz=()=>`sp-kv-value`,az=()=>`sp-small`;function oz(e,t,n){let r=!!n?.hideLeft,i=n?.catalogSide===`left`,a=document.createElement(`div`);a.className=bR();let o=null,s=null;if(r)i?a.classList.add(`spl-catalog-left`):a.classList.add(`spl-no-left`);else{o=document.createElement(`div`),o.className=xR(),s=document.createElement(`button`),s.className=SR(),s.textContent=`◀`,s.title=`Toggle sidebar`,s.addEventListener(`click`,()=>t.onToggleLeft()),o.appendChild(s);let n=document.createElement(`div`);n.className=`spl-left-content`,n.style.cssText=`display:flex;flex-direction:column;gap:12px;flex:1;min-height:0`,e.dateStrip.element.style.flex=`1`,e.dateStrip.element.style.minHeight=`0`,e.dateStrip.element.style.overflow=`auto`,n.appendChild(e.dateStrip.element),e.issuesPanel.element.style.flex=`1`,e.issuesPanel.element.style.minHeight=`0`,e.issuesPanel.element.style.overflow=`auto`,n.appendChild(e.issuesPanel.element),o.appendChild(n)}let c=e.courtGridSlot.element,l=document.createElement(`div`);l.className=kR(),e.matchUpCatalog.element.style.flex=`3`,e.matchUpCatalog.element.style.minHeight=`0`,e.matchUpCatalog.element.style.overflow=`auto`,l.appendChild(e.matchUpCatalog.element),e.inspectorPanel.element.style.flex=`1`,e.inspectorPanel.element.style.minHeight=`120px`,e.inspectorPanel.element.style.overflow=`auto`,l.appendChild(e.inspectorPanel.element),o&&a.appendChild(o),i&&r?(a.appendChild(l),a.appendChild(c)):(a.appendChild(c),a.appendChild(l));function u(t){r||(t.leftCollapsed?(a.classList.add(`spl-left-collapsed`),s&&(s.textContent=`▶`)):(a.classList.remove(`spl-left-collapsed`),s&&(s.textContent=`◀`)),e.dateStrip.update(t),e.issuesPanel.update(t)),e.courtGridSlot.update(t),e.matchUpCatalog.update(t),e.inspectorPanel.update(t)}return{element:a,update:u}}function sz(e){let t=e.sides;if(t?.length===2){let e=cz(t[0]),n=cz(t[1]);if(e&&n)return`${e} vs ${n}`;if(e)return`${e} vs TBD`;if(n)return`TBD vs ${n}`}return`TBD vs TBD`}function cz(e){return e?`${e.participantName??``}${e.seedNumber?` [${e.seedNumber}]`:``}`:``}function lz(e){let t=[e.eventName,e.drawName??``,e.roundName??``];if(e.sides)for(let n of e.sides)n.participantName&&t.push(n.participantName);return t.join(` `).toLowerCase()}function uz(){let e=document.createElement(`div`);e.className=IR();let t=document.createElement(`div`);t.className=LR();let n=document.createElement(`div`);n.className=RR(),n.textContent=`Inspector`,t.appendChild(n),e.appendChild(t);let r=document.createElement(`div`);r.className=tz(),e.appendChild(r);function i(e){r.innerHTML=``;let t=e.selectedMatchUp;if(!t){let e=document.createElement(`div`);e.className=az(),e.textContent=`Select a matchUp in the catalog to see details.`,r.appendChild(e);return}if(dz(r,`Event`,t.eventName),dz(r,`Draw`,t.drawName??t.drawId),dz(r,`Round`,t.roundName??`Round ${t.roundNumber}`),dz(r,`Type`,t.matchUpType??`—`),dz(r,`Format`,t.matchUpFormat??`—`),dz(r,`Scheduled`,t.isScheduled?`Yes`:`No`),t.scheduledTime&&dz(r,`Time`,t.scheduledTime),t.scheduledCourtName&&dz(r,`Court`,t.scheduledCourtName),t.sides?.length){let e=document.createElement(`div`);e.className=az(),e.style.marginTop=`8px`,e.textContent=`Participants:`,r.appendChild(e);let n=document.createElement(`div`);n.className=`spl-inspector-sides`;for(let e of t.sides){let t=document.createElement(`div`);t.className=`spl-inspector-side`;let r=document.createElement(`span`);if(r.textContent=cz(e)||`TBD`,t.appendChild(r),e.ranking){let n=document.createElement(`span`);n.className=`spl-inspector-seed`,n.textContent=`#${e.ranking}`,t.appendChild(n)}n.appendChild(t)}r.appendChild(n)}}return{element:e,update:i}}function dz(e,t,n){let r=document.createElement(`div`);r.className=nz();let i=document.createElement(`div`);i.className=rz(),i.textContent=t;let a=document.createElement(`div`);a.className=iz(),a.textContent=n,r.appendChild(i),r.appendChild(a),e.appendChild(r)}var fz=new Set([`COMPLETED`,`RETIRED`,`WALKOVER`,`DEFAULTED`,`DOUBLE_WALKOVER`,`DOUBLE_DEFAULT`,`CANCELLED`,`ABANDONED`,`DEAD_RUBBER`]);function pz(e){return!!e&&fz.has(e)}function mz(e,t,n=`dim`,r,i=!1){let a=t.toLowerCase().trim();return e.filter(e=>n===`hide`&&e.isScheduled||!i&&pz(e.matchUpStatus)||r&&(r.eventType&&e.matchUpType!==r.eventType||r.eventName&&e.eventName!==r.eventName||r.drawName&&(e.drawName??e.drawId)!==r.drawName||r.gender&&e.gender!==r.gender||r.roundName&&e.roundName!==r.roundName)?!1:a?lz(e).includes(a):!0)}function hz(e,t){let n=new Map,r=e=>t===`draw`?`${e.eventName} \u2014 ${e.drawName??e.drawId}`:t===`round`?e.roundName??`Round ${e.roundNumber}`:t===`structure`?`${e.eventName} \u2014 ${e.structureId}`:e.eventName;for(let t of e){let e=r(t),i=n.get(e);i?i.push(t):n.set(e,[t])}return new Map([...n.entries()].sort((e,t)=>e[0].localeCompare(t[0],void 0,{numeric:!0})))}function gz(e,t){let n=document.createElement(`div`);n.className=AR(),n.setAttribute(`data-matchup-id`,e.matchUpId);let r=pz(e.matchUpStatus);e.isScheduled?(n.classList.add(`scheduled`),n.draggable=!1):r?(n.classList.add(`completed`),n.draggable=!1):(n.draggable=!0,n.addEventListener(`dragstart`,t=>{t.stopPropagation(),t.dataTransfer.setDragImage(n,n.offsetWidth/2,20),t.dataTransfer.setData(`application/json`,JSON.stringify({type:`CATALOG_MATCHUP`,matchUp:e})),t.dataTransfer.effectAllowed=`copyMove`})),t.onClick&&n.addEventListener(`click`,n=>{n.stopPropagation(),t.onClick(e)});let i=document.createElement(`div`);i.className=jR(),i.textContent=`${e.eventName} \u2014 ${e.roundName??`Round `+e.roundNumber}`,n.appendChild(i);let a=document.createElement(`div`);a.className=MR(),a.textContent=sz(e),n.appendChild(a);let o=document.createElement(`div`);o.className=NR();let s=[];e.drawName&&s.push(e.drawName),e.matchUpType&&s.push(e.matchUpType.toLowerCase()),o.textContent=s.join(` · `),n.appendChild(o);let c=document.createElement(`div`);if(c.className=PR(),e.scheduledTime&&c.appendChild(_z(e.scheduledTime,`time`)),e.scheduledCourtName&&c.appendChild(_z(e.scheduledCourtName,`court`)),e.matchUpFormat&&c.appendChild(_z(e.matchUpFormat,`type`)),r&&e.matchUpStatus){let t=e.matchUpStatus.replace(/_/g,` `);c.appendChild(_z(t,`status`))}if(c.children.length&&n.appendChild(c),e.isScheduled){let e=document.createElement(`span`);e.className=`spl-matchup-check`,e.textContent=`✓`,n.appendChild(e)}return n}function _z(e,t){let n=document.createElement(`div`);return n.className=FR()+` `+t,n.textContent=e,n}function vz(e,t){let n=new Set;for(let r of e){let e=t(r);e&&n.add(e)}return[...n].sort((e,t)=>e.localeCompare(t,void 0,{numeric:!0}))}function yz(e){let t=document.createElement(`div`);t.className=IR();let n=`spl-catalog-drop-over`,r=`is-filtering`,i=new Set,a=null,o,s={};t.addEventListener(`dragover`,e=>{e.preventDefault(),t.classList.add(n),e.dataTransfer.dropEffect=`move`}),t.addEventListener(`dragleave`,e=>{t.contains(e.relatedTarget)||t.classList.remove(n)}),t.addEventListener(`drop`,r=>{if(t.classList.remove(n),r.preventDefault(),!e.onDropRemove)return;let i;try{i=JSON.parse(r.dataTransfer.getData(`application/json`))}catch{return}(i.type===`CATALOG_MATCHUP`||i.type===`GRID_MATCHUP`)&&e.onDropRemove(i.matchUp.matchUpId)});let c=document.createElement(`div`);c.className=LR();let l=document.createElement(`div`);l.className=`spl-catalog-title-row`;let u=document.createElement(`div`);u.className=RR(),u.textContent=`MatchUp Catalog`;let d=document.createElement(`button`);d.className=`spl-catalog-filter-btn`,d.title=`Filter matchUps`,d.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"/></svg>`,l.appendChild(u),l.appendChild(d);let f=document.createElement(`div`);f.className=zR(),c.appendChild(l),c.appendChild(f),t.appendChild(c);let p=document.createElement(`div`);p.className=WR();let m=document.createElement(`input`);m.type=`text`,m.placeholder=`Search matchUps...`,m.className=GR(),m.addEventListener(`input`,()=>e.onSearchChange(m.value));let h=Mb(m,()=>{m.value=``,e.onSearchChange(``),m.focus()}),g=document.createElement(`select`);g.className=KR();for(let[e,t]of[[`event`,`By Event`],[`draw`,`By Draw`],[`round`,`By Round`],[`structure`,`By Structure`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,g.appendChild(n)}g.addEventListener(`change`,()=>e.onGroupByChange(g.value)),p.appendChild(h),p.appendChild(g),t.appendChild(p);function _(){o&&=(o.destroy(),void 0)}function v(){return!!(s.eventType||s.eventName||s.drawName||s.gender||s.roundName)}function y(){d.classList.toggle(`active`,v())}function b(){let t=a?.matchUpCatalog??[],n=document.createElement(`div`);n.className=`spl-filter-popover`;let i=document.createElement(`div`);i.className=`spl-filter-header`;let o=document.createElement(`button`);o.className=`spl-filter-clear-btn`,o.textContent=`Clear All`,o.addEventListener(`click`,t=>{t.stopPropagation(),s={},e.onFilterChange(s),y();for(let e of n.querySelectorAll(`select`)){e.value=``,e.classList.remove(r);let t=e.previousElementSibling;t?.classList.contains(`spl-filter-label`)&&t.classList.remove(r)}}),i.appendChild(o);let c=document.createElement(`button`);c.className=`spl-filter-close-btn`,c.textContent=`×`,c.addEventListener(`click`,e=>{e.stopPropagation(),_()}),i.appendChild(c),n.appendChild(i);let l=[{label:`All Event Types`,key:`eventType`,values:vz(t,e=>e.matchUpType)},{label:`All Events`,key:`eventName`,values:vz(t,e=>e.eventName)},{label:`All Flights`,key:`drawName`,values:vz(t,e=>e.drawName)},{label:`All Genders`,key:`gender`,values:vz(t,e=>e.gender)},{label:`All Rounds`,key:`roundName`,values:vz(t,e=>e.roundName)}];for(let t of l){if(t.values.length<2)continue;let i=document.createElement(`label`);i.className=`spl-filter-label`,i.textContent=t.label,n.appendChild(i);let a=document.createElement(`select`);a.className=`spl-filter-select`;let o=document.createElement(`option`);o.value=``,o.textContent=t.label,a.appendChild(o);for(let e of t.values){let t=document.createElement(`option`);t.value=e,t.textContent=e,a.appendChild(t)}a.value=s[t.key]??``;let c=()=>{let e=a.value!==``;a.classList.toggle(r,e),i.classList.toggle(r,e)};c(),a.addEventListener(`change`,()=>{s={...s,[t.key]:a.value||void 0},e.onFilterChange(s),y(),c()}),n.appendChild(a)}let u=document.createElement(`label`);u.className=`spl-filter-toggle`;let d=document.createElement(`input`);d.type=`checkbox`,d.checked=a?.showScheduled??!1,d.addEventListener(`change`,()=>{e.onShowScheduledChange?.(d.checked)}),u.appendChild(d),u.appendChild(document.createTextNode(` Show assigned`)),n.appendChild(u);let f=document.createElement(`label`);f.className=`spl-filter-toggle`;let p=document.createElement(`input`);return p.type=`checkbox`,p.checked=a?.showCompleted??!1,p.addEventListener(`change`,()=>{e.onShowCompletedChange(p.checked)}),f.appendChild(p),f.appendChild(document.createTextNode(` Show completed`)),n.appendChild(f),n}d.addEventListener(`click`,()=>{_(),o=mm(d,{content:b(),placement:`bottom-start`,interactive:!0,trigger:`manual`,appendTo:()=>t,onClickOutside:()=>_(),theme:``}),o.show()});let x=document.createElement(`div`);x.className=UR(),t.appendChild(x);function S(t){a=t,s=t.catalogFilters??{},y();let n=t.showScheduled?t.scheduledBehavior:`hide`,r=mz(t.matchUpCatalog,t.catalogSearchQuery,n,t.catalogFilters,t.showCompleted),o=hz(r,t.catalogGroupBy);f.textContent=`${r.filter(e=>!e.isScheduled).length} unscheduled`,m.value!==t.catalogSearchQuery&&(m.value=t.catalogSearchQuery,Nb(h)),g.value!==t.catalogGroupBy&&(g.value=t.catalogGroupBy),x.innerHTML=``;for(let[n,r]of o){let o=document.createElement(`div`);o.className=qR();let s=i.has(n),c=document.createElement(`div`);c.className=JR();let l=document.createElement(`span`);l.className=XR(),l.textContent=s?`▶`:`▼`;let u=document.createElement(`span`);u.textContent=`${n} (${r.length})`,c.appendChild(l),c.appendChild(u),c.addEventListener(`click`,()=>{i.has(n)?i.delete(n):i.add(n),a&&S(a)});let d=document.createElement(`div`);d.className=YR(),s&&(d.style.display=`none`);for(let n of r){let r=gz(n,{onClick:t=>e.onMatchUpSelected?.(t)});t.selectedMatchUp?.matchUpId===n.matchUpId&&r.classList.add(`selected`),d.appendChild(r)}o.appendChild(c),o.appendChild(d),x.appendChild(o)}}return{element:t,update:S}}function bz(e){let t={ERROR:[],WARN:[],INFO:[]},n={},r={total:e.length,ERROR:0,WARN:0,INFO:0},i={},a=e=>e===`ERROR`?0:e===`WARN`?1:2;for(let a of e)if(t[a.severity].push(a),r[a.severity]++,a.date){(n[a.date]??=[]).push(a);let e=i[a.date]??={total:0,ERROR:0,WARN:0,INFO:0};e.total++,e[a.severity]++}let o=(e,t)=>a(e.severity)-a(t.severity)||e.message.localeCompare(t.message),s=[...e].sort(o);for(let e of Object.keys(t))t[e].sort(o);for(let e of Object.keys(n))n[e].sort(o);return{all:s,bySeverity:t,byDate:n,counts:r,countsByDate:i}}var xz=`spl-cell--issue-pulse`;function Sz(){let e=document.createElement(`div`);e.className=IR();let t=document.createElement(`div`);t.className=LR();let n=document.createElement(`div`);n.className=RR(),n.textContent=`Issues`;let r=document.createElement(`div`);r.className=zR(),t.appendChild(n),t.appendChild(r),e.appendChild(t);let i=document.createElement(`div`);i.className=ZR(),e.appendChild(i);function a(e){let t=bz(e.issues);if(r.textContent=`${t.counts.total} total (${t.counts.ERROR} errors)`,i.innerHTML=``,!t.all.length){let e=document.createElement(`div`);e.className=az(),e.textContent=`No scheduling conflicts.`,i.appendChild(e);return}for(let e of t.all.slice(0,30)){let t=document.createElement(`div`);t.className=QR(),e.severity===`ERROR`?t.classList.add(`error`):e.severity===`WARN`?t.classList.add(`warn`):t.classList.add(`info`);let n=document.createElement(`div`);n.className=$R(),n.textContent=e.severity;let r=document.createElement(`div`);if(r.className=ez(),e.participants){if(e.prefix){let t=document.createElement(`span`);t.textContent=e.prefix,t.style.opacity=`0.7`,r.appendChild(t)}let t=document.createElement(`span`);t.textContent=(e.issueType||``)+`: `,t.style.opacity=`0.7`,r.appendChild(t);let n=document.createElement(`span`);if(n.textContent=e.participants,n.style.color=`var(--spl-issue-participant1, #4fc3f7)`,n.style.fontWeight=`600`,r.appendChild(n),e.conflictParticipants?.length){let t=document.createElement(`span`);t.textContent=` conflicts with `,t.style.opacity=`0.7`,r.appendChild(t),e.conflictParticipants.forEach((e,t)=>{if(t>0){let e=document.createElement(`span`);e.textContent=`, `,e.style.opacity=`0.7`,r.appendChild(e)}let n=document.createElement(`span`);n.textContent=e,n.style.color=`var(--spl-issue-participant2, #ffb74d)`,n.style.fontWeight=`600`,r.appendChild(n)})}}else r.textContent=e.message;if(e.matchUpId){t.style.cursor=`pointer`;let n=e.matchUpId;t.addEventListener(`click`,()=>{console.log(`[issuesPanel] clicked issue row, matchUpId:`,n),o(n)})}else console.log(`[issuesPanel] issue has no matchUpId:`,e.message);t.appendChild(n),t.appendChild(r),i.appendChild(t)}}function o(e){let t=`.spl-grid-cell[data-matchup-id="${e}"]`,n=document.querySelector(t);console.log(`[issuesPanel] scrollToMatchUp selector:`,t,`found:`,!!n),n&&(n.scrollIntoView({behavior:`smooth`,block:`center`,inline:`center`}),n.classList.remove(xz),n.offsetWidth,n.classList.add(xz),n.addEventListener(`animationend`,()=>n.classList.remove(xz),{once:!0}))}return{element:e,update:a}}function Cz(e){let t=document.createElement(`div`);t.className=IR();let n=document.createElement(`div`);n.className=LR();let r=document.createElement(`div`);r.className=RR(),r.textContent=`Dates`;let i=document.createElement(`div`);i.className=zR(),n.appendChild(r),n.appendChild(i),t.appendChild(n);let a=document.createElement(`div`);a.className=BR(),t.appendChild(a);function o(t){let n=t.scheduleDates;i.textContent=`${n.length} dates`,a.innerHTML=``;for(let r of n){let n=document.createElement(`div`);n.className=VR(),r.date===t.selectedDate&&n.classList.add(`selected`),r.isActive||n.classList.add(`inactive`),n.setAttribute(`data-date`,r.date);let i=document.createElement(`div`),o=document.createElement(`div`);o.style.cssText=`font-weight:800;font-size:0.75rem`,o.textContent=r.date;let s=document.createElement(`div`);s.style.cssText=`font-size:0.6875rem;color:var(--sp-muted)`,s.textContent=r.isActive?`Active`:`Inactive`,i.appendChild(o),i.appendChild(s);let c=document.createElement(`div`);if(c.className=HR(),r.matchUpCount!=null){let e=document.createElement(`div`);e.className=`spl-date-badge matchups`,e.textContent=`${r.matchUpCount} matchUps`,c.appendChild(e)}if(r.issueCount&&r.issueCount>0){let e=document.createElement(`div`);e.className=`spl-date-badge issues`,e.textContent=`${r.issueCount} issues`,c.appendChild(e)}n.appendChild(i),n.appendChild(c),n.addEventListener(`click`,()=>e.onDateSelected(r.date)),a.appendChild(n)}}return{element:t,update:o}}function wz(e,t,n){let r=document.createElement(`div`);r.className=CR();let i=document.createElement(`div`);i.className=wR();let a=n?.titleLeadingActions,o;if(n?.titleSlot?o=n.titleSlot:(o=document.createElement(`div`),o.className=TR(),o.textContent=`Court Grid`),a){let e=document.createElement(`div`);e.className=DR();let t=Array.isArray(a)?a:[a];for(let n of t)e.appendChild(n);e.appendChild(o),i.appendChild(e)}else i.appendChild(o);let s=n?.headerActions;if(s){let e=document.createElement(`div`);e.className=ER();let t=Array.isArray(s)?s:[s];for(let n of t)e.appendChild(n);i.appendChild(e)}r.appendChild(i);let c=document.createElement(`div`);c.className=OR(),n?.gridMaxHeight&&(c.style.maxHeight=n.gridMaxHeight),e&&c.appendChild(e),c.addEventListener(`dragover`,e=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`}),c.addEventListener(`drop`,e=>{if(e.preventDefault(),!t.onMatchUpDrop)return;let n;try{n=JSON.parse(e.dataTransfer.getData(`application/json`))}catch{return}(n.type===`CATALOG_MATCHUP`||n.type===`GRID_MATCHUP`)&&t.onMatchUpDrop(n,e)}),r.appendChild(c);function l(e){}return{element:r,update:l}}var Tz=class{constructor(e){this.listeners=new Set,this.config=e;let t=e.initialCatalogState??{};this.state={matchUpCatalog:e.matchUpCatalog,scheduleDates:e.scheduleDates,issues:e.issues??[],selectedDate:e.scheduleDates[0]?.date??null,selectedMatchUp:null,catalogSearchQuery:t.catalogSearchQuery??``,catalogGroupBy:t.catalogGroupBy??`event`,catalogFilters:t.catalogFilters??{},showCompleted:t.showCompleted??!1,showScheduled:t.showScheduled??!1,scheduledBehavior:e.scheduledBehavior??`dim`,schedulingMode:e.schedulingMode??`immediate`,pendingActions:[],hasUnsavedChanges:!1,leftCollapsed:!!e.hideLeft,hideLeft:!!e.hideLeft,activeStripVisible:e.activeStripVisible??!0}}getState(){return this.state}setMatchUpCatalog(e){this.setState({matchUpCatalog:e}),this.state.selectedMatchUp&&(e.some(e=>e.matchUpId===this.state.selectedMatchUp?.matchUpId)||this.setState({selectedMatchUp:null}))}setScheduleDates(e){this.setState({scheduleDates:e})}setIssues(e){this.setState({issues:e})}handleMatchUpDrop(e,t){if(this.state.schedulingMode===`immediate`)this.config.onMatchUpDrop?.(e,t);else{let n={kind:`schedule`,matchUpId:e.matchUp.matchUpId,matchUp:e.matchUp,event:t};this.setState({pendingActions:[...this.state.pendingActions,n],hasUnsavedChanges:!0})}}handleMatchUpRemove(e){if(this.state.schedulingMode===`immediate`)this.config.onMatchUpRemove?.(e);else{let t=this.state.pendingActions.findIndex(t=>t.kind===`schedule`&&t.matchUpId===e);if(t>=0){let e=[...this.state.pendingActions];e.splice(t,1),this.setState({pendingActions:e,hasUnsavedChanges:e.length>0})}else{let t={kind:`unschedule`,matchUpId:e};this.setState({pendingActions:[...this.state.pendingActions,t],hasUnsavedChanges:!0})}}}save(){let e=this.state.pendingActions;return e.length?(this.config.onBulkSave?.(e),this.setState({pendingActions:[],hasUnsavedChanges:!1}),e):[]}discardPending(){this.setState({pendingActions:[],hasUnsavedChanges:!1})}getPendingActions(){return this.state.pendingActions}selectDate(e){this.state.selectedDate!==e&&(this.setState({selectedDate:e}),this.config.onDateSelected?.(e))}selectMatchUp(e){this.setState({selectedMatchUp:e}),this.config.onMatchUpSelected?.(e)}setCatalogSearch(e){this.setState({catalogSearchQuery:e})}setCatalogGroupBy(e){this.setState({catalogGroupBy:e})}setCatalogFilters(e){this.setState({catalogFilters:e})}setShowCompleted(e){this.setState({showCompleted:e})}setShowScheduled(e){this.setState({showScheduled:e})}toggleLeftPanel(){this.setState({leftCollapsed:!this.state.leftCollapsed})}setActiveStripVisible(e){this.state.activeStripVisible!==e&&this.setState({activeStripVisible:e})}toggleActiveStrip(){this.setState({activeStripVisible:!this.state.activeStripVisible})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state={...this.state,...e},this.emit()}emit(){for(let e of this.listeners)e(this.state)}},Ez=class{constructor(e){this.container=null,this.store=new Tz(e);let t=Cz({onDateSelected:e=>this.store.selectDate(e)}),n=Sz(),r=wz(e.courtGridElement,{onMatchUpDrop:(e,t)=>{this.store.handleMatchUpDrop(e,t)}},{gridMaxHeight:e.gridMaxHeight,headerActions:e.headerActions,titleLeadingActions:e.titleLeadingActions,titleSlot:e.titleSlot}),i=yz({onSearchChange:e=>this.store.setCatalogSearch(e),onGroupByChange:e=>this.store.setCatalogGroupBy(e),onFilterChange:e=>this.store.setCatalogFilters(e),onShowCompletedChange:e=>this.store.setShowCompleted(e),onShowScheduledChange:e=>this.store.setShowScheduled(e),onMatchUpSelected:e=>this.store.selectMatchUp(e),onDropRemove:e=>{this.store.handleMatchUpRemove(e)}}),a=uz();this.layout=oz({dateStrip:t,issuesPanel:n,courtGridSlot:r,matchUpCatalog:i,inspectorPanel:a},{onToggleLeft:()=>this.store.toggleLeftPanel()},{hideLeft:e.hideLeft,catalogSide:e.catalogSide}),this.unsubscribe=this.store.subscribe(e=>{this.layout.update(e)}),this.layout.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.layout.element)}destroy(){this.unsubscribe(),this.container&&this.layout.element.parentNode===this.container&&this.layout.element.remove(),this.container=null}setMatchUpCatalog(e){this.store.setMatchUpCatalog(e)}setScheduleDates(e){this.store.setScheduleDates(e)}setIssues(e){this.store.setIssues(e)}setActiveStripVisible(e){this.store.setActiveStripVisible(e)}toggleActiveStrip(){this.store.toggleActiveStrip()}get activeStripVisible(){return this.store.getState().activeStripVisible}save(){return this.store.save()}discardPending(){this.store.discardPending()}get hasUnsavedChanges(){return this.store.getState().hasUnsavedChanges}getStore(){return this.store}},Dz=new Set([`IN_PROGRESS`,`SUSPENDED`]),Oz=new Set([`CANCELLED`,`ABANDONED`,`COMPLETED`,`DEAD_RUBBER`,`DEFAULTED`,`DOUBLE_WALKOVER`,`DOUBLE_DEFAULT`,`RETIRED`,`WALKOVER`]),kz=`in-progress`,Az=`pending`,jz=`completed`;function Mz(e,t,n){let r=e.matchUpStatus;return r&&t.has(r)||e.hasScore&&e.winningSide===void 0&&(!r||!n.has(r))?kz:r&&n.has(r)||e.winningSide!==void 0?jz:Az}function Nz(e,t){let n=t?.inProgressStatuses??Dz,r=t?.completedStatuses??Oz,i=e.cells,a=-1;for(let t=0;t<i.length;t++){let o=i[t];if(!o)continue;let s=Mz(o,n,r);if(s===kz)return{courtId:e.courtId,state:kz,matchUp:o,rowIndex:t};s===Az&&a===-1&&(a=t)}return a===-1?{courtId:e.courtId,state:`free`}:{courtId:e.courtId,state:`next`,matchUp:i[a],rowIndex:a}}function Pz(e,t){return e.columns.map(e=>Nz(e,t))}function Fz(e,t){if(t.size===0)return!1;for(let n of e.participantIds)if(t.has(n))return!0;return!1}function Iz(e,t){return t.roundNumber!==void 0&&t.drawId!==void 0&&e.drawId===t.drawId&&e.roundNumber!==void 0&&e.roundNumber<t.roundNumber}function Lz(e,t){let n=new Set(t.participantIds??[]),r=-1,i=-1;for(let a of e.columns)for(let e=0;e<a.cells.length;e++){let o=a.cells[e];!o||o.matchUpId===t.matchUpId||(e>r&&Fz(o,n)&&(r=e),e>i&&Iz(o,t)&&(i=e))}return{participantFloor:r,earlierRoundFloor:i}}function Rz(e,t,n){let r=t;for(;r<e.cells.length;){let t=e.cells[r];if(!t||t.matchUpId===n)return r;r++}return r}function zz(e,t,n){let r=e.columns.find(e=>e.courtId===t);if(!r)throw Error(`computeActiveStripDropTarget: court "${t}" not present in grid`);let{participantFloor:i,earlierRoundFloor:a}=Lz(e,n);return{courtId:t,rowIndex:Rz(r,Math.max(0,i+1,a+1),n.matchUpId)}}var Bz=`drop-over`;function Vz(e,t,n,r){e.addEventListener(`dragover`,t=>{t.preventDefault(),e.classList.add(Bz),t.dataTransfer&&(t.dataTransfer.dropEffect=`move`)}),e.addEventListener(`dragleave`,()=>{e.classList.remove(Bz)}),e.addEventListener(`drop`,i=>{if(e.classList.remove(Bz),i.preventDefault(),!n.onMatchUpDrop)return;let a;try{a=JSON.parse(i.dataTransfer?.getData(`application/json`)??``)}catch{return}if(a.type!==`CATALOG_MATCHUP`&&a.type!==`GRID_MATCHUP`)return;let o={matchUpId:a.matchUp.matchUpId,drawId:a.matchUp.drawId,roundNumber:a.matchUp.roundNumber,participantIds:(a.matchUp.sides??[]).map(e=>e.participantId).filter(e=>!!e)},s=zz(r(),t.courtId,o);n.onMatchUpDrop(a,s,i)})}function Hz(e){return e===`in-progress`?`LIVE`:e===`next`?`NEXT`:null}function Uz(e,t,n,r){let i=document.createElement(`div`);if(i.className=`spl-active-strip-cell state-${e.state}`,i.dataset.courtId=e.courtId,e.rowIndex!==void 0&&(i.dataset.rowIndex=String(e.rowIndex)),r.cellHeight&&(i.style.minHeight=r.cellHeight),e.state!==`free`&&e.matchUp){let t=r.renderCell?.(e.matchUp);if(t)i.appendChild(t);else{let t=document.createElement(`div`);t.className=`spl-active-strip-body`,t.textContent=e.matchUp.participantIds.join(` – `)||e.matchUp.matchUpId,i.appendChild(t)}}let a=Hz(e.state);if(a){let e=document.createElement(`span`);e.className=`spl-active-strip-state-pill`,e.textContent=a,i.appendChild(e)}return Vz(i,e,t,n),i}function Wz(e){let t=document.createElement(`div`);if(t.className=`spl-active-strip-spacer`,e.cellHeight&&(t.style.minHeight=e.cellHeight),e.spacerLabel){let n=document.createElement(`span`);n.className=`spl-active-strip-spacer-label`,n.textContent=e.spacerLabel,t.appendChild(n)}return t}function Gz(e={},t={}){let n=document.createElement(`div`);n.className=`spl-active-strip`;let r={grid:{columns:[]},courts:[]};function i(){return r.grid}function a(){n.innerHTML=``,r.gridTemplateColumns?(n.style.display=`grid`,n.style.gridTemplateColumns=r.gridTemplateColumns):(n.style.display=``,n.style.gridTemplateColumns=``),n.style.minWidth=r.minWidth??``,n.appendChild(Wz(t));let a=Pz(r.grid,t.statusOptions);for(let r of a)n.appendChild(Uz(r,e,i,t))}function o(e){r=e,a()}function s(e){n.hidden=!e.activeStripVisible}return{element:n,setData:o,update:s}}var Kz=`spl-cell--conflict-highlight`,qz=`spl-cell--complete`,Jz={header:[`time`],body:[`eventRound`,`participants`],footer:[`score`],participantDisplay:{nameFormat:`full`,showSeed:!1,showRanking:!1,showNationality:!1,boldWinner:!0,showPotentials:!0}};function Yz(e,t){let n=t??Jz;return e.isBlocked?Xz(e):e.matchUpId?Qz(e,n):Zz()}function Xz(e){let t=document.createElement(`div`);t.className=`spl-grid-cell spl-cell--blocked`;let n=e.booking?.bookingType||`BLOCKED`;t.dataset.bookingType=n;let r=document.createElement(`div`);r.className=`spl-grid-cell__block-label`;let i=document.createElement(`div`);if(i.className=`spl-grid-cell__block-type`,i.textContent=n,r.appendChild(i),e.booking?.rowCount){let t=document.createElement(`div`);t.className=`spl-grid-cell__block-rows`,t.textContent=`${e.booking.rowCount} rows`,r.appendChild(t)}if(e.booking?.notes){let t=document.createElement(`div`);t.className=`spl-grid-cell__block-notes`,t.textContent=e.booking.notes,r.appendChild(t)}return t.appendChild(r),t}function Zz(){let e=document.createElement(`div`);return e.className=`spl-grid-cell spl-cell--empty`,e}function Qz(e,t){let n=document.createElement(`div`);if(n.className=`spl-grid-cell`,n.dataset.matchupId=e.matchUpId,e.drawId&&(n.dataset.drawId=e.drawId),e.gender&&(n.dataset.gender=e.gender),$z(n,e),t.header.length){let r=document.createElement(`div`);r.className=`spl-grid-cell__header`,eB(r,t.header,e,t),n.appendChild(r)}if(t.body.length){let r=document.createElement(`div`);r.className=`spl-grid-cell__body`,eB(r,t.body,e,t),n.appendChild(r)}if(t.footer.length){let r=document.createElement(`div`);r.className=`spl-grid-cell__footer`,eB(r,t.footer,e,t),n.appendChild(r)}return e.issueIds?.length&&(n.addEventListener(`mouseenter`,()=>{n.classList.add(Kz);for(let t of e.issueIds)document.querySelectorAll(`[data-matchup-id="${t}"]`).forEach(e=>e.classList.add(Kz))}),n.addEventListener(`mouseleave`,()=>{n.classList.remove(Kz);for(let t of e.issueIds)document.querySelectorAll(`[data-matchup-id="${t}"]`).forEach(e=>e.classList.remove(Kz))})),n}function $z(e,t){let n=t.matchUpStatus?.toUpperCase();n===`COMPLETED`||n===`RETIRED`||n===`DEFAULTED`||n===`WALKOVER`?e.classList.add(qz):n===`IN_PROGRESS`?e.classList.add(`spl-cell--inprogress`):n===`ABANDONED`?e.classList.add(`spl-cell--abandoned`):n===`CANCELLED`?e.classList.add(`spl-cell--cancelled`):n===`DOUBLE_WALKOVER`&&e.classList.add(`spl-cell--double-walkover`);let r=t.scheduleState?.toUpperCase();r===`SCHEDULE_ERROR`||r===`ERROR`?e.classList.add(`spl-cell--error`):r===`SCHEDULE_CONFLICT`||r===`CONFLICT`?e.classList.add(`spl-cell--conflict`):r===`SCHEDULE_WARNING`||r===`WARNING`?e.classList.add(`spl-cell--warning`):(r===`SCHEDULE_ISSUE`||r===`ISSUE`)&&e.classList.add(`spl-cell--issue`),(t.issueType===`DOUBLE_BOOKING`||t.issueType===`courtDoubleBooking`)&&e.classList.add(`spl-cell--double-booking`)}function eB(e,t,n,r){for(let i of t){let t=tB(i,n,r);t&&e.appendChild(t)}}function tB(e,t,n){switch(e){case`time`:return nB(t);case`eventRound`:return rB(t);case`participants`:return iB(t,n.participantDisplay);case`score`:return lB(t);case`matchUpStatus`:return uB(t);case`matchUpFormat`:return dB(t);case`umpire`:return fB(t);default:return null}}function nB(e){let t=e.schedule?.scheduledTime||e.schedule?.startTime,n=e.schedule?.timeModifiers,r=e.schedule?.courtAnnotation;if(!t&&!n?.length&&!r)return null;let i=document.createElement(`div`);i.className=`spl-grid-cell__time`;let a=[];if(n?.length&&a.push(n.join(` `)),t&&a.push(t),i.textContent=a.join(` `)||``,r){let e=document.createElement(`span`);e.className=`spl-grid-cell__court-annotation`,e.textContent=` ${r}`,i.appendChild(e)}return i}function rB(e){let t=[e.eventName,e.roundName].filter(Boolean);if(!t.length)return null;let n=document.createElement(`div`);return n.className=`spl-grid-cell__event-round`,n.textContent=t.join(` `),n}function iB(e,t){let n=t??Jz.participantDisplay,r=document.createElement(`div`);r.className=`spl-grid-cell__participants`;let i=e.sides||[],a=e.matchUpStatus?.toUpperCase()===`BYE`,o=i.some(e=>e.bye);if(i.length===0&&n.showPotentials!==!1&&e.potentialParticipants?.length){for(let t=0;t<e.potentialParticipants.length;t++){t>0&&r.appendChild(sB());let n=e.potentialParticipants[t].map(e=>e?.participantName||`TBD`).join(` / `),i=document.createElement(`div`);i.className=`spl-grid-cell__side spl-grid-cell__potential`,i.textContent=n||`TBD`,r.appendChild(i)}return r}if(i.length===0)return null;for(let t=0;t<i.length;t++){let a=i[t];a.bye?r.appendChild(oB()):(t>0&&!i[t-1]?.bye&&r.appendChild(sB()),r.appendChild(aB(a,e,n,a.sideNumber??t+1)))}return(a||o)&&i.length===1&&!i[0].bye&&r.appendChild(oB()),r}function aB(e,t,n,r){let i=document.createElement(`div`);i.className=`spl-grid-cell__side`;let a=document.createElement(`span`);a.className=`spl-grid-cell__name`;let o=cB(e.participantName,n.nameFormat)||`TBD`;if(n.showSeed&&e.seedNumber&&(o+=` [${e.seedNumber}]`),n.showRanking&&e.ranking&&(o+=` (#${e.ranking})`),n.showNationality&&e.nationality&&(o+=` ${e.nationality}`),a.textContent=o,n.boldWinner!==!1&&t.winningSide===r&&(a.style.fontWeight=`bold`),i.appendChild(a),e.teamName){let t=document.createElement(`div`);t.className=`spl-grid-cell__team-name`,t.textContent=e.teamName,i.appendChild(t)}return i}function oB(){let e=document.createElement(`div`);return e.className=`spl-grid-cell__bye`,e.textContent=`BYE`,e}function sB(){let e=document.createElement(`div`);return e.className=`spl-grid-cell__vs`,e.textContent=`vs.`,e}function cB(e,t){if(!e)return``;switch(t){case`last`:return e.includes(`,`)?e.split(`,`)[0].trim():e.trim().split(/\s+/).at(-1);case`lastFirst`:{if(e.includes(`,`))return e.trim();let t=e.trim().split(/\s+/);return t.length<2?e:`${t.at(-1)}, ${t.slice(0,-1).join(` `)}`}case`firstLast`:{if(!e.includes(`,`))return e.trim();let[t,...n]=e.split(`,`);return`${n.join(`,`).trim()} ${t.trim()}`}default:return e}}function lB(e){let t=e.score?.scoreStringSide1,n=e.matchUpStatus?.toUpperCase(),r=n===`WALKOVER`?`WALKOVER`:n===`DEFAULTED`?`DEFAULT`:n===`RETIRED`?`RET.`:n===`DOUBLE_WALKOVER`?`D.W/O`:n===`ABANDONED`?`ABN.`:null;if(!t&&!r)return null;let i=document.createElement(`div`);return i.className=`spl-grid-cell__score`,i.textContent=t||r||``,i}function uB(e){if(!e.matchUpStatus)return null;let t=document.createElement(`div`);t.className=`spl-grid-cell__status-badge`;let n=e.matchUpStatus.toUpperCase();return n===`IN_PROGRESS`?(t.textContent=`LIVE`,t.classList.add(`spl-grid-cell__status-badge--live`)):n===`COMPLETED`||n===`RETIRED`||n===`DEFAULTED`||n===`WALKOVER`?(t.textContent=`DONE`,t.classList.add(`spl-grid-cell__status-badge--done`)):t.textContent=e.matchUpStatus.replaceAll(`_`,` `),t}function dB(e){if(!e.matchUpFormat)return null;let t=document.createElement(`div`);return t.className=`spl-grid-cell__format`,t.textContent=e.matchUpFormat,t}function fB(e){if(!e.umpire)return null;let t=document.createElement(`div`);return t.className=`spl-grid-cell__umpire`,t.textContent=e.umpire,t}function pB(e){if(!e)return{matchUpId:``};if(e.isBlocked)return{matchUpId:``,isBlocked:!0,booking:e.booking};let t=(e.sides||[]).map((e,t)=>({sideNumber:e.sideNumber??t+1,participantName:e.participant?.participantName??e.participantName,participantId:e.participantId??e.participant?.participantId,seedNumber:e.seedValue??e.seedNumber,ranking:e.ranking,nationality:e.participant?.nationalityCode??e.participant?.person?.nationalityCode??e.nationalityCode,teamName:e.teamParticipant?.participantName??e.teamName,bye:e.bye||void 0}));return{matchUpId:e.matchUpId,drawId:e.drawId,eventName:e.eventName,roundName:e.roundName,matchUpFormat:e.matchUpFormat,matchUpType:e.matchUpType,matchUpStatus:e.matchUpStatus,winningSide:e.winningSide,gender:e.gender??e.eventGender,sides:t,potentialParticipants:e.potentialParticipants,schedule:e.schedule?{scheduledTime:e.schedule.scheduledTime,startTime:e.schedule.startTime,timeModifiers:e.schedule.timeModifiers,courtAnnotation:e.schedule.courtAnnotation,courtId:e.schedule.courtId,courtOrder:e.schedule.courtOrder,venueId:e.schedule.venueId}:void 0,score:e.score?{scoreStringSide1:e.score.scoreStringSide1,scoreStringSide2:e.score.scoreStringSide2}:void 0,umpire:e.umpire?.participantName??e.umpireName,scheduleState:e.scheduleState,issueType:e.issueType,issueIds:e.issueIds}}function mB({cell:e,listProvider:t,onSelect:n,onCancel:r}){let i=e.innerHTML,a=[],o=!1,s=!1;e.classList.add(`spl-cell--typeahead`),e.innerHTML=``;let c=document.createElement(`div`);c.className=`spl-cell--typeahead-wrapper`,e.appendChild(c);let l=document.createElement(`input`);l.type=`text`,l.placeholder=`Search matchUps...`,l.setAttribute(`inputmode`,`search`),l.setAttribute(`autocapitalize`,`off`),l.setAttribute(`enterkeyhint`,`search`),l.setAttribute(`autocomplete`,`off`),c.appendChild(l);let u=e,d=0;for(;u&&d<10;){let e=window.getComputedStyle(u);(e.overflow!==`visible`||e.overflowX!==`visible`||e.overflowY!==`visible`)&&(a.push({el:u,overflow:u.style.overflow,overflowX:u.style.overflowX,overflowY:u.style.overflowY}),u.style.setProperty(`overflow`,`visible`,`important`),u.style.setProperty(`overflow-x`,`visible`,`important`),u.style.setProperty(`overflow-y`,`visible`,`important`)),u=u.parentElement,d++}ne({list:t(),element:l,listProvider:t,callback:e=>{e&&!s&&(o=!0,p(),n(e))}}),l.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p(),r?.())}),l.addEventListener(`blur`,()=>{setTimeout(()=>{!o&&!s&&(p(),r?.())},200)});let f=e=>{e.target!==l&&!c.contains(e.target)&&(e.preventDefault(),l.blur())};e.addEventListener(`mousedown`,f),c.addEventListener(`click`,e=>{e.stopPropagation()}),setTimeout(()=>l.focus(),0);function p(){if(!s){s=!0,e.removeEventListener(`mousedown`,f),e.classList.remove(`spl-cell--typeahead`),e.innerHTML=i;for(let{el:e,overflow:t,overflowX:n,overflowY:r}of a)t?e.style.overflow=t:e.style.removeProperty(`overflow`),n?e.style.overflowX=n:e.style.removeProperty(`overflow-x`),r?e.style.overflowY=r:e.style.removeProperty(`overflow-y`)}}return{destroy:p}}function hB(e,t){let n=new Ez(e);return n.render(t),n}var gB=class{constructor(e){this.listeners=new Set,this.config=e,this.state={compositionName:e.compositionName||`Custom`,theme:e.composition?.theme||``,configuration:{...e.composition?.configuration||{}},colors:e.composition?.colors?{...e.composition.colors}:void 0,expandedSections:new Set([`theme`,`display`]),isDirty:!1,readOnly:e.readOnly||!1}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}toggleSection(e){let t=new Set(this.state.expandedSections);t.has(e)?t.delete(e):t.add(e),this.setState({expandedSections:t})}setTheme(e){this.setState({theme:e,isDirty:!0}),this.notifyChange()}setColorField(e,t){let n={...this.state.colors||{}};t===void 0||t===``?delete n[e]:n[e]=t;let r=Object.keys(n).length>0;this.setState({colors:r?n:void 0,isDirty:!0}),this.notifyChange()}clearColors(){this.setState({colors:void 0,isDirty:!0}),this.notifyChange()}setCompositionName(e){this.setState({compositionName:e,isDirty:!0})}setConfigField(e,t){let n={...this.state.configuration,[e]:t};this.setState({configuration:n,isDirty:!0}),this.notifyChange()}setConfigNestedField(e,t,n){let r={...this.state.configuration[e]||{},[t]:n};this.setConfigField(e,r)}setConfiguration(e){this.setState({configuration:{...e},isDirty:!0}),this.notifyChange()}loadComposition(e,t,n,r){this.setState({compositionName:e,theme:t,configuration:{...n},colors:r?{...r}:void 0,isDirty:!1}),this.notifyChange()}resetToInitial(){this.setState({compositionName:this.config.compositionName||`Custom`,theme:this.config.composition?.theme||``,configuration:{...this.config.composition?.configuration||{}},colors:this.config.composition?.colors?{...this.config.composition.colors}:void 0,isDirty:!1}),this.notifyChange()}setState(e){this.state={...this.state,...e},this.emit()}emit(){for(let e of this.listeners)e(this.state)}notifyChange(){this.config.onChange?.({theme:this.state.theme,configuration:this.state.configuration,...this.state.colors?{colors:{...this.state.colors}}:{}})}},_B=()=>`ce-layout`,vB=()=>`ce-left`,yB=()=>`ce-right`,bB=()=>`ce-name-row`,xB=()=>`ce-name-label`,SB=()=>`ce-name-input`,CB=()=>`ce-section`,wB=()=>`ce-section-header`,TB=()=>`ce-section-chevron`,EB=()=>`ce-section-body`,DB=()=>`ce-field`,OB=()=>`ce-field-label`,kB=()=>`ce-field-control`,AB=()=>`ce-select`,jB=()=>`ce-text-input`,MB=()=>`ce-color-input`,NB=()=>`ce-toggle`,PB=()=>`ce-toggle-track`,FB=()=>`ce-preview`,IB=()=>`ce-preview-header`,LB=()=>`ce-preview-body`,RB=()=>`ce-preview-matchup`,zB=()=>`ce-subgroup`,BB=()=>`ce-subgroup-title`;function VB(e,t){let n=document.createElement(`div`);n.className=CB();let r=document.createElement(`div`);r.className=wB();let i=document.createElement(`span`);i.className=TB();let a=document.createElement(`span`);a.textContent=e.label,r.appendChild(i),r.appendChild(a),r.addEventListener(`click`,()=>t.toggleSection(e.id));let o=document.createElement(`div`);o.className=EB();let s=e.factory(t);o.appendChild(s.element),n.appendChild(r),n.appendChild(o);function c(t){let n=t.expandedSections.has(e.id);i.textContent=n?`▼`:`▶`,o.style.display=n?`block`:`none`,n&&s.update(t)}return{element:n,update:c}}function HB(e,t,n,r=!1){let i=document.createElement(`div`);i.className=DB();let a=document.createElement(`span`);a.className=OB(),a.textContent=e,i.appendChild(a);let o=document.createElement(`label`);o.className=NB();let s=document.createElement(`input`);s.type=`checkbox`,s.checked=t,s.disabled=r,s.addEventListener(`change`,()=>n(s.checked));let c=document.createElement(`span`);c.className=PB(),o.appendChild(s),o.appendChild(c);let l=document.createElement(`div`);return l.className=kB(),l.appendChild(o),i.appendChild(l),{element:i,setChecked:e=>{s.checked=e},setDisabled:e=>{s.disabled=e}}}function UB(e,t,n,r,i=!1){let a=document.createElement(`div`);a.className=DB();let o=document.createElement(`span`);o.className=OB(),o.textContent=e,a.appendChild(o);let s=document.createElement(`select`);s.className=AB(),s.disabled=i;for(let e of t){let t=document.createElement(`option`);t.value=e.value,t.textContent=e.label,e.value===n&&(t.selected=!0),s.appendChild(t)}s.addEventListener(`change`,()=>r(s.value));let c=document.createElement(`div`);return c.className=kB(),c.appendChild(s),a.appendChild(c),{element:a,setValue:e=>{s.value=e}}}function WB(e,t,n,r=``,i=!1){let a=document.createElement(`div`);a.className=DB();let o=document.createElement(`span`);o.className=OB(),o.textContent=e,a.appendChild(o);let s=document.createElement(`input`);s.type=`text`,s.className=jB(),s.value=t,s.placeholder=r,s.disabled=i,s.addEventListener(`input`,()=>n(s.value));let c=document.createElement(`div`);return c.className=kB(),c.appendChild(s),a.appendChild(c),{element:a,setValue:e=>{s.value=e}}}function GB(e,t,n,r=!1){let i=document.createElement(`div`);i.className=DB();let a=document.createElement(`span`);a.className=OB(),a.textContent=e,i.appendChild(a);let o=document.createElement(`input`);o.type=`color`,o.className=MB(),o.value=t||`#000000`,o.disabled=r,o.addEventListener(`input`,()=>n(o.value));let s=document.createElement(`div`);return s.className=kB(),s.appendChild(o),i.appendChild(s),{element:i,setValue:e=>{o.value=e||`#000000`}}}var KB=[],qB=new Set;for(let[,e]of Object.entries(si))if(!qB.has(e.theme)){qB.add(e.theme);let t=e.theme.replace(`chc-theme-`,``).replace(/-/g,` `).replace(/\b\w/g,e=>e.toUpperCase());KB.push({value:e.theme,label:t})}function JB(e){let t=document.createElement(`div`),n=UB(`Load preset`,[{value:``,label:`— Load preset —`},...Object.keys(si).map(e=>({value:e,label:e}))],``,t=>{if(!t)return;let r=si[t];r&&e.loadComposition(t,r.theme,r.configuration||{},r.colors),n.setValue(``)},e.getState().readOnly);t.appendChild(n.element);let r=document.createElement(`div`);r.style.cssText=`font-size:0.7rem; color:var(--chc-text-secondary, #999); padding:0 0 0.3rem; line-height:1.3;`,r.textContent=`Replaces all settings with a built-in composition.`,t.appendChild(r);let i=UB(`Color theme`,KB,e.getState().theme,t=>e.setTheme(t),e.getState().readOnly);t.appendChild(i.element);let a=document.createElement(`div`);a.style.cssText=`font-size:0.7rem; color:var(--chc-text-secondary, #999); padding:0 0 0.3rem; line-height:1.3;`,a.textContent=`Changes only the color scheme, not the display settings.`,t.appendChild(a);function o(e){i.setValue(e.theme)}return{element:t,update:o}}var YB=[{key:`border`,label:`MatchUp border`},{key:`borderHover`,label:`MatchUp border (hover)`},{key:`borderInlineStart`,label:`Left-edge accent`},{key:`connector`,label:`Connector lines`,hint:`Use "transparent" to hide`},{key:`matchUpBackground`,label:`MatchUp background`},{key:`internalDividers`,label:`Participant dividers`},{key:`score`,label:`[Score] placeholder text`},{key:`roundHeader`,label:`Round header`}],XB=/^#[0-9a-f]{6}$/i;function ZB(e,t,n,r){let i=document.createElement(`div`);i.className=DB();let a=document.createElement(`span`);a.className=OB(),a.textContent=e.label,i.appendChild(a);let o=document.createElement(`div`);o.className=kB(),o.style.display=`flex`,o.style.gap=`0.4rem`,o.style.alignItems=`center`;let s=document.createElement(`input`);s.type=`color`,s.className=MB(),s.disabled=r;let c=document.createElement(`input`);c.type=`text`,c.className=jB(),c.placeholder=e.hint||`#rrggbb or color name`,c.disabled=r,c.style.flex=`1`;function l(e){c.value=e||``,e&&XB.test(e)?(s.value=e,s.style.opacity=`1`):(s.value=`#000000`,s.style.opacity=e?`0.4`:`1`)}return l(t),s.addEventListener(`input`,()=>{c.value=s.value,s.style.opacity=`1`,n(s.value)}),c.addEventListener(`input`,()=>{let e=c.value.trim();e&&XB.test(e)?(s.value=e,s.style.opacity=`1`):s.style.opacity=e?`0.4`:`1`,n(e||void 0)}),o.appendChild(s),o.appendChild(c),i.appendChild(o),{element:i,setValue:l}}function QB(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=document.createElement(`div`);r.style.cssText=`font-size:0.7rem; color:var(--chc-text-secondary, #999); padding:0 0 0.4rem; line-height:1.3;`,r.textContent=`Per-composition overrides. Leave blank to inherit from the selected theme.`,t.appendChild(r);let i=YB.map(r=>{let i=ZB(r,e.getState().colors?.[r.key],t=>e.setColorField(r.key,t),n);return t.appendChild(i.element),{def:r,ctrl:i}}),a=document.createElement(`div`);a.className=DB();let o=document.createElement(`span`);o.className=OB(),o.textContent=`Left-edge width`,a.appendChild(o);let s=document.createElement(`div`);s.className=kB();let c=document.createElement(`input`);c.type=`text`,c.className=jB(),c.placeholder=`e.g. 10px`,c.disabled=n,c.value=e.getState().colors?.borderInlineStartWidth||``,c.addEventListener(`input`,()=>{let t=c.value.trim();e.setColorField(`borderInlineStartWidth`,t||void 0)}),s.appendChild(c),a.appendChild(s),t.appendChild(a);let l=document.createElement(`button`);l.type=`button`,l.textContent=`Clear color overrides`,l.disabled=n,l.style.cssText=`margin-top:0.6rem; padding:0.25rem 0.5rem; font-size:0.75rem; cursor:pointer; background:transparent; border:1px solid var(--chc-border-secondary, #ccc); border-radius:4px;`,l.addEventListener(`click`,()=>e.clearColors()),t.appendChild(l);function u(e){for(let{def:t,ctrl:n}of i)n.setValue(e.colors?.[t.key]);c.value=e.colors?.borderInlineStartWidth||``}return{element:t,update:u}}function $B(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=HB(`Nationality flags`,!!r.flags,t=>e.setConfigField(`flags`,t),n),a=UB(`Seeding style`,[{value:``,label:`None`},{value:`true`,label:`Parentheses`},{value:`square`,label:`Square brackets`}],r.bracketedSeeds===`square`?`square`:r.bracketedSeeds?`true`:``,t=>{t===`square`?e.setConfigField(`bracketedSeeds`,`square`):t===`true`?e.setConfigField(`bracketedSeeds`,!0):e.setConfigField(`bracketedSeeds`,void 0)},n),o=UB(`Seed element`,[{value:``,label:`Default`},{value:`sup`,label:`Superscript`},{value:`span`,label:`Inline`}],r.seedingElement||``,t=>e.setConfigField(`seedingElement`,t||void 0),n),s=HB(`Draw positions (1st round)`,!!r.drawPositions,t=>e.setConfigField(`drawPositions`,t),n),c=HB(`Draw positions (all rounds)`,!!r.allDrawPositions,t=>e.setConfigField(`allDrawPositions`,t),n),l=HB(`Team logo`,r.teamLogo!==!1,t=>e.setConfigField(`teamLogo`,t),n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element),t.appendChild(s.element),t.appendChild(c.element),t.appendChild(l.element);function u(e){let t=e.configuration;i.setChecked(!!t.flags),a.setValue(t.bracketedSeeds===`square`?`square`:t.bracketedSeeds?`true`:``),o.setValue(t.seedingElement||``),s.setChecked(!!t.drawPositions),c.setChecked(!!t.allDrawPositions),l.setChecked(t.teamLogo!==!1)}return{element:t,update:u}}function eV(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=HB(`Score box`,!!r.scoreBox,t=>e.setConfigField(`scoreBox`,t),n),a=HB(`Game score only`,!!r.gameScoreOnly,t=>e.setConfigField(`gameScoreOnly`,t),n);t.appendChild(i.element),t.appendChild(a.element);let o=document.createElement(`div`);o.className=zB();let s=document.createElement(`div`);s.className=BB(),s.textContent=`Game Score Display`,o.appendChild(s);let c=UB(`Position`,[{value:``,label:`Default`},{value:`leading`,label:`Leading`},{value:`trailing`,label:`Trailing`}],r.gameScore?.position||``,t=>e.setConfigNestedField(`gameScore`,`position`,t||void 0),n),l=HB(`Inverted`,!!r.gameScore?.inverted,t=>e.setConfigNestedField(`gameScore`,`inverted`,t),n);o.appendChild(c.element),o.appendChild(l.element),t.appendChild(o);function u(e){let t=e.configuration;i.setChecked(!!t.scoreBox),a.setChecked(!!t.gameScoreOnly),c.setValue(t.gameScore?.position||``),l.setChecked(!!t.gameScore?.inverted)}return{element:t,update:u}}function tV(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=HB(`Gender color`,!!r.genderColor,t=>e.setConfigField(`genderColor`,t),n),a=HB(`Winner color`,!!r.winnerColor,t=>e.setConfigField(`winnerColor`,t),n),o=UB(`Detail`,[{value:``,label:`Default`},{value:`TEAM`,label:`Team`},{value:`ADDRESS`,label:`Address`}],r.participantDetail||``,t=>{e.setConfigField(`participantDetail`,t||void 0),e.setConfigField(`showAddress`,t===`ADDRESS`)},n),s=WB(`Position color`,r.drawPositionColor||``,t=>e.setConfigField(`drawPositionColor`,t||void 0),`#999`,n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element),t.appendChild(s.element);function c(e){let t=e.configuration;i.setChecked(!!t.genderColor),a.setChecked(!!t.winnerColor),o.setValue(t.participantDetail||``),s.setValue(t.drawPositionColor||``)}return{element:t,update:c}}function nV(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=WB(`TBD text`,r.placeHolders?.tbd||``,t=>e.setConfigNestedField(`placeHolders`,`tbd`,t||void 0),`TBD`,n),a=WB(`Bye text`,r.placeHolders?.bye||``,t=>e.setConfigNestedField(`placeHolders`,`bye`,t||void 0),`Bye`,n),o=WB(`Qualifier text`,r.placeHolders?.qualifier||``,t=>e.setConfigNestedField(`placeHolders`,`qualifier`,t||void 0),`Qualifier`,n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element);function s(e){let t=e.configuration;i.setValue(t.placeHolders?.tbd||``),a.setValue(t.placeHolders?.bye||``),o.setValue(t.placeHolders?.qualifier||``)}return{element:t,update:s}}var rV=[{scaleName:`WTN`,accessor:`wtnRating`,label:`WTN`},{scaleName:`UTR`,accessor:`utrRating`,label:`UTR`},{scaleName:`NTRP`,accessor:`ntrpRating`,label:`NTRP`},{scaleName:`ELO`,accessor:`eloRating`,label:`ELO`}];function iV(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration.scaleAttributes||{},i=UB(`Scale type`,[{value:``,label:`None`},{value:`RATING`,label:`Rating`},{value:`RANKING`,label:`Ranking`},{value:`SEEDING`,label:`Seeding`}],r.scaleType||``,t=>e.setConfigNestedField(`scaleAttributes`,`scaleType`,t||void 0),n),a=UB(`Scale name`,[{value:``,label:`None`},...rV.map(e=>({value:e.scaleName,label:e.label}))],r.scaleName||``,t=>{e.setConfigNestedField(`scaleAttributes`,`scaleName`,t||void 0);let n=rV.find(e=>e.scaleName===t);e.setConfigNestedField(`scaleAttributes`,`accessor`,n?.accessor||void 0)},n),o=GB(`Color`,r.scaleColor||`#ff0000`,t=>e.setConfigNestedField(`scaleAttributes`,`scaleColor`,t),n),s=UB(`Event type`,[{value:``,label:`Any`},{value:`SINGLES`,label:`Singles`},{value:`DOUBLES`,label:`Doubles`}],r.eventType||``,t=>e.setConfigNestedField(`scaleAttributes`,`eventType`,t||void 0),n),c=HB(`Fallback`,!!r.fallback,t=>e.setConfigNestedField(`scaleAttributes`,`fallback`,t),n),l=HB(`Right of name`,r.scalePosition===`right`,t=>e.setConfigNestedField(`scaleAttributes`,`scalePosition`,t?`right`:`left`),n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element),t.appendChild(s.element),t.appendChild(c.element),t.appendChild(l.element);function u(e){let t=e.configuration.scaleAttributes||{},n=!!e.configuration.flags;i.setValue(t.scaleType||``),a.setValue(t.scaleName||``),o.setValue(t.scaleColor||`#ff0000`),s.setValue(t.eventType||``),c.setChecked(!!t.fallback),n?(l.setChecked(!0),l.setDisabled(!0)):(l.setChecked(t.scalePosition===`right`),l.setDisabled(!1))}return{element:t,update:u}}function aV(e){let t=document.createElement(`div`),n=e.getState().readOnly,r=e.getState().configuration,i=HB(`Schedule info`,!!r.scheduleInfo,t=>e.setConfigField(`scheduleInfo`,t),n),a=HB(`MatchUp footer`,!!r.matchUpFooter,t=>e.setConfigField(`matchUpFooter`,t),n),o=HB(`Center info`,!!r.centerInfo,t=>e.setConfigField(`centerInfo`,t),n),s=HB(`Set number`,!!r.resultsInfo,t=>e.setConfigField(`resultsInfo`,t),n),c=HB(`Winner chevron`,!!r.winnerChevron,t=>e.setConfigField(`winnerChevron`,t),n);t.appendChild(i.element),t.appendChild(a.element),t.appendChild(o.element),t.appendChild(s.element),t.appendChild(c.element);function l(e){let t=e.configuration;i.setChecked(!!t.scheduleInfo),a.setChecked(!!t.matchUpFooter),o.setChecked(!!t.centerInfo),s.setChecked(!!t.resultsInfo),c.setChecked(!!t.winnerChevron)}return{element:t,update:l}}var{DOUBLES:oV,SINGLES:sV}=t.eventConstants,{AD_HOC:cV}=t.drawDefinitionConstants,{INDIVIDUAL:lV}=t.participantConstants;function uV({matchUpFormat:e=`SET5-S:6/TB7`,randomWinningSide:n=!0,qualifyingProfiles:r,participantsCount:i,completionGoal:a,drawSize:o=4,eventType:s,outcomes:c,drawType:l,withRatings:u,withAllRatings:d}={}){let f=a<100?Math.floor(o*.01*a):void 0,p=`venueId`,m=[{venueName:`Challenge Courts`,venueAbbreviation:`CC`,startTime:`08:00`,endTime:`20:00`,venueId:p,courtNames:[1,2,3,4,5,6,7,8],courtIds:[`c1`,`c2`,`c3`,`c4`],courtsCount:8}],h={eventType:s===oV?oV:sV,completionGoal:f,qualifyingProfiles:r,participantsCount:i,seedsCount:8,matchUpFormat:e,drawSize:o,drawType:l,outcomes:c};l===cV&&Object.assign(h,{drawMatic:!0,roundsCount:3});let{tournamentRecord:g}=t.mocksEngine.generateTournamentRecord({drawProfiles:[h],completeAllMatchUps:!0,randomWinningSide:n,venueProfiles:m});t.tournamentEngine.setState(g),t.tournamentEngine.createTeamsFromParticipantAttributes({personAttribute:`nationalityCode`,addParticipants:!0});let _=d||(u?[{...u,accessor:u.scaleName}]:[]);if(_.length>0){let{participants:e}=t.tournamentEngine.getParticipants({participantFilters:{participantTypes:[lV]}});for(let n of _)e.forEach(e=>{let r=+(10+Math.random()*6).toFixed(2);t.tournamentEngine.setParticipantScaleItem({participantId:e.participantId,scaleItem:{scaleValue:{[n.accessor]:r},scaleName:n.scaleName,scaleType:n.scaleType||`RATING`,eventType:n.eventType||sV}})})}let{matchUps:v}=t.tournamentEngine.allTournamentMatchUps({participantsProfile:{withGroupings:!0}}),y=v.map(({matchUpId:e})=>e),b={startTime:`08:00`,endTime:`10:00`,scheduledTime:`07:00`,scheduledDate:`2021-01-01`,courtId:`c1`,venueId:p};t.tournamentEngine.bulkScheduleMatchUps({matchUpIds:y,schedule:b});let{matchUps:x}=t.tournamentEngine.allTournamentMatchUps({participantsProfile:{withISO2:!0,withIOC:!0,withScaleValues:!!(u||d)}});return{matchUps:x}}var dV=null;function fV(){if(!dV){let{matchUps:e}=uV({drawSize:8,eventType:`SINGLES`,randomWinningSide:!0,matchUpFormat:`SET3-S:6/TB7`,withAllRatings:rV.map(e=>({scaleName:e.scaleName,accessor:e.accessor}))}),t=e.filter(e=>e.roundNumber===1).slice(0,2),n=t[0]?.sides?.[0]?.participant,r=t[0]?.sides?.[1]?.participant,i={matchUpId:`preview-in-progress`,matchUpType:`SINGLES`,matchUpStatus:`IN_PROGRESS`,roundNumber:1,sides:[{sideNumber:1,drawPosition:5,seedNumber:3,seedValue:`3`,participant:n},{sideNumber:2,drawPosition:6,seedNumber:6,seedValue:`6`,participant:r}],score:{scoreStringSide1:`6-4 3-2`,scoreStringSide2:`4-6 2-3`,sets:[{setNumber:1,side1Score:6,side2Score:4,winningSide:1},{setNumber:2,side1Score:3,side2Score:2,side1PointScore:`30`,side2PointScore:`15`}]}},a={matchUpId:`preview-bye`,matchUpType:`SINGLES`,matchUpStatus:`BYE`,roundNumber:1,sides:[{sideNumber:1,drawPosition:7,seedNumber:2,seedValue:`2`,participant:n},{sideNumber:2,drawPosition:8,bye:!0}]},o={matchUpId:`preview-tbd`,matchUpType:`SINGLES`,matchUpStatus:`TO_BE_PLAYED`,roundNumber:1,sides:[{sideNumber:1,drawPosition:9,seedNumber:3,seedValue:`3`,participant:n},{sideNumber:2,drawPosition:10}]},s={matchUpId:`preview-qualifier`,matchUpType:`SINGLES`,matchUpStatus:`TO_BE_PLAYED`,roundNumber:1,sides:[{sideNumber:1,drawPosition:11,qualifier:!0},{sideNumber:2,drawPosition:12,seedNumber:4,seedValue:`4`,participant:n}]};dV=[...t,i,a,o,s]}return dV}var pV=null;function mV(){if(!pV){let{matchUps:e}=uV({drawSize:4,eventType:`SINGLES`,matchUpFormat:`SET3-S:6/TB7`,completionGoal:50,randomWinningSide:!0});pV=e}return pV}function hV(){let e=document.createElement(`div`);e.className=FB();let t=document.createElement(`div`);t.className=IB(),t.textContent=`Preview`,e.appendChild(t);let n=document.createElement(`div`);n.className=LB(),e.appendChild(n);let r=``,i=``,a=``;function o(e){let t=JSON.stringify(e.configuration),o=JSON.stringify(e.colors||{});if(e.theme===r&&t===i&&o===a)return;r=e.theme,i=t,a=o,n.innerHTML=``,pr(n),fr(n,e.colors);let s={theme:e.theme,configuration:{...e.configuration},colors:e.colors?{...e.colors}:void 0},c=fV();for(let e of c){let t=document.createElement(`div`);t.className=RB();let r=qr({matchUp:e,composition:s,isLucky:!0});t.appendChild(r),n.appendChild(t)}let l=document.createElement(`div`);l.style.cssText=`margin-top:1.5rem; padding:0 0.25rem; font-size:0.7rem; color:var(--chc-text-secondary, #999); text-transform:uppercase; letter-spacing:0.05em;`,l.textContent=`Connector preview`,n.appendChild(l);let u=Yr({matchUps:mV(),composition:s});n.appendChild(u)}return{element:e,update:o}}var gV=[{id:`theme`,label:`Theme & Preset`,factory:JB},{id:`colors`,label:`Colors`,factory:QB},{id:`display`,label:`Display`,factory:$B},{id:`score`,label:`Score`,factory:eV},{id:`participant`,label:`Participant`,factory:tV},{id:`placeholder`,label:`Placeholders`,factory:nV},{id:`scale`,label:`Scale Attributes`,factory:iV},{id:`layout`,label:`Layout & Info`,factory:aV}];function _V(e,t){let n=new gB(t),r=document.createElement(`div`);r.className=_B();let i=document.createElement(`div`);i.className=vB();let a=document.createElement(`div`);a.className=bB();let o=document.createElement(`span`);o.className=xB(),o.textContent=`Name`;let s=document.createElement(`input`);s.type=`text`,s.className=SB(),s.value=n.getState().compositionName,s.disabled=n.getState().readOnly,s.addEventListener(`input`,()=>n.setCompositionName(s.value)),a.appendChild(o),a.appendChild(s),i.appendChild(a);let c=gV.map(e=>{let t=VB(e,n);return i.appendChild(t.element),t}),l=document.createElement(`div`);l.className=yB();let u=hV();l.appendChild(u.element),r.appendChild(i),r.appendChild(l),e.appendChild(r);let d=n.subscribe(e=>{s.value=e.compositionName;for(let t of c)t.update(e);u.update(e)}),f=n.getState();for(let e of c)e.update(f);return u.update(f),{destroy:()=>{d(),e.contains(r)&&e.removeChild(r)},getComposition:()=>{let e=n.getState(),{participantProvider:t,persistInputFields:r,inlineAssignment:i,...a}=e.configuration;return{compositionName:e.compositionName,theme:e.theme,configuration:a,...e.colors?{colors:{...e.colors}}:{},version:1}}}}var vV=[`grand-slam`,`itf`,`minimal`,`none`],yV=[`standard`,`seedings`,`officials`,`none`],bV=[`a4`,`letter`],xV=[`auto`,`portrait`,`landscape`],SV={page:{pageSize:`a4`,orientation:`auto`,margins:{top:15,right:10,bottom:15,left:10}},header:{layout:`itf`,tournamentName:``},footer:{layout:`standard`,showTimestamp:!0,showPageNumbers:!0},content:{}};function CV(e,t){let n=IV(SV,t.config??{}),r=!!t.readOnly,i=Z(`div`,`pce-root`),a=Z(`div`,`pce-form`),o=Z(`div`,`pce-aside`);i.appendChild(a),i.appendChild(o);let s=null;function c(){a.innerHTML=``,a.appendChild(wV(n,r,l)),a.appendChild(TV(n,r,l)),a.appendChild(EV(n,r,l)),a.appendChild(DV(n,r,t.printType,l)),!r&&t.onSave&&a.appendChild(OV(()=>t.onSave?.(LV(n)))),o.innerHTML=``;let e=Z(`div`,`pce-aside-title`);e.textContent=`Print Type`,o.appendChild(e);let i=Z(`span`,`pce-print-type-pill`);i.textContent=t.printType,o.appendChild(i);let c=Z(`div`,`pce-aside-title`);c.textContent=`Resolved Config`,c.style.marginTop=`8px`,o.appendChild(c),s=Z(`div`,`pce-preview-stub`),s.textContent=JSON.stringify(n,null,2),o.appendChild(s);let u=Z(`div`,`pce-preview-note`);u.textContent=`Live PDF preview not yet wired — see admin-client integration.`,o.appendChild(u)}function l(){s&&(s.textContent=JSON.stringify(n,null,2)),t.onChange?.(LV(n))}return c(),e.appendChild(i),{destroy:()=>{i.parentNode&&i.parentNode.removeChild(i)},getConfig:()=>LV(n),setConfig:e=>{Object.assign(n,IV(SV,e)),c()}}}function wV(e,t,n){let{section:r,body:i}=NV(`Page`);i.appendChild(kV(`Size`,bV,e.page?.pageSize??`a4`,t,t=>{FV(e,`page`).pageSize=t,n()})),i.appendChild(kV(`Orientation`,xV,e.page?.orientation??`auto`,t,t=>{FV(e,`page`).orientation=t,n()}));let a=Z(`div`,`pce-field pce-field-full`);a.appendChild(PV(`Margins (mm)`));let o=Z(`div`);return o.style.display=`grid`,o.style.gridTemplateColumns=`repeat(4, 1fr)`,o.style.gap=`6px`,[`top`,`right`,`bottom`,`left`].forEach(r=>{o.appendChild(jV(r,e.page?.margins?.[r]??10,t,t=>{let i=FV(FV(e,`page`),`margins`);i[r]=t,n()}))}),a.appendChild(o),i.appendChild(a),r}function TV(e,t,n){let{section:r,body:i}=NV(`Header`);return i.appendChild(kV(`Layout`,vV,e.header?.layout??`itf`,t,t=>{FV(e,`header`).layout=t,n()})),i.appendChild(AV(`Tournament name`,e.header?.tournamentName??``,t,t=>{FV(e,`header`).tournamentName=t,n()})),i.appendChild(AV(`Subtitle`,e.header?.subtitle??``,t,t=>{FV(e,`header`).subtitle=t||void 0,n()})),r}function EV(e,t,n){let{section:r,body:i}=NV(`Footer`);return i.appendChild(kV(`Layout`,yV,e.footer?.layout??`standard`,t,t=>{FV(e,`footer`).layout=t,n()})),i.appendChild(MV(`Show timestamp`,e.footer?.showTimestamp??!0,t,t=>{FV(e,`footer`).showTimestamp=t,n()})),i.appendChild(MV(`Show page numbers`,e.footer?.showPageNumbers??!0,t,t=>{FV(e,`footer`).showPageNumbers=t,n()})),r}function DV(e,t,n,r){let{section:i,body:a}=NV(`Content — ${n}`);if(n===`draw`){let n=FV(FV(e,`content`),`draw`);a.appendChild(MV(`Include seedings`,!!n.includeSeedings,t,e=>{n.includeSeedings=e,r()})),a.appendChild(MV(`Include scores`,!!n.includeScores,t,e=>{n.includeScores=e,r()})),a.appendChild(MV(`Show byes`,!!n.showByes,t,e=>{n.showByes=e,r()})),a.appendChild(MV(`Show draw positions`,!!n.showDrawPositions,t,e=>{n.showDrawPositions=e,r()}))}else if(n===`schedule`){let n=FV(FV(e,`content`),`schedule`);a.appendChild(kV(`Cell style`,[`detailed`,`compact`],n.cellStyle??`detailed`,t,e=>{n.cellStyle=e,r()})),a.appendChild(MV(`Show match numbers`,!!n.showMatchNumbers,t,e=>{n.showMatchNumbers=e,r()})),a.appendChild(AV(`Alert banner`,n.alertBanner??``,t,e=>{n.alertBanner=e||void 0,r()}))}else{let e=Z(`div`,`pce-field pce-field-full`),t=Z(`div`,`pce-preview-note`);t.textContent=`Content options for "${n}" not yet implemented.`,e.appendChild(t),a.appendChild(e)}return i}function OV(e){let t=Z(`div`,`pce-actions`),n=Z(`button`,`pce-button pce-button-primary`);return n.type=`button`,n.textContent=`Save`,n.addEventListener(`click`,e),t.appendChild(n),t}function kV(e,t,n,r,i){let a=Z(`div`,`pce-field`);a.appendChild(PV(e));let o=Z(`select`,`pce-select`);return o.disabled=r,t.forEach(e=>{let t=document.createElement(`option`);t.value=e,t.textContent=e,e===n&&(t.selected=!0),o.appendChild(t)}),o.addEventListener(`change`,()=>i(o.value)),a.appendChild(o),a}function AV(e,t,n,r){let i=Z(`div`,`pce-field`);i.appendChild(PV(e));let a=Z(`input`,`pce-input`);return a.type=`text`,a.value=t,a.disabled=n,a.addEventListener(`input`,()=>r(a.value)),i.appendChild(a),i}function jV(e,t,n,r){let i=Z(`div`,`pce-field`);i.appendChild(PV(e));let a=Z(`input`,`pce-input`);return a.type=`number`,a.value=String(t),a.disabled=n,a.addEventListener(`input`,()=>{let e=parseFloat(a.value);Number.isNaN(e)||r(e)}),i.appendChild(a),i}function MV(e,t,n,r){let i=Z(`div`,`pce-field pce-checkbox-row pce-field-full`),a=Z(`input`);a.type=`checkbox`,a.checked=t,a.disabled=n,a.addEventListener(`change`,()=>r(a.checked)),i.appendChild(a);let o=PV(e);return o.style.fontSize=`13px`,o.style.color=`var(--chc-text-primary, #222)`,i.appendChild(o),i}function NV(e){let t=Z(`div`,`pce-section`),n=Z(`div`,`pce-section-header`);n.textContent=e;let r=Z(`div`,`pce-section-body`);return t.appendChild(n),t.appendChild(r),{section:t,body:r}}function Z(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function PV(e){let t=Z(`label`,`pce-field-label`);return t.textContent=e,t}function FV(e,t){return(e[t]===void 0||e[t]===null)&&(e[t]={}),e[t]}function IV(e,t){return{name:t.name??e.name,page:{...e.page,...t.page,margins:{...e.page?.margins,...t.page?.margins}},header:{...e.header,...t.header},footer:{...e.footer,...t.footer},content:{...e.content,...t.content}}}function LV(e){return JSON.parse(JSON.stringify(e))}var RV=`chc-scorecard-side-score--winner`;function zV({matchUp:e,composition:t,eventHandlers:n,swapSides:r}){let i=document.createElement(`div`);i.className=`chc-scorecard`;let a=r?2:1,o=r?1:2,s=JV(e,a)||``,c=JV(e,o)||``,l=r?GV(e.winningSide):e.winningSide,u=BV({side1Name:s,side2Name:c,sets:r?KV(e.score?.sets):e.score?.sets,winningSide:l,side1Id:`chc-sc-side1`,side2Id:`chc-sc-side2`});i.appendChild(u);let d=e.tieFormat?.collectionDefinitions?.slice().sort((e,t)=>(e.collectionOrder||0)-(t.collectionOrder||0))||[];for(let a of d){let o=WV({collectionDefinition:a,collectionMatchUps:(e.tieMatchUps||[]).filter(e=>e.collectionId===a.collectionId).sort((e,t)=>(e.collectionPosition||0)-(t.collectionPosition||0)),composition:t,eventHandlers:n,swapSides:r});i.appendChild(o)}return i}function BV({side1Name:e,side2Name:t,sets:n,winningSide:r,side1Id:i,side2Id:a}){let o=document.createElement(`div`);o.className=`chc-scorecard-header`;let s=document.createElement(`div`);s.className=`chc-scorecard-header-body`;let c=HV(e,`end`),l=HV(t,`start`),u=UV(n,1,r,i),d=UV(n,2,r,a),f=document.createElement(`div`);f.className=`chc-scorecard-score-box`;let p=document.createElement(`div`);p.className=`chc-scorecard-score-flex`;let m=document.createElement(`div`);return m.className=`chc-scorecard-vs`,m.textContent=`vs`,p.appendChild(u),p.appendChild(m),p.appendChild(d),f.appendChild(p),s.appendChild(c),s.appendChild(f),s.appendChild(l),o.appendChild(s),o}function VV(e,t=`chc-sc-side1`,n=`chc-sc-side2`,r){let i=e?.score?.sets?.[0];if(!i)return;let a=document.getElementById(t),o=document.getElementById(n);if(!a||!o)return;a.classList.remove(RV),o.classList.remove(RV);let s=r?`side2Score`:`side1Score`,c=r?`side1Score`:`side2Score`;a.textContent=String(i[s]??0),o.textContent=String(i[c]??0);let l=r?GV(e.winningSide):e.winningSide;l===1&&a.classList.add(RV),l===2&&o.classList.add(RV)}function HV(e,t){let n=document.createElement(`div`);n.className=`chc-scorecard-side chc-scorecard-side--${t}`;let r=document.createElement(`div`);return r.className=`chc-scorecard-side-name`,r.textContent=e,n.appendChild(r),n}function UV(e,t,n,r){let i=e?.[0]?.[`side${t}Score`]??0,a=document.createElement(`span`);return a.className=`chc-scorecard-side-score`,r&&(a.id=r),t===1?a.style.paddingLeft=`1rem`:a.style.paddingRight=`1rem`,t===n&&a.classList.add(RV),a.textContent=String(i),a}function WV({collectionDefinition:e,collectionMatchUps:t,composition:n,eventHandlers:r,swapSides:i}){let a=document.createElement(`div`);a.className=`chc-scorecard-panel`;let o=document.createElement(`div`);o.className=`chc-scorecard-panel-header`;let s=document.createElement(`div`);s.className=`chc-scorecard-panel-name`,s.textContent=e.collectionName||`Collection`;let c=document.createElement(`div`);c.className=`chc-scorecard-panel-meta`;let l=(e.matchUpType||``).toUpperCase(),u=document.createElement(`span`);u.className=`chc-scorecard-type-badge chc-scorecard-type-badge--${l===`DOUBLES`?`doubles`:`singles`}`,u.textContent=l===`DOUBLES`?`D`:`S`;let d=document.createElement(`span`);d.className=`chc-scorecard-count-badge`,d.textContent=String(t.length),c.appendChild(u),c.appendChild(d),o.appendChild(s),o.appendChild(c),a.appendChild(o);let f=document.createElement(`div`);f.className=`chc-scorecard-grid`;for(let e of t){let t=qr({matchUp:i?qV(e):e,isLucky:!0,eventHandlers:r,composition:n});t.classList.add(`chc-scorecard-card`),f.appendChild(t)}return a.appendChild(f),a}function GV(e){if(e===1)return 2;if(e===2)return 1}function KV(e){if(e)return e.map(e=>({...e,side1Score:e.side2Score,side2Score:e.side1Score,side1TiebreakScore:e.side2TiebreakScore,side2TiebreakScore:e.side1TiebreakScore}))}function qV(e){let t=e.sides?.map(e=>({...e,sideNumber:e.sideNumber===1?2:1}));return{...e,sides:t,score:e.score?{...e.score,sets:KV(e.score.sets)}:e.score,winningSide:GV(e.winningSide)}}function JV(e,t){return e.sides?.find(e=>e.sideNumber===t)?.participant?.participantName}function YV(e){let{matchUpId:t,manager:n,baseMatchUp:r,onUpdate:i,showSituation:a}=e,o=document.createElement(`div`);o.className=`chc-inline-scoring-footer`;let s=document.createElement(`div`);s.className=`chc-inline-scoring-buttons`;let c=(e,t)=>{let n=document.createElement(`button`);return n.textContent=e,n.className=`chc-inline-scoring-btn ${t}`,n},l=c(`Undo`,`chc-is-undo`),u=c(`Redo`,`chc-is-redo`),d=c(`Clear`,`chc-is-clear`),f=c(`Submit`,`chc-is-submit`),p;a&&(p=document.createElement(`span`),p.className=`chc-inline-scoring-situation`),l.onclick=e=>{e.stopPropagation();let a=n.undo(t,r);a&&(i(a),m())},u.onclick=e=>{e.stopPropagation();let a=n.redo(t,r);a&&(i(a),m())},d.onclick=e=>{e.stopPropagation();let a=n.reset(t,r);a&&(i(a),m())},f.onclick=e=>{e.stopPropagation();let i=n.get(t);if(i){let e=n.getMatchUp(t,r);n.callbacks?.onSubmit?.({matchUpId:t,matchUp:e,engine:i.engine})}},s.append(l,u,d,f),o.appendChild(s),p&&o.appendChild(p);function m(){let e=n.canUndo(t),r=n.canRedo(t),i=n.isComplete(t);if(l.disabled=!e,u.disabled=!r,d.disabled=!e&&!r,p){let e=n.getSituation(t);if(e&&!i){let t=[e.isTiebreak&&`TB`,e.isBreakPoint&&`Break`,e.isGamePoint&&`Game`,e.isSetPoint&&`Set`,e.isMatchPoint&&`Match`].filter(Boolean);p.textContent=t.length?t.join(` • `):``}else p.textContent=i?`Complete`:``}}return m(),{element:o,update:m}}var XV=`chc-iss-score-cell`;function ZV(e){if(!e?.matchUpId)throw Error(`buildInteractiveScoringShell: matchUpId is required`);if(!e?.matchUpFormat)throw Error(`buildInteractiveScoringShell: matchUpFormat is required`);let t=e.initialMatchUp??QV(e),n=new Set,r=new ts({onScoreChange:({matchUp:e})=>{a(e,!1)},onMatchComplete:({winningSide:n})=>{a(r.getMatchUp(e.matchUpId,t),!0,n)}});r.getOrCreate(e.matchUpId,e.matchUpFormat,t);let i=document.createElement(`div`);i.className=`chc-interactive-scoring-shell`,i.dataset.matchupId=e.matchUpId,i.dataset.tournamentId=e.tournamentId,l();function a(t,r,i){let a={matchUpId:e.matchUpId,matchUp:t,isComplete:r,winningSide:i??t.winningSide},o=new CustomEvent(`stateChanged`,{detail:a});n.forEach(e=>{try{e(o)}catch(e){console.warn(`[interactive-scoring] listener threw`,e)}})}function o(n){r.isComplete(e.matchUpId)||(r.addPoint(e.matchUpId,n,t),l())}function s(){r.canUndo(e.matchUpId)&&(r.undo(e.matchUpId,t),l(),a(r.getMatchUp(e.matchUpId,t),r.isComplete(e.matchUpId)))}function c(){rH()&&(r.reset(e.matchUpId,t),l(),a(r.getMatchUp(e.matchUpId,t),!1))}function l(){i.innerHTML=``,i.append($V(e),eH(r,e,t),tH(r,e,o),nH(r,e,s,c))}return{element:i,getState:()=>r.getMatchUp(e.matchUpId,t),reset:()=>{r.reset(e.matchUpId,t),l(),a(r.getMatchUp(e.matchUpId,t),!1)},destroy:()=>{n.clear(),r.remove(e.matchUpId),i.innerHTML=``},addEventListener:(e,t)=>{e===`stateChanged`&&n.add(t)},removeEventListener:(e,t)=>{e===`stateChanged`&&n.delete(t)}}}function QV(e){return{matchUpId:e.matchUpId,tournamentId:e.tournamentId,matchUpFormat:e.matchUpFormat,matchUpStatus:`TO_BE_PLAYED`,score:{sets:[]},sides:[{sideNumber:1,participant:{participantName:e.side1Name}},{sideNumber:2,participant:{participantName:e.side2Name}}]}}function $V(e){let t=document.createElement(`div`);t.className=`chc-iss-header`;let n=document.createElement(`div`);n.className=`chc-iss-header-side chc-iss-header-side1`,n.textContent=e.side1Name||`Side 1`;let r=document.createElement(`div`);r.className=`chc-iss-header-vs`,r.textContent=`vs`;let i=document.createElement(`div`);return i.className=`chc-iss-header-side chc-iss-header-side2`,i.textContent=e.side2Name||`Side 2`,t.append(n,r,i),t}function eH(e,t,n){let r=document.createElement(`div`);r.className=`chc-iss-score-display`;let i=e.getMatchUp(t.matchUpId,n),a=i.score?.sets??[],o=document.createElement(`div`);o.className=`chc-iss-score-grid`,o.style.setProperty(`--sets`,String(Math.max(a.length,1)));let s=document.createElement(`div`);s.className=`chc-iss-score-row chc-iss-score-row-side1`;let c=document.createElement(`div`);c.className=`chc-iss-score-row chc-iss-score-row-side2`;for(let e of a){let t=document.createElement(`div`);t.className=XV,t.textContent=String(e.side1Score??0),e.winningSide===1&&t.classList.add(`chc-iss-score-cell-won`),s.append(t);let n=document.createElement(`div`);n.className=XV,n.textContent=String(e.side2Score??0),e.winningSide===2&&n.classList.add(`chc-iss-score-cell-won`),c.append(n)}if(a.length===0){let e=document.createElement(`div`);e.className=XV,e.textContent=`0`,s.append(e);let t=document.createElement(`div`);t.className=XV,t.textContent=`0`,c.append(t)}o.append(s,c),r.append(o);let l=a.at(-1);if(l&&!l.winningSide&&l.side1PointScore!=null){let e=document.createElement(`div`);e.className=`chc-iss-game-score`;let t=document.createElement(`span`);t.className=`chc-iss-game-score-side1`,t.textContent=String(l.side1PointScore);let n=document.createElement(`span`);n.className=`chc-iss-game-score-sep`,n.textContent=` — `;let i=document.createElement(`span`);i.className=`chc-iss-game-score-side2`,i.textContent=String(l.side2PointScore),e.append(t,n,i),r.append(e)}if(e.isComplete(t.matchUpId)){let e=document.createElement(`div`);e.className=`chc-iss-match-complete`,e.textContent=`${(i.winningSide===1?t.side1Name:t.side2Name)||`Match`} wins`,r.append(e)}return r}function tH(e,t,n){let r=document.createElement(`div`);r.className=`chc-iss-point-buttons`;let i=e.isComplete(t.matchUpId),a=document.createElement(`button`);a.type=`button`,a.className=`chc-iss-point-button chc-iss-point-button-side1`,a.disabled=i,a.setAttribute(`aria-label`,`${t.side1Name} won the point`);let o=document.createElement(`span`);o.className=`chc-iss-point-button-label`,o.textContent=t.side1Name||`Side 1`;let s=document.createElement(`span`);s.className=`chc-iss-point-button-hint`,s.textContent=`won the point`,a.append(o,s),a.addEventListener(`click`,()=>n(0));let c=document.createElement(`button`);c.type=`button`,c.className=`chc-iss-point-button chc-iss-point-button-side2`,c.disabled=i,c.setAttribute(`aria-label`,`${t.side2Name} won the point`);let l=document.createElement(`span`);l.className=`chc-iss-point-button-label`,l.textContent=t.side2Name||`Side 2`;let u=document.createElement(`span`);return u.className=`chc-iss-point-button-hint`,u.textContent=`won the point`,c.append(l,u),c.addEventListener(`click`,()=>n(1)),r.append(a,c),r}function nH(e,t,n,r){let i=document.createElement(`div`);i.className=`chc-iss-control-bar`;let a=document.createElement(`button`);a.type=`button`,a.className=`chc-iss-control-button chc-iss-control-undo`,a.textContent=`Undo`,a.disabled=!e.canUndo(t.matchUpId),a.addEventListener(`click`,n);let o=document.createElement(`button`);return o.type=`button`,o.className=`chc-iss-control-button chc-iss-control-reset`,o.textContent=`Reset`,o.addEventListener(`click`,r),i.append(a,o),i}function rH(){return typeof globalThis>`u`||typeof globalThis.confirm!=`function`?!1:globalThis.confirm(`Reset the scoring session? This will clear all points.`)}function iH(){return{policyName:`New Ranking Policy`,policyVersion:`1.0`,awardProfiles:[{profileName:`Default`,finishingPositionRanges:{1:100,2:70,4:50,8:30,16:15,32:8}}],requireWinForPoints:!0,doublesAttribution:`fullToEach`}}function Q(e){return structuredClone(e)}var aH=class{constructor(e){this.listeners=new Set,this.config=e;let t=Q(e.initialPolicy??iH()),n=t.awardProfiles?.length??0;this.state={draft:t,expandedSections:new Set(n>5?[`awardProfiles`]:[`metadata`,`awardProfiles`,`qualityWinProfiles`,`aggregationRules`]),expandedProfiles:new Set(n<=5?Array.from({length:n},(e,t)=>t):[]),profileFilter:``,dirty:!1,readonly:e.readonly??!1}}getState(){return this.state}getData(){return Q(this.state.draft)}setData(e){let t=e.awardProfiles?.length??0;this.state={...this.state,draft:Q(e),expandedProfiles:new Set(t<=5?Array.from({length:t},(e,t)=>t):[]),profileFilter:``,dirty:!1},this.emit()}toggleSection(e){let t=new Set(this.state.expandedSections);t.has(e)?t.delete(e):t.add(e),this.state={...this.state,expandedSections:t},this.emit()}toggleProfile(e){let t=new Set(this.state.expandedProfiles);t.has(e)?t.delete(e):t.add(e),this.state={...this.state,expandedProfiles:t},this.emit()}setProfileFilter(e){this.state={...this.state,profileFilter:e},this.emit()}setPolicyName(e){let t=Q(this.state.draft);t.policyName=e,this.commitDraft(t)}setPolicyVersion(e){let t=Q(this.state.draft);t.policyVersion=e,this.commitDraft(t)}setValidDateRange(e,t){let n=Q(this.state.draft);n.validDateRange||={},n.validDateRange[e]=t||void 0,this.commitDraft(n)}setGlobalFlag(e,t){let n=Q(this.state.draft);n[e]=t,this.commitDraft(n)}setDoublesAttribution(e){let t=Q(this.state.draft);t.doublesAttribution=e||void 0,this.commitDraft(t)}setCategoryResolution(e){let t=Q(this.state.draft);t.categoryResolution=e||void 0,this.commitDraft(t)}addProfile(){let e=Q(this.state.draft);e.awardProfiles||=[],e.awardProfiles.push({profileName:`Profile ${e.awardProfiles.length+1}`,finishingPositionRanges:{1:100,2:70,4:50,8:30}});let t=new Set(this.state.expandedProfiles);t.add(e.awardProfiles.length-1),this.state={...this.state,expandedProfiles:t},this.commitDraft(e)}removeProfile(e){let t=Q(this.state.draft);if(!t.awardProfiles||e<0||e>=t.awardProfiles.length)return;t.awardProfiles.splice(e,1);let n=new Set;for(let t of this.state.expandedProfiles)t<e?n.add(t):t>e&&n.add(t-1);this.state={...this.state,expandedProfiles:n},this.commitDraft(t)}duplicateProfile(e){let t=Q(this.state.draft);if(!t.awardProfiles||e<0||e>=t.awardProfiles.length)return;let n=Q(t.awardProfiles[e]);n.profileName=`${n.profileName??`Profile`} (Copy)`,t.awardProfiles.splice(e+1,0,n);let r=new Set;for(let t of this.state.expandedProfiles)t<=e?r.add(t):r.add(t+1);r.add(e+1),this.state={...this.state,expandedProfiles:r},this.commitDraft(t)}moveProfile(e,t){let n=Q(this.state.draft);if(!n.awardProfiles||e<0||e>=n.awardProfiles.length||t<0||t>=n.awardProfiles.length)return;let[r]=n.awardProfiles.splice(e,1);n.awardProfiles.splice(t,0,r),this.commitDraft(n)}setProfileName(e,t){let n=Q(this.state.draft);n.awardProfiles?.[e]&&(n.awardProfiles[e].profileName=t,this.commitDraft(n))}setProfileFlag(e,t,n){let r=Q(this.state.draft);r.awardProfiles?.[e]&&(n===void 0?delete r.awardProfiles[e][t]:r.awardProfiles[e][t]=n,this.commitDraft(r))}setFlatPositionPoints(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e];i&&(i.finishingPositionRanges||={},i.finishingPositionRanges[t]=n,this.commitDraft(r))}addPositionRow(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];r&&(r.finishingPositionRanges||={},r.finishingPositionRanges[t]===void 0&&(r.finishingPositionRanges[t]=0,this.commitDraft(n)))}removePositionRow(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];r?.finishingPositionRanges&&(delete r.finishingPositionRanges[t],this.commitDraft(n))}setPointsPerWin(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];r&&(t===void 0?delete r.pointsPerWin:r.pointsPerWin=t,this.commitDraft(n))}addBonusPoint(e){let t=Q(this.state.draft),n=t.awardProfiles?.[e];n&&(n.bonusPoints||=[],n.bonusPoints.push({finishingPositions:[1],value:0}),this.commitDraft(t))}removeBonusPoint(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];r?.bonusPoints&&(r.bonusPoints.splice(t,1),r.bonusPoints.length||delete r.bonusPoints,this.commitDraft(n))}setBonusPointPositions(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e]?.bonusPoints?.[t];i&&(i.finishingPositions=n,this.commitDraft(r))}setBonusPointValue(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e]?.bonusPoints?.[t];i&&(i.value=n,this.commitDraft(r))}setLevelPositionPoints(e,t,n,r){let i=Q(this.state.draft),a=i.awardProfiles?.[e];if(!a)return;a.finishingPositionRanges||={};let o=a.finishingPositionRanges[t];o&&typeof o==`object`&&o.level&&(o.level[n]=r),this.commitDraft(i)}addLevel(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];if(r?.finishingPositionRanges){for(let e of Object.keys(r.finishingPositionRanges)){let n=r.finishingPositionRanges[e];n&&typeof n==`object`&&n.level&&n.level[t]===void 0&&(n.level[t]=0)}r.levels&&!r.levels.includes(t)&&(r.levels.push(t),r.levels.sort((e,t)=>e-t)),this.commitDraft(n)}}removeLevel(e,t){let n=Q(this.state.draft),r=n.awardProfiles?.[e];if(r?.finishingPositionRanges){for(let e of Object.keys(r.finishingPositionRanges)){let n=r.finishingPositionRanges[e];n&&typeof n==`object`&&n.level&&delete n.level[t]}r.levels&&=r.levels.filter(e=>e!==t),this.commitDraft(n)}}setProfileScope(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e];i&&(n.length?i[t]=n:delete i[t],this.commitDraft(r))}setProfileField(e,t,n){let r=Q(this.state.draft),i=r.awardProfiles?.[e];i&&(n===void 0||n===``?delete i[t]:i[t]=n,this.commitDraft(r))}addQualityWinProfile(){let e=Q(this.state.draft);e.qualityWinProfiles||=[],e.qualityWinProfiles.push({rankingScaleName:`New Profile`,rankingRanges:[{rankRange:[1,10],value:10}]}),this.commitDraft(e)}removeQualityWinProfile(e){let t=Q(this.state.draft);t.qualityWinProfiles&&(t.qualityWinProfiles.splice(e,1),t.qualityWinProfiles.length||delete t.qualityWinProfiles,this.commitDraft(t))}setQualityWinField(e,t,n){let r=Q(this.state.draft),i=r.qualityWinProfiles?.[e];i&&(n===void 0||n===``?delete i[t]:i[t]=n,this.commitDraft(r))}addQualityWinRange(e){let t=Q(this.state.draft),n=t.qualityWinProfiles?.[e];if(!n)return;let r=n.rankingRanges.at(-1),i=r?r.rankRange[1]+1:1;n.rankingRanges.push({rankRange:[i,i+9],value:0}),this.commitDraft(t)}removeQualityWinRange(e,t){let n=Q(this.state.draft),r=n.qualityWinProfiles?.[e];r&&(r.rankingRanges.splice(t,1),this.commitDraft(n))}setQualityWinRange(e,t,n,r){let i=Q(this.state.draft),a=i.qualityWinProfiles?.[e]?.rankingRanges?.[t];a&&(n===`rankRange`?a.rankRange=r:a.value=r,this.commitDraft(i))}setAggregationField(e,t){let n=Q(this.state.draft);n.aggregationRules||={},t===void 0||t===``?delete n.aggregationRules[e]:n.aggregationRules[e]=t,this.commitDraft(n)}addTiebreakCriterion(e){let t=Q(this.state.draft);t.aggregationRules||={},t.aggregationRules.tiebreakCriteria||(t.aggregationRules.tiebreakCriteria=[]),t.aggregationRules.tiebreakCriteria.push(e),this.commitDraft(t)}removeTiebreakCriterion(e){let t=Q(this.state.draft);t.aggregationRules?.tiebreakCriteria&&(t.aggregationRules.tiebreakCriteria.splice(e,1),t.aggregationRules.tiebreakCriteria.length||delete t.aggregationRules.tiebreakCriteria,this.commitDraft(t))}addCountingBucket(){let e=Q(this.state.draft);e.aggregationRules||={},e.aggregationRules.countingBuckets||(e.aggregationRules.countingBuckets=[]),e.aggregationRules.countingBuckets.push({bucketName:`New Bucket`}),this.commitDraft(e)}removeCountingBucket(e){let t=Q(this.state.draft);t.aggregationRules?.countingBuckets&&(t.aggregationRules.countingBuckets.splice(e,1),t.aggregationRules.countingBuckets.length||delete t.aggregationRules.countingBuckets,this.commitDraft(t))}setCountingBucketField(e,t,n){let r=Q(this.state.draft),i=r.aggregationRules?.countingBuckets?.[e];i&&(n===void 0||n===``?delete i[t]:i[t]=n,this.commitDraft(r))}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}commitDraft(e){this.state={...this.state,draft:e,dirty:!0},this.emit(),this.config.onChange?.(Q(e))}emit(){for(let e of this.listeners)e(this.state)}},oH=()=>`re-section`,sH=()=>`re-section-header`,cH=()=>`re-section-chevron`,lH=()=>`re-section-count`,uH=()=>`re-section-body`,dH=()=>`re-field-row`,fH=()=>`re-field-label`,pH=()=>`re-field-input re-field-input--text`,mH=()=>`re-field-input re-field-input--number`,hH=()=>`re-field-input re-field-input--date`,gH=()=>`re-field-select`,_H=()=>`re-checkbox-row`,vH=()=>`re-points-input`,yH=()=>`re-profile-card`,bH=()=>`re-profile-header`,xH=()=>`re-profile-name-input`,SH=()=>`re-profile-body`,CH=()=>`re-profile-actions`,wH=()=>`re-icon-btn`,TH=()=>`re-icon-btn re-icon-btn--danger`,EH=()=>`re-empty`,DH=()=>`re-editor`,OH=[`totalPoints`,`bestResult`,`headToHead`,`numberOfWins`,`recentResults`,`drawSize`,`numberOfResults`];function kH(e){let t=document.createElement(`div`),n=``;function r(t,n,r,i,a,o){let s=document.createElement(`div`);s.className=dH();let c=document.createElement(`div`);if(c.className=fH(),c.textContent=n,s.appendChild(c),o){let e=document.createElement(`span`);e.style.cssText=`font-size:0.85rem;color:var(--sp-text)`,e.textContent=String(i),s.appendChild(e)}else if(r===`select`){let n=document.createElement(`select`);n.className=gH();let r=document.createElement(`option`);r.value=``,r.textContent=`(none)`,n.appendChild(r);for(let e of a??[]){let t=document.createElement(`option`);t.value=e,t.textContent=e,n.appendChild(t)}n.value=i??``,n.addEventListener(`change`,()=>e.setAggregationField(t,n.value||void 0)),s.appendChild(n)}else{let n=document.createElement(`input`);n.type=`number`,n.className=mH(),n.value=i===void 0?``:String(i),n.placeholder=`—`,n.addEventListener(`change`,()=>{let r=n.value.trim();e.setAggregationField(t,r?Number.parseInt(r,10):void 0)}),s.appendChild(n)}return s}function i(n,r){let i=document.createElement(`div`);if(i.style.cssText=`font-weight:600;font-size:0.8rem;margin:0.5rem 0 0.3rem;color:var(--sp-text)`,i.textContent=`Tiebreak Order`,t.appendChild(i),n.length){let i=document.createElement(`ol`);i.style.cssText=`font-size:0.8rem;margin:0;padding-left:1.5rem;color:var(--sp-text)`;for(let t=0;t<n.length;t++){let a=document.createElement(`li`);a.style.cssText=`display:flex;align-items:center;gap:6px;margin-bottom:2px`;let o=document.createElement(`span`);if(o.textContent=n[t],a.appendChild(o),!r){let n=document.createElement(`span`);n.className=TH(),n.textContent=`×`,n.style.cursor=`pointer`,n.addEventListener(`click`,()=>e.removeTiebreakCriterion(t)),a.appendChild(n)}i.appendChild(a)}t.appendChild(i)}else if(r){let e=document.createElement(`div`);e.className=EH(),e.textContent=`No tiebreak criteria`,t.appendChild(e)}if(!r){let r=document.createElement(`div`);r.style.cssText=`display:flex;align-items:center;gap:4px;margin-top:4px`;let i=document.createElement(`select`);i.className=gH(),i.style.fontSize=`0.75rem`;let a=new Set(n),o=OH.filter(e=>!a.has(e));for(let e of o){let t=document.createElement(`option`);t.value=e,t.textContent=e,i.appendChild(t)}let s=document.createElement(`button`);s.className=`sp-btn sp-btn--sm sp-btn--outline`,s.textContent=`+ Add`,s.addEventListener(`click`,()=>{i.value&&e.addTiebreakCriterion(i.value)}),o.length&&(r.appendChild(i),r.appendChild(s),t.appendChild(r))}}function a(t,n,r){let i=document.createElement(`div`);i.style.cssText=`border:1px solid var(--sp-border);border-radius:8px;padding:0.4rem;margin-bottom:0.4rem;font-size:0.8rem`;let a=document.createElement(`div`);if(a.style.cssText=`display:flex;align-items:center;gap:6px;margin-bottom:0.2rem`,r){let e=document.createElement(`span`);e.style.cssText=`font-weight:600;color:var(--sp-text)`,e.textContent=t.bucketName||`Bucket`,a.appendChild(e)}else{let r=document.createElement(`input`);r.type=`text`,r.className=`re-field-input re-field-input--text`,r.style.cssText=`width:120px;font-size:0.75rem;font-weight:600`,r.value=t.bucketName||``,r.placeholder=`Bucket name`,r.addEventListener(`change`,()=>e.setCountingBucketField(n,`bucketName`,r.value)),a.appendChild(r);let i=document.createElement(`div`);i.style.flexGrow=`1`,a.appendChild(i);let o=document.createElement(`span`);o.className=TH(),o.textContent=`✕`,o.style.cursor=`pointer`,o.addEventListener(`click`,()=>e.removeCountingBucket(n)),a.appendChild(o)}i.appendChild(a);let o=[];if(t.eventTypes?.length&&o.push(`Events: ${t.eventTypes.join(`, `)}`),t.bestOfCount!==void 0&&o.push(`Best of: ${t.bestOfCount}`),t.levels?.length&&o.push(`Levels: ${t.levels.join(`, `)}`),t.minResults!==void 0&&o.push(`Min: ${t.minResults}`),r&&o.length){let e=document.createElement(`div`);e.style.cssText=`color:var(--sp-muted);font-size:0.75rem`,e.textContent=o.join(` | `),i.appendChild(e)}else if(!r){let r=document.createElement(`div`);r.className=dH();let a=document.createElement(`div`);a.className=fH(),a.style.cssText=`min-width:70px;font-size:0.75rem`,a.textContent=`Best of`,r.appendChild(a);let o=document.createElement(`input`);o.type=`number`,o.className=mH(),o.style.fontSize=`0.75rem`,o.value=t.bestOfCount===void 0?``:String(t.bestOfCount),o.addEventListener(`change`,()=>{let t=o.value.trim();e.setCountingBucketField(n,`bestOfCount`,t?Number.parseInt(t,10):void 0)}),r.appendChild(o),i.appendChild(r)}return i}function o(n){let o=n.draft.aggregationRules;if(t.innerHTML=``,!o&&n.readonly){let e=document.createElement(`div`);e.className=EH(),e.textContent=`No aggregation rules defined (all results summed)`,t.appendChild(e);return}let s=[[`rollingPeriodDays`,`Rolling period (days)`,`number`,o?.rollingPeriodDays],[`bestOfCount`,`Best of count`,`number`,o?.bestOfCount],[`minCountableResults`,`Min countable results`,`number`,o?.minCountableResults],[`decayFunction`,`Decay function`,`select`,o?.decayFunction,[`none`,`linear`,`exponential`,`step`]]];for(let[e,i,a,o,c]of s)o===void 0&&n.readonly||t.appendChild(r(e,i,a,o,c,n.readonly));let c=[[`separateByGender`,`Separate by gender`,o?.separateByGender],[`perCategory`,`Per category`,o?.perCategory]];for(let[r,i,a]of c){if(a===void 0&&n.readonly)continue;let o=document.createElement(`div`);o.className=_H();let s=document.createElement(`input`);s.type=`checkbox`,s.checked=a??!1,s.disabled=n.readonly,s.addEventListener(`change`,()=>e.setAggregationField(r,s.checked));let c=document.createElement(`label`);c.textContent=i,o.appendChild(s),o.appendChild(c),t.appendChild(o)}i(o?.tiebreakCriteria??[],n.readonly);let l=o?.countingBuckets??[];if(l.length||!n.readonly){let r=document.createElement(`div`);r.style.cssText=`font-weight:600;font-size:0.8rem;margin:0.5rem 0 0.3rem;color:var(--sp-text)`,r.textContent=`Counting Buckets`,t.appendChild(r);for(let e=0;e<l.length;e++)t.appendChild(a(l[e],e,n.readonly));if(!n.readonly){let n=document.createElement(`button`);n.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,n.textContent=`+ Add Bucket`,n.addEventListener(`click`,()=>e.addCountingBucket()),t.appendChild(n)}}}function s(e){let t=JSON.stringify(e.draft.aggregationRules??{});t!==n&&(n=t,o(e))}return{element:t,update:s}}function AH(e){let t=document.createElement(`div`),n=``;function r(t,n,r){let i=document.createElement(`div`);if(i.style.cssText=`display:flex;align-items:center;gap:0.5rem;margin-bottom:0.4rem`,r){let e=document.createElement(`span`);e.style.cssText=`font-weight:600;font-size:0.85rem;color:var(--sp-text)`,e.textContent=n.rankingScaleName,i.appendChild(e)}else{let r=document.createElement(`input`);r.type=`text`,r.className=pH(),r.style.cssText=`width:150px;font-weight:600`,r.value=n.rankingScaleName,r.addEventListener(`change`,()=>e.setQualityWinField(t,`rankingScaleName`,r.value)),i.appendChild(r);let a=document.createElement(`div`);a.style.flexGrow=`1`,i.appendChild(a);let o=document.createElement(`span`);o.className=TH(),o.textContent=`✕`,o.title=`Delete profile`,o.style.cursor=`pointer`,o.addEventListener(`click`,()=>e.removeQualityWinProfile(t)),i.appendChild(o)}return i}let i=`text-align:right;padding:2px 4px`,a=`text-align:right;width:4rem`;function o(t,n,r,a){let o=document.createElement(`tr`);if(a)for(let e of[r.rankRange[0],r.rankRange[1],r.value]){let t=document.createElement(`td`);t.style.cssText=`text-align:right;font-variant-numeric:tabular-nums;padding:2px 4px`,t.textContent=e.toLocaleString(),o.appendChild(t)}else{let a=document.createElement(`td`);a.style.cssText=i,a.appendChild(jH(r.rankRange[0],i=>{e.setQualityWinRange(t,n,`rankRange`,[i,r.rankRange[1]])})),o.appendChild(a);let s=document.createElement(`td`);s.style.cssText=i,s.appendChild(jH(r.rankRange[1],i=>{e.setQualityWinRange(t,n,`rankRange`,[r.rankRange[0],i])})),o.appendChild(s);let c=document.createElement(`td`);c.style.cssText=i,c.appendChild(jH(r.value,r=>{e.setQualityWinRange(t,n,`value`,r)})),o.appendChild(c);let l=document.createElement(`td`);l.style.cssText=`text-align:center;padding:2px`;let u=document.createElement(`span`);u.className=TH(),u.textContent=`×`,u.style.cursor=`pointer`,u.addEventListener(`click`,()=>e.removeQualityWinRange(t,n)),l.appendChild(u),o.appendChild(l)}return o}function s(e,t,n){let r=document.createElement(`table`);r.style.cssText=`font-size:0.8rem;margin-bottom:0.3rem;border-collapse:collapse`;let i=document.createElement(`thead`),s=document.createElement(`tr`);for(let[e,t]of[[`From`,a],[`To`,a],[`Bonus`,a]]){let n=document.createElement(`th`);n.textContent=e,n.style.cssText=t+`;padding:2px 4px`,s.appendChild(n)}if(!n){let e=document.createElement(`th`);e.style.cssText=`width:2rem;padding:2px`,s.appendChild(e)}i.appendChild(s),r.appendChild(i);let c=document.createElement(`tbody`);for(let r=0;r<t.rankingRanges.length;r++)c.appendChild(o(e,r,t.rankingRanges[r],n));return r.appendChild(c),r}function c(t,n,r,i,a){let o=document.createElement(`div`);o.className=dH();let s=document.createElement(`div`);if(s.className=fH(),s.style.minWidth=`100px`,s.style.fontSize=`0.75rem`,s.textContent=r,o.appendChild(s),a){let e=document.createElement(`span`);e.style.cssText=`font-size:0.75rem;color:var(--sp-muted)`,e.textContent=String(i),o.appendChild(e)}else{let r=document.createElement(`input`);r.type=typeof i==`number`?`number`:`text`,r.className=typeof i==`number`?mH():pH(),r.style.fontSize=`0.75rem`,r.value=i===void 0?``:String(i),r.addEventListener(`change`,()=>{let a=r.value.trim();typeof i==`number`||n===`maxBonusPerTournament`?e.setQualityWinField(t,n,a?Number.parseFloat(a):void 0):e.setQualityWinField(t,n,a||void 0)}),o.appendChild(r)}return o}function l(n){let i=n.draft.qualityWinProfiles;if(t.innerHTML=``,!i?.length){let r=document.createElement(`div`);if(r.className=EH(),r.textContent=`No quality win profiles defined`,t.appendChild(r),!n.readonly){let n=document.createElement(`button`);n.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,n.textContent=`+ Add Quality Win Profile`,n.addEventListener(`click`,()=>e.addQualityWinProfile()),t.appendChild(n)}return}for(let a=0;a<i.length;a++){let o=i[a],l=document.createElement(`div`);if(l.style.cssText=`border:1px solid var(--sp-border);border-radius:10px;padding:0.5rem;margin-bottom:0.5rem`,l.appendChild(r(a,o,n.readonly)),o.rankingRanges?.length&&(l.appendChild(s(a,o,n.readonly)),!n.readonly)){let t=document.createElement(`button`);t.className=`sp-btn sp-btn--sm sp-btn--outline`,t.textContent=`+ Range`,t.style.marginBottom=`0.3rem`,t.addEventListener(`click`,()=>e.addQualityWinRange(a)),l.appendChild(t)}let u=[[`maxBonusPerTournament`,`Max bonus/tournament`,o.maxBonusPerTournament],[`rankingSnapshot`,`Ranking snapshot`,o.rankingSnapshot]];for(let[e,t,r]of u)r===void 0&&n.readonly||l.appendChild(c(a,e,t,r,n.readonly));if(o.includeWalkovers!==void 0||!n.readonly){let t=document.createElement(`div`);t.className=_H();let r=document.createElement(`input`);r.type=`checkbox`,r.checked=o.includeWalkovers??!1,r.disabled=n.readonly,r.addEventListener(`change`,()=>e.setQualityWinField(a,`includeWalkovers`,r.checked));let i=document.createElement(`label`);i.textContent=`Include walkovers`,i.style.fontSize=`0.75rem`,t.appendChild(r),t.appendChild(i),l.appendChild(t)}t.appendChild(l)}if(!n.readonly){let n=document.createElement(`button`);n.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,n.textContent=`+ Add Quality Win Profile`,n.addEventListener(`click`,()=>e.addQualityWinProfile()),t.appendChild(n)}}function u(e){let t=JSON.stringify(e.draft.qualityWinProfiles??[]);t!==n&&(n=t,l(e))}return{element:t,update:u}}function jH(e,t){let n=document.createElement(`input`);return n.type=`number`,n.className=vH(),n.value=String(e),n.addEventListener(`change`,()=>{let e=Number.parseFloat(n.value);Number.isNaN(e)||t(e)}),n}function MH(e){let t=document.createElement(`div`),n=document.createElement(`div`);n.className=dH();let r=document.createElement(`div`);r.className=fH(),r.textContent=`Name`;let i=document.createElement(`input`);i.type=`text`,i.className=pH(),i.placeholder=`Policy name`,i.addEventListener(`change`,()=>e.setPolicyName(i.value)),n.appendChild(r),n.appendChild(i),t.appendChild(n);let a=document.createElement(`div`);a.className=dH();let o=document.createElement(`div`);o.className=fH(),o.textContent=`Version`;let s=document.createElement(`input`);s.type=`text`,s.className=pH(),s.placeholder=`1.0`,s.style.width=`80px`,s.addEventListener(`change`,()=>e.setPolicyVersion(s.value)),a.appendChild(o),a.appendChild(s),t.appendChild(a);let c=document.createElement(`div`);c.className=dH();let l=document.createElement(`div`);l.className=fH(),l.textContent=`Valid from`;let u=document.createElement(`input`);u.type=`date`,u.className=hH(),u.addEventListener(`change`,()=>e.setValidDateRange(`startDate`,u.value)),c.appendChild(l),c.appendChild(u),t.appendChild(c);let d=document.createElement(`div`);d.className=dH();let f=document.createElement(`div`);f.className=fH(),f.textContent=`Valid until`;let p=document.createElement(`input`);p.type=`date`,p.className=hH(),p.addEventListener(`change`,()=>e.setValidDateRange(`endDate`,p.value)),d.appendChild(f),d.appendChild(p),t.appendChild(d);let m=document.createElement(`div`);m.className=dH();let h=document.createElement(`div`);h.className=fH(),h.textContent=`Doubles attribution`;let g=document.createElement(`select`);g.className=gH();for(let[e,t]of[[``,`(none)`],[`fullToEach`,`Full to each`],[`halfToEach`,`Half to each`],[`split`,`Split`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,g.appendChild(n)}g.addEventListener(`change`,()=>e.setDoublesAttribution(g.value)),m.appendChild(h),m.appendChild(g),t.appendChild(m);let _=document.createElement(`div`);_.className=dH();let v=document.createElement(`div`);v.className=fH(),v.textContent=`Category resolution`;let y=document.createElement(`select`);y.className=gH();for(let[e,t]of[[``,`(none)`],[`matchCategory`,`Match category`],[`eventCategory`,`Event category`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,y.appendChild(n)}y.addEventListener(`change`,()=>e.setCategoryResolution(y.value)),_.appendChild(v),_.appendChild(y),t.appendChild(_);let b=document.createElement(`div`);b.className=_H();let x=document.createElement(`input`);x.type=`checkbox`,x.id=`re-require-win`;let S=document.createElement(`label`);S.htmlFor=`re-require-win`,S.textContent=`Require win for points`,x.addEventListener(`change`,()=>e.setGlobalFlag(`requireWinForPoints`,x.checked)),b.appendChild(x),b.appendChild(S),t.appendChild(b);let C=document.createElement(`div`);C.className=_H();let w=document.createElement(`input`);w.type=`checkbox`,w.id=`re-require-win-r1`;let T=document.createElement(`label`);T.htmlFor=`re-require-win-r1`,T.textContent=`Require win in first round`,w.addEventListener(`change`,()=>e.setGlobalFlag(`requireWinFirstRound`,w.checked)),C.appendChild(w),C.appendChild(T),t.appendChild(C);let E=[i,s,u,p],D=[g,y],O=[x,w];function k(e){let{draft:t}=e;document.activeElement!==i&&(i.value=t.policyName??``),document.activeElement!==s&&(s.value=t.policyVersion??``),document.activeElement!==u&&(u.value=t.validDateRange?.startDate??``),document.activeElement!==p&&(p.value=t.validDateRange?.endDate??``),document.activeElement!==g&&(g.value=t.doublesAttribution??``),document.activeElement!==y&&(y.value=t.categoryResolution??``),x.checked=t.requireWinForPoints??!1,w.checked=t.requireWinFirstRound??!1;let n=e.readonly;for(let e of E)e.disabled=n;for(let e of D)e.disabled=n;for(let e of O)e.disabled=n}return{element:t,update:k}}var NH={1:`W`,2:`F`,4:`SF`,8:`QF`,16:`R16`,32:`R32`,64:`R64`,128:`R128`,256:`R256`},PH=`level-keyed`;function FH(e){return NH[e]??`R${e}`}function IH(e){if(!e)return{type:`flat`};let t=Object.values(e);if(!t.length||t.every(e=>typeof e==`number`))return{type:`flat`};let n=LH(t);return n.hasConditionalArray?{type:`conditional`}:n.hasLevelFlightNesting?RH(t,n.allLevels):n.allLevels.size>0?{type:`level-columns`,levels:[...n.allLevels].sort((e,t)=>e-t)}:n.allFlights.size>0?{type:`flight-columns`,flights:[...n.allFlights].sort((e,t)=>e-t)}:{type:`flat`}}function LH(e){let t=new Set,n=new Set,r=!1,i=!1;for(let a of e){let e=zH(a);if(e.type===PH){for(let n of e.levels)t.add(n);e.hasFlightNesting&&(i=!0)}else if(e.type===`flight-keyed`)for(let t=0;t<e.flightCount;t++)n.add(t+1);else e.type===`conditional-array`&&(r=!0)}return{allLevels:t,allFlights:n,hasConditionalArray:r,hasLevelFlightNesting:i}}function RH(e,t){let n={},r=[...t].sort((e,t)=>e-t);for(let t of e){let e=zH(t);if(e.type===PH&&e.flightDetails)for(let[t,r]of Object.entries(e.flightDetails)){let e=Number(t);n[e]||(n[e]=[]);for(let t of r)n[e].includes(t)||n[e].push(t)}}return{type:`level-flight-tabs`,levels:r,flightsPerLevel:n}}function zH(e){if(typeof e==`number`)return{type:`flat`,levels:[],flightCount:0,hasFlightNesting:!1};if(Array.isArray(e))return{type:`conditional-array`,levels:[],flightCount:0,hasFlightNesting:!1};if(typeof e!=`object`||!e)return{type:`flat`,levels:[],flightCount:0,hasFlightNesting:!1};if(e.level!==void 0){if(Array.isArray(e.level))return{type:PH,levels:e.level.map((e,t)=>t+1),flightCount:0,hasFlightNesting:!1};if(typeof e.level==`object`){let t=Object.keys(e.level).map(Number).filter(e=>!Number.isNaN(e)),n=!1,r={};for(let[t,i]of Object.entries(e.level))typeof i==`object`&&i&&i.flights&&(n=!0,r[Number(t)]=i.flights.map((e,t)=>t+1));return{type:PH,levels:t,flightCount:0,hasFlightNesting:n,flightDetails:r}}}return e.flights!==void 0||e.f!==void 0?{type:`flight-keyed`,levels:[],flightCount:(e.flights??e.f??[]).length,hasFlightNesting:!1}:e.value===void 0?{type:`flat`,levels:[],flightCount:0,hasFlightNesting:!1}:{type:`explicit-flat`,levels:[],flightCount:0,hasFlightNesting:!1}}function BH(e,t={}){if(typeof e==`number`)return e;if(e!=null){if(Array.isArray(e))return VH(e,t);if(typeof e==`object`){if(e.level!==void 0&&t.level!==void 0)return HH(e,t);if(t.flight!==void 0){let n=e.flights??e.f;if(Array.isArray(n))return n[t.flight-1]}if(e.value!==void 0)return e.value}}}function VH(e,t){for(let n of e){if(n.drawSizes&&t.drawSize&&n.drawSizes.includes(t.drawSize))return BH(n,t);if(n.drawSize!==void 0&&t.drawSize!==void 0&&(n.threshold?t.drawSize>=n.drawSize:t.drawSize===n.drawSize))return BH({...n,drawSize:void 0,drawSizes:void 0,threshold:void 0},t);if(n.drawSize===void 0&&n.drawSizes===void 0)return BH(n,t)}}function HH(e,t){let n=Array.isArray(e.level)?e.level[t.level-1]:e.level[t.level];if(n!==void 0)return typeof n==`object`&&n?BH(n,t):typeof n==`number`?n:void 0}function UH(e){let t=[],n=Object.keys(e.finishingPositionRanges??{}).length;return n&&t.push(`${n} positions`),(e.perWinPoints||e.pointsPerWin)&&t.push(`per-win`),e.bonusPoints?.length&&t.push(`${e.bonusPoints.length} bonus`),t.join(`, `)||`empty`}function WH(e){let t=[];for(let n of e.eventTypes??[])t.push({label:n,intent:`re-badge--accent`});for(let n of e.stages??[])t.push({label:n,intent:`re-badge--success`});for(let n of e.levels??[])t.push({label:`L${n}`,intent:`re-badge--warn`});for(let n of e.drawTypes??[])t.push({label:n.replaceAll(`_`,` `),intent:`re-badge--primary`});return e.participationOrder!==void 0&&t.push({label:`PO:${e.participationOrder}`,intent:`re-badge--info`}),t}function GH(e){return e==null?`--`:e.toLocaleString()}var KH=[1,2,4,8,16,32,64,128],qH=`font-size:0.8rem;margin-bottom:0;border-collapse:collapse`,JH=`width:3.5rem;text-align:center`;function YH(e,t){let n=document.createElement(`div`);n.style.cssText=`overflow-x:auto`;let r=``;function i(r){let i=r.draft.awardProfiles?.[t]?.finishingPositionRanges;if(n.innerHTML=``,!i||!Object.keys(i).length){let i=document.createElement(`div`);if(i.className=EH(),i.textContent=`No finishing position points defined`,!r.readonly){let n=document.createElement(`button`);n.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,n.textContent=`+ Add position`,n.style.marginLeft=`8px`,n.addEventListener(`click`,()=>e.addPositionRow(t,1)),i.appendChild(n)}n.appendChild(i);return}let a=IH(i),o=Object.keys(i).map(Number).sort((e,t)=>e-t);a.type===`flat`?XH(n,o,i,r.readonly,e,t):a.type===`level-columns`?ZH(n,o,i,a.levels,r.readonly,e,t):QH(n,o,i,a)}function a(e){let n=e.draft.awardProfiles?.[t],a=JSON.stringify(n?.finishingPositionRanges??{});a!==r&&(r=a,i(e))}return{element:n,update:a}}function XH(e,t,n,r,i,a){let o=document.createElement(`table`);o.style.cssText=qH;let s=document.createElement(`thead`),c=document.createElement(`tr`);$H(c,`Pos`,JH),$H(c,`Points`,`text-align:right`),r||$H(c,``,`width:2rem`),s.appendChild(c),o.appendChild(s);let l=document.createElement(`tbody`);for(let e of t){let t=document.createElement(`tr`);eU(t,e);let o=document.createElement(`td`);o.style.cssText=`text-align:right;padding:2px 4px`,r?(o.style.fontVariantNumeric=`tabular-nums`,o.textContent=GH(typeof n[e]==`number`?n[e]:BH(n[e]))):o.appendChild(nU(typeof n[e]==`number`?n[e]:BH(n[e])??0,t=>i.setFlatPositionPoints(a,e,t))),t.appendChild(o),r||tU(t,()=>i.removePositionRow(a,e)),l.appendChild(t)}o.appendChild(l),e.appendChild(o),r||rU(e,t,i,a)}function ZH(e,t,n,r,i,a,o){let s=document.createElement(`table`);s.style.cssText=qH;let c=document.createElement(`thead`),l=document.createElement(`tr`);$H(l,`Pos`,JH);for(let e of r){let t=document.createElement(`th`);if(t.style.cssText=`text-align:right;min-width:3.5rem;padding:2px 4px`,i)t.textContent=`L${e}`;else{let n=document.createElement(`div`);n.style.cssText=`display:flex;align-items:center;justify-content:flex-end;gap:4px`;let r=document.createElement(`span`);r.textContent=`L${e}`,n.appendChild(r);let i=document.createElement(`span`);i.className=TH(),i.textContent=`×`,i.title=`Remove level ${e}`,i.style.cssText=`cursor:pointer;font-size:0.65rem`,i.addEventListener(`click`,()=>a.removeLevel(o,e)),n.appendChild(i),t.appendChild(n)}l.appendChild(t)}i||$H(l,``,`width:2rem`),c.appendChild(l),s.appendChild(c);let u=document.createElement(`tbody`);for(let e of t){let t=document.createElement(`tr`);eU(t,e);for(let s of r){let r=document.createElement(`td`);r.style.cssText=`text-align:right;padding:2px 4px`;let c=BH(n[e],{level:s});i?(r.style.fontVariantNumeric=`tabular-nums`,r.textContent=GH(c),c===void 0&&(r.style.color=`var(--sp-muted)`)):r.appendChild(nU(c??0,t=>a.setLevelPositionPoints(o,e,s,t))),t.appendChild(r)}i||tU(t,()=>a.removePositionRow(o,e)),u.appendChild(t)}if(s.appendChild(u),e.appendChild(s),!i){let n=document.createElement(`div`);n.style.cssText=`display:flex;gap:8px;margin-top:6px;flex-wrap:wrap`;let i=document.createElement(`div`);i.style.cssText=`display:flex;align-items:center;gap:4px`;let s=document.createElement(`input`);s.type=`number`,s.className=vH(),s.style.width=`50px`,s.placeholder=`L#`,s.min=`1`;let c=document.createElement(`button`);c.className=`sp-btn sp-btn--sm sp-btn--outline`,c.textContent=`+ Level`,c.addEventListener(`click`,()=>{let e=Number.parseInt(s.value,10);!Number.isNaN(e)&&e>0&&!r.includes(e)&&(a.addLevel(o,e),s.value=``)}),i.appendChild(s),i.appendChild(c),n.appendChild(i),iU(n,t,a,o),e.appendChild(n)}}function QH(e,t,n,r){let i=document.createElement(`div`);i.style.cssText=`font-size:0.7rem;color:var(--sp-muted);margin-bottom:4px;font-style:italic`,i.textContent=`(${r.type} layout — view only)`,e.appendChild(i);let a=document.createElement(`table`);a.style.cssText=qH;let o=document.createElement(`thead`),s=document.createElement(`tr`);if($H(s,`Pos`,JH),r.type===`flight-columns`)for(let e of r.flights)$H(s,`F${e}`,`text-align:right;min-width:3.5rem`);else $H(s,`Points`,`text-align:right`);o.appendChild(s),a.appendChild(o);let c=document.createElement(`tbody`);for(let e of t){let t=document.createElement(`tr`);eU(t,e);let i=n[e];if(r.type===`flight-columns`)for(let e of r.flights){let n=document.createElement(`td`);n.style.cssText=`text-align:right;font-variant-numeric:tabular-nums;padding:2px 4px`;let r=BH(i,{flight:e});n.textContent=GH(r),r===void 0&&(n.style.color=`var(--sp-muted)`),t.appendChild(n)}else{let e=document.createElement(`td`);if(e.style.cssText=`text-align:right;font-variant-numeric:tabular-nums;padding:2px 4px`,e.textContent=GH(BH(i)),Array.isArray(i)){let t=document.createElement(`span`);t.style.cssText=`margin-left:0.3rem;font-size:0.65rem;color:var(--sp-muted)`,t.textContent=`${i.length} variants`,t.title=JSON.stringify(i,null,2),e.appendChild(t)}t.appendChild(e)}c.appendChild(t)}a.appendChild(c),e.appendChild(a)}function $H(e,t,n){let r=document.createElement(`th`);r.textContent=t,r.style.cssText=n+`;padding:2px 4px`,e.appendChild(r)}function eU(e,t){let n=document.createElement(`td`);n.style.cssText=`text-align:center;font-weight:600;color:var(--sp-text);padding:2px 4px`,n.textContent=FH(t),e.appendChild(n)}function tU(e,t){let n=document.createElement(`td`);n.style.cssText=`text-align:center;vertical-align:middle;padding:2px`;let r=document.createElement(`span`);r.className=TH(),r.textContent=`×`,r.title=`Remove position`,r.style.cursor=`pointer`,r.addEventListener(`click`,t),n.appendChild(r),e.appendChild(n)}function nU(e,t){let n=document.createElement(`input`);return n.type=`number`,n.className=vH(),n.value=String(e),n.addEventListener(`change`,()=>{let e=Number.parseFloat(n.value);Number.isNaN(e)||t(e)}),n}function rU(e,t,n,r){let i=document.createElement(`div`);i.style.cssText=`display:flex;gap:8px;margin-top:6px;flex-wrap:wrap`,iU(i,t,n,r),e.appendChild(i)}function iU(e,t,n,r){let i=new Set(t),a=KH.filter(e=>!i.has(e));if(!a.length)return;let o=document.createElement(`div`);o.style.cssText=`display:flex;align-items:center;gap:4px`;let s=document.createElement(`select`);s.className=`re-field-select`,s.style.cssText=`min-width:80px;font-size:11px;padding:4px 6px`;for(let e of a){let t=document.createElement(`option`);t.value=String(e),t.textContent=FH(e),s.appendChild(t)}let c=document.createElement(`button`);c.className=`sp-btn sp-btn--sm sp-btn--outline`,c.textContent=`+ Position`,c.addEventListener(`click`,()=>{let e=Number.parseInt(s.value,10);Number.isNaN(e)||n.addPositionRow(r,e)}),o.appendChild(s),o.appendChild(c),e.appendChild(o)}function aU(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:0.25rem 0;font-size:0.8rem`;let r=document.createElement(`div`);r.className=dH();let i=document.createElement(`div`);i.className=fH(),i.textContent=`Per-Win`,i.style.minWidth=`80px`;let a=document.createElement(`input`);a.type=`number`,a.className=vH(),a.placeholder=`—`,a.addEventListener(`change`,()=>{let n=a.value.trim();e.setPointsPerWin(t,n===``?void 0:parseFloat(n))});let o=document.createElement(`div`);o.style.cssText=`font-size:0.75rem;color:var(--sp-muted)`,r.appendChild(i),r.appendChild(a),n.appendChild(r),n.appendChild(o);function s(e){let r=e.draft.awardProfiles?.[t];if(!r){n.style.display=`none`;return}let i=r.perWinPoints,s=r.pointsPerWin;if(!i&&s===void 0){n.style.display=`none`;return}if(n.style.display=``,a.disabled=e.readonly,s!==void 0&&typeof s==`number`?(a.style.display=``,o.style.display=`none`,document.activeElement!==a&&(a.value=String(s))):s===void 0?i&&(a.style.display=`none`,o.style.display=``,o.textContent=(Array.isArray(i)?i:[i]).map(e=>{let t=[];return e.participationOrders?.length&&t.push(`PO:${e.participationOrders.join(`,`)}`),e.value!==void 0&&t.push(`${e.value} pts/win`),e.limit!==void 0&&t.push(`limit: ${e.limit}`),t.join(` | `)}).join(`; `)):(a.style.display=`none`,o.style.display=``,o.textContent=`${GH(BH(s))} pts/win (complex)`),r.maxCountableMatches!==void 0){let e=typeof r.maxCountableMatches==`number`?r.maxCountableMatches:`level-keyed`;o.style.display=``;let t=o.textContent;o.textContent=t?`${t} — max countable: ${e}`:`Max countable: ${e}`}}return{element:n,update:s}}function oU(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:0.25rem 0;font-size:0.8rem`;let r=``;function i(r){let i=r.draft.awardProfiles?.[t]?.bonusPoints;if(n.innerHTML=``,!i?.length&&r.readonly){n.style.display=`none`;return}n.style.display=``;let a=document.createElement(`div`);if(a.style.cssText=`font-weight:600;color:var(--sp-text);margin-bottom:4px`,a.textContent=`Bonus Points`,n.appendChild(a),i?.length)for(let a=0;a<i.length;a++){let o=i[a],s=document.createElement(`div`);if(s.style.cssText=`display:flex;align-items:center;gap:6px;margin-bottom:4px;padding-left:0.5rem`,r.readonly){let e=o.finishingPositions.map(FH).join(`, `),t=document.createElement(`span`);t.textContent=`${e}: `,s.appendChild(t);let n=document.createElement(`span`);n.style.fontVariantNumeric=`tabular-nums`,n.textContent=typeof o.value==`number`?o.value.toLocaleString():String(o.value??`—`),s.appendChild(n)}else{let n=document.createElement(`span`);n.style.cssText=`font-size:0.75rem;color:var(--sp-muted);min-width:30px`,n.textContent=`Pos:`,s.appendChild(n);let r=document.createElement(`input`);r.type=`text`,r.className=vH(),r.style.width=`80px`,r.value=o.finishingPositions.join(`, `),r.title=`Comma-separated positions (e.g. 1, 2)`,r.addEventListener(`change`,()=>{let n=r.value.split(`,`).map(e=>Number.parseInt(e.trim(),10)).filter(e=>!Number.isNaN(e)&&e>0);n.length&&e.setBonusPointPositions(t,a,n)}),s.appendChild(r);let i=document.createElement(`span`);i.style.cssText=`font-size:0.75rem;color:var(--sp-muted)`,i.textContent=`Pts:`,s.appendChild(i);let c=document.createElement(`input`);c.type=`number`,c.className=vH(),c.value=typeof o.value==`number`?String(o.value):``,c.addEventListener(`change`,()=>{let n=Number.parseFloat(c.value);Number.isNaN(n)||e.setBonusPointValue(t,a,n)}),s.appendChild(c);let l=document.createElement(`span`);l.className=TH(),l.textContent=`×`,l.title=`Remove bonus`,l.style.cursor=`pointer`,l.addEventListener(`click`,()=>e.removeBonusPoint(t,a)),s.appendChild(l)}n.appendChild(s)}if(!r.readonly){let r=document.createElement(`button`);r.className=`sp-btn sp-btn--sm sp-btn--outline`,r.textContent=`+ Add bonus`,r.style.cssText=`margin-top:4px;margin-left:0.5rem`,r.addEventListener(`click`,()=>e.addBonusPoint(t)),n.appendChild(r)}}function a(e){let n=e.draft.awardProfiles?.[t],a=JSON.stringify(n?.bonusPoints??[]);a!==r&&(r=a,i(e))}return{element:n,update:a}}function sU(e){let t=document.createElement(`div`);t.style.cssText=`display:inline-flex;gap:0.25rem;flex-wrap:wrap;margin-bottom:0`;let n=WH(e);if(!n.length){let e=document.createElement(`span`);return e.className=`re-badge re-badge--neutral`,e.textContent=`All`,t.appendChild(e),t}for(let e of n){let n=document.createElement(`span`);n.className=`re-badge ${e.intent}`,n.textContent=e.label,t.appendChild(n)}return t}var cU=[{field:`eventTypes`,label:`Event types`,options:[`SINGLES`,`DOUBLES`,`TEAM`]},{field:`drawTypes`,label:`Draw types`,options:[`SINGLE_ELIMINATION`,`DOUBLE_ELIMINATION`,`ROUND_ROBIN`,`COMPASS`,`FEED_IN`,`AD_HOC`,`LUCKY_DRAW`]},{field:`stages`,label:`Stages`,options:[`MAIN`,`QUALIFYING`,`CONSOLATION`,`PLAY_OFF`]},{field:`levels`,label:`Levels`,options:[],isNumeric:!0}],lU=[[`maxDrawSize`,`Max draw size`],[`maxLevel`,`Max level`],[`priority`,`Priority`],[`participationOrder`,`Participation order`]];function uU(e,t){let n=document.createElement(`div`);n.style.cssText=`padding:0.25rem 0`;let r=document.createElement(`div`);r.style.cssText=`font-weight:600;font-size:0.8rem;color:var(--sp-text);margin-bottom:4px`,r.textContent=`Scope`,n.appendChild(r);let i=document.createElement(`div`);n.appendChild(i);let a=``;function o(n,r){if(n.isNumeric){let i=document.createElement(`input`);return i.type=`number`,i.min=`1`,i.placeholder=`+`,i.style.cssText=`width:36px;font-size:0.7rem;padding:2px 4px;border:1px dashed var(--sp-border);border-radius:4px;background:transparent;color:var(--sp-text);outline:none;text-align:center`,i.addEventListener(`keydown`,a=>{if(a.key===`Enter`){let a=Number.parseInt(i.value,10);!Number.isNaN(a)&&a>0&&!r.includes(a)&&(e.setProfileScope(t,n.field,[...r,a].sort((e,t)=>e-t)),i.value=``)}}),i}let i=n.options.filter(e=>!r.includes(e));if(!i.length)return;let a=document.createElement(`select`);a.style.cssText=`font-size:0.65rem;padding:2px 4px;border:1px dashed var(--sp-border);border-radius:4px;background:transparent;color:var(--sp-muted);outline:none;cursor:pointer`;let o=document.createElement(`option`);o.value=``,o.textContent=`+`,a.appendChild(o);for(let e of i){let t=document.createElement(`option`);t.value=e,t.textContent=e,a.appendChild(t)}return a.addEventListener(`change`,()=>{a.value&&e.setProfileScope(t,n.field,[...r,a.value])}),a}function s(n,r,i){let a=document.createElement(`div`);a.style.cssText=`margin-bottom:6px`;let s=document.createElement(`div`);s.style.cssText=`font-size:0.7rem;color:var(--sp-muted);margin-bottom:2px`,s.textContent=n.label,a.appendChild(s);let c=document.createElement(`div`);c.style.cssText=`display:flex;flex-wrap:wrap;gap:4px;align-items:center`;for(let a of r){let o=document.createElement(`span`);if(o.className=`re-badge re-badge--accent`,o.style.cssText=`display:inline-flex;align-items:center;gap:3px`,o.textContent=n.isNumeric?`L${a}`:String(a),!i){let i=document.createElement(`span`);i.style.cssText=`cursor:pointer;font-size:0.6rem;opacity:0.7`,i.textContent=`×`,i.addEventListener(`click`,()=>{e.setProfileScope(t,n.field,r.filter(e=>e!==a))}),o.appendChild(i)}c.appendChild(o)}if(!i){let e=o(n,r);e&&c.appendChild(e)}return a.appendChild(c),a}function c(r){i.innerHTML=``;let a=r.draft.awardProfiles?.[t];if(!a)return;let o=r.readonly;for(let e of cU){let t=a[e.field]??[];o&&!t.length||i.appendChild(s(e,t,o))}for(let[n,r]of lU){let s=a[n];if(o&&s===void 0)continue;let c=document.createElement(`div`);c.className=dH();let l=document.createElement(`div`);if(l.className=fH(),l.style.cssText=`min-width:110px;font-size:0.75rem`,l.textContent=r,c.appendChild(l),o){let e=document.createElement(`span`);e.style.cssText=`font-size:0.75rem;color:var(--sp-text)`,e.textContent=String(s),c.appendChild(e)}else{let r=document.createElement(`input`);r.type=`number`,r.className=mH(),r.style.fontSize=`0.75rem`,r.value=s===void 0?``:String(s),r.placeholder=`—`,r.addEventListener(`change`,()=>{let i=r.value.trim();e.setProfileField(t,n,i?Number.parseInt(i,10):void 0)}),c.appendChild(r)}i.appendChild(c)}let c=i.children.length>0;n.style.display=c?``:`none`}function l(e){let n=e.draft.awardProfiles?.[t],r=cU.map(e=>n?.[e.field]??[]),i=lU.map(([e])=>n?.[e]),o=JSON.stringify([r,i,e.readonly]);o!==a&&(a=o,c(e))}return{element:n,update:l}}function dU(e,t){let n=document.createElement(`div`);n.className=yH();let r=document.createElement(`div`);r.className=bH();let i=document.createElement(`span`);i.className=cH(),i.style.flexShrink=`0`,r.appendChild(i);let a=document.createElement(`input`);a.type=`text`,a.className=xH(),a.addEventListener(`click`,e=>e.stopPropagation()),a.addEventListener(`change`,()=>e.setProfileName(t,a.value)),r.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`flex-grow:1;display:inline-flex;gap:0.25rem;flex-wrap:wrap`,r.appendChild(o);let s=document.createElement(`span`);s.style.cssText=`font-size:0.75rem;color:var(--sp-muted);white-space:nowrap;flex-shrink:0`,r.appendChild(s);let c=document.createElement(`div`);c.className=CH();let l=document.createElement(`button`);l.className=wH(),l.textContent=`⎘`,l.title=`Duplicate profile`,l.addEventListener(`click`,n=>{n.stopPropagation(),e.duplicateProfile(t)});let u=document.createElement(`button`);u.className=TH(),u.textContent=`✕`,u.title=`Delete profile`,u.addEventListener(`click`,n=>{n.stopPropagation(),e.removeProfile(t)}),c.appendChild(l),c.appendChild(u),r.appendChild(c),r.addEventListener(`click`,()=>e.toggleProfile(t)),n.appendChild(r);let d=document.createElement(`div`);d.className=SH();let f=document.createElement(`div`);f.style.cssText=`font-weight:600;font-size:0.85rem;color:var(--sp-text);margin-bottom:6px`,d.appendChild(f);let p=YH(e,t);d.appendChild(p.element);let m=aU(e,t);d.appendChild(m.element);let h=oU(e,t);d.appendChild(h.element);let g=uU(e,t);d.appendChild(g.element);let _=document.createElement(`div`);_.style.cssText=`padding:0.25rem 0;font-size:0.75rem;color:var(--sp-muted)`,d.appendChild(_),n.appendChild(d);function v(e){let r=e.draft.awardProfiles?.[t];if(!r){n.style.display=`none`;return}n.style.display=``;let l=e.expandedProfiles.has(t),u=e.readonly;i.textContent=l?`▼`:`▶`;let v=r.profileName||`Profile ${t+1}`;document.activeElement!==a&&(a.value=v),a.title=v,a.disabled=u,o.innerHTML=``;let y=sU(r);if(y.style.flexGrow=`1`,o.appendChild(y),s.textContent=l?``:UH(r),c.style.display=u?`none`:`flex`,d.style.display=l?``:`none`,l){f.textContent=v,p.update(e),m.update(e),h.update(e),g.update(e);let t=[];r.requireWinForPoints!==void 0&&t.push(`requireWin: ${r.requireWinForPoints}`),r.requireWinFirstRound!==void 0&&t.push(`requireWinR1: ${r.requireWinFirstRound}`),_.textContent=t.join(` | `),_.style.display=t.length?``:`none`}}return{element:n,update:v}}function fU(e,t){let n=document.createElement(`div`);n.className=DH();let r=MH(e),i=AH(e),a=kH(e),o=[{id:`metadata`,label:`Metadata`},{id:`awardProfiles`,label:`Award Profiles`,countFn:e=>e.draft.awardProfiles?.length??0},{id:`qualityWinProfiles`,label:`Quality Win Profiles`,countFn:e=>e.draft.qualityWinProfiles?.length??0},{id:`aggregationRules`,label:`Aggregation Rules`}],s=[];for(let t of o){let o=document.createElement(`div`);o.className=oH();let c=document.createElement(`div`);c.className=sH();let l=document.createElement(`span`);l.className=cH();let u=document.createElement(`span`);u.textContent=t.label;let d=document.createElement(`span`);d.className=lH(),c.appendChild(l),c.appendChild(u),c.appendChild(d),c.addEventListener(`click`,()=>e.toggleSection(t.id));let f=document.createElement(`div`);f.className=uH(),t.id===`metadata`&&f.appendChild(r.element),t.id===`qualityWinProfiles`&&f.appendChild(i.element),t.id===`aggregationRules`&&f.appendChild(a.element),o.appendChild(c),o.appendChild(f),n.appendChild(o),s.push({id:t.id,chevron:l,countEl:d,bodyEl:f})}let c=[],l=-1,u=``,d=null;function f(e,t){for(let n=0;n<o.length;n++){let r=o[n],i=s[n],a=e.has(r.id);if(i.chevron.textContent=a?`▼`:`▶`,i.bodyEl.style.display=a?`block`:`none`,r.countFn){let e=r.countFn(t);i.countEl.textContent=e?`(${e})`:``}}}function p(t,n){let r=s[1].bodyEl;r.innerHTML=``,c=[];let i=t.draft.awardProfiles??[],a=0;for(let t=0;t<i.length;t++){let o=i[t];if(n&&![o.profileName??``,...o.eventTypes??[],...o.stages??[],...(o.levels??[]).map(e=>`L${e}`),...o.drawTypes??[]].join(` `).toLowerCase().includes(n))continue;let s=dU(e,t);c.push(s),r.appendChild(s.element),a++}if(!a){let e=document.createElement(`div`);e.className=EH(),e.textContent=n?`No profiles match filter`:`No award profiles defined`,r.appendChild(e)}t.readonly||(d=document.createElement(`button`),d.className=`sp-btn sp-btn--sm sp-btn--outline re-add-btn`,d.textContent=`+ Add Profile`,d.addEventListener(`click`,()=>e.addProfile()),r.appendChild(d))}return{element:n,update:e=>{let{draft:t,expandedSections:n,profileFilter:o}=e;if(f(n,e),n.has(`metadata`)&&r.update(e),n.has(`awardProfiles`)){let n=t.awardProfiles?.length??0,r=o.toLowerCase();(n!==l||r!==u)&&(l=n,u=r,p(e,r));for(let t of c)t.update(e);d&&(d.style.display=e.readonly?`none`:``)}n.has(`qualityWinProfiles`)&&i.update(e),n.has(`aggregationRules`)&&a.update(e)}}}var pU=class e{constructor(e){this.container=null,this.store=new aH(e),this.panel=fU(this.store,e),this.unsubscribe=this.store.subscribe(e=>{this.panel.update(e)}),this.panel.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.panel.element)}destroy(){this.unsubscribe(),this.container&&this.panel.element.parentNode===this.container&&this.panel.element.remove(),this.container=null}getData(){return this.store.getData()}setData(e){this.store.setData(e)}getStore(){return this.store}static createEditorInstance(t){let n=new e({initialPolicy:t.initialData,onChange:e=>t.onChange(e),readonly:t.readonly});return{element:n.panel.element,setData(e){n.setData(e)},getData(){return n.getData()},destroy(){n.destroy()}}}};function mU(e){return hU[e]??e}var hU={"SET3-S:6/TB7":`Best of 3 TB sets`,"SET3-S:6/TB7-F:TB10":`2 TB sets, MTB10`,"SET3-S:6/TB7-F:TB7":`2 TB sets, MTB7`,"SET3-S:4NOAD-F:TB7":`2 short sets (4, NOAD), MTB7`,"SET3-S:4/TB7":`Best of 3 short sets (4)`,"SET3-S:4/TB7-F:TB7":`2 short sets (4), MTB7`,"SET3-S:4/TB7-F:TB10":`2 short sets (4), MTB10`,"SET3-S:4/TB5@3":`3 short sets (4), TB5@3`,"SET1-S:8/TB7":`8-game pro-set, TB7`,"SET1-S:8/TB7@7":`8-game pro-set, TB7@7`,"SET1-S:5/TB9@4":`1 set to 5, TB9@4`,"SET1-S:6/TB7":`1 TB set`,"SET1-S:6NOAD":`1 set to 6, NOAD`,"SET1-S:4/TB7":`1 short set (4), TB7`,"SET1-S:4/TB5@3":`1 short set (4), TB5@3`,"SET1-S:4NOAD":`1 short set (4), NOAD`,"SET3-S:TB10":`Best of 3 TB10 games`,"SET1-S:T20":`Timed 20 min`,"SET1-S:TB10":`1 TB10 game`,"SET5-S:6/TB7":`Best of 5 TB sets`,"SET5-S:6/TB7-F:TB10":`5 sets, MTB10`,"SET1-S:6/TB10":`1 set, TB10`,"SET1-S:8":`Pro-set to 8`,"SET1-S:10":`Pro-set to 10`,"SET1-S:T7":`TB7 only`,"SET1-S:T21":`TB21 only`};function gU(){return{allowModificationWhenMatchUpsScheduled:{courts:!1,venues:!1},defaultTimes:{averageTimes:[{categoryNames:[],minutes:{default:90}}],recoveryTimes:[{minutes:{default:60}}]},defaultDailyLimits:{SINGLES:2,DOUBLES:2,total:3},matchUpAverageTimes:[],matchUpRecoveryTimes:[],matchUpDailyLimits:[]}}function $(e){return structuredClone(e)}var _U=class{constructor(e){this.listeners=new Set,this.config=e,this.state={draft:$(e.initialPolicy??gU()),expandedSections:new Set([`modificationFlags`,`dailyLimits`,`defaultTimes`,`averageTimes`,`recoveryTimes`]),dirty:!1}}getState(){return this.state}getData(){return $(this.state.draft)}setData(e){this.state={...this.state,draft:$(e),dirty:!1},this.emit()}toggleSection(e){let t=new Set(this.state.expandedSections);t.has(e)?t.delete(e):t.add(e),this.state={...this.state,expandedSections:t},this.emit()}setModificationFlag(e,t){let n=$(this.state.draft);n.allowModificationWhenMatchUpsScheduled||={courts:!1,venues:!1},n.allowModificationWhenMatchUpsScheduled[e]=t,this.commitDraft(n)}setDailyLimit(e,t){let n=$(this.state.draft);n.defaultDailyLimits||={},n.defaultDailyLimits[e]=t,this.commitDraft(n)}setDefaultAverageTime(e,t,n){let r=$(this.state.draft);r.defaultTimes||={},r.defaultTimes.averageTimes||(r.defaultTimes.averageTimes=[{categoryNames:[],minutes:{default:90}}]);let i=r.defaultTimes.averageTimes[e];i&&(t===`DOUBLES`?n===void 0?delete i.minutes.DOUBLES:i.minutes.DOUBLES=n:i.minutes.default=n??0,this.commitDraft(r))}setDefaultRecoveryTime(e,t,n){let r=$(this.state.draft);r.defaultTimes||={},r.defaultTimes.recoveryTimes||(r.defaultTimes.recoveryTimes=[{minutes:{default:60}}]);let i=r.defaultTimes.recoveryTimes[e];i&&(t===`DOUBLES`?n===void 0?delete i.minutes.DOUBLES:i.minutes.DOUBLES=n:i.minutes.default=n??0,this.commitDraft(r))}addAverageFormatGroup(){let e=$(this.state.draft);e.matchUpAverageTimes||=[],e.matchUpAverageTimes.push({matchUpFormatCodes:[],averageTimes:[{categoryNames:[],minutes:{default:60}}]}),this.commitDraft(e)}removeAverageFormatGroup(e){let t=$(this.state.draft);t.matchUpAverageTimes&&(t.matchUpAverageTimes.splice(e,1),this.commitDraft(t))}setAverageFormatCodes(e,t){let n=$(this.state.draft),r=n.matchUpAverageTimes?.[e];r&&(r.matchUpFormatCodes=t,this.commitDraft(n))}setAverageTime(e,t,n,r){let i=$(this.state.draft),a=i.matchUpAverageTimes?.[e]?.averageTimes?.[t];a&&(n===`DOUBLES`?r===void 0?delete a.minutes.DOUBLES:a.minutes.DOUBLES=r:a.minutes.default=r??0,this.commitDraft(i))}addAverageCategoryOverride(e){let t=$(this.state.draft),n=t.matchUpAverageTimes?.[e];n&&(n.averageTimes.push({categoryTypes:[],minutes:{default:60}}),this.commitDraft(t))}removeAverageCategoryOverride(e,t){let n=$(this.state.draft),r=n.matchUpAverageTimes?.[e];r&&(r.averageTimes.splice(t,1),this.commitDraft(n))}setAverageOverrideCategories(e,t,n,r){let i=$(this.state.draft),a=i.matchUpAverageTimes?.[e]?.averageTimes?.[t];a&&(n===`categoryNames`?(delete a.categoryTypes,a.categoryNames=r):(delete a.categoryNames,a.categoryTypes=r),this.commitDraft(i))}addRecoveryFormatGroup(){let e=$(this.state.draft);e.matchUpRecoveryTimes||=[],e.matchUpRecoveryTimes.push({matchUpFormatCodes:[],recoveryTimes:[{categoryNames:[],minutes:{default:30}}]}),this.commitDraft(e)}removeRecoveryFormatGroup(e){let t=$(this.state.draft);t.matchUpRecoveryTimes&&(t.matchUpRecoveryTimes.splice(e,1),this.commitDraft(t))}setRecoveryFormatCodes(e,t){let n=$(this.state.draft),r=n.matchUpRecoveryTimes?.[e];r&&(r.matchUpFormatCodes=t,this.commitDraft(n))}setRecoveryTime(e,t,n,r){let i=$(this.state.draft),a=i.matchUpRecoveryTimes?.[e]?.recoveryTimes?.[t];a&&(n===`DOUBLES`?r===void 0?delete a.minutes.DOUBLES:a.minutes.DOUBLES=r:a.minutes.default=r??0,this.commitDraft(i))}addRecoveryCategoryOverride(e){let t=$(this.state.draft),n=t.matchUpRecoveryTimes?.[e];n&&(n.recoveryTimes.push({categoryTypes:[],minutes:{default:30}}),this.commitDraft(t))}removeRecoveryCategoryOverride(e,t){let n=$(this.state.draft),r=n.matchUpRecoveryTimes?.[e];r&&(r.recoveryTimes.splice(t,1),this.commitDraft(n))}setRecoveryOverrideCategories(e,t,n,r){let i=$(this.state.draft),a=i.matchUpRecoveryTimes?.[e]?.recoveryTimes?.[t];a&&(n===`categoryNames`?(delete a.categoryTypes,a.categoryNames=r):(delete a.categoryNames,a.categoryTypes=r),this.commitDraft(i))}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}commitDraft(e){this.state={...this.state,draft:e,dirty:!0},this.emit(),this.config.onChange?.($(e))}emit(){for(let e of this.listeners)e(this.state)}},vU=()=>`se-section`,yU=()=>`se-section-header`,bU=()=>`se-section-chevron`,xU=()=>`se-section-body`,SU=()=>`se-field-row`,CU=()=>`se-field-label`,wU=()=>`se-field-input`,TU=()=>`se-field-unit`,EU=()=>`se-checkbox-row`,DU=()=>`se-format-group`,OU=()=>`se-format-group-header`,kU=()=>`se-format-group-label`,AU=()=>`se-tag-picker`,jU=()=>`sp-chip`,MU=()=>`sp-chip__remove`,NU=()=>`se-tag-add-wrap`,PU=()=>`sp-btn-icon`,FU=()=>`se-override-row`,IU=()=>`se-override-categories`,LU=()=>`se-override-remove`,RU=()=>`sp-btn sp-btn--sm sp-btn--outline se-add-btn`,zU=()=>`sp-btn-icon sp-btn-icon--danger`,BU=()=>`se-editor`;function VU(e){let t=document.createElement(`div`),n=document.createElement(`div`);n.className=EU();let r=document.createElement(`input`);r.type=`checkbox`,r.id=`se-mod-courts`;let i=document.createElement(`label`);i.htmlFor=`se-mod-courts`,i.textContent=`Allow court modifications when matchUps scheduled`,r.addEventListener(`change`,()=>{e.setModificationFlag(`courts`,r.checked)}),n.appendChild(r),n.appendChild(i);let a=document.createElement(`div`);a.className=EU();let o=document.createElement(`input`);o.type=`checkbox`,o.id=`se-mod-venues`;let s=document.createElement(`label`);s.htmlFor=`se-mod-venues`,s.textContent=`Allow venue modifications when matchUps scheduled`,o.addEventListener(`change`,()=>{e.setModificationFlag(`venues`,o.checked)}),a.appendChild(o),a.appendChild(s),t.appendChild(n),t.appendChild(a);function c(e){let t=e.draft.allowModificationWhenMatchUpsScheduled;r.checked=t?.courts??!1,o.checked=t?.venues??!1}return{element:t,update:c}}var HU=`is-success`,UU=`is-danger`;function WU(e){if(e===``)return!0;let t=parseInt(e,10);return!isNaN(t)&&t>=0&&String(t)===e.trim()}function GU(e,t){if(t===``){e.classList.remove(HU,UU);return}WU(t)?(e.classList.remove(UU),e.classList.add(HU)):(e.classList.remove(HU),e.classList.add(UU))}function KU(e){let t=document.createElement(`div`),n=[];for(let[r,i]of[[`SINGLES`,`Singles limit`],[`DOUBLES`,`Doubles limit`],[`total`,`Total limit`]]){let a=document.createElement(`div`);a.className=SU();let o=document.createElement(`div`);o.className=CU(),o.textContent=i;let s=document.createElement(`input`);s.type=`text`,s.className=wU(),s.placeholder=`0`,s.addEventListener(`input`,()=>{GU(s,s.value)}),s.addEventListener(`change`,()=>{let t=parseInt(s.value,10);!isNaN(t)&&t>=0&&e.setDailyLimit(r,t)}),a.appendChild(o),a.appendChild(s),t.appendChild(a),n.push({key:r,label:i,input:s})}function r(e){let t=e.draft.defaultDailyLimits;for(let e of n){let n=t?.[e.key];document.activeElement!==e.input&&(e.input.value=n===void 0?``:String(n))}}return{element:t,update:r}}var qU=`is-success`,JU=`is-danger`;function YU(e){if(e===``)return!0;let t=parseInt(e,10);return!isNaN(t)&&t>=0&&String(t)===e.trim()}function XU(e,t,n){if(t===``&&n){e.classList.remove(qU,JU);return}YU(t)&&(t!==``||n)?(e.classList.remove(JU),e.classList.add(qU)):(e.classList.remove(qU),e.classList.add(JU))}function ZU(e){let t=document.createElement(`div`),n=document.createElement(`div`);n.style.cssText=`font-size:11px;font-weight:700;color:var(--sp-muted);margin-bottom:6px;`,n.textContent=`Default Average Times`,t.appendChild(n);let r=QU(`Default`,`min`,!1),i=QU(`Doubles override`,`min`,!0);t.appendChild(r.row),t.appendChild(i.row),r.input.addEventListener(`input`,()=>{XU(r.input,r.input.value,!1)}),r.input.addEventListener(`change`,()=>{let t=parseInt(r.input.value,10);!isNaN(t)&&t>=0&&e.setDefaultAverageTime(0,`default`,t)}),i.input.addEventListener(`input`,()=>{XU(i.input,i.input.value,!0)}),i.input.addEventListener(`change`,()=>{let t=i.input.value.trim();if(t===``||t===`-`)e.setDefaultAverageTime(0,`DOUBLES`,void 0);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&e.setDefaultAverageTime(0,`DOUBLES`,n)}});let a=document.createElement(`div`);a.style.height=`12px`,t.appendChild(a);let o=document.createElement(`div`);o.style.cssText=`font-size:11px;font-weight:700;color:var(--sp-muted);margin-bottom:6px;`,o.textContent=`Default Recovery Times`,t.appendChild(o);let s=QU(`Default`,`min`,!1),c=QU(`Doubles override`,`min`,!0);t.appendChild(s.row),t.appendChild(c.row),s.input.addEventListener(`input`,()=>{XU(s.input,s.input.value,!1)}),s.input.addEventListener(`change`,()=>{let t=parseInt(s.input.value,10);!isNaN(t)&&t>=0&&e.setDefaultRecoveryTime(0,`default`,t)}),c.input.addEventListener(`input`,()=>{XU(c.input,c.input.value,!0)}),c.input.addEventListener(`change`,()=>{let t=c.input.value.trim();if(t===``||t===`-`)e.setDefaultRecoveryTime(0,`DOUBLES`,void 0);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&e.setDefaultRecoveryTime(0,`DOUBLES`,n)}});function l(e){let t=e.draft.defaultTimes?.averageTimes?.[0];document.activeElement!==r.input&&(r.input.value=t?String(t.minutes.default):``),document.activeElement!==i.input&&(i.input.value=t?.minutes.DOUBLES===void 0?``:String(t.minutes.DOUBLES)),i.input.placeholder=`—`;let n=e.draft.defaultTimes?.recoveryTimes?.[0];document.activeElement!==s.input&&(s.input.value=n?String(n.minutes.default):``),document.activeElement!==c.input&&(c.input.value=n?.minutes.DOUBLES===void 0?``:String(n.minutes.DOUBLES)),c.input.placeholder=`—`}return{element:t,update:l}}function QU(e,t,n){let r=document.createElement(`div`);r.className=SU();let i=document.createElement(`div`);i.className=CU(),i.textContent=e;let a=document.createElement(`input`);a.type=`text`,a.className=wU(),a.placeholder=n?`—`:`0`;let o=document.createElement(`div`);return o.className=TU(),o.textContent=t,r.appendChild(i),r.appendChild(a),r.appendChild(o),{row:r,input:a}}var $U=`is-success`,eW=`is-danger`;function tW(e){if(e===``)return!0;let t=parseInt(e,10);return!isNaN(t)&&t>=0&&String(t)===e.trim()}function nW(e,t,n){if(t===``&&n){e.classList.remove($U,eW);return}tW(t)&&(t!==``||n)?(e.classList.remove(eW),e.classList.add($U)):(e.classList.remove($U),e.classList.add(eW))}function rW(e){let t=document.createElement(`div`);t.className=DU();let n=document.createElement(`div`);n.className=OU();let r=document.createElement(`div`);r.style.flex=`1`;let i=document.createElement(`div`);i.className=kU(),i.textContent=`Formats`,r.appendChild(i);let a=document.createElement(`div`);a.className=AU();for(let t of e.formatCodes){let n=document.createElement(`span`);n.className=jU(),n.title=`${t} — click to edit`;let r=document.createElement(`span`);r.textContent=mU(t),n.addEventListener(`click`,()=>{Da({existingMatchUpFormat:t,callback:n=>{if(!n||n===t)return;let r=e.formatCodes.map(e=>e===t?n:e);e.onFormatCodesChange(r)}})});let i=document.createElement(`span`);i.className=MU(),i.textContent=`×`,i.addEventListener(`click`,n=>{n.stopPropagation(),e.onFormatCodesChange(e.formatCodes.filter(e=>e!==t))}),n.appendChild(r),n.appendChild(i),a.appendChild(n)}let o=document.createElement(`div`);o.className=NU();let s=document.createElement(`button`);s.className=PU(),s.textContent=`+`,s.type=`button`,s.title=`Add format code`,s.addEventListener(`click`,t=>{t.stopPropagation(),Da({existingMatchUpFormat:`SET3-S:6/TB7`,callback:t=>{t&&!e.formatCodes.includes(t)&&e.onFormatCodesChange([...e.formatCodes,t])}})}),o.appendChild(s),a.appendChild(o),r.appendChild(a);let c=document.createElement(`button`);c.className=zU(),c.textContent=`×`,c.type=`button`,c.title=`Remove format group`,c.addEventListener(`click`,()=>e.onRemoveGroup()),n.appendChild(r),n.appendChild(c),t.appendChild(n);for(let n=0;n<e.overrides.length;n++){let r=e.overrides[n],i=document.createElement(`div`);i.className=FU();let a=document.createElement(`div`);a.className=`${IU()}${r.isDefault?` all`:``}`,a.textContent=r.categoryLabel;let o=document.createElement(`input`);o.type=`text`,o.className=wU(),o.value=String(r.defaultMinutes),o.placeholder=`0`;let s=n;o.addEventListener(`input`,()=>{nW(o,o.value,!1)}),o.addEventListener(`change`,()=>{let t=parseInt(o.value,10);!isNaN(t)&&t>=0&&e.onTimeChange(s,`default`,t)});let c=document.createElement(`span`);c.className=TU(),c.textContent=`min`;let l=document.createElement(`span`);l.style.cssText=`font-size:11px;color:var(--sp-muted);margin-left:8px;`,l.textContent=`Doubles:`;let u=document.createElement(`input`);if(u.type=`text`,u.className=wU(),u.value=r.doublesMinutes===void 0?``:String(r.doublesMinutes),u.placeholder=`—`,u.addEventListener(`input`,()=>{nW(u,u.value,!0)}),u.addEventListener(`change`,()=>{let t=u.value.trim();if(t===``||t===`-`)e.onTimeChange(s,`DOUBLES`,void 0);else{let n=parseInt(t,10);!isNaN(n)&&n>=0&&e.onTimeChange(s,`DOUBLES`,n)}}),i.appendChild(a),i.appendChild(o),i.appendChild(c),i.appendChild(l),i.appendChild(u),!r.isDefault){let t=document.createElement(`span`);t.className=LU(),t.textContent=`×`,t.addEventListener(`click`,()=>e.onRemoveOverride(s)),i.appendChild(t)}t.appendChild(i)}let l=document.createElement(`button`);return l.className=RU(),l.textContent=`+ Add Override`,l.type=`button`,l.addEventListener(`click`,()=>e.onAddOverride()),t.appendChild(l),t}function iW(e,t){let n=document.createElement(`div`),r=document.createElement(`div`);n.appendChild(r);let i=document.createElement(`button`);i.className=RU(),i.textContent=`+ Add Format Group`,i.type=`button`,i.addEventListener(`click`,()=>e.addAverageFormatGroup()),n.appendChild(i);function a(n){r.innerHTML=``;let i=n.draft.matchUpAverageTimes??[];for(let n=0;n<i.length;n++){let a=i[n],o=a.averageTimes.map((e,t)=>{let n=e.categoryTypes??e.categoryNames??[];return{categoryLabel:n.length===0&&t===0?`All categories`:n.join(`, `)||`All categories`,isDefault:n.length===0&&t===0,defaultMinutes:e.minutes.default,doublesMinutes:e.minutes.DOUBLES}}),s=n,c=rW({formatCodes:a.matchUpFormatCodes,overrides:o,availableFormats:t.matchUpFormatCodes??aW(),onFormatCodesChange:t=>e.setAverageFormatCodes(s,t),onTimeChange:(t,n,r)=>e.setAverageTime(s,t,n,r),onAddOverride:()=>e.addAverageCategoryOverride(s),onRemoveOverride:t=>e.removeAverageCategoryOverride(s,t),onRemoveGroup:()=>e.removeAverageFormatGroup(s)});r.appendChild(c)}if(i.length===0){let e=document.createElement(`div`);e.style.cssText=`font-size:12px;color:var(--sp-muted);padding:8px 0;`,e.textContent=`No format-specific average times configured. Add a format group to set per-format times.`,r.appendChild(e)}}return{element:n,update:a}}function aW(){return[`SET3-S:6/TB7`,`SET3-S:6/TB7-F:TB10`,`SET3-S:6/TB7-F:TB7`,`SET3-S:4NOAD-F:TB7`,`SET3-S:4/TB7`,`SET3-S:4/TB7-F:TB7`,`SET3-S:4/TB7-F:TB10`,`SET3-S:4/TB5@3`,`SET1-S:8/TB7`,`SET1-S:8/TB7@7`,`SET1-S:5/TB9@4`,`SET1-S:6/TB7`,`SET1-S:6NOAD`,`SET1-S:4/TB7`,`SET1-S:4/TB5@3`,`SET1-S:4NOAD`,`SET3-S:TB10`,`SET1-S:T20`,`SET1-S:TB10`]}function oW(e,t){let n=document.createElement(`div`),r=document.createElement(`div`);n.appendChild(r);let i=document.createElement(`button`);i.className=RU(),i.textContent=`+ Add Format Group`,i.type=`button`,i.addEventListener(`click`,()=>e.addRecoveryFormatGroup()),n.appendChild(i);function a(n){r.innerHTML=``;let i=n.draft.matchUpRecoveryTimes??[];for(let n=0;n<i.length;n++){let a=i[n],o=a.recoveryTimes.map((e,t)=>{let n=e.categoryTypes??e.categoryNames??[];return{categoryLabel:n.length===0&&t===0?`All categories`:n.join(`, `)||`All categories`,isDefault:n.length===0&&t===0,defaultMinutes:e.minutes.default,doublesMinutes:e.minutes.DOUBLES}}),s=n,c=rW({formatCodes:a.matchUpFormatCodes,overrides:o,availableFormats:t.matchUpFormatCodes??sW(),onFormatCodesChange:t=>e.setRecoveryFormatCodes(s,t),onTimeChange:(t,n,r)=>e.setRecoveryTime(s,t,n,r),onAddOverride:()=>e.addRecoveryCategoryOverride(s),onRemoveOverride:t=>e.removeRecoveryCategoryOverride(s,t),onRemoveGroup:()=>e.removeRecoveryFormatGroup(s)});r.appendChild(c)}if(i.length===0){let e=document.createElement(`div`);e.style.cssText=`font-size:12px;color:var(--sp-muted);padding:8px 0;`,e.textContent=`No format-specific recovery times configured. Add a format group to set per-format recovery.`,r.appendChild(e)}}return{element:n,update:a}}function sW(){return[`SET3-S:6/TB7`,`SET3-S:6/TB7-F:TB10`,`SET3-S:6/TB7-F:TB7`,`SET3-S:4NOAD-F:TB7`,`SET3-S:4/TB7`,`SET3-S:4/TB7-F:TB7`,`SET3-S:4/TB7-F:TB10`,`SET3-S:4/TB5@3`,`SET1-S:8/TB7`,`SET1-S:8/TB7@7`,`SET1-S:5/TB9@4`,`SET1-S:6/TB7`,`SET1-S:6NOAD`,`SET1-S:4/TB7`,`SET1-S:4/TB5@3`,`SET1-S:4NOAD`,`SET3-S:TB10`,`SET1-S:T20`,`SET1-S:TB10`]}function cW(e,t){let n=document.createElement(`div`);n.className=BU();let r=[{id:`modificationFlags`,label:`Modification Flags`,factory:()=>VU(e)},{id:`dailyLimits`,label:`Daily Limits`,factory:()=>KU(e)},{id:`defaultTimes`,label:`Default Times`,factory:()=>ZU(e)},{id:`averageTimes`,label:`Match Average Times`,factory:()=>iW(e,t)},{id:`recoveryTimes`,label:`Match Recovery Times`,factory:()=>oW(e,t)}],i=[];for(let t of r){let r=document.createElement(`div`);r.className=vU();let a=document.createElement(`div`);a.className=yU();let o=document.createElement(`span`);o.className=bU();let s=document.createElement(`span`);s.textContent=t.label,a.appendChild(o),a.appendChild(s),a.addEventListener(`click`,()=>e.toggleSection(t.id));let c=document.createElement(`div`);c.className=xU();let l=t.factory();c.appendChild(l.element),r.appendChild(a),r.appendChild(c),n.appendChild(r),i.push({id:t.id,chevron:o,bodyEl:c,inner:l})}function a(e){for(let t of i){let n=e.expandedSections.has(t.id);t.chevron.textContent=n?`▼`:`▶`,t.bodyEl.style.display=n?`block`:`none`,n&&t.inner.update(e)}}return{element:n,update:a}}var lW=class e{constructor(e){this.container=null,this.store=new _U(e),this.panel=cW(this.store,e),this.unsubscribe=this.store.subscribe(e=>{this.panel.update(e)}),this.panel.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.panel.element)}destroy(){this.unsubscribe(),this.container&&this.panel.element.parentNode===this.container&&this.container.removeChild(this.panel.element),this.container=null}getData(){return this.store.getData()}setData(e){this.store.setData(e)}getStore(){return this.store}static createEditorInstance(t){let n=new e({initialPolicy:t.initialData,onChange:e=>t.onChange(e)});return{element:n.panel.element,setData(e){n.setData(e)},getData(){return n.getData()},destroy(){n.destroy()}}}};function uW(e,t){let n=new lW(e);return n.render(t),n}var dW=()=>`pc-layout`,fW=()=>`pc-panel`,pW=()=>`pc-panel-header`,mW=()=>`pc-panel-title`,hW=()=>`pc-panel-meta`,gW=()=>`pc-toolbar`,_W=()=>`pc-input`,vW=()=>`pc-select`,yW=()=>`pc-catalog`,bW=()=>`pc-group`,xW=()=>`pc-group-header`,SW=()=>`pc-group-chevron`,CW=()=>`pc-group-body`,wW=()=>`pc-card`,TW=()=>`pc-card-title`,EW=()=>`pc-card-meta`,DW=()=>`pc-type-badge`,OW=()=>`pc-editor`,kW=()=>`pc-editor-header`,AW=()=>`pc-editor-header-left`,jW=()=>`pc-editor-actions`,MW=()=>`sp-btn sp-btn--sm`,NW=()=>`sp-btn sp-btn--sm sp-btn--accent`,PW=()=>`pc-dirty-dot`,FW=()=>`pc-editor-body`,IW=()=>`pc-empty`,LW=()=>`pc-json-editor`,RW=()=>`pc-json-error`;function zW(e){let t=document.createElement(`div`);t.className=dW(),t.appendChild(e.catalogPanel.element),t.appendChild(e.editorShell.element);function n(t){e.catalogPanel.update(t),e.editorShell.update(t)}return{element:t,update:n}}var BW=`scheduling`,VW=`scoring`,HW=`seeding`,UW=`draws`,WW=`avoidance`,GW=`feedIn`,KW=`progression`,qW=`roundNaming`,JW=`positionActions`,YW=`matchUpActions`,XW=`roundRobinTally`,ZW=`rankingPoints`,QW=`competitiveBands`,$W=`voluntaryConsolation`,eG=`participant`,tG=`display`,nG=`audit`,rG=`Tournament Operations`,iG=`Scoring & Results`,aG=`Ranking Points`,oG=`Draw Configuration`,sG=`Participants`,cG=`Display & Audit`,lG=(e,t,n,r,i)=>({policyType:e,label:t,description:n,group:r,hasEditor:i}),uG=[lG(BW,`Scheduling`,`Match scheduling, average times, recovery times, daily limits`,rG,!0),lG(JW,`Position Actions`,`Allowed position actions (alternates, walkovers, withdrawals)`,rG,!1),lG(YW,`MatchUp Actions`,`Allowed matchUp status transitions and actions`,rG,!1),lG(WW,`Avoidance`,`Draw placement avoidance rules (club, nationality, region)`,rG,!1),lG(VW,`Scoring`,`Score entry validation and completion rules`,iG,!1),lG(XW,`Round Robin Tally`,`Round-robin group standing calculation method`,iG,!1),lG(ZW,`Ranking Points`,`Point allocation by draw size, round, and result`,aG,!0),lG(QW,`Competitive Bands`,`Rating/ranking band definitions for competitive grouping`,iG,!1),lG(UW,`Draws`,`Draw generation rules and structure options`,oG,!1),lG(HW,`Seeding`,`Seeding thresholds and placement rules by draw size`,oG,!1),lG(GW,`Feed-In`,`Feed-in consolation structure rules`,oG,!1),lG(KW,`Progression`,`Player progression between draw structures`,oG,!1),lG($W,`Voluntary Consolation`,`Voluntary consolation entry rules`,oG,!1),lG(qW,`Round Naming`,`Custom round name labels (QF, SF, F, etc.)`,oG,!1),lG(eG,`Participant`,`Participant display and data rules`,sG,!1),lG(tG,`Display`,`Client display configuration (public vs admin views)`,cG,!1),lG(nG,`Audit`,`Audit trail and change logging configuration`,cG,!1)];function dG(e){return uG.find(t=>t.policyType===e)}function fG(e){return e===`rankingPoints`?iH():e===`scheduling`?gU():{}}var pG=[rG,iG,aG,oG,sG,cG];function mG(e,t){let n=t.toLowerCase().trim();return n?e.filter(e=>{let t=dG(e.policyType);return[e.name,e.description,e.policyType,t?.label??``,e.source].join(` `).toLowerCase().includes(n)}):e}function hG(e,t){let n=new Map;if(t===`type`){for(let e of pG)n.set(e,[]);for(let t of e){let e=dG(t.policyType)?.group??`Display & Audit`,r=n.get(e);r?r.push(t):n.set(e,[t])}for(let[e,t]of n)t.length===0&&n.delete(e)}else for(let t of e){let e=t.source===`builtin`?`Built-in Policies`:`User Policies`,r=n.get(e);r?r.push(t):n.set(e,[t])}return n}function gG(e){let t=document.createElement(`div`);t.className=fW(),t.style.overflowY=`auto`,t.style.scrollbarWidth=`thin`,t.style.scrollbarColor=`var(--sp-scrollbar) transparent`;let n=new Set,r=null,i=document.createElement(`div`);i.className=pW();let a=document.createElement(`div`);a.className=mW(),a.textContent=`Policy Catalog`;let o=document.createElement(`div`);o.className=hW(),i.appendChild(a),i.appendChild(o),t.appendChild(i);let s=document.createElement(`div`);s.className=gW();let c=document.createElement(`input`);c.type=`text`,c.placeholder=`Search policies...`,c.className=_W(),c.addEventListener(`input`,()=>e.onSearchChange(c.value));let l=document.createElement(`select`);l.className=vW();for(let[e,t]of[[`type`,`By Type`],[`source`,`By Source`]]){let n=document.createElement(`option`);n.value=e,n.textContent=t,l.appendChild(n)}l.addEventListener(`change`,()=>e.onGroupByChange(l.value));let u=document.createElement(`div`);u.style.cssText=`position:relative;flex-shrink:0`;let d=document.createElement(`button`);d.className=`sp-btn-icon`,d.textContent=`+`,d.title=`New policy`,d.style.cssText=`font-size:1rem;font-weight:700`;let f=document.createElement(`div`);f.style.cssText=`display:none;position:absolute;top:100%;right:0;z-index:100;min-width:180px;background:var(--sp-panel-bg);border:1px solid var(--sp-border);border-radius:12px;box-shadow:var(--sp-panel-shadow);padding:4px;margin-top:4px`;let p=uG.filter(e=>e.hasEditor);for(let t of p){let n=document.createElement(`div`);n.style.cssText=`padding:6px 10px;font-size:12px;border-radius:8px;cursor:pointer;color:var(--sp-text)`,n.textContent=t.label,n.addEventListener(`mouseenter`,()=>{n.style.background=`var(--sp-hover-bg)`}),n.addEventListener(`mouseleave`,()=>{n.style.background=``}),n.addEventListener(`click`,n=>{n.stopPropagation(),f.style.display=`none`,e.onNewPolicy?.(t.policyType)}),f.appendChild(n)}d.addEventListener(`click`,e=>{e.stopPropagation(),f.style.display=f.style.display===`none`?`block`:`none`}),document.addEventListener(`click`,()=>{f.style.display=`none`}),u.appendChild(d),u.appendChild(f),s.appendChild(c),s.appendChild(l),s.appendChild(u),t.appendChild(s);let m=document.createElement(`div`);m.className=yW(),t.appendChild(m);function h(t){r=t;let i=mG(t.catalog,t.searchQuery),a=hG(i,t.groupBy);o.textContent=`${i.length} policies`,c.value!==t.searchQuery&&(c.value=t.searchQuery),l.value!==t.groupBy&&(l.value=t.groupBy),m.innerHTML=``;for(let[i,o]of a){let a=document.createElement(`div`);a.className=bW();let s=n.has(i),c=document.createElement(`div`);c.className=xW();let l=document.createElement(`span`);l.className=SW(),l.textContent=s?`▶`:`▼`;let u=document.createElement(`span`);u.textContent=`${i} (${o.length})`,c.appendChild(l),c.appendChild(u),c.addEventListener(`click`,()=>{n.has(i)?n.delete(i):n.add(i),r&&h(r)});let d=document.createElement(`div`);d.className=CW(),s&&(d.style.display=`none`);for(let n of o){let r=document.createElement(`div`);r.className=wW(),n.id===t.selectedId&&r.classList.add(`active`),r.addEventListener(`click`,()=>e.onSelectPolicy(n.id));let i=document.createElement(`div`);i.style.cssText=`display:flex;align-items:center;gap:4px`;let a=document.createElement(`div`);if(a.className=TW(),a.style.flex=`1`,a.textContent=n.name,i.appendChild(a),e.onDuplicatePolicy){let t=document.createElement(`span`);t.style.cssText=`font-size:10px;cursor:pointer;color:var(--sp-muted);padding:2px`,t.textContent=`⎘`,t.title=`Duplicate`,t.addEventListener(`click`,t=>{t.stopPropagation(),e.onDuplicatePolicy?.(n.id)}),i.appendChild(t)}if(n.source===`user`&&e.onDeletePolicy){let t=document.createElement(`span`);t.style.cssText=`font-size:10px;cursor:pointer;color:var(--sp-muted);padding:2px`,t.textContent=`✕`,t.title=`Delete`,t.addEventListener(`click`,t=>{t.stopPropagation(),e.onDeletePolicy?.(n.id)}),i.appendChild(t)}r.appendChild(i);let o=document.createElement(`div`);o.className=EW();let s=dG(n.policyType),c=document.createElement(`span`);c.className=DW(),c.textContent=s?.label??n.policyType;let l=document.createElement(`span`);l.className=`${DW()} ${n.source}`,l.textContent=n.source,o.appendChild(c),o.appendChild(l),r.appendChild(o),d.appendChild(r)}a.appendChild(c),a.appendChild(d),m.appendChild(a)}}return{element:t,update:h}}function _G(e){return structuredClone(e)}var vG=class{constructor(e){this.listeners=new Set,this.config=e;let t=new Set((e.builtinPolicies??[]).map(e=>e.id)),n=[...e.builtinPolicies??[],...(e.userPolicies??[]).filter(e=>!t.has(e.id))];this.state={catalog:n,searchQuery:``,groupBy:`type`,selectedId:null,editorDraft:null,dirty:!1}}getState(){return this.state}getSelectedItem(){return this.state.selectedId?this.state.catalog.find(e=>e.id===this.state.selectedId)??null:null}setCatalogSearch(e){this.setState({searchQuery:e})}setCatalogGroupBy(e){this.setState({groupBy:e})}selectPolicy(e){if(this.state.selectedId===e)return;let t=this.state.catalog.find(t=>t.id===e);t&&(this.setState({selectedId:e,editorDraft:_G(t.policyData),dirty:!1}),this.config.onSelectionChanged?.(t))}clearSelection(){this.state.selectedId&&(this.setState({selectedId:null,editorDraft:null,dirty:!1}),this.config.onSelectionChanged?.(null))}updateEditorDraft(e){this.setState({editorDraft:e,dirty:!0})}markDirty(){this.state.dirty||this.setState({dirty:!0})}markClean(){this.state.dirty&&this.setState({dirty:!1})}savePolicy(){let e=this.getSelectedItem();if(!e||!this.state.editorDraft)return;let t={...e,policyData:_G(this.state.editorDraft)},n=this.state.catalog.map(e=>e.id===t.id?t:e);this.state={...this.state,catalog:n,dirty:!1},this.emit(),this.config.onPolicySaved?.(t)}resetDraft(){let e=this.getSelectedItem();e&&this.setState({editorDraft:_G(e.policyData),dirty:!1})}applyPolicy(){let e=this.getSelectedItem();if(!e)return;let t={...e,policyData:this.state.editorDraft?_G(this.state.editorDraft):_G(e.policyData)};this.config.onPolicyApplied?.(t)}addNewPolicy(e){let t=`user-${e}-${Date.now()}`,n={id:t,name:`New ${e} policy`,policyType:e,source:`user`,description:``,policyData:fG(e)},r=[...this.state.catalog,n];return this.state={...this.state,catalog:r,selectedId:t,editorDraft:_G(n.policyData),dirty:!1},this.emit(),this.config.onPolicyCreated?.(n),this.config.onSelectionChanged?.(n),t}duplicatePolicy(e){let t=this.state.catalog.find(t=>t.id===e);if(!t)return null;let n=`user-${t.policyType}-${Date.now()}`,r={id:n,name:`${t.name} (Copy)`,policyType:t.policyType,source:`user`,description:t.description,policyData:_G(t.policyData)},i=[...this.state.catalog,r];return this.state={...this.state,catalog:i,selectedId:n,editorDraft:_G(r.policyData),dirty:!1},this.emit(),this.config.onPolicyCreated?.(r),this.config.onSelectionChanged?.(r),n}deletePolicy(e){let t=this.state.catalog.find(t=>t.id===e);if(!t||t.source===`builtin`)return;let n=this.state.catalog.filter(t=>t.id!==e),r=this.state.selectedId===e;this.state={...this.state,catalog:n,...r?{selectedId:null,editorDraft:null,dirty:!1}:{}},this.emit(),this.config.onPolicyDeleted?.(e),r&&this.config.onSelectionChanged?.(null)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state={...this.state,...e},this.emit()}emit(){for(let e of this.listeners)e(this.state)}};function yG(e){let t=document.createElement(`div`);t.className=fW();let n=document.createElement(`div`);n.className=OW();let r=document.createElement(`div`);r.className=kW();let i=document.createElement(`div`);i.className=AW();let a=document.createElement(`div`);a.className=mW();let o=document.createElement(`span`);o.className=DW();let s=document.createElement(`span`);s.className=DW(),s.textContent=`read-only`,s.style.display=`none`;let c=document.createElement(`div`);c.className=PW(),c.style.display=`none`,c.title=`Unsaved changes`,i.appendChild(c),i.appendChild(a),i.appendChild(o),i.appendChild(s);let l=document.createElement(`div`);l.className=jW();let u=document.createElement(`button`);u.className=MW(),u.textContent=`Reset`,u.addEventListener(`click`,()=>e.onReset());let d=document.createElement(`button`);d.className=NW(),d.textContent=`Save`,d.addEventListener(`click`,()=>e.onSave());let f=document.createElement(`button`);f.className=MW(),f.textContent=`Apply`,f.addEventListener(`click`,()=>e.onApply());let p=document.createElement(`button`);p.className=MW(),p.textContent=`Duplicate`,p.addEventListener(`click`,()=>e.onDuplicate()),l.appendChild(u),l.appendChild(d),l.appendChild(f),l.appendChild(p);let m=document.createElement(`div`);m.className=jW();let h=document.createElement(`button`);h.className=NW(),h.textContent=`Use as Template`,h.addEventListener(`click`,()=>e.onDuplicate()),m.appendChild(h),r.appendChild(i),r.appendChild(l),r.appendChild(m);let g=document.createElement(`div`);g.className=FW(),n.appendChild(r),n.appendChild(g);let _=document.createElement(`div`);_.className=IW(),_.textContent=`Select a policy to edit`,t.appendChild(n),t.appendChild(_);function v(e){let t=e.selectedId!==null;if(n.style.display=t?`flex`:`none`,_.style.display=t?`none`:`flex`,!t)return;let r=e.catalog.find(t=>t.id===e.selectedId);if(!r)return;let i=r.source===`builtin`;a.textContent=r.name,o.textContent=dG(r.policyType)?.label??r.policyType,s.style.display=i?``:`none`,l.style.display=i?`none`:`flex`,m.style.display=i?`flex`:`none`,c.style.display=!i&&e.dirty?`block`:`none`}return{element:t,update:v,bodyElement:g}}function bG(e){let t=document.createElement(`div`);t.className=LW();let n=document.createElement(`textarea`);n.value=JSON.stringify(e.initialData,null,2);let r=document.createElement(`div`);r.className=RW(),r.style.display=`none`;let i={...e.initialData};return n.addEventListener(`input`,()=>{try{let t=JSON.parse(n.value);i=t,r.style.display=`none`,e.onChange(t)}catch(e){r.style.display=`block`,r.textContent=`Invalid JSON: ${e.message}`}}),t.appendChild(n),t.appendChild(r),{element:t,setData(e){i={...e},n.value=JSON.stringify(e,null,2),r.style.display=`none`},getData(){return{...i}},destroy(){t.remove()}}}var xG=class{constructor(e){this.currentEditor=null,this.container=null,this.store=new vG(e);let t=gG({onSearchChange:e=>this.store.setCatalogSearch(e),onGroupByChange:e=>this.store.setCatalogGroupBy(e),onSelectPolicy:e=>this.handleSelectPolicy(e),onNewPolicy:e=>{this.store.addNewPolicy(e),this.mountEditorForSelection()},onDuplicatePolicy:e=>{this.store.duplicatePolicy(e),this.mountEditorForSelection()},onDeletePolicy:e=>{this.store.deletePolicy(e),this.store.getSelectedItem()||this.destroyCurrentEditor()}});this.editorShell=yG({onSave:()=>this.store.savePolicy(),onReset:()=>{this.store.resetDraft(),this.syncEditorFromStore()},onApply:()=>this.store.applyPolicy(),onDuplicate:()=>{let e=this.store.getSelectedItem();e&&(this.store.duplicatePolicy(e.id),this.mountEditorForSelection())}}),this.layout=zW({catalogPanel:t,editorShell:this.editorShell}),this.unsubscribe=this.store.subscribe(e=>{this.layout.update(e)}),this.layout.update(this.store.getState())}render(e){this.container=e,e.appendChild(this.layout.element)}destroy(){this.destroyCurrentEditor(),this.unsubscribe(),this.container&&this.layout.element.parentNode===this.container&&this.layout.element.remove(),this.container=null}getStore(){return this.store}handleSelectPolicy(e){this.store.selectPolicy(e),this.mountEditorForSelection()}mountEditorForSelection(){this.destroyCurrentEditor();let e=this.store.getSelectedItem();if(!e)return;let t=e.source===`builtin`,n={initialData:{...e.policyData},onChange:e=>{this.store.updateEditorDraft(e)},readonly:t};e.policyType===`scheduling`?this.currentEditor=lW.createEditorInstance(n):e.policyType===`rankingPoints`?this.currentEditor=pU.createEditorInstance(n):this.currentEditor=bG(n),this.editorShell.bodyElement.innerHTML=``,this.editorShell.bodyElement.appendChild(this.currentEditor.element)}syncEditorFromStore(){let e=this.store.getState();this.currentEditor&&e.editorDraft&&this.currentEditor.setData(e.editorDraft)}destroyCurrentEditor(){this.currentEditor&&=(this.currentEditor.destroy(),null),this.editorShell.bodyElement.innerHTML=``}};function SG(e,t,n,r){e!==void 0&&e<0&&r.push({severity:`error`,path:t,message:n})}function CG(e,t){if(!e.defaultTimes)return;let n=e.defaultTimes.averageTimes;if(n)for(let e=0;e<n.length;e++)SG(n[e].minutes.default,`defaultTimes.averageTimes[${e}].minutes.default`,`Default average time must be non-negative`,t),SG(n[e].minutes.DOUBLES,`defaultTimes.averageTimes[${e}].minutes.DOUBLES`,`Doubles average time must be non-negative`,t);let r=e.defaultTimes.recoveryTimes;if(r)for(let e=0;e<r.length;e++)SG(r[e].minutes.default,`defaultTimes.recoveryTimes[${e}].minutes.default`,`Default recovery time must be non-negative`,t)}function wG(e,t){if(!e.defaultDailyLimits)return;let n=e.defaultDailyLimits;SG(n.SINGLES,`defaultDailyLimits.SINGLES`,`Singles daily limit must be non-negative`,t),SG(n.DOUBLES,`defaultDailyLimits.DOUBLES`,`Doubles daily limit must be non-negative`,t),SG(n.total,`defaultDailyLimits.total`,`Total daily limit must be non-negative`,t)}function TG(e){let t=[];return CG(e,t),wG(e,t),e.matchUpAverageTimes&&EG(e.matchUpAverageTimes,`matchUpAverageTimes`,`averageTimes`,t),e.matchUpRecoveryTimes&&DG(e.matchUpRecoveryTimes,`matchUpRecoveryTimes`,t),OG(e,t),t}function EG(e,t,n,r){for(let i=0;i<e.length;i++){let a=e[i];a.matchUpFormatCodes.length||r.push({severity:`error`,path:`${t}[${i}].matchUpFormatCodes`,message:`At least one format code is required per format group`});let o=a[n];if(o)for(let e=0;e<o.length;e++)SG(o[e].minutes.default,`${t}[${i}].${n}[${e}].minutes.default`,`Time must be non-negative`,r),SG(o[e].minutes.DOUBLES,`${t}[${i}].${n}[${e}].minutes.DOUBLES`,`Doubles time must be non-negative`,r)}}function DG(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];i.matchUpFormatCodes.length||n.push({severity:`error`,path:`${t}[${r}].matchUpFormatCodes`,message:`At least one format code is required per format group`});for(let e=0;e<i.recoveryTimes.length;e++)SG(i.recoveryTimes[e].minutes.default,`${t}[${r}].recoveryTimes[${e}].minutes.default`,`Recovery time must be non-negative`,n),SG(i.recoveryTimes[e].minutes.DOUBLES,`${t}[${r}].recoveryTimes[${e}].minutes.DOUBLES`,`Doubles recovery time must be non-negative`,n)}}function OG(e,t){let n=(e,n)=>{if(!e)return;let r=new Map;for(let i=0;i<e.length;i++)for(let a of e[i].matchUpFormatCodes)r.has(a)?t.push({severity:`warning`,path:`${n}[${i}].matchUpFormatCodes`,message:`Format code "${a}" also appears in group ${r.get(a)}`}):r.set(a,i)};n(e.matchUpAverageTimes,`matchUpAverageTimes`),n(e.matchUpRecoveryTimes,`matchUpRecoveryTimes`)}function kG(e,t){let n=new xG(e);return n.render(t),n}e.COMPETITIVENESS_BUCKETS=ev,e.COURT_SVG_RESOURCE_SUB_TYPE=Zm,e.CompositionEditorStore=gB,e.DEFAULT_COURT_CARD_CONFIG=u_,e.DEFAULT_DRAW_CARD_CONFIG=vv,e.DEFAULT_EVENT_CARD_CONFIG=uy,e.DEFAULT_SCHEDULE_CELL_CONFIG=Jz,e.DEFAULT_TOURNAMENT_CARD_CONFIG=hh,e.DEFAULT_VENUE_CARD_CONFIG=bg,e.DrawStateManager=kb,e.EVENT_CARD_LIGHT_MODE_THRESHOLD=dy,e.InlineScoringManager=ts,e.MATCH_FORMATS=vb,e.POLICY_TYPE_GROUPS=pG,e.POLICY_TYPE_METADATA=uG,e.PolicyCatalogControl=xG,e.PolicyCatalogStore=vG,e.ProfileStore=Vj,e.SchedulePageControl=Ez,e.SchedulePageStore=Tz,e.SchedulingEditorControl=lW,e.SchedulingEditorStore=_U,e.SchedulingProfileControl=eM,e.TemporalGrid=JP,e.TopologyBuilderControl=XL,e.TopologyStore=YF,e.activateScheduleCellTypeAhead=mB,e.aggregateCompetitiveness=rv,e.applyDropCommit=Lj,e.badmintonCourt=Ym,e.barButton=jk,e.baseballDiamond=Km,e.basketballCourt=Gm,e.buildActiveStripPanel=Gz,e.buildCardSkeleton=mh,e.buildCompetitivenessBar=ov,e.buildCompetitivenessDonut=_v,e.buildCourtCard=A_,e.buildCourtGridSlot=wz,e.buildCourtSkeletonCard=K_,e.buildDateStrip=Qj,e.buildDrawCard=Rv,e.buildDrawSkeletonCard=ry,e.buildEdgeEditor=WI,e.buildEditorShell=yG,e.buildEventCard=Fy,e.buildEventSkeletonCard=$y,e.buildInspectorPanel=dj,e.buildInteractiveScoringShell=ZV,e.buildIssueIndex=Fj,e.buildIssuesPanel=bj,e.buildJsonEditor=bG,e.buildMatchUpCard=gz,e.buildMatchUpCatalog=yz,e.buildNodeEditor=MI,e.buildPolicyCatalogLayout=zW,e.buildPolicyCatalogPanel=gG,e.buildRatingDistributionChart=Ck,e.buildRoundCard=qj,e.buildRoundCatalog=yj,e.buildScheduleDateStrip=Cz,e.buildScheduleGridCell=Yz,e.buildScheduleInspectorPanel=uz,e.buildScheduleIssueIndex=bz,e.buildScheduleIssuesPanel=Sz,e.buildSchedulePageLayout=oz,e.buildSchedulingEditorPanel=cW,e.buildSchedulingProfileLayout=ZA,e.buildSetScore=As,e.buildSkeletonCard=ig,e.buildStructureCard=PF,e.buildToolbar=yL,e.buildTopologyBuilderLayout=bL,e.buildTopologyCanvas=oI,e.buildTournamentCard=Bh,e.buildVenueBoard=Yj,e.buildVenueCard=Vg,e.buildVenueSkeletonCard=i_,e.burstChart=LO,e.cModal=F,e.calculateComplement=Es,e.compositions=si,e.controlBar=Yk,e.courthiveComponentsVersion=_b,e.createCardPopoverManager=QA,e.createCompositionEditor=_V,e.createCourtSvg=ih,e.createInlineScoringFooter=YV,e.createPolicyCatalog=kG,e.createPrintCompositionEditor=CV,e.createSchedulePage=hB,e.createSchedulingEditor=uW,e.createSchedulingProfile=tM,e.createTemporalGrid=YP,e.destroyTipster=Vm,e.drawer=ad,e.dropDownButton=Ek,e.emptySchedulingPolicy=gU,e.engineToMatchUp=$o,e.extractCourtSvgSport=ph,e.extractImageURL=fh,e.filterCatalog=mj,e.filterMatchUpCatalog=mz,e.filterPolicyCatalog=mG,e.findIssuesForLocator=sj,e.formatAddress=oh,e.formatCodeLabel=mU,e.formatDateRange=uh,e.formatFeeRange=hg,e.formatVenueLocation=sh,e.fromFactoryDrawData=UO,e.fromLegacyDraw=KO,e.generatePreviewMatchUps=uF,e.getAgeCategoryModal=ho,e.getCategoryModal=vo,e.getFlightProfileModal=Yo,e.getGenerateTeamsModal=ji,e.getMatchUpFormatModal=Da,e.getMatchWinner=Ts,e.getMaxAllowedScore=xs,e.getMockParticipantsModal=Ti,e.getPlannedRoundKeys=gj,e.getPolicyTypeMeta=dG,e.getPortPosition=FF,e.getRoundAt=oj,e.getScoringConfig=is,e.getSetFormatForIndex=vs,e.getSetWinner=Cs,e.getVenueRounds=aj,e.groupCatalog=hj,e.groupMatchUpCatalog=hz,e.groupPolicyCatalog=hG,e.hockeyRink=qm,e.initDrawer=od,e.isCompletedStatus=pz,e.isMatchComplete=ws,e.isSetComplete=Ss,e.isSetTiebreakOnly=ys,e.isSetTimed=bs,e.mapCourtToCardData=$_,e.mapDrawDefinitionToCardData=ly,e.mapEventToCardData=hb,e.mapMatchUpToCellData=pB,e.mapTournamentToCardData=yg,e.mapVenueToCardData=l_,e.matchUpLabel=sz,e.matchUpSearchKey=lz,e.maxSeverity=lj,e.mergeCourtCardConfig=d_,e.mergeDrawCardConfig=yv,e.mergeEventCardConfig=fy,e.mergeTournamentCardConfig=gh,e.mergeVenueCardConfig=xg,e.notesToolbar=bm,e.openCompositionEditorModal=Li,e.openScheduleCellConfigModal=zi,e.padelCourt=Xm,e.participantLabel=cz,e.pickleballCourt=Jm,e.renderButtons=yb,e.renderContainer=Zr,e.renderField=ln,e.renderForm=mi,e.renderInlineMatchUp=Zo,e.renderMatchUp=qr,e.renderMenu=Rm,e.renderOptions=cn,e.renderParticipant=cr,e.renderParticipantInput=gn,e.renderRound=Jr,e.renderRoundHeader=ur,e.renderSchematicMatchUp=di,e.renderSchematicRound=fi,e.renderSchematicStructure=pi,e.renderScorecard=zV,e.renderStructure=Yr,e.renderTeamVsHeader=BV,e.resetScoringConfig=os,e.resolveCourtSport=nh,e.resolveEventStatus=nb,e.resolvePublishedComposition=li,e.resolveTournamentStatus=lg,e.scoringModal=Jl,e.selectItem=Ok,e.setScoringConfig=as,e.shouldApplySmartComplement=Ds,e.shouldCreateNextSet=ks,e.shouldShowTiebreak=Os,e.showCourtAvailabilityModal=KP,e.sportFromMatchUpFormat=th,e.standardTemplates=BL,e.syncClearVisibility=Nb,e.tennisCourt=Wm,e.tipster=Hm,e.toggleOverlay=zk,e.topologyToDrawOptions=pR,e.totalBuckets=iv,e.updateHeadingSelect=Sm,e.updateTieScore=VV,e.updateToolbarState=xm,e.validateProfile=wj,e.validateSchedulingPolicy=TG,e.validateTopology=eL,e.validator=an,Object.defineProperty(e,`validators`,{enumerable:!0,get:function(){return Ob}}),e.wrapSearchWithClear=Mb});
|