UNPKG

tods-competition-factory

Version:

Create and mutate TODS compliant tournament objects

1 lines • 1.52 MB
var BY=Object.defineProperty;var _t=(t,e)=>{for(var r in e)BY(t,r,{get:e[r],enumerable:!0})};var bL="5.2.4";function Ci(){return bL}var cI={};_t(cI,{availabilityGovernor:()=>hw,competitionGovernor:()=>uC,drawsGovernor:()=>PO,entriesGovernor:()=>vO,eventGovernor:()=>jO,generationGovernor:()=>QO,matchUpFormatGovernor:()=>QN,matchUpGovernor:()=>I_,mocksGovernor:()=>yT,officiatingGovernor:()=>bw,participantGovernor:()=>K_,policyGovernor:()=>Jv,practiceGovernor:()=>Fw,publishingGovernor:()=>nx,queryGovernor:()=>EO,rankingGovernor:()=>ET,reportGovernor:()=>mx,scheduleGovernor:()=>Rx,scoreGovernor:()=>WS,tieFormatGovernor:()=>Fx,tournamentGovernor:()=>rw,venueGovernor:()=>Kw});var uC={};_t(uC,{getCompetitionLeaderboard:()=>LE,getCompetitionParticipantState:()=>wE,getCompetitionPolicy:()=>Lo,getCompetitionState:()=>zo,getLinkedTournamentIds:()=>Bp,getTournamentIds:()=>Sm,initializeCompetitionState:()=>rC,linkTournaments:()=>Wb,mutate:()=>aC,processCompetitionMatchUp:()=>Tm,processCompetitionRound:()=>iC,query:()=>cC,resetCompetitionState:()=>sC,unlinkTournament:()=>jb,unlinkTournaments:()=>Yb});var aC={};_t(aC,{initializeCompetitionState:()=>rC,linkTournaments:()=>Wb,processCompetitionMatchUp:()=>Tm,processCompetitionRound:()=>iC,resetCompetitionState:()=>sC,unlinkTournament:()=>jb,unlinkTournaments:()=>Yb});var Gs="SINGLES",Ct="SINGLES",ai="DOUBLES",Ut="DOUBLES",hr="TEAM",xt="TEAM",WY="HYBRID",qd="HYBRID",CL={SINGLES_MATCHUP:Gs,SINGLES:Ct,DOUBLES_MATCHUP:ai,DOUBLES:Ut,TEAM_MATCHUP:hr,TEAM:xt,HYBRID_MATCHUP:WY,HYBRID:qd};var yy={[Ct]:[Ct,"S"],[Ut]:[Ut,"D"],[xt]:[xt,"T"],[qd]:[qd,"H"],S:[Ct,"S"],D:[Ut,"D"],T:[xt,"T"],H:[qd,"H"]};function ee(t,e){return(t??0)-(e??0)}function st(t){return typeof t=="number"?parseInt(t.toString()):typeof t=="string"?parseInt(t):0}function Vr(t){return typeof t=="function"}function wt(t){return typeof t=="string"}function St(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ML(t,e){if(!St(t)||!St(e))return!1;let r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(let o of r)if(t[o]!==e[o])return!1;return!0}function Ay(t,e){return Array.isArray(t)?Object.assign({},...(t??[]).filter(St).map(r=>r[e]&&{[r[e]]:r}).filter(Boolean)):{}}var vL=t=>e=>Object.keys(t).every(r=>e[r]===t[r]);function Ey(t,e){if(t===void 0)return null;if(!St(t)||t===null)return t;let r=Object.keys(t),n=o=>o===void 0?null:o;return Object.assign({},...r.map(o=>Array.isArray(t[o])?{[o]:e?t[o]:t[o].map(i=>Ey(i))}:{[o]:e?n(t[o]):Ey(t[o])}))}function AU(t){return Array.isArray(t)?t.length+t.map(AU).reduce((e,r)=>e+r,0):St(t)&&t!==null?Object.keys(t).length+Object.keys(t).map(e=>AU(t[e])).reduce((e,r)=>e+r,0):0}function OL(t){if(t===null||typeof t!="object")return;let e=JSON.stringify(t),r=AU(t),n=e.split("").reduce((o,i)=>o+i.charCodeAt(0),0);return[e.length,r,n].map(o=>o.toString(36)).join("")}function rn(t){return Number.isNaN(Number(t))?!1:t>0&&(t&t-1)===0}function _L(t){if(!t.length)return;let e=[...t].sort(ee),r=Math.floor(e.length/2);return e.length%2?e[r]:(e[r-1]+e[r])/2}function xL(t){if(t===1||Number.isNaN(Number(t))||!rn(t))return!1;let e=t,r=1;for(;e!==2;)r+=1,e=e/2;return r}function xl(t){return Number.isNaN(Number(t))?0:t%2&&t+1||t}function wl(t){return Math.pow(2,Math.round(Math.log(t)/Math.log(2)))}function We(t){return!Number.isNaN(Number.parseFloat(t))}function Py(t){let e=st(t);if(!Number.isNaN(e))return e===0?!1:(e&-e)===1}function Mi(t){if(Number.isNaN(Number(t)))return!1;for(;!rn(t);)t++;return t}function pn(t,e,r){return t=Math.ceil(t),e=Math.floor(e),Math.floor((r??Math.random)()*(e-t+1))+t}function It(t){return wt(t)&&!t.trim().length?!1:Number.isSafeInteger(typeof t=="string"?+t:t)}function wL(t=1,e=3,r=!0,n){let o=n??Math.random,i=0;for(let s=0;s<e;s++)i+=o()*(t/e);return r&&t>1?Math.round(i):i}function YY(t,e){e||(e=1);let r=1/e;return Math.round(t*r)/r}function PU(t,e,r,n,o=2,i){let s=i??Math.random,a=1-s(),c=1-s(),u=Math.sqrt(-2*Math.log(a))*Math.cos(2*Math.PI*c);return u=u/10+.5,u>1||u<0?u=PU(t,e,r,void 0,2,i):(u=Math.pow(u,r),u*=e-t,u+=t),n&&(u=YY(u,n)),Number.parseFloat(u.toFixed(o))}function SI(t,e=2){return Number.parseFloat(Number(Math.round(t*1e3)/1e3).toFixed(e))}function ct(t){return Array.isArray(t)?t?.filter((e,r,n)=>n.lastIndexOf(e)===r):[]}function LL(t){return Array.isArray(t)?t?.map(e=>e===null?void 0:e):t}function dr(t,e){if(!Array.isArray(t))return[];let r=e??Math.random;return t.map(n=>[r(),n]).sort((n,o)=>n[0]-o[0]).map(n=>n[1])}function Jc(t){return It(t)?t:1/0}function dn(t){return Array.isArray(t)?t.reduce((e,r)=>(e[r]||(e[r]=0),e[r]++,e),{}):{}}function FL(t){return NU(dn(t))}function NU(t){return Object.keys(t).reduce((e,r)=>{let n=t[r];return e[n]?e[n].push(r):e[n]=[r],e},{})}function jY(t,e,r){return r.indexOf(t)===e}function Ny(t){return t.filter(jY)}function Sr(t,e){return Array.isArray(t)&&t.length?t.splice(Math.floor((e??Math.random)()*t.length),1)[0]:void 0}function Dn(t,e){let r=Math.floor((e??Math.random)()*t.length);return t[r]}function X(t,e){return Array.from({length:e-t},(r,n)=>n+t)}function Ss(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 DU(t,e){return!Array.isArray(t)||!Array.isArray(e)?[]:t.filter(r=>!e.includes(r))}function Le(t,e){return!Array.isArray(t)||!Array.isArray(e)?!1:t.some(r=>e.includes(r))}function kL(t,e){return Array.isArray(e)&&e.reduce((r,n)=>(r[n]=1+r[n]||1,r),{})[t]||0}function GL(t,e,r,n){return Array.isArray(t)?[].concat(...t.slice(0,e),...t.slice(e,e+r).sort(n),...t.slice(e+r,t.length)):[]}function Pe(t,e){return Array.isArray(t)?t.reduce((r,n,o)=>{let i=Math.floor(o/e);return r[i]=[].concat(r[i]??[],n),r},[]):[]}function UU(t,[e,...r]){return t.length?[t.slice(0,e),...UU(t.slice(e),[...r,e])]:[]}function VL(t){return t.reduce((e,r)=>{let n=e[e.length-1];return(!n||n[n.length-1]!==r-1)&&e.push([]),e[e.length-1].push(r),e},[])}function Dy(t){return Array.isArray(t)?t.reduce((e,r)=>!isNaN(parseInt(r))&&e,!0):!1}function Uy(t){return Array.isArray(t)?t.reduce((e,r)=>isNaN(parseInt(r))&&e,!0):!1}function TI(t,e,r){return Array.isArray(t)?t.reduce((n,o,i)=>{let s=r?!!(Math.floor(i/e)%2):!1,a=i%e,c=s?e-1-a:a;return n[c]||(n[c]=[]),n[c].push(o),n},[]):[]}function BL(t,e=1){if(!Array.isArray(t)||!t.every(It))return[];let r=Math.min(...t,e),n=Math.max(...t);return X(r,n+1).filter(o=>!t.includes(o))}function Vs(t,e){return!Array.isArray(t)||!wt(e)?!1:Ht(t,yy[e]).length}var P={success:!0},RU="error",HL={SUCCESS:P,ERROR:RU};function Ry({collectionValueProfiles:t,matchUpCount:e}){let 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(let o of t){if(typeof o!="object")return r.push(`valueProfile is not type object: ${o}`),{errors:r};let{matchUpValue: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}}let n=t.map(o=>o.collectionPosition);return n.length!==ct(n).length?(r.push("collectionPositions are not unique"),{errors:r}):{...P}}var iF={};_t(iF,{addNotice:()=>it,callListener:()=>Hl,createInstanceState:()=>KR,cycleMutationStatus:()=>JI,deepCopyEnabled:()=>XI,deleteNotice:()=>Vy,deleteNotices:()=>vi,disableNotifications:()=>JR,enableNotifications:()=>QI,getAuditAuthorityServer:()=>rm,getDevContext:()=>Ye,getMethods:()=>nm,getNotices:()=>Bl,getPayloads:()=>oF,getProvider:()=>By,getSaveDrawDeletions:()=>em,getSchemaWriteMode:()=>zI,getTopics:()=>nr,getTournamentId:()=>qi,getTournamentRecord:()=>ZI,getTournamentRecords:()=>Qn,globalLog:()=>eb,handleCaughtError:()=>im,hasTopic:()=>du,removeTournamentRecord:()=>tb,setAuditAuthorityServer:()=>XR,setDeepCopy:()=>Ep,setDevContext:()=>yp,setGlobalLog:()=>eF,setGlobalMethods:()=>rF,setGlobalSubscriptions:()=>Ej,setMethods:()=>nF,setSaveDrawDeletions:()=>QR,setSchemaWriteMode:()=>zR,setStateMethods:()=>rb,setStateProvider:()=>Tj,setSubscriptions:()=>Gy,setTournamentId:()=>om,setTournamentRecord:()=>ZR,setTournamentRecords:()=>Wl,timeKeeper:()=>yj,writeLegacyEnabled:()=>pu,writeNativeEnabled:()=>uu});var by={message:"Chronological error; time violation.",code:"ANACHRONISM"},Ll={message:"Duplicate entry",code:"DUPLICATE_ENTRY"},bU={message:"Cannot remove main structure",code:"ERR_CANNOT_REMOVE_MAIN_STRUCTURE"},Cy={message:"records must be an object with tournamentId keys",code:"ERR_INVALID_TOURNAMENTS"},kt={message:"Missing tournamentRecords",code:"ERR_MISSING_TOURNAMENTS"},j={message:"Missing tournamentRecord",code:"ERR_MISSING_TOURNAMENT"},Zc={message:"Invalid tournamentRecord",code:"ERR_INVALID_TOURNAMENT"},hc={message:"Missing tournamentId",code:"ERR_MISSING_TOURNAMENT_ID"},Ra={message:"Invalid drawDefinition",code:"ERR_INVALID_DRAWDEF"},K={message:"Missing drawDefinition",code:"ERR_MISSING_DRAWDEF"},CU={message:"Existing drawDefinition(s)",code:"ERR_EXISTING_DRAWDEFS"},Cr={message:"drawDefinition not found",code:"ERR_NOT_FOUND_DRAWDEF"},Yo={message:"Invalid structure",code:"ERR_INVALID_STRUCTURE"},yI={message:"Incomplete source structure",code:"ERR_INCOMPLETE_STRUCTURE"},EI={message:"Invalid drawPosition for seedAssignment",code:"ERR_INVALID_SEEDING_POSITION"},tu={message:"drawPosition already assigned",code:"ERR_EXISTING_POSITION_ASSIGNMENT"},MU={message:"Schedule not cleared",code:"ERR_UNCHANGED_SCHEDULE_NOT_CLEARED"},vU={message:"Schedule conflict: court slot already occupied",code:"ERR_SCHEDULE_CONFLICT_DOUBLE_BOOKING"},OU={message:"Schedule conflict: matchUps scheduled outside court availability",code:"ERR_SCHEDULE_CONFLICT_COURT_UNAVAILABLE"},_U={message:"drawPosition not cleared",code:"ERR_FAILURE_POSITION_NOT_CLEARED"},qY={message:"drawPosition not found",code:"ERR_NOT_FOUND_DRAW_POSITION"},lp={message:"Unrecognized drawType",code:"ERR_UNRECOGNIZED_DRAW_TYPE"},eu={message:"Missing drawPositions",code:"ERR_MISSING_DRAW_POSITIONS"},ru={message:"drawPosition is active",code:"ERR_ACTIVE_DRAW_POSITION"},WL={message:"drawPosition is occupied",code:"ERR_OCCUPIED_DRAW_POSITION"},Ts={message:"Invlid drawPosition",code:"ERR_INVALID_DRAW_POSITION"},ba={message:"Missing drawPosition",code:"ERR_MISSING_DRAW_POSITION"},Fl={message:"Invalid drawType",code:"ERR_INVALID_DRAW_TYPE"},$d={message:"Invalid drawSize",code:"ERR_INVALID_DRAW_SIZE"},$Y={message:"Cannot set drawSize to be less than existing entries",code:"ERR_INVALID_DRAW_SIZE_MISMATCH"},nu={message:"Missing drawSize",code:"ERR_MISSING_DRAW_SIZE"},Un={message:"Missing drawId",code:"ERR_MISSING_DRAW_ID"},xU={message:"drawId exists",code:"ERR_EXISTING_DRAW_ID"},wU={message:"participantId cannot be assigned to multiple seedNumbers",code:"INVALID_PARTICIPANT_SEEDING"},LU={message:"seedsCount greater than drawSize",code:"ERR_INVALID_SEED_COUNT"},FU={message:"Missing seedCountThresholds",code:"ERR_MISSING_SEED_COUNT_THRESHOLD"},kU={message:"Invalid action",code:"ERR_INVALID_ACTION"},My={message:"Invalid assignment",code:"ERR_INVALID_ASSIGNMENT"},GU={message:"Missing seedAssignments",code:"ERR_MISSING_SEED_ASSIGNMENTS"},VU={message:"Invalid seedNumber",code:"ERR_INVALID_SEED_NUMBER"},BU={message:"Invalid seedPosition",code:"ERR_INVALID_SEED_POSITION"},AI={message:"Missing targetLink",code:"ERR_MISSING_LINK_TARGET"},HU={message:"Existing round",code:"ERR_EXISTING_ROUND"},KY={message:"Missing roundNumber",code:"ERR_MISSING_ROUND_NUMBER"},mn={message:"Missing structureId",code:"ERR_MISSING_STRUCTURE_ID"},Pt={message:"structure not found",code:"ERR_NOT_FOUND_STRUCTURE"},PI={message:"Missing structures",code:"ERR_MISSING_STRUCTURES"},Wi={message:"Missing structure",code:"ERR_MISSING_STRUCTURE"},NI={message:"Missing MAIN structure",code:"ERR_MISSING_MAIN_STRUCTURE"},WU={message:"drawDefinition contains unlinked structures",code:"ERR_MISSING_STRUCTURE_LINKS"},so={message:"Invalid eventType",code:"ERR_INVALID_EVENT_TYPE"};var Se={message:"Missing event / eventId",code:"ERR_MISSING_EVENT_ID"},Br={message:"Event not found",code:"ERR_NOT_FOUND_EVENT"},YU={message:"Event exists",code:"ERR_EXISTING_EVENT"},jU={message:"Missing entries",code:"ERR_MISSING_ENTRIES"},qU={message:"Invalid entries",code:"ERR_INVALID_ENTRIES"},DI={message:"Missing assignments",code:"ERR_MISSING_ASSIGNMENTS"},UI={message:"Missing stage",code:"ERR_MISSING_STAGE"},Sc={message:"Invalid stage",code:"ERR_INVALID_STAGE"},$U={message:"stageSequence limit",code:"ERR_LIMIT_STAGE_SEQUENCE"},RI={message:"Missing positionAssignments",code:"ERR_MISSING_POSITION_ASSIGNMENTS"},KU={message:"Cannot Assign BYE status if no assignment: { bye: true }",code:"ERR_UNCHANGED_CANNOT_ASSIGN_BYE"},zU={message:"Lucky draw first round allows at most one BYE",code:"ERR_LUCKY_DRAW_BYE_LIMIT"},vy={message:"Unrecognized matchUpStatus",code:"ERR_UNRECOGNIZED_MATCHUP_STATUS"},ou={message:"Unrecognized matchUpFormat",code:"ERR_UNRECOGNIZED_MATCHUP_FORMAT"},bI={message:"Incompatible matchUpStatus",code:"ERR_INCOMPATIBLE_MATCHUP_STATUS"},YL={message:"Propagated exits downstream",code:"ERR_PROPAGATED_EXITS_DOWNSTREAM"},Tc={message:"Invalid matchUpStatus",code:"ERR_INVALID_MATCHUP_STATUS"},ci={message:"Invalid tieFormat",code:"ERR_INVALID_TIE_FORMAT"},QU={message:"Invalid matchUpFormat",code:"ERR_INVALID_MATCHUP_FORMAT"},XU={message:"Missing matchUpFormat",code:"ERR_MISSING_MATCHUP_FORMAT"},JU={message:"Missing collectionDefinition",code:"ERR_MISSING_COLLECTION_DEFINITION"},Ca={message:"Missing tieFormat",code:"ERR_MISSING_TIE_FORMAT"},cr={message:"Missing matchUpId",code:"ERR_MISSING_MATCHUP_ID"},Bs={message:"Missing matchUpIds",code:"ERR_MISSING_MATCHUP_IDS"},Ce={message:"matchUp not found",code:"ERR_NOT_FOUND_MATCHUP"},zn={message:"Missing matchUps",code:"ERR_MISSING_MATCHUPS"},or={message:"Missing matchUp",code:"ERR_MISSING_MATCHUP"},mr={message:"Invalid matchUp",code:"ERR_INVALID_MATCHUP"},Oy={message:"Missing policyType",code:"ERR_MISSING_POLICY_TYPE"},Ma={message:"Missing policyDefinitions",code:"ERR_MISSING_POLICY_DEFINITIONS"},zY={message:"Missing seeding policy",code:"ERR_MISSING_POLICY_SEEDING"},ZU={message:"Missing avoidance policy",code:"ERR_MISSING_POLICY_AVOIDANCE"},_y={message:"Missing policy attributes",code:"ERR_MISSING_POLICY_ATTRIBUTES"},tR={message:"Invalid policyDefinitions",code:"ERR_INVALID_POLICY_DEFINITIONS"},xy={message:"existing policyType",code:"ERR_EXISTING_POLICY_TYPE"},QY={message:"Policy not attached",code:"ERR_FAILURE_POLICY_NOT_ATTACHED"},fp={message:"Policy not found",code:"ERR_NOT_FOUND_POLICY"},XY={message:"Missing scoring policy / matchUpFormats",code:"ERR_MISSING_POLICY_SCORING_MATCHUP_FORMATS"},eR={message:"Invalid sideNumber",code:"ERR_INVALID_SIDE_NUMBER"},JY={message:"Invalid setNumber",code:"ERR_INVALID_SET_NUMBER"},CI={message:"Missing setObject",code:"ERR_MISSING_SET_ATTRIBUTE"},ZY={message:"Missing setNumber",code:"ERR_MISSING_SET_NUMBER"},tj={message:"Missing sideNumber",code:"ERR_MISSING_SIDE_NUMBER"},MI={message:"Missing courtId",code:"ERR_MISSING_COURT_ID"},nt={message:"Missing value",code:"ERR_MISSING_VALUE"},rR={message:"Missing birthdate",code:"ERR_MISSING_BIRTH_DATE"},nR={message:"Missing date",code:"ERR_MISSING_DATE"},vI={message:"No valid dates",code:"ERR_NO_VALID_DATES"},kl={message:"Invalid bookings",code:"ERR_INVALID_BOOKINGS"},OI={message:"Invalid dateAvailability",code:"ERR_INVALID_DATE_AVAILABILITY"},oR={message:"Missing dateAvailability",code:"ERR_MISSING_DATE_AVAILABILITY"},de={message:"Invalid Date",code:"ERR_INVALID_DATE"},Hs={message:"Invalid time",code:"ERR_INVALID_TIME"},iR={message:"Invalid tournament dates",code:"ERR_INVALID_DATES_TOURNAMENT"},jL={message:"Missing date range",info:"Event or tournament must have start and end dates",code:"ERR_MISSING_DATE_RANGE"},gp={message:"Invalid Time Zone",code:"ERR_INVALID_TIME_ZONE"},Ip={message:"Invalid embargo: must be an ISO 8601 datetime with timezone (Z or \xB1HH:MM offset)",code:"ERR_INVALID_EMBARGO"},wy={message:"Invalid game scores",code:"ERR_INVALID_SCORES_GAME"},sR={message:"Invalid score",code:"ERR_INVALID_SCORE"},Gl={message:"Invalid winningSide",code:"ERR_INVALID_WINNING_SIDE"};var qL={message:"No participants generated",code:"ERR_NO_PARTICIPANTS_GENERATED"},_I={message:"Cannot modify tieFormat",code:"ERR_UNCHANGED_CANNOT_MODIFY_TIEFORMAT"},aR={message:"Cannot modify participantType",code:"ERR_UNCHANGED_CANNOT_MODIFY_PARTICIPANT_TYPE"},Kd={message:"Cannot remove participants",code:"ERR_UNCHANGED_CANNOT_REMOVE_PARTICIPANTS"},cR={message:"Participant category mismatch",code:"ERR_CATEGORY_MISMATCH"},Vl={message:"Cannot change winningSide",code:"ERR_UNCHANGED_CANNOT_CHANGE_WINNING_SIDE"},Yi={message:"Invalid participant",code:"ERR_INVALID_PARTICIPANT"},Hr={message:"Invalid participantId",code:"ERR_INVALID_PARTICIPANT_ID"},vr={message:"Invalid participantIds",code:"ERR_INVALID_PARTICIPANT_IDS"},uR={message:"Invalid participantRole",code:"ERR_INVALID_PARTICIPANT_ROLE"},Rn={message:"Invalid participantType",code:"ERR_INVALID_PARTICIPANT_TYPE"},pR={message:"Missing participantRole",code:"ERR_MISSING_PARTICIPANT_ROLE"},va={message:"Missing participant",code:"ERR_MISSING_PARTICIPANT"},Oa={message:"Missing participants",code:"ERR_MISSING_PARTICIPANTS"},Ke={message:"Missing participantId",code:"ERR_MISSING_PARTICIPANT_ID"},dR={message:"Missing qualified participants",code:"ERR_MISSING_QUALIFIED_PARTICIPANTS"},Wt={message:"Participant Not Found",code:"ERR_NOT_FOUND_PARTICIPANT"},mR={message:"participantId exists",code:"ERR_EXISTING_PARTICIPANT_ID"},ej={message:"participant pair exists",code:"ERR_EXISTING_PARTICIPANT_PAIR"},lR={message:"No participant removed",code:"ERR_UNCHANGED_NO_PARTICIPANT_REMOVED"},jo={message:"Missing participantIds",code:"ERR_MISSING_PARTICIPANT_IDS"},fR={message:"Missing participantsCount",code:"ERR_MISSING_PARTICIPANT_COUNT"},gR={message:"Participant not checked in",code:"ERR_UNCHANGED_PARTICIPANT_NOT_CHECKED_IN"},IR={message:"Missing person details",code:"ERR_MISSING_PERSON_DETAILS"},_a={message:"Existing participant drawPosition assignment",code:"ERR_EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT"},zd={message:"Existing participant",code:"ERR_EXISTING_PARTICIPANT"},xI={message:"participantsCount exceeds drawSize",code:"ERR_INVALID_PARTICIPANT_COUNT"},wI={message:"Invalid entry status",code:"ERR_INVALID_ENTRY_STATUS"},Ly={message:"Participant Entry Not Found",code:"ERR_NOT_FOUND_PARTICIPANT_ENTRY"},$L={message:"Participant not entered in stage",code:"ERR_UNCHANGED_PARTICIPANT_NOT_ENTERED"},KL={message:"Participant not found in stageSequence",code:"ERR_NOT_FOUND_PARTICIPANT_IN_STAGE"},hR={message:"entryStatus not allowed in stage",code:"ERR_INVALID_ENTRY_STATUS_IN_STAGE"},SR={message:"entryStatus not allowed for event",code:"ERR_INVALID_ENTRY_STATUS_IN_EVENT"},LI={message:"No stage space available for entryStatus",code:"ERR_UNCHANGED_NO_AVAILABLE_STAGE_SPACE"},FI={message:"Insufficient drawPositions to accommodate qualifiers",code:"ERR_UNCHANGED_NO_DRAW_POSITIONS_FOR_QUALIFIERS"},kI={message:"Insufficient drawPositions to accommodate entries",code:"ERR_INSUFFICIENT_DRAW_POSITIONS"},TR={message:"Missing penaltyType",code:"ERR_MISSING_PENALTY_TYPE"},yR={message:"Missing penaltyId",code:"ERR_MISSING_PENALTY_ID"},hp={message:"Penalty not found",code:"ERR_NOT_FOUND_PENALTY"},ER={message:"Missing courtsCount/courtNames",code:"ERR_MISSING_COURTS_INFO"},So={message:"Court not found",code:"ERR_NOT_FOUND_COURT"},AR={message:"Court exists",code:"ERR_EXISTING_COURT"},Qd={message:"Booking not found",code:"ERR_NOT_FOUND_BOOKING"},PR={message:"An active draft already exists for this draw",code:"ERR_EXISTING_DRAFT"},NR={message:"Existing matchUps conflict with booking",code:"ERR_EXISTING_MATCHUPS"},DR={message:"Venue exists",code:"ERR_EXISTING_VENUE"},ji={message:"Venue not found",code:"ERR_NOT_FOUND_VENUE"},Ws={message:"Missing venueId",code:"ERR_MISSING_VENUE_ID"},UR={message:"Invalid endTime",code:"ERR_INVALID_END_TIME"},RR={message:"Existing endTime",code:"ERR_EXISTING_END_TIME"},bR={message:"Invalid stopTime",code:"ERR_INVALID_STOP_TIME"},CR={message:"Invalid startTime",code:"ERR_INVALID_START_TIME"},zL={message:"Invalid resumeTime",code:"ERR_INVALID_RESUME_TIME"},GI={message:"Invalid timeItem",code:"ERR_INVALID_TIME_ITEMS"},MR={message:"Missing async state provider",code:"ERR_MISSING_ASYNC_STATE_PROVIDER"},VI={message:"Missing timeItem",code:"ERR_MISSING_TIME_ITEM"},BI={message:"Missing timeItems",code:"ERR_MISSING_TIME_ITEMS"},Sp={message:"Missing context",code:"ERR_MISSING_CONTEXT"},vR={message:"Missing schedule",code:"ERR_MISSING_SCHEDULE"},iu={message:"Invalid scaleItem",code:"ERR_INVALID_SCALE_ITEM"},OR={message:"Modifications failed",code:"ERR_FAILURE_MODIFICATIONS"},xa={message:"No modifications applied",code:"ERR_UNCHANGED_NO_MODIFICATIONS_APPLIED"},_R={message:"Unable to assign court",code:"ERR_UNCHANGED_COURT_NOT_ASSIGNED"},Xd={message:"No Candidates",code:"ERR_UNCHANGED_NO_CANDIDATES"},ui={message:"Invalid configuration",code:"ERR_INVALID_CONFIG"},xR={message:"Invalid collectionDefinition",code:"ERR_INVALID_COLLECTION_DEFINITION"},vo={message:"Invalid object",code:"ERR_INVALID_OBJECT"},Jd={message:"Invalid gender",code:"ERR_INVALID_GENDER"},Tp={message:"Invalid category",code:"ERR_INVALID_CATEGORY"},v={message:"Invalid values",code:"ERR_INVALID_VALUES"},wR={message:"Duplicate value",code:"ERR_DUPLICATE_VALUE"},HI={message:"Team not found",code:"ERR_NOT_FOUND_TEAM"},LR={message:"No valid actions",code:"ERR_NO_VALID_ACTIONS"},su={message:"No valid attributes",code:"ERR_NO_VALID_ATTRIBUTES"},WI={message:"Value unchanged",code:"ABORT_UNCHANGED"},fe={message:"Not found",code:"ERR_NOT_FOUND"},YI={message:"Not implemented",code:"ERR_NOT_IMPLEMENTED"},FR={message:"Existing flight",code:"ERR_EXISTING_FLIGHT"},jI={message:"Existing flight profile",code:"ERR_EXISTING_FLIGHT_PROFILE"},kR={message:"Existing outcome",code:"ERR_EXISTING_OUTCOME"},GR={message:"Existing matchUpId",code:"ERR_EXISTING_MATCHUP_ID"},Fy={message:"Existing stage",code:"ERR_EXISTING_STAGE"},qI={message:"Existing structure",code:"ERR_EXISTING_STRUCTURE"},au={message:"Method not found",code:"ERR_NOT_FOUND_METHOD"},VR={message:"Mutation blocked by active lock",code:"ERR_MUTATION_LOCKED"},BR={message:"Active mutation lock already exists for scope",code:"ERR_EXISTING_MUTATION_LOCK"},HR={message:"Mutation lock not found",code:"ERR_NOT_FOUND_MUTATION_LOCK"},WR={message:"Lock token does not match",code:"ERR_UNAUTHORIZED_LOCK_OPERATION"},YR={message:"Scheduled matchUps",code:"ERR_SCHEDULED_MATCHUPS"},cu={message:"Scores present",code:"ERR_SCORES_PRESENT"},jR={message:"Tournament category is referenced by one or more events",code:"ERR_TOURNAMENT_CATEGORY_IN_USE"},$I={message:"Practice registration not found",code:"ERR_NOT_FOUND_REGISTRATION"},Zd={message:"Booking capacity exceeded",code:"ERR_CAPACITY_EXCEEDED"},QL={ANACHRONISM:by,BOOKING_NOT_FOUND:Qd,CANNOT_CHANGE_WINNING_SIDE:Vl,CAPACITY_EXCEEDED:Zd,REGISTRATION_NOT_FOUND:$I,CANNOT_MODIFY_TIEFORMAT:_I,TOURNAMENT_CATEGORY_IN_USE:jR,CANNOT_MODIFY_PARTICIPANT_TYPE:aR,CANNOT_REMOVE_MAIN_STRUCTURE:bU,CANNOT_REMOVE_PARTICIPANTS:Kd,CATEGORY_MISMATCH:cR,COURT_EXISTS:AR,COURT_NOT_FOUND:So,EXISTING_DRAFT:PR,EXISTING_MATCHUPS:NR,DRAW_DEFINITION_NOT_FOUND:Cr,DRAW_ID_EXISTS:xU,DRAW_POSITION_ACTIVE:ru,DRAW_POSITION_ASSIGNED:tu,DRAW_POSITION_NOT_CLEARED:_U,DRAW_POSITION_NOT_FOUND:qY,DRAW_SIZE_MISMATCH:$Y,DUPLICATE_ENTRY:Ll,DUPLICATE_VALUE:wR,ENTRY_STATUS_NOT_ALLOWED_FOR_EVENT:SR,ENTRY_STATUS_NOT_ALLOWED_IN_STAGE:hR,EVENT_EXISTS:YU,EVENT_NOT_FOUND:Br,EXISTING_DRAW_DEFINITIONS:CU,EXISTING_END_TIME:RR,EXISTING_FLIGHT:FR,EXISTING_MATCHUP_ID:GR,EXISTING_OUTCOME:kR,EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT:_a,EXISTING_PARTICIPANT:zd,EXISTING_POLICY_TYPE:xy,EXISTING_PROFILE:jI,EXISTING_ROUND:HU,EXISTING_STAGE:Fy,EXISTING_STRUCTURE:qI,INCOMPATIBLE_MATCHUP_STATUS:bI,INCOMPLETE_SOURCE_STRUCTURE:yI,INSUFFICIENT_DRAW_POSITIONS:kI,INVALID_ACTION:kU,INVALID_ASSIGNMENT:My,INVALID_BOOKINGS:kl,INVALID_CATEGORY:Tp,INVALID_COLLECTION_DEFINITION:xR,INVALID_CONFIGURATION:ui,INVALID_DATE_AVAILABILITY:OI,INVALID_DATE:de,INVALID_DRAW_DEFINITION:Ra,INVALID_DRAW_POSITION_FOR_SEEDING:EI,INVALID_DRAW_POSITION:Ts,INVALID_DRAW_SIZE:$d,INVALID_END_TIME:UR,INVALID_ENTRIES:qU,INVALID_EVENT_TYPE:so,INVALID_GAME_SCORES:wy,INVALID_GENDER:Jd,INVALID_MATCHUP_FORMAT:QU,INVALID_MATCHUP_STATUS:Tc,INVALID_MATCHUP_STATUS_BYE:KU,INVALID_MATCHUP:mr,INVALID_OBJECT:vo,INVALID_PARTICIPANT_ID:Hr,INVALID_PARTICIPANT_IDS:vr,INVALID_PARTICIPANT_ROLE:uR,INVALID_PARTICIPANT_SEEDING:wU,INVALID_PARTICIPANT_TYPE:Rn,INVALID_PARTICIPANT:Yi,INVALID_POLICY_DEFINITION:tR,INVALID_RECORDS:Cy,INVALID_SCALE_ITEM:iu,INVALID_SEED_NUMBER:VU,INVALID_SEED_POSITION:BU,INVALID_SET_NUMBER:JY,INVALID_SIDE_NUMBER:eR,INVALID_SCORE:sR,INVALID_STAGE:Sc,INVALID_START_TIME:CR,INVALID_STRUCTURE:Yo,INVALID_STOP_TIME:bR,INVALID_TIE_FORMAT:ci,INVALID_TIME:Hs,INVALID_TIME_ITEM:GI,INVALID_TOURNAMENT_DATES:iR,INVALID_TOURNAMENT_RECORD:Zc,INVALID_VALUES:v,INVALID_WINNING_SIDE:Gl,LUCKY_DRAW_BYE_LIMIT:zU,MATCHUP_NOT_FOUND:Ce,METHOD_NOT_FOUND:au,MUTATION_LOCKED:VR,MUTATION_LOCK_EXISTS:BR,MUTATION_LOCK_NOT_FOUND:HR,MISSING_ASSIGNMENTS:DI,MISSING_ASYNC_STATE_PROVIDER:MR,MISSING_AVOIDANCE_POLICY:ZU,MISSING_BIRTH_DATE:rR,MISSING_COLLECTION_DEFINITION:JU,MISSING_COURT_ID:MI,MISSING_COURTS_INFO:ER,MISSING_DATE_AVAILABILITY:oR,MISSING_DATE:nR,MISSING_DRAW_DEFINITION:K,MISSING_DRAW_ID:Un,MISSING_DRAW_POSITION:ba,MISSING_DRAW_POSITIONS:eu,MISSING_DRAW_SIZE:nu,MISSING_ENTRIES:jU,MISSING_EVENT:Se,MISSING_QUALIFIED_PARTICIPANTS:dR,MISSING_MATCHUP_FORMAT:XU,MISSING_MATCHUP_ID:cr,MISSING_MATCHUP_IDS:Bs,MISSING_MATCHUP:or,MISSING_MATCHUPS:zn,MISSING_PARTICIPANT_COUNT:fR,MISSING_PARTICIPANT_ID:Ke,MISSING_PARTICIPANT_IDS:jo,MISSING_PARTICIPANT_ROLE:pR,MISSING_PARTICIPANT:va,MISSING_PARTICIPANTS:Oa,MISSING_PENALTY_ID:yR,MISSING_PENALTY_TYPE:TR,MISSING_PERSON_DETAILS:IR,MISSING_POLICY_ATTRIBUTES:_y,MISSING_POLICY_DEFINITION:Ma,MISSING_POLICY_TYPE:Oy,MISSING_POSITION_ASSIGNMENTS:RI,MISSING_ROUND_NUMBER:KY,MISSING_SCHEDULE:vR,MISSING_SCORING_POLICY:XY,MISSING_SEED_ASSIGNMENTS:GU,MISSING_SEEDCOUNT_THRESHOLDS:FU,MISSING_SEEDING_POLICY:zY,MISSING_SET_NUMBER:ZY,MISSING_SET_OBJECT:CI,MISSING_SIDE_NUMBER:tj,MISSING_STAGE:UI,MISSING_STRUCTURE_ID:mn,MISSING_STRUCTURE:Wi,MISSING_MAIN_STRUCTURE:NI,MISSING_STRUCTURES:PI,MISSING_TARGET_LINK:AI,MISSING_TIE_FORMAT:Ca,MISSING_TIME_ITEM:VI,MISSING_TIME_ITEMS:BI,MISSING_TOURNAMENT_ID:hc,MISSING_TOURNAMENT_RECORD:j,MISSING_TOURNAMENT_RECORDS:kt,MISSING_VALUE:nt,MISSING_VENUE_ID:Ws,MODIFICATIONS_FAILED:OR,NO_CANDIDATES:Xd,NO_DRAW_POSITIONS_AVAILABLE_FOR_QUALIFIERS:FI,NO_MODIFICATIONS_APPLIED:xa,NO_STAGE_SPACE_AVAILABLE_FOR_ENTRY_STATUS:LI,NO_PARTICIPANT_REMOVED:lR,NO_VALID_ACTIONS:LR,NO_VALID_ATTRIBUTES:su,NO_VALID_DATES:vI,NOT_FOUND:fe,NOT_IMPLEMENTED:YI,PARTICIPANT_COUNT_EXCEEDS_DRAW_SIZE:xI,PARTICIPANT_ID_EXISTS:mR,PARTICIPANT_NOT_CHECKED_IN:gR,PARTICIPANT_NOT_FOUND:Wt,PARTICIPANT_PAIR_EXISTS:ej,PENALTY_NOT_FOUND:hp,POLICY_NOT_ATTACHED:QY,POLICY_NOT_FOUND:fp,SCHEDULE_NOT_CLEARED:MU,SCHEDULE_CONFLICT_DOUBLE_BOOKING:vU,SCHEDULE_CONFLICT_COURT_UNAVAILABLE:OU,SCHEDULED_MATCHUPS:YR,SCORES_PRESENT:cu,SEEDSCOUNT_GREATER_THAN_DRAW_SIZE:LU,STAGE_SEQUENCE_LIMIT:$U,STRUCTURE_NOT_FOUND:Pt,TEAM_NOT_FOUND:HI,UNABLE_TO_ASSIGN_COURT:_R,UNAUTHORIZED_LOCK_OPERATION:WR,UNLINKED_STRUCTURES:WU,UNRECOGNIZED_DRAW_TYPE:lp,UNRECOGNIZED_MATCHUP_FORMAT:ou,UNRECOGNIZED_MATCHUP_STATUS:vy,VALUE_UNCHANGED:WI,VENUE_EXISTS:DR};var rr={disableNotifications:!1,tournamentId:void 0,tournamentRecords:{},subscriptions:{},modified:!1,methods:{},notices:[]},qR={addNotice:lj,callListener:hj,cycleMutationStatus:mj,deleteNotice:gj,deleteNotices:fj,disableNotifications:rj,enableNotifications:nj,getMethods:tm,getNotices:XL,getPayloads:XL,getTopics:Ij,getTournamentId:JL,getTournamentRecord:oj,getTournamentRecords:ij,removeTournamentRecord:uj,setMethods:dj,setSubscriptions:pj,setTournamentId:aj,setTournamentRecord:sj,setTournamentRecords:cj,handleCaughtError:Sj};function rj(){rr.disableNotifications=!0}function nj(){rr.disableNotifications=!1}function JL(){return rr.tournamentId}function oj(t){return rr.tournamentRecords[t]}function ij(){return rr.tournamentRecords}function sj(t){let e=t?.tournamentId;return e?(rr.tournamentRecords[e]=t,{success:!0}):{error:Zc}}function aj(t){return t?rr.tournamentRecords[t]?(rr.tournamentId=t,{success:!0}):{error:j}:(rr.tournamentId=void 0,{success:!0})}function cj(t){rr.tournamentRecords=t;let e=Object.keys(t);e.length===1?rr.tournamentId=e[0]:e.length||(rr.tournamentId=void 0)}function uj(t){if(typeof t!="string")return{error:v};if(!rr.tournamentRecords[t])return{error:fe};delete rr.tournamentRecords[t];let e=Object.keys(rr.tournamentRecords);return e.length===1?rr.tournamentId=e[0]:e.length||(rr.tournamentId=void 0),{success:!0}}function pj(t){return t.subscriptions===null||Object.keys(t.subscriptions).length===0?(rr.subscriptions={},{...P}):typeof t.subscriptions!="object"?{error:v}:(Object.keys(t.subscriptions).forEach(e=>{typeof t.subscriptions[e]=="function"?rr.subscriptions[e]=t.subscriptions[e]:delete rr.subscriptions[e]}),{...P})}function dj(t){return typeof t!="object"?{error:v}:(Object.keys(t).forEach(e=>{typeof t[e]=="function"&&(rr.methods[e]=t[e])}),{...P})}function mj(){let t=rr.modified;return rr.modified=!1,t}function lj({topic:t,payload:e,key:r},n){if(!(typeof t!="string"||typeof e!="object")&&(rr.disableNotifications||(rr.modified=!0),!(rr.disableNotifications||!rr.subscriptions[t]&&!n)))return r&&(rr.notices=rr.notices.filter(o=>!(o.topic===t&&o.key===r))),rr.notices.push({topic:t,payload:e,key:r}),{...P}}function tm(){return rr.methods??{}}function XL({topic:t}){return rr.notices.filter(e=>e.topic===t).map(e=>e.payload)}function fj(){rr.notices=[]}function gj({topic:t,key:e}){rr.notices=rr.notices.filter(r=>(!t||r.topic===t)&&r.key!==e)}function Ij(){return{topics:Object.keys(rr.subscriptions)}}function hj({topic:t,payloads:e,notices:r},n){let o=e??r??[],i=rr.subscriptions[t];i&&typeof i=="function"&&i(o);let s=n?.[t];s&&typeof s=="function"&&s(o)}function Sj({engineName:t,methodName:e,params:r,err:n}){let o;return typeof n=="string"?o=n.toUpperCase():n instanceof Error&&(o=n.message),console.log("ERROR",{tournamentId:JL(),params:JSON.stringify(r),engine:t,methodName:e,error:o}),{error:o}}var KI="native",$R="legacy",ky="dual",ZL=[KI,ky,$R];var se={timers:{default:{elapsedTime:0}},globalSubscriptions:{},deepCopyAttributes:{stringify:[],ignore:[],toJSON:[]},globalMethods:[],schemaWriteMode:KI,saveDrawDeletions:!1,auditAuthorityServer:!1,deepCopy:!0},Wr=qR,tF=["addNotice","callListener","cycleMutationStatus","deleteNotice","deleteNotices","disableNotifications","enableNotifications","getMethods","getNotices","getTopics","getTournamentId","getTournamentRecord","getTournamentRecords","removeTournamentRecord","setSubscriptions","setTournamentId","setTournamentRecord","setTournamentRecords"];function Tj(t){if(typeof t!="object")throw new Error("Global state provider can not be undefined or null");if(Ht(Object.keys(t),tF).length!==tF.length)throw new Error("Global state provider is missing required methods");return Wr=t,{success:!0}}function KR(){if(Wr.createInstanceState){try{Wr.createInstanceState()}catch(t){return{error:t}}return{success:!0}}else return{error:MR}}function Ye(t){return!t||typeof t!="object"?se.devContext??!1:typeof se.devContext!="object"?!1:Object.keys(t).every(e=>se.devContext?.[e]===t[e])&&se.devContext}function yj(t="reset",e="default"){let r=Date.now();if(t==="report"){if(e==="allTimers")return Object.keys(se.timers).filter(o=>o!=="default"||se.timers[o].startTime).map(o=>{let i=se.timers[o],s=i.state==="stopped"?0:(r-(i?.startTime??0))/1e3,a=i.elapsedTime+s;return{state:se.timers[o].state,elapsedTime:a.toFixed(2),timer:o}});{let n=se.timers[e].state==="stopped"?0:(r-(se.timers[e]?.startTime??0))/1e3,o=se.timers[e].elapsedTime+n;return{state:se.timers[e].state,elapsedTime:o.toFixed(2),timer:e}}}if(!se.timers[e]||t==="reset"){if(e==="allTimers")return se.timers={default:{elapsedTime:0}},!0;se.timers[e]={startTime:r,state:"active",elapsedTime:0}}return se.timers[e].elapsedTime||(se.timers[e].elapsedTime=0),t==="stop"&&se.timers[e].state!=="stopped"&&(se.timers[e].state="stopped")&&(se.timers[e].elapsedTime+=(r-(se.timers[e]?.startTime??0))/1e3),t==="start"&&(se.timers[e].startTime=r)&&(se.timers[e].state="active"),se.timers[e]}function eF(t){Vr(t)?se.globalLog=t:delete se.globalLog}function yp(t){se.devContext=t}function zR(t){return t===void 0?(se.schemaWriteMode=KI,{...P}):ZL.includes(t)?(se.schemaWriteMode=t,{...P}):{error:v}}function zI(){return se.schemaWriteMode}function uu(){return se.schemaWriteMode===KI||se.schemaWriteMode===ky}function pu(){return se.schemaWriteMode===$R||se.schemaWriteMode===ky}function QR(t){return t===void 0?(se.saveDrawDeletions=!1,{...P}):typeof t!="boolean"?{error:v}:(se.saveDrawDeletions=t,{...P})}function em(){return se.saveDrawDeletions}function XR(t){return t===void 0?(se.auditAuthorityServer=!1,{...P}):typeof t!="boolean"?{error:v}:(se.auditAuthorityServer=t,{...P})}function rm(){return se.auditAuthorityServer}function JR(){Wr.disableNotifications()}function QI(){Wr.enableNotifications()}function Ep(t,e){typeof t=="boolean"&&(se.deepCopy=t),typeof e=="object"&&(Array.isArray(e.ignore)&&(se.deepCopyAttributes.ignore=e.ignore),Array.isArray(e.toJSON)&&(se.deepCopyAttributes.toJSON=e.toJSON),Array.isArray(e.stringify)&&(se.deepCopyAttributes.stringify=e.stringify),e.threshold&&(se.deepCopyAttributes.threshold=e.threshold))}function XI(){return{enabled:se.deepCopy,...se.deepCopyAttributes}}function Ej(t){return t?.subscriptions?(Object.keys(t.subscriptions).forEach(e=>{se.globalSubscriptions[e]=t.subscriptions[e]}),{...P}):{error:nt,info:"missing subscriptions"}}function Gy(t){return t?.subscriptions?Wr.setSubscriptions({subscriptions:t.subscriptions}):{error:nt,info:"missing subscriptions"}}function rF(t){return t?typeof t!="object"?{error:v}:(Object.keys(t).forEach(e=>{Vr(t[e])&&(se.globalMethods[e]=t[e])}),{...P}):{error:nt,info:"missing method declarations"}}function nF(t){return t?typeof t!="object"?{error:v}:Wr.setMethods(t):{error:nt,info:"missing method declarations"}}function JI(){return Wr.cycleMutationStatus()}function it(t){if(typeof t?.topic!="string")return;let e=se.globalSubscriptions[t.topic];return Wr.addNotice(t,e)}function nm(){return{...se.globalMethods,...Wr.getMethods()}}function Bl(t){return oF(t)}function oF(t){return typeof Wr.getPayloads=="function"?Wr.getPayloads(t):Wr.getNotices(t)}function Vy({key:t,topic:e}){return Wr.deleteNotice({key:t,topic:e})}function vi(){return Wr.deleteNotices()}function nr(){return Wr.getTopics()}function du(t){return nr()?.topics?.includes(t)}async function Hl(t){return Wr.callListener(t,se.globalSubscriptions)}function qi(){return Wr.getTournamentId()}function ZI(t){return Wr.getTournamentRecord(t)}function Qn(){return Wr.getTournamentRecords()}function ZR(t){return Wr.setTournamentRecord(t)}function Wl(t){return Wr.setTournamentRecords(t)}function om(t){return Wr.setTournamentId(t)}function tb(t){return Wr.removeTournamentRecord(t)}function By(){return Wr}function im({engineName:t,methodName:e,params:r,err:n}){let o=Vr(Wr.handleCaughtError)&&Wr.handleCaughtError||qR.handleCaughtError,{tournamentRecord:i,...s}=r;return o({params:s,engineName:t,methodName:e,err:n})}function eb(t,e){if(se.globalLog)try{se.globalLog({log:t,engine:e})}catch(r){console.log("globalLog error",r),console.log(e,t),eF()}else console.log(e,t)}function rb(t,e,r,n){if(!St(t))return{error:v};We||(r=1);let o=Array.isArray(e)?e:[],i={},s=(a,c=0)=>{Object.keys(a).forEach(u=>{Vr(a[u])?i[u]=a[u]:St(a[u])&&(e===!0||o?.includes(u))&&(r===void 0||c<r)&&s(a[u],c+1)})};return s(t),n?rF(i):nF(i),{methods:i}}function Aj(t,e,r){return Object.keys(t).filter(n=>!e.includes(t[n])&&(!r||(Array.isArray(t[n])?t[n].length:!0)))}function et(t,e,r,n){if(typeof t!="object"||t===null)return t;XI()?.enabled||(n=!0);let i=["",void 0,null];e&&i.push(!1);let s=Aj(t,i,r);return Object.assign({},...s.map(a=>Array.isArray(t[a])?{[a]:n?t[a]:t[a].map(c=>et(c))}:{[a]:n?t[a]:et(t[a])}))}function M({context:t,result:e,stack:r,info:n}){return e&&!Array.isArray(e?.stack)&&(e.stack=[]),e&&Array.isArray(e?.stack)&&typeof r=="string"&&e.stack.push(r),e&&n&&(e.info=n),e&&typeof t=="object"&&Object.keys(t).length&&(e.context??={},Object.assign(e.context,et(t))),e&&!e?.error&&!e?.success&&Object.assign(e,{...P}),e??{success:!0}}var Fe="FEMALE",pi="OTHER",Oo="MIXED",Ee="MALE";var Yl={FEMALE_ABBR:"F",OTHER_ABBR:"O",MIXED_ABBR:"X",MALE_ABBR:"M",ANY_ABBR:"A",FEMALE:Fe,MIXED:Oo,OTHER:pi,MALE:Ee,ANY:"ANY"};function ys(t){return[Fe,"F"].includes(t)}function wa(t){return[Ee,"M"].includes(t)}function Yr(t){return[Oo,"X"].includes(t)}function To(t){return["ANY","A"].includes(t)}function lr(t){if(t){if(ys(t))return Fe;if(Yr(t))return Oo;if(wa(t))return Ee;if(To(t))return"ANY"}return pi}function bn(t){return ys(t)||wa(t)}var Uj="MIXED events can not contain mixed singles or { gender: ANY } collections",Rj="events with { gender: ANY } can not contain MIXED singles collections";function jl(t){let e="tieFormatGenderValidityCheck",{referenceGender:r,matchUpType:n,gender:o}=t;return r&&o&&bn(r)&&lr(r)!==lr(o)?M({result:{valid:!1,error:Jd},context:{gender:o},stack:e}):Yr(r)&&(To(o)||Yr(o)&&n!==Ut)?M({result:{error:Jd,valid:!1},info:Uj,stack:e}):To(r)&&Yr(o)&&n!==Ut?M({result:{error:Jd,valid:!1},info:Rj,stack:e}):{valid:!0}}var bj="normal",nb="timed",Cj="final",th="NOAD";var ob=["SET","HAL","QTR","PER","INN","RND","FRM","MAP","MAT"],Hy="CONSECUTIVE",Wy="TRADITIONAL",Mj="game",vj="matchUp",sF={S:bj,F:Cj,G:Mj,M:vj};function sm(t,e){if(St(t)&&(t?.bestOf||t?.exactly)&&t?.setFormat)return _j(t,e)}function ql(t){return!Number.isNaN(Number(t))&&Number(t)}function uF(t){let e=`T${t.minutes}`;return t.based==="P"&&(e+="P"),t.tiebreakFormat?.tiebreakTo&&(e+=`/TB${t.tiebreakFormat.tiebreakTo}`),t.modifier&&(e+=`@${t.modifier}`),e}function Oj(t){let e=t?.deuceAfter?`${t.deuceAfter}D`:"";if(t?.type===Wy)return`TN${e}`;if(t?.type===Hy&&Number.isInteger(t.count))return`${t.count}C${e}`}function _j(t,e){let r=ql(t.bestOf)||void 0,n=ql(t.exactly)||void 0,o=r||n;if(t.setFormat?.timed&&t.simplified&&o===1)return uF(t.setFormat);let i=t.matchRoot||"SET",s=n&&n!==1?"X":"",a=t.aggregate?"A":"",c=o&&`${i}${o}${s}${a}`||"",u=aF(t.setFormat,e),p=u&&`S:${u}`||"",d=aF(t.finalSetFormat,e),m=o&&o>1&&d&&u!==d&&`F:${d}`||"",l=t.gameFormat?`G:${Oj(t.gameFormat)}`:"",f=t.matchUpConstraint?.timed?`M:T${t.matchUpConstraint.minutes}`:"";if(c&&u)return[c,p,l,m,f].filter(Boolean).join("-")}function aF(t,e){if(typeof t=="object"&&Object.keys(t).length){if(t.timed)return uF(t);if(t.outs)return`O${t.outs}`;if(t.tiebreakSet)return cF(t.tiebreakSet);let r=ql(t.setTo);if(r){let n=t.NoAD&&th||"",o=ql(t.winBy),i=cF(t.tiebreakFormat),s=i&&`/${i}`||"",a=o&&o!==2&&!i?`WB${o}`:"",c=ql(t.tiebreakAt),u=c&&(c!==r||e)&&`@${c}`||"";if(i!==!1)return`${r}${n}${a}${s}${u}`}}}function cF(t){if(t){if(typeof t=="object"&&!t.tiebreakTo)return"";if(typeof t=="object"&&ql(t.tiebreakTo)){let e=`TB${t.tiebreakTo}${t.NoAD?th:""}`;return t.modifier&&(e+=`@${t.modifier}`),e}else return!1}}function ne(t){if(wt(t)){let e=t.startsWith("T")&&nb||ob.some(r=>t.startsWith(r))&&"SET"||"";if(e===nb){let r=lF(t),n={simplified:!0,setFormat:r,bestOf:1};if(r)return n}if(e==="SET")return Lj(t)}}function xj(t){let e=ob.find(u=>t.startsWith(u));if(!e)return;let r=t.slice(e.length),n=/^(\d+)([A-Z]*)$/.exec(r);if(!n)return;let o=Ap(n[1]);if(!o)return;let i=n[2],s=!1,a=!1,c=[];for(let u of i)u==="X"?s=!0:u==="A"?a=!0:c.push(u);return{matchRoot:e,count:o,exactly:s,aggregate:a,matchMods:c}}function wj(t){let e=/^(.+?)(\d+D)$/.exec(t),r=e?e[1]:t,n=e?Number(e[2].slice(0,-1)):void 0;if(n!==void 0&&(n<1||!Number.isInteger(n)))return;if(r==="TN"){let i={type:Wy};return n&&(i.deuceAfter=n),i}let o=/^([1-9]\d*)C$/.exec(r);if(o){let i={type:Hy,count:Number(o[1])};return n&&(i.deuceAfter=n),i}}function Lj(t){let e=t.split("-"),r=xj(e[0]);if(!r)return;let{matchRoot:n,count:o,exactly:i,aggregate:s,matchMods:a}=r,c=i&&o!==1?void 0:o,u=i&&o!==1?o:void 0,p,d,m,l,S={setFormat:p,finalSetFormat:d,gameFormat:m,matchUpConstraint:l,sCount:0,fCount:0,gCount:0,mCount:0};for(let T=1;T<e.length;T++)if(!Fj(e[T],S))return;return{setFormat:p,finalSetFormat:d,gameFormat:m,matchUpConstraint:l}=S,kj({setFormat:p,finalSetFormat:d,gameFormat:m,matchUpConstraint:l,matchRoot:n,aggregate:s,matchMods:a,bestOf:c,exactly:u})}function Fj(t,e){let r=t.indexOf(":");if(r<0)return!1;let n=t.slice(0,r),o=t.slice(r+1);if(!(n in sF))return!1;if(n==="S"){if(e.sCount++,e.sCount>1)return!1;e.setFormat=pF(t,o)}else if(n==="F"){if(e.fCount++,e.fCount>1)return!1;e.finalSetFormat=pF(t,o)}else if(n==="G"){if(e.gCount++,e.gCount>1||(e.gameFormat=wj(o),!e.gameFormat))return!1}else if(n==="M"&&(e.mCount++,e.mCount>1||(e.matchUpConstraint=Yj(o),!e.matchUpConstraint)))return!1;return!0}function kj({setFormat:t,finalSetFormat:e,gameFormat:r,matchUpConstraint:n,matchRoot:o,aggregate:i,matchMods:s,bestOf:a,exactly:c}){let u=t&&t.timed||e&&e.timed;if(o==="SET"&&!(a&&a<6||u&&c)||!t||!(!e||e))return;let m=et({setFormat:t,exactly:c,bestOf:a});return o!=="SET"&&(m.matchRoot=o),i&&(m.aggregate=!0),s.length>0&&(m.matchMods=s),e&&(m.finalSetFormat=e),r&&(m.gameFormat=r),n&&(m.matchUpConstraint=n),m}function pF(t,e){return e.startsWith("TB")?Gj(e):e.startsWith("O")?Vj(e):e.startsWith("T")?lF(e):Bj(t,e)}function Gj(t){let e=mF(t);return e===!1?!1:typeof e=="object"?{tiebreakSet:e}:void 0}function Vj(t){let e=/^O([1-9]\d*)$/.exec(t);if(e)return{outs:Number(e[1])}}function Bj(t,e){let r=/^[FS]:(\d+)([A-Za-z]*?)(WB(\d+))?(?=[/@]|$)/.exec(t),n=r&&fF(r[2])||!1,o=!r?.[2]||n,i=r?Ap(r[1]):void 0,s=r?.[4],a=s?Ap(s):void 0,c=a===void 0||a>=1,u=dF(e),p=u!==!1,d=p&&u||i,m=mF(e.split("/")[1]);return!i||!o||!(m!==!1)||!p||!c||a!==void 0&&m?!1:Hj(i,n,m,d,a)}function Hj(t,e,r,n,o){let i={setTo:t};return e&&(i.NoAD=!0),r?(i.tiebreakFormat=r,i.tiebreakAt=n):(i.noTiebreak=!0,o!==void 0&&o!==2&&(i.winBy=o)),i}function dF(t,e=!0){let r=t?.indexOf("@")>0&&t.split("@");if(r)return(e?Ap(r[1]):r[1])||!1}function mF(t){if(t)return t.startsWith("TB")?Wj(t):!1}function Wj(t){let e=dF(t,!1),r=/^TB(\d+)([A-Za-z]*)/.exec(t),n=r?.[1],o=r&&fF(r[2]),i=!r?.[2]||o,s=Ap(n);if(!s||!i)return!1;let a={tiebreakTo:s};return e&&typeof e=="string"&&!It(e)&&(a.modifier=e),o&&(a.NoAD=!0),a}function lF(t){let e=t.slice(1),r=/^(\d+)([PG])?(?:\/TB(\d+))?(@[A-Za-z]+)?$/.exec(e),n=Ap(r?.[1]);if(!n)return;let o={timed:!0,minutes:n},i=r?.[2];i==="P"?o.based="P":i==="G"&&(o.based="G");let s=r?.[3];if(s){let u=Ap(s);u&&(o.tiebreakFormat={tiebreakTo:u})}let a=r?.[4],c=[void 0,"P","G",""].includes(a);if(a&&!c){let u=/^(\d+)([PGA])?(?:\/TB\d+)?(@)([A-Za-z]+)$/.exec(e)?.[4];return u?(o.modifier=u,o):void 0}return a&&(o.based=a),o}function Yj(t){let e=/^T(\d+)$/.exec(t);if(!e)return;let r=Ap(e[1]);if(r)return{timed:!0,minutes:r}}function fF(t){return t?.includes(th)}function Ap(t){let e=Number(t);return Number.isNaN(e)?0:e}function jj(t){return t.replaceAll(/T(\d+)G(?=\/TB|@|-|$)/g,"T$1")}function Or({matchUpFormat:t}){if(!wt(t)||t==="")return!1;let e=ne(t),r=/-S:(\d+)\/TB(\d{1,2})@?(\d?)/.exec(t),n=r?.[1],o=r?.[2],i=r?.[3],s=/-F:(\d+)\/TB(\d{1,2})@?(\d?)/.exec(t),a=s?.[1],c=s?.[2],u=s?.[3];return sm(e,!!(r&&o&&n===i||s&&c&&a===u))===jj(t)}var am=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])$/,Yy=/^((0\d|1\d|2[0-3]):[0-5]\d(:[0-5]\d)?)([.,]\d{3})?$/,qo=/^(\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?$/,mu=/^(\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 Kl(t){let{scheduledDate:e}=t;if(!e&&t.scheduledTime&&(e=ut(t.scheduledTime)),!e)return;let r=zt(t.scheduledTime),n=ut(e);return n&&r&&(n+=`T${r}`),n}function gF(t){return typeof t!="object"||Array.isArray(t)?!1:Object.prototype.toString.call(t)==="[object Date]"}function cm(t){let e=typeof t=="string"?t?.split(" "):[];if(t&&e?.length>1&&!["AM","PM"].includes(e[1].toUpperCase()))return!1;let r=Pp(t,!0,!0);return!!(!t||r&&mu.test(r))}function ke(t){return Es(t)||am.test(t)}function qj(t){let e=new Date(t),r=e.getSeconds()+60*e.getMinutes()+3600*e.getHours();return $j(r,{displaySeconds:!1})}function $j(t,e){let r=Number.parseInt(t,10),n=Math.floor(r/3600),o=Math.floor((r-n*3600)/60),i=r-n*3600-o*60;return(!e||e?.displaySeconds?n+":"+o+":"+i:n+":"+o).split(":").map(yo).join(":")}var nh=t=>{let e=eh(t)||Es(t)?new Date(t):new Date,r=e.getUTCMonth()+1,n=r<10?`0${r}`:`${r}`;return`${e.getUTCFullYear()}-${yo(n)}-${yo(e.getUTCDate())}`};function Kj(t){let e=eh(t)||Es(t)?new Date(t):new Date;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function ao(t,e="-",r="YMD"){if(!t)return"";typeof t=="string"&&!t.includes("T")&&(t=t+"T00:00");let n=new Date(t),o=""+(n.getMonth()+1),i=""+n.getDate(),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 jy(t){let e=t?new Date(t):new Date,r=e.getTimezoneOffset();return new Date(e.getTime()-r*60*1e3)}function zj(t){return jy(t).getTime()}function eh(t){if(typeof t=="boolean")return!1;let e=t instanceof Date&&t||!Number.isNaN(Number(t))&&new Date(t)||!1;return e&&!Number.isNaN(Number(e.valueOf()))}function Qj(t,e){return t<=e}function La(t,e){if(!ke(t)||!ke(e))return[];let r=ut(t)+"T00:00",n=ut(e)+"T00:00",o=new Date(r),i=new Date(n),s=eh(i)&&eh(o)&&Qj(o,i),a=[],c=0;if(s){let u=o,p=u.getTime();for(;p<=i.getTime()&&c<300;)c+=1,a.push(new Date(u)),p=u.setDate(u.getDate()+1)}return a.map(u=>ao(u))}var Xj=/^([+-]?\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 Es(t){return typeof t!="string"?!1:Xj.test(t)}function Fa(t){return typeof t!="string"||!Es(t)?!1:/([zZ]|[+-]\d{2}:?\d{2})$/.test(t)}function $y(t){if(typeof t!="string")return!1;let r=t.split("Z")[0].split(":"),n=r.every(i=>!Number.isNaN(Number.parseInt(i)));return!(r.length<2||!n||Number.parseInt(r[0])>23||Number.parseInt(r[1])>60)}function jt(t){let e=zt(t);if(!e)return 0;let[r,n]=e.split(":").map(o=>Number.parseInt(o));return r*60+n}function IF(t){let e=Math.floor(t/60),r=t-e*60;return e>23&&(e=e%24),[yo(e),yo(r)].join(":")}function rh(t){return $y(t)?t.split(":").slice(0,2).map(yo).join(":"):void 0}function zt(t){return Es(t)&&t.indexOf("T")>0?rh(t.split("T").reverse()[0]):rh(t)}function ut(t){return Es(t)||qo.test(t)?t.split("T")[0]:""}function um(t,e){let r=new Date(t);return r.setUTCDate(r.getUTCDate()+e),ut(r.toISOString())}function qy(t){t=typeof t=="string"?t:"00:00";let e={},r={};return{0:e.time,1:e.ampm}=t.split(" ")??[],{0:r.hours,1:r.minutes}=e.time.split(":")??[],r.ampm=e.ampm,Number.isNaN(Number.parseInt(r.hours))||Number.isNaN(Number.parseInt(r.minutes))||r.ampm&&!["AM","PM"].includes(r.ampm.toUpperCase())?{}:r}function Jj(t){let e=qy(t);return e.ampm&&e.hours&&(e.ampm.toLowerCase()==="pm"&&Number.parseInt(e.hours)<12&&(e.hours=(e.hours&&Number.parseInt(e.hours)||0)+12),e.ampm.toLowerCase()==="am"&&e.hours==="12"&&(e.hours="00")),`${e.hours||"12"}:${e.minutes||"00"}`.split(":").map(yo).join(":")}function Zj(t){let e=qy(t);if(!(typeof e=="object"&&!Object.keys(e).length))return e.ampm?t:(e.hours>12?(e.hours-=12,e.ampm="PM"):e.hours==="12"?e.ampm="PM":(e.hours==="00"&&(e.hours="12"),e.ampm="AM"),e.hours?.[0]==="0"&&(e.hours=e.hours.slice(1)),`${e.hours||"12"}:${e.minutes||"00"} ${e.ampm}`)}function Pp(t,e,r){let n=ut(t),o=zt(t),i=n?o:t;return t?e&&(n&&r&&t||Jj(i))||Zj(i):void 0}function Ky(t,e){let r=qy(t),n=qy(e);if(Number.parseInt(r.hours)<Number.parseInt(n.hours))return-1;if(Number.parseInt(r.hours)>Number.parseInt(n.hours))return 1;if(r.hours===n.hours){if(Number.parseInt(r.minutes)<Number.parseInt(n.minutes))return-1;if(Number.parseInt(r.minutes)>Number.parseInt(n.minutes))return 1}return 0}function zy(t,e=7){let r=ut(t)+"T00:00",n=new Date(r),o=new Date(n.setDate(n.getDate()+e));return ao(o)}function tq(t){return zy(t)}function eq(t,e,r,n=!1){let o=new Date(e,0,1+(t-1)*7),i=n?0:1;return o.setDate(o.getDate()+(i-o.getDay())),ao(o,r)}function hF(t,e,r){let n=new Date(t,0);return ao(new Date(n.setDate(e)),r)}function Ge(t,e=void 0){let[r,n]=(t||"00:00").split(":").map(yo),o=jy(e).setHours(r,n,0,0);return jy(o)}function Ys(t,e,r=!0){let n=new Date(t),i=(new Date(e).getTime()-n.getTime())/1e3/60;return r?Math.abs(Math.round(i)):Math.round(i)}function jr(t,e){let r=zt(t);if(!r)return"00:00";let n=Number.isNaN(e)?0:e;return zt(oh(Ge(r),n).toISOString())||"00:00"}function oh(t,e){let r=new Date(t);return new Date(r.getTime()+e*6e4)}function yo(t){return t.toString()[1]?t:"0"+t}function nn(t,e){let r=new Date(t),n=new Date(e);return r.getFullYear()===n.getFullYear()&&r.getMonth()===n.getMonth()&&r.getDate()===n.getDate()}var Qy={addDays:zy,addWeek:tq,addMinutesToTimeString:jr,convertTime:Pp,getIsoDateString:Kl,getUTCdateString:nh,DateHHMM:qj,extractDate:ut,extractTime:zt,formatDate:ao,getDateByWeek:eq,isISODateString:Es,isValidEmbargoDate:Fa,isDate:eh,isTimeString:$y,offsetDate:jy,offsetTime:zj,sameDay:nn,timeStringMinutes:jt,timeToDate:Ge,timeUTC:Kj,validTimeValue:cm,validDateString:am,timeValidation:mu,dateValidation:qo};var rq=(t,e)=>t.filter(Boolean).every(r=>typeof r===e),nq=t=>t.filter(Boolean).every(We);function zl(t,e){return`${t}-${e}`}function As(t){let e=t.category;if(typeof e!="object"||!e)return{error:Tp};le