UNPKG

tods-competition-factory

Version:

Create and mutate TODS compliant tournament objects

1 lines • 1.51 MB
var Tj=Object.defineProperty;var kt=(t,e)=>{for(var r in e)Tj(t,r,{get:e[r],enumerable:!0})};var uL="5.0.0";function Ri(){return uL}var zD={};kt(zD,{availabilityGovernor:()=>cw,competitionGovernor:()=>eC,drawsGovernor:()=>fO,entriesGovernor:()=>AO,eventGovernor:()=>LO,generationGovernor:()=>BO,matchUpFormatGovernor:()=>YN,matchUpGovernor:()=>a_,mocksGovernor:()=>fT,officiatingGovernor:()=>Tw,participantGovernor:()=>G_,policyGovernor:()=>jv,publishingGovernor:()=>K_,queryGovernor:()=>mO,rankingGovernor:()=>gT,reportGovernor:()=>nx,scheduleGovernor:()=>Sx,scoreGovernor:()=>FS,tieFormatGovernor:()=>bx,tournamentGovernor:()=>$x,venueGovernor:()=>Mw});var eC={};kt(eC,{getCompetitionLeaderboard:()=>vE,getCompetitionParticipantState:()=>ME,getCompetitionPolicy:()=>vo,getCompetitionState:()=>jo,getLinkedTournamentIds:()=>Vp,getTournamentIds:()=>fm,initializeCompetitionState:()=>Kb,linkTournaments:()=>wb,mutate:()=>Zb,processCompetitionMatchUp:()=>gm,processCompetitionRound:()=>Jb,query:()=>tC,resetCompetitionState:()=>Xb,unlinkTournament:()=>Fb,unlinkTournaments:()=>Lb});var Zb={};kt(Zb,{initializeCompetitionState:()=>Kb,linkTournaments:()=>wb,processCompetitionMatchUp:()=>gm,processCompetitionRound:()=>Jb,resetCompetitionState:()=>Xb,unlinkTournament:()=>Fb,unlinkTournaments:()=>Lb});var Fs="SINGLES",bt="SINGLES",ni="DOUBLES",Ut="DOUBLES",hr="TEAM",Ot="TEAM",Ej="HYBRID",jd="HYBRID",pL={SINGLES_MATCHUP:Fs,SINGLES:bt,DOUBLES_MATCHUP:ni,DOUBLES:Ut,TEAM_MATCHUP:hr,TEAM:Ot,HYBRID_MATCHUP:Ej,HYBRID:jd};var fy={[bt]:[bt,"S"],[Ut]:[Ut,"D"],[Ot]:[Ot,"T"],[jd]:[jd,"H"],S:[bt,"S"],D:[Ut,"D"],T:[Ot,"T"],H:[jd,"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 _t(t){return typeof t=="string"}function ht(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function dL(t,e){if(!ht(t)||!ht(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 Iy(t,e){return Array.isArray(t)?Object.assign({},...(t??[]).filter(ht).map(r=>r[e]&&{[r[e]]:r}).filter(Boolean)):{}}var mL=t=>e=>Object.keys(t).every(r=>e[r]===t[r]);function gy(t,e){if(t===void 0)return null;if(!ht(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=>gy(i))}:{[o]:e?n(t[o]):gy(t[o])}))}function fU(t){return Array.isArray(t)?t.length+t.map(fU).reduce((e,r)=>e+r,0):ht(t)&&t!==null?Object.keys(t).length+Object.keys(t).map(e=>fU(t[e])).reduce((e,r)=>e+r,0):0}function lL(t){if(t===null||typeof t!="object")return;let e=JSON.stringify(t),r=fU(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 fL(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 gL(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 vl(t){return Number.isNaN(Number(t))?0:t%2&&t+1||t}function Ol(t){return Math.pow(2,Math.round(Math.log(t)/Math.log(2)))}function Be(t){return!Number.isNaN(Number.parseFloat(t))}function hy(t){let e=st(t);if(!Number.isNaN(e))return e===0?!1:(e&-e)===1}function bi(t){if(Number.isNaN(Number(t)))return!1;for(;!rn(t);)t++;return t}function un(t,e,r){return t=Math.ceil(t),e=Math.floor(e),Math.floor((r??Math.random)()*(e-t+1))+t}function St(t){return _t(t)&&!t.trim().length?!1:Number.isSafeInteger(typeof t=="string"?+t:t)}function IL(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 Aj(t,e){e||(e=1);let r=1/e;return Math.round(t*r)/r}function gU(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=gU(t,e,r,void 0,2,i):(u=Math.pow(u,r),u*=e-t,u+=t),n&&(u=Aj(u,n)),Number.parseFloat(u.toFixed(o))}function fI(t,e=2){return Number.parseFloat(Number(Math.round(t*1e3)/1e3).toFixed(e))}function at(t){return Array.isArray(t)?t?.filter((e,r,n)=>n.lastIndexOf(e)===r):[]}function hL(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 St(t)?t:1/0}function pn(t){return Array.isArray(t)?t.reduce((e,r)=>(e[r]||(e[r]=0),e[r]++,e),{}):{}}function SL(t){return IU(pn(t))}function IU(t){return Object.keys(t).reduce((e,r)=>{let n=t[r];return e[n]?e[n].push(r):e[n]=[r],e},{})}function Pj(t,e,r){return r.indexOf(t)===e}function Sy(t){return t.filter(Pj)}function Sr(t,e){return Array.isArray(t)&&t.length?t.splice(Math.floor((e??Math.random)()*t.length),1)[0]:void 0}function Pn(t,e){let r=Math.floor((e??Math.random)()*t.length);return t[r]}function Q(t,e){return Array.from({length:e-t},(r,n)=>n+t)}function gs(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 hU(t,e){return!Array.isArray(t)||!Array.isArray(e)?[]:t.filter(r=>!e.includes(r))}function we(t,e){return!Array.isArray(t)||!Array.isArray(e)?!1:t.some(r=>e.includes(r))}function TL(t,e){return Array.isArray(e)&&e.reduce((r,n)=>(r[n]=1+r[n]||1,r),{})[t]||0}function yL(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 Ae(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 SU(t,[e,...r]){return t.length?[t.slice(0,e),...SU(t.slice(e),[...r,e])]:[]}function EL(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 Ty(t){return Array.isArray(t)?t.reduce((e,r)=>!isNaN(parseInt(r))&&e,!0):!1}function yy(t){return Array.isArray(t)?t.reduce((e,r)=>isNaN(parseInt(r))&&e,!0):!1}function gI(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 AL(t,e=1){if(!Array.isArray(t)||!t.every(St))return[];let r=Math.min(...t,e),n=Math.max(...t);return Q(r,n+1).filter(o=>!t.includes(o))}function ks(t,e){return!Array.isArray(t)||!_t(e)?!1:Ht(t,fy[e]).length}var P={success:!0},TU="error",PL={SUCCESS:P,ERROR:TU};function Ey({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!==at(n).length?(r.push("collectionPositions are not unique"),{errors:r}):{...P}}var VL={};kt(VL,{addNotice:()=>it,callListener:()=>Gl,createInstanceState:()=>VR,cycleMutationStatus:()=>$I,deepCopyEnabled:()=>qI,deleteNotice:()=>wy,deleteNotices:()=>Ci,disableNotifications:()=>jR,enableNotifications:()=>YI,getAuditAuthorityServer:()=>Xd,getDevContext:()=>He,getMethods:()=>Zd,getNotices:()=>kl,getPayloads:()=>GL,getProvider:()=>Ly,getSaveDrawDeletions:()=>Jd,getSchemaWriteMode:()=>jI,getTopics:()=>rr,getTournamentId:()=>ji,getTournamentRecord:()=>KI,getTournamentRecords:()=>Kn,globalLog:()=>$R,handleCaughtError:()=>em,hasTopic:()=>pu,removeTournamentRecord:()=>qR,setAuditAuthorityServer:()=>WR,setDeepCopy:()=>Tp,setDevContext:()=>Sp,setGlobalLog:()=>LL,setGlobalMethods:()=>FL,setGlobalSubscriptions:()=>Zj,setMethods:()=>kL,setSaveDrawDeletions:()=>HR,setSchemaWriteMode:()=>BR,setStateMethods:()=>KR,setStateProvider:()=>Jj,setSubscriptions:()=>xy,setTournamentId:()=>tm,setTournamentRecord:()=>YR,setTournamentRecords:()=>Vl,timeKeeper:()=>Xj,writeLegacyEnabled:()=>uu,writeNativeEnabled:()=>cu});var Ay={message:"Chronological error; time violation.",code:"ANACHRONISM"},_l={message:"Duplicate entry",code:"DUPLICATE_ENTRY"},yU={message:"Cannot remove main structure",code:"ERR_CANNOT_REMOVE_MAIN_STRUCTURE"},Py={message:"records must be an object with tournamentId keys",code:"ERR_INVALID_TOURNAMENTS"},Ft={message:"Missing tournamentRecords",code:"ERR_MISSING_TOURNAMENTS"},Y={message:"Missing tournamentRecord",code:"ERR_MISSING_TOURNAMENT"},Xc={message:"Invalid tournamentRecord",code:"ERR_INVALID_TOURNAMENT"},gc={message:"Missing tournamentId",code:"ERR_MISSING_TOURNAMENT_ID"},Da={message:"Invalid drawDefinition",code:"ERR_INVALID_DRAWDEF"},$={message:"Missing drawDefinition",code:"ERR_MISSING_DRAWDEF"},EU={message:"Existing drawDefinition(s)",code:"ERR_EXISTING_DRAWDEFS"},Cr={message:"drawDefinition not found",code:"ERR_NOT_FOUND_DRAWDEF"},ko={message:"Invalid structure",code:"ERR_INVALID_STRUCTURE"},II={message:"Incomplete source structure",code:"ERR_INCOMPLETE_STRUCTURE"},hI={message:"Invalid drawPosition for seedAssignment",code:"ERR_INVALID_SEEDING_POSITION"},Zc={message:"drawPosition already assigned",code:"ERR_EXISTING_POSITION_ASSIGNMENT"},AU={message:"Schedule not cleared",code:"ERR_UNCHANGED_SCHEDULE_NOT_CLEARED"},PU={message:"Schedule conflict: court slot already occupied",code:"ERR_SCHEDULE_CONFLICT_DOUBLE_BOOKING"},NU={message:"Schedule conflict: matchUps scheduled outside court availability",code:"ERR_SCHEDULE_CONFLICT_COURT_UNAVAILABLE"},DU={message:"drawPosition not cleared",code:"ERR_FAILURE_POSITION_NOT_CLEARED"},Nj={message:"drawPosition not found",code:"ERR_NOT_FOUND_DRAW_POSITION"},dp={message:"Unrecognized drawType",code:"ERR_UNRECOGNIZED_DRAW_TYPE"},tu={message:"Missing drawPositions",code:"ERR_MISSING_DRAW_POSITIONS"},eu={message:"drawPosition is active",code:"ERR_ACTIVE_DRAW_POSITION"},NL={message:"drawPosition is occupied",code:"ERR_OCCUPIED_DRAW_POSITION"},Is={message:"Invlid drawPosition",code:"ERR_INVALID_DRAW_POSITION"},Ua={message:"Missing drawPosition",code:"ERR_MISSING_DRAW_POSITION"},xl={message:"Invalid drawType",code:"ERR_INVALID_DRAW_TYPE"},Yd={message:"Invalid drawSize",code:"ERR_INVALID_DRAW_SIZE"},Dj={message:"Cannot set drawSize to be less than existing entries",code:"ERR_INVALID_DRAW_SIZE_MISMATCH"},ru={message:"Missing drawSize",code:"ERR_MISSING_DRAW_SIZE"},Nn={message:"Missing drawId",code:"ERR_MISSING_DRAW_ID"},UU={message:"drawId exists",code:"ERR_EXISTING_DRAW_ID"},RU={message:"participantId cannot be assigned to multiple seedNumbers",code:"INVALID_PARTICIPANT_SEEDING"},bU={message:"seedsCount greater than drawSize",code:"ERR_INVALID_SEED_COUNT"},CU={message:"Missing seedCountThresholds",code:"ERR_MISSING_SEED_COUNT_THRESHOLD"},MU={message:"Invalid action",code:"ERR_INVALID_ACTION"},Ny={message:"Invalid assignment",code:"ERR_INVALID_ASSIGNMENT"},vU={message:"Missing seedAssignments",code:"ERR_MISSING_SEED_ASSIGNMENTS"},OU={message:"Invalid seedNumber",code:"ERR_INVALID_SEED_NUMBER"},_U={message:"Invalid seedPosition",code:"ERR_INVALID_SEED_POSITION"},SI={message:"Missing targetLink",code:"ERR_MISSING_LINK_TARGET"},xU={message:"Existing round",code:"ERR_EXISTING_ROUND"},Uj={message:"Missing roundNumber",code:"ERR_MISSING_ROUND_NUMBER"},dn={message:"Missing structureId",code:"ERR_MISSING_STRUCTURE_ID"},Pt={message:"structure not found",code:"ERR_NOT_FOUND_STRUCTURE"},TI={message:"Missing structures",code:"ERR_MISSING_STRUCTURES"},Bi={message:"Missing structure",code:"ERR_MISSING_STRUCTURE"},yI={message:"Missing MAIN structure",code:"ERR_MISSING_MAIN_STRUCTURE"},wU={message:"drawDefinition contains unlinked structures",code:"ERR_MISSING_STRUCTURE_LINKS"},oo={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"},LU={message:"Event exists",code:"ERR_EXISTING_EVENT"},FU={message:"Missing entries",code:"ERR_MISSING_ENTRIES"},kU={message:"Invalid entries",code:"ERR_INVALID_ENTRIES"},EI={message:"Missing assignments",code:"ERR_MISSING_ASSIGNMENTS"},AI={message:"Missing stage",code:"ERR_MISSING_STAGE"},Ic={message:"Invalid stage",code:"ERR_INVALID_STAGE"},GU={message:"stageSequence limit",code:"ERR_LIMIT_STAGE_SEQUENCE"},PI={message:"Missing positionAssignments",code:"ERR_MISSING_POSITION_ASSIGNMENTS"},VU={message:"Cannot Assign BYE status if no assignment: { bye: true }",code:"ERR_UNCHANGED_CANNOT_ASSIGN_BYE"},BU={message:"Lucky draw first round allows at most one BYE",code:"ERR_LUCKY_DRAW_BYE_LIMIT"},Dy={message:"Unrecognized matchUpStatus",code:"ERR_UNRECOGNIZED_MATCHUP_STATUS"},nu={message:"Unrecognized matchUpFormat",code:"ERR_UNRECOGNIZED_MATCHUP_FORMAT"},NI={message:"Incompatible matchUpStatus",code:"ERR_INCOMPATIBLE_MATCHUP_STATUS"},DL={message:"Propagated exits downstream",code:"ERR_PROPAGATED_EXITS_DOWNSTREAM"},hc={message:"Invalid matchUpStatus",code:"ERR_INVALID_MATCHUP_STATUS"},oi={message:"Invalid tieFormat",code:"ERR_INVALID_TIE_FORMAT"},HU={message:"Invalid matchUpFormat",code:"ERR_INVALID_MATCHUP_FORMAT"},WU={message:"Missing matchUpFormat",code:"ERR_MISSING_MATCHUP_FORMAT"},jU={message:"Missing collectionDefinition",code:"ERR_MISSING_COLLECTION_DEFINITION"},Ra={message:"Missing tieFormat",code:"ERR_MISSING_TIE_FORMAT"},cr={message:"Missing matchUpId",code:"ERR_MISSING_MATCHUP_ID"},Gs={message:"Missing matchUpIds",code:"ERR_MISSING_MATCHUP_IDS"},be={message:"matchUp not found",code:"ERR_NOT_FOUND_MATCHUP"},$n={message:"Missing matchUps",code:"ERR_MISSING_MATCHUPS"},nr={message:"Missing matchUp",code:"ERR_MISSING_MATCHUP"},mr={message:"Invalid matchUp",code:"ERR_INVALID_MATCHUP"},Uy={message:"Missing policyType",code:"ERR_MISSING_POLICY_TYPE"},ba={message:"Missing policyDefinitions",code:"ERR_MISSING_POLICY_DEFINITIONS"},Rj={message:"Missing seeding policy",code:"ERR_MISSING_POLICY_SEEDING"},YU={message:"Missing avoidance policy",code:"ERR_MISSING_POLICY_AVOIDANCE"},Ry={message:"Missing policy attributes",code:"ERR_MISSING_POLICY_ATTRIBUTES"},qU={message:"Invalid policyDefinitions",code:"ERR_INVALID_POLICY_DEFINITIONS"},by={message:"existing policyType",code:"ERR_EXISTING_POLICY_TYPE"},bj={message:"Policy not attached",code:"ERR_FAILURE_POLICY_NOT_ATTACHED"},mp={message:"Policy not found",code:"ERR_NOT_FOUND_POLICY"},Cj={message:"Missing scoring policy / matchUpFormats",code:"ERR_MISSING_POLICY_SCORING_MATCHUP_FORMATS"},$U={message:"Invalid sideNumber",code:"ERR_INVALID_SIDE_NUMBER"},Mj={message:"Invalid setNumber",code:"ERR_INVALID_SET_NUMBER"},DI={message:"Missing setObject",code:"ERR_MISSING_SET_ATTRIBUTE"},vj={message:"Missing setNumber",code:"ERR_MISSING_SET_NUMBER"},Oj={message:"Missing sideNumber",code:"ERR_MISSING_SIDE_NUMBER"},UI={message:"Missing courtId",code:"ERR_MISSING_COURT_ID"},nt={message:"Missing value",code:"ERR_MISSING_VALUE"},KU={message:"Missing birthdate",code:"ERR_MISSING_BIRTH_DATE"},zU={message:"Missing date",code:"ERR_MISSING_DATE"},RI={message:"No valid dates",code:"ERR_NO_VALID_DATES"},wl={message:"Invalid bookings",code:"ERR_INVALID_BOOKINGS"},bI={message:"Invalid dateAvailability",code:"ERR_INVALID_DATE_AVAILABILITY"},QU={message:"Missing dateAvailability",code:"ERR_MISSING_DATE_AVAILABILITY"},de={message:"Invalid Date",code:"ERR_INVALID_DATE"},Vs={message:"Invalid time",code:"ERR_INVALID_TIME"},JU={message:"Invalid tournament dates",code:"ERR_INVALID_DATES_TOURNAMENT"},UL={message:"Missing date range",info:"Event or tournament must have start and end dates",code:"ERR_MISSING_DATE_RANGE"},lp={message:"Invalid Time Zone",code:"ERR_INVALID_TIME_ZONE"},fp={message:"Invalid embargo: must be an ISO 8601 datetime with timezone (Z or \xB1HH:MM offset)",code:"ERR_INVALID_EMBARGO"},Cy={message:"Invalid game scores",code:"ERR_INVALID_SCORES_GAME"},XU={message:"Invalid score",code:"ERR_INVALID_SCORE"},Ll={message:"Invalid winningSide",code:"ERR_INVALID_WINNING_SIDE"};var RL={message:"No participants generated",code:"ERR_NO_PARTICIPANTS_GENERATED"},CI={message:"Cannot modify tieFormat",code:"ERR_UNCHANGED_CANNOT_MODIFY_TIEFORMAT"},ZU={message:"Cannot modify participantType",code:"ERR_UNCHANGED_CANNOT_MODIFY_PARTICIPANT_TYPE"},qd={message:"Cannot remove participants",code:"ERR_UNCHANGED_CANNOT_REMOVE_PARTICIPANTS"},tR={message:"Participant category mismatch",code:"ERR_CATEGORY_MISMATCH"},Fl={message:"Cannot change winningSide",code:"ERR_UNCHANGED_CANNOT_CHANGE_WINNING_SIDE"},Hi={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"},eR={message:"Invalid participantRole",code:"ERR_INVALID_PARTICIPANT_ROLE"},Dn={message:"Invalid participantType",code:"ERR_INVALID_PARTICIPANT_TYPE"},rR={message:"Missing participantRole",code:"ERR_MISSING_PARTICIPANT_ROLE"},Ca={message:"Missing participant",code:"ERR_MISSING_PARTICIPANT"},Ma={message:"Missing participants",code:"ERR_MISSING_PARTICIPANTS"},qe={message:"Missing participantId",code:"ERR_MISSING_PARTICIPANT_ID"},nR={message:"Missing qualified participants",code:"ERR_MISSING_QUALIFIED_PARTICIPANTS"},Yt={message:"Participant Not Found",code:"ERR_NOT_FOUND_PARTICIPANT"},oR={message:"participantId exists",code:"ERR_EXISTING_PARTICIPANT_ID"},_j={message:"participant pair exists",code:"ERR_EXISTING_PARTICIPANT_PAIR"},iR={message:"No participant removed",code:"ERR_UNCHANGED_NO_PARTICIPANT_REMOVED"},Go={message:"Missing participantIds",code:"ERR_MISSING_PARTICIPANT_IDS"},sR={message:"Missing participantsCount",code:"ERR_MISSING_PARTICIPANT_COUNT"},aR={message:"Participant not checked in",code:"ERR_UNCHANGED_PARTICIPANT_NOT_CHECKED_IN"},cR={message:"Missing person details",code:"ERR_MISSING_PERSON_DETAILS"},va={message:"Existing participant drawPosition assignment",code:"ERR_EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT"},$d={message:"Existing participant",code:"ERR_EXISTING_PARTICIPANT"},MI={message:"participantsCount exceeds drawSize",code:"ERR_INVALID_PARTICIPANT_COUNT"},vI={message:"Invalid entry status",code:"ERR_INVALID_ENTRY_STATUS"},My={message:"Participant Entry Not Found",code:"ERR_NOT_FOUND_PARTICIPANT_ENTRY"},bL={message:"Participant not entered in stage",code:"ERR_UNCHANGED_PARTICIPANT_NOT_ENTERED"},CL={message:"Participant not found in stageSequence",code:"ERR_NOT_FOUND_PARTICIPANT_IN_STAGE"},uR={message:"entryStatus not allowed in stage",code:"ERR_INVALID_ENTRY_STATUS_IN_STAGE"},pR={message:"entryStatus not allowed for event",code:"ERR_INVALID_ENTRY_STATUS_IN_EVENT"},OI={message:"No stage space available for entryStatus",code:"ERR_UNCHANGED_NO_AVAILABLE_STAGE_SPACE"},_I={message:"Insufficient drawPositions to accommodate qualifiers",code:"ERR_UNCHANGED_NO_DRAW_POSITIONS_FOR_QUALIFIERS"},xI={message:"Insufficient drawPositions to accommodate entries",code:"ERR_INSUFFICIENT_DRAW_POSITIONS"},dR={message:"Missing penaltyType",code:"ERR_MISSING_PENALTY_TYPE"},mR={message:"Missing penaltyId",code:"ERR_MISSING_PENALTY_ID"},gp={message:"Penalty not found",code:"ERR_NOT_FOUND_PENALTY"},lR={message:"Missing courtsCount/courtNames",code:"ERR_MISSING_COURTS_INFO"},Vo={message:"Court not found",code:"ERR_NOT_FOUND_COURT"},fR={message:"Court exists",code:"ERR_EXISTING_COURT"},vy={message:"Booking not found",code:"ERR_NOT_FOUND_BOOKING"},gR={message:"An active draft already exists for this draw",code:"ERR_EXISTING_DRAFT"},IR={message:"Existing matchUps conflict with booking",code:"ERR_EXISTING_MATCHUPS"},hR={message:"Venue exists",code:"ERR_EXISTING_VENUE"},Wi={message:"Venue not found",code:"ERR_NOT_FOUND_VENUE"},Bs={message:"Missing venueId",code:"ERR_MISSING_VENUE_ID"},SR={message:"Invalid endTime",code:"ERR_INVALID_END_TIME"},TR={message:"Existing endTime",code:"ERR_EXISTING_END_TIME"},yR={message:"Invalid stopTime",code:"ERR_INVALID_STOP_TIME"},ER={message:"Invalid startTime",code:"ERR_INVALID_START_TIME"},ML={message:"Invalid resumeTime",code:"ERR_INVALID_RESUME_TIME"},wI={message:"Invalid timeItem",code:"ERR_INVALID_TIME_ITEMS"},AR={message:"Missing async state provider",code:"ERR_MISSING_ASYNC_STATE_PROVIDER"},LI={message:"Missing timeItem",code:"ERR_MISSING_TIME_ITEM"},FI={message:"Missing timeItems",code:"ERR_MISSING_TIME_ITEMS"},Ip={message:"Missing context",code:"ERR_MISSING_CONTEXT"},PR={message:"Missing schedule",code:"ERR_MISSING_SCHEDULE"},ou={message:"Invalid scaleItem",code:"ERR_INVALID_SCALE_ITEM"},NR={message:"Modifications failed",code:"ERR_FAILURE_MODIFICATIONS"},Oa={message:"No modifications applied",code:"ERR_UNCHANGED_NO_MODIFICATIONS_APPLIED"},DR={message:"Unable to assign court",code:"ERR_UNCHANGED_COURT_NOT_ASSIGNED"},Kd={message:"No Candidates",code:"ERR_UNCHANGED_NO_CANDIDATES"},ii={message:"Invalid configuration",code:"ERR_INVALID_CONFIG"},UR={message:"Invalid collectionDefinition",code:"ERR_INVALID_COLLECTION_DEFINITION"},bo={message:"Invalid object",code:"ERR_INVALID_OBJECT"},zd={message:"Invalid gender",code:"ERR_INVALID_GENDER"},hp={message:"Invalid category",code:"ERR_INVALID_CATEGORY"},O={message:"Invalid values",code:"ERR_INVALID_VALUES"},RR={message:"Duplicate value",code:"ERR_DUPLICATE_VALUE"},kI={message:"Team not found",code:"ERR_NOT_FOUND_TEAM"},bR={message:"No valid actions",code:"ERR_NO_VALID_ACTIONS"},iu={message:"No valid attributes",code:"ERR_NO_VALID_ATTRIBUTES"},GI={message:"Value unchanged",code:"ABORT_UNCHANGED"},fe={message:"Not found",code:"ERR_NOT_FOUND"},VI={message:"Not implemented",code:"ERR_NOT_IMPLEMENTED"},CR={message:"Existing flight",code:"ERR_EXISTING_FLIGHT"},BI={message:"Existing flight profile",code:"ERR_EXISTING_FLIGHT_PROFILE"},MR={message:"Existing outcome",code:"ERR_EXISTING_OUTCOME"},vR={message:"Existing matchUpId",code:"ERR_EXISTING_MATCHUP_ID"},Oy={message:"Existing stage",code:"ERR_EXISTING_STAGE"},HI={message:"Existing structure",code:"ERR_EXISTING_STRUCTURE"},su={message:"Method not found",code:"ERR_NOT_FOUND_METHOD"},OR={message:"Mutation blocked by active lock",code:"ERR_MUTATION_LOCKED"},_R={message:"Active mutation lock already exists for scope",code:"ERR_EXISTING_MUTATION_LOCK"},xR={message:"Mutation lock not found",code:"ERR_NOT_FOUND_MUTATION_LOCK"},wR={message:"Lock token does not match",code:"ERR_UNAUTHORIZED_LOCK_OPERATION"},LR={message:"Scheduled matchUps",code:"ERR_SCHEDULED_MATCHUPS"},au={message:"Scores present",code:"ERR_SCORES_PRESENT"},FR={message:"Tournament category is referenced by one or more events",code:"ERR_TOURNAMENT_CATEGORY_IN_USE"},vL={ANACHRONISM:Ay,BOOKING_NOT_FOUND:vy,CANNOT_CHANGE_WINNING_SIDE:Fl,CANNOT_MODIFY_TIEFORMAT:CI,TOURNAMENT_CATEGORY_IN_USE:FR,CANNOT_MODIFY_PARTICIPANT_TYPE:ZU,CANNOT_REMOVE_MAIN_STRUCTURE:yU,CANNOT_REMOVE_PARTICIPANTS:qd,CATEGORY_MISMATCH:tR,COURT_EXISTS:fR,COURT_NOT_FOUND:Vo,EXISTING_DRAFT:gR,EXISTING_MATCHUPS:IR,DRAW_DEFINITION_NOT_FOUND:Cr,DRAW_ID_EXISTS:UU,DRAW_POSITION_ACTIVE:eu,DRAW_POSITION_ASSIGNED:Zc,DRAW_POSITION_NOT_CLEARED:DU,DRAW_POSITION_NOT_FOUND:Nj,DRAW_SIZE_MISMATCH:Dj,DUPLICATE_ENTRY:_l,DUPLICATE_VALUE:RR,ENTRY_STATUS_NOT_ALLOWED_FOR_EVENT:pR,ENTRY_STATUS_NOT_ALLOWED_IN_STAGE:uR,EVENT_EXISTS:LU,EVENT_NOT_FOUND:Br,EXISTING_DRAW_DEFINITIONS:EU,EXISTING_END_TIME:TR,EXISTING_FLIGHT:CR,EXISTING_MATCHUP_ID:vR,EXISTING_OUTCOME:MR,EXISTING_PARTICIPANT_DRAW_POSITION_ASSIGNMENT:va,EXISTING_PARTICIPANT:$d,EXISTING_POLICY_TYPE:by,EXISTING_PROFILE:BI,EXISTING_ROUND:xU,EXISTING_STAGE:Oy,EXISTING_STRUCTURE:HI,INCOMPATIBLE_MATCHUP_STATUS:NI,INCOMPLETE_SOURCE_STRUCTURE:II,INSUFFICIENT_DRAW_POSITIONS:xI,INVALID_ACTION:MU,INVALID_ASSIGNMENT:Ny,INVALID_BOOKINGS:wl,INVALID_CATEGORY:hp,INVALID_COLLECTION_DEFINITION:UR,INVALID_CONFIGURATION:ii,INVALID_DATE_AVAILABILITY:bI,INVALID_DATE:de,INVALID_DRAW_DEFINITION:Da,INVALID_DRAW_POSITION_FOR_SEEDING:hI,INVALID_DRAW_POSITION:Is,INVALID_DRAW_SIZE:Yd,INVALID_END_TIME:SR,INVALID_ENTRIES:kU,INVALID_EVENT_TYPE:oo,INVALID_GAME_SCORES:Cy,INVALID_GENDER:zd,INVALID_MATCHUP_FORMAT:HU,INVALID_MATCHUP_STATUS:hc,INVALID_MATCHUP_STATUS_BYE:VU,INVALID_MATCHUP:mr,INVALID_OBJECT:bo,INVALID_PARTICIPANT_ID:Hr,INVALID_PARTICIPANT_IDS:vr,INVALID_PARTICIPANT_ROLE:eR,INVALID_PARTICIPANT_SEEDING:RU,INVALID_PARTICIPANT_TYPE:Dn,INVALID_PARTICIPANT:Hi,INVALID_POLICY_DEFINITION:qU,INVALID_RECORDS:Py,INVALID_SCALE_ITEM:ou,INVALID_SEED_NUMBER:OU,INVALID_SEED_POSITION:_U,INVALID_SET_NUMBER:Mj,INVALID_SIDE_NUMBER:$U,INVALID_SCORE:XU,INVALID_STAGE:Ic,INVALID_START_TIME:ER,INVALID_STRUCTURE:ko,INVALID_STOP_TIME:yR,INVALID_TIE_FORMAT:oi,INVALID_TIME:Vs,INVALID_TIME_ITEM:wI,INVALID_TOURNAMENT_DATES:JU,INVALID_TOURNAMENT_RECORD:Xc,INVALID_VALUES:O,INVALID_WINNING_SIDE:Ll,LUCKY_DRAW_BYE_LIMIT:BU,MATCHUP_NOT_FOUND:be,METHOD_NOT_FOUND:su,MUTATION_LOCKED:OR,MUTATION_LOCK_EXISTS:_R,MUTATION_LOCK_NOT_FOUND:xR,MISSING_ASSIGNMENTS:EI,MISSING_ASYNC_STATE_PROVIDER:AR,MISSING_AVOIDANCE_POLICY:YU,MISSING_BIRTH_DATE:KU,MISSING_COLLECTION_DEFINITION:jU,MISSING_COURT_ID:UI,MISSING_COURTS_INFO:lR,MISSING_DATE_AVAILABILITY:QU,MISSING_DATE:zU,MISSING_DRAW_DEFINITION:$,MISSING_DRAW_ID:Nn,MISSING_DRAW_POSITION:Ua,MISSING_DRAW_POSITIONS:tu,MISSING_DRAW_SIZE:ru,MISSING_ENTRIES:FU,MISSING_EVENT:Se,MISSING_QUALIFIED_PARTICIPANTS:nR,MISSING_MATCHUP_FORMAT:WU,MISSING_MATCHUP_ID:cr,MISSING_MATCHUP_IDS:Gs,MISSING_MATCHUP:nr,MISSING_MATCHUPS:$n,MISSING_PARTICIPANT_COUNT:sR,MISSING_PARTICIPANT_ID:qe,MISSING_PARTICIPANT_IDS:Go,MISSING_PARTICIPANT_ROLE:rR,MISSING_PARTICIPANT:Ca,MISSING_PARTICIPANTS:Ma,MISSING_PENALTY_ID:mR,MISSING_PENALTY_TYPE:dR,MISSING_PERSON_DETAILS:cR,MISSING_POLICY_ATTRIBUTES:Ry,MISSING_POLICY_DEFINITION:ba,MISSING_POLICY_TYPE:Uy,MISSING_POSITION_ASSIGNMENTS:PI,MISSING_ROUND_NUMBER:Uj,MISSING_SCHEDULE:PR,MISSING_SCORING_POLICY:Cj,MISSING_SEED_ASSIGNMENTS:vU,MISSING_SEEDCOUNT_THRESHOLDS:CU,MISSING_SEEDING_POLICY:Rj,MISSING_SET_NUMBER:vj,MISSING_SET_OBJECT:DI,MISSING_SIDE_NUMBER:Oj,MISSING_STAGE:AI,MISSING_STRUCTURE_ID:dn,MISSING_STRUCTURE:Bi,MISSING_MAIN_STRUCTURE:yI,MISSING_STRUCTURES:TI,MISSING_TARGET_LINK:SI,MISSING_TIE_FORMAT:Ra,MISSING_TIME_ITEM:LI,MISSING_TIME_ITEMS:FI,MISSING_TOURNAMENT_ID:gc,MISSING_TOURNAMENT_RECORD:Y,MISSING_TOURNAMENT_RECORDS:Ft,MISSING_VALUE:nt,MISSING_VENUE_ID:Bs,MODIFICATIONS_FAILED:NR,NO_CANDIDATES:Kd,NO_DRAW_POSITIONS_AVAILABLE_FOR_QUALIFIERS:_I,NO_MODIFICATIONS_APPLIED:Oa,NO_STAGE_SPACE_AVAILABLE_FOR_ENTRY_STATUS:OI,NO_PARTICIPANT_REMOVED:iR,NO_VALID_ACTIONS:bR,NO_VALID_ATTRIBUTES:iu,NO_VALID_DATES:RI,NOT_FOUND:fe,NOT_IMPLEMENTED:VI,PARTICIPANT_COUNT_EXCEEDS_DRAW_SIZE:MI,PARTICIPANT_ID_EXISTS:oR,PARTICIPANT_NOT_CHECKED_IN:aR,PARTICIPANT_NOT_FOUND:Yt,PARTICIPANT_PAIR_EXISTS:_j,PENALTY_NOT_FOUND:gp,POLICY_NOT_ATTACHED:bj,POLICY_NOT_FOUND:mp,SCHEDULE_NOT_CLEARED:AU,SCHEDULE_CONFLICT_DOUBLE_BOOKING:PU,SCHEDULE_CONFLICT_COURT_UNAVAILABLE:NU,SCHEDULED_MATCHUPS:LR,SCORES_PRESENT:au,SEEDSCOUNT_GREATER_THAN_DRAW_SIZE:bU,STAGE_SEQUENCE_LIMIT:GU,STRUCTURE_NOT_FOUND:Pt,TEAM_NOT_FOUND:kI,UNABLE_TO_ASSIGN_COURT:DR,UNAUTHORIZED_LOCK_OPERATION:wR,UNLINKED_STRUCTURES:wU,UNRECOGNIZED_DRAW_TYPE:dp,UNRECOGNIZED_MATCHUP_FORMAT:nu,UNRECOGNIZED_MATCHUP_STATUS:Dy,VALUE_UNCHANGED:GI,VENUE_EXISTS:hR};var er={disableNotifications:!1,tournamentId:void 0,tournamentRecords:{},subscriptions:{},modified:!1,methods:{},notices:[]},kR={addNotice:Yj,callListener:zj,cycleMutationStatus:jj,deleteNotice:$j,deleteNotices:qj,disableNotifications:xj,enableNotifications:wj,getMethods:Qd,getNotices:OL,getPayloads:OL,getTopics:Kj,getTournamentId:_L,getTournamentRecord:Lj,getTournamentRecords:Fj,removeTournamentRecord:Bj,setMethods:Wj,setSubscriptions:Hj,setTournamentId:Gj,setTournamentRecord:kj,setTournamentRecords:Vj,handleCaughtError:Qj};function xj(){er.disableNotifications=!0}function wj(){er.disableNotifications=!1}function _L(){return er.tournamentId}function Lj(t){return er.tournamentRecords[t]}function Fj(){return er.tournamentRecords}function kj(t){let e=t?.tournamentId;return e?(er.tournamentRecords[e]=t,{success:!0}):{error:Xc}}function Gj(t){return t?er.tournamentRecords[t]?(er.tournamentId=t,{success:!0}):{error:Y}:(er.tournamentId=void 0,{success:!0})}function Vj(t){er.tournamentRecords=t;let e=Object.keys(t);e.length===1?er.tournamentId=e[0]:e.length||(er.tournamentId=void 0)}function Bj(t){if(typeof t!="string")return{error:O};if(!er.tournamentRecords[t])return{error:fe};delete er.tournamentRecords[t];let e=Object.keys(er.tournamentRecords);return e.length===1?er.tournamentId=e[0]:e.length||(er.tournamentId=void 0),{success:!0}}function Hj(t){return t.subscriptions===null||Object.keys(t.subscriptions).length===0?(er.subscriptions={},{...P}):typeof t.subscriptions!="object"?{error:O}:(Object.keys(t.subscriptions).forEach(e=>{typeof t.subscriptions[e]=="function"?er.subscriptions[e]=t.subscriptions[e]:delete er.subscriptions[e]}),{...P})}function Wj(t){return typeof t!="object"?{error:O}:(Object.keys(t).forEach(e=>{typeof t[e]=="function"&&(er.methods[e]=t[e])}),{...P})}function jj(){let t=er.modified;return er.modified=!1,t}function Yj({topic:t,payload:e,key:r},n){if(!(typeof t!="string"||typeof e!="object")&&(er.disableNotifications||(er.modified=!0),!(er.disableNotifications||!er.subscriptions[t]&&!n)))return r&&(er.notices=er.notices.filter(o=>!(o.topic===t&&o.key===r))),er.notices.push({topic:t,payload:e,key:r}),{...P}}function Qd(){return er.methods??{}}function OL({topic:t}){return er.notices.filter(e=>e.topic===t).map(e=>e.payload)}function qj(){er.notices=[]}function $j({topic:t,key:e}){er.notices=er.notices.filter(r=>(!t||r.topic===t)&&r.key!==e)}function Kj(){return{topics:Object.keys(er.subscriptions)}}function zj({topic:t,payloads:e,notices:r},n){let o=e??r??[],i=er.subscriptions[t];i&&typeof i=="function"&&i(o);let s=n?.[t];s&&typeof s=="function"&&s(o)}function Qj({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:_L(),params:JSON.stringify(r),engine:t,methodName:e,error:o}),{error:o}}var WI="native",GR="legacy",_y="dual",xL=[WI,_y,GR];var se={timers:{default:{elapsedTime:0}},globalSubscriptions:{},deepCopyAttributes:{stringify:[],ignore:[],toJSON:[]},globalMethods:[],schemaWriteMode:WI,saveDrawDeletions:!1,auditAuthorityServer:!1,deepCopy:!0},Wr=kR,wL=["addNotice","callListener","cycleMutationStatus","deleteNotice","deleteNotices","disableNotifications","enableNotifications","getMethods","getNotices","getTopics","getTournamentId","getTournamentRecord","getTournamentRecords","removeTournamentRecord","setSubscriptions","setTournamentId","setTournamentRecord","setTournamentRecords"];function Jj(t){if(typeof t!="object")throw new Error("Global state provider can not be undefined or null");if(Ht(Object.keys(t),wL).length!==wL.length)throw new Error("Global state provider is missing required methods");return Wr=t,{success:!0}}function VR(){if(Wr.createInstanceState){try{Wr.createInstanceState()}catch(t){return{error:t}}return{success:!0}}else return{error:AR}}function He(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 Xj(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 LL(t){Vr(t)?se.globalLog=t:delete se.globalLog}function Sp(t){se.devContext=t}function BR(t){return t===void 0?(se.schemaWriteMode=WI,{...P}):xL.includes(t)?(se.schemaWriteMode=t,{...P}):{error:O}}function jI(){return se.schemaWriteMode}function cu(){return se.schemaWriteMode===WI||se.schemaWriteMode===_y}function uu(){return se.schemaWriteMode===GR||se.schemaWriteMode===_y}function HR(t){return t===void 0?(se.saveDrawDeletions=!1,{...P}):typeof t!="boolean"?{error:O}:(se.saveDrawDeletions=t,{...P})}function Jd(){return se.saveDrawDeletions}function WR(t){return t===void 0?(se.auditAuthorityServer=!1,{...P}):typeof t!="boolean"?{error:O}:(se.auditAuthorityServer=t,{...P})}function Xd(){return se.auditAuthorityServer}function jR(){Wr.disableNotifications()}function YI(){Wr.enableNotifications()}function Tp(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 qI(){return{enabled:se.deepCopy,...se.deepCopyAttributes}}function Zj(t){return t?.subscriptions?(Object.keys(t.subscriptions).forEach(e=>{se.globalSubscriptions[e]=t.subscriptions[e]}),{...P}):{error:nt,info:"missing subscriptions"}}function xy(t){return t?.subscriptions?Wr.setSubscriptions({subscriptions:t.subscriptions}):{error:nt,info:"missing subscriptions"}}function FL(t){return t?typeof t!="object"?{error:O}:(Object.keys(t).forEach(e=>{Vr(t[e])&&(se.globalMethods[e]=t[e])}),{...P}):{error:nt,info:"missing method declarations"}}function kL(t){return t?typeof t!="object"?{error:O}:Wr.setMethods(t):{error:nt,info:"missing method declarations"}}function $I(){return Wr.cycleMutationStatus()}function it(t){if(typeof t?.topic!="string")return;let e=se.globalSubscriptions[t.topic];return Wr.addNotice(t,e)}function Zd(){return{...se.globalMethods,...Wr.getMethods()}}function kl(t){return GL(t)}function GL(t){return typeof Wr.getPayloads=="function"?Wr.getPayloads(t):Wr.getNotices(t)}function wy({key:t,topic:e}){return Wr.deleteNotice({key:t,topic:e})}function Ci(){return Wr.deleteNotices()}function rr(){return Wr.getTopics()}function pu(t){return rr()?.topics?.includes(t)}async function Gl(t){return Wr.callListener(t,se.globalSubscriptions)}function ji(){return Wr.getTournamentId()}function KI(t){return Wr.getTournamentRecord(t)}function Kn(){return Wr.getTournamentRecords()}function YR(t){return Wr.setTournamentRecord(t)}function Vl(t){return Wr.setTournamentRecords(t)}function tm(t){return Wr.setTournamentId(t)}function qR(t){return Wr.removeTournamentRecord(t)}function Ly(){return Wr}function em({engineName:t,methodName:e,params:r,err:n}){let o=Vr(Wr.handleCaughtError)&&Wr.handleCaughtError||kR.handleCaughtError,{tournamentRecord:i,...s}=r;return o({params:s,engineName:t,methodName:e,err:n})}function $R(t,e){if(se.globalLog)try{se.globalLog({log:t,engine:e})}catch(r){console.log("globalLog error",r),console.log(e,t),LL()}else console.log(e,t)}function KR(t,e,r,n){if(!ht(t))return{error:O};Be||(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]:ht(a[u])&&(e===!0||o?.includes(u))&&(r===void 0||c<r)&&s(a[u],c+1)})};return s(t),n?FL(i):kL(i),{methods:i}}function tY(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;qI()?.enabled||(n=!0);let i=["",void 0,null];e&&i.push(!1);let s=tY(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 or="FEMALE",si="OTHER",hs="MIXED",Le="MALE";var Bl={FEMALE_ABBR:"F",OTHER_ABBR:"O",MIXED_ABBR:"X",MALE_ABBR:"M",ANY_ABBR:"A",FEMALE:or,MIXED:hs,OTHER:si,MALE:Le,ANY:"ANY"};function Ss(t){return[or,"F"].includes(t)}function _a(t){return[Le,"M"].includes(t)}function jr(t){return[hs,"X"].includes(t)}function ho(t){return["ANY","A"].includes(t)}function lr(t){if(t){if(Ss(t))return or;if(jr(t))return hs;if(_a(t))return Le;if(ho(t))return"ANY"}return si}function Un(t){return Ss(t)||_a(t)}var oY="MIXED events can not contain mixed singles or { gender: ANY } collections",iY="events with { gender: ANY } can not contain MIXED singles collections";function Hl(t){let e="tieFormatGenderValidityCheck",{referenceGender:r,matchUpType:n,gender:o}=t;return r&&o&&Un(r)&&lr(r)!==lr(o)?M({result:{valid:!1,error:zd},context:{gender:o},stack:e}):jr(r)&&(ho(o)||jr(o)&&n!==Ut)?M({result:{error:zd,valid:!1},info:oY,stack:e}):ho(r)&&jr(o)&&n!==Ut?M({result:{error:zd,valid:!1},info:iY,stack:e}):{valid:!0}}var sY="normal",zR="timed",aY="final",zI="NOAD";var QR=["SET","HAL","QTR","PER","INN","RND","FRM","MAP","MAT"],Fy="CONSECUTIVE",ky="TRADITIONAL",cY="game",uY="matchUp",BL={S:sY,F:aY,G:cY,M:uY};function rm(t,e){if(ht(t)&&(t?.bestOf||t?.exactly)&&t?.setFormat)return dY(t,e)}function Wl(t){return!Number.isNaN(Number(t))&&Number(t)}function jL(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 pY(t){let e=t?.deuceAfter?`${t.deuceAfter}D`:"";if(t?.type===ky)return`TN${e}`;if(t?.type===Fy&&Number.isInteger(t.count))return`${t.count}C${e}`}function dY(t,e){let r=Wl(t.bestOf)||void 0,n=Wl(t.exactly)||void 0,o=r||n;if(t.setFormat?.timed&&t.simplified&&o===1)return jL(t.setFormat);let i=t.matchRoot||"SET",s=n&&n!==1?"X":"",a=t.aggregate?"A":"",c=o&&`${i}${o}${s}${a}`||"",u=HL(t.setFormat,e),p=u&&`S:${u}`||"",d=HL(t.finalSetFormat,e),m=o&&o>1&&d&&u!==d&&`F:${d}`||"",l=t.gameFormat?`G:${pY(t.gameFormat)}`:"",f=t.matchUpConstraint?.timed?`M:T${t.matchUpConstraint.minutes}`:"";if(c&&u)return[c,p,l,m,f].filter(Boolean).join("-")}function HL(t,e){if(typeof t=="object"&&Object.keys(t).length){if(t.timed)return jL(t);if(t.outs)return`O${t.outs}`;if(t.tiebreakSet)return WL(t.tiebreakSet);let r=Wl(t.setTo);if(r){let n=t.NoAD&&zI||"",o=Wl(t.winBy),i=WL(t.tiebreakFormat),s=i&&`/${i}`||"",a=o&&o!==2&&!i?`WB${o}`:"",c=Wl(t.tiebreakAt),u=c&&(c!==r||e)&&`@${c}`||"";if(i!==!1)return`${r}${n}${a}${s}${u}`}}}function WL(t){if(t){if(typeof t=="object"&&!t.tiebreakTo)return"";if(typeof t=="object"&&Wl(t.tiebreakTo)){let e=`TB${t.tiebreakTo}${t.NoAD?zI:""}`;return t.modifier&&(e+=`@${t.modifier}`),e}else return!1}}function ne(t){if(_t(t)){let e=t.startsWith("T")&&zR||QR.some(r=>t.startsWith(r))&&"SET"||"";if(e===zR){let r=KL(t),n={simplified:!0,setFormat:r,bestOf:1};if(r)return n}if(e==="SET")return fY(t)}}function mY(t){let e=QR.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=Ep(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 lY(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:ky};return n&&(i.deuceAfter=n),i}let o=/^([1-9]\d*)C$/.exec(r);if(o){let i={type:Fy,count:Number(o[1])};return n&&(i.deuceAfter=n),i}}function fY(t){let e=t.split("-"),r=mY(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(!gY(e[T],S))return;return{setFormat:p,finalSetFormat:d,gameFormat:m,matchUpConstraint:l}=S,IY({setFormat:p,finalSetFormat:d,gameFormat:m,matchUpConstraint:l,matchRoot:n,aggregate:s,matchMods:a,bestOf:c,exactly:u})}function gY(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 BL))return!1;if(n==="S"){if(e.sCount++,e.sCount>1)return!1;e.setFormat=YL(t,o)}else if(n==="F"){if(e.fCount++,e.fCount>1)return!1;e.finalSetFormat=YL(t,o)}else if(n==="G"){if(e.gCount++,e.gCount>1||(e.gameFormat=lY(o),!e.gameFormat))return!1}else if(n==="M"&&(e.mCount++,e.mCount>1||(e.matchUpConstraint=AY(o),!e.matchUpConstraint)))return!1;return!0}function IY({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 YL(t,e){return e.startsWith("TB")?hY(e):e.startsWith("O")?SY(e):e.startsWith("T")?KL(e):TY(t,e)}function hY(t){let e=$L(t);return e===!1?!1:typeof e=="object"?{tiebreakSet:e}:void 0}function SY(t){let e=/^O([1-9]\d*)$/.exec(t);if(e)return{outs:Number(e[1])}}function TY(t,e){let r=/^[FS]:(\d+)([A-Za-z]*?)(WB(\d+))?(?=[/@]|$)/.exec(t),n=r&&zL(r[2])||!1,o=!r?.[2]||n,i=r?Ep(r[1]):void 0,s=r?.[4],a=s?Ep(s):void 0,c=a===void 0||a>=1,u=qL(e),p=u!==!1,d=p&&u||i,m=$L(e.split("/")[1]);return!i||!o||!(m!==!1)||!p||!c||a!==void 0&&m?!1:yY(i,n,m,d,a)}function yY(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 qL(t,e=!0){let r=t?.indexOf("@")>0&&t.split("@");if(r)return(e?Ep(r[1]):r[1])||!1}function $L(t){if(t)return t.startsWith("TB")?EY(t):!1}function EY(t){let e=qL(t,!1),r=/^TB(\d+)([A-Za-z]*)/.exec(t),n=r?.[1],o=r&&zL(r[2]),i=!r?.[2]||o,s=Ep(n);if(!s||!i)return!1;let a={tiebreakTo:s};return e&&typeof e=="string"&&!St(e)&&(a.modifier=e),o&&(a.NoAD=!0),a}function KL(t){let e=t.slice(1),r=/^(\d+)([PG])?(?:\/TB(\d+))?(@[A-Za-z]+)?$/.exec(e),n=Ep(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=Ep(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 AY(t){let e=/^T(\d+)$/.exec(t);if(!e)return;let r=Ep(e[1]);if(r)return{timed:!0,minutes:r}}function zL(t){return t?.includes(zI)}function Ep(t){let e=Number(t);return Number.isNaN(e)?0:e}function PY(t){return t.replaceAll(/T(\d+)G(?=\/TB|@|-|$)/g,"T$1")}function Or({matchUpFormat:t}){if(!_t(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 rm(e,!!(r&&o&&n===i||s&&c&&a===u))===PY(t)}var nm=/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])$/,Gy=/^((0\d|1\d|2[0-3]):[0-5]\d(:[0-5]\d)?)([.,]\d{3})?$/,Bo=/^(\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?$/,du=/^(\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 Yl(t){let{scheduledDate:e}=t;if(!e&&t.scheduledTime&&(e=ct(t.scheduledTime)),!e)return;let r=$t(t.scheduledTime),n=ct(e);return n&&r&&(n+=`T${r}`),n}function QL(t){return typeof t!="object"||Array.isArray(t)?!1:Object.prototype.toString.call(t)==="[object Date]"}function om(t){let e=typeof t=="string"?t?.split(" "):[];if(t&&e?.length>1&&!["AM","PM"].includes(e[1].toUpperCase()))return!1;let r=Ap(t,!0,!0);return!!(!t||r&&du.test(r))}function Fe(t){return Ts(t)||nm.test(t)}function NY(t){let e=new Date(t),r=e.getSeconds()+60*e.getMinutes()+3600*e.getHours();return DY(r,{displaySeconds:!1})}function DY(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(So).join(":")}var XI=t=>{let e=QI(t)||Ts(t)?new Date(t):new Date,r=e.getUTCMonth()+1,n=r<10?`0${r}`:`${r}`;return`${e.getUTCFullYear()}-${So(n)}-${So(e.getUTCDate())}`};function UY(t){let e=QI(t)||Ts(t)?new Date(t):new Date;return Date.UTC(e.getFullYear(),e.getMonth(),e.getDate())}function io(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 Vy(t){let e=t?new Date(t):new Date,r=e.getTimezoneOffset();return new Date(e.getTime()-r*60*1e3)}function RY(t){return Vy(t).getTime()}function QI(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 bY(t,e){return t<=e}function xa(t,e){if(!Fe(t)||!Fe(e))return[];let r=ct(t)+"T00:00",n=ct(e)+"T00:00",o=new Date(r),i=new Date(n),s=QI(i)&&QI(o)&&bY(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=>io(u))}var CY=/^([+-]?\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 Ts(t){return typeof t!="string"?!1:CY.test(t)}function wa(t){return typeof t!="string"||!Ts(t)?!1:/([zZ]|[+-]\d{2}:?\d{2})$/.test(t)}function Hy(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 Wt(t){let e=$t(t);if(!e)return 0;let[r,n]=e.split(":").map(o=>Number.parseInt(o));return r*60+n}function JL(t){let e=Math.floor(t/60),r=t-e*60;return e>23&&(e=e%24),[So(e),So(r)].join(":")}function JI(t){return Hy(t)?t.split(":").slice(0,2).map(So).join(":"):void 0}function $t(t){return Ts(t)&&t.indexOf("T")>0?JI(t.split("T").reverse()[0]):JI(t)}function ct(t){return Ts(t)||Bo.test(t)?t.split("T")[0]:""}function im(t,e){let r=new Date(t);return r.setUTCDate(r.getUTCDate()+e),ct(r.toISOString())}function By(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 MY(t){let e=By(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(So).join(":")}function vY(t){let e=By(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 Ap(t,e,r){let n=ct(t),o=$t(t),i=n?o:t;return t?e&&(n&&r&&t||MY(i))||vY(i):void 0}function Wy(t,e){let r=By(t),n=By(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 jy(t,e=7){let r=ct(t)+"T00:00",n=new Date(r),o=new Date(n.setDate(n.getDate()+e));return io(o)}function OY(t){return jy(t)}function _Y(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())),io(o,r)}function XL(t,e,r){let n=new Date(t,0);return io(new Date(n.setDate(e)),r)}function ke(t,e=void 0){let[r,n]=(t||"00:00").split(":").map(So),o=Vy(e).setHours(r,n,0,0);return Vy(o)}function Hs(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 Yr(t,e){let r=$t(t);if(!r)return"00:00";let n=Number.isNaN(e)?0:e;return $t(ZI(ke(r),n).toISOString())||"00:00"}function ZI(t,e){let r=new Date(t);return new Date(r.getTime()+e*6e4)}function So(t){return t.toString()[1]?t:"0"+t}function so(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 Yy={addDays:jy,addWeek:OY,addMinutesToTimeString:Yr,convertTime:Ap,getIsoDateString:Yl,getUTCdateString:XI,DateHHMM:NY,extractDate:ct,extractTime:$t,formatDate:io,getDateByWeek:_Y,isISODateString:Ts,isValidEmbargoDate:wa,isDate:QI,isTimeString:Hy,offsetDate:Vy,offsetTime:RY,sameDay:so,timeStringMinutes:Wt,timeToDate:ke,timeUTC:UY,validTimeValue:om,validDateString:nm,timeValidation:du,dateValidation:Bo};var xY=(t,e)=>t.filter(Boolean).every(r=>typeof r===e),wY=t=>t.filter(Boolean).every(Be);function ql(t,e){return`${t}-${e}`}function ys(t){let e=t.category;if(typeof e!="object"||!e)return{error:hp};let{ageCategoryCode:r,ageMaxDate:n,ageMinDate:o,ageMax:i,ageMin:s}=e,a=e.categoryName,c;if(!(xY([r,n,o,a],"string")&&wY([i,s])&&[n,o].filter(Boolean).every(Fe)))return{error:hp};let p=t.consideredDate??ct(new Date().toLocale