courthive-components 0.7.3 → 0.7.4
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(no,Js){typeof exports=="object"&&typeof module<"u"?Js(exports):typeof define=="function"&&define.amd?define(["exports"],Js):(no=typeof globalThis<"u"?globalThis:no||self,Js(no["courthive-components"]={}))})(this,function(no){"use strict";var Js,$t="colors",Vr="sizes",Ne="space",qR={gap:Ne,gridGap:Ne,columnGap:Ne,gridColumnGap:Ne,rowGap:Ne,gridRowGap:Ne,inset:Ne,insetBlock:Ne,insetBlockEnd:Ne,insetBlockStart:Ne,insetInline:Ne,insetInlineEnd:Ne,insetInlineStart:Ne,margin:Ne,marginTop:Ne,marginRight:Ne,marginBottom:Ne,marginLeft:Ne,marginBlock:Ne,marginBlockEnd:Ne,marginBlockStart:Ne,marginInline:Ne,marginInlineEnd:Ne,marginInlineStart:Ne,padding:Ne,paddingTop:Ne,paddingRight:Ne,paddingBottom:Ne,paddingLeft:Ne,paddingBlock:Ne,paddingBlockEnd:Ne,paddingBlockStart:Ne,paddingInline:Ne,paddingInlineEnd:Ne,paddingInlineStart:Ne,top:Ne,right:Ne,bottom:Ne,left:Ne,scrollMargin:Ne,scrollMarginTop:Ne,scrollMarginRight:Ne,scrollMarginBottom:Ne,scrollMarginLeft:Ne,scrollMarginX:Ne,scrollMarginY:Ne,scrollMarginBlock:Ne,scrollMarginBlockEnd:Ne,scrollMarginBlockStart:Ne,scrollMarginInline:Ne,scrollMarginInlineEnd:Ne,scrollMarginInlineStart:Ne,scrollPadding:Ne,scrollPaddingTop:Ne,scrollPaddingRight:Ne,scrollPaddingBottom:Ne,scrollPaddingLeft:Ne,scrollPaddingX:Ne,scrollPaddingY:Ne,scrollPaddingBlock:Ne,scrollPaddingBlockEnd:Ne,scrollPaddingBlockStart:Ne,scrollPaddingInline:Ne,scrollPaddingInlineEnd:Ne,scrollPaddingInlineStart:Ne,fontSize:"fontSizes",background:$t,backgroundColor:$t,backgroundImage:$t,borderImage:$t,border:$t,borderBlock:$t,borderBlockEnd:$t,borderBlockStart:$t,borderBottom:$t,borderBottomColor:$t,borderColor:$t,borderInline:$t,borderInlineEnd:$t,borderInlineStart:$t,borderLeft:$t,borderLeftColor:$t,borderRight:$t,borderRightColor:$t,borderTop:$t,borderTopColor:$t,caretColor:$t,color:$t,columnRuleColor:$t,fill:$t,outline:$t,outlineColor:$t,stroke:$t,textDecorationColor:$t,fontFamily:"fonts",fontWeight:"fontWeights",lineHeight:"lineHeights",letterSpacing:"letterSpacings",blockSize:Vr,minBlockSize:Vr,maxBlockSize:Vr,inlineSize:Vr,minInlineSize:Vr,maxInlineSize:Vr,width:Vr,minWidth:Vr,maxWidth:Vr,height:Vr,minHeight:Vr,maxHeight:Vr,flexBasis:Vr,gridTemplateColumns:Vr,gridTemplateRows:Vr,borderWidth:"borderWidths",borderTopWidth:"borderWidths",borderRightWidth:"borderWidths",borderBottomWidth:"borderWidths",borderLeftWidth:"borderWidths",borderStyle:"borderStyles",borderTopStyle:"borderStyles",borderRightStyle:"borderStyles",borderBottomStyle:"borderStyles",borderLeftStyle:"borderStyles",borderRadius:"radii",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",borderBottomRightRadius:"radii",borderBottomLeftRadius:"radii",boxShadow:"shadows",textShadow:"shadows",transition:"transitions",zIndex:"zIndices"},zR=(t,e)=>typeof e=="function"?{"()":Function.prototype.toString.call(e)}:e,al=()=>{const t=Object.create(null);return(e,r,...n)=>{const o=(i=>JSON.stringify(i,zR))(e);return o in t?t[o]:t[o]=r(e,...n)}},qc=Symbol.for("sxs.internal"),Hp=(t,e)=>Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)),_h=t=>{for(const e in t)return!0;return!1},{hasOwnProperty:YR}=Object.prototype,qp=t=>t.includes("-")?t:t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),KR=/\s+(?![^()]*\))/,Zs=t=>e=>t(...typeof e=="string"?String(e).split(KR):[e]),Ih={appearance:t=>({WebkitAppearance:t,appearance:t}),backfaceVisibility:t=>({WebkitBackfaceVisibility:t,backfaceVisibility:t}),backdropFilter:t=>({WebkitBackdropFilter:t,backdropFilter:t}),backgroundClip:t=>({WebkitBackgroundClip:t,backgroundClip:t}),boxDecorationBreak:t=>({WebkitBoxDecorationBreak:t,boxDecorationBreak:t}),clipPath:t=>({WebkitClipPath:t,clipPath:t}),content:t=>({content:t.includes('"')||t.includes("'")||/^([A-Za-z]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)$/.test(t)?t:`"${t}"`}),hyphens:t=>({WebkitHyphens:t,hyphens:t}),maskImage:t=>({WebkitMaskImage:t,maskImage:t}),maskSize:t=>({WebkitMaskSize:t,maskSize:t}),tabSize:t=>({MozTabSize:t,tabSize:t}),textSizeAdjust:t=>({WebkitTextSizeAdjust:t,textSizeAdjust:t}),userSelect:t=>({WebkitUserSelect:t,userSelect:t}),marginBlock:Zs((t,e)=>({marginBlockStart:t,marginBlockEnd:e||t})),marginInline:Zs((t,e)=>({marginInlineStart:t,marginInlineEnd:e||t})),maxSize:Zs((t,e)=>({maxBlockSize:t,maxInlineSize:e||t})),minSize:Zs((t,e)=>({minBlockSize:t,minInlineSize:e||t})),paddingBlock:Zs((t,e)=>({paddingBlockStart:t,paddingBlockEnd:e||t})),paddingInline:Zs((t,e)=>({paddingInlineStart:t,paddingInlineEnd:e||t}))},zp=/([\d.]+)([^]*)/,QR=(t,e)=>t.length?t.reduce((r,n)=>(r.push(...e.map(o=>o.includes("&")?o.replace(/&/g,/[ +>|~]/.test(n)&&/&.*&/.test(o)?`:is(${n})`:n):n+" "+o)),r),[]):e,JR=(t,e)=>t in ZR&&typeof e=="string"?e.replace(/^((?:[^]*[^\w-])?)(fit-content|stretch)((?:[^\w-][^]*)?)$/,(r,n,o,i)=>n+(o==="stretch"?`-moz-available${i};${qp(t)}:${n}-webkit-fill-available`:`-moz-fit-content${i};${qp(t)}:${n}fit-content`)+i):String(e),ZR={blockSize:1,height:1,inlineSize:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,width:1},Bo=t=>t?t+"-":"",Ph=(t,e,r)=>t.replace(/([+-])?((?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?)?(\$|--)([$\w-]+)/g,(n,o,i,s,a)=>s=="$"==!!i?n:(o||s=="--"?"calc(":"")+"var(--"+(s==="$"?Bo(e)+(a.includes("$")?"":Bo(r))+a.replace(/\$/g,"-"):a)+")"+(o||s=="--"?"*"+(o||"")+(i||"1")+")":"")),XR=/\s*,\s*(?![^()]*\))/,eF=Object.prototype.toString,Xs=(t,e,r,n,o)=>{let i,s,a;const l=(c,u,d)=>{let p,v;const f=m=>{for(p in m){const _=p.charCodeAt(0)===64,I=_&&Array.isArray(m[p])?m[p]:[m[p]];for(v of I){const P=/[A-Z]/.test(h=p)?h:h.replace(/-[^]/g,S=>S[1].toUpperCase()),y=typeof v=="object"&&v&&v.toString===eF&&(!n.utils[P]||!u.length);if(P in n.utils&&!y){const S=n.utils[P];if(S!==s){s=S,f(S(v)),s=null;continue}}else if(P in Ih){const S=Ih[P];if(S!==a){a=S,f(S(v)),a=null;continue}}if(_&&(g=p.slice(1)in n.media?"@media "+n.media[p.slice(1)]:p,p=g.replace(/\(\s*([\w-]+)\s*(=|<|<=|>|>=)\s*([\w-]+)\s*(?:(<|<=|>|>=)\s*([\w-]+)\s*)?\)/g,(S,O,b,w,T,E)=>{const N=zp.test(O),$=.0625*(N?-1:1),[A,U]=N?[w,O]:[O,w];return"("+(b[0]==="="?"":b[0]===">"===N?"max-":"min-")+A+":"+(b[0]!=="="&&b.length===1?U.replace(zp,(C,M,D)=>Number(M)+$*(b===">"?1:-1)+D):U)+(T?") and ("+(T[0]===">"?"min-":"max-")+A+":"+(T.length===1?E.replace(zp,(C,M,D)=>Number(M)+$*(T===">"?-1:1)+D):E):"")+")"})),y){const S=_?d.concat(p):[...d],O=_?[...u]:QR(u,p.split(XR));i!==void 0&&o(yh(...i)),i=void 0,l(v,O,S)}else i===void 0&&(i=[[],u,d]),p=_||p.charCodeAt(0)!==36?p:`--${Bo(n.prefix)}${p.slice(1).replace(/\$/g,"-")}`,v=y?v:typeof v=="number"?v&&P in tF?String(v)+"px":String(v):Ph(JR(P,v??""),n.prefix,n.themeMap[P]),i[0].push(`${_?`${p} `:`${qp(p)}:`}${v}`)}}var g,h};f(c),i!==void 0&&o(yh(...i)),i=void 0};l(t,e,r)},yh=(t,e,r)=>`${r.map(n=>`${n}{`).join("")}${e.length?`${e.join(",")}{`:""}${t.join(";")}${e.length?"}":""}${Array(r.length?r.length+1:0).join("}")}`,tF={animationDelay:1,animationDuration:1,backgroundSize:1,blockSize:1,border:1,borderBlock:1,borderBlockEnd:1,borderBlockEndWidth:1,borderBlockStart:1,borderBlockStartWidth:1,borderBlockWidth:1,borderBottom:1,borderBottomLeftRadius:1,borderBottomRightRadius:1,borderBottomWidth:1,borderEndEndRadius:1,borderEndStartRadius:1,borderInlineEnd:1,borderInlineEndWidth:1,borderInlineStart:1,borderInlineStartWidth:1,borderInlineWidth:1,borderLeft:1,borderLeftWidth:1,borderRadius:1,borderRight:1,borderRightWidth:1,borderSpacing:1,borderStartEndRadius:1,borderStartStartRadius:1,borderTop:1,borderTopLeftRadius:1,borderTopRightRadius:1,borderTopWidth:1,borderWidth:1,bottom:1,columnGap:1,columnRule:1,columnRuleWidth:1,columnWidth:1,containIntrinsicSize:1,flexBasis:1,fontSize:1,gap:1,gridAutoColumns:1,gridAutoRows:1,gridTemplateColumns:1,gridTemplateRows:1,height:1,inlineSize:1,inset:1,insetBlock:1,insetBlockEnd:1,insetBlockStart:1,insetInline:1,insetInlineEnd:1,insetInlineStart:1,left:1,letterSpacing:1,margin:1,marginBlock:1,marginBlockEnd:1,marginBlockStart:1,marginBottom:1,marginInline:1,marginInlineEnd:1,marginInlineStart:1,marginLeft:1,marginRight:1,marginTop:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,offsetDistance:1,offsetRotate:1,outline:1,outlineOffset:1,outlineWidth:1,overflowClipMargin:1,padding:1,paddingBlock:1,paddingBlockEnd:1,paddingBlockStart:1,paddingBottom:1,paddingInline:1,paddingInlineEnd:1,paddingInlineStart:1,paddingLeft:1,paddingRight:1,paddingTop:1,perspective:1,right:1,rowGap:1,scrollMargin:1,scrollMarginBlock:1,scrollMarginBlockEnd:1,scrollMarginBlockStart:1,scrollMarginBottom:1,scrollMarginInline:1,scrollMarginInlineEnd:1,scrollMarginInlineStart:1,scrollMarginLeft:1,scrollMarginRight:1,scrollMarginTop:1,scrollPadding:1,scrollPaddingBlock:1,scrollPaddingBlockEnd:1,scrollPaddingBlockStart:1,scrollPaddingBottom:1,scrollPaddingInline:1,scrollPaddingInlineEnd:1,scrollPaddingInlineStart:1,scrollPaddingLeft:1,scrollPaddingRight:1,scrollPaddingTop:1,shapeMargin:1,textDecoration:1,textDecorationThickness:1,textIndent:1,textUnderlineOffset:1,top:1,transitionDelay:1,transitionDuration:1,verticalAlign:1,width:1,wordSpacing:1},Sh=t=>String.fromCharCode(t+(t>25?39:97)),Zi=t=>(e=>{let r,n="";for(r=Math.abs(e);r>52;r=r/52|0)n=Sh(r%52)+n;return Sh(r%52)+n})(((e,r)=>{let n=r.length;for(;n;)e=33*e^r.charCodeAt(--n);return e})(5381,JSON.stringify(t))>>>0),ll=["themed","global","styled","onevar","resonevar","allvar","inline"],rF=t=>{if(t.href&&!t.href.startsWith(location.origin))return!1;try{return!!t.cssRules}catch{return!1}},nF=t=>{let e;const r=()=>{const{cssRules:o}=e.sheet;return[].map.call(o,(i,s)=>{const{cssText:a}=i;let l="";if(a.startsWith("--sxs"))return"";if(o[s-1]&&(l=o[s-1].cssText).startsWith("--sxs")){if(!i.cssRules.length)return"";for(const c in e.rules)if(e.rules[c].group===i)return`--sxs{--sxs:${[...e.rules[c].cache].join(" ")}}${a}`;return i.cssRules.length?`${l}${a}`:""}return a}).join("")},n=()=>{if(e){const{rules:a,sheet:l}=e;if(!l.deleteRule){for(;Object(Object(l.cssRules)[0]).type===3;)l.cssRules.splice(0,1);l.cssRules=[]}for(const c in a)delete a[c]}const o=Object(t).styleSheets||[];for(const a of o)if(rF(a)){for(let l=0,c=a.cssRules;c[l];++l){const u=Object(c[l]);if(u.type!==1)continue;const d=Object(c[l+1]);if(d.type!==4)continue;++l;const{cssText:p}=u;if(!p.startsWith("--sxs"))continue;const v=p.slice(14,-3).trim().split(/\s+/),f=ll[v[0]];f&&(e||(e={sheet:a,reset:n,rules:{},toString:r}),e.rules[f]={group:d,index:l,cache:new Set(v)})}if(e)break}if(!e){const a=(l,c)=>({type:c,cssRules:[],insertRule(u,d){this.cssRules.splice(d,0,a(u,{import:3,undefined:1}[(u.toLowerCase().match(/^@([a-z]+)/)||[])[1]]||4))},get cssText(){return l==="@media{}"?`@media{${[].map.call(this.cssRules,u=>u.cssText).join("")}}`:l}});e={sheet:t?(t.head||t).appendChild(document.createElement("style")).sheet:a("","text/css"),rules:{},reset:n,toString:r}}const{sheet:i,rules:s}=e;for(let a=ll.length-1;a>=0;--a){const l=ll[a];if(!s[l]){const c=ll[a+1],u=s[c]?s[c].index:i.cssRules.length;i.insertRule("@media{}",u),i.insertRule(`--sxs{--sxs:${a}}`,u),s[l]={group:i.cssRules[u+1],index:u,cache:new Set([a])}}oF(s[l])}};return n(),e},oF=t=>{const e=t.group;let r=e.cssRules.length;t.apply=n=>{try{e.insertRule(n,r),++r}catch{}}},cl=Symbol(),iF=al(),sF=(t,e)=>iF(t,()=>(...r)=>{let n={type:null,composers:new Set};for(const o of r)if(o!=null)if(o[qc]){n.type==null&&(n.type=o[qc].type);for(const i of o[qc].composers)n.composers.add(i)}else o.constructor!==Object||o.$$typeof?n.type==null&&(n.type=o):n.composers.add(aF(o,t));return n.type==null&&(n.type="span"),n.composers.size||n.composers.add(["PJLV",{},[],[],{},[]]),lF(t,n,e)}),aF=({variants:t,compoundVariants:e,defaultVariants:r,...n},o)=>{const i=`${Bo(o.prefix)}c-${Zi(n)}`,s=[],a=[],l=Object.create(null),c=[];for(const p in r)l[p]=String(r[p]);if(typeof t=="object"&&t)for(const p in t){u=l,d=p,YR.call(u,d)||(l[p]="undefined");const v=t[p];for(const f in v){const m={[p]:String(f)};String(f)==="undefined"&&c.push(p);const g=v[f],h=[m,g,!_h(g)];s.push(h)}}var u,d;if(typeof e=="object"&&e)for(const p of e){let{css:v,...f}=p;v=typeof v=="object"&&v||{};for(const g in f)f[g]=String(f[g]);const m=[f,v,!_h(v)];a.push(m)}return[i,n,s,a,l,c]},lF=(t,e,r)=>{const[n,o,i,s]=cF(e.composers),a=typeof e.type=="function"||e.type.$$typeof?(d=>{function p(){for(let v=0;v<p[cl].length;v++){const[f,m]=p[cl][v];d.rules[f].apply(m)}return p[cl]=[],null}return p[cl]=[],p.rules={},ll.forEach(v=>p.rules[v]={apply:f=>p[cl].push([v,f])}),p})(r):null,l=(a||r).rules,c=`.${n}${o.length>1?`:where(.${o.slice(1).join(".")})`:""}`,u=d=>{d=typeof d=="object"&&d||uF;const{css:p,...v}=d,f={};for(const h in i)if(delete v[h],h in d){let _=d[h];typeof _=="object"&&_?f[h]={"@initial":i[h],..._}:(_=String(_),f[h]=_!=="undefined"||s.has(h)?_:i[h])}else f[h]=i[h];const m=new Set([...o]);for(const[h,_,I,P]of e.composers){r.rules.styled.cache.has(h)||(r.rules.styled.cache.add(h),Xs(_,[`.${h}`],[],t,O=>{l.styled.apply(O)}));const y=Oh(I,f,t.media),S=Oh(P,f,t.media,!0);for(const O of y)if(O!==void 0)for(const[b,w,T]of O){const E=`${h}-${Zi(w)}-${b}`;m.add(E);const N=(T?r.rules.resonevar:r.rules.onevar).cache,$=T?l.resonevar:l.onevar;N.has(E)||(N.add(E),Xs(w,[`.${E}`],[],t,A=>{$.apply(A)}))}for(const O of S)if(O!==void 0)for(const[b,w]of O){const T=`${h}-${Zi(w)}-${b}`;m.add(T),r.rules.allvar.cache.has(T)||(r.rules.allvar.cache.add(T),Xs(w,[`.${T}`],[],t,E=>{l.allvar.apply(E)}))}}if(typeof p=="object"&&p){const h=`${n}-i${Zi(p)}-css`;m.add(h),r.rules.inline.cache.has(h)||(r.rules.inline.cache.add(h),Xs(p,[`.${h}`],[],t,_=>{l.inline.apply(_)}))}for(const h of String(d.className||"").trim().split(/\s+/))h&&m.add(h);const g=v.className=[...m].join(" ");return{type:e.type,className:g,selector:c,props:v,toString:()=>g,deferredInjector:a}};return Hp(u,{className:n,selector:c,[qc]:e,toString:()=>(r.rules.styled.cache.has(n)||u(),n)})},cF=t=>{let e="";const r=[],n={},o=[];for(const[i,,,,s,a]of t){e===""&&(e=i),r.push(i),o.push(...a);for(const l in s){const c=s[l];(n[l]===void 0||c!=="undefined"||a.includes(c))&&(n[l]=c)}}return[e,r,n,new Set(o)]},Oh=(t,e,r,n)=>{const o=[];e:for(let[i,s,a]of t){if(a)continue;let l,c=0,u=!1;for(l in i){const d=i[l];let p=e[l];if(p!==d){if(typeof p!="object"||!p)continue e;{let v,f,m=0;for(const g in p){if(d===String(p[g])){if(g!=="@initial"){const h=g.slice(1);(f=f||[]).push(h in r?r[h]:g.replace(/^@media ?/,"")),u=!0}c+=m,v=!0}++m}if(f&&f.length&&(s={["@media "+f.join(", ")]:s}),!v)continue e}}}(o[c]=o[c]||[]).push([n?"cv":`${l}-${i[l]}`,s,u])}return o},uF={},dF=al(),pF=(t,e)=>dF(t,()=>(...r)=>{const n=()=>{for(let o of r){o=typeof o=="object"&&o||{};let i=Zi(o);if(!e.rules.global.cache.has(i)){if(e.rules.global.cache.add(i),"@import"in o){let s=[].indexOf.call(e.sheet.cssRules,e.rules.themed.group)-1;for(let a of[].concat(o["@import"]))a=a.includes('"')||a.includes("'")?a:`"${a}"`,e.sheet.insertRule(`@import ${a};`,s++);delete o["@import"]}Xs(o,[],[],t,s=>{e.rules.global.apply(s)})}}return""};return Hp(n,{toString:n})}),fF=al(),vF=(t,e)=>fF(t,()=>r=>{const n=`${Bo(t.prefix)}k-${Zi(r)}`,o=()=>{if(!e.rules.global.cache.has(n)){e.rules.global.cache.add(n);const i=[];Xs(r,[],[],t,a=>i.push(a));const s=`@keyframes ${n}{${i.join("")}}`;e.rules.global.apply(s)}return n};return Hp(o,{get name(){return o()},toString:o})}),mF=class{constructor(t,e,r,n){this.token=t==null?"":String(t),this.value=e==null?"":String(e),this.scale=r==null?"":String(r),this.prefix=n==null?"":String(n)}get computedValue(){return"var("+this.variable+")"}get variable(){return"--"+Bo(this.prefix)+Bo(this.scale)+this.token}toString(){return this.computedValue}},gF=al(),hF=(t,e)=>gF(t,()=>(r,n)=>{n=typeof r=="object"&&r||Object(n);const o=`.${r=(r=typeof r=="string"?r:"")||`${Bo(t.prefix)}t-${Zi(n)}`}`,i={},s=[];for(const l in n){i[l]={};for(const c in n[l]){const u=`--${Bo(t.prefix)}${l}-${c}`,d=Ph(String(n[l][c]),t.prefix,l);i[l][c]=new mF(c,d,l,t.prefix),s.push(`${u}:${d}`)}}const a=()=>{if(s.length&&!e.rules.themed.cache.has(r)){e.rules.themed.cache.add(r);const l=`${n===t.theme?":root,":""}.${r}{${s.join(";")}}`;e.rules.themed.apply(l)}return r};return{...i,get className(){return a()},selector:o,toString:a}}),_F=al(),bh=t=>{let e=!1;const r=_F(t,n=>{e=!0;const o="prefix"in(n=typeof n=="object"&&n||{})?String(n.prefix):"",i=typeof n.media=="object"&&n.media||{},s=typeof n.root=="object"?n.root||null:globalThis.document||null,a=typeof n.theme=="object"&&n.theme||{},l={prefix:o,media:i,theme:a,themeMap:typeof n.themeMap=="object"&&n.themeMap||{...qR},utils:typeof n.utils=="object"&&n.utils||{}},c=nF(s),u={css:sF(l,c),globalCss:pF(l,c),keyframes:vF(l,c),createTheme:hF(l,c),reset(){c.reset(),u.theme.toString()},theme:{},sheet:c,config:l,prefix:o,getCssText:c.toString,toString:c.toString};return String(u.theme=u.createTheme(a)),u});return e||r.reset(),r},IF=()=>Js||(Js=bh()),Ke=(...t)=>IF().css(...t);function PF({variant:t}){return Ke({margin:"2.5px 0",variants:{variant:{showAddress:{lineHeight:"2.3em"}}}})({variant:t})}const Th=Ke({justifyContent:"flex-start",alignItems:"center",whiteSpace:"nowrap",fontWeight:500,display:"flex"}),yF=Ke({textTransform:"$participant$textTransform",fontSize:"0.875rem",fontWeight:500,variants:{variant:{winner:{fontWeight:700,color:"$winnerName"},loser:{fontWeight:500}}}}),SF=Ke({"&::WebkitScrollbar":{display:"none"},justifyContent:"space-between",flexDirection:"column",marginInlineEnd:"0rem",scrollbarWidth:"none",overflowX:"scroll",fontWeight:500,display:"flex",width:"100%",variants:{variant:{doubles:{marginTop:"0.25rem",fontSize:"0.75rem",lineHeight:"1rem"}}}});function OF({drawPosition:t,sideNumber:e}){return Ke({minHeight:"$participant$minHeight",justifyContent:"space-between",paddingInlineStart:"0.75rem",backgroundColor:"$matchUp",paddingInlineEnd:"0rem",boxSizing:"border-box",paddingBottom:".2rem",position:"relative",alignItems:"center",paddingTop:".2rem",minWidth:"15rem",cursor:"pointer",display:"flex",flexGrow:1,"& p":{fontFamily:"Sharp Sans, Arial, sans-serif",color:"$color"},variants:{sideNumber:{1:{borderBottom:"1px solid $internalDividers"}}}})({sideNumber:e,css:t&&{"&:before":{backgroundColor:"$backgroundColor",content:`${t}`,justifyContent:"center",alignContent:"center",insetInlineStart:-10,position:"absolute",color:"#55AFFE",display:"flex",width:20}}})}function bF({winnerChevron:t,isDoubles:e}){const r=(e?.4:.3)*2;return Ke({variants:{variant:{winner:{"&::before":{borderTop:`${r}rem solid transparent`,borderBottom:`${r}rem solid transparent`,borderInlineStart:"8px solid #008f70",position:"absolute",insetInlineStart:0,display:"block",content:""}}}}})({variant:t?"winner":void 0})}const TF=Ke({color:"$participant$seed",marginInlineStart:".5rem",textTransform:"uppercase",fontSize:"0.75rem",lineHeight:"1rem"}),wh=Ke({fontSize:"smaller",color:"gray"});function wF({className:t,composition:e,side:r}){const n=(r==null?void 0:r.seedValue)||(r==null?void 0:r.seedNumber);if(!n)return"";const o=(e==null?void 0:e.configuration)||{},{bracketedSeeds:i}=o,s=typeof i=="boolean"&&["(",")"]||i==="square"&&["[","]"]||["",""],a=`${s[0]}${n}${s[1]}`,l=o.seedingElement==="sup"?"sup":"span",c=document.createElement(l);return c.className=t,c.innerHTML=a,c}const EF=Ke({WebkitBoxSizing:"border-box",display:"inline-block",boxSizing:"border-box",marginInlineStart:2,position:"relative",fontSize:"smaller",fontWeight:"bold",marginInlineEnd:2,borderRadius:2,width:"1.8rem",color:"blue"});var $F=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Eh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $h={exports:{}};/*!
|
|
1
|
+
(function(no,Js){typeof exports=="object"&&typeof module<"u"?Js(exports):typeof define=="function"&&define.amd?define(["exports"],Js):(no=typeof globalThis<"u"?globalThis:no||self,Js(no["courthive-components"]={}))})(this,function(no){"use strict";var Js,$t="colors",Vr="sizes",Ne="space",qR={gap:Ne,gridGap:Ne,columnGap:Ne,gridColumnGap:Ne,rowGap:Ne,gridRowGap:Ne,inset:Ne,insetBlock:Ne,insetBlockEnd:Ne,insetBlockStart:Ne,insetInline:Ne,insetInlineEnd:Ne,insetInlineStart:Ne,margin:Ne,marginTop:Ne,marginRight:Ne,marginBottom:Ne,marginLeft:Ne,marginBlock:Ne,marginBlockEnd:Ne,marginBlockStart:Ne,marginInline:Ne,marginInlineEnd:Ne,marginInlineStart:Ne,padding:Ne,paddingTop:Ne,paddingRight:Ne,paddingBottom:Ne,paddingLeft:Ne,paddingBlock:Ne,paddingBlockEnd:Ne,paddingBlockStart:Ne,paddingInline:Ne,paddingInlineEnd:Ne,paddingInlineStart:Ne,top:Ne,right:Ne,bottom:Ne,left:Ne,scrollMargin:Ne,scrollMarginTop:Ne,scrollMarginRight:Ne,scrollMarginBottom:Ne,scrollMarginLeft:Ne,scrollMarginX:Ne,scrollMarginY:Ne,scrollMarginBlock:Ne,scrollMarginBlockEnd:Ne,scrollMarginBlockStart:Ne,scrollMarginInline:Ne,scrollMarginInlineEnd:Ne,scrollMarginInlineStart:Ne,scrollPadding:Ne,scrollPaddingTop:Ne,scrollPaddingRight:Ne,scrollPaddingBottom:Ne,scrollPaddingLeft:Ne,scrollPaddingX:Ne,scrollPaddingY:Ne,scrollPaddingBlock:Ne,scrollPaddingBlockEnd:Ne,scrollPaddingBlockStart:Ne,scrollPaddingInline:Ne,scrollPaddingInlineEnd:Ne,scrollPaddingInlineStart:Ne,fontSize:"fontSizes",background:$t,backgroundColor:$t,backgroundImage:$t,borderImage:$t,border:$t,borderBlock:$t,borderBlockEnd:$t,borderBlockStart:$t,borderBottom:$t,borderBottomColor:$t,borderColor:$t,borderInline:$t,borderInlineEnd:$t,borderInlineStart:$t,borderLeft:$t,borderLeftColor:$t,borderRight:$t,borderRightColor:$t,borderTop:$t,borderTopColor:$t,caretColor:$t,color:$t,columnRuleColor:$t,fill:$t,outline:$t,outlineColor:$t,stroke:$t,textDecorationColor:$t,fontFamily:"fonts",fontWeight:"fontWeights",lineHeight:"lineHeights",letterSpacing:"letterSpacings",blockSize:Vr,minBlockSize:Vr,maxBlockSize:Vr,inlineSize:Vr,minInlineSize:Vr,maxInlineSize:Vr,width:Vr,minWidth:Vr,maxWidth:Vr,height:Vr,minHeight:Vr,maxHeight:Vr,flexBasis:Vr,gridTemplateColumns:Vr,gridTemplateRows:Vr,borderWidth:"borderWidths",borderTopWidth:"borderWidths",borderRightWidth:"borderWidths",borderBottomWidth:"borderWidths",borderLeftWidth:"borderWidths",borderStyle:"borderStyles",borderTopStyle:"borderStyles",borderRightStyle:"borderStyles",borderBottomStyle:"borderStyles",borderLeftStyle:"borderStyles",borderRadius:"radii",borderTopLeftRadius:"radii",borderTopRightRadius:"radii",borderBottomRightRadius:"radii",borderBottomLeftRadius:"radii",boxShadow:"shadows",textShadow:"shadows",transition:"transitions",zIndex:"zIndices"},zR=(t,e)=>typeof e=="function"?{"()":Function.prototype.toString.call(e)}:e,al=()=>{const t=Object.create(null);return(e,r,...n)=>{const o=(i=>JSON.stringify(i,zR))(e);return o in t?t[o]:t[o]=r(e,...n)}},qc=Symbol.for("sxs.internal"),Hp=(t,e)=>Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)),_h=t=>{for(const e in t)return!0;return!1},{hasOwnProperty:YR}=Object.prototype,qp=t=>t.includes("-")?t:t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),KR=/\s+(?![^()]*\))/,Zs=t=>e=>t(...typeof e=="string"?String(e).split(KR):[e]),Ih={appearance:t=>({WebkitAppearance:t,appearance:t}),backfaceVisibility:t=>({WebkitBackfaceVisibility:t,backfaceVisibility:t}),backdropFilter:t=>({WebkitBackdropFilter:t,backdropFilter:t}),backgroundClip:t=>({WebkitBackgroundClip:t,backgroundClip:t}),boxDecorationBreak:t=>({WebkitBoxDecorationBreak:t,boxDecorationBreak:t}),clipPath:t=>({WebkitClipPath:t,clipPath:t}),content:t=>({content:t.includes('"')||t.includes("'")||/^([A-Za-z]+\([^]*|[^]*-quote|inherit|initial|none|normal|revert|unset)$/.test(t)?t:`"${t}"`}),hyphens:t=>({WebkitHyphens:t,hyphens:t}),maskImage:t=>({WebkitMaskImage:t,maskImage:t}),maskSize:t=>({WebkitMaskSize:t,maskSize:t}),tabSize:t=>({MozTabSize:t,tabSize:t}),textSizeAdjust:t=>({WebkitTextSizeAdjust:t,textSizeAdjust:t}),userSelect:t=>({WebkitUserSelect:t,userSelect:t}),marginBlock:Zs((t,e)=>({marginBlockStart:t,marginBlockEnd:e||t})),marginInline:Zs((t,e)=>({marginInlineStart:t,marginInlineEnd:e||t})),maxSize:Zs((t,e)=>({maxBlockSize:t,maxInlineSize:e||t})),minSize:Zs((t,e)=>({minBlockSize:t,minInlineSize:e||t})),paddingBlock:Zs((t,e)=>({paddingBlockStart:t,paddingBlockEnd:e||t})),paddingInline:Zs((t,e)=>({paddingInlineStart:t,paddingInlineEnd:e||t}))},zp=/([\d.]+)([^]*)/,QR=(t,e)=>t.length?t.reduce((r,n)=>(r.push(...e.map(o=>o.includes("&")?o.replace(/&/g,/[ +>|~]/.test(n)&&/&.*&/.test(o)?`:is(${n})`:n):n+" "+o)),r),[]):e,JR=(t,e)=>t in ZR&&typeof e=="string"?e.replace(/^((?:[^]*[^\w-])?)(fit-content|stretch)((?:[^\w-][^]*)?)$/,(r,n,o,i)=>n+(o==="stretch"?`-moz-available${i};${qp(t)}:${n}-webkit-fill-available`:`-moz-fit-content${i};${qp(t)}:${n}fit-content`)+i):String(e),ZR={blockSize:1,height:1,inlineSize:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,width:1},Bo=t=>t?t+"-":"",Ph=(t,e,r)=>t.replace(/([+-])?((?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?)?(\$|--)([$\w-]+)/g,(n,o,i,s,a)=>s=="$"==!!i?n:(o||s=="--"?"calc(":"")+"var(--"+(s==="$"?Bo(e)+(a.includes("$")?"":Bo(r))+a.replace(/\$/g,"-"):a)+")"+(o||s=="--"?"*"+(o||"")+(i||"1")+")":"")),XR=/\s*,\s*(?![^()]*\))/,eF=Object.prototype.toString,Xs=(t,e,r,n,o)=>{let i,s,a;const l=(c,u,d)=>{let p,v;const f=m=>{for(p in m){const _=p.charCodeAt(0)===64,I=_&&Array.isArray(m[p])?m[p]:[m[p]];for(v of I){const P=/[A-Z]/.test(h=p)?h:h.replace(/-[^]/g,S=>S[1].toUpperCase()),y=typeof v=="object"&&v&&v.toString===eF&&(!n.utils[P]||!u.length);if(P in n.utils&&!y){const S=n.utils[P];if(S!==s){s=S,f(S(v)),s=null;continue}}else if(P in Ih){const S=Ih[P];if(S!==a){a=S,f(S(v)),a=null;continue}}if(_&&(g=p.slice(1)in n.media?"@media "+n.media[p.slice(1)]:p,p=g.replace(/\(\s*([\w-]+)\s*(=|<|<=|>|>=)\s*([\w-]+)\s*(?:(<|<=|>|>=)\s*([\w-]+)\s*)?\)/g,(S,O,b,w,T,E)=>{const N=zp.test(O),$=.0625*(N?-1:1),[A,U]=N?[w,O]:[O,w];return"("+(b[0]==="="?"":b[0]===">"===N?"max-":"min-")+A+":"+(b[0]!=="="&&b.length===1?U.replace(zp,(C,M,D)=>Number(M)+$*(b===">"?1:-1)+D):U)+(T?") and ("+(T[0]===">"?"min-":"max-")+A+":"+(T.length===1?E.replace(zp,(C,M,D)=>Number(M)+$*(T===">"?-1:1)+D):E):"")+")"})),y){const S=_?d.concat(p):[...d],O=_?[...u]:QR(u,p.split(XR));i!==void 0&&o(yh(...i)),i=void 0,l(v,O,S)}else i===void 0&&(i=[[],u,d]),p=_||p.charCodeAt(0)!==36?p:`--${Bo(n.prefix)}${p.slice(1).replace(/\$/g,"-")}`,v=y?v:typeof v=="number"?v&&P in tF?String(v)+"px":String(v):Ph(JR(P,v??""),n.prefix,n.themeMap[P]),i[0].push(`${_?`${p} `:`${qp(p)}:`}${v}`)}}var g,h};f(c),i!==void 0&&o(yh(...i)),i=void 0};l(t,e,r)},yh=(t,e,r)=>`${r.map(n=>`${n}{`).join("")}${e.length?`${e.join(",")}{`:""}${t.join(";")}${e.length?"}":""}${Array(r.length?r.length+1:0).join("}")}`,tF={animationDelay:1,animationDuration:1,backgroundSize:1,blockSize:1,border:1,borderBlock:1,borderBlockEnd:1,borderBlockEndWidth:1,borderBlockStart:1,borderBlockStartWidth:1,borderBlockWidth:1,borderBottom:1,borderBottomLeftRadius:1,borderBottomRightRadius:1,borderBottomWidth:1,borderEndEndRadius:1,borderEndStartRadius:1,borderInlineEnd:1,borderInlineEndWidth:1,borderInlineStart:1,borderInlineStartWidth:1,borderInlineWidth:1,borderLeft:1,borderLeftWidth:1,borderRadius:1,borderRight:1,borderRightWidth:1,borderSpacing:1,borderStartEndRadius:1,borderStartStartRadius:1,borderTop:1,borderTopLeftRadius:1,borderTopRightRadius:1,borderTopWidth:1,borderWidth:1,bottom:1,columnGap:1,columnRule:1,columnRuleWidth:1,columnWidth:1,containIntrinsicSize:1,flexBasis:1,fontSize:1,gap:1,gridAutoColumns:1,gridAutoRows:1,gridTemplateColumns:1,gridTemplateRows:1,height:1,inlineSize:1,inset:1,insetBlock:1,insetBlockEnd:1,insetBlockStart:1,insetInline:1,insetInlineEnd:1,insetInlineStart:1,left:1,letterSpacing:1,margin:1,marginBlock:1,marginBlockEnd:1,marginBlockStart:1,marginBottom:1,marginInline:1,marginInlineEnd:1,marginInlineStart:1,marginLeft:1,marginRight:1,marginTop:1,maxBlockSize:1,maxHeight:1,maxInlineSize:1,maxWidth:1,minBlockSize:1,minHeight:1,minInlineSize:1,minWidth:1,offsetDistance:1,offsetRotate:1,outline:1,outlineOffset:1,outlineWidth:1,overflowClipMargin:1,padding:1,paddingBlock:1,paddingBlockEnd:1,paddingBlockStart:1,paddingBottom:1,paddingInline:1,paddingInlineEnd:1,paddingInlineStart:1,paddingLeft:1,paddingRight:1,paddingTop:1,perspective:1,right:1,rowGap:1,scrollMargin:1,scrollMarginBlock:1,scrollMarginBlockEnd:1,scrollMarginBlockStart:1,scrollMarginBottom:1,scrollMarginInline:1,scrollMarginInlineEnd:1,scrollMarginInlineStart:1,scrollMarginLeft:1,scrollMarginRight:1,scrollMarginTop:1,scrollPadding:1,scrollPaddingBlock:1,scrollPaddingBlockEnd:1,scrollPaddingBlockStart:1,scrollPaddingBottom:1,scrollPaddingInline:1,scrollPaddingInlineEnd:1,scrollPaddingInlineStart:1,scrollPaddingLeft:1,scrollPaddingRight:1,scrollPaddingTop:1,shapeMargin:1,textDecoration:1,textDecorationThickness:1,textIndent:1,textUnderlineOffset:1,top:1,transitionDelay:1,transitionDuration:1,verticalAlign:1,width:1,wordSpacing:1},Sh=t=>String.fromCharCode(t+(t>25?39:97)),Zi=t=>(e=>{let r,n="";for(r=Math.abs(e);r>52;r=r/52|0)n=Sh(r%52)+n;return Sh(r%52)+n})(((e,r)=>{let n=r.length;for(;n;)e=33*e^r.charCodeAt(--n);return e})(5381,JSON.stringify(t))>>>0),ll=["themed","global","styled","onevar","resonevar","allvar","inline"],rF=t=>{if(t.href&&!t.href.startsWith(location.origin))return!1;try{return!!t.cssRules}catch{return!1}},nF=t=>{let e;const r=()=>{const{cssRules:o}=e.sheet;return[].map.call(o,(i,s)=>{const{cssText:a}=i;let l="";if(a.startsWith("--sxs"))return"";if(o[s-1]&&(l=o[s-1].cssText).startsWith("--sxs")){if(!i.cssRules.length)return"";for(const c in e.rules)if(e.rules[c].group===i)return`--sxs{--sxs:${[...e.rules[c].cache].join(" ")}}${a}`;return i.cssRules.length?`${l}${a}`:""}return a}).join("")},n=()=>{if(e){const{rules:a,sheet:l}=e;if(!l.deleteRule){for(;Object(Object(l.cssRules)[0]).type===3;)l.cssRules.splice(0,1);l.cssRules=[]}for(const c in a)delete a[c]}const o=Object(t).styleSheets||[];for(const a of o)if(rF(a)){for(let l=0,c=a.cssRules;c[l];++l){const u=Object(c[l]);if(u.type!==1)continue;const d=Object(c[l+1]);if(d.type!==4)continue;++l;const{cssText:p}=u;if(!p.startsWith("--sxs"))continue;const v=p.slice(14,-3).trim().split(/\s+/),f=ll[v[0]];f&&(e||(e={sheet:a,reset:n,rules:{},toString:r}),e.rules[f]={group:d,index:l,cache:new Set(v)})}if(e)break}if(!e){const a=(l,c)=>({type:c,cssRules:[],insertRule(u,d){this.cssRules.splice(d,0,a(u,{import:3,undefined:1}[(u.toLowerCase().match(/^@([a-z]+)/)||[])[1]]||4))},get cssText(){return l==="@media{}"?`@media{${[].map.call(this.cssRules,u=>u.cssText).join("")}}`:l}});e={sheet:t?(t.head||t).appendChild(document.createElement("style")).sheet:a("","text/css"),rules:{},reset:n,toString:r}}const{sheet:i,rules:s}=e;for(let a=ll.length-1;a>=0;--a){const l=ll[a];if(!s[l]){const c=ll[a+1],u=s[c]?s[c].index:i.cssRules.length;i.insertRule("@media{}",u),i.insertRule(`--sxs{--sxs:${a}}`,u),s[l]={group:i.cssRules[u+1],index:u,cache:new Set([a])}}oF(s[l])}};return n(),e},oF=t=>{const e=t.group;let r=e.cssRules.length;t.apply=n=>{try{e.insertRule(n,r),++r}catch{}}},cl=Symbol(),iF=al(),sF=(t,e)=>iF(t,()=>(...r)=>{let n={type:null,composers:new Set};for(const o of r)if(o!=null)if(o[qc]){n.type==null&&(n.type=o[qc].type);for(const i of o[qc].composers)n.composers.add(i)}else o.constructor!==Object||o.$$typeof?n.type==null&&(n.type=o):n.composers.add(aF(o,t));return n.type==null&&(n.type="span"),n.composers.size||n.composers.add(["PJLV",{},[],[],{},[]]),lF(t,n,e)}),aF=({variants:t,compoundVariants:e,defaultVariants:r,...n},o)=>{const i=`${Bo(o.prefix)}c-${Zi(n)}`,s=[],a=[],l=Object.create(null),c=[];for(const p in r)l[p]=String(r[p]);if(typeof t=="object"&&t)for(const p in t){u=l,d=p,YR.call(u,d)||(l[p]="undefined");const v=t[p];for(const f in v){const m={[p]:String(f)};String(f)==="undefined"&&c.push(p);const g=v[f],h=[m,g,!_h(g)];s.push(h)}}var u,d;if(typeof e=="object"&&e)for(const p of e){let{css:v,...f}=p;v=typeof v=="object"&&v||{};for(const g in f)f[g]=String(f[g]);const m=[f,v,!_h(v)];a.push(m)}return[i,n,s,a,l,c]},lF=(t,e,r)=>{const[n,o,i,s]=cF(e.composers),a=typeof e.type=="function"||e.type.$$typeof?(d=>{function p(){for(let v=0;v<p[cl].length;v++){const[f,m]=p[cl][v];d.rules[f].apply(m)}return p[cl]=[],null}return p[cl]=[],p.rules={},ll.forEach(v=>p.rules[v]={apply:f=>p[cl].push([v,f])}),p})(r):null,l=(a||r).rules,c=`.${n}${o.length>1?`:where(.${o.slice(1).join(".")})`:""}`,u=d=>{d=typeof d=="object"&&d||uF;const{css:p,...v}=d,f={};for(const h in i)if(delete v[h],h in d){let _=d[h];typeof _=="object"&&_?f[h]={"@initial":i[h],..._}:(_=String(_),f[h]=_!=="undefined"||s.has(h)?_:i[h])}else f[h]=i[h];const m=new Set([...o]);for(const[h,_,I,P]of e.composers){r.rules.styled.cache.has(h)||(r.rules.styled.cache.add(h),Xs(_,[`.${h}`],[],t,O=>{l.styled.apply(O)}));const y=Oh(I,f,t.media),S=Oh(P,f,t.media,!0);for(const O of y)if(O!==void 0)for(const[b,w,T]of O){const E=`${h}-${Zi(w)}-${b}`;m.add(E);const N=(T?r.rules.resonevar:r.rules.onevar).cache,$=T?l.resonevar:l.onevar;N.has(E)||(N.add(E),Xs(w,[`.${E}`],[],t,A=>{$.apply(A)}))}for(const O of S)if(O!==void 0)for(const[b,w]of O){const T=`${h}-${Zi(w)}-${b}`;m.add(T),r.rules.allvar.cache.has(T)||(r.rules.allvar.cache.add(T),Xs(w,[`.${T}`],[],t,E=>{l.allvar.apply(E)}))}}if(typeof p=="object"&&p){const h=`${n}-i${Zi(p)}-css`;m.add(h),r.rules.inline.cache.has(h)||(r.rules.inline.cache.add(h),Xs(p,[`.${h}`],[],t,_=>{l.inline.apply(_)}))}for(const h of String(d.className||"").trim().split(/\s+/))h&&m.add(h);const g=v.className=[...m].join(" ");return{type:e.type,className:g,selector:c,props:v,toString:()=>g,deferredInjector:a}};return Hp(u,{className:n,selector:c,[qc]:e,toString:()=>(r.rules.styled.cache.has(n)||u(),n)})},cF=t=>{let e="";const r=[],n={},o=[];for(const[i,,,,s,a]of t){e===""&&(e=i),r.push(i),o.push(...a);for(const l in s){const c=s[l];(n[l]===void 0||c!=="undefined"||a.includes(c))&&(n[l]=c)}}return[e,r,n,new Set(o)]},Oh=(t,e,r,n)=>{const o=[];e:for(let[i,s,a]of t){if(a)continue;let l,c=0,u=!1;for(l in i){const d=i[l];let p=e[l];if(p!==d){if(typeof p!="object"||!p)continue e;{let v,f,m=0;for(const g in p){if(d===String(p[g])){if(g!=="@initial"){const h=g.slice(1);(f=f||[]).push(h in r?r[h]:g.replace(/^@media ?/,"")),u=!0}c+=m,v=!0}++m}if(f&&f.length&&(s={["@media "+f.join(", ")]:s}),!v)continue e}}}(o[c]=o[c]||[]).push([n?"cv":`${l}-${i[l]}`,s,u])}return o},uF={},dF=al(),pF=(t,e)=>dF(t,()=>(...r)=>{const n=()=>{for(let o of r){o=typeof o=="object"&&o||{};let i=Zi(o);if(!e.rules.global.cache.has(i)){if(e.rules.global.cache.add(i),"@import"in o){let s=[].indexOf.call(e.sheet.cssRules,e.rules.themed.group)-1;for(let a of[].concat(o["@import"]))a=a.includes('"')||a.includes("'")?a:`"${a}"`,e.sheet.insertRule(`@import ${a};`,s++);delete o["@import"]}Xs(o,[],[],t,s=>{e.rules.global.apply(s)})}}return""};return Hp(n,{toString:n})}),fF=al(),vF=(t,e)=>fF(t,()=>r=>{const n=`${Bo(t.prefix)}k-${Zi(r)}`,o=()=>{if(!e.rules.global.cache.has(n)){e.rules.global.cache.add(n);const i=[];Xs(r,[],[],t,a=>i.push(a));const s=`@keyframes ${n}{${i.join("")}}`;e.rules.global.apply(s)}return n};return Hp(o,{get name(){return o()},toString:o})}),mF=class{constructor(t,e,r,n){this.token=t==null?"":String(t),this.value=e==null?"":String(e),this.scale=r==null?"":String(r),this.prefix=n==null?"":String(n)}get computedValue(){return"var("+this.variable+")"}get variable(){return"--"+Bo(this.prefix)+Bo(this.scale)+this.token}toString(){return this.computedValue}},gF=al(),hF=(t,e)=>gF(t,()=>(r,n)=>{n=typeof r=="object"&&r||Object(n);const o=`.${r=(r=typeof r=="string"?r:"")||`${Bo(t.prefix)}t-${Zi(n)}`}`,i={},s=[];for(const l in n){i[l]={};for(const c in n[l]){const u=`--${Bo(t.prefix)}${l}-${c}`,d=Ph(String(n[l][c]),t.prefix,l);i[l][c]=new mF(c,d,l,t.prefix),s.push(`${u}:${d}`)}}const a=()=>{if(s.length&&!e.rules.themed.cache.has(r)){e.rules.themed.cache.add(r);const l=`${n===t.theme?":root,":""}.${r}{${s.join(";")}}`;e.rules.themed.apply(l)}return r};return{...i,get className(){return a()},selector:o,toString:a}}),_F=al(),bh=t=>{let e=!1;const r=_F(t,n=>{e=!0;const o="prefix"in(n=typeof n=="object"&&n||{})?String(n.prefix):"",i=typeof n.media=="object"&&n.media||{},s=typeof n.root=="object"?n.root||null:globalThis.document||null,a=typeof n.theme=="object"&&n.theme||{},l={prefix:o,media:i,theme:a,themeMap:typeof n.themeMap=="object"&&n.themeMap||{...qR},utils:typeof n.utils=="object"&&n.utils||{}},c=nF(s),u={css:sF(l,c),globalCss:pF(l,c),keyframes:vF(l,c),createTheme:hF(l,c),reset(){c.reset(),u.theme.toString()},theme:{},sheet:c,config:l,prefix:o,getCssText:c.toString,toString:c.toString};return String(u.theme=u.createTheme(a)),u});return e||r.reset(),r},IF=()=>Js||(Js=bh()),Ke=(...t)=>IF().css(...t);function PF({variant:t}){return Ke({margin:"2.5px 0",variants:{variant:{showAddress:{lineHeight:"2.3em"}}}})({variant:t})}const Th=Ke({justifyContent:"flex-start",alignItems:"center",whiteSpace:"nowrap",fontWeight:500,display:"flex"}),yF=Ke({textTransform:"$participant$textTransform",fontSize:"0.875rem",fontWeight:500,variants:{variant:{winner:{fontWeight:700,color:"$winnerName"},loser:{fontWeight:500}}}}),SF=Ke({"&::WebkitScrollbar":{display:"none"},justifyContent:"space-between",flexDirection:"column",marginInlineEnd:"0rem",scrollbarWidth:"none",overflowX:"scroll",fontWeight:500,display:"flex",width:"100%",variants:{variant:{doubles:{marginTop:"0.25rem",fontSize:"0.75rem",lineHeight:"1rem"}}}});function OF({drawPosition:t,sideNumber:e}){return Ke({minHeight:"$participant$minHeight",justifyContent:"space-between",paddingInlineStart:"0.75rem",backgroundColor:"$matchUp",paddingInlineEnd:"0rem",boxSizing:"border-box",paddingBottom:".2rem",position:"relative",alignItems:"center",paddingTop:".2rem",minWidth:"15rem",cursor:"pointer",display:"flex",flexGrow:1,"& p":{fontFamily:"Sharp Sans, Arial, sans-serif",color:"$color"},variants:{sideNumber:{1:{borderBottom:"1px solid $internalDividers"}}}})({sideNumber:e,css:t&&{"&:before":{backgroundColor:"$backgroundColor",content:`${t}`,justifyContent:"center",alignContent:"center",insetInlineStart:-10,position:"absolute",color:"#55AFFE",display:"flex",width:20}}})}function bF({winnerChevron:t,isDoubles:e}){const r=(e?.4:.3)*2;return Ke({variants:{variant:{winner:{"&::before":{borderTop:`${r}rem solid transparent`,borderBottom:`${r}rem solid transparent`,borderInlineStart:"8px solid #008f70",position:"absolute",insetInlineStart:0,display:"block",content:""}}}}})({variant:t?"winner":void 0})}const TF=Ke({color:"$participant$seed",marginInlineStart:".5rem",textTransform:"uppercase",fontSize:"0.75rem",lineHeight:"1rem"}),wh=Ke({fontSize:"smaller",color:"gray"});function wF({className:t,composition:e,side:r}){const n=(r==null?void 0:r.seedValue)||(r==null?void 0:r.seedNumber);if(!n)return"";const o=(e==null?void 0:e.configuration)||{},{bracketedSeeds:i}=o,s=typeof i=="boolean"&&["(",")"]||i==="square"&&["[","]"]||["",""],a=`${s[0]}${n}${s[1]}`,l=o.seedingElement==="sup"?"sup":"span",c=document.createElement(l);return c.className=t,c.innerHTML=a,c}const EF=Ke({WebkitBoxSizing:"border-box",marginInlineEnd:".5em",boxSizing:"border-box",display:"inline-block",position:"relative",fontSize:"smaller",fontWeight:"bold",borderRadius:2,width:"1.8rem",color:"blue"});var $F=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Eh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $h={exports:{}};/*!
|
|
2
2
|
Copyright (c) 2018 Jed Watson.
|
|
3
3
|
Licensed under the MIT License (MIT), see
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
5
|
-
*/(function(t){(function(){var e={}.hasOwnProperty;function r(){for(var n=[],o=0;o<arguments.length;o++){var i=arguments[o];if(i){var s=typeof i;if(s==="string"||s==="number")n.push(i);else if(Array.isArray(i)){if(i.length){var a=r.apply(null,i);a&&n.push(a)}}else if(s==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){n.push(i.toString());continue}for(var l in i)e.call(i,l)&&i[l]&&n.push(l)}}}return n.join(" ")}t.exports?(r.default=r,t.exports=r):window.classNames=r})()})($h);var NF=$h.exports;const Xi=Eh(NF);function UF({individualParticipant:t,composition:e,className:r,matchUp:n,spacer:o}){var f,m,g;const i=(n==null?void 0:n.matchUpType)||"SINGLES",s=(f=t==null?void 0:t.ratings)==null?void 0:f[i],a=(m=t==null?void 0:t.rankings)==null?void 0:m[i],l=(g=e==null?void 0:e.configuration)==null?void 0:g.scaleAttributes,c=l==null?void 0:l.scaleType,u=l==null?void 0:l.accessor,d=c==="RATING"?s:a,p=!o&&(d==null?void 0:d[u]),v=document.createElement("span");return(p||o)&&(v.className=Xi(r,EF())),v.innerHTML=p||"",v}const AF="normal",Nh="timed",CF="final",Yp="NOAD",zc="SET",MF={S:AF,F:CF};function Kp(t,e){if(typeof t=="object"){if(t.timed&&!isNaN(t.minutes))return Qp(t);if(t.bestOf&&t.setFormat)return DF(t,e)}}function Yc(t){return!isNaN(Number(t))&&Number(t)}function Qp(t){let e=`T${t.minutes}`;return t.based&&(e+=t.based),t.modifier&&(e+=`@${t.modifier}`),e}function DF(t,e){var r;const n=Yc(t.bestOf);if((r=t.setFormat)!=null&&r.timed&&t.simplified&&n===1)return Qp(t.setFormat);const o=n&&`${zc}${n}`||"",i=Uh(t.setFormat,e),s=i&&`S:${i}`||"",a=Uh(t.finalSetFormat,e),l=n&&n>1&&a&&i!==a&&`F:${a}`||"";if(o&&i)return[o,s,l].filter(u=>u).join("-")}function Uh(t,e){if(typeof t=="object"&&Object.keys(t).length){if(t.timed)return Qp(t);if(t.tiebreakSet)return Ah(t.tiebreakSet);const r=Yc(t.setTo);if(r){const n=t.NoAD&&Yp||"",o=Ah(t.tiebreakFormat),i=o&&`/${o}`||"",s=Yc(t.tiebreakAt),a=s&&(s!==r||e)&&`@${s}`||"";if(o!==!1)return`${r}${n}${i}${a}`}}}function Ah(t){if(t){if(typeof t=="object"&&!t.tiebreakTo)return"";if(typeof t=="object"&&Yc(t.tiebreakTo)){let e=`TB${t.tiebreakTo}${t.NoAD?Yp:""}`;return t.modifier&&(e+=`@${t.modifier}`),e}else return!1}}function Oe(t){return parseInt(typeof t=="number"?t.toString():t)}function Xr(t){return isNaN(t)?!1:t&&(t&t-1)===0}function jF(t){if(!Xr(t))return!1;let e=t,r=1;for(;e!==2;)r+=1,e=e/2;return r}function Jp(t){return isNaN(t)?0:t%2&&t+1||t}function Zp(t){return Math.pow(2,Math.round(Math.log(t)/Math.log(2)))}function Ut(t){return!isNaN(parseFloat(t))}function RF(t){const e=Oe(t);if(!isNaN(e))return e===0?!1:(e&-e)===1}function ea(t){if(isNaN(t))return!1;for(;!Xr(t);)t++;return t}function Br(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}function _t(t){return Number.isSafeInteger(typeof t=="string"?+t:t)}function FF(t=1,e=3,r=!0){let n=0;for(let o=0;o<e;o++)n+=Math.random()*(t/e);return r&&t>1?Math.round(n):n}function xF(t,e){e||(e=1);const r=1/e;return Math.round(t*r)/r}function Ch(t,e,r,n,o=2){const i=1-Math.random(),s=1-Math.random();let a=Math.sqrt(-2*Math.log(i))*Math.cos(2*Math.PI*s);return a=a/10+.5,a>1||a<0?a=Ch(t,e,r):(a=Math.pow(a,r),a*=e-t,a+=t),n&&(a=xF(a,n)),parseFloat(a.toFixed(o))}function Ir(t){if(typeof t=="string"){const e=t.startsWith("T")&&Nh||t.startsWith(zc)&&zc||"";if(e===Nh){const n={simplified:!0,setFormat:Rh(t),bestOf:1};if(n.setFormat)return n}if(e===zc)return LF(t)}}function LF(t){const e=t.split("-"),r=ul(e[0].slice(3)),n=e&&Mh(e[1]),o=e&&Mh(e[2]),i=r&&r<6,s=!e[2]||o,a=n,l={bestOf:r,setFormat:n};if(o&&(l.finalSetFormat=o),i&&a&&s)return l}function Mh(t){if((t==null?void 0:t[1])===":"){const e=t.split(":"),r=MF[e[0]],n=e[1];if(r&&n){if(n.indexOf("TB")===0){const g=jh(n);return g===!1?!1:typeof g=="object"?{tiebreakSet:g}:void 0}if(n.indexOf("T")===0)return Rh(n);const s=t.match(/^[FS]:(\d+)([A-Za-z]*)/),a=s&&Fh(s[2])||!1,l=!(s!=null&&s[2])||a,c=s?ul(s[1]):void 0,u=Dh(n),d=u!==!1,p=d&&u||c,v=jh(n.split("/")[1]),f=v!==!1,m={setTo:c};return a&&(m.NoAD=!0),v?(m.tiebreakFormat=v,m.tiebreakAt=p):m.noTiebreak=!0,c&&l&&f&&d&&m||!1}}}function Dh(t,e=!0){const r=(t==null?void 0:t.indexOf("@"))>0&&t.split("@");if(r)return(e?ul(r[1]):r[1])||!1}function jh(t){if(t)if(t.startsWith("TB")){const e=Dh(t,!1),r=t.match(/^TB(\d+)([A-Za-z]*)/),n=r==null?void 0:r[1],o=r&&Fh(r[2]),i=!(r!=null&&r[2])||o,s=ul(n);if(s&&i){const a={tiebreakTo:s};return e&&typeof e=="string"&&!_t(e)&&(a.modifier=e),o&&(a.NoAD=!0),a}else return!1}else return!1}function Rh(t){var e;const r=t.slice(1),n=r.match(/^(\d+)(@?[A-Za-z]*)/),o=ul(n==null?void 0:n[1]);if(!o)return;const i={timed:!0,minutes:o},s=n==null?void 0:n[2],a=[void 0,"P","G"].includes(s);if(s&&!a){const l=(e=r.match(/^(\d+)(@)([A-Za-z]+)$/))==null?void 0:e[3];return l?(i.modifier=l,i):void 0}return s&&(i.based=n[2]),i}function Fh(t){return t&&t.indexOf(Yp)>=0}function ul(t){return isNaN(Number(t))?0:Number(t)}function en(t){if(typeof t!="string")return!1;const e=Ir(t),r=t.match(/-S:(\d+)+\/TB(\d+)@?(\d*)*/),n=r==null?void 0:r[1],o=r==null?void 0:r[2],i=r==null?void 0:r[3],s=t.match(/-F:(\d+)+\/TB(\d+)@?(\d*)*/),a=s==null?void 0:s[1],l=s==null?void 0:s[2],c=s==null?void 0:s[3];return Kp(e,!!(r&&o&&n===i||s&&l&&a===c))===t}const VF={isValidMatchUpFormat:en,stringify:Kp,isValid:en,parse:Ir};function yo(){return"1.4.31"}function ko(t){if(!t)return;const{tieFormatId:e,tieFormats:r}=t;if(t.tieFormat)return t.tieFormat;if(e&&Array.isArray(r))return r.find(n=>n.tieFormatId===e)}function dl({item:t,drawDefinition:e,structure:r,event:n}){var o,i,s;if(t){if(t.tieFormat)return t.tieFormat;if(t.tieFormatId){if(e.tieFormat)return e.tieFormat;const a=(o=e.tieFormats)==null?void 0:o.find(l=>t.tieFormatId===l.tieFormatId);return a||(n.tieFormat?n.tieFormat:(i=n.tieFormats)==null?void 0:i.find(l=>t.tieFormatId===l.tieFormatId))}if(r.tieFormat)return r.tieFormat;if(r.tieFormatId){const a=(s=e.tieFormats)==null?void 0:s.find(l=>r.tieFormatId===l.tieFormatId);if(a)return a}}}function fr({drawDefinition:t,structure:e,matchUp:r,event:n}){return{tieFormat:dl({item:r,drawDefinition:t,structure:e,event:n})||dl({item:e,drawDefinition:t,structure:e,event:n})||ko(t)||ko(n)}}function or(t){return`${t} must be an array`}function He(t){return t.filter((e,r,n)=>n.lastIndexOf(e)===r)}function vr(t){return t.map(e=>[Math.random(),e]).sort((e,r)=>e[0]-r[0]).map(e=>e[1])}function $r(t){return t.reduce((e,r)=>(e[r]||(e[r]=0),e[r]++,e),{})}function BF(t){return kF($r(t))}function kF(t){return Object.keys(t).reduce((e,r)=>{const n=t[r];return e[n]?e[n].push(r):e[n]=[r],e},{})}function GF(t,e,r){return r.indexOf(t)===e}function xh(t){return t.filter(GF)}function mr(t){return Array.isArray(t)&&t.length?t.splice(Math.floor(Math.random()*t.length),1)[0]:void 0}function Nr(t){const e=Math.floor(Math.random()*t.length);return t[e]}function pe(t,e){return Array.from({length:e-t},(r,n)=>n+t)}function Rn(t,e){return e.reduce((r,n,o)=>(n===t&&r.push(o),r),[])}function Ht(t,e){return!Array.isArray(t)||!Array.isArray(e)?[]:t.filter(r=>e.indexOf(r)!==-1).filter((r,n,o)=>o.indexOf(r)===n)}function Lh(t,e){return!Array.isArray(t)||!Array.isArray(e)?[]:t.filter(r=>!e.includes(r))}function Xt(t,e){return!Array.isArray(t)||!Array.isArray(e)?!1:t.some(r=>e.includes(r))}function qt(t,e){return t.reduce((r,n,o)=>{const i=Math.floor(o/e);return r[i]=[].concat(r[i]||[],n),r},[])}function WF(t){return t.reduce((e,r)=>{const n=e[e.length-1];return(!n||n[n.length-1]!==r-1)&&e.push([]),e[e.length-1].push(r),e},[])}function HF(t){return t.reduce((e,r)=>!isNaN(parseInt(r))&&e,!0)}function qF(t){return t.reduce((e,r)=>isNaN(parseInt(r))&&e,!0)}function Vh(t,e,r){return t.reduce((n,o,i)=>{const s=r?!!(Math.floor(i/e)%2):!1,a=i%e,l=s?e-1-a:a;return n[l]||(n[l]=[]),n[l].push(o),n},[])}const V={success:!0},Bh={message:"Chronological error; time violation.",code:"ANACHRONISM"},zF={message:"Cannot remove main structure",code:"ERR_CANNOT_REMOVE_MAIN_STRUCTURE"},kh={message:"records must be an object with tournamentId keys",code:"ERR_INVALID_TOURNAMENTS"},ke={message:"Missing tournamentRecords",code:"ERR_MISSING_TOURNAMENTS"},re={message:"Missing tournamentRecord",code:"ERR_MISSING_TOURNAMENT"},Kc={message:"Invalid tournamentRecord",code:"ERR_INVALID_TOURNAMENT"},So={message:"Missing tournamentId",code:"ERR_MISSING_TOURNAMENT_ID"},es={message:"Invalid drawDefinition",code:"ERR_INVALID_DRAWDEF"},fe={message:"Missing drawDefinition",code:"ERR_MISSING_DRAWDEF"},YF={message:"Existing drawDefinition(s)",code:"ERR_EXISTING_DRAWDEFS"},tn={message:"drawDefinition not found",code:"ERR_NOT_FOUND_DRAWDEF"},ts={message:"Invalid structure",code:"ERR_INVALID_STRUCTURE"},Gh={message:"Incomplete source structure",code:"ERR_INCOMPLETE_STRUCTURE"},Wh={message:"Invalid drawPosition for seedAssignment",code:"ERR_INVALID_SEEDING_POSITION"},pl={message:"drawPosition already assigned",code:"ERR_EXISTING_POSITION_ASSIGNMENT"},KF={message:"Schedule not cleared",code:"ERR_UNCHANGED_SCHEDULE_NOT_CLEARED"},QF={message:"drawPosition not cleared",code:"ERR_FAILURE_POSITION_NOT_CLEARED"},Hh={message:"Unrecognized drawType",code:"ERR_UNRECOGNIZED_DRAW_TYPE"},Xp={message:"Missing drawPositions",code:"ERR_MISSING_DRAW_POSITIONS"},ef={message:"drawPosition is active",code:"ERR_ACTIVE_DRAW_POSITION"},ta={message:"Invlid drawPosition",code:"ERR_INVALID_DRAW_POSITION"},fl={message:"Missing drawPosition",code:"ERR_MISSING_DRAW_POSITION"},qh={message:"Invalid drawType",code:"ERR_INVALID_DRAW_TYPE"},tf={message:"Invalid drawSize",code:"ERR_INVALID_DRAW_SIZE"},Qc={message:"Cannot set drawSize to be less than existing entries",code:"ERR_INVALID_DRAW_SIZE_MISMATCH"},Jc={message:"Missing drawSize",code:"ERR_MISSING_DRAW_SIZE"},kr={message:"Missing drawId",code:"ERR_MISSING_DRAW_ID"},JF={message:"drawId exists",code:"ERR_EXISTING_DRAW_ID"},ZF={message:"participantId cannot be assigned to multiple seedNumbers",code:"INVALID_PARTICIPANT_SEEDING"},XF={message:"seedsCount greater than drawSize",code:"ERR_INVALID_SEED_COUNT"},ex={message:"Missing seedCountThresholds",code:"ERR_MISSING_SEED_COUNT_THRESHOLD"},tx={message:"Invalid action",code:"ERR_INVALID_ACTION"},zh={message:"Invalid assignment",code:"ERR_INVALID_ASSIGNMENT"},rx={message:"Missing seedAssignments",code:"ERR_MISSING_SEED_ASSIGNMENTS"},nx={message:"Invalid seedNumber",code:"ERR_INVALID_SEED_NUMBER"},ox={message:"Invalid seedPosition",code:"ERR_INVALID_SEED_POSITION"},Yh={message:"Missing targetLink",code:"ERR_MISSING_LINK_TARGET"},ix={message:"Existing round",code:"ERR_EXISTING_ROUND"},Pr={message:"Missing structureId",code:"ERR_MISSING_STRUCTURE_ID"},St={message:"structure not found",code:"ERR_NOT_FOUND_STRUCTURE"},sx={message:"Missing structures",code:"ERR_MISSING_STRUCTURES"},ra={message:"Missing structure",code:"ERR_MISSING_STRUCTURE"},ax={message:"drawDefinition contains unlinked structures",code:"ERR_MISSING_STRUCTURE_LINKS"},Ii={message:"Invalid eventType",code:"ERR_INVALID_EVENT_TYPE"},Ge={message:"Missing event / eventId",code:"ERR_MISSING_EVENT_ID"},Ur={message:"Event not found",code:"ERR_NOT_FOUND_EVENT"},lx={message:"Event exists",code:"ERR_EXISTING_EVENT"},cx={message:"Missing entries",code:"ERR_MISSING_ENTRIES"},ux={message:"Invalid entries",code:"ERR_INVALID_ENTRIES"},Kh={message:"Missing assignments",code:"ERR_MISSING_ASSIGNMENTS"},Qh={message:"Missing stage",code:"ERR_MISSING_STAGE"},Go={message:"Invalid stage",code:"ERR_INVALID_STAGE"},dx={message:"Missing positionAssignments",code:"ERR_MISSING_POSITION_ASSIGNMENTS"},px={message:"Cannot Assign BYE status if no assignment: { bye: true }",code:"ERR_UNCHANGED_CANNOT_ASSIGN_BYE"},Jh={message:"Unrecognized matchUpStatus",code:"ERR_UNRECOGNIZED_MATCHUP_STATUS"},Zc={message:"Unrecognized matchUpFormat",code:"ERR_UNRECOGNIZED_MATCHUP_FORMAT"},rf={message:"Incompatible matchUpStatus",code:"ERR_INCOMPATIBLE_MATCHUP_STATUS"},vl={message:"Invalid matchUpStatus",code:"ERR_INVALID_MATCHUP_STATUS"},Pi={message:"Invalid tieFormat",code:"ERR_INVALID_TIE_FORMAT"},Zh={message:"Invalid matchUpFormat",code:"ERR_INVALID_MATCHUP_FORMAT"},nf={message:"Missing matchUpFormat",code:"ERR_MISSING_MATCHUP_FORMAT"},fx={message:"Missing collectionDefinition",code:"ERR_MISSING_COLLECTION_DEFINITION"},Xc={message:"Missing tieFormat",code:"ERR_MISSING_TIE_FORMAT"},Vt={message:"Missing matchUpId",code:"ERR_MISSING_MATCHUP_ID"},ml={message:"Missing matchUpIds",code:"ERR_MISSING_MATCHUP_IDS"},ir={message:"matchUp not found",code:"ERR_NOT_FOUND_MATCHUP"},Wo={message:"Missing matchUps",code:"ERR_MISSING_MATCHUPS"},jr={message:"Missing matchUp",code:"ERR_MISSING_MATCHUP"},rn={message:"Invalid matchUp",code:"ERR_INVALID_MATCHUP"},Xh={message:"Missing policyType",code:"ERR_MISSING_POLICY_TYPE"},eu={message:"Missing policyDefinitions",code:"ERR_MISSING_POLICY_DEFINITIONS"},vx={message:"Missing avoidance policy",code:"ERR_MISSING_POLICY_AVOIDANCE"},e_={message:"Missing policy attributes",code:"ERR_MISSING_POLICY_ATTRIBUTES"},mx={message:"Invalid policyDefinitions",code:"ERR_INVALID_POLICY_DEFINITIONS"},t_={message:"existing policyType",code:"ERR_EXISTING_POLICY_TYPE"},gx={message:"Policy not attached",code:"ERR_FAILURE_POLICY_NOT_ATTACHED"},of={message:"Policy not found",code:"ERR_NOT_FOUND_POLICY"},hx={message:"Missing scoring policy / matchUpFormats",code:"ERR_MISSING_POLICY_SCORING_MATCHUP_FORMATS"},r_={message:"Invalid sideNumber",code:"ERR_INVALID_SIDE_NUMBER"},sf={message:"Missing setObject",code:"ERR_MISSING_SET_ATTRIBUTE"},na={message:"Missing courtId",code:"ERR_MISSING_COURT_ID"},_e={message:"Missing value",code:"ERR_MISSING_VALUE"},n_={message:"Missing date",code:"ERR_MISSING_DATE"},_x={message:"No valid dates",code:"ERR_NO_VALID_DATES"},af={message:"Invalid bookings",code:"ERR_INVALID_BOOKINGS"},lf={message:"Invalid dateAvailability",code:"ERR_INVALID_DATE_AVAILABILITY"},Ix={message:"Missing dateAvailability",code:"ERR_MISSING_DATE_AVAILABILITY"},yr={message:"Invalid Date",code:"ERR_INVALID_DATE"},nn={message:"Invalid time",code:"ERR_INVALID_TIME"},Px={message:"Invalid tournament dates",code:"ERR_INVALID_DATES_TOURNAMENT"},o_={message:"Invalid game scores",code:"ERR_INVALID_SCORES_GAME"},yx={message:"Invalid score",code:"ERR_INVALID_SCORE"},i_={message:"Invalid winningSide",code:"ERR_INVALID_WINNING_SIDE"},Sx={message:"No participants generated",code:"ERR_NO_PARTICIPANTS_GENERATED"},s_={message:"Cannot modify tieFormat",code:"ERR_UNCHANGED_CANNOT_MODIFY_TIEFORMAT"},Ox={message:"Cannot modify participantType",code:"ERR_UNCHANGED_CANNOT_MODIFY_PARTICIPANT_TYPE"},cf={message:"Cannot remove participants",code:"ERR_UNCHANGED_CANNOT_REMOVE_PARTICIPANTS"},a_={message:"Cannot change winningSide",code:"ERR_UNCHANGED_CANNOT_CHANGE_WINNING_SIDE"},tu={message:"Invalid participant",code:"ERR_INVALID_PARTICIPANT"},Oo={message:"Invalid participantId",code:"ERR_INVALID_PARTICIPANT_ID"},mn={message:"Invalid participantIds",code:"ERR_INVALID_PARTICIPANT_IDS"},bx={message:"Invalid participantRole",code:"ERR_INVALID_PARTICIPANT_ROLE"},Fn={message:"Invalid participantType",code:"ERR_INVALID_PARTICIPANT_TYPE"},Tx={message:"Missing participantRole",code:"ERR_MISSING_PARTICIPANT_ROLE"},oa={message:"Missing participant",code:"ERR_MISSING_PARTICIPANT"},gl={message:"Missing participants",code:"ERR_MISSING_PARTICIPANTS"},Tt={message:"Missing participantId",code:"ERR_MISSING_PARTICIPANT_ID"},Dt={message:"Participant Not Found",code:"ERR_NOT_FOUND_PARTICIPANT"},wx={message:"participantId exists",code:"ERR_EXISTING_PARTICIPANT_ID"},Ex={message:"No participant removed",code:"ERR_UNCHANGED_NO_PARTICIPANT_REMOVED"},bo={message:"Missing participantIds",code:"ERR_MISSING_PARTICIPANT_IDS"},$x={message:"Missing participantsCount",code:"ERR_MISSING_PARTICIPANT_COUNT"},Nx={message:"Participant not checked in",code:"ERR_UNCHANGED_PARTICIPANT_NOT_CHECKED_IN"},l_={message:"Participant already checked in",code:"ERR_UNCHANGED_PARTICIPANT_CHECKED_IN"},Ux={message:"Missing person details",code:"ERR_MISSING_PERSON_DETAILS"},ia={message:"Existing participant drawPosition assignment",code:"ERR_EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT"},uf={message:"Existing participant",code:"ERR_EXISTING_PARTICIPANT"},c_={message:"participantsCount exceeds drawSize",code:"ERR_INVALID_PARTICIPANT_COUNT"},df={message:"Invalid entry status",code:"ERR_INVALID_ENTRY_STATUS"},u_={message:"Participant Entry Not Found",code:"ERR_NOT_FOUND_PARTICIPANT_ENTRY"},Ax={message:"Participant not entered in stage",code:"ERR_UNCHANGED_PARTICIPANT_NOT_ENTERED"},Cx={message:"Participant not found in stageSequence",code:"ERR_NOT_FOUND_PARTICIPANT_IN_STAGE"},Mx={message:"entryStatus not allowed in stage",code:"ERR_INVALID_ENTRY_STATUS_IN_STAGE"},Dx={message:"entryStatus not allowed for event",code:"ERR_INVALID_ENTRY_STATUS_IN_EVENT"},d_={message:"No stage space available for entryStatus",code:"ERR_UNCHANGED_NO_AVAILABLE_STAGE_SPACE"},jx={message:"Insufficient drawPositions to accommodate qualifiers",code:"ERR_UNCHANGED_NO_DRAW_POSITIONS_FOR_QUALIFIERS"},p_={message:"Insufficient drawPositions to accommodate entries",code:"ERR_INSUFFICIENT_DRAW_POSITIONS"},Rx={message:"Missing penaltyType",code:"ERR_MISSING_PENALTY_TYPE"},f_={message:"Missing penaltyId",code:"ERR_MISSING_PENALTY_ID"},ru={message:"Penalty not found",code:"ERR_NOT_FOUND_PENALTY"},Fx={message:"Missing courtsCount/courtNames",code:"ERR_MISSING_COURTS_INFO"},pf={message:"Court not found",code:"ERR_NOT_FOUND_COURT"},xx={message:"Court exists",code:"ERR_EXISTING_COURT"},Lx={message:"Venue exists",code:"ERR_EXISTING_VENUE"},yi={message:"Venue not found",code:"ERR_NOT_FOUND_VENUE"},Ho={message:"Missing venueId",code:"ERR_MISSING_VENUE_ID"},Vx={message:"Invalid endTime",code:"ERR_INVALID_END_TIME"},v_={message:"Existing endTime",code:"ERR_EXISTING_END_TIME"},Bx={message:"Invalid stopTime",code:"ERR_INVALID_STOP_TIME"},kx={message:"Invalid startTime",code:"ERR_INVALID_START_TIME"},Gx={message:"Invalid resumeTime",code:"ERR_INVALID_RESUME_TIME"},m_={message:"Invalid timeItem",code:"ERR_INVALID_TIME_ITEMS"},g_={message:"Missing timeItem",code:"ERR_MISSING_TIME_ITEM"},h_={message:"Missing timeItems",code:"ERR_MISSING_TIME_ITEMS"},nu={message:"Missing context",code:"ERR_MISSING_CONTEXT"},Wx={message:"Missing schedule",code:"ERR_MISSING_SCHEDULE"},ou={message:"Invalid scaleItem",code:"ERR_INVALID_SCALE_ITEM"},Hx={message:"No scaleItem found",code:"ERR_NOT_FOUND_SCALE_ITEM"},qx={message:"Modifications failed",code:"ERR_FAILURE_MODIFICATIONS"},hl={message:"No modifications applied",code:"ERR_UNCHANGED_NO_MODIFICATIONS_APPLIED"},zx={message:"Unable to assign court",code:"ERR_UNCHANGED_COURT_NOT_ASSIGNED"},ff={message:"No Candidates",code:"ERR_UNCHANGED_NO_CANDIDATES"},Yx={message:"Invalid configuration",code:"ERR_INVALID_CONFIG"},oo={message:"Invalid object",code:"ERR_INVALID_OBJECT"},X={message:"Invalid values",code:"ERR_INVALID_VALUES"},Kx={message:"Duplicate value",code:"ERR_DUPLICATE_VALUE"},__={message:"Team not found",code:"ERR_NOT_FOUND_TEAM"},Qx={message:"No valid actions",code:"ERR_NO_VALID_ACTIONS"},vf={message:"No valid attributes",code:"ERR_NO_VALID_ATTRIBUTES"},I_={message:"Value unchanged",code:"ABORT_UNCHANGED"},sr={message:"Not found",code:"ERR_NOT_FOUND"},P_={message:"Not implemented",code:"ERR_NOT_IMPLEMENTED"},Jx={message:"Existing flight",code:"ERR_EXISTING_FLIGHT"},y_={message:"Existing flight profile",code:"ERR_EXISTING_FLIGHT_PROFILE"},Zx={message:"Existing outcome",code:"ERR_EXISTING_OUTCOME"},Xx={message:"Existing matchUpId",code:"ERR_EXISTING_MATCHUP_ID"},S_={message:"Existing stage",code:"ERR_EXISTING_STAGE"},eL={message:"Existing structure",code:"ERR_EXISTING_STRUCTURE"},O_={message:"Method not found",code:"ERR_NOT_FOUND_METHOD"},tL={message:"Scheduled matchUps",code:"ERR_SCHEDULED_MATCHUPS"};var rL=Object.defineProperty,b_=Object.getOwnPropertySymbols,nL=Object.prototype.hasOwnProperty,oL=Object.prototype.propertyIsEnumerable,T_=(t,e,r)=>e in t?rL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,iL=(t,e)=>{for(var r in e||(e={}))nL.call(e,r)&&T_(t,r,e[r]);if(b_)for(var r of b_(e))oL.call(e,r)&&T_(t,r,e[r]);return t};const Pt={disableNotifications:!1,tournamentId:void 0,tournamentRecords:{},subscriptions:{},modified:!1,notices:[]};var sL={addNotice:_L,callListener:OL,cycleMutationStatus:hL,deleteNotice:yL,deleteNotices:PL,disableNotifications:aL,enableNotifications:lL,getNotices:IL,getTopics:SL,getTournamentId:cL,getTournamentRecord:uL,getTournamentRecords:dL,removeTournamentRecord:mL,setSubscriptions:gL,setTournamentId:fL,setTournamentRecord:pL,setTournamentRecords:vL};function aL(){Pt.disableNotifications=!0}function lL(){Pt.disableNotifications=!1}function cL(){return Pt.tournamentId}function uL(t){return Pt.tournamentRecords[t]}function dL(){return Pt.tournamentRecords}function pL(t){const e=t==null?void 0:t.tournamentId;return e?(Pt.tournamentRecords[e]=t,{success:!0}):{error:Kc}}function fL(t){return Pt.tournamentRecords[t]?(Pt.tournamentId=t,{success:!0}):{error:re}}function vL(t){Pt.tournamentRecords=t;const e=Object.keys(t);e.length===1?Pt.tournamentId=e[0]:e.length||(Pt.tournamentId=void 0)}function mL(t){if(typeof t!="string")return{error:X};if(!Pt.tournamentRecords[t])return{error:sr};delete Pt.tournamentRecords[t];const e=Object.keys(Pt.tournamentRecords);return e.length===1?Pt.tournamentId=e[0]:e.length||(Pt.tournamentId=void 0),{success:!0}}function gL(t){return typeof t.subscriptions!="object"?{error:X}:(Object.keys(t.subscriptions).forEach(e=>{Pt.subscriptions[e]=t.subscriptions[e]}),iL({},V))}function hL(){const t=Pt.modified;return Pt.modified=!1,t}function _L({topic:t,payload:e,key:r}){Pt.modified=!0,!(typeof t!="string"||typeof e!="object")&&(Pt.disableNotifications||!Pt.subscriptions[t]||(r&&(Pt.notices=Pt.notices.filter(n=>!(n.topic===t&&n.key===r))),Pt.notices.push({topic:t,payload:e,key:r})))}function IL({topic:t}){const e=Pt.notices.filter(r=>r.topic===t).map(r=>r.payload);return e.length&&e}function PL(){Pt.notices=[]}function yL({topic:t,key:e}){Pt.notices=Pt.notices.filter(r=>(!t||r.topic===t)&&r.key!==e)}function SL(){return{topics:Object.keys(Pt.subscriptions)}}function OL({topic:t,notices:e}){const r=Pt.subscriptions[t];r&&typeof r=="function"&&r(e)}var bL=Object.defineProperty,w_=Object.getOwnPropertySymbols,TL=Object.prototype.hasOwnProperty,wL=Object.prototype.propertyIsEnumerable,E_=(t,e,r)=>e in t?bL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,EL=(t,e)=>{for(var r in e||(e={}))TL.call(e,r)&&E_(t,r,e[r]);if(w_)for(var r of w_(e))wL.call(e,r)&&E_(t,r,e[r]);return t};const on={tournamentFactoryVersion:"0.0.0",timers:{default:{elapsedTime:0}},iterators:{makeDeepCopy:0},deepCopyAttributes:{stringify:[],ignore:[],toJSON:[]},deepCopy:!0};let Rr=sL;function zt(t){var e;return!t||typeof t!="object"?(e=on.devContext)!=null?e:!1:typeof on.devContext!="object"?!1:Object.keys(t).every(r=>{var n;return((n=on.devContext)==null?void 0:n[r])===t[r]})&&on.devContext}function sa(t){on.devContext=t}function $L(t){on.iterators.makeDeepCopy=t}function NL(){return on.iterators.makeDeepCopy}function UL(){Rr.disableNotifications()}function mf(){Rr.enableNotifications()}function rs(t,e){typeof t=="boolean"&&(on.deepCopy=t),typeof e=="object"&&(Array.isArray(e.ignore)&&(on.deepCopyAttributes.ignore=e.ignore),Array.isArray(e.toJSON)&&(on.deepCopyAttributes.toJSON=e.toJSON),Array.isArray(e.stringify)&&(on.deepCopyAttributes.stringify=e.stringify),e.threshold&&(on.deepCopyAttributes.threshold=e.threshold))}function $_(){return EL({enabled:on.deepCopy},on.deepCopyAttributes)}function _l(){return Rr.cycleMutationStatus()}function qe(t){return Rr.addNotice(t)}function AL(t){return Rr.getNotices(t)}function N_({key:t,topic:e}){return Rr.deleteNotice({key:t,topic:e})}function Si(){return Rr.deleteNotices()}function xn(){return Rr.getTopics()}async function U_(t){return Rr.callListener(t)}function gn(){return Rr.getTournamentId()}function Il(t){return Rr.getTournamentRecord(t)}function iu(){return Rr.getTournamentRecords()}function A_(t){return Rr.setTournamentRecord(t)}function Pl(t){return Rr.setTournamentRecords(t)}function yl(t){return Rr.setTournamentId(t)}function gf(t){return Rr.removeTournamentRecord(t)}function ns(t){return typeof t=="object"}const CL=t=>e=>Object.keys(t).every(r=>e[r]===t[r]),sn=t=>e=>!t||typeof e!="object"?void 0:Array.isArray(t)&&t.map(r=>({[r]:e[r]}))||typeof t=="object"&&Object.keys(t).map(r=>({[r]:e[r]}))||typeof t=="string"&&ML(e,t);function ML(t,e){const r=e.split(".");for(const n of r)if(t=t==null?void 0:t[n],!t)return;return t}function ye(t,e,r,n){if(typeof t!="object"||t===null)return t;const o=$_();o!=null&&o.enabled||(n=!0);const i=["",void 0,null];e&&i.push(!1);const s=Object.keys(t).filter(a=>!i.includes(t[a])&&(!r||(Array.isArray(t[a])?t[a].length:!0)));return Object.assign({},...s.map(a=>Array.isArray(t[a])?{[a]:n?t[a]:t[a].map(l=>ye(l))}:{[a]:n?t[a]:ye(t[a])}))}function hf(t){return Array.isArray(t)?t.length+t.map(hf).reduce((e,r)=>e+r,0):typeof t=="object"&&t!==null?Object.keys(t).length+Object.keys(t).map(e=>hf(t[e])).reduce((e,r)=>e+r,0):0}function DL(t){if(t===null||typeof t!="object")return;const e=JSON.stringify(t),r=hf(t),n=e.split("").reduce((o,i)=>o+i.charCodeAt(0),0);return[e.length,r,n].map(o=>o.toString(36)).join("")}function su(t){if(t===null)return{};const{source:e,template:r}=t||{};if(!r)return e;const n={};return o(e,r,n),n;function o(i,s,a){if(!i||!s)return;const l=Object.keys(i),c=Object.keys(s),u=Object.assign({},...c.filter(v=>v.indexOf("||")).map(v=>v.split("||").map(f=>({[f]:v}))).flat()),d=c.concat(...Object.keys(u)),p=d.includes("*");for(const v of l)if(d.indexOf(v)>=0||p){const f=u[v]||v,m=s[f]||p,g=i[v];if(typeof m=="object"&&typeof g!="function"&&!Array.isArray(m))if(Array.isArray(g)){const h=g.map(_=>{const I={};return o(_,m,I)!==!1?I:void 0}).filter(Boolean);a[v]=h}else g&&(a[v]={},o(g,m,a[v]));else{const h=i[v];if(Array.isArray(m)&&!m.includes(h))return!1;(s[v]||p&&s[v]!==!1)&&(a[v]=h)}}}}function C_(t=0){const e=new Date;return e.setHours(e.getHours()+t),e.getTime().toString(36).slice(-6).toUpperCase()}const au=/^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/,M_=/^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/,Ln=/^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))([ T](0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/,Oi=/^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))?([ T]?(0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;function lu(t){let{scheduledDate:e}=t;if(!e&&t.scheduledTime&&(e=Re(t.scheduledTime)),!e)return;const r=ct(t.scheduledTime);let n=Re(e);return n&&r&&(n+=`T${r}`),n}function jL(t){return typeof t!="object"||Array.isArray(t)?!1:Object.prototype.toString.call(t)==="[object Date]"}function aa(t){const e=typeof t=="string"?t==null?void 0:t.split(" "):[];return t&&(e==null?void 0:e.length)>1&&!["AM","PM"].includes(e[1].toUpperCase())?!1:!!(!t||Oi.test(os(t,!0,!0)))}function Gr(t){return bi(t)||au.test(t)}function RL(t){const e=new Date(t),r=e.getSeconds()+60*e.getMinutes()+60*60*e.getHours();return FL(r,{displaySeconds:!1})}function FL(t,e){const r=parseInt(t,10),n=Math.floor(r/3600),o=Math.floor((r-n*3600)/60),i=r-n*3600-o*60;return(!e||(e==null?void 0:e.displaySeconds)?n+":"+o+":"+i:n+":"+o).split(":").map(io).join(":")}const _f=t=>{const e=Sl(t)||bi(t)?new Date(t):new Date,r=e.getUTCMonth()+1,n=r<10?`0${r}`:`${r}`;return`${e.getUTCFullYear()}-${io(n)}-${io(e.getUTCDate())}`};function xL(t){const e=Sl(t)||bi(t)?new Date(t):new Date;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function hn(t,e="-",r="YMD"){if(!t)return"";typeof t=="string"&&t.indexOf("T")<0&&(t=t+"T00:00");const n=new Date(t);let o=""+(n.getMonth()+1),i=""+n.getDate();const s=n.getFullYear();return o.length<2&&(o="0"+o),i.length<2&&(i="0"+i),r==="DMY"?[i,o,s].join(e):r==="MDY"?[o,i,s].join(e):r==="YDM"?[s,i,o].join(e):r==="DYM"?[i,s,o].join(e):r==="MYD"?[o,s,i].join(e):[s,o,i].join(e)}function cu(t){const e=t?new Date(t):new Date,r=e.getTimezoneOffset();return new Date(e.getTime()-r*60*1e3)}function LL(t){return cu(t).getTime()}function Sl(t){if(typeof t=="boolean")return!1;const e=t instanceof Date&&t||!isNaN(t)&&new Date(t)||!1;return e&&!isNaN(e.valueOf())}function If(t,e){if(!Gr(t)||!Gr(e))return[];const r=Re(t)+"T00:00",n=Re(e)+"T00:00",o=new Date(r),i=new Date(n),s=Sl(i)&&Sl(o)&&c(o,i),a=[];let l=0;if(s){const u=o;let d=u.getTime();for(;d<=i.getTime()&&l<300;)l+=1,a.push(new Date(u)),d=u.setDate(u.getDate()+1)}return a.map(u=>hn(u));function c(u,d){return u<=d}}const VL=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function bi(t){return typeof t!="string"?!1:VL.test(t)}function D_(t){if(typeof t!="string")return!1;const r=t.split("Z")[0].split(":"),n=r.every(i=>!isNaN(parseInt(i)));return!(r.length<2||!n||parseInt(r[0])>23||parseInt(r[1])>60)}function xe(t){const e=ct(t);if(!e)return 0;const[r,n]=e.split(":").map(o=>parseInt(o));return r*60+n}function BL(t){let e=Math.floor(t/60);const r=t-e*60;return e>23&&(e=e%24),[io(e),io(r)].join(":")}function uu(t){return D_(t)?t.split(":").slice(0,2).map(io).join(":"):void 0}function ct(t){return bi(t)&&t.indexOf("T")>0?uu(t.split("T").reverse()[0]):uu(t)}function Re(t){return bi(t)||Ln.test(t)?t.split("T")[0]:void 0}function kL(t,e){const r=new Date(t);return r.setDate(r.getDate()+e),Re(r.toISOString())}function du(t){t=typeof t!="string"?"00:00":t;const e={},r={};return{0:e.time,1:e.ampm}=t.split(" ")||[],{0:r.hours,1:r.minutes}=e.time.split(":")||[],r.ampm=e.ampm,isNaN(r.hours)||isNaN(r.minutes)||r.ampm&&!["AM","PM"].includes(r.ampm.toUpperCase())?{}:r}function GL(t){const e=du(t);return e.ampm&&e.hours&&(e.ampm.toLowerCase()==="pm"&&parseInt(e.hours)<12&&(e.hours=(e.hours&&parseInt(e.hours)||0)+12),e.ampm.toLowerCase()==="am"&&e.hours==="12"&&(e.hours="00")),`${e.hours||"12"}:${e.minutes||"00"}`.split(":").map(io).join(":")}function WL(t){var e;const r=du(t);if(!(typeof r=="object"&&!Object.keys(r).length))return r.ampm?t:(r.hours>12?(r.hours-=12,r.ampm="PM"):r.hours==="12"?r.ampm="PM":(r.hours==="00"&&(r.hours="12"),r.ampm="AM"),((e=r.hours)==null?void 0:e[0])==="0"&&(r.hours=r.hours.slice(1)),`${r.hours||"12"}:${r.minutes||"00"} ${r.ampm}`)}function os(t,e,r){const n=Re(t),o=ct(t),i=n?o:t;return t?e&&(n&&r&&t||GL(i))||WL(i):void 0}function j_(t,e){const r=du(t),n=du(e);if(parseInt(r.hours)<parseInt(n.hours))return-1;if(parseInt(r.hours)>parseInt(n.hours))return 1;if(r.hours===n.hours){if(parseInt(r.minutes)<parseInt(n.minutes))return-1;if(parseInt(r.minutes)>parseInt(n.minutes))return 1}return 0}function R_(t,e=7){const r=Re(t)+"T00:00",n=new Date(r),o=new Date(n.setDate(n.getDate()+e));return hn(o)}function HL(t){return R_(t)}function qL(t,e,r,n=!1){const o=new Date(e,0,1+(t-1)*7),i=n?0:1;return o.setDate(o.getDate()+(i-o.getDay())),hn(o,r)}function zL(t,e,r){const n=new Date(t,0);return hn(new Date(n.setDate(e)),r)}function wt(t,e=void 0){const[r,n]=(t||"00:00").split(":").map(io),o=cu(e).setHours(r,n,0,0);return cu(o)}function Ol(t,e,r=!0){const n=new Date(t),i=(new Date(e).getTime()-n.getTime())/1e3/60;return r?Math.abs(Math.round(i)):Math.round(i)}function Sr(t,e){const r=ct(t);if(!r)return"00:00";const n=isNaN(e)?0:e;return ct(Pf(wt(r),n).toISOString())}function Pf(t,e){const r=new Date(t);return new Date(r.getTime()+e*6e4)}function io(t){return t.toString()[1]?t:"0"+t}function so(t,e){const r=new Date(t),n=new Date(e);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()&&r.getDate()===n.getDate()}const YL={addDays:R_,addWeek:HL,addMinutesToTimeString:Sr,convertTime:os,getIsoDateString:lu,getUTCdateString:_f,DateHHMM:RL,extractDate:Re,extractTime:ct,formatDate:hn,getDateByWeek:qL,isISODateString:bi,isDate:Sl,isTimeString:D_,offsetDate:cu,offsetTime:LL,sameDay:so,timeStringMinutes:xe,timeToDate:wt,timeUTC:xL,validTimeValue:aa,validDateString:au,timeValidation:Oi,dateValidation:Ln};function ve(t,e,r,n,o=0){const i=$_(),{stringify:s,toJSON:a,ignore:l,modulate:c}=i||{};if(!(i!=null&&i.enabled)&&!r||typeof t!="object"||typeof t=="function"||t===null||typeof(i==null?void 0:i.threshold)=="number"&&o>=i.threshold)return t;const u=zt({makeDeepCopy:!0});u&&($L(o),typeof u=="object"&&(o>(u.iterationThreshold||15)||u.firstIteration&&o===0)&&u.log&&(!u.notInternalUse||u.notInternalUse&&!r)&&console.log({devContext:u,iteration:o,internalUse:r},t));const d=Array.isArray(t)?[]:{},p=Object.keys(t).filter(f=>!r||!l||Array.isArray(l)&&!l.includes(f)||typeof l=="function"&&!l(f)),v=(f,m)=>{d[f]=typeof(m==null?void 0:m.toString)=="function"?m.toString():JSON.stringify(m)};for(const f of p){const m=t[f],g=typeof c=="function"?c(m):void 0;if(g!==void 0)d[f]=g;else if(e&&f==="extensions"&&Array.isArray(m)){const h=yf(m);Object.assign(d,...h)}else n&&f==="extensions"?d[f]=[]:Array.isArray(s)&&s.includes(f)?v(f,m):Array.isArray(a)&&a.includes(f)&&typeof(m==null?void 0:m.toJSON)=="function"?d[f]=m.toJSON():m===null?d[f]=void 0:jL(m)?d[f]=new Date(m).toISOString():d[f]=ve(m,e,r,n,o+1)}return d}function yf(t){return t==null?void 0:t.map(e=>{const{name:r,value:n}=e;return r&&n&&{[`_${r}`]:n}}).filter(Boolean)}function er(t,e){return t-e}function KL(t,e){if(e&&typeof e!="object")return X;let{columnTransform:r={}}=e||{};const{includeTransformAccessors:n,includeHeaderRow:o=!0,returnTransformedJSON:i,removeEmptyColumns:s,onlyHeaderRow:a,columnAccessors:l=[],functionMap:c={},columnMap:u={},valuesMap:d={},context:p={},delimiter:v='"',columnJoiner:f=",",rowJoiner:m=`\r
|
|
5
|
+
*/(function(t){(function(){var e={}.hasOwnProperty;function r(){for(var n=[],o=0;o<arguments.length;o++){var i=arguments[o];if(i){var s=typeof i;if(s==="string"||s==="number")n.push(i);else if(Array.isArray(i)){if(i.length){var a=r.apply(null,i);a&&n.push(a)}}else if(s==="object"){if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]")){n.push(i.toString());continue}for(var l in i)e.call(i,l)&&i[l]&&n.push(l)}}}return n.join(" ")}t.exports?(r.default=r,t.exports=r):window.classNames=r})()})($h);var NF=$h.exports;const Xi=Eh(NF);function UF({individualParticipant:t,composition:e,className:r,matchUp:n,spacer:o}){var g,h,_,I;const i=(n==null?void 0:n.matchUpType)||"SINGLES",s=(g=t==null?void 0:t.ratings)==null?void 0:g[i],a=(h=t==null?void 0:t.rankings)==null?void 0:h[i],l=(_=e==null?void 0:e.configuration)==null?void 0:_.scaleAttributes,c=l==null?void 0:l.scaleType,u=l==null?void 0:l.scaleName,d=l==null?void 0:l.accessor,p=c==="RATING"?s:a,v=!o&&((I=p==null?void 0:p.find(P=>(P==null?void 0:P.scaleName)===u))==null?void 0:I.scaleValue),f=v&&d?v[d]:v||"",m=document.createElement("span");return f&&(m.className=Xi(r,EF())),m.innerHTML=f||"",m}const AF="normal",Nh="timed",CF="final",Yp="NOAD",zc="SET",MF={S:AF,F:CF};function Kp(t,e){if(typeof t=="object"){if(t.timed&&!isNaN(t.minutes))return Qp(t);if(t.bestOf&&t.setFormat)return DF(t,e)}}function Yc(t){return!isNaN(Number(t))&&Number(t)}function Qp(t){let e=`T${t.minutes}`;return t.based&&(e+=t.based),t.modifier&&(e+=`@${t.modifier}`),e}function DF(t,e){var r;const n=Yc(t.bestOf);if((r=t.setFormat)!=null&&r.timed&&t.simplified&&n===1)return Qp(t.setFormat);const o=n&&`${zc}${n}`||"",i=Uh(t.setFormat,e),s=i&&`S:${i}`||"",a=Uh(t.finalSetFormat,e),l=n&&n>1&&a&&i!==a&&`F:${a}`||"";if(o&&i)return[o,s,l].filter(u=>u).join("-")}function Uh(t,e){if(typeof t=="object"&&Object.keys(t).length){if(t.timed)return Qp(t);if(t.tiebreakSet)return Ah(t.tiebreakSet);const r=Yc(t.setTo);if(r){const n=t.NoAD&&Yp||"",o=Ah(t.tiebreakFormat),i=o&&`/${o}`||"",s=Yc(t.tiebreakAt),a=s&&(s!==r||e)&&`@${s}`||"";if(o!==!1)return`${r}${n}${i}${a}`}}}function Ah(t){if(t){if(typeof t=="object"&&!t.tiebreakTo)return"";if(typeof t=="object"&&Yc(t.tiebreakTo)){let e=`TB${t.tiebreakTo}${t.NoAD?Yp:""}`;return t.modifier&&(e+=`@${t.modifier}`),e}else return!1}}function Oe(t){return parseInt(typeof t=="number"?t.toString():t)}function Xr(t){return isNaN(t)?!1:t&&(t&t-1)===0}function jF(t){if(!Xr(t))return!1;let e=t,r=1;for(;e!==2;)r+=1,e=e/2;return r}function Jp(t){return isNaN(t)?0:t%2&&t+1||t}function Zp(t){return Math.pow(2,Math.round(Math.log(t)/Math.log(2)))}function Ut(t){return!isNaN(parseFloat(t))}function RF(t){const e=Oe(t);if(!isNaN(e))return e===0?!1:(e&-e)===1}function ea(t){if(isNaN(t))return!1;for(;!Xr(t);)t++;return t}function Br(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}function _t(t){return Number.isSafeInteger(typeof t=="string"?+t:t)}function FF(t=1,e=3,r=!0){let n=0;for(let o=0;o<e;o++)n+=Math.random()*(t/e);return r&&t>1?Math.round(n):n}function xF(t,e){e||(e=1);const r=1/e;return Math.round(t*r)/r}function Ch(t,e,r,n,o=2){const i=1-Math.random(),s=1-Math.random();let a=Math.sqrt(-2*Math.log(i))*Math.cos(2*Math.PI*s);return a=a/10+.5,a>1||a<0?a=Ch(t,e,r):(a=Math.pow(a,r),a*=e-t,a+=t),n&&(a=xF(a,n)),parseFloat(a.toFixed(o))}function Ir(t){if(typeof t=="string"){const e=t.startsWith("T")&&Nh||t.startsWith(zc)&&zc||"";if(e===Nh){const n={simplified:!0,setFormat:Rh(t),bestOf:1};if(n.setFormat)return n}if(e===zc)return LF(t)}}function LF(t){const e=t.split("-"),r=ul(e[0].slice(3)),n=e&&Mh(e[1]),o=e&&Mh(e[2]),i=r&&r<6,s=!e[2]||o,a=n,l={bestOf:r,setFormat:n};if(o&&(l.finalSetFormat=o),i&&a&&s)return l}function Mh(t){if((t==null?void 0:t[1])===":"){const e=t.split(":"),r=MF[e[0]],n=e[1];if(r&&n){if(n.indexOf("TB")===0){const g=jh(n);return g===!1?!1:typeof g=="object"?{tiebreakSet:g}:void 0}if(n.indexOf("T")===0)return Rh(n);const s=t.match(/^[FS]:(\d+)([A-Za-z]*)/),a=s&&Fh(s[2])||!1,l=!(s!=null&&s[2])||a,c=s?ul(s[1]):void 0,u=Dh(n),d=u!==!1,p=d&&u||c,v=jh(n.split("/")[1]),f=v!==!1,m={setTo:c};return a&&(m.NoAD=!0),v?(m.tiebreakFormat=v,m.tiebreakAt=p):m.noTiebreak=!0,c&&l&&f&&d&&m||!1}}}function Dh(t,e=!0){const r=(t==null?void 0:t.indexOf("@"))>0&&t.split("@");if(r)return(e?ul(r[1]):r[1])||!1}function jh(t){if(t)if(t.startsWith("TB")){const e=Dh(t,!1),r=t.match(/^TB(\d+)([A-Za-z]*)/),n=r==null?void 0:r[1],o=r&&Fh(r[2]),i=!(r!=null&&r[2])||o,s=ul(n);if(s&&i){const a={tiebreakTo:s};return e&&typeof e=="string"&&!_t(e)&&(a.modifier=e),o&&(a.NoAD=!0),a}else return!1}else return!1}function Rh(t){var e;const r=t.slice(1),n=r.match(/^(\d+)(@?[A-Za-z]*)/),o=ul(n==null?void 0:n[1]);if(!o)return;const i={timed:!0,minutes:o},s=n==null?void 0:n[2],a=[void 0,"P","G"].includes(s);if(s&&!a){const l=(e=r.match(/^(\d+)(@)([A-Za-z]+)$/))==null?void 0:e[3];return l?(i.modifier=l,i):void 0}return s&&(i.based=n[2]),i}function Fh(t){return t&&t.indexOf(Yp)>=0}function ul(t){return isNaN(Number(t))?0:Number(t)}function en(t){if(typeof t!="string")return!1;const e=Ir(t),r=t.match(/-S:(\d+)+\/TB(\d+)@?(\d*)*/),n=r==null?void 0:r[1],o=r==null?void 0:r[2],i=r==null?void 0:r[3],s=t.match(/-F:(\d+)+\/TB(\d+)@?(\d*)*/),a=s==null?void 0:s[1],l=s==null?void 0:s[2],c=s==null?void 0:s[3];return Kp(e,!!(r&&o&&n===i||s&&l&&a===c))===t}const VF={isValidMatchUpFormat:en,stringify:Kp,isValid:en,parse:Ir};function yo(){return"1.4.31"}function ko(t){if(!t)return;const{tieFormatId:e,tieFormats:r}=t;if(t.tieFormat)return t.tieFormat;if(e&&Array.isArray(r))return r.find(n=>n.tieFormatId===e)}function dl({item:t,drawDefinition:e,structure:r,event:n}){var o,i,s;if(t){if(t.tieFormat)return t.tieFormat;if(t.tieFormatId){if(e.tieFormat)return e.tieFormat;const a=(o=e.tieFormats)==null?void 0:o.find(l=>t.tieFormatId===l.tieFormatId);return a||(n.tieFormat?n.tieFormat:(i=n.tieFormats)==null?void 0:i.find(l=>t.tieFormatId===l.tieFormatId))}if(r.tieFormat)return r.tieFormat;if(r.tieFormatId){const a=(s=e.tieFormats)==null?void 0:s.find(l=>r.tieFormatId===l.tieFormatId);if(a)return a}}}function fr({drawDefinition:t,structure:e,matchUp:r,event:n}){return{tieFormat:dl({item:r,drawDefinition:t,structure:e,event:n})||dl({item:e,drawDefinition:t,structure:e,event:n})||ko(t)||ko(n)}}function or(t){return`${t} must be an array`}function He(t){return t.filter((e,r,n)=>n.lastIndexOf(e)===r)}function vr(t){return t.map(e=>[Math.random(),e]).sort((e,r)=>e[0]-r[0]).map(e=>e[1])}function $r(t){return t.reduce((e,r)=>(e[r]||(e[r]=0),e[r]++,e),{})}function BF(t){return kF($r(t))}function kF(t){return Object.keys(t).reduce((e,r)=>{const n=t[r];return e[n]?e[n].push(r):e[n]=[r],e},{})}function GF(t,e,r){return r.indexOf(t)===e}function xh(t){return t.filter(GF)}function mr(t){return Array.isArray(t)&&t.length?t.splice(Math.floor(Math.random()*t.length),1)[0]:void 0}function Nr(t){const e=Math.floor(Math.random()*t.length);return t[e]}function pe(t,e){return Array.from({length:e-t},(r,n)=>n+t)}function Rn(t,e){return e.reduce((r,n,o)=>(n===t&&r.push(o),r),[])}function Ht(t,e){return!Array.isArray(t)||!Array.isArray(e)?[]:t.filter(r=>e.indexOf(r)!==-1).filter((r,n,o)=>o.indexOf(r)===n)}function Lh(t,e){return!Array.isArray(t)||!Array.isArray(e)?[]:t.filter(r=>!e.includes(r))}function Xt(t,e){return!Array.isArray(t)||!Array.isArray(e)?!1:t.some(r=>e.includes(r))}function qt(t,e){return t.reduce((r,n,o)=>{const i=Math.floor(o/e);return r[i]=[].concat(r[i]||[],n),r},[])}function WF(t){return t.reduce((e,r)=>{const n=e[e.length-1];return(!n||n[n.length-1]!==r-1)&&e.push([]),e[e.length-1].push(r),e},[])}function HF(t){return t.reduce((e,r)=>!isNaN(parseInt(r))&&e,!0)}function qF(t){return t.reduce((e,r)=>isNaN(parseInt(r))&&e,!0)}function Vh(t,e,r){return t.reduce((n,o,i)=>{const s=r?!!(Math.floor(i/e)%2):!1,a=i%e,l=s?e-1-a:a;return n[l]||(n[l]=[]),n[l].push(o),n},[])}const V={success:!0},Bh={message:"Chronological error; time violation.",code:"ANACHRONISM"},zF={message:"Cannot remove main structure",code:"ERR_CANNOT_REMOVE_MAIN_STRUCTURE"},kh={message:"records must be an object with tournamentId keys",code:"ERR_INVALID_TOURNAMENTS"},ke={message:"Missing tournamentRecords",code:"ERR_MISSING_TOURNAMENTS"},re={message:"Missing tournamentRecord",code:"ERR_MISSING_TOURNAMENT"},Kc={message:"Invalid tournamentRecord",code:"ERR_INVALID_TOURNAMENT"},So={message:"Missing tournamentId",code:"ERR_MISSING_TOURNAMENT_ID"},es={message:"Invalid drawDefinition",code:"ERR_INVALID_DRAWDEF"},fe={message:"Missing drawDefinition",code:"ERR_MISSING_DRAWDEF"},YF={message:"Existing drawDefinition(s)",code:"ERR_EXISTING_DRAWDEFS"},tn={message:"drawDefinition not found",code:"ERR_NOT_FOUND_DRAWDEF"},ts={message:"Invalid structure",code:"ERR_INVALID_STRUCTURE"},Gh={message:"Incomplete source structure",code:"ERR_INCOMPLETE_STRUCTURE"},Wh={message:"Invalid drawPosition for seedAssignment",code:"ERR_INVALID_SEEDING_POSITION"},pl={message:"drawPosition already assigned",code:"ERR_EXISTING_POSITION_ASSIGNMENT"},KF={message:"Schedule not cleared",code:"ERR_UNCHANGED_SCHEDULE_NOT_CLEARED"},QF={message:"drawPosition not cleared",code:"ERR_FAILURE_POSITION_NOT_CLEARED"},Hh={message:"Unrecognized drawType",code:"ERR_UNRECOGNIZED_DRAW_TYPE"},Xp={message:"Missing drawPositions",code:"ERR_MISSING_DRAW_POSITIONS"},ef={message:"drawPosition is active",code:"ERR_ACTIVE_DRAW_POSITION"},ta={message:"Invlid drawPosition",code:"ERR_INVALID_DRAW_POSITION"},fl={message:"Missing drawPosition",code:"ERR_MISSING_DRAW_POSITION"},qh={message:"Invalid drawType",code:"ERR_INVALID_DRAW_TYPE"},tf={message:"Invalid drawSize",code:"ERR_INVALID_DRAW_SIZE"},Qc={message:"Cannot set drawSize to be less than existing entries",code:"ERR_INVALID_DRAW_SIZE_MISMATCH"},Jc={message:"Missing drawSize",code:"ERR_MISSING_DRAW_SIZE"},kr={message:"Missing drawId",code:"ERR_MISSING_DRAW_ID"},JF={message:"drawId exists",code:"ERR_EXISTING_DRAW_ID"},ZF={message:"participantId cannot be assigned to multiple seedNumbers",code:"INVALID_PARTICIPANT_SEEDING"},XF={message:"seedsCount greater than drawSize",code:"ERR_INVALID_SEED_COUNT"},ex={message:"Missing seedCountThresholds",code:"ERR_MISSING_SEED_COUNT_THRESHOLD"},tx={message:"Invalid action",code:"ERR_INVALID_ACTION"},zh={message:"Invalid assignment",code:"ERR_INVALID_ASSIGNMENT"},rx={message:"Missing seedAssignments",code:"ERR_MISSING_SEED_ASSIGNMENTS"},nx={message:"Invalid seedNumber",code:"ERR_INVALID_SEED_NUMBER"},ox={message:"Invalid seedPosition",code:"ERR_INVALID_SEED_POSITION"},Yh={message:"Missing targetLink",code:"ERR_MISSING_LINK_TARGET"},ix={message:"Existing round",code:"ERR_EXISTING_ROUND"},Pr={message:"Missing structureId",code:"ERR_MISSING_STRUCTURE_ID"},St={message:"structure not found",code:"ERR_NOT_FOUND_STRUCTURE"},sx={message:"Missing structures",code:"ERR_MISSING_STRUCTURES"},ra={message:"Missing structure",code:"ERR_MISSING_STRUCTURE"},ax={message:"drawDefinition contains unlinked structures",code:"ERR_MISSING_STRUCTURE_LINKS"},Ii={message:"Invalid eventType",code:"ERR_INVALID_EVENT_TYPE"},Ge={message:"Missing event / eventId",code:"ERR_MISSING_EVENT_ID"},Ur={message:"Event not found",code:"ERR_NOT_FOUND_EVENT"},lx={message:"Event exists",code:"ERR_EXISTING_EVENT"},cx={message:"Missing entries",code:"ERR_MISSING_ENTRIES"},ux={message:"Invalid entries",code:"ERR_INVALID_ENTRIES"},Kh={message:"Missing assignments",code:"ERR_MISSING_ASSIGNMENTS"},Qh={message:"Missing stage",code:"ERR_MISSING_STAGE"},Go={message:"Invalid stage",code:"ERR_INVALID_STAGE"},dx={message:"Missing positionAssignments",code:"ERR_MISSING_POSITION_ASSIGNMENTS"},px={message:"Cannot Assign BYE status if no assignment: { bye: true }",code:"ERR_UNCHANGED_CANNOT_ASSIGN_BYE"},Jh={message:"Unrecognized matchUpStatus",code:"ERR_UNRECOGNIZED_MATCHUP_STATUS"},Zc={message:"Unrecognized matchUpFormat",code:"ERR_UNRECOGNIZED_MATCHUP_FORMAT"},rf={message:"Incompatible matchUpStatus",code:"ERR_INCOMPATIBLE_MATCHUP_STATUS"},vl={message:"Invalid matchUpStatus",code:"ERR_INVALID_MATCHUP_STATUS"},Pi={message:"Invalid tieFormat",code:"ERR_INVALID_TIE_FORMAT"},Zh={message:"Invalid matchUpFormat",code:"ERR_INVALID_MATCHUP_FORMAT"},nf={message:"Missing matchUpFormat",code:"ERR_MISSING_MATCHUP_FORMAT"},fx={message:"Missing collectionDefinition",code:"ERR_MISSING_COLLECTION_DEFINITION"},Xc={message:"Missing tieFormat",code:"ERR_MISSING_TIE_FORMAT"},Vt={message:"Missing matchUpId",code:"ERR_MISSING_MATCHUP_ID"},ml={message:"Missing matchUpIds",code:"ERR_MISSING_MATCHUP_IDS"},ir={message:"matchUp not found",code:"ERR_NOT_FOUND_MATCHUP"},Wo={message:"Missing matchUps",code:"ERR_MISSING_MATCHUPS"},jr={message:"Missing matchUp",code:"ERR_MISSING_MATCHUP"},rn={message:"Invalid matchUp",code:"ERR_INVALID_MATCHUP"},Xh={message:"Missing policyType",code:"ERR_MISSING_POLICY_TYPE"},eu={message:"Missing policyDefinitions",code:"ERR_MISSING_POLICY_DEFINITIONS"},vx={message:"Missing avoidance policy",code:"ERR_MISSING_POLICY_AVOIDANCE"},e_={message:"Missing policy attributes",code:"ERR_MISSING_POLICY_ATTRIBUTES"},mx={message:"Invalid policyDefinitions",code:"ERR_INVALID_POLICY_DEFINITIONS"},t_={message:"existing policyType",code:"ERR_EXISTING_POLICY_TYPE"},gx={message:"Policy not attached",code:"ERR_FAILURE_POLICY_NOT_ATTACHED"},of={message:"Policy not found",code:"ERR_NOT_FOUND_POLICY"},hx={message:"Missing scoring policy / matchUpFormats",code:"ERR_MISSING_POLICY_SCORING_MATCHUP_FORMATS"},r_={message:"Invalid sideNumber",code:"ERR_INVALID_SIDE_NUMBER"},sf={message:"Missing setObject",code:"ERR_MISSING_SET_ATTRIBUTE"},na={message:"Missing courtId",code:"ERR_MISSING_COURT_ID"},_e={message:"Missing value",code:"ERR_MISSING_VALUE"},n_={message:"Missing date",code:"ERR_MISSING_DATE"},_x={message:"No valid dates",code:"ERR_NO_VALID_DATES"},af={message:"Invalid bookings",code:"ERR_INVALID_BOOKINGS"},lf={message:"Invalid dateAvailability",code:"ERR_INVALID_DATE_AVAILABILITY"},Ix={message:"Missing dateAvailability",code:"ERR_MISSING_DATE_AVAILABILITY"},yr={message:"Invalid Date",code:"ERR_INVALID_DATE"},nn={message:"Invalid time",code:"ERR_INVALID_TIME"},Px={message:"Invalid tournament dates",code:"ERR_INVALID_DATES_TOURNAMENT"},o_={message:"Invalid game scores",code:"ERR_INVALID_SCORES_GAME"},yx={message:"Invalid score",code:"ERR_INVALID_SCORE"},i_={message:"Invalid winningSide",code:"ERR_INVALID_WINNING_SIDE"},Sx={message:"No participants generated",code:"ERR_NO_PARTICIPANTS_GENERATED"},s_={message:"Cannot modify tieFormat",code:"ERR_UNCHANGED_CANNOT_MODIFY_TIEFORMAT"},Ox={message:"Cannot modify participantType",code:"ERR_UNCHANGED_CANNOT_MODIFY_PARTICIPANT_TYPE"},cf={message:"Cannot remove participants",code:"ERR_UNCHANGED_CANNOT_REMOVE_PARTICIPANTS"},a_={message:"Cannot change winningSide",code:"ERR_UNCHANGED_CANNOT_CHANGE_WINNING_SIDE"},tu={message:"Invalid participant",code:"ERR_INVALID_PARTICIPANT"},Oo={message:"Invalid participantId",code:"ERR_INVALID_PARTICIPANT_ID"},mn={message:"Invalid participantIds",code:"ERR_INVALID_PARTICIPANT_IDS"},bx={message:"Invalid participantRole",code:"ERR_INVALID_PARTICIPANT_ROLE"},Fn={message:"Invalid participantType",code:"ERR_INVALID_PARTICIPANT_TYPE"},Tx={message:"Missing participantRole",code:"ERR_MISSING_PARTICIPANT_ROLE"},oa={message:"Missing participant",code:"ERR_MISSING_PARTICIPANT"},gl={message:"Missing participants",code:"ERR_MISSING_PARTICIPANTS"},Tt={message:"Missing participantId",code:"ERR_MISSING_PARTICIPANT_ID"},Dt={message:"Participant Not Found",code:"ERR_NOT_FOUND_PARTICIPANT"},wx={message:"participantId exists",code:"ERR_EXISTING_PARTICIPANT_ID"},Ex={message:"No participant removed",code:"ERR_UNCHANGED_NO_PARTICIPANT_REMOVED"},bo={message:"Missing participantIds",code:"ERR_MISSING_PARTICIPANT_IDS"},$x={message:"Missing participantsCount",code:"ERR_MISSING_PARTICIPANT_COUNT"},Nx={message:"Participant not checked in",code:"ERR_UNCHANGED_PARTICIPANT_NOT_CHECKED_IN"},l_={message:"Participant already checked in",code:"ERR_UNCHANGED_PARTICIPANT_CHECKED_IN"},Ux={message:"Missing person details",code:"ERR_MISSING_PERSON_DETAILS"},ia={message:"Existing participant drawPosition assignment",code:"ERR_EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT"},uf={message:"Existing participant",code:"ERR_EXISTING_PARTICIPANT"},c_={message:"participantsCount exceeds drawSize",code:"ERR_INVALID_PARTICIPANT_COUNT"},df={message:"Invalid entry status",code:"ERR_INVALID_ENTRY_STATUS"},u_={message:"Participant Entry Not Found",code:"ERR_NOT_FOUND_PARTICIPANT_ENTRY"},Ax={message:"Participant not entered in stage",code:"ERR_UNCHANGED_PARTICIPANT_NOT_ENTERED"},Cx={message:"Participant not found in stageSequence",code:"ERR_NOT_FOUND_PARTICIPANT_IN_STAGE"},Mx={message:"entryStatus not allowed in stage",code:"ERR_INVALID_ENTRY_STATUS_IN_STAGE"},Dx={message:"entryStatus not allowed for event",code:"ERR_INVALID_ENTRY_STATUS_IN_EVENT"},d_={message:"No stage space available for entryStatus",code:"ERR_UNCHANGED_NO_AVAILABLE_STAGE_SPACE"},jx={message:"Insufficient drawPositions to accommodate qualifiers",code:"ERR_UNCHANGED_NO_DRAW_POSITIONS_FOR_QUALIFIERS"},p_={message:"Insufficient drawPositions to accommodate entries",code:"ERR_INSUFFICIENT_DRAW_POSITIONS"},Rx={message:"Missing penaltyType",code:"ERR_MISSING_PENALTY_TYPE"},f_={message:"Missing penaltyId",code:"ERR_MISSING_PENALTY_ID"},ru={message:"Penalty not found",code:"ERR_NOT_FOUND_PENALTY"},Fx={message:"Missing courtsCount/courtNames",code:"ERR_MISSING_COURTS_INFO"},pf={message:"Court not found",code:"ERR_NOT_FOUND_COURT"},xx={message:"Court exists",code:"ERR_EXISTING_COURT"},Lx={message:"Venue exists",code:"ERR_EXISTING_VENUE"},yi={message:"Venue not found",code:"ERR_NOT_FOUND_VENUE"},Ho={message:"Missing venueId",code:"ERR_MISSING_VENUE_ID"},Vx={message:"Invalid endTime",code:"ERR_INVALID_END_TIME"},v_={message:"Existing endTime",code:"ERR_EXISTING_END_TIME"},Bx={message:"Invalid stopTime",code:"ERR_INVALID_STOP_TIME"},kx={message:"Invalid startTime",code:"ERR_INVALID_START_TIME"},Gx={message:"Invalid resumeTime",code:"ERR_INVALID_RESUME_TIME"},m_={message:"Invalid timeItem",code:"ERR_INVALID_TIME_ITEMS"},g_={message:"Missing timeItem",code:"ERR_MISSING_TIME_ITEM"},h_={message:"Missing timeItems",code:"ERR_MISSING_TIME_ITEMS"},nu={message:"Missing context",code:"ERR_MISSING_CONTEXT"},Wx={message:"Missing schedule",code:"ERR_MISSING_SCHEDULE"},ou={message:"Invalid scaleItem",code:"ERR_INVALID_SCALE_ITEM"},Hx={message:"No scaleItem found",code:"ERR_NOT_FOUND_SCALE_ITEM"},qx={message:"Modifications failed",code:"ERR_FAILURE_MODIFICATIONS"},hl={message:"No modifications applied",code:"ERR_UNCHANGED_NO_MODIFICATIONS_APPLIED"},zx={message:"Unable to assign court",code:"ERR_UNCHANGED_COURT_NOT_ASSIGNED"},ff={message:"No Candidates",code:"ERR_UNCHANGED_NO_CANDIDATES"},Yx={message:"Invalid configuration",code:"ERR_INVALID_CONFIG"},oo={message:"Invalid object",code:"ERR_INVALID_OBJECT"},X={message:"Invalid values",code:"ERR_INVALID_VALUES"},Kx={message:"Duplicate value",code:"ERR_DUPLICATE_VALUE"},__={message:"Team not found",code:"ERR_NOT_FOUND_TEAM"},Qx={message:"No valid actions",code:"ERR_NO_VALID_ACTIONS"},vf={message:"No valid attributes",code:"ERR_NO_VALID_ATTRIBUTES"},I_={message:"Value unchanged",code:"ABORT_UNCHANGED"},sr={message:"Not found",code:"ERR_NOT_FOUND"},P_={message:"Not implemented",code:"ERR_NOT_IMPLEMENTED"},Jx={message:"Existing flight",code:"ERR_EXISTING_FLIGHT"},y_={message:"Existing flight profile",code:"ERR_EXISTING_FLIGHT_PROFILE"},Zx={message:"Existing outcome",code:"ERR_EXISTING_OUTCOME"},Xx={message:"Existing matchUpId",code:"ERR_EXISTING_MATCHUP_ID"},S_={message:"Existing stage",code:"ERR_EXISTING_STAGE"},eL={message:"Existing structure",code:"ERR_EXISTING_STRUCTURE"},O_={message:"Method not found",code:"ERR_NOT_FOUND_METHOD"},tL={message:"Scheduled matchUps",code:"ERR_SCHEDULED_MATCHUPS"};var rL=Object.defineProperty,b_=Object.getOwnPropertySymbols,nL=Object.prototype.hasOwnProperty,oL=Object.prototype.propertyIsEnumerable,T_=(t,e,r)=>e in t?rL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,iL=(t,e)=>{for(var r in e||(e={}))nL.call(e,r)&&T_(t,r,e[r]);if(b_)for(var r of b_(e))oL.call(e,r)&&T_(t,r,e[r]);return t};const Pt={disableNotifications:!1,tournamentId:void 0,tournamentRecords:{},subscriptions:{},modified:!1,notices:[]};var sL={addNotice:_L,callListener:OL,cycleMutationStatus:hL,deleteNotice:yL,deleteNotices:PL,disableNotifications:aL,enableNotifications:lL,getNotices:IL,getTopics:SL,getTournamentId:cL,getTournamentRecord:uL,getTournamentRecords:dL,removeTournamentRecord:mL,setSubscriptions:gL,setTournamentId:fL,setTournamentRecord:pL,setTournamentRecords:vL};function aL(){Pt.disableNotifications=!0}function lL(){Pt.disableNotifications=!1}function cL(){return Pt.tournamentId}function uL(t){return Pt.tournamentRecords[t]}function dL(){return Pt.tournamentRecords}function pL(t){const e=t==null?void 0:t.tournamentId;return e?(Pt.tournamentRecords[e]=t,{success:!0}):{error:Kc}}function fL(t){return Pt.tournamentRecords[t]?(Pt.tournamentId=t,{success:!0}):{error:re}}function vL(t){Pt.tournamentRecords=t;const e=Object.keys(t);e.length===1?Pt.tournamentId=e[0]:e.length||(Pt.tournamentId=void 0)}function mL(t){if(typeof t!="string")return{error:X};if(!Pt.tournamentRecords[t])return{error:sr};delete Pt.tournamentRecords[t];const e=Object.keys(Pt.tournamentRecords);return e.length===1?Pt.tournamentId=e[0]:e.length||(Pt.tournamentId=void 0),{success:!0}}function gL(t){return typeof t.subscriptions!="object"?{error:X}:(Object.keys(t.subscriptions).forEach(e=>{Pt.subscriptions[e]=t.subscriptions[e]}),iL({},V))}function hL(){const t=Pt.modified;return Pt.modified=!1,t}function _L({topic:t,payload:e,key:r}){Pt.modified=!0,!(typeof t!="string"||typeof e!="object")&&(Pt.disableNotifications||!Pt.subscriptions[t]||(r&&(Pt.notices=Pt.notices.filter(n=>!(n.topic===t&&n.key===r))),Pt.notices.push({topic:t,payload:e,key:r})))}function IL({topic:t}){const e=Pt.notices.filter(r=>r.topic===t).map(r=>r.payload);return e.length&&e}function PL(){Pt.notices=[]}function yL({topic:t,key:e}){Pt.notices=Pt.notices.filter(r=>(!t||r.topic===t)&&r.key!==e)}function SL(){return{topics:Object.keys(Pt.subscriptions)}}function OL({topic:t,notices:e}){const r=Pt.subscriptions[t];r&&typeof r=="function"&&r(e)}var bL=Object.defineProperty,w_=Object.getOwnPropertySymbols,TL=Object.prototype.hasOwnProperty,wL=Object.prototype.propertyIsEnumerable,E_=(t,e,r)=>e in t?bL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,EL=(t,e)=>{for(var r in e||(e={}))TL.call(e,r)&&E_(t,r,e[r]);if(w_)for(var r of w_(e))wL.call(e,r)&&E_(t,r,e[r]);return t};const on={tournamentFactoryVersion:"0.0.0",timers:{default:{elapsedTime:0}},iterators:{makeDeepCopy:0},deepCopyAttributes:{stringify:[],ignore:[],toJSON:[]},deepCopy:!0};let Rr=sL;function zt(t){var e;return!t||typeof t!="object"?(e=on.devContext)!=null?e:!1:typeof on.devContext!="object"?!1:Object.keys(t).every(r=>{var n;return((n=on.devContext)==null?void 0:n[r])===t[r]})&&on.devContext}function sa(t){on.devContext=t}function $L(t){on.iterators.makeDeepCopy=t}function NL(){return on.iterators.makeDeepCopy}function UL(){Rr.disableNotifications()}function mf(){Rr.enableNotifications()}function rs(t,e){typeof t=="boolean"&&(on.deepCopy=t),typeof e=="object"&&(Array.isArray(e.ignore)&&(on.deepCopyAttributes.ignore=e.ignore),Array.isArray(e.toJSON)&&(on.deepCopyAttributes.toJSON=e.toJSON),Array.isArray(e.stringify)&&(on.deepCopyAttributes.stringify=e.stringify),e.threshold&&(on.deepCopyAttributes.threshold=e.threshold))}function $_(){return EL({enabled:on.deepCopy},on.deepCopyAttributes)}function _l(){return Rr.cycleMutationStatus()}function qe(t){return Rr.addNotice(t)}function AL(t){return Rr.getNotices(t)}function N_({key:t,topic:e}){return Rr.deleteNotice({key:t,topic:e})}function Si(){return Rr.deleteNotices()}function xn(){return Rr.getTopics()}async function U_(t){return Rr.callListener(t)}function gn(){return Rr.getTournamentId()}function Il(t){return Rr.getTournamentRecord(t)}function iu(){return Rr.getTournamentRecords()}function A_(t){return Rr.setTournamentRecord(t)}function Pl(t){return Rr.setTournamentRecords(t)}function yl(t){return Rr.setTournamentId(t)}function gf(t){return Rr.removeTournamentRecord(t)}function ns(t){return typeof t=="object"}const CL=t=>e=>Object.keys(t).every(r=>e[r]===t[r]),sn=t=>e=>!t||typeof e!="object"?void 0:Array.isArray(t)&&t.map(r=>({[r]:e[r]}))||typeof t=="object"&&Object.keys(t).map(r=>({[r]:e[r]}))||typeof t=="string"&&ML(e,t);function ML(t,e){const r=e.split(".");for(const n of r)if(t=t==null?void 0:t[n],!t)return;return t}function ye(t,e,r,n){if(typeof t!="object"||t===null)return t;const o=$_();o!=null&&o.enabled||(n=!0);const i=["",void 0,null];e&&i.push(!1);const s=Object.keys(t).filter(a=>!i.includes(t[a])&&(!r||(Array.isArray(t[a])?t[a].length:!0)));return Object.assign({},...s.map(a=>Array.isArray(t[a])?{[a]:n?t[a]:t[a].map(l=>ye(l))}:{[a]:n?t[a]:ye(t[a])}))}function hf(t){return Array.isArray(t)?t.length+t.map(hf).reduce((e,r)=>e+r,0):typeof t=="object"&&t!==null?Object.keys(t).length+Object.keys(t).map(e=>hf(t[e])).reduce((e,r)=>e+r,0):0}function DL(t){if(t===null||typeof t!="object")return;const e=JSON.stringify(t),r=hf(t),n=e.split("").reduce((o,i)=>o+i.charCodeAt(0),0);return[e.length,r,n].map(o=>o.toString(36)).join("")}function su(t){if(t===null)return{};const{source:e,template:r}=t||{};if(!r)return e;const n={};return o(e,r,n),n;function o(i,s,a){if(!i||!s)return;const l=Object.keys(i),c=Object.keys(s),u=Object.assign({},...c.filter(v=>v.indexOf("||")).map(v=>v.split("||").map(f=>({[f]:v}))).flat()),d=c.concat(...Object.keys(u)),p=d.includes("*");for(const v of l)if(d.indexOf(v)>=0||p){const f=u[v]||v,m=s[f]||p,g=i[v];if(typeof m=="object"&&typeof g!="function"&&!Array.isArray(m))if(Array.isArray(g)){const h=g.map(_=>{const I={};return o(_,m,I)!==!1?I:void 0}).filter(Boolean);a[v]=h}else g&&(a[v]={},o(g,m,a[v]));else{const h=i[v];if(Array.isArray(m)&&!m.includes(h))return!1;(s[v]||p&&s[v]!==!1)&&(a[v]=h)}}}}function C_(t=0){const e=new Date;return e.setHours(e.getHours()+t),e.getTime().toString(36).slice(-6).toUpperCase()}const au=/^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/,M_=/^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/,Ln=/^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))([ T](0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/,Oi=/^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))?([ T]?(0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;function lu(t){let{scheduledDate:e}=t;if(!e&&t.scheduledTime&&(e=Re(t.scheduledTime)),!e)return;const r=ct(t.scheduledTime);let n=Re(e);return n&&r&&(n+=`T${r}`),n}function jL(t){return typeof t!="object"||Array.isArray(t)?!1:Object.prototype.toString.call(t)==="[object Date]"}function aa(t){const e=typeof t=="string"?t==null?void 0:t.split(" "):[];return t&&(e==null?void 0:e.length)>1&&!["AM","PM"].includes(e[1].toUpperCase())?!1:!!(!t||Oi.test(os(t,!0,!0)))}function Gr(t){return bi(t)||au.test(t)}function RL(t){const e=new Date(t),r=e.getSeconds()+60*e.getMinutes()+60*60*e.getHours();return FL(r,{displaySeconds:!1})}function FL(t,e){const r=parseInt(t,10),n=Math.floor(r/3600),o=Math.floor((r-n*3600)/60),i=r-n*3600-o*60;return(!e||(e==null?void 0:e.displaySeconds)?n+":"+o+":"+i:n+":"+o).split(":").map(io).join(":")}const _f=t=>{const e=Sl(t)||bi(t)?new Date(t):new Date,r=e.getUTCMonth()+1,n=r<10?`0${r}`:`${r}`;return`${e.getUTCFullYear()}-${io(n)}-${io(e.getUTCDate())}`};function xL(t){const e=Sl(t)||bi(t)?new Date(t):new Date;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function hn(t,e="-",r="YMD"){if(!t)return"";typeof t=="string"&&t.indexOf("T")<0&&(t=t+"T00:00");const n=new Date(t);let o=""+(n.getMonth()+1),i=""+n.getDate();const s=n.getFullYear();return o.length<2&&(o="0"+o),i.length<2&&(i="0"+i),r==="DMY"?[i,o,s].join(e):r==="MDY"?[o,i,s].join(e):r==="YDM"?[s,i,o].join(e):r==="DYM"?[i,s,o].join(e):r==="MYD"?[o,s,i].join(e):[s,o,i].join(e)}function cu(t){const e=t?new Date(t):new Date,r=e.getTimezoneOffset();return new Date(e.getTime()-r*60*1e3)}function LL(t){return cu(t).getTime()}function Sl(t){if(typeof t=="boolean")return!1;const e=t instanceof Date&&t||!isNaN(t)&&new Date(t)||!1;return e&&!isNaN(e.valueOf())}function If(t,e){if(!Gr(t)||!Gr(e))return[];const r=Re(t)+"T00:00",n=Re(e)+"T00:00",o=new Date(r),i=new Date(n),s=Sl(i)&&Sl(o)&&c(o,i),a=[];let l=0;if(s){const u=o;let d=u.getTime();for(;d<=i.getTime()&&l<300;)l+=1,a.push(new Date(u)),d=u.setDate(u.getDate()+1)}return a.map(u=>hn(u));function c(u,d){return u<=d}}const VL=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;function bi(t){return typeof t!="string"?!1:VL.test(t)}function D_(t){if(typeof t!="string")return!1;const r=t.split("Z")[0].split(":"),n=r.every(i=>!isNaN(parseInt(i)));return!(r.length<2||!n||parseInt(r[0])>23||parseInt(r[1])>60)}function xe(t){const e=ct(t);if(!e)return 0;const[r,n]=e.split(":").map(o=>parseInt(o));return r*60+n}function BL(t){let e=Math.floor(t/60);const r=t-e*60;return e>23&&(e=e%24),[io(e),io(r)].join(":")}function uu(t){return D_(t)?t.split(":").slice(0,2).map(io).join(":"):void 0}function ct(t){return bi(t)&&t.indexOf("T")>0?uu(t.split("T").reverse()[0]):uu(t)}function Re(t){return bi(t)||Ln.test(t)?t.split("T")[0]:void 0}function kL(t,e){const r=new Date(t);return r.setDate(r.getDate()+e),Re(r.toISOString())}function du(t){t=typeof t!="string"?"00:00":t;const e={},r={};return{0:e.time,1:e.ampm}=t.split(" ")||[],{0:r.hours,1:r.minutes}=e.time.split(":")||[],r.ampm=e.ampm,isNaN(r.hours)||isNaN(r.minutes)||r.ampm&&!["AM","PM"].includes(r.ampm.toUpperCase())?{}:r}function GL(t){const e=du(t);return e.ampm&&e.hours&&(e.ampm.toLowerCase()==="pm"&&parseInt(e.hours)<12&&(e.hours=(e.hours&&parseInt(e.hours)||0)+12),e.ampm.toLowerCase()==="am"&&e.hours==="12"&&(e.hours="00")),`${e.hours||"12"}:${e.minutes||"00"}`.split(":").map(io).join(":")}function WL(t){var e;const r=du(t);if(!(typeof r=="object"&&!Object.keys(r).length))return r.ampm?t:(r.hours>12?(r.hours-=12,r.ampm="PM"):r.hours==="12"?r.ampm="PM":(r.hours==="00"&&(r.hours="12"),r.ampm="AM"),((e=r.hours)==null?void 0:e[0])==="0"&&(r.hours=r.hours.slice(1)),`${r.hours||"12"}:${r.minutes||"00"} ${r.ampm}`)}function os(t,e,r){const n=Re(t),o=ct(t),i=n?o:t;return t?e&&(n&&r&&t||GL(i))||WL(i):void 0}function j_(t,e){const r=du(t),n=du(e);if(parseInt(r.hours)<parseInt(n.hours))return-1;if(parseInt(r.hours)>parseInt(n.hours))return 1;if(r.hours===n.hours){if(parseInt(r.minutes)<parseInt(n.minutes))return-1;if(parseInt(r.minutes)>parseInt(n.minutes))return 1}return 0}function R_(t,e=7){const r=Re(t)+"T00:00",n=new Date(r),o=new Date(n.setDate(n.getDate()+e));return hn(o)}function HL(t){return R_(t)}function qL(t,e,r,n=!1){const o=new Date(e,0,1+(t-1)*7),i=n?0:1;return o.setDate(o.getDate()+(i-o.getDay())),hn(o,r)}function zL(t,e,r){const n=new Date(t,0);return hn(new Date(n.setDate(e)),r)}function wt(t,e=void 0){const[r,n]=(t||"00:00").split(":").map(io),o=cu(e).setHours(r,n,0,0);return cu(o)}function Ol(t,e,r=!0){const n=new Date(t),i=(new Date(e).getTime()-n.getTime())/1e3/60;return r?Math.abs(Math.round(i)):Math.round(i)}function Sr(t,e){const r=ct(t);if(!r)return"00:00";const n=isNaN(e)?0:e;return ct(Pf(wt(r),n).toISOString())}function Pf(t,e){const r=new Date(t);return new Date(r.getTime()+e*6e4)}function io(t){return t.toString()[1]?t:"0"+t}function so(t,e){const r=new Date(t),n=new Date(e);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()&&r.getDate()===n.getDate()}const YL={addDays:R_,addWeek:HL,addMinutesToTimeString:Sr,convertTime:os,getIsoDateString:lu,getUTCdateString:_f,DateHHMM:RL,extractDate:Re,extractTime:ct,formatDate:hn,getDateByWeek:qL,isISODateString:bi,isDate:Sl,isTimeString:D_,offsetDate:cu,offsetTime:LL,sameDay:so,timeStringMinutes:xe,timeToDate:wt,timeUTC:xL,validTimeValue:aa,validDateString:au,timeValidation:Oi,dateValidation:Ln};function ve(t,e,r,n,o=0){const i=$_(),{stringify:s,toJSON:a,ignore:l,modulate:c}=i||{};if(!(i!=null&&i.enabled)&&!r||typeof t!="object"||typeof t=="function"||t===null||typeof(i==null?void 0:i.threshold)=="number"&&o>=i.threshold)return t;const u=zt({makeDeepCopy:!0});u&&($L(o),typeof u=="object"&&(o>(u.iterationThreshold||15)||u.firstIteration&&o===0)&&u.log&&(!u.notInternalUse||u.notInternalUse&&!r)&&console.log({devContext:u,iteration:o,internalUse:r},t));const d=Array.isArray(t)?[]:{},p=Object.keys(t).filter(f=>!r||!l||Array.isArray(l)&&!l.includes(f)||typeof l=="function"&&!l(f)),v=(f,m)=>{d[f]=typeof(m==null?void 0:m.toString)=="function"?m.toString():JSON.stringify(m)};for(const f of p){const m=t[f],g=typeof c=="function"?c(m):void 0;if(g!==void 0)d[f]=g;else if(e&&f==="extensions"&&Array.isArray(m)){const h=yf(m);Object.assign(d,...h)}else n&&f==="extensions"?d[f]=[]:Array.isArray(s)&&s.includes(f)?v(f,m):Array.isArray(a)&&a.includes(f)&&typeof(m==null?void 0:m.toJSON)=="function"?d[f]=m.toJSON():m===null?d[f]=void 0:jL(m)?d[f]=new Date(m).toISOString():d[f]=ve(m,e,r,n,o+1)}return d}function yf(t){return t==null?void 0:t.map(e=>{const{name:r,value:n}=e;return r&&n&&{[`_${r}`]:n}}).filter(Boolean)}function er(t,e){return t-e}function KL(t,e){if(e&&typeof e!="object")return X;let{columnTransform:r={}}=e||{};const{includeTransformAccessors:n,includeHeaderRow:o=!0,returnTransformedJSON:i,removeEmptyColumns:s,onlyHeaderRow:a,columnAccessors:l=[],functionMap:c={},columnMap:u={},valuesMap:d={},context:p={},delimiter:v='"',columnJoiner:f=",",rowJoiner:m=`\r
|
|
6
6
|
`,keyJoiner:g="."}=e||{};if(!Array.isArray(t)||!Array.isArray(l)||typeof p!="object"||typeof u!="object"||typeof r!="object"||typeof c!="object"||typeof d!="object"||typeof f!="string"||typeof m!="string"||typeof g!="string"||typeof v!="string")return X;r=Object.assign({},...Object.keys(r).reverse().map(A=>({[A]:Array.isArray(r[A])?r[A]:[typeof r[A]=="string"&&r[A]].filter(Boolean)})));const h=t.filter(Boolean).map(A=>Sf(A,g)),_=Object.values(r).flat();n&&l.push(..._);const I=h.reduce((A,U)=>Object.keys(U).every(C=>!A.includes(C)&&A.push(C)||!0)&&A,[]).filter(A=>!(l!=null&&l.length)||l.includes(A)),P=Object.assign({},...Object.keys(r).reverse().map(A=>r[A].map(U=>({[U]:A})).flat()).flat()),y=(A,U)=>e!=null&&e.sortOrder?e.sortOrder.includes(A)&&e.sortOrder.includes(U)&&e.sortOrder.indexOf(A)-e.sortOrder.indexOf(U)||!e.sortOrder.includes(U)&&-1:0,S=I.reduce((A,U)=>{const C=P[U];return C?A.includes(C)||A.push(C):A.push(U),A},[]).sort(y);Object.keys(u).forEach(A=>!S.includes(A)&&S.unshift(A)),Object.keys(r).forEach(A=>!S.includes(A)&&S.unshift(A)),typeof p=="object"&&Object.keys(p).forEach(A=>!S.includes(A)&&S.unshift(A));let O=S.map(A=>u[A]||A);if(a)return[O];const b=A=>`${v}${A}${v}`,w=[],T=A=>Object.values(S.reduce((U,C,M)=>{var D;const R=r[C],j=(R!=null&&R.length?A[R.find(z=>A[z])]:A[C])||(p==null?void 0:p[C])||"",G=((D=d[C])==null?void 0:D[j])||j,W=typeof c[C]=="function"?c[C](G):G;return U[C]=b(W),W&&(w[M]=(w[M]||0)+1),U},{}));let E=h.map(T);const N=s&&[...w].map((A,U)=>!A&&U).filter(Ut).reverse();if(N){const A=U=>U.filter((C,M)=>!N.includes(M));E=E.map(A),O=A(O)}const $=E.map(A=>A.join(f));return i?$.map(A=>{const U=A.split(f);return Object.assign({},...U.map((C,M)=>({[O[M]]:C})))}):o?[O.map(b).join(f),...$].join(m):$.join(m)}function Sf(t,e,r=[]){return typeof t=="object"&&Object.keys(t).reduce((n,o)=>typeof t[o]!="object"?(n[r.concat(o).join(e)]=t[o],n):Object.assign(n,Sf(t[o],e,r.concat(o))),{})}function QL(t=1){return pe(0,t).map(ze)}function ze(){const t=[];for(let i=0;i<256;i++)t[i]=(i<16?"0":"")+i.toString(16);const e=Math.random()*4294967295|0,r=Math.random()*4294967295|0,n=Math.random()*4294967295|0,o=Math.random()*4294967295|0;return t[e&255]+t[e>>8&255]+t[e>>16&255]+t[e>>24&255]+"-"+t[r&255]+t[r>>8&255]+"-"+t[r>>16&15|64]+t[r>>24&255]+"-"+t[n&63|128]+t[n>>8&255]+"-"+t[n>>16&255]+t[n>>24&255]+t[o&255]+t[o>>8&255]+t[o>>16&255]+t[o>>24&255]}var JL=Object.defineProperty,F_=Object.getOwnPropertySymbols,ZL=Object.prototype.hasOwnProperty,XL=Object.prototype.propertyIsEnumerable,x_=(t,e,r)=>e in t?JL(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,eV=(t,e)=>{for(var r in e||(e={}))ZL.call(e,r)&&x_(t,r,e[r]);if(F_)for(var r of F_(e))XL.call(e,r)&&x_(t,r,e[r]);return t};function k({context:t,result:e,stack:r,info:n}){return e&&!Array.isArray(e==null?void 0:e.stack)&&(e.stack=[]),e&&Array.isArray(e==null?void 0:e.stack)&&typeof r=="string"&&e.stack.push(r),n&&(e!=null&&e.error)&&(e.error.info=n),e&&typeof t=="object"&&Object.keys(t).length&&Object.assign(e,ye(t)),e&&!(e!=null&&e.error)&&!(e!=null&&e.success)&&Object.assign(e,eV({},V)),e??{success:!0}}var L_=(t=>(t.AdHoc="AD_HOC",t.Compass="COMPASS",t.CurtisConsolation="CURTIS_CONSOLATION",t.DoubleElimination="DOUBLE_ELIMINATION",t.FeedIn="FEED_IN",t.FeedInChampionship="FEED_IN_CHAMPIONSHIP",t.FeedInChampionshipToQf="FEED_IN_CHAMPIONSHIP_TO_QF",t.FeedInChampionshipToR16="FEED_IN_CHAMPIONSHIP_TO_R16",t.FeedInChampionshipToSf="FEED_IN_CHAMPIONSHIP_TO_SF",t.FirstMatchLoserConsolation="FIRST_MATCH_LOSER_CONSOLATION",t.FirstRoundLoserConsolation="FIRST_ROUND_LOSER_CONSOLATION",t.ModifiedFeedInChampionship="MODIFIED_FEED_IN_CHAMPIONSHIP",t.Lucky="LUCKY_DRAW",t.Olympic="OLYMPIC",t.Other="OTHER",t.Playoff="PLAYOFF",t.RoundRobin="ROUND_ROBIN",t.RoundRobinWithPlayoff="ROUND_ROBIN_WITH_PLAYOFF",t.SingleElimination="SINGLE_ELIMINATION",t))(L_||{}),To=(t=>(t.Consolation="CONSOLATION",t.Main="MAIN",t.PlayOff="PLAY_OFF",t.Qualifying="QUALIFYING",t.VoluntaryConsolation="VOLUNTARY_CONSOLATION",t))(To||{}),ar=(t=>(t.Alternate="ALTERNATE",t.Confirmed="CONFIRMED",t.DirectAcceptance="DIRECT_ACCEPTANCE",t.FeedIn="FEED_IN",t.JuniorExempt="JUNIOR_EXEMPT",t.LuckyLoser="LUCKY_LOSER",t.OrganiserAcceptance="ORGANISER_ACCEPTANCE",t.Qualifier="QUALIFIER",t.SpecialExempt="SPECIAL_EXEMPT",t.Registered="Registered",t.Ungrouped="UNGROUPED",t.Unpaired="UNPAIRED",t.Wildcard="WILDCARD",t.Withdrawn="WITHDRAWN",t))(ar||{}),qo=(t=>(t.Loser="LOSER",t.Position="POSITION",t.Winner="WINNER",t))(qo||{}),bl=(t=>(t.BottomUp="BOTTOM_UP",t.Draw="DRAW",t.LossPosition="LOSS_POSITION",t.Random="RANDOM",t.TopDown="TOP_DOWN",t.Waterfall="WATERFALL",t))(bl||{}),Ar=(t=>(t.Doubles="DOUBLES",t.Singles="SINGLES",t.Team="TEAM",t))(Ar||{}),pt=(t=>(t.Abandoned="ABANDONED",t.AwaitingResult="AWAITING_RESULT",t.Bye="BYE",t.Cancelled="CANCELLED",t.Completed="COMPLETED",t.DeadRubber="DEAD_RUBBER",t.Defaulted="DEFAULTED",t.DoubleDefault="DOUBLE_DEFAULT",t.DoubleWalkover="DOUBLE_WALKOVER",t.InProgress="IN_PROGRESS",t.Incomplete="INCOMPLETE",t.NotPlayed="NOT_PLAYED",t.Retired="RETIRED",t.Suspended="SUSPENDED",t.ToBePlayed="TO_BE_PLAYED",t.Walkover="WALKOVER",t))(pt||{}),Of=(t=>(t.Any="ANY",t.Female="FEMALE",t.Male="MALE",t.Mixed="MIXED",t))(Of||{}),V_=(t=>(t.Administration="ADMINISTRATION",t.Captain="CAPTAIN",t.Coach="COACH",t.Competitor="COMPETITOR",t.Media="MEDIA",t.Medical="MEDICAL",t.Official="OFFICIAL",t.Other="OTHER",t.Security="SECURITY",t))(V_||{}),Vn=(t=>(t.Group="GROUP",t.Individual="INDIVIDUAL",t.Pair="PAIR",t.Team="TEAM",t))(Vn||{}),tV=Object.defineProperty,B_=Object.getOwnPropertySymbols,rV=Object.prototype.hasOwnProperty,nV=Object.prototype.propertyIsEnumerable,k_=(t,e,r)=>e in t?tV(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,oV=(t,e)=>{for(var r in e||(e={}))rV.call(e,r)&&k_(t,r,e[r]);if(B_)for(var r of B_(e))nV.call(e,r)&&k_(t,r,e[r]);return t};function Or(t){var e,r,n,o;const i=t==null?void 0:t.checkCollectionIds,s=t==null?void 0:t.tieFormat,a="validateTieFormat",l=[];if(typeof s!="object")return l.push("tieFormat must be an object"),k({result:{error:Pi,stack:a,context:{tieFormat:s,errors:l}}});if(typeof s.winCriteria!="object")return l.push("tieFormat.winCriteria must be an object"),k({result:{error:Pi,stack:a,context:{tieFormat:s,errors:l}}});if(!Array.isArray(s.collectionDefinitions))return l.push(or("tieFormat.collectionDefinitions")),k({result:{error:Pi,stack:a,context:{tieFormat:s,errors:l}}});let c;const u=s.collectionDefinitions.every(g=>{const{setValue:h,scoreValue:_,collectionValue:I}=g;(h||_)&&!I&&(c=!0);const{valid:P,errors:y}=G_({collectionDefinition:g,checkCollectionIds:i});return P?!0:(Array.isArray(y)&&l.push(...y),!1)}),d=typeof((e=s.winCriteria)==null?void 0:e.valueGoal)=="number"&&((r=s.winCriteria)==null?void 0:r.valueGoal)>0&&!c||((n=s.winCriteria)==null?void 0:n.aggregateValue);if(!(d||(o=s.winCriteria)!=null&&o.aggregateValue))return c?l.push("aggregateValue is required"):l.push("Either non-zero valueGoal, or { aggregateValue: true } must be specified in winCriteria"),k({result:{context:{tieFormat:s,errors:l,aggregateValueImperative:c},error:Pi,stack:a}});const p=s.collectionDefinitions.map(({collectionId:g})=>g),v=!i||p.length===He(p).length,f=u&&d&&v,m={valid:f,errors:l};return f?m:k({result:{context:{tieFormat:s,errors:l},error:Pi,stack:a}})}function G_({checkValueDefinition:t=!0,collectionDefinition:e,checkCollectionIds:r}){const n=[];if(typeof e!="object")return n.push(`collectionDefinition must be an object: ${e}`),{errors:n};const{collectionValueProfiles:o,collectionGroupNumber:i,collectionValue:s,collectionId:a,matchUpCount:l,matchUpFormat:c,matchUpValue:u,matchUpType:d,scoreValue:p,setValue:v}=e;if(r&&typeof a!="string")return n.push(`collectionId is not type string: ${a}`),{errors:n};if(typeof l!="number")return n.push(`matchUpCount is not type number: ${l}`),{errors:n};if(d&&![Ar.Singles,Ar.Doubles].includes(d))return n.push(`matchUpType must be SINGLES or DOUBLES: ${d}`),{errors:n};if(t&&!u&&!s&&!o&&!p&&!v)return n.push("Missing value definition for matchUps: matchUpValue, collectionValue, or collectionValueProfiles"),{errors:n};if(u&&typeof u!="number")return n.push(`matchUpValue is not type number: ${u}`),{errors:n};if(s&&typeof s!="number")return n.push(`collectionValue is not type number: ${s}`),{errors:n};if(o){const f=W_({collectionValueProfiles:o,matchUpCount:l});if(f.errors)return n.push(...f.errors),{errors:n}}return i&&typeof i!="number"?(n.push(`collectionValue is not type number: ${s}`),{errors:n}):c&&!VF.isValid(c)?(n.push(`Invalid matchUpFormat: ${c}`),{errors:n}):{valid:!0}}function iV(t){const e=Or({tieFormat:t,checkCollectionIds:!1});if(e.error)return e;for(const r of t.collectionDefinitions)r.collectionId||(r.collectionId=ze());return{tieFormat:t}}function W_({collectionValueProfiles:t,matchUpCount:e}){const r=[];if(!Array.isArray(t))return r.push(`collectionValueProfiles is not an array: ${t}`),{errors:r};if(t.length&&t.length!==e)return r.push("collectionValueProfiles do not align with matchUpsCount"),{errors:r};for(const o of t){if(typeof o!="object")return r.push(`valueProfile is not type object: ${o}`),{errors:r};const{value:i,collectionPosition:s}=o;if(typeof i!="number"||typeof s!="number"||s>e||s<1)return r.push("Invalid value profile: value and collectionPosition must be numeric. collectionPosition cannot be greater than matchUpCount"),{errors:r}}const n=t.map(o=>o.collectionPosition);return n.length!==He(n).length?(r.push("collectionPositions are not unique"),{errors:r}):oV({},V)}const Wr="ABANDONED",la="AWAITING_RESULT",nt="BYE",zo="CANCELLED",At="COMPLETED",Tl="DEAD_RUBBER",et="DEFAULTED",tr="DOUBLE_DEFAULT",jt="DOUBLE_WALKOVER",Bn="IN_PROGRESS",ao="INCOMPLETE",bf="NOT_PLAYED",hr="RETIRED",Ti="SUSPENDED",Rt="TO_BE_PLAYED",ot="WALKOVER",sV=[la,At,et,jt,tr,Bn,ao,hr,Ti,ot],aV=[Wr,la,nt,zo,At,Tl,et,jt,tr,Bn,ao,bf,hr,Ti,Rt,ot],lV=[nt,jt,tr,At,et,hr,ot],cV=[Wr,la,zo,Tl,Bn,ao,bf,Ti,Rt,void 0],Yt=[pt.Cancelled,pt.Abandoned,pt.Completed,pt.DeadRubber,pt.Defaulted,pt.DoubleWalkover,pt.DoubleDefault,pt.Retired,pt.Walkover],H_=[Wr,At,et,jt,tr,Bn,hr,ot],uV=[Bn,ao,Ti,Rt],dV={ABANDONED:Wr,AWAITING_RESULT:la,BYE:nt,CANCELLED:zo,COMPLETED:At,DEAD_RUBBER:Tl,DEFAULTED:et,DOUBLE_WALKOVER:jt,DOUBLE_DEFAULT:tr,IN_PROGRESS:Bn,INCOMPLETE:ao,NOT_PLAYED:bf,RETIRED:hr,SUSPENDED:Ti,TO_BE_PLAYED:Rt,WALKOVER:ot};function ca({matchUp:t}){return Yt.includes(t==null?void 0:t.matchUpStatus)||(t==null?void 0:t.winningSide)}const pu="SET3-S:6/TB7",pV={FORMAT_STANDARD:pu,FORMAT_STANDARD_NOAD:"SET3-S:6NOAD",FORMAT_ATP_DOUBLES:"SET3-S:6/TB7-F:TB10",FORMAT_SHORT_SETS:"SET3-S:4/TB7",FORMAT_FAST4:"SET3-S:4/TB5@3",FORMAT_PRO_SET:"SET1-S:8/TB7",FORMAT_COLLEGE_PRO_SET:"SET1-S:8/TB7@7",TIMED20:"SET1-S:T20"};function q_({winningSide:t,matchUpFormat:e=pu,matchUpStatus:r,tallyPolicy:n,score:o}){var i;const s=[0,0],{sets:a}=o||{},l=t-1,c=Ir(e),u=Tf((i=c==null?void 0:c.bestOf)!=null?i:1);if(r===et&&(n!=null&&n.setsCreditForDefaults)||r===ot&&(n!=null&&n.setsCreditForWalkovers))s[l]=u;else for(const d of a||[]){const{winningSide:p}=d;p&&(s[p-1]+=1)}return r===hr&&(+s[1-l]===u&&(s[1-l]-=1),n!=null&&n.setsCreditForRetirements&&(s[l]=u)),s}function fV({matchUpFormat:t=pu,winningSide:e,matchUpStatus:r,tallyPolicy:n,score:o}){var i,s,a;const{sets:l}=o||{};if(!l)return[0,0];const c=e-1,u=Ir(t),d=(i=u==null?void 0:u.bestOf)!=null?i:1,p=Tf(d),v=((s=u==null?void 0:u.setFormat)==null?void 0:s.tiebreakAt)||0,f=[[],[]];if(r===et&&(n!=null&&n.gamesCreditForDefaults)||r===ot&&(n!=null&&n.gamesCreditForWalkovers)){const m=((a=u==null?void 0:u.setFormat)==null?void 0:a.setTo)||0,g=p*m;f[c].push(g)}else l.forEach((m,g)=>{var h;const I=(m.setNumber||g+1)>p&&(u!=null&&u.finalSetFormat)?"finalSetFormat":"setFormat",P=(h=u==null?void 0:u[I])==null?void 0:h.based,y=u==null?void 0:u[I].tiebreakSet,{side1Score:S,side2Score:O}=m;Y_(P)&&(f[0].push(Oe(S||0)),f[1].push(Oe(O||0))),y&&m.winningSide&&(n==null?void 0:n.gamesCreditForTiebreakSets)!==!1&&f[m.winningSide-1].push(1)});if(r===hr){const m=l.length>p&&(u!=null&&u.finalSetFormat)?"finalSetFormat":"setFormat",g=u==null?void 0:u[m];if(Y_(g.based)){const h=(g==null?void 0:g.setTo)||0,_=y=>{if(!(!u||y===""))return+y===v-1||+y===v?Oe(v||0)+1:+y<v?h:v},I=q_({winningSide:e,score:{sets:l},matchUpStatus:r,matchUpFormat:t,tallyPolicy:n});if(f.map(y=>y[c]<=y[1-c]).reduce((y,S)=>y+(S?1:0),0)>I[1-c]){const y=f[c].length,S=_(f[1-c][y-1]);S&&(f[c][y-1]=S)}p>f[c].length&&(n!=null&&n.gamesCreditForRetirements)&&f[c].push(h)}}return[f[0].reduce((m,g)=>m+g,0),f[1].reduce((m,g)=>m+g,0)]}function vV({matchUpFormat:t,score:e}){var r,n;const o=Ir(t),i=(r=o==null?void 0:o.bestOf)!=null?r:1,s=Tf(i),a=[0,0];return(n=e==null?void 0:e.sets)==null||n.forEach((l,c)=>{var u;const p=(l.setNumber||c+1)>s&&(o!=null&&o.finalSetFormat)?"finalSetFormat":"setFormat",v=(u=o==null?void 0:o[p])==null?void 0:u.based;if(z_(v)){const{side1Score:f,side2Score:m}=l;f&&(a[0]+=Oe(f||0)),m&&(a[1]+=Oe(m||0))}else l.side1TiebreakScore&&(a[0]+=Oe(l.side1TiebreakScore||0)),l.side2TiebreakScore&&(a[1]+=Oe(l.side2TiebreakScore||0))}),a}function Tf(t){return t&&Math.ceil(t/2)||1}function z_(t){return t==="P"}function Y_(t){return!z_(t)}function mV({participantResults:t,matchUpFormat:e,tallyPolicy:r,perPlayer:n,totalSets:o}){var i;const s=e&&Ir(e)||{},a=s.bestOf,l=a&&Math.ceil(a/2)||1,c=(i=s.setFormat)==null?void 0:i.setTo;Object.keys(t).forEach(u=>{const d=t[u].setsWon,p=t[u].setsLost,v=r!=null&&r.groupTotalSetsPlayed?o:n*(l||0)||d+p;let f=Math.round(d/v*1e3)/1e3;(f===1/0||isNaN(f))&&(f=v);const m=t[u].tieMatchUpsWon,g=t[u].tieMatchUpsLost,h=m+g;let _=Math.round(m/h*1e3)/1e3;(_===1/0||isNaN(_))&&(_=m);const I=t[u].matchUpsWon,P=t[u].matchUpsLost,y=I+P;let S=Math.round(I/y*1e3)/1e3;(S===1/0||isNaN(S))&&(S=I);const O=t[u].gamesWon||0,b=t[u].gamesLost||0,w=(n||0)*(l||0)*(c||0),T=Math.max(w,O+b);let E=Math.round(O/T*1e3)/1e3;(E===1/0||isNaN(E))&&(E=0);let N=Math.round(t[u].pointsWon/t[u].pointsLost*1e3)/1e3;(N===1/0||isNaN(N))&&(N=0),t[u].setsWon=d,t[u].setsLost=p,t[u].setsPct=f,t[u].tieMatchUpsWon=m,t[u].tieMatchUpsPct=_,t[u].matchUpsPct=S,t[u].gamesWon=O,t[u].gamesLost=b,t[u].gamesPct=E,t[u].pointsPct=N,t[u].result=`${t[u].matchUpsWon}/${t[u].matchUpsLost}`})}const wi="SINGLES",Nt="SINGLES",_n="DOUBLES",ft="DOUBLES",In="TEAM",Qe="TEAM";function K_({participantIds:t,matchUpFormat:e,tallyPolicy:r,perPlayer:n,matchUps:o}){var i,s,a,l;const c={},u=(r==null?void 0:r.excludeMatchUpStatuses)||[],d=o.filter(f=>(f.tieMatchUps||!u.includes(f.matchUpStatus))&&(!(t!=null&&t.length)||Ht(t,[ua(f,0),ua(f,1)]).length===2)),v=d.flatMap(({score:f,tieMatchUps:m})=>{var g;return m?m.filter(({matchUpStatus:h})=>!u.includes(h)).flatMap(({score:h})=>{var _;return((_=h==null?void 0:h.sets)==null?void 0:_.length)||0}):((g=f==null?void 0:f.sets)==null?void 0:g.length)||0}).reduce((f,m)=>f+m,0);for(const f of d){const{matchUpStatus:m,tieMatchUps:g,tieFormat:h,score:_,winningSide:I,sides:P}=f,y=h&&f._disableAutoCalc&&h.collectionDefinitions.every(({scoreValue:b})=>b),S=I&&gV(f),O=I&&hV(f);if(!S||!O)if(Yt.includes(m)){const b=ua(f,0),w=ua(f,1);b&&(Yo(c,b),c[b].matchUpsCancelled+=1),w&&(Yo(c,w),c[w].matchUpsCancelled+=1)}else if(g!=null&&g.length){n=0;for(const b of g){if(b.winningSide){const w=(i=P.find(({sideNumber:E})=>E===b.winningSide))==null?void 0:i.participantId,T=(s=P.find(({sideNumber:E})=>E===b.winningSide))==null?void 0:s.participantId;w&&T&&(Yo(c,w),Yo(c,T),c[w].tieMatchUpsWon+=1,c[T].tieMatchUpsLost+=1,b.matchUpType===Nt?(c[w].tieSinglesWon+=1,c[T].tieSinglesLost+=1):b.matchUpType===ft&&(c[w].tieDoublesWon+=1,c[T].tieDoublesLost+=1))}Q_({score:b.score,manualGamesOverride:y,participantResults:c,sides:P})}}else Q_({manualGamesOverride:y,participantResults:c,score:_,sides:P});else if(Yo(c,S),Yo(c,O),g!=null&&g.length){n=0;for(const b of g){const{matchUpType:w}=b,T=w===ft,E=w===Nt;b.winningSide&&(b.winningSide===I?(S&&(c[S].tieMatchUpsWon+=1,E&&(c[S].tieSinglesWon+=1),T&&(c[S].tieDoublesWon+=1)),O&&(c[O].tieMatchUpsLost+=1,E&&(c[O].tieSinglesLost+=1),T&&(c[O].tieDoublesLost+=1))):b.winningSide!==I&&(O&&(c[O].tieMatchUpsWon+=1,E&&(c[O].tieSinglesWon+=1),T&&(c[O].tieDoublesWon+=1)),S&&(c[S].tieMatchUpsLost+=1,E&&(c[S].tieSinglesLost+=1),T&&(c[S].tieDoublesLost+=1)))),J_({matchUpFormat:b.matchUpFormat,matchUpStatus:b.matchUpStatus,score:b.score,winningParticipantId:S,losingParticipantId:O,participantResults:c,isTieMatchUp:!0,manualGamesOverride:y,tallyPolicy:r,winningSide:I})}Z_({winningParticipantId:S,losingParticipantId:O,participantResults:c,matchUpStatus:m})}else J_({matchUpFormat:f.matchUpFormat||e,isTieMatchUp:void 0,winningParticipantId:S,manualGamesOverride:y,losingParticipantId:O,participantResults:c,matchUpStatus:m,tallyPolicy:r,winningSide:I,score:_});if(y){const b=(a=P.find(({sideNumber:N})=>N===1))==null?void 0:a.participantId,w=(l=P.find(({sideNumber:N})=>N===2))==null?void 0:l.participantId;Yo(c,b),Yo(c,w);const T=_.sets.reduce((N,$)=>N+$.side1Score,0),E=_.sets.reduce((N,$)=>N+$.side2Score,0);c[b].gamesWon+=T,c[w].gamesWon+=E,c[b].gamesLost+=E,c[w].gamesLost+=T}}return mV({participantResults:c,matchUpFormat:e,tallyPolicy:r,perPlayer:n,totalSets:v}),{participantResults:c}}function gV(t){const e=t.winningSide-1;return ua(t,e)}function hV(t){const e=1-(t.winningSide-1);return ua(t,e)}function ua(t,e){if(!(t!=null&&t.sides))return console.log("no sides:",{matchUp:t}),"foo";const r=t.sides[e];return r?r.participantId:(console.log("No Side",{matchUp:t,index:e}),"foo")}function Yo(t,e){e&&!t[e]&&(t[e]={allDefaults:0,defaults:0,defeats:[],gamesLost:0,gamesWon:0,matchUpsCancelled:0,matchUpsLost:0,matchUpsWon:0,pointsLost:0,pointsWon:0,retirements:0,setsLost:0,setsWon:0,tieSinglesWon:0,tieSinglesLost:0,tieDoublesWon:0,tieDoublesLost:0,tieMatchUpsLost:0,tieMatchUpsWon:0,victories:[],walkovers:0})}function Q_({manualGamesOverride:t,participantResults:e,score:r,sides:n}){const{sets:o}=r||{},i=[[],[]],s=[0,0];for(const l of o||[]){const{winningSide:c,side1Score:u,side2Score:d}=l;c&&(s[c-1]+=1),i[0].push(Oe(u||0)),i[1].push(Oe(d||0))}const a=[i[0].reduce((l,c)=>l+c,0),i[1].reduce((l,c)=>l+c,0)];n.forEach((l,c)=>{const{participantId:u}=l;u&&(Yo(e,u),e[u].setsWon+=s[c],e[u].setsLost+=s[1-c],t||(e[u].gamesWon+=a[c],e[u].gamesLost+=a[1-c]))})}function J_({winningParticipantId:t,losingParticipantId:e,participantResults:r,manualGamesOverride:n,matchUpFormat:o,matchUpStatus:i,isTieMatchUp:s,tallyPolicy:a,winningSide:l,score:c}){const u=l&&l-1,d=1-u;s||Z_({winningParticipantId:t,losingParticipantId:e,participantResults:r,matchUpStatus:i});const p=q_({matchUpStatus:i,matchUpFormat:o,tallyPolicy:a,winningSide:l,score:c}),v=fV({matchUpStatus:i,matchUpFormat:o,tallyPolicy:a,winningSide:l,score:c}),f=vV({score:c,matchUpFormat:o});t&&(r[t].setsWon+=p[u],r[t].setsLost+=p[d],n||(r[t].gamesWon+=v[u],r[t].gamesLost+=v[d]),r[t].pointsWon+=f[u],r[t].pointsLost+=f[d]),e&&(r[e].setsWon+=p[d],r[e].setsLost+=p[u],n||(r[e].gamesWon+=v[d],r[e].gamesLost+=v[u]),r[e].pointsWon+=f[d],r[e].pointsLost+=f[u])}function Z_({winningParticipantId:t,losingParticipantId:e,participantResults:r,matchUpStatus:n}){e&&(n===ot&&(r[e].walkovers+=1),n===et&&(r[e].defaults+=1),n===hr&&(r[e].retirements+=1),[et,hr,ot].includes(n)&&(r[e].allDefaults+=1),r[e].matchUpsLost+=1),t&&(r[t].matchUpsWon+=1),e&&t&&(r[e].defeats.push(t),r[t].victories.push(e))}function _V({matchUps:t,order:e,report:r}){const n={};t.forEach(({sides:i})=>{i.forEach(s=>{s.participantId&&s.participant&&(n[s.participantId]=s.participant.participantName)})});const o=[];return Array.isArray(r)&&r.forEach((i,s)=>{var a;if((a=i.excludedDirectives)!=null&&a.length){const l=i.excludedDirectives.map(({attribute:d})=>d).join(", "),c=`${l.length} directives were excluded due to participants limit}`;o.push(c);const u=`Excluded: ${l}`;o.push(u)}else{const l=(v,f)=>parseFloat(i.reversed?v:f)-parseFloat(i.reversed?f:v),c=v=>{Object.keys(v.groups).sort(l).forEach(f=>{const m=v.groups[f].map(h=>n[h]).join(", "),g=`${f} ${v.attribute}: ${m}`;o.push(g)})},u=i.reversed?" in reverse order":"",d=Object.values(i.groups).flat(1/0).length,p=`Step ${s+1}: ${d} particiants were grouped${u} by ${i.attribute}`;if(o.push(p),i.idsFilter){const v=`${i.attribute} was calculated considering ONLY TIED PARTICIPANTS`;o.push(v)}c(i)}o.push("----------------------")}),o.push("Final Order:"),e.forEach(i=>{const{participantId:s,resolved:a}=i,l=i.groupOrder||i.provisionalOrder;o.push(`${l}: ${n[s]} => resolved: ${a}`)}),o.join(`\r
|
|
7
7
|
`)}function X_({participantResults:t,participantIds:e,attribute:r}){return eI({participantResults:t,participantIds:e}).reduce((o,i)=>{const{participantId:s,results:a}=i,l=a==null?void 0:a[r];return!isNaN(l)&&s&&(o[l]?o[l].push(s):o[l]=[s]),o},{})}function eI(t){return(t.participantIds||Object.keys(t.participantResults)).reduce((r,n,o)=>(r.push({participantId:n,i:o,results:t.participantResults[n]}),r),[])}var IV=Object.defineProperty,tI=Object.getOwnPropertySymbols,PV=Object.prototype.hasOwnProperty,yV=Object.prototype.propertyIsEnumerable,rI=(t,e,r)=>e in t?IV(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,SV=(t,e)=>{for(var r in e||(e={}))PV.call(e,r)&&rI(t,r,e[r]);if(tI)for(var r of tI(e))yV.call(e,r)&&rI(t,r,e[r]);return t};const OV=[{attribute:"matchUpsPct",idsFilter:!1},{attribute:"allDefaults",reversed:!0,idsFilter:!1},{attribute:"defaults",reversed:!0,idsFilter:!1},{attribute:"walkovers",reversed:!0,idsFilter:!1},{attribute:"retirements",reversed:!0,idsFilter:!1},{attribute:"setsPct",idsFilter:!1},{attribute:"gamesPct",idsFilter:!1},{attribute:"pointsPct",idsFilter:!1},{attribute:"matchUpsPct",idsFilter:!0},{attribute:"setsPct",idsFilter:!0},{attribute:"gamesPct",idsFilter:!0},{attribute:"pointsPct",idsFilter:!0}],wf={matchUpsPct:20,tieMatchUpsPct:16,setsPct:12,gamesPct:8,pointsPct:4};function nI(t){const{requireCompletion:e=!0,participantResults:r,subOrderMap:n,tallyPolicy:o}=t,i=[];if(e&&!bV(t))return{};const s=["tieMatchUpsWon","tieSinglesWon","tieDoublesWon","matchUpsWon","pointsWon","gamesWon","setsWon","gamesPct","setsPct","pointsPct","matchUpsPct"].includes(o==null?void 0:o.groupOrderKey)?o.groupOrderKey:"matchUpsWon",a=X_({participantResults:r,attribute:s});i.push({attribute:s,groups:a});const l=Object.keys(a).map(f=>parseFloat(f)).sort((f,m)=>m-f).map(f=>a[f]).map(f=>{const m=oI(SV({participantIds:f},t));return i.push(m.report),m.order}).flat(1/0);let c=1,u;l.forEach((f,m)=>{m&&(f.resolved||u&&!f.resolved)&&(c+=1),u=f.resolved,f.resolved?(f.position=m+1,c=f.position):f.position=c});const d=l.map(({position:f})=>f),p=$r(d);return l.forEach(f=>{const{participantId:m,position:g}=f||{},h=r[m];f.GEMscore=v(h);const _=p[g];(f==null?void 0:f.position)!==void 0&&(_>1&&(f.ties=_,n&&(f.subOrder=n[m])),f.rankOrder=g,f.groupOrder=g+(f.subOrder||1)-1)}),{groupOrder:l,report:i.flat(1/0).filter(Boolean)};function v(f){return(Array.isArray(o==null?void 0:o.GEMscore)?Object.keys(wf).filter(h=>o.GEMscore.includes(h)):Object.keys(wf)).map(h=>(f[h]||0)*Math.pow(10,wf[h].toFixed(3))).reduce((h,_)=>h+_,0)}}function bV({participantResults:t,participantsCount:e}){const n=eI({participantResults:t}).filter(o=>e-1===o.results.matchUpsWon+o.results.matchUpsLost+o.results.matchUpsCancelled);return e===n.length}function TV({disableHeadToHead:t,participantIds:e,matchUpFormat:r,tallyPolicy:n,attribute:o,idsFilter:i,matchUps:s,reversed:a}){const{participantResults:l}=K_({participantIds:i&&e,matchUpFormat:r,tallyPolicy:n,matchUps:s}),c=X_({participantResults:l,participantIds:e,attribute:o}),u=[{attribute:o,reversed:a,groups:c,idsFilter:i}];let d;return Object.keys(c).length>1&&e.length&&(d=Object.keys(c).map(p=>parseFloat(p)).sort((p,v)=>a?p-v:v-p).map(p=>c[p]).map(p=>{const v=oI({participantResults:l,disableHeadToHead:t,participantIds:p,matchUpFormat:r,tallyPolicy:n,matchUps:s});return u.push(v.report),v.order}).flat(1/0)),{order:d,report:u}}function oI({participantResults:t,disableHeadToHead:e,participantIds:r,matchUpFormat:n,tallyPolicy:o,matchUps:i}){if((r==null?void 0:r.length)===1)return{order:[{resolved:!0,participantId:r[0]}]};if((r==null?void 0:r.length)===2&&(!(o!=null&&o.headToHead)||!o.headToHead.disabled&&!e)){const d=wV({participantIds:r,participantResults:t});if(d)return{order:[d],headToHeadWinner:d[0].participantId}}const s=(o==null?void 0:o.tallyDirectives)||OV,a=[],l=[];let c;const u=s.filter(d=>{const p=!(Ut(d.maxParticipants)&&(r==null?void 0:r.length)>d.maxParticipants);return p||a.push(d),p});return a.length&&l.push({excludedDirectives:a,participantIds:r}),u.every(({attribute:d,reversed:p,idsFilter:v,disableHeadToHead:f})=>(c=TV({disableHeadToHead:f,participantIds:r,matchUpFormat:n,tallyPolicy:o,attribute:d,idsFilter:v,matchUps:i,reversed:p}),l.push(c.report),!c.order)),c.order?{order:c.order,report:l}:{order:r==null?void 0:r.map(d=>({participantId:d})),report:l}}function wV({participantIds:t,participantResults:e}){if(t){if(e[t[0]].victories.includes(t[1]))return t.map(r=>({resolved:!0,participantId:r}));if(e[t[1]].victories.includes(t[0]))return t.reverse().map(r=>({resolved:!0,participantId:r}))}}const iI="voluntaryConsolation",Ko="competitiveBands",sI="roundRobinTally",wo="positionActions",kn="matchUpActions",Ef="rankingPoints",$f="roundNaming",wl="participant",fu="progression",Nf="scheduling",EV="avoidance",da="scoring",pa="seeding",vu="feedIn",$V="draws";function Uf({policyDefinitions:t,generateReport:e,matchUpFormat:r,matchUps:n=[],subOrderMap:o,perPlayer:i}){if(!Array.isArray(n))return{error:Wo};if(n.reduce((I,{structureId:P})=>I.includes(P)?I:I.concat(P),[]).length!==1)return{error:X,info:"Maximum one structureId"};const a=n.filter(I=>I&&I.matchUpStatus!==nt),l=a.length&&He(a.map(({drawPositions:I})=>I).flat()).length,c=a.filter(I=>ca({matchUp:I})).length===a.length;c||(i=0);const u=n.every(({matchUpType:I,tieMatchUps:P})=>I===Qe&&P.every(y=>ca({matchUp:y}))),d=t==null?void 0:t[sI],p=n.filter(I=>ca({matchUp:I})||I.matchUpType===Qe),{participantResults:v}=K_({matchUps:p,matchUpFormat:r,tallyPolicy:d,perPlayer:i});let f,m;const{groupOrder:g,report:h}=nI({matchUps:p,participantResults:v,participantsCount:l,matchUpFormat:r,tallyPolicy:d,subOrderMap:o});if(c&&g)f=h,m=g,g.forEach(I=>{const{participantId:P,groupOrder:y,rankOrder:S,subOrder:O,ties:b,GEMscore:w}=I,T=v[P];Object.assign(T,{groupOrder:y,rankOrder:S,GEMscore:w,subOrder:O,ties:b})});else{const{groupOrder:I,report:P}=nI({requireCompletion:!1,participantResults:v,participantsCount:l,matchUpFormat:r,tallyPolicy:d,subOrderMap:o,matchUps:n});f=P,m=I,I&&I.forEach(y=>{const{participantId:S,groupOrder:O,GEMscore:b}=y,w=v[S];Object.assign(w,{provisionalOrder:O,GEMscore:b})})}const _={completedTieMatchUps:u,readableReport:"",participantResults:v,bracketComplete:c,order:[],report:f};if((c||u)&&(_.order=m),e||zt({tally:!0})){const I=_V({matchUps:n,report:f,order:m});zt({tally:!0})&&console.log(I),_.readableReport=I}return _}function NV({collectionDefinition:t,groupValueNumbers:e,groupValueGroups:r,sideTieValues:n,tieMatchUps:o}){const i=o.filter(_=>_.collectionId===t.collectionId),s=[0,0];let a=[0,0];const l=i.every(_=>Yt.includes(_.matchUpStatus)),{collectionValueProfiles:c,collectionGroupNumber:u,collectionValue:d,matchUpValue:p,winCriteria:v,scoreValue:f,setValue:m}=t,g=u&&e.includes(u),h=[0,0];if(i.forEach(_=>{_.winningSide&&(h[_.winningSide-1]+=1)}),p?i.forEach(_=>{_.winningSide&&(s[_.winningSide-1]+=p)}):m?i.forEach(_=>{var I,P;(P=(I=_.score)==null?void 0:I.sets)==null||P.forEach(y=>{y.winningSide&&(s[y.winningSide-1]+=m)})}):f?i.forEach(_=>{var I,P;(P=(I=_.score)==null?void 0:I.sets)==null||P.forEach(y=>{const{side1TiebreakScore:S=0,side2TiebreakScore:O=0,side1Score:b=0,side2Score:w=0}=y;(_.matchUpStatus===At||_.winningSide||y.winningSide)&&(b||w?(s[0]+=b,s[1]+=w):(S||O)&&y.winningSide&&(s[y.winningSide-1]+=1))})}):Array.isArray(c)&&i.forEach(_=>{if(_.winningSide){const I=_.collectionPosition,P=UV({collectionDefinition:t,collectionPosition:I});s[_.winningSide-1]+=P}}),d){let _;if(v!=null&&v.aggregateValue)l&&((p||m||f)&&s[0]!==s[1]?_=s[0]>s[1]?1:2:h[0]!==h[1]&&(_=h[0]>h[1]?1:2));else if(v!=null&&v.valueGoal)_=s.reduce((I,P,y)=>P>=v.valueGoal?y+1:I,0);else{const I=Math.floor(t.matchUpCount/2)+1;_=h.reduce((P,y,S)=>y>=I?S+1:P,0)}_&&(g?r[u].values[_-1]+=d:a[_-1]+=d)}else g?(r[u].values[0]+=s[0]||0,r[u].values[1]+=s[1]||0):a=s;g?(r[u].sideWins[0]+=h[0]||0,r[u].sideWins[1]+=h[1]||0,r[u].allGroupMatchUpsCompleted=r[u].allGroupMatchUpsCompleted&&l,r[u].matchUpsCount+=i.length):a.forEach((_,I)=>n[I]+=_)}function UV({collectionDefinition:t,collectionPosition:e}){const r=t.collectionValueProfiles||[],n=r==null?void 0:r.find(o=>o.collectionPosition===e);return n==null?void 0:n.matchUpValue}const is="appliedPolicies",mu="positionActions",aI="context",gu="delegatedOutcome",Pn="disabled",hu="disableLinks",fa="disableAutoCalc",_u="drawDeletions",AV="drawProfile",Iu="entryProfile",CV="eventProfile",MV="factory",yn="flightProfile",Af="groupingAttribute",Gn="lineUps",ss="linkedTournamentsIds",Pu="matchUpHistory",Cf="participantRepresentatives",va="personRequests",lI="rankingPoints",Wn="roundTarget",as="scheduleLimits",Hn="scheduleTiming",Qo="schedulingProfile",DV="statusDetail",ma="subOrder",Jo="tally",ls="tieFormatModification",cI={APPLIED_POLICIES:is,AUDIT_POSITION_ACTIONS:mu,CONTEXT:aI,DELEGATED_OUTCOME:gu,DISABLED:Pn,DISABLE_LINKS:hu,DISABLE_AUTO_CALC:fa,DRAW_DELETIONS:_u,DRAW_PROFILE:AV,ENTRY_PROFILE:Iu,EVENT_PROFILE:CV,FLIGHT_PROFILE:yn,GROUPING_ATTRIBUTE:Af,LINEUPS:Gn,LINKED_TOURNAMENTS:ss,MATCHUP_HISTORY:Pu,PARTICIPANT_REPRESENTATIVES:Cf,PERSON_REQUESTS:va,RANKING_POINTS:lI,ROUND_TARGET:Wn,SCHEDULE_LIMITS:as,SCHEDULE_TIMING:Hn,SCHEDULING_PROFILE:Qo,STATUS_DETAIL:DV,SUB_ORDER:ma,TALLY:Jo,TIE_FORMAT_MODIFICATIONS:ls,FACTORY:MV},uI=[gu,Pn,hu,yn,Gn,Pu,Cf,va,Wn,as,Hn,Qo,ma,Jo];var jV=Object.defineProperty,dI=Object.getOwnPropertySymbols,RV=Object.prototype.hasOwnProperty,FV=Object.prototype.propertyIsEnumerable,pI=(t,e,r)=>e in t?jV(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xV=(t,e)=>{for(var r in e||(e={}))RV.call(e,r)&&pI(t,r,e[r]);if(dI)for(var r of dI(e))FV.call(e,r)&&pI(t,r,e[r]);return t};function vt({onlySpecifiedPolicyTypes:t=!1,policyTypes:e=[],tournamentRecord:r,drawDefinition:n,structure:o,event:i}){if(!Array.isArray(e))return{error:Xh};const s={};return r&&a(r),i&&a(i),n&&a(n),o&&a(o),xV({appliedPolicies:s},V);function a(l){var c;const u=l==null?void 0:l.extensions,d=(c=u==null?void 0:u.find(p=>p.name===is))==null?void 0:c.value;if(d)for(const p of Object.keys(d))(t?e.includes(p):!e.length||e.includes(p))&&(s[p]=ve(d[p],!1,!0))}}function cs({policyTypes:t=[],tournamentRecord:e,drawDefinition:r,structure:n,event:o}){if(!Array.isArray(t))return{error:Xh};const{appliedPolicies:i}=vt({tournamentRecord:e,drawDefinition:r,structure:n,event:o}),s={};for(const a of t){const l=i==null?void 0:i[a];l&&(s[a]=l)}return Object.keys(s).length?{policyDefinitions:s}:{error:of}}const fI="WALKOVER",vI="RETIRED",Mf="COMPETITIVE",El="ROUTINE",$l="DECISIVE",Nl="winRatio",Df={[Ko]:{policyName:"Competitive Bands Default",competitiveProfile:{[$l]:20,[El]:50}}};function Eo({policyDefinitions:t,tournamentRecord:e,contextProfile:r,drawDefinition:n,event:o}){const i={policies:{}};if(!r)return i;const s=cs({tournamentRecord:e,drawDefinition:n,event:o}).policyDefinitions;if(r.withCompetitiveness){const a=(t==null?void 0:t[Ko])||(s==null?void 0:s[Ko])||Df[Ko];i.policies[Ko]=a}return i}function mI({matchUps:t,matchUpId:e}){return{matchUp:(t||[]).find(n=>n.matchUpId===e)}}function LV({matchUps:t}){const e=t.reduce((n,o)=>!o.collectionPosition||n.includes(o.collectionPosition)?n:n.concat(o.collectionPosition),[]).map(n=>({[n]:t.filter(o=>o.collectionPosition===n)}));return{collectionPositionMatchUps:Object.assign({},...e)}}const VV=(t,e)=>(t||0)+(e||0);function gI(t,e){return isNaN(t)&&fI||t<=e[$l]&&$l||t<=e[El]&&El||Mf}function hI({score:t}){const e=(t==null?void 0:t.sets)||[],r=e.reduce((o,i)=>(o[0]+=i.side1Score||0,o[1]+=i.side2Score||0,o),[0,0]),n=e.reduce((o,i)=>(o[0]+=i.side1TiebreakScore||0,o[1]+=i.side2TiebreakScore||0,o),[0,0]);return n.reduce(VV)&&(r[n[0]>n[1]?0:1]+=1),{sets:e,games:r,score:t}}function BV(t){const e=Math.min(...t.games),r=Math.max(...t.games);return Math.round(e/r*100)}function _I(t){return t.map(BV).sort().map(e=>e.toFixed(2))}function us({tournamentRecord:t,drawDefinition:e,policyType:r,structure:n,event:o}){if(!t)return{error:re};const{appliedPolicies:i}=vt({tournamentRecord:t,drawDefinition:e,structure:n,event:o});return i!=null&&i[r]?{policy:i[r]}:{error:of}}var kV=Object.defineProperty,GV=Object.defineProperties,WV=Object.getOwnPropertyDescriptors,II=Object.getOwnPropertySymbols,HV=Object.prototype.hasOwnProperty,qV=Object.prototype.propertyIsEnumerable,PI=(t,e,r)=>e in t?kV(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zV=(t,e)=>{for(var r in e||(e={}))HV.call(e,r)&&PI(t,r,e[r]);if(II)for(var r of II(e))qV.call(e,r)&&PI(t,r,e[r]);return t},YV=(t,e)=>GV(t,WV(e));function yI({competitiveProfile:t,tournamentRecord:e,matchUp:r}){if(!r)return{error:jr};const{score:n,winningSide:o}=r;if(!o)return{error:X};const i=!t&&e&&us({policyType:Ko,tournamentRecord:e}).policy,s=t||(i==null?void 0:i.competitiveProfile)||Df[Ko].competitiveProfile,a=hI({score:n}),l=_I([a]),c=gI(l,s);return YV(zV({},V),{competitiveness:c})}function Ul(t){const{matchUpAverageTimes:e,matchUpFormat:r}=t||{},n=(e==null?void 0:e.map(({matchUpFormatCodes:a})=>a==null?void 0:a.filter(l=>l===r)).flat().filter(Boolean).sort((a,l)=>((a==null?void 0:a.length)||0)-((l==null?void 0:l.length)||0)))||[],i=n.includes(r)?r:n[0],s=e==null?void 0:e.find(({matchUpFormatCodes:a,averageTimes:l})=>(a==null?void 0:a.find(c=>i===c))&&l);return s==null?void 0:s.averageTimes}function Al(t){var e;const{matchUpRecoveryTimes:r,averageMinutes:n,matchUpFormat:o}=t||{};return(e=r==null?void 0:r.find(({matchUpFormatCodes:i,averageTimes:s,recoveryTimes:a})=>{if(s&&n){const{greaterThan:l=0,lessThan:c=360}=s;if(n>l&&n<c)return!0}return(i==null?void 0:i.find(l=>l===o))&&a}))==null?void 0:e.recoveryTimes}function SI({timesBlockArray:t,categoryName:e,categoryType:r}){return t.filter(n=>Array.isArray(n)).map(n=>n.sort((o,i)=>{var s,a;return(((s=i.categoryNames)==null?void 0:s.length)||0)-(((a=o.categoryNames)==null?void 0:a.length)||0)}).find(({categoryTypes:o,categoryNames:i})=>!(i!=null&&i.length)&&!(o!=null&&o.length)||(i==null?void 0:i.includes(e))||(o==null?void 0:o.includes(r)))).find(Boolean)}var KV=Object.defineProperty,QV=Object.defineProperties,JV=Object.getOwnPropertyDescriptors,OI=Object.getOwnPropertySymbols,ZV=Object.prototype.hasOwnProperty,XV=Object.prototype.propertyIsEnumerable,bI=(t,e,r)=>e in t?KV(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jf=(t,e)=>{for(var r in e||(e={}))ZV.call(e,r)&&bI(t,r,e[r]);if(OI)for(var r of OI(e))XV.call(e,r)&&bI(t,r,e[r]);return t},Rf=(t,e)=>QV(t,JV(e));function eB({tournamentScheduling:t,eventScheduling:e,averageMinutes:r,defaultTiming:n,matchUpFormat:o,categoryName:i,categoryType:s,policy:a}){var l;const c=(e==null?void 0:e.matchUpRecoveryTimes)&&Al(Rf(jf({},e),{averageMinutes:r,matchUpFormat:o})),u=(t==null?void 0:t.matchUpRecoveryTimes)&&Al(Rf(jf({},t),{averageMinutes:r,matchUpFormat:o})),d=(a==null?void 0:a.matchUpRecoveryTimes)&&Al(Rf(jf({},a),{averageMinutes:r,matchUpFormat:o})),p=[c,u,d,(l=a==null?void 0:a.defaultTimes)==null?void 0:l.recoveryTimes,n==null?void 0:n.recoveryTimes];return SI({categoryName:i,categoryType:s,timesBlockArray:p})}var tB=Object.defineProperty,rB=Object.defineProperties,nB=Object.getOwnPropertyDescriptors,TI=Object.getOwnPropertySymbols,oB=Object.prototype.hasOwnProperty,iB=Object.prototype.propertyIsEnumerable,wI=(t,e,r)=>e in t?tB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ff=(t,e)=>{for(var r in e||(e={}))oB.call(e,r)&&wI(t,r,e[r]);if(TI)for(var r of TI(e))iB.call(e,r)&&wI(t,r,e[r]);return t},xf=(t,e)=>rB(t,nB(e));function sB({matchUpFormat:t,categoryName:e,categoryType:r,defaultTiming:n,tournamentScheduling:o,eventScheduling:i,policy:s}){var a;const l=(i==null?void 0:i.matchUpAverageTimes)&&Ul(xf(Ff({},i),{matchUpFormat:t})),c=(o==null?void 0:o.matchUpAverageTimes)&&Ul(xf(Ff({},o),{matchUpFormat:t})),u=(s==null?void 0:s.matchUpAverageTimes)&&Ul(xf(Ff({},s),{matchUpFormat:t})),d=[l,c,u,(a=s==null?void 0:s.defaultTimes)==null?void 0:a.averageTimes,n==null?void 0:n.averageTimes];return SI({categoryName:e,categoryType:r,timesBlockArray:d})}const Ei="RANKING",ds="RATING",ps="SCALE",Sn="SEEDING";var aB=Object.defineProperty,EI=Object.getOwnPropertySymbols,lB=Object.prototype.hasOwnProperty,cB=Object.prototype.propertyIsEnumerable,$I=(t,e,r)=>e in t?aB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,NI=(t,e)=>{for(var r in e||(e={}))lB.call(e,r)&&$I(t,r,e[r]);if(EI)for(var r of EI(e))cB.call(e,r)&&$I(t,r,e[r]);return t};function ga({participant:t}){var e;const r=(e=t.timeItems)==null?void 0:e.filter(({itemType:o})=>(o==null?void 0:o.startsWith(ps))&&[Ei,ds,Sn].includes(o.split(".")[1])),n={ratings:{},rankings:{},seedings:{}};if(r!=null&&r.length){const o=s=>r.filter(a=>(a==null?void 0:a.itemType)===s).sort((a,l)=>new Date(a.createdAt||void 0).getTime()-new Date(l.createdAt||void 0).getTime()).pop(),i=He(r.map(({itemType:s})=>s));for(const s of i){const a=o(s);if(a){const[,l,c,u]=a.itemType.split("."),d=l===Sn&&"seedings"||l===Ei&&"rankings"||"ratings";n[d][c]||(n[d][c]=[]),n[d][c].push({scaleValue:a.itemValue,scaleDate:a.itemDate,scaleName:u})}}}return NI(NI({},V),n)}function $o({tournamentParticipants:t=[],policyDefinitions:e={},contextProfile:r,participantId:n,internalUse:o,personId:i}){const s=t.find(l=>n&&l.participantId===n||i&&l.person&&l.person.personId===i),a=ve(s,!1,o);if(a){const l=e==null?void 0:e[wl];if(r!=null&&r.withScaleValues){const{ratings:c,rankings:u}=ga({participant:a});a.rankings=u,a.ratings=c}if(l!=null&&l.participant)return su({template:l.participant,source:a})}return a}function Zo({tournamentRecord:t,participantId:e}){return{participant:(t.participants||[]).reduce((o,i)=>i.participantId===e?i:o,void 0)}}function uB({tournamentRecord:t,policyDefinitions:e,convertExtensions:r,participantId:n,personId:o}){if(!t)return{error:re};if(typeof n!="string"&&typeof o!="string")return{error:_e};const i=t.participants||[],s=$o({tournamentParticipants:i,policyDefinitions:e,participantId:n,personId:o});return{participant:ve(s,r,!0)}}const Cl="extensionQueries";function Kt({element:t,name:e}){if(!t||!e)return k({result:{error:_e},stack:Cl});if(!Array.isArray(t.extensions))return{info:sr};const r=t.extensions.find(o=>(o==null?void 0:o.name)===e);return{extension:r,info:r?void 0:sr}}function Fr({tournamentRecord:t,name:e}){return Kt({element:t,name:e})}function No({event:t,name:e}){return t?Kt({element:t,name:e}):k({result:{error:Ge},stack:Cl})}function yu({drawDefinition:t,name:e}){return t?Kt({element:t,name:e}):k({result:{error:fe},stack:Cl})}function dB({tournamentRecord:t,participantId:e,name:r}){if(!t)return k({result:{error:re},stack:Cl});if(!e)return k({result:{error:Tt},stack:Cl});const{participant:n}=Zo({tournamentRecord:t,participantId:e});return Kt({element:n,name:r})}function Ml({tournamentRecord:t,categoryName:e,categoryType:r,event:n}){var o,i,s,a,l,c;e=(s=e??((o=n==null?void 0:n.category)==null?void 0:o.categoryName))!=null?s:(i=n==null?void 0:n.category)==null?void 0:i.ageCategoryCode,r=(c=r??((a=n==null?void 0:n.category)==null?void 0:a.categoryType))!=null?c:(l=n==null?void 0:n.category)==null?void 0:l.subType;const{policy:u}=us({policyType:Nf,tournamentRecord:t,event:n}),d=t?Fr({name:Hn,tournamentRecord:t}).extension:void 0,p=d==null?void 0:d.value,v=n&&No({name:Hn,event:n}).extension,f=v==null?void 0:v.value;return{scheduleTiming:{tournamentScheduling:p,eventScheduling:f,categoryName:e,categoryType:r,policy:u}}}const pB="DOUBLES_SINGLES",fB="SINGLES_DOUBLES",On="total",UI="participantConflict",$i="matchUpConflict",vB="ISSUE_IDS",fs="CONFLICT",vs="WARNING",AI="ERROR",CI="ISSUE",Lf="STATE";var mB=Object.defineProperty,gB=Object.defineProperties,hB=Object.getOwnPropertyDescriptors,MI=Object.getOwnPropertySymbols,_B=Object.prototype.hasOwnProperty,IB=Object.prototype.propertyIsEnumerable,DI=(t,e,r)=>e in t?mB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jI=(t,e)=>{for(var r in e||(e={}))_B.call(e,r)&&DI(t,r,e[r]);if(MI)for(var r of MI(e))IB.call(e,r)&&DI(t,r,e[r]);return t},RI=(t,e)=>gB(t,hB(e));function Vf({defaultAverageMinutes:t=90,defaultRecoveryMinutes:e=0,tournamentRecord:r,matchUpFormat:n,categoryName:o,categoryType:i,eventType:s,event:a}){if(!r)return{error:re};s=s||(a==null?void 0:a.eventType)||Ar.Singles;const l={averageTimes:[{minutes:{default:t}}],recoveryTimes:[{minutes:{default:e}}]},{scheduleTiming:c}=Ml({tournamentRecord:r,categoryName:o,categoryType:i,event:a}),u=RI(jI({},c),{matchUpFormat:n,categoryType:i,defaultTiming:l});return Su({eventType:s,timingDetails:u})}function Su({timingDetails:t,eventType:e}){const r=sB(t),n=Object.keys((r==null?void 0:r.minutes)||{}),o=(r==null?void 0:r.minutes)&&((n==null?void 0:n.includes(e))&&r.minutes[e]||r.minutes.default),i=eB(RI(jI({},t),{averageMinutes:o})),s=Object.keys((i==null?void 0:i.minutes)||{}),a=(i==null?void 0:i.minutes)&&((s==null?void 0:s.includes(e))&&i.minutes[e]||i.minutes.default),l=e===Nt?fB:pB,c=(i==null?void 0:i.minutes)&&((s==null?void 0:s.includes(l))&&i.minutes[l]||a);return{averageMinutes:o,recoveryMinutes:a,typeChangeRecoveryMinutes:c}}function an({requiredAttributes:t=["name","value"],extension:e}){if(!e||typeof e!="object"||typeof e.name!="string")return!1;const r=Object.keys(e);return t.filter(n=>r.includes(n)).length===t.length}function Et({event:t,eventId:e}){var r;if(!t)return{error:Ge};const n=No({name:yn,event:t}),o=n==null?void 0:n.extension,i=e?ve(o==null?void 0:o.value,!1,!0):o==null?void 0:o.value;return e&&((r=t.drawDefinitions)==null||r.forEach(s=>{var a;(a=i==null?void 0:i.flights)==null||a.forEach(l=>{l.drawId===s.drawId&&Object.assign(l,{drawDefinition:s})})})),{flightProfile:i}}var PB=Object.defineProperty,yB=Object.defineProperties,SB=Object.getOwnPropertyDescriptors,FI=Object.getOwnPropertySymbols,OB=Object.prototype.hasOwnProperty,bB=Object.prototype.propertyIsEnumerable,xI=(t,e,r)=>e in t?PB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ou=(t,e)=>{for(var r in e||(e={}))OB.call(e,r)&&xI(t,r,e[r]);if(FI)for(var r of FI(e))bB.call(e,r)&&xI(t,r,e[r]);return t},TB=(t,e)=>yB(t,SB(e));function wB({tournamentRecord:t,drawDefinition:e,event:r,context:n}){var o;if(!t)return{error:re};if(!r)return{error:Ge};const i=ve(r);n&&Object.assign(i,n);const s=e&&((o=i.drawDefinitions)==null?void 0:o.find(({drawId:a})=>e.drawId===a));return ye({event:i,drawDefinition:s})}function EB({tournamentRecord:t,context:e,inContext:r}){if(!t)return{error:re};const{tournamentId:n}=t;return{events:(t.events||[]).map(i=>{const s=ve(i);return e&&Object.assign(s,e),r&&Object.assign(s,{tournamentId:n}),s})}}function Qt({tournamentRecord:t,eventId:e,drawId:r}){const n="findEvent";if(!t)return Ou({event:void 0,drawDefinition:void 0},k({result:{error:re},stack:n}));const o=(t==null?void 0:t.events)||[];if(r){let i;const s=o.find(a=>{var l;const u=((a==null?void 0:a.drawDefinitions)||[]).find(d=>d.drawId===r);if(u)i=u;else{const{flightProfile:d}=Et({event:a}),p=(l=d==null?void 0:d.flights)==null?void 0:l.find(v=>v.drawId===r);if(p)return{drawId:r,entries:p.drawEntries,drawName:p.drawName}}return u});if(s)return{event:s,drawDefinition:i}}if(e){const i=o.find(s=>s.eventId===e);return i?{event:i,drawDefinition:void 0}:Ou({event:void 0,drawDefinition:void 0},k({result:{error:Ur},stack:n}))}return Ou({event:void 0,drawDefinition:void 0},k({result:{error:tn},context:{drawId:r,eventId:e},stack:n}))}function Xo({tournamentRecord:t,drawId:e}){if(!t)return{error:re};if(!e)return{error:kr};const r=(t.events||[]).reduce((n,o)=>{const i=(o.drawDefinitions||[]).reduce((s,a)=>a.drawId===e?a:s,void 0);return i&&i.drawId===e?{event:o,drawDefinition:i}:n},void 0);return r?TB(Ou({},r),{SUCCESS:V}):k({result:{error:tn},stack:"getDrawDefinition"})}var $B=Object.defineProperty,LI=Object.getOwnPropertySymbols,NB=Object.prototype.hasOwnProperty,UB=Object.prototype.propertyIsEnumerable,VI=(t,e,r)=>e in t?$B(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,AB=(t,e)=>{for(var r in e||(e={}))NB.call(e,r)&&VI(t,r,e[r]);if(LI)for(var r of LI(e))UB.call(e,r)&&VI(t,r,e[r]);return t};function it(t){if(typeof t!="object")return{error:_e};const e="addExtension";if(!(t!=null&&t.element))return k({result:{error:_e},stack:e});if(typeof t.element!="object")return k({result:{error:X},stack:e});if(!an({extension:t.extension}))return k({result:{error:X,info:"invalid extension"},stack:e});if(t.element.extensions||(t.element.extensions=[]),t.creationTime!==void 0?t.creationTime:!0){const o=new Date().toISOString();Object.assign(t.extension,{createdAt:o})}const n=t.element.extensions.find(({name:o})=>o===t.extension.name);return n?n.value=t.extension.value:t.extension.value&&t.element.extensions.push(t.extension),AB({},V)}const Bf="element required",kf="missing name";var CB=Object.defineProperty,MB=Object.defineProperties,DB=Object.getOwnPropertyDescriptors,BI=Object.getOwnPropertySymbols,jB=Object.prototype.hasOwnProperty,RB=Object.prototype.propertyIsEnumerable,kI=(t,e,r)=>e in t?CB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,GI=(t,e)=>{for(var r in e||(e={}))jB.call(e,r)&&kI(t,r,e[r]);if(BI)for(var r of BI(e))RB.call(e,r)&&kI(t,r,e[r]);return t},FB=(t,e)=>MB(t,DB(e));function bn(t){return!t||typeof t!="object"?{error:_e}:t!=null&&t.element?typeof(t==null?void 0:t.element)!="object"?{error:X}:t!=null&&t.name?t!=null&&t.element.extensions?(t.element.extensions=t.element.extensions.filter(e=>(e==null?void 0:e.name)!==t.name),GI({},V)):FB(GI({},V),{info:sr}):{error:_e,info:kf}:{error:_e,info:Bf}}function Ni(t){return!t||typeof t!="object"?{error:_e}:t.tournamentRecord?it({creationTime:t.creationTime,element:t.tournamentRecord,extension:t.extension}):{error:re}}function Gf(t){return!t||typeof t!="object"?{error:_e}:t.drawDefinition?it({creationTime:t.creationTime,element:t.drawDefinition,extension:t.extension}):{error:tn}}function lo(t){return!t||typeof t!="object"?{error:_e}:t.event?it({creationTime:t.creationTime,extension:t.extension,element:t.event}):{error:Ge}}function xB(t){var e;if(!t||typeof t!="object")return{error:_e};if(!t.participantId)return{error:Tt};const r=((e=t.tournamentRecord)==null?void 0:e.participants)||[],n=$o({participantId:t.participantId,tournamentParticipants:r});return n?it({creationTime:t.creationTime,extension:t.extension,element:n}):{error:Dt}}function Wf(t){return!t||typeof t!="object"?{error:_e}:t.tournamentRecord?bn({element:t.tournamentRecord,name:t.name}):{error:re}}function LB(t){return!t||typeof t!="object"?{error:_e}:t.drawDefinition?bn({element:t.drawDefinition,name:t.name}):{error:tn}}function bu(t){return!t||typeof t!="object"?{error:_e}:t!=null&&t.event?bn({element:t.event,name:t.name}):{error:Ur}}function VB(t){var e;if(!t||typeof t!="object")return{error:_e};if(!t.participantId)return{error:Tt};const r=((e=t.tournamentRecord)==null?void 0:e.participants)||[],n=$o({participantId:t.participantId,tournamentParticipants:r});return n?bn({element:n,name:t.name}):{error:Dt}}var BB=Object.defineProperty,kB=Object.defineProperties,GB=Object.getOwnPropertyDescriptors,WI=Object.getOwnPropertySymbols,WB=Object.prototype.hasOwnProperty,HB=Object.prototype.propertyIsEnumerable,HI=(t,e,r)=>e in t?BB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qI=(t,e)=>{for(var r in e||(e={}))WB.call(e,r)&&HI(t,r,e[r]);if(WI)for(var r of WI(e))HB.call(e,r)&&HI(t,r,e[r]);return t},qB=(t,e)=>kB(t,GB(e));function Hf({tournamentRecords:t,extension:e}){if(!an({extension:e}))return{error:X};const r="addExtension";for(const n of Object.values(t)){const o=Ni({tournamentRecord:n,extension:e});if(o.error)return k({result:o,stack:r})}return qI({},V)}function Tu({tournamentRecords:t,name:e}){if(!e)return{error:_e,info:kf};let r;return Object.keys(t).find(o=>{const i=t[o],{extension:s}=Fr({tournamentRecord:i,name:e});return r=s,!!s})?{extension:r}:{error:sr}}function wu({tournamentRecords:t,name:e}){if(!e)return{error:_e,info:kf};let r=0;for(const n of Object.keys(t)){const o=t[n],i=Wf({tournamentRecord:o,name:e});if(i.error)return k({result:i,stack:"removeExtension"});i.info!==sr&&r++}return qB(qI({},V),{removed:r})}function zB({tournamentRecords:t,eventId:e,extension:r}){if(typeof e!="string")return{error:Ge};if(!an({extension:r}))return{error:X};for(const n of Object.values(t)){const{event:o}=Qt({tournamentRecord:n,eventId:e});if(o)return lo({event:o,extension:r})}return{error:Ur}}var YB=Object.defineProperty,zI=Object.getOwnPropertySymbols,KB=Object.prototype.hasOwnProperty,QB=Object.prototype.propertyIsEnumerable,YI=(t,e,r)=>e in t?YB(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,KI=(t,e)=>{for(var r in e||(e={}))KB.call(e,r)&&YI(t,r,e[r]);if(zI)for(var r of zI(e))QB.call(e,r)&&YI(t,r,e[r]);return t};function qf({tournamentRecords:t}){return typeof t!="object"||!Object.keys(t).length?{error:ke}:{linkedTournamentIds:Object.assign({},...Object.keys(t).map(r=>{var n;const o=t[r],i=o==null?void 0:o.tournamentId,{extension:s}=Fr({tournamentRecord:o,name:ss}),a=(((n=s==null?void 0:s.value)==null?void 0:n.tournamentIds)||[]).filter(l=>l!==i);return{[r]:a}}))}}function JB({tournamentRecords:t}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const e=QI(t),{tournamentIds:r}=e;return(r==null?void 0:r.length)>1?Hf({tournamentRecords:t,extension:{name:ss,value:{tournamentIds:r}}}):KI({},V)}function ZB({tournamentRecords:t}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const e=wu({name:ss,tournamentRecords:t});return k({result:e,stack:"unlinkTournaments"})}function XB({tournamentRecords:t,tournamentId:e}){if(typeof t!="object")return{error:X};if(!e)return{error:So};const r=QI(t),{tournamentIds:n}=r;if(!n.includes(e))return{error:So};let o;return n.every(i=>{var s;const a=t[i],{extension:l}=Fr({tournamentRecord:a,name:ss});if(!l)return!0;const c=((s=l==null?void 0:l.value)==null?void 0:s.tournamentIds)||[];if(!(c!=null&&c.length)||c.length===1&&c.includes(e)||i===e){const p=Wf({name:ss,tournamentRecord:a});return p.error&&(o=p.error),p.success}const u=c.filter(p=>p!==e);l.value={tournamentIds:u};const d=Ni({tournamentRecord:a,extension:l});return d.error&&(o=d.error),d.success}),o?{error:o}:KI({},V)}function QI(t){return{tournamentIds:Object.keys(t).filter(Boolean)}}function JI({extension:t,dates:e=[]}){if(!t)return!1;if(typeof t.value=="boolean"&&t.value)return!0;if(typeof t.value=="object"&&Array.isArray(t.value.dates))return e.length?!!e.filter(n=>t.value.dates.includes(n)).length:!0}function xr({element:t,name:e}){const r="findExtension";if(!t||!e)return k({result:{error:_e},stack:r});if(!Array.isArray(t.extensions))return k({result:{error:sr},stack:r});const n=t.extensions.find(o=>(o==null?void 0:o.name)===e);return n?{extension:n}:k({result:{error:sr},stack:r})}var ek=Object.defineProperty,tk=Object.defineProperties,rk=Object.getOwnPropertyDescriptors,ZI=Object.getOwnPropertySymbols,nk=Object.prototype.hasOwnProperty,ok=Object.prototype.propertyIsEnumerable,XI=(t,e,r)=>e in t?ek(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ik=(t,e)=>{for(var r in e||(e={}))nk.call(e,r)&&XI(t,r,e[r]);if(ZI)for(var r of ZI(e))ok.call(e,r)&&XI(t,r,e[r]);return t},sk=(t,e)=>tk(t,rk(e));function eP({convertExtensions:t,ignoreDisabled:e,venue:r,court:n}){const o=sk(ik({},ve(n,t,!0)),{venueId:r.venueId}),{extension:i}=xr({name:Pn,element:n});if(e&&i){const s=typeof i.value=="object"&&i.value.dates||[],a=i.value===!0?[]:o.dateAvailability.map(l=>{const c=l.date;if(!(!c||s.includes(c)))return l}).filter(Boolean);o.dateAvailability=a}return{inContextCourt:o}}const tP="addDrawDefinition",zf="addMatchUps",Ui="addParticipants",rP="addScaleItems",nP="addVenue",Dl="audit",oP="deleteParticipants",iP="deleteVenue",sP="deletedDrawIds",aP="deletedMatchUpIds",lP="modifyDrawDefinition",ak="modifyDrawEntries",lk="modifyEventEntries",cP="modifyMatchUp",rr="modifyParticipants",uP="modifyPositionAssignments",dP="modifySeedAssignments",ck="modifyTournamentDetail",ms="modifyVenue",pP="mutations",uk="publishEvent",dk="publishEventSeeding",pk="publishOrderOfPlay",fP="unPublishEvent",vP="unPublishEventSeeding",mP="unPublishOrderOfPlay",Yf="updateInContextMatchUp";var fk=Object.defineProperty,vk=Object.defineProperties,mk=Object.getOwnPropertyDescriptors,gP=Object.getOwnPropertySymbols,gk=Object.prototype.hasOwnProperty,hk=Object.prototype.propertyIsEnumerable,hP=(t,e,r)=>e in t?fk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_k=(t,e)=>{for(var r in e||(e={}))gk.call(e,r)&&hP(t,r,e[r]);if(gP)for(var r of gP(e))hk.call(e,r)&&hP(t,r,e[r]);return t},Ik=(t,e)=>vk(t,mk(e));function jl({tournamentRecord:t,disableNotice:e,context:r,venue:n}){return t?n?(t.venues||(t.venues=[]),n.venueId||(n.venueId=ze()),t.venues.reduce((i,s)=>i||s.venueId===n.venueId,void 0)?{error:Lx}:(r&&it({element:n,extension:{value:r,name:aI}}),t.venues.push(n),e||qe({payload:{venue:n,tournamentId:t.tournamentId},topic:nP}),Ik(_k({},V),{venue:ve(n)}))):{error:_e,info:"missing venue"}:{error:re}}var Pk=Object.defineProperty,yk=Object.defineProperties,Sk=Object.getOwnPropertyDescriptors,Eu=Object.getOwnPropertySymbols,_P=Object.prototype.hasOwnProperty,IP=Object.prototype.propertyIsEnumerable,PP=(t,e,r)=>e in t?Pk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yP=(t,e)=>{for(var r in e||(e={}))_P.call(e,r)&&PP(t,r,e[r]);if(Eu)for(var r of Eu(e))IP.call(e,r)&&PP(t,r,e[r]);return t},SP=(t,e)=>yk(t,Sk(e)),Ok=(t,e)=>{var r={};for(var n in t)_P.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Eu)for(var n of Eu(t))e.indexOf(n)<0&&IP.call(t,n)&&(r[n]=t[n]);return r};function Kf({convertExtensions:t,tournamentRecord:e,ignoreDisabled:r,dates:n}){var o;if(!e)return{error:re};const i=ve((o=e.venues)!=null?o:[],t).filter(a=>{if(!r)return a;const{extension:l}=xr({name:Pn,element:a});return!(l!=null&&l.value)&&a}).filter(Boolean),s=i.reduce((a,l)=>{const c=((l==null?void 0:l.courts)||[]).filter(u=>{if(!r&&!(n!=null&&n.length))return u;const{extension:d}=xr({name:Pn,element:u});return JI({extension:d,dates:n})}).filter(Boolean).map(u=>{const{inContextCourt:d}=eP({convertExtensions:t,ignoreDisabled:r,venue:l,court:u});return d});return c.length?a.concat(c):a},[]);return{venues:i,courts:s}}function ei({tournamentRecords:t,tournamentRecord:e,venueId:r}){var n;if(!e)return{error:re};if(!r)return{error:Ho};const i=((n=e.venues)!=null?n:[]).reduce((s,a)=>a.venueId===r?a:s,void 0);if(!i&&t){const a=(qf({tournamentRecords:t}).linkedTournamentIds||[])[e.tournamentId];for(const l of a){const c=t[l],u=ei({tournamentRecord:c,venueId:r});if(u.success&&u.venue)return jl({tournamentRecord:e,venue:u.venue}),SP(yP({},V),{venue:i})}}return i?SP(yP({},V),{venue:i}):{error:yi}}function bk(t){var e=t,{convertExtensions:r}=e,n=Ok(e,["convertExtensions"]);const{tournamentRecords:o,tournamentRecord:i,venueId:s}=n,a=ei({tournamentRecords:o,tournamentRecord:i,venueId:s});return ve(a,r,!0)}var Tk=Object.defineProperty,wk=Object.defineProperties,Ek=Object.getOwnPropertyDescriptors,OP=Object.getOwnPropertySymbols,$k=Object.prototype.hasOwnProperty,Nk=Object.prototype.propertyIsEnumerable,bP=(t,e,r)=>e in t?Tk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,TP=(t,e)=>{for(var r in e||(e={}))$k.call(e,r)&&bP(t,r,e[r]);if(OP)for(var r of OP(e))Nk.call(e,r)&&bP(t,r,e[r]);return t},wP=(t,e)=>wk(t,Ek(e));function gs({tournamentRecords:t,tournamentRecord:e,courtId:r}){var n;if(!e)return{error:re};if(!r)return{error:na};const o="findCourt";let i,s;if(((n=e.venues)!=null?n:[]).forEach(a=>{var l;((l=a.courts)!=null?l:[]).forEach(c=>{c.courtId===r&&(i=c,s=a)})}),i)return wP(TP({},V),{court:i,venue:s});if(t){const l=(qf({tournamentRecords:t}).linkedTournamentIds||[])[e.tournamentId];for(const c of l){const u=t[c],d=gs({tournamentRecord:u,courtId:r});if(d.success)return d.venue&&jl({tournamentRecord:e,venue:d.venue}),wP(TP({},V),{court:i,venue:s})}}return k({result:{error:pf},stack:o})}function Uk(t){return ve(gs(t),!1,!0)}function Ak({tournamentRecord:t,venueId:e,venueIds:r}){return t?{courts:(t.venues||[]).filter(o=>e?o.venueId===e:r?r.includes(o.venueId):!0).map(o=>{const{venueId:i}=o,s=ve(o.courts||[]);return s.forEach(a=>Object.assign(a,{venueId:i})),s}).flat()}:{error:re}}var Ck=Object.defineProperty,Mk=Object.defineProperties,Dk=Object.getOwnPropertyDescriptors,EP=Object.getOwnPropertySymbols,jk=Object.prototype.hasOwnProperty,Rk=Object.prototype.propertyIsEnumerable,$P=(t,e,r)=>e in t?Ck(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fk=(t,e)=>{for(var r in e||(e={}))jk.call(e,r)&&$P(t,r,e[r]);if(EP)for(var r of EP(e))Rk.call(e,r)&&$P(t,r,e[r]);return t},xk=(t,e)=>Mk(t,Dk(e));function NP({tournamentRecord:t,internalUse:e,courtId:r}){if(!t)return{error:re};if(!r)return{error:na};const n=gs({tournamentRecord:t,courtId:r});if(n.error)return n;const o=n.court&&(({altitude:i,courtId:s,courtName:a,courtDimensions:l,latitude:c,longitude:u,surfaceCategory:d,surfaceType:p,surfacedDate:v,pace:f,notes:m})=>({altitude:i,courtId:s,courtName:a,courtDimensions:l,latitude:c,longitude:u,surfaceCategory:d,surfaceType:p,surfacedDate:v,pace:f,notes:m}))(n.court);return xk(Fk({},V),{courtInfo:ve(o,!1,e)})}var Lk=Object.defineProperty,Vk=Object.defineProperties,Bk=Object.getOwnPropertyDescriptors,UP=Object.getOwnPropertySymbols,kk=Object.prototype.hasOwnProperty,Gk=Object.prototype.propertyIsEnumerable,AP=(t,e,r)=>e in t?Lk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qf=(t,e)=>{for(var r in e||(e={}))kk.call(e,r)&&AP(t,r,e[r]);if(UP)for(var r of UP(e))Gk.call(e,r)&&AP(t,r,e[r]);return t},CP=(t,e)=>Vk(t,Bk(e));function $u({tournamentRecord:t,venueId:e}){var r,n;if(!t)return{error:re};if(!e)return{error:Ho};const o=ei({tournamentRecord:t,venueId:e});if(o.error)return o;const s=((n=(r=o.venue)==null?void 0:r.courts)!=null?n:[]).map(c=>(({courtInfo:u})=>Qf({},u))(NP({courtId:c.courtId,internalUse:!0,tournamentRecord:t}))),a=o.venue&&(({venueId:c,venueName:u,venueAbbreviation:d})=>({venueAbbreviation:d,venueName:u,venueId:c}))(o.venue),l=a&&CP(Qf({},a),{courtsInfo:s});return CP(Qf({},V),{venueData:ve(l,!1,!0)})}const Jf="CHECK_IN",Zf="CHECK_OUT",Rl="SCHEDULE.ASSIGNMENT.VENUE",ti="SCHEDULE.ALLOCATION.COURTS",hs="SCHEDULE.ASSIGNMENT.COURT",MP="SCHEDULE.COURT.ORDER",Fl="SCHEDULE.DATE",Wk="SCHEDULE.ASSIGN.OFFICIAL",xl="SCHEDULE.TIME.SCHEDULED",qn="SCHEDULE.TIME.START",ri="SCHEDULE.TIME.STOP",Uo="SCHEDULE.TIME.RESUME",ni="SCHEDULE.TIME.END",DP="SCHEDULE.TIME.MODIFIERS",jP=["TO_BE_ANNOUNCED","NEXT_AVAILABLE","FOLLOWED_BY","AFTER_REST","RAIN_DELAY"],Hk="SCALE",qk="RATING",zk="RANKING",RP="SEEDING",Hr="PUBLISH",zn="PUBLIC",qr="STATUS";function Nu(t){return t.createdAt?new Date(t.createdAt).getTime():0}function Ai({visibilityThreshold:t,timeItems:e,itemType:r}){const n=e.filter(i=>i&&i.itemType===r&&(!t||Nu(i)<new Date(t).getTime())).sort((i,s)=>Nu(i)-Nu(s)).pop(),o=n&&Nu(n);return{itemValue:n==null?void 0:n.itemValue,timeStamp:o}}function Xf({visibilityThreshold:t,timeStamp:e,schedule:r,matchUp:n}){const{itemValue:o,timeStamp:i}=Ai({timeItems:(n==null?void 0:n.timeItems)||[],itemType:xl,visibilityThreshold:t});return!r||i&&e&&new Date(i).getTime()>new Date(e).getTime()?{scheduledTime:o}:r}function Ci({visibilityThreshold:t,timeStamp:e,schedule:r,matchUp:n}){const{itemValue:o,timeStamp:i}=Ai({timeItems:(n==null?void 0:n.timeItems)||[],itemType:Fl,visibilityThreshold:t});return!r||i&&e&&new Date(i).getTime()>new Date(e).getTime()?{scheduledDate:o}:r}function FP({visibilityThreshold:t,timeStamp:e,schedule:r,matchUp:n}){const{itemValue:o,timeStamp:i}=Ai({timeItems:(n==null?void 0:n.timeItems)||[],itemType:ti,visibilityThreshold:t});return!r||i&&e&&new Date(i).getTime()>new Date(e).getTime()?{allocatedCourts:ve(o,!1,!0)}:r}function xP({visibilityThreshold:t,timeStamp:e,schedule:r,matchUp:n}){const{itemValue:o,timeStamp:i}=Ai({timeItems:(n==null?void 0:n.timeItems)||[],itemType:hs,visibilityThreshold:t});return!r||i&&e&&new Date(i).getTime()>new Date(e).getTime()?{courtId:o}:r}function LP({visibilityThreshold:t,timeStamp:e,schedule:r,matchUp:n}){const{itemValue:o,timeStamp:i}=Ai({timeItems:(n==null?void 0:n.timeItems)||[],itemType:Rl,visibilityThreshold:t});return!r||i&&e&&new Date(i).getTime()>new Date(e).getTime()?{venueId:o}:r}function ev({visibilityThreshold:t,timeStamp:e,schedule:r,matchUp:n}){const{itemValue:o,timeStamp:i}=Ai({timeItems:(n==null?void 0:n.timeItems)||[],itemType:DP,visibilityThreshold:t});return!r||i&&e&&new Date(i).getTime()>new Date(e).getTime()?{timeModifiers:o}:r}function _s(t){if(M_.test(t)){const e=_f();return new Date(`${e}T${t}`)}else return new Date(t)}function VP({matchUp:t}){if(!t)return{error:jr};if(!t.timeItems)return{error:h_};const e=t.timeItems.filter(n=>[qn,ri,Uo,ni].includes(n==null?void 0:n.itemType)).sort((n,o)=>_s(n.itemValue).getTime()-_s(o.itemValue).getTime()),r=e.reduce((n,o)=>{var i,s;let a;const l=(i=o==null?void 0:o.itemType)==null?void 0:i.split("."),u=`SCHEDULE.TIME.${((s=o==null?void 0:o.itemType)==null?void 0:s.startsWith("SCHEDULE.TIME"))&&l[2]}`;switch(u){case qn:a=0;break;case ni:if(n.lastValue&&[qn,Uo].includes(n.lastType)){const d=_s(o.itemValue).getTime()-_s(n.lastValue).getTime();a=n.milliseconds+d}else a=n.milliseconds;break;case ri:if([qn,"SCHECULE.TIME.RESUME"].includes(n.lastType)){const d=_s(o.itemValue).getTime()-_s(n.lastValue).getTime();a=n.milliseconds+d}else a=n.milliseconds;break;default:a=n.milliseconds;break}return{milliseconds:a,lastType:u,lastValue:o.itemValue}},{milliseconds:0,lastType:void 0,lastValue:void 0});if([qn,Uo].includes(r.lastType)){const n=new Date().getTime()-_s(r.lastValue).getTime();r.milliseconds+=n}return{milliseconds:r.milliseconds,time:Yk(r.milliseconds),relevantTimeItems:e}}function Yk(t){const e=(r,n=2)=>("00"+r).slice(-n);return e(t/36e5|0)+":"+e(t%36e5/6e4|0)+":"+e(t%6e4/1e3|0)}function Kk({visibilityThreshold:t,timeStamp:e,schedule:r,matchUp:n}){const{itemValue:o,timeStamp:i}=Ai({timeItems:(n==null?void 0:n.timeItems)||[],itemType:MP,visibilityThreshold:t});return!r||i&&e&&new Date(i).getTime()>new Date(e).getTime()?{courtOrder:o}:r}function Qk({matchUp:t}){const e=(t==null?void 0:t.timeItems)||[],r=i=>i.createdAt?new Date(i.createdAt).getTime():0,n=e.reduce((i,s)=>{const a=s.itemType===qn&&s;return a&&(!i||r(a)<r(i))?a:i},void 0);return{startTime:n==null?void 0:n.itemValue}}function Jk({matchUp:t}){const e=(t==null?void 0:t.timeItems)||[],r=i=>i.createdAt?new Date(i.createdAt).getTime():0,n=e.reduce((i,s)=>{const a=s.itemType===ni&&s;return a&&(!i||r(a)>r(i))?a:i},void 0);return{endTime:n==null?void 0:n.itemValue}}const oi="SINGLES",BP="SINGLES",ln="DOUBLES",Uu="DOUBLES",Bt="TEAM",co="TEAM";var Zk=Object.defineProperty,kP=Object.getOwnPropertySymbols,Xk=Object.prototype.hasOwnProperty,eG=Object.prototype.propertyIsEnumerable,GP=(t,e,r)=>e in t?Zk(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,tG=(t,e)=>{for(var r in e||(e={}))Xk.call(e,r)&&GP(t,r,e[r]);if(kP)for(var r of kP(e))eG.call(e,r)&&GP(t,r,e[r]);return t};function tv({scheduleVisibilityFilters:t,afterRecoveryTimes:e,tournamentRecord:r,scheduleTiming:n,matchUpFormat:o,matchUpType:i,matchUp:s,event:a}){var l,c,u,d,p,v,f;if(!s)return{error:jr};if(e&&!s.matchUpType&&!i&&(a||r)&&s.drawId){let E=(l=a==null?void 0:a.drawDefinitions)==null?void 0:l.find($=>$.drawId===s.drawId);!E&&r&&({drawDefinition:E,event:a}=Qt({tournamentRecord:r,drawId:s.drawId}));const N=s.structureId&&((c=E==null?void 0:E.structures)==null?void 0:c.find(({structureId:$})=>$===s.structureId));i=(N==null?void 0:N.matchUpType)||(E==null?void 0:E.matchUpType)||(a==null?void 0:a.eventType)!==Bt&&(a==null?void 0:a.eventType)}const{milliseconds:m,time:g}=VP({matchUp:s}),{startTime:h}=Qk({matchUp:s}),{endTime:_}=Jk({matchUp:s});let I;const{visibilityThreshold:P,eventIds:y,drawIds:S}=t??{};if((!y||y.includes(s.eventId))&&(!S||S.includes(s.drawId))){const E={matchUp:s,visibilityThreshold:P},{allocatedCourts:N}=FP(E),{scheduledTime:$}=Xf(E);let{scheduledDate:A}=Ci(E);const{venueId:U}=LP(E),{courtId:C}=xP(E),{courtOrder:M}=Kk(E),{timeModifiers:D}=ev(E);let R,j,G,W,z;const F=(u=s.matchUpType)!=null?u:i;if(n&&$&&e&&F){const Q=tG({matchUpFormat:(d=s.matchUpFormat)!=null?d:o},n);({averageMinutes:j=0,recoveryMinutes:G=0,typeChangeRecoveryMinutes:W=0}=Su({timingDetails:Q,eventType:F})),(j||G)&&(R=_?Sr(ct(_),G):Sr($,j+G)),W&&(z=_?Sr(ct(_),W):Sr($,j+W))}!A&&$&&(A=Re($));const L=lu({scheduledDate:A,scheduledTime:$}),x={},B=((p=r&&U&&$u({tournamentRecord:r,venueId:U}))==null?void 0:p.venueData)||{};U&&(x[U]=B);const{venueName:H,venueAbbreviation:q,courtsInfo:J}=B,K=C&&(J==null?void 0:J.find(Q=>Q.courtId===C)),Y=K==null?void 0:K.courtName;for(const Q of N||[]){if(!r)break;Q.venueId&&!x[Q.venueid]&&(x[Q.venueId]=(v=$u({venueId:Q.venueId,tournamentRecord:r}))==null?void 0:v.venueData);const Z=x[Q.venueId];Q.venueName=Z==null?void 0:Z.venueName;const ee=(f=Z==null?void 0:Z.courtsInfo)==null?void 0:f.find(ne=>ne.courtId===Q.courtId);Q.courtName=ee==null?void 0:ee.courtName}I=ye({typeChangeTimeAfterRecovery:z,timeAfterRecovery:R,scheduledDate:A,scheduledTime:$,isoDateString:L,allocatedCourts:N,timeModifiers:D,venueAbbreviation:q,venueName:H,venueId:U,courtOrder:M,courtName:Y,courtId:C,typeChangeRecoveryMinutes:W,recoveryMinutes:G,averageMinutes:j,milliseconds:m,startTime:h,endTime:_,time:g})}else I=ye({time:g,startTime:h,endTime:_,milliseconds:m});const O=s.matchUpStatus&&Yt.includes(s.matchUpStatus),{scheduledDate:b}=Ci({matchUp:s}),{scheduledTime:w}=Xf({matchUp:s}),T=O&&(Re(_)||Re(b)||Re(w))||void 0;return{schedule:I,endDate:T}}var rG=Object.defineProperty,WP=Object.getOwnPropertySymbols,nG=Object.prototype.hasOwnProperty,oG=Object.prototype.propertyIsEnumerable,HP=(t,e,r)=>e in t?rG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,iG=(t,e)=>{for(var r in e||(e={}))nG.call(e,r)&&HP(t,r,e[r]);if(WP)for(var r of WP(e))oG.call(e,r)&&HP(t,r,e[r]);return t};function Au({collectionPosition:t,collectionId:e,lineUp:r}){let n=[];const o=[];if(r){const i=a=>a===void 0?-1:a,s=r.map(a=>{const{collectionAssignments:l,participantId:c}=a,u=l==null?void 0:l.find(d=>d.collectionPosition===t&&d.collectionId===e);return u&&iG({participantId:c},u)}).filter(Boolean).sort((a,l)=>i(a.substitutionOrder)-i(l.substitutionOrder));for(const a of s){const{participantId:l,previousParticipantId:c,substitutionOrder:u}=a;n.includes(l)||(c&&o.push({previousParticipantId:c,substitutionOrder:u,participantId:l}),n=n.filter(d=>d!==c),n.push(l))}}return{assignedParticipantIds:n,substitutions:o}}const Ll="SIGN_IN_STATUS",Fe=Vn.Individual,Cr=Vn.Group,Ue=Vn.Pair,rt=Vn.Team,Yn=Vn.Team,Vl="SIGNED_IN",sG="SIGNED_OUT",Bl={TEAM_PARTICIPANT:Yn,INDIVIDUAL:Fe,GROUP:Cr,TEAM:rt,PAIR:Ue};var aG=Object.defineProperty,qP=Object.getOwnPropertySymbols,lG=Object.prototype.hasOwnProperty,cG=Object.prototype.propertyIsEnumerable,zP=(t,e,r)=>e in t?aG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,uG=(t,e)=>{for(var r in e||(e={}))lG.call(e,r)&&zP(t,r,e[r]);if(qP)for(var r of qP(e))cG.call(e,r)&&zP(t,r,e[r]);return t};function Kn({tournamentParticipants:t,tournamentRecord:e,participantIds:r}){const n="getPairedParticipant";if(!t&&!e)return{error:re};if(!Array.isArray(r)||r.length>2)return{error:mn};if(!r.length)return k({result:{error:bo},stack:n});t=t||(e==null?void 0:e.participants)||[];const o=t.filter(a=>a.participantType===Ue&&Ht(r,a.individualParticipantIds).length===r.length&&a.individualParticipantIds.length===r.length),i=o[0];if(!i)return k({result:{error:Dt},stack:n});const s=ve(o.slice(1),!1,!0);return uG({participant:ve(i),duplicatedPairParticipants:s},V)}function kl({drawDefinition:t,participantId:e}){if(typeof t!="object")return{error:fe};if(typeof e!="string")return{error:Tt};const{extension:r}=Kt({element:t,name:Gn});return{lineUp:((r==null?void 0:r.value)||{})[e]}}function dG({tournamentParticipants:t,positionAssignments:e,collectionPosition:r,drawPositions:n=[],participantMap:o,drawDefinition:i,collectionId:s,sideLineUps:a,matchUpType:l}){if(!s||!r)return;const c=(n==null?void 0:n.map(u=>{var d,p,v,f,m,g;const h=(d=e.find(O=>O.drawPosition===u))==null?void 0:d.participantId,_=a==null?void 0:a.find(O=>(O==null?void 0:O.drawPosition)===u),I=(_==null?void 0:_.teamParticipant)||h&&((p=o==null?void 0:o[h])==null?void 0:p.participant)||(t==null?void 0:t.find(({participantId:O})=>O===h)),P=(_==null?void 0:_.lineUp)||((v=kl({participantId:h,drawDefinition:i}))==null?void 0:v.lineUp),{assignedParticipantIds:y,substitutions:S}=Au({collectionPosition:r,collectionId:s,lineUp:P});if(l===ft){if((y==null?void 0:y.length)<=2){const O=(m=(f=o==null?void 0:o[y[0]])==null?void 0:f.pairIdMap)==null?void 0:m[y[1]],w=O&&((g=o[O])==null?void 0:g.participant)||Kn({participantIds:y,tournamentParticipants:t}).participant,T=w==null?void 0:w.participantId;return{[u]:{participantId:T,teamParticipant:I,substitutions:S}}}else if((y==null?void 0:y.length)>2)return{[u]:{teamParticipant:I,substitutions:S}}}else{const O=y==null?void 0:y[0];return O&&{[u]:{participantId:O,teamParticipant:I,substitutions:S}}}}).filter(Boolean))||{};return Object.assign({},...c)}function br({matchUps:t=[],interpolate:e}){var r;if(!Array.isArray(t))return{roundMatchUps:[],error:X};const n=t.reduce((v,f)=>{const m=typeof f.roundNumber=="string"?Oe(f.roundNumber):f.roundNumber;return!f.roundNumber||v.includes(m)?v:v.concat(m)},[]).sort(er).map(v=>{const f=t.filter(_=>_.roundNumber===v),g=f.find(({matchUpType:_})=>_===Qe)?f.filter(({matchUpType:_})=>_===Qe):f,h=_=>_.sort((I,P)=>er(I.roundPosition,P.roundPosition));return{[v]:h(g)}}),o=t.reduce((v,f)=>{const m=typeof f.roundNumber=="string"?Oe(f.roundNumber):f.roundNumber;return v[m]||(v[m]=ye({abbreviatedRoundName:f.abbreviatedRoundName,finishingRound:f.finishingRound,roundName:f.roundName})),v},{}),i=Object.assign({},...n);if(e){const v=Math.max(...Object.keys(i).map(m=>Oe(m)).filter(m=>!isNaN(m))),f=(r=i[v])==null?void 0:r.length;if(f>1&&Xr(f)){const m=v+1,g=m+f/2;pe(m,g).forEach((_,I)=>{i[_]=pe(0,f/(2+I*2)).map(()=>({}))})}}let s=0;const a=Object.assign({},...Object.keys(i).map(v=>{var f,m,g;const h=(f=i[v])==null?void 0:f.length,_=(g=(m=i[v])==null?void 0:m.filter(P=>{var y;return!Yt.includes(P.matchUpStatus)&&!((y=P.score)!=null&&y.scoreStringSide1)}))==null?void 0:g.length,I=h&&h===_;return s=Math.max(s,h),{[v]:{matchUpsCount:h,inactiveCount:_,inactiveRound:I}}}));let l=0,c=0;const u=Object.keys(i).map(v=>Oe(v)).filter(v=>!isNaN(v));u.forEach(v=>{var f,m,g;const h=i[v].sort((I,P)=>I.roundPosition-P.roundPosition),_=h.map(I=>(I==null?void 0:I.drawPositions)||[]).flat();if(a[v].roundNumber=v,a[v].roundFactor=a[v].matchUpsCount?s/a[v].matchUpsCount:1,a[v].finishingRound=(f=o[v])==null?void 0:f.finishingRound,a[v].roundName=(m=o[v])==null?void 0:m.roundName,a[v].abbreviatedRoundName=(g=o[v])==null?void 0:g.abbreviatedRoundName,a[v].finishingPositionRange=i[v][0].finishingPositionRange,v===1||!a[v-1]){const I=_.sort(er),P=qt(I,2);a[v].drawPositions=I,a[v].pairedDrawPositions=P}else{const I=a[v-1],P=I.drawPositions,y=I.matchUpsCount/a[v].matchUpsCount,S=qt(P,y),O=h.map(b=>{const{roundPosition:w}=b,T=[...b.drawPositions||[],void 0,void 0].slice(0,2);if(!w)return T;const E=(T==null?void 0:T.filter(Boolean))||[];if(!(E!=null&&E.length))return[void 0,void 0];if(v<3&&(E==null?void 0:E.length)===2)return T==null?void 0:T.slice().sort(er);const N=Ht(P,E).length!==(E==null?void 0:E.length);if(E!=null&&E.length&&N)return(E==null?void 0:E.length)===1?[E[0],void 0]:T==null?void 0:T.slice().sort(er);const $=(w-1)*2;return S.slice($,$+2).map(U=>E==null?void 0:E.find(C=>U.includes(C)))});a[v].drawPositions=O==null?void 0:O.flat(),a[v].pairedDrawPositions=O}a[v+1]&&a[v+1].matchUpsCount===a[v].matchUpsCount&&(a[v+1].feedRound=!0,a[v+1].feedRoundIndex=c,a[v].preFeedRound=!0,c+=1),a[v]&&!a[v].feedRound&&(a[v].roundIndex=l,l+=1)});const d=!!Object.values(a).find(({matchUpsCount:v})=>!Xr(v)),p=t.some(v=>!v.roundPosition);return{isNotEliminationStructure:d,hasNoRoundPositions:p,maxMatchUpsCount:s,roundMatchUps:i,roundNumbers:u,roundProfile:a}}function YP(t){var e;const r=t==null?void 0:t.matchUp;let n=r==null?void 0:r.matchUpType;if(!n&&((e=r.sides)!=null&&e.length)){const o=r.sides.find(({participant:a})=>a),i=o==null?void 0:o.participant,s=i==null?void 0:i.participantType;n=s===Fe&&Nt||s===Ue&&ft||s===rt&&rt||void 0}return{matchUpType:n}}function Gl({drawDefinition:t,attributes:e}){let{extension:r}=yu({name:Iu,drawDefinition:t});const n=(r==null?void 0:r.value)||{};return e.forEach(o=>{Object.keys(o).forEach(i=>{n[i]?Object.assign(n[i],o[i]):n[i]=o[i]})}),r={name:Iu,value:n},Gf({drawDefinition:t,extension:r}),{entryProfile:n}}function Wl({drawDefinition:t}){const{extension:e}=yu({name:Iu,drawDefinition:t});return{entryProfile:(e==null?void 0:e.value)||{}}}const ge="MAIN",be="QUALIFYING",Ft="CONSOLATION",kt="VOLUNTARY_CONSOLATION",mt="PLAY_OFF",rv=[ge,be,Ft,mt,kt],Is={[be]:1,[ge]:2,[mt]:3,[Ft]:3,[kt]:4},KP="finishingPositions",QP="aggregateEventStructures",JP={[ge]:1,[mt]:2,[Ft]:3,[be]:4,[kt]:5},pG={[mt]:1,[ge]:2,[Ft]:3,[be]:4,[kt]:5},nv="CLUSTER",fG="SEPARATE",ov="WATERFALL",Cu="ITEM",gr="CONTAINER",Tn="DRAW",ZP="RANDOM",Mi="TOP_DOWN",Ps="BOTTOM_UP",Di="POSITION",ji="WINNER",ys="LOSER",uo="FIRST_MATCHUP",cn="AD_HOC",ha="FEED_IN",_a="COMPASS",Ia="OLYMPIC",vG="SINGLE_ELIMINATION",Ao="SINGLE_ELIMINATION",Hl="DOUBLE_ELIMINATION",Pa="FIRST_MATCH_LOSER_CONSOLATION",ql="FIRST_ROUND_LOSER_CONSOLATION",Ri="LUCKY_DRAW",Mu="CURTIS_CONSOLATION",mG="CURTIS_CONSOLATION",iv="FEED_IN_CHAMPIONSHIP_TO_SF",zl="FEED_IN_CHAMPIONSHIP_TO_SF",sv="FEED_IN_CHAMPIONSHIP_TO_QF",Yl="FEED_IN_CHAMPIONSHIP_TO_QF",av="FEED_IN_CHAMPIONSHIP_TO_R16",Kl="FEED_IN_CHAMPIONSHIP_TO_R16",XP="MODIFIED_FEED_IN_CHAMPIONSHIP",Ql="MODIFIED_FEED_IN_CHAMPIONSHIP",Jl="FEED_IN_CHAMPIONSHIP",wn="ROUND_ROBIN",Co="ROUND_ROBIN_WITH_PLAYOFF",ey="DECIDER",ty="BACKDRAW",lv={0:{name:"EAST",abbreviation:"E"},"0-1":{name:"WEST",abbreviation:"W"},"0-2":{name:"NORTH",abbreviation:"N"},"0-3":{name:"NORTHEAST",abbreviation:"NE"},"0-1-1":{name:"SOUTH",abbreviation:"S"},"0-1-2":{name:"SOUTHWEST",abbreviation:"SW"},"0-2-1":{name:"NORTHWEST",abbreviation:"NW"},"0-1-1-1":{name:"SOUTHEAST",abbreviation:"SE"}},cv={0:{name:"EAST",abbreviation:"E"},"0-1":{name:"WEST",abbreviation:"W"},"0-2":{name:"NORTH",abbreviation:"N"},"0-1-1":{name:"SOUTH",abbreviation:"S"}},ya="WIN_RATIO",Fi="ROUND_OUTCOME",ry=[_a,Mu,Yl,Kl,zl,Jl,sv,av,iv,Pa,ql,Ri,Ql,Ia,mt,Co],gG={MAIN:ge,QUALIFYING:be,CONSOLATION:Ft,ITEM:Cu,CONTAINER:gr,FIRST_MATCHUP:uo,WINNER:ji,LOSER:ys,AD_HOC:cn,FEED_IN:ha,COMPASS:_a,PLAY_OFF:mt,OLYMPIC:Ia,KNOCKOUT:vG,SINGLE_ELIMINATION:Ao,DOUBLE_ELIMINATION:Hl,CURTIS:Mu,FICSF:iv,FICQF:sv,FICR16:av,MFIC:XP,VOLUNTARY_CONSOLATION:kt,FIRST_MATCH_LOSER_CONSOLATION:Pa,FIRST_ROUND_LOSER_CONSOLATION:ql,MODIFIED_FEED_IN_CHAMPIONSHIP:Ql,FEED_IN_CHAMPIONSHIP_TO_R16:Kl,FEED_IN_CHAMPIONSHIP_TO_QF:Yl,FEED_IN_CHAMPIONSHIP_TO_SF:zl,FEED_IN_CHAMPIONSHIP:Jl,LUCKY_DRAW:Ri,ROUND_ROBIN_WITH_PLAYOFF:Co,ROUND_ROBIN:wn,DECIDER:ey,BACKDRAW:ty,COMPASS_ATTRIBUTES:lv,OLYMPIC_ATTRIBUTES:cv,DRAW:Tn,RANDOM:ZP,TOP_DOWN:Mi,BOTTOM_UP:Ps,WATERFALL:ov,WIN_RATIO:ya,ROUND_OUTCOME:Fi,MULTI_STRUCTURE_DRAWS:ry,generatedDrawTypes:[cn,_a,Mu,Hl,Yl,Kl,zl,Jl,ha,Pa,ql,Ri,Ql,Ia,mt,wn,Co,Ao],stageOrder:Is,finishOrder:JP,AGGREGATE_EVENT_STRUCTURES:QP,FINISHING_POSITIONS:KP};function xi(t,e,r){var n,o;const i=v=>{var f,m;return(m=(f=Kt({element:v,name:Wn}))==null?void 0:f.extension)==null?void 0:m.value},s=r==null?void 0:r.deprioritizeCompleted,a=(r==null?void 0:r.mode)===QP&&pG,l=(r==null?void 0:r.mode)===KP&&JP,c=l||a||Is,u=v=>(v==null?void 0:v.stage)===ge&&(v==null?void 0:v.stageSequence)===1,d=v=>u(v)?-1:c[v==null?void 0:v.stage],p=v=>v==null?void 0:v.matchUps.every(({matchUpStatus:f})=>Yt.includes(f)?1:-1);return s&&p(t)-p(e)||a&&d(t)-d(e)||((t==null?void 0:t.stage)&&c[t.stage]||0)-((e==null?void 0:e.stage)&&c[e.stage]||0)||(i(t)||0)-(i(e)||0)||!l&&!a&&(((n=e==null?void 0:e.positionAssignments)==null?void 0:n.length)||1/0)-(((o=t==null?void 0:t.positionAssignments)==null?void 0:o.length)||1/0)||((t==null?void 0:t.stageSequence)||0)-((e==null?void 0:e.stageSequence)||0)||(ny(t)||0)-(ny(e)||0)}function ny(t){return((t==null?void 0:t.matchUps)||[]).reduce((e,r)=>{var n;const o=(((n=r.finishingPositionRange)==null?void 0:n.winner)||[]).reduce((i,s)=>i+s,0);return!e||o<e?o:e},void 0)}function Ee({drawDefinition:t,structureId:e}){if(!t)return{error:fe};if(!e)return{error:Pr};const{structures:r}=un({drawDefinition:t}),n=r==null?void 0:r.map(s=>s.structures?[...s.structures].concat(s):s).flat(),o=n==null?void 0:n.find(s=>s.structureId===e);if(!o)return{error:St};const i=o.structureType===Cu?n==null?void 0:n.find(s=>{var a;return(a=s.structures)==null?void 0:a.some(l=>l.structureId===e)}):void 0;return{structure:o,containingStructure:i}}function un({withStageGrouping:t,drawDefinition:e,stageSequences:r,stageSequence:n,roundTarget:o,sortConfig:i,stages:s,stage:a}){var l,c;const u=!e&&fe||!(e!=null&&e.structures)&&sx||void 0;if(u)return{error:u,structures:[],stageStructures:{}};const d=g=>{var h,_;const I=(_=(h=Kt({element:g,name:Wn}))==null?void 0:h.extension)==null?void 0:_.value;return!o||o===I},p=(c=(l=e==null?void 0:e.structures)==null?void 0:l.filter(f).filter(m).filter(d).sort((g,h)=>xi(g,h,i)))!=null?c:[],v=t?Object.assign({},...rv.map(g=>{const h=p==null?void 0:p.filter(_=>_.stage===g);return(h==null?void 0:h.length)&&{[g]:h}}).filter(Boolean)):{};return{structures:p,stageStructures:v};function f(g){return!a&&!Array.isArray(s)||a&&g.stage===a||Array.isArray(s)&&s.includes(g.stage)}function m(g){return!n&&!Array.isArray(r)||n&&g.stageSequence===n||Array.isArray(r)&&r.includes(g.stageSequence)}}const En=ar.Alternate,Du=ar.Confirmed,$n=ar.DirectAcceptance,Zl=ar.FeedIn,ju=ar.JuniorExempt,Xl=ar.LuckyLoser,Ru=ar.OrganiserAcceptance,Fu=ar.Qualifier,hG=ar.Registered,xu=ar.SpecialExempt,Nn=ar.Ungrouped,Ss=ar.Unpaired,Sa=ar.Wildcard,ii=ar.Withdrawn,uv=[Du,$n,ju,Ru,xu],_G=[Zl,Xl,Fu],Os=[Du,$n,Zl,ju,Ru,xu,Sa],si=[Du,$n,Zl,ju,Xl,Fu,Ru,xu,Sa],IG=[En,Du,$n,Zl,ju,Xl,Ru,Fu,hG,xu,Nn,Ss,Sa,ii],oy=si;function ec({stage:t,drawDefinition:e}){const{entryProfile:r}=Wl({drawDefinition:e}),n=Object.keys(r).includes(t);if(!n&&rv.includes(t)){const o=[{[t]:{drawSize:void 0,alternates:!0}}];return Gl({drawDefinition:e,attributes:o}),!0}return n}function PG({stage:t,drawDefinition:e}){var r;const{entryProfile:n}=Wl({drawDefinition:e});return((r=n[t])==null?void 0:r.alternates)||0}function yG({stage:t,drawDefinition:e}){var r;const{entryProfile:n}=Wl({drawDefinition:e});return((r=n[t])==null?void 0:r.wildcardsCount)||0}function Lu({stage:t,drawDefinition:e,entryStatus:r}){return e.entries.reduce((n,o)=>o.entryStage===t&&o.entryStatus===r?n+1:n,0)}function bs({provisionalPositioning:t,drawDefinition:e,stageSequence:r,entryStatuses:n,structureId:o,roundTarget:i,stages:s,stage:a}){var l,c;const u=(c=(l=e.entries)==null?void 0:l.reduce((d,p)=>{var v,f,m;const g=(f=(v=Kt({name:Wn,element:p}))==null?void 0:v.extension)==null?void 0:f.value,h=a&&p.entryStage===a||(s==null?void 0:s.length)&&p.entryStage&&s.includes(p.entryStage),_=!n||p.entryStatus&&n.includes(p.entryStatus),I=(m=p.entryStageSequence)!=null?m:1;return h&&(!r||I===r)&&_&&(!i||!g||i===g)?d.concat(p):d},[]))!=null?c:[];if(o&&a===mt){const{playoffEntries:d,error:p}=SG({provisionalPositioning:t,drawDefinition:e,structureId:o});return p&&console.log("playoff entries error"),d!=null&&d.length?d:u}return u}function SG({provisionalPositioning:t,drawDefinition:e,structureId:r}){var n;const o=[],i=((n=e.links)!=null?n:[]).find(s=>s.linkType===Di&&s.target.structureId===r);if(i){const{finishingPositions:s,structureId:a}=i.source,{structure:l}=Ee({drawDefinition:e,structureId:a});(l==null?void 0:l.structureType)===gr&&(l.structures||[]).forEach(u=>{const d=u.positionAssignments||[],{structureId:p}=u,v=p,f=Object.assign({},...d.map(_=>{var I;const{participantId:P}=_,y=(I=Kt({element:_,name:Jo}).extension)==null?void 0:I.value;return y&&P?{[P]:y}:void 0}).filter(Boolean)),g=Object.keys(f).reduce((_,I)=>{const P=f[I],y=P.groupOrder||t&&P.provisionalOrder;return _.includes(y)||_.push(y),_},[]).length===Object.keys(f).length,h=Object.keys(f).filter(_=>{const I=f[_],P=I.groupOrder||t&&I.provisionalOrder;return s==null?void 0:s.includes(P)});(!t||g)&&h.forEach(_=>{const I=f[_],{groupOrder:P,provisionalOrder:y,GEMscore:S}=I,O=P||t&&y,b=(s??[]).sort().indexOf(O)+1;o.push({entryStage:mt,entryStatus:Zl,placementGroup:b,groupingValue:v,participantId:_,GEMscore:S})})})}return{playoffEntries:o}}function iy({stage:t,drawDefinition:e}){return Os.reduce((r,n)=>(Lu({drawDefinition:e,entryStatus:n,stage:t})||0)+r,0)}function OG({stage:t,drawDefinition:e}){return Lu({entryStatus:Sa,drawDefinition:e,stage:t})}function Un({provisionalPositioning:t,drawDefinition:e,structureId:r,structure:n}){var o;let i,s=[];if(n||({structure:n,error:i}=Ee({drawDefinition:e,structureId:r})),i||!n)return{seedAssignments:[],error:St};r||(r=n.structureId);const{stage:a,stageSequence:l}=n,u=a===mt&&e&&bs({provisionalPositioning:t,drawDefinition:e,stageSequence:l,structureId:r,stage:a}),d=u?u.filter(v=>v.placementGroup===1).sort((v,f)=>v.GEMscore<f.GEMscore&&1||v.GEMscore>f.GEMscore&&-1||0).map((v,f)=>{const m=f+1;return{participantId:v.participantId,seedValue:m,seedNumber:m,seedProxy:!0}}):[];d.length?s=d:n.seedAssignments?s=n.seedAssignments:i=rx;const p=n.seedLimit||((o=n==null?void 0:n.positionAssignments)==null?void 0:o.length);return{seedAssignments:s,seedLimit:p,stage:a,stageSequence:l,error:i}}function dv({drawDefinition:t}){if(typeof t!="object")return{error:es};const e={},{structures:r=[],links:n=[]}=t||{},o=r.reduce((s,a)=>{const{stage:l}=a;return s[l]?s[l].push(a):s[l]=[a],s},{});for(const s of Object.keys(o)){const a=o[s].find(({stageSequence:u})=>u===1);if(!a)continue;const{structureId:l}=a;i({aggregator:{},targetRound:0,exitProfiles:e,exitProfile:"0",structureId:l,stage:s})}return{exitProfiles:e};function i({exitProfiles:s,exitProfile:a,structureId:l,targetRound:c,aggregator:u,stage:d}){s[l]||(s[l]=[]),a==="0"&&[Ft,mt].includes(d)||s[l].push(a);const p=n.filter(v=>v.source.structureId===l&&v.source.roundNumber>=c);for(const v of p){const f=v.source.roundNumber,m=v.target.roundNumber,g=v.target.structureId,h=r.find(I=>I.structureId===g).stage,_=[h,g,m,f].join("|");if(u[_])return;u[_]=!0,i({exitProfile:`${a}-${f}`,structureId:g,exitProfiles:s,targetRound:m,aggregator:u,stage:h})}}}function lr({drawDefinition:t,structure:e}){var r;const n={},o=[];return((r=t==null?void 0:t.structures)!=null?r:[e]).filter(i=>i&&typeof i=="object").forEach(i=>{if(!i)return;const{structureId:s,matchUps:a,structures:l}=i,c=Array.isArray(l);if(c)c&&l.forEach(u=>{const{structureName:d}=u,p=u.matchUps;n[u.structureId]={matchUps:p,itemStructureIds:[],structureName:d},p&&(o.push(...p),p.forEach(v=>{v.tieMatchUps&&o.push(...v.tieMatchUps)})),n[s]||(n[s]={itemStructureIds:[],matchUps:[]}),n[s].itemStructureIds||(n[s].itemStructureIds=[]),n[s].itemStructureIds.push(u.structureId)});else{const u=a;n[s]={matchUps:u,itemStructureIds:[]},u==null||u.forEach(d=>{o.push(d),d.tieMatchUps&&o.push(...d.tieMatchUps)})}}),{mappedMatchUps:n,drawMatchUps:o}}function Li({mappedMatchUps:t,matchUpsMap:e,structureId:r,inContext:n}){var o;t=(o=e==null?void 0:e.mappedMatchUps)!=null?o:t;const i=t[r],s=((i==null?void 0:i.itemStructureIds)||[]).map(a=>{const{matchUps:l,structureName:c}=t[a];return n?l.map(u=>Object.assign(ve(u,!0,!0),{containerStructureId:r,structureId:a,structureName:c})):l}).flat();return((i==null?void 0:i.matchUps)||[]).concat(...s)}function sy({groupedOrder:t,roundPositionsCount:e}){if(!t||(t==null?void 0:t.length)<=e)return t;const n=qt(t,t.length/e).map(i=>i.reduce((s,a)=>s+a)),o=n.slice().sort(er);return n.map(i=>o.indexOf(i)+1)}function Vu(t){if(!Array.isArray(t))return"";const e=t.filter(Ut);return e.length?He([Math.min(...e),Math.max(...e)]).join("-"):""}function bG({drawDefinition:t,structureId:e,matchUpsMap:r}){if(!t)return{error:fe};if(!e)return{error:Pr};const{structure:n}=Ee({drawDefinition:t,structureId:e});if((n==null?void 0:n.stage)!==Ft)return{error:Go,info:"Structure is not CONSOLATION stage"};const{links:o}=t,i=(o==null?void 0:o.filter(d=>d.target.structureId===e))||[],s=(i==null?void 0:i.reduce((d,p)=>{const{structureId:v}=p.source;return d.includes(v)?d:d.concat(v)},[]))||[],a=Object.assign({},...s.map(d=>{const p=Li({structureId:d,matchUpsMap:r}),{roundProfile:v}=br({matchUps:p});return{[d]:v}})),l=Li({matchUpsMap:r,structureId:e}),{roundProfile:c}=br({matchUps:l}),u={};return i==null||i.forEach(d=>{var p;const{structureId:v,roundNumber:f}=d.source,{feedProfile:m,groupedOrder:g,positionInterleave:h,roundNumber:_}=d.target,I=a[v],P=(p=I[1])==null?void 0:p.drawPositions,y=I[f],S=y==null?void 0:y.matchUpsCount;if(!S)return;const O=S?P.length/S:0,b=P.length/O;let w=P.slice();const T=sy({roundPositionsCount:w.length,groupedOrder:g}),E=(T==null?void 0:T.length)||1;if(E<=b){const U=P.length/E,C=qt(w,U);m===Ps&&C.forEach(M=>M.reverse()),w=(T==null?void 0:T.length)&&(T==null?void 0:T.map(M=>C[M-1]).flat())||w}let N=qt(w,O);if(!(T!=null&&T.length)&&m===Ps&&N.reverse(),h){const U=pe(0,h.interleave).map(()=>{}),C=pe(0,h.offset).map(()=>{});N=N.map(D=>[D,...U]),N.unshift(C),N=N.flat(1);const M=N.length-h.offset;N=N.slice(0,M)}u[_]||(u[_]={});const $=c==null?void 0:c[_],A=$!=null&&$.feedRound?2:1;N.forEach((U,C)=>{const M=1+C*A;u[_][M]||(u[_][M]=Vu(U))})}),{sourceDrawPositionRanges:u}}function ay({drawDefinition:t}){if(!t)return{error:fe};const e={};return{allPositionedParticipantIds:(t.structures||[]).map(n=>{var o;const i=n.stage;e[i]||(e[i]=[]);const{positionAssignments:s}=st({structure:n}),a=(o=s==null?void 0:s.map(sn("participantId")).filter(Boolean))!=null?o:[];return e[i].push(...a),a}).flat(),stagePositionedParticipantIds:e}}function st({drawDefinition:t,structureId:e,structure:r}){let n,o=[];if(!r){if(!t)return{positionAssignments:o,error:fe};if({structure:r,error:n}=Ee({drawDefinition:t,structureId:e}),n)return{positionAssignments:o,error:n}}return r.structures?o=[].concat(...r.structures.map(i=>st({structure:i}).positionAssignments)):r.positionAssignments?o=r.positionAssignments:n=dx,{positionAssignments:o,error:n}}function Ct({drawDefinition:t,structureId:e,structure:r}){var n;const o=((n=st({drawDefinition:t,structureId:e,structure:r}))==null?void 0:n.positionAssignments)||[],i=o==null?void 0:o.filter(u=>{var d,p;return(p=(d=u.participantId)!=null?d:u.bye)!=null?p:u.qualifier}),s=o&&(o==null?void 0:o.length)===(i==null?void 0:i.length),a=o==null?void 0:o.filter(u=>!u.participantId&&!u.bye&&!u.qualifier),l=o==null?void 0:o.filter(u=>!u.participantId&&u.bye),c=o==null?void 0:o.filter(u=>!u.participantId&&u.qualifier);return{allPositionsAssigned:s,positionAssignments:o,unassignedPositions:a,assignedPositions:i,qualifierPositions:c,byePositions:l}}function TG({drawPositions:t,roundProfile:e,roundNumber:r}){const n=[void 0,void 0];if(qF(t))return{orderedDrawPositions:n,displayOrder:n};const o=e[r],i=o==null?void 0:o.pairedDrawPositions,s=(i==null?void 0:i.find(l=>Xt(l||[],t.filter(Boolean))))||n,a=o==null?void 0:o.feedRound;if(HF(t)){const l=t.sort(er);return{orderedDrawPositions:l.length===2?l:s,displayOrder:a?l:s}}if(a){const c=[t.find(u=>!isNaN(Oe(u))),void 0];return{orderedDrawPositions:c,displayOrder:c}}return{orderedDrawPositions:s,displayOrder:s}}function wG({drawDefinition:t,roundProfile:e,structureId:r,matchUpsMap:n}){var o;if(!t)return{error:fe};if(!r)return{error:Pr};if(!e){const c=Li({matchUpsMap:n,structureId:r});if({roundProfile:e}=br({matchUps:c}),!e)return{error:_e}}const s=(Math.min(...((o=e==null?void 0:e[1])==null?void 0:o.drawPositions)||[])||1)-1,a=Object.keys(e);return{drawPositionsRanges:Object.assign({},...(a||[]).map(c=>{var u,d;const p=(u=e==null?void 0:e[c])==null?void 0:u.matchUpsCount,v=((d=e==null?void 0:e[1])==null?void 0:d.drawPositions)||[],f=qt(v,v.length/p),m=f.map(Vu),g=f.map(y=>y.map(S=>S-s)).map(Vu),h=a.map(y=>{var S,O;if(y>c)return;const b=(O=(S=e==null?void 0:e[y])==null?void 0:S.drawPositions)!=null?O:[];return qt(b,b.length/p)}).filter(Boolean),_=pe(0,p).map(y=>h.map(S=>S[y]).flat().filter(Boolean).sort(er)).map(y=>He(y)),I=_.map(y=>WF(y).map(Vu).join(", ")),P=Object.assign({},...pe(0,p).map(y=>({[y+1]:{firstRoundDrawPositionsRange:m[y],firstRoundOffsetDrawPositionsRange:g[y],possibleDrawPositions:_[y],drawPositionsRange:I[y]}})));return{[c]:P}}))}}function pv({matchUp:t}){let e=[],r=[],n=[],o=[],i;if(t||(i=jr),t&&!t.sides&&(i=rn),t&&!t.hasContext&&(i=nu),!i){o=t.sides.map(l=>l.participantId);const s=t.sides.filter(l=>l.participantType===Fe).map(l=>l.participantId).filter(Boolean);e=t.sides.map(l=>{var c;return(c=l.participant)==null?void 0:c.individualParticipants}).filter(Boolean).map(l=>l.map(c=>c==null?void 0:c.participantId).filter(Boolean)),n=[...s,...e.flat()].filter(Boolean),r=He(n.concat(o)).filter(Boolean)}return{nestedIndividualParticipantIds:e,allRelevantParticipantIds:r,individualParticipantIds:n,sideParticipantIds:o,error:i}}function tc({matchUp:t}){if(!t)return{error:jr};if(!t.hasContext)return{error:nu};if(!t.sides||t.sides.filter(Boolean).length!==2)return{error:rn};const{nestedIndividualParticipantIds:e,allRelevantParticipantIds:r,sideParticipantIds:n}=pv({matchUp:t}),i=(t.timeItems||[]).filter(c=>[Jf,Zf].includes(c==null?void 0:c.itemType)).sort((c,u)=>new Date(c.createdAt).getTime()-new Date(u.createdAt).getTime()),a=i.map(c=>c.itemValue).filter(c=>i.filter(u=>(u==null?void 0:u.itemValue)===c).reverse()[0].itemType===Jf);return e==null||e.forEach((c,u)=>{const d=n[u],p=(c==null?void 0:c.length)&&c.every(v=>a.includes(v));d&&p&&!a.includes(d)&&a.push(d)}),n.forEach((c,u)=>{a.includes(c)&&((e==null?void 0:e[u])||[]).forEach(d=>{d&&!a.includes(d)&&a.push(d)})}),{allParticipantsCheckedIn:n.reduce((c,u)=>a.includes(u)&&c,!0),checkedInParticipantIds:a,allRelevantParticipantIds:r}}function Ts(t){const{matchUps:e,isCollectionMatchUp:r,excludeMatchUpStatuses:n,matchUpStatuses:o,hasWinningSide:i,matchUpFormats:s,roundPositions:a,matchUpFormat:l,collectionIds:c,isMatchUpTie:u,roundNumbers:d,matchUpIds:p,roundNames:v,stageSequences:f,scheduledDates:m,scheduledDate:g,participantIds:h,processContext:_,tournamentIds:I,matchUpTypes:P,structureIds:y,readyToScore:S,courtIds:O,eventIds:b,venueIds:w,drawIds:T,stages:E,filterMatchUpIds:N=!0,filterMatchUpTypes:$=!0}=t,A=Array.isArray(h)?h.filter(Boolean):[],U=Array.isArray(o)?o.filter(Boolean):[],C=Array.isArray(n)?n.filter(Boolean):[],M=Array.isArray(E)?E.filter(Boolean):[],D=Array.isArray(f)?f.filter(Boolean):[],R=Array.isArray(c)?c.filter(Boolean):[],j=Array.isArray(v)?v.filter(Boolean):[],G=Array.isArray(d)?d.filter(Boolean):[],W=Array.isArray(a)?a.filter(Boolean):[],z=Array.isArray(p)&&N?p.filter(Boolean):[],F=Array.isArray(P)&&$?P.filter(Boolean):[],L=Array.isArray(O)?O.filter(Boolean):[],x=Array.isArray(w)?w.filter(Boolean):[],B=Array.isArray(s)&&s.filter(Boolean)||typeof l=="string"&&[l]||[],H=Array.isArray(m)&&m.filter(Boolean)||typeof g=="string"&&g.length&&[g]||[],q=Array.isArray(I)?I.filter(Boolean):[],J=Array.isArray(b)?b.filter(Boolean):[],K=Array.isArray(T)?T.filter(Boolean):[],Y=Array.isArray(y)?y.filter(Boolean):[];return e.filter(Q=>{var Z,ee;if(S&&Q.matchUpType!==In&&!Q.readyToScore||Q.winningSide&&i&&![1,2].includes(Q.winningSide)||u!==void 0&&(u&&!Q.tieMatchUps||!u&&Q.tieMatchUps)||r!==void 0&&(r&&!Q.collectionId||!r&&Q.collectionId)||M.length&&!M.includes(Q.stage)||D.length&&!D.includes(Q.stageSequence)||R.length&&(!Q.collectionId||!R.includes(Q.collectionId))||j.length&&(!Q.roundName||!j.includes(Q.roundName))||G.length&&(!Q.roundNumber||!G.includes(Q.roundNumber))||W.length&&(!Q.roundPosition||!W.includes(Q.roundPosition))||U.length&&(!Q.matchUpStatus||!U.includes(Q.matchUpStatus))||C.length&&Q.matchUpStatus&&C.includes(Q.matchUpStatus)||z.length&&!z.includes(Q.matchUpId)||F.length&&(!Q.matchUpType||!F.includes(Q.matchUpType))||B.length&&(!Q.matchUpFormat||!B.includes(Q.matchUpFormat)))return!1;if(H!=null&&H.length){const{scheduledTime:ne}=Xf({matchUp:Q}),{scheduledDate:te}=Ci({matchUp:Q}),ie=Re(ne)||te;if(!H.find(le=>so(le,ie)))return!1}if(L.length){const{courtId:ne}=xP({matchUp:Q}),{allocatedCourts:te}=FP({matchUp:Q}),oe=te==null?void 0:te.map(({courtId:ie})=>ie);if(!L.filter(Boolean).includes(ne)||oe!=null&&oe.includes(ne))return!1}if(x.length){const{venueId:ne}=LP({matchUp:Q});if(!x.filter(Boolean).includes(ne))return!1}if(_){if(q.length&&!q.includes(Q.tournamentId)||J.length&&!J.includes(Q.eventId)||K.length&&!K.includes(Q.drawId)||Y.length&&!Y.includes(Q.structureId))return!1;if(A.length){const ne=(ee=(Z=Q.sides)==null?void 0:Z.map(({participantId:oe})=>oe).filter(Boolean))!=null?ee:[];if(!A.some(oe=>ne.includes(oe)))return!1}}return!0})}function EG({isNotEliminationStructure:t,drawDefinition:e,roundMatchUps:r,structure:n}){var o,i,s;if(!n)return!1;r||({isNotEliminationStructure:t,roundMatchUps:r}=br({matchUps:(o=n.matchUps)!=null?o:[]}));const a=!!((i=r==null?void 0:r[1])!=null&&i.find(({drawPositions:c})=>c)),l=!((s=r==null?void 0:r[2])!=null&&s.find(({drawPositions:c})=>c));return t&&!(n!=null&&n.structures)&&a&&l&&!(e!=null&&e.drawType&&e.drawType!==Ri)}function Mo({drawDefinition:t,structure:e}){var r;return e?!(e!=null&&e.structures)&&!(t!=null&&t.drawType&&t.drawType!==cn)&&!((r=e==null?void 0:e.matchUps)!=null&&r.find(({roundPosition:n})=>!!n)):!1}const ly={[$f]:{policyName:"Round Naming Default",abbreviatedRoundNamingMap:{1:"F",2:"SF",4:"QF"},roundNamingMap:{1:"Final",2:"Semifinal",4:"Quarterfinal"},affixes:{roundNumber:"R",preFeedRound:"Q"},stageConstants:{[ge]:"",[mt]:"P",[be]:"Q",[Ft]:"C"}}};function $G({roundNamingPolicy:t,structure:e,matchUps:r}){const{isNotEliminationStructure:n,roundProfile:o,roundMatchUps:i}=br({matchUps:r}),{structureAbbreviation:s,stage:a}=e,l=Mo({structure:e}),c=EG({isNotEliminationStructure:n,roundMatchUps:i,structure:e}),u=e.structures,d={},p=ly[$f],v=(t==null?void 0:t.roundNamingMap)||p.roundNamingMap||{},f=(t==null?void 0:t.abbreviatedRoundNamingMap)||p.abbreviatedRoundNamingMap||{},m=(t==null?void 0:t.affixes)||p.affixes,g=a&&a!==ge&&a[0],h=t==null?void 0:t.stageConstants,_=a&&(h==null?void 0:h[a])||g,I=o?Object.keys(o):[];return u||l||c?Object.assign(d,...I.map(P=>{const y=`Round ${P}`,S=`R${P}`;return{[P]:{roundName:y,abbreviatedRoundName:S}}})):Object.assign(d,...I.map(P=>{if(!(o!=null&&o[P]))return;const{matchUpsCount:y,preFeedRound:S}=o[P],O=y*2,b=v[y]||`${m.roundNumber}${O}`,w=S?`-${m.preFeedRound}`:"",T=`${b}${w}`,E=[_,s,T].filter(Boolean).join("-"),$=`${f[y]||`${m.roundNumber}${O}`}${w}`,A=[_,s,$].filter(Boolean).join("-");return{[P]:{abbreviatedRoundName:A,roundName:E}}})),{roundNamingProfile:d,roundProfile:o,roundMatchUps:i}}function NG({drawPositionCollectionAssignment:t,positionAssignments:e,displaySideNumber:r,seedAssignments:n,drawPosition:o,isFeedRound:i,sideNumber:s}){var a,l,c,u;const d=e.find(h=>h.drawPosition===o),p=t?(a=t[o])==null?void 0:a.participantId:d==null?void 0:d.participantId,v=d?UG({displaySideNumber:r,seedAssignments:n,participantId:p,assignment:d,sideNumber:s}):{};i&&(s===1?Object.assign(v,{participantFed:!0}):Object.assign(v,{participantAdvanced:!0}));const f=(l=t==null?void 0:t[o])==null?void 0:l.teamParticipant,m=(c=t==null?void 0:t[o])==null?void 0:c.participant,g=(u=t==null?void 0:t[o])==null?void 0:u.substitutions;return m&&Object.assign(v,{participant:m}),g&&Object.assign(v,{substitutions:g}),f&&Object.assign(v,{teamParticipant:f}),v}function UG({displaySideNumber:t,seedAssignments:e,participantId:r,assignment:n,sideNumber:o}){const i={drawPosition:n.drawPosition,displaySideNumber:t,sideNumber:o};if(r){const s=AG({seedAssignments:e,participantId:r});Object.assign(i,s,{participantId:r})}else n.bye&&Object.assign(i,{bye:!0});return n.qualifier&&Object.assign(i,{qualifier:!0}),i}function AG({seedAssignments:t,participantId:e}){return t==null?void 0:t.find(r=>!r.seedProxy&&r.participantId===e)}const Oa="ANY",gt="MALE",Do="MIXED",ws="OTHER",Ot="FEMALE",cy={ANY:Oa,MALE:gt,FEMALE:Ot,MIXED:Do,OTHER:ws};var CG=Object.defineProperty,MG=Object.defineProperties,DG=Object.getOwnPropertyDescriptors,uy=Object.getOwnPropertySymbols,jG=Object.prototype.hasOwnProperty,RG=Object.prototype.propertyIsEnumerable,dy=(t,e,r)=>e in t?CG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dn=(t,e)=>{for(var r in e||(e={}))jG.call(e,r)&&dy(t,r,e[r]);if(uy)for(var r of uy(e))RG.call(e,r)&&dy(t,r,e[r]);return t},Bu=(t,e)=>MG(t,DG(e));function Je({scheduleVisibilityFilters:t,tournamentAppliedPolicies:e,provisionalPositioning:r,tournamentParticipants:n,afterRecoveryTimes:o,policyDefinitions:i,tournamentRecord:s,seedAssignments:a,contextFilters:l,contextContent:c,matchUpFilters:u,participantMap:d,scheduleTiming:p,contextProfile:v,drawDefinition:f,context:m={},exitProfiles:g,matchUpsMap:h,structure:_,inContext:I,event:P}){var y,S,O,b,w,T,E;let N={},$={};if(n=n??(s==null?void 0:s.participants),!_)return{collectionPositionMatchUps:N,error:ra,roundMatchUps:$,matchUps:[]};const A=Array.isArray(u==null?void 0:u.eventIds)?u==null?void 0:u.eventIds.filter(Boolean):[],U=Array.isArray(u==null?void 0:u.structureIds)?u==null?void 0:u.structureIds.filter(Boolean):[],C=Array.isArray(u==null?void 0:u.drawIds)?u==null?void 0:u.drawIds.filter(Boolean):[],M=!(m!=null&&m.eventId)||!(A!=null&&A.length)&&!((y=l==null?void 0:l.eventIds)!=null&&y.filter(Boolean).length)||(A==null?void 0:A.includes(m.eventId))||((S=l==null?void 0:l.eventIds)==null?void 0:S.includes(m.eventId)),D=!(U!=null&&U.length)||U.includes(_.structureId),R=!f||!(C!=null&&C.length)||C.includes(f.drawId);if(!M||!D||!R)return{collectionPositionMatchUps:N,roundMatchUps:$,matchUps:[]};v&&!c&&(c=Eo({tournamentRecord:s,contextProfile:v,drawDefinition:f}));const{appliedPolicies:j}=vt({drawDefinition:f}),G=dn(dn(dn({},e),j),i),W=(O=G==null?void 0:G.scoring)==null?void 0:O.structures,z=_.stage&&(W==null?void 0:W.stage)&&(W==null?void 0:W.stage[_.stage]),F=_.stageSequence&&(z==null?void 0:z.stageSequence)&&z.stageSequence[_.stageSequence],L=((b=G==null?void 0:G.scoring)==null?void 0:b.requireAllPositionsAssigned)||(z==null?void 0:z.requireAllPositionsAssigned)||(F==null?void 0:F.requireAllPositionsAssigned);h||(h=lr({drawDefinition:f,structure:_}));const{positionAssignments:x,allPositionsAssigned:B}=Ct({structure:_}),H=!L||B,{seedAssignments:q}=Un({provisionalPositioning:r,drawDefinition:f,structure:_});a=a??q;const{roundOffset:J,structureId:K,structureName:Y,stage:Q,stageSequence:Z}=_,{drawId:ee,drawName:ne,drawType:te}=f??{};g=g||f&&dv({drawDefinition:f}).exitProfiles;const oe=g==null?void 0:g[K],ie=(oe==null?void 0:oe.length)&&(oe[0].split("-").map(ce=>parseInt(ce)).reduce((ce,Se)=>ce+Se)||0),le=!!_.structures;let ae=Li({matchUpsMap:h,structureId:K,inContext:I});const Ie=G==null?void 0:G[$f],he=$G({roundNamingPolicy:Ie,structure:_,matchUps:ae}),{roundNamingProfile:de,roundProfile:Ce}=he;if($=(w=he==null?void 0:he.roundMatchUps)!=null?w:[],u&&(ae=Ts(Bu(dn({matchUps:ae},u),{filterMatchUpTypes:!1,filterMatchUpIds:!1}))),I){const{sourceDrawPositionRanges:ce}=bG({drawDefinition:f,matchUpsMap:h,structureId:K}),Se=f?wG({drawDefinition:f,roundProfile:Ce,matchUpsMap:h,structureId:K}).drawPositionsRanges:void 0;ae=ae.map(Pe=>se({scheduleVisibilityFilters:t,sourceDrawPositionRanges:ce,drawPositionsRanges:Se,roundNamingProfile:de,initialRoundOfPlay:ie,appliedPolicies:G,isRoundRobin:le,roundProfile:Ce,matchUp:Pe,event:P})),(ae==null?void 0:ae.filter(Pe=>Array.isArray(Pe.tieMatchUps))).forEach(Pe=>{const Me=Pe.tieMatchUps;ae=ae.concat(...Me)}),l&&(ae=Ts(Bu(dn({processContext:!0},l),{matchUps:ae})))}else(ae==null?void 0:ae.filter(Se=>Array.isArray(Se.tieMatchUps))).forEach(Se=>{const je=Se.tieMatchUps;ae=ae.concat(...je)});return u&&(ae=Ts(Bu(dn({matchUps:ae},u),{filterMatchUpTypes:!1,filterMatchUpIds:!1}))),(u!=null&&u.matchUpTypes||u!=null&&u.matchUpIds)&&(ae=Ts({matchUpTypes:u.matchUpTypes,matchUpIds:u.matchUpIds,matchUps:ae})),(u!=null&&u.matchUpTypes||u!=null&&u.matchUpIds||I)&&($=(T=br({matchUps:ae}).roundMatchUps)!=null?T:[]),(E=fr({drawDefinition:f,structure:_,event:P}))!=null&&E.tieFormat&&({collectionPositionMatchUps:N}=LV({matchUps:ae})),{matchUps:ae,roundMatchUps:$,roundProfile:Ce,collectionPositionMatchUps:N};function se({scheduleVisibilityFilters:ce,sourceDrawPositionRanges:Se,drawPositionsRanges:je,initialRoundOfPlay:Pe,additionalContext:Me,roundNamingProfile:Le,tieDrawPositions:Ye,appliedPolicies:Te,isCollectionBye:De,matchUpTieId:We,isRoundRobin:me,roundProfile:ue,sideLineUps:we,matchUp:$e,event:Ae}){var at,Xe,Mt,Lt,Be,lt,Ve,It,nr,Dr,Kr,gi,Lr,Lp,Vp,yt;Me=Me||{};const wr=(at=fr({drawDefinition:f,structure:_,matchUp:$e,event:Ae}))==null?void 0:at.tieFormat,hi=wr==null?void 0:wr.collectionDefinitions,Dn=$e.collectionId&&(hi==null?void 0:hi.find(dr=>dr.collectionId===$e.collectionId)),Bp=$e.collectionId?Dn==null?void 0:Dn.matchUpFormat:$e.matchUpFormat||(_==null?void 0:_.matchUpFormat)||(f==null?void 0:f.matchUpFormat)||(Ae==null?void 0:Ae.matchUpFormat),gh=$e.matchUpType||(Dn==null?void 0:Dn.matchUpType)||(_==null?void 0:_.matchUpType)||(f==null?void 0:f.matchUpType)||(Ae==null?void 0:Ae.eventType)!==Bt&&(Ae==null?void 0:Ae.eventType),Y0e=De?nt:$e.matchUpStatus,{schedule:K0e,endDate:Q0e}=tv({scheduleVisibilityFilters:ce,afterRecoveryTimes:o,tournamentRecord:s,scheduleTiming:p,matchUpFormat:Bp,matchUpType:gh,matchUp:$e,event:Ae}),Hc=(Xe=Ye??$e.drawPositions)!=null?Xe:[],{collectionPosition:J0e,collectionId:LR,roundPosition:kp}=$e,ro=$e.roundNumber||Me.roundNumber,Z0e=LR?dG({tournamentParticipants:n,positionAssignments:x,collectionPosition:J0e,drawDefinition:f,participantMap:d,drawPositions:Hc,collectionId:LR,sideLineUps:we,matchUpType:gh}):void 0,VR=((Mt=Le==null?void 0:Le[ro])==null?void 0:Mt.roundName)||Me.roundName,BR=((Lt=Le==null?void 0:Le[ro])==null?void 0:Lt.abbreviatedRoundName)||Me.abbreviatedRoundName,X0e=(Be=ue==null?void 0:ue[ro])==null?void 0:Be.feedRound,eSe=(lt=ue==null?void 0:ue[ro])==null?void 0:lt.preFeedRound,tSe=(Ve=ue==null?void 0:ue[ro])==null?void 0:Ve.roundFactor,kR=je==null?void 0:je[ro],rSe=kp?kR==null?void 0:kR[kp]:void 0,GR=Se==null?void 0:Se[ro],nSe=Dn!=null&&Dn.category?dn(dn({},(m==null?void 0:m.category)||{}),Dn.category):m==null?void 0:m.category,oSe=((It=$e.processCodes)==null?void 0:It.length)&&$e.processCodes||((nr=Dn==null?void 0:Dn.processCodes)==null?void 0:nr.length)&&(Dn==null?void 0:Dn.processCodes)||((Dr=_==null?void 0:_.processCodes)==null?void 0:Dr.length)&&(_==null?void 0:_.processCodes)||((Kr=f==null?void 0:f.processCodes)==null?void 0:Kr.length)&&(f==null?void 0:f.processCodes)||((gi=Ae==null?void 0:Ae.processCodes)==null?void 0:gi.length)&&(Ae==null?void 0:Ae.processCodes)||(s==null?void 0:s.processCodes),iSe=(v==null?void 0:v.withCompetitiveness)&&yI(Bu(dn({},c),{matchUp:$e})).competitiveness,sSe=$e.finishingPositionRange||Me.finishingPositionRange,Gp=dr=>ye(dr,void 0,!0),bt=dn(dn(dn({},Gp(m)),Gp({matchUpFormat:$e.matchUpType===Bt?void 0:Bp,tieFormat:$e.matchUpType!==Bt?void 0:wr,roundOfPlay:Q!==be&&_t(Pe)&&Pe+(ro||0),endDate:$e.endDate||Q0e,gender:Dn==null?void 0:Dn.gender,discipline:Ae==null?void 0:Ae.discipline,category:nSe,finishingPositionRange:sSe,abbreviatedRoundName:BR,drawPositionsRange:rSe,competitiveness:iSe,structureName:Y,stageSequence:Z,drawPositions:Hc,matchUpStatus:Y0e,processCodes:oSe,isRoundRobin:me,matchUpTieId:We,preFeedRound:eSe,matchUpType:gh,roundFactor:tSe,roundOffset:J,structureId:K,roundNumber:ro,feedRound:X0e,roundName:VR,drawName:ne,drawType:te,schedule:K0e,drawId:ee,stage:Q})),ve(Gp($e),!0,!0));if(Bp&&((Lr=$e.score)!=null&&Lr.scoreStringSide1)){const dr=Ir(Bp),{bestOf:Vo,finalSetFormat:Qr,setFormat:ht}=dr??{};(Qr!=null&&Qr.tiebreakSet||ht!=null&&ht.tiebreakSet||ht!=null&&ht.timed)&&(bt.score.sets=bt.score.sets.sort((pr,Er)=>pr.setNumber-Er.setNumber).map((pr,Er)=>(Er+1===Vo?(Qr!=null&&Qr.tiebreakSet||Qr!=null&&Qr.timed)&&(pr.tiebreakSet=!0):(ht!=null&&ht.tiebreakSet||ht!=null&&ht.timed)&&(pr.tiebreakSet=!0),pr)))}if(Array.isArray(Hc)){const{orderedDrawPositions:dr,displayOrder:Vo}=TG({drawPositions:Hc,roundProfile:ue,roundNumber:ro}),Qr=(Lp=ue[ro])==null?void 0:Lp.feedRound,ht=Vo[0]!==dr[0],Er=dr.concat(void 0,void 0).slice(0,2).map((Jr,jn)=>{var Zr;const _i=jn+1,hh=ht?3-_i:_i,Wp=NG({drawPositionCollectionAssignment:Z0e,positionAssignments:x,displaySideNumber:hh,seedAssignments:a,drawPosition:Jr,isFeedRound:Qr,sideNumber:_i}),lSe=(Zr=$e.sides)==null?void 0:Zr.find(uSe=>uSe.sideNumber===_i),HR=kp?(kp-1)*2+jn+1:void 0,cSe=HR?GR==null?void 0:GR[HR]:void 0;return Gp(dn(dn({sourceDrawPositionRange:cSe},lSe),Wp))});Object.assign(bt,ve({sides:Er},!0,!0))}if(n&&bt.sides){const dr=i==null?void 0:i[wl],Vo=ht=>{var pr;const Er=(pr=d==null?void 0:d[ht])==null?void 0:pr.participant;return Er&&su({template:dr==null?void 0:dr.participant,source:Er})};if(bt.sides.filter(Boolean).forEach(ht=>{var pr,Er,Jr;if(ht.participantId){const jn=ve(Vo(ht.participantId)||n&&$o({policyDefinitions:Te,participantId:ht.participantId,tournamentParticipants:n,internalUse:!0,contextProfile:v}),void 0,!0);if(jn){if(f!=null&&f.entries){const Zr=f.entries.find(_i=>_i.participantId===ht.participantId);Zr!=null&&Zr.entryStatus&&(jn.entryStatus=Zr.entryStatus),Zr!=null&&Zr.entryStage&&(jn.entryStage=Zr.entryStage)}Object.assign(ht,{participant:jn})}}if((Er=(pr=ht==null?void 0:ht.participant)==null?void 0:pr.individualParticipantIds)!=null&&Er.length&&!((Jr=ht.participant.individualParticipants)!=null&&Jr.length)){const jn=ht.participant.individualParticipantIds.map(Zr=>Vo(Zr)||n&&$o({policyDefinitions:Te,tournamentParticipants:n,internalUse:!0,contextProfile:v,participantId:Zr}));Object.assign(ht.participant,{individualParticipants:jn})}}),!bt.matchUpType){const{matchUpType:ht}=YP({matchUp:bt});ht&&Object.assign(bt,{matchUpType:ht})}if((v==null?void 0:v.inferGender)&&(!bt.gender||bt.gender===Do)&&((Vp=bt.sides)==null?void 0:Vp.length)===2&&bt.matchUpType!==Bt){const ht=bt.sides.map(pr=>{var Er,Jr,jn,Zr;if(bt.matchUpType===Nt)return(Jr=(Er=pr.participant)==null?void 0:Er.person)==null?void 0:Jr.sex;if(((Zr=(jn=pr.participant)==null?void 0:jn.individualParticipants)==null?void 0:Zr.length)===2){const _i=He(pr.participant.individualParticipants.map(hh=>{var Wp;return(Wp=hh.person)==null?void 0:Wp.sex})).filter(Boolean);if(_i.length===1)return _i[0]}});if(ht.filter(Boolean).length===2&&He(ht).length===1){const pr=ht[0];bt.inferredGender=pr}}}if(bt.tieMatchUps){const dr=bt.matchUpStatus===nt,Vo=(yt=bt.sides)==null?void 0:yt.map(({participant:Qr,drawPosition:ht,sideNumber:pr,lineUp:Er})=>{const Jr=(Qr==null?void 0:Qr.participantType)===Bt&&Qr;return{teamParticipant:Jr&&ye({participantRoleResponsibilities:Jr.participantRoleResponsibilities,participantOtherName:Jr.participanOthertName,participantName:Jr.participantName,participantId:Jr.participantId,teamId:Jr.teamId}),drawPosition:ht,sideNumber:pr,lineUp:Er}});bt.tieMatchUps=bt.tieMatchUps.map(Qr=>{const ht=bt.matchUpId,Er={finishingPositionRange:bt.finishingPositionRange,abbreviatedRoundName:BR,roundNumber:ro,roundName:VR};return se({tieDrawPositions:Hc,scheduleVisibilityFilters:ce,sourceDrawPositionRanges:Se,sideLineUps:Vo,drawPositionsRanges:je,initialRoundOfPlay:Pe,roundNamingProfile:Le,additionalContext:Er,appliedPolicies:Te,isCollectionBye:dr,matchUpTieId:ht,isRoundRobin:me,roundProfile:ue,matchUp:Qr,event:Ae})})}const WR=bt.sides&&bt.sides.filter(dr=>dr==null?void 0:dr.participantId).length===2,aSe=!bt.winningSide;if(Object.assign(bt,{readyToScore:H&&WR&&aSe,hasContext:!0}),WR){const{allParticipantsCheckedIn:dr,checkedInParticipantIds:Vo}=tc({matchUp:bt});Object.assign(bt,{allParticipantsCheckedIn:dr,checkedInParticipantIds:Vo})}return Array.isArray(v==null?void 0:v.exclude)&&(v==null||v.exclude.forEach(dr=>delete bt[dr])),bt}}function FG(t){return Object.assign(t,{inContext:!0}),{matchUp:ve(ut(t).matchUp,!1,!0)}}function ut({tournamentParticipants:t,afterRecoveryTimes:e,contextContent:r,contextProfile:n,drawDefinition:o,matchUpsMap:i,matchUpId:s,inContext:a,context:l,event:c}){if(!o)return{error:fe};if(!s)return{error:Vt};if(typeof s!="string")return{error:X};const{structures:u=[]}=un({drawDefinition:o});n&&!r&&(r=Eo({contextProfile:n,drawDefinition:o}));for(const d of u){const{matchUps:p}=Je({tournamentParticipants:t,afterRecoveryTimes:e,contextContent:r,drawDefinition:o,contextProfile:n,matchUpsMap:i,inContext:a,structure:d,context:l,event:c}),{matchUp:v}=mI({matchUps:p,matchUpId:s});if(v)return{matchUp:v,structure:d}}return{error:ir}}var xG=Object.defineProperty,LG=Object.defineProperties,VG=Object.getOwnPropertyDescriptors,py=Object.getOwnPropertySymbols,BG=Object.prototype.hasOwnProperty,kG=Object.prototype.propertyIsEnumerable,fy=(t,e,r)=>e in t?xG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,GG=(t,e)=>{for(var r in e||(e={}))BG.call(e,r)&&fy(t,r,e[r]);if(py)for(var r of py(e))kG.call(e,r)&&fy(t,r,e[r]);return t},WG=(t,e)=>LG(t,VG(e));function vy({collectionGroups:t=[]}){const e=Object.assign({},...t.filter(n=>(n==null?void 0:n.groupValue)&&(n==null?void 0:n.groupNumber)).map(n=>({[n.groupNumber]:WG(GG({},n),{allGroupMatchUpsCompleted:!0,matchUpsCount:0,sideWins:[0,0],values:[0,0]})}))),r=Object.keys(e).map(n=>Oe(n));return{groupValueGroups:e,groupValueNumbers:r}}function rc(t){var e,r,n,o;const{sideAdjustments:i=[0,0],separator:s="-",drawDefinition:a,matchUpsMap:l,structure:c,matchUp:u,event:d}=t;if(!Array.isArray(i)||i.length!==2||isNaN(i.reduce((b,w)=>b+w)))return{error:X};if(!u)return{error:jr};const p=((e=fr({matchUp:u,drawDefinition:a,structure:c,event:d}))==null?void 0:e.tieFormat)||(t==null?void 0:t.tieFormat);if(!p)return{error:Xc};const v=Or({tieFormat:p});if(v.error)return v;const f=(p==null?void 0:p.collectionDefinitions)||[],m=(u==null?void 0:u.tieMatchUps)||[],g=[0,0],{groupValueGroups:h,groupValueNumbers:_}=vy(p);for(const b of f)NV({collectionDefinition:b,groupValueNumbers:_,groupValueGroups:h,sideTieValues:g,tieMatchUps:m});for(const b of _){const w=h[b],{allGroupMatchUpsCompleted:T,matchUpCount:E,winCriteria:N,groupValue:$,sideWins:A,values:U}=w;let C;if(N!=null&&N.aggregateValue)T&&U[0]!==U[1]&&(C=U[0]>U[1]?1:2);else if(N!=null&&N.valueGoal)C=U.reduce((M,D,R)=>D>=N.valueGoal?R+1:M,void 0);else{const M=Math.floor(E/2)+1;C=A.reduce((D,R,j)=>R>=M?j+1:D,void 0)}C&&(g[C-1]+=$)}const I=g.map((b,w)=>b+i[w]),P={side1Score:I[0],side2Score:I[1],winningSide:void 0},y=I.join(s),S=I.slice().reverse().join(s);let O;if(p!=null&&p.winCriteria){const{valueGoal:b,aggregateValue:w,tallyDirectives:T}=p.winCriteria;if(b){const E=I.map((N,$)=>({sideNumber:$+1,points:N})).find(({points:N})=>N>=b);O=E==null?void 0:E.sideNumber}else w&&m.every(N=>N.matchUpStatus&&Yt.includes(N.matchUpStatus)||N.winningSide)&&I[0]!==I[1]&&(O=I[0]>I[1]?1:2);if(!O&&T){const E=u.matchUpId,N=u.hasContext?u:((r=l==null?void 0:l.drawMatchUps)==null?void 0:r[E])||a&&((n=ut({inContext:!0,drawDefinition:a,matchUpId:E}))==null?void 0:n.matchUp);if(N){const{completedTieMatchUps:$,order:A}=Uf({matchUps:[N]});if($&&(A!=null&&A.length)){const U=A[0].participantId;O=(o=N.sides.find(({participantId:C})=>C===U))==null?void 0:o.sideNumber}}}}return O&&(P.winningSide=O),{scoreStringSide1:y,scoreStringSide2:S,winningSide:O,set:P}}function An(t){if(t)return ve(t,!1,!0)}function Gt(t){var e,r;const n=t==null?void 0:t.matchUp,o=(t==null?void 0:t.score)||(n==null?void 0:n.score),i=(e=o==null?void 0:o.sets)==null?void 0:e[0],{side1Score:s,side2Score:a,side1TiebreakScore:l,side2TiebreakScore:c,side1PointScore:u,side2PointScore:d}=i||{},p=s||a||l||c||u||d;return!!(((r=o==null?void 0:o.sets)==null?void 0:r.length)>1||p)}function nc({matchUpStatus:t}){return lV.includes(t)}function HG({matchUpStatus:t}){return H_.includes(t)}function fv({matchUpStatus:t}){return cV.includes(t)}function vv({matchUpStatus:t,winningSide:e,tieMatchUps:r,sides:n,score:o}){var i;const s=n==null?void 0:n.find(({participantId:c})=>c),a=(i=r==null?void 0:r.filter(vv))==null?void 0:i.length;return Gt({score:o})||a||e&&s||t&&HG({matchUpStatus:t})&&![et,ot,Bn].includes(t)}var qG=Object.defineProperty,my=Object.getOwnPropertySymbols,zG=Object.prototype.hasOwnProperty,YG=Object.prototype.propertyIsEnumerable,gy=(t,e,r)=>e in t?qG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hy=(t,e)=>{for(var r in e||(e={}))zG.call(e,r)&&gy(t,r,e[r]);if(my)for(var r of my(e))YG.call(e,r)&&gy(t,r,e[r]);return t};function mv(t){var e;return typeof t!="object"?{error:_e}:typeof t.element!="object"?{error:X}:t.notes?typeof t.notes!="string"&&!((e=t.notes)!=null&&e.testing)?{error:X}:(Object.assign(t.element,{notes:t.notes}),hy({},V)):{error:_e}}function KG(t){return typeof t!="object"?{error:_e}:typeof t.element!="object"?{error:X}:(t.element.notes&&delete t.element.notes,hy({},V))}var QG=Object.defineProperty,_y=Object.getOwnPropertySymbols,JG=Object.prototype.hasOwnProperty,ZG=Object.prototype.propertyIsEnumerable,Iy=(t,e,r)=>e in t?QG(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jo=(t,e)=>{for(var r in e||(e={}))JG.call(e,r)&&Iy(t,r,e[r]);if(_y)for(var r of _y(e))ZG.call(e,r)&&Iy(t,r,e[r]);return t};function ku(t,e){var r;if(!t)return{error:fe};let n=Date.now();t.updatedAt&&n===new Date(t.updatedAt).getTime()&&(n+=1);const o=new Date(n).toISOString(),i=e==null?void 0:e.filter(Boolean);return t.updatedAt=o,(r=t.structures)==null||r.filter(Boolean).forEach(s=>{(!(i!=null&&i.length)||i!=null&&i.includes(s.structureId))&&(s.updatedAt=o)}),jo({},V)}function Vi({drawDefinition:t,tournamentId:e,matchUps:r,eventId:n}){return t&&ku(t),qe({payload:{matchUps:r,tournamentId:e,eventId:n},topic:zf}),jo({},V)}function Bi({drawDefinition:t,tournamentId:e,matchUpIds:r,eventId:n,action:o}){t&&ku(t),qe({topic:aP,payload:{tournamentId:e,matchUpIds:r,eventId:n,action:o}});for(const i of r)N_({key:i});return jo({},V)}function Ze({drawDefinition:t,tournamentId:e,structureId:r,context:n,eventId:o,matchUp:i}){return i?(t&&tt({drawDefinition:t,structureIds:r?[r]:void 0,tournamentId:e,eventId:o}),qe({topic:cP,payload:{matchUp:i,tournamentId:e,context:n},key:i.matchUpId}),jo({},V)):(console.log(jr),{error:jr})}function XG({tournamentId:t,inContextMatchUp:e}){return e?(qe({topic:Yf,payload:{inContextMatchUp:e,tournamentId:t},key:e.matchUpId}),jo({},V)):{error:jr}}function oc({tournamentId:t,eventId:e,drawDefinition:r}){return r?(ku(r),qe({payload:{drawDefinition:r,tournamentId:t,eventId:e},topic:tP,key:r.drawId}),jo({},V)):(console.log(fe),{error:fe})}function e3({tournamentId:t,eventId:e,drawId:r}){return qe({payload:{drawId:r,tournamentId:t,eventId:e},topic:sP,key:r}),N_({key:r}),jo({},V)}function tt({drawDefinition:t,tournamentId:e,structureIds:r,eventId:n}){return t?(ku(t,r),qe({payload:{tournamentId:e,eventId:n,drawDefinition:t},topic:lP,key:t.drawId}),jo({},V)):{error:fe}}function Py({drawDefinition:t,tournamentId:e,structure:r,eventId:n}){if(!t)return{error:fe};if(!r)return{error:ra};const o=r.seedAssignments,i=r.structureId,s=t.drawId;return qe({payload:{tournamentId:e,eventId:n,drawId:s,structureId:i,seedAssignments:o},topic:dP,key:t.drawId}),tt({structureIds:[i],drawDefinition:t,tournamentId:e,eventId:n}),jo({},V)}function ai({drawDefinition:t,tournamentId:e,structure:r,event:n}){if(!t)return{error:fe};if(!r)return{error:ra};const o=st({structure:r}),i=r.structureId,s=t.drawId,a=n==null?void 0:n.eventId;return qe({topic:uP,payload:{positionAssignments:o,tournamentId:e,structureId:i,eventId:a,drawId:s},key:i}),tt({structureIds:[i],drawDefinition:t,tournamentId:e,eventId:a}),jo({},V)}const Gu=t=>t==null?void 0:t.participantId;function t3({positionAssignments:t}){const e=(t||[]).filter(Gu).map(i=>{const{extension:s}=Kt({element:i,name:ma}),a=Oe(s==null?void 0:s.value),l=!isNaN(a)&&a;return l&&{participantId:i.participantId,subOrder:l}}).filter(Boolean),r=e.map(({subOrder:i})=>i),n=$r(r);return{subOrderMap:Object.assign({},...e.filter(({subOrder:i})=>n[i]===1).map(({participantId:i,subOrder:s})=>({[i]:s})))}}var r3=Object.defineProperty,n3=Object.defineProperties,o3=Object.getOwnPropertyDescriptors,yy=Object.getOwnPropertySymbols,i3=Object.prototype.hasOwnProperty,s3=Object.prototype.propertyIsEnumerable,Sy=(t,e,r)=>e in t?r3(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,a3=(t,e)=>{for(var r in e||(e={}))i3.call(e,r)&&Sy(t,r,e[r]);if(yy)for(var r of yy(e))s3.call(e,r)&&Sy(t,r,e[r]);return t},l3=(t,e)=>n3(t,o3(e));function Oy({positionAssignments:t,tournamentRecord:e,drawDefinition:r,matchUpFormat:n,matchUps:o,event:i}){if(!Array.isArray(o))return{error:X};if(!t)return{error:X};const{policyDefinitions:s}=cs({policyTypes:[sI],tournamentRecord:e,drawDefinition:r,event:i}),{subOrderMap:a}=t3({positionAssignments:t}),l=Uf({policyDefinitions:s,matchUpFormat:n,subOrderMap:a,matchUps:o});if(l.error)return l;const{participantResults:c,bracketComplete:u,report:d}=l,p=Object.keys(c);return t.forEach(v=>{const{participantId:f}=v;if(p.includes(f)){const m={value:c[f],name:Jo};it({element:v,extension:m}),c[f].ties||bn({element:v,name:ma})}else bn({element:v,name:Jo}),bn({element:v,name:ma})}),tt({drawDefinition:r}),l3(a3({},V),{participantResults:c,bracketComplete:u,report:d})}function gv({participantsProfile:t,participants:e=[]}){const r=ve(e,t==null?void 0:t.convertExtensions,!0),n=r.filter(s=>s.participantType===rt),o=r.filter(s=>s.participantType===Cr),i=r.filter(s=>s.participantType===Ue);return r.forEach(s=>{if(s.participantType===Fe){const{participantId:a}=s;s.groupParticipantIds=[],s.teamParticipantIds=[],s.pairParticipantIds=[],s.groups=[],s.teams=[],n.forEach(l=>{((l==null?void 0:l.individualParticipantIds)||[]).forEach(c=>{var u;c===a&&!((u=s.teamParticipantIds)!=null&&u.includes(l.participantId))&&(s.teamParticipantIds.push(l.participantId),s.teams.push({participantRoleResponsibilities:l.participantRoleResponsibilities,participantOtherName:l.participantOtherName,participantName:l.participantName,participantId:l.participantId,teamId:l.teamId}))})}),i.forEach(l=>{((l==null?void 0:l.individualParticipantIds)||[]).forEach(c=>{c===a&&!s.pairParticipantIds.includes(l.participantId)&&s.pairParticipantIds.push(l.participantId)})}),o.forEach(l=>{((l==null?void 0:l.individualParticipantIds)||[]).forEach(c=>{c===a&&!s.groupParticipantIds.includes(l.participantId)&&(s.groupParticipantIds.push(l.participantId),s.groups.push({participantRoleResponsibilities:l.participantRoleResponsibilities,participantOtherName:l.participantOtherName,participantName:l.participantName,participantId:l.participantId}))})})}}),r}const hv=t=>e=>t[e],_v=(t=[])=>t.map(Jt).filter(Boolean),ic=(t=[])=>t.map(dt).filter(Boolean),dt=(t={})=>hv(t)("participantId"),c3=(t={})=>hv(t)("drawPosition"),Jt=(t={})=>hv(t)("matchUpId");function u3({structureMatchUps:t,matchUp:e}){const{roundNumber:r,roundPosition:n}=e,o=t.filter(s=>s.roundNumber===r&&!s.matchUpTieId),i=t.filter(s=>s.roundNumber===r+1&&!s.matchUpTieId);if(i.length){let s;return i.length===o.length?s=i.find(a=>a.roundPosition===n):i.length===o.length/2&&(s=i.find(a=>a.roundPosition===Math.ceil(n/2))),{matchUp:s}}return{message:"no progression found"}}function Iv({sourceRoundMatchUpCount:t,inContextDrawMatchUps:e,sourceRoundPosition:r,drawDefinition:n,targetLink:o}){var i;if(!o)return{error:Yh};const{target:{structureId:s,feedProfile:a,groupedOrder:l,roundNumber:c,positionInterleave:u}}=o,{structure:d}=Ee({drawDefinition:n,structureId:s}),{positionAssignments:p}=st({structure:d}),f=(e==null?void 0:e.filter(E=>E.structureId===(d==null?void 0:d.structureId))).filter(E=>E.roundNumber===c&&!E.matchUpTieId),m=f.length,g=pe(1,m+1),h=m/t;let _=Math.ceil(h*r),I=1-r%2;if(u!=null&&u.interleave&&h!==.5){const E=u.offset+(r-1)*u.interleave,N=r+E;_=Math.ceil(N/2),I=1-N%2}let P=g,y=g[_-1];const S=sy({groupedOrder:l,roundPositionsCount:g.length}),O=(S==null?void 0:S.length)||1;if(O<=g.length){const E=m/O,N=qt(g,E);a===Ps&&N.forEach($=>$.reverse()),P=(S==null?void 0:S.length)&&(S==null?void 0:S.map($=>N[$-1]).flat())||P}a===Mi?y=P[_-1]:a===Ps?((!(S!=null&&S.length)||O>g.length)&&(_=f.length+1-_),y=P[_-1]):a===ZP&&zt()&&console.log(P_,{feedProfile:a});const b=y&&f.reduce((E,N)=>N.roundPosition===y?N:E,void 0);let w;b!=null&&b.feedRound?(I=0,w=Math.min(...(b.drawPositions||[]).filter(Boolean))):w=((i=b==null?void 0:b.drawPositions)==null?void 0:i.length)===2&&(b==null?void 0:b.drawPositions[I]);const T=p==null?void 0:p.find(({drawPosition:E})=>E===w);if(T){const{extension:E}=Kt({element:T,name:hu});if(E!=null&&E.value)return{disabledDrawPosition:w}}return{matchUp:b,targetDrawPosition:w,matchUpDrawPositionIndex:I}}function d3({drawDefinition:t,roundNumber:e,structureId:r}){if(!t)return{error:fe};if(!r)return{error:Pr};const{links:n}=sc({drawDefinition:t,structureId:r}),o=n.source.reduce((s,a)=>!a.source.roundNumber||a.source.roundNumber===e?s.concat(a):s,[]),i=n.target.reduce((s,a)=>!a.target.roundNumber||a.target.roundNumber===e?s.concat(a):s,[]);return{links:{source:o,target:i}}}function Pv({finishingPositions:t,linkCondition:e,linkType:r,source:n}){var o;const i=n.find(s=>{var a,l;const c=!((a=s.source)!=null&&a.finishingPositions)||!t||Xt(t,(l=s.source)==null?void 0:l.finishingPositions);return e===s.linkCondition&&c&&s.linkType===r});return[ji,ys].includes(i==null?void 0:i.linkType)&&!((o=i==null?void 0:i.source)!=null&&o.roundNumber)?k({result:{error:X},stack:"getTargetLink",context:i}):i}function sc({drawDefinition:t,structureId:e,roundNumber:r}){return t?e?{links:(t.links||[]).filter(Boolean).reduce((i,s)=>{var a,l;return((a=s.source)==null?void 0:a.structureId)===e&&(!r||s.source.roundNumber===r)&&(i.source=i.source.concat(s)),((l=s.target)==null?void 0:l.structureId)===e&&(!r||s.target.roundNumber===r)&&(i.target=i.target.concat(s)),i},{source:[],target:[]})}:{error:Pr}:{error:fe}}function _r({inContextDrawMatchUps:t=[],useTargetMatchUpIds:e,inContextMatchUp:r,drawDefinition:n,matchUpId:o}){let i=r;t.length&&!i&&(i=t.find(l=>l.matchUpId===o));const{structure:s}=Ee({structureId:i==null?void 0:i.structureId,drawDefinition:n});return(s==null?void 0:s.finishingPosition)===Fi?p3({inContextDrawMatchUps:t,useTargetMatchUpIds:e,drawDefinition:n,structure:s,matchUp:i}):f3({matchUp:i})}function p3({inContextDrawMatchUps:t,useTargetMatchUpIds:e,drawDefinition:r,structure:n,matchUp:o}){var i,s,a;const{winnerMatchUpId:l,loserMatchUpId:c}=o,{links:u}=d3({roundNumber:o.roundNumber,structureId:n.structureId,drawDefinition:r}),d=u==null?void 0:u.source,p=Pv({source:d,linkType:ji}),v=Pv({linkCondition:uo,linkType:ys,source:d});let f=Pv({source:d,linkType:ys});const m=v&&f;f||(f=v);const g=(i=p==null?void 0:p.target)==null?void 0:i.feedProfile,h=(s=f==null?void 0:f.target)==null?void 0:s.feedProfile,_=(a=v==null?void 0:v.target)==null?void 0:a.feedProfile;let I,P,y,S,O,b,w,T,E,N;if(e&&(l||c)&&(w=l&&g!==Tn&&t.find(({matchUpId:U})=>U===l),S=c&&h!==Tn&&t.find(({matchUpId:U})=>U===c),w||S))return{matchUp:o,targetLinks:{loserTargetLink:f,winnerTargetLink:p},targetMatchUps:{loserMatchUp:S,winnerMatchUp:w}};const{roundPosition:$}=o;N=N||t.filter(U=>U.structureId===n.structureId);const A=N.reduce((U,C)=>C.roundNumber===o.roundNumber&&!C.matchUpTieId?U+1:U,0);return f&&!S&&h!==Tn&&({matchUpDrawPositionIndex:b,targetDrawPosition:O,matchUp:S}=Iv({targetLink:f,sourceRoundMatchUpCount:A,inContextDrawMatchUps:t,sourceRoundPosition:$,drawDefinition:r})),m&&_!==Tn&&({matchUpDrawPositionIndex:y,targetDrawPosition:P,matchUp:I}=Iv({targetLink:v,sourceRoundMatchUpCount:A,inContextDrawMatchUps:t,sourceRoundPosition:$,drawDefinition:r})),p&&!w&&g!==Tn&&({matchUpDrawPositionIndex:E,targetDrawPosition:T,matchUp:w}=Iv({targetLink:p,sourceRoundMatchUpCount:A,inContextDrawMatchUps:t,sourceRoundPosition:$,drawDefinition:r})),w||(N=N||t.filter(U=>U.structureId===n.structureId),{matchUp:w}=u3({structureMatchUps:N,matchUp:o})),ye({matchUp:o,targetLinks:{loserTargetLink:f,winnerTargetLink:p,byeTargetLink:v},targetMatchUps:{byeMatchUp:I,loserMatchUp:S,winnerMatchUp:w,byeTargetDrawPosition:P,loserTargetDrawPosition:O,winnerTargetDrawPosition:T,byeMatchUpDrawPositionIndex:y,loserMatchUpDrawPositionIndex:b,winnerMatchUpDrawPositionIndex:E},targetMatchUpIds:!!(l||c)})}function f3({matchUp:t}){return{matchUp:t,targetLinks:{loserTargetLink:void 0,winnerTargetLink:void 0},targetMatchUps:{loserMatchUp:void 0,winnerMatchUp:void 0}}}function v3({drawDefinition:t,inContextDrawMatchUps:e}){const r={};return e.forEach(n=>{var o,i,s,a,l;const{matchUpId:c,structureId:u,drawPositions:d=[]}=n,{structure:p}=Ee({drawDefinition:t,structureId:u});if((p==null?void 0:p.finishingPosition)===ya){const{roundNumber:v}=n,f=v&&Oe(v)+1,m=p.matchUps||[],{roundMatchUps:g}=br({matchUps:m});if(f&&(g!=null&&g[f])){const h=d.sort().map((_,I)=>{const P=g[f].find(y=>{var S;return(S=y.drawPositions)==null?void 0:S.includes(_)});return{matchUpId:P==null?void 0:P.matchUpId,roundNumber:f,schedule:P==null?void 0:P.schedule,sideNumber:I+1,structureName:p.structureName}});Object.assign(n,{sidesTo:h})}}else{const v=_r({useTargetMatchUpIds:!0,inContextDrawMatchUps:e,inContextMatchUp:n,drawDefinition:t,matchUpId:c});let{winnerMatchUp:f}=v.targetMatchUps;const{loserMatchUp:m}=v.targetMatchUps;!n.winnerMatchUpId&&f&&(n.winnerMatchUpId=f.matchUpId),!n.loserMatchUpId&&m&&(n.loserMatchUpId=m.matchUpId);const g=yv({upcomingMatchUp:f});let h=yv({upcomingMatchUp:m});if(n.matchUpStatus!==nt&&(m==null?void 0:m.matchUpStatus)===nt){const{matchUp:I}=by({matchUp:m,drawDefinition:t,inContextDrawMatchUps:e})||{};h=I&&yv({upcomingMatchUp:I})||h}const _=(o=n.schedule)==null?void 0:o.timeAfterRecovery;if(_&&((i=g==null?void 0:g.schedule)!=null&&i.scheduledTime&&xe(g.schedule.scheduledTime)<xe(_)&&(r[g.matchUpId]=n.matchUpId,g.schedule.scheduleConflict=n.matchUpId),(s=h==null?void 0:h.schedule)!=null&&s.scheduledTime&&xe(h.schedule.scheduledTime)<xe(_)&&(r[h.matchUpId]=n.matchUpId,h.schedule.scheduleConflict=n.matchUpId)),Object.assign(n,{winnerTo:g,loserTo:h}),(a=n.drawPositions)!=null&&a.filter(Boolean).length){const I=(l=v.targetLinks)==null?void 0:l.loserTargetLink,P=(I==null?void 0:I.linkCondition)===uo,y=m3(n);if(y.length){const S=ic(f==null?void 0:f.sides),O=ic(m==null?void 0:m.sides),w=y.find(({participantId:N})=>S.includes(N))?[]:y,E=y.find(({participantId:N})=>O.includes(N))?[]:y;m&&P&&E.length<2&&E.push({bye:!0,tbd:!0}),w!=null&&w.length&&f&&(!v.targetMatchUpIds&&f&&(f=e.find(({matchUpId:N})=>N===f.matchUpId)),f.potentialParticipants||(f.potentialParticipants=[]),f.potentialParticipants.push(w)),E!=null&&E.length&&m&&(v.targetMatchUpIds||(f=e.find(({matchUpId:N})=>N===m.matchUpId)),m.potentialParticipants||(m.potentialParticipants=[]),m.potentialParticipants.push(E))}}}}),Object.keys(r).length&&e.forEach(n=>{Object.keys(r).includes(n.matchUpId)&&(n.schedule.scheduleConflict=r[n.matchUpId])}),{scheduleConflictMatchUpIds:r}}function m3(t){var e;return((e=t==null?void 0:t.sides)==null?void 0:e.map(({participant:r,participantId:n,qualifier:o})=>r||n&&{participantId:n}||o&&{qualifier:o}).filter(Boolean))||[]}function by({matchUp:t,drawDefinition:e,inContextDrawMatchUps:r}){const{matchUpId:n,matchUpStatus:o,structureId:i}=t||{};if(!t||!i||(t==null?void 0:t.matchUpStatus)===Rt)return{matchUp:t};if(o===nt){let s;if(t.winnerMatchUpId)s=r.find(({matchUpId:a})=>a===t.winnerMatchUpId);else{const a=_r({inContextDrawMatchUps:r,drawDefinition:e,matchUpId:n});({winnerMatchUp:s}=(a==null?void 0:a.targetMatchUps)||{})}return by({matchUp:s,drawDefinition:e,inContextDrawMatchUps:r})}return{matchUp:void 0}}function yv(t){if(t!=null&&t.upcomingMatchUp)return(({matchUpId:e,structureId:r,schedule:n,roundNumber:o,roundPosition:i,structureName:s})=>({matchUpId:e,structureId:r,schedule:n,roundNumber:o,roundPosition:i,structureName:s}))(t.upcomingMatchUp)}function ac({requireParticipants:t=!0,scheduleVisibilityFilters:e,tournamentAppliedPolicies:r,tournamentParticipants:n,afterRecoveryTimes:o,policyDefinitions:i,tournamentRecord:s,matchUpFilters:a,contextFilters:l,contextContent:c,participantMap:u,scheduleTiming:d,contextProfile:p,drawDefinition:v,exitProfiles:f,matchUpsMap:m,structureId:g,inContext:h,structure:_,context:I,event:P}){!_&&g&&({structure:_}=Ee({drawDefinition:v,structureId:g}));const y=Je({tournamentAppliedPolicies:r,scheduleVisibilityFilters:e,tournamentParticipants:n,afterRecoveryTimes:o,policyDefinitions:i,tournamentRecord:s,drawDefinition:v,matchUpFilters:a,contextFilters:l,contextProfile:p,contextContent:c,participantMap:u,scheduleTiming:d,exitProfiles:f,matchUpsMap:m,structure:_,inContext:h,context:I,event:P}),S=[],O=[],b=[],w=[],T=[];if(y.error)return y;const{matchUps:E}=y,{assignedPositions:N}=Ct({structure:_}),$=N==null?void 0:N.filter(U=>U.participantId).map(U=>U.drawPosition);let A;return E.filter(U=>{var C;const M=((C=a==null?void 0:a.matchUpTypes)==null?void 0:C.length)===1&&a.matchUpTypes[0]===Qe;return!(U.matchUpType!==Qe&&M)}).forEach(U=>{var C,M,D,R;if(U.matchUpStatus===Wr){S.push(U);return}U.matchUpType===Qe&&(A=!0);const j=U.collectionId,G=j&&((C=U.sides)==null?void 0:C.every(H=>H.participantId)),W=!j&&((M=U.drawPositions)==null?void 0:M.filter(Boolean).length)===2,z=!j&&((D=U.drawPositions)==null?void 0:D.every(H=>$==null?void 0:$.includes(H))),F=N==null?void 0:N.filter(H=>H.bye).map(H=>H.drawPosition),L=!j&&((R=U.drawPositions)==null?void 0:R.find(H=>F==null?void 0:F.includes(H))),B=uV.includes(U.matchUpStatus)&&(G||W&&(!t||z));return L?T.push(U):ca({matchUp:U})?O.push(U):B?b.push(U):w.push(U)}),{includesTeamMatchUps:A,abandonedMatchUps:S,completedMatchUps:O,upcomingMatchUps:b,pendingMatchUps:w,byeMatchUps:T,structure:_}}var g3=Object.defineProperty,h3=Object.defineProperties,_3=Object.getOwnPropertyDescriptors,Ty=Object.getOwnPropertySymbols,I3=Object.prototype.hasOwnProperty,P3=Object.prototype.propertyIsEnumerable,wy=(t,e,r)=>e in t?g3(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sv=(t,e)=>{for(var r in e||(e={}))I3.call(e,r)&&wy(t,r,e[r]);if(Ty)for(var r of Ty(e))P3.call(e,r)&&wy(t,r,e[r]);return t},y3=(t,e)=>h3(t,_3(e));function xt(t){const e="getAllDrawMatchUps";Object.assign(t,{requireParticipants:!1});const r=Es(t);if(r.error)return k({result:r,stack:e});const{abandonedMatchUps:n,completedMatchUps:o,upcomingMatchUps:i,pendingMatchUps:s,byeMatchUps:a,matchUpsMap:l}=r;return{matchUps:(n??[]).concat(...o??[],...i??[],...s??[],...a??[]),matchUpsMap:l}}function Es(t){if(!(t!=null&&t.drawDefinition))return{error:fe};let{tournamentParticipants:e,contextContent:r,matchUpsMap:n}=t;const{scheduleVisibilityFilters:o,tournamentAppliedPolicies:i,requireParticipants:s,participantsProfile:a,afterRecoveryTimes:l,policyDefinitions:c,tournamentRecord:u,contextFilters:d,contextProfile:p,drawDefinition:v,matchUpFilters:f,scheduleTiming:m,participantMap:g,nextMatchUps:h,inContext:_,context:I,event:P}=t;let y=[],S=[],O=[],b=[],w=[];p&&!r&&(r=Eo({policyDefinitions:c,tournamentRecord:u,contextProfile:p,event:P})),!(e!=null&&e.length)&&u&&(e=u==null?void 0:u.participants,(_||a!=null&&a.withGroupings)&&(e!=null&&e.length)&&(e=gv({participants:e,participantsProfile:a})));const{structures:T}=un({drawDefinition:v});if(!T)return{error:St};n||(n=lr({drawDefinition:v}));const E=v&&dv({drawDefinition:v}).exitProfiles;T.forEach(A=>{const{byeMatchUps:U=[],pendingMatchUps:C=[],upcomingMatchUps:M=[],completedMatchUps:D=[],abandonedMatchUps:R=[]}=ac({matchUpFilters:h?void 0:f,contextFilters:h?void 0:d,inContext:_||h||d,tournamentAppliedPolicies:i,scheduleVisibilityFilters:o,tournamentParticipants:e,requireParticipants:s,afterRecoveryTimes:l,policyDefinitions:c,tournamentRecord:u,participantMap:g,scheduleTiming:m,contextContent:r,contextProfile:p,drawDefinition:v,exitProfiles:E,matchUpsMap:n,structure:A,context:I,event:P});y=y.concat(...R),S=S.concat(...D),O=O.concat(...M),b=b.concat(...C),w=w.concat(...U)});const N=A=>(!f&&!h&&!d||(f&&(A=Ts(Sv({matchUps:A},f))),d&&(A=Ts(y3(Sv({matchUps:A},d),{processContext:!0})))),A),$=Sv({abandonedMatchUps:N(y),completedMatchUps:N(S),upcomingMatchUps:N(O),pendingMatchUps:N(b),byeMatchUps:N(w),matchUpsMap:n},V);if(h){const A=typeof h=="object"||{abandoned:!0,completed:!0,upcoming:!0,pending:!0,bye:!0},{abandoned:U,completed:C,upcoming:M,pending:D,bye:R}=A,j=[].concat(...U&&y||[],...C&&S||[],...M&&O||[],...D&&b||[],...R&&w||[]);v3({inContextDrawMatchUps:j,drawDefinition:v})}return $}const Wu={matchUpStatus:Rt,matchUpStatusCodes:[],score:{scoreStringSide1:"",scoreStringSide2:"",sets:void 0},matchUpFormat:void 0,winningSide:void 0};var S3=Object.defineProperty,Ey=Object.getOwnPropertySymbols,O3=Object.prototype.hasOwnProperty,b3=Object.prototype.propertyIsEnumerable,$y=(t,e,r)=>e in t?S3(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ny=(t,e)=>{for(var r in e||(e={}))O3.call(e,r)&&$y(t,r,e[r]);if(Ey)for(var r of Ey(e))b3.call(e,r)&&$y(t,r,e[r]);return t};function Qn({matchUpStatusCodes:t,removeWinningSide:e,tournamentRecord:r,drawDefinition:n,matchUpFormat:o,matchUpStatus:i,removeScore:s,winningSide:a,matchUpId:l,matchUp:c,event:u,notes:d,score:p}){var v,f,m,g,h,_,I,P;const y="modifyMatchUpScore";let S;const O=c.matchUpType===Qe;if(O&&n){if(l&&c.matchUpId!==l){const A=ut({drawDefinition:n,matchUpId:l,event:u});if(!A.matchUp)return{error:ir};({matchUp:c,structure:S}=A)}}else c.matchUpId!==l&&console.log("!!!!!");i&&[ot,jt].includes(i)||s?Object.assign(c,Ny({},Wu)):p&&(c.score=p);const b=i&&(c==null?void 0:c.matchUpStatus)===et&&i!==et;i&&(c.matchUpStatus=i),o&&(c.matchUpFormat=o),t&&(c.matchUpStatusCodes=t),a&&(c.winningSide=a),e&&(c.winningSide=void 0),!S&&n&&({structure:S}=ut({drawDefinition:n,matchUpId:l,event:u})),i&&!c.winningSide&&Gt(c)&&!Yt.includes(i)&&![la,Ti].includes(i)&&(c.matchUpStatus=pt.InProgress);let w;if(b&&((v=c==null?void 0:c.processCodes)!=null&&v.length)||i===et){const A=(f=vt({tournamentRecord:r,drawDefinition:n,structure:S,event:u}))==null?void 0:f.appliedPolicies;w=(g=(m=A==null?void 0:A[da])==null?void 0:m.processCodes)==null?void 0:g.incompleteAssignmentsOnDefault}if((S==null?void 0:S.structureType)===gr&&!c.collectionId){o=O?"SET1-S:T100":o||c.matchUpFormat||(S==null?void 0:S.matchUpFormat)||(n==null?void 0:n.matchUpFormat)||(u==null?void 0:u.matchUpFormat);const A=S.structures.find(D=>D==null?void 0:D.matchUps.find(R=>R.matchUpId===l)),U=O?{matchUpTypes:[Qe]}:void 0,{matchUps:C}=Je({afterRecoveryTimes:!1,structure:A,inContext:!0,matchUpFilters:U,event:u}),M=Oy({positionAssignments:A.positionAssignments,tournamentRecord:r,drawDefinition:n,matchUpFormat:o,matchUps:C,event:u});if(M.error)return k({result:M,stack:y})}if(d){const A=mv({element:c,notes:d});if(A.error)return k({result:A,stack:y})}const T=r==null?void 0:r.tournamentId,E=xn().topics.includes(Yf),N=(E||w)&&lr({drawDefinition:n}),$=N&&((h=xt({matchUpFilters:{matchUpIds:[l]},nextMatchUps:!0,tournamentRecord:r,inContext:!0,drawDefinition:n,matchUpsMap:N}).matchUps)==null?void 0:h[0]);if(E&&$&&XG({tournamentId:T,inContextMatchUp:$}),Array.isArray(w)&&$&&!((_=$.sides)!=null&&_.every(({participantId:A})=>A)))if(i===et)c.processCodes?c.processCodes.push(...w):c.processCodes=w;else for(const A of w||[]){const U=A&&((I=c==null?void 0:c.processCodes)==null?void 0:I.lastIndexOf(A));(P=c==null?void 0:c.processCodes)==null||P.splice(U,1)}return Ze({eventId:u==null?void 0:u.eventId,context:y,drawDefinition:n,tournamentId:T,matchUp:c}),Ny({},V)}var T3=Object.defineProperty,w3=Object.defineProperties,E3=Object.getOwnPropertyDescriptors,Uy=Object.getOwnPropertySymbols,$3=Object.prototype.hasOwnProperty,N3=Object.prototype.propertyIsEnumerable,Ay=(t,e,r)=>e in t?T3(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ov=(t,e)=>{for(var r in e||(e={}))$3.call(e,r)&&Ay(t,r,e[r]);if(Uy)for(var r of Uy(e))N3.call(e,r)&&Ay(t,r,e[r]);return t},Cy=(t,e)=>w3(t,E3(e));function po({tournamentRecord:t,exitWhenNoValues:e,drawDefinition:r,matchUpStatus:n,removeScore:o,matchUpsMap:i,matchUpId:s,event:a}){var l,c;const u=ut({drawDefinition:r,event:a,matchUpId:s});if(u.error)return u;if(!u.matchUp)return{error:ir};const{matchUp:d,structure:p}=u;if(!d.tieMatchUps)return{error:rn};const{extension:v}=xr({name:fa,element:d});if(v!=null&&v.value)if(o)bn({element:d,name:fa});else return Cy(Ov({},V),{score:d.score});const f=(l=fr({drawDefinition:r,structure:p,matchUp:d,event:a}))==null?void 0:l.tieFormat;d.tieFormat=An(f);const m=rc({drawDefinition:r,matchUpsMap:i,structure:p,matchUp:d,event:a}),{winningSide:g,set:h,scoreStringSide1:_,scoreStringSide2:I}=m,P=(h==null?void 0:h.side1Score)||(h==null?void 0:h.side2Score);if(e&&!d.score&&!P)return Ov({},V);const y={scoreStringSide1:_,scoreStringSide2:I,sets:h?[h]:[]},S=g&&[1,2].includes(g),O=S&&At||vv({matchUpStatus:n??d.matchUpStatus,tieMatchUps:d.tieMatchUps,winningSide:d.winningSide,score:y})&&Bn||Rt,b=!!(d.winningSide&&!S),w=d.tieMatchUps.find(({score:E,winningSide:N,matchUpStatus:$})=>{var A;return((A=E==null?void 0:E.sets)==null?void 0:A.length)&&(E.sets[0].side1Score||E.sets[0].side2Score)||$&&Yt.includes($)||N});let T;if(d.tieFormat&&!S&&!w){const E=(c=fr({drawDefinition:r,structure:p,event:a}))==null?void 0:c.tieFormat;E&&JSON.stringify(f)===JSON.stringify(E)&&(d.tieFormatId=void 0,d.tieFormat=void 0,T=!0)}return Qn({matchUpStatus:O,score:y,removeWinningSide:b,tournamentRecord:t,drawDefinition:r,removeScore:o,winningSide:g,matchUpId:s,matchUp:d,event:a}),Cy(Ov({},V),{score:y,removeWinningSide:b,tieFormatRemoved:T,winningSide:g})}function fo(t){const{winnerFirst:e=!0,addOutcomeString:r,reversed:n=!1,matchUpStatus:o,matchUpFormat:i,autoComplete:s,winningSide:a,sets:l}=t;if(!l)return{error:_e,info:"missing sets"};const c=i&&Ir(i),{bestOf:u,finalSetFormat:d,setFormat:p}=c||{},f=n||!(!e||!a||a===1),m=r?U3({matchUpStatus:o}):"",g=(l==null?void 0:l.sort(A3).map(h).filter(Boolean).join(" "))||"";if(!m)return g;if(a===2)return`${m} ${g}`;return`${g} ${m}`;function h(_){const P=u&&_.setNumber===u&&d?d:p,y=R=>Ut(R==null?void 0:R.side1Score)||Ut(R==null?void 0:R.side2Score),S=R=>Ut(R==null?void 0:R.side1TiebreakScore)||Ut(R==null?void 0:R.side2TiebreakScore),O=(P==null?void 0:P.tiebreakSet)||!y(_)&&S(_),{side1Score:b,side2Score:w,side1TiebreakScore:T,side2TiebreakScore:E}=_,N=T||(Ut(T)||s?0:""),$=E||(Ut(E)||s?0:"");if(O)return`[${(f?[$,N]:[N,$]).join("-")}]`;const A=Math.min(N,$),U=A?`(${A})`:"",C=b||(Ut(b)||s?0:""),M=w||(Ut(w)||s?0:"");let D=f?`${[M,C].join("-")}${U}`:`${[C,M].join("-")}${U}`;return["-"," "].includes(D)&&(D=""),D}}function U3({matchUpStatus:t}){const e={[hr]:"RET",[ot]:"WO",[tr]:"DF/DF",[jt]:"WO/WO",[Ti]:"SUS",[Wr]:"ABN",[et]:"DEF",[Tl]:"DR"};return t&&e[t]||""}function A3(t,e){return t.setNumber-e.setNumber}function C3({existingMatchUpStatus:t,matchUpFormat:e,matchUpStatus:r,winningSide:n,score:o}){const i=(o==null?void 0:o.sets)||[],a=((i==null?void 0:i.filter(S=>S==null?void 0:S.winningSide))||[]).reduce((S,O)=>{const{winningSide:b}=O;if(!b)return S;const w=b-1;return S[w]++,S},[0,0]),l=n?n-1:void 0,c=l!==void 0?1-l:void 0,u=l!==void 0&&a[l],d=c!==void 0&&a[c],p=e?Ir(e):void 0,v=Math.max(...a),f=$r(a)[v],m=p==null?void 0:p.bestOf,g=m&&Math.ceil(m/2)||1,h=r||t,_=h&&[et,hr,ot].includes(h),I=!p||!i.length||i.every((S,O)=>{const b=O+1,w=b===m,T=b===i.length,{side1Score:E,side2Score:N,side1TiebreakScore:$,side2TiebreakScore:A,winningSide:U}=S,C=Math.max(E||0,N||0),M=$||A,{finalSetFormat:D,setFormat:R}=p,j=w&&D||R;if(M){const{tiebreakTo:W,NoAD:z}=(j==null?void 0:j.tiebreakFormat)||{},F=Math.max($||0,A||0);if(z&&F>W||F<W&&U&&(T&&!_||!T))return!1}return j.setTo?!(!j.noTiebreak&&C>j.setTo+1):!0}),P=(!e||v===g)&&f===1&&a.indexOf(v)+1||void 0;return{valid:I&&(n&&u>d&&n===P||!n&&!P||_)}}function bv({existingMatchUpStatus:t,matchUpFormat:e,matchUpStatus:r,winningSide:n,score:o}){if(typeof o!="object")return{error:X};const{sets:i,scoreStringSide1:s,scoreStringSide2:a}=o,l="scoreString must be a string!";if(s!==void 0&&typeof s!="string")return{error:X,info:l};if(a!==void 0&&typeof a!="string")return{error:X,info:l};if(i!==void 0&&!Array.isArray(i))return{error:X,info:or("sets")};if(i!=null&&i.length){const c=i.map(d=>d==null?void 0:d.setNumber).filter(Boolean);if(c.length!==He(c).length)return{error:X,info:"setNumbers not unique"};for(const d of i){const{side1Score:p,side2Score:v,side1TiebreakScore:f,side2TiebreakScore:m,side1PointScore:g,side2PointScore:h,winningSide:_,setNumber:I}=d;if(![[p,v],[f,m],[g,h]].filter(S=>S.some(O=>O!==void 0)).every(S=>S.every(O=>_t(O))))return{error:X,info:"non-numeric values"};if(![I,_].filter(S=>S!==void 0).every(S=>_t(S)))return{error:X,info:"non-numeric values"};if(_&&![1,2].includes(_))return{error:X,info:"winningSide must be 1 or 2"}}const{valid:u}=C3({existingMatchUpStatus:t,matchUpStatus:r,matchUpFormat:e,winningSide:n,score:o});if(!u)return{error:yx,info:"score is invalid for matchUpFormat or winningSide does not match calculated winningSide"}}return{valid:!0}}function Tv({analysis:t,set:e}){const r=wv({set:e}),{isDecidingSet:n,isTiebreakSet:o,matchUpScoringFormat:i}=t;return My({matchUpScoringFormat:i,isDecidingSet:n,isTiebreakSet:o,set:e})&&r}function My(t){let e=t.matchUpScoringFormat;const{ignoreTiebreak:r=!1,matchUpFormat:n,isTiebreakSet:o,isDecidingSet:i,set:s}=t;if(!s)return{error:_e};e=e||n;const a=i&&e.finalSetFormat||(e==null?void 0:e.setFormat)||{},{side1Score:l,side2Score:c}=s,{NoAD:u,setTo:d,tiebreakAt:p,tiebreakFormat:v}=a,f=v==null?void 0:v.NoAd,m=wv({set:s}),g=Math.abs(l-c),h=l>=d||c>=d,_=o||l>=d&&c>=d||p&&p<d&&(l===p||c===p),I=r||_&&(m===1&&s.side1TiebreakScore>s.side2TiebreakScore||m===2&&s.side2TiebreakScore>s.side1TiebreakScore),y=g>=(u||_&&(p&&!o||o&&f)?1:2);return(h&&(y||_)||o)&&(!_||I)}function wv({set:t}){if(t.side1Score||t.side2Score){if(t.side1Score>t.side2Score)return 1;if(t.side2Score>t.side1Score)return 2}else if(t.side1TiebreakScore||t.side2TiebreakScore){if(t.side1TiebreakScore>t.side2TiebreakScore)return 1;if(t.side2TiebreakScore>t.side1TiebreakScore)return 2}}const $s=" ",Ev="DEF",M3="COMPLETED",Dy="WO",D3="WO/WO",jy="ABN",Ry="SUS",Fy="RET",xy="INT",Ly=[Fy,Ev,Dy,D3,jy,Ry,xy],$v="DEFAULTED",Vy="WALKOVER",By="ABANDONED",ky="SUSPENDED",Gy="RETIRED",Wy="INTERRUPTED",j3=[Gy,$v,Vy],Ns="()",ki="[]",R3=["up","left","shift+tab"],F3=["enter","down","tab","right"],Hu="backspace",Hy="r",qy="s",zy="a",Yy="d",Ky="w",Qy="i",Nv=[Hy,Yy,Ky,zy,qy,Qy],qu="space",Uv=["[","("],zu=[...R3,...F3,qu,"]"],Jy="-",x3="/",Us=Jy,vo=Jy,Zy=[x3],L3=0,Xy=["0","1","2","3","4","5","6","7","8","9"].concat(Nv),V3=Xy.map(t=>`shift+${t}`),B3=[Us,Hu].concat(zu,Zy),k3=[Xy,V3,B3].join(",");function G3({analysis:t,scoreString:e,sets:r,value:n}){let o;if(!(r!=null&&r.length))return{sets:[]};const i=r[r.length-1];n=Oe(n);const{validSide2Score:s,requiresTiebreak:a}=W3({analysis:t,set:i,value:n});if(s){o=!0,e=(e||"")+n,i.side2Score=n;const l=Tv({analysis:t,set:r[r.length-1]});if(i.winningSide=l||void 0,a){const c=Ns.split("")[0];e+=c}else t.isDecidingSet||(e+=$s)}return{sets:r,scoreString:e,updated:o}}function W3({analysis:t,set:e={},value:r}){const n=t.isDecidingSet&&t.matchUpScoringFormat.finalSetFormat||t.matchUpScoringFormat.setFormat,{tiebreakAt:o,setTo:i,NoAD:s}=n,{side1Score:a}=e;let l,c;return o&&o<i?a===o?l=r<=i:l=r<=o:a===i?s?l=r<i:l=r<=i+1:a===i-1?s?l=r<=i:l=r<=i+1:a===i+1?l=r===i||r===i-1:l=r<=i,l&&(o&&o<i?c=a===i&&r===o||a===o&&r===i:c=a>=i&&r>=i&&a!==r),{validSide2Score:l,requiresTiebreak:c}}function ba({scoreString:t,lowSide:e,outcome:r}){if({scoreString:t}=e0({scoreString:t}),e===2){const o=(t&&t[t.length-1])!==$s?$s:"";return t+o+r}else return r+$s+t}function e0({scoreString:t}){if(!t)return{scoreString:""};let e=!1;for(const r of Ly){const n=t==null?void 0:t.indexOf(r);n===0?t=t.slice(r.length+1).trim()+$s:n>0&&(t=t.slice(0,n)),n>=0&&(e=!0)}return t!=null&&t.trim()||(t=""),{scoreString:t,removed:e}}function Av({analysis:t,scoreString:e,sets:r,lowSide:n}){var o,i,s;let a,l;if(!e)return{scoreString:e,sets:r};const{scoreString:c,removed:u}=e0({scoreString:e});if(e=c,u)return{scoreString:e,sets:r,outcomeRemoved:!0};let d=r[r.length-1]||{};const p=Object.values(d).filter(_=>_!==void 0).length;d.setNumber&&p===1&&(r=r.slice(0,r.length-1),d=r[r.length-1]||{});const{tiebreakSet:v}=t.setFormat,{tiebreakTo:f,NoAD:m}=v||{},{isTiebreakEntry:g}=Ta({brackets:ki,scoreString:e}),h=q3(e);if(h>=0){a=e.slice(0,h);const{isTiebreakEntry:_}=Ta({brackets:Ns,scoreString:a}),{lastOpenBracketIndex:I,isTiebreakEntry:P}=Ta({brackets:ki,scoreString:a}),y=a&&a[a.length-1].trim(),S=a&&!isNaN(y);let O=t.isIncompleteSetScore;if(g&&P){const w=a.slice(I+1).split(vo),T=(w==null?void 0:w.length)>0&&w[0]!==void 0&&!isNaN(parseInt(w[0]))&&parseInt(w[0])||void 0,E=(w==null?void 0:w.length)>1&&w[1]!==void 0&&parseInt(w[1])||void 0,N=[T,E];if(E){const $=n===1?1:0;N[$]=((N==null?void 0:N[1-$])||0)+(m?1:2),(N[$]||0)<f&&(N[$]=f),a=e.slice(0,I+1),a+=N.join(vo)}else T!==void 0?(a=e.slice(0,I+1),a+=T):(a=e.slice(0,I),O=!0);d.side1TiebreakScore=N[0]||0,d.side2TiebreakScore=N[1]||0}if(a.length||(a=void 0),O){const b=(o=d.side1Score)==null?void 0:o.toString();if(b){const w=b==null?void 0:b.slice(0,b.length-1);d.side1Score=!isNaN(w)&&parseInt(w)||void 0,d.side1Score===void 0&&(d.side2Score=void 0)}t.isTimedSet?(l=d.side1Score?r:(r==null?void 0:r.slice(0,r.length-1))||[],l[r.length-1]=d):l=(r==null?void 0:r.slice(0,r.length-1))||[]}else if(S){const b=(i=d.side2Score)==null?void 0:i.toString(),w=(s=d.side1Score)==null?void 0:s.toString();if(!t.isTiebreakEntry&&!t.isMatchTiebreak)if(d.side2Score){const T=b==null?void 0:b.slice(0,b.length-1);d.side2Score=!isNaN(T)&&parseInt(T)||void 0}else{const T=w==null?void 0:w.slice(0,w.length-1);d.side1Score=!isNaN(T)&&parseInt(T)||void 0}t.isTimedSet?d.side1Score?(l=r||[],l[r.length-1]=d):l=(r==null?void 0:r.slice(0,r.length-1))||[]:(l=r||[],l[r.length-1]=d),l[l.length-1]&&Object.assign(l[l.length-1],{winningSide:void 0})}else _?(l=r||[],Object.assign(l[l.length-1]||{},{winningSide:void 0,side1TiebreakScore:void 0,side2TiebreakScore:void 0})):(g&&!P?l=(r==null?void 0:r.slice(0,r.length-1))||[]:(l=r,l[r.length-1]=d),g||(l[l.length-1].side2Score=0,l[l.length-1].winningSide=void 0));return{scoreString:a,sets:l}}return{scoreString:e,sets:r}}function Ta({brackets:t=Ns,scoreString:e}){if(!e)return{};const[r,n]=t.split(""),o=e.split(""),i=Math.max(...Rn(r,o)),s=Math.max(...Rn(n,o));return{isTiebreakEntry:i>s,lastOpenBracketIndex:i}}function H3({scoreString:t}){if(!t)return!1;const e=t&&t[t.length-1].trim(),r=t&&!isNaN(e),[n,o]=ki.split(""),i=t.split(""),s=Math.max(...Rn(n,i)),a=Math.max(...Rn(o,i)),l=Math.max(...Rn(vo,i));return r&&s>a&&l>s}function q3(t){return t.split("").reduce((n,o,i)=>(o.match(/\d+/g)&&n.push(i),n),[]).pop()}function t0(t){const{lowValue:e=0,NoAD:r=!1,tiebreakTo:n}=t||{},o=r?1:2;return e+1>=n?e+o:parseInt(n)}function r0({matchUpFormat:t,matchUpStatus:e,winningSide:r,sets:n}){const o=Ir(t),{bestOf:i}=o,s=Math.ceil(i/2),a=n==null?void 0:n.reduce((c,u)=>{const{winningSide:d}=u;return d&&c[d-1]++,c},[0,0]);let l=(a==null?void 0:a.indexOf(s))+1||void 0;return j3.includes(e)&&r&&(l=r),{matchUpWinningSide:l}}function n0({lowSide:t,value:e,sets:r,scoreString:n,winningSide:o,matchUpStatus:i}){let s;return e===Hy?n?(s=!0,n=ba({scoreString:n,lowSide:t,outcome:Fy}),o=t===2?1:2,i=Gy):(s=!0,n=ba({scoreString:n,lowSide:t,outcome:Ev}),o=t===2?1:2,i=$v):e===Yy?(s=!0,n=ba({scoreString:n,lowSide:t,outcome:Ev}),o=t===2?1:2,i=$v):e===Ky?(s=!0,r=[],n=Dy,o=t===2?1:2,i=Vy):e===qy&&n?(s=!0,n=ba({scoreString:n,lowSide:t,outcome:Ry}),i=ky,o=void 0):e===zy?(s=!0,n=ba({scoreString:n,lowSide:t,outcome:jy}),i=By,o=void 0):e===Qy&&n&&(s=!0,n=ba({scoreString:n,lowSide:t,outcome:xy}),i=Wy,o=void 0),{updated:s,sets:r,scoreString:n,matchUpStatus:i,winningSide:o}}function z3(t){let{sets:e,info:r,scoreString:n,winningSide:o,matchUpStatus:i}=t;const{analysis:s,lowSide:a,value:l}=t;let c,u;!(e!=null&&e.length)&&l!==Hu&&(e=[{setNumber:1}]);const d=e.length-1;if(Nv.includes(l)){const p=e[e.length-1]||{},{side1Score:v,side2Score:f}=p;v&&!f?r="missing side2Score":s.finalSetIsComplete||o?r="final set is already complete":s.isIncompleteSetScore?r="incomplete set scoreString":s.isIncompleteSetScore||({sets:e,scoreString:n,winningSide:o,matchUpStatus:i,updated:c}=n0({lowSide:a,value:l,sets:e,scoreString:n,matchUpStatus:i,winningSide:o}))}else if(l===Hu){if({scoreString:n,sets:e,outcomeRemoved:u}=Av({analysis:s,scoreString:n,sets:e}),(n==null?void 0:n.trim())===""&&(n=n.trim()),n||(e=[]),u){const p=e[e.length-1]||{},{side1Score:v,side2Score:f}=p;if(v&&f){const m=v>f&&1||f>v&&2||void 0;m&&(p.winningSide=m,e.push({setNumber:e.length+1}))}}i=void 0,o=void 0,c=!0}else if(s.hasOutcome)r="has outcome";else{if(o)return{sets:e,scoreString:n,winningSide:o,matchUpStatus:i,updated:!1,info:"matchUp is complete"};if(l===qu){const p=e[e.length-1]||{},{side1Score:v,side2Score:f}=p,m=v>f&&1||f>v&&2||void 0;m&&!o&&!s.isIncompleteSetScore&&(e[e.length-1].winningSide=m,e.push({setNumber:e.length+1}),n+=" ",c=!0)}else if(l===Us&&e[d].side1Score!==void 0&&e[d].side2Score===void 0&&n&&s.isNumericEnding)n+="-",e[d].side2Score=0,i=void 0,o=void 0,c=!0;else if(!isNaN(l)){let p;if(e[d].side2Score===void 0){const v=Oe((e[d].side1Score||0).toString()+l).toString().slice(0,2);e[d].side1Score=Oe(v),p=e[d].side1Score.toString(),c=!0}else{const v=Oe((e[d].side2Score||0).toString()+l).toString().slice(0,2);e[d].side2Score=Oe(v),p=[e[d].side1Score,e[d].side2Score].join("-"),c=!0}if(c){const v=(e.slice(0,d)||[]).filter(f=>f).map(f=>{const{side1Score:m,side2Score:g}=f;return[m,g].join("-")}).join(" ");v?n=v+" "+p:n=p}}}return{sets:e,scoreString:n,winningSide:o,matchUpStatus:i,info:r,updated:c}}function Y3({analysis:t,auto:e,lowSide:r,scoreString:n="",sets:o,value:i}){var s;let a,l;const{tiebreakSet:{tiebreakTo:c,NoAD:u}}=t.setFormat,[d]=ki.split("");if(t.isMatchTiebreakEntry||(n+=d),o[t.setNumber-1]){const{lastOpenBracketIndex:v}=Ta({brackets:ki,scoreString:n}),m=(n.slice((v??0)+1)+(e?"":i)).split(vo);if((((s=m[r-1])==null?void 0:s.length)||0)>=2)l="tiebreak digit limit";else if(e){r===1&&(m[0]=(m[0]||"")+i),r===2&&(m[1]=(m[1]||"")+i);const h=[m[0]||0,m[1]||0].map(P=>Oe(P)),_=r===1?1:0;h[_]=h[1-_]+(u?1:2),h[_]<c&&(h[_]=c);const I=o[o.length-1];I.side1TiebreakScore=h[0],I.side2TiebreakScore=h[1],n=n.slice(0,(v??0)+1),n+=h.join(vo),a=!0}else{const h=[m[0]||0,m[1]||0].map(I=>Oe(I)),_=o[o.length-1];_.side1TiebreakScore=h[0],_.side2TiebreakScore=h[1],n+=i,a=!0}}else{const v=t0({lowValue:Oe(i||0),tiebreakTo:c,NoAD:u}),f=[Oe(i),v];r===2&&f.reverse();const m={side1TiebreakScore:f[0],side2TiebreakScore:f[1],setNumber:(o==null?void 0:o.length)+1||1};o.push(m),n+=f.join(vo),a=!0}return{info:l,scoreString:n,sets:o,updated:a}}function K3({analysis:t,lowSide:e,scoreString:r,value:n}){const{setTo:o,tiebreakAt:i,NoAD:s}=(t==null?void 0:t.setFormat)||{},a=n===parseInt(i||o);if(i&&i<o&&n>i)return{scoreString:r};if(s&&n===o||n>o)return{scoreString:r};const l=m(),c=[n,l];e===2&&c.reverse();const d=Ns.split("")[0],p=c.join(Us)+(a?d:$s);r=(r||"")+p;const v={side1Score:c[0],side2Score:c[1]},f=Tv({analysis:t,set:v});return v.winningSide=f||void 0,{scoreString:r,set:v};function m(){return a?n+1:n+1===o?n+(s?1:2):o}}function Q3({matchUpFormat:t,scoreString:e,winningSide:r,value:n,sets:o}){var i,s,a;const c=(((i=o==null?void 0:o.filter(x=>x==null?void 0:x.winningSide))==null?void 0:i.length)||0)+(r?0:1),u=Ir(t),d=c===(u==null?void 0:u.bestOf),p=d&&(u==null?void 0:u.finalSetFormat)||(u==null?void 0:u.setFormat)||{},v=(p==null?void 0:p.timed)||(u==null?void 0:u.timed),f=d&&o[(u==null?void 0:u.bestOf)-1],m=f==null?void 0:f.winningSide,{isTiebreakEntry:g}=Ta({brackets:Ns,scoreString:e}),{isTiebreakEntry:h}=Ta({brackets:ki,scoreString:e}),_=g||h,I=!!p.tiebreakSet,P=(s=e==null?void 0:e[e.length-1])==null?void 0:s.trim(),y=e&&!isNaN(P),S=!_&&P===Us,O=g&&Uv.includes(P),b=h&&Uv.includes(P),w=h&&P===vo,T=e==null?void 0:e.split(""),[E]=ki.split(""),N=T&&Math.max(...Rn(E,T)),$=T&&Math.max(...Rn(vo,T)),A=T&&$>N,U=(a=o[o.length-1])==null?void 0:a.winningSide,C=(o==null?void 0:o.length)&&!U,M=Ly.find(x=>(e==null?void 0:e.indexOf(x))>=0),D=!isNaN(n),R=n===qu,j=zu.includes(n),G=e==null?void 0:e.split("").find(x=>Uv.includes(x)),W=j&&h&&!b&&(w||!H3({scoreString:e}));return{isTiebreakSetValue:I&&D,matchUpScoringFormat:u,setNumber:c,setFormat:p,matchTiebreakHasJoiner:A,isGameScoreEntry:C,isSpace:R,isCloser:j,isTiebreakCloser:j&&G&&_&&y,isDecidingSet:d,isTiebreakSet:I,isTimedSet:v,isNumericEnding:y,isNumericValue:D,hasOpener:G,hasOutcome:M,finalSet:f,finalSetIsComplete:m,lastSetIsComplete:U,isInvalidSetTiebreakValue:R&&_&&O,isInvalidMatchTiebreakValue:W,isTiebreakEntry:_,isSetTiebreakEntry:g,isMatchTiebreakEntry:h,isIncompleteSetScore:S,isIncompleteSetTiebreak:O,isIncompleteMatchTiebreak:b,isPartialMatchTiebreakValue:w}}function J3(t){let{lowSide:e=1,value:r}=t,{scoreString:n,sets:o,winningSide:i,matchUpStatus:s}=t;const{matchUpFormat:a,shiftFirst:l,auto:c=!0}=t;let u,d;const p=l&&e===2||!l&&e===1;if(!k3.includes(r))return{updated:!1,info:"invalid key"};l&&(e=3-e);const{matchUpWinningSide:v}=r0({sets:o,winningSide:i,matchUpStatus:s,matchUpFormat:a});i=v;const f=Q3({value:r,winningSide:i,scoreString:n,sets:o,matchUpFormat:a});if(Zy.includes(r)&&(r=Us),f.hasOpener&&f.isTiebreakEntry&&!f.isTiebreakSet&&p&&Oe(r)===0&&(f.isTiebreakCloser=!0),zu.includes(r)&&f.hasOpener&&(r=""),zu.includes(r)&&(r=qu),f.lastSetIsComplete){const m=(n==null?void 0:n.length)&&n[n.length-1];n&&m!==" "&&(n+=" ")}if(f.isTimedSet)({info:d,sets:o,scoreString:n,updated:u,matchUpStatus:s,winningSide:i}=z3({analysis:f,lowSide:e,scoreString:n,sets:o,matchUpStatus:s,winningSide:i,value:r}));else if(Nv.includes(r))f.finalSetIsComplete||i?d="final set is already complete":!f.isTiebreakEntry&&!f.isIncompleteSetScore?{sets:o,scoreString:n,matchUpStatus:s,winningSide:i,updated:u}=n0({lowSide:e,sets:o,scoreString:n,matchUpStatus:s,winningSide:i,value:r}):f.isTiebreakEntry||f.isIncompleteSetScore?d="incomplete set scoreString or tiebreak entry":console.log("handle case",{value:r});else if(r===Hu)u=!0,{scoreString:n,sets:o}=Av({analysis:f,scoreString:n,sets:o,lowSide:e}),n||(o=[]),s=void 0,i=void 0;else if(f.hasOutcome)d="has outcome";else if(r===Us&&!f.isMatchTiebreakEntry)(!f.isSetTiebreakEntry||f.isSetTiebreakEntry&&!f.isNumericEnding)&&(u=!0,{scoreString:n,sets:o}=Av({analysis:f,scoreString:n,sets:o,lowSide:e}),s=void 0);else if(r===vo&&f.isMatchTiebreakEntry&&!f.isSetTiebreakEntry)f.matchTiebreakHasJoiner?d="existing joiner":f.isNumericEnding&&(u=!0,n+=vo);else if([Us,vo].includes(r))d="invalid location for joiner";else{if(i)return{updated:!1,info:"matchUp is complete"};if(f.isIncompleteSetScore)f.isNumericValue&&({sets:o,scoreString:n,updated:u}=G3({analysis:f,scoreString:n,sets:o,value:r}));else if(f.isInvalidMatchTiebreakValue)d="invalid matchUp tiebreak character";else if(f.isInvalidSetTiebreakValue)d="invalid set tiebreak character";else if(f.isTiebreakCloser){const m=f.isSetTiebreakEntry?Ns:ki,g=m.split("").reverse()[0],h=m.split("")[0],_=o[o.length-1],{tiebreakFormat:I}=f.setFormat,{tiebreakTo:P,NoAD:y}=I||{},S=wv({set:_});if(!f.isTiebreakSet){const b=parseInt(n.split(h).reverse()[0]),w=t0({lowValue:b,tiebreakTo:P,NoAD:y});S===1?(_.side1TiebreakScore=w,_.side2TiebreakScore=b):(_.side1TiebreakScore=b,_.side2TiebreakScore=w)}n=(n||"")+g,f.isDecidingSet||(n+=$s);const O=Tv({analysis:f,set:_});_.winningSide=O||void 0,u=!0}else if(f.isTiebreakSetValue)({info:d,scoreString:n,sets:o,updated:u}=Y3({analysis:f,auto:c,lowSide:e,scoreString:n,sets:o,value:r}));else if(f.isSetTiebreakEntry){const[m]=Ns.split(""),g=Math.max(...Rn(m,n.split(""))),h=n.slice(g+1),_=h&&Oe(h)===L3,I=Oe(h?h+r:r),{tiebreakFormat:P}=f.setFormat,{tiebreakTo:y,NoAD:S}=P||{};!_&&h.length<2?S&&I>y-1?d="invalid low value for NoAD tiebreak":(u=!0,n=(n||"")+r):d=_?"tiebreak begins with zero":"tiebreak digit limit"}else if(f.isCloser)d=`invalid key: ${r}`;else if(f.isGameScoreEntry)d="game scoreString entry";else if(f.lastSetIsComplete||!o.length){u=!0;const{scoreString:m,set:g}=K3({analysis:f,lowSide:e,scoreString:n,value:Oe(r)});g&&(g.setNumber=(o==null?void 0:o.length)+1||1),o=(o==null?void 0:o.concat(g).filter(Boolean))||[g],n=m||void 0}else console.log("error: unknown outcome")}if(u){o=o==null?void 0:o.filter(Boolean);const{matchUpWinningSide:m}=r0({sets:o,winningSide:i,matchUpStatus:s,matchUpFormat:a});return i=m,m&&(!s||[Rt,ao].includes(s))?(s=M3,o=o.filter(g=>{const{side1Score:h,side2Score:_,side1TiebreakScore:I,side2TiebreakScore:P}=g;return h||_||I||P})):n&&!i&&![ky,By,Wy].includes(s)&&(s=void 0),{updated:u,scoreString:n,sets:o,winningSide:i,matchUpStatus:s,info:d}}return{updated:u,scoreString:n,sets:o,winningSide:i,matchUpStatus:s,info:d}}function Z3({matchUpScoringFormat:t,isDecidingSet:e,isTiebreakSet:r,setObject:n}){if(!n)return;const o=o0({set:n});return X3({matchUpScoringFormat:t,isDecidingSet:e,isTiebreakSet:r,set:n})&&o||void 0}function X3({ignoreTiebreak:t=!1,matchUpScoringFormat:e,matchUpFormat:r,isTiebreakSet:n,isDecidingSet:o,set:i}){if(!i)return{error:_e,info:"missing set"};e=e||r&&Ir(r);const s=o&&e.finalSetFormat||(e==null?void 0:e.setFormat)||{},{side1Score:a,side2Score:l}=i,{setTo:c,tiebreakAt:u,tiebreakFormat:d}=s,p=d==null?void 0:d.NoAd,v=o0({set:i}),f=Math.abs(a-l),m=a>=c||l>=c,g=n||a>=c&&l>=c||u&&u<c&&(a===u||l===u),h=t||g&&(v===1&&i.side1TiebreakScore>i.side2TiebreakScore||v===2&&i.side2TiebreakScore>i.side1TiebreakScore),I=f>=(g&&(u&&!n||n&&p)?1:2);return(m&&(I||g)||n)&&(!g||h)}function o0({set:t}){if(t.side1Score||t.side2Score){if(t.side1Score>t.side2Score)return 1;if(t.side2Score>t.side1Score)return 2}else if(t.side1TiebreakScore||t.side2TiebreakScore){if(t.side1TiebreakScore>t.side2TiebreakScore)return 1;if(t.side2TiebreakScore>t.side1TiebreakScore)return 2}}function Yu(t){const{setObject:e,matchUpScoringFormat:r}=t;if(!e)return{error:sf};const{setNumber:n}=e||{},{bestOf:o}=r||{},i=!!(n&&o&&n===o),s=i&&(r==null?void 0:r.finalSetFormat)||(r==null?void 0:r.setFormat),a=!!(s!=null&&s.tiebreakSet),l=!!(s!=null&&s.timed),c=!a&&!l,u=!!(n&&o&&n<=o),d=[e==null?void 0:e.side1Score,e==null?void 0:e.side2Score],p=[e==null?void 0:e.side1PointScore,e==null?void 0:e.side2PointScore],v=[e==null?void 0:e.side1TiebreakScore,e==null?void 0:e.side2TiebreakScore],f=d.filter(C=>C!==void 0).length,m=p.filter(C=>C!==void 0).length,g=v.filter(C=>C!==void 0).length,h=d==null?void 0:d.filter(C=>!isNaN(C)).length,_=v==null?void 0:v.filter(C=>!isNaN(C)).length,{tiebreakAt:I}=s||{},P=I&&d.filter(C=>C>=I).length===2,y=P&&(d[0]>d[1]&&1||d[1]>d[0]&&2||void 0),S=!!(_&&!h),O=!!(e!=null&&e.winningSide),{error:b,result:w}=eW({setObject:e,setFormat:s,sideGameScores:d,sideTiebreakScores:v}),{error:T,result:E}=tW({setObject:e,setFormat:s,sideTiebreakScores:v}),N=c&&!S&&w||a&&S&&E,$=u&&!(a&&!S)&&!(c&&S)&&(!O||N),A=Z3({isDecidingSet:i,isTiebreakSet:S,matchUpScoringFormat:r,setObject:e}),U={expectTiebreakSet:a,expectTimedSet:l,hasTiebreakCondition:P,isCompletedSet:O,isDecidingSet:i,isTiebreakSet:S,isValidSet:$,isValidSetNumber:u,isValidSetOutcome:N,leadingSide:y,setFormat:s,sideGameScores:d,sideGameScoresCount:f,sidePointScores:p,sidePointScoresCount:m,sideTiebreakScores:v,sideTiebreakScoresCount:g,winningSide:A};return(e==null?void 0:e.winningSide)!==void 0&&(S?(U.isValidTiebreakSetOutcome=E,E||(U.tiebreakSetError=T)):(U.isValidStandardSetOutcome=w,w||(U.standardSetError=b))),U}function eW({setObject:t,setFormat:e,sideGameScores:r,sideTiebreakScores:n}){if(!t)return{result:!1,error:sf};const o=!!(e!=null&&e.tiebreakSet),i=!!(e!=null&&e.timed);if(!e||o||i)return{result:!1,error:X};if(!((r==null?void 0:r.filter(E=>!isNaN(E)).length)===2))return{result:!1,error:o_};const{setTo:a,tiebreakAt:l,tiebreakFormat:c,NoAD:u}=e||{};if(!!!(a&&(r!=null&&r.find(E=>E>=a))))return{result:!1,error:o_};const p=[1,2].includes(t==null?void 0:t.winningSide);if(!t||!p)return{result:!1,error:i_};const v=(t==null?void 0:t.winningSide)-1,f=1-v,m=r[v],g=r[f],h=m-g;if(!(m>g))return{result:!1,error:{message:"winningSide game scoreString is not high"}};const I=l&&c,P=(n==null?void 0:n.filter(E=>!isNaN(E)).length)===2,y=n==null?void 0:n[v],S=n==null?void 0:n[f],O=l&&r.filter(E=>E>=l).length===2;if(I){const{NoAD:E,tiebreakTo:N}=c;if(O){if(h>1)return{result:!1,error:{message:"invalid winning game scoreString (5)"}};if(!P)return{result:!1,error:{message:"invalid tiebreak scores (1)"}};if(isNaN(N))return{result:!1,error:{message:"tiebreakTo error"}};if(!!!(N&&(n!=null&&n.find(j=>j>=N))))return{result:!1,error:{message:"invalid tiebreak scores (2)"}};const U=l<a?a:a+1;if(m>U)return{result:!1,error:{message:"invalid winning game scoreString (1)"}};if(!y||!S||y<S)return{result:!1,error:{message:"winningSide tiebreak value is not high"}};const C=E?1:2,M=y-S,D=S>=N-1;if(M&&D&&M<C)return{result:!1,error:{message:"invalid tiebreak scores (3)"}}}if(m>a&&!O)return{result:!1,error:{message:"invalid winning game scoreString (2)"}}}const b=u?1:2,w=g>=a-1;return h&&w&&!O&&h<b?{result:!1,error:{message:"invalid winning game scoreString (3)"}}:h>b&&m>a?{result:!1,error:{message:"invalid winning game scoreString (4)"}}:{result:!0}}function tW({setObject:t,setFormat:e,sideTiebreakScores:r}){if(!t)return{result:!1,error:sf};const n=!!(e!=null&&e.tiebreakSet),o=!!(e!=null&&e.timed);if(!e||!n||o)return{result:!1,error:{message:"not tiebreak set"}};const i=[1,2].includes(t==null?void 0:t.winningSide);if(!t||!i)return{result:!1,error:i_};const{tiebreakSet:s}=e||{},{NoAD:a,tiebreakTo:l}=s||{};if(!((r==null?void 0:r.filter(I=>!isNaN(I)).length)===2))return{result:!1,error:{message:"invalid tiebreak scores (1)"}};if(isNaN(l))return{result:!1,error:{message:"tiebreakTo error"}};if(!!!(r!=null&&r.find(I=>I>=l)))return{result:!1,error:{message:"invalid tiebreak scores (2)"}};const d=(t==null?void 0:t.winningSide)-1,p=1-d,v=r[d],f=r[p];if(!v||!f||v<f)return{result:!1,error:{message:"winningSide tiebreak value is not high"}};const m=a?1:2,g=v-f,h=f>=l-1;return g&&h&&g<m?{result:!1,error:{message:"invalid tiebreak scores (3)"}}:{result:!0}}var rW=Object.defineProperty,i0=Object.getOwnPropertySymbols,nW=Object.prototype.hasOwnProperty,oW=Object.prototype.propertyIsEnumerable,s0=(t,e,r)=>e in t?rW(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,iW=(t,e)=>{for(var r in e||(e={}))nW.call(e,r)&&s0(t,r,e[r]);if(i0)for(var r of i0(e))oW.call(e,r)&&s0(t,r,e[r]);return t};function sW(t){if(!(t!=null&&t.score))return{error:_e};const{sets:e}=t.score,r=e.map(i=>{const{side1TiebreakScore:s,side2TiebreakScore:a,winningSide:l,side1Score:c,side2Score:u,setNumber:d}=i;return ye({winningSide:l?3-l:void 0,side1TiebreakScore:a,side2TiebreakScore:s,side1Score:u,side2Score:c,setNumber:d})}),n=fo({sets:r}),o=fo({sets:r,reversed:!0});return iW({reversedScore:{sets:r,scoreStringSide1:n,scoreStringSide2:o}},V)}const a0=t=>{const{isSide1:e,lowValue:r,setTo:n,tiebreakAt:o,NoAD:i}=t;if(r===void 0)return!1;let s=Oe(r);(s==null?void 0:s.toString().length)>2&&(s=parseInt(s.toString().slice(0,2))),o&&o<n&&s>o&&(s=o);let a;return i&&!o?a=s<n?n:n-1:a=s+1<n&&n||o&&o<n&&s===o&&n||!o&&s+2||n+1,[e?s:a,e?a:s]},Cv=t=>{const{isSide1:e,lowValue:r,tiebreakTo:n,tiebreakNoAd:o}=t;if(r===void 0)return!1;let i=typeof r=="string"?parseInt(r):r;(i==null?void 0:i.toString().length)>2&&(i=parseInt(i.toString().slice(0,2))),o&&i>n-1&&(i=n-1);const s=aW({lowValue:i,NoAD:o,tiebreakTo:n});return[e?i:s,e?s:i]};function aW(t){const{lowValue:e,NoAD:r,tiebreakTo:n}=t,o=r?1:2;return e+1>=n?e+o:n}const l0={stringifyMatchUpFormat:Kp,isValidMatchUpFormat:en,parseMatchUpFormat:Ir,generateTieMatchUpScore:rc,getTiebreakComplement:Cv,updateTieMatchUpScore:po,generateScoreString:fo,checkSetIsComplete:My,validateTieFormat:Or,getSetComplement:a0,scoreHasValue:Gt,keyValueScore:J3,validateScore:bv,reverseScore:sW,analyzeSet:Yu};function c0(t){return t&&typeof String.fromCodePoint<"u"?t.toUpperCase().replace(/./g,e=>String.fromCodePoint(e.charCodeAt(0)+127397)):t}function lW(t){const e=Object.assign({},...li.filter(r=>r.ioc).map(r=>({[r.ioc]:r.iso})));return c0(e[t])}const li=[{ioc:"",iso2:"",iso:"",label:"NONE",phone:""},{ioc:"AND",iso2:"AD",iso:"AND",label:"Andorra",phone:"376"},{ioc:"UAE",iso2:"AE",iso:"ARE",label:"United Arab Emirates",phone:"971"},{ioc:"AFG",iso2:"AF",iso:"AFG",label:"Afghanistan",phone:"93"},{ioc:"ANT",iso2:"AG",iso:"ATG",label:"Antigua and Barbuda",phone:"1-268"},{ioc:"AIA",iso2:"AI",iso:"AIA",label:"Anguilla",phone:"1-264"},{ioc:"ALB",iso2:"AL",iso:"ALB",label:"Albania",phone:"355"},{ioc:"ARM",iso2:"AM",iso:"ARM",label:"Armenia",phone:"374"},{ioc:"ANG",iso2:"AO",iso:"AGO",label:"Angola",phone:"244"},{ioc:"",iso2:"AQ",iso:"ATA",label:"Antarctica",phone:"672"},{ioc:"ARG",iso2:"AR",iso:"ARG",label:"Argentina",phone:"54"},{ioc:"ASA",iso2:"AS",iso:"ASM",label:"American Samoa",phone:"1-684"},{ioc:"AUT",iso2:"AT",iso:"AUT",label:"Austria",phone:"43"},{ioc:"AUS",iso2:"AU",iso:"AUS",label:"Australia",phone:"61",suggested:!0},{ioc:"ARU",iso2:"AW",iso:"ABW",label:"Aruba",phone:"297"},{ioc:"AZE",iso2:"AZ",iso:"AZE",label:"Azerbaijan",phone:"994"},{ioc:"BIH",iso2:"BA",iso:"BIH",label:"Bosnia and Herzegovina",phone:"387"},{ioc:"BAR",iso2:"BB",iso:"BRB",label:"Barbados",phone:"1-246"},{ioc:"BAN",iso2:"BD",iso:"BGD",label:"Bangladesh",phone:"880"},{ioc:"BEL",iso2:"BE",iso:"BEL",label:"Belgium",phone:"32"},{ioc:"BUR",iso2:"BF",iso:"BFA",label:"Burkina Faso",phone:"226"},{ioc:"BUL",iso2:"BG",iso:"BGR",label:"Bulgaria",phone:"359"},{ioc:"BRN",iso2:"BH",iso:"BHR",label:"Bahrain",phone:"973"},{ioc:"BDI",iso2:"BI",iso:"BDI",label:"Burundi",phone:"257"},{ioc:"BEN",iso2:"BJ",iso:"BEN",label:"Benin",phone:"229"},{ioc:"",iso2:"BL",iso:"BLM",label:"Saint Barthelemy",phone:"590"},{ioc:"BER",iso2:"BM",iso:"BMU",label:"Bermuda",phone:"1-441"},{ioc:"BRU",iso2:"BN",iso:"BRN",label:"Brunei Darussalam",phone:"673"},{ioc:"BOL",iso2:"BO",iso:"BOL",label:"Bolivia",phone:"591"},{ioc:"BRA",iso2:"BR",iso:"BRA",label:"Brazil",phone:"55"},{ioc:"BAH",iso2:"BS",iso:"BHS",label:"Bahamas",phone:"1-242"},{ioc:"BHU",iso2:"BT",iso:"BTN",label:"Bhutan",phone:"975"},{ioc:"",iso2:"BV",iso:"BVT",label:"Bouvet Island",phone:"47"},{ioc:"BOT",iso2:"BW",iso:"BWA",label:"Botswana",phone:"267"},{ioc:"BLR",iso2:"BY",iso:"BLR",label:"Belarus",phone:"375"},{ioc:"BIZ",iso2:"BZ",iso:"BLZ",label:"Belize",phone:"501"},{ioc:"CAN",iso2:"CA",iso:"CAN",label:"Canada",phone:"1",suggested:!0},{ioc:"",iso2:"CC",iso:"CCK",label:"Cocos (Keeling) Islands",phone:"61"},{ioc:"CGO",iso2:"CD",iso:"COG",label:"Congo, Republic of the",phone:"242"},{ioc:"CAF",iso2:"CF",iso:"CAF",label:"Central African Republic",phone:"236"},{ioc:"COD",iso2:"CG",iso:"CGD",label:"Congo, Democratic Republic of the",phone:"243"},{ioc:"SUI",iso2:"CH",iso:"CHE",label:"Switzerland",phone:"41"},{ioc:"CIV",iso2:"CI",iso:"CIV",label:"Cote d'Ivoire",phone:"225"},{ioc:"COK",iso2:"CK",iso:"COK",label:"Cook Islands",phone:"682"},{ioc:"CHI",iso2:"CL",iso:"CHL",label:"Chile",phone:"56"},{ioc:"CMR",iso2:"CM",iso:"CMR",label:"Cameroon",phone:"237"},{ioc:"CHN",iso2:"CN",iso:"CHN",label:"China",phone:"86"},{ioc:"COL",iso2:"CO",iso:"COL",label:"Colombia",phone:"57"},{ioc:"CRC",iso2:"CR",iso:"CRI",label:"Costa Rica",phone:"506"},{ioc:"CUB",iso2:"CU",iso:"CUB",label:"Cuba",phone:"53"},{ioc:"CPV",iso2:"CV",iso:"CPV",label:"Cape Verde",phone:"238"},{ioc:"CUW",iso2:"CW",iso:"CUW",label:"Curacao",phone:"599"},{ioc:"CXR",iso2:"CX",iso:"CXR",label:"Christmas Island",phone:"61"},{ioc:"CYP",iso2:"CY",iso:"CYP",label:"Cyprus",phone:"357"},{ioc:"CZE",iso2:"CZ",iso:"CZE",label:"Czech Republic",phone:"420"},{ioc:"GER",iso2:"DE",iso:"DEU",label:"Germany",phone:"49",suggested:!0},{ioc:"DJI",iso2:"DJ",iso:"DJI",label:"Djibouti",phone:"253"},{ioc:"DEN",iso2:"DK",iso:"DNK",label:"Denmark",phone:"45"},{ioc:"DMA",iso2:"DM",iso:"DMA",label:"Dominica",phone:"1-767"},{ioc:"DOM",iso2:"DO",iso:"DOM",label:"Dominican Republic",phone:"1-809"},{ioc:"ALG",iso2:"DZ",iso:"DZA",label:"Algeria",phone:"213"},{ioc:"ECU",iso2:"EC",iso:"ECU",label:"Ecuador",phone:"593"},{ioc:"EST",iso2:"EE",iso:"ESE",label:"Estonia",phone:"372"},{ioc:"EGY",iso2:"EG",iso:"EGY",label:"Egypt",phone:"20"},{ioc:"",iso2:"EH",iso:"ESH",label:"Western Sahara",phone:"212"},{ioc:"ERI",iso2:"ER",iso:"ERI",label:"Eritrea",phone:"291"},{ioc:"ESP",iso2:"ES",iso:"ESP",label:"Spain",phone:"34"},{ioc:"ETH",iso2:"ET",iso:"ETH",label:"Ethiopia",phone:"251"},{ioc:"FIN",iso2:"FI",iso:"FIN",label:"Finland",phone:"358"},{ioc:"FIJ",iso2:"FJ",iso:"FJI",label:"Fiji",phone:"679"},{ioc:"FLK",iso2:"FK",iso:"FLK",label:"Falkland Islands (Malvinas)",phone:"500"},{ioc:"FSM",iso2:"FM",iso:"FSM",label:"Micronesia, Federated States of",phone:"691"},{ioc:"FAR",iso2:"FO",iso:"FRO",label:"Faroe Islands",phone:"298"},{ioc:"FRA",iso2:"FR",iso:"FRA",label:"France",phone:"33",suggested:!0},{ioc:"GAB",iso2:"GA",iso:"GAB",label:"Gabon",phone:"241"},{ioc:"GBR",iso2:"GB",iso:"GBR",label:"United Kingdom",phone:"44"},{ioc:"GRN",iso2:"GD",iso:"GRD",label:"Grenada",phone:"1-473"},{ioc:"GEO",iso2:"GE",iso:"GEO",label:"Georgia",phone:"995"},{ioc:"FGU",iso2:"GF",iso:"GUF",label:"French Guiana",phone:"594"},{ioc:"",iso2:"GG",iso:"GGY",label:"Guernsey",phone:"44"},{ioc:"",iso2:"GH",iso:"GHA",label:"Ghana",phone:"233"},{ioc:"GIB",iso2:"GI",iso:"GIB",label:"Gibraltar",phone:"350"},{ioc:"GRL",iso2:"GL",iso:"GRL",label:"Greenland",phone:"299"},{ioc:"GAM",iso2:"GM",iso:"GMB",label:"Gambia",phone:"220"},{ioc:"GUI",iso2:"GN",iso:"GIN",label:"Guinea",phone:"224"},{ioc:"GUD",iso2:"GP",iso:"GLP",label:"Guadeloupe",phone:"590"},{ioc:"GEQ",iso2:"GQ",iso:"GNQ",label:"Equatorial Guinea",phone:"240"},{ioc:"GRE",iso2:"GR",iso:"GRC",label:"Greece",phone:"30"},{ioc:"",iso2:"GS",iso:"SGS",label:"South Georgia and the South Sandwich Islands",phone:"500"},{ioc:"GUA",iso2:"GT",iso:"GTM",label:"Guatemala",phone:"502"},{ioc:"GUM",iso2:"GU",iso:"GUM",label:"Guam",phone:"1-671"},{ioc:"GBS",iso2:"GW",iso:"GNB",label:"Guinea-Bissau",phone:"245"},{ioc:"GUY",iso2:"GY",iso:"GUY",label:"Guyana",phone:"592"},{ioc:"HKG",iso2:"HK",iso:"HKG",label:"Hong Kong",phone:"852"},{ioc:"",iso2:"HM",iso:"HMD",label:"Heard Island and McDonald Islands",phone:"672"},{ioc:"HON",iso2:"HN",iso:"HND",label:"Honduras",phone:"504"},{ioc:"CRO",iso2:"HR",iso:"HRV",label:"Croatia",phone:"385"},{ioc:"HAI",iso2:"HT",iso:"HTI",label:"Haiti",phone:"509"},{ioc:"HUN",iso2:"HU",iso:"HUN",label:"Hungary",phone:"36"},{ioc:"INA",iso2:"ID",iso:"IDN",label:"Indonesia",phone:"62"},{ioc:"IRL",iso2:"IE",iso:"IRL",label:"Ireland",phone:"353"},{ioc:"ISR",iso2:"IL",iso:"ISR",label:"Israel",phone:"972"},{ioc:"",iso2:"IM",iso:"IMN",label:"Isle of Man",phone:"44"},{ioc:"IND",iso2:"IN",iso:"IND",label:"India",phone:"91"},{ioc:"",iso2:"IO",iso:"IOT",label:"British Indian Ocean Territory",phone:"246"},{ioc:"IRQ",iso2:"IQ",iso:"IRQ",label:"Iraq",phone:"964"},{ioc:"IRI",iso2:"IR",iso:"IRN",label:"Iran, Islamic Republic of",phone:"98"},{ioc:"ISL",iso2:"IS",iso:"ISL",label:"Iceland",phone:"354"},{ioc:"ITA",iso2:"IT",iso:"ITA",label:"Italy",phone:"39"},{ioc:"",iso2:"JE",iso:"JEY",label:"Jersey",phone:"44"},{ioc:"JAM",iso2:"JM",iso:"JAM",label:"Jamaica",phone:"1-876"},{ioc:"JOR",iso2:"JO",iso:"JOR",label:"Jordan",phone:"962"},{ioc:"JPN",iso2:"JP",iso:"JPN",label:"Japan",phone:"81",suggested:!0},{ioc:"KEN",iso2:"KE",iso:"KEN",label:"Kenya",phone:"254"},{ioc:"KGZ",iso2:"KG",iso:"KGZ",label:"Kyrgyzstan",phone:"996"},{ioc:"CAM",iso2:"KH",iso:"KHM",label:"Cambodia",phone:"855"},{ioc:"KIR",iso2:"KI",iso:"KIR",label:"Kiribati",phone:"686"},{ioc:"COM",iso2:"KM",iso:"COM",label:"Comoros",phone:"269"},{ioc:"SKN",iso2:"KN",iso:"KNA",label:"Saint Kitts and Nevis",phone:"1-869"},{ioc:"KOR",iso2:"KP",iso:"KOR",label:"Korea, Democratic People's Republic of",phone:"850"},{ioc:"PRK",iso2:"KR",iso:"PRK",label:"Korea, Republic of",phone:"82"},{ioc:"KUW",iso2:"KW",iso:"KWT",label:"Kuwait",phone:"965"},{ioc:"CAY",iso2:"KY",iso:"CYM",label:"Cayman Islands",phone:"1-345"},{ioc:"KAZ",iso2:"KZ",iso:"KAZ",label:"Kazakhstan",phone:"7"},{ioc:"LAO",iso2:"LA",iso:"LAO",label:"Lao People's Democratic Republic",phone:"856"},{ioc:"LIB",iso2:"LB",iso:"LBN",label:"Lebanon",phone:"961"},{ioc:"LCA",iso2:"LC",iso:"LCA",label:"Saint Lucia",phone:"1-758"},{ioc:"LIE",iso2:"LI",iso:"LIE",label:"Liechtenstein",phone:"423"},{ioc:"SRI",iso2:"LK",iso:"LKA",label:"Sri Lanka",phone:"94"},{ioc:"LBR",iso2:"LR",iso:"LBR",label:"Liberia",phone:"231"},{ioc:"LES",iso2:"LS",iso:"LSO",label:"Lesotho",phone:"266"},{ioc:"LTU",iso2:"LT",iso:"LTU",label:"Lithuania",phone:"370"},{ioc:"LUX",iso2:"LU",iso:"LUX",label:"Luxembourg",phone:"352"},{ioc:"LAT",iso2:"LV",iso:"LVA",label:"Latvia",phone:"371"},{ioc:"LBA",iso2:"LY",iso:"LBY",label:"Libya",phone:"218"},{ioc:"MAR",iso2:"MA",iso:"MAR",label:"Morocco",phone:"212"},{ioc:"MON",iso2:"MC",iso:"MCO",label:"Monaco",phone:"377"},{ioc:"MDA",iso2:"MD",iso:"MDA",label:"Moldova, Republic of",phone:"373"},{ioc:"MNE",iso2:"ME",iso:"MNE",label:"Montenegro",phone:"382"},{ioc:"",iso2:"MF",iso:"MAF",label:"Saint Martin (French part)",phone:"590"},{ioc:"MAD",iso2:"MG",iso:"MDG",label:"Madagascar",phone:"261"},{ioc:"MSH",iso2:"MH",iso:"MHL",label:"Marshall Islands",phone:"692"},{ioc:"MKD",iso2:"MK",iso:"MKD",label:"Macedonia, the Former Yugoslav Republic of",phone:"389"},{ioc:"MLI",iso2:"ML",iso:"MLI",label:"Mali",phone:"223"},{ioc:"MYA",iso2:"MM",iso:"MMR",label:"Myanmar",phone:"95"},{ioc:"MGL",iso2:"MN",iso:"MNG",label:"Mongolia",phone:"976"},{ioc:"MAC",iso2:"MO",iso:"MAC",label:"Macao",phone:"853"},{ioc:"NMA",iso2:"MP",iso:"NMP",label:"Northern Mariana Islands",phone:"1-670"},{ioc:"MRT",iso2:"MQ",iso:"MTQ",label:"Martinique",phone:"596"},{ioc:"MTN",iso2:"MR",iso:"MRT",label:"Mauritania",phone:"222"},{ioc:"MNT",iso2:"MS",iso:"MSR",label:"Montserrat",phone:"1-664"},{ioc:"MLT",iso2:"MT",iso:"MLT",label:"Malta",phone:"356"},{ioc:"MRI",iso2:"MU",iso:"MUS",label:"Mauritius",phone:"230"},{ioc:"MDV",iso2:"MV",iso:"MDV",label:"Maldives",phone:"960"},{ioc:"MAW",iso2:"MW",iso:"MWI",label:"Malawi",phone:"265"},{ioc:"MEX",iso2:"MX",iso:"MEX",label:"Mexico",phone:"52"},{ioc:"MAS",iso2:"MY",iso:"MYS",label:"Malaysia",phone:"60"},{ioc:"MOZ",iso2:"MZ",iso:"MOZ",label:"Mozambique",phone:"258"},{ioc:"NAM",iso2:"NA",iso:"NAM",label:"Namibia",phone:"264"},{ioc:"NCL",iso2:"NC",iso:"NCL",label:"New Caledonia",phone:"687"},{ioc:"NIG",iso2:"NE",iso:"NER",label:"Niger",phone:"227"},{ioc:"NFI",iso2:"NF",iso:"NFK",label:"Norfolk Island",phone:"672"},{ioc:"NGR",iso2:"NG",iso:"NGA",label:"Nigeria",phone:"234"},{ioc:"NCA",iso2:"NI",iso:"NIC",label:"Nicaragua",phone:"505"},{ioc:"NED",iso2:"NL",iso:"NLD",label:"Netherlands",phone:"31"},{ioc:"NOR",iso2:"NO",iso:"NOR",label:"Norway",phone:"47"},{ioc:"NEP",iso2:"NP",iso:"NPL",label:"Nepal",phone:"977"},{ioc:"NRU",iso2:"NR",iso:"NRU",label:"Nauru",phone:"674"},{ioc:"NIU",iso2:"NU",iso:"NIU",label:"Niue",phone:"683"},{ioc:"NZL",iso2:"NZ",iso:"NZL",label:"New Zealand",phone:"64"},{ioc:"OMA",iso2:"OM",iso:"OMN",label:"Oman",phone:"968"},{ioc:"PAN",iso2:"PA",iso:"PAN",label:"Panama",phone:"507"},{ioc:"PER",iso2:"PE",iso:"PER",label:"Peru",phone:"51"},{ioc:"FPO",iso2:"PF",iso:"PYF",label:"French Polynesia",phone:"689"},{ioc:"PNG",iso2:"PG",iso:"PNG",label:"Papua New Guinea",phone:"675"},{ioc:"PHI",iso2:"PH",iso:"PHL",label:"Philippines",phone:"63"},{ioc:"PAK",iso2:"PK",iso:"PAK",label:"Pakistan",phone:"92"},{ioc:"POL",iso2:"PL",iso:"POL",label:"Poland",phone:"48"},{ioc:"SPM",iso2:"PM",iso:"SPM",label:"Saint Pierre and Miquelon",phone:"508"},{ioc:"",iso2:"PN",iso:"PCN",label:"Pitcairn",phone:"870"},{ioc:"PUR",iso2:"PR",iso:"PRI",label:"Puerto Rico",phone:"1"},{ioc:"PLE",iso2:"PS",iso:"PSE",label:"Palestine, State of",phone:"970"},{ioc:"POR",iso2:"PT",iso:"PRT",label:"Portugal",phone:"351"},{ioc:"PLW",iso2:"PW",iso:"PLW",label:"Palau",phone:"680"},{ioc:"PAR",iso2:"PY",iso:"PRY",label:"Paraguay",phone:"595"},{ioc:"QAT",iso2:"QA",iso:"QAT",label:"Qatar",phone:"974"},{ioc:"REU",iso2:"RE",iso:"REU",label:"Reunion",phone:"262"},{ioc:"ROU",iso2:"RO",iso:"ROU",label:"Romania",phone:"40"},{ioc:"SRB",iso2:"RS",iso:"SRB",label:"Serbia",phone:"381"},{ioc:"RUS",iso2:"RU",iso:"RUS",label:"Russia",phone:"7"},{ioc:"RWA",iso2:"RW",iso:"RWA",label:"Rwanda",phone:"250"},{ioc:"KSA",iso2:"SA",iso:"SAU",label:"Saudi Arabia",phone:"966"},{ioc:"SOL",iso2:"SB",iso:"SLB",label:"Solomon Islands",phone:"677"},{ioc:"SEY",iso2:"SC",iso:"SYC",label:"Seychelles",phone:"248"},{ioc:"SUD",iso2:"SD",iso:"SDN",label:"Sudan",phone:"249"},{ioc:"SWE",iso2:"SE",iso:"SWE",label:"Sweden",phone:"46"},{ioc:"SIN",iso2:"SG",iso:"SGP",label:"Singapore",phone:"65"},{ioc:"HEL",iso2:"SH",iso:"SHN",label:"Saint Helena",phone:"290"},{ioc:"SLO",iso2:"SI",iso:"SVN",label:"Slovenia",phone:"386"},{ioc:"",iso2:"SJ",iso:"SJM",label:"Svalbard and Jan Mayen",phone:"47"},{ioc:"SVK",iso2:"SK",iso:"SVK",label:"Slovakia",phone:"421"},{ioc:"SLE",iso2:"SL",iso:"SLE",label:"Sierra Leone",phone:"232"},{ioc:"SMR",iso2:"SM",iso:"SMR",label:"San Marino",phone:"378"},{ioc:"SEN",iso2:"SN",iso:"SEN",label:"Senegal",phone:"221"},{ioc:"SOM",iso2:"SO",iso:"SOM",label:"Somalia",phone:"252"},{ioc:"SUR",iso2:"SR",iso:"SUR",label:"Suriname",phone:"597"},{ioc:"",iso2:"SS",iso:"SSD",label:"South Sudan",phone:"211"},{ioc:"STP",iso2:"ST",iso:"STP",label:"Sao Tome and Principe",phone:"239"},{ioc:"ESA",iso2:"SV",iso:"SLV",label:"El Salvador",phone:"503"},{ioc:"",iso2:"SX",iso:"SMX",label:"Sint Maarten",phone:"1-721"},{ioc:"SYR",iso2:"SY",iso:"SYR",label:"Syria",phone:"963"},{ioc:"",iso2:"SZ",iso:"SWZ",label:"Swaziland",phone:"268"},{ioc:"TKS",iso2:"TC",iso:"TCA",label:"Turks and Caicos Islands",phone:"1-649"},{ioc:"CHA",iso2:"TD",iso:"TCD",label:"Chad",phone:"235"},{ioc:"",iso2:"TF",iso:"ATF",label:"French Southern Territories",phone:"262"},{ioc:"TOG",iso2:"TG",iso:"TGO",label:"Togo",phone:"228"},{ioc:"THA",iso2:"TH",iso:"THA",label:"Thailand",phone:"66"},{ioc:"TJK",iso2:"TJ",iso:"TJK",label:"Tajikistan",phone:"992"},{ioc:"",iso2:"TK",iso:"TKL",label:"Tokelau",phone:"690"},{ioc:"TLS",iso2:"TL",iso:"TLS",label:"Timor-Leste",phone:"670"},{ioc:"TKM",iso2:"TM",iso:"TKM",label:"Turkmenistan",phone:"993"},{ioc:"TUN",iso2:"TN",iso:"TUN",label:"Tunisia",phone:"216"},{ioc:"TGA",iso2:"TO",iso:"TON",label:"Tonga",phone:"676"},{ioc:"TUR",iso2:"TR",iso:"TUR",label:"Turkey",phone:"90"},{ioc:"TTO",iso2:"TT",iso:"TTO",label:"Trinidad and Tobago",phone:"1-868"},{ioc:"TUV",iso2:"TV",iso:"TUV",label:"Tuvalu",phone:"688"},{ioc:"TPE",iso2:"TW",iso:"TWN",label:"Taiwan",phone:"886"},{ioc:"TAN",iso2:"TZ",iso:"TZA",label:"United Republic of Tanzania",phone:"255"},{ioc:"UKR",iso2:"UA",iso:"UKR",label:"Ukraine",phone:"380"},{ioc:"UGA",iso2:"UG",iso:"UGA",label:"Uganda",phone:"256"},{ioc:"USA",iso2:"US",label:"United States",phone:"1",suggested:!0,iso:"USA"},{ioc:"URU",iso2:"UY",iso:"URY",label:"Uruguay",phone:"598"},{ioc:"UZB",iso2:"UZ",iso:"UZB",label:"Uzbekistan",phone:"998"},{ioc:"",iso2:"VA",iso:"VAT",label:"Holy See (Vatican City State)",phone:"379"},{ioc:"VIN",iso2:"VC",iso:"VCT",label:"Saint Vincent and the Grenadines",phone:"1-784"},{ioc:"VEN",iso2:"VE",iso:"VEN",label:"Venezuela",phone:"58"},{ioc:"IVB",iso2:"VG",iso:"VGB",label:"British Virgin Islands",phone:"1-284"},{ioc:"ISV",iso2:"VI",iso:"VIR",label:"US Virgin Islands",phone:"1-340"},{ioc:"VIE",iso2:"VN",iso:"VNM",label:"Vietnam",phone:"84"},{ioc:"VAN",iso2:"VU",iso:"VUT",label:"Vanuatu",phone:"678"},{ioc:"WAF",iso2:"WF",iso:"WLF",label:"Wallis and Futuna",phone:"681"},{ioc:"SAM",iso2:"WS",iso:"WSM",label:"Samoa",phone:"685"},{ioc:"KOS",iso2:"XK",iso:"KOS",label:"Kosovo",phone:"383"},{ioc:"YEM",iso2:"YE",iso:"YEM",label:"Yemen",phone:"967"},{ioc:"MAY",iso2:"YT",iso:"MYT",label:"Mayotte",phone:"262"},{ioc:"RSA",iso2:"ZA",iso:"ZAF",label:"South Africa",phone:"27"},{ioc:"ZAM",iso2:"ZM",iso:"ZMB",label:"Zambia",phone:"260"},{ioc:"ZIM",iso2:"ZW",iso:"ZWE",label:"Zimbabwe",phone:"263"}],As="ELO",cW="NTRP",uW="UTR",u0="WTN",mo={[As]:{range:[0,3e3],decimalsCount:0,defaultInitialization:1500},[cW]:{range:[1,7],decimalsCount:1,defaultInitialization:3,accessor:"dntrpRatingHundredths",accessors:["ntrpRating","dntrpRatingHundredths"],attributes:{ustaRatingType:""}},[uW]:{range:[1,16],decimalsCount:2,defaultInitialization:6},[u0]:{range:[40,1],decimalsCount:2,defaultInitialization:23,accessor:"wtnRating",accessors:["wtnRating"],attributes:{confidence:{generator:!0,range:[60,100]}}}};var dW=[{collectionName:"Doubles",matchUpCount:3,matchUpFormat:"SET1-S:8/TB7@7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Singles",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",matchUpValue:1}],pW="COLLEGE_D3",fW={valueGoal:5},vW={collectionDefinitions:dW,tieFormatName:pW,winCriteria:fW},mW=[{collectionName:"Doubles",collectionValue:1,matchUpCount:3,matchUpFormat:"SET1-S:6/TB7",matchUpType:"DOUBLES"},{collectionName:"Singles",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",matchUpValue:1}],gW="COLLEGE_DEFAULT",hW={valueGoal:5},_W={collectionDefinitions:mW,tieFormatName:gW,winCriteria:hW},IW=[{collectionName:"Doubles",matchUpCount:3,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Singles",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",matchUpValue:1}],PW="COLLEGE_JUCO",yW={valueGoal:5},SW={collectionDefinitions:IW,tieFormatName:PW,winCriteria:yW},OW=[{collectionName:"Doubles",matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Singles",matchUpCount:2,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1}],bW="DOMINANT_DUO",TW={valueGoal:2},d0={collectionDefinitions:OW,tieFormatName:bW,winCriteria:TW},wW=[{collectionName:"Mixed Doubles",gender:"MIXED",matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Male Singles",matchUpCount:1,gender:"MALE",matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Female Singles",gender:"FEMALE",matchUpCount:1,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1}],EW="DOMINANT_DUO_MIXED",$W={valueGoal:2},p0={collectionDefinitions:wW,tieFormatName:EW,winCriteria:$W},NW=[{collectionGroupNumber:1,matchUpType:"DOUBLES",matchUpCount:1,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpValue:1},{collectionGroupNumber:1,matchUpType:"SINGLES",matchUpCount:3,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpValue:1},{collectionGroupNumber:2,matchUpType:"DOUBLES",matchUpCount:1,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpValue:2},{collectionGroupNumber:2,matchUpType:"SINGLES",matchUpCount:3,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpValue:2},{collectionGroupNumber:3,matchUpType:"DOUBLES",matchUpCount:1,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpValue:3},{collectionGroupNumber:3,matchUpType:"SINGLES",matchUpCount:3,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpValue:3}],UW=[{groupNumber:1,groupName:"Day 1"},{groupNumber:2,groupName:"Day 2"},{groupNumber:3,groupName:"Day 3"}],AW="LAVER_CUP",CW={valueGoal:13},f0={collectionDefinitions:NW,collectionGroups:UW,tieFormatName:AW,winCriteria:CW},MW=[{collectionName:"Round 1",matchUpCount:3,matchUpFormat:"SET1-S:T20",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Round 2",matchUpCount:3,matchUpFormat:"SET1-S:T20",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Round 3",matchUpCount:3,matchUpFormat:"SET1-S:T20",matchUpType:"DOUBLES",scoreValue:1}],DW="Doubles Shuffle",jW=!0,RW={aggregateValue:!0},v0={collectionDefinitions:MW,tieFormatName:DW,unrestrictedSelections:jW,winCriteria:RW},FW=[{category:{ageCategoryCode:"14U"},collectionName:"14U Singles",matchUpCount:2,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{category:{ageCategoryCode:"16U"},collectionName:"16U Singles",matchUpCount:2,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{category:{ageCategoryCode:"18U"},collectionName:"18U Singles",matchUpCount:2,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{category:{ageCategoryCode:"14U"},collectionName:"14U Doubles",collectionGroupNumber:1,matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{category:{ageCategoryCode:"16U"},collectionName:"16U Doubles",collectionGroupNumber:1,matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{category:{ageCategoryCode:"18U"},collectionName:"18U Doubles",collectionGroupNumber:1,matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1}],xW=[{groupNumber:1,groupName:"Doubles",groupValue:1,winCriteria:{valueGoal:2}}],LW="USTA_BREWER_CUP",VW={valueGoal:4},m0={collectionDefinitions:FW,collectionGroups:xW,tieFormatName:LW,winCriteria:VW},BW={valueGoal:23},kW="USTA_OZAKI_CUP",GW=[{category:{ageCategoryCode:"18U"},matchUpFormat:"SET3-S:6/TB7-F:TB10",collectionName:"18U Boys Singles",matchUpType:"SINGLES",matchUpCount:3,matchUpValue:1,gender:"MALE"},{category:{ageCategoryCode:"18U"},matchUpFormat:"SET3-S:6/TB7-F:TB10",collectionName:"18U Girls Singles",matchUpType:"SINGLES",gender:"FEMALE",matchUpCount:3,matchUpValue:1},{category:{ageCategoryCode:"18U"},collectionName:"18U Boys Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",matchUpCount:1,matchUpValue:1,gender:"MALE"},{category:{ageCategoryCode:"18U"},collectionName:"18U Girls Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",gender:"FEMALE",matchUpCount:1,matchUpValue:1},{category:{ageCategoryCode:"18U"},collectionName:"18U Mixed Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",gender:"MIXED",matchUpCount:1,matchUpValue:1},{category:{ageCategoryCode:"16U"},matchUpFormat:"SET3-S:6/TB7-F:TB10",collectionName:"16U Boys Singles",matchUpType:"SINGLES",matchUpCount:3,matchUpValue:1,gender:"MALE"},{category:{ageCategoryCode:"16U"},matchUpFormat:"SET3-S:6/TB7-F:TB10",collectionName:"16U Girls Singles",matchUpType:"SINGLES",gender:"FEMALE",matchUpCount:3,matchUpValue:1},{category:{ageCategoryCode:"16U"},collectionName:"16U Boys Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",matchUpCount:1,matchUpValue:1,gender:"MALE"},{category:{ageCategoryCode:"16U"},collectionName:"16U Girls Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",gender:"FEMALE",matchUpCount:1,matchUpValue:1},{category:{ageCategoryCode:"16U"},collectionName:"16U Mixed Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",gender:"MIXED",matchUpCount:1,matchUpValue:1},{category:{ageCategoryCode:"14U"},matchUpFormat:"SET3-S:6/TB7-F:TB10",collectionName:"14U Boys Singles",matchUpType:"SINGLES",matchUpCount:3,matchUpValue:1,gender:"MALE"},{category:{ageCategoryCode:"14U"},matchUpFormat:"SET3-S:6/TB7-F:TB10",collectionName:"14U Girls Singles",matchUpType:"SINGLES",gender:"FEMALE",matchUpCount:3,matchUpValue:1},{category:{ageCategoryCode:"14U"},collectionName:"14U Boys Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",matchUpCount:1,matchUpValue:1,gender:"MALE"},{category:{ageCategoryCode:"14U"},collectionName:"14U Girls Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",gender:"FEMALE",matchUpCount:1,matchUpValue:1},{category:{ageCategoryCode:"14U"},collectionName:"14U Mixed Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",gender:"MIXED",matchUpCount:1,matchUpValue:1},{category:{ageCategoryCode:"12U"},matchUpFormat:"SET3-S:6/TB7-F:TB10",collectionName:"12U Boys Singles",matchUpType:"SINGLES",matchUpCount:3,matchUpValue:1,gender:"MALE"},{category:{ageCategoryCode:"12U"},matchUpFormat:"SET3-S:6/TB7-F:TB10",collectionName:"12U Girls Singles",matchUpType:"SINGLES",gender:"FEMALE",matchUpCount:3,matchUpValue:1},{category:{ageCategoryCode:"12U"},collectionName:"12U Boys Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",matchUpCount:1,matchUpValue:1,gender:"MALE"},{category:{ageCategoryCode:"12U"},collectionName:"12U Girls Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",gender:"FEMALE",matchUpCount:1,matchUpValue:1},{category:{ageCategoryCode:"12U"},collectionName:"12U Mixed Doubles",matchUpFormat:"SET1-S:8/TB8",matchUpType:"DOUBLES",gender:"MIXED",matchUpCount:1,matchUpValue:1}],g0={winCriteria:BW,tieFormatName:kW,collectionDefinitions:GW},WW=[{collectionName:"Doubles",matchUpCount:3,matchUpFormat:"SET1-S:8/TB7@7",matchUpType:"DOUBLES",collectionValue:1},{collectionName:"Singles",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1}],HW="USTA_COLLEGE",qW={valueGoal:4},h0={collectionDefinitions:WW,tieFormatName:HW,winCriteria:qW},zW=[{collectionName:"Male Singles",matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",matchUpCount:4,matchUpValue:1,gender:"MALE"},{collectionName:"Female Singles",matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",gender:"FEMALE",matchUpCount:4,matchUpValue:1},{collectionName:"Male Doubles",matchUpFormat:"SET1-S:8/TB7@7",matchUpType:"DOUBLES",matchUpCount:2,matchUpValue:1,gender:"MALE"},{collectionName:"Female Doubles",matchUpFormat:"SET1-S:8/TB7@7",matchUpType:"DOUBLES",gender:"FEMALE",matchUpCount:2,matchUpValue:1},{collectionName:"Mixed Doubles",matchUpFormat:"SET1-S:8/TB7@7",matchUpType:"DOUBLES",matchUpCount:4,matchUpValue:1,gender:"MIXED"}],YW="USTA_GOLD_TEAM_CHALLENGE",KW={valueGoal:9},_0={collectionDefinitions:zW,tieFormatName:YW,winCriteria:KW},QW=[{collectionName:"Male Singles",gender:"MALE",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Female Singles",gender:"FEMALE",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Male Doubles",gender:"MALE",matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Female Doubles",gender:"FEMALE",matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Mixed Doubles",gender:"MIXED",matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1}],JW="USTA_INTERSECTIONAL",ZW={valueGoal:8},I0={collectionDefinitions:QW,tieFormatName:JW,winCriteria:ZW},XW=[{collectionName:"Male Singles",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Female Singles",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Male Doubles",matchUpCount:3,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Female Doubles",matchUpCount:3,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1}],e4="USTA_LEVEL_1",t4={valueGoal:10},P0={collectionDefinitions:XW,tieFormatName:e4,winCriteria:t4},r4=[{category:{ageCategoryCode:"16U"},collectionName:"16U Singles",matchUpCount:4,matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",matchUpValue:1},{category:{ageCategoryCode:"18U"},collectionName:"18U Singles",matchUpCount:4,matchUpFormat:"SET3-S:6/TB7",matchUpType:"SINGLES",matchUpValue:1},{category:{ageCategoryCode:"16U"},collectionName:"16U Doubles",matchUpCount:2,matchUpFormat:"SET1-S:6/TB7",matchUpType:"DOUBLES",matchUpValue:1},{category:{ageCategoryCode:"18U"},collectionName:"18U Doubles",matchUpCount:2,matchUpFormat:"SET1-S:6/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Tiebreak Doubles",matchUpCount:1,matchUpFormat:"SET1-S:TB10",matchUpType:"DOUBLES",matchUpValue:1,processCodes:["RANKING.IGNORE"]}],n4="USTA_SECTION_BATTLE",o4={valueGoal:9},y0={collectionDefinitions:r4,tieFormatName:n4,winCriteria:o4},i4=[{collectionName:"Male Singles",gender:"MALE",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Female Singles",gender:"FEMALE",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Mixed Doubles",gender:"MIXED",matchUpCount:3,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1}],s4="USTA_SOUTHERN_LEVEL_5",a4={valueGoal:8},S0={collectionDefinitions:i4,tieFormatName:s4,winCriteria:a4},l4=[{collectionName:"Female Doubles",gender:"FEMALE",matchUpCount:1,matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Male Doubles",gender:"MALE",matchUpCount:1,matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Female Singles",gender:"FEMALE",matchUpCount:1,matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"SINGLES",scoreValue:1},{collectionName:"Male Singles",matchUpCount:1,gender:"MALE",matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"SINGLES",scoreValue:1},{collectionName:"Mixed Doubles",matchUpCount:1,gender:"MIXED",matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Overtime",matchUpCount:1,gender:"MIXED",matchUpFormat:"SET1-S:T20",matchUpType:"DOUBLES",scoreValue:1}],c4="USTA_TOC",u4={aggregateValue:!0},O0={collectionDefinitions:l4,tieFormatName:c4,winCriteria:u4},d4=[{collectionName:"Female Doubles",gender:"FEMALE",matchUpCount:1,matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Male Doubles",gender:"MALE",matchUpCount:1,matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Female Singles",gender:"FEMALE",matchUpCount:1,matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"SINGLES",scoreValue:1},{collectionName:"Male Singles",matchUpCount:1,gender:"MALE",matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"SINGLES",scoreValue:1},{collectionName:"Mixed Doubles",matchUpCount:1,gender:"MIXED",matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Mixed Doubles",matchUpCount:1,gender:"MIXED",matchUpFormat:"SET1-S:6/TB5NOAD@5",matchUpType:"DOUBLES",scoreValue:1},{collectionName:"Overtime",matchUpCount:1,gender:"MIXED",matchUpFormat:"SET1-S:T20",matchUpType:"DOUBLES",scoreValue:1}],p4="USTA_WTT_ITT",f4={aggregateValue:!0},b0={collectionDefinitions:d4,tieFormatName:p4,winCriteria:f4},v4=[{collectionName:"Male Singles",gender:"MALE",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Female Singles",gender:"FEMALE",matchUpCount:6,matchUpFormat:"SET3-S:6/TB7-F:TB10",matchUpType:"SINGLES",matchUpValue:1},{collectionName:"Male Doubles",gender:"MALE",matchUpCount:3,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Female Doubles",gender:"FEMALE",matchUpCount:3,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1},{collectionName:"Mixed Doubles",gender:"MIXED",matchUpCount:1,matchUpFormat:"SET1-S:8/TB7",matchUpType:"DOUBLES",matchUpValue:1}],m4="USTA_ZONAL",g4={valueGoal:10},T0={collectionDefinitions:v4,tieFormatName:m4,winCriteria:g4};const w0={COLLEGE_D3:vW,COLLEGE_DEFAULT:_W,COLLEGE_JUCO:SW,DOMINANT_DUO:d0,DOMINANT_DUO_MIXED:p0,LAVER_CUP:f0,TEAM_DOUBLES_3_AGGREGATION:v0,USTA_BREWER_CUP:m0,USTA_OZAKI_CUP:g0,USTA_COLLEGE:h0,USTA_GOLD_TEAM_CHALLENGE:_0,USTA_INTERSECTIONAL:I0,USTA_LEVEL_1:P0,USTA_SECTION_BATTLE:y0,USTA_SOUTHERN_LEVEL_5:S0,USTA_TOC:O0,USTA_WTT_ITT:b0,USTA_ZONAL:T0},h4={[EV]:{roundsToSeparate:void 0,policyName:"Nationality Code",policyAttributes:[{key:"person.nationalityCode"},{key:"individualParticipants.person.nationalityCode"}]}},_4="qualifierDrawPositionAssignment",I4="withdrawParticipantAtDrawPosition",P4="alternateDrawPositionAssignment",y4="luckyLoserDrawPositionAssignment",E0="removeDrawPositionAssignment",S4="swapDrawPositionAssignments",O4="modifyPairAssignment",b4="modifyParticipantOtherName",$0="assignMatchUpSideParticipant",N0="assignDrawPosition",T4="removeSeededParticipant",w4="assignDrawPositionBye",E4="modifySeedAssignment",U0="addPenalty",A0="MODIFY_PAIR",Mv="QUALIFIER",C0="ALTERNATE",M0="WITHDRAW",wa="ASSIGN",D0="REMOVE",j0="LUCKY",Ku="REMOVE_SEED",R0="SWAP",Qu="NICKNAME",Ea="SEED_VALUE",$a="PENALTY",Dv="BYE",F0={[wo]:{policyName:"positionActionsDefault",enabledStructures:[{stages:[be,ge],stageSequences:[1],enabledActions:[],disabledActions:[]},{stages:[],stageSequences:[],enabledActions:[Qu,$a,Mv,Ea],disabledActions:[]}],disbledStructures:[],otherFlightEntries:!1,activePositionOverrides:[]}},$4={[wo]:{policyName:"positionActionsDisabled",enabledStructures:!1}},N4={[wo]:{policyName:"positionActionsNoMovement",enabledStructures:[{stages:[],stageSequences:[],enabledActions:[Ea,Qu,$a],disabledActions:[]}]}},U4={[wo]:{policyName:"positionActionsUnrestricted",enabledStructures:[],otherFlightEntries:!0,disableRoundRestrictions:!0,activePositionOverrides:[Ea,Ku]}},A4={[wl]:{policyName:"Participant Privacy Policy",participant:{contacts:!1,individualParticipants:{onlineResources:!1,participantName:!0,participantOtherName:!0,participantId:!0,participantRole:!0,participantStatus:!0,penalties:!1,representing:!0,participantRoleResponsibilities:!1,participantType:!0,person:{addresses:!1,biographicalInformation:!1,birthDate:!1,contacts:!1,nationalityCode:!0,nativeFamilyName:!1,nativeGivenName:!1,onlineResources:!1,otherNames:!0,parentOrganisationId:!1,passportFamilyName:!1,passportGivenName:!1,personId:!1,personOtherIds:!1,previousNames:!1,sex:!1,standardFamilyName:!0,standardGivenName:!0,status:!1,tennisId:!1,wheelchair:!0}},individualParticipantIds:!0,onlineResources:!1,participantName:!0,participantOtherName:!0,participantId:!0,participantRole:!0,participantStatus:!0,penalties:!1,representing:!0,participantRoleResponsibilities:!1,participantType:!0,person:{addresses:!1,biographicalInformation:!1,birthDate:!1,contacts:!1,nationalityCode:!0,nativeFamilyName:!1,nativeGivenName:!1,onlineResources:!1,otherNames:!0,parentOrganisationId:!1,passportFamilyName:!1,passportGivenName:!1,personId:!1,personOtherIds:!1,previousNames:!1,sex:!1,standardFamilyName:!0,standardGivenName:!0,status:!1,tennisId:!1,wheelchair:!0}}}},jv="ADULT",Rv="JUNIOR",Ju="WHEELCHAIR",C4={[Nf]:{defaultTimes:{averageTimes:[{categoryNames:[],minutes:{default:90}}],recoveryTimes:[{minutes:{[ft]:30,default:60}}]},defaultDailyLimits:{[Nt]:2,[ft]:2,total:3},matchUpAverageTimes:[{matchUpFormatCodes:["SET3-S:6/TB7"],averageTimes:[{categoryNames:[],minutes:{default:90}},{categoryTypes:[Ju],minutes:{default:120}}]},{matchUpFormatCodes:["SET3-S:6/TB7-F:TB10"],averageTimes:[{categoryNames:[],minutes:{default:85}}]},{matchUpFormatCodes:["SET3-S:6/TB7-F:TB7"],averageTimes:[{categoryNames:[],minutes:{default:70}}]},{matchUpFormatCodes:["SET3-S:4NOAD-F:TB7"],averageTimes:[{categoryNames:[],minutes:{default:55}}]},{matchUpFormatCodes:["SET3-S:4/TB7"],averageTimes:[{categoryNames:[],minutes:{default:60}}]},{matchUpFormatCodes:["SET3-S:4/TB7-F:TB7"],averageTimes:[{categoryNames:[],minutes:{default:50}}]},{matchUpFormatCodes:["SET3-S:4/TB7-F:TB10"],averageTimes:[{categoryNames:[],minutes:{default:55}}]},{matchUpFormatCodes:["SET3-S:4/TB5@3"],averageTimes:[{categoryNames:[],minutes:{default:45}}]},{matchUpFormatCodes:["SET1-S:8/TB7","SET1-S:8/TB7@7"],averageTimes:[{categoryNames:[],minutes:{default:40}}]},{matchUpFormatCodes:["SET1-S:5/TB9@4"],averageTimes:[{categoryNames:[],minutes:{default:30}}]},{matchUpFormatCodes:["SET1-S:6/TB7"],averageTimes:[{categoryNames:[],minutes:{default:30}}]},{matchUpFormatCodes:["SET1-S:6NOAD"],averageTimes:[{categoryNames:[],minutes:{default:30}}]},{matchUpFormatCodes:["SET1-S:4/TB7","SET1-S:4/TB5@3","SET3-S:TB10","SET1-S:T20"],averageTimes:[{categoryNames:[],minutes:{default:20}}]},{matchUpFormatCodes:["SET1-S:4NOAD"],averageTimes:[{categoryNames:[],minutes:{default:20}}]},{matchUpFormatCodes:["SET1-S:TB10"],averageTimes:[{categoryNames:[],minutes:{default:10}}]}],matchUpRecoveryTimes:[{matchUpFormatCodes:["SET3-S:6/TB7","SET3-S:6/TB7-F:TB10","SET3-S:6/TB7-F:TB7"],recoveryTimes:[{categoryTypes:[jv,Ju],minutes:{default:60,[ft]:30}},{categoryTypes:[Rv],minutes:{default:60,[ft]:60}}]},{matchUpFormatCodes:["SET3-S:4/TB7-F:TB7","SET3-S:4/TB7-F:TB10","SET3-S:4NOAD-F:TB7","SET3-S:4/TB7","SET3-S:4/TB5@3"],recoveryTimes:[{categoryTypes:[jv,Ju],minutes:{default:30}},{categoryTypes:[Rv],minutes:{default:60}}]},{matchUpFormatCodes:["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:4NOAD","SET3-S:TB10","SET1-S:T20"],recoveryTimes:[{categoryNames:[],minutes:{default:30}}]},{matchUpFormatCodes:["SET1-S:4/TB5@3"],recoveryTimes:[{categoryTypes:[jv,Rv],minutes:{default:30}},{categoryTypes:[Ju],minutes:{default:15}}]},{matchUpFormatCodes:["SET1-S:TB10"],recoveryTimes:[{categoryNames:[],minutes:{default:15}}]}],matchUpDailyLimits:[]}},M4={[da]:{requireAllPositionsAssigned:!1,stage:{[ge]:{stageSequence:{1:{requireAllPositionsAssigned:!0}}}},defaultMatchUpFormat:"SET3-S:6/TB7",matchUpFormats:[{description:"Best of 3 tiebreak sets",matchUpFormat:"SET3-S:6/TB7",categoryNames:[],categoryTypes:[]},{description:"Two tiebreak sets, 7-point match tiebreak at one set all",matchUpFormat:"SET3-S:6/TB7-F:TB7"},{description:"Two tiebreak sets, 10-point match tiebreak at one set all",matchUpFormat:"SET3-S:6/TB7-F:TB10"},{description:"One standard tiebreak set to 6, 7-point tiebreak at 6 games all",matchUpFormat:"SET1-S:6/TB7"},{description:"Best of 3 sets to 4",matchUpFormat:"SET3-S:4/TB7"},{description:"Two out of three short sets to 4 with 5-point tiebreak at 3 games all",matchUpFormat:"SET3-S:4/TB5@3"},{description:"One short set to 4, 7-point tiebreak at 4 games all",matchUpFormat:"SET1-S:4/TB7"},{description:"One short set to 4, 5-point tiebreak at 3 games all",matchUpFormat:"SET1-S:4/TB5@3"},{description:"Two short sets to 4, 10-point match tiebreak at one set all",matchUpFormat:"SET3-S:4/TB7-F:TB10"},{description:"Two short sets to 4, 7-point match tiebreak at one set all",matchUpFormat:"SET3-S:4/TB7-F:TB7"},{description:"One no advantage set to 5, tiebreak to 9 at 4-4",matchUpFormat:"SET1-S:5/TB9@4"},{description:"One set to 6 with deciding game at 5 games all",matchUpFormat:"SET1-S:6NOAD"},{description:"One short set to 4, deciding game is played at 3 games all",matchUpFormat:"SET1-S:4NOAD"},{description:"Two short sets to 4 with deciding game at 3-3, 7-point match tiebreak at one set all",matchUpFormat:"SET3-S:4NOAD-F:TB7"},{description:"8 game pro-set with 7 point tiebreak at 8 games all",matchUpFormat:"SET1-S:8/TB7"},{description:"8 game pro-set with 7 point tiebreak at 7 games all",matchUpFormat:"SET1-S:8/TB7@7"},{description:"Best of 3 10-point tiebreak games",matchUpFormat:"SET3-S:TB10"},{description:"One 10-point tiebreak game",matchUpFormat:"SET1-S:TB10"},{description:"Timed 20 minute game - game based",matchUpFormat:"SET1-S:T20"}]}},D4={[da]:{defaultMatchUpFormat:"SET3-S:6/TB7",requireAllPositionsAssigned:!1,processCodes:{incompleteAssignmentsOnDefault:["RANKING.IGNORE"]},stage:{[ge]:{stageSequence:{1:{requireAllPositionsAssigned:!0}}}}}},j4={[pa]:{seedingProfile:{positioning:nv},validSeedPositions:{ignore:!0},duplicateSeedNumbers:!0,drawSizeProgression:!0,policyName:"ITF SEEDING",seedsCountThresholds:[{drawSize:4,minimumParticipantCount:3,seedsCount:2},{drawSize:16,minimumParticipantCount:12,seedsCount:4},{drawSize:32,minimumParticipantCount:24,seedsCount:8},{drawSize:64,minimumParticipantCount:48,seedsCount:16},{drawSize:128,minimumParticipantCount:97,seedsCount:32},{drawSize:256,minimumParticipantCount:192,seedsCount:64}]}},Fv={[pa]:{validSeedPositions:{ignore:!0},duplicateSeedNumbers:!0,drawSizeProgression:!0,seedingProfile:{positioning:fG},policyName:"USTA SEEDING",seedsCountThresholds:[{drawSize:4,minimumParticipantCount:3,seedsCount:2},{drawSize:16,minimumParticipantCount:12,seedsCount:4},{drawSize:32,minimumParticipantCount:24,seedsCount:8},{drawSize:64,minimumParticipantCount:48,seedsCount:16},{drawSize:128,minimumParticipantCount:96,seedsCount:32},{drawSize:256,minimumParticipantCount:192,seedsCount:64}]}},R4={ratingsParameters:mo,matchUpFormats:pV,countryToFlag:c0,tieFormats:w0,countries:li,policies:{POLICY_AVOIDANCE_COUNTRY:h4,POLICY_POSITION_ACTIONS_DEFAULT:F0,POLICY_POSITION_ACTIONS_DISABLED:$4,POLICY_POSITION_ACTIONS_NO_MOVEMENT:N4,POLICY_POSITION_ACTIONS_UNRESTRICTED:U4,POLICY_PRIVACY_DEFAULT:A4,POLICY_ROUND_NAMING_DEFAULT:ly,POLICY_SCHEDULING_USTA:C4,POLICY_SCORING_DEFAULT:D4,POLICY_SCORING_USTA:M4,POLICY_SEEDING_ITF:j4,POLICY_SEEDING_USTA:Fv},flagIOC:lW};function Na({collectionDefinitions:t=[],collectionGroups:e=[]}){let r=0;const{groupValueNumbers:n}=vy({collectionGroups:e});let o;for(const s of t||[]){const{collectionValueProfiles:a,collectionGroupNumber:l,collectionValue:c,matchUpCount:u,matchUpValue:d,scoreValue:p,setValue:v}=s,f=l&&n.includes(l);if(v||p)o=!0;else{if(f)continue;if(c)r+=c;else if(a!=null&&a.length)for(const m of a)r+=m.matchUpValue;else d?r+=(u||0)*d:r+=u||0}}for(const s of e)r+=s.groupValue||0;return o||!r?{aggregateValue:!0}:{valueGoal:Math.floor(r/2)+1}}function Zu({participant:t,withISO2:e,withIOC:r}){const{person:n,individualParticipants:o}=t,i=[n,o==null?void 0:o.map(({person:a})=>a)].flat().filter(Boolean);function s(a){const{nationalityCode:l}=a||{};if(l){const c=li.find(({iso:u})=>u===l);r&&(c!=null&&c.ioc)&&!a.iocNationalityCode&&(a.iocNationalityCode=c.ioc),e&&(c!=null&&c.iso2)&&!a.iso2NationalityCode&&(a.iso2NationalityCode=c.iso2),c!=null&&c.label&&!a.countryName&&(a.countryName=c.label)}}i.forEach(s)}var F4=Object.defineProperty,x0=Object.getOwnPropertySymbols,x4=Object.prototype.hasOwnProperty,L4=Object.prototype.propertyIsEnumerable,L0=(t,e,r)=>e in t?F4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,V4=(t,e)=>{for(var r in e||(e={}))x4.call(e,r)&&L0(t,r,e[r]);if(x0)for(var r of x0(e))L4.call(e,r)&&L0(t,r,e[r]);return t};function Cn({returnPreviousValues:t,itemSubTypes:e,itemType:r,element:n}){if(!n)return{error:_e,info:Bf};if(e&&!Array.isArray(e))return{error:X,context:{itemSubTypes:e}};if(!Array.isArray(n.timeItems))return{error:h_};const o=n.timeItems.filter(s=>(s==null?void 0:s.itemType)===r).filter(s=>!(e!=null&&e.length)||e.some(a=>{var l;return(l=s==null?void 0:s.itemSubTypes)==null?void 0:l.includes(a)})).sort((s,a)=>{const l=new Date(s.createdAt||void 0).getTime(),c=new Date(a.createdAt||void 0).getTime();return l-c}),i=o.pop();if(i){const s=V4({timeItem:i},V);return t&&Object.assign(s,{previousItems:o}),s}else return{info:sr}}function B4({returnPreviousValues:t,drawDefinition:e,itemSubTypes:r,itemType:n}){if(!e)return{error:kr};if(!e.timeItems)return{info:sr};const{timeItem:o,previousItems:i,info:s}=Cn({element:e,returnPreviousValues:t,itemSubTypes:r,itemType:n});return o&&{timeItem:o,previousItems:i}||{info:s}}function Ro({returnPreviousValues:t,itemSubTypes:e,itemType:r,event:n}){if(!n)return{error:Ge};if(!n.timeItems)return{info:sr};const{timeItem:o,previousItems:i,info:s}=Cn({returnPreviousValues:t,element:n,itemSubTypes:e,itemType:r});return o&&{timeItem:o,previousItems:i}||{info:s}}function Xu({returnPreviousValues:t,tournamentRecord:e,itemSubTypes:r,itemType:n}){if(!e)return{error:re};if(!e.timeItems)return{info:sr};const{timeItem:o,previousItems:i,info:s}=Cn({element:e,returnPreviousValues:t,itemSubTypes:r,itemType:n});return o&&{timeItem:o,previousItems:i}||{info:s}}function k4({returnPreviousValues:t,tournamentRecord:e,participantId:r,itemSubTypes:n,itemType:o}){if(!e)return{error:re};if(!r)return{error:Tt};const i=Zo({tournamentRecord:e,participantId:r});if(i.error)return i;const{participant:s}=i;if(!(s!=null&&s.timeItems))return{info:sr};const{timeItem:a,previousItems:l,info:c}=Cn({element:i.participant,returnPreviousValues:t,itemSubTypes:n,itemType:o});return a&&{timeItem:a,previousItems:l}||{info:c}}var G4=Object.defineProperty,V0=Object.getOwnPropertySymbols,W4=Object.prototype.hasOwnProperty,H4=Object.prototype.propertyIsEnumerable,B0=(t,e,r)=>e in t?G4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ed=(t,e)=>{for(var r in e||(e={}))W4.call(e,r)&&B0(t,r,e[r]);if(V0)for(var r of V0(e))H4.call(e,r)&&B0(t,r,e[r]);return t};const q4={[Cr]:"groupParticipantIds",[Ue]:"pairParticipantIds",[rt]:"teamParticipantIds"},z4={[Cr]:"groups",[rt]:"teams"};function k0({withIndividualParticipants:t,convertExtensions:e,policyDefinitions:r,tournamentRecord:n,withSignInStatus:o,withScaleValues:i,internalUse:s,withISO2:a,withIOC:l}){const c=r==null?void 0:r[wl],u=c==null?void 0:c.participant,d={};for(const p of n.participants||[]){const v=p==null?void 0:p.participantId;v&&J4({participantMap:d,participantId:v})}for(const p of n.participants||[]){const v=ve(p,e,s),f=u?su({template:c.participant,source:v}):v,{participantId:m,individualParticipantIds:g,participantType:h}=f;if(Object.assign(d[m].participant,f),g&&Q4({individualParticipantIds:g,filteredParticipant:f,participantMap:d,participantType:h,participantId:m}),o&&(d[m].participant.signedIn=Y4(v)),i){const{ratings:_,rankings:I,seedings:P}=ga({participant:v});d[m].participant.seedings=P,d[m].participant.rankings=I,d[m].participant.ratings=_}(l||a)&&Zu({participant:d[m].participant,withISO2:a,withIOC:l})}return t&&K4({participantMap:d}),{participantMap:d}}function Y4(t){const{timeItem:e}=Cn({itemType:Ll,element:t});return(e==null?void 0:e.itemValue)===Vl}function K4({participantMap:t}){var e;const r=Object.values(t);for(const n of r){const o=n.participant;if((e=o.individualParticipantIds)!=null&&e.length){o.individualParticipants=[];for(const i of o.individualParticipantIds)o.individualParticipants.push(t[i].participant)}}}function Q4({individualParticipantIds:t,filteredParticipant:e,participantMap:r,participantType:n,participantId:o}){for(const i of t){const s=r[i].participant;if(s[q4[n]].push(o),[rt,Cr].includes(n)){const{participantRoleResponsibilities:a,participantOtherName:l,participantName:c,participantId:u,teamId:d}=e,p=z4[n];s[p].push({participantRoleResponsibilities:a,participantOtherName:l,participantName:c,participantId:u,teamId:d})}if(n===Ue){const a=t.find(l=>l!==i);r[i].pairIdMap[o]=a,r[i].pairIdMap[a]=o}}}function J4({participantMap:t,participantId:e}){if(t[e])return;const r={walkoverWins:0,defaultWins:0,walkovers:0,defaults:0,losses:0,wins:0};t[e]={structureParticipation:{},potentialMatchUps:{},scheduleConflicts:[],scheduleItems:[],participant:{groupParticipantIds:[],pairParticipantIds:[],teamParticipantIds:[],groups:[],teams:[]},statistics:{},opponents:{},pairIdMap:{},matchUps:{},events:{},draws:{},counters:ed({[Nt]:ed({},r),[ft]:ed({},r),[rt]:ed({},r)},r)}}var Z4=Object.defineProperty,X4=Object.defineProperties,eH=Object.getOwnPropertyDescriptors,G0=Object.getOwnPropertySymbols,tH=Object.prototype.hasOwnProperty,rH=Object.prototype.propertyIsEnumerable,W0=(t,e,r)=>e in t?Z4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xv=(t,e)=>{for(var r in e||(e={}))tH.call(e,r)&&W0(t,r,e[r]);if(G0)for(var r of G0(e))rH.call(e,r)&&W0(t,r,e[r]);return t},nH=(t,e)=>X4(t,eH(e));function Cs({participantsProfile:t,useParticipantMap:e,policyDefinitions:r,tournamentRecord:n,contextProfile:o,inContext:i}){var s;if(e)return{participantMap:(s=k0(nH(xv(xv({},t),o),{policyDefinitions:r,tournamentRecord:n})))==null?void 0:s.participantMap};let a=ve(n.participants,!1,!0)||[];if((t!=null&&t.withIOC||t!=null&&t.withISO2)&&a.forEach(l=>Zu(xv({participant:l},t))),(i||t!=null&&t.withGroupings)&&(a!=null&&a.length)&&(a=gv({participantsProfile:t,participants:a})),t!=null&&t.withScaleValues&&(a!=null&&a.length))for(const l of a){const{ratings:c,rankings:u}=ga({participant:l});l.rankings=u,l.ratings=c}return{participants:a}}var oH=Object.defineProperty,iH=Object.defineProperties,sH=Object.getOwnPropertyDescriptors,H0=Object.getOwnPropertySymbols,aH=Object.prototype.hasOwnProperty,lH=Object.prototype.propertyIsEnumerable,q0=(t,e,r)=>e in t?oH(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ci=(t,e)=>{for(var r in e||(e={}))aH.call(e,r)&&q0(t,r,e[r]);if(H0)for(var r of H0(e))lH.call(e,r)&&q0(t,r,e[r]);return t},z0=(t,e)=>iH(t,sH(e));function Wt(t){var e,r,n;if(!(t!=null&&t.tournamentRecord))return{error:re};let{participantMap:o,participants:i}=t;const{scheduleVisibilityFilters:s,participantsProfile:a,afterRecoveryTimes:l,useParticipantMap:c,policyDefinitions:u,tournamentRecord:d,inContext:p=!0,contextProfile:v,matchUpFilters:f,contextFilters:m,nextMatchUps:g,context:h}=t,_=(e=t.tournamentId)!=null?e:d.tournamentId,I=(r=d==null?void 0:d.events)!=null?r:[];i||({participants:i,participantMap:o}=Cs({participantsProfile:a,policyDefinitions:u,useParticipantMap:c,tournamentRecord:d,contextProfile:v,inContext:p}));const{appliedPolicies:P}=vt({tournamentRecord:d}),y=z0(ci({},h),{tournamentId:_,indoorOutDoor:d.indoorOutdoor,surfaceCategory:d.surfaceCategory,endDate:d.endDate}),S=Eo({policyDefinitions:u,tournamentRecord:d,contextProfile:v});return{matchUps:I.flatMap(b=>{var w,T,E;return y.eventDrawsCount=(T=(w=b.drawDefinitions)==null?void 0:w.length)!=null?T:0,(E=ui({context:y,scheduleVisibilityFilters:s,tournamentAppliedPolicies:P,participantsProfile:a,afterRecoveryTimes:l,policyDefinitions:u,tournamentRecord:d,contextContent:S,contextFilters:m,contextProfile:v,matchUpFilters:f,participantMap:o,nextMatchUps:g,participants:i,inContext:p,event:b}).matchUps)!=null?E:[]}).concat(...(n=d.matchUps)!=null?n:[])}}function zr(t){var e,r;let{participants:n,participantMap:o,contextContent:i}=t;const{scheduleVisibilityFilters:s,tournamentAppliedPolicies:a,participantsProfile:l,afterRecoveryTimes:c,policyDefinitions:u,useParticipantMap:d,tournamentRecord:p,contextFilters:v,contextProfile:f,drawDefinition:m,matchUpFilters:g,nextMatchUps:h,inContext:_,context:I,event:P}=t,{eventId:y,eventName:S,eventType:O,category:b,gender:w,matchUpFormat:T}=P??{},E=z0(ci({},I),{eventId:y,eventType:O,eventName:S,category:b,gender:w,matchUpFormat:T,indoorOutDoor:(e=P==null?void 0:P.indoorOutdoor)!=null?e:p==null?void 0:p.indoorOutdoor,surfaceCategory:(r=P==null?void 0:P.surfaceCategory)!=null?r:p==null?void 0:p.surfaceCategory,endDate:P==null?void 0:P.endDate});return!(n!=null&&n.length)&&!o&&p&&({participants:n=[],participantMap:o}=Cs({participantsProfile:l,useParticipantMap:d,policyDefinitions:u,tournamentRecord:p,contextProfile:f,inContext:_})),f&&!i&&(i=Eo({policyDefinitions:u,tournamentRecord:p,contextProfile:f,drawDefinition:m,event:P})),xt({context:E,tournamentAppliedPolicies:a,scheduleVisibilityFilters:s,tournamentParticipants:n,participantsProfile:l,afterRecoveryTimes:c,policyDefinitions:u,tournamentRecord:p,drawDefinition:m,contextContent:i,contextFilters:v,contextProfile:f,matchUpFilters:g,participantMap:o,nextMatchUps:h,inContext:_,event:P})}function ui(t){var e,r,n,o,i;let{participants:s=[],contextContent:a,participantMap:l}=t;const{scheduleVisibilityFilters:c,tournamentAppliedPolicies:u,participantsProfile:d,afterRecoveryTimes:p,policyDefinitions:v,useParticipantMap:f,tournamentRecord:m,contextFilters:g,contextProfile:h,matchUpFilters:_,nextMatchUps:I,inContext:P,context:y,event:S}=t;if(!S)return{error:Ge};const{eventId:O,eventName:b,endDate:w,category:T,gender:E,matchUpFormat:N}=S,$=[],A=ci(ci({},y),ye({indoorOutDoor:(e=S.indoorOutdoor)!=null?e:m==null?void 0:m.indoorOutdoor,surfaceCategory:(r=S.surfaceCategory)!=null?r:m==null?void 0:m.surfaceCategory,endDate:(n=S.endDate)!=null?n:m==null?void 0:m.endDate,tournamentId:m==null?void 0:m.tournamentId,matchUpFormat:N,eventName:b,category:T,gender:E,eventId:O}));if(w&&(A.endDate=w),h&&!a&&(a=Eo({policyDefinitions:v,tournamentRecord:m,contextProfile:h,event:S})),!(s!=null&&s.length)&&!l&&m){const D=Cs({participantsProfile:d,useParticipantMap:f,policyDefinitions:v,tournamentRecord:m,contextProfile:h,inContext:P});l=D.participantMap,s=(o=D.participants)!=null?o:[]}const U=(i=S.drawDefinitions)!=null?i:[],C=Ml({tournamentRecord:m,event:S}).scheduleTiming;return{matchUps:U.flatMap(D=>{const{matchUps:R,matchUpsMap:j}=xt({tournamentParticipants:s,tournamentAppliedPolicies:u,scheduleVisibilityFilters:c,context:A,participantsProfile:d,afterRecoveryTimes:p,policyDefinitions:v,tournamentRecord:m,contextFilters:g,contextProfile:h,drawDefinition:D,contextContent:a,matchUpFilters:_,participantMap:l,scheduleTiming:C,nextMatchUps:I,inContext:P,event:S});return j!=null&&j.drawMatchUps&&$.push(...j.drawMatchUps),R??[]}),eventMatchUps:$}}function Y0(t){var e,r,n;if(!(t!=null&&t.tournamentRecord))return{error:re};let o=t.contextContent;const{scheduleVisibilityFilters:i,participantsProfile:s,afterRecoveryTimes:a,policyDefinitions:l,useParticipantMap:c,tournamentRecord:u,inContext:d=!0,contextFilters:p,contextProfile:v,matchUpFilters:f,nextMatchUps:m,context:g}=t,h=(e=t.tournamentId)!=null?e:u.tournamentId,_=(r=u==null?void 0:u.events)!=null?r:[],{participants:I,participantMap:P}=Cs({participantsProfile:s,policyDefinitions:l,useParticipantMap:c,tournamentRecord:u,contextProfile:v,inContext:d});v&&!o&&(o=Eo({policyDefinitions:l,tournamentRecord:u,contextProfile:v}));const{appliedPolicies:y}=vt({tournamentRecord:u}),S=(n=p==null?void 0:p.eventIds)!=null?n:[];return _.filter(b=>!S.includes(b.eventId)).map(b=>{var w,T;const E=Et({event:b}).flightProfile,N=ci({eventDrawsCount:((w=E==null?void 0:E.flights)==null?void 0:w.length)||((T=b.drawDefinitions)==null?void 0:T.length)||0},g);return K0({context:N,tournamentAppliedPolicies:y,scheduleVisibilityFilters:i,participantsProfile:s,afterRecoveryTimes:a,policyDefinitions:l,tournamentRecord:u,contextFilters:p,contextProfile:v,contextContent:o,matchUpFilters:f,participantMap:P,participants:I,tournamentId:h,nextMatchUps:m,inContext:d,event:b})}).reduce((b,w)=>{const T=w&&Object.keys(w).filter(E=>!["success","matchUpsMap"].includes(E));return T==null||T.forEach(E=>{b[E]||(b[E]=[]),b[E]=b[E].concat(w[E]),b.matchUpsCount+=w[E].length}),b},{matchUpsCount:0})}function K0(t){var e,r,n;let{participants:o,contextContent:i,participantMap:s}=t;const{tournamentAppliedPolicies:a,scheduleVisibilityFilters:l,participantsProfile:c,afterRecoveryTimes:u,policyDefinitions:d,useParticipantMap:p,tournamentRecord:v,contextFilters:f,contextProfile:m,matchUpFilters:g,nextMatchUps:h,tournamentId:_,inContext:I,context:P,event:y}=t;if(!y)return{error:Ge};const{eventId:S,eventName:O,endDate:b}=y,w=ci(ci({},P),ye({eventId:S,eventName:O,endDate:b??(v==null?void 0:v.endDate),tournamentId:_??(v==null?void 0:v.tournamentId),indoorOutDoor:(e=y.indoorOutdoor)!=null?e:v==null?void 0:v.indoorOutdoor,surfaceCategory:(r=y.surfaceCategory)!=null?r:v==null?void 0:v.surfaceCategory}));return!o&&v&&({participants:o,participantMap:s}=Cs({participantsProfile:c,policyDefinitions:d,useParticipantMap:p,tournamentRecord:v,contextProfile:m,inContext:I})),m&&!i&&(i=Eo({policyDefinitions:d,tournamentRecord:v,contextProfile:m,event:y})),((n=y.drawDefinitions)!=null?n:[]).reduce((E,N)=>{const $=Es({context:w,tournamentAppliedPolicies:a,scheduleVisibilityFilters:l,tournamentParticipants:o,participantsProfile:c,afterRecoveryTimes:u,policyDefinitions:d,tournamentRecord:v,drawDefinition:N,contextContent:i,contextFilters:f,contextProfile:m,matchUpFilters:g,participantMap:s,nextMatchUps:h,inContext:I,event:y}),A=Object.keys($);return A==null||A.forEach(U=>{E[U]||(E[U]=[]),E[U]=E[U].concat($[U])}),E},{})}function cH({participants:t,tournamentAppliedPolicies:e,scheduleVisibilityFilters:r,participantsProfile:n,afterRecoveryTimes:o,policyDefinitions:i,useParticipantMap:s,tournamentRecord:a,contextFilters:l,contextProfile:c,contextContent:u,drawDefinition:d,matchUpFilters:p,participantMap:v,nextMatchUps:f,tournamentId:m,inContext:g,context:h,event:_}){var I,P,y;const{eventId:S,eventName:O,endDate:b}=_??{},w=ci(ci({},h),ye({eventId:S,eventName:O,endDate:(I=b??(_==null?void 0:_.endDate))!=null?I:a==null?void 0:a.endDate,tournamentId:m??(a==null?void 0:a.tournamentId),indoorOutDoor:(P=_==null?void 0:_.indoorOutdoor)!=null?P:a==null?void 0:a.indoorOutdoor,surfaceCategory:(y=_==null?void 0:_.surfaceCategory)!=null?y:a==null?void 0:a.surfaceCategory}));return!(t!=null&&t.length)&&a&&({participants:t,participantMap:v}=Cs({participantsProfile:n,policyDefinitions:i,useParticipantMap:s,tournamentRecord:a,contextProfile:c,inContext:g})),_&&c&&!u&&(u=Eo({policyDefinitions:i,tournamentRecord:a,contextProfile:c,drawDefinition:d,event:_})),Es({context:w,tournamentAppliedPolicies:e,scheduleVisibilityFilters:r,tournamentParticipants:t,participantsProfile:n,afterRecoveryTimes:o,policyDefinitions:i,tournamentRecord:a,participantMap:v,drawDefinition:d,matchUpFilters:p,contextFilters:l,contextProfile:c,contextContent:u,nextMatchUps:f,inContext:g,event:_})}function lc({finishingPositionOffset:t=0,finishingPositionLimit:e,positionsFed:r,roundsCount:n,roundLimit:o,matchUps:i,lucky:s,fmlc:a}){var l;if(!Array.isArray(i))return[];const{roundProfile:c,roundNumbers:u=[]}=br({interpolate:!0,matchUps:i});n=n||Math.max(...u,0);const d=o?n-o:0,p=d&&((l=c==null?void 0:c[n-d])==null?void 0:l.matchUpsCount),v=c&&Object.values(c).map(sn("matchUpsCount")),f=(h,_)=>{let I=Math.min(...h);p&&_&&I===1&&(I=p);let P=Math.max(...h);return e&&P>e&&(P=e),[I,P]},m=c&&Object.assign({},...u.map(h=>{const _=(n||0)+1-h-d,I=c[h].matchUpsCount,P={finishingPositionRange:{},finishingRound:_},y=v==null?void 0:v.slice(h-1).reduce(($,A)=>$+(A||0),0),S=a&&h!==1,O=1+t+(S&&r||0),b=1,w=pe(O,s?O+I*2:y+O+b),T=y+b-I,E=f(w.slice(T)),N=f(w.slice(0,T),!0);return P.finishingPositionRange={loser:E,winner:N},{[h]:P}})),g=zt({finishingRound:!0});return i.filter(Boolean).forEach(h=>{const _=h.roundNumber&&m[h.roundNumber];g&&!_&&console.log({roundFinishingData:m,matchUp:h}),h.finishingRound=_==null?void 0:_.finishingRound,h.finishingPositionRange=_==null?void 0:_.finishingPositionRange}),i}function Ua({inContextDrawMatchUps:t,drawDefinition:e,matchUpsMap:r}){var n;if(!e)return{error:fe};const o={loserMatchUpIds:{},winnerMatchUpIds:{}};if(t||({matchUps:t,matchUpsMap:r}=xt({inContext:!0,drawDefinition:e,matchUpsMap:r})),!(r==null?void 0:r.drawMatchUps.some(s=>s.finishingPositionRange))&&((n=e==null?void 0:e.structures)==null?void 0:n.length)===1&&!(e!=null&&e.structures[0].structures)){const s=(r==null?void 0:r.drawMatchUps)||[];lc({matchUps:s})}return(t||[]).filter(({collectionId:s})=>!s).forEach(s=>{const{matchUpId:a,structureId:l}=s,c=_r({inContextDrawMatchUps:t,drawDefinition:e,matchUpId:a}),{winnerMatchUp:u,loserMatchUp:d}=c.targetMatchUps,p=u==null?void 0:u.matchUpId,v=d==null?void 0:d.matchUpId,m=Li({matchUpsMap:r,structureId:l}).find(g=>g.matchUpId===a);if(m&&(p&&(o.winnerMatchUpIds[m.matchUpId]=p,Object.assign(m,{winnerMatchUpId:p}),Object.assign(s,{winnerMatchUpId:p})),v&&(o.loserMatchUpIds[m.matchUpId]=v,s.loserMatchUpId=v,m.loserMatchUpId=v,s.finishingPositionRange))){const g=d.finishingPositionRange&&[...s.finishingPositionRange.loser,...d.finishingPositionRange.loser],h=g&&[Math.min(...g),Math.max(...g)];s.finishingPositionRange.loser=h,m.finishingPositionRange.loser=h}}),{inContextDrawMatchUps:t,goesToMap:o}}function td(t){var e;const{sides:r,matchUpType:n}=t||{},o=(e=t.potentialParticipants)!=null&&e.length?t.potentialParticipants.flat().map(a=>n===ft?(a==null?void 0:a.individualParticipantIds)||[]:a.participantId).flat():[],i=(r||[]).map(a=>{var l;return n===ft&&(((l=a==null?void 0:a.participant)==null?void 0:l.individualParticipantIds)||[])||(a==null?void 0:a.participantId)&&[a.participantId]||[]}).flat();return{individualParticipantIds:i.concat(o).flat(),enteredIndividualParticipantIds:i,potentialIndividualParticipantIds:o}}function Fo({scheduleVisibilityFilters:t,afterRecoveryTimes:e,participantsProfile:r,tournamentRecords:n,policyDefinitions:o,matchUpFilters:i,contextFilters:s,nextMatchUps:a,inContext:l}){return typeof n!="object"||!Object.keys(n).length?{error:ke}:{matchUps:Object.keys(n).map(d=>{var p;const v=n[d];return(p=Wt({scheduleVisibilityFilters:t,afterRecoveryTimes:e,participantsProfile:r,policyDefinitions:o,tournamentRecord:v,matchUpFilters:i,contextFilters:s,nextMatchUps:a,inContext:l}).matchUps)!=null?p:[]}).flat()}}function Lv({scheduleVisibilityFilters:t,participantsProfile:e,tournamentRecords:r,policyDefinitions:n,matchUpFilters:o,contextFilters:i,nextMatchUps:s,inContext:a}){return typeof r!="object"||!Object.keys(r).length?{error:ke}:Object.keys(r).map(u=>{const d=r[u];return Y0({scheduleVisibilityFilters:t,participantsProfile:e,policyDefinitions:n,tournamentRecord:d,matchUpFilters:o,contextFilters:i,nextMatchUps:s,inContext:a})}).reduce((u,d)=>(Object.keys(d).forEach(v=>{u[v]||(u[v]=[]),u[v]=u[v].concat(d[v])}),u),{})}function Ms(t,e){return uH(t,e)||((t==null?void 0:t.stageSequence)||0)-((e==null?void 0:e.stageSequence)||0)||(t==null?void 0:t.roundNumber)&&e.roundNumber&&(t==null?void 0:t.roundNumber)-(e==null?void 0:e.roundNumber)||((t==null?void 0:t.roundPosition)||0)-((e==null?void 0:e.roundPosition)||0)}function uH(t,e){return(Is[t==null?void 0:t.stage]||0)-(Is[e==null?void 0:e.stage]||0)}var dH=Object.defineProperty,Q0=Object.getOwnPropertySymbols,pH=Object.prototype.hasOwnProperty,fH=Object.prototype.propertyIsEnumerable,J0=(t,e,r)=>e in t?dH(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,vH=(t,e)=>{for(var r in e||(e={}))pH.call(e,r)&&J0(t,r,e[r]);if(Q0)for(var r of Q0(e))fH.call(e,r)&&J0(t,r,e[r]);return t};function pn(t){var e,r,n,o;let i=(e=t.tournamentRecords)!=null?e:{};const s=(r=t.matchUps)!=null?r:[];let a=(n=t.drawIds)!=null?n:[];const{includeParticipantDependencies:l,tournamentRecord:c,drawDefinition:u}=t;if(!Array.isArray(s))return{error:Wo};if(!Array.isArray(a))return{error:kr};const d=(o=t.matchUpIds)!=null&&o.length?t.matchUpIds:s.map(O=>O.matchUpId);if(!Array.isArray(d))return{error:ml};const p={},v={},f={},m={};c&&!Object.keys(i).length&&(i={[c.tournamentId]:c});const g=Object.values(i),_=g.reduce((O,b)=>O.concat(b.events||[]).map(w=>(w.drawDefinitions||[]).map(T=>T.links||[])).flat(1/0),[]).filter(({linkType:O})=>O===Di);let I=s;if(_.length){I=Fo({nextMatchUps:!0,tournamentRecords:i}).matchUps;const O=_.reduce((b,w)=>{var T,E;const N=(T=w.source)==null?void 0:T.structureId,$=(E=w.target)==null?void 0:E.structureId;return N&&$&&(f[$]=N),N&&!b.includes(N)&&b.push(N),b},[]);for(const b of O)p[b]=[];for(const b of I||[]){const w=b.containerStructureId||b.structureId;O.includes(w)&&p[w].push(b.matchUpId)}}const P=O=>{v[O]||(v[O]={dependentMatchUpIds:[],participantIds:[],matchUpIds:[],sources:[]},m[O]=[])},y=(O,b)=>{v[O].matchUpIds.forEach(T=>{v[b].matchUpIds.push(T)}),v[b].matchUpIds.push(O),v[O].dependentMatchUpIds.push(b),l&&v[O].participantIds.forEach(T=>v[b].participantIds.push(T))},S=O=>{const b=Object.keys(p).length;for(const w of O||[]){const{matchUpId:T,winnerMatchUpId:E,loserMatchUpId:N}=w;if(!d.length||d.includes(T)){if(P(T),l){const{individualParticipantIds:U}=td(w);v[T].participantIds=U}E&&(P(E),y(T,E),m[E].push(T)),N&&(P(N),y(T,N),m[N].push(T)),v[T].sources.push(m[T]);const $=m[T].map(U=>v[U].sources[0]).flat(),A=m[T].map(U=>v[U].sources[1]).flat();if(v[T].sources.push($,A),b){const U=w.containerStructureId||w.structureId,C=f[U];if(p[C])for(const M of p[C])P(M),y(M,T),m[M].push(T)}}}};if(u)Ua({drawDefinition:u}),I!=null&&I.length||(I=zr({drawDefinition:u}).matchUps),S(I);else{if(I!=null&&I.length||(I=Fo({nextMatchUps:!0,tournamentRecords:i}).matchUps),!a.length){const O=g!=null&&g.length?g.map(({events:b=[]})=>b.map(({drawDefinitions:w=[]})=>w.map(({drawId:T})=>T))).flat(1/0):[];O&&(a=O)}for(const O of a){const b=I==null?void 0:I.filter(T=>T.drawId===O).sort(Ms);if(!(b==null?void 0:b.find(({roundPosition:T})=>!T))){const T=b==null?void 0:b.find(({tournamentId:N})=>N),{drawDefinition:E}=Qt({tournamentRecord:i[T==null?void 0:T.tournamentId],drawId:O});E&&Ua({drawDefinition:E})}S(b)}}return vH({positionDependencies:p,matchUpDependencies:v,sourceMatchUpIds:m,matchUps:I},V)}function Z0({tournamentRecords:t,matchUps:e}){if(!Array.isArray(e))return{error:Wo};if(e.some(({matchUpId:f,hasContext:m})=>f&&!m))return{info:"matchUps must have { inContext: true, nextMatchUps: true }",error:nu};const r=Math.max(...e.map(({schedule:f})=>(f==null?void 0:f.courtOrder)||1).map(f=>Oe(f))),n=pe(1,r+1).map(f=>e.filter(m=>{var g;return Oe((g=m.schedule)==null?void 0:g.courtOrder)===f})),o={},i={},s={};n.flat().filter(Boolean).sort(Ms).forEach(({schedule:f})=>delete f[Lf]);const l=He(e.map(({drawId:f})=>f)),c=pn({includeParticipantDependencies:!0,tournamentRecords:t,drawIds:l}).matchUpDependencies,u=n.map((f,m)=>f.reduce((g,h)=>{if(!h.matchUpId)return g;const{matchUpId:_,winnerMatchUpId:I,loserMatchUpId:P,schedule:y,sides:S,potentialParticipants:O}=h,b=y==null?void 0:y.courtId;o[_]=m,i[b]=[],g.matchUpIds.push(_),s[_]=h;const w=c[_].matchUpIds;w.length&&g.sourceMatchUpIds.push(...w);const T=(S==null?void 0:S.map(N=>{var $;return[($=N.participant)==null?void 0:$.individualParticipantIds,N.participantId]}).flat().filter(Boolean))||[],E=(O==null?void 0:O.flat().map(({individualParticipantIds:N,participantId:$})=>[N,$]).flat().filter(Boolean))||[];return g.participantIds.push(...E,...T),I&&g.targetMatchUpIds.push(I),P&&g.targetMatchUpIds.push(P),g},{sourceMatchUpIds:[],targetMatchUpIds:[],participantIds:[],matchUpIds:[]})),d=(f,m)=>c[f].sources.reduce((g,h,_)=>h.includes(m)&&_+1||g,0),p=u.map(()=>[]),v=(f,m,g,h)=>{if(!s[f].schedule[Lf]){s[f].schedule[Lf]=m,s[f].schedule[vB]=h,p[o[f]].push({matchUpId:f,issueType:g,issueIds:h,issue:m});const _=s[f].schedule.courtId;i[_]||(i[_]=[]),i[_].push({matchUpId:f,issue:m,issueType:g,issueIds:h})}};return u.forEach((f,m)=>{const g=m?u[m-1]:void 0,h=u.slice(m+1),_={},I=$r(f.participantIds),P=Object.keys(I).filter(O=>I[O]>1),y=f.matchUpIds.filter(O=>c[O].participantIds.some(b=>P.includes(b)));y.forEach(O=>{_[O]||(_[O]={}),_[O][fs]||(_[O][fs]=y.filter(b=>b!==O))});const S=g&&f.participantIds.filter(O=>g.participantIds.includes(O));S&&S.forEach(O=>{const b=f.matchUpIds.concat(g.matchUpIds).filter(w=>c[w].participantIds.includes(O));b.forEach(w=>{_[w]||(_[w]={}),_[w][vs]||(_[w][vs]=b.filter(T=>T!==w))})}),f.matchUpIds.forEach(O=>{var b,w,T,E;const N=c[O].matchUpIds;for(const A of h){const U=A.matchUpIds.filter(C=>N.includes(C));U!=null&&U.length&&(U.forEach(C=>v(C,AI,$i,[O])),v(O,AI,$i,U))}if((b=_[O])!=null&&b[fs]&&v(O,fs,UI,_[O][fs]),f.sourceMatchUpIds.includes(O)){const A=f.matchUpIds.filter(U=>c[U].matchUpIds.includes(O));v(O,fs,$i,A),f.matchUpIds.filter(U=>c[U].matchUpIds.includes(O)).forEach(U=>v(U,fs,$i,[O]))}const $=(w=g==null?void 0:g.matchUpIds)==null?void 0:w.filter(A=>d(O,A)>1);if($!=null&&$.length&&(v(O,CI,$i,$),$.forEach(A=>v(A,CI,$i,[O]))),(T=_[O])!=null&&T[vs]&&v(O,vs,UI,_[O][vs]),(E=g==null?void 0:g.targetMatchUpIds)!=null&&E.includes(O)){const A=s[O].schedule.courtId,U=N.filter(M=>g.matchUpIds.includes(M));U.some(M=>s[M].schedule.courtId===A)||(U.forEach(M=>v(M,vs,$i,[O])),v(O,vs,$i,U))}})}),{courtIssues:i,rowIssues:p}}function rd(t){var e;if(!t)return{};const r=[],n=t.tieFormatName,o=(e=t.collectionDefinitions)==null?void 0:e.map(i=>{const{matchUpType:s,matchUpFormat:a,matchUpCount:l,category:c,gender:u}=i;r.includes(a)||r.push(a);const d=c==null?void 0:c.ageCategoryCode;return[l,s===_n?"D":"S",d,a,u].join(";")}).join("|");return{tieFormatName:t&&n||"UNNAMED",matchUpFormats:r,tieFormatDesc:o}}var mH=Object.defineProperty,gH=Object.defineProperties,hH=Object.getOwnPropertyDescriptors,X0=Object.getOwnPropertySymbols,_H=Object.prototype.hasOwnProperty,IH=Object.prototype.propertyIsEnumerable,eS=(t,e,r)=>e in t?mH(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,PH=(t,e)=>{for(var r in e||(e={}))_H.call(e,r)&&eS(t,r,e[r]);if(X0)for(var r of X0(e))IH.call(e,r)&&eS(t,r,e[r]);return t},yH=(t,e)=>gH(t,hH(e));function Aa({considerations:t={},descendant:e,ancestor:r}){var n,o,i,s;const a={},l={},{matchUpFormats:c,tieFormatDesc:u}=rd(e),{matchUpFormats:d,tieFormatDesc:p}=rd(r),v=He((c??[]).filter(y=>!(d??[]).includes(y)).concat((d??[]).filter(y=>!(c??[]).includes(y)))),f=!!(t!=null&&t.collectionName&&e.collectionDefinitions.map(({collectionName:y})=>y).join("|")!==r.collectionDefinitions.map(({collectionName:y})=>y).join("|")),m=!!(t!=null&&t.collectionOrder&&e.collectionDefinitions.map(({collectionOrder:y})=>y).join("|")!==r.collectionDefinitions.map(({collectionOrder:y})=>y).join("|")),g=f||m||p!==u,h=Object.assign({},...((e==null?void 0:e.collectionDefinitions)||[]).map(y=>({[y.collectionId]:y}))),_=Object.assign({},...((r==null?void 0:r.collectionDefinitions)||[]).map(y=>({[y.collectionId]:y})));a.collectionIds=Lh(Object.keys(h),Object.keys(_)),l.collectionIds=Lh(Object.keys(_),Object.keys(h)),a.collectionsValue=tS(h,a),l.collectionsValue=tS(_,l),a.groupsCount=(s=(n=r==null?void 0:r.collectionGroups)==null?void 0:n.length)!=null?s:0-((i=(o=e==null?void 0:e.collectionGroups)==null?void 0:o.length)!=null?i:0)||0,l.groupsCount=a.groupsCount?-1*a.groupsCount:0;const I=a.collectionsValue.totalValue-l.collectionsValue.totalValue,P=a.collectionsValue.totalMatchUps-l.collectionsValue.totalMatchUps;return yH(PH({matchUpFormatDifferences:v,matchUpCountDifference:P,descendantDifferences:a,ancestorDifferences:l,orderDifference:m,valueDifference:I,nameDifference:f,descendantDesc:u,ancestorDesc:p},V),{different:g})}function tS(t,e){let r=0;return{totalValue:e.collectionIds.reduce((o,i)=>{const s=t[i],{collectionValueProfiles:a,collectionValue:l,matchUpCount:c,matchUpValue:u}=s;return r+=c,a?o+a.reduce((d,p)=>d+p.value,0):u&&c?o+u*c:o+l},0),totalMatchUps:r}}var SH=Object.defineProperty,rS=Object.getOwnPropertySymbols,OH=Object.prototype.hasOwnProperty,bH=Object.prototype.propertyIsEnumerable,nS=(t,e,r)=>e in t?SH(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,TH=(t,e)=>{for(var r in e||(e={}))OH.call(e,r)&&nS(t,r,e[r]);if(rS)for(var r of rS(e))bH.call(e,r)&&nS(t,r,e[r]);return t};function wH({tournamentRecord:t}){if(!t)return{error:re};if(typeof t!="object"||!t.tournamentId)return{error:X};const{matchUps:e}=Wt({tournamentRecord:t,inContext:!1});if(e!=null&&e.length){const r=EH({tournamentRecord:t});NH(e,r)}return TH({},V)}function EH({tournamentRecord:t}){const e={};for(const r of t.events||[]){r.matchUpFormat&&(e[r.eventId]=r.matchUpFormat);for(const n of r.drawDefinitions||[]){n.matchUpFormat&&(e[n.drawId]=n.matchUpFormat);for(const o of n.structures||[]){o.matchUpFormat&&(e[o.structureId]=o.matchUpFormat);for(const i of o.structures||[])i.matchUpFormat&&(e[i.structureId]=i.matchUpFormat)}}}return e}const $H=["collectionId","collectionPosition","drawPositions","extensions","finishingPositionRange","finishingRound","isMock","matchUpId","matchUpStatus","matchUpStatusCodes","orderOfFinish","processCodes","roundNumber","tieFormat","tieMatchUps","roundPosition","score","sides","winnerMatchUpId","loserMatchUpId","matchUpDuration","winningSide"];function NH(t,e={}){for(const r of t){const{structureId:n,drawId:o,eventId:i}=r,s=e[n]||e[o]||e[i],a=r.matchUpFormat===s?void 0:r.matchUpFormat;for(const l of Object.keys(r))$H.includes(l)||delete r[l];r.sides&&r.drawPositions&&!r.tieMatchUps&&delete r.sides,a&&(r.matchUpFormat=a)}}function cc({court:t,date:e}){const r=e&&t.dateAvailability.find(o=>so(o.date,e)),n=t.dateAvailability.find(o=>!o.date);return r||n}function Ca({includeBookingTypes:t=[],courtDate:e}){const r=[];let n=wt(e.startTime);(e.bookings||[]).filter(i=>!i.bookingType||!t.includes(i.bookingType)).sort((i,s)=>uu(i.startTime).localeCompare(uu(s.startTime))).forEach(i=>{const s={startTime:ct(n.toISOString()),endTime:i.startTime};wt(i.startTime)>n&&r.push(s),wt(i.endTime)>n&&(n=wt(i.endTime))});const o={startTime:ct(n.toISOString()),endTime:e.endTime};return wt(e.endTime)>n&&r.push(o),r}function UH({averageMatchUpMinutes:t,includeBookingTypes:e,periodStartTime:r,periodEndTime:n}){const o=s=>!!Ca({includeBookingTypes:e,courtDate:s}).filter(i).length;function i(s){const a=wt(s.startTime),l=wt(s.endTime);return a>r||l<n?!1:Ol(r,l)>=t}return{enoughTime:o}}function oS(t){const{averageMatchUpMinutes:e,includeBookingTypes:r,periodStart:n,date:o}=t,i=t.courts,s=wt(n),a=Pf(s,e),{enoughTime:l}=UH({averageMatchUpMinutes:e,includeBookingTypes:r,periodStartTime:s,periodEndTime:a});return{availableToScheduleCount:((i==null?void 0:i.filter(u=>{if(!Array.isArray(u.dateAvailability))return!1;const d=cc({date:o,court:u});return!!(d&&l(d))}))||[]).length}}function Vv(t){const{remainingScheduleTimes:e=[],clearScheduleDates:r,periodLength:n=30,scheduleDate:o,courts:i=[]}=t;let{bookings:s=[]}=t;if(!Array.isArray(i)||!i.length)return{error:X,courts:i};if(!Array.isArray(s))return{error:af};if(!Gr(o))return{error:yr};r&&(Array.isArray(r)?r.includes(o)&&(s=[]):s=[]);const{courtBookings:a,unassignedBookings:l}=s.reduce((v,f)=>{const{courtId:m}=f;return m?v.courtBookings[m]?v.courtBookings[m].push(f):v.courtBookings[m]=[f]:v.unassignedBookings.push(f),v},{courtBookings:{},unassignedBookings:[]}),c=i.map((v,f)=>{const{courtId:m,courtName:g}=v,h=a[m]||[],_=cc({date:o,court:v})||{},{bookings:I=[],startTime:P,endTime:y,date:S}=_,b=[e[f]&&{startTime:P,endTime:e[f]},...ve(I,!1,!0),...h].filter(Boolean);return{courtId:m,courtName:g,dateAvailability:{bookings:b,startTime:P,endTime:y,date:S}}});l.sort((v,f)=>xe(v.startTime)-xe(f.startTime));const u=()=>c.map(v=>{const f=v.dateAvailability,m=Ca({courtDate:f});return{courtName:v.courtName,courtId:v.courtId,timeSlots:m}}).flat(),d=[];for(const v of l){const{startTime:f,endTime:m,averageMinutes:g,recoveryMinutes:h,matchUpId:_}=v,I=xe(f),P=xe(m),S=u().reduce((O,{courtId:b,courtName:w,timeSlots:T})=>{let E;return T.find(({startTime:$,endTime:A})=>{E=xe($)-I;const U=I>=xe($);return P<=xe(A)&&O.startDifference!==0&&((E===0||E+n>=0)&&(O.startDifference===void 0||E<O.startDifference)||U)})?{courtName:w,courtId:b,startDifference:E}:O},{});if(S.courtId){const O={averageMinutes:g,recoveryMinutes:h,matchUpId:_,startTime:f,endTime:m};d.push(O);const b=c.find(({courtId:w})=>w===S.courtId);b==null||b.dateAvailability.bookings.push(O)}else console.log({unassignedBooking:v})}return{virtualCourts:c.map(({courtId:v,courtName:f,dateAvailability:m})=>({dateAvailability:[m],courtName:f,courtId:v})),assignedBookings:d}}function nd({averageMatchUpMinutes:t,periodLength:e=30,recoveryMinutes:r}){const n=(t||90)+(r||0);return e>n?n:e||30}function Ma({scheduleDate:t,startTime:e,endTime:r,courts:n}){const o=e&&"startTime"||r&&"endTime"||void 0;return n.reduce((i,s)=>{const a=cc({date:t,court:s}),l=o&&((a==null?void 0:a[o])||s[o]);return l&&(!i||e&&xe(l)<xe(i)||xe(l)>xe(i))?l:i},void 0)}function AH({averageMinutes:t,startTime:e,endTime:r,courts:n,date:o}){e=e||Ma({courts:n,scheduleDate:o,startTime:!0}),r=r||Ma({courts:n,scheduleDate:o,endTime:!0});let i;if(e&&r){const s=wt(e),a=wt(r);for(const l of n||[]){if(!Array.isArray(l.dateAvailability))continue;const c=cc({court:l,date:o});Ca({courtDate:c}).forEach(d=>{const p=wt(d.startTime),v=wt(d.endTime);if(p>a||p<s||v<s)return!1;if(Ol(p,v)>=t){const g=ct(p.toISOString());(!i||g<i)&&(i=g)}})}}return{firstTimeSlotStartTime:i}}function iS(t){const{startTime:e="8:00",endTime:r="20:30",count:n=10,date:o}=t||{};return pe(0,n).map(()=>({dateAvailability:[{date:o,startTime:e,endTime:r}]}))}function Bv(t){let{date:e=_f(),startTime:r="08:00",endTime:n="19:00",periodLength:o,courts:i}=t;const{calculateStartTimeFromCourts:s=!0,remainingScheduleTimes:a,averageMatchUpMinutes:l,clearScheduleDates:c,courtsCount:u,bookings:d}=t;o=o||nd({averageMatchUpMinutes:l}),e=Re(e),r=ct(r),n=ct(n);let p=0,v=0,f=0,m=0,g=0;!i&&u&&(i=iS({startTime:r,endTime:n,count:u,date:e}));const{virtualCourts:h}=Vv({remainingScheduleTimes:a,clearScheduleDates:c,scheduleDate:e,periodLength:o,bookings:d,courts:i}),{firstTimeSlotStartTime:_}=AH({averageMinutes:l,courts:h,startTime:r,endTime:n,date:e});s&&_&&(r=_||r);const I=xe(r),y=xe(n)-I,S=Math.floor(y/o),b=pe(0,S+1).map(T=>{const E=I+T*o,N=BL(E),{availableToScheduleCount:$}=oS({courts:h||[],averageMatchUpMinutes:l,periodStart:N,date:e}),A=$>v?$-v:0;g+=T?$:0;const U=T?g/T:$,M=o*U/l,D=T?M*(T-1)+U:U,R=$?v&&D-p||A:0;p=D,v=$,f+=R;const j=Oe(f)-m;return m+=j,{periodStart:N,add:j,availableToScheduleCount:$,newCourts:A,totalMatchUps:m}});return{scheduleTimes:b.reduce((T,E)=>{const $=pe(0,E.add).map(()=>({scheduleTime:E.periodStart}));return T.concat(...$)},[]).flat(),timingProfile:b,totalMatchUps:m}}const CH={getCourtsAvailableAtPeriodStart:oS,generateTimeSlots:Ca,getScheduleTimes:Bv,courtGenerator:iS},MH=(t,e)=>t.filter(Boolean).every(r=>typeof r===e),DH=t=>t.filter(Boolean).every(Ut);function sS({consideredDate:t,category:e}={consideredDate:""}){var r;const n={error:X,ageMin:8,ageMax:99};if(typeof e!="object"||!Gr(t))return n;const o=parseInt(t.split("-")[0]),i=[];let{ageCategoryCode:s,ageMaxDate:a,ageMinDate:l,ageMax:c,ageMin:u}=e;const d=e.categoryName;let p;if(!MH([s,a,l,d],"string")||!DH([c,u]))return n;s=s??d;const v=/^([UO]?)(\d{1,2})([UO]?)$/,f=/^C(\d{1,2})-(\d{1,2})$/,m=s==null?void 0:s.includes("-"),g=m&&(s==null?void 0:s.match(f)),h=s==null?void 0:s.match(v),_=w=>w.match(/^\d{2}-\d{2}$/),I=(w,T,E)=>Gr(T)&&T||T&&_(T)&&`${w}-${T}`||`${w}-${E}`,P=w=>{const T=o-w;return l=I(T,l,"01-01"),c&&c!==w-1&&i.push(`Invalid ageMax: ${c}`),c||(c=w-1),{ageMinDate:l,ageMax:c}},y=w=>{const T=o-w-1;return l=I(T,l,"01-01"),c&&c!==w&&i.push(`Invalid ageMax: ${c}`),c||(c=w),{ageMinDate:l,ageMax:c}},S=w=>{const T=o-w-2;return a=I(T,a,"12-31"),u&&u!==w+1&&i.push(`Invalid ageMin: ${u}`),u||(u=w+1),{ageMaxDate:a,ageMin:u}},O=w=>{const T=o-w-1;return a=I(T,a,"12-31"),u&&u!==w&&i.push(`Invalid ageMin: ${u}`),u||(u=w),{ageMaxDate:a,ageMin:u}},b=w=>{const[T,E,N]=(w.match(v)||[]).slice(1),$=parseInt(E);T==="U"&&({ageMinDate:l,ageMax:c}=P($)),N==="U"&&({ageMinDate:l,ageMax:c}=y($)),T==="O"&&({ageMaxDate:a,ageMin:u}=S($)),N==="O"&&({ageMaxDate:a,ageMin:u}=O($))};if(g){const[w,T]=((r=s==null?void 0:s.match(f))!=null?r:[]).slice(1).map(E=>parseInt(E));w<=T?(u=u??w,c=c??T,p=!0):i.push(`Invalid combined age range ${s}`)}else m?s==null||s.split("-").forEach(b):h&&b(s);return i.length?{error:i,ageMin:8,ageMax:99}:ye({combinedAge:p,ageMaxDate:a,ageMinDate:l,ageMax:c,ageMin:u})}function od({tiebreakTo:t=7,scoreString:e}){return e.split(" ").filter(Boolean).map((n,o)=>r({set:n,setNumber:o+1}));function r({set:n,setNumber:o}){const i=(n==null?void 0:n.startsWith("["))&&n.split("[")[1].split("]")[0].split("-").map(g=>parseInt(g)),s=n.includes("(")&&n.split("(")[0]||n.includes("[")&&n.split("[")[0]||n,a=!i&&s.split("-").map(g=>parseInt(g)),l=i?i[0]>i[1]&&1||i[0]<i[1]&&2||void 0:a[0]>a[1]&&1||a[0]<a[1]&&2||void 0,c=n.includes("(")?n.split("(")[1].split(")")[0]:void 0,d=c&&Cv({lowValue:c,isSide1:l===2,tiebreakTo:t})||[],[p,v]=a||[],[f,m]=i||d||[];return{side1Score:p,side2Score:v,side1TiebreakScore:f,side2TiebreakScore:m,winningSide:l,setNumber:o}}}function kv({drawPositions:t}){const e=o=>t.filter(i=>i!==o).map(i=>[o,i]),r=[].concat(...t.map(e)),n=He(r.map(id)).map(o=>o.split("|").map(i=>+i));return{groupMatchUps:r,uniqueMatchUpGroupings:n}}function id(t){return t.sort(er).join("|")}function aS({groupSize:t,drawPositionOffset:e}){const r=d=>[...Array(d)].map((p,v)=>v),n=r(2*Math.round(t/2)+1).slice(1),o=r(n.length-1).map(()=>[]);let i=n.slice(0,n.length/2),s=n.slice(n.length/2);n.slice(1).forEach((d,p)=>{i.forEach((g,h)=>{o[p].push([i[h],s[h]])});const v=i.shift(),f=i.pop(),m=s.shift();i=[v,m,...i].filter(Boolean),s=[...s,f].filter(Boolean)});const a=i.shift(),l=i.pop(),c=s.shift();i=[a,c,...i].filter(Boolean),s=[...s,l].filter(Boolean);const u=d=>d[0].reduce((p,v)=>p+v);return o.reverse().sort((d,p)=>u(d)-u(p)).map(d=>d.filter(p=>p.every(v=>v<=t)).map(p=>{const v=p.map(f=>f+e);return id(v)}))}function jH({rounds:t,hash:e}){return t.reduce((r,n,o)=>n.includes(e)?o+1:r,void 0)}const RH={getRoundRobinGroupMatchUps:kv,determineRoundNumber:jH,drawPositionsHash:id,groupRounds:aS},sd="\\d+-\\d+",uc="\\d+-\\d+\\(\\d+\\)",Gv="\\[\\d+-\\d+\\]",FH="\\d+-\\d+\\(\\d+-\\d+\\)",xH=new RegExp(`(${sd}),`,"g"),LH=new RegExp(`(${uc}),`,"g"),VH=[sd,uc,Gv,FH],BH=["0","1","2","00","01","10","11","002","012","102","112","000","001","010","100","011","101","110","111","002","012","102","112","0002","0012","0102","1002","0112","1012","1102","1112","3","03","13","013","103"].map(t=>{const r=t.split("").map(n=>VH[n]).join(" ");return new RegExp(`^${r}$`)});function lS(t){return!t||BH.some(e=>e.test(t))}function kH(t){const e="[];",r="()",n=e+r,o=[e[0],r[0]],i=Object.assign({},...n.split("").map(l=>({[l]:0})));let s="";const a=t.split("").map(l=>{const c=n.includes(l)&&l,u=o.includes(c);if(u&&c)return i[c]+=1,s=c,l;if(!u&&c&&s&&c!==s){i[s]-=1;const d=e.includes(s)&&e||r.includes(s)&&r||"",p=d.split("").find(v=>v!==s);if(d.includes(c))i[s]||(s="");else return i[c]||(s=""),p}return l}).join("");return t!==a?a:t}function ad(t){return/^\(\d+\)$/.test(t)||/^\(\d+$/.test(t)}function GH(t){return/^\(\d+-\d+\)$/.test(t)||/^\[\d+-\d+\]$/.test(t)}function Da(t){const r=(n=>n==null?void 0:n.split("-").join("").split("/").join(""))(t);if(/^\d+$/.test(r)&&r.length===2){const n=r.split("");return Math.abs(n.reduce((i,s)=>+i-+s))===1}return!1}function ld(t,e){const r=[t.slice(e,e+2),e?t.slice(0,1):t.slice(2)].map(i=>parseInt(i.join(""))),n=e?r.reverse():r;if(Math.abs(n.reduce((i,s)=>+i-+s))>=2)return n.join("-")}function cS(t){return t.length===2?t.split("").join("-"):([", ",",","/"," "].forEach(e=>t=t.split(e).join("-")),t=t.replace(/-{2,}/,"-"),t)}function WH(t){return t.startsWith("(")&&t.endsWith(")")}function HH({score:t,applied:e}){t=kH(t);const r=/\)(\d+)/g;if(r.test(t))for(const S of t.match(r)){const O=S.replace(")",") ");t=t.replace(S,O)}t=t.replace(/\)\//g,") / "),t=t.replace(/\/\)/g,")");const n=/\(([\d- ]+)\)/g,o=/\(([\d- ]+)\)/,i=t.match(n);for(const S of i||[]){const[O]=S.match(o).slice(1),b=O.replace(/ /g,"");t=t.replace(S,`(${b})`)}let s=/\(\(\d-\d\)\)/g;if(s.test(t)){const S=t.match(s);S.length&&S.forEach(O=>{const b=O.match(/\((\(\d-\d\))\)/).slice(1)[0];t=t.replace(O,b)})}if(s=/\(\((\d)\)\)/g,s.test(t)){const S=t.match(s);S.length&&S.forEach(O=>{const b=O.match(/\((\(\d\))\)/).slice(1)[0];t=t.replace(O,b)})}/(^|\s)6-,/.test(t)&&(t=t.replace(/(^|\s)6-,/g,"6-0,"));const a=new RegExp(/[-,]{2,}/g);t=t.replace(a,"-"),["- "," -"].forEach(S=>{const O=new RegExp(`(\\d+)${S}(\\d+)`,"g"),b=t.match(O);b&&b.forEach(w=>t=t.replace(w,w.split(S).join("-")))}),/^[(-/,]+$/.test(t)&&(t=""),/\)[-/,]+$/.test(t)&&(t=t.slice(0,t.length-1)),/\d \/\d/.test(t)&&(t=t.replace(/ \//g,"/")),t.includes(" /")&&(t=t.replace(/ \//g," "));const l=/\(\d+, \)/g;l.test(t)&&t.match(l).forEach(O=>{const[b]=O.match(/\((\d+), \)/).slice(1);b.length===2?t=t.replace(O,`(${b})`):b.length===1&&b==="6"&&(t=t.replace(O,"(6-0)"))});const c=/\((\d+)\/\)/g;c.test(t)&&t.match(c).forEach(O=>{const[b]=O.match(/\((\d+)\/\)/).slice(1);b.length===2?t=t.replace(O,`(${b})`):b.length===1&&b==="6"?t=t.replace(O,"(6-0)"):t=t.replace(O,`(${b})`)});const u=/\d\/\d\/,/g;u.test(t)&&t.match(u).forEach(O=>{const[b]=O.match(/(\d\/\d)\/,/).slice(1);t=t.replace(O,`${b},`),e.push("slashComma")});const d=/\(\/(\d+)\)/g;d.test(t)&&t.match(d).forEach(O=>{const[b]=O.match(/\(\/(\d+)\)/).slice(1);b.length===2?t=t.replace(O,`(${b})`):b.length===1&&parseInt(b)<6?t=t.replace(O,`(6-${b})`):t=t.replace(O,`(${b})`)});let p,v,f,m,g;const h=()=>{g=$r(t.split("")),v=g["("]===(g[")"]||0)+1,p=(g["("]||0)+1===g[")"],f=g["["]===g["]"]+1,m=v&&!f};h();const _=/(\d+-\d+\(\d+)0,/;if(_.test(t)){const[S]=t.match(_).slice(1);t=t.replace(_,S+")")}if(g["("]===g[")"]&&g["("]>1){const S=t.split(")(").join(") (").split(" ");S.every(WH)?t=S.map(O=>{const b=O.slice(1,O.length-1);return b.length>2?b:O}).join(" "):t=S.join(" ")}h();const I=/[A-Za-z]+/.test(t),P=/\d+/.test(t);if(!I&&!P)return{score:""};if(/^\[.+\]$/.test(t)&&"()/,- ".split("").some(S=>g[S])&&(t=t.slice(1,t.length-1)),/^\(.+\)$/.test(t)&&g["("]===1&&g[")"]===1&&"[]/,".split("").some(S=>g[S]>1)&&(t=t.slice(1,t.length-1)),t.startsWith("(")&&t.endsWith("))")&&(t=t.slice(1,t.length-1)),g["("]>(g[")"]||0)&&t[t.length-1]==="("&&(t=t.slice(0,t.length-1)+")",h()),g["("]===1&&!g[")"]&&t[0]==="("&&(t=t+")",h()),g["("]>(g[")"]||0)&&t.slice(0,2)==="(("&&(t=t.slice(1)),p){if(/^9\d/.test(t))t="("+t.slice(1);else if(t[0]!=="(")t="("+t;else{const S=[];let O=0;for(const b of t.split("").reverse())b===")"&&(O?S.push("("):O+=1),b==="("&&(O-=1),S.push(b);S.reverse(),t=S.join("")}h()}if(g[")"]>(g["("]||0)&&t[0]===")"&&(t="("+t.slice(1),h()),m&&(t.endsWith(9)||/\d+0$/.test(t))&&(t=t.slice(0,t.length-1)+")",h()),m&&(!t.endsWith(")")||t.startsWith("(("))&&(t=t+")",h()),m){let S="",O=0;for(const b of t.split(""))b==="("&&(O?S+=")":O+=1),b===")"&&(O-=1),S+=b;t=S}h(),f&&!v&&(t=t+"]"),t.includes("([")&&t.includes("])")&&(t=t.split("([").join("[").split("])").join("]"),h()),/\(\d+0$/.test(t)&&(t=t.slice(0,t.length-1)+")"),h(),g[")"]===1&&!g["("]&&t.endsWith(")")&&(t=t.slice(0,t.length-1)),t.startsWith("(")&&t.endsWith(")")&&g["("]===1&&g[")"]===1&&(t=t.slice(1,t.length-1),h());const y=S=>{const O=S.indexOf("("),b=S.indexOf(")");return O>=0&&b>=0&&O<b};if(/^\([\d ]+.*[\d ]+\)$/.test(t)&&g["("]===g[")"]){const S=t.slice(1,t.length-1);y(S)&&(t=S,h())}return{score:t,applied:e}}function cd(t){if(!/^[\d-]+(\(\d\))*$/.test(t))return t;const e=Rn("-",t.split(""));if(!e.length)return t;const r=t.split("-"),n=!(r.length%2),o=!!(e.length%2);return n&&o&&e.length>r.length/2&&e.filter((s,a)=>a%2).forEach(s=>{t=t.substring(0,s)+" "+t.substring(s+1)}),t}function qH({score:t,applied:e}){return t.includes("( ")&&(e.push("removeParenSpacingAfterOpen"),t=t.split("( ").map(r=>r.trim()).join("(")),t.includes(" )")&&(e.push("removeParenSpacingBeforeClose"),t=t.split(" )").map(r=>r.trim()).join(")")),[xH,LH].forEach(r=>{const n=t.match(r);n!=null&&n.length&&(n.forEach(o=>{t=t.replace(o,o.slice(0,o.length-1)+" ")}),e.push("setsEndComma"))}),t=t.split(" ").filter(Boolean).map(cd).join(" "),{score:t,applied:e}}function zH({score:t}){if(typeof t!="string")return{score:t};const e=p=>p==null?void 0:p.split("-").join("").split("/").join(""),r=p=>p.split("[").join("(").split("]").join(")");t=t.split(", ").join(" ");let n=t.split(" ");t=n.map(p=>{const v=/^-(\d+)$/;if(v.test(p)){const[f]=p.match(v).slice(1);if(f.length===2)return f.split("").join("-")}return p}).join(" "),n=t.split(" ");const o=n.filter(ad);let i=0,s="";for(const p of o){const v=Rn(p,n).filter(h=>!i||h>i)[0],f=n.slice(i,v-1),m=n[v-1],g=e(m);if(/^\d+$/.test(g)&&g.length===2){const h=g.split(""),_=Math.abs(h.reduce((I,P)=>+I-+P));if(_===1){const I=[f.join(" "),[m,p].join("")].join(" ");s+=I,i=v+1}else if(_===0){const I=Math.max(...h);if([4,5,6,7,8,9].includes(I)){const P=[6,4].includes(I)?I+1:I-1,y=[I,P].sort().reverse().join("-"),S=[f.join(" "),[y,p].join("")].join(" ");s+=S,i=v+1}}}}if(o.length&&s.length){const p=n.slice(i).join(" ");return s=[s,p].join(" "),{score:s.trim()}}if(n.length===2&&["(","["].some(p=>n[1].includes(p))){const v=e(n[0]).split("");if(Math.abs(v.reduce((m,g)=>+m-+g,0))===1)return n[1]=r(n[1]),{score:n.join("")}}const a=n.map(p=>GH(p)&&"bracket"||Da(p)&&"set");if(a.includes("set")&&a.includes("bracket")){let p,v="";return n.forEach((f,m)=>{a[m]==="bracket"&&p==="set"?(f=r(f),v+=f):v+=` ${f}`,p=a[m]}),{score:v.trim()}}n=t.split(" ");let l,c=n.map(p=>{const v=new RegExp(/^(\d+)-(\d+)$/);if(v.test(p)){const[f,m]=p.match(v).slice(1),g=Math.abs([f,m].reduce((_,I)=>+_-+I)),h=Math.max(f,m);if(g===1)return l="tiebreakSet",l;if(g>=2&&h>=7&&l==="tiebreakSet")return l="tiebreak",l}});const u=Rn("tiebreak",c);if(u.length){let p="";n.forEach((v,f)=>{u.includes(f)?p+=`(${v}) `:u.includes(f+1)?p+=`${v}`:p+=`${v} `}),t=p.trim()}const d=/(\d+-\d+)\((\d+)-(\d+)\)$/;if(d.test(t)){const[p,v,f]=t.match(d).slice(1),g=Math.max(v,f)>=10;!Da(p)&&g&&(t=t.replace(d,`${p} [${v}-${f}]`))}return c=[],t=t.split(" ").map(p=>{const v=/^\((.*)\)$/,f=v.test(p),m=new RegExp(Gv).test(p)&&"super"||new RegExp(uc).test(p)&&"tiebreak"||new RegExp(sd).test(p)&&"standard"||"unknown";return c.push(m),m==="standard"&&f?p.match(v)[1]:p}).join(" "),{score:t}}function YH({score:t,applied:e}){for(const T of[".",","," ","/"]){const E=new RegExp(`^(\\d+)\\${T}(\\d+)$`);if(E.test(t)){const N=t.match(E).slice(1).map(A=>parseInt(A)),$=Math.abs(N[0]-N[1]);$<=10&&$>=2&&(t=t.split(T).join("-"),e.push("variedJoinerPattern"))}}t.includes(";")&&(t=t.split(";").join(" "),e.push("semicolon set separation"));const r=/(^|\s)(\d)\/(\d)(\d)\/(\d)(\(|$)/;if(r.test(t)){const[T,E,N,$,A,U]=t.match(r).slice(1);t=t.replace(r,`${T}${E}-${N} ${$}-${A}${U}`),e.push("smashSlashPattern")}/.*\s6[/-]+$/.test(t)&&(t+="0",e.push("incompleteFinalSetPattern"));const o=/\(6,\)/g;o.test(t)&&(t=t.replace(o,"(6, 0)"),e.push("missingZeroPattern1"));const i=/^\d{3,}\(/,s=/\(\d+\)\d+/;[i,s].forEach(()=>{t=t.split(" ").map(E=>(i.test(E)&&(E=E.replace("("," (")),s.test(E)&&(E=E.replace(")",") ")),E)).join(" "),e.push("spaceConsiderationPatterns")});const l=cd(t);l!==t&&(t=l,e.push("deDashMash"));const c=/^(\d)[-/,]+(\d{2})[-/,]+(\d)$/;if(c.test(t)){const[T,E,N]=t.match(c).slice(1),[$,A]=E.split("");t=`${T}-${$} ${A}-${N}`,e.push("smashSetPattern")}const u=/^(\d+)[ -](\d+)$/,d=/^([\d -]+)\/([\d -]+)$/;if(d.test(t)){const[T,E]=t.match(d).slice(1),N=T.trim(),$=E.trim();if(u.test(N)&&u.test($)){const A=N.match(u).slice(1,3).join("-"),U=$.match(u).slice(1,3).join("-");t=`${A} ${U}`,e.push("slashSeparationPattern")}}const p=/^([\d -]+),([\d -]+)$/;if(p.test(t)){const[T,E]=t.match(p).slice(1),N=T.trim(),$=E.trim();if(u.test(N)&&u.test($)){const A=N.match(u).slice(1,3).join("-"),U=$.match(u).slice(1,3).join("-");t=`${A} ${U}`,e.push("commaSeparationPattern")}}const v=/^\d \d,/;if(v.test(t)){const T=t.match(v)[0],E=T.slice(0,T.length-1).split(" ").join("-");t=t.replace(T,E),e.push("singleSetCommaSeparationPattern")}let f=0;const m=/(\d+)-(\d{2})-(\d+)/;for(;m.test(t)&&f<3;){const[T,E,N]=t.match(m).slice(1),$=E.split(""),A=`${T}-${$[0]} ${$[1]}-${N}`;t=t.replace(m,A),e.push("noSetSeparationPattern"),f+=1}const g=/(^|\s)7-6\s(\d+)\s/g,h=t.match(g);if(h!=null&&h.length){const T=/(^|\s)7-6\s(\d+)\s/;h.forEach(E=>{const N=E.match(T).slice(2)[0];t=t.replace(E,`7-6(${N}) `),e.push("floatingTiebreakPattern1")})}let _=t.match(/\d \d /);_==null||_.forEach(T=>{const E=T.slice(0,T.length-1).split(" ").join("-");t=t.replace(T,E),e.push("spaceSeparatedSetPattern1")}),_=t.match(/ \d \d$/),_==null||_.forEach(T=>{const E=" "+T.slice(1).split(" ").join("-");t=t.replace(T,E),e.push("spaceSeparatedSetPattern2")});const I=/^\d, *\d\/\d, *\d/;if(I.test(t)){const T=t.match(I)[0],E=T.split("/").map(N=>`(${N})`).join(" ")+" ";t=t.replace(T,E),e.push("slashCommaSetPattern")}const P=/\(6-\)/g;P.test(t)&&(t=t.replace(P,"(6-0)"),e.push("missingZeroPattern2"));const y=new RegExp("(?<!-)(\\d+)\\/(\\d+)(?!-)","g");if(y.test(t)){const T=t.match(y),E=new RegExp("(?<!-)(\\d+)\\/(\\d+)(?!-)");let N=t;T.forEach($=>{const[A,U]=$.match(E).slice(1),C=`${A}-${U}`;N=N.replace($,C)}),t=N,e.push("slashSetPattern")}const S=/(.*)\s(1\d)\s(\d+)$/;if(S.test(t)){const[T,E,N]=t.match(S).slice(1);T.replace(/\D/g,"").length>=4&&(t=T+` ${E}${N}`,e.push("spaceSeparatedSuperPattern"))}const O=/(^|\s)(\d+-\d+)\s(\d+)(\s|$)/g;for(const T of t.match(O)||[]){const[E,N,$,A]=T.match(/(^|\s)(\d+-\d+)\s(\d+)(\s|$)/).slice(1),[U,C]=N.split("-").map(D=>parseInt(D));Math.abs(U-C)===1&&(t=t.replace(T,`${E}${N}(${$})${A}`),e.push("spaceSeparatedSetPattern"))}const b=/\d-\d \(\d{1,2}\)(\s|$|,)/g;for(const T of t.match(b)||[]){const E=/(\d-\d) \((\d{1,2})\)(\s|$|,)/,[N,$,A]=T.match(E).slice(1),[U,C]=N.split("-").map(D=>parseInt(D));Math.abs(U-C)===1&&(t=t.replace(T,`${N}(${$})${A}`),e.push("floatingTiebreakPattern2"))}const w=/(^|\s)(\d \d)\(/g;for(const T of t.match(w)||[]){const E=/(^|\s)(\d \d)\(/,[N,$]=T.match(E).slice(1);t=t.replace(T,`${N}${$.split(" ").join("-")}(`),e.push("spacedTiebreakPattern")}return{score:t,applied:e}}function KH({score:t,matchUpStatus:e}){var r;let n=t==null?void 0:t.split(" ");t=n.map(l=>{if(l.endsWith("]")){const c=l.split("[");if(Da(c[0]))return c[0]+`(${c[1].slice(0,c[1].length-1)})`}return l}).join(" ");const o=new RegExp(/(\([\d ]+\))/g);if(o.test(t))for(const l of t.match(o)){let u=(r=l.replace(" ","-").match(/\((.*)\)/))==null?void 0:r[1];if(Ut(u)&&(u==null?void 0:u[0])>2){if([2,4].includes(u.length))u=u.split("").join("-");else if(u.length===3){const d=u.indexOf("1");u=ld(u.split(""),d)}}t=t.replace(l,`(${u})`)}n=t==null?void 0:t.split(" ");let i=new RegExp(/^(\d[-/]+\d)\((\d+)[-/]+(\d+)\)$/);const s=n.length-1;t=n.map((l,c)=>{const u=[void 0,"","COMPLETED"].includes(e)||c!==s;if(i.test(l)&&u){const[d,p,v]=Array.from(l.match(i)).slice(1),f=Math.min(p,v);return`${d}(${f})`}return l}).join(" "),n=t==null?void 0:t.split(" "),i=new RegExp(/^(\d{2})\((\d+)\)$/),t=n.map(l=>{if(i.test(l)){const[c,u]=Array.from(l.match(i)).slice(1),d=c.split("");return`${d[0]}-${d[1]}(${u})`}return l}).join(" "),n=t==null?void 0:t.split(" "),i=new RegExp(/^\((\d[-/]+\d)\)(\d+)$/),t=n.map(l=>{if(i.test(l)){const[c,u]=Array.from(l.match(i)).slice(1);return Da(c)?`${c}(${u})`:c}return l}).join(" "),n=t==null?void 0:t.split(" "),i=new RegExp(/^1-0\((\d+)\)$/),t=n.map(l=>{if(i.test(l)){const[c]=l.match(i).slice(1);return`[${c<9?10:parseInt(c)+2}-${c}]`}return l}).join(" ");const a=/\((\d)+0 /;if(a.test(t)){const l=t.match(a)[1];t=t.replace(a,`(${l}) `)}return{score:t}}function QH({score:t,attributes:e,identifier:r}){var n;if(typeof t!="string")return{score:t,identifier:r};const o=new RegExp(/\([\d,/ ]+\)/g),i=t.match(o);for(const p of i||[]){const v=p.match(/^\((.*)\)$/),f=(n=v==null?void 0:v.slice(1))==null?void 0:n[0],g=t.split(p)[0].split(")").reverse()[0].replace(/\D/g,"");if((f==null?void 0:f.length)===2&&(g==null?void 0:g.length)>=2){const I=g.slice(g.length-2).split("").map(y=>parseInt(y));if(Math.abs(I[0]-I[1])===1)continue}const h=cS(f),_=cd(h);t=t.replace(p,`(${_})`).trim()}const s=new RegExp(/\[[\d,/ ]+\]/g),a=t.match(s);a==null||a.forEach(p=>{const v=cS(p.match(/^\[(.*)\]$/)[1]);t=t.replace(p,`(${v}) `).trim()});const l=[")","]"],c=[")(","), (",") (",")[",") [","](","] ("];if(t.startsWith("(")&&l.some(p=>t.endsWith(p))&&c.some(p=>t.includes(p))){let p="";const v=t.split(/[)\]]/).filter(Boolean).map(_=>(_.startsWith(",")&&(_=_.slice(1)),_.trim())),f=v.every(_=>_.includes(",")||ad(_)),m=v.every(_=>_.includes("/")||ad(_)),g=v.every(_=>_.includes("-")||ad(_)),h=f&&","||g&&"-"||m&&"/";if(h){let _;v.forEach(I=>{if(I.startsWith("("))if(_==="set"&&(p+=" "),I.includes(h))p+=I.slice(1).split(h).map(P=>P.trim()).join("-"),_="set";else{const P=I.slice(1);p+=`(${P}) `,_="tiebreak"}else if(I.startsWith("[")){const P=I.slice(1).split(h).map(S=>parseInt(S.trim())),y=Math.min(...P);_==="set"?p+=`(${y}) `:p+=`[${P.join("-")}] `,_="tiebreak"}}),t=p.trim()}}const u=$r(t.split(""));u["("]===1&&u[")"]===1&&t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,t.length-1),u["-"]===1&&Da(t)&&Ut(e==null?void 0:e.removed)&&(t=t+`(${e.removed})`,e.removed=void 0));const d=/\(\)/g;return d.test(t)&&(t=t.replace(d,"").trim()),{score:t}}function uS({score:t}){const e=t.split(""),r=[];let n;const o=()=>n=[void 0,void 0,void 0],i=()=>{let a=`${n[0]}-${n[1]}`;return n[2]&&(a+=` (${n[2]})`),o(),n.push(n),a};o();const s=()=>n[0]!==void 0&&n[1]!==void 0&&Math.abs(parseInt(n[0])-parseInt(n[1]));for(;e.length;){const a=e.shift(),l=Ut(a)&&parseInt(a),c=n[0]!==void 0&&n[1]!==void 0;if(Ut(l)){if(n[0]===void 0){n[0]=l;continue}if(n[1]===void 0&&(n[1]=l,s()||0>1)){r.push(i()),n=[void 0,void 0];continue}if(c&&e.length===1&&Ut(e[0])){const u=e.pop();n[0]=n[0].toString()+n[1].toString(),n[1]=u,r.push(i()),n=[void 0,void 0]}c&&s()}}return{sets:r}}function Wv(t){const e=t.indexOf("1"),r=t.split(""),n=r.every(o=>!isNaN(o));if(n&&t.length===3&&e===0){const o=ld(r,e);if(o)return o}if(n&&t.length===7&&e>3){const o=r.slice(4),i=ld(o,e-4);if(i)return`${r[0]}-${r[1]} ${r[2]}-${r[3]} ${i}`}}function dS(t){let{score:e}=t;const{applied:r,matchUpStatus:n}=t,o=e==null?void 0:e.toString().split(""),i=o==null?void 0:o.every(a=>Ut(a)),s=a=>Math.abs(a[0]-a[1]);if(typeof e=="number"||i){e=e.toString().toLowerCase(),i&&(e=o.join(""));const a=i?o.map(l=>parseInt(l)):e.split("").map(l=>parseInt(l));if(uS({score:e}),a.length,e.length===3&&s(a.slice(0,2))===1){const[l,c,u]=a;e=`${l}-${c}(${u})`,r.push("numericTiebreakPattern1")}else if(e.length===3&&a[0]===1){const[l,c,u]=a;e=`[${l}${c}-${u}]`,r.push("numericTiebreakPattern2")}else if(e.length===4&&s(a.slice(0,2))===1&&"987654".split("").includes(a[0].toString())){const[l,c,u,d]=a,p=Math.min(u,d);e=`${l}-${c}(${p})`,r.push("numericTiebreakPattern3")}else if(e.length===4&&a[0]===1&&a[2]===1){const[l,c,u,d]=a;e=`[${l}${c}-${u}${d}]`,r.push("bigSuper")}else if(e.length===4){const[l,c,u,d]=a;e=`${l}${c} ${u}${d}`,r.push("split4")}else if(e.length===5&&s(a.slice(0,2))===1){const[l,c,u,d,p]=a;e=`${l}-${c}(${u}) ${d}-${p}`,r.push("numericTiebreakPattern4")}else if(e.length===5&&s(a.slice(3))===1){const[l,c,u,d,p]=a;e=`${l}-${c} ${u}-${d}(${p})`,r.push("numericTiebreakPattern5")}else if(a.length===7)if(s(a.slice(0,2))>1&&s(a.slice(2,4))>1&&a[4]===1){const[l,c,u,d,p,v,f]=a;e=`${l}-${c} ${u}-${d} [${p}${v}-${f}]`,r.push("numericTiebreakPattern6")}else if(s(a.slice(0,2))===1&&s(a.slice(3,5))>1&&s(a.slice(5,7))>1){const[l,c,u,d,p,v,f]=a;e=`${l}-${c}(${u}) ${d}-${p} ${v}-${f}`,r.push("numericTiebreakPattern7")}else if(s(a.slice(0,2))>1&&s(a.slice(2,4))===1&&s(a.slice(5,7))>1){const[l,c,u,d,p,v,f]=a;e=`${l}-${c} ${u}-${d}(${p}) ${v}-${f}`,r.push("numericTiebreakPattern8")}else if(s(a.slice(0,2))>1&&s(a.slice(2,4))>1&&s(a.slice(4,6))===1){const[l,c,u,d,p,v,f]=a;e=`${l}-${c} ${u}-${d} ${p}-${v}(${f})`,r.push("numericTiebreakPattern9")}else e=e.slice(0,2)+" "+e.slice(2,4)+" "+e.slice(4),r.push("numericMatchTiebreakPattern");else if(e.length%2){const l=Wv(e);l&&e!==l&&r.push("parsedSuperPattern"),e=l||e}else{const l=qt(e.split(""),2).map(g=>g.join("")),c=l.map(g=>{const[h,_]=g.split("").map(y=>parseInt(y)),I=Math.abs(h-_),P=h>_?1:2;return I>1&&P||P*-1}),u=c.reduce((g,h)=>g>0&&h>0,1),d=$r(c),p=c.map(g=>Math.abs(g)),v=$r(p),f=c[0]<0,m=!f&&c[1]<0;if(c[0]>0&&c[1]>0&&c[0]!==c[1])e=[l.slice(0,2).join(" "),l.slice(2).join("-")].join(" "),r.push("numeric3rdSetTiebreakPattern");else if(u)e=l.join(" "),r.push("chunkSplit");else if(a.length==6){if(d[1]==2||d[2]===2)if(!Object.values(v).includes(3))e=l.join(" "),r.push("chunkSplit");else{const[g,h,_,I,P,y]=a,S=c.reduce((O,b,w)=>b<0?w:O,void 0);if(S===0){const O=Math.min(_,I);e=`${g}-${h}(${O}) ${P}-${y}`,r.push("chunkSplitTiebreak1")}else if(S===1){const O=Math.min(P,y);e=`${g}-${h} ${_}-${I}(${O})`,r.push("chunkSplitTiebreak2")}else e=`${g}-${h} ${_}-${I}`,r.push("chunkSplitTrimExtraneous")}}else if(a.length===8){const[g,h,_,I,P,y,S,O]=a;f||m?a[5]===1&&(f?e=`${g}-${h}(${_}) ${I}-${P} [${y}${S}-${O}]`:e=`${g}-${h} ${_}-${I}(${P}) [${y}${S}-${O}]`):(c[0],c[1])}}}return{score:e,applied:r,matchUpStatus:n}}function pS(t){const e=[0,0],r=[],n=t.split(" "),o=/(\d+)-(\d+)/;n.forEach(l=>{if(o.test(l)){const c=l.match(o).slice(1).map(d=>parseInt(d)),u=c[0]>c[1]&&1||c[1]>c[0]&&2;u&&(e[u-1]+=1,r.push(u))}});const i=e[0]>e[1]&&1||e[1]>e[0]&&2,s=e[0]>0&&e[0]===e[1],a=e.reduce((l,c)=>l+c,0);return{setsWon:e,setsTied:s,setWinners:r,totalSets:a,winningSide:i}}function JH({score:t,matchUpStatus:e,attributes:r}){const n=[];let o;const i=t.split(" "),s=i.length;t=i.map((u,d)=>{if(new RegExp(uc).test(u)){const v=u.slice(3),f=u.slice(0,3),m=f.split("-");if(!Da(f)&&!e){const g=Math.max(...m),h=f.indexOf(g),_=[g,g-1];return(h?_.reverse().join("-"):_.join("-"))+v}}else if(u.length===2&&Ut(u))return u.split("").join("-");u=cd(u);const p=new RegExp(`^${Gv}$`).test(u)&&"super"||new RegExp(`^${uc}$`).test(u)&&"tiebreak"||new RegExp(`^${sd}$`).test(u)&&"standard"||"unknown";if(n.push(p),s>1&&p==="standard"&&d<2){const[v,f]=u.split("-"),m=Math.abs(parseInt(v)-parseInt(f)),g=Math.max(v,f),h=Math.min(v,f),_=[parseInt(v),parseInt(f)].indexOf(h);if(g>9&&m>2){const I=g.toString().split(""),P=I.find(y=>parseInt(y)>h||d&&parseInt(y)<=o)||I[0];P&&(u=_?[P,h].join("-"):[h,P].join("-"))}g>(o||0)&&(o=g)}if(p==="standard"){const[v,f]=u.split("-");if(!Math.abs(parseInt(v)-parseInt(f))&&e!=="RETIRED")return""}return u}).filter(Boolean).join(" ");const{setsWon:a,setWinners:l,totalSets:c}=pS(t);if(c===1&&(r==null?void 0:r.removed)==="6"&&(t+=" 6-0"),t.split(" ").length>2&&Math.max(...a)>=2&&l[0]===l[1]&&(t=t.split(" ").slice(0,2).join(" ")),Math.max(...a)>2){const u=[0,0];t=t.split(" ").map((d,p)=>(u[l[p]]+=1,Math.max(...u)>2?void 0:d)).filter(Boolean).join(" ")}return{score:t,profile:n}}function ZH({score:t}){const{setsTied:e,winningSide:r}=pS(t),n=/\s\((\d+)\)$/;if(!r&&e&&n.test(t)){const a=t.match(n).slice(1)[0],l=a<=8?10:a+2;t=t.replace(n,` [${l}-${a}]`)}const o=t.split(" "),i=o[o.length-1];if(!i.includes("-")||i.indexOf("(")>0)return{score:t};let s=i.split("(").join("").split(")").join("").split("-");if(!s.every(a=>Ut(a)))return{score:t};if(s[0]==="76"){const a=s[1].length===2?Math.min(...s[1].split("").map(l=>parseInt(l))):s[1];t=[...o.slice(0,o.length-1),`7-6(${a})`].join(" ")}else{s=s.map(c=>parseInt(c));const a=Math.max(...s);let l=Math.abs(s[0]-s[1]);if(a>=10){if(l>2&&s.every(c=>+c>=10)){const c=s.map(u=>u===a?u-10:10).sort();l=Math.abs(c[0]-c[1]),l>2&&(s=c)}t=[...o.slice(0,o.length-1),`[${s.join("-")}]`].join(" ")}else o.length===3&&a>=7&&l>2&&(t=[...o.slice(0,o.length-1),`[${s.join("-")}]`].join(" "))}return{score:t}}function XH({score:t}){return t=(t==null?void 0:t.toString().toLowerCase())||"",{score:t}}function eq({score:t,applied:e}){return typeof t!="string"?{score:t}:(t.toLowerCase().includes("o")&&(t=t.toLowerCase().split(" ").map(r=>r.split("o").join("0")).join(" "),e.push("replaceOh")),{score:t,applied:e})}function tq({score:t,applied:e}){return typeof t!="string"?{score:t}:(t=t.toLowerCase().split(" ").map(r=>{if(/^\d+$/.test(r)&&r.length>2){const n=r.indexOf("1");if(r.length%2){if(r.length===3&&n===0){const o=ld(r.split(""),n);return e.push("getSuper"),o}}else{const{score:o,applied:i}=dS({score:r,applied:[]});o!==r&&(r=o,e.push(...i))}}return r}).join(" "),{score:t,applied:e})}function rq({score:t,applied:e}){return typeof t!="string"?{score:t}:[3,4].includes(t.length)&&Wv(t)?{score:Wv(t)}:(t=t.toLowerCase().split(" ").map(r=>{if(/^\d+$/.test(r)&&r.length===1){e.push("removeErroneous1");return}return r}).filter(Boolean).join(" "),{score:t,applied:e})}function nq({score:t,applied:e}){return["walkover","wo","w/o","w-o"].includes(t==null?void 0:t.toString().toLowerCase())?(e.push("handleWalkover"),{matchUpStatus:"walkover",score:"",applied:e}):{score:t}}function oq({score:t,profile:e,applied:r}){var n;t=t==null?void 0:t.toString().toLowerCase();const o=/^(.*\d+.*)(ret|con)+[A-Za-z ]*$/;if(o.test(t)){const[l]=t.match(o).slice(1);return r.push("handleRetired"),{score:l.trim(),matchUpStatus:"retired",applied:r}}const i=(n=e==null?void 0:e.matchUpStatuses)==null?void 0:n.retired,a=["rtd",...Array.isArray(i)?i:[i].filter(Boolean)].find(l=>t==null?void 0:t.endsWith(l));return a?(r.push("handleRetired"),{matchUpStatus:"retired",score:t==null?void 0:t.replace(a,"").trim(),applied:r}):{score:t}}function iq({score:t,attributes:e}){(t.endsWith(" am")||t.endsWith(" pm"))&&(t=""),t=t.replace(/[A-Za-z]+/g,"").trim(),[".",","].some(o=>t.endsWith(o))&&(t=t.slice(0,t.length-1));const r="()/-".split("").some(o=>t.includes(o));/ \d$/.test(t)&&r&&(e={removed:t.slice(t.length-2).trim()},t=t.slice(0,t.length-2));const n=/(.*)[A-Za-z]+$/;return n.test(t)&&(t=t.match(n).slice(1)[0].trim()),{score:t,attributes:e}}function sq({score:t}){return new RegExp(/-\d+\/\d+-/).test(t)&&(t=t.split("/").join(" ")),{score:t}}function aq({score:t}){const e=new RegExp(/^\d+\/\d+/),r=t.split(" ");r.some(o=>e.test(o))&&(t=r.map(o=>e.test(o)?o.replace("/","-"):o).join(" "));const n=/^(\d+), *(\d+)$/;if(n.test(t)){const[o,i]=t.match(n).slice(1);t=[o,i].join("-")}return{score:t}}function lq({score:t}){const e=new RegExp(/\(\d+\/\d+\)/g),r=t.match(e);for(const n of r||[]){const o=n.replace("/","-");t=t.replace(n,o)}return{score:t}}function cq({score:t}){if(t.includes(",")){const e=t.split(",").map(o=>o.trim()),r=o=>/\d \d/.test(o);e.every(r)&&(t=e.map(o=>{const i=/\d+ \d+/g;for(const s of o.match(i)){const[a,l]=s.match(/(\d+) (\d+)/).slice(1);o=o.replace(s,`${a}-${l}`)}return o}).join(" "))}if(t.includes(" ")){const e=t.replace(/[ ,]/g,"");e.split("").every(n=>Ut(n))&&e.length===4&&(t=e)}return{score:t}}function uq({score:t}){const e=new RegExp(/^\[\d+\](.*)$/);e.test(t)&&(t=t.match(e).slice(1)[0].trim());const r=/\(,/g;return r.test(t)&&(t=t.replace(r,"(")),{score:t}}const dq={handleTiebreakSlashSeparation:lq,handleSetSlashSeparation:sq,punctuationAdjustments:HH,handleGameSeparation:aq,joinFloatingTiebreak:zH,handleBracketSpacing:qH,handleSpaceSeparator:cq,separateScoreBlocks:tq,matchKnownPatterns:YH,removeDanglingBits:iq,removeErroneous:rq,handleWalkover:nq,properTiebreak:KH,handleNumeric:dS,handleRetired:oq,containedSets:QH,sensibleSets:JH,stringScore:XH,superSquare:ZH,setBuilder:uS,excisions:uq,replaceOh:eq};let Hv={};const pq=["handleNumeric","handleWalkover","handleRetired","replaceOh","stringScore","punctuationAdjustments","excisions","handleSpaceSeparator","matchKnownPatterns","removeDanglingBits","handleBracketSpacing","matchKnownPatterns","containedSets","separateScoreBlocks","handleGameSeparation","removeErroneous","joinFloatingTiebreak","handleSetSlashSeparation","handleTiebreakSlashSeparation","properTiebreak","sensibleSets","superSquare"],fq=["handleNumeric","separateScoreBlocks","sensibleSets","superSquare"];function vq(t){const{score:e,sheetName:r,identifier:n,fileName:o,stepLog:i,fullLog:s,profile:a}=t,l=[];let c,u=[],d,p,v=e;const f=g=>{g.forEach(h=>{p=dq[h]({profile:a,identifier:n,matchUpStatus:c,attributes:d,applied:u,score:v});const _=p.score!==v;_&&l.push({method:h,score:p.score}),i&&(s||_||p.matchUpStatus!==c)&&console.log(c?{score:p.score,matchUpStatus:c}:{score:p.score},h),p.matchUpStatus&&(c=p.matchUpStatus),p.attributes&&(d=p.attributes),p.applied&&(u=p.applied),v=p.score})};f(pq);let m=lS(v);return m||(v=e.toString().replace(/\D/g,""),d!=null&&d.removed&&(d.removed=void 0),f(fq),m=lS(v),m||(v="")),u.forEach(g=>{Hv[g]||(Hv[g]=0),Hv[g]+=1}),{matchUpStatus:c==null?void 0:c.toUpperCase(),modifications:l,attributes:d,isValid:m,score:v}}var mq=Object.defineProperty,fS=Object.getOwnPropertySymbols,gq=Object.prototype.hasOwnProperty,hq=Object.prototype.propertyIsEnumerable,vS=(t,e,r)=>e in t?mq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mS=(t,e)=>{for(var r in e||(e={}))gq.call(e,r)&&vS(t,r,e[r]);if(fS)for(var r of fS(e))hq.call(e,r)&&vS(t,r,e[r]);return t};const{FACTORY:gS}=cI;function ud({tournamentRecord:t,value:e}){const{extension:r}=xr({element:t,name:gS}),n={name:gS,value:mS(mS({},r==null?void 0:r.value),e)};it({element:t,extension:n})}function Gi(t){const{mutationStatus:e,tournamentId:r,directives:n,timeStamp:o}=t||{},{topics:i}=xn();for(const s of[...i].sort(_q)){const a=AL({topic:s});a&&U_({topic:s,notices:a})}e&&o&&i.includes(pP)&&U_({notices:[{tournamentId:r,directives:n,timeStamp:o}],topic:pP})}const hS={[vP]:5,[fP]:5,[mP]:5,[dP]:5,[uP]:5,[lP]:5,[ak]:5,[lk]:5,[cP]:1,[Yf]:1,[rr]:5,[ms]:5,[aP]:4,[oP]:4,[iP]:4,[sP]:4,[zf]:3,[tP]:2};function _q(t,e){return(hS[e]||0)-(hS[t]||0)}function Ds({tournamentRecords:t,convertExtensions:e,ignoreDisabled:r,venueIds:n=[],dates:o}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const i=[],s=[],a=[],l=[];return Object.keys(t).forEach(u=>{const d=t[u];for(const p of d.venues||[])if(d.venues,!(n.length&&!n.includes(p.venueId))){if(r){const{extension:v}=xr({name:Pn,element:p});if(v!=null&&v.value)continue}i.includes(p.venueId)||(l.push(ve(p,e,!0)),i.push(p.venueId));for(const v of p.courts||[])if(!s.includes(v.courtId)){if(r&&o){const{extension:m}=xr({name:Pn,element:v});if(JI({extension:m,dates:o}))continue}const{inContextCourt:f}=eP({convertExtensions:e,ignoreDisabled:r,venue:p,court:v});a.push(f),s.push(v.courtId)}}}),{courts:a,venues:l}}function qv({tournamentRecords:t,requireCourts:e,dates:r}){return typeof t!="object"||!Object.keys(t).length?{error:ke}:Object.keys(t).reduce((o,i)=>{const s=t[i],{venues:a}=Kf({tournamentRecord:s,dates:r});return a==null||a.forEach(l=>{const{venueId:c,courts:u}=l;(!e||(u==null?void 0:u.length))&&!o.venueIds.includes(c)&&(o.venues.push(l),o.venueIds.push(c))}),o},{venues:[],venueIds:[]})}var Iq=Object.defineProperty,_S=Object.getOwnPropertySymbols,Pq=Object.prototype.hasOwnProperty,yq=Object.prototype.propertyIsEnumerable,IS=(t,e,r)=>e in t?Iq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,PS=(t,e)=>{for(var r in e||(e={}))Pq.call(e,r)&&IS(t,r,e[r]);if(_S)for(var r of _S(e))yq.call(e,r)&&IS(t,r,e[r]);return t};function dc({duplicateValues:t=!0,creationTime:e=!0,removePriorValues:r,timeItem:n,element:o}){if(!n)return{error:g_};if(!o)return{error:_e,info:Bf};const i=n&&Object.keys(n),s=["itemType","itemValue"];if(!(s.filter(c=>i.includes(c)).length===s.length))return{error:m_};if(!o.timeItems)o.timeItems=[];else{const{itemType:c,itemSubTypes:u,itemValue:d}=n,{timeItem:p}=Cn({itemSubTypes:u,itemType:c,element:o});if(JSON.stringify(p==null?void 0:p.itemValue)===JSON.stringify(d)&&!t)return PS({},V)}if(n.itemSubTypes&&!n.itemSubTypes.length&&delete n.itemSubTypes,e){const c=new Date().toISOString();Object.assign(n,{createdAt:c})}return r&&(o.timeItems=o.timeItems.filter(({itemType:c})=>n.itemType!==c)),r&&!n.itemValue||o.timeItems.push(n),PS({},V)}function yS({creationTime:t=!0,removePriorValues:e,tournamentRecord:r,duplicateValues:n,participantId:o,timeItem:i}){if(!r)return{error:re};if(!o)return{error:Tt};const s=Zo({tournamentRecord:r,participantId:o});return s.error?s:dc({element:s.participant,removePriorValues:e,duplicateValues:n,creationTime:t,timeItem:i})}function xo(t){const{removePriorValues:e,tournamentRecord:r,duplicateValues:n,creationTime:o,timeItem:i}=t;return r?dc({element:r,removePriorValues:e,duplicateValues:n,creationTime:o,timeItem:i}):{error:re}}function di(t){const{removePriorValues:e,duplicateValues:r,creationTime:n,timeItem:o,event:i}=t;return i?dc({removePriorValues:e,duplicateValues:r,element:i,creationTime:n,timeItem:o}):{error:Ur}}var Sq=Object.defineProperty,SS=Object.getOwnPropertySymbols,Oq=Object.prototype.hasOwnProperty,bq=Object.prototype.propertyIsEnumerable,OS=(t,e,r)=>e in t?Sq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tq=(t,e)=>{for(var r in e||(e={}))Oq.call(e,r)&&OS(t,r,e[r]);if(SS)for(var r of SS(e))bq.call(e,r)&&OS(t,r,e[r]);return t};function Mr({removePriorValues:t,tournamentRecord:e,duplicateValues:r,drawDefinition:n,disableNotice:o,matchUpId:i,timeItem:s,event:a}){const{matchUp:l}=ut({drawDefinition:n,event:a,matchUpId:i});if(!l)return{error:ir};const c=dc({removePriorValues:t,element:l,duplicateValues:r,timeItem:s});return o||Ze({tournamentId:e==null?void 0:e.tournamentId,eventId:a==null?void 0:a.eventId,context:"addTimeItem",drawDefinition:n,matchUp:l}),c}function wq({tournamentRecord:t,drawDefinition:e,matchUpId:r,event:n}){const{matchUp:o}=ut({drawDefinition:e,event:n,matchUpId:r});return o?(o.timeItems=[],Ze({tournamentId:t==null?void 0:t.tournamentId,context:"resetTimeItems",eventId:n==null?void 0:n.eventId,drawDefinition:e,matchUp:o}),Tq({},V)):{error:ir}}function dd({removePriorValues:t,tournamentRecords:e,tournamentRecord:r,drawDefinition:n,disableNotice:o,courtDayDate:i,matchUpId:s,courtIds:a}){var l,c;if(!r&&!e)return{error:re};if(!s)return{error:Vt};const u=ut({drawDefinition:n,matchUpId:s});if(u.error)return u;if(((l=u==null?void 0:u.matchUp)==null?void 0:l.matchUpType)!==In)return{error:rn};if(!(a===void 0||Array.isArray(a)&&a.length&&a.every(f=>typeof f=="string")))return{error:X,context:{courtIds:a}};let p;if(a){const f=e?r:r&&{[r.tournamentId]:r},m=Ds({tournamentRecords:f});if(m.error)return m;const g=(c=m.courts)==null?void 0:c.filter(h=>a.includes(h.courtId));if((g==null?void 0:g.length)!==a.length)return{error:X,context:{courtIds:a}};p=g==null?void 0:g.map(h=>({venueId:h.venueId,courtId:h.courtId}))}return Mr({duplicateValues:!1,removePriorValues:t,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:s,timeItem:{itemType:ti,itemDate:i,itemValue:p}})}function ja({removePriorValues:t,tournamentRecords:e,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:i,venueId:s}){if(!r)return{error:re};if(!i)return{error:Vt};if(s){const l=ei({tournamentRecords:e,tournamentRecord:r,venueId:s});if(l.error)return l}return Mr({duplicateValues:!1,removePriorValues:t,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:i,timeItem:{itemType:Rl,itemValue:s}})}function js({removePriorValues:t,tournamentRecords:e,tournamentRecord:r,drawDefinition:n,disableNotice:o,courtDayDate:i,matchUpId:s,courtId:a}){var l;if(!r&&!e)return{error:re};if(!s)return{error:Vt};if(a){const u=gs({tournamentRecords:e,tournamentRecord:r,courtId:a});if(u.error)return u;const d=(l=u.venue)==null?void 0:l.venueId;ja({tournamentRecords:e,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:s,venueId:d})}return Mr({duplicateValues:!1,removePriorValues:t,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:s,timeItem:{itemType:hs,itemDate:i,itemValue:a}})}function Eq({matchUps:t,matchUpId:e}){if(!Array.isArray(t))return{error:X};const r=t.find(a=>a.matchUpId===e),{drawId:n,eventId:o,structureId:i,tournamentId:s}=r||{};return{matchUpId:e,drawId:n,eventId:o,structureId:i,tournamentId:s}}var $q=Object.defineProperty,bS=Object.getOwnPropertySymbols,Nq=Object.prototype.hasOwnProperty,Uq=Object.prototype.propertyIsEnumerable,TS=(t,e,r)=>e in t?$q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Aq=(t,e)=>{for(var r in e||(e={}))Nq.call(e,r)&&TS(t,r,e[r]);if(bS)for(var r of bS(e))Uq.call(e,r)&&TS(t,r,e[r]);return t};function Wi(t){let e=t.matchUp;const{removePriorValues:r,tournamentRecord:n,drawDefinition:o,disableNotice:i,scheduledTime:s,matchUpId:a}=t;if(!a)return{error:Vt};if(!aa(s))return{error:nn};if(!e){const f=ut({drawDefinition:o,matchUpId:a});if(f.error)return f;e=f.matchUp}const l=Re(s),c="addMatchUpScheduledTime";if(l){const f=Ci({matchUp:e}).scheduledDate;if(f&&f!==l)return k({info:`date in time: ${l} does not corresponde to scheduledDate: ${f}`,result:{error:nn},stack:c})}const u=ev({matchUp:e}).timeModifiers||[];if(u!=null&&u.length){const f=zv({disableNotice:!0,removePriorValues:r,tournamentRecord:n,timeModifiers:[],drawDefinition:o,matchUpId:a,matchUp:e});if(f!=null&&f.error)return f}const p=os(s,!0,!0);return Mr({duplicateValues:!1,removePriorValues:r,tournamentRecord:n,drawDefinition:o,disableNotice:i,matchUpId:a,timeItem:{itemType:xl,itemValue:p}})}function zv({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,timeModifiers:o,matchUpId:i,matchUp:s}){if(!i)return{error:Vt};if(o!==void 0&&!Array.isArray(o))return{error:X,info:or("timeModifiers")};if(!s){const p=ut({drawDefinition:r,matchUpId:i});if(p.error)return p;s=p.matchUp}let a=ev({matchUp:s}).timeModifiers||[];const l=o.filter(p=>!a.includes(p));if(o.length&&!l.length)return Aq({},V);if(l.some(p=>jP.includes(p))){a=a.filter(v=>!jP.includes(v));const p=Wi({disableNotice:!0,removePriorValues:t,scheduledTime:"",tournamentRecord:e,drawDefinition:r,matchUpId:i});if(p.error)return p}const u=o!=null&&o.length?[...l,...a]:void 0;return Mr({duplicateValues:!1,removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,matchUpId:i,timeItem:{itemType:DP,itemValue:u}})}var Cq=Object.defineProperty,Mq=Object.defineProperties,Dq=Object.getOwnPropertyDescriptors,wS=Object.getOwnPropertySymbols,jq=Object.prototype.hasOwnProperty,Rq=Object.prototype.propertyIsEnumerable,ES=(t,e,r)=>e in t?Cq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$S=(t,e)=>{for(var r in e||(e={}))jq.call(e,r)&&ES(t,r,e[r]);if(wS)for(var r of wS(e))Rq.call(e,r)&&ES(t,r,e[r]);return t},Fq=(t,e)=>Mq(t,Dq(e));function Jn(t,e){const r=M_.test(t)?t:ct(t),n=Re(t)||Re(e)||hn(new Date);return new Date(`${n}T${r}`).getTime()}function pd({errorOnAnachronism:t=!1,checkChronology:e=!0,matchUpDependencies:r,inContextMatchUps:n,removePriorValues:o,tournamentRecords:i,tournamentRecord:s,drawDefinition:a,disableNotice:l,drawMatchUps:c,matchUpId:u,schedule:d,event:p}){var v;if(!d)return{error:_e,info:"Missing schedule"};if(!a)return{error:fe};if(!u)return{error:Vt};const f="drawEngine.addMatchUpScheduleItems";let m,g;if(c)m=c.find($=>$.matchUpId===u);else{const $=ut({drawDefinition:a,event:p,matchUpId:u});if($.error)return $;m=$.matchUp}const{endTime:h,courtId:_,courtIds:I,courtOrder:P,resumeTime:y,scheduledDate:S,scheduledTime:O,startTime:b,stopTime:w,timeModifiers:T,venueId:E}=d;e&&(!r||!n)&&({matchUpDependencies:r,matchUps:n}=pn({drawDefinition:a}));const N=(v=r==null?void 0:r[u])==null?void 0:v.matchUpIds;if(d.scheduledDate&&e&&N){const $=n==null?void 0:n.filter(A=>{var U,C;return(((U=A.schedule)==null?void 0:U.scheduledDate)||Re((C=A.schedule)==null?void 0:C.scheduledTime))&&N.includes(A.matchUpId)}).map(({schedule:A})=>{const U=lu(A);return new Date(U).getTime()});if($!=null&&$.length){const A=lu(d),U=new Date(A).getTime();if(Math.max(...$)>=U){if(t)return k({result:{error:Bh},stack:f});g=Bh}}}if(S!==void 0){const $=Yv({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,scheduledDate:S,matchUpId:u});if($!=null&&$.error)return k({result:$,stack:f,context:{scheduledDate:S}})}if(O!==void 0){const $=Wi({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,scheduledTime:O,matchUpId:u,matchUp:m});if($!=null&&$.error)return k({result:$,stack:f,context:{scheduledTime:O}})}if(b!==void 0){const $=Qv({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,matchUpId:u,startTime:b,event:p});if($!=null&&$.error)return k({result:$,stack:f,context:{startTime:b}})}if(w!==void 0){const $=Zv({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,matchUpId:u,stopTime:w,event:p});if($!=null&&$.error)return k({result:$,stack:f,context:{stopTime:w}})}if(y!==void 0){const $=Xv({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,resumeTime:y,matchUpId:u,event:p});if($!=null&&$.error)return k({result:$,stack:f,context:{resumeTime:y}})}if(h!==void 0){const $=Jv({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,matchUpId:u,endTime:h,event:p});if($!=null&&$.error)return k({result:$,stack:f,context:{endTime:h}})}if(I!==void 0){const $=dd({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,matchUpId:u,courtIds:I});if($!=null&&$.error)return k({result:$,stack:f,context:{courtIds:I}})}if(_!==void 0&&S!==void 0){const $=js({courtDayDate:S,disableNotice:!0,removePriorValues:o,tournamentRecords:i,tournamentRecord:s,drawDefinition:a,matchUpId:u,courtId:_});if($!=null&&$.error)return k({result:$,stack:f,context:{courtId:_}})}if(E!==void 0){const $=ja({disableNotice:!0,removePriorValues:o,tournamentRecords:i,tournamentRecord:s,drawDefinition:a,matchUpId:u,venueId:E});if($!=null&&$.error)return k({result:$,stack:f,context:{venueId:E}})}if(P!==void 0&&_t(P)){const $=Kv({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,courtOrder:P,matchUpId:u});if($!=null&&$.error)return k({result:$,stack:f,context:{courtOrder:P}})}if(T!==void 0){const $=zv({disableNotice:!0,removePriorValues:o,tournamentRecord:s,drawDefinition:a,timeModifiers:T,matchUpId:u,matchUp:m});if($!=null&&$.error)return k({result:$,stack:f,context:{timeModifiers:T}})}return l||Ze({tournamentId:s==null?void 0:s.tournamentId,eventId:p==null?void 0:p.eventId,context:f,drawDefinition:a,matchUp:m}),g?Fq($S({},V),{warnings:[g]}):$S({},V)}function Yv({scheduledDate:t,removePriorValues:e,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:i}){if(!i)return{error:Vt};const s=t&&Ln.test(t);if(t&&!s)return{error:yr};const l={itemValue:Re(t),itemType:Fl};return Mr({duplicateValues:!1,removePriorValues:e,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:i,timeItem:l})}function Kv({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,courtOrder:o,matchUpId:i}){if(!i)return{error:Vt};if(o&&!_t(o))return{error:X,info:"courtOrder must be numeric"};const s=o&&Oe(o);return Mr({duplicateValues:!1,removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,matchUpId:i,timeItem:{itemType:MP,itemValue:s}})}function NS({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,participantId:o,officialType:i,matchUpId:s}){if(!s)return{error:Vt};const a={itemType:"SCHEDULE.ASSIGNMENT.OFFICIAL",itemValue:o};return i&&(a.itemSubTypes=[i]),Mr({duplicateValues:!1,removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,matchUpId:s,timeItem:a})}function Qv({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,matchUpId:o,startTime:i,event:s}){var a;if(!o)return{error:Vt};if(!aa(i))return{error:nn};const{matchUp:l}=ut({drawDefinition:r,event:s,matchUpId:o}),{scheduledDate:c}=Ci({matchUp:l}),d=((a=l==null?void 0:l.timeItems)!=null?a:[]).filter(p=>[ri,Uo,ni].includes(p==null?void 0:p.itemType)).map(p=>Jn(p.itemValue,c)).reduce((p,v)=>!p||v<p?v:p,void 0);if(!d||Jn(i,c)<d){l!=null&&l.timeItems&&(l.timeItems=l.timeItems.filter(f=>f.itemType!==qn));const p=os(i,!0,!0);return Mr({duplicateValues:!1,removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,matchUpId:o,timeItem:{itemType:qn,itemValue:p}})}else return{error:kx}}function Jv({validateTimeSeries:t=!0,removePriorValues:e,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:i,endTime:s,event:a}){var l;if(!i)return{error:Vt};if(!aa(s))return{error:nn};const{matchUp:c}=ut({drawDefinition:n,event:a,matchUpId:i}),{scheduledDate:u}=Ci({matchUp:c}),p=((l=c==null?void 0:c.timeItems)!=null?l:[]).filter(v=>[qn,Uo,ri].includes(v==null?void 0:v.itemType)).map(v=>Jn(v.itemValue,u)).reduce((v,f)=>!v||f>v?f:v,void 0);if(!t||!p||Jn(s,u)>p){c!=null&&c.timeItems&&(c.timeItems=c.timeItems.filter(m=>m.itemType!==ni));const v=os(s,!0,!0);return Mr({duplicateValues:!1,removePriorValues:e,tournamentRecord:r,drawDefinition:n,disableNotice:o,matchUpId:i,timeItem:{itemType:ni,itemValue:v}})}else return{error:Vx}}function Zv({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,matchUpId:o,stopTime:i,event:s}){var a;if(!o)return{error:Vt};if(!aa(i))return{error:nn};const{matchUp:l}=ut({drawDefinition:r,event:s,matchUpId:o}),{scheduledDate:c}=Ci({matchUp:l}),u=(a=l==null?void 0:l.timeItems)!=null?a:[];if(u.reduce((g,h)=>h.itemType===ni||g,void 0))return{error:v_};const p=u.filter(g=>[qn,Uo,ri].includes(g==null?void 0:g.itemType)).sort((g,h)=>Jn(g.itemValue,c)-Jn(h.itemValue,c)),v=p[p.length-1],f=v&&v.itemType===ri,m=p.filter(g=>!f||g.createdAt!==v.createdAt).map(g=>Jn(g.itemValue,c)).reduce((g,h)=>!g||h>g?h:g,void 0);if(Jn(i,c)>m){if(l!=null&&l.timeItems&&f){const _=v.createdAt;l.timeItems=l.timeItems.filter(I=>I.createdAt!==_)}const h={itemValue:os(i,!0,!0),itemType:ri};return Mr({duplicateValues:!0,removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,matchUpId:o,timeItem:h})}else return{error:Bx}}function Xv({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,resumeTime:o,matchUpId:i,event:s}){var a;if(!i)return{error:Vt};if(!aa(o))return{error:nn};const{matchUp:l}=ut({drawDefinition:r,event:s,matchUpId:i}),{scheduledDate:c}=Ci({matchUp:l}),u=(a=l==null?void 0:l.timeItems)!=null?a:[];if(u.reduce((g,h)=>h.itemType===ni||g,void 0))return{error:v_};const p=u.filter(g=>[qn,Uo,ri].includes(g==null?void 0:g.itemType)).sort((g,h)=>Jn(g.itemValue,c)-Jn(h.itemValue,c)),v=p[p.length-1],f=v&&v.itemType===Uo,m=p.filter(g=>!f||g.createdAt!==v.createdAt).map(g=>Jn(g.itemValue,c)).reduce((g,h)=>!g||h>g?h:g,void 0);if(Jn(o,c)>m){if(l!=null&&l.timeItems&&f){const _=v.createdAt;l.timeItems=l.timeItems.filter(I=>I.createdAt!==_)}const h={itemValue:os(o,!0,!0),itemType:Uo};return Mr({duplicateValues:!0,removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,matchUpId:i,timeItem:h})}else return{error:Gx}}var xq=Object.defineProperty,Lq=Object.defineProperties,Vq=Object.getOwnPropertyDescriptors,US=Object.getOwnPropertySymbols,Bq=Object.prototype.hasOwnProperty,kq=Object.prototype.propertyIsEnumerable,AS=(t,e,r)=>e in t?xq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,CS=(t,e)=>{for(var r in e||(e={}))Bq.call(e,r)&&AS(t,r,e[r]);if(US)for(var r of US(e))kq.call(e,r)&&AS(t,r,e[r]);return t},MS=(t,e)=>Lq(t,Vq(e));function DS({errorOnAnachronism:t=!1,checkChronology:e=!0,matchUpDependencies:r,tournamentRecords:n,tournamentRecord:o,matchUpDetails:i,matchUpIds:s,schedule:a}){var l,c,u;if(!o)return{error:re};if(!i&&(!s||!Array.isArray(s)))return{error:ml};if(!i&&(!a||typeof a!="object"))return{error:Wx};let d;const p=[];let v=0;if(e&&!r){const g=pn({tournamentRecords:n});r=g.matchUpDependencies,d=g.matchUps}d||(d=((l=Wt({tournamentRecord:o}))==null?void 0:l.matchUps)||[]);const f=d.reduce((g,h)=>{const{matchUpId:_,drawId:I}=h;return g[I]?g[I].push(_):g[I]=[_],g},{}),m=i==null?void 0:i.map(g=>g.matchUpId);for(const g of Object.keys(f)){const{drawDefinition:h}=Xo({tournamentRecord:o,drawId:g}),_=f[g].filter(P=>(s==null?void 0:s.includes(P))||(m==null?void 0:m.includes(P))),I=zr({inContext:!1,drawDefinition:h}).matchUps;for(const P of _){const y=((c=i==null?void 0:i.find(O=>O.matchUpId===P))==null?void 0:c.schedule)||a,S=pd({schedule:y,matchUpDependencies:r,errorOnAnachronism:t,inContextMatchUps:d,tournamentRecords:n,tournamentRecord:o,checkChronology:e,drawDefinition:h,drawMatchUps:I,matchUpId:P});if((u=S==null?void 0:S.warnings)!=null&&u.length&&p.push(...S.warnings),S!=null&&S.success&&(v+=1),S.error)return S}}return p.length?MS(CS({},V),{scheduled:v,warnings:p}):MS(CS({},V),{scheduled:v})}var Gq=Object.defineProperty,Wq=Object.defineProperties,Hq=Object.getOwnPropertyDescriptors,jS=Object.getOwnPropertySymbols,qq=Object.prototype.hasOwnProperty,zq=Object.prototype.propertyIsEnumerable,RS=(t,e,r)=>e in t?Gq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,FS=(t,e)=>{for(var r in e||(e={}))qq.call(e,r)&&RS(t,r,e[r]);if(jS)for(var r of jS(e))zq.call(e,r)&&RS(t,r,e[r]);return t},xS=(t,e)=>Wq(t,Hq(e));function LS({errorOnAnachronism:t,matchUpContextIds:e,tournamentRecords:r,checkChronology:n,matchUpDetails:o,schedule:i}){var s;if(!r)return{error:ke};if(!Array.isArray(e)&&!Array.isArray(o))return{error:X};if((!o||e)&&!i)return{error:_e,info:"schedule is required"};const a=[];let l=0;const{matchUpDependencies:c}=pn({tournamentRecords:r});for(const u of Object.values(r)){const{tournamentId:d}=u,p=e==null?void 0:e.filter(f=>f.tournamentId===d).map(Jt),v=o==null?void 0:o.filter(f=>(f==null?void 0:f.tournamentId)===d);if(p!=null&&p.length||v!=null&&v.length){const f=DS({matchUpDetails:v,matchUpDependencies:c,errorOnAnachronism:t,tournamentRecords:r,tournamentRecord:u,checkChronology:n,matchUpIds:p,schedule:i});if((s=f.warnings)!=null&&s.length&&a.push(...f.warnings),f.scheduled&&(l+=f.scheduled),f.error)return f}}return a.length?xS(FS({},V),{scheduled:l,warnings:a}):xS(FS({},V),{scheduled:l})}function fd({tournamentRecords:t}){return t?Object.keys(t).reduce((r,n)=>{r.tournamentIdMap[n]=[];const i=t[n].events||[],s=i.map(({eventId:l})=>l),a=i.map(l=>(l.drawDefinitions||[]).map(({drawId:c})=>c)).flat();return r.tournamentIdMap[n].push(...s,...a),r.eventIds.push(...s),r.drawIds.push(...a),r},{eventIds:[],drawIds:[],tournamentIdMap:{}}):{error:ke}}function em({tournamentRecords:t,eventId:e,drawId:r}){const{tournamentIdMap:n}=fd({tournamentRecords:t});return(n?Object.keys(n):[]).find(i=>e&&(n==null?void 0:n[i].includes(e))||r&&(n==null?void 0:n[i].includes(r)))}var Yq=Object.defineProperty,VS=Object.getOwnPropertySymbols,Kq=Object.prototype.hasOwnProperty,Qq=Object.prototype.propertyIsEnumerable,BS=(t,e,r)=>e in t?Yq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Jq=(t,e)=>{for(var r in e||(e={}))Kq.call(e,r)&&BS(t,r,e[r]);if(VS)for(var r of VS(e))Qq.call(e,r)&&BS(t,r,e[r]);return t};function Zq({drawDefinition:t,matchUpStatus:e,matchUpsMap:r,winningSide:n,dualMatchUp:o,tieFormat:i,structure:s,matchUp:a,event:l,score:c}){var u;const d=ve(o,void 0,!0);for(const v of(d==null?void 0:d.tieMatchUps)||[])v.matchUpId===a.matchUpId&&(v.winningSide=n,v.score=c,!Gt({score:c})&&!e?Object.assign(v,Jq({},Wu)):e&&(v.matchUpStatus=e));i=i||((u=fr({matchUp:a,structure:s,drawDefinition:t,event:l}))==null?void 0:u.tieFormat);const{winningSide:p}=rc({matchUp:d,drawDefinition:t,matchUpsMap:r,structure:s,tieFormat:i,event:l});return{projectedWinningSide:p}}function Xq(t){var e;const{matchUpFormat:r,score:n}=t,o=(e=n==null?void 0:n.sets)==null?void 0:e.length,i=r&&Ir(r),{setFormat:s,finalSetFormat:a,bestOf:l}=i||{},u=l&&o===l&&a||s;return(u==null?void 0:u.timed)||!1}function Rs({drawPosition:t,matchUps:e=[]}){return{initialRoundNumber:e.filter(({drawPositions:n})=>t&&(n==null?void 0:n.includes(t))).map(({roundNumber:n})=>n).sort(er)[0]}}function kS({structureId:t,matchUpsMap:e,matchUp:r}){const n=r==null?void 0:r.roundPosition,o=n%2?1:-1,i=n+o;return{pairedPreviousMatchUp:Li({matchUpsMap:e,structureId:t}).find(({roundNumber:l,roundPosition:c})=>l===(r==null?void 0:r.roundNumber)&&c===i)}}var e6=Object.defineProperty,t6=Object.defineProperties,r6=Object.getOwnPropertyDescriptors,GS=Object.getOwnPropertySymbols,n6=Object.prototype.hasOwnProperty,o6=Object.prototype.propertyIsEnumerable,WS=(t,e,r)=>e in t?e6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,i6=(t,e)=>{for(var r in e||(e={}))n6.call(e,r)&&WS(t,r,e[r]);if(GS)for(var r of GS(e))o6.call(e,r)&&WS(t,r,e[r]);return t},s6=(t,e)=>t6(t,r6(e));function HS({inContextDrawMatchUps:t,sourceMatchUpStatus:e,sourceMatchUpId:r,matchUpsMap:n,matchUp:o}){var i;const s=t.find(l=>l.matchUpId===r),{pairedPreviousMatchUp:a}=kS({structureId:s==null?void 0:s.structureId,matchUp:s,matchUpsMap:n});if(s&&a){const l=a==null?void 0:a.matchUpId,c=t.find(d=>d.matchUpId===l),u=(s==null?void 0:s.structureId)===(c==null?void 0:c.structureId)?(s==null?void 0:s.roundPosition)<(c==null?void 0:c.roundPosition)&&1||2:s.structureId===(c==null?void 0:c.structureId)&&2||1;o.matchUpStatusCodes=((i=o.matchUpStatusCodes)!=null?i:[]).map(d=>d.sideNumber===u?s6(i6({},d),{previousMatchUpStatus:e}):d)}}var a6=Object.defineProperty,qS=Object.getOwnPropertySymbols,l6=Object.prototype.hasOwnProperty,c6=Object.prototype.propertyIsEnumerable,zS=(t,e,r)=>e in t?a6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,tm=(t,e)=>{for(var r in e||(e={}))l6.call(e,r)&&zS(t,r,e[r]);if(qS)for(var r of qS(e))c6.call(e,r)&&zS(t,r,e[r]);return t};function u6({inContextDrawMatchUps:t,sourceMatchUpStatus:e,targetDrawPosition:r,tournamentRecord:n,sourceMatchUpId:o,drawDefinition:i,structureId:s,dualMatchUp:a,roundNumber:l,matchUpsMap:c,event:u}){const{structure:d}=Ee({drawDefinition:i,structureId:s});if((d==null?void 0:d.structureType)===gr)return tm({},V);c=c||lr({drawDefinition:i});const v=((c==null?void 0:c.mappedMatchUps)||{})[s].matchUps,{initialRoundNumber:f}=Rs({drawPosition:r,matchUps:v}),m=v==null?void 0:v.filter(h=>{var _;return h.roundNumber>=l&&h.roundNumber!==f&&((_=h.drawPositions)==null?void 0:_.includes(r))}),{positionAssignments:g}=st({drawDefinition:i,structureId:s});for(const h of m||[])d6({inContextDrawMatchUps:t,sourceMatchUpStatus:e,positionAssignments:g,targetDrawPosition:r,tournamentRecord:n,sourceMatchUpId:o,drawDefinition:i,dualMatchUp:a,matchUpsMap:c,matchUp:h,event:u});return tm({},V)}function d6({inContextDrawMatchUps:t,positionAssignments:e,sourceMatchUpStatus:r,targetDrawPosition:n,tournamentRecord:o,sourceMatchUpId:i,drawDefinition:s,dualMatchUp:a,matchUpsMap:l,matchUp:c,event:u}){var d,p,v;const f="removeSubsequentDrawPosition";if(a){const _=(p=(d=t.find(({matchUpId:P})=>c.matchUpId===P).sides)==null?void 0:d.find(P=>P.drawPosition===n))==null?void 0:p.sideNumber,I=(v=c.sides)==null?void 0:v.find(P=>P.sideNumber===_);I&&delete I.lineUp}c.drawPositions=(c.drawPositions||[]).map(h=>h===n?void 0:h).filter(Boolean);const g=e.filter(({drawPosition:h})=>{var _;return(_=c.drawPositions)==null?void 0:_.includes(h)}).filter(h=>h.bye).length;return c.matchUpStatus=g&&nt||[et,ot].includes(c.matchUpStatus)&&c.matchUpStatus||Rt,[ot,et].includes(c.matchUpStatus)&&(c.winningSide=void 0),c.matchUpStatusCodes&&HS({inContextDrawMatchUps:t,sourceMatchUpStatus:r,sourceMatchUpId:i,matchUpsMap:l,matchUp:c}),Ze({tournamentId:o==null?void 0:o.tournamentId,eventId:u==null?void 0:u.eventId,context:`${f}-${n}`,drawDefinition:s,matchUp:c}),tm({},V)}function YS({positionAssignments:t,tournamentRecord:e,drawDefinition:r,matchUpsMap:n,structure:o,event:i}){const{matchUps:s}=Je({drawDefinition:r,matchUpsMap:n,structure:o,event:i});s.forEach(a=>{const c=t.filter(({drawPosition:u})=>{var d;return(d=a.drawPositions)==null?void 0:d.includes(u)}).filter(u=>u.bye).length;a.winningSide||(Object.assign(a,{matchUpStatus:c?nt:Rt}),Ze({tournamentId:e==null?void 0:e.tournamentId,context:"modifyRoundRobinMatchUpsStatus",eventId:i==null?void 0:i.eventId,drawDefinition:r,matchUp:a}))})}function Ra({tournamentRecord:t,drawDefinition:e,event:r}){const n=(t==null?void 0:t.events)||r&&[r],o=(n==null?void 0:n.map(l=>l==null?void 0:l.drawDefinitions).flat().filter(Boolean))||e&&[e]||[],i={},s={},a=o.map(l=>{var c;return(c=l==null?void 0:l.structures)==null?void 0:c.filter(u=>u==null?void 0:u.structures)}).flat().filter(Boolean);for(const l of a){const{structures:c,structureId:u}=l||{};c&&u&&(i[u]=c==null?void 0:c.map(d=>d.structureId))&&c.forEach(d=>s[d.structureId]=l==null?void 0:l.structureId)}return{containedStructures:i,containerStructures:s}}function pc(t){var e;const{drawDefinition:r,findContainer:n,structureId:o,event:i}=t;let s=t.structure;const a={isCollectionMatchUp:!1},{containedStructures:l}=Ra({drawDefinition:r}),c=o?l[o]||[]:[];if(!s){const b=Ee({drawDefinition:r,structureId:o});if(b.error)return b;s=n&&b.containingStructure||b.structure}if(Mo({drawDefinition:r,structure:s}))return{structure:s,isAdHoc:!0,error:ta};const{matchUps:u}=xt({inContext:!0,matchUpFilters:a,drawDefinition:r,event:i}),d=u==null?void 0:u.filter(b=>b.structureId===o||c.includes(b.structureId)),{matchUpDependencies:p}=pn({drawIds:[r.drawId],matchUps:u,drawDefinition:r}),v=[],f=[],m={},g=[];for(const b of u||[]){if(b.structureId===o||c.includes(b.structureId)){f.push(...b.drawPositions||[]);const w=b.roundNumber;for(const T of(b.drawPositions||[]).filter(Boolean))(!m[T]||w&&m[T]>w)&&(m[T]=w)}vv(b)&&(g.push(b),v.push(b.matchUpId,...((e=p==null?void 0:p[b==null?void 0:b.matchUpId])==null?void 0:e.matchUpIds)||[]))}const h=He(f.filter(Boolean)).sort(er),_=He(v),I=He(d==null?void 0:d.map(({matchUpId:b,drawPositions:w})=>_.includes(b)?w:[]).flat().filter(Boolean)).sort(er),{positionAssignments:P}=st({drawDefinition:r,structure:s}),y=P==null?void 0:P.filter(b=>b.bye).map(b=>b.drawPosition),S=P==null?void 0:P.filter(b=>b.qualifier).map(b=>b.drawPosition),O=(h==null?void 0:h.filter(b=>!I.includes(b)))||[];return{allDrawPositions:h,inContextStructureMatchUps:d,drawPositionInitialRounds:m,activeDependentMatchUpIds:_,qualifyingDrawPositions:S,inactiveDrawPositions:O,positionAssignments:P,activeDrawPositions:I,byeDrawPositions:y,activeMatchUps:g,structure:s}}function Zn(t,e){e||zt()}var p6=Object.defineProperty,f6=Object.defineProperties,v6=Object.getOwnPropertyDescriptors,KS=Object.getOwnPropertySymbols,m6=Object.prototype.hasOwnProperty,g6=Object.prototype.propertyIsEnumerable,QS=(t,e,r)=>e in t?p6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fc=(t,e)=>{for(var r in e||(e={}))m6.call(e,r)&&QS(t,r,e[r]);if(KS)for(var r of KS(e))g6.call(e,r)&&QS(t,r,e[r]);return t},h6=(t,e)=>f6(t,v6(e));function Fa(t){let{inContextDrawMatchUps:e,participantId:r,drawPosition:n}=t;const{tournamentRecord:o,drawDefinition:i,structureId:s,matchUpsMap:a,event:l}=t,{structure:c}=Ee({drawDefinition:i,structureId:s}),d=(Ct({drawDefinition:i,structure:c}).positionAssignments||[]).find(m=>r&&m.participantId===r||n&&m.drawPosition===n);if(d&&r&&!n&&(n=d==null?void 0:d.drawPosition),!n)return{error:fl};r||(r=d==null?void 0:d.participantId);const{activeDrawPositions:p}=pc({drawDefinition:i,structureId:s});return p.includes(n)?{error:ef}:(e||({matchUps:e}=xt({inContext:!0,drawDefinition:i,matchUpsMap:a})),rm({inContextDrawMatchUps:e,tournamentRecord:o,drawDefinition:i,structureId:s,drawPosition:n,matchUpsMap:a,event:l}).drawPositionCleared?(ai({tournamentId:o==null?void 0:o.tournamentId,drawDefinition:i,structure:c,event:l}),h6(fc({},V),{participantId:r})):{error:QF})}function rm({inContextDrawMatchUps:t,tournamentRecord:e,drawDefinition:r,drawPosition:n,matchUpsMap:o,structureId:i,event:s}){const{structure:a}=Ee({drawDefinition:r,structureId:i});if(!a)return{error:St};const l=Ct({drawDefinition:r,structure:a}).positionAssignments||[],c=l.some(I=>{if(I.drawPosition===n)return delete I.participantId,delete I.qualifier,delete I.bye,!0});if(a.structureType===gr)return YS({positionAssignments:l,tournamentRecord:e,drawDefinition:r,matchUpsMap:o,structure:a}),fc({drawPositionCleared:c},V);const u={isCollectionMatchUp:!1},{matchUps:d}=Je({drawDefinition:r,matchUpFilters:u,matchUpsMap:o,structure:a,event:s}),{roundProfile:p,roundMatchUps:v}=br({matchUps:d}),f=p&&Object.keys(p),m=f==null?void 0:f.map(I=>Oe(I));let g=n;const h=m==null?void 0:m.map(I=>{var P,y,S;const O=p==null?void 0:p[I],b=(P=O==null?void 0:O.pairedDrawPositions)==null?void 0:P.find(M=>M.includes(g)),w=b==null?void 0:b.find(M=>M!==g),T=l.find(M=>M.drawPosition===w),E=p==null?void 0:p[I+1],N=T==null?void 0:T.bye,$=(y=E==null?void 0:E.pairedDrawPositions)==null?void 0:y.find(M=>M.includes(w)),A=N&&$&&E&&((S=E.drawPositions)==null?void 0:S.includes(w)),C=b&&{pairedDrawPositionByeAdvancedPair:!A&&$,pairedDrawPosition:w,targetDrawPosition:g,relevantPair:b,roundNumber:I};return A&&(g=w),C}).filter(I=>I==null?void 0:I.targetDrawPosition),_=h==null?void 0:h.reduce((I,P)=>{const{roundNumber:y,relevantPair:S,targetDrawPosition:O,pairedDrawPosition:b,pairedDrawPositionByeAdvancedPair:w}=P,T={roundNumber:y,targetDrawPosition:O,relevantPair:S},E=w&&{roundNumber:y+1,targetDrawPosition:b,relevantPair:w,subsequentRoundRemoval:!0},N=[T,E].filter(Boolean);return I.concat(...N)},[]);return _==null||_.forEach(({roundNumber:I,targetDrawPosition:P,relevantPair:y})=>{const S=v==null?void 0:v[I].find(O=>Xt(O.drawPositions.filter(Boolean),y.filter(Boolean)));S&&(_6({inContextDrawMatchUps:t,targetDrawPosition:P,tournamentRecord:e,drawDefinition:r,structureId:i,roundNumber:I,matchUpsMap:o}),JS({inContextDrawMatchUps:t,positionAssignments:l,tournamentRecord:e,drawDefinition:r,targetMatchUp:S,drawPosition:n,matchUpsMap:o,structure:a,event:s}))}),{tasks:_,drawPositionCleared:c,positionAssignments:l}}function _6({inContextDrawMatchUps:t,targetDrawPosition:e,tournamentRecord:r,drawDefinition:n,matchUpsMap:o,roundNumber:i,structureId:s}){const{structure:a}=Ee({drawDefinition:n,structureId:s});if(!a)return{error:St};if(a.structureType===gr)return;o=o||lr({drawDefinition:n});const c=((o==null?void 0:o.mappedMatchUps)||{})[s].matchUps,{initialRoundNumber:u}=Rs({drawPosition:e,matchUps:c}),d=c==null?void 0:c.filter(v=>{var f;return v.roundNumber>=i&&v.roundNumber!==u&&((f=v.drawPositions)==null?void 0:f.includes(e))}),p=st({drawDefinition:n,structureId:s}).positionAssignments||[];return d==null||d.forEach(v=>JS({drawPosition:e,targetMatchUp:v,inContextDrawMatchUps:t,positionAssignments:p,tournamentRecord:r,drawDefinition:n,matchUpsMap:o,structure:a})),fc({},V)}function JS({inContextDrawMatchUps:t,positionAssignments:e,tournamentRecord:r,drawDefinition:n,targetMatchUp:o,drawPosition:i,matchUpsMap:s,structure:a,event:l}){var c,u,d,p,v;const f="removeDrawPosition",m=(c=o.drawPositions)==null?void 0:c.slice(),g=o.matchUpStatus,h=o.winningSide;s=s||lr({drawDefinition:n});const I=s.mappedMatchUps[a.structureId].matchUps,{initialRoundNumber:P}=Rs({drawPosition:i,matchUps:I});if(o.roundNumber&&P&&o.roundNumber>P){const U=(o.drawPositions||[]).map(C=>C===i?void 0:C);o.drawPositions=U}if(o.matchUpType===Qe){const U=t==null?void 0:t.find(D=>D.matchUpId===o.matchUpId),M=((U==null?void 0:U.sides)||[]).reduce((D,R,j)=>R.drawPosition===i?j:D,void 0);M!==void 0&&((d=(u=o.sides)==null?void 0:u[M])!=null&&d.lineUp)&&((p=o.sides)==null||delete p[M].lineUp,Ze({tournamentId:r==null?void 0:r.tournamentId,context:`${f}-TEAM`,eventId:l==null?void 0:l.eventId,matchUp:o,drawDefinition:n}))}const y=_r({matchUpId:o.matchUpId,inContextDrawMatchUps:t,drawDefinition:n}),{targetLinks:{winnerTargetLink:S},targetMatchUps:{loserMatchUp:O,winnerMatchUp:b,loserMatchUpDrawPositionIndex:w}}=y,E=e.filter(({drawPosition:U})=>{var C;return(C=o.drawPositions)==null?void 0:C.includes(U)}).filter(U=>U.bye).length,N=E&&nt||o.matchUpStatus&&[et,ot].includes(o.matchUpStatus)&&o.matcHUpStatus||((v=o.drawPositions)==null?void 0:v.length)===2&&Rt||void 0;o.matchUpStatus=N,o.matchUpStatus&&[ot,et].includes(o.matchUpStatus)&&(o.winningSide=void 0);const $=m==null?void 0:m.find(U=>{var C;return!((C=o.drawPositions)!=null&&C.includes(U))});if((m==null?void 0:m.includes(i))&&g===o.matchUpStatus&&h===o.winningSide||($&&Zn(),Ze({tournamentId:r==null?void 0:r.tournamentId,eventId:l==null?void 0:l.eventId,matchUp:o,context:`${f}-${i}`,drawDefinition:n})),O&&O.structureId!==y.matchUp.structureId&&!E){const{drawPositions:U,roundNumber:C}=O;if(C===1){const M=U[w];rm({structureId:O.structureId,drawPosition:M,inContextDrawMatchUps:t,tournamentRecord:r,drawDefinition:n,matchUpsMap:s})}else{const M=Math.min(...U.filter(Boolean)),D=I6({loserMatchUpDrawPosition:M,inContextDrawMatchUps:t,tournamentRecord:r,drawDefinition:n,loserMatchUp:O,matchUpsMap:s,event:l});if(D.error)return k({result:D,stack:f});const j=((s==null?void 0:s.mappedMatchUps)||{})[O.structureId].matchUps,{initialRoundNumber:G}=Rs({drawPosition:M,matchUps:j});G===1&&(Zn(),rm({structureId:O.structureId,drawPosition:M,inContextDrawMatchUps:t,tournamentRecord:r,drawDefinition:n,matchUpsMap:s}))}}return b&&b.structureId!==y.matchUp.structureId&&S.target.feedProfile,fc({},V)}function I6({loserMatchUpDrawPosition:t,inContextDrawMatchUps:e,tournamentRecord:r,drawDefinition:n,loserMatchUp:o,matchUpsMap:i,event:s}){const{structure:a}=Ee({structureId:o.structureId,drawDefinition:n}),{positionAssignments:l}=st({structure:a}),c=l==null?void 0:l.find(u=>u.drawPosition===t);if(c!=null&&c.bye){const u=Fa({drawPosition:t,structureId:o.structureId,inContextDrawMatchUps:e,tournamentRecord:r,drawDefinition:n,matchUpsMap:i,event:s});if(u.error)return u}return fc({},V)}function P6({matchUpStatuses:t=[nt,ot,et],drawPositionMatchUps:e,loserDrawPosition:r,sourceMatchUps:n}){var o;const i=e==null?void 0:e.reduce((d,p)=>!d||p.roundNumber>d.roundNumber?p:d,void 0),s=(o=i==null?void 0:i.drawPositions)==null?void 0:o.find(d=>d!==r),a=n.filter(d=>{var p;return(p=d==null?void 0:d.drawPositions)==null?void 0:p.includes(s)}).map(d=>d.matchUpStatus),l=n.filter(d=>{var p;return(p=d==null?void 0:d.drawPositions)==null?void 0:p.includes(r)}).map(d=>d.matchUpStatus),c=Xt(a||[],t),u=Xt(l||[],t);return{sourceMatchUp:i,winnerHadMatchUpStatus:c,winnerMatchUpStatuses:a,loserHadMatchUpStatus:u,loserMatchUpStatuses:l}}var y6=Object.defineProperty,S6=Object.defineProperties,O6=Object.getOwnPropertyDescriptors,ZS=Object.getOwnPropertySymbols,b6=Object.prototype.hasOwnProperty,T6=Object.prototype.propertyIsEnumerable,XS=(t,e,r)=>e in t?y6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Hi=(t,e)=>{for(var r in e||(e={}))b6.call(e,r)&&XS(t,r,e[r]);if(ZS)for(var r of ZS(e))T6.call(e,r)&&XS(t,r,e[r]);return t},w6=(t,e)=>S6(t,O6(e));function xa(t){const{dualWinningSideChange:e,inContextDrawMatchUps:r,tournamentRecord:n,drawDefinition:o,matchUpStatus:i,matchUpsMap:s,dualMatchUp:a,targetData:l,matchUpId:c,structure:u,event:d}=t,p=!!t.matchUp.collectionId,v=Mo({drawDefinition:o,structure:u}),{drawPositions:f,winningSide:m}=l.matchUp||{};if(!v&&!f)return{error:Xp};const{targetLinks:{loserTargetLink:g,winnerTargetLink:h,byeTargetLink:_},targetMatchUps:{loserMatchUp:I,winnerMatchUp:P,byeMatchUp:y}}=l,S=Qn(w6(Hi({},t),{matchUpStatus:i||Rt,removeWinningSide:!0}));if(S.error)return S;let O;if(p){const{matchUpTieId:D,matchUpsMap:R}=t;if(O=po({matchUpId:D,tournamentRecord:n,drawDefinition:o,matchUpsMap:R,event:d}),!e&&!O.removeWinningSide)return Hi({},V)}if(v)return Hi({},V);const{matchUps:b}=Je({afterRecoveryTimes:!1,inContext:!0,drawDefinition:o,matchUpsMap:s,structure:u}),{positionAssignments:w}=Ct({structure:u}),T=m-1,E=1-T,N=f[T],$=f[E],{winnerParticipantId:A,loserParticipantId:U}=(w==null?void 0:w.reduce((D,R)=>(R.drawPosition===$&&(D.loserParticipantId=R.participantId),R.drawPosition===N&&(D.winnerParticipantId=R.participantId),D),{winnerParticipantId:void 0,loserParticipantId:void 0}))||{},C=b.filter(D=>{var R;return(R=D.drawPositions)==null?void 0:R.includes($)});if(P&&eO({sourceMatchUpStatus:i,sourceMatchUpId:c,inContextDrawMatchUps:r,winningDrawPosition:N,winnerParticipantId:A,tournamentRecord:n,winnerTargetLink:h,drawDefinition:o,winnerMatchUp:P,dualMatchUp:a,matchUpsMap:s}),I){const{winnerHadMatchUpStatus:D}=P6({drawPositionMatchUps:C,loserDrawPosition:$,sourceMatchUps:b}),j=g.linkCondition===uo;if(D&&j){const W=Math.min(...I.drawPositions);nm({targetLink:g,inContextDrawMatchUps:r,drawDefinition:o,drawPosition:W,matchUpsMap:s,event:d})}const G=E6({sourceMatchUpStatus:i,sourceMatchUpId:c,loserParticipantId:U,tournamentRecord:n,loserTargetLink:g,drawDefinition:o,loserMatchUp:I,dualMatchUp:a,matchUpsMap:s,event:d});if(G.error)return G}if(y){const D=Math.min(...y.drawPositions);nm({sourceMatchUpId:c,targetLink:_,inContextDrawMatchUps:r,drawDefinition:o,drawPosition:D,matchUpsMap:s,event:d})}const M=O&&{tieMatchUpResult:O};return Hi(Hi({},V),M)}function eO({inContextDrawMatchUps:t,winningDrawPosition:e,sourceMatchUpStatus:r,winnerParticipantId:n,tournamentRecord:o,winnerTargetLink:i,sourceMatchUpId:s,drawDefinition:a,winnerMatchUp:l,matchUpsMap:c,dualMatchUp:u,event:d}){var p;const{structureId:v,roundNumber:f}=l,m="removeDirectedWinner";if(i){const g=i.target.structureId,{structure:h}=Ee({drawDefinition:a,structureId:g});if(!h)return{error:St};const{positionAssignments:_}=Ct({structure:h});h.seedAssignments=(h.seedAssignments||[]).filter(T=>T.participantId!==n);const I=_==null?void 0:_.find(T=>T.participantId===n),P=I==null?void 0:I.drawPosition,{matchUps:y}=Je({drawDefinition:a,structure:h,event:d}),S=y.map(T=>T.drawPositions).flat(1/0).filter(Boolean),O=$r(S);if((P?O[P]:void 0)===1)_==null||_.forEach(T=>{T.participantId===n&&delete T.participantId});else{const T=y.filter(({drawPositions:E})=>E.includes(P));console.log("not removing from position assignments since instances > 1",{drawPositionMatchUps:T,winnerTargetLink:i})}const w=(p=c==null?void 0:c.drawMatchUps)==null?void 0:p.find(({matchUpId:T})=>T===l.matchUpId);w&&Ze({tournamentId:o==null?void 0:o.tournamentId,eventId:d==null?void 0:d.eventId,matchUp:w,context:m,drawDefinition:a})}return f&&u6({targetDrawPosition:e,inContextDrawMatchUps:t,sourceMatchUpStatus:r,tournamentRecord:o,sourceMatchUpId:s,drawDefinition:a,dualMatchUp:u,matchUpsMap:c,roundNumber:f,structureId:v}),Hi({},V)}function E6({sourceMatchUpStatus:t,loserParticipantId:e,tournamentRecord:r,loserTargetLink:n,sourceMatchUpId:o,drawDefinition:i,loserMatchUp:s,matchUpsMap:a,dualMatchUp:l,event:c}){var u,d,p;const v="removeDirectedLoser",f=n.target.structureId,{structure:m}=Ee({drawDefinition:i,structureId:f});if(!m)return{error:St};const{positionAssignments:g}=Ct({structure:m}),h=(u=g==null?void 0:g.find(_=>_.participantId===e))==null?void 0:u.drawPosition;if(g==null||g.forEach(_=>{_.participantId===e&&delete _.participantId}),m.seedAssignments=(m.seedAssignments||[]).filter(_=>_.participantId!==e),l){const _=s==null?void 0:s.sides.reduce((y,S,O)=>S.drawPosition===h?O:y,void 0),I=(d=a==null?void 0:a.drawMatchUps)==null?void 0:d.find(({matchUpId:y})=>y===s.matchUpId),P=(p=I==null?void 0:I.sides)==null?void 0:p[_];P&&(delete P.lineUp,Ze({tournamentId:r==null?void 0:r.tournamentId,eventId:c==null?void 0:c.eventId,matchUp:I,context:v,drawDefinition:i}))}return Hi({},V)}function nm({inContextDrawMatchUps:t,tournamentRecord:e,drawDefinition:r,drawPosition:n,matchUpsMap:o,targetLink:i,event:s}){const a=i.target.structureId;return Fa({inContextDrawMatchUps:t,tournamentRecord:e,drawDefinition:r,matchUpsMap:o,drawPosition:n,structureId:a,event:s}),Hi({},V)}function tO(t){let{sourceMatchUp:e}=t;const{targetMatchUp:r,structure:n,matchUpsMap:o,drawPosition:i}=t,s=r.roundNumber>1&&r.roundNumber-1,a=Li({structureId:n.structureId,matchUpsMap:o});!e&&i&&(e=a.find(({drawPositions:f,roundNumber:m})=>m===s&&(f==null?void 0:f.includes(i))));const l=e==null?void 0:e.roundPosition,c=l%2?1:-1,u=l+c,d=s&&a.find(({roundNumber:f,roundPosition:m})=>f===s&&m===u),p=d==null?void 0:d.matchUpStatus,v=[jt,tr].includes(p);return{pairedPreviousMatchUp:d,pairedPreviousMatchUpIsDoubleExit:v}}function vd({drawDefinition:t,positionAction:e}){var r;const{extension:n}=xr({name:mu,element:t}),o=Array.isArray(n==null?void 0:n.value)?(n==null?void 0:n.value)||[]:[];if(!(o!=null&&o.length)){const s=t.structures.find(a=>a.stage===ge);if(s){const a=(r=st({structure:s}).positionAssignments)==null?void 0:r.map(({drawPosition:l,participantId:c,bye:u,qualifier:d})=>({drawPosition:l,participantId:c,qualifier:d,bye:u}));o.push({name:"initialMainAssignments",initialAssignments:a})}}const i={name:mu,value:o.concat(e)};it({element:t,extension:i})}var $6=Object.defineProperty,rO=Object.getOwnPropertySymbols,N6=Object.prototype.hasOwnProperty,U6=Object.prototype.propertyIsEnumerable,nO=(t,e,r)=>e in t?$6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,md=(t,e)=>{for(var r in e||(e={}))N6.call(e,r)&&nO(t,r,e[r]);if(rO)for(var r of rO(e))U6.call(e,r)&&nO(t,r,e[r]);return t};function Yr({provisionalPositioning:t,isPositionAction:e,tournamentRecord:r,drawDefinition:n,drawPosition:o,matchUpsMap:i,structureId:s,structure:a,event:l}){var c;if(!n)return{error:fe};if(a||({structure:a}=Ee({drawDefinition:n,structureId:s})),!a)return{error:St};s||({structureId:s}=a);const u="assignDrawPositionBye";Zn(),i||(i=lr({drawDefinition:n}));const{positionAssignments:d}=st({structure:a}),{activeDrawPositions:p}=pc({drawDefinition:n,structureId:s}),v=d==null?void 0:d.find(N=>N.drawPosition===o);if(v!=null&&v.bye)return md({},V);if(p==null?void 0:p.includes(o))return{error:ef};const m=d==null?void 0:d.find(N=>N.drawPosition===o);if(!m)return{error:ta};const{filled:g,containsBye:h,assignedParticipantId:_}=A6(m);if(h)return md({},V);if(g&&!h)return k({result:{error:pl},stack:u});const I=xt({inContext:!0,drawDefinition:n,matchUpsMap:i}).matchUps||[],P={isCollectionMatchUp:!1},{matchUps:y}=Je({provisionalPositioning:t,drawDefinition:n,matchUpFilters:P,matchUpsMap:i,structure:a});if(d==null||d.forEach(N=>{N.drawPosition===o&&(N.bye=!0)}),a.structureType===gr)return C6({tournamentRecord:r,drawDefinition:n,drawPosition:o,matchUps:y}),ai({tournamentId:r==null?void 0:r.tournamentId,drawDefinition:n,structure:a,event:l}),oO({assignedParticipantId:_,isPositionAction:e,drawDefinition:n,drawPosition:o,structureId:s,stack:u});const{roundProfile:S,roundMatchUps:O}=br({matchUps:y}),b=S&&Object.keys(S).map(N=>parseInt(N)).reverse(),w=b==null?void 0:b.find(N=>{var $;return($=S==null?void 0:S[N].drawPositions)==null?void 0:$.includes(o)}),T=w&&(O==null?void 0:O[w].find(({drawPositions:N})=>N==null?void 0:N.includes(o)));iO({tournamentRecord:r,drawDefinition:n,matchUp:T,event:l});const E=(c=T.drawPositions)==null?void 0:c.find(N=>N!==o);if(E){const N=om({sourceDrawPositions:T.drawPositions,matchUpId:T.matchUpId,inContextDrawMatchUps:I,drawPositionToAdvance:E,tournamentRecord:r,drawDefinition:n,matchUpsMap:i});if(N.error)return N}return ai({tournamentId:r==null?void 0:r.tournamentId,drawDefinition:n,structure:a,event:l}),oO({assignedParticipantId:_,isPositionAction:e,drawDefinition:n,drawPosition:o,structureId:s,stack:u})}function oO({assignedParticipantId:t,isPositionAction:e,drawDefinition:r,drawPosition:n,structureId:o,stack:i}){return e&&vd({drawDefinition:r,positionAction:{removedParticipantId:t,drawPosition:n,structureId:o,name:i}}),k({result:md({},V),stack:i})}function A6(t){const e=t.bye,r=t.qualifier,n=t.participantId;return{containsBye:e,containsQualifier:r,assignedParticipantId:n,filled:e||r||n}}function iO({tournamentRecord:t,drawDefinition:e,eventId:r,matchUp:n,event:o}){Object.assign(n,{matchUpStatus:nt,score:void 0,winningSide:void 0}),Ze({tournamentId:t==null?void 0:t.tournamentId,eventId:r??(o==null?void 0:o.eventId),context:"setMatchUpStatusBye",drawDefinition:e,matchUp:n})}function C6({tournamentRecord:t,drawDefinition:e,drawPosition:r,matchUps:n,event:o}){n.forEach(i=>{var s;(s=i.drawPositions)!=null&&s.includes(r)&&iO({eventId:o==null?void 0:o.eventId,tournamentRecord:t,drawDefinition:e,matchUp:i})})}function om({drawPositionToAdvance:t,inContextDrawMatchUps:e,sourceDrawPositions:r,tournamentRecord:n,drawDefinition:o,matchUpsMap:i,matchUpId:s,event:a}){var l;Zn();const c=i.drawMatchUps.find(y=>y.matchUpId===s),u=e.find(y=>y.matchUpId===s),d=u==null?void 0:u.structureId,{structure:p}=Ee({drawDefinition:o,structureId:d}),{positionAssignments:v}=st({structure:p}),f=v==null?void 0:v.filter(y=>y.bye).map(y=>y.drawPosition),m=(l=c==null?void 0:c.drawPositions)==null?void 0:l.find(y=>y!==t),g=m&&(f==null?void 0:f.includes(m)),{targetLinks:{loserTargetLink:h},targetMatchUps:{loserMatchUp:_,winnerMatchUp:I,loserTargetDrawPosition:P}}=_r({inContextDrawMatchUps:e,drawDefinition:o,matchUpId:s});if(I&&I.structureId===(p==null?void 0:p.structureId)&&M6({drawPositionToAdvance:t,inContextDrawMatchUps:e,sourceDrawPositions:r,tournamentRecord:n,drawDefinition:o,winnerMatchUp:I,matchUpsMap:i,event:a}),_&&g&&_.structureId!==(p==null?void 0:p.structureId)){const{roundNumber:y}=_;if(y===1){const S=Yr({structureId:h.target.structureId,drawPosition:P,tournamentRecord:n,drawDefinition:o,event:a});if(S.error)return S}else sO({loserTargetDrawPosition:P,tournamentRecord:n,loserTargetLink:h,drawDefinition:o,loserMatchUp:_,matchUpsMap:i,event:a})}return md({},V)}function M6({drawPositionToAdvance:t,inContextDrawMatchUps:e,sourceDrawPositions:r,tournamentRecord:n,drawDefinition:o,winnerMatchUp:i,matchUpsMap:s,event:a}){var l,c,u;const d="advanceWinner",p=s.drawMatchUps.find(j=>j.matchUpId===i.matchUpId),v=e.find(j=>j.matchUpId===i.matchUpId),f=v==null?void 0:v.structureId,{structure:m}=Ee({drawDefinition:o,structureId:f}),{positionAssignments:g}=st({structure:m}),h=g==null?void 0:g.find(({drawPosition:j})=>j===t),_=h==null?void 0:h.bye,I=(l=p.drawPositions)==null?void 0:l.filter(Boolean),P=g==null?void 0:g.filter(j=>I==null?void 0:I.includes(j.drawPosition)),y=g==null?void 0:g.find(({drawPosition:j})=>j===t),S=r==null?void 0:r.find(j=>j!==t),O=S&&(P==null?void 0:P.find(({drawPosition:j})=>j===S)),b=O==null?void 0:O.bye,w=_&&b;if(w&&console.log({isByeAdvancedBye:w}),(I==null?void 0:I.length)>1&&_&&!b)return k({result:{error:pl},stack:d});const T=I==null?void 0:I.find(j=>j!==t);let E=w;const N=[...(p.drawPositions||[]).filter(Boolean),void 0,void 0].slice(0,2),$=N.map(j=>!j&&!E||j===t?(E=!0,t):j).sort(er);if(!E)return console.log("@@@@@@@",{advancingAssignmentIsBye:y,drawPositionToAdvance:t,existingAssignments:P}),k({result:{error:pl},stack:d});const A=(c=g==null?void 0:g.find(({drawPosition:j})=>j===T))==null?void 0:c.bye,U=(u=g==null?void 0:g.find(({drawPosition:j})=>j===t))==null?void 0:u.bye;Object.assign(p,{matchUpStatus:U||A?nt:Rt,score:void 0,winningSide:void 0,drawPositions:$}),p.drawPositions.find(j=>!N.includes(j)),Zn(),Ze({tournamentId:n==null?void 0:n.tournamentId,matchUp:p,eventId:a==null?void 0:a.eventId,context:d,drawDefinition:o});const{targetLinks:{loserTargetLink:M},targetMatchUps:{loserMatchUp:D,loserTargetDrawPosition:R}}=_r({matchUpId:i.matchUpId,inContextDrawMatchUps:e,drawDefinition:o});if(A||U){const j=A?t:T;if(j)om({drawPositionToAdvance:j,matchUpId:i.matchUpId,inContextDrawMatchUps:e,tournamentRecord:n,drawDefinition:o,matchUpsMap:s});else if(U&&M&&D)if(D.feedRound)sO({loserTargetDrawPosition:R,tournamentRecord:n,loserTargetLink:M,drawDefinition:o,loserMatchUp:D,matchUpsMap:s});else{const W=1-i.roundPosition%2,z=D.drawPositions[W],F=Yr({structureId:M.target.structureId,drawPosition:z,tournamentRecord:n,drawDefinition:o,event:a});if(F.error)return F}}}function sO({loserTargetDrawPosition:t,tournamentRecord:e,loserTargetLink:r,drawDefinition:n,loserMatchUp:o,matchUpsMap:i,event:s}){const{roundNumber:a}=o;Zn();const c=((i==null?void 0:i.mappedMatchUps)||{})[o.structureId].matchUps,{initialRoundNumber:u}=Rs({drawPosition:t,matchUps:c});if(u===a){const d=Yr({structureId:r.target.structureId,drawPosition:t,tournamentRecord:e,drawDefinition:n,event:s});if(d.error)return d}}var D6=Object.defineProperty,j6=Object.defineProperties,R6=Object.getOwnPropertyDescriptors,aO=Object.getOwnPropertySymbols,F6=Object.prototype.hasOwnProperty,x6=Object.prototype.propertyIsEnumerable,lO=(t,e,r)=>e in t?D6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,L6=(t,e)=>{for(var r in e||(e={}))F6.call(e,r)&&lO(t,r,e[r]);if(aO)for(var r of aO(e))x6.call(e,r)&&lO(t,r,e[r]);return t},V6=(t,e)=>j6(t,R6(e));function im({inContextTargetMatchUp:t,drawPositionSideIndex:e,teamParticipantId:r,tournamentRecord:n,drawDefinition:o,matchUp:i,event:s}){var a,l,c,u;const d=(l=(a=t==null?void 0:t.sides)==null?void 0:a[e])==null?void 0:l.sideNumber,p=d&&((c=i.sides)==null?void 0:c.find(g=>g.sideNumber===d)),{extension:v}=Kt({element:o,name:Gn}),m=((v==null?void 0:v.value)||{})[r];if(p)(u=i==null?void 0:i.sides)==null||u.forEach(g=>{g.sideNumber===d&&(g.lineUp=m)});else{i.sides=[1,2].map(h=>{var _;const I=((_=i.sides)==null?void 0:_.find(P=>P.sideNumber===h))||{};return V6(L6({},I),{sideNumber:h})});const g=i.sides.find(h=>h.sideNumber===d);g&&(g.lineUp=m)}Ze({tournamentId:n==null?void 0:n.tournamentId,context:"updateSidLineUps",eventId:s==null?void 0:s.eventId,drawDefinition:o,matchUp:i})}function B6({drawPosition:t,drawPositions:e}){let r=!1,n=!!(e!=null&&e.includes(t));return{updatedDrawPositions:n?e||[]:[...e,void 0,void 0].slice(0,2).map(s=>!s&&!n?(n=!0,r=!0,t):s).sort(er).filter(Boolean),positionAdded:r,positionAssigned:n}}function gd({inContextDrawMatchUps:t,drawPosition:e,matchUpId:r}){const n=t.filter(({winnerMatchUpId:s,loserMatchUpId:a})=>a===r||s===r).sort((s,a)=>s.roundPosition-a.roundPosition);return t.find(s=>s.matchUpId===r).feedRound?1:n.reduce((s,a,l)=>{var c;return(c=a.drawPositions)!=null&&c.includes(e)?l+1:s},void 0)}var k6=Object.defineProperty,cO=Object.getOwnPropertySymbols,G6=Object.prototype.hasOwnProperty,W6=Object.prototype.propertyIsEnumerable,uO=(t,e,r)=>e in t?k6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,H6=(t,e)=>{for(var r in e||(e={}))G6.call(e,r)&&uO(t,r,e[r]);if(cO)for(var r of cO(e))W6.call(e,r)&&uO(t,r,e[r]);return t};function La({inContextDrawMatchUps:t,sourceMatchUpStatus:e,tournamentRecord:r,sourceMatchUpId:n,drawDefinition:o,matchUpStatus:i,drawPosition:s,matchUpsMap:a,matchUpId:l,event:c}){var u,d,p;const v="assignMatchUpDrawPosition";a||(a=lr({drawDefinition:o})),t||(t=xt({inContext:!0,drawDefinition:o,matchUpsMap:a}).matchUps||[]);const f=t.find(C=>C.matchUpId===l),m=f==null?void 0:f.structureId,g=(u=o==null?void 0:o.structures)==null?void 0:u.find(C=>C.structureId===m);if(!g)return{error:St};const h=(d=a==null?void 0:a.drawMatchUps)==null?void 0:d.find(C=>C.matchUpId===l),_=(h==null?void 0:h.drawPositions)||[],{positionAdded:I,positionAssigned:P,updatedDrawPositions:y}=B6({drawPosition:s,drawPositions:_}),{positionAssignments:S}=st({drawDefinition:o,structure:g}),O=S==null?void 0:S.filter(C=>y.includes(C.drawPosition)),b=O==null?void 0:O.find(({bye:C})=>C),w=(h==null?void 0:h.matchUpStatus)&&[ot,et].includes(h.matchUpStatus)&&y.filter(Boolean).length<2;if(i=b&&nt||i||w&&h.matchUpStatus||(h==null?void 0:h.matchUpStatus)&&[jt,tr].includes(h.matchUpStatus)&&h.matchUpStatus||Rt,h&&I){t=xt({inContext:!0,drawDefinition:o,matchUpsMap:a}).matchUps||[];const C=w&&gd({inContextDrawMatchUps:t,drawPosition:s,matchUpId:l})||void 0;h!=null&&h.matchUpStatusCodes&&HS({inContextDrawMatchUps:t,sourceMatchUpStatus:e,sourceMatchUpId:n,matchUpsMap:a,matchUp:h}),Object.assign(h,{drawPositions:y,winningSide:C,matchUpStatus:i}),Ze({tournamentId:r==null?void 0:r.tournamentId,eventId:f==null?void 0:f.eventId,context:v,drawDefinition:o,matchUp:h})}const T=_r({inContextDrawMatchUps:t,inContextMatchUp:f,drawDefinition:o,matchUpId:l}),{targetMatchUps:{winnerMatchUp:E,loserMatchUp:N,loserTargetDrawPosition:$},targetLinks:{loserTargetLink:A}}=T,U=Li({structureId:g.structureId,matchUpsMap:a});if(P&&b){if(E)if([nt,jt,tr].includes(i)){const C=La({matchUpId:E.matchUpId,inContextDrawMatchUps:t,tournamentRecord:r,drawDefinition:o,drawPosition:s,matchUpsMap:a});if(C.error)return C}else{const{structureId:C}=E;C!==g.structureId&&console.log("winnerMatchUp in different structure... participant is in different targetDrawPosition")}}else if(E&&f&&!f.feedRound){const{pairedPreviousMatchUpIsDoubleExit:C}=tO({targetMatchUp:h,drawPosition:s,matchUpsMap:a,structure:g});if(C){const M=La({matchUpId:E.matchUpId,inContextDrawMatchUps:t,tournamentRecord:r,drawDefinition:o,drawPosition:s,matchUpsMap:a});if(M.error)return M}}if((h==null?void 0:h.matchUpType)===Qe){const C=t==null?void 0:t.find(({matchUpId:j})=>j===h.matchUpId),D=((C==null?void 0:C.sides)||[]).reduce((j,G,W)=>G.drawPosition===s?W:j,void 0),R=(p=S==null?void 0:S.find(j=>j.drawPosition===s))==null?void 0:p.participantId;R&&D!==void 0&&im({inContextTargetMatchUp:C,drawPositionSideIndex:D,teamParticipantId:R,tournamentRecord:r,drawDefinition:o,matchUp:h})}if((A==null?void 0:A.linkCondition)===uo&&y.filter(Boolean).length===2&&!b&&U.filter(({drawPositions:D,roundNumber:R})=>R===1&&Xt(D,y)).every(({matchUpStatus:D})=>[At,hr].includes(D))&&N){const{structureId:D}=N,R=Yr({drawPosition:$,tournamentRecord:r,drawDefinition:o,structureId:D,matchUpsMap:a,event:c});if(R.error)return R}return P?H6({},V):k({result:{error:pl},context:{drawPosition:s},stack:v})}var q6=Object.defineProperty,z6=Object.defineProperties,Y6=Object.getOwnPropertyDescriptors,dO=Object.getOwnPropertySymbols,K6=Object.prototype.hasOwnProperty,Q6=Object.prototype.propertyIsEnumerable,pO=(t,e,r)=>e in t?q6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,go=(t,e)=>{for(var r in e||(e={}))K6.call(e,r)&&pO(t,r,e[r]);if(dO)for(var r of dO(e))Q6.call(e,r)&&pO(t,r,e[r]);return t},Va=(t,e)=>z6(t,Y6(e));function vc(t){var e;const{tournamentRecord:r,appliedPolicies:n,drawDefinition:o,matchUpsMap:i,targetData:s,structure:a,event:l}=t,c="doubleExitAdvancement";if(a.structureType===gr)return k({result:go({},V),stack:c});const{matchUp:u,targetMatchUps:d,targetLinks:p}=s,{loserMatchUp:v,winnerMatchUp:f,loserTargetDrawPosition:m}=d;if(v&&v.matchUpStatus!==pt.Bye){const{loserTargetLink:g}=p;if((e=n==null?void 0:n.progression)!=null&&e.doubleExitPropagateBye){const h=vO({loserTargetDrawPosition:m,tournamentRecord:r,loserTargetLink:g,drawDefinition:o,loserMatchUp:v,matchUpsMap:i,event:l});if(h.error)return k({result:h,stack:c})}else{const{feedRound:h,drawPositions:_,matchUpId:I}=v,P=h?2:2-_.indexOf(m),y=fO(Va(go({},t),{targetMatchUp:v,walkoverWinningSide:P,tournamentRecord:r,sourceMatchUp:u,matchUpId:I}));if(y.error)return k({result:y,stack:c})}}if(f){const g=fO(Va(go({},t),{matchUpId:f.matchUpId,targetMatchUp:f,tournamentRecord:r,sourceMatchUp:u}));if(g.error)return k({result:g,stack:c})}return k({result:go({},V),stack:c})}function fO(t){var e,r,n;const{inContextDrawMatchUps:o,tournamentRecord:i,drawDefinition:s,sourceMatchUp:a,targetMatchUp:l,matchUpsMap:c}=t,u=s.structures.find(({structureId:H})=>H===l.structureId),d=t.matchUpStatus===pt.DoubleDefault?pt.DoubleDefault:pt.DoubleWalkover,p=t.matchUpStatus===pt.DoubleDefault?pt.Defaulted:pt.Walkover,v="conditionallyAdvanceDrawPosition",f=c.drawMatchUps.find(H=>H.matchUpId===l.matchUpId);if(!f)return{error:jr};const m=(a==null?void 0:a.drawPositions)||[];let g=(e=f.drawPositions)==null?void 0:e.filter(Boolean);const h=(a==null?void 0:a.structureId)===l.structureId;if(h&&Xt(m,g)&&(g=g.filter(H=>!m.includes(H))),h&&g.length>1)return k({result:{error:pl},stack:v});const{pairedPreviousMatchUpIsDoubleExit:_,pairedPreviousMatchUp:I}=tO(t),P=_r({matchUpId:l.matchUpId,inContextDrawMatchUps:o,drawDefinition:s}),{targetMatchUps:y,targetLinks:S}=P,{loserTargetDrawPosition:O,winnerMatchUp:b,loserMatchUp:w}=y;if(w){const{loserTargetLink:H}=S,q=vO({loserTargetDrawPosition:O,loserMatchUp:w,tournamentRecord:i,loserTargetLink:H,drawDefinition:s,matchUpsMap:c});if(q.error)return k({result:q,stack:v})}const T=((r=f.drawPositions)==null?void 0:r.filter(Boolean))||[],E=T.length===1,N=t.walkoverWinningSide||E&&gd({drawPosition:T[0],matchUpId:l.matchUpId,inContextDrawMatchUps:o})||void 0,$=[pt.Walkover,pt.Defaulted].includes(f.matchUpStatus)&&!T.length,A=f.finishingRound===1,U=$&&!A?d:p,C=o.find(H=>H.matchUpId===I.matchUpId);let M=[],D;a&&((a==null?void 0:a.structureId)===(C==null?void 0:C.structureId)?a.roundPosition<(I==null?void 0:I.roundPosition)?D=1:D=2:l.feedRound?a.structureId===l.structureId?D=2:D=1:N&&(D=3-N));const R=t.matchUpStatus,j=I==null?void 0:I.matchUpStatus;D===1?M=[{matchUpStatus:hd(R),previousMatchUpStatus:R,sideNumber:1},{matchUpStatus:hd(j),previousMatchUpStatus:j,sideNumber:2}]:D===2&&(M=[{matchUpStatus:hd(j),previousMatchUpStatus:j,sideNumber:1},{matchUpStatus:hd(R),previousMatchUpStatus:R,sideNumber:2}]),M.length&&(M=M.map(H=>ye(H)));const G=Qn(Va(go({},t),{matchUp:f,winningSide:N,matchUpStatusCodes:M,matchUpStatus:U}));if(G.error)return k({result:G,stack:v});if($)return vc(Va(go({},t),{matchUpStatus:U,targetData:P}));if(!b)return k({result:go({},V),stack:v});const W=g.length===2?g[N-1]:g[0],{positionAssignments:z}=st({structure:u}),F=z==null?void 0:z.find(H=>H.drawPosition===W),L=c.drawMatchUps.find(H=>H.matchUpId===b.matchUpId),x=(n=L==null?void 0:L.drawPositions)==null?void 0:n.filter(Boolean),B=x.length===1;if(W){if(F!=null&&F.bye){const H=_r({matchUpId:L.matchUpId,inContextDrawMatchUps:o,drawDefinition:s});if(B){const q=x.filter(Boolean)[0],J=gd({drawPosition:q,matchUpId:L.matchUpId,inContextDrawMatchUps:o}),K=Qn({matchUpId:L.matchUpId,matchUp:L,matchUpStatus:p,matchUpStatusCodes:[],removeScore:!0,drawDefinition:s,winningSide:J});return K.error?k({result:K,stack:v}):om({drawPositionToAdvance:q,matchUpId:L.matchUpId,inContextDrawMatchUps:o,drawDefinition:s,matchUpsMap:c})}else if([pt.Walkover,pt.Defaulted].includes(b.matchUpStatus)){const q=vc(Va(go({},t),{matchUpId:L.matchUpId,matchUpStatus:U,targetData:H}));if(q.error)return k({result:q,stack:v})}return k({result:go({},V),stack:v})}return La({matchUpId:b.matchUpId,drawPosition:W,inContextDrawMatchUps:o,drawDefinition:s})}else if(_){if(!L)return{error:jr};if(B){const J=x[0],K=gd({matchUpId:l.matchUpId,inContextDrawMatchUps:o,drawPosition:J});console.log("existing drawPosition is winningSide",{walkoverWinningSide:K})}const H=[pt.Walkover,pt.Defaulted].includes(L.matchUpStatus)?p:d,q=Qn({matchUpId:L.matchUpId,matchUp:L,matchUpStatusCodes:[],removeScore:!0,drawDefinition:s,matchUpStatus:H});if(q.error)return k({result:q,stack:v});if(H===d){const J=vc(Va(go({},t),{matchUpId:l.matchUpId,matchUpStatus:H,targetData:P}));if(J.error)return J}}return k({result:go({},V),stack:v})}function vO(t){var e;const{loserTargetDrawPosition:r,tournamentRecord:n,loserTargetLink:o,drawDefinition:i,matchUpsMap:s,event:a}=t,l=(e=o==null?void 0:o.target)==null?void 0:e.structureId,{structure:c}=Ee({drawDefinition:i,structureId:l});return c?Yr({drawPosition:r,tournamentRecord:n,drawDefinition:i,structureId:l,matchUpsMap:s,event:a}):{error:ra}}function hd(t){return t===pt.DoubleWalkover?pt.Walkover:t===pt.DoubleDefault?pt.Defaulted:t}var J6=Object.defineProperty,mO=Object.getOwnPropertySymbols,Z6=Object.prototype.hasOwnProperty,X6=Object.prototype.propertyIsEnumerable,gO=(t,e,r)=>e in t?J6(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,e5=(t,e)=>{for(var r in e||(e={}))Z6.call(e,r)&&gO(t,r,e[r]);if(mO)for(var r of mO(e))X6.call(e,r)&&gO(t,r,e[r]);return t};function t5({tournamentRecord:t,drawDefinition:e,structure:r,matchUp:n}){var o;const i="attemptToSetMatchUpStatusBYE";if(n!=null&&n.winningSide)return k({result:{error:vl},context:{matchUpStatus:nt},stack:i});const{positionAssignments:s}=Ct({structure:r}),a=s==null?void 0:s.filter(c=>c.bye).map(c=>c.drawPosition);return((o=n.drawPositions)==null?void 0:o.some(c=>a==null?void 0:a.includes(c)))?(n.matchUpStatus=nt,n.matchUpStatusCodes=[],Ze({tournamentId:t==null?void 0:t.tournamentId,context:i,drawDefinition:e,matchUp:n}),e5({},V)):k({result:{error:px},info:"matchUp does not include BYE",stack:i})}var r5=Object.defineProperty,n5=Object.defineProperties,o5=Object.getOwnPropertyDescriptors,hO=Object.getOwnPropertySymbols,i5=Object.prototype.hasOwnProperty,s5=Object.prototype.propertyIsEnumerable,_O=(t,e,r)=>e in t?r5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,IO=(t,e)=>{for(var r in e||(e={}))i5.call(e,r)&&_O(t,r,e[r]);if(hO)for(var r of hO(e))s5.call(e,r)&&_O(t,r,e[r]);return t},PO=(t,e)=>n5(t,o5(e));function a5(t){const{tournamentRecord:e,drawDefinition:r,matchUpStatus:n,structure:o,matchUp:i}=t,s=!!(i.tieMatchUps&&!i.rondPosition&&t.inContextDrawMatchUps.find(h=>h.matchUpId===i.matchUpId).containerStructureId),a="attemptToSetMatchUpStatus",l=n===nt,c=i.winningSide,u=[jt,tr].includes(n),d=nc({matchUpStatus:n}),p=fv({matchUpStatus:n}),v=!d&&!p,f=t.matchUpTieId||c&&d&&!u,m=c&&u,g=()=>Qn(PO(IO({},t),{removeScore:[zo,ot].includes(n),matchUpStatus:n||Rt}));return v&&{error:Jh}||f&&sm(t)||m&&l5(t)||c&&xa(t)||p&&g()||l&&t5({tournamentRecord:e,drawDefinition:r,structure:o,matchUp:i})||!d&&{error:Jh}||u&&c5(t)||s&&sm(t)||k({result:{error:vl},stack:a})}function l5(t){const e=xa(t);return e.error?e:vc(t)}function c5(t){const e=sm(PO(IO({},t),{removeScore:!0}));return e.error?e:vc(t)}function sm(t){var e;const r="scoreModification";if(t.isCollectionMatchUp&&((e=t.dualMatchUp)==null?void 0:e.winningSide)&&!t.projectedWinningSide){const s=xa(t);if(s.error)return k({result:s,stack:r})}const o=!!t.matchUp.collectionId,i=Qn(t);if(o){const{matchUpTieId:s,drawDefinition:a,matchUpsMap:l}=t,c=po({tournamentRecord:t.tournamentRecord,matchUpId:s,event:t.event,drawDefinition:a,matchUpsMap:l});if(c.error)return k({result:c,stack:r});Object.assign(i,{tieMatchUpResult:c})}return k({result:i,stack:r})}function u5({drawDefinition:t,structure:e,matchUp:r}){var n,o;const{drawPositions:i}=r,{positionAssignments:s}=st({drawDefinition:t,structure:e}),a=s==null?void 0:s.filter(({drawPosition:v})=>i==null?void 0:i.includes(v)),l=a==null?void 0:a.map(v=>{var f;const{extension:m}=Kt({element:v,name:Jo});return(f=m==null?void 0:m.value)==null?void 0:f.groupOrder}),{containerStructures:c}=Ra({drawDefinition:t}),u=c[e.structureId],d=(o=(n=sc({drawDefinition:t,structureId:u}))==null?void 0:n.links)==null?void 0:o.source;return{structureIds:d==null?void 0:d.filter(v=>{var f;return Xt(l,((f=v.source)==null?void 0:f.finishingPositions)||[])}).map(v=>v.source.structureId)}}function yO({drawDefinition:t,structureId:e}){if(!t)return{error:fe};const{structure:r}=Ee({drawDefinition:t,structureId:e}),n=((t==null?void 0:t.links)||[]).filter(i=>{var s;return((s=i.source)==null?void 0:s.structureId)===e}).map(i=>{var s;return(s=i.target)==null?void 0:s.structureId});return{playoffStructures:((t==null?void 0:t.structures)||[]).filter(i=>n.includes(i.structureId)&&i.stage===mt),structure:r}}function SO({withStageGrouping:t,stageSequences:e,stageSequence:r,roundTarget:n,stages:o,event:i,stage:s}){if(!i)return{error:Ge};const a={},l=[];for(const c of i.drawDefinitions||[]){const{structures:u,stageStructures:d}=un({withStageGrouping:t,stageSequences:e,drawDefinition:c,stageSequence:r,roundTarget:n,stages:o,stage:s});if(l.push(...u),d)for(const p of Object.keys(d))a[p]||(a[p]=[]),a[p].push(...d[p])}return{structures:l,stageStructures:a}}function d5({withStageGrouping:t,tournamentRecord:e,stageSequences:r,stageSequence:n,roundTarget:o,stages:i,stage:s}){if(!e)return{error:re};const a={},l=[];for(const c of e.events||[]){const{structures:u,stageStructures:d}=SO({withStageGrouping:t,stageSequences:r,stageSequence:n,roundTarget:o,stages:i,event:c,stage:s});if(u&&l.push(...u),d)for(const p of Object.keys(d))a[p]||(a[p]=[]),a[p].push(...d[p])}return{structures:l,stageStructures:a}}function p5(t){const e=[];if(!(t!=null&&t.drawDefinition))return{error:fe};const r=qi(t),n=OO(t);return{actions:e,state:{isComplete:r,hasPlayoffPositionsFilled:n}}}function qi(t){if(!(t!=null&&t.drawDefinition))return!1;const e=ac(t),r=e==null?void 0:e.includesTeamMatchUps;let{completedMatchUps:n,pendingMatchUps:o,upcomingMatchUps:i}=e||{};return r&&(n=n==null?void 0:n.filter(({matchUpType:a})=>a===Qe),o=o==null?void 0:o.filter(({matchUpType:a})=>a===Qe),i=i==null?void 0:i.filter(({matchUpType:a})=>a===Qe)),!!((n==null?void 0:n.length)&&!(o!=null&&o.length)&&!(i!=null&&i.length))}function OO(t){var e,r;const{drawDefinition:n,structureId:o}=t;if(!n)return{error:fe};const{playoffStructures:i}=yO({drawDefinition:n,structureId:o});if(!(i!=null&&i.length))return!1;const s=((r=(e=n==null?void 0:n.entries)==null?void 0:e.filter(u=>si.includes(u==null?void 0:u.entryStatus)))==null?void 0:r.length)||0;let a=0;return(i||[]).reduce((u,d)=>{var p;return!((p=d==null?void 0:d.positionAssignments)!=null&&p.filter(f=>(f.participantId&&a++,!(f!=null&&f.bye)&&!(f!=null&&f.participantId))).length)&&u},!0)||a===s}function bO({drawDefinition:t,structure:e,matchUp:r}){const n=[];if(e.finishingPosition===ya&&qi({drawDefinition:t,structure:e})){const{structureIds:i}=u5({drawDefinition:t,structure:e,matchUp:r});i!=null&&i.length&&n.push(...i)}return{connectedStructureIds:n}}function am(t){const{dualWinningSideChange:e,matchUpStatusCodes:r,tournamentRecord:n,drawDefinition:o,matchUpFormat:i,matchUpStatus:s,winningSide:a,matchUpId:l,structure:c,matchUp:u,event:d,score:p}=t,v=nc({matchUpStatus:s})||[zo,Wr].includes(s)&&e,f="attemptToModifyScore",m=!!u.collectionId,g=Mo({drawDefinition:o,structure:c});if(!(m||g||f5({structure:c,matchUp:u})))return{error:Kh};const _=[ot].includes(s),I=Qn({matchUpStatusCodes:v&&r||[],matchUpStatus:v&&s||At,tournamentRecord:n,drawDefinition:o,matchUpFormat:i,removeScore:_,winningSide:a,matchUpId:l,matchUp:u,event:d,score:p});return k({result:I,stack:f})}function f5({structure:t,matchUp:e}){const{drawPositions:r}=e,{positionAssignments:n}=Ct({structure:t}),o=n==null?void 0:n.filter(i=>(r==null?void 0:r.includes(i.drawPosition))&&i.participantId);return(o==null?void 0:o.length)===2}function lm({lineUp:t}){if(!Array.isArray(t))return;const e={};return He(t.flatMap(({collectionAssignments:n})=>n.map(({collectionId:o,collectionPosition:i})=>[o,i].join("|")))).forEach(n=>{const[o,i]=n.split("|"),s=parseInt(i),{assignedParticipantIds:a}=Au({collectionPosition:s,collectionId:o,lineUp:t});a.forEach(l=>{e[l]||(e[l]=[]),e[l].push({collectionId:o,collectionPosition:s})})}),Object.keys(e).map(n=>({participantId:n,collectionAssignments:e[n]}))}function Ba(t){if(!t)return 1/0;if(_t(t))return Oe(t);const e=t.split("-")[0];return _t(e)?Oe(e):1/0}const Zt=({finishingPosition:t=Fi,qualifyingRoundNumber:e,structureAbbreviation:r,seedAssignments:n=[],stageSequence:o=1,structureOrder:i,seedingProfile:s,matchUpFormat:a,structureType:l,structureName:c,matchUpType:u,matchUps:d=[],structureId:p,roundOffset:v,roundLimit:f,stageOrder:m,structures:g,stage:h})=>{const _={structureId:p??ze(),structureAbbreviation:r,finishingPosition:t,seedAssignments:n,matchUpFormat:a,stageSequence:o,structureName:c};i&&(_.structureOrder=i),l&&(_.structureType=l),s&&(typeof s=="string"?_.seedingProfile=s:typeof s=="object"&&typeof s.positioning=="string"&&(_.seedingProfile=s.positioning)),u&&(_.matchUpType=u),v&&(_.roundOffset=v),m&&(_.stageOrder=m),f&&(_.roundLimit=f),h&&(_.stage=h),e&&(_.qualifyingRoundNumber=e);const I=d.flatMap(({drawPositions:P})=>P).filter(Boolean);return g?_.structures=g:(_.matchUps=d,_.positionAssignments=He(I).sort((P,y)=>P-y).map(P=>({drawPosition:P}))),_};var v5=Object.defineProperty,m5=Object.defineProperties,g5=Object.getOwnPropertyDescriptors,TO=Object.getOwnPropertySymbols,h5=Object.prototype.hasOwnProperty,_5=Object.prototype.propertyIsEnumerable,wO=(t,e,r)=>e in t?v5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,EO=(t,e)=>{for(var r in e||(e={}))h5.call(e,r)&&wO(t,r,e[r]);if(TO)for(var r of TO(e))_5.call(e,r)&&wO(t,r,e[r]);return t},I5=(t,e)=>m5(t,g5(e));function mc({structureName:t=ge,stageSequence:e=1,structureOptions:r,appliedPolicies:n,seedingProfile:o,stage:i=ge,matchUpType:s,roundTarget:a,structureId:l,drawSize:c,idPrefix:u,isMock:d,uuids:p}){const{groupCount:v,groupSize:f}=P5({structureOptions:r,appliedPolicies:n,drawSize:c}),m=ya;let g;const h=pe(1,v+1).map(I=>{const P=y5({groupSize:f,structureOrder:I,matchUpType:s,drawSize:c,idPrefix:u,isMock:d});return g=Math.max(...P.map(({roundNumber:y})=>y)),Zt({structureName:`Group ${I}`,structureId:p==null?void 0:p.pop(),structureType:Cu,finishingPosition:m,structureOrder:I,matchUps:P})}),_=Zt({structureId:l||(p==null?void 0:p.pop()),structureType:gr,finishingPosition:m,seedingProfile:o,structureName:t,stageSequence:e,structures:h,stage:i});return a&&it({extension:{name:Wn,value:a},element:_}),EO({structures:[_],maxRoundNumber:g,groupCount:v,links:[],groupSize:f},V)}function P5({appliedPolicies:t,structureOptions:e,drawSize:r}){let n=e==null?void 0:e.groupSize;const o=(e==null?void 0:e.groupSizeLimit)||8,{validGroupSizes:i}=cm({groupSizeLimit:o,drawSize:r}),s=i&&Math.max(...i);n&&(i==null?void 0:i.includes(n))||(n&&n>4||!(i!=null&&i.includes(4))?n=s:n=4);const l=Math.ceil(r/n);return{groupSize:n,groupCount:l}}function cm({drawSize:t,groupSizeLimit:e=10}){const r=pe(3,e+1).filter(n=>{const o=Math.ceil(t/n),i=o*n-t,s=Math.ceil(t/o),a=Math.ceil(i/o);return(!i||i<n)&&s===n&&s>=3&&a<2});return I5(EO({},V),{validGroupSizes:r})}function y5({structureOrder:t,matchUpType:e,groupSize:r,drawSize:n,idPrefix:o,isMock:i,uuids:s}){const a=(t-1)*r,l=pe(1+a,r+1+a),{uniqueMatchUpGroupings:c}=kv({drawPositions:l}),u=aS({groupSize:r,drawPositionOffset:a});return c.map(v).sort((f,m)=>(f.roundNumber||1/0)-(m.roundNumber||1/0));function p(f){return u.reduce((m,g,h)=>g.includes(f)?h+1:m,void 0)}function v(f){const m=id(f),g=p(m),h=[1,n],_=S5({structureOrder:t,drawPositions:f,roundNumber:g,idPrefix:o,uuids:s}),I={matchUpStatus:g?pt.ToBePlayed:pt.Bye,matchUpType:e,finishingPositionRange:{winner:h,loser:h},drawPositions:f,roundNumber:g,matchUpId:_};return i&&(I.isMock=!0),I}}function S5({structureOrder:t,drawPositions:e,roundNumber:r,idPrefix:n,uuids:o}){return n?`${n}-${t}-${r}-DP-${e.join("-")}`:(o==null?void 0:o.pop())||ze()}var O5=Object.defineProperty,b5=Object.defineProperties,T5=Object.getOwnPropertyDescriptors,$O=Object.getOwnPropertySymbols,w5=Object.prototype.hasOwnProperty,E5=Object.prototype.propertyIsEnumerable,NO=(t,e,r)=>e in t?O5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ka=(t,e)=>{for(var r in e||(e={}))w5.call(e,r)&&NO(t,r,e[r]);if($O)for(var r of $O(e))E5.call(e,r)&&NO(t,r,e[r]);return t},um=(t,e)=>b5(t,T5(e));function _d(t){const{roundRobinGroupsCount:e,participantsCount:r,cluster:n}=t;if(!_t(r))return ka({seedBlocks:void 0},k({result:{error:X},context:{participantsCount:r},stack:"getSeedBlocks"}));const o=ea(r);if(e){const v=Math.min(e,o),f=[];let m=1;for(pe(0,v).forEach(()=>{f.push([m]),m++});m<o;){const g=pe(m,m+v);m+=v,f.push(g)}return um(ka({},V),{seedBlocks:f})}const i=pe(1,o+1),s=[];let a=o/2;for(;a>1;){const v=qt(i,a),f=v.length;v.forEach((m,g)=>{let h;const _=g<f/2,I=g%2===0,P=m[0],y=m[m.length-1];n&&f>4?f===8?h=_?y:P:h=I?P:y:h=_?P:y,Xt(m,s)||s.push(h)}),a=a/2}const l=i.filter(v=>!s.includes(v));for(;l.length;)l.length%2===0?s.push(l.pop()):s.push(l.shift());const c=pe(0,20).map(v=>Math.pow(2,v));c.unshift(1);const u=c.indexOf(o);let d=0;const p=[];return pe(0,u).forEach(v=>{p.push(s.slice(d,d+c[v])),d+=c[v]}),um(ka({},V),{seedBlocks:p})}function Id({roundRobinGroupsCount:t,drawSize:e}){const r="getSeedGroups";if(!_t(e))return ka({seedGroups:void 0},k({result:{error:X},context:{drawSize:e},stack:r}));if(t){if(!_t(t))return ka({seedGroups:void 0},k({result:{error:X},context:{roundRobinGroupsCount:t},stack:r}));let n=1;const o=Math.floor(e/t);return{seedGroups:pe(0,o).map(()=>{const s=pe(n,n+t);return n+=t,s})}}else{const{seedBlocks:n}=_d({participantsCount:e,roundRobinGroupsCount:t});let o=0;return{seedGroups:(n||[]).map(s=>(s||[]).map(()=>(o+=1,o)))}}}function $5({roundRobinGroupsCount:t,participantsCount:e}){if(t){const{validGroupSizes:o}=cm({drawSize:e}),i=o==null?void 0:o.map(a=>Math.ceil(e/a));if(!(i!=null&&i.includes(t)))return k({result:{error:X},context:{roundRobinGroupsCount:t}})}const{seedGroups:r}=Id({drawSize:e,roundRobinGroupsCount:t}),n=(r==null?void 0:r.map(o=>Math.min(...o)))||[];return um(ka({},V),{seedingThresholds:n})}function Fs({provisionalPositioning:t,appliedPolicies:e,drawDefinition:r,allPositions:n,structure:o}){var i;let s=[];if(!o)return{error:ra};const{roundMatchUps:a}=Je({matchUpFilters:{roundNumbers:[1]},provisionalPositioning:t,structure:o}),{seedAssignments:l}=Un({provisionalPositioning:t,drawDefinition:r,structure:o}),{positionAssignments:c}=Ct({structure:o}),u=c==null?void 0:c.length,d=(l==null?void 0:l.length)||0;let p=[];const f=Object.keys(a).map(M=>parseInt(M)).sort((M,D)=>M-D).map(M=>{const D=a[M].map(j=>j.drawPositions).flat(1/0).filter(Boolean),R=D.filter(j=>!p.includes(j));return p=p.concat(...D),R}).filter(M=>M.length).reverse(),m=f.pop(),g=m&&Math.min(...m)-1||0,h=(i=e==null?void 0:e.seeding)==null?void 0:i.seedingProfile,_=(m==null?void 0:m.length)||0,I=f.filter(M=>M.filter(D=>D<=d).length),{stage:P,structureType:y,roundLimit:S}=o,O=y===gr,b=!O&&(f==null?void 0:f.length),w=(m==null?void 0:m.length)&&!Xr(_),T=!O&&P===be&&S,E=I.flat(1/0),N=b?E==null?void 0:E.length:0,$=n?u:d,A=w?0:!b&&$||$&&E.length<$&&$-E.length||0;if(T){const M=o!=null&&o.matchUps?o.matchUps.filter(({roundNumber:R})=>R===o.roundLimit).length:0,D=m.length/M;if(!b){const R=gc(h),j=qt(m,D);let G=1;const W=pe(0,j[0].length).map(()=>{const z=pe(G,G+j.length);return G+=j.length,z});({validSeedBlocks:s}=UO({drawPositionBlocks:j,positioning:R,seedGroups:W}))}}else O?{validSeedBlocks:s}=N5({seedingProfile:h,structure:o}):b?s=I.map(M=>({seedNumbers:M,drawPositions:M})):w&&qt(m,2).map((D,R)=>({drawPositions:[D[0]],seedNumbers:[R+1]})).forEach(D=>s.push(D));if(!O&&!w&&!T){const{blocks:M}=U5({drawPositionOffset:g,seedNumberOffset:N,seedCountGoal:A,seedingProfile:h,baseDrawSize:_});M.forEach(D=>s.push(D))}const C=s.flatMap(M=>M.drawPositions).reduce((M,D)=>(m==null?void 0:m.includes(D))&&M,!0);return!w&&!b&&!O&&!C?{error:ox,validSeedBlocks:[],isContainer:O,isFeedIn:b}:{validSeedBlocks:s,isContainer:O,isFeedIn:b,isLucky:w}}function N5({seedingProfile:t,structure:e}){var r,n;const o=e.structures||[],i=o.length,s=(r=st({structure:e}))==null?void 0:r.positionAssignments,a=gc(t),l=(n=s==null?void 0:s.length)!=null?n:0,{seedGroups:c}=Id({roundRobinGroupsCount:i,drawSize:l}),u=o.map(d=>{var p;return(p=st({structure:d}).positionAssignments)==null?void 0:p.map(v=>v.drawPosition)});return UO({drawPositionBlocks:u,positioning:a,seedGroups:c})}function UO({positioning:t,seedGroups:e,drawPositionBlocks:r}){const n=[],o=(a,l)=>a-l,i=(a,l)=>l-a,s=[];return e.forEach((a,l)=>{l&&t!==ov&&vr(a),a.forEach((c,u)=>{const d=l%2?r.length-u-1:u,p=r[d].sort(l%2?i:o).find(v=>!s.includes(v));s.push(p),n.push({seedNumbers:[c],drawPositions:[p]})})}),{validSeedBlocks:n}}function U5(t){const{drawPositionOffset:e=0,roundRobinGroupsCount:r,seedNumberOffset:n=0,seedingProfile:o,seedCountGoal:i,baseDrawSize:s}=t;let a=1;const l=[],{seedBlocks:c}=_d({cluster:gc(o)===nv,participantsCount:s,roundRobinGroupsCount:r});a=0;for(const d of c){if(a+1>i)break;const p=d.map(f=>f+e),v=u(a+1,d.length).map(f=>+f+n);a+=d.length,l.push({drawPositions:p,seedNumbers:v})}return{blocks:l};function u(d,p){return Array.from(new Array(p),(v,f)=>f+d)}}function Pd({appliedPolicies:t,drawDefinition:e,seedBlockInfo:r,drawPosition:n,structureId:o,seedNumber:i}){var s,a,l,c,u;const{structure:d}=Ee({drawDefinition:e,structureId:o});t||(t=vt({drawDefinition:e}).appliedPolicies);let p=r==null?void 0:r.validSeedBlocks;if(!p&&d&&(p=(s=Fs({appliedPolicies:t,drawDefinition:e,structure:d}))==null?void 0:s.validSeedBlocks),(l=(a=t==null?void 0:t.seeding)==null?void 0:a.validSeedPositions)!=null&&l.ignore)return!0;if((u=(c=t==null?void 0:t.seeding)==null?void 0:c.validSeedPositions)!=null&&u.strict){const f=p.find(g=>g.seedNumbers.includes(i));return((f==null?void 0:f.drawPositions)||[]).includes(n)}return[].concat(...p.map(f=>f.drawPositions)).includes(n)}function yd(t){var e,r;const{provisionalPositioning:n,drawDefinition:o,seedBlockInfo:i,structureId:s,randomize:a}=t,{structure:l}=Ee({drawDefinition:o,structureId:s}),{seedAssignments:c}=Un({provisionalPositioning:n,drawDefinition:o,structure:l}),{positionAssignments:u}=Ct({structure:l}),d=u==null?void 0:u.filter(j=>{var G,W;return(W=(G=j.participantId)!=null?G:j.bye)!=null?W:j.qualifier}),p=d==null?void 0:d.map(j=>j.drawPosition).filter(Boolean),{appliedPolicies:v}=vt({drawDefinition:o}),g=((i==null?void 0:i.validSeedBlocks)||l&&((e=Fs({provisionalPositioning:n,appliedPolicies:v,drawDefinition:o,structure:l}))==null?void 0:e.validSeedBlocks)||[]).filter(j=>j.drawPositions.filter(W=>!(p!=null&&p.includes(W))).length)[0],h=c==null?void 0:c.map(j=>j.participantId).filter(Boolean),_=u==null?void 0:u.map(j=>j.participantId).filter(Boolean),I=h==null?void 0:h.filter(j=>_==null?void 0:_.includes(j)),P=h==null?void 0:h.filter(j=>!(_!=null&&_.includes(j))),y=c==null?void 0:c.filter(j=>P==null?void 0:P.includes(j.participantId)),S=c==null?void 0:c.filter(j=>!j.participantId),b=((y==null?void 0:y.length)||(S==null?void 0:S.length))&&(g==null?void 0:g.drawPositions.filter(j=>!(p!=null&&p.includes(j))))||[],w=a?vr(b):b,T=[],E=w.map(()=>{const j=R(y,T),G=j==null?void 0:j.participantId;return G&&T.push(G),G}).filter(Boolean),N=c==null?void 0:c.filter(j=>I==null?void 0:I.includes(j.participantId)).map(j=>j.seedNumber),A=((g==null?void 0:g.seedNumbers)||[]).filter(j=>!(N!=null&&N.includes(j))),U=c==null?void 0:c.filter(j=>A.includes(j.seedNumber)).map(j=>j.participantId),C=(r=v==null?void 0:v.seeding)==null?void 0:r.duplicateSeedNumbers;return{nextSeedBlock:g,unplacedSeedParticipantIds:(C!==void 0?C:!0)?E:U,unplacedSeedNumbers:A,unfilledPositions:w,unplacedSeedAssignments:y};function R(j,G){const W=j.filter(x=>!G.includes(x.participantId)),z=Math.min(...W.map(x=>Ba(x.seedValue))),F=W.filter(x=>Ba(x.seedValue)===z);return vr(F).pop()}}function gc(t){if(typeof t=="string")return t;if(typeof t=="object")return t.positioning}function xs({participantId:t,drawDefinition:e,entryStatus:r,entryStage:n}){var o;if(!e)return{error:fe};const i=(o=e.entries)==null?void 0:o.find(s=>s.participantId===t&&(!r||r===s.entryStatus)&&(!n||n===s.entryStage));return t&&i}var A5=Object.defineProperty,AO=Object.getOwnPropertySymbols,C5=Object.prototype.hasOwnProperty,M5=Object.prototype.propertyIsEnumerable,CO=(t,e,r)=>e in t?A5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,D5=(t,e)=>{for(var r in e||(e={}))C5.call(e,r)&&CO(t,r,e[r]);if(AO)for(var r of AO(e))M5.call(e,r)&&CO(t,r,e[r]);return t};function Ls({provisionalPositioning:t,tournamentRecord:e,drawDefinition:r,seedingProfile:n,participantId:o,seedBlockInfo:i,structureId:s,seedNumber:a,seedValue:l,eventId:c,event:u}){var d,p;const v="assignSeed",{structure:f}=Ee({drawDefinition:r,structureId:s}),{positionAssignments:m}=Ct({structure:f}),g=Un({provisionalPositioning:t,drawDefinition:r,structure:f}).seedAssignments,h=g.map(b=>b.seedNumber),_=xs({drawDefinition:r,participantId:o});if(o&&!_)return k({result:{error:Oo},context:{participantId:o},stack:v});const I=u?(p=(d=Et({event:u}).flightProfile)==null?void 0:d.flights)==null?void 0:p.length:0,P=I&&I>1,y=m==null?void 0:m.find(b=>b.participantId===o),S=y==null?void 0:y.drawPosition;if(S&&!Pd({drawPosition:S,drawDefinition:r,seedBlockInfo:i,structureId:s,seedNumber:a}))return k({result:{error:Wh},context:{assignedDrawPosition:S},info:"invalid seed position",stack:v});h.includes(a)||g.push({seedNumber:a,seedValue:l});let O;return g.forEach(b=>{b.participantId===o&&b.seedNumber!==a&&(b.participantId=void 0),b.seedNumber===a&&(b.participantId=o,!(n!=null&&n.groupSeedingThreshold)&&!P&&(b.seedValue=l||a),O=!0)}),O?(Py({tournamentId:e==null?void 0:e.tournamentId,drawDefinition:r,structure:f,eventId:c}),D5({},V)):k({result:{error:nx},stack:v})}function MO({inContextDrawMatchUps:t,drawDefinition:e,assignments:r,matchUpsMap:n,structure:o}){var i,s,a;const l=(i=Ra({drawDefinition:e}))==null?void 0:i.containedStructures,c=((s=l==null?void 0:l[o.structureId])==null?void 0:s.map(({structureId:f})=>f))||[];c.push(o==null?void 0:o.structureId);const u=(r==null?void 0:r.map(({drawPosition:f})=>f))||[],d=(t==null?void 0:t.filter(f=>c.includes(f.structureId)&&Ht(f.drawPositions||[],u).length))||[],p=d.map(({matchUpId:f})=>f),v=((a=n==null?void 0:n.drawMatchUps)==null?void 0:a.filter(f=>p.includes(f.matchUpId)))||[];return{drawPositions:u,matchUps:v,targetMatchUps:d}}var j5=Object.defineProperty,DO=Object.getOwnPropertySymbols,R5=Object.prototype.hasOwnProperty,F5=Object.prototype.propertyIsEnumerable,jO=(t,e,r)=>e in t?j5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,x5=(t,e)=>{for(var r in e||(e={}))R5.call(e,r)&&jO(t,r,e[r]);if(DO)for(var r of DO(e))F5.call(e,r)&&jO(t,r,e[r]);return t};function dm({inContextDrawMatchUps:t,tournamentRecord:e,drawDefinition:r,matchUpsMap:n,assignments:o,structure:i,event:s}){const{drawPositions:a,matchUps:l,targetMatchUps:c}=MO({inContextDrawMatchUps:t,matchUpsMap:n,assignments:o,structure:i});for(const u of c)u.matchUpType===In&&(u.sides||[]).forEach((d,p)=>{var v;if(d!=null&&d.drawPosition&&(a!=null&&a.includes(d.drawPosition))){const f=l.find(({matchUpId:m})=>m===u.matchUpId);(v=f==null?void 0:f.sides)!=null&&v[p]&&(f==null||delete f.sides[p].lineUp,Ze({tournamentId:e==null?void 0:e.tournamentId,context:"cleanupLineUps",eventId:s==null?void 0:s.eventId,drawDefinition:r,matchUp:f}))}});return x5({},V)}var L5=Object.defineProperty,RO=Object.getOwnPropertySymbols,V5=Object.prototype.hasOwnProperty,B5=Object.prototype.propertyIsEnumerable,FO=(t,e,r)=>e in t?L5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xO=(t,e)=>{for(var r in e||(e={}))V5.call(e,r)&&FO(t,r,e[r]);if(RO)for(var r of RO(e))B5.call(e,r)&&FO(t,r,e[r]);return t};function Mn({provisionalPositioning:t,inContextDrawMatchUps:e,isQualifierPosition:r,sourceMatchUpStatus:n,tournamentRecord:o,drawDefinition:i,seedingProfile:s,participantId:a,seedBlockInfo:l,drawPosition:c,matchUpsMap:u,structureId:d,event:p}){var v;const f="assignDrawPosition";if(!a&&!r)return k({result:{error:Tt},stack:f});u=u||lr({drawDefinition:i}),e||({matchUps:e}=xt({inContext:!0,drawDefinition:i,matchUpsMap:u}));const m=Ee({drawDefinition:i,structureId:d});if(m.error)return k({result:m,stack:f});const{structure:g}=m;if(!g)return{error:St};if(Mo({drawDefinition:i,structure:g}))return k({result:{error:rn},stack:f});const{seedAssignments:h}=Un({provisionalPositioning:t,drawDefinition:i,structure:g}),_=h==null?void 0:h.find(N=>N.participantId===a),I=_==null?void 0:_.seedNumber,{appliedPolicies:P}=vt({tournamentRecord:o,drawDefinition:i,structure:g,event:p});if(I&&!Pd({seedNumber:I,appliedPolicies:P,drawDefinition:i,seedBlockInfo:l,drawPosition:c,structureId:d}))return k({result:{error:Wh},context:{drawPosition:c},stack:f});const S=Ct({structure:g}).positionAssignments||[],O=S==null?void 0:S.find(N=>N.drawPosition===c);if(!O)return k({result:{error:ta},context:{drawPosition:c},stack:f});if(S==null?void 0:S.map(dt).includes(a))return k({result:{error:ia},context:{drawPosition:c},stack:f});const{containsParticipant:w,containsBye:T}=E(O);if(T){const N=Fa({inContextDrawMatchUps:e,tournamentRecord:o,drawDefinition:i,drawPosition:c,structureId:d,matchUpsMap:u,event:p});if(N.error)return k({result:N,stack:f})}if(w&&O.participantId!==a){const{activeDrawPositions:N}=pc({drawDefinition:i,structureId:d});if(N.includes(c))return k({result:{error:ef},stack:f});dm({assignments:[O],inContextDrawMatchUps:e,tournamentRecord:o,drawDefinition:i,matchUpsMap:u,structure:g})}if(O.participantId=a,r&&(O.qualifier=!0),((g==null?void 0:g.stageSequence)||0)>1||g.stage&&[Ft,mt].includes(g.stage)){const N=g.stage===be?be:ge,$=(v=i.structures)==null?void 0:v.find(C=>(C==null?void 0:C.stage)===N&&(C==null?void 0:C.stageSequence)===1),U=(($==null?void 0:$.seedAssignments)||[]).find(C=>C.participantId===a);if(U!=null&&U.participantId){const{participantId:C,seedNumber:M,seedValue:D}=U;Ls({eventId:p==null?void 0:p.eventId,provisionalPositioning:t,tournamentRecord:o,drawDefinition:i,seedingProfile:s,participantId:C,seedNumber:M,seedValue:D,structureId:d,event:p})}}if(g.structureType!==gr)k5({provisionalPositioning:t,inContextDrawMatchUps:e,sourceMatchUpStatus:n,tournamentRecord:o,drawDefinition:i,drawPosition:c,matchUpsMap:u,structure:g,event:p});else{YS({positionAssignments:S,tournamentRecord:o,drawDefinition:i,matchUpsMap:u,structure:g});const{drawPositions:N,matchUps:$,targetMatchUps:A}=MO({assignments:[O],inContextDrawMatchUps:e,drawDefinition:i,matchUpsMap:u,structure:g});if(N&&($==null?void 0:$.length)===1&&$[0].matchUpType===Qe){const C=((A==null?void 0:A[0].sides)||[]).reduce((M,D,R)=>N!=null&&N.includes(D.drawPosition)?R:M,void 0);im({inContextTargetMatchUp:A[0],teamParticipantId:a,matchUp:$[0],drawPositionSideIndex:C,tournamentRecord:o,drawDefinition:i})}}return ai({tournamentId:o==null?void 0:o.tournamentId,drawDefinition:i,structure:g,event:p}),xO({positionAssignments:S},V);function E(N){const $=N.bye,A=N.qualifier,U=N.participantId;return{containsBye:$,containsQualifier:A,containsParticipant:U,filled:$||A||U}}}function k5({provisionalPositioning:t,inContextDrawMatchUps:e,sourceMatchUpStatus:r,tournamentRecord:n,drawDefinition:o,drawPosition:i,matchUpsMap:s,structure:a,event:l}){const c={isCollectionMatchUp:!1},{matchUps:u}=Je({provisionalPositioning:t,matchUpFilters:c,drawDefinition:o,matchUpsMap:s,structure:a,event:l}),{roundMatchUps:d}=br({matchUps:u}),{initialRoundNumber:p}=Rs({drawPosition:i,matchUps:u}),v=p&&(d==null?void 0:d[p].find(f=>{var m;return(m=f.drawPositions)==null?void 0:m.includes(i)}));if(v){const f=La({matchUpId:v.matchUpId,inContextDrawMatchUps:e,sourceMatchUpStatus:r,tournamentRecord:n,drawDefinition:o,drawPosition:i,matchUpsMap:s});if(f.error)return k({stack:"assignDrawPositionToMatchUps",context:{drawPosition:i},result:f})}return xO({},V)}var G5=Object.defineProperty,W5=Object.defineProperties,H5=Object.getOwnPropertyDescriptors,LO=Object.getOwnPropertySymbols,q5=Object.prototype.hasOwnProperty,z5=Object.prototype.propertyIsEnumerable,VO=(t,e,r)=>e in t?G5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,pm=(t,e)=>{for(var r in e||(e={}))q5.call(e,r)&&VO(t,r,e[r]);if(LO)for(var r of LO(e))z5.call(e,r)&&VO(t,r,e[r]);return t},BO=(t,e)=>W5(t,H5(e));function Y5({winnerMatchUpDrawPositionIndex:t,inContextDrawMatchUps:e,projectedWinningSide:r,sourceMatchUpStatus:n,winningDrawPosition:o,tournamentRecord:i,winnerTargetLink:s,sourceMatchUpId:a,drawDefinition:l,winnerMatchUp:c,dualMatchUp:u,matchUpsMap:d,event:p}){var v,f,m;const g="directWinner";if(s){const h=c.drawPositions||[],_=h[t],I=s.source.structureId,P=Ee({structureId:I,drawDefinition:l});if(P.error)return P;const{structure:y}=P,{positionAssignments:S}=Ct({structureId:I,drawDefinition:l}),O=S==null?void 0:S.find(U=>U.drawPosition===o),b=O==null?void 0:O.participantId,w=s.target.structureId,{positionAssignments:T}=Ct({structureId:w,drawDefinition:l}),E=T==null?void 0:T.find(U=>U.participantId===b),N=E==null?void 0:E.drawPosition,$=T==null?void 0:T.filter(U=>{const C=h.includes(U.drawPosition),M=!U.participantId&&!U.bye&&!U.qualifier;return C&&M}).map(U=>U.drawPosition),A=$==null?void 0:$.includes(_);if(b&&s.target.roundNumber===1&&A)Mn({drawPosition:_,participantId:b,structureId:w,inContextDrawMatchUps:e,sourceMatchUpStatus:n,tournamentRecord:i,drawDefinition:l,matchUpsMap:d,event:p});else if(b&&($!=null&&$.length)){const U=$.pop();U&&Mn({participantId:b,structureId:w,inContextDrawMatchUps:e,sourceMatchUpStatus:n,tournamentRecord:i,drawDefinition:l,drawPosition:U,matchUpsMap:d,event:p})}else if(N){const U=La({drawPosition:N,matchUpId:c.matchUpId,inContextDrawMatchUps:e,sourceMatchUpStatus:n,tournamentRecord:i,sourceMatchUpId:a,drawDefinition:l,matchUpsMap:d});if(U.error)return k({result:U,stack:g})}else if((y==null?void 0:y.stage)!==be){const U="winner target position unavaiallble";return console.log(U),{error:U}}if(y!=null&&y.seedAssignments&&y.structureId!==w){const U=y.seedAssignments.find(({participantId:M})=>M===b),C=U==null?void 0:U.participantId;U&&C&&Ls(BO(pm({eventId:c==null?void 0:c.eventId,structureId:w},U),{tournamentRecord:i,drawDefinition:l,participantId:C}))}}else{const h=La({matchUpId:c.matchUpId,drawPosition:o,inContextDrawMatchUps:e,sourceMatchUpStatus:n,tournamentRecord:i,sourceMatchUpId:a,drawDefinition:l,matchUpsMap:d});if(h.error)return h}if(u&&r){const h=(v=u.sides)==null?void 0:v.find(_=>_.sideNumber===r);if(h!=null&&h.lineUp){const _=u.roundPosition,I=c.roundPosition,P=_===I&&_!==1||Math.floor(_/2)===I?2:1,y=(f=d==null?void 0:d.drawMatchUps)==null?void 0:f.find(({matchUpId:b})=>b===c.matchUpId),S=[1,2].map(b=>{var w;const T=((w=y.sides)==null?void 0:w.find(E=>E.sideNumber===b))||{};return BO(pm({},T),{sideNumber:b})});y.sides=S;const O=y.sides.find(b=>b.sideNumber===P);if(O){const b=(m=h.lineUp)==null?void 0:m.filter(w=>w==null?void 0:w.participantId);O.lineUp=lm({lineUp:b}),Ze({tournamentId:i==null?void 0:i.tournamentId,eventId:c==null?void 0:c.eventId,matchUp:y,context:g,drawDefinition:l})}}}return pm({},V)}var K5=Object.defineProperty,Q5=Object.defineProperties,J5=Object.getOwnPropertyDescriptors,kO=Object.getOwnPropertySymbols,Z5=Object.prototype.hasOwnProperty,X5=Object.prototype.propertyIsEnumerable,GO=(t,e,r)=>e in t?K5(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sd=(t,e)=>{for(var r in e||(e={}))Z5.call(e,r)&&GO(t,r,e[r]);if(kO)for(var r of kO(e))X5.call(e,r)&&GO(t,r,e[r]);return t},WO=(t,e)=>Q5(t,J5(e));function ez(t){var e,r;const{loserMatchUpDrawPositionIndex:n,inContextDrawMatchUps:o,projectedWinningSide:i,sourceMatchUpStatus:s,loserDrawPosition:a,tournamentRecord:l,loserTargetLink:c,drawDefinition:u,loserMatchUp:d,dualMatchUp:p,matchUpsMap:v,event:f}=t,m="directLoser",g=c.linkCondition,h=d.drawPositions||[],_=g===uo&&d.roundNumber===2&&Math.min(...h.filter(Boolean)),I=_||h[n],P=_||h[1-n],y=c.source.structureId,{structure:S}=Ee({structureId:y,drawDefinition:u}),{matchUps:O}=Je({afterRecoveryTimes:!1,inContext:!0,drawDefinition:u,structure:S,event:f}),w=O.filter(L=>{var x;return(x=L.drawPositions)==null?void 0:x.includes(a)}).filter(L=>{const x=L.sides.find(H=>H.drawPosition===a),B=L.matchUpStatus===ot||L.matchUpStatus===et&&!Gt(L);return(x==null?void 0:x.sideNumber)===L.winningSide&&!B}),T=g===uo&&w.length===0,{positionAssignments:E}=Ct({structureId:y,drawDefinition:u}),N=E==null?void 0:E.find(L=>L.drawPosition===a),$=N==null?void 0:N.participantId,A=c.target.structureId,{positionAssignments:U}=Ct({structureId:A,drawDefinition:u}),C=U==null?void 0:U.filter(({drawPosition:L})=>h.includes(L));if(C==null?void 0:C.some(L=>L.participantId===$))return Sd({},V);const D=C==null?void 0:C.filter(L=>{const x=h.includes(L.drawPosition),B=!L.participantId&&!L.bye&&!L.qualifier;return x&&B}).map(L=>L.drawPosition),R=D==null?void 0:D.includes(I),j=c.target.roundNumber>1&&(D==null?void 0:D.length),G=c.target.roundNumber===1&&R;if(_){const L=W();if(L.error)return k({result:L,stack:m})}else if(G){const L=F();if(L.error)return k({result:L,stack:m})}else if($&&j){const L=D.sort(er)[0],x=Mn({participantId:$,structureId:A,drawPosition:L,inContextDrawMatchUps:o,sourceMatchUpStatus:s,tournamentRecord:l,drawDefinition:u,matchUpsMap:v,event:f});if(x.error)return k({result:x,stack:m})}else return k({result:{error:ta},context:{loserDrawPosition:a,loserTargetLink:c},stack:m});if(S!=null&&S.seedAssignments&&S.structureId!==A){const L=S.seedAssignments.find(({participantId:B})=>B===$),x=L==null?void 0:L.participantId;L&&x&&Ls(WO(Sd({eventId:d==null?void 0:d.eventId,structureId:A},L),{tournamentRecord:l,drawDefinition:u,participantId:x}))}if(p&&i){const L=(e=p.sides)==null?void 0:e.find(x=>x.sideNumber===3-i);if(L!=null&&L.lineUp){const{roundNumber:x,eventId:B}=d,{roundPosition:H}=p,q=x===1?2-H%2:1,J=(r=v==null?void 0:v.drawMatchUps)==null?void 0:r.find(({matchUpId:Q})=>Q===d.matchUpId),K=[1,2].map(Q=>{var Z;const ee=((Z=J.sides)==null?void 0:Z.find(ne=>ne.sideNumber===Q))||{};return WO(Sd({},ee),{sideNumber:Q})});J.sides=K;const Y=J.sides.find(Q=>Q.sideNumber===q);Y&&(Y.lineUp=lm({lineUp:L.lineUp}),Ze({tournamentId:l==null?void 0:l.tournamentId,matchUp:J,context:m,drawDefinition:u,eventId:B}))}}return Sd({},V);function W(){const L="loserLinkFedFMLC";return k(T?{result:F(),stack:L}:{result:z(),stack:L})}function z(){const L=Yr({drawPosition:P,structureId:A,tournamentRecord:l,drawDefinition:u,event:f});return k({result:L,stack:"assignLoserPositionBye"})}function F(){const L=$?Mn({drawPosition:I,participantId:$,structureId:A,inContextDrawMatchUps:o,sourceMatchUpStatus:s,tournamentRecord:l,drawDefinition:u,matchUpsMap:v,event:f}):{error:Tt};return k({result:L,stack:"assignLoserDrawPosition"})}}var tz=Object.defineProperty,HO=Object.getOwnPropertySymbols,rz=Object.prototype.hasOwnProperty,nz=Object.prototype.propertyIsEnumerable,qO=(t,e,r)=>e in t?tz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ga=(t,e)=>{for(var r in e||(e={}))rz.call(e,r)&&qO(t,r,e[r]);if(HO)for(var r of HO(e))nz.call(e,r)&&qO(t,r,e[r]);return t};function zO(t){const e=am(t);if(e.error)return e;const r=nc({matchUpStatus:t.matchUpStatus}),{dualWinningSideChange:n,projectedWinningSide:o,inContextDrawMatchUps:i,tournamentRecord:s,drawDefinition:a,matchUpStatus:l,dualMatchUp:c,matchUpsMap:u,winningSide:d,targetData:p,matchUpId:v,structure:f,matchUp:m,event:g}=t,h="directParticipants",_=!!m.collectionId,I=Mo({drawDefinition:a,structure:f});let P=m.drawPositions,y;if(_){const{matchUpTieId:S,matchUpsMap:O}=t,b=po({matchUpId:S,tournamentRecord:s,drawDefinition:a,matchUpsMap:O,event:g});y=b&&{tieMatchUpResult:b};const w=i.find(({matchUpId:T})=>T===S);if(P=w==null?void 0:w.drawPositions,!n)return k({result:Ga(Ga({},V),y),stack:h})}if(I)return k({result:Ga(Ga({},V),y),stack:h});if(P){const S=o?o-1:d-1,O=1-S,b=P[S],w=P[O],{targetLinks:{loserTargetLink:T,winnerTargetLink:E,byeTargetLink:N},targetMatchUps:{winnerMatchUpDrawPositionIndex:$,loserMatchUpDrawPositionIndex:A,winnerMatchUp:U,loserMatchUp:C,byeMatchUp:M}}=p;if(U){const D=Y5({sourceMatchUpStatus:r&&l||At,winnerMatchUpDrawPositionIndex:$,sourceMatchUpId:v,inContextDrawMatchUps:i,projectedWinningSide:o,winningDrawPosition:b,tournamentRecord:s,winnerTargetLink:E,drawDefinition:a,winnerMatchUp:U,dualMatchUp:c,matchUpsMap:u,event:g});if(D.error)return k({result:D,stack:h})}if(C){const D=ez({sourceMatchUpStatus:r&&l||At,loserMatchUpDrawPositionIndex:A,sourceMatchUpId:v,inContextDrawMatchUps:i,projectedWinningSide:o,loserDrawPosition:w,tournamentRecord:s,loserTargetLink:T,drawDefinition:a,loserMatchUp:C,winningSide:d,matchUpsMap:u,dualMatchUp:c,event:g});if(D.error)return k({result:D,stack:h})}if(M){const D=M.drawPositions||[],R=Math.min(...D.filter(Boolean)),j=N.target.structureId,G=Yr({drawPosition:R,structureId:j,tournamentRecord:s,drawDefinition:a,event:g});if(G.error)return k({result:G,stack:h})}}else return k({result:{error:Xp},stack:h});return k({result:Ga(Ga({},V),y),stack:h})}function zi(t){var e,r;const{inContextDrawMatchUps:n,targetData:o,drawDefinition:i,relevantLink:s}=t;if((s==null?void 0:s.linkCondition)===uo&&((e=o==null?void 0:o.matchUp)==null?void 0:e.matchUpStatus)===nt)return!1;const{targetMatchUps:{loserMatchUp:l,winnerMatchUp:c},targetLinks:u}=o,d=[et,ot].includes(l==null?void 0:l.matchUpStatus),p=((r=c==null?void 0:c.drawPositions)==null?void 0:r.filter(Boolean).length)||0;if(l!=null&&l.winningSide&&!d||c!=null&&c.winningSide&&p===2&&(!c.feedRound||![ot,et].includes(c==null?void 0:c.matchUpStatus)))return!0;const v=l&&_r({matchUpId:l.matchUpId,inContextDrawMatchUps:n,drawDefinition:i}),f=c&&_r({matchUpId:c.matchUpId,inContextDrawMatchUps:n,drawDefinition:i}),m=v&&zi({relevantLink:u==null?void 0:u.loserTargetLink,targetData:v,inContextDrawMatchUps:n,drawDefinition:i});return!!(f&&zi({targetData:f,inContextDrawMatchUps:n,drawDefinition:i})||m)}var oz=Object.defineProperty,iz=Object.defineProperties,sz=Object.getOwnPropertyDescriptors,YO=Object.getOwnPropertySymbols,az=Object.prototype.hasOwnProperty,lz=Object.prototype.propertyIsEnumerable,KO=(t,e,r)=>e in t?oz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,cz=(t,e)=>{for(var r in e||(e={}))az.call(e,r)&&KO(t,r,e[r]);if(YO)for(var r of YO(e))lz.call(e,r)&&KO(t,r,e[r]);return t},uz=(t,e)=>iz(t,sz(e));function dz(t){var e,r,n;let o;const{inContextDrawMatchUps:i,inContextMatchUp:s,drawDefinition:a,winningSide:l}=t,c=(e=t.targetData.targetLinks)==null?void 0:e.winnerTargetLink;if(c.target.feedProfile===Tn){const u=s.sides.find(({sideNumber:p})=>p!==l).participantId,d=i.find(p=>p.structureId===c.target.structureId&&p.roundNumber===c.target.roundNumber&&p.sides.some(({participantId:v})=>v===u));if((d==null?void 0:d.matchUpStatus)===Rt){const p=_r({matchUpId:d.matchUpId,inContextDrawMatchUps:i,drawDefinition:a});if(!zi({inContextDrawMatchUps:i,drawDefinition:a,targetData:p})){const{structure:f}=Ee({structureId:d.structureId,drawDefinition:a}),m=st({structure:f}).positionAssignments;for(const g of m||[])if(g.participantId===u){const h=s.sides.find(({sideNumber:_})=>_===l).participantId;if(g.participantId=h,f!=null&&f.positionAssignments)f.positionAssignments=m;else if(f!=null&&f.structures){const _=Object.assign({},...(m||[]).map(I=>({[I.drawPosition]:I.participantId})));for(const I of f.structures)(r=I.positionAssignments)==null||r.forEach(P=>P.participantId=_[P.drawPosition])}ai({tournamentId:(n=t.tournamentRecord)==null?void 0:n.tournamentId,event:t.event,drawDefinition:a,structure:f}),o=!0}}}}return uz(cz({},V),{qualifierReplaced:o})}var pz=Object.defineProperty,fz=Object.defineProperties,vz=Object.getOwnPropertyDescriptors,QO=Object.getOwnPropertySymbols,mz=Object.prototype.hasOwnProperty,gz=Object.prototype.propertyIsEnumerable,JO=(t,e,r)=>e in t?pz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hz=(t,e)=>{for(var r in e||(e={}))mz.call(e,r)&&JO(t,r,e[r]);if(QO)for(var r of QO(e))gz.call(e,r)&&JO(t,r,e[r]);return t},_z=(t,e)=>fz(t,vz(e));function Iz(t){var e,r,n,o,i;let s;const{inContextDrawMatchUps:a,inContextMatchUp:l,drawDefinition:c,winningSide:u}=t,d=(e=t.targetData.targetLinks)==null?void 0:e.winnerTargetLink;if(d.target.feedProfile===Tn){const p=(r=l.sides.find(({sideNumber:m})=>m===u))==null?void 0:r.participantId,v=a.filter(m=>m.structureId===d.target.structureId&&m.roundNumber===d.target.roundNumber&&m.sides.some(({participantId:g,qualifier:h})=>h&&!g)),f=Nr(v);if((f==null?void 0:f.matchUpStatus)===Rt){const m=_r({matchUpId:f.matchUpId,inContextDrawMatchUps:a,drawDefinition:c});if(!zi({inContextDrawMatchUps:a,drawDefinition:c,targetData:m})){const h=(n=f.sides.find(P=>P.qualifier&&!P.participantId))==null?void 0:n.drawPosition,{structure:_}=Ee({structureId:f.structureId,drawDefinition:c});if(!_)return{error:St};const I=st({structure:_}).positionAssignments;for(const P of I||[])if(P.drawPosition===h&&!P.participantId){if(P.participantId=p,_.positionAssignments)_.positionAssignments=I;else if(_.structures){const y=Object.assign({},...(I||[]).map(S=>({[S.drawPosition]:S.participantId})));for(const S of _.structures)(o=S.positionAssignments)==null||o.forEach(O=>O.participantId=y[O.drawPosition])}ai({tournamentId:(i=t.tournamentRecord)==null?void 0:i.tournamentId,event:t.event,drawDefinition:c,structure:_}),s=!0}}}}return _z(hz({},V),{qualifierPlaced:s})}var Pz=Object.defineProperty,yz=Object.defineProperties,Sz=Object.getOwnPropertyDescriptors,ZO=Object.getOwnPropertySymbols,Oz=Object.prototype.hasOwnProperty,bz=Object.prototype.propertyIsEnumerable,XO=(t,e,r)=>e in t?Pz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,eb=(t,e)=>{for(var r in e||(e={}))Oz.call(e,r)&&XO(t,r,e[r]);if(ZO)for(var r of ZO(e))bz.call(e,r)&&XO(t,r,e[r]);return t},Tz=(t,e)=>yz(t,Sz(e));function wz(t){var e,r;const n="attemptToSetWinningSide";let o;const{appliedPolicies:i,disableAutoCalc:s,drawDefinition:a,dualMatchUp:l,winningSide:c,structure:u,matchUp:d}=t;if(l!=null&&l._disableAutoCalc&&s!==!1)return am(t);if(d.winningSide&&d.winningSide!==c){const{connectedStructureIds:m}=bO({drawDefinition:a,structure:u,matchUp:d});m.length&&(console.log({connectedStructureIds:m}),o=!0);const g=xa(t);if(g.error)return g}const p=zO(t);if(p.error)return k({result:p,stack:n});let v,f;return t.qualifierChanging&&((e=i==null?void 0:i[fu])!=null&&e.autoReplaceQualifiers)&&(v=dz(t).qualifierReplaced),t.qualifierAdvancing&&((r=i==null?void 0:i[fu])!=null&&r.autoPlaceQualifiers)&&(f=Iz(t).qualifierPlaced),k({result:ye(Tz(eb(eb({},V),p),{connectedStructures:o,qualifierReplaced:v,qualifierPlaced:f})),stack:n})}var Ez=Object.defineProperty,$z=Object.defineProperties,Nz=Object.getOwnPropertyDescriptors,tb=Object.getOwnPropertySymbols,Uz=Object.prototype.hasOwnProperty,Az=Object.prototype.propertyIsEnumerable,rb=(t,e,r)=>e in t?Ez(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hc=(t,e)=>{for(var r in e||(e={}))Uz.call(e,r)&&rb(t,r,e[r]);if(tb)for(var r of tb(e))Az.call(e,r)&&rb(t,r,e[r]);return t},fm=(t,e)=>$z(t,Nz(e));function nb(t){var e;const{inContextDrawMatchUps:r,appliedPolicies:n,drawDefinition:o,matchUpsMap:i,targetData:s,matchUp:a}=t;let{iteration:l=0}=t;l+=1;const c="removeDoubleExit";Zn();const{targetLinks:{loserTargetLink:u},targetMatchUps:{loserMatchUp:d,winnerMatchUp:p,loserTargetDrawPosition:v}}=s;if(p&&p.matchUpStatus!==nt&&(Zn(),ob(fm(hc({},t),{targetMatchUp:p,sourceMatchUp:a,iteration:l}))),d&&d.matchUpStatus!==nt){const f=r.find(({matchUpId:g})=>g===d.matchUpId),{structure:m}=Ee({drawDefinition:o,structureId:f.structureId});if(Zn(),(e=n==null?void 0:n.progression)!=null&&e.doubleExitPropagateBye)nm({drawPosition:v,targetLink:u,inContextDrawMatchUps:r,drawDefinition:o,matchUpsMap:i});else{const g=ob(fm(hc({},t),{structure:m,targetMatchUp:d,iteration:l}));if(g.error)return k({result:g,stack:c})}}return k({result:hc({},V),stack:c})}function ob(t){var e,r,n,o,i;const{inContextDrawMatchUps:s,appliedPolicies:a,drawDefinition:l,sourceMatchUp:c,targetMatchUp:u,matchUpsMap:d,structure:p,iteration:v}=t,f="conditionallyRemoveDrawPosition";Zn();const m=_r({matchUpId:u.matchUpId,inContextDrawMatchUps:s,drawDefinition:l}),{targetMatchUps:{winnerMatchUp:g}}=m,h=d==null?void 0:d.drawMatchUps.find(w=>w.matchUpId===u.matchUpId);let _=[],I,P,y;if(u.feedRound){const w=(e=g==null?void 0:g.drawPositions)==null?void 0:e.filter(Boolean);y=w==null?void 0:w.find(T=>u.drawPositions.includes(T))}else if(!c)y=(r=Ht((u==null?void 0:u.drawPositions)||[],(g==null?void 0:g.drawPositions)||[]))==null?void 0:r[0];else if(P=(n=kS({structureId:p.structureId,matchUp:c,matchUpsMap:d}))==null?void 0:n.pairedPreviousMatchUp,I=[jt,tr].includes(P==null?void 0:P.matchUpStatus),_=((o=P==null?void 0:P.drawPositions)==null?void 0:o.filter(Boolean))||[],[...Yt,nt].includes(P==null?void 0:P.matchUpStatus)||(P==null?void 0:P.winningSide)){const T=c.drawPositions||[];let E=(i=u.drawPositions)==null?void 0:i.filter(Boolean);Xt(T,E)&&(E=E==null?void 0:E.filter($=>!T.includes($))),y=T.concat(_).find($=>E==null?void 0:E.includes($))}g&&y&&(Zn(),eO({winningDrawPosition:y,winnerMatchUp:g,inContextDrawMatchUps:s,drawDefinition:l,matchUpsMap:d}));let S=nb({targetData:m,matchUp:u,inContextDrawMatchUps:s,appliedPolicies:a,drawDefinition:l,matchUpsMap:d,structure:p,iteration:v});if(S.error)return k({result:S,stack:f});const O=Cz({pairedPreviousDoubleExit:I,noContextTargetMatchUp:h}),b=!I;return S=Qn(fm(hc({},t),{matchUpStatus:O,removeScore:b,score:{scoreStringSide1:"",scoreStringSide2:"",sets:void 0},removeWinningSide:!0,matchUp:h,matchUpId:u.matchUpId,matchUpStatusCodes:[]})),S.error?k({result:S,stack:f}):hc({},V)}function Cz({pairedPreviousDoubleExit:t,noContextTargetMatchUp:e}){return e.matchUpStatus===nt?nt:t?[tr,et].includes(e==null?void 0:e.matchUpStatus)?et:ot:Rt}function Mz(t){var e,r,n,o,i;let s;const{inContextDrawMatchUps:a,inContextMatchUp:l,drawDefinition:c}=t,u=(e=t.targetData.targetLinks)==null?void 0:e.winnerTargetLink;if(u.target.feedProfile===Tn){const d=(n=(r=l.sides)==null?void 0:r.find(({sideNumber:v})=>v===l.winningSide))==null?void 0:n.participantId,p=a.find(v=>{var f;return v.structureId===u.target.structureId&&v.roundNumber===u.target.roundNumber&&((f=v.sides)==null?void 0:f.some(({participantId:m})=>m===d))});if((p==null?void 0:p.matchUpStatus)===Rt){const v=_r({matchUpId:p.matchUpId,inContextDrawMatchUps:a,drawDefinition:c});if(!zi({inContextDrawMatchUps:a,drawDefinition:c,targetData:v})){const{structure:m}=Ee({structureId:p.structureId,drawDefinition:c}),g=st({structure:m}).positionAssignments;for(const h of g||[])if(h.participantId===d){if(h.participantId=void 0,m!=null&&m.positionAssignments)m.positionAssignments=g;else if(m!=null&&m.structures){const _=Object.assign({},...(g||[]).map(I=>({[I.drawPosition]:I.participantId})));for(const I of(m==null?void 0:m.structures)||[])(o=I.positionAssignments)==null||o.forEach(P=>P.participantId=_[P.drawPosition])}ai({tournamentId:(i=t.tournamentRecord)==null?void 0:i.tournamentId,event:t.event,drawDefinition:c,structure:m}),s=!0}}}}return{qualifierRemoved:s}}var Dz=Object.defineProperty,jz=Object.defineProperties,Rz=Object.getOwnPropertyDescriptors,ib=Object.getOwnPropertySymbols,Fz=Object.prototype.hasOwnProperty,xz=Object.prototype.propertyIsEnumerable,sb=(t,e,r)=>e in t?Dz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wa=(t,e)=>{for(var r in e||(e={}))Fz.call(e,r)&&sb(t,r,e[r]);if(ib)for(var r of ib(e))xz.call(e,r)&&sb(t,r,e[r]);return t},vm=(t,e)=>jz(t,Rz(e));function Lz(t){var e;const{matchUp:r,matchUpStatus:n,score:o,winningSide:i}=t,s="noDownStreamDependencies";if([jt,tr].includes(r==null?void 0:r.matchUpStatus)&&![jt,tr].includes(n)){const h=nb(t);if(h.error)return k({result:h,stack:s})}const l=n===jt,c=Gt({score:o})&&!l&&(t.isCollectionMatchUp&&!t.projectedWinningSide||!i),u=((e=t==null?void 0:t.inContextMatchUp)==null?void 0:e.collectionId)&&Xq(t.inContextMatchUp),d=t.removeScore||!u&&![ao,Wr].includes(n||ao),p=t.isCollectionMatchUp&&t.dualMatchUp.winningSide&&!t.projectedWinningSide||r.winningSide&&!i&&!Gt({score:o}),v=n&&n!==Rt,f=h=>{var _,I;let P;const{structure:y,drawDefinition:S,dualMatchUp:O,disableAutoCalc:b}=t;if(O!=null&&O._disableAutoCalc&&b!==!1)return am(t);const{connectedStructureIds:w}=bO({drawDefinition:S,structure:y,matchUp:r});w.length&&(console.log({connectedStructureIds:w}),P=!0),Object.assign(t,{removeScore:h});const T=xa(t);if(T.error)return T;if(t.removingQualifier&&((I=(_=t.appliedPolicies)==null?void 0:_[fu])!=null&&I.autoRemoveQualifiers)){const E=Mz(t);return Wa(vm(Wa({},V),{connectedStructures:P}),E)}return vm(Wa({},V),{connectedStructures:P})};if(p&&i&&t.isCollectionMatchUp)return ab(t);const m=[zo,Wr].includes(n)&&t.dualWinningSideChange,g=(i||m)&&wz(t)||c&&f(d)||v&&a5(t)||p&&f(d)||r&&ab(vm(Wa({},t),{removeScore:!0}))||Wa({},V);return k({result:g,stack:s})}function ab(t){var e;const r="scoreModification";if(t.isCollectionMatchUp&&((e=t.dualMatchUp)==null?void 0:e.winningSide)&&!t.projectedWinningSide){const i=xa(t);if(i.error)return i}const o=Qn(Wa({},t));if(t.isCollectionMatchUp){const{matchUpTieId:i,drawDefinition:s,event:a,matchUpsMap:l}=t,{removeWinningSide:c}=po({tournamentRecord:t.tournamentRecord,matchUpId:i,drawDefinition:s,matchUpsMap:l,event:a});c&&console.log("REMOVE WINNING SIDE")}return k({result:o,stack:r})}function Vz(t){var e;const{tournamentRecord:r,inContextMatchUp:n,structure:o,drawDefinition:i}=t,s=n.roundNumber,a=n.sides.find(O=>O.sideNumber===n.winningSide),l=n.sides.find(O=>O.sideNumber!==n.winningSide),{drawPosition:c,participantId:u}=a,{drawPosition:d,participantId:p}=l,v="swapWinnerLoser",{matchUps:f}=Je(t),m=f.filter(({drawPositions:O,roundNumber:b})=>(O==null?void 0:O.includes(c))&&b>s);zt({changeWinner:!0})&&console.log({existingWinnerSubsequentMatchUps:m}),m.forEach(O=>{var b,w;O.drawPositions=((b=O.drawPositions)==null?void 0:b.map(T=>T===c?d:T))||[],Ze({tournamentId:r==null?void 0:r.tournamentId,eventId:(w=t.event)==null?void 0:w.eventId,context:v,drawDefinition:i,matchUp:O})});const{stage:g,stageSequence:h}=o,_=i.structures.filter(({stage:O,stageSequence:b})=>O===g&&b>h).map(({structureId:O})=>O),{targetLinks:{loserTargetLink:I,winnerTargetLink:P}}=t.targetData,y=[I==null?void 0:I.target.structureId,(e=P==null?void 0:P.target)==null?void 0:e.structureId].filter(Boolean);return i.structures.filter(({stage:O,structureId:b})=>O!==g&&y.includes(b)).forEach(({stage:O,stageSequence:b,structureId:w})=>{_.includes(w)||_.push(w),i.structures.filter(({stage:T,stageSequence:E})=>T===O&&E>b).forEach(({structureId:T})=>{_.includes(T)||_.push(T)})}),i.structures.filter(({structureId:O})=>_.includes(O)).forEach(O=>{const{positionAssignments:b}=st({structure:O}),w=b==null?void 0:b.find(({participantId:E})=>E===u),T=b==null?void 0:b.find(({participantId:E})=>E===p);w&&(w.participantId=p),T&&(T.participantId=u)}),Qn(t)}var Bz=Object.defineProperty,kz=Object.defineProperties,Gz=Object.getOwnPropertyDescriptors,lb=Object.getOwnPropertySymbols,Wz=Object.prototype.hasOwnProperty,Hz=Object.prototype.propertyIsEnumerable,cb=(t,e,r)=>e in t?Bz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qz=(t,e)=>{for(var r in e||(e={}))Wz.call(e,r)&&cb(t,r,e[r]);if(lb)for(var r of lb(e))Hz.call(e,r)&&cb(t,r,e[r]);return t},zz=(t,e)=>kz(t,Gz(e));function _c(t){var e,r,n,o,i;const s="setMatchUpStatus";t.matchUpStatus&&[ot,jt].includes(t.matchUpStatus)&&(t.score=void 0);const{allowChangePropagation:a,disableScoreValidation:l,tournamentRecords:c,tournamentRecord:u,disableAutoCalc:d,enableAutoCalc:p,drawDefinition:v,matchUpStatus:f,winningSide:m,matchUpId:g,event:h,score:_}=t;if(!v)return{error:fe};if(f&&[zo,ao,Wr,Rt].includes(f)&&m)return{error:X,winningSide:m,matchUpStatus:f};if(![void 0,...aV].includes(f))return k({result:{error:vl},info:"matchUpStatus does not exist",stack:"setMatchUpStatus"});const I=lr({drawDefinition:v}),{matchUps:P}=xt({nextMatchUps:!0,inContext:!0,drawDefinition:v,matchUpsMap:I,event:h}),y=I.drawMatchUps.find(x=>x.matchUpId===g),S=P==null?void 0:P.find(x=>x.matchUpId===g);if(!y||!P)return{error:ir};if((y.winningSide||m)&&f===nt)return{context:"Cannot have Bye with winningSide",error:rf,matchUpStatus:f};const O=S==null?void 0:S.structureId,{structure:b}=Ee({drawDefinition:v,structureId:O}),w=(e=S==null?void 0:S.drawPositions)==null?void 0:e.filter(Boolean);let T;if(y.matchUpType===Qe){if(d)it({extension:{name:fa,value:!0},element:y});else if(p){const x=y.winningSide;bn({name:fa,element:y});const{winningSide:B,scoreStringSide1:H,scoreStringSide2:q,set:J}=rc({drawDefinition:v,matchUpsMap:I,structure:b,matchUp:y,event:h}),K={scoreStringSide1:H,scoreStringSide2:q,sets:J?[J]:[]};T=B!==x,Object.assign(t,{winningSide:B,dualWinningSideChange:T,projectedWinningSide:B,score:K})}}if(y.matchUpType===Qe&&f&&[la].includes(f))return{error:X,info:"Not supported for matchUpType: TEAM"};const E=S==null?void 0:S.matchUpTieId,N=_r({matchUpId:E||g,inContextDrawMatchUps:P,drawDefinition:v});if(_&&y.matchUpType!==Qe&&!l){const x=y.matchUpFormat||(b==null?void 0:b.matchUpFormat)||(v==null?void 0:v.matchUpFormat)||(h==null?void 0:h.matchUpFormat),B=bv({existingMatchUpStatus:y.matchUpStatus,matchUpFormat:x,matchUpStatus:f,winningSide:m,score:_});if(B.error)return B}const $=y!=null&&y.sides?[]:st({drawDefinition:v,structureId:O}).positionAssignments,A=((r=y.sides)==null?void 0:r.map(x=>x.participantId).filter(Boolean).length)===2||(w==null?void 0:w.length)===2&&($==null?void 0:$.filter(x=>w.includes(x.drawPosition)).every(x=>x.participantId));if(f&&sV.includes(f)&&!A)return k({result:{error:vl},info:"present in participantRequiredMatchUpStatuses",context:{matchUpStatus:f,bothSideParticipants:A}});const U=(o=(n=vt({policyTypes:[fu],tournamentRecord:u,drawDefinition:v,event:h}))==null?void 0:n.appliedPolicies)!=null?o:{};typeof t.policyDefinitions=="object"&&Object.assign(U,t.policyDefinitions);const C=(S==null?void 0:S.stage)===be&&S.finishingRound===1,M=C&&m,D=C&&y.winningSide&&!m&&(!t.matchUpStatus||t.matchUpStatus&&fv({matchUpStatus:t.matchUpStatus}))&&(!t.outcome||!Gt({outcome:t.outcome})),R=M&&m!==y.winningSide&&y.winningSide;if(Object.assign(t,{inContextDrawMatchUps:P,qualifierAdvancing:M,qualifierChanging:R,removingQualifier:D,inContextMatchUp:S,appliedPolicies:U,matchUpTieId:E,matchUpsMap:I,targetData:N,structure:b,matchUp:y}),E){const{matchUp:x}=ut({matchUpId:E,inContext:!0,drawDefinition:v,matchUpsMap:I,event:h});if(x){const B=(i=fr({matchUp:x,drawDefinition:v,structure:b,event:h}))==null?void 0:i.tieFormat,{projectedWinningSide:H}=Zq({drawDefinition:v,matchUpStatus:f,dualMatchUp:x,matchUpsMap:I,winningSide:m,tieFormat:B,structure:b,matchUp:y,event:h,score:_}),q=x.winningSide;T=H!==q,Object.assign(t,{isCollectionMatchUp:!0,dualWinningSideChange:T,projectedWinningSide:H,matchUpTieId:E,dualMatchUp:x,tieFormat:B})}}const j=zi(t),G=nc({matchUpStatus:f});if(!E){if(j&&!m&&(f&&fv({matchUpStatus:f})||f&&[jt,tr].includes(f)))return{error:rf,activeDownstream:j,winningSide:m};if(m&&m===y.winningSide&&f&&!G)return{context:"winningSide must include directing matchUpStatus",error:rf,directingMatchUpStatus:G,matchUpStatus:f}}const{schedule:W}=t;if(W){const x=pd({disableNotice:!0,tournamentRecords:c,tournamentRecord:u,drawDefinition:v,matchUpId:g,schedule:W});if(x.error)return x}const z=y.matchUpType!==Qe&&!T&&m&&y.winningSide&&y.winningSide!==m;if(a&&z&&y.roundPosition)return Vz(t);const F=m&&!E||t.projectedWinningSide;Zn();const L=!j&&Lz(t)||F&&Yz(t)||G&&ub(t)||{error:Qx};return k({result:L,stack:s})}function Yz(t){const{matchUp:e,winningSide:r,matchUpTieId:n,dualWinningSideChange:o}=t;return r===e.winningSide||n&&!o?ub(t):k({result:{error:a_},stack:"winningSideWithDownstreamDependencies",context:{winningSide:r,matchUp:e}})}function ub(t){const{tournamentRecord:e,matchUp:r,event:n}=t,o=t.isCollectionMatchUp&&r.winningSide&&!t.winningSide&&!Gt({score:t.score}),i=t.isCollectionMatchUp?t.matchUpStatus||o&&Rt||At:t.matchUpStatus||At,s=t.removeScore||[zo,ot].includes(i)&&![ao,Wr].includes(i),a=Qn(zz(qz({},t),{matchUpStatus:i,removeWinningSide:o,removeScore:s}));if(a.error)return a;if(t.isCollectionMatchUp){const{matchUpTieId:l,drawDefinition:c,matchUpsMap:u}=t,d=po({matchUpId:l,tournamentRecord:e,drawDefinition:c,matchUpsMap:u,event:n});if(d.error)return d;Object.assign(a,{tieMatchUpResult:d})}return a}var Kz=Object.defineProperty,db=Object.getOwnPropertySymbols,Qz=Object.prototype.hasOwnProperty,Jz=Object.prototype.propertyIsEnumerable,pb=(t,e,r)=>e in t?Kz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zz=(t,e)=>{for(var r in e||(e={}))Qz.call(e,r)&&pb(t,r,e[r]);if(db)for(var r of db(e))Jz.call(e,r)&&pb(t,r,e[r]);return t};function Od(t){let e=t.structureIds;const{tournamentRecord:r,drawDefinition:n,matchUpFormat:o,structureId:i,matchUpId:s,event:a}=t;if(!n)return{error:fe};if(!o)return{error:nf};if(!en(o))return{error:Zc};const l="setMatchUpFormat";if(s){const c=ut({drawDefinition:n,matchUpId:s,event:a});if(c.error)return c;if(!c.matchUp)return{error:ir};const u=c.matchUp;if((u==null?void 0:u.matchUpType)===Bt)return{error:rn,info:"Cannot set matchUpFormat when { matchUpType: TEAM }"};u.matchUpFormat=o,Ze({tournamentId:r==null?void 0:r.tournamentId,eventId:a==null?void 0:a.eventId,context:l,drawDefinition:n,matchUp:u})}else if(Array.isArray(e)){if((a==null?void 0:a.eventType)===Bt)return{error:Ii};for(const c of e){const u=Ee({drawDefinition:n,structureId:c});if(u.error)return u;if(u.structure)u.structure.matchUpFormat=o;else return{error:St}}}else if(i){if((a==null?void 0:a.eventType)===Bt)return{error:Ii};const c=Ee({drawDefinition:n,structureId:i});if(c.error)return c;if(c.structure)c.structure.matchUpFormat=o;else return{error:St}}else n&&(n.matchUpFormat=o);return e=e||(i?[i]:void 0),tt({drawDefinition:n,structureIds:e}),Zz({},V)}function fb(t){const{matchUpFormat:e,matchUpStatus:r,winningSide:n,score:o}=t;if(!o)return{sets:[]};const i=o.sets||[];let s=fo({winnerFirst:!1,matchUpFormat:e,matchUpStatus:r,sets:i}),a=fo({winnerFirst:!1,reversed:!0,matchUpFormat:e,matchUpStatus:r,sets:i});const l=fo({matchUpFormat:e,matchUpStatus:r,winningSide:n,sets:i}),c=s===l?a:s;return n&&(s=n===1?l:c,a=n===2?l:c),{score:{sets:i,scoreStringSide1:s,scoreStringSide2:a}}}var Xz=Object.defineProperty,vb=Object.getOwnPropertySymbols,eY=Object.prototype.hasOwnProperty,tY=Object.prototype.propertyIsEnumerable,mb=(t,e,r)=>e in t?Xz(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,rY=(t,e)=>{for(var r in e||(e={}))eY.call(e,r)&&mb(t,r,e[r]);if(vb)for(var r of vb(e))tY.call(e,r)&&mb(t,r,e[r]);return t};function Ic(t){var e;const{tournamentRecords:r,policyDefinitions:n,tournamentRecord:o,disableAutoCalc:i,enableAutoCalc:s,drawDefinition:a,matchUpFormat:l,matchUpId:c,schedule:u,event:d,notes:p}=t;if(!a)return{error:kr};if(!c)return{error:Vt};const{policy:v}=us({policyType:da,tournamentRecord:o,event:d}),f=t.allowChangePropagation!==void 0&&t.allowChangePropagation||(v==null?void 0:v.allowChangePropagation)!==void 0&&v.allowChangePropagation||void 0,{outcome:m}=t;if(l){const g=Od({tournamentRecord:o,drawDefinition:a,matchUpFormat:l,matchUpId:c,event:d});if(g.error)return g}if((e=m==null?void 0:m.score)!=null&&e.sets&&!m.score.scoreStringSide1){const{score:g}=fb(m);m.score=g,m.score.sets=m.score.sets.filter(h=>h.side1Score||h.side2Score||h.side1TiebreakScore||h.side2TiebreakScore)}return _c({matchUpStatusCodes:m==null?void 0:m.matchUpStatusCodes,matchUpStatus:m==null?void 0:m.matchUpStatus,winningSide:m==null?void 0:m.winningSide,allowChangePropagation:f,score:m==null?void 0:m.score,tournamentRecords:r,policyDefinitions:n,tournamentRecord:o,disableAutoCalc:i,enableAutoCalc:s,drawDefinition:a,matchUpFormat:l,matchUpId:c,schedule:u,event:d,notes:p})}function gb(t){var e;if(!t.tournamentRecord)return{error:re};const{tournamentRecords:r,tournamentRecord:n,outcomes:o,policyDefinitions:i}=t,s={};o.forEach(a=>{const{eventId:l}=a;s[l]||(s[l]=[]),s[l].push(a)});for(const a of Object.keys(s)){const{event:l}=Qt({tournamentRecord:n,eventId:a});for(const c of s[a]){const{drawId:u}=c,d=(e=l==null?void 0:l.drawDefinitions)==null?void 0:e.find(p=>p.drawId===u);if(d&&u){const{matchUpFormat:p,matchUpId:v}=c,f=Ic({schedule:c==null?void 0:c.schedule,tournamentRecords:r,policyDefinitions:i,tournamentRecord:n,drawDefinition:d,matchUpFormat:p,matchUpId:v,outcome:c,drawId:u,event:l});if(f.error)return f}}}return rY({},V)}var nY=Object.defineProperty,oY=Object.defineProperties,iY=Object.getOwnPropertyDescriptors,hb=Object.getOwnPropertySymbols,sY=Object.prototype.hasOwnProperty,aY=Object.prototype.propertyIsEnumerable,_b=(t,e,r)=>e in t?nY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ib=(t,e)=>{for(var r in e||(e={}))sY.call(e,r)&&_b(t,r,e[r]);if(hb)for(var r of hb(e))aY.call(e,r)&&_b(t,r,e[r]);return t},lY=(t,e)=>oY(t,iY(e));function cY(t){const e=t.tournamentRecords,r=t.tournamentId||em(t);if(typeof r!="string")return{error:So};const n=e[r];if(!n)return{error:re};const{drawDefinition:o,event:i}=Qt({eventId:t.eventId,drawId:t.drawId,tournamentRecord:n});return Ic(lY(Ib({tournamentRecord:n},t),{drawDefinition:o,event:i}))}function uY(t){const{tournamentRecords:e,outcomes:r}=t;if(!Array.isArray(r))return{error:_e,info:or("outcomes")};const n=r.reduce((o,i)=>o.includes(i.tournamentId)?o:o.concat(i.tournamentId),[]);for(const o of n){const i=e[o];if(!i)return{error:re};const s=r.filter(a=>a.tournamentId===o);if(s.length){const a=gb({tournamentRecord:i,outcomes:s});if(a.error)return a}}return Ib({},V)}function Pb({courtPrefix:t="C|",minRowsCount:e,courtsData:r}){if(!Array.isArray(r))return{error:X};const n=r==null?void 0:r.reduce((s,a)=>{const l=a.matchUps||[],c=Math.max(0,...l.map(u=>u.schedule.courtOrder||0));return c>s?c:s},1),o=e?Math.max(e,n):n,i=pe(0,o).map(s=>({matchUps:pe(0,r.length).map(a=>{const l=r[a],{courtId:c,venueId:u}=l;return{schedule:{courtOrder:s+1,venueId:u,courtId:c}}})}));return r.forEach((s,a)=>{var l;for(const c of s.matchUps){const u=(l=c.schedule)==null?void 0:l.courtOrder;u&&(i[u-1].matchUps[a]=c)}}),{courtPrefix:t,rows:i.map((s,a)=>Object.assign({rowId:`rowId-${a+1}`},...s.matchUps.map((l,c)=>({[`${t}${c}`]:l}))))}}var dY=Object.defineProperty,pY=Object.defineProperties,fY=Object.getOwnPropertyDescriptors,yb=Object.getOwnPropertySymbols,vY=Object.prototype.hasOwnProperty,mY=Object.prototype.propertyIsEnumerable,Sb=(t,e,r)=>e in t?dY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mm=(t,e)=>{for(var r in e||(e={}))vY.call(e,r)&&Sb(t,r,e[r]);if(yb)for(var r of yb(e))mY.call(e,r)&&Sb(t,r,e[r]);return t},gm=(t,e)=>pY(t,fY(e));function Pc(t){var e,r,n,o,i,s,a,l,c,u,d,p;const{flight:v,suppressNotifications:f,modifyEventEntries:m,existingDrawCount:g,allowReplacement:h,checkEntryStatus:_,tournamentRecord:I,drawDefinition:P,event:y}=t;if(!P)return{error:kr};if(!y)return{error:Ge};y.drawDefinitions||(y.drawDefinitions=[]);const{drawId:S,drawName:O,entries:b}=P,{entries:w}=y;let T=0;if(g!==void 0&&g!==y.drawDefinitions.length)return{error:X,info:"drawDefintions count mismatch"};const{flightProfile:E}=Et({event:y}),N=v&&((e=E==null?void 0:E.flights)==null?void 0:e.find(x=>x.flightNumber===v.flightNumber)),$=(o=(n=(r=E==null?void 0:E.links)==null?void 0:r.find(x=>{var B;return((B=x==null?void 0:x.target)==null?void 0:B.drawId)===S}))==null?void 0:n.source)==null?void 0:o.drawId;if($&&!y.drawDefinitions.find(x=>x.drawId===$))return k({result:{error:fe},info:{sourceDrawId:$}});if(N&&N.drawId!==P.drawId)return k({result:{error:es},info:{relevantFlight:N}});const C=b==null?void 0:b.every(({participantId:x,entryStatus:B})=>{const H=N==null?void 0:N.drawEntries.find(q=>q.participantId===x);return!B||(H==null?void 0:H.entryStatus)===B}),M=!_||w&&(b==null?void 0:b.every(({participantId:x,entryStatus:B,entryStage:H})=>{const q=w.find(J=>J.participantId===x&&(!J.entryStage||J.entryStage===H));return(q==null?void 0:q.entryStatus)===B}));if(N&&!C)return k({result:{error:es,context:{drawEntriesPresentInFlight:C,matchingEventEntries:M,relevantFlight:N},info:"Draw entries are not present in flight or do not match entryStatuses"}});if(m&&(b==null||b.filter(Boolean).forEach(x=>{if(x!=null&&x.entryStatus&&si.includes(x==null?void 0:x.entryStatus)){const B=w==null?void 0:w.filter(Boolean).find(H=>H.participantId===x.participantId);B&&x.entryStatus&&(B==null?void 0:B.entryStatus)!==x.entryStatus&&(B.entryStatus=x.entryStatus,T+=1)}})),w&&!M)return k({result:{error:es,context:{matchingEventEntries:M,eventEntries:w},info:"Draw entries do not match event entryStatuses"}});const D=((s=(i=E==null?void 0:E.flights)==null?void 0:i.map(({flightNumber:x})=>!isNaN(x)&&Oe(x)))==null?void 0:s.filter(Boolean))||[],R=((a=y.drawDefinitions.map(({drawOrder:x})=>x&&Oe(x)))==null?void 0:a.filter(Boolean))||[];let j=Math.max(0,...R,...D)+1;const G=(l=E==null?void 0:E.flights)==null?void 0:l.find(x=>x.drawId===S);let W;if(G){G.drawName=P.drawName,W={name:yn,value:gm(mm({},E),{flights:E.flights})};const x=G.flightNumber;x&&!R.includes(x)?j=x:G.flightNumber=j}else{const x=(E==null?void 0:E.flights)||[];x.push({manuallyAdded:!0,flightNumber:j,drawEntries:b,drawName:O,drawId:S}),W={name:yn,value:gm(mm({},E||{}),{flights:x})}}lo({event:y,extension:W}),Object.assign(P,{drawOrder:j});const z=y.drawDefinitions.find(x=>x.drawId===S),F=I==null?void 0:I.tournamentId,L=y.eventId;if(z){if(!h)return{error:JF};const x=(c=zr({drawDefinition:z}))==null?void 0:c.matchUps,B=(u=x==null?void 0:x.map(Jt))!=null?u:[],H=(d=zr({drawDefinition:P}))==null?void 0:d.matchUps;if(!f){B!=null&&B.length&&Bi({matchUpIds:B,action:"modifyDrawDefinition",tournamentId:F,eventId:L}),H!=null&&H.length&&Vi({matchUps:H,tournamentId:F,eventId:L}),y.drawDefinitions=y.drawDefinitions.map(J=>J.drawId===S?P:J);const q=(p=P.structures)==null?void 0:p.map(({structureId:J})=>J);tt({drawDefinition:P,tournamentId:F,structureIds:q,eventId:L})}}else if(y.drawDefinitions.push(P),!f){const{matchUps:x}=zr({drawDefinition:P,event:y});x&&Vi({tournamentId:I==null?void 0:I.tournamentId,matchUps:x}),oc({drawDefinition:P,tournamentId:F,eventId:L})}return gm(mm({},V),{modifiedEventEntryStatusCount:T})}function gY({tournamentRecords:t,existingDrawCount:e,allowReplacement:r,drawDefinition:n,tournamentId:o,eventId:i,flight:s}){if(!i)return{error:Ge};if(o=o??em({tournamentRecords:t,eventId:i}),!o)return{error:So};const a=t[o];if(!a)return{error:re};const l=Qt({tournamentRecord:a,eventId:i});return l.event?l.error?l:Pc({event:l.event,existingDrawCount:e,allowReplacement:r,drawDefinition:n,flight:s}):{error:Ur}}var hY=Object.defineProperty,_Y=Object.defineProperties,IY=Object.getOwnPropertyDescriptors,Ob=Object.getOwnPropertySymbols,PY=Object.prototype.hasOwnProperty,yY=Object.prototype.propertyIsEnumerable,bb=(t,e,r)=>e in t?hY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bd=(t,e)=>{for(var r in e||(e={}))PY.call(e,r)&&bb(t,r,e[r]);if(Ob)for(var r of Ob(e))yY.call(e,r)&&bb(t,r,e[r]);return t},SY=(t,e)=>_Y(t,IY(e));function Xn({allowDuplicateParticipantIdPairs:t,returnParticipant:e,tournamentRecord:r,disableNotice:n,pairOverride:o,participant:i}){var s,a,l;const c="addParticipant";if(!r)return{error:re};if(!i)return k({result:{error:oa},stack:c});i.participantId||(i.participantId=ze()),r.participants||(r.participants=[]);const{participantId:u,individualParticipantIds:d}=i;if(r.participants.reduce((_,I)=>I.participantId===u||_,!1))return{error:wx};const{participantType:v,participantRole:f}=i;if(!v||!Object.keys(Bl).includes(v))return{error:Fn,participantType:v};if(!f)return{error:Tx};const m=r.participants||[],g=m.filter(_=>_.participantType===Fe).map(_=>_.participantId);if(v!==Fe&&i.person)return{error:X,person:i.person};if(d&&!Array.isArray(d))return{error:X,individualParticipantIds:d};if(v===Ue){if(i.person)return{error:X,person:i.person};if(i.individualParticipantIds){if(i.individualParticipantIds.length!==2&&!o)return k({result:{error:mn,info:"PAIR must be 2 individualParticipantIds"},stack:c});{const P=m.filter(S=>S.participantType===Fe).map(S=>S.participantId);if(!Array.isArray(i.individualParticipantIds))return k({result:{error:mn},stack:c});if(!i.individualParticipantIds.reduce((S,O)=>P.includes(O)&&S,!0))return k({result:{error:mn},stack:c})}}else return k({result:{error:bo},stack:c});const _=m.filter(P=>P.participantType===Ue).map(P=>({individualParticipantIds:P.individualParticipantIds,participant:P})),I=i.participantType===Ue&&_.find(P=>Ht(P.individualParticipantIds,i.individualParticipantIds).length===2);if(I&&!t)return SY(bd({},V),{existingParticipant:!0,participant:e&&ve(I.participant)});if(!i.participantName){const P=m.filter(S=>{var O;return(O=i.individualParticipantIds)==null?void 0:O.includes(S.participantId)});let y=P.map(S=>{var O;return(O=S.person)==null?void 0:O.standardFamilyName}).filter(Boolean).join("/");P.length===1&&(y+="/Unknown"),i.participantName=y}}else if(v===Fe){if(!((s=i.person)!=null&&s.standardFamilyName)||!((a=i.person)!=null&&a.standardGivenName))return{error:Ux};if(!i.participantName){const _=`${i.person.standardFamilyName.toUpperCase()}, ${i.person.standardGivenName}`;i.participantName=_}}else if(v&&[rt,Cr].includes(v)){if(d||(i.individualParticipantIds=[]),(l=i.individualParticipantIds)!=null&&l.length)for(const _ of i.individualParticipantIds){if(typeof _!="string")return k({result:{participantId:_,error:X},stack:c});if(!g.includes(_))return k({result:{participantId:_,error:Dt},stack:c})}}else return{error:Fn};r.participants.push(i),n||qe({payload:{tournamentId:r.tournamentId,participants:[i]},topic:Ui});const h=bd({participant:e&&ve(i)},V);return ye(h)}function ho({allowDuplicateParticipantIdPairs:t,returnParticipants:e,participants:r,tournamentRecord:n}){if(!n)return{error:re};n.participants||(n.participants=[]);const i=n.participants.map(p=>p.participantId)||[];r.forEach(p=>{p.participantId||(p.participantId=ze())});const s=r.filter(p=>!i.includes(p.participantId)),a=r.filter(p=>i.includes(p.participantId)),l=s.filter(p=>p.participantType===Fe),c=s.filter(p=>p.participantType!==Fe),u=l.concat(...c),d=[];if(u.length){for(const v of u){const f=Xn({allowDuplicateParticipantIdPairs:t,returnParticipant:!0,disableNotice:!0,tournamentRecord:n,participant:v});if(f.error)return f;f.success&&!f.existingParticipant&&d.push(f.participant)}d.length&&qe({topic:Ui,payload:{tournamentId:n.tournamentId,participants:d}});const p=bd({participants:e&&ve(d),addedCount:d.length},V);return a.length&&Object.assign(p,{notAdded:a,info:uf}),ye(p)}else return bd({info:"No new participants to add",addedCount:0},V)}function OY({tournamentRecords:t,returnParticipant:e,pairOverride:r,tournamentId:n,participant:o}){if(typeof n!="string")return{error:So};const i=t[n];return i?Xn({returnParticipant:e,tournamentRecord:i,pairOverride:r,participant:o}):{error:re}}function bY({event:t}){var e;const r=`${Hr}.${qr}`,{timeItem:n}=Cn({element:t,itemType:r});if((e=n==null?void 0:n.itemValue)!=null&&e.PUBLIC){const{drawIds:o=[],seeding:i}=n.itemValue.PUBLIC||{},s={published:void 0,seedingScaleNames:[],drawIds:[]};return i&&Object.assign(s,n.itemValue.PUBLIC.seeding),{publishedDrawIds:o,publishedSeeding:s}}}function Td({element:t,accessor:e}){if(typeof e!="string")return{values:[]};const r=ve(t),n=e.split("."),o=[];let i;a({targetElement:r,attributes:n});const s={value:i};return o.length&&(s.values=o),s;function a({targetElement:l,attributes:c=[],significantCharacters:u}){for(const[p,v]of c.entries())if(l!=null&&l[v])if(Array.isArray(l[v])){const f=l[v],m=c.slice(p);f.forEach(g=>a({targetElement:g,attributes:m}))}else l=l[v],d({targetElement:l,index:p});function d({targetElement:p,index:v}){if(p&&v===c.length-1&&["string","number"].includes(typeof p)){const f=u?p.slice(0,u):p;i?o.includes(f)||o.push(f):(i=f,o.push(f))}}}}function _o({requireTimeStamp:t,scaleAttributes:e,participant:r}){var n,o;if(!r)return{error:oa};if(typeof e!="object")return{error:X};if(r.timeItems||(r.timeItems=[]),r&&Array.isArray(r.timeItems)){const{accessor:i,scaleType:s,eventType:a,scaleName:l}=e,c=[ps,s,a,l].join("."),d=r.timeItems.filter(p=>(p==null?void 0:p.itemType)===c).filter(p=>!t||(p==null?void 0:p.itemDate)).sort((p,v)=>(p.createdAt?new Date(p.createdAt).getTime():0)-(v.createdAt?new Date(v.createdAt).getTime():0)).pop();if(d){const[p,v,f,m]=(o=(n=d.itemType)==null?void 0:n.split("."))!=null?o:[];if(p!==ps)return{error:ou};const g=i&&Td({element:d.itemValue,accessor:i}),h=(g==null?void 0:g.value)||d.itemValue;return{scaleItem:{eventType:f,scaleDate:d.itemDate,scaleValue:h,scaleName:m,scaleType:v}}}else return{error:Hx}}return{error:oa}}function TY({publishedSeeding:t,usePublishState:e,withSeeding:r,participant:n,event:o}){var i,s,a;const l={},c=f=>[ps,Sn,o.eventType,f].join("."),u=Object.assign({},...(n.timeItems||[]).filter(({itemType:f})=>f.split(".")[1]===Sn).map(({itemType:f,itemValue:m})=>({[f]:m}))),d=((t==null?void 0:t.stageSeedingScaleNames)&&Object.values(t==null?void 0:t.stageSeedingScaleNames)||Array.isArray(t==null?void 0:t.seedingScaleNames)&&t.seedingScaleNames||[]).map(c),p=Ht(Object.keys(u),d);if(!!(!e||!Object.keys(u).length&&!((i=t==null?void 0:t.drawIds)!=null&&i.length)||p.length)&&p.length){if(t!=null&&t.stageSeedingScaleNames){const f=Object.keys(t.stageSeedingScaleNames).map(g=>{const h=c(t.stageSeedingScaleNames[g]),_=u[h];return[g,_]}).filter(g=>g[1]).map(g=>({[g[0]]:{seedValue:g[1]}})),m=Object.assign({},...f);l.seedAssignments=m}else if(p){const f=p.map(m=>u[m]);l.seedValue=f.pop()}}else if(!e&&typeof r=="object"){const f=Object.keys(r).map(g=>{const h=c(r[g]),_=u[h];return[g,_]}).filter(g=>g[1]).map(g=>({[g[0]]:{seedValue:g[1]}})),m=Object.assign({},...f);l.seedAssignments=m}else{const{categoryName:f,ageCategoryCode:m}=o.category||{};let g;for(const h of[m,o.eventId,f]){const _={eventType:o.eventType,scaleType:Sn,scaleName:h},I=_o({scaleAttributes:_,participant:n});if(I.scaleItem){g=I.scaleItem;break}}if(g&&(!e||(t==null?void 0:t.published)&&!((a=(s=t==null?void 0:t.published)==null?void 0:s.drawIds)!=null&&a.length))){const _=g.scaleValue;l.seedValue=_}}return l}var wY=Object.defineProperty,EY=Object.defineProperties,$Y=Object.getOwnPropertyDescriptors,Tb=Object.getOwnPropertySymbols,NY=Object.prototype.hasOwnProperty,UY=Object.prototype.propertyIsEnumerable,wb=(t,e,r)=>e in t?wY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wd=(t,e)=>{for(var r in e||(e={}))NY.call(e,r)&&wb(t,r,e[r]);if(Tb)for(var r of Tb(e))UY.call(e,r)&&wb(t,r,e[r]);return t},Ed=(t,e)=>EY(t,$Y(e));function Eb({tournamentRecord:t,matchUpFormat:e,event:r}){if(!t)return{error:re};if(!en(e))return{error:Zc};const{extension:n}=No({event:r,name:Hn}),o=n==null?void 0:n.value,{extension:i}=Fr({tournamentRecord:t,name:Hn}),s=i==null?void 0:i.value,a=(o==null?void 0:o.matchUpAverageTimes)&&Ul(Ed(wd({},o),{matchUpFormat:e})),l=(s==null?void 0:s.matchUpAverageTimes)&&Ul(Ed(wd({},s),{matchUpFormat:e})),c=[a,l].find(v=>v),u=(o==null?void 0:o.matchUpRecoveryTimes)&&Al(Ed(wd({},o),{matchUpFormat:e})),d=(s==null?void 0:s.matchUpRecoveryTimes)&&Al(Ed(wd({},s),{matchUpFormat:e})),p=[u,d].find(v=>v);return{matchUpFormat:e,averageTimes:c,recoveryTimes:p}}var AY=Object.defineProperty,CY=Object.defineProperties,MY=Object.getOwnPropertyDescriptors,$b=Object.getOwnPropertySymbols,DY=Object.prototype.hasOwnProperty,jY=Object.prototype.propertyIsEnumerable,Nb=(t,e,r)=>e in t?AY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yc=(t,e)=>{for(var r in e||(e={}))DY.call(e,r)&&Nb(t,r,e[r]);if($b)for(var r of $b(e))jY.call(e,r)&&Nb(t,r,e[r]);return t},$d=(t,e)=>CY(t,MY(e));function hm({tournamentRecord:t,recoveryTimes:e,matchUpFormat:r,averageTimes:n,event:o}){if(!t)return{error:re};if(n&&!Array.isArray(n))return{error:X};if(e&&!Array.isArray(e))return{error:X};const i=Hn;if(o){const{extension:s}=No({event:o,name:i}),a=(s==null?void 0:s.value)||{},l=Ub($d(yc({},a),{matchUpFormat:r,averageTimes:n,recoveryTimes:e}));lo({event:o,extension:{name:i,value:l}})}else{const{extension:s}=Fr({tournamentRecord:t,name:i}),a=(s==null?void 0:s.value)||{},l=Ub($d(yc({},a),{matchUpFormat:r,averageTimes:n,recoveryTimes:e}));Ni({tournamentRecord:t,extension:{name:i,value:l}})}return yc({},V)}function Ub(t){const{matchUpRecoveryTimes:e=[],matchUpAverageTimes:r=[],matchUpFormat:n}=t;let{averageTimes:o,recoveryTimes:i}=t;o=(o||[]).filter(l=>{var c,u;return((c=l==null?void 0:l.categoryNames)==null?void 0:c.length)||((u=l==null?void 0:l.categoryTypes)==null?void 0:u.length)});const s=(o==null?void 0:o.length)&&r.map(l=>{var c;return l!=null&&l.matchUpFormatCodes.includes(n)?$d(yc({},l),{matchUpFormatCodes:(c=l.matchUpFormatCodes)==null?void 0:c.filter(u=>u!==n)}):l}).filter(({matchUpFormatCodes:l})=>l==null?void 0:l.length).concat({matchUpFormatCodes:[n],averageTimes:o});i=(i||[]).filter(l=>{var c,u;return((c=l==null?void 0:l.categoryNames)==null?void 0:c.length)||((u=l==null?void 0:l.categoryTypes)==null?void 0:u.length)});const a=(i==null?void 0:i.length)&&e.map(l=>{var c;return l!=null&&l.matchUpFormatCodes.includes(n)?$d(yc({},l),{matchUpFormatCodes:(c=l.matchUpFormatCodes)==null?void 0:c.filter(u=>u!==n)}):l}).filter(({matchUpFormatCodes:l,averageTimes:c})=>(l==null?void 0:l.length)||c).concat({matchUpFormatCodes:[n],recoveryTimes:i});return{matchUpAverageTimes:(s==null?void 0:s.length)&&s||r,matchUpRecoveryTimes:(a==null?void 0:a.length)&&a||e}}function Ab({tournamentRecord:t,recoveryMinutes:e,averageMinutes:r,matchUpFormat:n,categoryType:o,event:i}){if(!t)return{error:re};if(!en(n))return{error:X};if(!i)return{error:Ge};const{averageTimes:s=[],recoveryTimes:a=[]}=Eb({tournamentRecord:t,matchUpFormat:n,event:i}),l=i.category,c=(l==null?void 0:l.categoryName)||(l==null?void 0:l.ageCategoryCode)||(i==null?void 0:i.eventId);let u={categoryNames:[c],minutes:{}};const d={categoryNames:[c],minutes:{}},p=h=>{var _,I;if((_=h.categoryTypes)!=null&&_.includes(o)&&console.log("encountered:",{categoryType:o}),!((I=h.categoryNames)!=null&&I.includes(c)&&(h.categoryNames=h.categoryNames.filter(P=>P!==c),u={minutes:h.minutes,categoryNames:[c]},!h.categoryNames.length)))return h},v=!isNaN(Oe(r)),f=!isNaN(Oe(e)),m=s.map(p).filter(h=>{var _;return(_=h==null?void 0:h.categoryNames)==null?void 0:_.length}),g=a.map(p).filter(h=>{var _;return(_=h==null?void 0:h.categoryNames)==null?void 0:_.length});return v&&(Object.assign(u.minutes,{[(i==null?void 0:i.eventType)||Nt]:r}),m.push(u)),f&&(Object.assign(d.minutes,{[(i==null?void 0:i.eventType)||Nt]:e}),g.push(d)),!v&&!f?{error:X}:hm({averageTimes:v&&m,recoveryTimes:f&&g,tournamentRecord:t,matchUpFormat:n,event:i})}function RY({tournamentRecords:t,recoveryMinutes:e,averageMinutes:r,matchUpFormat:n,categoryType:o,tournamentId:i,eventId:s}){if(!s)return{error:Ge};const a=Object.keys(t).filter(l=>!i||i===l);if(i&&!a.includes(i))return{error:X};for(const l of a){const c=t[l],{event:u}=Qt({tournamentRecord:c,eventId:s});if(u)return Ab({tournamentRecord:c,recoveryMinutes:e,averageMinutes:r,matchUpFormat:n,categoryType:o,event:u})}return{error:Ur}}const Sc=({scheduleAttributes:t=["scheduledDate","scheduledTime"],schedule:e={}})=>!!Object.keys(e).filter(n=>t.includes(n)).filter(n=>e[n]).length;var FY=Object.defineProperty,xY=Object.defineProperties,LY=Object.getOwnPropertyDescriptors,Cb=Object.getOwnPropertySymbols,VY=Object.prototype.hasOwnProperty,BY=Object.prototype.propertyIsEnumerable,Mb=(t,e,r)=>e in t?FY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kY=(t,e)=>{for(var r in e||(e={}))VY.call(e,r)&&Mb(t,r,e[r]);if(Cb)for(var r of Cb(e))BY.call(e,r)&&Mb(t,r,e[r]);return t},GY=(t,e)=>xY(t,LY(e));function Oc({tournamentRecord:t}){if(!t)return{error:re};const e=(({tournamentId:r,tournamentRank:n,tournamentStatus:o,formalName:i,tournamentName:s,promotionalName:a,onlineResources:l,localTimeZone:c,startDate:u,endDate:d,hostCountryCode:p,tournamentContacts:v,tournamentAddresses:f})=>({tournamentId:r,tournamentRank:n,tournamentStatus:o,formalName:i,tournamentName:s,promotionalName:a,onlineResources:l,localTimeZone:c,startDate:u,endDate:d,hostCountryCode:p,tournamentContacts:v,tournamentAddresses:f}))(t);return GY(kY({},V),{tournamentInfo:ve(e,!1,!0)})}var WY=Object.defineProperty,Nd=Object.getOwnPropertySymbols,Db=Object.prototype.hasOwnProperty,jb=Object.prototype.propertyIsEnumerable,Rb=(t,e,r)=>e in t?WY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Fb=(t,e)=>{for(var r in e||(e={}))Db.call(e,r)&&Rb(t,r,e[r]);if(Nd)for(var r of Nd(e))jb.call(e,r)&&Rb(t,r,e[r]);return t},xb=(t,e)=>{var r={};for(var n in t)Db.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Nd)for(var n of Nd(t))e.indexOf(n)<0&&jb.call(t,n)&&(r[n]=t[n]);return r};function Lb({derivedDrawInfo:t,participantId:e,drawId:r}){var n,o,i,s;const a=(o=(n=t[r])==null?void 0:n.mainPositionAssignments)==null?void 0:o.find(u=>u.participantId===e),l=(s=(i=t[r])==null?void 0:i.qualifyingPositionAssignments)==null?void 0:s.find(u=>u.participantId===e),c={};if(a){const u=a,{participantId:d}=u,p=xb(u,["participantId"]);d&&(c[ge]=Fb({},p))}if(l){const u=l,{participantId:d}=u,p=xb(u,["participantId"]);d&&(c[be]=Fb({},p))}return Object.keys(c).length?c:void 0}function HY({processParticipantId:t,tournamentRecords:e,tournamentRecord:r}){if(typeof r!="object"&&typeof e!="object")return{error:re};const n=e?Object.values(e).map(i=>(i==null?void 0:i.participants)||[]).flat():(r==null?void 0:r.participants)||[];return{relevantParticipantIdsMap:Object.assign({},...n.map(({participantId:i,participantType:s,individualParticipantIds:a})=>{typeof t=="function"&&t(i);const l=(a||[]).map(c=>({participantType:Fe,relevantParticipantId:c}));return{[i]:l.concat({relevantParticipantId:i,participantType:s})}}))}}var qY=Object.defineProperty,Ud=Object.getOwnPropertySymbols,Vb=Object.prototype.hasOwnProperty,Bb=Object.prototype.propertyIsEnumerable,kb=(t,e,r)=>e in t?qY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gb=(t,e)=>{for(var r in e||(e={}))Vb.call(e,r)&&kb(t,r,e[r]);if(Ud)for(var r of Ud(e))Bb.call(e,r)&&kb(t,r,e[r]);return t},Wb=(t,e)=>{var r={};for(var n in t)Vb.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Ud)for(var n of Ud(t))e.indexOf(n)<0&&Bb.call(t,n)&&(r[n]=t[n]);return r};function Ad({derivedDrawInfo:t,participantId:e,drawId:r}){var n,o,i,s;const a=(o=(n=t[r])==null?void 0:n.mainSeedAssignments)==null?void 0:o.find(u=>u.participantId===e),l=(s=(i=t[r])==null?void 0:i.qualifyingSeedAssignments)==null?void 0:s.find(u=>u.participantId===e),c={};if(a){const u=a,{participantId:d}=u,p=Wb(u,["participantId"]);d&&(c[ge]=Gb({},p))}if(l){const u=l,{participantId:d}=u,p=Wb(u,["participantId"]);d&&(c[be]=Gb({},p))}return Object.keys(c).length?c:void 0}function Hb({scheduleAttributes:t=["scheduledDate","scheduledTime"],matchUps:e=[]}){if(!Array.isArray(e))return{error:Wo};if(!Array.isArray(t))return{error:X};const r=e.filter(Boolean).filter(({schedule:o})=>Sc({schedule:o,scheduleAttributes:t})).reduce((o,i)=>{const{schedule:s}=i,a=Re(s==null?void 0:s.scheduledDate),l=ct(s==null?void 0:s.scheduledTime);return a&&l&&(o[a]?o[a].push(i):o[a]=[i]),o},{});return Object.keys(r).forEach(o=>{r[o].sort((i,s)=>{var a,l;return j_(ct((a=i.schedule)==null?void 0:a.scheduledTime),ct((l=s.schedule)==null?void 0:l.scheduledTime))})}),{scheduledMatchUps:r}}var zY=Object.defineProperty,YY=Object.defineProperties,KY=Object.getOwnPropertyDescriptors,qb=Object.getOwnPropertySymbols,QY=Object.prototype.hasOwnProperty,JY=Object.prototype.propertyIsEnumerable,zb=(t,e,r)=>e in t?zY(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ZY=(t,e)=>{for(var r in e||(e={}))QY.call(e,r)&&zb(t,r,e[r]);if(qb)for(var r of qb(e))JY.call(e,r)&&zb(t,r,e[r]);return t},XY=(t,e)=>YY(t,KY(e));function e7(t){var e,r,n,o,i,s,a,l,c,u,d;const{withScaleValues:p=!0,eventsPublishStatuses:v,withEvents:f=!0,withDraws:m=!0,participantIdMap:g,scheduleAnalysis:h,derivedDrawInfo:_,usePublishState:I,withStatistics:P,withOpponents:y,withMatchUps:S,withSeeding:O,participant:b,withISO2:w,withIOC:T}=t,E=[],N=[];if((T||w)&&Zu({participant:b,withIOC:T,withISO2:w}),p){const{ratings:Z,rankings:ee}=ga({participant:b});b.rankings=ee,b.ratings=Z}const $=b==null?void 0:b.participantId;if(!$||!g[$])return{};const{potentialMatchUps:A,opponents:U,matchUps:C,events:M,losses:D,draws:R,wins:j}=g[$],G=j+D,W=j,z=G&&W/G,F={statCode:Nl,denominator:G,numerator:W,statValue:z},L=Object.values(R),x=Object.values(M);if(m&&L){b.draws=L;for(const Z of L){const ee=(e=v[Z.eventId])==null?void 0:e.publishedSeeding;if(!I||(ee==null?void 0:ee.published)&&(((r=ee==null?void 0:ee.drawIds)==null?void 0:r.length)===0||((n=ee==null?void 0:ee.drawIds)==null?void 0:n.includes(Z.drawId)))){const te=Ad({drawId:Z.drawId,derivedDrawInfo:_,participantId:$});te&&(Z.seedAssignments=te)}}}if(f&&x&&(b.events=x,O)){const Z=Object.assign({},...(b.timeItems||[]).filter(({itemType:ee})=>ee.split(".")[1]===Sn).map(({itemType:ee,itemValue:ne})=>({[ee]:ne})));for(const ee of x){const ne=ae=>[ps,Sn,ee.eventType,ae].join("."),te=(o=v[ee.eventId])==null?void 0:o.publishedSeeding,oe=((te==null?void 0:te.stageSeedingScaleNames)&&Object.values(te==null?void 0:te.stageSeedingScaleNames)||Array.isArray(te==null?void 0:te.seedingScaleNames)&&te.seedingScaleNames||[]).map(ne),ie=Ht(Object.keys(Z),oe),le=!!(!I||!Object.keys(Z).length&&!((i=te==null?void 0:te.drawIds)!=null&&i.length)||ie.length);if(le&&ie.length){if(te!=null&&te.stageSeedingScaleNames){const ae=Object.keys(te.stageSeedingScaleNames).map(he=>{const de=ne(te.stageSeedingScaleNames[he]),Ce=Z[de];return[he,Ce]}).filter(he=>he[1]).map(he=>({[he[0]]:{seedValue:he[1]}})),Ie=Object.assign({},...ae);ee.seedAssignments=Ie}else if(ie){const ae=ie.map(Ie=>Z[Ie]);ee.seedValue=ae.pop()}}else if(!I&&typeof O=="object"){const ae=Object.keys(O).map(he=>{const de=ne(O[he]),Ce=Z[de];return[he,Ce]}).filter(he=>he[1]).map(he=>({[he[0]]:{seedValue:he[1]}})),Ie=Object.assign({},...ae);ee.seedAssignments=Ie}else{const{categoryName:ae,ageCategoryCode:Ie}=ee.category||{};let he;for(const de of[ee.eventId,Ie,ae]){const Ce={eventType:ee.eventType,scaleType:Sn,scaleName:de},se=_o({scaleAttributes:Ce,participant:b});if(se.scaleItem){he=se.scaleItem;break}}if(he){const de=he.scaleValue;(!I||(te==null?void 0:te.published)&&(((s=te==null?void 0:te.drawIds)==null?void 0:s.length)===0||((a=te==null?void 0:te.drawIds)==null?void 0:a.includes(ee.drawId))))&&(ee.seedValue=de)}}if((l=ee.drawIds)!=null&&l.length)for(const ae of ee.drawIds||[]){const Ie=((c=te==null?void 0:te.drawIds)==null?void 0:c.length)&&!((u=te==null?void 0:te.drawIds)!=null&&u.includes(ae));if(le&&!Ie){const he=Ad({drawId:ae,derivedDrawInfo:_,participantId:$});if(he&&ee.seedAssignments)for(const de of Object.keys(ee.seedAssignments))ee.seedAssignments[de]=he[de];else ee.seedAssignments=he}}}}const B=Object.values(U).flat();y&&(B!=null&&B.length)&&(b.opponents=B,L==null||L.forEach(Z=>{Z.opponents=B.filter(ee=>ee.drawId===Z.drawId)}));const H=Object.values(A),q=Object.values(C);S&&(b.potentialMatchUps=H,b.matchUps=q);const J=q.concat(H),K=((d=Hb({matchUps:J}))==null?void 0:d.scheduledMatchUps)||[],{scheduledMinutesDifference:Y}=h||{};return Object.keys(K).forEach(Z=>{K[Z].filter(Boolean).forEach((ee,ne)=>{var te,oe,ie,le;const{schedule:{scheduledTime:ae,timeAfterRecovery:Ie,typeChangeTimeAfterRecovery:he},matchUpStatus:de,roundPosition:Ce,structureName:se,matchUpType:ce,roundNumber:Se,matchUpId:je,drawId:Pe,score:Me}=ee;N.push(XY(ZY({},ee.schedule),{scheduledTime:ct((te=ee.schedule)==null?void 0:te.scheduledTime),roundPosition:Ce,structureName:se,matchUpType:ce,roundNumber:Se,matchUpId:je,drawId:Pe}));const Le=de===nt||[ot,et].includes(de)&&!Gt({score:Me});if(ae&&!Le){const Ye=xe(ae),Te=K[Z].slice(ne+1);for(const De of Te)if(!(De.matchUpStatus===nt||[ot,et].includes(De.matchUpStatus)&&!Gt(De))&&((oe=De.schedule)!=null&&oe.scheduledTime)){const ue=ee.matchUpType!==De.matchUpType&&he||Ie,we=ee.drawId===De.drawId,$e=ee.potential&&De.potential,at=xe((ie=De.schedule)==null?void 0:ie.scheduledTime)-Ye;(Y&&!isNaN(Y)?at<=Y:xe(ue)>xe((le=De.schedule)==null?void 0:le.scheduledTime))&&!($e&&we)&&E.push({priorScheduledMatchUpId:De.matchUpId,matchUpIdWithConflict:je})}}})}),P&&(b.statistics=[F]),{scheduleConflicts:E,scheduleItems:N}}function t7({eventEntries:t,sortConfig:e,event:r}){var n;const o={},i=Object.assign({},...((n=r.drawDefinitions)!=null?n:[]).map(s=>{var a,l,c,u,d,p,v,f,m;const g=Object.assign({},...(t??[]).filter(N=>N.participantId).map(N=>({[N.participantId]:N})),...s.entries.filter(N=>N.participantId).map(N=>({[N.participantId]:N}))),h=Object.values(g),_=(l=(a=un({stageSequence:1,drawDefinition:s,stage:ge}))==null?void 0:a.structures)==null?void 0:l[0],I=_&&((c=st({structure:_}))==null?void 0:c.positionAssignments),P=I==null?void 0:I.length,y=(d=(u=un({stageSequence:1,stage:be,drawDefinition:s}))==null?void 0:u.structures)==null?void 0:d[0],S=_&&((p=st({structure:y}))==null?void 0:p.positionAssignments),O=S==null?void 0:S.length,b=_==null?void 0:_.seedAssignments,w=y==null?void 0:y.seedAssignments,T=(s.structures||[]).sort((N,$)=>xi(N,$,e)).map(({structureId:N,structures:$})=>[N,...($||[]).map(({structureId:A})=>A)]).flat(1/0),E=(m=(f=(v=r==null?void 0:r._flightProfile)==null?void 0:v.flights)==null?void 0:f.find(N=>N.drawId===s.drawId))==null?void 0:m.flightNumber;return o[s.drawId]={qualifyingPositionAssignments:S,qualifyingSeedAssignments:w,mainPositionAssignments:I,mainSeedAssignments:b,orderedStructureIds:T,qualifyingDrawSize:O,flightNumber:E,drawSize:P},{[s.drawId]:{drawType:s.drawType,drawEntries:h}}}));return{derivedInfo:o,drawDetails:i}}function r7({relevantParticipantIdsMap:t,participantFilters:e,participantIdMap:r,derivedDrawInfo:n,eventDrawsCount:o,drawDetails:i,eventType:s,matchUp:a}){var l;const{collectionId:c,collectionPosition:u,drawId:d,drawName:p,eventId:v,eventName:f,finishingRound:m,finishingPositionRange:g,processCodes:h,loserTo:_,matchUpId:I,matchUpType:P,matchUpFormat:y,matchUpStatus:S,matchUpStatusCodes:O,matchUpTieId:b,roundName:w,roundNumber:T,roundPosition:E,score:N,sides:$,stage:A,stageSequence:U,schedule:C,structureName:M,structureId:D,tieFormat:R,tieMatchUps:j,tournamentId:G,winnerTo:W,winningSide:z}=a,F=e==null?void 0:e.participantIds,L=q=>{const J=q&&t[q]||[];return J.push(q),J.some(K=>!F||F.includes(K.relevantParticipantId))?J:[]},{winner:x,loser:B}=g||{},H=(j==null?void 0:j.length)&&j.filter(({matchUpType:q})=>q===_n).map(({sides:q})=>q.map(({sideNumber:J,participantId:K,participant:Y})=>J&&K&&{sideNumber:J,participantId:K,participant:Y})).flat().filter(Boolean)||[];if(s===co&&P===_n){const q=(((l=a.sides)==null?void 0:l.filter(Boolean))||[]).map(({sideNumber:J,participantId:K,participant:Y})=>J&&K&&{sideNumber:J,participantId:K,participant:Y}).filter(Boolean);H.push(...q)}if($==null||$.forEach(q=>{const{participantId:J,sideNumber:K}=q;if(!J)return;const{drawType:Y,drawEntries:Q}=i[d],Z=K===1?N==null?void 0:N.scoreStringSide1:N==null?void 0:N.scoreStringSide2,ee=z&&K===z,ne=a.sides.find(de=>de.sideNumber===3-K),te=ne==null?void 0:ne.participantId,oe=te&&t[te]||[],ie=ee?x:B,le=Q.find(de=>de.participantId===J),ae=L(J),Ie=[];H==null||H.filter(de=>de.sideNumber===K).forEach(de=>{const Ce=de.participantId;Ce&&!Ie.includes(Ce)&&(ae.push({relevantParticipantId:Ce,participantType:Ue}),Ie.push(Ce))});const he=ae.filter(de=>s!==co||s===co&&[_n,In].includes(P)&&[Ue,Yn].includes(de.participantType)||s===co&&[wi,_n].includes(P)&&[Fe].includes(de.participantType));he==null||he.forEach(({relevantParticipantId:de,participantType:Ce})=>{var se,ce;const{entryStage:Se,entryStatus:je,entryPosition:Pe}=le||{};if(!r[de])return;if(!r[de].draws[d]){const We=Lb({participantId:de,derivedDrawInfo:n,drawId:d}),me=Ad({participantId:de,derivedDrawInfo:n,drawId:d});r[de].draws[d]=ye({qualifyingDrawSize:(se=n[d])==null?void 0:se.qualifyingDrawSize,drawSize:(ce=n[d])==null?void 0:ce.drawSize,partnerParticipantIds:[],positionAssignments:We,seedAssignments:me,entryPosition:Pe,entryStatus:je,entryStage:Se,drawName:p,drawType:Y,eventId:v,drawId:d})}r[de].events[v]||(r[de].events[v]={partnerParticipantIds:[],drawIds:[],eventName:f,eventId:v});const Me=r[de].events[v].drawIds;Me&&!(Me!=null&&Me.includes(d))&&r[de].events[v].drawIds.push(d);let Le;if(Ce===Fe&&P===_n){const We=he.find(me=>me.relevantParticipantId!==de&&me.participantType===Fe);Le=We==null?void 0:We.relevantParticipantId}const Ye=(oe==null?void 0:oe.filter(We=>P===In&&Ce===Yn&&We.participantType===Yn||P===wi&&We.participantType===Fe||P===_n&&(Ce===Fe?[Fe,Ue].includes(We.participantType):We.participantType===Ue)))||[];Ye.forEach(({relevantParticipantId:We,participantType:me})=>{r[de].opponents||(r[de].opponents={}),r[de].opponents[We]={eventId:v,drawId:d,matchUpId:I,participantType:me,participantId:We}});const Te=Ye.map(({relevantParticipantId:We,participantType:me})=>({participantId:We,participantType:me}));(P!==In&&[Fe,Ue].includes(Ce)||P===In&&Ce===Yn)&&(r[de].matchUps[I]=ye({collectionId:c,collectionPosition:u,drawId:d,eventId:v,eventType:s,eventDrawsCount:o,finishingRound:m,finishingPositionRange:ie,loserTo:_,matchUpId:I,matchUpType:P,matchUpFormat:y,matchUpStatus:S,matchUpStatusCodes:O,matchUpTieId:b,opponentParticipantInfo:Te,participantWon:ee,partnerParticipantId:Le,perspectiveScoreString:Z,processCodes:h,roundName:w,roundNumber:T,roundPosition:E,schedule:C,score:N,sides:$,stage:A,stageSequence:U,structureName:M,structureId:D,tieFormat:R,tournamentId:G,winnerTo:W,winningSide:z})),Le&&(r[de].events[v].partnerParticipantIds.push(Le),r[de].draws[d].partnerParticipantIds.push(Le),r[de].events[v].partnerParticipantId=Le,r[de].draws[d].partnerParticipantId=Le),z&&(ee?r[de].wins++:r[de].losses++)})}),Array.isArray(a.potentialParticipants)){const q=ic(a.potentialParticipants.flat());q==null||q.forEach(J=>{const K=L(J);K==null||K.forEach(({relevantParticipantId:Y})=>{r[Y].potentialMatchUps[I]=ye({drawId:d,eventId:v,eventType:s,matchUpId:I,matchUpType:P,matchUpFormat:y,roundName:w,roundNumber:T,roundPosition:E,schedule:C,tieFormat:R,structureName:M,tournamentId:G,potential:!0})})})}}var n7=Object.defineProperty,o7=Object.defineProperties,i7=Object.getOwnPropertyDescriptors,Yb=Object.getOwnPropertySymbols,s7=Object.prototype.hasOwnProperty,a7=Object.prototype.propertyIsEnumerable,Kb=(t,e,r)=>e in t?n7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,_m=(t,e)=>{for(var r in e||(e={}))s7.call(e,r)&&Kb(t,r,e[r]);if(Yb)for(var r of Yb(e))a7.call(e,r)&&Kb(t,r,e[r]);return t},Im=(t,e)=>o7(t,i7(e));function l7(t){var e,r;const n=[],o={},i={},s={},a=f=>{s[f]||(s[f]={groupParticipantIds:[],teamParticipantIds:[],pairParticipantIds:[],potentialMatchUps:{},scheduleItems:[],opponents:{},matchUps:{},events:{},groups:[],teams:[],draws:{},losses:0,wins:0})},{tournamentRecord:l,participantFilters:c,allTournamentParticipants:u}=t,{relevantParticipantIdsMap:d}=HY({processParticipantId:a,tournamentRecord:l}),p=c==null?void 0:c.participantIds,v=f=>{const m=f&&d[f]||[];return m.push(f),m.some(g=>!p||p.includes(g.relevantParticipantId))?m:[]};return t.withGroupings&&u.forEach(f=>{var m,g,h;if(f.participantType===Cr){const _=f.participantId;(m=f==null?void 0:f.individualParticipantIds)==null||m.forEach(I=>{s[I].groupParticipantIds.includes(_)||(s[I].groupParticipantIds.push(_),s[I].groups.push({participantRoleResponsibilities:f.participantRoleResponsibilities,participantOtherName:f.participantOtherName,participantName:f.participantName,participantId:f.participantId}))})}if(f.participantType===Qe){const _=f.participantId;(g=f==null?void 0:f.individualParticipantIds)==null||g.forEach(I=>{var P,y,S,O;(y=(P=s[I])==null?void 0:P.teamParticipantIds)!=null&&y.includes(_)||((S=s[I])==null||S.teamParticipantIds.push(_),(O=s[I])==null||O.teams.push({participantRoleResponsibilities:f.participantRoleResponsibilities,participantOtherName:f.participantOtherName,participantName:f.participantName,participantId:f.participantId,teamId:f.teamId}))})}if(f.participantType===Ue){const _=f.participantId;(h=f==null?void 0:f.individualParticipantIds)==null||h.forEach(I=>{s[I]&&!s[I].pairParticipantIds.includes(_)&&s[I].pairParticipantIds.push(_)})}}),t.withMatchUps&&pn({tournamentRecord:l}),(t.withScheduleItems||t.scheduleAnalysis||t.withStatistics||t.withOpponents||t.withMatchUps||t.withSeeding||t.withEvents||t.withDraws)&&((e=t.tournamentEvents)==null||e.forEach(f=>{var m,g,h,_,I,P,y;const S=ve(f,!0,!0),O=Et({event:S}).flightProfile,b=((m=O==null?void 0:O.flights)==null?void 0:m.length)||((g=S.drawDefinitions)==null?void 0:g.length)||0;(S.drawDefinitions||[]).forEach((L,x)=>{if((S==null?void 0:S.eventType)===Qe){const{extension:B}=Kt({element:f.drawDefinitions[x],name:Gn});B&&(L.extensions=[B])}});const{eventId:w,eventName:T,eventType:E,category:N}=S,$={eventId:w,eventName:T,eventType:E,category:N},A=S&&Object.keys(S).filter(L=>L.startsWith("_"));A==null||A.forEach(L=>$[L]=S[L]);const U=S.entries||[],C=`${Hr}.${qr}`,{timeItem:M}=Ro({itemType:C,event:S});if((h=M==null?void 0:M.itemValue)!=null&&h.PUBLIC){const{drawIds:L=[],seeding:x}=M.itemValue.PUBLIC||{},B={published:void 0,seedingScaleNames:[],drawIds:[]};x&&Object.assign(B,M.itemValue.PUBLIC.seeding),o[w]={publishedDrawIds:L,publishedSeeding:B}}const R=[...Object.values(cI)].map(L=>`_${L}`),j=$&&Object.keys($).filter(L=>!R.includes(L)).reduce((L,x)=>(L[x]=$[x],L),{});U==null||U.filter(L=>L==null?void 0:L.participantId).forEach(L=>{const{participantId:x,entryStage:B,entryStatus:H,entryPosition:q}=L,J=v(x);J==null||J.forEach(({relevantParticipantId:K})=>{s[K]||a(K),s[K].events[w]=Im(_m({},j),{partnerParticipantIds:[],entryPosition:q,entryStatus:H,entryStage:B,drawIds:[],eventId:w})})});const G=({drawEntry:L,drawId:x})=>{const{participantId:B,entryStage:H,entryStatus:q,entryPosition:J}=L,K=v(B);K==null||K.forEach(({relevantParticipantId:Y})=>{var Q,Z;if(s[Y].events[w]||(s[Y].events[w]=Im(_m({},j),{partnerParticipantIds:[],entryPosition:J,entryStatus:q,entryStage:H,drawIds:[],eventId:w})),!s[Y].draws[x]){const ne=Lb({participantId:Y,derivedDrawInfo:i,drawId:x}),te=Ad({participantId:Y,derivedDrawInfo:i,drawId:x});s[Y].draws[x]=ye({qualifyingDrawSize:(Q=i[x])==null?void 0:Q.qualifyingDrawSize,drawSize:(Z=i[x])==null?void 0:Z.drawSize,partnerParticipantIds:[],positionAssignments:ne,eventDrawsCount:b,seedAssignments:te,entryPosition:J,entryStatus:q,entryStage:H,eventId:w,drawId:x})}const ee=s[Y].events[w].drawIds;ee&&!(ee!=null&&ee.includes(x))&&s[Y].events[w].drawIds.push(x)})},W=((_=S.drawDefinitions)==null?void 0:_.map(({drawId:L})=>L))||[];(P=(I=$._flightProfile)==null?void 0:I.flights)==null||P.forEach(L=>{const{drawId:x,drawEntries:B}=L;W.includes(x)||B==null||B.forEach(H=>G({drawEntry:H,drawId:x}))});const{drawDetails:z,derivedInfo:F}=t7({eventEntries:U,event:S});if(Object.assign(i,F),S.eventType===Qe||t.withScheduleItems||t.scheduleAnalysis||t.withStatistics||t.withOpponents||t.withMatchUps||t.withDraws){const L=(y=ui({afterRecoveryTimes:t.scheduleAnalysis,participants:u,nextMatchUps:!0,tournamentRecord:l,inContext:!0,event:S}))==null?void 0:y.matchUps;L==null||L.forEach(x=>r7({relevantParticipantIdsMap:d,participantFilters:c,participantIdMap:s,derivedDrawInfo:i,eventDrawsCount:b,drawDetails:z,eventType:E,matchUp:x}))}})),(r=t.tournamentParticipants)==null||r.forEach(f=>{const{scheduleConflicts:m,scheduleItems:g}=e7(Im(_m({},t),{eventsPublishStatuses:o,participantIdMap:s,derivedDrawInfo:i,participant:f}));if(t.withSignInStatus){const{timeItem:h}=Cn({itemType:Ll,element:f});f.signedIn=(h==null?void 0:h.itemValue)===Vl}if(t.withScheduleItems&&(f.scheduleItems=g),t.scheduleAnalysis&&(f.scheduleConflicts=m,m!=null&&m.length&&!n.includes(f.participantId)&&n.push(f.participantId)),t.withGroupings!==!1){const h=s[f.participantId];f.groupParticipantIds=h==null?void 0:h.groupParticipantIds,f.pairParticipantIds=h==null?void 0:h.pairParticipantIds,f.teamParticipantIds=h==null?void 0:h.teamParticipantIds,f.groups=h==null?void 0:h.groups,f.teams=h==null?void 0:h.teams}t.withTeamMatchUps}),{participantIdsWithConflicts:n,eventsPublishStatuses:o}}function Cd({participantFilters:t={},tournamentRecord:e,participants:r=[]}){var n;if(!Object.keys(t).length)return r;const{accessorValues:o,drawEntryStatuses:i,positionedParticipants:s,eventEntryStatuses:a,participantRoles:l,participantRoleResponsibilities:c,participantTypes:u,participantIds:d,signInStatus:p,enableOrFiltering:v,eventIds:f,genders:m}=t,g=Io(f)&&((n=e==null?void 0:e.events)==null?void 0:n.filter(y=>f==null?void 0:f.includes(y.eventId)))||(e==null?void 0:e.events)||[],h=i&&c7({drawEntryStatuses:i,tournamentEvents:g}),_=a&&u7({eventEntryStatuses:a,tournamentEvents:g}),I=s!==void 0&&[!0,!1].includes(s)&&g.reduce((y,S)=>y.concat(...(S.drawDefinitions||[]).map(O=>ay({drawDefinition:O}).allPositionedParticipantIds).filter(Boolean)),[]),P=y=>o==null?void 0:o.reduce((S,O)=>{const{accessor:b,value:w}=O,{values:T}=Td({element:y,accessor:b});return S&&(T==null?void 0:T.includes(w))},!0);if(r=r==null?void 0:r.filter(y=>{var S,O;const b=(O=(S=Cn({element:y,itemType:Ll}))==null?void 0:S.timeItem)==null?void 0:O.itemValue,{participantRoleResponsibilities:w,participantType:T,participantRole:E,participantId:N,person:$}=y,A=Array.isArray(m)&&(m==null?void 0:m.length)&&($==null?void 0:$.sex)&&m.includes($.sex);return v?m&&A||s&&I.includes(N)||s===!1&&!I.includes(N)||(h==null?void 0:h.includes(N))||(_==null?void 0:_.includes(N))||(d==null?void 0:d.includes(N))||p&&b===p||u&&T&&Io(u)&&u.includes(T)||l&&E&&Io(l)&&l.includes(E)||c&&Io(w)&&Io(c)&&c.find(U=>w==null?void 0:w.includes(U))||(o==null?void 0:o.length)&&Io(o)&&P(y):(!m||A)&&(s===void 0||s&&I.includes(N)||s===!1&&!I.includes(N))&&(!h||h.includes(N))&&(!_||_.includes(N))&&(!d||d.includes(N))&&(!p||b===p)&&(!u||T&&Io(u)&&u.includes(T))&&(!l||E&&Io(l)&&l.includes(E))&&(!c||Io(w)&&Io(c)&&c.find(U=>w==null?void 0:w.includes(U)))&&(!(o!=null&&o.length)||Io(o)&&P(y))}),g.length&&f){const y=g.filter(S=>f.includes(S.eventId)).map(S=>{const O=(S.entries||[]).map(w=>w.participantId);if(S.eventType===oi)return O;const b=((e==null?void 0:e.participants)||[]).filter(w=>O.includes(w.participantId)).map(w=>w.individualParticipantIds).flat(1);return O.concat(...b)}).flat(1);r=r==null?void 0:r.filter(S=>y.includes(S.participantId))}return r}function Io(t){return t&&Array.isArray(t)&&t.length}function c7({drawEntryStatuses:t,tournamentEvents:e}){const r=({entryStatus:n})=>Array.isArray(t)?t.includes(n):!0;return He(e.reduce((n,o)=>{var i,s;const{flightProfile:a}=Et({event:o}),l=((i=a==null?void 0:a.flights)==null?void 0:i.map(({drawEntries:u})=>Array.isArray(u)?u.filter(r).map(dt):[]).flat())||[],c=((s=o.drawDefinitions)==null?void 0:s.map(({entries:u})=>u?u.filter(r).map(dt):[]))||[];return n.concat(...l,...c)},[]))}function u7({eventEntryStatuses:t,tournamentEvents:e}){return He(e.reduce((r,n)=>{const o=(n.entries||[]).filter(({entryStatus:i})=>Array.isArray(t)?t.includes(i):!0).map(dt);return r.concat(...o)},[]))}function cr(t){const{participantFilters:e={},convertExtensions:r,policyDefinitions:n,withScheduleItems:o,scheduleAnalysis:i,withSignInStatus:s,withTeamMatchUps:a,tournamentRecord:l,usePublishState:c,withScaleValues:u,withStatistics:d,withGroupings:p,withOpponents:v,withMatchUps:f,withSeeding:m,withEvents:g,withDraws:h,inContext:_,withISO2:I,withIOC:P}=t;if(!l)return{error:re};if(!l.participants)return{error:gl};const y=l.participants.map(E=>ve(E,r));if(typeof e!="object")return{error:oo,participantFilters:e};_&&(y==null||y.forEach(E=>{var N;[Ue,rt,Cr].includes(E.participantType)&&(E.individualParticipants=(N=E.individualParticipantIds)==null?void 0:N.map($=>{const A=l.participants.find(C=>C.participantId===$),U=ve(A,r,!0);if(u){const{ratings:C,rankings:M}=ga({participant:U});U.ratings=C,U.rankings=M}return(P||I)&&Zu({participant:U,withISO2:I,withIOC:P}),U}))}));let S=e?Cd({participants:y,participantFilters:e,tournamentRecord:l}):y,O,b;if(o||s||i||u||d||p||v||f||m||g||h||I||P){const E=l7({tournamentEvents:l.events,allTournamentParticipants:y,tournamentParticipants:S,participantFilters:e,withScheduleItems:o,withSignInStatus:s,tournamentRecord:l,scheduleAnalysis:i,withTeamMatchUps:a,usePublishState:c,withScaleValues:u,withStatistics:d,withGroupings:p,withOpponents:v,withMatchUps:f,withSeeding:m,withEvents:g,withDraws:h,withISO2:I,withIOC:P});O=E==null?void 0:E.participantIdsWithConflicts,b=E==null?void 0:E.eventsPublishStatuses}const T=n==null?void 0:n[wl];return T!=null&&T.participant&&(S=S.map(E=>su({template:T.participant,source:E}))),{participantIdsWithConflicts:O,tournamentParticipants:S,eventsPublishStatuses:b}}const d7="ADMINISTRATION",p7="CAPTAIN",f7="COACH",ur="COMPETITOR",v7="MEDIA",m7="MEDICAL",Qb="OFFICIAL",Jb="OTHER",Zb={ADMINISTRATION:d7,CAPTAIN:p7,COACH:f7,COMPETITOR:ur,MEDIA:v7,MEDICAL:m7,OFFICIAL:Qb,OTHER:Jb,SECURITY:"SECURITY"};function Xb(t){return pd(t)}function Pm({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,scheduledDate:o,matchUpId:i}){return Yv({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,scheduledDate:o,matchUpId:i})}function ym({removePriorValues:t,tournamentRecord:e,drawDefinition:r,scheduledTime:n,disableNotice:o,matchUpId:i}){return Wi({removePriorValues:t,tournamentRecord:e,drawDefinition:r,scheduledTime:n,disableNotice:o,matchUpId:i})}function eT({tournamentRecord:t,drawDefinition:e,disableNotice:r,matchUpId:n,startTime:o}){return Qv({tournamentRecord:t,drawDefinition:e,disableNotice:r,matchUpId:n,startTime:o})}function tT({tournamentRecord:t,drawDefinition:e,disableNotice:r,matchUpId:n,endTime:o}){return Jv({tournamentRecord:t,drawDefinition:e,disableNotice:r,matchUpId:n,endTime:o})}function rT({tournamentRecord:t,drawDefinition:e,disableNotice:r,matchUpId:n,stopTime:o}){return Zv({tournamentRecord:t,drawDefinition:e,disableNotice:r,matchUpId:n,stopTime:o})}function nT({tournamentRecord:t,drawDefinition:e,disableNotice:r,resumeTime:n,matchUpId:o}){return Xv({tournamentRecord:t,drawDefinition:e,disableNotice:r,resumeTime:n,matchUpId:o})}function g7({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,courtOrder:o,matchUpId:i}){return Kv({removePriorValues:t,tournamentRecord:e,drawDefinition:r,disableNotice:n,courtOrder:o,matchUpId:i})}function oT({tournamentRecord:t,drawDefinition:e,disableNotice:r,participantId:n,officialType:o,matchUpId:i}){if(!n)return{error:Tt};const{tournamentParticipants:s}=cr({tournamentRecord:t,participantFilters:{participantTypes:[Fe],participantRoles:[Qb]}});return $o({tournamentParticipants:s,participantId:n})?NS({drawDefinition:e,disableNotice:r,participantId:n,officialType:o,matchUpId:i}):{error:Dt}}var h7=Object.defineProperty,_7=Object.defineProperties,I7=Object.getOwnPropertyDescriptors,iT=Object.getOwnPropertySymbols,P7=Object.prototype.hasOwnProperty,y7=Object.prototype.propertyIsEnumerable,sT=(t,e,r)=>e in t?h7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sm=(t,e)=>{for(var r in e||(e={}))P7.call(e,r)&&sT(t,r,e[r]);if(iT)for(var r of iT(e))y7.call(e,r)&&sT(t,r,e[r]);return t},S7=(t,e)=>_7(t,I7(e));function aT({tournamentRecord:t,scheduleChange:e,matchUpIds:r,dryRun:n}){if(!t)return{error:re};if(!r||!Array.isArray(r))return{error:ml};if(typeof e!="object")return{error:X};const o=[],i=[],{minutesChange:s,daysChange:a}=e;if(!s&&!a)return Sm({},V);if(s&&isNaN(s))return{error:X};if(a&&isNaN(a))return{error:X};const{matchUps:l}=Wt({matchUpFilters:{matchUpIds:r},tournamentRecord:t}),c=({matchUpStatus:P})=>!Yt.includes(P),u=l==null?void 0:l.filter(P=>Sc({schedule:P.schedule})).filter(P=>c({matchUpStatus:P.matchUpStatus}));if(!(u!=null&&u.length))return Sm({},V);const{tournamentInfo:d}=Oc({tournamentRecord:t}),{startDate:p,endDate:v}=d,f=u==null?void 0:u.reduce((P,y)=>{const{matchUpId:S,drawId:O}=y;return P[O]?P[O].push(S):P[O]=[S],P},{}),m=1440;for(const P of Object.keys(f)){const y=Xo({tournamentRecord:t,drawId:P});if(y.error)return y;const S=y.drawDefinition,O=f[P].filter(b=>r.includes(b));for(const b of O)if(b&&S){const w=u.find(C=>C.matchUpId===b),T=w==null?void 0:w.schedule,{scheduledTime:E,scheduledDate:N}=T;let $,A,U;if(!$&&a&&N){const C=Re(N);U=kL(C,a),$=new Date(U)<new Date(p)||new Date(U)>new Date(v)}if(s&&E){const C=Re(E),D=xe(ct(E))+s;if($=D<0||D>m,!$){const R=Sr(E,s);A=C&&U?`${U}T${R}`:R}}if($)i.push(b);else{if(!n){if(A){const C=ym({scheduledTime:A,drawDefinition:S,matchUpId:b});if(C.error)return C}if(U){const C=Pm({scheduledDate:U,drawDefinition:S,matchUpId:b});if(C.error)return C}}(A||U)&&o.push(b)}}}const g=Wt({matchUpFilters:{matchUpIds:r},tournamentRecord:t}).matchUps||[],h=g.filter(({matchUpId:P})=>o.includes(P)),_=g.filter(({matchUpId:P})=>i.includes(P)),I=h.length&&!_.length;return S7(Sm({},V),{rescheduled:h,notRescheduled:_,allRescheduled:I})}var O7=Object.defineProperty,b7=Object.defineProperties,T7=Object.getOwnPropertyDescriptors,lT=Object.getOwnPropertySymbols,w7=Object.prototype.hasOwnProperty,E7=Object.prototype.propertyIsEnumerable,cT=(t,e,r)=>e in t?O7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,$7=(t,e)=>{for(var r in e||(e={}))w7.call(e,r)&&cT(t,r,e[r]);if(lT)for(var r of lT(e))E7.call(e,r)&&cT(t,r,e[r]);return t},N7=(t,e)=>b7(t,T7(e));function U7({tournamentRecords:t,scheduleChange:e,matchUpIds:r,dryRun:n}){var o,i;if(!r||!Array.isArray(r))return{error:ml};if(typeof e!="object")return{error:X};const s=[];let a=[];for(const c of Object.values(t)){const u=aT({tournamentRecord:c,scheduleChange:e,matchUpIds:r,dryRun:n});if(u.error)return u;Array.isArray(u.notRescheduled)&&a.push(...u.notRescheduled);const d=_v(u.notRescheduled),p=[];(o=u.rescheduled)==null||o.forEach(v=>{const{matchUpId:f}=v;d.includes(f)&&p.push(f),s.push(v)}),p.length&&(a=((i=u==null?void 0:u.notRescheduled)==null?void 0:i.filter(({matchUpId:v})=>!p.includes(v)))||[])}const l=!!(s.length&&!a.length);return N7($7({},V),{rescheduled:s,notRescheduled:a,allRescheduled:l})}function uT({tournamentRecord:t,dailyLimits:e}){return t?typeof e!="object"?{error:oo}:Ni({extension:{name:as,value:{dailyLimits:e}},tournamentRecord:t}):{error:re}}var A7=Object.defineProperty,dT=Object.getOwnPropertySymbols,C7=Object.prototype.hasOwnProperty,M7=Object.prototype.propertyIsEnumerable,pT=(t,e,r)=>e in t?A7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,D7=(t,e)=>{for(var r in e||(e={}))C7.call(e,r)&&pT(t,r,e[r]);if(dT)for(var r of dT(e))M7.call(e,r)&&pT(t,r,e[r]);return t};function j7({tournamentRecords:t,tournamentId:e,dailyLimits:r}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const n=Object.keys(t).filter(o=>!e||e===o);if(e&&!n.includes(e))return{error:X};for(const o of n){const i=t[o],s=uT({tournamentRecord:i,dailyLimits:r});if(s.error)return s}return D7({},V)}var R7=Object.defineProperty,F7=Object.defineProperties,x7=Object.getOwnPropertyDescriptors,fT=Object.getOwnPropertySymbols,L7=Object.prototype.hasOwnProperty,V7=Object.prototype.propertyIsEnumerable,vT=(t,e,r)=>e in t?R7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,B7=(t,e)=>{for(var r in e||(e={}))L7.call(e,r)&&vT(t,r,e[r]);if(fT)for(var r of fT(e))V7.call(e,r)&&vT(t,r,e[r]);return t},k7=(t,e)=>F7(t,x7(e));function G7({extensionConversions:t,seedAssignments:e,participant:r,withSeeding:n,seedValue:o,eventId:i,ranking:s,entry:a}){const{entryStatus:l,entryStage:c,entryPosition:u,extensions:d}=a,p=d!=null&&d.length?Object.assign({},...yf(d)):{},v=Object.assign(p,k7(B7({},t),{entryPosition:u,entryStatus:l,entryStage:c,ranking:s,eventId:i}));r.events[i]=ye(v,!1,!1,!0),n&&(e&&(r.events[i].seedAssignments=e),o&&(r.events[i].seedValue=o))}var W7=Object.defineProperty,H7=Object.defineProperties,q7=Object.getOwnPropertyDescriptors,mT=Object.getOwnPropertySymbols,z7=Object.prototype.hasOwnProperty,Y7=Object.prototype.propertyIsEnumerable,gT=(t,e,r)=>e in t?W7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,K7=(t,e)=>{for(var r in e||(e={}))z7.call(e,r)&&gT(t,r,e[r]);if(mT)for(var r of mT(e))Y7.call(e,r)&&gT(t,r,e[r]);return t},Q7=(t,e)=>H7(t,q7(e));function hT(t){const{participantMap:e,participantId:r,matchUpStatus:n,roundPosition:o,structureId:i,matchUpType:s,roundNumber:a,matchUpId:l,potential:c,schedule:u,drawId:d,score:p}=t;if(!u||!Object.keys(u).length)return;n===nt||e[r].scheduleItems.push(Q7(K7({},u),{scheduledDate:Re(u==null?void 0:u.scheduledDate),scheduledTime:ct(u==null?void 0:u.scheduledTime),scoreHasValue:Gt({score:p}),matchUpStatus:n,roundPosition:o,structureId:i,matchUpType:s,roundNumber:a,matchUpId:l,potential:c,drawId:d}))}function J7({finishingPositionRange:t={},participantMap:e,finishingRound:r,participantWon:n,matchUpStatus:o,participantId:i,stageSequence:s,roundNumber:a,structureId:l,matchUpId:c,drawId:u,stage:d}){const p=e[i],v=_=>Math.abs(_[0]-_[1]);p.structureParticipation[l]||(p.structureParticipation[l]={rankingStage:d,walkoverWinCount:0,defaultWinCount:0,stageSequence:s,winCount:0,structureId:l,drawId:u});const f=p.structureParticipation[l],{winner:m,loser:g}=t,h=n?m:g;n&&(f.winCount+=1,o===ot&&(f.walkoverWinCount+=1),o===et&&(f.defaultWinCount+=1)),h&&(!f.finishingPositionRange||v(h)<v(f.finishingPositionRange))&&(f.finishingPositionRange=h),r&&((!f.finishingRound||r<f.finishingRound)&&(f.finishingMatchUpId=c,f.finishingRound=r,f.roundNumber=a),r===1&&(f.participantWon=n))}function _T(t){var e,r,n,o,i,s,a,l,c,u;const{withScheduleTimes:d,scheduleAnalysis:p,withTeamMatchUps:v,participantMap:f,withOpponents:m,withMatchUps:g,withEvents:h,withDraws:_,finishingPositionRange:I,finishingRound:P,matchUpStatus:y,stageSequence:S,roundNumber:O,structureId:b,score:w,stage:T,withRankingProfile:E,tieWinningSide:N,roundPosition:$,matchUpTieId:A,matchUpSides:U,collectionId:C,matchUpType:M,winningSide:D,matchUpId:R,schedule:j,eventId:G,drawId:W,sides:z}=t,F=m&&(z==null?void 0:z.length)===2&&Object.assign({},...z.map(({sideNumber:L},x)=>{const B=z[1-x].participantId;return L&&{[L]:B}}).filter(Boolean));for(const L of z){const{participantId:x,sideNumber:B,bye:H}=L;if(H)continue;const q=D===B,J=Z=>{var ee,ne;const te=(ee=f[Z])==null?void 0:ee.participant,oe=te==null?void 0:te.participantType,ie=[{participantId:Z,participantType:oe}];if(oe!==Yn)for(const le of(te==null?void 0:te.individualParticipantIds)||[]){const ae=(ne=f[le])==null?void 0:ne.participant;ie.push({participantType:ae==null?void 0:ae.participantType,participantId:le})}return ie},K=(Z,ee)=>{if(g){if(f[Z].matchUps[R]={participantWon:q,matchUpType:M,structureId:b,sideNumber:B,matchUpId:R,eventId:G,drawId:W},m){const ne=J(ee);f[Z].matchUps[R].opponentParticipantInfo=ne}C&&(f[Z].matchUps[R].collectionId=C)}E&&J7({finishingPositionRange:I,participantMap:f,participantWon:q,finishingRound:P,matchUpStatus:y,participantId:Z,stageSequence:S,roundNumber:O,structureId:b,matchUpId:R,drawId:W,stage:T}),(p||d)&&hT({participantMap:f,participantId:Z,matchUpStatus:y,roundPosition:$,matchUpType:M,roundNumber:O,structureId:b,matchUpId:R,schedule:j,drawId:W,score:w})},Y=(Z,ee)=>{Z&&(Z.partnerParticipantIds||(Z.partnerParticipantIds=[]),Z.partnerParticipantIds.includes(ee)||Z.partnerParticipantIds.push(ee))},Q=({participantId:Z,partnerParticipantId:ee})=>{var ne,te,oe,ie,le,ae;_&&Y((te=(ne=f[Z])==null?void 0:ne.draws)==null?void 0:te[W],ee),h&&Y((ie=(oe=f[Z])==null?void 0:oe.events)==null?void 0:ie[G],ee),g&&Y((ae=(le=f[Z])==null?void 0:le.matchUps)==null?void 0:ae[R],ee)};if(x&&f[x]){const Z=F==null?void 0:F[B];K(x,Z),m&&Z&&(f[x].opponents[Z]={participantId:Z,matchUpId:R,eventId:G,drawId:W});const ee=((e=f[x])==null?void 0:e.participant.participantType)===Ue,ne=((r=f[x])==null?void 0:r.participant.individualParticipantIds)||[];if(A){if(v){const te=oe=>f[oe].matchUps[A]={participantWon:N===B,matchUpType:Ar.Team,matchUpId:A,sideNumber:B};te(x),ne.forEach(te)}if(_&&!f[x].draws[W]){const te=(o=(n=U.find(le=>le.sideNumber===B))==null?void 0:n.participant)==null?void 0:o.participantId,oe=(a=(s=(i=f[te])==null?void 0:i.draws)==null?void 0:s[W])==null?void 0:a.entryStatus,ie=le=>f[le].draws[W]={entryStatus:oe,eventId:G,drawId:W};ie(x),ne.forEach(ie)}}if(ee&&(ne.forEach(te=>f[te]&&K(te,Z)),ne.forEach((te,oe)=>{const ie=ne[1-oe];Q({participantId:te,partnerParticipantId:ie})}),h&&U)){const te=(c=(l=U.find(oe=>oe.sideNumber===B))==null?void 0:l.participant)==null?void 0:c.participantId;if(te){const oe=(u=f[te])==null?void 0:u.events[G];oe?(f[x].events[G]=oe,ne.forEach(ie=>f[ie].events[G]=oe)):console.log("Missing teamEntry",{eventId:G,teamParticipantId:te})}}if(D){const te=oe=>{q?(f[oe].counters[M].wins+=1,f[oe].counters.wins+=1,y===ot&&(f[oe].counters[M].walkoverWins+=1,f[oe].counters.walkoverWins+=1),y===et&&(f[oe].counters[M].defaultWins+=1,f[oe].counters.defaultWins+=1)):(f[oe].counters[M].losses+=1,f[oe].counters.losses+=1,y===ot&&(f[oe].counters[M].walkovers+=1,f[oe].counters.walkovers+=1),y===et&&(f[oe].counters[M].defaults+=1,f[oe].counters.defaults+=1))};te(x),ne.forEach(te)}}}}var Z7=Object.defineProperty,X7=Object.defineProperties,eK=Object.getOwnPropertyDescriptors,IT=Object.getOwnPropertySymbols,tK=Object.prototype.hasOwnProperty,rK=Object.prototype.propertyIsEnumerable,PT=(t,e,r)=>e in t?Z7(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ha=(t,e)=>{for(var r in e||(e={}))tK.call(e,r)&&PT(t,r,e[r]);if(IT)for(var r of IT(e))rK.call(e,r)&&PT(t,r,e[r]);return t},Md=(t,e)=>X7(t,eK(e));function nK(t){var e,r,n,o,i;const{participantFilters:s,convertExtensions:a,policyDefinitions:l,tournamentRecord:c,usePublishState:u,contextProfile:d,participantMap:p,withPotentialMatchUps:v,withRankingProfile:f,withScheduleTimes:m,withScheduleItems:g,scheduleAnalysis:h,withTeamMatchUps:_,withStatistics:I,withOpponents:P,withMatchUps:y,withSeeding:S,withEvents:O,withDraws:b}=t;g&&console.log({withScheduleItems:g});const w=s==null?void 0:s.participantIds,T=R=>{var j,G;const W=[R];return W.push(R),(G=(j=p[R])==null?void 0:j.participant.individualParticipantIds)==null||G.forEach(z=>W.push(z)),W.some(z=>!(w!=null&&w.length)||w.includes(z.relevantParticipantId))?W:[]},E={withMatchUps:y||f,withEvents:O||f,withDraws:b||f,withPotentialMatchUps:v,withRankingProfile:f,withScheduleTimes:m,scheduleAnalysis:h,withTeamMatchUps:_,withStatistics:I,participantMap:p,withOpponents:P,withSeeding:S},N=[],$={},A=[],U={},C={},M={},D=({eventType:R,scaleNames:j,participantId:G})=>{var W,z,F,L;return(L=(F=(z=(W=p[G].participant)==null?void 0:W.rankings)==null?void 0:z[R])==null?void 0:F.find(x=>j.includes(x.scaleName)))==null?void 0:L.scaleValue};for(const R of(c==null?void 0:c.events)||[]){if(s!=null&&s.eventIds&&!s.eventIds.includes(R.eventId))continue;const{drawDefinitions:j=[],extensions:G,eventType:W,eventName:z,category:F,entries:L,eventId:x,gender:B}=R,{flightProfile:H}=Et({event:R}),q=H==null?void 0:H.flights,J=bY({event:R}),K=J==null?void 0:J.publishedSeeding;if(J&&(U[x]=J),O||S||f){const Y=a?Object.assign({},...yf(G)):{};C[x]=Md(Ha({},Y),{eventName:z,eventType:W,category:F,eventId:x,gender:B});const Q=[F==null?void 0:F.categoryName,F==null?void 0:F.ageCategoryCode].filter(Boolean);for(const Z of L){const{participantId:ee}=Z;if(!ee||!p[ee])continue;const ne=D({eventType:W,scaleNames:Q,participantId:ee});let te,oe;if(S){const ae=p[ee].participant;({seedAssignments:te,seedValue:oe}=TY({publishedSeeding:K,usePublishState:u,withSeeding:S,participant:ae,event:R}))}const ie=ae=>{var Ie;if((Ie=p[ae])!=null&&Ie.events[x])return;const he=p[ae];G7({extensionConversions:Y,seedAssignments:te,participant:he,withSeeding:S,seedValue:oe,eventId:x,ranking:ne,entry:Z})};ie(ee),(p[ee].participant.individualParticipantIds||[]).forEach(ie)}}if(b||f||S){const Y=Q=>Q?Object.assign({},...Q.map(Z=>({[Z.participantId]:Z}))):void 0;for(const Q of j){const{structures:Z=[],drawOrder:ee,drawName:ne,drawType:te,entries:oe,drawId:ie}=Q,le=(e=q==null?void 0:q.find(Te=>Te.drawId===ie))==null?void 0:e.flightNumber,ae=[F==null?void 0:F.categoryName,F==null?void 0:F.ageCategoryCode].filter(Boolean),Ie=(Q.structures||[]).sort((Te,De)=>xi(Te,De)).map(({structureId:Te,structures:De})=>[Te,...(De||[]).map(({structureId:We})=>We)]).flat(1/0);let he,de,Ce,se,ce=0;const Se=Z.filter(({stage:Te,stageSequence:De})=>Te===ge&&De===1||Te===be).flatMap(Te=>{const{seedAssignments:De,stageSequence:We,stage:me}=Te,{positionAssignments:ue}=st({structure:Te});return me===ge?(ce=(ue==null?void 0:ue.length)||0,Ce=ue,se=De):We===1&&(he=ue,de=De),ue}).map(({participantId:Te})=>Te).filter(Boolean),je=Y(se),Pe=Y(de),Me=oe.filter(({participantId:Te})=>Se.includes(Te)),Le=(r=U[x])==null?void 0:r.publishedSeeding,Ye=!u||(Le==null?void 0:Le.published)&&(((n=Le==null?void 0:Le.drawIds)==null?void 0:n.length)===0||((o=Le==null?void 0:Le.drawIds)==null?void 0:o.includes(ie)));for(const Te of Me){const{entryStatus:De,entryStage:We,entryPosition:me,participantId:ue}=Te,we=D({participantId:ue,scaleNames:ae,eventType:W}),$e=Ae=>{var at,Xe,Mt,Lt;if(p[Ae].draws[ie])return;const Be=S&&Ye,lt=Be?{}:void 0,Ve=Be?((at=je==null?void 0:je[ue])==null?void 0:at.seedValue)||((Xe=je==null?void 0:je[ue])==null?void 0:Xe.seedNumber):void 0,It=Be?((Mt=Pe==null?void 0:Pe[ue])==null?void 0:Mt.seedValue)||((Lt=Pe==null?void 0:Pe[ue])==null?void 0:Lt.seedNumber):void 0;lt&&Ve&&(lt[ge]=Ve),lt&&It&&(lt[be]=Ve),(O||f)&&(Be?p[Ae].events[x].seedValue=Ve||It:p[Ae].events[x].seedValue&&(p[Ae].events[x].seedValue=void 0)),(b||f)&&(p[Ae].draws[ie]=ye({seedAssignments:lt,entryPosition:me,entryStatus:De,entryStage:We,eventId:x,ranking:we,drawId:ie},!1,!1,!0))};if(![Nn,Ss].includes(De)){$e(ue);const Ae=p[ue].participant.individualParticipantIds||[];Ae==null||Ae.forEach($e)}}M[ie]={qualifyingPositionAssignments:he,qualifyingSeedAssignments:de,mainPositionAssignments:Ce,qualifyingSeedingMap:Pe,mainSeedAssignments:se,orderedStructureIds:Ie,mainSeedingMap:je,flightNumber:le,drawOrder:ee,drawName:ne,drawType:te,drawSize:ce,drawId:ie}}}if(f||h||_||I||P||y||b){const Y=!!h||v,Q=((i=ui({afterRecoveryTimes:!!h,policyDefinitions:l,tournamentRecord:c,inContext:!0,contextProfile:d,participantMap:p,nextMatchUps:Y,event:R}))==null?void 0:i.matchUps)||[];for(const Z of Q){const{finishingPositionRange:ee,potentialParticipants:ne,tieMatchUps:te=[],sides:oe=[],winningSide:ie,matchUpType:le,matchUpId:ae,eventId:Ie,drawId:he,collectionId:de,stageSequence:Ce,finishingRound:se,matchUpStatus:ce,roundPosition:Se,roundNumber:je,structureId:Pe,schedule:Me,score:Le,stage:Ye}=Z;$[ae]=Z;const Te={finishingPositionRange:ee,finishingRound:se,stageSequence:Ce,roundPosition:Se,collectionId:de,roundNumber:je,structureId:Pe,schedule:Me,eventId:Ie,drawId:he,score:Le,stage:Ye};_T(Md(Ha(Ha({},Te),E),{matchUpStatus:ce,winningSide:ie,matchUpType:le,matchUpId:ae,sides:oe}));for(const De of te){const{winningSide:We,sides:me=[],matchUpId:ue,matchUpStatus:we,matchUpType:$e}=De;_T(Md(Ha(Ha({},Te),E),{winningSide:We,tieWinningSide:ie,matchUpTieId:ae,matchUpId:ue,sides:me,matchUpSides:oe,matchUpStatus:we,matchUpType:$e}))}if(Array.isArray(ne)&&(Y||h||m)){const De=ne.flat().map(sn("participantId")).filter(Boolean);De==null||De.forEach(We=>{const me=T(We);me==null||me.forEach(ue=>{p[ue]&&(p[ue].potentialMatchUps[ae]=ye({tournamentId:c==null?void 0:c.tournamentId,matchUpId:ae,eventId:Ie,drawId:he}))}),(h||m)&&hT({potential:!0,participantMap:p,participantId:We,matchUpStatus:ce,roundPosition:Se,structureId:Pe,matchUpType:le,roundNumber:je,matchUpId:ae,schedule:Me,drawId:he,score:Le})})}}A.push(...Q)}}if(I||f||h){const R=Object.values(p);for(const j of R){const{wins:G,losses:W,[Nt]:{wins:z,losses:F},[ft]:{wins:L,losses:x}}=j.counters,B=(H,q,J)=>{const K=q+J,Y=q,Q=K&&Y/K;j.statistics[H]={denominator:K,numerator:Y,statValue:Q,statCode:H}};if(I&&(B(Nl,G,W),B(`${Nl}.${Nt}`,z,F),B(`${Nl}.${ft}`,L,x)),f){const H=(q=[])=>Math.abs(q[0]-q[1]);for(const q of Object.keys(j.draws)){const{orderedStructureIds:J=[],flightNumber:K}=M[q]||{};if(j.structureParticipation&&J.length){let Y,Q=0;const Z=J.map(ee=>{const ne=j.structureParticipation[ee];if(!ne)return;Y||(Y=ne.finishingPositionRange),H(Y)>H(ne.finishingPositionRange)&&(Y=ne.finishingPositionRange);const te=ne.stage!==be;te&&(Q+=1);const oe=te?Q:void 0;return ye(Md(Ha({},ne),{participationOrder:oe,flightNumber:K}))}).filter(Boolean);j.draws[q].finishingPositionRange=Y,j.draws[q].structureParticipation=Z}}}if(h){const H=ns(h)?h.scheduledMinutesDifference:0,q=j.scheduleItems||[],J=j.potentialMatchUps||{},K=q.reduce((Q,Z)=>{const{scheduledDate:ee,scheduledTime:ne}=Z;return Q[ee]||(Q[ee]=[]),ne&&Q[ee].push(Z),Q},{});Object.values(K).forEach(Q=>Q.sort(j_));for(const Q of q){const{typeChangeTimeAfterRecovery:Z,timeAfterRecovery:ee,scheduledDate:ne,scheduledTime:te}=Q,oe=K[ne],ie=xe(te);for(const le of oe){if(le.matchUpId===Q.matchUpId||[ot,et].includes(le.matchUpStatus)&&!le.scoreHasValue)continue;const he=Q.matchUpType!==le.matchUpType&&Z||ee,de=Q.drawId===le.drawId,Ce=J[Q.matchUpId]&&J[le.matchUpId],se=xe(le.scheduledTime),ce=Math.abs(se-ie);(H&&!isNaN(H)?ce<=H:xe(he)>xe(le.scheduledTime))&&!(Ce&&de)&&j.scheduleConflicts.push({priorScheduledMatchUpId:le.matchUpId,matchUpIdWithConflict:Q.matchUpId})}}const Y=j.participant.participantId;j.scheduleConflicts.length&&N.push(Y),p[Y].scheduleConflicts=j.scheduleConflicts}}}return{participantIdsWithConflicts:N,eventsPublishStatuses:U,derivedEventInfo:C,derivedDrawInfo:M,mappedMatchUps:$,participantMap:p,matchUps:A}}var oK=Object.defineProperty,iK=Object.defineProperties,sK=Object.getOwnPropertyDescriptors,yT=Object.getOwnPropertySymbols,aK=Object.prototype.hasOwnProperty,lK=Object.prototype.propertyIsEnumerable,ST=(t,e,r)=>e in t?oK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,OT=(t,e)=>{for(var r in e||(e={}))aK.call(e,r)&&ST(t,r,e[r]);if(yT)for(var r of yT(e))lK.call(e,r)&&ST(t,r,e[r]);return t},bT=(t,e)=>iK(t,sK(e));function Vs(t){const{withIndividualParticipants:e,participantFilters:r={},withPotentialMatchUps:n,withRankingProfile:o,convertExtensions:i,policyDefinitions:s,withScheduleItems:a,tournamentRecord:l,scheduleAnalysis:c,withSignInStatus:u,withTeamMatchUps:d,withScaleValues:p,usePublishState:v,contextProfile:f,withStatistics:m,withOpponents:g,withMatchUps:h,internalUse:_,withSeeding:I,withEvents:P,withDraws:y,withISO2:S,withIOC:O}=t;if(!l)return{error:re};(h||o)&&pn({tournamentRecord:l});let{participantMap:b}=k0({withIndividualParticipants:e,convertExtensions:i,policyDefinitions:s,tournamentRecord:l,withSignInStatus:u,withScaleValues:p,internalUse:_,withISO2:S,withIOC:O});const w=nK({withMatchUps:h||o,withEvents:P||o,withDraws:y||o,withPotentialMatchUps:n,participantFilters:r,withRankingProfile:o,convertExtensions:i,withScheduleItems:a,policyDefinitions:s,tournamentRecord:l,scheduleAnalysis:c,withTeamMatchUps:d,usePublishState:v,withStatistics:m,participantMap:b,withOpponents:g,contextProfile:f,withSeeding:I}),{participantIdsWithConflicts:T,eventsPublishStatuses:E,derivedEventInfo:N,derivedDrawInfo:$,mappedMatchUps:A}=w,U=w.matchUps;b=w.participantMap;const C=c||n,M=Object.values(b).map(({potentialMatchUps:R,scheduleConflicts:j,participant:G,statistics:W,opponents:z,matchUps:F,events:L,draws:x})=>{const B=Object.values(x),H=Object.values(z);return g&&(B==null||B.forEach(q=>{q.opponents=H.filter(J=>J.drawId===q.drawId)})),ye(bT(OT({},G),{scheduleConflicts:c?j:void 0,draws:y||o?B:void 0,events:P||o?Object.values(L):void 0,matchUps:h||o?Object.values(F):void 0,opponents:g?H:void 0,potentialMatchUps:C?Object.values(R):void 0,statistics:m?Object.values(W):void 0}),!1,!1,!0)}),D=Cd({participants:M,participantFilters:r,tournamentRecord:l});return bT(OT({participantIdsWithConflicts:T,eventsPublishStatuses:E,derivedEventInfo:N,derivedDrawInfo:$,mappedMatchUps:A,participantMap:b,participants:D},V),{matchUps:U})}function Om(t,e,r){return!t&&e?e:t&&!e||typeof t!="object"||typeof e!="object"?t:He(Object.keys(t).concat(Object.keys(e))).reduce((o,i)=>{if(!e[i])o[i]=t[i];else if(!t[i])o[i]=e[i];else if(typeof t[i]!=typeof e[i])o[i]=e[i];else if(Array.isArray(t[i]))if(r===!0||Array.isArray(r)&&r.includes(i)){const s=He(t[i].map(a=>JSON.stringify(a)).concat(e[i].map(a=>JSON.stringify(a)))).map(a=>JSON.parse(a));o[i]=s}else o[i]=e[i];else typeof t[i]=="object"?o[i]=Om(t[i],e[i],r):o[i]=e[i];return o},{})}var cK=Object.defineProperty,uK=Object.defineProperties,dK=Object.getOwnPropertyDescriptors,TT=Object.getOwnPropertySymbols,pK=Object.prototype.hasOwnProperty,fK=Object.prototype.propertyIsEnumerable,wT=(t,e,r)=>e in t?cK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,bc=(t,e)=>{for(var r in e||(e={}))pK.call(e,r)&&wT(t,r,e[r]);if(TT)for(var r of TT(e))fK.call(e,r)&&wT(t,r,e[r]);return t},vK=(t,e)=>uK(t,dK(e));function mK(t){const{tournamentRecords:e}=t||{};if(typeof e!="object"||!Object.keys(e).length)return{error:ke};const r={},n=[],o={},i={},s=[],a={},l=[];for(const c of Object.values(e)){const{participantIdsWithConflicts:u,mappedMatchUps:d,participantMap:p,participants:v,matchUps:f,derivedEventInfo:m,derivedDrawInfo:g}=Vs(bc({tournamentRecord:c},t));Object.assign(a,d),Object.assign(r,p),Object.assign(o,m),Object.assign(i,g),n.push(...v??[]),s.push(...f??[]),u==null||u.forEach(h=>{l.includes(h)||l.push(h)})}return vK(bc({participantIdsWithConflicts:l,derivedEventInfo:o,derivedDrawInfo:i,participantMap:r,mappedMatchUps:a,participants:n},V),{matchUps:s})}function gK(t){const{tournamentRecords:e}=t||{};if(typeof e!="object"||!Object.keys(e).length)return{error:ke};let r=[];const n=[],o=[];for(const i of Object.values(e)){const{tournamentParticipants:s,participantIdsWithConflicts:a}=cr(bc({tournamentRecord:i},t));for(const l of s){const{participantId:c}=l;o.includes(c)?r=r.map(u=>u.participantId!==c?u:Om(u,l,!0)):(o.push(c),r.push(l))}a==null||a.forEach(l=>{n.includes(l)||n.push(l)})}return bc({competitionParticipants:r,participantIdsWithConflicts:n},V)}function ET({policyDefinitions:t,tournamentRecords:e,participantId:r,inContext:n,personId:o}){if(!e)return{error:ke};if(typeof r!="string"&&typeof o!="string")return{error:_e,stack:"publicFindParticipant"};let i,s;for(const a of Object.values(e)){s=a.tournamentId;const{tournamentParticipants:l}=cr({policyDefinitions:t,tournamentRecord:a,inContext:n});if(i=$o({tournamentParticipants:l,internalUse:!0,policyDefinitions:t,participantId:r,personId:o}),i)break}return bc({participant:i,tournamentId:s},V)}const $T=({penaltyId:t=ze()}={})=>({refereeParticipantId:void 0,penaltyCode:void 0,penaltyType:void 0,extensions:void 0,matchUpId:void 0,createdAt:void 0,issuedAt:void 0,notes:void 0,penaltyId:t});var hK=Object.defineProperty,_K=Object.defineProperties,IK=Object.getOwnPropertyDescriptors,NT=Object.getOwnPropertySymbols,PK=Object.prototype.hasOwnProperty,yK=Object.prototype.propertyIsEnumerable,UT=(t,e,r)=>e in t?hK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Dd=(t,e)=>{for(var r in e||(e={}))PK.call(e,r)&&UT(t,r,e[r]);if(NT)for(var r of NT(e))yK.call(e,r)&&UT(t,r,e[r]);return t},jd=(t,e)=>_K(t,IK(e));function AT({refereeParticipantId:t,tournamentRecord:e,participantIds:r,penaltyCode:n,penaltyType:o,extensions:i,penaltyId:s,matchUpId:a,issuedAt:l,notes:c}){if(!e)return{error:re};if(!r)return{error:Tt};if(!o)return{error:Rx};const d=((e==null?void 0:e.participants)||[]).filter(f=>r.includes(f.participantId));if(!d.length)return{error:Dt};const p=new Date().toISOString(),v=Object.assign($T({penaltyId:s}),{refereeParticipantId:t,penaltyCode:n,penaltyType:o,matchUpId:a,notes:c,issuedAt:l,createdAt:p});return Array.isArray(i)&&i.forEach(f=>it({element:v,extension:f})),d.forEach(f=>{f.penalties||(f.penalties=[]),f.penalties.push(v)}),qe({topic:rr,payload:{tournamentId:e.tournamentId,participants:d}}),jd(Dd({},V),{penaltyId:v.penaltyId})}function CT({tournamentRecord:t,penaltyId:e}){if(!t)return{error:re};if(!e)return{error:f_};const r=(t==null?void 0:t.participants)||[],n=[];let o=!1,i;return r.forEach(s=>{let a=!1;s.penalties=(s.penalties||[]).filter(l=>(l.penaltyId===e&&(a=!0,o||(i=l,o=!0)),a&&n.push(s),l.penaltyId!==e))}),i&&qe({topic:rr,payload:{tournamentId:t.tournamentId,participants:n}}),i?jd(Dd({},V),{penalty:i}):{error:ru}}function MT({tournamentRecord:t}){if(!t)return{error:re};const r=((t==null?void 0:t.participants)||[]).reduce((n,o)=>{const{participantId:i}=o;return(o.penalties||[]).forEach(s=>{const{penaltyId:a}=s||{};n[a]?n[a].participants.push(i):n[a]=jd(Dd({},s),{participantIds:[i]})}),n},{});return{penalties:Object.values(r)}}function DT({tournamentRecord:t,modifications:e,penaltyId:r}){if(!t)return{error:re};if(!e)return{error:X,modifications:e};if(!r)return{error:f_};const n=(t==null?void 0:t.participants)||[],o=Object.keys($T()).filter(l=>l!=="penaltyId"),i=Object.keys(e).filter(l=>o.includes(l));if(!i.length)return{error:vf};let s;const a=[];return n.forEach(l=>{let c=!1;l.penalties=(l.penalties||[]).map(u=>(u.penaltyId===r&&(c=!0,i.forEach(d=>Object.assign(u,{[d]:e[d]})),s||(s=u)),u)),c&&a.push(l)}),s&&qe({topic:rr,payload:{tournamentId:t.tournamentId,participants:a}}),s?jd(Dd({},V),{penalty:s}):{error:ru}}var SK=Object.defineProperty,OK=Object.defineProperties,bK=Object.getOwnPropertyDescriptors,jT=Object.getOwnPropertySymbols,TK=Object.prototype.hasOwnProperty,wK=Object.prototype.propertyIsEnumerable,RT=(t,e,r)=>e in t?SK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,qa=(t,e)=>{for(var r in e||(e={}))TK.call(e,r)&&RT(t,r,e[r]);if(jT)for(var r of jT(e))wK.call(e,r)&&RT(t,r,e[r]);return t},FT=(t,e)=>OK(t,bK(e));function EK(t){const{tournamentRecords:e,participantIds:r}=t;let n;for(const o of Object.values(e)){const{tournamentParticipants:i}=cr({tournamentRecord:o}),s=ic(i).filter(a=>r.includes(a));s.length&&(n=AT(FT(qa({},t),{penaltyId:t.penaltyId||n,tournamentRecord:o,participantIds:s})).penaltyId)}return n?FT(qa({},V),{penaltyId:n}):{error:Dt}}function $K(t){const{tournamentRecords:e}=t;if(typeof e!="object"||!Object.keys(e).length)return{error:ke};for(const r of Object.values(e)){const n=DT(qa({tournamentRecord:r},t));if(n.error&&n.error!==ru)return n}return qa({},V)}function NK(t){const{tournamentRecords:e}=t;if(typeof e!="object"||!Object.keys(e).length)return{error:ke};for(const r of Object.values(e)){const n=CT(qa({tournamentRecord:r},t));if(n.error&&n.error!==ru)return n}return qa({},V)}function UK({tournamentRecords:t}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const e=[];for(const r of Object.values(t)){const{penalties:n}=MT({tournamentRecord:r});e.push(...n||[])}return{penalties:e}}const AK={addExtension:Hf,findExtension:Tu,removeExtension:wu,addEventExtension:zB,linkTournaments:JB,unlinkTournament:XB,unlinkTournaments:ZB,getLinkedTournamentIds:qf,addDrawDefinition:gY,getCompetitionParticipants:gK,getParticipants:mK,addParticipant:OY,courtGridRows:Pb,setMatchUpStatus:cY,bulkMatchUpStatusUpdate:uY,bulkScheduleMatchUps:LS,addPenalty:EK,removePenalty:NK,modifyPenalty:$K,getCompetitionPenalties:UK,findParticipant:ET};var CK=Object.defineProperty,xT=Object.getOwnPropertySymbols,MK=Object.prototype.hasOwnProperty,DK=Object.prototype.propertyIsEnumerable,LT=(t,e,r)=>e in t?CK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,VT=(t,e)=>{for(var r in e||(e={}))MK.call(e,r)&<(t,r,e[r]);if(xT)for(var r of xT(e))DK.call(e,r)&<(t,r,e[r]);return t};function BT({removePriorValues:t=!0,tournamentRecord:e,status:r=zn}){if(!e)return{error:re};const n=`${Hr}.${qr}`,{timeItem:o}=Xu({tournamentRecord:e,itemType:n}),i=(o==null?void 0:o.itemValue)||{[r]:{}};return i[r]&&delete i[r].orderOfPlay,xo({timeItem:{itemValue:i,itemType:n},removePriorValues:t,tournamentRecord:e}),qe({topic:mP,payload:{tournamentId:e.tournamentId}}),VT({},V)}function kT({scheduledDates:t=[],removePriorValues:e,tournamentRecord:r,status:n=zn,eventIds:o=[]}){if(!r)return{error:re};const i=`${Hr}.${qr}`,{timeItem:s}=Xu({tournamentRecord:r,itemType:i}),a=(s==null?void 0:s.itemValue)||{[n]:{}};return a[n].orderOfPlay={published:!0,scheduledDates:t,eventIds:o},xo({timeItem:{itemValue:a,itemType:i},removePriorValues:e,tournamentRecord:r}),qe({topic:pk,payload:{tournamentId:r.tournamentId,scheduledDates:t,eventIds:o}}),VT({},V)}var jK=Object.defineProperty,GT=Object.getOwnPropertySymbols,RK=Object.prototype.hasOwnProperty,FK=Object.prototype.propertyIsEnumerable,WT=(t,e,r)=>e in t?jK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Rd=(t,e)=>{for(var r in e||(e={}))RK.call(e,r)&&WT(t,r,e[r]);if(GT)for(var r of GT(e))FK.call(e,r)&&WT(t,r,e[r]);return t};function xK(t){const e=t==null?void 0:t.tournamentRecords;if(!e)return{error:ke};for(const r of Object.values(e)){const n=BT(Rd({tournamentRecord:r},t));if(n.error)return n}return Rd({},V)}function LK(t){const e=t==null?void 0:t.tournamentRecords;if(!e)return{error:ke};for(const r of Object.values(e)){const n=kT(Rd({tournamentRecord:r},t));if(n.error)return n}return Rd({},V)}const VK={unPublishOrderOfPlay:xK,publishOrderOfPlay:LK};function HT({tournamentRecords:t,extensionName:e}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const r=[];let n;for(const o of Object.values(t)){const{extension:i}=Fr({name:e,tournamentRecord:o});i&&!n&&(r.push({method:"addExtension",params:{extension:i}}),n=!0);const s=o.events||[];for(const a of s){const{eventId:l}=a,{extension:c}=No({name:e,event:a});c&&r.push({params:{eventId:l,extension:c},method:"addEventExtension"})}}return{methods:r}}function BK({tournamentRecords:t}){return HT({extensionName:Hn,tournamentRecords:t})}var kK=Object.defineProperty,GK=Object.defineProperties,WK=Object.getOwnPropertyDescriptors,qT=Object.getOwnPropertySymbols,HK=Object.prototype.hasOwnProperty,qK=Object.prototype.propertyIsEnumerable,zT=(t,e,r)=>e in t?kK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,zK=(t,e)=>{for(var r in e||(e={}))HK.call(e,r)&&zT(t,r,e[r]);if(qT)for(var r of qT(e))qK.call(e,r)&&zT(t,r,e[r]);return t},YK=(t,e)=>GK(t,WK(e));function YT({tournamentRecord:t,matchUpFormats:e,categoryType:r,event:n}){if(!t)return{error:re};if(!n)return{error:Ge};let o=[];if(e!=null&&e.length){const u=[];o=e.map(d=>{const p=typeof d=="string"?{matchUpFormat:d}:d;if(!u.includes(p==null?void 0:p.matchUpFormat)&&en(p==null?void 0:p.matchUpFormat))return u.push(p.matchUpFormat),p}).filter(Boolean)}else{const{policy:u}=us({policyType:da,tournamentRecord:t,event:n});if(u!=null&&u.matchUpFormats)o=u==null?void 0:u.matchUpFormats;else{const{extension:d}=No({name:Hn,event:n});if(d!=null&&d.value)o=He([...(d.value.matchUpAverageTimes||[]).map(p=>p.matchUpFormatCodes),...(d.value.matchUpRecoveryTimes||[]).map(p=>p.matchUpFormatCodes)].flat()).map(p=>({matchUpFormat:p}));else return{error:hx}}}const{eventType:i,eventId:s,category:a}=n,l=(a==null?void 0:a.categoryName)||(a==null?void 0:a.ageCategoryCode)||s;return s?{eventMatchUpFormatTiming:o.map(({matchUpFormat:u,description:d})=>{const p=Vf({tournamentRecord:t,matchUpFormat:u,categoryName:l,categoryType:r,eventType:i,event:n});return Object.assign({},YK(zK({},p),{description:d,matchUpFormat:u}))})}:{error:Ge}}function KK({tournamentRecords:t,matchUpFormats:e,categoryType:r,tournamentId:n,eventId:o}){if(!o)return{error:Ge};const i=Object.keys(t).filter(c=>!n||c===n);if(n&&!i.length)return{error:X};let s,a,l;return i.forEach(c=>{const u=t[c],{event:d}=Qt({tournamentRecord:u,eventId:o});if(!d)return!1;l=!0;const{eventMatchUpFormatTiming:p,error:v}=YT({tournamentRecord:u,matchUpFormats:e,categoryType:r,event:d});v&&(a=v),s=p}),!l&&{error:Ur}||a&&{error:a}||{eventMatchUpFormatTiming:s}}function Fd({tournamentRecords:t,schedulingProfile:e}){if(!e)return{valid:!0};if(!Array.isArray(e))return{valid:!1,error:X};const{venueIds:r,tournamentsMap:n}=QK({tournamentRecords:t});let o,i;const s=e.every(a=>{const{scheduleDate:l,venues:c}=a;return Gr(l)?c.every(u=>{const{venueId:d,rounds:p}=u;return typeof d!="string"?(i="venueId should be a string",!1):Array.isArray(p)?r.includes(d)?!!p.every(f=>{var m,g,h;if(!f)return i="empty round",!1;const{roundSegment:_,tournamentId:I,structureId:P,roundNumber:y,eventId:S,drawId:O}=f,b=(h=(g=(m=n==null?void 0:n[I])==null?void 0:m[S])==null?void 0:g[O])==null?void 0:h[P],w=b==null?void 0:b.includes(y);w||(i="Invalid rounds");const{segmentNumber:T,segmentsCount:E}=_||{},N=!_||_t(T)&&Xr(E)&&T<=E;return N||(i="Invalid segment"),w&&N}):(o=yi,!1):(i="rounds should be an array",!1)}):!1});return!s&&!o&&(o=X),{valid:!!s,error:o,info:i}}function KT(t){const{tournamentRecord:e={},tournamentMap:r={},requireCourts:n}=t,o=[],i=[],s=[],a=[],l=((e==null?void 0:e.venues)||[]).map(({venueId:u,courts:d})=>(!n||(d==null?void 0:d.length))&&u),c=e==null?void 0:e.tournamentId;return c&&(o.push(c),r[c]={},((e==null?void 0:e.events)||[]).forEach(d=>{const p=d.eventId;s.push(p),r[c][p]={},(d.drawDefinitions||[]).forEach(v=>{const f=v.drawId;a.push(f),r[c][p][f]={};const{structures:m}=un({drawDefinition:v});(m||[]).forEach(g=>{var h;const _=g.structureId,{matchUps:I}=Je({structure:g}),{roundMatchUps:P}=br({matchUps:I}),y=P&&Object.keys(P).map(S=>parseInt(S));r[c][p][f][_]=y,i.push(_),(h=g.structures)!=null&&h.length&&g.structures.forEach(S=>{i.push(S.structureId),r[c][p][f][S.structureId]=y})})})})),{tournamentMap:r,tournamentIds:o,structureIds:i,venueIds:l,eventIds:s,drawIds:a}}function QK(t){const e=(t==null?void 0:t.tournamentRecords)&&Object.values(t==null?void 0:t.tournamentRecords)||[],r={},{venueIds:n,eventIds:o,drawIds:i,structureIds:s,tournamentIds:a}=e.reduce((l,c)=>{const{tournamentIds:u,tournamentMap:d,structureIds:p,venueIds:v,eventIds:f,drawIds:m}=KT({tournamentRecord:c});return v.forEach(g=>{l.venueIds.includes(g)||l.venueIds.push(g)}),l.tournamentIds.push(...u),l.structureIds.push(...p),l.eventIds.push(...f),l.drawIds.push(...m),Object.assign(r,d),l},{tournamentIds:[],structureIds:[],venueIds:[],eventIds:[],drawIds:[]});return{tournamentsMap:r,tournamentIds:a,structureIds:s,venueIds:n,eventIds:o,drawIds:i}}var JK=Object.defineProperty,QT=Object.getOwnPropertySymbols,ZK=Object.prototype.hasOwnProperty,XK=Object.prototype.propertyIsEnumerable,JT=(t,e,r)=>e in t?JK(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,e8=(t,e)=>{for(var r in e||(e={}))ZK.call(e,r)&&JT(t,r,e[r]);if(QT)for(var r of QT(e))XK.call(e,r)&&JT(t,r,e[r]);return t};function t8({tournamentRecords:t,matchUpFormat:e,recoveryTimes:r,averageTimes:n,tournamentId:o,eventId:i}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const s=Object.keys(t).filter(l=>!o||o===l);if(o&&!s.includes(o))return{error:X};let a;for(const l of s){const c=t[l],{event:u}=Qt({tournamentRecord:c,eventId:i});i&&u&&(a=!0);const d=hm({tournamentRecord:c,event:u,matchUpFormat:e,averageTimes:n,recoveryTimes:r});if(d.error)return d}return!i||a?e8({},V):{error:Ur}}function bm({defaultRecoveryMinutes:t=0,defaultAverageMinutes:e,tournamentRecords:r,matchUpFormat:n,categoryName:o,categoryType:i,tournamentId:s,eventType:a,eventId:l}){if(!en(n))return{error:Zc};const c=Object.keys(r).filter(d=>!s||d===s);let u;return c.forEach(d=>{var p;if(u)return;const v=r[d],f=l?(p=Qt({tournamentRecord:v,eventId:l}))==null?void 0:p.event:void 0;return u=Vf({tournamentRecord:v,matchUpFormat:n,categoryName:o,categoryType:i,eventType:a,event:f}),(u==null?void 0:u.averageMinutes)||(u==null?void 0:u.recoveryMinutes)}),{recoveryMinutes:(u==null?void 0:u.recoveryMinutes)||t,averageMinutes:(u==null?void 0:u.averageMinutes)||e,typeChangeRecoveryMinutes:(u==null?void 0:u.typeChangeRecoveryMinutes)||(u==null?void 0:u.recoveryMinutes)||t}}var r8=Object.defineProperty,ZT=Object.getOwnPropertySymbols,n8=Object.prototype.hasOwnProperty,o8=Object.prototype.propertyIsEnumerable,XT=(t,e,r)=>e in t?r8(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,i8=(t,e)=>{for(var r in e||(e={}))n8.call(e,r)&&XT(t,r,e[r]);if(ZT)for(var r of ZT(e))o8.call(e,r)&&XT(t,r,e[r]);return t};function Tm({scheduleCompletedMatchUps:t,containedStructureIds:e,tournamentRecords:r,periodLength:n=30,matchUps:o,rounds:i}){if(typeof r!="object")return{error:ke};if(!Array.isArray(i))return{error:_e,info:or("rounds")};const s={},a=[];i.sort((v,f)=>{var m,g;return((m=v.sortOrder)!=null?m:0)-((g=f.sortOrder)!=null?g:0)}),e=e??Object.assign({},...Object.values(r).map(v=>Ra({tournamentRecord:v}).containedStructures)),o||({matchUps:o}=Fo({nextMatchUps:!0,tournamentRecords:r}));let l=0;const c={},u={},d={},p=i.flatMap(v=>{var f;const m=v.periodLength||n,g=[];e!=null&&e[v.structureId]?g.push(...e[v.structureId]):g.push(v.structureId);let h=o?Ts({tournamentIds:[v.tournamentId],roundNumbers:[v.roundNumber],matchUpIds:v.matchUpIds,eventIds:[v.eventId],drawIds:[v.drawId],processContext:!0,structureIds:g,matchUps:o}).sort(Ms):[];const{segmentNumber:_,segmentsCount:I}=v.roundSegment||{};if(_t(_)&&Xr(h==null?void 0:h.length)&&Xr(I)&&_>0&&_<=I&&I<(h==null?void 0:h.length)&&!((f=v.matchUpIds)!=null&&f.length)){const O=h.length/I,b=O*(_-1);h=h.slice(b,b+O)}const P=r[v.tournamentId],y=Qt({drawId:v.drawId,tournamentRecord:P}).event,S=[];for(const O of h){const b=O.matchUpFormat;b&&(s[b]||(s[b]=[],s[b].push(O)),S.push(b))}for(const O of S){const{eventType:b,category:w}=y??{},{categoryName:T,ageCategoryCode:E}=w??{},{typeChangeRecoveryMinutes:N,recoveryMinutes:$,averageMinutes:A,error:U}=bm({categoryName:T??E,categoryType:w==null?void 0:w.categoryType,tournamentId:v.tournamentId,eventId:v.eventId,tournamentRecords:r,matchUpFormat:O,eventType:b});if(U)return{error:U,round:v};const C=h.filter(D=>(t||!Yt.includes(D.matchUpStatus))&&D.matchUpStatus!==nt).map(Jt);C.forEach(D=>{d[D]={typeChangeRecoveryMinutes:N,recoveryMinutes:$,averageMinutes:A},c[D]=$,u[D]=A}),a.push(...C),l=Math.max(A||0,l);const M=`${A}|${m}`;return{roundPeriodLength:m,recoveryMinutes:$,averageMinutes:A,matchUpIds:C,hash:M}}});return i8({scheduledRoundsDetails:p,greatestAverageMinutes:l,matchUpFormatCohorts:s,recoveryMinutesMap:c,averageMinutesMap:u,orderedMatchUpIds:a,minutesMap:d},V)}function ew({tournamentRecords:t}){const r=Object.keys(t).reduce((i,s)=>{const a=t[s],{tournamentInfo:{startDate:l,endDate:c}}=Oc({tournamentRecord:a}),u=l&&new Date(Re(l));(!i.startDate||u&&u<i.startDate)&&(i.startDate=u);const d=c&&new Date(Re(c));return(!i.endDate||d&&d>i.endDate)&&(i.endDate=d),i},{startDate:void 0,endDate:void 0}),n=r.startDate&&Re(r.startDate.toISOString()),o=r.endDate&&Re(r.endDate.toISOString());return!n||!o?{error:n_}:{startDate:n,endDate:o}}var s8=Object.defineProperty,a8=Object.defineProperties,l8=Object.getOwnPropertyDescriptors,tw=Object.getOwnPropertySymbols,c8=Object.prototype.hasOwnProperty,u8=Object.prototype.propertyIsEnumerable,rw=(t,e,r)=>e in t?s8(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,wm=(t,e)=>{for(var r in e||(e={}))c8.call(e,r)&&rw(t,r,e[r]);if(tw)for(var r of tw(e))u8.call(e,r)&&rw(t,r,e[r]);return t},d8=(t,e)=>a8(t,l8(e));function za({tournamentRecords:t}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const{extension:e}=Tu({name:Qo,tournamentRecords:t});let r=(e==null?void 0:e.value)||[];if(r.length){const{venueIds:n}=qv({requireCourts:!0,tournamentRecords:t}),{eventIds:o,drawIds:i}=fd({tournamentRecords:t}),{updatedSchedulingProfile:s,modifications:a,issues:l}=xd({schedulingProfile:r,venueIds:n,eventIds:o,drawIds:i});if(a){r=s;const c=Tc({tournamentRecords:t,schedulingProfile:r});return c.error?c:{schedulingProfile:r,modifications:a,issues:l}}}return{schedulingProfile:r,modifications:0}}function Tc({tournamentRecords:t,schedulingProfile:e}){const r=Fd({tournamentRecords:t,schedulingProfile:e});return r.error?r:e?Hf({tournamentRecords:t,extension:{name:Qo,value:e}}):wu({tournamentRecords:t,name:Qo})}function nw({tournamentRecords:t,scheduleDate:e,venueId:r,round:n}){if(!Gr(e))return{error:yr};const o="addSchedulingProfileRound",{extension:i}=Tu({tournamentRecords:t,name:Qo}),s=(i==null?void 0:i.value)||[];let a=s.find(v=>so(e,v.scheduleDate));if(!a){const{startDate:v,endDate:f}=ew({tournamentRecords:t}),m=new Date(e);if(v&&m<new Date(v)||f&&m>new Date(f))return{error:yr};a={scheduleDate:e,venues:[]},s.push(a)}let l=a.venues.find(v=>v.venueId===r);l||(l={venueId:r,rounds:[]},a.venues.push(l));const c=["notBeforeTime"],u=v=>Object.keys(v).filter(f=>!c.includes(f)).sort().map(f=>ns(v[f])?u(v[f]):v[f]).flat().join("|");if(l.rounds.find(v=>u(v)===u(n)))return k({result:{error:ix},stack:o});l.rounds.push(n);const p=Tc({tournamentRecords:t,schedulingProfile:s});return p.error?p:wm({},V)}function xd({schedulingProfile:t,venueIds:e,eventIds:r,drawIds:n}){const o=[],i=t==null?void 0:t.map(a=>{const l=Re(a==null?void 0:a.scheduleDate);if(!l){o.push(`Invalid date: ${a==null?void 0:a.scheduledDate}`);return}const c=((a==null?void 0:a.venues)||[]).map(u=>{const{rounds:d,venueId:p}=u;if(!e.includes(p)){o.push(`Missing venueId: ${p}`);return}const f=d.filter(m=>{const g=r.includes(m.eventId)&&n.includes(m.drawId);return g||o.push(`Invalid eventId: ${m.eventId} or drawId: ${m.drawId}`),g});if(f.length)return{venueId:p,rounds:f}}).filter(Boolean);return c.length&&l&&d8(wm({},a),{venues:c})}).filter(Boolean),s=o.length;return{updatedSchedulingProfile:i,modifications:s,issues:o}}function ow({tournamentRecords:t}){const{schedulingProfile:e}=za({tournamentRecords:t});if(e){const{venueIds:r}=qv({tournamentRecords:t}),{eventIds:n,drawIds:o}=fd({tournamentRecords:t}),{updatedSchedulingProfile:i,modifications:s}=xd({schedulingProfile:e,venueIds:r,eventIds:n,drawIds:o});if(s)return Tc({tournamentRecords:t,schedulingProfile:i})}return wm({},V)}function Ld({matchUps:t=[],schedulingProfile:e}){const r={},n=({eventId:a,drawId:l,structureId:c,roundNumber:u})=>`${a}|${l}|${c}${u}`;e!=null&&e.length&&e.map(({venues:l})=>l.map(({rounds:c})=>c)).flat().forEach(l=>{l.sort((u,d)=>(u.sortOrder||0)-(d.sortOrder||0)).forEach(({eventId:u,drawId:d,structureId:p,roundNumber:v},f)=>{const m=n({eventId:u,drawId:d,structureId:p,roundNumber:v});r[m]=f})});const o=[],i={noScheduledDate:[]};for(const a of t){const l=a.schedule||{},c=l.scheduledDate&&Re(l.scheduledDate)||l.scheduledTime&&Re(l.scheduledTime)||"noScheduledDate";i[c]||(i[c]=[]),i[c].push(a)}const s=Object.keys(i).sort();for(const a of s){const l=i[a],c={noScheduledTime:[]};for(const d of l){const p=d.schedule||{},v=p.scheduledTime&&ct(p.scheduledTime)||"noScheduledTime";c[v]||(c[v]=[]),c[v].push(d)}const u=Object.keys(c).sort();for(const d of u){const p=c[d];p.sort((v,f)=>{const m=r[n(v)]||0,g=r[n(f)]||0;return m-g}),o.push(...p)}}return o}var p8=Object.defineProperty,f8=Object.defineProperties,v8=Object.getOwnPropertyDescriptors,iw=Object.getOwnPropertySymbols,m8=Object.prototype.hasOwnProperty,g8=Object.prototype.propertyIsEnumerable,sw=(t,e,r)=>e in t?p8(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vd=(t,e)=>{for(var r in e||(e={}))m8.call(e,r)&&sw(t,r,e[r]);if(iw)for(var r of iw(e))g8.call(e,r)&&sw(t,r,e[r]);return t},Em=(t,e)=>f8(t,v8(e));function $m(t){var e,r,n,o,i,s,a;if(typeof(t==null?void 0:t.tournamentRecords)!="object"||!Object.keys(t==null?void 0:t.tournamentRecords).length)return{error:ke};const{courts:l,venues:c}=Ds(t),d=za(t).schedulingProfile,{sortDateMatchUps:p=!0,courtCompletedMatchUps:v,alwaysReturnCompleted:f,activeTournamentId:m,tournamentRecords:g,withCourtGridRows:h,minCourtGridRows:_,usePublishState:I,status:P=zn,sortCourtsData:y}=t,S=I?Xu({tournamentRecord:g[m??gn()],itemType:`${Hr}.${qr}`}).timeItem:void 0,O=(e=S==null?void 0:S.itemValue)==null?void 0:e[P],b=f?Lv(Em(Vd({},t),{matchUpFilters:Em(Vd({},t.matchUpFilters),{matchUpStatuses:[pt.Completed]}),contextFilters:t.contextFilters})).completedMatchUps:[];if(I&&(!O||!Object.keys(O).length))return{completedMatchUps:b,dateMatchUps:[],courtsData:[],venues:c};const w=I?h8({tournamentRecords:g}).drawIds:void 0;w!=null&&w.length&&(t.contextFilters||(t.contextFilters={}),(r=t.contextFilters)!=null&&r.drawIds?t.contextFilters.drawIds=t.contextFilters.drawIds.filter(D=>w.includes(D)):t.contextFilters.drawIds=w),(n=O==null?void 0:O.eventIds)!=null&&n.length&&(t.matchUpFilters||(t.matchUpFilters={}),(o=t.matchUpFilters)!=null&&o.eventIds&&t.matchUpFilters.eventIds.length?t.matchUpFilters.eventIds=t.matchUpFilters.eventIds.filter(D=>O.eventIds.includes(D)):t.matchUpFilters.eventIds=O.eventIds),(i=O==null?void 0:O.scheduledDates)!=null&&i.length&&(t.matchUpFilters||(t.matchUpFilters={}),t.matchUpFilters.scheduledDates&&t.matchUpFilters.scheduledDates.length?t.matchUpFilters.scheduledDates=t.matchUpFilters.scheduledDates.filter(D=>O.scheduledDates.includes(D)):t.matchUpFilters.scheduledDates=O.scheduledDates),f&&(t.matchUpFilters||(t.matchUpFilters={}),(a=(s=t.matchUpFilters)==null?void 0:s.excludeMatchUpStatuses)!=null&&a.length?t.matchUpFilters.excludeMatchUpStatuses.includes(At)||t.matchUpFilters.excludeMatchUpStatuses.push(At):t.matchUpFilters.excludeMatchUpStatuses=[At]);const{completedMatchUps:T,upcomingMatchUps:E,pendingMatchUps:N}=Lv(Em(Vd({},t),{matchUpFilters:t.matchUpFilters,contextFilters:t.contextFilters})),$=[...E??[],...N??[]],A=p?Ld({matchUps:$,schedulingProfile:d}):$,U=l==null?void 0:l.map(D=>{var R;const j=M(D);return Vd({surfaceCategory:(R=D==null?void 0:D.surfaceCategory)!=null?R:"",matchUps:j},D)}),C={courtsData:U,completedMatchUps:f?b:T,dateMatchUps:A,venues:c};if(h){const{rows:D,courtPrefix:R}=Pb({minRowsCount:_,courtsData:U});C.courtPrefix=R,C.rows=D}return C;function M({courtId:D}){const j=(v?A.concat(T??[]):A).filter(G=>{var W,z,F;return((W=G.schedule)==null?void 0:W.courtId)===D||((F=(z=G.schedule)==null?void 0:z.allocatedCourts)==null?void 0:F.map(({courtId:L})=>L).includes(D))});return y?Ld({matchUps:j,schedulingProfile:d}):j}}function h8({tournamentRecords:t}){var e,r,n,o;const i=[];for(const s of Object.values(t))for(const a of(e=s.events)!=null?e:[]){const{timeItem:l}=Ro({itemType:`${Hr}.${qr}`,event:a}),c=(r=l==null?void 0:l.itemValue)==null?void 0:r[zn];if((n=c==null?void 0:c.drawIds)!=null&&n.length)i.push(...c.drawIds);else{const u=((o=a.drawDefinitions)!=null?o:[]).map(({drawId:d})=>d).filter(Boolean);i.push(...u)}}return{drawIds:i}}var _8=Object.defineProperty,I8=Object.defineProperties,P8=Object.getOwnPropertyDescriptors,aw=Object.getOwnPropertySymbols,y8=Object.prototype.hasOwnProperty,S8=Object.prototype.propertyIsEnumerable,lw=(t,e,r)=>e in t?_8(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,O8=(t,e)=>{for(var r in e||(e={}))y8.call(e,r)&&lw(t,r,e[r]);if(aw)for(var r of aw(e))S8.call(e,r)&&lw(t,r,e[r]);return t},b8=(t,e)=>I8(t,P8(e));function cw({calculateStartTimeFromCourts:t=!0,defaultRecoveryMinutes:e=0,averageMatchUpMinutes:r=90,remainingScheduleTimes:n,clearScheduleDates:o,tournamentRecords:i,periodLength:s,scheduleDate:a,startTime:l,venueIds:c,endTime:u}){if(typeof i!="object"||!Object.keys(i).length)return{error:ke};s=s||nd({recoveryMinutes:e,averageMatchUpMinutes:r});const{courts:d,venues:p}=Ds({dates:[a],ignoreDisabled:!0,tournamentRecords:i}),v=d==null?void 0:d.filter(E=>!c||c.includes(E.venueId));l||(l=v==null?void 0:v.reduce((E,N)=>{var $;const A=($=N.dateAvailability)==null?void 0:$.find(C=>!C.date||so(a,C.date)),U=(A==null?void 0:A.startTime)||N.startTime;return U&&(!E||xe(U)<xe(E))?U:E},void 0)),u||(u=v==null?void 0:v.reduce((E,N)=>{var $;const A=($=N.dateAvailability)==null?void 0:$.find(C=>!C.date||so(a,C.date)),U=(A==null?void 0:A.endTime)||N.endTime;return U&&(!E||xe(U)>xe(E))?U:E},void 0));const f=Object.values(i),m=Object.assign({},...f.map(E=>(E.events||[]).map(N=>{const{scheduleTiming:$}=Ml({tournamentRecord:E,event:N});return{[N.eventId]:{event:N,scheduleTiming:$}}})).flat()),h=$m({sortDateMatchUps:!1,tournamentRecords:i,matchUpFilters:{scheduledDate:a,venueIds:c}}),_=(h==null?void 0:h.dateMatchUps)||[],I=(h==null?void 0:h.completedMatchUps)||[],P=[];P.push(..._),P.push(...I);const y={averageTimes:[{minutes:{default:r}}],recoveryTimes:[{minutes:{default:e}}]},S=P==null?void 0:P.map(({eventId:E,schedule:N,matchUpFormat:$})=>{const{event:A,scheduleTiming:U}=m[E],C=A==null?void 0:A.eventType,M=b8(O8({},U),{defaultTiming:y,matchUpFormat:$}),{averageMinutes:D,recoveryMinutes:R}=Su({eventType:C,timingDetails:M}),{courtId:j,venueId:G}=N,W=ct(N.scheduledTime),z=Sr(W,D);return{recoveryMinutes:R,averageMinutes:D,periodLength:s,startTime:W,endTime:z,courtId:j,venueId:G}}),O={calculateStartTimeFromCourts:t,remainingScheduleTimes:n,averageMatchUpMinutes:r,date:a,clearScheduleDates:o,periodLength:s,startTime:l,endTime:u,bookings:S,courts:v},{scheduleTimes:b}=Bv(O),w=(c==null?void 0:c.length)===1&&c[0]||(p==null?void 0:p.length)===1&&p[0].venueId||void 0,T=P.map(Jt);return{venueId:w,scheduleTimes:b,dateScheduledMatchUpIds:T}}function Nm({matchUpScheduleTimes:t,matchUpDependencies:e,allDateMatchUpIds:r,matchUp:n}){var o;const s=(((o=e==null?void 0:e[n.matchUpId])==null?void 0:o.matchUpIds)||[]).filter(l=>r.includes(l)).filter(l=>!t[l]);return{dependenciesScheduled:!(s!=null&&s.length),remainingDependencies:s}}function Ya({matchUpPotentialParticipantIds:t,matchUpNotBeforeTimes:e,timeAfterRecovery:r,matchUp:n}){var o,i,s,a;const{individualParticipantIds:l}=td(n);r=r||((o=n.schedule)==null?void 0:o.timeAfterRecovery);const c=v=>{t[v]||(t[v]=[]),t[v]=He(t[v].concat(...l))},u=v=>{r&&(!e[v]||r>e[v])&&(e[v]=r)},d=((i=n.winnerTo)==null?void 0:i.matchUpId)||n.winnerMatchUpId;d&&(r&&u(d),c(d));const p=((s=n.loserTo)==null?void 0:s.matchUpId)||n.loserMatchUpId;p&&(r&&u(p),c(p)),(a=n.sidesTo)!=null&&a.length&&n.sidesTo.forEach(({matchUpId:v})=>{v&&(r&&u(v),c(v))})}function wc({individualParticipantProfiles:t,participantId:e}){t[e]||(t[e]={typeChangeTimeAfterRecovery:void 0,timeAfterRecovery:void 0,priorMatchUpType:void 0,potentialRecovery:{},potentialCounted:{},potentialBookings:{},bookings:[],counters:{}})}function T8({individualParticipantProfiles:t,recoveryValue:e,participantId:r,scheduleTime:n,drawId:o}){t[r].potentialRecovery[o]||(t[r].potentialRecovery[o]=[]),t[r].potentialRecovery[o].push(e),t[r].potentialBookings[o]||(t[r].potentialBookings[o]=[]),t[r].potentialBookings[o].push({timeAfterRecovery:e,scheduleTime:n})}function Ec({matchUpPotentialParticipantIds:t,individualParticipantProfiles:e,typeChangeRecoveryMinutes:r,averageMatchUpMinutes:n=0,matchUpNotBeforeTimes:o,matchUpDependencies:i,recoveryMinutes:s=0,scheduleTime:a,matchUp:l}){var c,u;const d=ct((c=l==null?void 0:l.schedule)==null?void 0:c.endTime),p=d?Sr(d,Oe(s)):Sr(a,Oe(n)+Oe(s)),v=r&&(d?Sr(ct(d),r):Sr(a,Oe(n)+Oe(r))),f=((u=i==null?void 0:i[l.matchUpId])==null?void 0:u.participantIds)||[],m=(l.roundPosition&&t[l.matchUpId]||[]).flat();f.forEach(g=>{wc({individualParticipantProfiles:e,participantId:g});const _=e[g].priorMatchUpType!==l.matchUpType&&v||p;m.includes(g)?T8({individualParticipantProfiles:e,drawId:l.drawId,recoveryValue:_,participantId:g,scheduleTime:a}):(e[g].timeAfterRecovery=_,e[g].bookings.push({scheduleTime:a,timeAfterRecovery:_}))}),Ya({matchUpPotentialParticipantIds:t,matchUpNotBeforeTimes:o,timeAfterRecovery:p,matchUp:l})}function uw({matchUpScheduleTimes:t,matchUpDependencies:e,scheduleTime:r,matchUpId:n,details:o}){var i,s,a,l,c;let u;const d=(s=(i=o.minutesMap)==null?void 0:i[n])==null?void 0:s.recoveryMinutes,v=(((l=(a=o.minutesMap)==null?void 0:a[n])==null?void 0:l.averageMinutes)||0)+(d||0),f=Sr(r,v),m=((c=e==null?void 0:e[n])==null?void 0:c.dependentMatchUpIds)||[];if(m.length){const g=m.reduce((h,_)=>{const I=t[_];if(!I)return h;const P={scheduleTime:I,matchUpId:_};return I&&!h.matchUpId||xe(I)<xe(h.scheduleTime)?P:h},{});g.scheduleTime&&xe(f)>xe(g.scheduleTime)&&(u=g)}return{scheduledDependent:u}}function w8(t){const{sides:e,matchUpType:r}=t||{};return(e||[]).map(n=>{var o;return r===ft&&(((o=n==null?void 0:n.participant)==null?void 0:o.individualParticipants)||[])||(n==null?void 0:n.participant)&&[n.participant]||[]}).flat()}const Bd="DO_NOT_SCHEDULE";var E8=Object.defineProperty,$8=Object.defineProperties,N8=Object.getOwnPropertyDescriptors,dw=Object.getOwnPropertySymbols,U8=Object.prototype.hasOwnProperty,A8=Object.prototype.propertyIsEnumerable,pw=(t,e,r)=>e in t?E8(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,C8=(t,e)=>{for(var r in e||(e={}))U8.call(e,r)&&pw(t,r,e[r]);if(dw)for(var r of dw(e))A8.call(e,r)&&pw(t,r,e[r]);return t},M8=(t,e)=>$8(t,N8(e));function Um({averageMatchUpMinutes:t=90,requestConflicts:e={},potentials:r=!0,personRequests:n,scheduleTime:o,scheduleDate:i,matchUp:s}){const a=w8(s).map(({person:v})=>v==null?void 0:v.personId);if(r){const v=((s==null?void 0:s.potentialParticipants)||[]).flat().map(({person:f})=>f==null?void 0:f.personId);a.push(...v)}const l=a.map(v=>{var f;return(f=n[v])==null?void 0:f.map(m=>M8(C8({},m),{personId:v}))}).filter(Boolean).flat().filter(v=>v.requestType===Bd&&so(i,v.date)),c=[],u=s==null?void 0:s.matchUpId,d=wt(ct(o),Re(i)),p=ct(Pf(d,t).toISOString());for(const v of l){const{requestId:f,startTime:m,endTime:g}=v;(o>m&&o<g||p>m&&p<g)&&(c.push({matchUpId:u,request:v,scheduleTime:o}),e[f]?(e[f].scheduleTimes.includes(o)||e[f].scheduleTimes.push(o),e[f].matchUpIds.includes(u)||e[f].matchUpIds.push(u)):e[f]={request:v,scheduleTimes:[o],matchUpIds:[u]})}return{conflicts:c}}function Am({matchUpPotentialParticipantIds:t,individualParticipantProfiles:e,matchUp:r,value:n}){const{matchUpType:o}=r,{individualParticipantIds:i}=td(r),a=(t[r.matchUpId]||[]).filter(c=>!Xt(c,i)).flat();[...i,...a].forEach(c=>{if(wc({individualParticipantProfiles:e,participantId:c}),!e[c].potentialCounted[r.drawId]){const u=e[c].counters;u[o]?u[o]+=n:n>0&&(u[o]=n),u[On]?u[On]+=n:n>0&&(u[On]=n),a.includes(c)&&(e[c].potentialCounted[r.drawId]=!0)}})}function D8({matchUpPotentialParticipantIds:t,individualParticipantProfiles:e,dateScheduledMatchUpIds:r,greatestAverageMinutes:n,dateScheduledMatchUps:o,matchUpNotBeforeTimes:i,matchUpScheduleTimes:s,matchUpDependencies:a,clearScheduleDates:l,scheduleDate:c,minutesMap:u,matchUps:d}){var p,v;r||(o=d==null?void 0:d.filter(g=>{const h=g.schedule||{};return Sc({schedule:h})&&(!c||g.schedule.scheduledDate===c)}),r=o.map(Jt));const f=Array.isArray(l)?l.includes(c):l,m=f?[]:d.filter(({matchUpId:g})=>r.includes(g));for(const g of m){Am({matchUpPotentialParticipantIds:t,individualParticipantProfiles:e,value:1,matchUp:g});const h=(p=g.schedule)==null?void 0:p.scheduledTime;if(h){s[g.matchUpId]=h;const _=(v=u==null?void 0:u[g.matchUpId])==null?void 0:v.recoveryMinutes;Ec({individualParticipantProfiles:e,matchUpPotentialParticipantIds:t,matchUpNotBeforeTimes:i,matchUpDependencies:a,averageMatchUpMinutes:n,recoveryMinutes:_,scheduleTime:h,matchUp:g})}}return{clearDate:f,dateScheduledMatchUpIds:r,dateScheduledMatchUps:o}}function j8({scheduledRoundsDetails:t,greatestAverageMinutes:e,garmanSinglePass:r}){const n=[];let o=[],i,s,a,l;for(const c of t.filter(Boolean))l||(l=c.hash),(c.hash===l||r)&&(o=o.concat(c.matchUpIds)),c.hash!==l&&!r&&(l=c.hash,n.push({averageMinutes:a,recoveryMinutes:s,roundPeriodLength:i,matchUpIds:o}),o=c.matchUpIds),a=r?e:c.averageMinutes,s=c.recoveryMinutes,i=c.roundPeriodLength;return o.length&&n.push({averageMinutes:a,recoveryMinutes:s,roundPeriodLength:i,matchUpIds:o}),{groupedRounds:n}}function R8({matchUpPotentialParticipantIds:t,scheduleCompletedMatchUps:e,dateScheduledMatchUpIds:r,matchUpNotBeforeTimes:n,orderedMatchUpIds:o,clearDate:i,matchUps:s}){const a=o.map(c=>s.find(u=>u.matchUpId===c)).filter(Boolean).filter(c=>{const u=!i&&r.includes(c.matchUpId),d=[nt,et,At,Wr,hr,ot,jt,tr].includes(c==null?void 0:c.matchUpStatus);return e||!u&&!c.winningSide&&!d}),{matchUpMap:l}=a.reduce((c,u)=>{const{drawId:d,tournamentId:p}=u;return c.matchUpMap[p]||(c.matchUpMap[p]={}),c.matchUpMap[p][d]?c.matchUpMap[p][d].push(u):c.matchUpMap[p][d]=[u],Ya({matchUpPotentialParticipantIds:t,matchUpNotBeforeTimes:n,matchUp:u}),c},{matchUpMap:{}});return{matchUpsToSchedule:a,matchUpMap:l}}var F8=Object.defineProperty,x8=Object.defineProperties,L8=Object.getOwnPropertyDescriptors,fw=Object.getOwnPropertySymbols,V8=Object.prototype.hasOwnProperty,B8=Object.prototype.propertyIsEnumerable,vw=(t,e,r)=>e in t?F8(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,k8=(t,e)=>{for(var r in e||(e={}))V8.call(e,r)&&vw(t,r,e[r]);if(fw)for(var r of fw(e))B8.call(e,r)&&vw(t,r,e[r]);return t},G8=(t,e)=>x8(t,L8(e));function Cm({defaultRecoveryMinutes:t=0,averageMatchUpMinutes:e=90,dateScheduledMatchUps:r,tournamentRecords:n,venueIds:o=[],periodLength:i,scheduleDate:s,matchUps:a}){if(typeof n!="object")return{error:ke};if(!Array.isArray(a)&&!Array.isArray(r))return{error:Wo};i=i||nd({recoveryMinutes:t,averageMatchUpMinutes:e});const l=Object.assign({},...Object.values(n).map(p=>(p.events||[]).map(v=>{const{scheduleTiming:f}=Ml({tournamentRecord:p,event:v});return{[v.eventId]:{event:v,scheduleTiming:f}}})).flat()),c={averageTimes:[{minutes:{default:e}}],recoveryTimes:[{minutes:{default:t}}]};r||(r=a==null?void 0:a.filter(p=>{const v=p.schedule;return Sc({schedule:v})&&(!s||p.schedule.scheduledDate===s)}));const u=r==null?void 0:r.filter(p=>!o.length||o.includes(p.schedule.venueId));return{bookings:u==null?void 0:u.map(({eventId:p,schedule:v,matchUpFormat:f})=>{const{event:m,scheduleTiming:g}=l[p],h=m==null?void 0:m.eventType,_=G8(k8({},g),{defaultTiming:c,matchUpFormat:f}),{averageMinutes:I,recoveryMinutes:P}=Su({timingDetails:_,eventType:h}),{courtId:y,venueId:S}=v,O=ct(v.scheduledTime),b=Sr(O,I);return{recoveryMinutes:P,averageMinutes:I,periodLength:i,startTime:O,courtId:y,endTime:b,venueId:S}}).filter(Boolean),relevantMatchUps:u,dateScheduledMatchUps:r}}function W8({calculateStartTimeFromCourts:t=!0,remainingScheduleTimes:e,defaultRecoveryMinutes:r,averageMatchUpMinutes:n,clearScheduleDates:o,tournamentRecords:i,tournamentRecord:s,periodLength:a,scheduleDate:l,startTime:c,venueIds:u,matchUps:d,endTime:p}){if(s&&!i&&(i={[s.tournamentId]:s}),typeof i!="object"||!Object.keys(i).length)return{error:ke};a=a||nd({recoveryMinutes:r,averageMatchUpMinutes:n});const{courts:v,venues:f}=Ds({dates:[l],ignoreDisabled:!0,tournamentRecords:i}),m=(v==null?void 0:v.filter(S=>!u||u.includes(S.venueId)))||[];c=c||Ma({courts:m,scheduleDate:l,startTime:!0}),p=p||Ma({courts:m,scheduleDate:l,endTime:!0});const{bookings:g,dateScheduledMatchUps:h}=Cm({defaultRecoveryMinutes:r,averageMatchUpMinutes:n,tournamentRecords:i,scheduleDate:l,periodLength:a,venueIds:u,matchUps:d}),_={calculateStartTimeFromCourts:t,remainingScheduleTimes:e,averageMatchUpMinutes:n,clearScheduleDates:o,date:l,periodLength:a,startTime:c,bookings:g,endTime:p,courts:m},{scheduleTimes:I}=Bv(_),P=(u==null?void 0:u.length)===1&&u[0]||(f==null?void 0:f.length)===1&&f[0].venueId||void 0;return{dateScheduledMatchUpIds:h==null?void 0:h.map(sn("matchUpId")),dateScheduledMatchUps:h,scheduleTimes:I,venueId:P}}function mw({matchUpPotentialParticipantIds:t,individualParticipantProfiles:e,scheduleCompletedMatchUps:r,containedStructureIds:n,matchUpNotBeforeTimes:o,matchUpScheduleTimes:i,matchUpDependencies:s,clearScheduleDates:a,tournamentRecords:l,periodLength:c,scheduleDate:u,useGarman:d,matchUps:p,courts:v,venues:f}){var m;const g={},h=[],_=[];for(const I of f){const{rounds:P=[],venueId:y}=I,{scheduledRoundsDetails:S,greatestAverageMinutes:O,orderedMatchUpIds:b,minutesMap:w}=Tm({scheduleCompletedMatchUps:r,containedStructureIds:n,tournamentRecords:l,periodLength:c,matchUps:p,rounds:P});_.push(...b||[]);const{groupedRounds:T}=j8({scheduledRoundsDetails:S,greatestAverageMinutes:O,garmanSinglePass:!0});let E,N,$=[];d&&({scheduleTimes:$,dateScheduledMatchUpIds:E,dateScheduledMatchUps:N}=W8({averageMatchUpMinutes:(m=T[0])==null?void 0:m.averageMinutes,scheduleDate:Re(u),venueIds:[I.venueId],clearScheduleDates:a,tournamentRecords:l,periodLength:c,matchUps:p}));const A=D8({matchUpPotentialParticipantIds:t,individualParticipantProfiles:e,dateScheduledMatchUpIds:E,greatestAverageMinutes:O,matchUpNotBeforeTimes:o,matchUpScheduleTimes:i,matchUpDependencies:s,clearScheduleDates:a,scheduleDate:u,minutesMap:w,matchUps:p}),U=A.clearDate;({dateScheduledMatchUpIds:E,dateScheduledMatchUps:N}=A);const{matchUpsToSchedule:C,matchUpMap:M}=R8({matchUpPotentialParticipantIds:t,scheduleCompletedMatchUps:r,dateScheduledMatchUpIds:E,matchUpNotBeforeTimes:o,orderedMatchUpIds:b,clearDate:U,matchUps:p}),D=v.filter(R=>R.venueId===y);g[y]={previousRemainingScheduleTimes:[],courtsCount:D.length,greatestAverageMinutes:O,scheduledRoundsDetails:S,dateScheduledMatchUps:N,matchUpsToSchedule:C,scheduleTimes:$,groupedRounds:T,venueCourts:D,minutesMap:w,matchUpMap:M},a||h.push(...E)}return{allDateScheduledMatchUpIds:h,venueScheduledRoundDetails:g,allDateMatchUpIds:_}}function H8(t,e){const r=xe(t.scheduleTime),n=xe(t.timeAfterRecovery),o=xe(e.scheduleTime),i=xe(e.timeAfterRecovery),s=r===o||n===i,a=r>o&&r<i,l=o>r&&o<n,c=n>o&&n<i,u=i>r&&i<n;return ye({hasOverlap:s||a||c||l||u,startAisContained:a,endAisContained:c,startBisContained:l,endBisContained:u},!0)}function Mm({individualParticipantProfiles:t,matchUpNotBeforeTimes:e,matchUpDependencies:r,scheduleTime:n,matchUp:o,details:i}){var s,a,l,c,u;const d=(((s=r==null?void 0:r[o.matchUpId])==null?void 0:s.participantIds)||[]).flat(),p=((l=(a=i==null?void 0:i.minutesMap)==null?void 0:a[o.matchUpId])==null?void 0:l.averageMinutes)||0,v=((u=(c=i==null?void 0:i.minutesMap)==null?void 0:c[o.matchUpId])==null?void 0:u.recoveryMinutes)||0,f=d.every(I=>{var P;wc({individualParticipantProfiles:t,participantId:I});const y=t[I];if(!y.timeAfterRecovery)return!0;const S=ct((P=o==null?void 0:o.schedule)==null?void 0:P.endTime),O=S?Sr(S,Oe(v)):Sr(n,Oe(p)+Oe(v));return!!![...Object.keys(y.potentialBookings).filter(E=>E!==o.drawId).map(E=>y.potentialBookings[E]).flat(),...y.bookings].find(E=>H8({scheduleTime:n,timeAfterRecovery:O},E).hasOverlap)}),m=e[o.matchUpId],h=(m?Ol(wt(m),wt(n),!1):0)>=0;return{enoughTime:f&&h}}function Dm({individualParticipantProfiles:t,matchUpPotentialParticipantIds:e,matchUpDailyLimits:r={},matchUp:n}){const{matchUpId:o,matchUpType:i}=n,{enteredIndividualParticipantIds:s}=td(n),a=(n.roundPosition&&e[o]||[]).flat(),l=He(s.concat(...a));return l.forEach(u=>{wc({individualParticipantProfiles:t,participantId:u})}),{participantIdsAtLimit:l.filter(u=>{const d=t[u];if(d)return[i,On].find(p=>{var v;const f=((v=d.counters)==null?void 0:v[p])||0,m=r[p]||0;return f&&m&&f>=m})}),relevantParticipantIds:l}}const q8="deleteDrawDefinitions",z8="autoSchedulingAudit",gw="deleteEvents";function hw({autoSchedulingAudit:t,tournamentRecords:e}){var r;qe({topic:Dl,payload:t});const n=a=>a?Object.values(a).reduce((c,u)=>c+u.length||0,0):0,o=((t==null?void 0:t.schedulingProfile)||[]).reduce((a,l)=>a+l.venues.reduce((c,u)=>c+u.rounds.length,0),0),i={scheduledDatesCount:(r=t.scheduledDates)==null?void 0:r.length,noTimeMatchUpIdsCount:n(t==null?void 0:t.noTimeMatchUpIds),scheduledMatchUpIdsCount:n(t==null?void 0:t.scheduledMatchUpIds),overLimitMatchUpIdsCount:n(t==null?void 0:t.overLimitMatchUpIds),requestConflictsCount:n(t==null?void 0:t.requestConflicts),profileRoundsCount:o},s={itemType:z8,itemValue:i};for(const a of Object.values(e))xo({tournamentRecord:a,timeItem:s})}var Y8=Object.defineProperty,K8=Object.defineProperties,Q8=Object.getOwnPropertyDescriptors,_w=Object.getOwnPropertySymbols,J8=Object.prototype.hasOwnProperty,Z8=Object.prototype.propertyIsEnumerable,Iw=(t,e,r)=>e in t?Y8(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,X8=(t,e)=>{for(var r in e||(e={}))J8.call(e,r)&&Iw(t,r,e[r]);if(_w)for(var r of _w(e))Z8.call(e,r)&&Iw(t,r,e[r]);return t},e9=(t,e)=>K8(t,Q8(e));function t9({schedulingProfileModifications:t,checkPotentialRequestConflicts:e,scheduleCompletedMatchUps:r,schedulingProfileIssues:n,dateSchedulingProfiles:o,containedStructureIds:i,matchUpDependencies:s,matchUpDailyLimits:a,clearScheduleDates:l,schedulingProfile:c,tournamentRecords:u,personRequests:d,periodLength:p,matchUps:v,courts:f,dryRun:m}){var g,h,_,I,P,y,S;const O={},b={},w={},T={},E={},N={},$={},A={},U={},C={};for(const R of o){const j=Re(R==null?void 0:R.scheduleDate),G=(R==null?void 0:R.venues)||[],W={},z={},F=(Y,Q)=>{Y.forEach(Z=>{const ee=z[Z].counters;ee[Q]?ee[Q]+=1:ee[Q]=1,ee[On]?ee[On]+=1:ee[On]=1})};w[j]={},T[j]={},O[j]={},b[j]={},$[j]=[],A[j]=[],U[j]=[],C[j]=[];const L={};v.forEach(Y=>{var Q;(Q=Y.schedule)!=null&&Q.scheduledDate&&so(j,Re(Y.schedule.scheduledDate))&&Ya({matchUpPotentialParticipantIds:W,matchUpNotBeforeTimes:L,matchUp:Y})});const{venueScheduledRoundDetails:x,allDateMatchUpIds:B}=mw({matchUpPotentialParticipantIds:W,individualParticipantProfiles:z,scheduleCompletedMatchUps:r,containedStructureIds:i,matchUpNotBeforeTimes:L,matchUpScheduleTimes:N,matchUpDependencies:s,clearScheduleDates:l,tournamentRecords:u,useGarman:!0,periodLength:p,scheduleDate:j,matchUps:v,courts:f,venues:G}),H=10;let q=0,J;const K=10;for(;!J;){for(const{venueId:Y}of G){let Q=0;const Z=x[Y];for(;Z.courtsCount&&((g=Z.scheduleTimes)!=null&&g.length)&&((h=Z.matchUpsToSchedule)!=null&&h.length)&&Q<=Z.courtsCount;){const{scheduleTime:ee,attempts:ne=0}=Z.scheduleTimes.shift(),te=Z.matchUpsToSchedule.find(oe=>{var ie,le;const{matchUpId:ae,matchUpType:Ie}=oe,{participantIdsAtLimit:he,relevantParticipantIds:de}=Dm({matchUpPotentialParticipantIds:W,individualParticipantProfiles:z,matchUpDailyLimits:a,matchUp:oe});if(he.length)return A[j].includes(ae)||A[j].push(ae),!1;const{scheduledDependent:Ce}=uw({matchUpScheduleTimes:N,matchUpDependencies:s,scheduleTime:ee,matchUpId:ae,details:Z});if(Ce)return!1;const{dependenciesScheduled:se,remainingDependencies:ce}=Nm({matchUpScheduleTimes:N,matchUpDependencies:s,allDateMatchUpIds:B,matchUp:oe});if(!se)return T[j][ae]||(T[j][ae]=[]),T[j][ae].push({scheduleTime:ee,remainingDependencies:ce}),!1;const{enoughTime:Se}=Mm({individualParticipantProfiles:z,matchUpNotBeforeTimes:L,matchUpDependencies:s,scheduleTime:ee,details:Z,matchUp:oe});if(!Se)return w[j][ae]||(w[j][ae]=[]),w[j][ae].push({scheduleTime:ee}),!1;const je=Z.greatestAverageMinutes,{conflicts:Pe}=Um({potentials:e,averageMatchUpMinutes:je,requestConflicts:C,personRequests:d,scheduleTime:ee,scheduleDate:j,matchUp:oe});if(Pe!=null&&Pe.length)return E[j]||(E[j]=[]),E[j].push(...Pe),!1;F(de,Ie);const Me=(le=(ie=Z.minutesMap)==null?void 0:ie[ae])==null?void 0:le.recoveryMinutes;return Ec({matchUpPotentialParticipantIds:W,individualParticipantProfiles:z,matchUpNotBeforeTimes:L,averageMatchUpMinutes:je,matchUpDependencies:s,recoveryMinutes:Me,scheduleTime:ee,matchUp:oe}),N[ae]=ee,!0});Z.matchUpsToSchedule=Z.matchUpsToSchedule.filter(({matchUpId:oe})=>oe!==(te==null?void 0:te.matchUpId)),te?Q+=1:(b[j][Y]||(b[j][Y]=[]),b[j][Y].push({scheduleTime:ee,attempts:ne+1}))}(_=Z.matchUpsToSchedule)!=null&&_.length&&(b[j][Y]=(I=b[j][Y])==null?void 0:I.filter(ee=>{const ne=ee.attempts<H;return ne&&Z.scheduleTimes.push(ee),!ne})),(!((P=Z.scheduleTimes)!=null&&P.length)||!((y=Z.matchUpsToSchedule)!=null&&y.length))&&(Z.complete=!0)}q+=1,J=G.every(({venueId:Y})=>x[Y].complete)||q===K}for(const{venueId:Y}of G){const Q=x[Y].matchUpMap;Object.keys(Q).forEach(Z=>{const ee=u[Z];ee&&Object.keys(Q[Z]).forEach(ne=>{const{drawDefinition:te}=Xo({tournamentRecord:ee,drawId:ne});te&&Q[Z][ne].forEach(({matchUpId:ie})=>{const le=N[ie];if(le){const ae=le.split(":").map(io).join(":"),Ie=`${Re(j)}T${ae}`;m?$[j].push(ie):(Wi({drawDefinition:te,scheduledTime:Ie,matchUpId:ie}).success&&$[j].push(ie),Y&&ja({tournamentRecord:ee,drawDefinition:te,matchUpId:ie,venueId:Y}))}})})}),U[j]=x[Y].matchUpsToSchedule.map(Jt),O[j][Y]=x[Y].scheduleTimes.sort((Z,ee)=>xe(Z.scheduleTime)-xe(ee.scheduleTime))}for(const Y of R.venues)for(const Q of Y.rounds){const ee=(((S=Q.matchUps)==null?void 0:S.map(({matchUpId:te})=>te))||[]).filter(te=>$[j].includes(te));Q.canScheduledMatchUpIds=ee;let ne=Math.round(ee.length/Q.matchUpsCount*1e4)/100;(ne===1/0||isNaN(ne))&&(ne=0),Q.possibleToSchedulePct=ne,Q.matchUpsCount===ee.length&&(Q.possibleToSchedule=!0)}}const M=o.map(({scheduleDate:R})=>R),D={timeStamp:Date.now(),overLimitMatchUpIds:A,scheduledMatchUpIds:$,schedulingProfile:c,noTimeMatchUpIds:U,requestConflicts:C,scheduledDates:M};return hw({tournamentRecords:u,autoSchedulingAudit:D}),e9(X8({},V),{schedulingProfileModifications:t,schedulingProfileIssues:n,scheduleTimesRemaining:O,dateSchedulingProfiles:o,skippedScheduleTimes:b,recoveryTimeDeferredMatchUpIds:w,dependencyDeferredMatchUpIds:T,matchUpScheduleTimes:N,overLimitMatchUpIds:A,scheduledMatchUpIds:$,noTimeMatchUpIds:U,requestConflicts:C,scheduledDates:M})}function Pw({averageMinutes:t,startTime:e,endTime:r,court:n,date:o}){if(!Array.isArray(n.dateAvailability))return{error:_e,stack:"getEarliestCourtTime"};const i=Ma({scheduleDate:o,courts:[n],startTime:!0}),s=Ma({scheduleDate:o,courts:[n],endTime:!0});e=e||i,r=r||s;const a=cc({court:n,date:o}),l=Ca({courtDate:a}),c=wt(e),u=wt(r);return{earliestCourtTime:l.reduce((p,v)=>{const f=wt(v.startTime),m=wt(v.endTime);if(f>u||m<c)return p;const g=c>f?c:f;if(Ol(g,m)>=t){const I=ct(g.toISOString());(!p||I<p)&&(p=I)}return p},void 0),courtStartTime:i,courtEndTime:s}}var r9=Object.defineProperty,n9=Object.defineProperties,o9=Object.getOwnPropertyDescriptors,yw=Object.getOwnPropertySymbols,i9=Object.prototype.hasOwnProperty,s9=Object.prototype.propertyIsEnumerable,Sw=(t,e,r)=>e in t?r9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,a9=(t,e)=>{for(var r in e||(e={}))i9.call(e,r)&&Sw(t,r,e[r]);if(yw)for(var r of yw(e))s9.call(e,r)&&Sw(t,r,e[r]);return t},l9=(t,e)=>n9(t,o9(e));function c9({schedulingProfileModifications:t,checkPotentialRequestConflicts:e,scheduleCompletedMatchUps:r,schedulingProfileIssues:n,dateSchedulingProfiles:o,containedStructureIds:i,matchUpDependencies:s,matchUpDailyLimits:a,clearScheduleDates:l,tournamentRecords:c,periodLength:u=30,schedulingProfile:d,personRequests:p,matchUps:v,courts:f,dryRun:m}){var g;const h={},_={},I={},P={},y={},S={},O={},b={},w={};for(const N of o){const $=Re(N==null?void 0:N.scheduleDate),A=(N==null?void 0:N.venues)||[],U={},C={},M=(K,Y)=>{K.forEach(Q=>{const Z=C[Q].counters;Z[Y]?Z[Y]+=1:Z[Y]=1,Z[On]?Z[On]+=1:Z[On]=1})};h[$]={},_[$]={},S[$]=[],O[$]=[],b[$]=[],w[$]=[];const D={};v.forEach(K=>{var Y;(Y=K.schedule)!=null&&Y.scheduledDate&&so($,Re(K.schedule.scheduledDate))&&Ya({matchUpPotentialParticipantIds:U,matchUpNotBeforeTimes:D,matchUp:K})});const{allDateScheduledMatchUpIds:R,venueScheduledRoundDetails:j,allDateMatchUpIds:G}=mw({matchUpPotentialParticipantIds:U,individualParticipantProfiles:C,scheduleCompletedMatchUps:r,containedStructureIds:i,matchUpNotBeforeTimes:D,matchUpScheduleTimes:y,matchUpDependencies:s,clearScheduleDates:l,tournamentRecords:c,periodLength:u,scheduleDate:$,matchUps:v,courts:f,venues:A}),W=v.filter(({matchUpId:K})=>R.includes(K)),{bookings:z}=Cm({dateScheduledMatchUps:W,tournamentRecords:c,scheduleDate:$,periodLength:u}),{virtualCourts:F}=Vv({scheduleDate:$,periodLength:u,bookings:z,courts:f}),L=F==null?void 0:F.reduce((K,Y)=>{const{earliestCourtTime:Q,courtEndTime:Z}=Pw({date:$,averageMinutes:0,court:Y});return(!K.startTime||wt(Q)<wt(K.startTime))&&(K.startTime=Q),(!K.endTime||wt(Z)>wt(K.endTime))&&(K.endTime=Z),K},{});let x=L.startTime;const B=({courtId:K,booking:Y})=>{var Q;return(Q=F==null?void 0:F.find(Z=>Z.courtId===K))==null?void 0:Q.dateAvailability[0].bookings.push(Y)},H=10;let q=0,J;for(;!J;){for(const{venueId:K}of A){const Y=j[K],Q=Y.matchUpsToSchedule.length,Z=[],ee=[];let ne,te=0;for(;!ne;){for(const oe of Y.matchUpsToSchedule){if(ee.length===Y.courtsCount||Z.length===Y.courtsCount){ne=!0;break}const{matchUpId:ie,matchUpType:le}=oe,{participantIdsAtLimit:ae,relevantParticipantIds:Ie}=Dm({matchUpPotentialParticipantIds:U,individualParticipantProfiles:C,matchUpDailyLimits:a,matchUp:oe});if(ae.length){O[$].includes(ie)||O[$].push(ie);continue}const{dependenciesScheduled:he,remainingDependencies:de}=Nm({matchUpScheduleTimes:y,matchUpDependencies:s,allDateMatchUpIds:G,matchUp:oe});if(!he){_[$][ie]||(_[$][ie]=[]),_[$][ie].push({remainingDependencies:de});continue}const Ce=[],se=F==null?void 0:F.reduce((ce,Se)=>{var je,Pe,Me,Le;if(ee.includes(Se.courtId))return ce;const{earliestCourtTime:Ye}=Pw({averageMinutes:Y.greatestAverageMinutes,startTime:x,date:$,court:Se});if(ce.scheduleTime&&xe(Ye)>=xe(ce.scheduleTime))return ce;const{scheduledDependent:Te}=uw({matchUpScheduleTimes:y,matchUpDependencies:s,scheduleTime:Ye,matchUpId:ie,details:Y});if(Te)return ce;const{enoughTime:De}=Mm({individualParticipantProfiles:C,matchUpNotBeforeTimes:D,matchUpDependencies:s,scheduleTime:Ye,details:Y,matchUp:oe});if(!De)return h[$][ie]||(h[$][ie]=[]),h[$][ie].includes(Ye)||h[$][ie].push(Ye),ce;const We=((Pe=(je=Y.minutesMap)==null?void 0:je[ie])==null?void 0:Pe.averageMinutes)||Y.greatestAverageMinutes,{conflicts:me}=Um({potentials:e,averageMatchUpMinutes:We,requestConflicts:w,personRequests:p,scheduleTime:Ye,scheduleDate:$,matchUp:oe});if(me!=null&&me.length)return Ce.push(...me),!1;M(Ie,le);const ue=(Le=(Me=Y.minutesMap)==null?void 0:Me[ie])==null?void 0:Le.recoveryMinutes;return Ec({matchUpPotentialParticipantIds:U,individualParticipantProfiles:C,matchUpNotBeforeTimes:D,averageMatchUpMinutes:We,matchUpDependencies:s,recoveryMinutes:ue,scheduleTime:Ye,matchUp:oe}),(!ce.scheduleTime||xe(Ye)<xe(ce.scheduleTime))&&(ce.averageMatchUpMinutes=We,ce.recoveryMinutes=ue,ce.scheduleTime=Ye,ce.courtName=Se.courtName,ce.courtId=Se.courtId),ce},{});if(se.scheduleTime){const{averageMatchUpMinutes:ce,recoveryMinutes:Se,scheduleTime:je,courtId:Pe}=se;y[ie]=je,P[ie]=Pe,Z.push(ie),ee.push(Pe);const Me=je,Le=Sr(Me,ce);B({courtId:Pe,booking:{averageMatchUpMinutes:ce,recoveryMinutes:Se,periodLength:u,matchUpId:ie,startTime:Me,courtId:Pe,endTime:Le,venueId:K}}),Y.matchUpsToSchedule=Y.matchUpsToSchedule.filter(Te=>Te.matchUpId!==ie)}else Ce!=null&&Ce.length&&(I[$]||(I[$]=[]),I[$].push(...Ce))}(ee.length===Y.courtsCount||Z.length===Y.courtsCount||!Y.matchUpsToSchedule.length)&&(ne=!0),Y.matchUpsToSchedule.length&&Z<Y.courtsCount&&(wt(x)<wt(L.endTime)?x=Sr(x,u):(ne=!0,Y.complete=!0)),te+=1,!ne&&te>=Q&&(ne=!0)}(g=Y.matchUpsToSchedule)!=null&&g.length||(Y.complete=!0)}q+=1,J=A.every(({venueId:K})=>j[K].complete)||q===H}for(const{venueId:K}of A){const Y=j[K].matchUpMap;Object.keys(Y).forEach(Q=>{const Z=c[Q];Z&&Object.keys(Y[Q]).forEach(ee=>{const{drawDefinition:ne}=Xo({tournamentRecord:Z,drawId:ee});ne&&Y[Q][ee].forEach(({matchUpId:oe})=>{const ie=y[oe],le=P[oe];if(ie){const ae=ie.split(":").map(io).join(":"),Ie=`${Re($)}T${ae}`;m||(Wi({drawDefinition:ne,scheduledTime:Ie,matchUpId:oe}),js({courtDayDate:$,tournamentRecords:c,tournamentRecord:Z,drawDefinition:ne,matchUpId:oe,courtId:le})),S[$].push(oe)}})})}),b[$]=j[K].matchUpsToSchedule.map(Jt)}for(const K of N.venues)for(const Y of K.rounds){const Z=Y.matchUps.map(({matchUpId:ne})=>ne).filter(ne=>S[$].includes(ne));Y.canScheduledMatchUpIds=Z;let ee=Math.round(Z.length/Y.matchUpsCount*1e4)/100;(ee===1/0||isNaN(ee))&&(ee=0),Y.possibleToSchedulePct=ee,Y.matchUpsCount===Z.length&&(Y.possibleToSchedule=!0)}}const T=o.map(({scheduleDate:N})=>N),E={timeStamp:Date.now(),overLimitMatchUpIds:O,scheduledMatchUpIds:S,schedulingProfile:d,noTimeMatchUpIds:b,requestConflicts:w,scheduledDates:T};return hw({tournamentRecords:c,autoSchedulingAudit:E}),l9(a9({},V),{schedulingProfileModifications:t,schedulingProfileIssues:n,dateSchedulingProfiles:o,recoveryTimeDeferredMatchUpIds:h,dependencyDeferredMatchUpIds:_,matchUpScheduleTimes:y,overLimitMatchUpIds:O,scheduledMatchUpIds:S,noTimeMatchUpIds:b,requestConflicts:w,scheduledDates:T})}var u9=Object.defineProperty,Ow=Object.getOwnPropertySymbols,d9=Object.prototype.hasOwnProperty,p9=Object.prototype.propertyIsEnumerable,bw=(t,e,r)=>e in t?u9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Tw=(t,e)=>{for(var r in e||(e={}))d9.call(e,r)&&bw(t,r,e[r]);if(Ow)for(var r of Ow(e))p9.call(e,r)&&bw(t,r,e[r]);return t};function Ka({tournamentRecords:t,requestType:e}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const r={};for(const n of Object.values(t)){const{extension:o}=Fr({name:va,tournamentRecord:n}),i=(o==null?void 0:o.value)||[];for(const s of i){const{personId:a,requests:l}=s||{};r[a]||(r[a]=[]);for(const c of l)e&&c.requestType!==e||r[a].push(c)}}return{personRequests:r}}function jm({tournamentRecords:t,personRequests:e}){var r;if(!t)return{error:ke};if(!e)return Tw({},V);const n=Object.values(t);for(const o of n){const i=(r=o.participants)!=null?r:[],s=[];for(const a of Object.keys(e))if($o({tournamentParticipants:i,personId:a})){const l=e[a];l.length&&s.push({personId:a,requests:l})}Object.keys(s).length&&Ni({tournamentRecord:o,extension:{name:va,value:s}})}return Tw({},V)}function f9({tournamentRecords:t,personId:e,requests:r}){if(!t)return{error:ke};if(typeof e!="string")return{error:X};if(!Array.isArray(r))return{error:X};const{personRequests:n}=Ka({tournamentRecords:t}),{mergeCount:o}=ww({personRequests:n,personId:e,requests:r});return o&&n?jm({tournamentRecords:t,personRequests:n}):{error:X}}function ww({personRequests:t,personId:e,requests:r}){t[e]||(t[e]=[]);const n=r.filter(({requestType:o})=>o).map(o=>{let{date:i,startTime:s,endTime:a}=o;return o.requestType===Bd&&(i=Re(i),s=ct(s),a=ct(a),i&&s&&a)?{date:i,startTime:s,endTime:a,requestType:o.requestType}:o}).filter(Boolean);for(const o of n)o.requestId=C_(),t[e].push(o);return{mergeCount:n.length}}function v9({tournamentRecords:t,requestType:e,requestId:r,personId:n,date:o}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const{personRequests:i}=Ka({tournamentRecords:t}),s=l=>{var c;i&&(i[l]=i[l].filter(u=>(!e||u.requestType!==e)&&(!r||u.requestId!==r)&&(!o||u.date!==o)),(c=i==null?void 0:i[l])!=null&&c.length||delete i[l])},a=!e&&!r&&!n&&!o;if(!a){if(n&&(i!=null&&i[n]))s(n);else if(i)for(const l of Object.keys(i))s(l)}return a||!i||!Object.keys(i).length?wu({tournamentRecords:t,name:va}):jm({tournamentRecords:t,personRequests:i})}function m9({tournamentRecords:t,requests:e,personId:r}){if(!t)return{error:ke};if(!Array.isArray(e))return{error:X};const n=e.map(({requestId:a})=>a).filter(Boolean),{personRequests:o}=Ka({tournamentRecords:t}),i=a=>{o&&(o[a]=o[a].map(l=>{if(!n.includes(l.requestId))return l;const c=e.find(u=>u.requestId===l.requestId);if(c.requestType)return Object.assign(l,c)}).filter(Boolean))};if(r&&(o!=null&&o[r]))i(r);else if(o)for(const a of Object.keys(o))i(a);const s=e.filter(a=>!a.requestId);return s.length&&ww({personRequests:o,personId:r,requests:s}),jm({tournamentRecords:t,personRequests:o})}var g9=Object.defineProperty,h9=Object.defineProperties,_9=Object.getOwnPropertyDescriptors,Ew=Object.getOwnPropertySymbols,I9=Object.prototype.hasOwnProperty,P9=Object.prototype.propertyIsEnumerable,$w=(t,e,r)=>e in t?g9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,y9=(t,e)=>{for(var r in e||(e={}))I9.call(e,r)&&$w(t,r,e[r]);if(Ew)for(var r of Ew(e))P9.call(e,r)&&$w(t,r,e[r]);return t},S9=(t,e)=>h9(t,_9(e));function Rm({scheduleAttributes:t=["scheduledDate","scheduledTime"],ignoreMatchUpStatuses:e=Yt,tournamentRecord:r,scheduledDates:n,venueIds:o=[]}){if(typeof r!="object")return{error:re};if(!Array.isArray(e)||!Array.isArray(o))return{error:X};o.length&&t.push("venueId");const s=(Wt({matchUpFilters:{scheduledDates:n},tournamentRecord:r}).matchUps||[]).filter(c=>c.matchUpStatus&&!e.includes(c.matchUpStatus)&&Sc({schedule:c.schedule,scheduleAttributes:t})&&(!(o!=null&&o.length)||o.includes(c.schedule.venueId))).map(Jt),a=Wt({tournamentRecord:r,inContext:!1}).matchUps||[];let l=0;for(const c of a)s.includes(c.matchUpId)&&(c.timeItems=(c.timeItems||[]).filter(u=>(u==null?void 0:u.itemType)&&![ti,hs,Rl,Fl,xl].includes(u==null?void 0:u.itemType)),l+=1);return S9(y9({},V),{clearedScheduleCount:l})}var O9=Object.defineProperty,Nw=Object.getOwnPropertySymbols,b9=Object.prototype.hasOwnProperty,T9=Object.prototype.propertyIsEnumerable,Uw=(t,e,r)=>e in t?O9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,w9=(t,e)=>{for(var r in e||(e={}))b9.call(e,r)&&Uw(t,r,e[r]);if(Nw)for(var r of Nw(e))T9.call(e,r)&&Uw(t,r,e[r]);return t};function Aw({scheduleAttributes:t=["scheduledDate","scheduledTime"],ignoreMatchUpStatuses:e=Yt,tournamentRecords:r,scheduledDates:n,venueIds:o}){const i=ns(r)?Object.values(r).map(({tournamentId:s})=>s).filter(Boolean):[];if(!(i!=null&&i.length))return{error:ke};for(const s of i){const a=r[s],l=Rm({ignoreMatchUpStatuses:e,scheduleAttributes:t,tournamentRecord:a,scheduledDates:n,venueIds:o});if(l.error)return l}return w9({},V)}function Cw({tournamentRecord:t}){var e;if(!t)return{error:re};const{policy:r}=us({policyType:Nf,tournamentRecord:t}),{extension:n}=Fr({name:as,tournamentRecord:t}),o=(e=n==null?void 0:n.value)==null?void 0:e.dailyLimits,i=r==null?void 0:r.defaultDailyLimits;return{matchUpDailyLimits:o||i}}function Mw({tournamentRecords:t,tournamentId:e}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};const r=Object.keys(t).filter(o=>!e||o===e);let n;return r.forEach(o=>{const i=t[o],{matchUpDailyLimits:s}=Cw({tournamentRecord:i});n=s}),{matchUpDailyLimits:n}}function Fm({checkPotentialRequestConflicts:t=!0,scheduleCompletedMatchUps:e,clearScheduleDates:r,scheduleDates:n=[],tournamentRecords:o,periodLength:i,dryRun:s,pro:a}){if(!o)return{error:ke};if(!Array.isArray(n))return{error:X};const l=za({tournamentRecords:o});if(l.error)return l;const{schedulingProfile:c=[],issues:u=[],modifications:d}=l,p=Object.assign({},...Object.values(o).map(S=>Ra({tournamentRecord:S}).containedStructures)),v=n.map(S=>{if(Gr(S))return Re(S)}).filter(Boolean),f=c.map(S=>S.scheduleDate).map(S=>Gr(S)&&Re(S)).filter(S=>S&&(!n.length||v.includes(S)));if(!f.length)return{error:_x};if(r&&!s){const S=Array.isArray(r)?r:[];Aw({tournamentRecords:o,scheduledDates:S})}const{courts:m}=Ds({dates:n,ignoreDisabled:!0,tournamentRecords:o}),{matchUps:g}=Fo({matchUpFilters:{matchUpTypes:[Nt,ft]},afterRecoveryTimes:!0,nextMatchUps:!0,tournamentRecords:o}),{matchUpDependencies:h}=pn({includeParticipantDependencies:!0,tournamentRecords:o,matchUps:g}),{matchUpDailyLimits:_}=Mw({tournamentRecords:o}),{personRequests:I}=Ka({requestType:Bd,tournamentRecords:o}),P=c.filter(S=>{const O=Re(S==null?void 0:S.scheduleDate);return f.includes(O)}).sort((S,O)=>new Date(S.scheduleDate).getTime()-new Date(O.scheduleDate).getTime()),y={schedulingProfileModifications:d,checkPotentialRequestConflicts:t,scheduleCompletedMatchUps:e,schedulingProfileIssues:u,dateSchedulingProfiles:P,containedStructureIds:p,matchUpDependencies:h,matchUpDailyLimits:_,clearScheduleDates:r,tournamentRecords:o,schedulingProfile:c,personRequests:I,periodLength:i,matchUps:g,dryRun:s,courts:m};return a?c9(y):t9(y)}function Dw({event:t}){return t?bu({event:t,name:Hn}):{error:Ge}}function E9({tournamentRecords:t,eventId:e}){if(!t)return{error:ke};if(typeof e!="string")return{error:_e,info:"missing eventId"};for(const r of Object.values(t)){const{event:n}=Qt({tournamentRecord:r,eventId:e});if(n)return Dw({event:n})}return{error:Ur}}function $9(t){Object.assign(t,{inContext:!0});const{matchUp:e,error:r}=$c(t);return{matchUp:ve(e,!0,!0),error:r}}function $c({participantsProfile:t,afterRecoveryTimes:e,tournamentRecord:r,contextContent:n,contextProfile:o,drawDefinition:i,matchUpId:s,inContext:a,eventId:l,drawId:c,event:u}){if(!r)return{error:re};if(typeof s!="string")return{error:Vt};if(!i||!u){const g=(Wt({tournamentRecord:r}).matchUps||[]).find(h=>h.matchUpId===s);if(!g)return{error:ir};({eventId:l,drawId:c}=g),{event:u,drawDefinition:i}=Qt({tournamentRecord:r,eventId:l,drawId:c})}if(!i)return{error:tn};o&&!n&&(n=Eo({tournamentRecord:r,contextProfile:o}));const d={surfaceCategory:(u==null?void 0:u.surfaceCategory)||r.surfaceCategory,indoorOutDoor:(u==null?void 0:u.indoorOutdoor)||r.indoorOutdoor,endDate:(u==null?void 0:u.endDate)||r.endDate,tournamentId:r.tournamentId,eventId:l||(u==null?void 0:u.eventId),drawId:c},{participants:p=[]}=Cs({participantsProfile:t,tournamentRecord:r,contextProfile:o,inContext:a}),{matchUp:v,structure:f}=ut({context:a?d:void 0,tournamentParticipants:p,afterRecoveryTimes:e,contextContent:n,drawDefinition:i,contextProfile:o,matchUpId:s,inContext:a,event:u});return{matchUp:v,structure:f,drawDefinition:i}}function xm({tournamentParticipants:t,tournamentRecord:e,drawDefinition:r,participantId:n,matchUpId:o,matchUp:i,event:s}){if(!n)return{error:Tt};if(!o)return{error:jr};if(t=t??(e==null?void 0:e.participants),t!=null&&t.length){if(!i&&r){const d=ut({tournamentParticipants:t,inContext:!0,drawDefinition:r,matchUpId:o,event:s});if(!d.matchUp)return{error:ir};i=d.matchUp}const l=tc({matchUp:i});if(l.error)return l;const{checkedInParticipantIds:c,allRelevantParticipantIds:u}=l;if(!u.includes(n))return{error:Oo};if(c.includes(n))return{error:l_}}return Mr({tournamentRecord:e,drawDefinition:r,matchUpId:o,timeItem:{itemType:Jf,itemValue:n}})}function Lm({tournamentParticipants:t,tournamentRecord:e,drawDefinition:r,participantId:n,matchUpId:o,matchUp:i,event:s}){if(!n)return{error:Tt};if(!o&&!i)return{error:Vt};if(t=t??(e==null?void 0:e.participants),!i){const u=ut({tournamentParticipants:t,inContext:!0,drawDefinition:r,matchUpId:o,event:s});if(u.error)return u;if(!u.matchUp)return{error:ir};i=u.matchUp}const{matchUpStatus:a,score:l}=i;if(a&&H_.includes(a)||a&&Yt.includes(a)||Gt({score:l}))return{error:tx};if(t!=null&&t.length){const{checkedInParticipantIds:u,allRelevantParticipantIds:d}=tc({matchUp:i});if(!(d!=null&&d.includes(n)))return{error:Oo};if(!u.includes(n))return{error:Nx};const{sideParticipantIds:p,nestedIndividualParticipantIds:v}=pv({matchUp:i}),f=p.indexOf(n);[0,1].includes(f)&&(v[f]||[]).forEach(m=>{Mr({drawDefinition:r,matchUpId:o,timeItem:{itemType:Zf,itemValue:m}})})}return Mr({tournamentRecord:e,drawDefinition:r,matchUpId:o,timeItem:{itemType:Zf,itemValue:n}})}function jw(t){if(!(t!=null&&t.tournamentRecord))return{error:re};const{tournamentRecord:e,participantId:r,matchUpId:n,drawDefinition:o,event:i}=t,s=e.participants||[],a=$c({tournamentRecord:e,inContext:!0,drawDefinition:o,matchUpId:n,event:i});if(!a.matchUp)return{error:ir};const l=a.matchUp,{checkedInParticipantIds:c=[]}=tc({matchUp:l});return c.includes(r)?Lm({tournamentParticipants:s,tournamentRecord:e,drawDefinition:o,participantId:r,matchUpId:n,matchUp:l}):xm({tournamentParticipants:s,tournamentRecord:e,drawDefinition:o,participantId:r,matchUpId:n,matchUp:l})}function N9(t){const{tournamentRecords:e}=t,{participantId:r,tournamentId:n,matchUpId:o,drawId:i}=t;if(!e||!n||!r||!o)return{error:_e,stack:"toggleParticipantCheckInState"};const s=e[n],{drawDefinition:a,event:l}=Xo({tournamentRecord:s,drawId:i});return Object.assign(t,{drawDefinition:a,event:l,tournamentRecord:s}),jw(t)}function Rw(t){var e;const{tournamentRecords:r}=t;if(!r)return{error:ke};const{removePriorValues:n,tournamentId:o,courtDayDate:i,matchUpId:s,courtId:a,drawId:l}=t,c=r[o];if(!c)return{error:re};const{drawDefinition:u,event:d}=Xo({tournamentRecord:c,drawId:l}),p=ut({drawDefinition:u,event:d,matchUpId:s});if(p.error)return p;if(((e=p==null?void 0:p.matchUp)==null?void 0:e.matchUpType)===In){const{itemValue:v}=Ai({timeItems:p.matchUp.timeItems||[],itemType:ti}),f=a&&v.filter(g=>g.courtId!==a);return Mr({duplicateValues:!1,removePriorValues:n,tournamentRecord:c,drawDefinition:u,matchUpId:s,timeItem:{itemType:ti,itemValue:f}})}else return js({tournamentRecord:c,drawDefinition:u,courtDayDate:i,courtId:"",matchUpId:s})}function U9({tournamentRecords:t}){return HT({extensionName:as,tournamentRecords:t})}var A9=Object.defineProperty,C9=Object.defineProperties,M9=Object.getOwnPropertyDescriptors,Fw=Object.getOwnPropertySymbols,D9=Object.prototype.hasOwnProperty,j9=Object.prototype.propertyIsEnumerable,xw=(t,e,r)=>e in t?A9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bs=(t,e)=>{for(var r in e||(e={}))D9.call(e,r)&&xw(t,r,e[r]);if(Fw)for(var r of Fw(e))j9.call(e,r)&&xw(t,r,e[r]);return t},kd=(t,e)=>C9(t,M9(e));const{stageOrder:Lw}=gG;function Vm({tournamentRecords:t,schedulingProfile:e,tournamentRecord:r,withRoundId:n}){if(r&&!t){if(typeof r!="object")return{error:Kc};t={[r.tournamentId]:r}}if(e){const s=Fd({tournamentRecords:t,schedulingProfile:e});if(s.error)return s}if(!e&&t){const s=za({tournamentRecords:t});if(s.error)return s;e=s.schedulingProfile}if(!e)return{error:sr};const o={};return{profileRounds:e.map(({venues:s,scheduleDate:a})=>s.map(({rounds:l})=>l.map(c=>{var u;const d=Bm(c);return(u=d.roundSegment)!=null&&u.segmentsCount&&(o[d.id]=d.roundSegment.segmentsCount),ye(Bs({id:n?d.id:void 0,scheduleDate:a},d))}))).flat(1/0),segmentedRounds:o}}function Bm(t){const{containerStructureId:e,roundSegment:r,isRoundRobin:n,tournamentId:o,roundNumber:i,structureId:s,eventId:a,drawId:l}=t,c=n?e:s,u=[o,a,l,c,i].join("|");return ye({id:u,roundSegment:r,tournamentId:o,eventId:a,drawId:l,structureId:c,roundNumber:i})}function Vw(t){const e=t.length,r=t.filter(({sides:u})=>u==null?void 0:u.some(({bye:d})=>d)).length||0,n=t.filter(({winningSide:u,matchUpStatus:d})=>u||Yt.includes(d)).length||0,o=t.filter(({schedule:u})=>(u==null?void 0:u.scheduledDate)&&(u==null?void 0:u.scheduledTime)).length||0,i=e-r,s=i===n,a=i-o,l=i-o;return{unscheduledCount:a,incompleteCount:l,scheduledCount:o,completedCount:n,matchUpsCount:e,isScheduled:i===o,isComplete:s,byeCount:r}}function Bw({excludeScheduleDateProfileRounds:t,excludeScheduledRounds:e,excludeCompletedRounds:r,inContextMatchUps:n,tournamentRecords:o,schedulingProfile:i,tournamentRecord:s,withSplitRounds:a,matchUpFilters:l,withRoundId:c,context:u}){var d;if(n&&!Array.isArray(n||typeof n[0]!="object"))return{error:X,inContextMatchUps:n};if(s&&!o){if(typeof s!="object")return{error:Kc};o={[s.tournamentId]:s}}const p=typeof o!="object"||!Object.keys(o).length;if((!n||!i&&(t||r||i||a))&&p)return{error:ke};const f=Object.values(o??{}).map(({events:y})=>y).flat(),{segmentedRounds:m,profileRounds:g}=o&&(t||r||i||a)&&Vm({tournamentRecords:o,schedulingProfile:i})||{},h=t&&Object.assign({},...g.map(y=>({[y.id]:y}))),_=n||o&&((d=Fo({tournamentRecords:o,matchUpFilters:l}))==null?void 0:d.matchUps)||[],I=[],P=_&&Object.values(_.reduce((y,S)=>{var O,b;const w=Bm(S).id,T=m==null?void 0:m[w],E=[...(b=(O=y[w])==null?void 0:O.matchUps)!=null?b:[],S],{containerStructureId:N,stageSequence:$,structureName:A,tournamentId:U,isRoundRobin:C,matchUpType:M,roundNumber:D,roundOffset:R,structureId:j,eventName:G,roundName:W,drawName:z,eventId:F,drawId:L}=S,x=C?N:j;return kd(Bs({},y),{[w]:{id:c?w:void 0,structureId:x,stageSequence:$,segmentsCount:T,structureName:A,tournamentId:U,matchUpType:M,roundNumber:D,roundOffset:R,eventName:G,roundName:W,drawName:z,matchUps:E,eventId:F,drawId:L}})},{})).map(y=>{const{minFinishingSum:S,winnerFinishingPositionRange:O}=F9(y.matchUps),b=y.segmentsCount;if(b){const C=y.matchUps.length/b;return qt(y.matchUps.sort((D,R)=>D.roundPosition-R.roundPosition),C).map((D,R)=>{const{unscheduledCount:j,incompleteCount:G,matchUpsCount:W,isScheduled:z,isComplete:F,byeCount:L}=Vw(D),x=kw({matchUps:y.matchUps,tournamentRecords:o,events:f,round:y});return ye(kd(Bs(Bs({},y),u),{roundSegment:{segmentsCount:b,segmentNumber:R+1},winnerFinishingPositionRange:O,unscheduledCount:j,incompleteCount:G,minFinishingSum:S,matchUpsCount:W,isScheduled:z,roundTiming:x,isComplete:F,byeCount:L,matchUps:D}))})}const{unscheduledCount:w,incompleteCount:T,matchUpsCount:E,isScheduled:N,isComplete:$,byeCount:A}=Vw(y.matchUps),U=kw({matchUps:y.matchUps,tournamentRecords:o,events:f,round:y});return ye(kd(Bs(Bs({},y),u),{winnerFinishingPositionRange:O,unscheduledCount:w,incompleteCount:T,minFinishingSum:S,matchUpsCount:E,isScheduled:N,roundTiming:U,isComplete:$,byeCount:A}))}).flat().filter(y=>{if(t){const E=Re(t),N=c?y.id:Bm(y).id;if(E&&h[N]&&Re(h[N].scheduleDate)===E)return!1}const{isComplete:S,isScheduled:O}=y,T=(!r||!S)&&(!e||!O);return T||I.push(y),T}).sort(R9)||[];return kd(Bs({},V),{rounds:P,excludedRounds:I})}function kw({round:t,matchUps:e,events:r,tournamentRecords:n}){const o=r.find(p=>p.eventId===t.eventId),{eventType:i,category:s,categoryType:a}=o||{},{categoryName:l,ageCategoryCode:c}=s||{},u=$r(e.map(({matchUpFormat:p})=>p));let d=0;return Object.keys(u).forEach(p=>{const v=u[p],f=bm({categoryName:l||c,tournamentId:t.tournamentId,eventId:t.eventId,tournamentRecords:n,matchUpFormat:p,categoryType:a,eventType:i});if(f.error)return f;const m=f.averageMinutes*v;isNaN(d)||(d+=m)}),{roundMinutes:d}}function R9(t,e){return t.eventName.localeCompare(e.eventName)||t.eventId.localeCompare(e.eventId)||(Lw[t==null?void 0:t.stage]||0)-(Lw[e==null?void 0:e.stage]||0)||e.matchUpsCount-t.matchUpsCount||`${t.stageSequence}-${t.roundNumber}-${t.minFinishingSum}`.localeCompare(`${e.stageSequence}-${e.roundNumber}-${e.minFinishingSum}`)}function F9(t){return(t||[]).reduce((e,r)=>{var n,o;const i=(((n=r.finishingPositionRange)==null?void 0:n.winner)||[]).reduce((a,l)=>a+l,0),s=(((o=r.finishingPositionRange)==null?void 0:o.winner)||[]).join("-")||"";return!e.minFinishingSum||i<e.minFinishingSum?{minFinishingSum:i,winnerFinishingPositionRange:s}:e},{minFinishingSum:0,winnerFinishingPositionRange:""})}function x9({tournamentRecords:t,courtAssignments:e,courtDayDate:r}){if(!t)return{error:ke};if(!Array.isArray(e))return{error:_e,info:or("courtAssignments")};const n=e.reduce((s,a)=>{const{tournamentId:l}=a;return s[l]||(s[l]=[]),s[l].push(a),s},{});let o;return Object.keys(n).every(s=>{const a=t[s];if(!a)return o={error:re},!1;const l=n[s].reduce((u,d)=>{const{drawId:p}=d;return u[p]||(u[p]=[]),u[p].push(d),u},{});Object.keys(l).every(u=>{const{drawDefinition:d}=Qt({tournamentRecord:a,drawId:u});return d?(l[u].every(p=>{const{matchUpId:v,courtId:f}=p,m=js({tournamentRecord:a,drawDefinition:d,courtDayDate:r,matchUpId:v,courtId:f});if(m.success)return m==null?void 0:m.success;o={error:zx}}),!0):(o={error:fe},!1)})}),o||V}var L9=Object.defineProperty,V9=Object.defineProperties,B9=Object.getOwnPropertyDescriptors,Gw=Object.getOwnPropertySymbols,k9=Object.prototype.hasOwnProperty,G9=Object.prototype.propertyIsEnumerable,Ww=(t,e,r)=>e in t?L9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,W9=(t,e)=>{for(var r in e||(e={}))k9.call(e,r)&&Ww(t,r,e[r]);if(Gw)for(var r of Gw(e))G9.call(e,r)&&Ww(t,r,e[r]);return t},H9=(t,e)=>V9(t,B9(e));function q9({tournamentRecords:t,competitionMatchUps:e,matchUpDependencies:r,allDateMatchUpIds:n=[],averageMatchUpMinutes:o=90,recoveryMinutes:i=0,recoveryMinutesMap:s,matchUpPotentialParticipantIds:a={},individualParticipantProfiles:l={},matchUpNotBeforeTimes:c={},matchUpDailyLimits:u={},checkPotentialRequestConflicts:d=!0,remainingScheduleTimes:p,clearScheduleDates:v,periodLength:f=30,scheduleDate:m,matchUpIds:g,venueIds:h,startTime:_,endTime:I,dryRun:P}){if(!t)return{error:ke};if(!g)return{error:ml};if(!Gr(m))return{error:yr};if(isNaN(f)||isNaN(o)||isNaN(i))return{error:X};e||({matchUps:e}=Fo({tournamentRecords:t,nextMatchUps:!0})),r||({matchUpDependencies:r}=pn({includeParticipantDependencies:!0,matchUps:e,tournamentRecords:t})),e.forEach(F=>{var L;(L=F.schedule)!=null&&L.scheduledDate&&so(m,Re(F.schedule.scheduledDate))&&Ya({matchUpPotentialParticipantIds:a,matchUpNotBeforeTimes:c,matchUp:F})});const y=g.map(F=>e.find(L=>L.matchUpId===F)).filter(Boolean),{venueId:S,scheduleTimes:O,dateScheduledMatchUpIds:b}=cw({tournamentRecords:t,remainingScheduleTimes:p,startTime:ct(_),endTime:ct(I),scheduleDate:Re(m),averageMatchUpMinutes:o,clearScheduleDates:v,periodLength:f,venueIds:h}),w={},T=[],E={},N={},$={};e.filter(({matchUpId:F})=>b==null?void 0:b.includes(F)).forEach(F=>{var L;Am({matchUpPotentialParticipantIds:a,individualParticipantProfiles:l,matchUp:F,value:1});const x=(L=F.schedule)==null?void 0:L.scheduledTime;if(x){E[F.matchUpId]=x;const B=s==null?void 0:s[F.matchUpId];Ec({recoveryMinutes:B||i,matchUpPotentialParticipantIds:a,individualParticipantProfiles:l,matchUpNotBeforeTimes:c,averageMatchUpMinutes:o,matchUpDependencies:r,scheduleTime:x,matchUp:F})}});let U=y.filter(F=>{const L=b==null?void 0:b.includes(F.matchUpId),x=[nt,et,At,Wr,hr,ot].includes(F==null?void 0:F.matchUpStatus);return!L&&!F.winningSide&&!x});const{matchUpMap:C,overLimitMatchUpIds:M,participantIdsAtLimit:D}=U.reduce((F,L)=>{const{drawId:x,tournamentId:B,matchUpType:H}=L,{participantIdsAtLimit:q,relevantParticipantIds:J}=Dm({individualParticipantProfiles:l,matchUpPotentialParticipantIds:a,matchUpDailyLimits:u,matchUp:L});return q!=null&&q.length?(F.overLimitMatchUpIds.push(L.matchUpId),F.participantIdsAtLimit.push(...q),F):(J.forEach(K=>{wc({individualParticipantProfiles:l,participantId:K});const Y=l[K].counters;Y[H]?Y[H]+=1:Y[H]=1,Y[On]?Y[On]+=1:Y[On]=1}),F.matchUpMap[B]||(F.matchUpMap[B]={}),F.matchUpMap[B][x]?F.matchUpMap[B][x].push(L):F.matchUpMap[B][x]=[L],Ya({matchUpPotentialParticipantIds:a,matchUpNotBeforeTimes:c,matchUp:L}),F)},{matchUpMap:{},overLimitMatchUpIds:[],participantIdsAtLimit:[]});U=U.filter(({matchUpId:F})=>!M.includes(F));let R=0;const j=(O==null?void 0:O.length)||0,{personRequests:G}=Ka({tournamentRecords:t,requestType:Bd});for(;O!=null&&O.length&&U.length&&R<=j;){R++;const{scheduleTime:F}=O.shift(),L=U.find(x=>{const{matchUpId:B}=x,{dependenciesScheduled:H,remainingDependencies:q}=Nm({matchUpScheduleTimes:E,matchUpDependencies:r,allDateMatchUpIds:n,matchUp:x});if(!H)return $[B]||($[B]=[]),$[B].push({scheduleTime:F,remainingDependencies:q}),!1;const{enoughTime:J}=Mm({individualParticipantProfiles:l,matchUpNotBeforeTimes:c,matchUpDependencies:r,scheduleTime:F,matchUp:x});if(!J)return N[B]||(N[B]=[]),N[B].push({scheduleTime:F}),!1;const{conflicts:K}=Um({potentials:d,averageMatchUpMinutes:o,requestConflicts:w,personRequests:G,scheduleTime:F,scheduleDate:m,matchUp:x});if(K!=null&&K.length)return!1;const Y=s==null?void 0:s[x.matchUpId];return Ec({recoveryMinutes:Y||i,matchUpPotentialParticipantIds:a,individualParticipantProfiles:l,matchUpNotBeforeTimes:c,averageMatchUpMinutes:o,matchUpDependencies:r,scheduleTime:F,matchUp:x}),E[x.matchUpId]=F,!0});U=U.filter(({matchUpId:x})=>x!==(L==null?void 0:L.matchUpId)),L||T.push(F)}U.forEach(F=>{Am({individualParticipantProfiles:l,matchUpPotentialParticipantIds:a,value:-1,matchUp:F})});const W=[];Object.keys(C).forEach(F=>{const L=t[F];L?Object.keys(C[F]).forEach(x=>{const{drawDefinition:B}=Xo({tournamentRecord:L,drawId:x});B&&C[F][x].forEach(({matchUpId:q})=>{const J=E[q];if(J){const K=J.split(":").map(io).join(":"),Y=`${Re(m)}T${K}`;P?W.push(q):(Wi({drawDefinition:B,matchUpId:q,scheduledTime:Y}).success&&W.push(q),S&&ja({tournamentRecords:t,tournamentRecord:L,drawDefinition:B,matchUpId:q,venueId:S}))}})}):zt()&&console.log(So)});const z=_v(U);return H9(W9({},V),{requestConflicts:Object.values(w),remainingScheduleTimes:O==null?void 0:O.map(({scheduleTime:F})=>F),individualParticipantProfiles:l,matchUpNotBeforeTimes:c,participantIdsAtLimit:D,skippedScheduleTimes:T,overLimitMatchUpIds:M,scheduledMatchUpIds:W,noTimeMatchUpIds:z,recoveryTimeDeferred:N,dependencyDeferred:$})}var z9=Object.defineProperty,Hw=Object.getOwnPropertySymbols,Y9=Object.prototype.hasOwnProperty,K9=Object.prototype.propertyIsEnumerable,qw=(t,e,r)=>e in t?z9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Q9=(t,e)=>{for(var r in e||(e={}))Y9.call(e,r)&&qw(t,r,e[r]);if(Hw)for(var r of Hw(e))K9.call(e,r)&&qw(t,r,e[r]);return t};function J9(t){const e="reorderUpcomingMatchUps",{tournamentRecords:r}=t;if(typeof r!="object"||!Object.keys(r).length)return k({result:{error:ke},stack:e});const{matchUpsContextIds:n,firstToLast:o}=t;if(!n)return k({result:{error:_e},stack:e});const i=n==null?void 0:n.length;if(!i)return Q9({},V);let s=0;return n.forEach((l,c)=>{const{tournamentId:u,drawId:d,matchUpId:p}=l;let v=c+(o?-1:1);v<0&&(v=i-1),v===i&&(v=0);const f=n[v].schedule.scheduledTime,m=a({tournamentId:u,scheduledTime:f,matchUpId:p,drawId:d});if(m.success)s++;else return m}),s===i?V:k({result:{error:qx},stack:e});function a({tournamentId:l,scheduledTime:c,matchUpId:u,drawId:d}){const p=r[l],{drawDefinition:v}=Xo({tournamentRecord:p,drawId:d});return Wi({drawDefinition:v,scheduledTime:c,matchUpId:u})}}var Z9=Object.defineProperty,X9=Object.defineProperties,eQ=Object.getOwnPropertyDescriptors,zw=Object.getOwnPropertySymbols,tQ=Object.prototype.hasOwnProperty,rQ=Object.prototype.propertyIsEnumerable,Yw=(t,e,r)=>e in t?Z9(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kw=(t,e)=>{for(var r in e||(e={}))tQ.call(e,r)&&Yw(t,r,e[r]);if(zw)for(var r of zw(e))rQ.call(e,r)&&Yw(t,r,e[r]);return t},Qw=(t,e)=>X9(t,eQ(e));function nQ({scheduleCompletedMatchUps:t,tournamentRecords:e,scheduledDate:r,matchUps:n}){if(!Array.isArray(n))return{error:X};if(n.some(({hasContext:m})=>!m))return{info:"matchUps must have { inContext: true, nextMatchUps: true }",error:nu};let i=$m({courtCompletedMatchUps:!0,withCourtGridRows:!0,minCourtGridRows:10,tournamentRecords:e,matchUpFilters:{localPerspective:!0,scheduledDate:r}});if(i.error)return i;const{rows:s}=i,a=[],l=m=>[(m.sides||[]).map(g=>{var h;return[g.participantId,(h=g.participant)==null?void 0:h.individualParticipantIds]}),(m.potentialParticipants||[]).flat().map(g=>[g.participantId,g.individualParticipantIds])].flat(1/0).filter(Boolean),c=s==null?void 0:s.reduce((m,g)=>{const h=[],_=[];Object.values(g).forEach(P=>{if(ns(P)&&(P.matchUpId&&(h.push(P.matchUpId),a.push(P)),P.sides)){const y=l(P);_.push(...y)}});const I=Object.values(g).filter(P=>ns(P)&&!P.matchUpId);return m.concat({matchUpIds:h,availableCourts:I,rowId:g.rowId,participantIds:_})},[]);n.filter(({matchUpStatus:m})=>m&&m!==pt.Bye&&(t||!Yt.includes(m))).sort(Ms);const u=pn({matchUps:n.concat(a),includeParticipantDependencies:!0,tournamentRecords:e}).matchUpDependencies,d=[],p=[];for(;n.length&&c.length;){const m=c.shift(),g=[];for(;n.length&&m.availableCourts.length;){const h=n.concat(g).map(T=>T.matchUpId),_=n.shift(),I=_==null?void 0:_.matchUpId,P=I&&u[I].matchUpIds.concat(u[I].dependentMatchUpIds),y=I&&h.some(T=>u[I].matchUpIds.includes(T)),S=I&&p.some(T=>u[I].dependentMatchUpIds.includes(T)),O=m.matchUpIds.some(T=>P.includes(T)),b=l(_),w=m.participantIds.some(T=>b.includes(T));if(_&&!O&&!y&&!w&&!S){const T=m.availableCourts.shift();Object.assign(_.schedule,T.schedule),Object.assign(T,_),d.push(_),m.participantIds.push(...b),m.matchUpIds.push(I)}else _&&g.push(_)}n.push(...g),p.push(...m.matchUpIds)}const v=d.map(({matchUpId:m,tournamentId:g,schedule:h,drawId:_})=>({tournamentId:g,matchUpId:m,drawId:_,schedule:Qw(Kw({},h),{scheduledDate:r})}));i=LS({tournamentRecords:e,matchUpDetails:v});const f=n;return Qw(Kw({},i),{scheduled:d,notScheduled:f})}var oQ=Object.defineProperty,iQ=Object.defineProperties,sQ=Object.getOwnPropertyDescriptors,Jw=Object.getOwnPropertySymbols,aQ=Object.prototype.hasOwnProperty,lQ=Object.prototype.propertyIsEnumerable,Zw=(t,e,r)=>e in t?oQ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xw=(t,e)=>{for(var r in e||(e={}))aQ.call(e,r)&&Zw(t,r,e[r]);if(Jw)for(var r of Jw(e))lQ.call(e,r)&&Zw(t,r,e[r]);return t},eE=(t,e)=>iQ(t,sQ(e));function cQ(t){const e="matchUpScheduleChange",{tournamentRecords:r}=t;if(typeof r!="object"||!Object.keys(r).length)return{error:ke};const{sourceMatchUpContextIds:n,targetMatchUpContextIds:o,sourceCourtId:i,targetCourtId:s,courtDayDate:a}=t||{},{drawId:l,matchUpId:c,tournamentId:u}=n||{},{drawId:d,matchUpId:p,tournamentId:v}=o||{};if(!c&&!p)return k({result:{error:_e},stack:e});const{matchUps:f}=Fo({matchUpFilters:{matchUpIds:[c,p].filter(Boolean),drawIds:[l,d].filter(Boolean)},tournamentRecords:t.tournamentRecords}),m=f==null?void 0:f.find(({matchUpId:y})=>y===c),g=f==null?void 0:f.find(({matchUpId:y})=>y===p);let h=0;if(s&&c&&!p){const y=_({tournamentId:u,matchUpId:c,courtId:s,matchUp:m,drawId:l,tournamentRecords:r,sourceCourtId:i,courtDayDate:a});if(y!=null&&y.success&&h++,y.error)return k({result:y,stack:e})}else if(i&&s&&c&&p){const y=_({tournamentId:u,matchUpId:c,courtId:s,matchUp:m,drawId:l,tournamentRecords:r,sourceCourtId:i,courtDayDate:a});if(y.success&&h++,y.error)return k({result:y,stack:e,info:"source"});const S=_({tournamentId:v,sourceCourtId:s,matchUpId:p,matchUp:g,courtId:i,drawId:d,tournamentRecords:r,courtDayDate:a});if(S.success&&h++,S.error)return k({result:S,stack:e,info:"target"})}else return{error:_e};return h?V:k({result:{error:hl},stack:e});function _(y){const{tournamentRecords:S,tournamentId:O,matchUp:b,drawId:w}=y,T=S[O],{drawDefinition:E}=Xo({tournamentRecord:T,drawId:w});return b.matchUpType===Qe?I(eE(Xw({},y),{tournamentRecord:T,drawDefinition:E})):P(eE(Xw({},y),{tournamentRecord:T,drawDefinition:E}))}function I({removePriorValues:y,tournamentRecords:S,tournamentRecord:O,drawDefinition:b,sourceCourtId:w,courtDayDate:T,matchUpId:E,matchUp:N,courtId:$}){const A=[$].concat(N.schedule.allocatedCourts.map(({courtId:U})=>U).filter(U=>U!==w));return dd({removePriorValues:y,tournamentRecords:S,tournamentRecord:O,drawDefinition:b,courtDayDate:T,matchUpId:E,courtIds:A})}function P({tournamentRecords:y,tournamentRecord:S,drawDefinition:O,courtDayDate:b,matchUpId:w,courtId:T}){return js({tournamentRecords:y,tournamentRecord:S,drawDefinition:O,courtDayDate:b,matchUpId:w,courtId:T})}}var uQ=Object.defineProperty,dQ=Object.defineProperties,pQ=Object.getOwnPropertyDescriptors,tE=Object.getOwnPropertySymbols,fQ=Object.prototype.hasOwnProperty,vQ=Object.prototype.propertyIsEnumerable,rE=(t,e,r)=>e in t?uQ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,mQ=(t,e)=>{for(var r in e||(e={}))fQ.call(e,r)&&rE(t,r,e[r]);if(tE)for(var r of tE(e))vQ.call(e,r)&&rE(t,r,e[r]);return t},gQ=(t,e)=>dQ(t,pQ(e));function hQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e;return Xb(gQ(mQ({},t),{tournamentRecord:r,drawDefinition:n}))}function _Q(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e;if(!n)return{error:fe};const{disableNotice:o,scheduledDate:i,matchUpId:s,removePriorValues:a}=t;return Pm({removePriorValues:a,tournamentRecord:r,drawDefinition:n,disableNotice:o,scheduledDate:i,matchUpId:s})}function IQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e,{disableNotice:o,scheduledTime:i,matchUpId:s,removePriorValues:a}=t;return n?ym({removePriorValues:a,tournamentRecord:r,drawDefinition:n,disableNotice:o,scheduledTime:i,matchUpId:s}):{error:fe}}function PQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e,{disableNotice:o,startTime:i,matchUpId:s}=t;return eT({tournamentRecord:r,drawDefinition:n,disableNotice:o,startTime:i,matchUpId:s})}function yQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e,{disableNotice:o,endTime:i,matchUpId:s}=t;return tT({tournamentRecord:r,drawDefinition:n,disableNotice:o,endTime:i,matchUpId:s})}function SQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e,{disableNotice:o,stopTime:i,matchUpId:s}=t;return rT({tournamentRecord:r,drawDefinition:n,disableNotice:o,stopTime:i,matchUpId:s})}function OQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e,{disableNotice:o,resumeTime:i,matchUpId:s}=t;return nT({tournamentRecord:r,drawDefinition:n,disableNotice:o,resumeTime:i,matchUpId:s})}function bQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e,{disableNotice:o,participantId:i,officialType:s,matchUpId:a}=t;return oT({tournamentRecord:r,drawDefinition:n,disableNotice:o,participantId:i,officialType:s,matchUpId:a})}function TQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e,{matchUpId:o,venueId:i,disableNotice:s,removePriorValues:a}=t;return n?ja({tournamentRecords:t.tournamentRecords,removePriorValues:a,tournamentRecord:r,drawDefinition:n,disableNotice:s,matchUpId:o,venueId:i}):{error:fe}}function wQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e;if(!r)return{error:re};if(!n)return{error:fe};const{removePriorValues:o,tournamentRecords:i,disableNotice:s,courtDayDate:a,matchUpId:l,courtId:c}=t;return js({removePriorValues:o,tournamentRecords:i,tournamentRecord:r,drawDefinition:n,disableNotice:s,courtDayDate:a,matchUpId:l,courtId:c})}function EQ(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e;if(!n)return{error:fe};const{removePriorValues:o,tournamentRecords:i,disableNotice:s,courtDayDate:a,matchUpId:l,courtIds:c}=t;return dd({removePriorValues:o,tournamentRecords:i,tournamentRecord:r,drawDefinition:n,disableNotice:s,courtDayDate:a,matchUpId:l,courtIds:c})}function $Q(t){const e=eo(t);if(e.error)return e;const{tournamentRecord:r,drawDefinition:n}=e,{removePriorValues:o,disableNotice:i,courtOrder:s,matchUpId:a}=t;return g7({removePriorValues:o,tournamentRecord:r,drawDefinition:n,disableNotice:i,courtOrder:s,matchUpId:a})}function eo({tournamentRecords:t,tournamentId:e,drawId:r}){if(!t)return{error:ke};if(!r)return{error:kr};if(typeof e!="string"&&(e=em({tournamentRecords:t,drawId:r}),!e))return{error:So};const n=t[e];if(!n)return{error:re};const o=Qt({tournamentRecord:n,drawId:r});return o.error?k({stack:"addScheduleItems.getDrawDefinition",result:o}):{drawDefinition:o.drawDefinition,tournamentRecord:n}}const NQ={scheduleMatchUps:q9,scheduleProfileRounds:Fm,clearScheduledMatchUps:Aw,bulkRescheduleMatchUps:U7,getScheduledRoundsDetails:Tm,getMatchUpDependencies:pn,generateVirtualCourts:Vv,generateBookings:Cm,proAutoSchedule:nQ,proConflicts:Z0,matchUpScheduleChange:cQ,calculateScheduleTimes:cw,reorderUpcomingMatchUps:J9,bulkUpdateCourtAssignments:x9,removeMatchUpCourtAssignment:Rw,toggleParticipantCheckInState:N9,findMatchUpFormatTiming:bm,modifyMatchUpFormatTiming:t8,modifyEventMatchUpFormatTiming:RY,getMatchUpFormatTimingUpdate:BK,getEventMatchUpFormatTiming:KK,removeEventMatchUpFormatTiming:E9,getMatchUpDailyLimitsUpdate:U9,getMatchUpDailyLimits:Mw,setMatchUpDailyLimits:j7,getProfileRounds:Vm,getRounds:Bw,assignMatchUpVenue:TQ,assignMatchUpCourt:wQ,allocateTeamMatchUpCourts:EQ,addMatchUpScheduleItems:hQ,addMatchUpScheduledDate:_Q,addMatchUpScheduledTime:IQ,addMatchUpCourtOrder:$Q,addMatchUpStartTime:PQ,addMatchUpStopTime:SQ,addMatchUpResumeTime:OQ,addMatchUpEndTime:yQ,addMatchUpOfficial:bQ,getSchedulingProfile:za,setSchedulingProfile:Tc,addSchedulingProfileRound:nw,validateSchedulingProfile:Fd,addPersonRequests:f9,getPersonRequests:Ka,modifyPersonRequests:m9,removePersonRequests:v9};var UQ=Object.defineProperty,AQ=Object.defineProperties,CQ=Object.getOwnPropertyDescriptors,nE=Object.getOwnPropertySymbols,MQ=Object.prototype.hasOwnProperty,DQ=Object.prototype.propertyIsEnumerable,oE=(t,e,r)=>e in t?UQ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,jQ=(t,e)=>{for(var r in e||(e={}))MQ.call(e,r)&&oE(t,r,e[r]);if(nE)for(var r of nE(e))DQ.call(e,r)&&oE(t,r,e[r]);return t},RQ=(t,e)=>AQ(t,CQ(e));function km({tournamentRecord:t,policyDefinitions:e,allowReplacement:r}){var n;if(!t)return{error:re};if(!e||typeof e!="object")return{error:eu};t.extensions||(t.extensions=[]);const o=(n=vt({tournamentRecord:t}).appliedPolicies)!=null?n:{},i=Object.keys(e).map(s=>{if(!o[s]||r)return o[s]=e[s],s}).filter(Boolean);if(i!=null&&i.length){const a=Ni({tournamentRecord:t,extension:{name:is,value:o}});if(a.error)return a}return i!=null&&i.length?RQ(jQ({},V),{applied:i}):{error:t_}}function iE({policyDefinitions:t,allowReplacement:e,event:r}){var n;if(!r)return{error:Ge};if(!t)return{error:eu};let o=0;r.extensions||(r.extensions=[]);const i=(n=vt({event:r}).appliedPolicies)!=null?n:{};return Object.keys(t).forEach(s=>{(!i[s]||e)&&(i[s]=t[s],o++)}),o&&lo({event:r,extension:{name:is,value:i}}),o?V:{error:gx}}function FQ({event:t,policyType:e}){if(!e)return{error:_e};if(!t)return{error:Ge};let r;if(t.extensions){const{appliedPolicies:n}=vt({event:t});n!=null&&n[e]&&(delete n[e],r=!0,Object.keys(n).length?lo({event:t,extension:{name:is,value:n}}):bu({event:t,name:is}))}return r?V:{error:of}}var xQ=Object.defineProperty,sE=Object.getOwnPropertySymbols,LQ=Object.prototype.hasOwnProperty,VQ=Object.prototype.propertyIsEnumerable,aE=(t,e,r)=>e in t?xQ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,BQ=(t,e)=>{for(var r in e||(e={}))LQ.call(e,r)&&aE(t,r,e[r]);if(sE)for(var r of sE(e))VQ.call(e,r)&&aE(t,r,e[r]);return t};function kQ({tournamentRecords:t,policyDefinitions:e}){if(typeof t!="object"||!Object.keys(t).length)return{error:ke};for(const r of Object.values(t)){const n=km({allowReplacement:!0,tournamentRecord:r,policyDefinitions:e});if(n.error)return n}return BQ({},V)}const GQ={attachPolicies:kQ};var WQ=Object.defineProperty,HQ=Object.defineProperties,qQ=Object.getOwnPropertyDescriptors,lE=Object.getOwnPropertySymbols,zQ=Object.prototype.hasOwnProperty,YQ=Object.prototype.propertyIsEnumerable,cE=(t,e,r)=>e in t?WQ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Gm=(t,e)=>{for(var r in e||(e={}))zQ.call(e,r)&&cE(t,r,e[r]);if(lE)for(var r of lE(e))YQ.call(e,r)&&cE(t,r,e[r]);return t},uE=(t,e)=>HQ(t,qQ(e));function KQ({tournamentRecords:t,policyDefinitions:e,scaleAttributes:r,participantId:n,inContext:o,personId:i}){let s=ET({tournamentRecords:t,policyDefinitions:e,participantId:n,inContext:o,personId:i});if(s.error)return s;const{participant:a,tournamentId:l}=s;return s=_o({participant:a,scaleAttributes:r}),s.error?uE(Gm({},s),{tournamentId:l}):Gm(uE(Gm({},V),{tournamentId:l}),s)}var QQ=Object.defineProperty,dE=Object.getOwnPropertySymbols,JQ=Object.prototype.hasOwnProperty,ZQ=Object.prototype.propertyIsEnumerable,pE=(t,e,r)=>e in t?QQ(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fE=(t,e)=>{for(var r in e||(e={}))JQ.call(e,r)&&pE(t,r,e[r]);if(dE)for(var r of dE(e))ZQ.call(e,r)&&pE(t,r,e[r]);return t};function XQ(t){const{scheduleDates:e=[],tournamentRecords:r,periodLength:n=30}=t||{};if(typeof r!="object")return{error:Kc};if(!Array.isArray(e))return{error:X};if(!e.every(Gr))return{error:yr};const i=[];let s=0;const a={},{schedulingProfile:l}=za({tournamentRecords:r});if(!l)return fE({issues:i},V);const{matchUps:c}=Fo({nextMatchUps:!0,tournamentRecords:r});for(const d of l){const{scheduleDate:p,venues:v=[]}=d;if(!(e!=null&&e.length)||e.includes(p)){for(const f of v||[])if(f){const{rounds:m}=f,g=[],{orderedMatchUpIds:h,scheduledRoundsDetails:_}=Tm({tournamentRecords:r,periodLength:n,matchUps:c,rounds:m}),{matchUpDependencies:I}=pn({tournamentRecords:r,matchUps:c}),P=y=>{let S;return _==null||_.find((O,b)=>{const w=O.matchUpIds.includes(y);return w&&(S=b),w}),S};if(h==null||h.forEach((y,S)=>{var O;const b=h.slice(S+1),w=Ht(b,((O=I==null?void 0:I[y])==null?void 0:O.matchUpIds)||[]);w.length&&g.push({matchUpId:y,shouldBeAfter:w})}),g.length){s+=g.length;const y=g.map(({matchUpId:S,shouldBeAfter:O})=>{const b=P(S),w=He(O.map(P));return a[p]||(a[p]={}),a[p][b]||(a[p][b]=[]),w.forEach(T=>{a[p][b].includes(T)||a[p][b].push(T)}),{matchUpId:S,matchUpRoundIndex:b,earlierRoundIndices:w,shouldBeAfter:O}});i.push(...y)}}}}const u={matchUpIdShouldBeAfter:Object.assign({},...i.map(d=>{const{matchUpId:p,shouldBeAfter:v,earlierRoundIndices:f}=d;return{[p]:{earlierRoundIndices:f,shouldBeAfter:v}}}))};return fE({issuesCount:s,profileIssues:u,roundIndexShouldBeAfter:a},V)}function Gd(){return`
|
|
8
8
|
This project would not have been possible without the generous input and patience
|
|
@@ -29,4 +29,4 @@
|
|
|
29
29
|
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path>
|
|
30
30
|
</svg>
|
|
31
31
|
</div>
|
|
32
|
-
`}function TR({eventHandlers:t,sideContainer:e,composition:r,sideNumber:n,matchUp:o,participant:i}){var w,T,E,N;const{winningSide:s,matchUpType:a,isRoundRobin:l,matchUpStatus:c}=o||{},u=r==null?void 0:r.configuration;let d;const p=n?(w=o==null?void 0:o.sides)==null?void 0:w.find($=>$.sideNumber===n):void 0;i||(i=p==null?void 0:p.participant,d=u!=null&&u.allDrawPositions||u!=null&&u.drawPositions&&(p!=null&&p.drawPosition)&&((o==null?void 0:o.roundNumber)===1||p!=null&&p.participantFed||l)?p==null?void 0:p.drawPosition:"");const v=((T=i==null?void 0:i.individualParticipants)==null?void 0:T.length)===2||a==="DOUBLES",f=v?(E=i==null?void 0:i.individualParticipants)==null?void 0:E[0]:i,m=v&&((N=i==null?void 0:i.individualParticipants)==null?void 0:N[1]),g=n===s||c==="BYE"&&i,h=(u==null?void 0:u.winnerChevron)&&g,_=u==null?void 0:u.teamLogo,I=["RETIRED","DOUBLE_WALKOVER","WALKOVER","DEFAULTED"].includes(c)&&!g,P=u==null?void 0:u.gameScoreOnly,y=document.createElement("div");if(y.className=e&&OF({drawPosition:d,sideNumber:n}),_){const $=e0e({teamLogo:_});y.appendChild($)}const S=document.createElement("div");S.className=SF({variant:v?"doubles":"singles"});const O=document.createElement("div");O.className=bF({winnerChevron:h,isDoubles:v});const b=bR({individualParticipant:f,eventHandlers:t,isWinningSide:g,composition:r,matchUp:o,side:p});if(O.appendChild(b),m){const $=bR({individualParticipant:m,eventHandlers:t,isWinningSide:g,composition:r,matchUp:o,side:p});O.appendChild($)}if(S.appendChild(O),y.appendChild(S),e){const $=document.createElement("div");if(g&&!P){const A=o0e();typeof A=="string"?$.innerHTML=A:$.appendChild(A)}else if(I){const A=Zye({matchUpStatus:c});$.appendChild(A)}y.appendChild($)}return y}const i0e=Ke({marginInlineStart:"1rem",overflowX:"auto",display:"flex"}),s0e=Ke({borderTop:"solid 1px black",marginRight:"-1em",marginLeft:"-1em",paddingTop:".5em",marginTop:".2em",variants:{variant:{0:{marginTop:"1em",borderTop:"none",paddingTop:"0px"}},roundOrder:{first:{marginLeft:"0em"},last:{marginRight:"0em"}}}}),a0e=Ke({flexDirection:"column",display:"flex"}),l0e=Ke({fontWeight:"bold",color:"blue",height:"1em"}),c0e=Ke({borderBottom:"solid 1px black",marginInlineStart:"16px",marginInlineEnd:"16px",fontWeight:"bold",width:"460px",height:"1.5em"}),u0e=Ke({willChange:"opacity",position:"fixed",zIndex:9998,bottom:0,right:0,left:0,top:0}),d0e=Ke({display:"block"}),p0e=Ke({position:"fixed",right:0,left:0}),f0e=Ke({paddingRight:"15px",alignItems:"center",margin:"30px auto",paddingLeft:"15px",position:"fixed",height:"100vh",display:"flex",width:"100%",zIndex:9999,bottom:0,right:0,left:0,top:0}),v0e=Ke({boxShadow:"0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23)",backgroundColor:"white",position:"relative",borderRadius:"3px",minHeight:"auto",width:"100%"}),m0e=Ke({borderBottom:"1px solid rgba(0, 0, 0, 0.1)",alignItems:"center",position:"relative",display:"flex"}),g0e=Ke({fontWeight:"600",fontSize:"20px"}),wR=Ke({borderTop:"1px solid rgba(0, 0, 0, 0.1)",justifyContent:"right",alignItems:"center",position:"relative",display:"flex"}),ER="Nothing to see here";function sl(t){return typeof t=="function"}function xp(t){return typeof t=="string"}function $R(t){return Array.isArray(t)}function vh(t){return typeof t=="object"&&!Array.isArray(t)}function h0e(t){if(t)for(;t.firstChild;)t.removeChild(t.firstChild)}const mh=(()=>{const t=p0e(),e={},r=".5";let n=[],o,i=[],s=[],a;const l=h=>{if(h){let _;s=s.filter(I=>(I.id===h&&(_=I),I.id!==h)),_&&document.body.removeChild(_)}else{const _=s.pop();_&&document.body.removeChild(_)}},c=()=>{a&&(a.style.opacity=0,a.style.display="none")},u=h=>{const _=s.length;if(h&&e[_]===!1)return;const I=i.pop(),P=n.pop();sl(I)&&I({content:P}),document.body.classList.remove(t),document.body.style.top=null,window.scrollTo({top:o,behavior:"instant"}),c(),l()},d=()=>{a=document.createElement("div"),a.className=u0e(),a.id="cmdl-backdrop",a.onclick=()=>u(!0),document.body.appendChild(a)},p=({config:h})=>{o=window.scrollY,document.body.classList.add(t),document.body.style.top=`-${o}px`,a||d(),a.style.display="",(h==null?void 0:h.backdrop)!==!1&&(a.style.backgroundColor="rgba(0, 0, 0, 0.2)",a.style.transition="opacity 0.15s linear",a.style.opacity=1)},v=({config:h,attr:_})=>{if(!xp(_))return;const I=_.split(".");for(const P of I)if(h=h==null?void 0:h[P],!h)return;return h},f=({config:h,attr:_,attrs:I,unit:P="em",value:y})=>{var O;let S;return xp(_)?S=v({config:h,attr:_}):$R(I)&&(S=(O=I.map(b=>v({config:h,attr:b})).filter(Boolean))==null?void 0:O[0]),S!==void 0&&(y=S),isNaN(y)?y:`${y}${P}`},m=({buttons:h,config:_,modalNumber:I})=>{var S,O;const P=document.createElement("div");P.className=wR(),P.style.padding=f({config:_,attrs:["footer.padding","padding"],value:r});const y={label:((S=_==null?void 0:_.dictionary)==null?void 0:S.close)||"Close",onClick:mh.close,intent:"is-info"};for(const b of h){if(b.hide)continue;const w=Object.assign({},y);vh(b)&&Object.assign(w,b);const T=document.createElement("button");w.disabled!==void 0&&(T.disabled=w.disabled),w.id&&(T.id=w.id),T.className=((O=w==null?void 0:w.footer)==null?void 0:O.className)||"button font-medium",T.classList.add(w.intent),T.style="margin-right: .5em;",T.innerHTML=w.label||w.text,T.onclick=E=>{E.stopPropagation(),sl(w.onClick)&&w.onClick({e:E,content:n[I]}),w.close!==!1&&(sl(w.close)&&w.close(),mh.close())},P.appendChild(T)}return P};return{close:u,open:({title:h="",content:_,buttons:I,footer:P,config:y,onClose:S}={})=>{p({config:y}),i.push(S);const O=s.length+1;e[O]=y==null?void 0:y.clickAway;const b=document.createElement("section"),w=`cmdl-${O}`;b.className=d0e(),b.role="dialog",b.tabIndex=-1,b.id=w;const T=document.createElement("div");T.className=f0e(),T.style.maxWidth=`${(y==null?void 0:y.maxWidth)||450}px`,T.onclick=()=>u(!0);const E=document.createElement("div");E.className=v0e(),E.onclick=j=>j.stopPropagation();const N=document.createElement("div"),$=document.createElement("div");N.appendChild($),E.appendChild(N);const A=({title:j,config:G})=>{N.className=j?m0e():"",N.style.padding=f({config:G,attrs:["title.padding","padding"],value:r}),$.className=j?g0e():"",$.innerHTML=j};h&&A({title:h});const U=document.createElement("div");E.appendChild(U);const C=({content:j,config:G})=>{U.style.fontSize=f({config:G,attr:"fontSize",value:"15px"}),U.style.position="relative",U.style.padding=f({config:G,attrs:["content.padding","padding"],value:r}),sl(j)?n[O]=j(U):vh(j)?U.appendChild(j):xp(j)?U.innerHTML=j:U.innerHTML=ER};if(C({content:_,config:y}),$R(I))P=m({buttons:I,config:y,modalNumber:O}),E.appendChild(P);else if(P){const j=document.createElement("div");j.className=wR(),j.style.padding=f({config:y,attrs:["footer.padding","padding"]}),vh(P)?j.appendChild(P):xp(P)?j.innerHTML=P:j.innerHTML=ER,E.appendChild(j)}T.appendChild(E),b.appendChild(T),document.body.appendChild(b),s.push(b);const M=({content:j,config:G})=>{n[O]=void 0,h0e(U),C({content:j,config:G})},D=({buttons:j,config:G})=>{E.removeChild(P),P=m({buttons:j,config:G,modalNumber:O}),E.appendChild(P)};return{setContent:M,setButtons:D,update:({content:j,buttons:G,title:W,config:z})=>{y=z||y,j&&M({content:j,config:y}),G&&D({buttons:G,config:y}),W&&A({title:W,config:y})}}}}})();function _0e({eventHandlers:t,roundMatchUps:e,roundProfile:r,roundNumber:n}){var s;const o=document.createElement("div");o.className=c0e(),sl(t==null?void 0:t.roundHeaderClick)&&(o.onclick=()=>t.roundHeaderClick({roundNumber:n,roundProfile:r,roundMatchUps:e}));const i=(s=r==null?void 0:r[n])==null?void 0:s.roundName;return o.innerHTML=i||"",o}const I0e=Ke({justifyContent:"space-around",marginInlineStart:"16px",marginInlineEnd:"16px",flexDirection:"column",height:"100%",display:"flex",width:"460px"}),NR=Ke({width:"$score$setWidth",display:"inline-block",fontSize:9,variants:{variant:{set:{textAlign:"center"},points:{marginInlineEnd:3}}}}),P0e=Ke({transform:"translateY(-50%)",textTransform:"uppercase",backgroundColor:"#fff",position:"absolute",textAlign:"center",top:"calc(50%)",color:"#bbb",fontSize:0,right:4});function y0e(){return Ke({backgroundColor:"magenta",position:"absolute",opacity:"0.2",height:"100%",width:"100%",top:0})}const S0e=Ke({});function O0e({configuration:t}){const e={backgroundColor:"$matchUpBackgroundColor",WebkitTransition:"all 0.30s linear",boxShadow:"$matchUp$boxShadow",transition:"all 0.30s linear",border:"solid $border",marginBottom:"$space$1",marginTop:"$space$1",position:"relative",display:"grid",width:"100%",borderInlineStartWidth:"$borderWidths$borderInlineStart"};if(t!=null&&t.matchUpHover){const r=typeof t.matchUpHover=="string"?t.matchUpHover:"cyan";e["&:hover"]={backgroundColor:r}}else e["&:hover"]={borderColor:"$borderHover"};return Ke(e)}function b0e({variant:t}){return Ke({borderBottom:"solid 1px lightgray",backgroundColor:"$matchUp",position:"relative",width:"100%",height:"$lineHeights$centerInfo",variants:{variant:{1:{borderBottom:"solid 1px black"},2:{borderBottom:"solid 1px lightgray"}}}})({variant:t})}const T0e=Ke({justifyContent:"center",alignContent:"center",flexDirection:"column",height:"100%",display:"flex"}),w0e=Ke({fontFamily:"Lato,Arial,Helvetica,sans-serif",WebkitFontSmooting:"antialiased",marginInlineStart:"calc(20%)",WebkitBoxOrient:"horizontal",WebKitBoxDirection:"normal",WebkitBoxPack:"center",boxSizing:"inherit",flexDirection:"row",display:"flex"}),UR=Ke({alignContent:"center",boxSizing:"inherit",fontFamily:"Lato",fontWeight:900,fontSize:9});function E0e({eventHandlers:t,entryStatus:e,sideNumber:r,className:n}){const o=document.createElement("div");o.onclick=t==null?void 0:t.centerInfoClick,o.className=Xi(b0e({variant:r}),n);const i=document.createElement("div");i.className=T0e();const s=document.createElement("div");s.className=w0e();const a=document.createElement("div");a.className=UR(),a.innerHTML=e?"Entry status: ":"",s.appendChild(a);const l=document.createElement("div");return l.className=UR(),l.innerHTML=e||"",s.appendChild(l),i.appendChild(s),o.appendChild(i),o}const Wc={scheduleInfo:1.8,centerInfo:1.5,gameScore:2};function $0e({composition:t,isDoubles:e,roundFactor:r=1}){const n=parseInt(window.getComputedStyle(document.body).getPropertyValue("font-size")),o=(t==null?void 0:t.configuration)||{},i=(o==null?void 0:o.connectorWidth)||16,s=o.centerInfo?Wc.centerInfo*n:0,a=o.scheduleInfo?Wc.scheduleInfo*n:0,c=(60+(o.showAddress?n:0))*(e?1.3:1)+s,u=c*r,d=(c+a)*r;return Ke({"&::before":{borderBlockStart:"$borderWidths$matchUp solid #999",left:-i,width:i,position:"absolute",borderRadius:2,top:-1},"&::after":{width:i,position:"absolute",borderRadius:2,left:"100%"},"&::after, &::before":{borderWidth:"$borderWidths$matchUp",borderColor:"$connector",display:"block",content:""},variants:{isFirstRound:{true:{"&::before":{height:0,width:0,borderWidth:0}}},link:{m1:{"&::after":{borderInlineEnd:"$borderWidths$matchUp solid $connector",borderTopStyle:"solid",height:u,top:-1}},m2:{"&::after":{bottom:"calc(100%)",borderInlineEnd:"$borderWidths$matchUp solid $connector",borderBottomStyle:"solid",height:d}},m0:{"&::after":{borderTopStyle:"solid",borderColor:"$connector",top:-1}},mr:{"&::before":{height:0,width:0,borderWidth:0},"&::after":{height:0,width:0,borderWidth:0}},noProgression:{true:{"&::after":{height:0,width:0,borderWidth:0}}}}}})}const AR=t=>Ke({display:"flex",alignItems:"center",height:t,justifyContent:"flex-end",backgroundColor:"$matchUp",variants:{sideNumber:{1:{borderBottom:"1px solid $internalDividers"}},fontSize:{small:{fontSize:"smaller",paddingRight:"1em",color:"blue"}}}}),N0e=Ke({letterSpacing:"-0.2em",lineHeight:"0.75rem",position:"absolute",fontSize:"0.625rem",left:"1.1rem",top:".4rem"}),CR=Ke({lineHeight:"$lineHeights$gameScore",justifyContent:"center",width:"$score$setWidth",position:"relative",textAlign:"center",cursor:"pointer",fontWeight:500,fontSize:"$1",display:"flex",margin:0,variants:{variant:{winner:{color:"$winner!important",fontWeight:700},loser:{color:"$loser!important"}}}}),U0e=Ke({marginInlineEnd:"$space$gameMarginInlineEnd",justifyContent:"flex-end",alignItems:"center",display:"flex"});function A0e({value:t}={}){const e=document.createElement("input");return e.onclick=r=>r.target.select(),e.className=CR(),e.value=t,e}function C0e({gameScoreOnly:t,scoreStripes:e,set:r,sideNumber:n}){const i=n===(r==null?void 0:r.winningSide)||r!=null&&r.winningSide?"loser":void 0,s=n===2?r.side2Score:r.side1Score,a=n===2?r.side2TiebreakScore:r.side1TiebreakScore,l=s===void 0&&a,c=l||s,u=e&&r.setNumber%2?"lightgray":"transparent",p=r.editing?r.editing===n:void 0;let v;if(p)v=A0e({value:c});else if(v=document.createElement("p"),v.className=CR({variant:i}),v.style.backgroundColor=u,v.innerHTML=isNaN(c)?"":c,!t){const f=document.createElement("span");f.className=N0e(),f.innerHTML=l?a:"",v.appendChild(f)}return v}function M0e({participantHeight:t,eventHandlers:e,composition:r,sideNumber:n,matchUp:o}){var f,m,g,h;const i=(f=r==null?void 0:r.configuration)==null?void 0:f.winnerChevron,s=(m=r==null?void 0:r.configuration)==null?void 0:m.gameScoreOnly,a=((g=o==null?void 0:o.score)==null?void 0:g.sets)||[],l=(h=r==null?void 0:r.configuration)==null?void 0:h.scoreBox,c=n===2?t:t-1,u=AR(c),d=_=>{typeof(e==null?void 0:e.scoreClick)=="function"&&(_.stopPropagation(),e.scoreClick({event:_,matchUp:o}))},p=document.createElement("div");p.className=u({sideNumber:!l&&n,fontSize:"5px"}),p.classList.add("sideScore"),p.onclick=d;const v=document.createElement("div");v.className=U0e();for(const _ of a||[]){const I=C0e({gameScoreOnly:s,scoreStripes:i,sideNumber:n,set:_});v.appendChild(I)}return p.appendChild(v),p}const D0e=Ke({height:"$lineHeights$scheduleInfo",borderBottom:"1px solid darkgray",justifyContent:"space-between",backgroundColor:"#F8F9F9",boxSizing:"border-box",paddingRight:"0.5rem",paddingLeft:"0.5rem",alignItems:"center",cursor:"pointer",color:"#7F8080",display:"flex",width:"100%"});var MR={exports:{}};(function(t,e){(function(r,n){t.exports=n()})($F,function(){var r=1e3,n=6e4,o=36e5,i="millisecond",s="second",a="minute",l="hour",c="day",u="week",d="month",p="quarter",v="year",f="date",m="Invalid Date",g=/^(\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,_={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($){var A=["th","st","nd","rd"],U=$%100;return"["+$+(A[(U-20)%10]||A[U]||A[0])+"]"}},I=function($,A,U){var C=String($);return!C||C.length>=A?$:""+Array(A+1-C.length).join(U)+$},P={s:I,z:function($){var A=-$.utcOffset(),U=Math.abs(A),C=Math.floor(U/60),M=U%60;return(A<=0?"+":"-")+I(C,2,"0")+":"+I(M,2,"0")},m:function $(A,U){if(A.date()<U.date())return-$(U,A);var C=12*(U.year()-A.year())+(U.month()-A.month()),M=A.clone().add(C,d),D=U-M<0,R=A.clone().add(C+(D?-1:1),d);return+(-(C+(U-M)/(D?M-R:R-M))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:d,y:v,w:u,d:c,D:f,h:l,m:a,s,ms:i,Q:p}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},y="en",S={};S[y]=_;var O=function($){return $ instanceof E},b=function $(A,U,C){var M;if(!A)return y;if(typeof A=="string"){var D=A.toLowerCase();S[D]&&(M=D),U&&(S[D]=U,M=D);var R=A.split("-");if(!M&&R.length>1)return $(R[0])}else{var j=A.name;S[j]=A,M=j}return!C&&M&&(y=M),M||!C&&y},w=function($,A){if(O($))return $.clone();var U=typeof A=="object"?A:{};return U.date=$,U.args=arguments,new E(U)},T=P;T.l=b,T.i=O,T.w=function($,A){return w($,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var E=function(){function $(U){this.$L=b(U.locale,null,!0),this.parse(U)}var A=$.prototype;return A.parse=function(U){this.$d=function(C){var M=C.date,D=C.utc;if(M===null)return new Date(NaN);if(T.u(M))return new Date;if(M instanceof Date)return new Date(M);if(typeof M=="string"&&!/Z$/i.test(M)){var R=M.match(g);if(R){var j=R[2]-1||0,G=(R[7]||"0").substring(0,3);return D?new Date(Date.UTC(R[1],j,R[3]||1,R[4]||0,R[5]||0,R[6]||0,G)):new Date(R[1],j,R[3]||1,R[4]||0,R[5]||0,R[6]||0,G)}}return new Date(M)}(U),this.$x=U.x||{},this.init()},A.init=function(){var U=this.$d;this.$y=U.getFullYear(),this.$M=U.getMonth(),this.$D=U.getDate(),this.$W=U.getDay(),this.$H=U.getHours(),this.$m=U.getMinutes(),this.$s=U.getSeconds(),this.$ms=U.getMilliseconds()},A.$utils=function(){return T},A.isValid=function(){return this.$d.toString()!==m},A.isSame=function(U,C){var M=w(U);return this.startOf(C)<=M&&M<=this.endOf(C)},A.isAfter=function(U,C){return w(U)<this.startOf(C)},A.isBefore=function(U,C){return this.endOf(C)<w(U)},A.$g=function(U,C,M){return T.u(U)?this[C]:this.set(M,U)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function(U,C){var M=this,D=!!T.u(C)||C,R=T.p(U),j=function(H,q){var J=T.w(M.$u?Date.UTC(M.$y,q,H):new Date(M.$y,q,H),M);return D?J:J.endOf(c)},G=function(H,q){return T.w(M.toDate()[H].apply(M.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(q)),M)},W=this.$W,z=this.$M,F=this.$D,L="set"+(this.$u?"UTC":"");switch(R){case v:return D?j(1,0):j(31,11);case d:return D?j(1,z):j(0,z+1);case u:var x=this.$locale().weekStart||0,B=(W<x?W+7:W)-x;return j(D?F-B:F+(6-B),z);case c:case f:return G(L+"Hours",0);case l:return G(L+"Minutes",1);case a:return G(L+"Seconds",2);case s:return G(L+"Milliseconds",3);default:return this.clone()}},A.endOf=function(U){return this.startOf(U,!1)},A.$set=function(U,C){var M,D=T.p(U),R="set"+(this.$u?"UTC":""),j=(M={},M[c]=R+"Date",M[f]=R+"Date",M[d]=R+"Month",M[v]=R+"FullYear",M[l]=R+"Hours",M[a]=R+"Minutes",M[s]=R+"Seconds",M[i]=R+"Milliseconds",M)[D],G=D===c?this.$D+(C-this.$W):C;if(D===d||D===v){var W=this.clone().set(f,1);W.$d[j](G),W.init(),this.$d=W.set(f,Math.min(this.$D,W.daysInMonth())).$d}else j&&this.$d[j](G);return this.init(),this},A.set=function(U,C){return this.clone().$set(U,C)},A.get=function(U){return this[T.p(U)]()},A.add=function(U,C){var M,D=this;U=Number(U);var R=T.p(C),j=function(z){var F=w(D);return T.w(F.date(F.date()+Math.round(z*U)),D)};if(R===d)return this.set(d,this.$M+U);if(R===v)return this.set(v,this.$y+U);if(R===c)return j(1);if(R===u)return j(7);var G=(M={},M[a]=n,M[l]=o,M[s]=r,M)[R]||1,W=this.$d.getTime()+U*G;return T.w(W,this)},A.subtract=function(U,C){return this.add(-1*U,C)},A.format=function(U){var C=this,M=this.$locale();if(!this.isValid())return M.invalidDate||m;var D=U||"YYYY-MM-DDTHH:mm:ssZ",R=T.z(this),j=this.$H,G=this.$m,W=this.$M,z=M.weekdays,F=M.months,L=M.meridiem,x=function(q,J,K,Y){return q&&(q[J]||q(C,D))||K[J].slice(0,Y)},B=function(q){return T.s(j%12||12,q,"0")},H=L||function(q,J,K){var Y=q<12?"AM":"PM";return K?Y.toLowerCase():Y};return D.replace(h,function(q,J){return J||function(K){switch(K){case"YY":return String(C.$y).slice(-2);case"YYYY":return T.s(C.$y,4,"0");case"M":return W+1;case"MM":return T.s(W+1,2,"0");case"MMM":return x(M.monthsShort,W,F,3);case"MMMM":return x(F,W);case"D":return C.$D;case"DD":return T.s(C.$D,2,"0");case"d":return String(C.$W);case"dd":return x(M.weekdaysMin,C.$W,z,2);case"ddd":return x(M.weekdaysShort,C.$W,z,3);case"dddd":return z[C.$W];case"H":return String(j);case"HH":return T.s(j,2,"0");case"h":return B(1);case"hh":return B(2);case"a":return H(j,G,!0);case"A":return H(j,G,!1);case"m":return String(G);case"mm":return T.s(G,2,"0");case"s":return String(C.$s);case"ss":return T.s(C.$s,2,"0");case"SSS":return T.s(C.$ms,3,"0");case"Z":return R}return null}(q)||R.replace(":","")})},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function(U,C,M){var D,R=this,j=T.p(C),G=w(U),W=(G.utcOffset()-this.utcOffset())*n,z=this-G,F=function(){return T.m(R,G)};switch(j){case v:D=F()/12;break;case d:D=F();break;case p:D=F()/3;break;case u:D=(z-W)/6048e5;break;case c:D=(z-W)/864e5;break;case l:D=z/o;break;case a:D=z/n;break;case s:D=z/r;break;default:D=z}return M?D:T.a(D)},A.daysInMonth=function(){return this.endOf(d).$D},A.$locale=function(){return S[this.$L]},A.locale=function(U,C){if(!U)return this.$L;var M=this.clone(),D=b(U,C,!0);return D&&(M.$L=D),M},A.clone=function(){return T.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},$}(),N=E.prototype;return w.prototype=N,[["$ms",i],["$s",s],["$m",a],["$H",l],["$W",c],["$M",d],["$y",v],["$D",f]].forEach(function($){N[$[1]]=function(A){return this.$g(A,$[0],$[1])}}),w.extend=function($,A){return $.$i||($(A,E,w),$.$i=!0),w},w.locale=b,w.isDayjs=O,w.unix=function($){return w(1e3*$)},w.en=S[y],w.Ls=S,w.p={},w})})(MR);var j0e=MR.exports;const R0e=Eh(j0e);function F0e({matchUp:t,eventHandlers:e}){const{scheduledTime:r,scheduledDate:n,venueAbbreviation:o,courtName:i}=(t==null?void 0:t.schedule)||{},{dateTime:{extractDate:s,extractTime:a}}=fh,l=a(r);let u=s(n),d="ddd D MMMM";l&&(d+=", hh:mm A",u+=`T${l}`);const p=n?R0e(u).format(d):"Not scheduled",v=o&&(i==null?void 0:i.toString().startsWith(o))&&i||o&&i&&`${o} ${i}`||i||o||"",f=document.createElement("div");f.className=D0e(),f.onclick=e==null?void 0:e.scheduleClick;const m=document.createElement("div");m.innerHTML=p,f.append(m);const g=_=>{typeof(e==null?void 0:e.venueClick)=="function"&&(_.stopPropagation(),e.venueClick({matchUp:t,event:_}))},h=document.createElement("div");return h.onclick=g,h.innerHTML=v,f.append(h),f}function DR({eventHandlers:t,composition:e,sideNumber:r,className:n,matchUp:o}){var v,f;const i=(e==null?void 0:e.configuration)||{},s=i==null?void 0:i.scheduleInfo,a=(v=o==null?void 0:o.score)==null?void 0:v.scoreStringSide1,l=((f=e==null?void 0:e.configuration)==null?void 0:f.scoreBox)&&a,c=(o==null?void 0:o.readyToScore)&&(t==null?void 0:t.scoreClick)&&!fh.scoreHasValue({matchUp:o}),u=document.createElement("div");if(u.className=Xi(t0e(),n),s&&r===1){const m=F0e({matchUp:o,eventHandlers:t});u.appendChild(m)}const d=document.createElement("div");d.className=r0e();const p=TR({sideContainer:!0,eventHandlers:t,composition:e,sideNumber:r,matchUp:o});if(d.appendChild(p),l){const m=document.createElement("div");m.style.border="1px solid lightgray",d.appendChild(m)}if(a){const m=M0e({eventHandlers:t,composition:e,sideNumber:r,matchUp:o});d.appendChild(m)}if(c){const m=AR(),g=_=>{typeof(t==null?void 0:t.scoreClick)=="function"&&(_.stopPropagation(),t.scoreClick({event:_,matchUp:o}))},h=document.createElement("div");h.className=m({sideNumber:!l&&r,fontSize:"small"}),h.onclick=g,h.innerHTML="[Score]",d.appendChild(h)}return u.appendChild(d),u}function jR(t){const{composition:e,matchUp:r,moeity:n,selectedMatchUpId:o,searchActive:i}=t,{roundFactor:s,roundNumber:a,finishingRound:l,matchUpType:c,preFeedRound:u,stage:d}=r,p=d==="QUALIFYING",v=parseInt(l)===1,f=d==="QUALIFYING"&&v,m=!p&&v,g=parseInt(a)===1,h=c==="DOUBLES",_=(i||r.isRoundRobin||r.collectionId||t.isLucky||t.isAdHoc)&&"mr"||m&&"noProgression"||(f||u)&&"m0"||n&&"m1"||"m2",I=$0e({composition:e,isDoubles:h,roundFactor:s})({isFirstRound:g,link:_}),P=(e==null?void 0:e.configuration)||{},{resultsInfo:y,centerInfo:S}=P||{},O=t.eventHandlers||{},b=A=>{typeof(O==null?void 0:O.matchUpClick)=="function"&&O.matchUpClick({event:A,matchUp:r})},w=document.createElement("div");w.className=Xi(e.theme,t==null?void 0:t.className,"matchup",S0e()),w.onclick=b;const T=document.createElement("div");T.className=O0e({configuration:P});const E=({sideNumber:A})=>{var M,D,R;const U=(R=(D=(M=r==null?void 0:r.sides.find(j=>j.sideNumber===A))==null?void 0:M.participant)==null?void 0:D.entryStatus)==null?void 0:R.replace("_"," ");return E0e({eventHandlers:O,entryStatus:U,sideNumber:A,className:A===2&&I})},N=DR({sideNumber:1,eventHandlers:O,composition:e,matchUp:r}),$=DR({className:!S&&I,sideNumber:2,eventHandlers:O,composition:e,matchUp:r});if(T.appendChild(N),S&&(T.appendChild(E({sideNumber:1})),T.appendChild(E({sideNumber:2}))),T.appendChild($),y){const A=x0e({score:r.score});T.appendChild(A)}if(w.appendChild(T),o===r.matchUpId){const A=document.createElement("div");A.className=y0e(),w.appendChild(A)}return w}function x0e({score:t}){var i;const e=(i=t==null?void 0:t.sets)==null?void 0:i.filter(Boolean).sort((s,a)=>(s.setNumber||0)-(a.setNumber||0)),r=e==null?void 0:e[e.length-1],n=(r==null?void 0:r.side1PointsScore)||(r==null?void 0:r.side2PointsScore),o=document.createElement("div");if(o.className=P0e(),n){const s=document.createElement("div");s.className=NR({variant:"points"}),s.innerHTML="PTS",o.appendChild(s)}for(const s of e||[]){const a=document.createElement("div");a.setAttribute("key",s.setNumber),a.className=NR({variant:"set"}),a.innerHTML=s.setNumber,o.appendChild(a)}return o}function L0e({selectedMatchUpId:t,eventHandlers:e,isRoundRobin:r,searchActive:n,composition:o,roundFactor:i,roundNumber:s,roundProfile:a,matchUps:l,isLucky:c}){const u=l.filter(S=>S.roundNumber===s).sort((S,O)=>(S.roundPosition||0)-(O.roundPosition||0)),d=u.every(({roundPosition:S})=>!S),p=(o==null?void 0:o.configuration)||{},v=document.createElement("div");if(v.className=a0e(),p.roundHeader){const S=_0e({roundProfile:a,roundMatchUps:u,roundNumber:s,eventHandlers:e});v.appendChild(S)}const f=document.createElement("div");f.className=I0e();let m,g,h;if(r){const S=b=>b.reduce((w,T)=>T+w,0);u.sort((b,w)=>{const T=S(b.drawPositions)-S(w.drawPositions),E=Math.min(...b.drawPositions??[])-Math.min(...w.drawPositions??[]);return T||E});const O=u.reduce((b,w)=>(b[w.structureId]=w.structureName,b),{});m=Object.values(O),g=Object.keys(O),h=Object.keys(fh.instanceCount(u.map(({structureId:b})=>b))).length}else d&&u.sort((S,O)=>(S.roundOrder??0)-(O.roundOrder??0));const _=h&&u.length/h,I=Object.keys(a).map(S=>parseInt(S)),P=I.indexOf(s),y=P===0&&"first"||P===I.length-1&&"last";return u.forEach((S,O)=>{const b=_&&!(O%_),w=_&&Math.floor(O/_),T=_&&m[w];if(b){const $=document.createElement("div");$.className=s0e({variant:w,roundOrder:y}),f.appendChild($);const A=document.createElement("div");if(A.className=l0e(),sl(e==null?void 0:e.groupHeaderClick)){const{drawId:U,containerStructureId:C}=u[0];f.onclick=()=>e.groupHeaderClick({drawId:U,structureId:g[w],containerStructureId:C})}s===1&&(A.innerHTML=T),f.appendChild(A)}const E=O%2===0;i&&(S.roundFactor=i);const N=jR({selectedMatchUpId:t,eventHandlers:e,searchActive:n,composition:o,matchUp:S,isAdHoc:d,isLucky:c,moeity:E});f.appendChild(N)}),v.appendChild(f),v}function V0e({selectedMatchUpId:t,eventHandlers:e,searchActive:r,composition:n,matchUps:o}){const{roundNumbers:i,roundProfile:s,hasOddMatchUpsCount:a,isNotEliminationStructure:l}=dae.getRoundMatchUps({matchUps:o}),c=o.some(({isRoundRobin:p})=>p),u=a||l,d=document.createElement("div");d.className=i0e();for(const p of i){const v=L0e({selectedMatchUpId:t,eventHandlers:e,isRoundRobin:c,searchActive:r,composition:n,roundNumber:p,roundProfile:s,matchUps:o,isLucky:u});d.appendChild(v)}return d}const RR=Ke({backgroundColor:"$colors$backgroundColor",color:"$colors$color",height:1e3});function B0e({content:t,theme:e}){const r=document.createElement("div");return r.className=e?Xi(RR(),e):RR(),e&&r.classList.add(e),typeof t=="string"?r.innerHTML=t:r.appendChild(t),r}const{createTheme:Qs}=bh({theme:{lineHeights:{scheduleInfo:`${Wc.scheduleInfo}rem`,centerInfo:`${Wc.centerInfo}rem`,gameScore:`${Wc.gameScore}rem`},borderWidths:{matchUpInline:"1px 1px",matchUp:"1px"},space:{1:"10px",2:"0.375rem",gameMarginInlineEnd:"0.25rem"},fontSizes:{1:"0.875rem"},colors:{internalDividers:"lightgray",backgroundColor:"white",connector:"lightgray",border:"darkgray",color:"black"},participant:{textTransform:"capitalize",minHeight:"2rem",seed:"gray"},score:{setWidth:"1.3rem"}}}),FR=Qs("australian-theme",{colors:{borderHover:"#0091d2",connector:"#999"}}),k0e=Qs("wimbledon-theme",{borderWidths:{borderInlineStart:"10px"},colors:{connector:"transparent",borderHover:"darkgrey",border:"#00703c",matchUp:"#fff"},participant:{textTransform:"uppercase"}}),G0e=Qs("french-theme",{colors:{winnerName:"#01503d!important",winner:"#01503d!important",borderHover:"#0091d2",border:"#F8F9F9"},matchUp:{boxShadow:"0 0 30px 0 hsla(0,0%,89%,9)"}}),W0e=Qs("usopen-theme",{colors:{matchUpBackgroundColor:"#F8F9F9",internalDividers:"darkgray",borderHover:"#0091d2",connector:"#999"}}),xR=Qs("basic-theme",{colors:{internalDividers:"transparent",winner:"#50B649!important",loser:"#E61A1A!important",connector:"#999"},space:{gameMarginInlineEnd:"0.75rem"},participant:{seed:"transparent"},fontSizes:{1:"1.5rem"}}),H0e=Qs("dark-theme",{colors:{backgroundColor:"#333333",borderHover:"#0091d2",color:"white"},participant:{seed:"cyan"}}),q0e=Qs("itf-theme",{colors:{borderHover:"#0091d2",connector:"#999",matchUp:"#fff"},participant:{textTransform:"uppercase",seed:"gray"}}),z0e={Australian:{configuration:{flags:!0},theme:FR},Basic:{configuration:{gameScoreOnly:!0,teamLogo:!1,roundHeader:!0},theme:xR},DrawPositions:{configuration:{gameScoreOnly:!0,drawPositions:!0,teamLogo:!1},theme:xR},French:{configuration:{bracketedSeeds:!0,flags:!0},theme:G0e},Wimbledon:{configuration:{resultsInfo:!0,flags:!0},theme:k0e},"US Open":{configuration:{scoreBox:!0,flags:!0},theme:W0e},ITF:{configuration:{winnerChevron:!0,centerInfo:!0,flags:!0,roundHeader:!0},theme:q0e},National:{configuration:{bracketedSeeds:"square",allDrawPositions:!0,drawPositions:!0,scheduleInfo:!0,roundHeader:!0,showAddress:!0},theme:FR},Night:{configuration:{flags:!0},theme:H0e}};no.cModal=mh,no.compositions=z0e,no.renderContainer=B0e,no.renderMatchUp=jR,no.renderParticipant=TR,no.renderStructure=V0e,Object.defineProperty(no,Symbol.toStringTag,{value:"Module"})});
|
|
32
|
+
`}function TR({eventHandlers:t,sideContainer:e,composition:r,sideNumber:n,matchUp:o,participant:i}){var w,T,E,N;const{winningSide:s,matchUpType:a,isRoundRobin:l,matchUpStatus:c}=o||{},u=r==null?void 0:r.configuration;let d;const p=n?(w=o==null?void 0:o.sides)==null?void 0:w.find($=>$.sideNumber===n):void 0;i||(i=p==null?void 0:p.participant,d=u!=null&&u.allDrawPositions||u!=null&&u.drawPositions&&(p!=null&&p.drawPosition)&&((o==null?void 0:o.roundNumber)===1||p!=null&&p.participantFed||l)?p==null?void 0:p.drawPosition:"");const v=((T=i==null?void 0:i.individualParticipants)==null?void 0:T.length)===2||a==="DOUBLES",f=v?(E=i==null?void 0:i.individualParticipants)==null?void 0:E[0]:i,m=v&&((N=i==null?void 0:i.individualParticipants)==null?void 0:N[1]),g=n===s||c==="BYE"&&i,h=(u==null?void 0:u.winnerChevron)&&g,_=u==null?void 0:u.teamLogo,I=["RETIRED","DOUBLE_WALKOVER","WALKOVER","DEFAULTED"].includes(c)&&!g,P=u==null?void 0:u.gameScoreOnly,y=document.createElement("div");if(y.className=e&&OF({drawPosition:d,sideNumber:n}),_){const $=e0e({teamLogo:_});y.appendChild($)}const S=document.createElement("div");S.className=SF({variant:v?"doubles":"singles"});const O=document.createElement("div");O.className=bF({winnerChevron:h,isDoubles:v});const b=bR({individualParticipant:f,eventHandlers:t,isWinningSide:g,composition:r,matchUp:o,side:p});if(O.appendChild(b),m){const $=bR({individualParticipant:m,eventHandlers:t,isWinningSide:g,composition:r,matchUp:o,side:p});O.appendChild($)}if(S.appendChild(O),y.appendChild(S),e){const $=document.createElement("div");if(g&&!P){const A=o0e();typeof A=="string"?$.innerHTML=A:$.appendChild(A)}else if(I){const A=Zye({matchUpStatus:c});$.appendChild(A)}y.appendChild($)}return y}const i0e=Ke({marginInlineStart:"1rem",overflowX:"auto",display:"flex"}),s0e=Ke({borderTop:"solid 1px black",marginRight:"-1em",marginLeft:"-1em",paddingTop:".5em",marginTop:".2em",variants:{variant:{0:{marginTop:"1em",borderTop:"none",paddingTop:"0px"}},roundOrder:{first:{marginLeft:"0em"},last:{marginRight:"0em"}}}}),a0e=Ke({flexDirection:"column",display:"flex"}),l0e=Ke({fontWeight:"bold",color:"blue",height:"1em"}),c0e=Ke({borderBottom:"solid 1px black",marginInlineStart:"16px",marginInlineEnd:"16px",fontWeight:"bold",width:"460px",height:"1.5em"}),u0e=Ke({willChange:"opacity",position:"fixed",zIndex:9998,bottom:0,right:0,left:0,top:0}),d0e=Ke({display:"block"}),p0e=Ke({position:"fixed",right:0,left:0}),f0e=Ke({paddingRight:"15px",alignItems:"center",margin:"30px auto",paddingLeft:"15px",position:"fixed",height:"100vh",display:"flex",width:"100%",zIndex:9999,bottom:0,right:0,left:0,top:0}),v0e=Ke({boxShadow:"0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23)",backgroundColor:"white",position:"relative",borderRadius:"3px",minHeight:"auto",width:"100%"}),m0e=Ke({borderBottom:"1px solid rgba(0, 0, 0, 0.1)",alignItems:"center",position:"relative",display:"flex"}),g0e=Ke({fontWeight:"600",fontSize:"20px"}),wR=Ke({borderTop:"1px solid rgba(0, 0, 0, 0.1)",justifyContent:"right",alignItems:"center",position:"relative",display:"flex"}),ER="Nothing to see here";function sl(t){return typeof t=="function"}function xp(t){return typeof t=="string"}function $R(t){return Array.isArray(t)}function vh(t){return typeof t=="object"&&!Array.isArray(t)}function h0e(t){if(t)for(;t.firstChild;)t.removeChild(t.firstChild)}const mh=(()=>{const t=p0e(),e={},r=".5";let n=[],o,i=[],s=[],a;const l=h=>{if(h){let _;s=s.filter(I=>(I.id===h&&(_=I),I.id!==h)),_&&document.body.removeChild(_)}else{const _=s.pop();_&&document.body.removeChild(_)}},c=()=>{a&&(a.style.opacity=0,a.style.display="none")},u=h=>{const _=s.length;if(h&&e[_]===!1)return;const I=i.pop(),P=n.pop();sl(I)&&I({content:P}),document.body.classList.remove(t),document.body.style.top=null,window.scrollTo({top:o,behavior:"instant"}),c(),l()},d=()=>{a=document.createElement("div"),a.className=u0e(),a.id="cmdl-backdrop",a.onclick=()=>u(!0),document.body.appendChild(a)},p=({config:h})=>{o=window.scrollY,document.body.classList.add(t),document.body.style.top=`-${o}px`,a||d(),a.style.display="",(h==null?void 0:h.backdrop)!==!1&&(a.style.backgroundColor="rgba(0, 0, 0, 0.2)",a.style.transition="opacity 0.15s linear",a.style.opacity=1)},v=({config:h,attr:_})=>{if(!xp(_))return;const I=_.split(".");for(const P of I)if(h=h==null?void 0:h[P],!h)return;return h},f=({config:h,attr:_,attrs:I,unit:P="em",value:y})=>{var O;let S;return xp(_)?S=v({config:h,attr:_}):$R(I)&&(S=(O=I.map(b=>v({config:h,attr:b})).filter(Boolean))==null?void 0:O[0]),S!==void 0&&(y=S),isNaN(y)?y:`${y}${P}`},m=({buttons:h,config:_,modalNumber:I})=>{var S,O;const P=document.createElement("div");P.className=wR(),P.style.padding=f({config:_,attrs:["footer.padding","padding"],value:r});const y={label:((S=_==null?void 0:_.dictionary)==null?void 0:S.close)||"Close",onClick:mh.close,intent:"is-info"};for(const b of h){if(b.hide)continue;const w=Object.assign({},y);vh(b)&&Object.assign(w,b);const T=document.createElement("button");w.disabled!==void 0&&(T.disabled=w.disabled),w.id&&(T.id=w.id),T.className=((O=w==null?void 0:w.footer)==null?void 0:O.className)||"button font-medium",T.classList.add(w.intent),T.style="margin-right: .5em;",T.innerHTML=w.label||w.text,T.onclick=E=>{E.stopPropagation(),sl(w.onClick)&&w.onClick({e:E,content:n[I]}),w.close!==!1&&(sl(w.close)&&w.close(),mh.close())},P.appendChild(T)}return P};return{close:u,open:({title:h="",content:_,buttons:I,footer:P,config:y,onClose:S}={})=>{p({config:y}),i.push(S);const O=s.length+1;e[O]=y==null?void 0:y.clickAway;const b=document.createElement("section"),w=`cmdl-${O}`;b.className=d0e(),b.role="dialog",b.tabIndex=-1,b.id=w;const T=document.createElement("div");T.className=f0e(),T.style.maxWidth=`${(y==null?void 0:y.maxWidth)||450}px`,T.onclick=()=>u(!0);const E=document.createElement("div");E.className=v0e(),E.onclick=j=>j.stopPropagation();const N=document.createElement("div"),$=document.createElement("div");N.appendChild($),E.appendChild(N);const A=({title:j,config:G})=>{N.className=j?m0e():"",N.style.padding=f({config:G,attrs:["title.padding","padding"],value:r}),$.className=j?g0e():"",$.innerHTML=j};h&&A({title:h});const U=document.createElement("div");E.appendChild(U);const C=({content:j,config:G})=>{U.style.fontSize=f({config:G,attr:"fontSize",value:"15px"}),U.style.position="relative",U.style.padding=f({config:G,attrs:["content.padding","padding"],value:r}),sl(j)?n[O]=j(U):vh(j)?U.appendChild(j):xp(j)?U.innerHTML=j:U.innerHTML=ER};if(C({content:_,config:y}),$R(I))P=m({buttons:I,config:y,modalNumber:O}),E.appendChild(P);else if(P){const j=document.createElement("div");j.className=wR(),j.style.padding=f({config:y,attrs:["footer.padding","padding"]}),vh(P)?j.appendChild(P):xp(P)?j.innerHTML=P:j.innerHTML=ER,E.appendChild(j)}T.appendChild(E),b.appendChild(T),document.body.appendChild(b),s.push(b);const M=({content:j,config:G})=>{n[O]=void 0,h0e(U),C({content:j,config:G})},D=({buttons:j,config:G})=>{E.removeChild(P),P=m({buttons:j,config:G,modalNumber:O}),E.appendChild(P)};return{setContent:M,setButtons:D,update:({content:j,buttons:G,title:W,config:z})=>{y=z||y,j&&M({content:j,config:y}),G&&D({buttons:G,config:y}),W&&A({title:W,config:y})}}}}})();function _0e({eventHandlers:t,roundMatchUps:e,roundProfile:r,roundNumber:n}){var s;const o=document.createElement("div");o.className=c0e(),sl(t==null?void 0:t.roundHeaderClick)&&(o.onclick=()=>t.roundHeaderClick({roundNumber:n,roundProfile:r,roundMatchUps:e}));const i=(s=r==null?void 0:r[n])==null?void 0:s.roundName;return o.innerHTML=i||"",o}const I0e=Ke({justifyContent:"space-around",marginInlineStart:"16px",marginInlineEnd:"16px",flexDirection:"column",height:"100%",display:"flex",width:"460px"}),NR=Ke({width:"$score$setWidth",display:"inline-block",fontSize:9,variants:{variant:{set:{textAlign:"center"},points:{marginInlineEnd:3}}}}),P0e=Ke({transform:"translateY(-50%)",textTransform:"uppercase",backgroundColor:"#fff",position:"absolute",textAlign:"center",top:"calc(50%)",color:"#bbb",fontSize:0,right:4});function y0e(){return Ke({backgroundColor:"magenta",position:"absolute",opacity:"0.2",height:"100%",width:"100%",top:0})}const S0e=Ke({});function O0e({configuration:t}){const e={backgroundColor:"$matchUpBackgroundColor",WebkitTransition:"all 0.30s linear",boxShadow:"$matchUp$boxShadow",transition:"all 0.30s linear",border:"solid $border",marginBottom:"$space$1",marginTop:"$space$1",position:"relative",display:"grid",width:"100%",borderInlineStartWidth:"$borderWidths$borderInlineStart"};if(t!=null&&t.matchUpHover){const r=typeof t.matchUpHover=="string"?t.matchUpHover:"cyan";e["&:hover"]={backgroundColor:r}}else e["&:hover"]={borderColor:"$borderHover"};return Ke(e)}function b0e({variant:t}){return Ke({borderBottom:"solid 1px lightgray",backgroundColor:"$matchUp",position:"relative",width:"100%",height:"$lineHeights$centerInfo",variants:{variant:{1:{borderBottom:"solid 1px black"},2:{borderBottom:"solid 1px lightgray"}}}})({variant:t})}const T0e=Ke({justifyContent:"center",alignContent:"center",flexDirection:"column",height:"100%",display:"flex"}),w0e=Ke({fontFamily:"Lato,Arial,Helvetica,sans-serif",WebkitFontSmooting:"antialiased",marginInlineStart:"calc(20%)",WebkitBoxOrient:"horizontal",WebKitBoxDirection:"normal",WebkitBoxPack:"center",boxSizing:"inherit",flexDirection:"row",display:"flex"}),UR=Ke({alignContent:"center",boxSizing:"inherit",fontFamily:"Lato",fontWeight:900,fontSize:9});function E0e({eventHandlers:t,entryStatus:e,sideNumber:r,className:n}){const o=document.createElement("div");o.onclick=t==null?void 0:t.centerInfoClick,o.className=Xi(b0e({variant:r}),n);const i=document.createElement("div");i.className=T0e();const s=document.createElement("div");s.className=w0e();const a=document.createElement("div");a.className=UR(),a.innerHTML=e?"Entry status: ":"",s.appendChild(a);const l=document.createElement("div");return l.className=UR(),l.innerHTML=e||"",s.appendChild(l),i.appendChild(s),o.appendChild(i),o}const Wc={scheduleInfo:1.8,centerInfo:1.5,gameScore:2};function $0e({composition:t,isDoubles:e,roundFactor:r=1}){const n=parseInt(window.getComputedStyle(document.body).getPropertyValue("font-size")),o=(t==null?void 0:t.configuration)||{},i=(o==null?void 0:o.connectorWidth)||16,s=o.centerInfo?Wc.centerInfo*n:0,a=o.scheduleInfo?Wc.scheduleInfo*n:0,c=(60+(o.showAddress?n:0))*(e?1.3:1)+s,u=c*r,d=(c+a)*r;return Ke({"&::before":{borderBlockStart:"$borderWidths$matchUp solid #999",left:-i,width:i,position:"absolute",borderRadius:2,top:-1},"&::after":{width:i,position:"absolute",borderRadius:2,left:"100%"},"&::after, &::before":{borderWidth:"$borderWidths$matchUp",borderColor:"$connector",display:"block",content:""},variants:{isFirstRound:{true:{"&::before":{height:0,width:0,borderWidth:0}}},link:{m1:{"&::after":{borderInlineEnd:"$borderWidths$matchUp solid $connector",borderTopStyle:"solid",height:u,top:-1}},m2:{"&::after":{bottom:"calc(100%)",borderInlineEnd:"$borderWidths$matchUp solid $connector",borderBottomStyle:"solid",height:d}},m0:{"&::after":{borderTopStyle:"solid",borderColor:"$connector",top:-1}},mr:{"&::before":{height:0,width:0,borderWidth:0},"&::after":{height:0,width:0,borderWidth:0}},noProgression:{true:{"&::after":{height:0,width:0,borderWidth:0}}}}}})}const AR=t=>Ke({display:"flex",alignItems:"center",height:t,justifyContent:"flex-end",backgroundColor:"$matchUp",variants:{sideNumber:{1:{borderBottom:"1px solid $internalDividers"}},fontSize:{small:{fontSize:"smaller",paddingRight:"1em",color:"blue"}}}}),N0e=Ke({letterSpacing:"-0.2em",lineHeight:"0.75rem",position:"absolute",fontSize:"0.625rem",left:"1.1rem",top:".4rem"}),CR=Ke({lineHeight:"$lineHeights$gameScore",justifyContent:"center",width:"$score$setWidth",position:"relative",textAlign:"center",cursor:"pointer",fontWeight:500,fontSize:"$1",display:"flex",margin:0,variants:{variant:{winner:{color:"$winner!important",fontWeight:700},loser:{color:"$loser!important"}}}}),U0e=Ke({marginInlineEnd:"$space$gameMarginInlineEnd",justifyContent:"flex-end",alignItems:"center",display:"flex"});function A0e({value:t}={}){const e=document.createElement("input");return e.onclick=r=>r.target.select(),e.className=CR(),e.value=t,e}function C0e({gameScoreOnly:t,scoreStripes:e,set:r,sideNumber:n}){const i=n===(r==null?void 0:r.winningSide)||r!=null&&r.winningSide?"loser":void 0,s=n===2?r.side2Score:r.side1Score,a=n===2?r.side2TiebreakScore:r.side1TiebreakScore,l=s===void 0&&a,c=l||s,u=e&&r.setNumber%2?"lightgray":"transparent",p=r.editing?r.editing===n:void 0;let v;if(p)v=A0e({value:c});else if(v=document.createElement("p"),v.className=CR({variant:i}),v.style.backgroundColor=u,v.innerHTML=isNaN(c)?"":c,!t){const f=document.createElement("span");f.className=N0e(),f.innerHTML=l?a:"",v.appendChild(f)}return v}function M0e({participantHeight:t,eventHandlers:e,composition:r,sideNumber:n,matchUp:o}){var f,m,g,h;const i=(f=r==null?void 0:r.configuration)==null?void 0:f.winnerChevron,s=(m=r==null?void 0:r.configuration)==null?void 0:m.gameScoreOnly,a=((g=o==null?void 0:o.score)==null?void 0:g.sets)||[],l=(h=r==null?void 0:r.configuration)==null?void 0:h.scoreBox,c=n===2?t:t-1,u=AR(c),d=_=>{typeof(e==null?void 0:e.scoreClick)=="function"&&(_.stopPropagation(),e.scoreClick({event:_,matchUp:o}))},p=document.createElement("div");p.className=u({sideNumber:!l&&n,fontSize:"5px"}),p.classList.add("sideScore"),p.onclick=d;const v=document.createElement("div");v.className=U0e();for(const _ of a||[]){const I=C0e({gameScoreOnly:s,scoreStripes:i,sideNumber:n,set:_});v.appendChild(I)}return p.appendChild(v),p}const D0e=Ke({height:"$lineHeights$scheduleInfo",borderBottom:"1px solid darkgray",justifyContent:"space-between",backgroundColor:"#F8F9F9",boxSizing:"border-box",paddingRight:"0.5rem",paddingLeft:"0.5rem",alignItems:"center",cursor:"pointer",color:"#7F8080",display:"flex",width:"100%"});var MR={exports:{}};(function(t,e){(function(r,n){t.exports=n()})($F,function(){var r=1e3,n=6e4,o=36e5,i="millisecond",s="second",a="minute",l="hour",c="day",u="week",d="month",p="quarter",v="year",f="date",m="Invalid Date",g=/^(\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,_={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($){var A=["th","st","nd","rd"],U=$%100;return"["+$+(A[(U-20)%10]||A[U]||A[0])+"]"}},I=function($,A,U){var C=String($);return!C||C.length>=A?$:""+Array(A+1-C.length).join(U)+$},P={s:I,z:function($){var A=-$.utcOffset(),U=Math.abs(A),C=Math.floor(U/60),M=U%60;return(A<=0?"+":"-")+I(C,2,"0")+":"+I(M,2,"0")},m:function $(A,U){if(A.date()<U.date())return-$(U,A);var C=12*(U.year()-A.year())+(U.month()-A.month()),M=A.clone().add(C,d),D=U-M<0,R=A.clone().add(C+(D?-1:1),d);return+(-(C+(U-M)/(D?M-R:R-M))||0)},a:function($){return $<0?Math.ceil($)||0:Math.floor($)},p:function($){return{M:d,y:v,w:u,d:c,D:f,h:l,m:a,s,ms:i,Q:p}[$]||String($||"").toLowerCase().replace(/s$/,"")},u:function($){return $===void 0}},y="en",S={};S[y]=_;var O=function($){return $ instanceof E},b=function $(A,U,C){var M;if(!A)return y;if(typeof A=="string"){var D=A.toLowerCase();S[D]&&(M=D),U&&(S[D]=U,M=D);var R=A.split("-");if(!M&&R.length>1)return $(R[0])}else{var j=A.name;S[j]=A,M=j}return!C&&M&&(y=M),M||!C&&y},w=function($,A){if(O($))return $.clone();var U=typeof A=="object"?A:{};return U.date=$,U.args=arguments,new E(U)},T=P;T.l=b,T.i=O,T.w=function($,A){return w($,{locale:A.$L,utc:A.$u,x:A.$x,$offset:A.$offset})};var E=function(){function $(U){this.$L=b(U.locale,null,!0),this.parse(U)}var A=$.prototype;return A.parse=function(U){this.$d=function(C){var M=C.date,D=C.utc;if(M===null)return new Date(NaN);if(T.u(M))return new Date;if(M instanceof Date)return new Date(M);if(typeof M=="string"&&!/Z$/i.test(M)){var R=M.match(g);if(R){var j=R[2]-1||0,G=(R[7]||"0").substring(0,3);return D?new Date(Date.UTC(R[1],j,R[3]||1,R[4]||0,R[5]||0,R[6]||0,G)):new Date(R[1],j,R[3]||1,R[4]||0,R[5]||0,R[6]||0,G)}}return new Date(M)}(U),this.$x=U.x||{},this.init()},A.init=function(){var U=this.$d;this.$y=U.getFullYear(),this.$M=U.getMonth(),this.$D=U.getDate(),this.$W=U.getDay(),this.$H=U.getHours(),this.$m=U.getMinutes(),this.$s=U.getSeconds(),this.$ms=U.getMilliseconds()},A.$utils=function(){return T},A.isValid=function(){return this.$d.toString()!==m},A.isSame=function(U,C){var M=w(U);return this.startOf(C)<=M&&M<=this.endOf(C)},A.isAfter=function(U,C){return w(U)<this.startOf(C)},A.isBefore=function(U,C){return this.endOf(C)<w(U)},A.$g=function(U,C,M){return T.u(U)?this[C]:this.set(M,U)},A.unix=function(){return Math.floor(this.valueOf()/1e3)},A.valueOf=function(){return this.$d.getTime()},A.startOf=function(U,C){var M=this,D=!!T.u(C)||C,R=T.p(U),j=function(H,q){var J=T.w(M.$u?Date.UTC(M.$y,q,H):new Date(M.$y,q,H),M);return D?J:J.endOf(c)},G=function(H,q){return T.w(M.toDate()[H].apply(M.toDate("s"),(D?[0,0,0,0]:[23,59,59,999]).slice(q)),M)},W=this.$W,z=this.$M,F=this.$D,L="set"+(this.$u?"UTC":"");switch(R){case v:return D?j(1,0):j(31,11);case d:return D?j(1,z):j(0,z+1);case u:var x=this.$locale().weekStart||0,B=(W<x?W+7:W)-x;return j(D?F-B:F+(6-B),z);case c:case f:return G(L+"Hours",0);case l:return G(L+"Minutes",1);case a:return G(L+"Seconds",2);case s:return G(L+"Milliseconds",3);default:return this.clone()}},A.endOf=function(U){return this.startOf(U,!1)},A.$set=function(U,C){var M,D=T.p(U),R="set"+(this.$u?"UTC":""),j=(M={},M[c]=R+"Date",M[f]=R+"Date",M[d]=R+"Month",M[v]=R+"FullYear",M[l]=R+"Hours",M[a]=R+"Minutes",M[s]=R+"Seconds",M[i]=R+"Milliseconds",M)[D],G=D===c?this.$D+(C-this.$W):C;if(D===d||D===v){var W=this.clone().set(f,1);W.$d[j](G),W.init(),this.$d=W.set(f,Math.min(this.$D,W.daysInMonth())).$d}else j&&this.$d[j](G);return this.init(),this},A.set=function(U,C){return this.clone().$set(U,C)},A.get=function(U){return this[T.p(U)]()},A.add=function(U,C){var M,D=this;U=Number(U);var R=T.p(C),j=function(z){var F=w(D);return T.w(F.date(F.date()+Math.round(z*U)),D)};if(R===d)return this.set(d,this.$M+U);if(R===v)return this.set(v,this.$y+U);if(R===c)return j(1);if(R===u)return j(7);var G=(M={},M[a]=n,M[l]=o,M[s]=r,M)[R]||1,W=this.$d.getTime()+U*G;return T.w(W,this)},A.subtract=function(U,C){return this.add(-1*U,C)},A.format=function(U){var C=this,M=this.$locale();if(!this.isValid())return M.invalidDate||m;var D=U||"YYYY-MM-DDTHH:mm:ssZ",R=T.z(this),j=this.$H,G=this.$m,W=this.$M,z=M.weekdays,F=M.months,L=M.meridiem,x=function(q,J,K,Y){return q&&(q[J]||q(C,D))||K[J].slice(0,Y)},B=function(q){return T.s(j%12||12,q,"0")},H=L||function(q,J,K){var Y=q<12?"AM":"PM";return K?Y.toLowerCase():Y};return D.replace(h,function(q,J){return J||function(K){switch(K){case"YY":return String(C.$y).slice(-2);case"YYYY":return T.s(C.$y,4,"0");case"M":return W+1;case"MM":return T.s(W+1,2,"0");case"MMM":return x(M.monthsShort,W,F,3);case"MMMM":return x(F,W);case"D":return C.$D;case"DD":return T.s(C.$D,2,"0");case"d":return String(C.$W);case"dd":return x(M.weekdaysMin,C.$W,z,2);case"ddd":return x(M.weekdaysShort,C.$W,z,3);case"dddd":return z[C.$W];case"H":return String(j);case"HH":return T.s(j,2,"0");case"h":return B(1);case"hh":return B(2);case"a":return H(j,G,!0);case"A":return H(j,G,!1);case"m":return String(G);case"mm":return T.s(G,2,"0");case"s":return String(C.$s);case"ss":return T.s(C.$s,2,"0");case"SSS":return T.s(C.$ms,3,"0");case"Z":return R}return null}(q)||R.replace(":","")})},A.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},A.diff=function(U,C,M){var D,R=this,j=T.p(C),G=w(U),W=(G.utcOffset()-this.utcOffset())*n,z=this-G,F=function(){return T.m(R,G)};switch(j){case v:D=F()/12;break;case d:D=F();break;case p:D=F()/3;break;case u:D=(z-W)/6048e5;break;case c:D=(z-W)/864e5;break;case l:D=z/o;break;case a:D=z/n;break;case s:D=z/r;break;default:D=z}return M?D:T.a(D)},A.daysInMonth=function(){return this.endOf(d).$D},A.$locale=function(){return S[this.$L]},A.locale=function(U,C){if(!U)return this.$L;var M=this.clone(),D=b(U,C,!0);return D&&(M.$L=D),M},A.clone=function(){return T.w(this.$d,this)},A.toDate=function(){return new Date(this.valueOf())},A.toJSON=function(){return this.isValid()?this.toISOString():null},A.toISOString=function(){return this.$d.toISOString()},A.toString=function(){return this.$d.toUTCString()},$}(),N=E.prototype;return w.prototype=N,[["$ms",i],["$s",s],["$m",a],["$H",l],["$W",c],["$M",d],["$y",v],["$D",f]].forEach(function($){N[$[1]]=function(A){return this.$g(A,$[0],$[1])}}),w.extend=function($,A){return $.$i||($(A,E,w),$.$i=!0),w},w.locale=b,w.isDayjs=O,w.unix=function($){return w(1e3*$)},w.en=S[y],w.Ls=S,w.p={},w})})(MR);var j0e=MR.exports;const R0e=Eh(j0e);function F0e({matchUp:t,eventHandlers:e}){const{scheduledTime:r,scheduledDate:n,venueAbbreviation:o,courtName:i}=(t==null?void 0:t.schedule)||{},{dateTime:{extractDate:s,extractTime:a}}=fh,l=a(r);let u=s(n),d="ddd D MMMM";l&&(d+=", hh:mm A",u+=`T${l}`);const p=n?R0e(u).format(d):"Not scheduled",v=o&&(i==null?void 0:i.toString().startsWith(o))&&i||o&&i&&`${o} ${i}`||i||o||"",f=document.createElement("div");f.className=D0e(),f.onclick=e==null?void 0:e.scheduleClick;const m=document.createElement("div");m.innerHTML=p,f.append(m);const g=_=>{typeof(e==null?void 0:e.venueClick)=="function"&&(_.stopPropagation(),e.venueClick({matchUp:t,event:_}))},h=document.createElement("div");return h.onclick=g,h.innerHTML=v,f.append(h),f}function DR({eventHandlers:t,composition:e,sideNumber:r,className:n,matchUp:o}){var v,f;const i=(e==null?void 0:e.configuration)||{},s=i==null?void 0:i.scheduleInfo,a=(v=o==null?void 0:o.score)==null?void 0:v.scoreStringSide1,l=((f=e==null?void 0:e.configuration)==null?void 0:f.scoreBox)&&a,c=(o==null?void 0:o.readyToScore)&&(t==null?void 0:t.scoreClick)&&!fh.scoreHasValue({matchUp:o}),u=document.createElement("div");if(u.className=Xi(t0e(),n),s&&r===1){const m=F0e({matchUp:o,eventHandlers:t});u.appendChild(m)}const d=document.createElement("div");d.className=r0e();const p=TR({sideContainer:!0,eventHandlers:t,composition:e,sideNumber:r,matchUp:o});if(d.appendChild(p),l){const m=document.createElement("div");m.style.border="1px solid lightgray",d.appendChild(m)}if(a){const m=M0e({eventHandlers:t,composition:e,sideNumber:r,matchUp:o});d.appendChild(m)}if(c){const m=AR(),g=_=>{typeof(t==null?void 0:t.scoreClick)=="function"&&(_.stopPropagation(),t.scoreClick({event:_,matchUp:o}))},h=document.createElement("div");h.className=m({sideNumber:!l&&r,fontSize:"small"}),h.onclick=g,h.innerHTML="[Score]",d.appendChild(h)}return u.appendChild(d),u}function jR(t){const{composition:e,matchUp:r,moeity:n,selectedMatchUpId:o,searchActive:i}=t,{roundFactor:s,roundNumber:a,finishingRound:l,matchUpType:c,preFeedRound:u,stage:d}=r,p=d==="QUALIFYING",v=parseInt(l)===1,f=d==="QUALIFYING"&&v,m=!p&&v,g=parseInt(a)===1,h=c==="DOUBLES",_=(i||r.isRoundRobin||r.collectionId||t.isLucky||t.isAdHoc)&&"mr"||m&&"noProgression"||(f||u)&&"m0"||n&&"m1"||"m2",I=$0e({composition:e,isDoubles:h,roundFactor:s})({isFirstRound:g,link:_}),P=(e==null?void 0:e.configuration)||{},{resultsInfo:y,centerInfo:S}=P||{},O=t.eventHandlers||{},b=A=>{typeof(O==null?void 0:O.matchUpClick)=="function"&&O.matchUpClick({event:A,matchUp:r})},w=document.createElement("div");w.className=Xi(e.theme,t==null?void 0:t.className,"matchup",S0e()),w.onclick=b;const T=document.createElement("div");T.className=O0e({configuration:P});const E=({sideNumber:A})=>{var M,D,R;const U=(R=(D=(M=r==null?void 0:r.sides.find(j=>j.sideNumber===A))==null?void 0:M.participant)==null?void 0:D.entryStatus)==null?void 0:R.replace("_"," ");return E0e({eventHandlers:O,entryStatus:U,sideNumber:A,className:A===2&&I})},N=DR({sideNumber:1,eventHandlers:O,composition:e,matchUp:r}),$=DR({className:!S&&I,sideNumber:2,eventHandlers:O,composition:e,matchUp:r});if(T.appendChild(N),S&&(T.appendChild(E({sideNumber:1})),T.appendChild(E({sideNumber:2}))),T.appendChild($),y){const A=x0e({score:r.score});T.appendChild(A)}if(w.appendChild(T),o===r.matchUpId){const A=document.createElement("div");A.className=y0e(),w.appendChild(A)}return w}function x0e({score:t}){var i;const e=(i=t==null?void 0:t.sets)==null?void 0:i.filter(Boolean).sort((s,a)=>(s.setNumber||0)-(a.setNumber||0)),r=e==null?void 0:e[e.length-1],n=(r==null?void 0:r.side1PointsScore)||(r==null?void 0:r.side2PointsScore),o=document.createElement("div");if(o.className=P0e(),n){const s=document.createElement("div");s.className=NR({variant:"points"}),s.innerHTML="PTS",o.appendChild(s)}for(const s of e||[]){const a=document.createElement("div");a.setAttribute("key",s.setNumber),a.className=NR({variant:"set"}),a.innerHTML=s.setNumber,o.appendChild(a)}return o}function L0e({selectedMatchUpId:t,eventHandlers:e,isRoundRobin:r,searchActive:n,composition:o,roundFactor:i,roundNumber:s,roundProfile:a,matchUps:l,isLucky:c}){const u=l.filter(S=>S.roundNumber===s).sort((S,O)=>(S.roundPosition||0)-(O.roundPosition||0)),d=u.every(({roundPosition:S})=>!S),p=(o==null?void 0:o.configuration)||{},v=document.createElement("div");if(v.className=a0e(),p.roundHeader){const S=_0e({roundProfile:a,roundMatchUps:u,roundNumber:s,eventHandlers:e});v.appendChild(S)}const f=document.createElement("div");f.className=I0e();let m,g,h;if(r){const S=b=>b.reduce((w,T)=>T+w,0);u.sort((b,w)=>{const T=S(b.drawPositions)-S(w.drawPositions),E=Math.min(...b.drawPositions??[])-Math.min(...w.drawPositions??[]);return T||E});const O=u.reduce((b,w)=>(b[w.structureId]=w.structureName,b),{});m=Object.values(O),g=Object.keys(O),h=Object.keys(fh.instanceCount(u.map(({structureId:b})=>b))).length}else d&&u.sort((S,O)=>(S.roundOrder??0)-(O.roundOrder??0));const _=h&&u.length/h,I=Object.keys(a).map(S=>parseInt(S)),P=I.indexOf(s),y=P===0&&"first"||P===I.length-1&&"last";return u.forEach((S,O)=>{const b=_&&!(O%_),w=_&&Math.floor(O/_),T=_&&m[w];if(b){const $=document.createElement("div");$.className=s0e({variant:w,roundOrder:y}),f.appendChild($);const A=document.createElement("div");if(A.className=l0e(),sl(e==null?void 0:e.groupHeaderClick)){const{drawId:U,containerStructureId:C}=u[0];f.onclick=()=>e.groupHeaderClick({drawId:U,structureId:g[w],containerStructureId:C})}s===1&&(A.innerHTML=T),f.appendChild(A)}const E=O%2===0;i&&(S.roundFactor=i);const N=jR({selectedMatchUpId:t,eventHandlers:e,searchActive:n,composition:o,matchUp:S,isAdHoc:d,isLucky:c,moeity:E});f.appendChild(N)}),v.appendChild(f),v}function V0e({selectedMatchUpId:t,eventHandlers:e,searchActive:r,composition:n,matchUps:o}){const{roundNumbers:i,roundProfile:s,hasOddMatchUpsCount:a,isNotEliminationStructure:l}=dae.getRoundMatchUps({matchUps:o}),c=o.some(({isRoundRobin:p})=>p),u=a||l,d=document.createElement("div");d.className=i0e();for(const p of i){const v=L0e({selectedMatchUpId:t,eventHandlers:e,isRoundRobin:c,searchActive:r,composition:n,roundNumber:p,roundProfile:s,matchUps:o,isLucky:u});d.appendChild(v)}return d}const RR=Ke({backgroundColor:"$colors$backgroundColor",color:"$colors$color",height:1e3});function B0e({content:t,theme:e}){const r=document.createElement("div");return r.className=e?Xi(RR(),e):RR(),e&&r.classList.add(e),typeof t=="string"?r.innerHTML=t:r.appendChild(t),r}const{createTheme:Qs}=bh({theme:{lineHeights:{scheduleInfo:`${Wc.scheduleInfo}rem`,centerInfo:`${Wc.centerInfo}rem`,gameScore:`${Wc.gameScore}rem`},borderWidths:{matchUpInline:"1px 1px",matchUp:"1px"},space:{1:"10px",2:"0.375rem",gameMarginInlineEnd:"0.25rem"},fontSizes:{1:"0.875rem"},colors:{internalDividers:"lightgray",backgroundColor:"white",connector:"lightgray",border:"darkgray",color:"black"},participant:{textTransform:"capitalize",minHeight:"2rem",seed:"gray"},score:{setWidth:"1.3rem"}}}),FR=Qs("australian-theme",{colors:{borderHover:"#0091d2",connector:"#999"}}),k0e=Qs("wimbledon-theme",{borderWidths:{borderInlineStart:"10px"},colors:{connector:"transparent",borderHover:"darkgrey",border:"#00703c",matchUp:"#fff"},participant:{textTransform:"uppercase"}}),G0e=Qs("french-theme",{colors:{winnerName:"#01503d!important",winner:"#01503d!important",borderHover:"#0091d2",border:"#F8F9F9"},matchUp:{boxShadow:"0 0 30px 0 hsla(0,0%,89%,9)"}}),W0e=Qs("usopen-theme",{colors:{matchUpBackgroundColor:"#F8F9F9",internalDividers:"darkgray",borderHover:"#0091d2",connector:"#999"}}),xR=Qs("basic-theme",{colors:{internalDividers:"transparent",winner:"#50B649!important",loser:"#E61A1A!important",connector:"#999"},space:{gameMarginInlineEnd:"0.75rem"},participant:{seed:"transparent"},fontSizes:{1:"1.5rem"}}),H0e=Qs("dark-theme",{colors:{backgroundColor:"#333333",borderHover:"#0091d2",color:"white"},participant:{seed:"cyan"}}),q0e=Qs("itf-theme",{colors:{borderHover:"#0091d2",connector:"#999",matchUp:"#fff"},participant:{textTransform:"uppercase",seed:"gray"}}),z0e={Australian:{configuration:{flags:!0},theme:FR},Basic:{configuration:{gameScoreOnly:!0,teamLogo:!1,roundHeader:!0},theme:xR},DrawPositions:{configuration:{gameScoreOnly:!0,drawPositions:!0,teamLogo:!1},theme:xR},French:{configuration:{bracketedSeeds:!0,flags:!0},theme:G0e},Wimbledon:{configuration:{resultsInfo:!0,flags:!0},theme:k0e},"US Open":{configuration:{scoreBox:!0,flags:!0},theme:W0e},ITF:{configuration:{winnerChevron:!0,centerInfo:!0,flags:!0,roundHeader:!0},theme:q0e},National:{configuration:{bracketedSeeds:"square",allDrawPositions:!0,drawPositions:!0,scheduleInfo:!0,roundHeader:!0,showAddress:!0,scaleAttributes:{scaleType:"RATING",scaleName:"WTN",accessor:"wtnRating"}},theme:FR},Night:{configuration:{flags:!0},theme:H0e}};no.cModal=mh,no.compositions=z0e,no.renderContainer=B0e,no.renderMatchUp=jR,no.renderParticipant=TR,no.renderStructure=V0e,Object.defineProperty(no,Symbol.toStringTag,{value:"Module"})});
|