@xcpcio/core 0.78.6 → 0.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1108,6 +1108,44 @@ class Group {
1108
1108
  }
1109
1109
  }
1110
1110
 
1111
+ class Organization {
1112
+ id;
1113
+ name;
1114
+ logo;
1115
+ icpcID;
1116
+ // Teams belonging to this organization
1117
+ teams;
1118
+ rank;
1119
+ constructor() {
1120
+ this.id = "";
1121
+ this.name = new I18nText();
1122
+ this.teams = [];
1123
+ this.rank = -1;
1124
+ }
1125
+ reset() {
1126
+ this.rank = -1;
1127
+ }
1128
+ static compare(lhs, rhs) {
1129
+ if (lhs.id < rhs.id) {
1130
+ return -1;
1131
+ } else if (lhs.id > rhs.id) {
1132
+ return 1;
1133
+ }
1134
+ return 0;
1135
+ }
1136
+ }
1137
+ function createOrganization(orgJSON) {
1138
+ const org = new Organization();
1139
+ org.id = orgJSON.id;
1140
+ org.name = I18nText.fromIText(orgJSON.name);
1141
+ org.logo = orgJSON.logo;
1142
+ org.icpcID = orgJSON.icpc_id;
1143
+ return org;
1144
+ }
1145
+ function createOrganizations(orgsJSON) {
1146
+ return orgsJSON.map((org) => createOrganization(org));
1147
+ }
1148
+
1111
1149
  class Contest {
1112
1150
  id = "";
1113
1151
  name;
@@ -1137,6 +1175,7 @@ class Contest {
1137
1175
  bannerMode;
1138
1176
  boardLink;
1139
1177
  options;
1178
+ organizations;
1140
1179
  constructor() {
1141
1180
  this.name = new I18nText();
1142
1181
  this.startTime = createDayJS();
@@ -1361,6 +1400,9 @@ function createContest(contestJSON) {
1361
1400
  if (contestJSON.options) {
1362
1401
  c.options = createContestOptions(contestJSON.options);
1363
1402
  }
1403
+ if (contestJSON.organizations) {
1404
+ c.organizations = createOrganizations(contestJSON.organizations);
1405
+ }
1364
1406
  return c;
1365
1407
  }
1366
1408
 
@@ -1781,49 +1823,14 @@ function getImageSource(image, data_host) {
1781
1823
  return `${normalizePath(data_host)}${image.url}`;
1782
1824
  }
1783
1825
  if (image?.base64) {
1826
+ if (image.mime) {
1827
+ return `data:${image.mime};base64,${image.base64}`;
1828
+ }
1784
1829
  return `data:image/${image.type ?? "png"};base64,${image.base64}`;
1785
1830
  }
1786
1831
  return "";
1787
1832
  }
1788
1833
 
1789
- class Organization {
1790
- id;
1791
- name;
1792
- logo;
1793
- icpcID;
1794
- // Teams belonging to this organization
1795
- teams;
1796
- rank;
1797
- constructor() {
1798
- this.id = "";
1799
- this.name = new I18nText();
1800
- this.teams = [];
1801
- this.rank = -1;
1802
- }
1803
- reset() {
1804
- this.rank = -1;
1805
- }
1806
- static compare(lhs, rhs) {
1807
- if (lhs.id < rhs.id) {
1808
- return -1;
1809
- } else if (lhs.id > rhs.id) {
1810
- return 1;
1811
- }
1812
- return 0;
1813
- }
1814
- }
1815
- function createOrganization(orgJSON) {
1816
- const org = new Organization();
1817
- org.id = orgJSON.id;
1818
- org.name = I18nText.fromIText(orgJSON.name);
1819
- org.logo = orgJSON.logo;
1820
- org.icpcID = orgJSON.icpc_id;
1821
- return org;
1822
- }
1823
- function createOrganizations(orgsJSON) {
1824
- return orgsJSON.map((org) => createOrganization(org));
1825
- }
1826
-
1827
1834
  class RankStatistics {
1828
1835
  teamSolvedNum;
1829
1836
  teamSolvedNumIndex;
@@ -1974,8 +1981,16 @@ class Rank {
1974
1981
  });
1975
1982
  }
1976
1983
  this.submissionsMap = new Map(this.submissions.map((s) => [s.id, s]));
1977
- this.organizationsMap = this.buildOrganizationsMap();
1978
- this.organizations = [...this.organizationsMap.values()];
1984
+ if (this.contest.organizations) {
1985
+ this.organizations = this.contest.organizations;
1986
+ this.organizationsMap = new Map(
1987
+ this.organizations.map((org) => [org.id, org])
1988
+ );
1989
+ this.linkTeamAndOrg();
1990
+ } else {
1991
+ this.organizationsMap = this.buildOrganizationsMap();
1992
+ this.organizations = [...this.organizationsMap.values()];
1993
+ }
1979
1994
  this.organizations.sort(Organization.compare);
1980
1995
  this.originTeams = this.teams.map((t) => t);
1981
1996
  this.originTeams.sort(Team.compare);
@@ -1999,6 +2014,14 @@ class Rank {
1999
2014
  this.statuses = [...se].sort();
2000
2015
  }
2001
2016
  }
2017
+ linkTeamAndOrg() {
2018
+ this.teams.forEach((t) => {
2019
+ if (!t.organizationId) {
2020
+ return;
2021
+ }
2022
+ t.organization = this.organizationsMap.get(t.organizationId);
2023
+ });
2024
+ }
2002
2025
  buildOrganizationsMap() {
2003
2026
  if (!this.contest.organization) {
2004
2027
  return /* @__PURE__ */ new Map();
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Lang, I18NStringSet, Text, CalculationOfPenalty, TimeUnit, Image, StatusTimeDisplay, MedalPreset, BannerMode, ContestState, Contest as Contest$1, SubmissionReaction, SubmissionStatus, Submission as Submission$1, Submissions as Submissions$1, BalloonColor, Problem as Problem$1, Problems as Problems$1, Organization as Organization$1, Organizations as Organizations$1, Person as Person$1, Persons as Persons$1, Team as Team$1, Teams as Teams$1, ContestIndex as ContestIndex$1, IRatingHistory, IRatingUser, IRating } from '@xcpcio/types';
1
+ import { CalculationOfPenalty, TimeUnit, Image, Lang, I18NStringSet, Text, Person as Person$1, Persons as Persons$1, Team as Team$1, Teams as Teams$1, Organization as Organization$1, Organizations as Organizations$1, StatusTimeDisplay, MedalPreset, BannerMode, ContestState, Contest as Contest$1, SubmissionReaction, SubmissionStatus, Submission as Submission$1, Submissions as Submissions$1, BalloonColor, Problem as Problem$1, Problems as Problems$1, ContestIndex as ContestIndex$1, IRatingHistory, IRatingUser, IRating } from '@xcpcio/types';
2
2
  import dayjs from 'dayjs';
3
3
  export { default as dayjs } from 'dayjs';
4
4
  import * as XLSX from 'xlsx-js-style';
@@ -19,6 +19,22 @@ declare class Award {
19
19
  declare function isValidMedalType(medal: MedalType): boolean;
20
20
  type Awards = Map<string, Award[]>;
21
21
 
22
+ declare class ContestOptions {
23
+ calculationOfPenalty: CalculationOfPenalty;
24
+ submissionTimestampUnit: TimeUnit;
25
+ submissionHasTimeField: boolean;
26
+ submissionHasLanguageField: boolean;
27
+ submissionEnableActionField: boolean;
28
+ submissionHasReactionField: boolean;
29
+ submissionHasExternalUrlField: boolean;
30
+ reactionVideoUrlTemplate?: string;
31
+ submissionExternalUrlTemplate?: string;
32
+ teamPhotoTemplate?: Image;
33
+ teamWebcamStreamUrlTemplate?: string;
34
+ teamScreenStreamUrlTemplate?: string;
35
+ constructor();
36
+ }
37
+
22
38
  interface SelectOptionItem {
23
39
  value: string;
24
40
  text: string;
@@ -38,21 +54,87 @@ declare class I18nText {
38
54
  valueOf(): string;
39
55
  }
40
56
 
41
- declare class ContestOptions {
42
- calculationOfPenalty: CalculationOfPenalty;
43
- submissionTimestampUnit: TimeUnit;
44
- submissionHasTimeField: boolean;
45
- submissionHasLanguageField: boolean;
46
- submissionEnableActionField: boolean;
47
- submissionHasReactionField: boolean;
48
- submissionHasExternalUrlField: boolean;
49
- reactionVideoUrlTemplate?: string;
50
- submissionExternalUrlTemplate?: string;
51
- teamPhotoTemplate?: Image;
52
- teamWebcamStreamUrlTemplate?: string;
53
- teamScreenStreamUrlTemplate?: string;
57
+ declare class Person {
58
+ name: I18nText;
59
+ cfID?: string;
60
+ icpcID?: string;
61
+ constructor(name?: I18nText);
62
+ toIPerson(): Person$1;
63
+ static fromIPerson(iPerson: Person$1): Person;
64
+ }
65
+ type Persons = Array<Person>;
66
+ declare function createPersons(iPersons?: Text | Array<Text> | Persons$1): Persons;
67
+
68
+ declare class PlaceChartPointData {
69
+ timePoint: number;
70
+ rank: number;
71
+ lastSolvedProblem: Problem | null;
72
+ constructor();
73
+ }
74
+ declare class Team {
75
+ id: string;
76
+ name: I18nText;
77
+ organizationId?: string;
78
+ organizationName?: string;
79
+ organization?: Organization;
80
+ isFirstRankOfOrganization: boolean;
81
+ group: Array<string>;
82
+ tag: Array<string>;
83
+ coaches: Persons;
84
+ members: Persons;
85
+ rank: number;
86
+ originalRank: number;
87
+ solvedProblemNum: number;
88
+ attemptedProblemNum: number;
89
+ lastSolvedProblem: Problem | null;
90
+ lastSolvedProblemStatistics: TeamProblemStatistics | null;
91
+ penalty: number;
92
+ problemStatistics: Array<TeamProblemStatistics>;
93
+ problemStatisticsMap: Map<string, TeamProblemStatistics>;
94
+ submissions: Submissions;
95
+ placeChartPoints: Array<PlaceChartPointData>;
96
+ awards: MedalType[];
97
+ badge?: Image;
98
+ missingPhoto: boolean;
99
+ photo?: Image;
100
+ location?: string;
101
+ icpcID?: string;
102
+ ip?: string;
103
+ se: number;
104
+ constructor();
105
+ reset(): void;
106
+ get penaltyToMinute(): number;
107
+ get isUnofficial(): boolean;
108
+ get isGirl(): boolean;
109
+ get isEffectiveTeam(): boolean;
110
+ get dirt(): number;
111
+ membersToString(lang?: Lang): string;
112
+ coachesToString(lang?: Lang): string;
113
+ calcSE(totalTeams: number): number;
114
+ calcSolvedData(options: ContestOptions): void;
115
+ calcAwards(awards?: Award[]): void;
116
+ isEqualRank(otherTeam: Team): boolean;
117
+ postProcessPlaceChartPoints(): void;
118
+ static compare(lhs: Team, rhs: Team): number;
119
+ }
120
+ type Teams = Array<Team>;
121
+ declare function createTeam(teamJSON: Team$1): Team;
122
+ declare function createTeams(teamsJSON: Teams$1): Teams;
123
+
124
+ declare class Organization {
125
+ id: string;
126
+ name: I18nText;
127
+ logo?: Image;
128
+ icpcID?: string;
129
+ teams: Teams;
130
+ rank: number;
54
131
  constructor();
132
+ reset(): void;
133
+ static compare(lhs: Organization, rhs: Organization): number;
55
134
  }
135
+ type Organizations = Array<Organization>;
136
+ declare function createOrganization(orgJSON: Organization$1): Organization;
137
+ declare function createOrganizations(orgsJSON: Organizations$1): Organizations;
56
138
 
57
139
  declare class Group {
58
140
  name: I18nText;
@@ -100,6 +182,7 @@ declare class Contest {
100
182
  bannerMode?: BannerMode;
101
183
  boardLink?: string;
102
184
  options: ContestOptions;
185
+ organizations?: Organizations;
103
186
  constructor();
104
187
  getStartTime(): dayjs.Dayjs;
105
188
  getEndTime(): dayjs.Dayjs;
@@ -200,88 +283,6 @@ declare class TeamProblemStatistics {
200
283
  get penaltyInSecond(): number;
201
284
  }
202
285
 
203
- declare class Organization {
204
- id: string;
205
- name: I18nText;
206
- logo?: Image;
207
- icpcID?: string;
208
- teams: Teams;
209
- rank: number;
210
- constructor();
211
- reset(): void;
212
- static compare(lhs: Organization, rhs: Organization): number;
213
- }
214
- type Organizations = Array<Organization>;
215
- declare function createOrganization(orgJSON: Organization$1): Organization;
216
- declare function createOrganizations(orgsJSON: Organizations$1): Organizations;
217
-
218
- declare class Person {
219
- name: I18nText;
220
- cfID?: string;
221
- icpcID?: string;
222
- constructor(name?: I18nText);
223
- toIPerson(): Person$1;
224
- static fromIPerson(iPerson: Person$1): Person;
225
- }
226
- type Persons = Array<Person>;
227
- declare function createPersons(iPersons?: Text | Array<Text> | Persons$1): Persons;
228
-
229
- declare class PlaceChartPointData {
230
- timePoint: number;
231
- rank: number;
232
- lastSolvedProblem: Problem | null;
233
- constructor();
234
- }
235
- declare class Team {
236
- id: string;
237
- name: I18nText;
238
- organizationId?: string;
239
- organizationName?: string;
240
- organization?: Organization;
241
- isFirstRankOfOrganization: boolean;
242
- group: Array<string>;
243
- tag: Array<string>;
244
- coaches: Persons;
245
- members: Persons;
246
- rank: number;
247
- originalRank: number;
248
- solvedProblemNum: number;
249
- attemptedProblemNum: number;
250
- lastSolvedProblem: Problem | null;
251
- lastSolvedProblemStatistics: TeamProblemStatistics | null;
252
- penalty: number;
253
- problemStatistics: Array<TeamProblemStatistics>;
254
- problemStatisticsMap: Map<string, TeamProblemStatistics>;
255
- submissions: Submissions;
256
- placeChartPoints: Array<PlaceChartPointData>;
257
- awards: MedalType[];
258
- badge?: Image;
259
- missingPhoto: boolean;
260
- photo?: Image;
261
- location?: string;
262
- icpcID?: string;
263
- ip?: string;
264
- se: number;
265
- constructor();
266
- reset(): void;
267
- get penaltyToMinute(): number;
268
- get isUnofficial(): boolean;
269
- get isGirl(): boolean;
270
- get isEffectiveTeam(): boolean;
271
- get dirt(): number;
272
- membersToString(lang?: Lang): string;
273
- coachesToString(lang?: Lang): string;
274
- calcSE(totalTeams: number): number;
275
- calcSolvedData(options: ContestOptions): void;
276
- calcAwards(awards?: Award[]): void;
277
- isEqualRank(otherTeam: Team): boolean;
278
- postProcessPlaceChartPoints(): void;
279
- static compare(lhs: Team, rhs: Team): number;
280
- }
281
- type Teams = Array<Team>;
282
- declare function createTeam(teamJSON: Team$1): Team;
283
- declare function createTeams(teamsJSON: Teams$1): Teams;
284
-
285
286
  declare class Balloon {
286
287
  problem: Problem;
287
288
  team: Team;
@@ -398,6 +399,7 @@ declare class Rank {
398
399
  languages: Array<string>;
399
400
  statuses: Array<SubmissionStatus>;
400
401
  constructor(contest: Contest, teams: Teams, submissions: Submissions);
402
+ linkTeamAndOrg(): void;
401
403
  buildOrganizationsMap(): Map<string, Organization>;
402
404
  cleanRank(): void;
403
405
  buildRank(): this;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Lang, I18NStringSet, Text, CalculationOfPenalty, TimeUnit, Image, StatusTimeDisplay, MedalPreset, BannerMode, ContestState, Contest as Contest$1, SubmissionReaction, SubmissionStatus, Submission as Submission$1, Submissions as Submissions$1, BalloonColor, Problem as Problem$1, Problems as Problems$1, Organization as Organization$1, Organizations as Organizations$1, Person as Person$1, Persons as Persons$1, Team as Team$1, Teams as Teams$1, ContestIndex as ContestIndex$1, IRatingHistory, IRatingUser, IRating } from '@xcpcio/types';
1
+ import { CalculationOfPenalty, TimeUnit, Image, Lang, I18NStringSet, Text, Person as Person$1, Persons as Persons$1, Team as Team$1, Teams as Teams$1, Organization as Organization$1, Organizations as Organizations$1, StatusTimeDisplay, MedalPreset, BannerMode, ContestState, Contest as Contest$1, SubmissionReaction, SubmissionStatus, Submission as Submission$1, Submissions as Submissions$1, BalloonColor, Problem as Problem$1, Problems as Problems$1, ContestIndex as ContestIndex$1, IRatingHistory, IRatingUser, IRating } from '@xcpcio/types';
2
2
  import dayjs from 'dayjs';
3
3
  export { default as dayjs } from 'dayjs';
4
4
  import * as XLSX from 'xlsx-js-style';
@@ -19,6 +19,22 @@ declare class Award {
19
19
  declare function isValidMedalType(medal: MedalType): boolean;
20
20
  type Awards = Map<string, Award[]>;
21
21
 
22
+ declare class ContestOptions {
23
+ calculationOfPenalty: CalculationOfPenalty;
24
+ submissionTimestampUnit: TimeUnit;
25
+ submissionHasTimeField: boolean;
26
+ submissionHasLanguageField: boolean;
27
+ submissionEnableActionField: boolean;
28
+ submissionHasReactionField: boolean;
29
+ submissionHasExternalUrlField: boolean;
30
+ reactionVideoUrlTemplate?: string;
31
+ submissionExternalUrlTemplate?: string;
32
+ teamPhotoTemplate?: Image;
33
+ teamWebcamStreamUrlTemplate?: string;
34
+ teamScreenStreamUrlTemplate?: string;
35
+ constructor();
36
+ }
37
+
22
38
  interface SelectOptionItem {
23
39
  value: string;
24
40
  text: string;
@@ -38,21 +54,87 @@ declare class I18nText {
38
54
  valueOf(): string;
39
55
  }
40
56
 
41
- declare class ContestOptions {
42
- calculationOfPenalty: CalculationOfPenalty;
43
- submissionTimestampUnit: TimeUnit;
44
- submissionHasTimeField: boolean;
45
- submissionHasLanguageField: boolean;
46
- submissionEnableActionField: boolean;
47
- submissionHasReactionField: boolean;
48
- submissionHasExternalUrlField: boolean;
49
- reactionVideoUrlTemplate?: string;
50
- submissionExternalUrlTemplate?: string;
51
- teamPhotoTemplate?: Image;
52
- teamWebcamStreamUrlTemplate?: string;
53
- teamScreenStreamUrlTemplate?: string;
57
+ declare class Person {
58
+ name: I18nText;
59
+ cfID?: string;
60
+ icpcID?: string;
61
+ constructor(name?: I18nText);
62
+ toIPerson(): Person$1;
63
+ static fromIPerson(iPerson: Person$1): Person;
64
+ }
65
+ type Persons = Array<Person>;
66
+ declare function createPersons(iPersons?: Text | Array<Text> | Persons$1): Persons;
67
+
68
+ declare class PlaceChartPointData {
69
+ timePoint: number;
70
+ rank: number;
71
+ lastSolvedProblem: Problem | null;
72
+ constructor();
73
+ }
74
+ declare class Team {
75
+ id: string;
76
+ name: I18nText;
77
+ organizationId?: string;
78
+ organizationName?: string;
79
+ organization?: Organization;
80
+ isFirstRankOfOrganization: boolean;
81
+ group: Array<string>;
82
+ tag: Array<string>;
83
+ coaches: Persons;
84
+ members: Persons;
85
+ rank: number;
86
+ originalRank: number;
87
+ solvedProblemNum: number;
88
+ attemptedProblemNum: number;
89
+ lastSolvedProblem: Problem | null;
90
+ lastSolvedProblemStatistics: TeamProblemStatistics | null;
91
+ penalty: number;
92
+ problemStatistics: Array<TeamProblemStatistics>;
93
+ problemStatisticsMap: Map<string, TeamProblemStatistics>;
94
+ submissions: Submissions;
95
+ placeChartPoints: Array<PlaceChartPointData>;
96
+ awards: MedalType[];
97
+ badge?: Image;
98
+ missingPhoto: boolean;
99
+ photo?: Image;
100
+ location?: string;
101
+ icpcID?: string;
102
+ ip?: string;
103
+ se: number;
104
+ constructor();
105
+ reset(): void;
106
+ get penaltyToMinute(): number;
107
+ get isUnofficial(): boolean;
108
+ get isGirl(): boolean;
109
+ get isEffectiveTeam(): boolean;
110
+ get dirt(): number;
111
+ membersToString(lang?: Lang): string;
112
+ coachesToString(lang?: Lang): string;
113
+ calcSE(totalTeams: number): number;
114
+ calcSolvedData(options: ContestOptions): void;
115
+ calcAwards(awards?: Award[]): void;
116
+ isEqualRank(otherTeam: Team): boolean;
117
+ postProcessPlaceChartPoints(): void;
118
+ static compare(lhs: Team, rhs: Team): number;
119
+ }
120
+ type Teams = Array<Team>;
121
+ declare function createTeam(teamJSON: Team$1): Team;
122
+ declare function createTeams(teamsJSON: Teams$1): Teams;
123
+
124
+ declare class Organization {
125
+ id: string;
126
+ name: I18nText;
127
+ logo?: Image;
128
+ icpcID?: string;
129
+ teams: Teams;
130
+ rank: number;
54
131
  constructor();
132
+ reset(): void;
133
+ static compare(lhs: Organization, rhs: Organization): number;
55
134
  }
135
+ type Organizations = Array<Organization>;
136
+ declare function createOrganization(orgJSON: Organization$1): Organization;
137
+ declare function createOrganizations(orgsJSON: Organizations$1): Organizations;
56
138
 
57
139
  declare class Group {
58
140
  name: I18nText;
@@ -100,6 +182,7 @@ declare class Contest {
100
182
  bannerMode?: BannerMode;
101
183
  boardLink?: string;
102
184
  options: ContestOptions;
185
+ organizations?: Organizations;
103
186
  constructor();
104
187
  getStartTime(): dayjs.Dayjs;
105
188
  getEndTime(): dayjs.Dayjs;
@@ -200,88 +283,6 @@ declare class TeamProblemStatistics {
200
283
  get penaltyInSecond(): number;
201
284
  }
202
285
 
203
- declare class Organization {
204
- id: string;
205
- name: I18nText;
206
- logo?: Image;
207
- icpcID?: string;
208
- teams: Teams;
209
- rank: number;
210
- constructor();
211
- reset(): void;
212
- static compare(lhs: Organization, rhs: Organization): number;
213
- }
214
- type Organizations = Array<Organization>;
215
- declare function createOrganization(orgJSON: Organization$1): Organization;
216
- declare function createOrganizations(orgsJSON: Organizations$1): Organizations;
217
-
218
- declare class Person {
219
- name: I18nText;
220
- cfID?: string;
221
- icpcID?: string;
222
- constructor(name?: I18nText);
223
- toIPerson(): Person$1;
224
- static fromIPerson(iPerson: Person$1): Person;
225
- }
226
- type Persons = Array<Person>;
227
- declare function createPersons(iPersons?: Text | Array<Text> | Persons$1): Persons;
228
-
229
- declare class PlaceChartPointData {
230
- timePoint: number;
231
- rank: number;
232
- lastSolvedProblem: Problem | null;
233
- constructor();
234
- }
235
- declare class Team {
236
- id: string;
237
- name: I18nText;
238
- organizationId?: string;
239
- organizationName?: string;
240
- organization?: Organization;
241
- isFirstRankOfOrganization: boolean;
242
- group: Array<string>;
243
- tag: Array<string>;
244
- coaches: Persons;
245
- members: Persons;
246
- rank: number;
247
- originalRank: number;
248
- solvedProblemNum: number;
249
- attemptedProblemNum: number;
250
- lastSolvedProblem: Problem | null;
251
- lastSolvedProblemStatistics: TeamProblemStatistics | null;
252
- penalty: number;
253
- problemStatistics: Array<TeamProblemStatistics>;
254
- problemStatisticsMap: Map<string, TeamProblemStatistics>;
255
- submissions: Submissions;
256
- placeChartPoints: Array<PlaceChartPointData>;
257
- awards: MedalType[];
258
- badge?: Image;
259
- missingPhoto: boolean;
260
- photo?: Image;
261
- location?: string;
262
- icpcID?: string;
263
- ip?: string;
264
- se: number;
265
- constructor();
266
- reset(): void;
267
- get penaltyToMinute(): number;
268
- get isUnofficial(): boolean;
269
- get isGirl(): boolean;
270
- get isEffectiveTeam(): boolean;
271
- get dirt(): number;
272
- membersToString(lang?: Lang): string;
273
- coachesToString(lang?: Lang): string;
274
- calcSE(totalTeams: number): number;
275
- calcSolvedData(options: ContestOptions): void;
276
- calcAwards(awards?: Award[]): void;
277
- isEqualRank(otherTeam: Team): boolean;
278
- postProcessPlaceChartPoints(): void;
279
- static compare(lhs: Team, rhs: Team): number;
280
- }
281
- type Teams = Array<Team>;
282
- declare function createTeam(teamJSON: Team$1): Team;
283
- declare function createTeams(teamsJSON: Teams$1): Teams;
284
-
285
286
  declare class Balloon {
286
287
  problem: Problem;
287
288
  team: Team;
@@ -398,6 +399,7 @@ declare class Rank {
398
399
  languages: Array<string>;
399
400
  statuses: Array<SubmissionStatus>;
400
401
  constructor(contest: Contest, teams: Teams, submissions: Submissions);
402
+ linkTeamAndOrg(): void;
401
403
  buildOrganizationsMap(): Map<string, Organization>;
402
404
  cleanRank(): void;
403
405
  buildRank(): this;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Lang, I18NStringSet, Text, CalculationOfPenalty, TimeUnit, Image, StatusTimeDisplay, MedalPreset, BannerMode, ContestState, Contest as Contest$1, SubmissionReaction, SubmissionStatus, Submission as Submission$1, Submissions as Submissions$1, BalloonColor, Problem as Problem$1, Problems as Problems$1, Organization as Organization$1, Organizations as Organizations$1, Person as Person$1, Persons as Persons$1, Team as Team$1, Teams as Teams$1, ContestIndex as ContestIndex$1, IRatingHistory, IRatingUser, IRating } from '@xcpcio/types';
1
+ import { CalculationOfPenalty, TimeUnit, Image, Lang, I18NStringSet, Text, Person as Person$1, Persons as Persons$1, Team as Team$1, Teams as Teams$1, Organization as Organization$1, Organizations as Organizations$1, StatusTimeDisplay, MedalPreset, BannerMode, ContestState, Contest as Contest$1, SubmissionReaction, SubmissionStatus, Submission as Submission$1, Submissions as Submissions$1, BalloonColor, Problem as Problem$1, Problems as Problems$1, ContestIndex as ContestIndex$1, IRatingHistory, IRatingUser, IRating } from '@xcpcio/types';
2
2
  import dayjs from 'dayjs';
3
3
  export { default as dayjs } from 'dayjs';
4
4
  import * as XLSX from 'xlsx-js-style';
@@ -19,6 +19,22 @@ declare class Award {
19
19
  declare function isValidMedalType(medal: MedalType): boolean;
20
20
  type Awards = Map<string, Award[]>;
21
21
 
22
+ declare class ContestOptions {
23
+ calculationOfPenalty: CalculationOfPenalty;
24
+ submissionTimestampUnit: TimeUnit;
25
+ submissionHasTimeField: boolean;
26
+ submissionHasLanguageField: boolean;
27
+ submissionEnableActionField: boolean;
28
+ submissionHasReactionField: boolean;
29
+ submissionHasExternalUrlField: boolean;
30
+ reactionVideoUrlTemplate?: string;
31
+ submissionExternalUrlTemplate?: string;
32
+ teamPhotoTemplate?: Image;
33
+ teamWebcamStreamUrlTemplate?: string;
34
+ teamScreenStreamUrlTemplate?: string;
35
+ constructor();
36
+ }
37
+
22
38
  interface SelectOptionItem {
23
39
  value: string;
24
40
  text: string;
@@ -38,21 +54,87 @@ declare class I18nText {
38
54
  valueOf(): string;
39
55
  }
40
56
 
41
- declare class ContestOptions {
42
- calculationOfPenalty: CalculationOfPenalty;
43
- submissionTimestampUnit: TimeUnit;
44
- submissionHasTimeField: boolean;
45
- submissionHasLanguageField: boolean;
46
- submissionEnableActionField: boolean;
47
- submissionHasReactionField: boolean;
48
- submissionHasExternalUrlField: boolean;
49
- reactionVideoUrlTemplate?: string;
50
- submissionExternalUrlTemplate?: string;
51
- teamPhotoTemplate?: Image;
52
- teamWebcamStreamUrlTemplate?: string;
53
- teamScreenStreamUrlTemplate?: string;
57
+ declare class Person {
58
+ name: I18nText;
59
+ cfID?: string;
60
+ icpcID?: string;
61
+ constructor(name?: I18nText);
62
+ toIPerson(): Person$1;
63
+ static fromIPerson(iPerson: Person$1): Person;
64
+ }
65
+ type Persons = Array<Person>;
66
+ declare function createPersons(iPersons?: Text | Array<Text> | Persons$1): Persons;
67
+
68
+ declare class PlaceChartPointData {
69
+ timePoint: number;
70
+ rank: number;
71
+ lastSolvedProblem: Problem | null;
72
+ constructor();
73
+ }
74
+ declare class Team {
75
+ id: string;
76
+ name: I18nText;
77
+ organizationId?: string;
78
+ organizationName?: string;
79
+ organization?: Organization;
80
+ isFirstRankOfOrganization: boolean;
81
+ group: Array<string>;
82
+ tag: Array<string>;
83
+ coaches: Persons;
84
+ members: Persons;
85
+ rank: number;
86
+ originalRank: number;
87
+ solvedProblemNum: number;
88
+ attemptedProblemNum: number;
89
+ lastSolvedProblem: Problem | null;
90
+ lastSolvedProblemStatistics: TeamProblemStatistics | null;
91
+ penalty: number;
92
+ problemStatistics: Array<TeamProblemStatistics>;
93
+ problemStatisticsMap: Map<string, TeamProblemStatistics>;
94
+ submissions: Submissions;
95
+ placeChartPoints: Array<PlaceChartPointData>;
96
+ awards: MedalType[];
97
+ badge?: Image;
98
+ missingPhoto: boolean;
99
+ photo?: Image;
100
+ location?: string;
101
+ icpcID?: string;
102
+ ip?: string;
103
+ se: number;
104
+ constructor();
105
+ reset(): void;
106
+ get penaltyToMinute(): number;
107
+ get isUnofficial(): boolean;
108
+ get isGirl(): boolean;
109
+ get isEffectiveTeam(): boolean;
110
+ get dirt(): number;
111
+ membersToString(lang?: Lang): string;
112
+ coachesToString(lang?: Lang): string;
113
+ calcSE(totalTeams: number): number;
114
+ calcSolvedData(options: ContestOptions): void;
115
+ calcAwards(awards?: Award[]): void;
116
+ isEqualRank(otherTeam: Team): boolean;
117
+ postProcessPlaceChartPoints(): void;
118
+ static compare(lhs: Team, rhs: Team): number;
119
+ }
120
+ type Teams = Array<Team>;
121
+ declare function createTeam(teamJSON: Team$1): Team;
122
+ declare function createTeams(teamsJSON: Teams$1): Teams;
123
+
124
+ declare class Organization {
125
+ id: string;
126
+ name: I18nText;
127
+ logo?: Image;
128
+ icpcID?: string;
129
+ teams: Teams;
130
+ rank: number;
54
131
  constructor();
132
+ reset(): void;
133
+ static compare(lhs: Organization, rhs: Organization): number;
55
134
  }
135
+ type Organizations = Array<Organization>;
136
+ declare function createOrganization(orgJSON: Organization$1): Organization;
137
+ declare function createOrganizations(orgsJSON: Organizations$1): Organizations;
56
138
 
57
139
  declare class Group {
58
140
  name: I18nText;
@@ -100,6 +182,7 @@ declare class Contest {
100
182
  bannerMode?: BannerMode;
101
183
  boardLink?: string;
102
184
  options: ContestOptions;
185
+ organizations?: Organizations;
103
186
  constructor();
104
187
  getStartTime(): dayjs.Dayjs;
105
188
  getEndTime(): dayjs.Dayjs;
@@ -200,88 +283,6 @@ declare class TeamProblemStatistics {
200
283
  get penaltyInSecond(): number;
201
284
  }
202
285
 
203
- declare class Organization {
204
- id: string;
205
- name: I18nText;
206
- logo?: Image;
207
- icpcID?: string;
208
- teams: Teams;
209
- rank: number;
210
- constructor();
211
- reset(): void;
212
- static compare(lhs: Organization, rhs: Organization): number;
213
- }
214
- type Organizations = Array<Organization>;
215
- declare function createOrganization(orgJSON: Organization$1): Organization;
216
- declare function createOrganizations(orgsJSON: Organizations$1): Organizations;
217
-
218
- declare class Person {
219
- name: I18nText;
220
- cfID?: string;
221
- icpcID?: string;
222
- constructor(name?: I18nText);
223
- toIPerson(): Person$1;
224
- static fromIPerson(iPerson: Person$1): Person;
225
- }
226
- type Persons = Array<Person>;
227
- declare function createPersons(iPersons?: Text | Array<Text> | Persons$1): Persons;
228
-
229
- declare class PlaceChartPointData {
230
- timePoint: number;
231
- rank: number;
232
- lastSolvedProblem: Problem | null;
233
- constructor();
234
- }
235
- declare class Team {
236
- id: string;
237
- name: I18nText;
238
- organizationId?: string;
239
- organizationName?: string;
240
- organization?: Organization;
241
- isFirstRankOfOrganization: boolean;
242
- group: Array<string>;
243
- tag: Array<string>;
244
- coaches: Persons;
245
- members: Persons;
246
- rank: number;
247
- originalRank: number;
248
- solvedProblemNum: number;
249
- attemptedProblemNum: number;
250
- lastSolvedProblem: Problem | null;
251
- lastSolvedProblemStatistics: TeamProblemStatistics | null;
252
- penalty: number;
253
- problemStatistics: Array<TeamProblemStatistics>;
254
- problemStatisticsMap: Map<string, TeamProblemStatistics>;
255
- submissions: Submissions;
256
- placeChartPoints: Array<PlaceChartPointData>;
257
- awards: MedalType[];
258
- badge?: Image;
259
- missingPhoto: boolean;
260
- photo?: Image;
261
- location?: string;
262
- icpcID?: string;
263
- ip?: string;
264
- se: number;
265
- constructor();
266
- reset(): void;
267
- get penaltyToMinute(): number;
268
- get isUnofficial(): boolean;
269
- get isGirl(): boolean;
270
- get isEffectiveTeam(): boolean;
271
- get dirt(): number;
272
- membersToString(lang?: Lang): string;
273
- coachesToString(lang?: Lang): string;
274
- calcSE(totalTeams: number): number;
275
- calcSolvedData(options: ContestOptions): void;
276
- calcAwards(awards?: Award[]): void;
277
- isEqualRank(otherTeam: Team): boolean;
278
- postProcessPlaceChartPoints(): void;
279
- static compare(lhs: Team, rhs: Team): number;
280
- }
281
- type Teams = Array<Team>;
282
- declare function createTeam(teamJSON: Team$1): Team;
283
- declare function createTeams(teamsJSON: Teams$1): Teams;
284
-
285
286
  declare class Balloon {
286
287
  problem: Problem;
287
288
  team: Team;
@@ -398,6 +399,7 @@ declare class Rank {
398
399
  languages: Array<string>;
399
400
  statuses: Array<SubmissionStatus>;
400
401
  constructor(contest: Contest, teams: Teams, submissions: Submissions);
402
+ linkTeamAndOrg(): void;
401
403
  buildOrganizationsMap(): Map<string, Organization>;
402
404
  cleanRank(): void;
403
405
  buildRank(): this;
package/dist/index.mjs CHANGED
@@ -1077,6 +1077,44 @@ class Group {
1077
1077
  }
1078
1078
  }
1079
1079
 
1080
+ class Organization {
1081
+ id;
1082
+ name;
1083
+ logo;
1084
+ icpcID;
1085
+ // Teams belonging to this organization
1086
+ teams;
1087
+ rank;
1088
+ constructor() {
1089
+ this.id = "";
1090
+ this.name = new I18nText();
1091
+ this.teams = [];
1092
+ this.rank = -1;
1093
+ }
1094
+ reset() {
1095
+ this.rank = -1;
1096
+ }
1097
+ static compare(lhs, rhs) {
1098
+ if (lhs.id < rhs.id) {
1099
+ return -1;
1100
+ } else if (lhs.id > rhs.id) {
1101
+ return 1;
1102
+ }
1103
+ return 0;
1104
+ }
1105
+ }
1106
+ function createOrganization(orgJSON) {
1107
+ const org = new Organization();
1108
+ org.id = orgJSON.id;
1109
+ org.name = I18nText.fromIText(orgJSON.name);
1110
+ org.logo = orgJSON.logo;
1111
+ org.icpcID = orgJSON.icpc_id;
1112
+ return org;
1113
+ }
1114
+ function createOrganizations(orgsJSON) {
1115
+ return orgsJSON.map((org) => createOrganization(org));
1116
+ }
1117
+
1080
1118
  class Contest {
1081
1119
  id = "";
1082
1120
  name;
@@ -1106,6 +1144,7 @@ class Contest {
1106
1144
  bannerMode;
1107
1145
  boardLink;
1108
1146
  options;
1147
+ organizations;
1109
1148
  constructor() {
1110
1149
  this.name = new I18nText();
1111
1150
  this.startTime = createDayJS();
@@ -1330,6 +1369,9 @@ function createContest(contestJSON) {
1330
1369
  if (contestJSON.options) {
1331
1370
  c.options = createContestOptions(contestJSON.options);
1332
1371
  }
1372
+ if (contestJSON.organizations) {
1373
+ c.organizations = createOrganizations(contestJSON.organizations);
1374
+ }
1333
1375
  return c;
1334
1376
  }
1335
1377
 
@@ -1750,49 +1792,14 @@ function getImageSource(image, data_host) {
1750
1792
  return `${normalizePath(data_host)}${image.url}`;
1751
1793
  }
1752
1794
  if (image?.base64) {
1795
+ if (image.mime) {
1796
+ return `data:${image.mime};base64,${image.base64}`;
1797
+ }
1753
1798
  return `data:image/${image.type ?? "png"};base64,${image.base64}`;
1754
1799
  }
1755
1800
  return "";
1756
1801
  }
1757
1802
 
1758
- class Organization {
1759
- id;
1760
- name;
1761
- logo;
1762
- icpcID;
1763
- // Teams belonging to this organization
1764
- teams;
1765
- rank;
1766
- constructor() {
1767
- this.id = "";
1768
- this.name = new I18nText();
1769
- this.teams = [];
1770
- this.rank = -1;
1771
- }
1772
- reset() {
1773
- this.rank = -1;
1774
- }
1775
- static compare(lhs, rhs) {
1776
- if (lhs.id < rhs.id) {
1777
- return -1;
1778
- } else if (lhs.id > rhs.id) {
1779
- return 1;
1780
- }
1781
- return 0;
1782
- }
1783
- }
1784
- function createOrganization(orgJSON) {
1785
- const org = new Organization();
1786
- org.id = orgJSON.id;
1787
- org.name = I18nText.fromIText(orgJSON.name);
1788
- org.logo = orgJSON.logo;
1789
- org.icpcID = orgJSON.icpc_id;
1790
- return org;
1791
- }
1792
- function createOrganizations(orgsJSON) {
1793
- return orgsJSON.map((org) => createOrganization(org));
1794
- }
1795
-
1796
1803
  class RankStatistics {
1797
1804
  teamSolvedNum;
1798
1805
  teamSolvedNumIndex;
@@ -1943,8 +1950,16 @@ class Rank {
1943
1950
  });
1944
1951
  }
1945
1952
  this.submissionsMap = new Map(this.submissions.map((s) => [s.id, s]));
1946
- this.organizationsMap = this.buildOrganizationsMap();
1947
- this.organizations = [...this.organizationsMap.values()];
1953
+ if (this.contest.organizations) {
1954
+ this.organizations = this.contest.organizations;
1955
+ this.organizationsMap = new Map(
1956
+ this.organizations.map((org) => [org.id, org])
1957
+ );
1958
+ this.linkTeamAndOrg();
1959
+ } else {
1960
+ this.organizationsMap = this.buildOrganizationsMap();
1961
+ this.organizations = [...this.organizationsMap.values()];
1962
+ }
1948
1963
  this.organizations.sort(Organization.compare);
1949
1964
  this.originTeams = this.teams.map((t) => t);
1950
1965
  this.originTeams.sort(Team.compare);
@@ -1968,6 +1983,14 @@ class Rank {
1968
1983
  this.statuses = [...se].sort();
1969
1984
  }
1970
1985
  }
1986
+ linkTeamAndOrg() {
1987
+ this.teams.forEach((t) => {
1988
+ if (!t.organizationId) {
1989
+ return;
1990
+ }
1991
+ t.organization = this.organizationsMap.get(t.organizationId);
1992
+ });
1993
+ }
1971
1994
  buildOrganizationsMap() {
1972
1995
  if (!this.contest.organization) {
1973
1996
  return /* @__PURE__ */ new Map();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xcpcio/core",
3
3
  "type": "module",
4
- "version": "0.78.6",
4
+ "version": "0.79.0",
5
5
  "description": "The core library for XCPCIO",
6
6
  "author": "Dup4 <hi@dup4.com>",
7
7
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "papaparse": "^5.5.3",
43
43
  "string-width": "^8.1.0",
44
44
  "xlsx-js-style": "^1.2.0",
45
- "@xcpcio/types": "0.78.6"
45
+ "@xcpcio/types": "0.79.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@babel/types": "^7.28.6",