@mtgame/core 0.0.1

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.
Files changed (293) hide show
  1. package/README.md +24 -0
  2. package/api/basketball-game-api.d.ts +17 -0
  3. package/api/league-api.d.ts +16 -0
  4. package/api/media-api.d.ts +24 -0
  5. package/api/notification-api.d.ts +4 -0
  6. package/api/notification-base-api.d.ts +22 -0
  7. package/api/org-notification-api.d.ts +4 -0
  8. package/api/paginated-response.interface.d.ts +4 -0
  9. package/api/public-api.d.ts +12 -0
  10. package/api/reference-api.d.ts +11 -0
  11. package/api/tournament-api.d.ts +64 -0
  12. package/api/tournament-join-api.d.ts +14 -0
  13. package/api/tournament-stage-api.d.ts +15 -0
  14. package/api/volleyball-game-api.d.ts +17 -0
  15. package/bundles/mtgame-core.umd.js +4785 -0
  16. package/bundles/mtgame-core.umd.js.map +1 -0
  17. package/bundles/mtgame-core.umd.min.js +16 -0
  18. package/bundles/mtgame-core.umd.min.js.map +1 -0
  19. package/esm2015/api/basketball-game-api.js +54 -0
  20. package/esm2015/api/league-api.js +60 -0
  21. package/esm2015/api/media-api.js +110 -0
  22. package/esm2015/api/notification-api.js +18 -0
  23. package/esm2015/api/notification-base-api.js +83 -0
  24. package/esm2015/api/org-notification-api.js +18 -0
  25. package/esm2015/api/paginated-response.interface.js +1 -0
  26. package/esm2015/api/public-api.js +12 -0
  27. package/esm2015/api/reference-api.js +40 -0
  28. package/esm2015/api/tournament-api.js +187 -0
  29. package/esm2015/api/tournament-join-api.js +51 -0
  30. package/esm2015/api/tournament-stage-api.js +56 -0
  31. package/esm2015/api/volleyball-game-api.js +54 -0
  32. package/esm2015/http-cookie.interceptor.js +34 -0
  33. package/esm2015/localization/basketball-game-log-types.js +26 -0
  34. package/esm2015/localization/overtime-types.js +7 -0
  35. package/esm2015/localization/public-api.js +7 -0
  36. package/esm2015/localization/team-event-type.js +6 -0
  37. package/esm2015/localization/team-user-role.js +7 -0
  38. package/esm2015/localization/user-profile.js +46 -0
  39. package/esm2015/localization/volleyball-game-log-types.js +25 -0
  40. package/esm2015/models/basketball-game-config.js +42 -0
  41. package/esm2015/models/basketball-game-log.js +109 -0
  42. package/esm2015/models/basketball-game-statistic.js +50 -0
  43. package/esm2015/models/basketball-game-team-statistic.js +27 -0
  44. package/esm2015/models/basketball-profile.js +43 -0
  45. package/esm2015/models/basketball-statistic.js +69 -0
  46. package/esm2015/models/city.js +22 -0
  47. package/esm2015/models/file.js +38 -0
  48. package/esm2015/models/game-invite.js +37 -0
  49. package/esm2015/models/game-log-base.js +1 -0
  50. package/esm2015/models/game-statistic-base.js +1 -0
  51. package/esm2015/models/game-timeline-stages.js +49 -0
  52. package/esm2015/models/game-user.js +32 -0
  53. package/esm2015/models/game.js +108 -0
  54. package/esm2015/models/league-court.js +24 -0
  55. package/esm2015/models/league.js +52 -0
  56. package/esm2015/models/media-item.js +40 -0
  57. package/esm2015/models/notification-settings.js +35 -0
  58. package/esm2015/models/notification.js +134 -0
  59. package/esm2015/models/organization.js +27 -0
  60. package/esm2015/models/playoff.js +78 -0
  61. package/esm2015/models/poll.js +132 -0
  62. package/esm2015/models/public-api.js +50 -0
  63. package/esm2015/models/sport.js +47 -0
  64. package/esm2015/models/team-event-invite.js +32 -0
  65. package/esm2015/models/team-event-type.js +6 -0
  66. package/esm2015/models/team-event.js +45 -0
  67. package/esm2015/models/team-invite-external.js +25 -0
  68. package/esm2015/models/team-invite.js +41 -0
  69. package/esm2015/models/team-user.js +39 -0
  70. package/esm2015/models/team.js +56 -0
  71. package/esm2015/models/tournament-disqualification.js +29 -0
  72. package/esm2015/models/tournament-event.js +38 -0
  73. package/esm2015/models/tournament-group.js +23 -0
  74. package/esm2015/models/tournament-invite.js +39 -0
  75. package/esm2015/models/tournament-join-team.js +55 -0
  76. package/esm2015/models/tournament-news.js +33 -0
  77. package/esm2015/models/tournament-stage-team.js +45 -0
  78. package/esm2015/models/tournament-stage.js +35 -0
  79. package/esm2015/models/tournament-team-user-invite.js +29 -0
  80. package/esm2015/models/tournament-team-user.js +49 -0
  81. package/esm2015/models/tournament-team.js +54 -0
  82. package/esm2015/models/tournament.js +161 -0
  83. package/esm2015/models/user-profile.js +24 -0
  84. package/esm2015/models/user.js +74 -0
  85. package/esm2015/models/util.js +208 -0
  86. package/esm2015/models/volleyball-game-config.js +40 -0
  87. package/esm2015/models/volleyball-game-log.js +139 -0
  88. package/esm2015/models/volleyball-game-statistic.js +50 -0
  89. package/esm2015/models/volleyball-game-team-statistic.js +27 -0
  90. package/esm2015/models/volleyball-profile.js +43 -0
  91. package/esm2015/models/volleyball-statistic.js +66 -0
  92. package/esm2015/mtgame-core.js +5 -0
  93. package/esm2015/public-api.js +8 -0
  94. package/esm2015/services/base.service.js +18 -0
  95. package/esm2015/services/centrifugo.service.js +107 -0
  96. package/esm2015/services/config.service.js +40 -0
  97. package/esm2015/services/public-api.js +4 -0
  98. package/esm2015/storage/local-storage-engine.js +18 -0
  99. package/esm2015/storage/public-api.js +4 -0
  100. package/esm2015/storage/storage-engine.js +61 -0
  101. package/esm2015/storage/store.js +63 -0
  102. package/esm2015/utils/array.js +18 -0
  103. package/esm2015/utils/component-destroyed.js +21 -0
  104. package/esm2015/utils/cookie.js +9 -0
  105. package/esm2015/utils/data.js +75 -0
  106. package/esm2015/utils/device.js +14 -0
  107. package/esm2015/utils/enum.js +7 -0
  108. package/esm2015/utils/errors.js +10 -0
  109. package/esm2015/utils/favicon.js +25 -0
  110. package/esm2015/utils/form.js +22 -0
  111. package/esm2015/utils/public-api.js +11 -0
  112. package/esm2015/utils/validators.js +47 -0
  113. package/esm5/api/basketball-game-api.js +65 -0
  114. package/esm5/api/league-api.js +70 -0
  115. package/esm5/api/media-api.js +125 -0
  116. package/esm5/api/notification-api.js +21 -0
  117. package/esm5/api/notification-base-api.js +109 -0
  118. package/esm5/api/org-notification-api.js +21 -0
  119. package/esm5/api/paginated-response.interface.js +1 -0
  120. package/esm5/api/public-api.js +12 -0
  121. package/esm5/api/reference-api.js +45 -0
  122. package/esm5/api/tournament-api.js +245 -0
  123. package/esm5/api/tournament-join-api.js +59 -0
  124. package/esm5/api/tournament-stage-api.js +65 -0
  125. package/esm5/api/volleyball-game-api.js +65 -0
  126. package/esm5/http-cookie.interceptor.js +35 -0
  127. package/esm5/localization/basketball-game-log-types.js +27 -0
  128. package/esm5/localization/overtime-types.js +8 -0
  129. package/esm5/localization/public-api.js +7 -0
  130. package/esm5/localization/team-event-type.js +7 -0
  131. package/esm5/localization/team-user-role.js +8 -0
  132. package/esm5/localization/user-profile.js +47 -0
  133. package/esm5/localization/volleyball-game-log-types.js +26 -0
  134. package/esm5/models/basketball-game-config.js +47 -0
  135. package/esm5/models/basketball-game-log.js +117 -0
  136. package/esm5/models/basketball-game-statistic.js +63 -0
  137. package/esm5/models/basketball-game-team-statistic.js +32 -0
  138. package/esm5/models/basketball-profile.js +48 -0
  139. package/esm5/models/basketball-statistic.js +78 -0
  140. package/esm5/models/city.js +27 -0
  141. package/esm5/models/file.js +41 -0
  142. package/esm5/models/game-invite.js +42 -0
  143. package/esm5/models/game-log-base.js +1 -0
  144. package/esm5/models/game-statistic-base.js +1 -0
  145. package/esm5/models/game-timeline-stages.js +57 -0
  146. package/esm5/models/game-user.js +37 -0
  147. package/esm5/models/game.js +134 -0
  148. package/esm5/models/league-court.js +29 -0
  149. package/esm5/models/league.js +69 -0
  150. package/esm5/models/media-item.js +49 -0
  151. package/esm5/models/notification-settings.js +40 -0
  152. package/esm5/models/notification.js +143 -0
  153. package/esm5/models/organization.js +32 -0
  154. package/esm5/models/playoff.js +91 -0
  155. package/esm5/models/poll.js +154 -0
  156. package/esm5/models/public-api.js +50 -0
  157. package/esm5/models/sport.js +52 -0
  158. package/esm5/models/team-event-invite.js +35 -0
  159. package/esm5/models/team-event-type.js +6 -0
  160. package/esm5/models/team-event.js +58 -0
  161. package/esm5/models/team-invite-external.js +30 -0
  162. package/esm5/models/team-invite.js +46 -0
  163. package/esm5/models/team-user.js +44 -0
  164. package/esm5/models/team.js +61 -0
  165. package/esm5/models/tournament-disqualification.js +34 -0
  166. package/esm5/models/tournament-event.js +43 -0
  167. package/esm5/models/tournament-group.js +28 -0
  168. package/esm5/models/tournament-invite.js +48 -0
  169. package/esm5/models/tournament-join-team.js +73 -0
  170. package/esm5/models/tournament-news.js +38 -0
  171. package/esm5/models/tournament-stage-team.js +54 -0
  172. package/esm5/models/tournament-stage.js +40 -0
  173. package/esm5/models/tournament-team-user-invite.js +34 -0
  174. package/esm5/models/tournament-team-user.js +66 -0
  175. package/esm5/models/tournament-team.js +63 -0
  176. package/esm5/models/tournament.js +176 -0
  177. package/esm5/models/user-profile.js +27 -0
  178. package/esm5/models/user.js +95 -0
  179. package/esm5/models/util.js +275 -0
  180. package/esm5/models/volleyball-game-config.js +49 -0
  181. package/esm5/models/volleyball-game-log.js +142 -0
  182. package/esm5/models/volleyball-game-statistic.js +71 -0
  183. package/esm5/models/volleyball-game-team-statistic.js +32 -0
  184. package/esm5/models/volleyball-profile.js +48 -0
  185. package/esm5/models/volleyball-statistic.js +71 -0
  186. package/esm5/mtgame-core.js +5 -0
  187. package/esm5/public-api.js +8 -0
  188. package/esm5/services/base.service.js +19 -0
  189. package/esm5/services/centrifugo.service.js +111 -0
  190. package/esm5/services/config.service.js +52 -0
  191. package/esm5/services/public-api.js +4 -0
  192. package/esm5/storage/local-storage-engine.js +25 -0
  193. package/esm5/storage/public-api.js +4 -0
  194. package/esm5/storage/storage-engine.js +77 -0
  195. package/esm5/storage/store.js +77 -0
  196. package/esm5/utils/array.js +18 -0
  197. package/esm5/utils/component-destroyed.js +21 -0
  198. package/esm5/utils/cookie.js +9 -0
  199. package/esm5/utils/data.js +79 -0
  200. package/esm5/utils/device.js +14 -0
  201. package/esm5/utils/enum.js +7 -0
  202. package/esm5/utils/errors.js +12 -0
  203. package/esm5/utils/favicon.js +47 -0
  204. package/esm5/utils/form.js +22 -0
  205. package/esm5/utils/public-api.js +11 -0
  206. package/esm5/utils/validators.js +49 -0
  207. package/fesm2015/mtgame-core.js +3749 -0
  208. package/fesm2015/mtgame-core.js.map +1 -0
  209. package/fesm5/mtgame-core.js +4455 -0
  210. package/fesm5/mtgame-core.js.map +1 -0
  211. package/http-cookie.interceptor.d.ts +10 -0
  212. package/localization/basketball-game-log-types.d.ts +25 -0
  213. package/localization/overtime-types.d.ts +6 -0
  214. package/localization/public-api.d.ts +6 -0
  215. package/localization/team-event-type.d.ts +5 -0
  216. package/localization/team-user-role.d.ts +6 -0
  217. package/localization/user-profile.d.ts +45 -0
  218. package/localization/volleyball-game-log-types.d.ts +24 -0
  219. package/models/basketball-game-config.d.ts +22 -0
  220. package/models/basketball-game-log.d.ts +52 -0
  221. package/models/basketball-game-statistic.d.ts +29 -0
  222. package/models/basketball-game-team-statistic.d.ts +8 -0
  223. package/models/basketball-profile.d.ts +20 -0
  224. package/models/basketball-statistic.d.ts +44 -0
  225. package/models/city.d.ts +7 -0
  226. package/models/file.d.ts +14 -0
  227. package/models/game-invite.d.ts +16 -0
  228. package/models/game-log-base.d.ts +10 -0
  229. package/models/game-statistic-base.d.ts +3 -0
  230. package/models/game-timeline-stages.d.ts +18 -0
  231. package/models/game-user.d.ts +12 -0
  232. package/models/game.d.ts +56 -0
  233. package/models/league-court.d.ts +9 -0
  234. package/models/league.d.ts +25 -0
  235. package/models/media-item.d.ts +15 -0
  236. package/models/notification-settings.d.ts +15 -0
  237. package/models/notification.d.ts +98 -0
  238. package/models/organization.d.ts +9 -0
  239. package/models/playoff.d.ts +25 -0
  240. package/models/poll.d.ts +46 -0
  241. package/models/public-api.d.ts +50 -0
  242. package/models/sport.d.ts +19 -0
  243. package/models/team-event-invite.d.ts +12 -0
  244. package/models/team-event-type.d.ts +4 -0
  245. package/models/team-event.d.ts +17 -0
  246. package/models/team-invite-external.d.ts +10 -0
  247. package/models/team-invite.d.ts +20 -0
  248. package/models/team-user.d.ts +18 -0
  249. package/models/team.d.ts +21 -0
  250. package/models/tournament-disqualification.d.ts +10 -0
  251. package/models/tournament-event.d.ts +16 -0
  252. package/models/tournament-group.d.ts +10 -0
  253. package/models/tournament-invite.d.ts +17 -0
  254. package/models/tournament-join-team.d.ts +19 -0
  255. package/models/tournament-news.d.ts +13 -0
  256. package/models/tournament-stage-team.d.ts +21 -0
  257. package/models/tournament-stage.d.ts +15 -0
  258. package/models/tournament-team-user-invite.d.ts +11 -0
  259. package/models/tournament-team-user.d.ts +22 -0
  260. package/models/tournament-team.d.ts +28 -0
  261. package/models/tournament.d.ts +87 -0
  262. package/models/user-profile.d.ts +8 -0
  263. package/models/user.d.ts +33 -0
  264. package/models/util.d.ts +49 -0
  265. package/models/volleyball-game-config.d.ts +17 -0
  266. package/models/volleyball-game-log.d.ts +54 -0
  267. package/models/volleyball-game-statistic.d.ts +28 -0
  268. package/models/volleyball-game-team-statistic.d.ts +8 -0
  269. package/models/volleyball-profile.d.ts +20 -0
  270. package/models/volleyball-statistic.d.ts +43 -0
  271. package/mtgame-core.d.ts +4 -0
  272. package/mtgame-core.metadata.json +1 -0
  273. package/package.json +23 -0
  274. package/public-api.d.ts +7 -0
  275. package/services/base.service.d.ts +5 -0
  276. package/services/centrifugo.service.d.ts +20 -0
  277. package/services/config.service.d.ts +11 -0
  278. package/services/public-api.d.ts +3 -0
  279. package/storage/local-storage-engine.d.ts +6 -0
  280. package/storage/public-api.d.ts +3 -0
  281. package/storage/storage-engine.d.ts +24 -0
  282. package/storage/store.d.ts +21 -0
  283. package/utils/array.d.ts +2 -0
  284. package/utils/component-destroyed.d.ts +7 -0
  285. package/utils/cookie.d.ts +1 -0
  286. package/utils/data.d.ts +6 -0
  287. package/utils/device.d.ts +1 -0
  288. package/utils/enum.d.ts +1 -0
  289. package/utils/errors.d.ts +1 -0
  290. package/utils/favicon.d.ts +9 -0
  291. package/utils/form.d.ts +2 -0
  292. package/utils/public-api.d.ts +10 -0
  293. package/utils/validators.d.ts +25 -0
@@ -0,0 +1,3749 @@
1
+ import { __decorate, __param, __awaiter } from 'tslib';
2
+ import { ɵɵdefineInjectable, Injectable, Optional, Inject, ɵɵinject, Injector, PLATFORM_ID } from '@angular/core';
3
+ import { HttpClient, HttpParams } from '@angular/common/http';
4
+ import { filter, map, delay, switchMap } from 'rxjs/operators';
5
+ import { BehaviorSubject, Observable, of } from 'rxjs';
6
+ import { Subject } from 'rxjs/internal/Subject';
7
+ import { ReplaySubject } from 'rxjs/internal/ReplaySubject';
8
+ import * as Centrifuge from 'centrifuge';
9
+ import { captureException } from '@sentry/browser';
10
+ import { FormGroup } from '@angular/forms';
11
+ import { isPlatformBrowser } from '@angular/common';
12
+
13
+ const MODEL_MAPPING_FIELDS_KEY = '_mapping_fields_';
14
+ const MODEL_RELATION_KEY = '_relation_';
15
+ const MODEL_TO_FRONT_KEY = '_to_front_';
16
+ const MODEL_TO_BACK_KEY = '_to_back_';
17
+ class BaseModel {
18
+ constructor(data) {
19
+ if (data) {
20
+ for (const key of Object.keys(data)) {
21
+ this[key] = data[key];
22
+ }
23
+ }
24
+ }
25
+ static toFront(dto) {
26
+ return undefined;
27
+ }
28
+ static toBack(dto) {
29
+ return undefined;
30
+ }
31
+ }
32
+ function enumField(enumClass) {
33
+ return {
34
+ toFront: (value) => {
35
+ if (isNaN(+value)) {
36
+ return enumClass[value];
37
+ }
38
+ else {
39
+ return value;
40
+ }
41
+ },
42
+ toBack: (value) => {
43
+ if (isNaN(+value)) {
44
+ return value;
45
+ }
46
+ else {
47
+ return enumClass[value];
48
+ }
49
+ }
50
+ };
51
+ }
52
+ function listField(modelClass) {
53
+ return {
54
+ toFront: (value) => {
55
+ if (!Array.isArray(value)) {
56
+ return [];
57
+ }
58
+ return modelClass.toFront(value);
59
+ },
60
+ toBack: (value) => {
61
+ if (!Array.isArray(value)) {
62
+ return [];
63
+ }
64
+ return modelClass.toBack(value);
65
+ }
66
+ };
67
+ }
68
+ class DateField extends BaseModel {
69
+ static toFront(date) {
70
+ if (date) {
71
+ return new Date(date);
72
+ }
73
+ else {
74
+ return undefined;
75
+ }
76
+ }
77
+ static toBack(date) {
78
+ if (date) {
79
+ const dateUtc = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
80
+ return dateUtc.toISOString().slice(0, 10);
81
+ }
82
+ else {
83
+ return undefined;
84
+ }
85
+ }
86
+ }
87
+ class DateTimeField extends BaseModel {
88
+ static toFront(date) {
89
+ if (date) {
90
+ return new Date(date);
91
+ }
92
+ else {
93
+ return undefined;
94
+ }
95
+ }
96
+ static toBack(date) {
97
+ if (date) {
98
+ const dateUtc = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
99
+ return date.toISOString();
100
+ }
101
+ else {
102
+ return undefined;
103
+ }
104
+ }
105
+ }
106
+ function ModelInstance(config) {
107
+ return (target) => {
108
+ if (config) {
109
+ if (config.mappingFields) {
110
+ target[MODEL_MAPPING_FIELDS_KEY] = config.mappingFields;
111
+ }
112
+ if (config.relation) {
113
+ target[MODEL_RELATION_KEY] = config.relation;
114
+ }
115
+ target[MODEL_TO_FRONT_KEY] = (dto, path) => {
116
+ return toFront(target, dto, path);
117
+ };
118
+ target[MODEL_TO_BACK_KEY] = (dto, path) => {
119
+ return toBack(target, dto, path);
120
+ };
121
+ }
122
+ };
123
+ }
124
+ const ToFrontHook = (target, key, descriptor) => {
125
+ return {
126
+ value: (...args) => {
127
+ const parseMethod = target[MODEL_TO_FRONT_KEY];
128
+ if (parseMethod) {
129
+ return parseMethod(args[0], (args.length > 1 ? args[1] : undefined));
130
+ }
131
+ return undefined;
132
+ }
133
+ };
134
+ };
135
+ const ToBackHook = (target, key, descriptor) => {
136
+ return {
137
+ value: (...args) => {
138
+ const parseMethod = target[MODEL_TO_BACK_KEY];
139
+ if (parseMethod) {
140
+ return parseMethod(args[0]);
141
+ }
142
+ return undefined;
143
+ }
144
+ };
145
+ };
146
+ function extractValue(key, data) {
147
+ if (!data) {
148
+ return undefined;
149
+ }
150
+ const keyParts = key.split('.');
151
+ if (keyParts.length === 1) {
152
+ if (key in data) {
153
+ return data[key];
154
+ }
155
+ else {
156
+ return undefined;
157
+ }
158
+ }
159
+ for (const k of keyParts) {
160
+ if (data && k in data) {
161
+ data = data[k];
162
+ }
163
+ else {
164
+ return undefined;
165
+ }
166
+ }
167
+ return data;
168
+ }
169
+ function toFront(modelType, data, path) {
170
+ // Check if recursion is required
171
+ if (Array.isArray(data)) {
172
+ return data.map(item => {
173
+ return toFront(modelType, item);
174
+ });
175
+ }
176
+ const instance = new modelType();
177
+ // Mapping fields
178
+ const mappingFields = modelType[MODEL_MAPPING_FIELDS_KEY];
179
+ const relation = modelType[MODEL_RELATION_KEY];
180
+ if (mappingFields) {
181
+ for (const backField of Object.keys(mappingFields)) {
182
+ const frontField = mappingFields[backField];
183
+ const value = extractValue(backField, data);
184
+ if (relation && relation.hasOwnProperty(frontField)) {
185
+ instance[frontField] = relation[frontField].toFront(value);
186
+ }
187
+ else {
188
+ instance[frontField] = value;
189
+ }
190
+ }
191
+ }
192
+ return instance;
193
+ }
194
+ function toBack(modelType, instance, path) {
195
+ if (!instance) {
196
+ return instance;
197
+ }
198
+ // Check if recursion is required
199
+ if (Array.isArray(instance)) {
200
+ return instance.map(item => {
201
+ return toBack(modelType, item);
202
+ });
203
+ }
204
+ const data = {};
205
+ const mappingFields = modelType[MODEL_MAPPING_FIELDS_KEY];
206
+ const relation = modelType[MODEL_RELATION_KEY];
207
+ if (mappingFields) {
208
+ for (const backField of Object.keys(mappingFields)) {
209
+ const frontField = mappingFields[backField];
210
+ if (relation && relation.hasOwnProperty(frontField) && instance[frontField] !== undefined) {
211
+ data[backField] = relation[frontField].toBack(instance[frontField]);
212
+ }
213
+ else {
214
+ data[backField] = instance[frontField];
215
+ }
216
+ }
217
+ }
218
+ return data;
219
+ }
220
+
221
+ var FileEngine;
222
+ (function (FileEngine) {
223
+ FileEngine[FileEngine["django"] = 1] = "django";
224
+ FileEngine[FileEngine["s3"] = 2] = "s3";
225
+ })(FileEngine || (FileEngine = {}));
226
+ let File = class File {
227
+ static toFront(data) {
228
+ return null;
229
+ }
230
+ static toBack(file) {
231
+ return null;
232
+ }
233
+ };
234
+ __decorate([
235
+ ToFrontHook
236
+ ], File, "toFront", null);
237
+ __decorate([
238
+ ToBackHook
239
+ ], File, "toBack", null);
240
+ File = __decorate([
241
+ ModelInstance({
242
+ mappingFields: {
243
+ id: 'id',
244
+ name: 'name',
245
+ path: 'path',
246
+ mime_type: 'mimeType',
247
+ size: 'size',
248
+ engine: 'engine',
249
+ },
250
+ relation: {
251
+ engine: enumField(FileEngine)
252
+ }
253
+ })
254
+ ], File);
255
+
256
+ var SportTypes;
257
+ (function (SportTypes) {
258
+ SportTypes[SportTypes["basketball"] = 1] = "basketball";
259
+ SportTypes[SportTypes["volleyball"] = 2] = "volleyball";
260
+ SportTypes[SportTypes["classic_basketball"] = 3] = "classic_basketball";
261
+ SportTypes[SportTypes["streetball"] = 4] = "streetball";
262
+ })(SportTypes || (SportTypes = {}));
263
+ let Sport = class Sport extends BaseModel {
264
+ isBasketball() {
265
+ return this.id === SportTypes.basketball || this.parentId === SportTypes.basketball;
266
+ }
267
+ isClassicBasketball() {
268
+ return this.id === SportTypes.classic_basketball;
269
+ }
270
+ isVolleyball() {
271
+ return this.id === SportTypes.volleyball || this.parentId === SportTypes.volleyball;
272
+ }
273
+ isStreetball() {
274
+ return this.id === SportTypes.streetball;
275
+ }
276
+ static toFront(data) {
277
+ return null;
278
+ }
279
+ static toBack(sport) {
280
+ return null;
281
+ }
282
+ };
283
+ __decorate([
284
+ ToFrontHook
285
+ ], Sport, "toFront", null);
286
+ __decorate([
287
+ ToBackHook
288
+ ], Sport, "toBack", null);
289
+ Sport = __decorate([
290
+ ModelInstance({
291
+ mappingFields: {
292
+ id: 'id',
293
+ name: 'name',
294
+ parent_id: 'parentId',
295
+ sub_sports: 'subSports'
296
+ }
297
+ })
298
+ ], Sport);
299
+
300
+ let UserProfile = class UserProfile {
301
+ static toFront(value) { }
302
+ static toBack(value) { }
303
+ };
304
+ __decorate([
305
+ ToFrontHook
306
+ ], UserProfile, "toFront", null);
307
+ __decorate([
308
+ ToBackHook
309
+ ], UserProfile, "toBack", null);
310
+ UserProfile = __decorate([
311
+ ModelInstance({
312
+ mappingFields: {
313
+ id: 'id',
314
+ user_id: 'userId',
315
+ height: 'height',
316
+ weight: 'weight'
317
+ }
318
+ })
319
+ ], UserProfile);
320
+
321
+ let City = class City extends BaseModel {
322
+ static toFront(value) { }
323
+ static toBack(value) { }
324
+ };
325
+ __decorate([
326
+ ToFrontHook
327
+ ], City, "toFront", null);
328
+ __decorate([
329
+ ToBackHook
330
+ ], City, "toBack", null);
331
+ City = __decorate([
332
+ ModelInstance({
333
+ mappingFields: {
334
+ id: 'id',
335
+ name: 'name'
336
+ }
337
+ })
338
+ ], City);
339
+
340
+ var GameBasketballPosition;
341
+ (function (GameBasketballPosition) {
342
+ GameBasketballPosition[GameBasketballPosition["point_guard"] = 1] = "point_guard";
343
+ GameBasketballPosition[GameBasketballPosition["shooting_guard"] = 2] = "shooting_guard";
344
+ GameBasketballPosition[GameBasketballPosition["small_forward"] = 3] = "small_forward";
345
+ GameBasketballPosition[GameBasketballPosition["power_forward"] = 4] = "power_forward";
346
+ GameBasketballPosition[GameBasketballPosition["center"] = 5] = "center";
347
+ })(GameBasketballPosition || (GameBasketballPosition = {}));
348
+ var WorkHand;
349
+ (function (WorkHand) {
350
+ WorkHand[WorkHand["left"] = 1] = "left";
351
+ WorkHand[WorkHand["right"] = 2] = "right";
352
+ })(WorkHand || (WorkHand = {}));
353
+ let BasketballProfile = class BasketballProfile extends BaseModel {
354
+ static toFront(value) {
355
+ }
356
+ static toBack(value) {
357
+ }
358
+ };
359
+ __decorate([
360
+ ToFrontHook
361
+ ], BasketballProfile, "toFront", null);
362
+ __decorate([
363
+ ToBackHook
364
+ ], BasketballProfile, "toBack", null);
365
+ BasketballProfile = __decorate([
366
+ ModelInstance({
367
+ mappingFields: {
368
+ id: 'id',
369
+ user_id: 'userId',
370
+ position: 'position',
371
+ work_hand: 'workHand'
372
+ },
373
+ relation: {
374
+ position: enumField(GameBasketballPosition),
375
+ workHand: enumField(WorkHand)
376
+ }
377
+ })
378
+ ], BasketballProfile);
379
+
380
+ var GameVolleyballPosition;
381
+ (function (GameVolleyballPosition) {
382
+ GameVolleyballPosition[GameVolleyballPosition["setter"] = 1] = "setter";
383
+ GameVolleyballPosition[GameVolleyballPosition["libero"] = 2] = "libero";
384
+ GameVolleyballPosition[GameVolleyballPosition["middle_player"] = 3] = "middle_player";
385
+ GameVolleyballPosition[GameVolleyballPosition["receiver_attacker"] = 4] = "receiver_attacker";
386
+ GameVolleyballPosition[GameVolleyballPosition["dioganal"] = 5] = "dioganal";
387
+ })(GameVolleyballPosition || (GameVolleyballPosition = {}));
388
+ var VolleyballWorkHand;
389
+ (function (VolleyballWorkHand) {
390
+ VolleyballWorkHand[VolleyballWorkHand["left"] = 1] = "left";
391
+ VolleyballWorkHand[VolleyballWorkHand["right"] = 2] = "right";
392
+ })(VolleyballWorkHand || (VolleyballWorkHand = {}));
393
+ let VolleyballProfile = class VolleyballProfile extends BaseModel {
394
+ static toFront(value) {
395
+ }
396
+ static toBack(value) {
397
+ }
398
+ };
399
+ __decorate([
400
+ ToFrontHook
401
+ ], VolleyballProfile, "toFront", null);
402
+ __decorate([
403
+ ToBackHook
404
+ ], VolleyballProfile, "toBack", null);
405
+ VolleyballProfile = __decorate([
406
+ ModelInstance({
407
+ mappingFields: {
408
+ id: 'id',
409
+ user_id: 'userId',
410
+ position: 'position',
411
+ work_hand: 'workHand'
412
+ },
413
+ relation: {
414
+ position: enumField(GameVolleyballPosition),
415
+ workHand: enumField(VolleyballWorkHand)
416
+ }
417
+ })
418
+ ], VolleyballProfile);
419
+
420
+ var UserGender;
421
+ (function (UserGender) {
422
+ UserGender[UserGender["male"] = 1] = "male";
423
+ UserGender[UserGender["female"] = 2] = "female";
424
+ })(UserGender || (UserGender = {}));
425
+ let User = class User extends BaseModel {
426
+ static toFront(data) {
427
+ return null;
428
+ }
429
+ static toBack(user) {
430
+ return null;
431
+ }
432
+ get fullName() {
433
+ return [this.lastName, this.firstName].filter(s => s).join(' ');
434
+ }
435
+ get shortName() {
436
+ return [this.lastName, this.firstName].filter(s => s).join(' ');
437
+ }
438
+ get initials() {
439
+ return [this.lastName, this.firstName].filter(s => s).map(s => s.substr(0, 1)).join('');
440
+ }
441
+ get age() {
442
+ if (!this.birthDate) {
443
+ return null;
444
+ }
445
+ const diff = (new Date()).getTime() - this.birthDate.getTime();
446
+ return Math.floor(diff / (365 * 86400 * 1000));
447
+ }
448
+ };
449
+ __decorate([
450
+ ToFrontHook
451
+ ], User, "toFront", null);
452
+ __decorate([
453
+ ToBackHook
454
+ ], User, "toBack", null);
455
+ User = __decorate([
456
+ ModelInstance({
457
+ mappingFields: {
458
+ id: 'id',
459
+ last_name: 'lastName',
460
+ first_name: 'firstName',
461
+ middle_name: 'middleName',
462
+ email: 'email',
463
+ phone: 'phone',
464
+ birth_date: 'birthDate',
465
+ photo: 'photo',
466
+ profile: 'profile',
467
+ basketball_profile: 'basketballProfile',
468
+ volleyball_profile: 'volleyballProfile',
469
+ wizards: 'wizards',
470
+ city: 'city',
471
+ gender: 'gender',
472
+ is_active: 'isActive',
473
+ },
474
+ relation: {
475
+ birthDate: DateField,
476
+ photo: File,
477
+ profile: UserProfile,
478
+ basketballProfile: BasketballProfile,
479
+ volleyballProfile: VolleyballProfile,
480
+ city: City,
481
+ gender: enumField(UserGender)
482
+ }
483
+ })
484
+ ], User);
485
+
486
+ let Team = class Team extends BaseModel {
487
+ getEmptyLogoClass() {
488
+ const classList = ['empty-logo'];
489
+ if (this.sport.isBasketball()) {
490
+ classList.push('empty-logo-basketball');
491
+ }
492
+ if (this.sport.isVolleyball()) {
493
+ classList.push('empty-logo-volleyball');
494
+ }
495
+ return classList.join(' ');
496
+ }
497
+ static toFront(data) {
498
+ return null;
499
+ }
500
+ static toBack(team) {
501
+ return null;
502
+ }
503
+ };
504
+ __decorate([
505
+ ToFrontHook
506
+ ], Team, "toFront", null);
507
+ __decorate([
508
+ ToBackHook
509
+ ], Team, "toBack", null);
510
+ Team = __decorate([
511
+ ModelInstance({
512
+ mappingFields: {
513
+ id: 'id',
514
+ name: 'name',
515
+ sport: 'sport',
516
+ logo: 'logo',
517
+ owner: 'owner',
518
+ city: 'city',
519
+ users_count: 'usersCount',
520
+ won_games_count: 'wonGamesCount',
521
+ games_count: 'gamesCount',
522
+ score_sum: 'scoreSum',
523
+ closest_game_datetime: 'closestGameDatetime',
524
+ },
525
+ relation: {
526
+ sport: Sport,
527
+ logo: File,
528
+ owner: User,
529
+ city: City,
530
+ closestGameDatetime: DateField,
531
+ }
532
+ })
533
+ ], Team);
534
+
535
+ let Organization = class Organization extends BaseModel {
536
+ static toFront(data) { }
537
+ static toBack(data) { }
538
+ };
539
+ __decorate([
540
+ ToFrontHook
541
+ ], Organization, "toFront", null);
542
+ __decorate([
543
+ ToBackHook
544
+ ], Organization, "toBack", null);
545
+ Organization = __decorate([
546
+ ModelInstance({
547
+ mappingFields: {
548
+ id: 'id',
549
+ owner_id: 'ownerId',
550
+ owner: 'owner',
551
+ },
552
+ relation: {
553
+ owner: User,
554
+ }
555
+ })
556
+ ], Organization);
557
+
558
+ let League = class League extends BaseModel {
559
+ static toFront(data) { }
560
+ static toBack(data) { }
561
+ get vkLink() {
562
+ return this.socialLinks.find(link => link.substr(0, 15) === 'https://vk.com/');
563
+ }
564
+ get fbLink() {
565
+ return this.socialLinks.find(link => link.substr(0, 25) === 'https://www.facebook.com/');
566
+ }
567
+ get instaLink() {
568
+ return this.socialLinks.find(link => link.substr(0, 25) === 'https://www.instagram.com');
569
+ }
570
+ };
571
+ __decorate([
572
+ ToFrontHook
573
+ ], League, "toFront", null);
574
+ __decorate([
575
+ ToBackHook
576
+ ], League, "toBack", null);
577
+ League = __decorate([
578
+ ModelInstance({
579
+ mappingFields: {
580
+ id: 'id',
581
+ logo: 'logo',
582
+ contact_email: 'contactEmail',
583
+ contact_phone: 'contactPhone',
584
+ name: 'name',
585
+ alias: 'alias',
586
+ sport: 'sport',
587
+ description: 'description',
588
+ social_links: 'socialLinks',
589
+ links: 'links',
590
+ organization: 'organization',
591
+ tournaments_count: 'tournamentsCount',
592
+ closest_game_datetime: 'closestGameDatetime',
593
+ cover: 'cover',
594
+ },
595
+ relation: {
596
+ organization: Organization,
597
+ logo: File,
598
+ cover: File,
599
+ sport: Sport
600
+ }
601
+ })
602
+ ], League);
603
+
604
+ var TournamentTypes;
605
+ (function (TournamentTypes) {
606
+ TournamentTypes["group"] = "group";
607
+ TournamentTypes["elimination"] = "elimination";
608
+ TournamentTypes["fiba"] = "fiba";
609
+ })(TournamentTypes || (TournamentTypes = {}));
610
+ var TournamentStatuses;
611
+ (function (TournamentStatuses) {
612
+ TournamentStatuses[TournamentStatuses["open"] = 0] = "open";
613
+ TournamentStatuses[TournamentStatuses["in_progress"] = 1] = "in_progress";
614
+ TournamentStatuses[TournamentStatuses["closed"] = 2] = "closed";
615
+ })(TournamentStatuses || (TournamentStatuses = {}));
616
+ var TournamentGender;
617
+ (function (TournamentGender) {
618
+ TournamentGender[TournamentGender["male"] = 1] = "male";
619
+ TournamentGender[TournamentGender["female"] = 2] = "female";
620
+ TournamentGender[TournamentGender["all"] = 3] = "all";
621
+ })(TournamentGender || (TournamentGender = {}));
622
+ var BasketballStatisticTypes;
623
+ (function (BasketballStatisticTypes) {
624
+ BasketballStatisticTypes[BasketballStatisticTypes["standard"] = 1] = "standard";
625
+ BasketballStatisticTypes[BasketballStatisticTypes["light"] = 2] = "light";
626
+ BasketballStatisticTypes[BasketballStatisticTypes["extended"] = 3] = "extended";
627
+ })(BasketballStatisticTypes || (BasketballStatisticTypes = {}));
628
+ let TournamentSettings = class TournamentSettings extends BaseModel {
629
+ static toFront(data) { }
630
+ static toBack(data) { }
631
+ };
632
+ __decorate([
633
+ ToFrontHook
634
+ ], TournamentSettings, "toFront", null);
635
+ __decorate([
636
+ ToBackHook
637
+ ], TournamentSettings, "toBack", null);
638
+ TournamentSettings = __decorate([
639
+ ModelInstance({
640
+ mappingFields: {
641
+ id: 'id',
642
+ gender: 'gender',
643
+ age_from: 'ageFrom',
644
+ age_to: 'ageTo',
645
+ max_team_players: 'maxTeamPlayers',
646
+ max_game_players: 'maxGamePlayers',
647
+ type: 'type',
648
+ tours_count: 'toursCount',
649
+ periods_count: 'periodsCount',
650
+ period_time: 'periodTime',
651
+ overtime_type: 'overtimeType',
652
+ overtime_time: 'overtimeTime',
653
+ overtime_score: 'overtimeScore',
654
+ game_type: 'gameType',
655
+ timeout_count: 'timeoutCount',
656
+ timeout_time: 'timeoutTime',
657
+ substitute_count: 'substituteCount',
658
+ game_up_to_score: 'gameUpToScore',
659
+ volleyball_score_in_set: 'volleyballScoreInSet',
660
+ volleyball_score_in_last_set: 'volleyballScoreInLastSet',
661
+ manage_team_application: 'manageTeamApplication',
662
+ recruitment_is_open: 'recruitmentIsOpen',
663
+ transfer_is_open: 'transferIsOpen',
664
+ basketball_statistic_type: 'basketballStatisticType',
665
+ },
666
+ relation: {
667
+ type: enumField(TournamentTypes),
668
+ gender: enumField(TournamentGender),
669
+ basketballStatisticType: enumField(BasketballStatisticTypes),
670
+ }
671
+ })
672
+ ], TournamentSettings);
673
+ let TournamentTeamWinner = class TournamentTeamWinner extends BaseModel {
674
+ static toFront(data) { }
675
+ static toBack(data) { }
676
+ };
677
+ __decorate([
678
+ ToFrontHook
679
+ ], TournamentTeamWinner, "toFront", null);
680
+ __decorate([
681
+ ToBackHook
682
+ ], TournamentTeamWinner, "toBack", null);
683
+ TournamentTeamWinner = __decorate([
684
+ ModelInstance({
685
+ mappingFields: {
686
+ id: 'id',
687
+ team_id: 'teamId',
688
+ tournament_id: 'tournamentId',
689
+ team: 'team',
690
+ points: 'points',
691
+ },
692
+ relation: {
693
+ team: Team,
694
+ }
695
+ })
696
+ ], TournamentTeamWinner);
697
+ let Tournament = class Tournament extends BaseModel {
698
+ getEmptyLogoClass() {
699
+ const classList = ['empty-logo'];
700
+ if (this.sport.isBasketball()) {
701
+ classList.push('empty-logo-basketball');
702
+ }
703
+ if (this.sport.isVolleyball()) {
704
+ classList.push('empty-logo-volleyball');
705
+ }
706
+ return classList.join(' ');
707
+ }
708
+ static toFront(data) { }
709
+ static toBack(data) { }
710
+ };
711
+ __decorate([
712
+ ToFrontHook
713
+ ], Tournament, "toFront", null);
714
+ __decorate([
715
+ ToBackHook
716
+ ], Tournament, "toBack", null);
717
+ Tournament = __decorate([
718
+ ModelInstance({
719
+ mappingFields: {
720
+ id: 'id',
721
+ name: 'name',
722
+ alias: 'alias',
723
+ logo: 'logo',
724
+ cover: 'cover',
725
+ preview_image: 'previewImage',
726
+ city: 'city',
727
+ sport: 'sport',
728
+ location: 'location',
729
+ description: 'description',
730
+ date: 'date',
731
+ price: 'price',
732
+ regulation_files: 'regulationFiles',
733
+ settings: 'settings',
734
+ league: 'league',
735
+ teams_count: 'teamsCount',
736
+ closest_game_datetime: 'closestGameDatetime',
737
+ status: 'status',
738
+ team_winner: 'teamWinner'
739
+ },
740
+ relation: {
741
+ logo: File,
742
+ cover: File,
743
+ city: City,
744
+ sport: Sport,
745
+ regulationFile: File,
746
+ settings: TournamentSettings,
747
+ date: DateTimeField,
748
+ league: League,
749
+ status: enumField(TournamentStatuses),
750
+ teamWinner: TournamentTeamWinner
751
+ }
752
+ })
753
+ ], Tournament);
754
+
755
+ var OvertimeTypes;
756
+ (function (OvertimeTypes) {
757
+ OvertimeTypes[OvertimeTypes["to_score_total"] = 0] = "to_score_total";
758
+ OvertimeTypes[OvertimeTypes["to_score_diff"] = 1] = "to_score_diff";
759
+ OvertimeTypes[OvertimeTypes["time"] = 2] = "time";
760
+ })(OvertimeTypes || (OvertimeTypes = {}));
761
+ let BasketballGameConfig = class BasketballGameConfig extends BaseModel {
762
+ static toFront(data) { }
763
+ static toBack(data) { }
764
+ };
765
+ __decorate([
766
+ ToFrontHook
767
+ ], BasketballGameConfig, "toFront", null);
768
+ __decorate([
769
+ ToBackHook
770
+ ], BasketballGameConfig, "toBack", null);
771
+ BasketballGameConfig = __decorate([
772
+ ModelInstance({
773
+ mappingFields: {
774
+ periods_count: 'periodsCount',
775
+ period_time: 'periodTime',
776
+ game_up_to_score: 'gameUpToScore',
777
+ overtime_type: 'overtimeType',
778
+ overtime_time: 'overtimeTime',
779
+ overtime_score: 'overtimeScore',
780
+ max_game_players: 'maxGamePlayers',
781
+ timeout_count: 'timeoutCount',
782
+ overtime_timeout_count: 'overtimeTimeoutCount',
783
+ timeout_time: 'timeoutTime',
784
+ statistic_type: 'statisticType',
785
+ },
786
+ relation: {
787
+ overtimeType: enumField(OvertimeTypes),
788
+ statisticType: enumField(BasketballStatisticTypes)
789
+ }
790
+ })
791
+ ], BasketballGameConfig);
792
+
793
+ var VolleyballGameTypes;
794
+ (function (VolleyballGameTypes) {
795
+ VolleyballGameTypes[VolleyballGameTypes["best_of_five"] = 1] = "best_of_five";
796
+ VolleyballGameTypes[VolleyballGameTypes["best_of_three"] = 2] = "best_of_three";
797
+ })(VolleyballGameTypes || (VolleyballGameTypes = {}));
798
+ let VolleyballGameConfig = class VolleyballGameConfig extends BaseModel {
799
+ get setsCount() {
800
+ return this.gameType === VolleyballGameTypes.best_of_three ? 3 : 5;
801
+ }
802
+ getSetMaxScore(set) {
803
+ return set === this.setsCount ? this.scoreInLastSet : this.scoreInSet;
804
+ }
805
+ static toFront(data) { }
806
+ static toBack(data) { }
807
+ };
808
+ __decorate([
809
+ ToFrontHook
810
+ ], VolleyballGameConfig, "toFront", null);
811
+ __decorate([
812
+ ToBackHook
813
+ ], VolleyballGameConfig, "toBack", null);
814
+ VolleyballGameConfig = __decorate([
815
+ ModelInstance({
816
+ mappingFields: {
817
+ game_type: 'gameType',
818
+ timeout_count: 'timeoutCount',
819
+ timeout_time: 'timeoutTime',
820
+ substitute_count: 'substituteCount',
821
+ score_in_set: 'scoreInSet',
822
+ score_in_last_set: 'scoreInLastSet'
823
+ },
824
+ relation: {
825
+ gameType: enumField(VolleyballGameTypes)
826
+ }
827
+ })
828
+ ], VolleyballGameConfig);
829
+
830
+ let LeagueCourt = class LeagueCourt extends BaseModel {
831
+ static toFront(data) { }
832
+ static toBack(data) { }
833
+ };
834
+ __decorate([
835
+ ToFrontHook
836
+ ], LeagueCourt, "toFront", null);
837
+ __decorate([
838
+ ToBackHook
839
+ ], LeagueCourt, "toBack", null);
840
+ LeagueCourt = __decorate([
841
+ ModelInstance({
842
+ mappingFields: {
843
+ id: 'id',
844
+ name: 'name',
845
+ address: 'address',
846
+ league_id: 'leagueId'
847
+ }
848
+ })
849
+ ], LeagueCourt);
850
+
851
+ let MediaItem = class MediaItem extends BaseModel {
852
+ get isVideo() {
853
+ return Boolean(this.videoUrl);
854
+ }
855
+ static toFront(data) { }
856
+ static toBack(data) { }
857
+ };
858
+ __decorate([
859
+ ToFrontHook
860
+ ], MediaItem, "toFront", null);
861
+ __decorate([
862
+ ToBackHook
863
+ ], MediaItem, "toBack", null);
864
+ MediaItem = __decorate([
865
+ ModelInstance({
866
+ mappingFields: {
867
+ id: 'id',
868
+ original_photo: 'originalPhoto',
869
+ list_photo: 'listPhoto',
870
+ detail_photo: 'detailPhoto',
871
+ game: 'game',
872
+ tournament: 'tournament',
873
+ game_id: 'gameId',
874
+ tournament_id: 'tournament_id',
875
+ video_url: 'videoUrl',
876
+ video_preview: 'videoPreview',
877
+ },
878
+ relation: {
879
+ originalPhoto: File,
880
+ listPhoto: File,
881
+ detailPhoto: File,
882
+ videoPreview: File
883
+ }
884
+ })
885
+ ], MediaItem);
886
+
887
+ var GameStatuses;
888
+ (function (GameStatuses) {
889
+ GameStatuses[GameStatuses["open"] = 1] = "open";
890
+ GameStatuses[GameStatuses["in_progress"] = 2] = "in_progress";
891
+ GameStatuses[GameStatuses["closed"] = 3] = "closed";
892
+ GameStatuses[GameStatuses["archived"] = 4] = "archived";
893
+ GameStatuses[GameStatuses["draft"] = 5] = "draft";
894
+ })(GameStatuses || (GameStatuses = {}));
895
+ var GameResultTypes;
896
+ (function (GameResultTypes) {
897
+ GameResultTypes[GameResultTypes["team_won"] = 1] = "team_won";
898
+ GameResultTypes[GameResultTypes["competitor_team_won"] = 2] = "competitor_team_won";
899
+ GameResultTypes[GameResultTypes["team_technical_defeat"] = 3] = "team_technical_defeat";
900
+ GameResultTypes[GameResultTypes["competitor_team_technical_defeat"] = 4] = "competitor_team_technical_defeat";
901
+ })(GameResultTypes || (GameResultTypes = {}));
902
+ let Game = class Game extends BaseModel {
903
+ get scoreByPeriodList() {
904
+ if (!this.scoreByPeriod) {
905
+ return [];
906
+ }
907
+ return Object.keys(this.scoreByPeriod).map(period => ({
908
+ period: +period,
909
+ teamScore: this.scoreByPeriod[period][0],
910
+ competitorTeamScore: this.scoreByPeriod[period][1]
911
+ }));
912
+ }
913
+ get isClosed() {
914
+ return this.status === GameStatuses.closed;
915
+ }
916
+ get isTeamWon() {
917
+ return this.teamScore > this.competitorTeamScore;
918
+ }
919
+ get isCompetitorTeamWon() {
920
+ return this.competitorTeamScore > this.teamScore;
921
+ }
922
+ get teamWinnerId() {
923
+ if (this.status !== GameStatuses.closed) {
924
+ return null;
925
+ }
926
+ if (this.teamScore === this.competitorTeamScore) {
927
+ return null;
928
+ }
929
+ if (this.team.id) {
930
+ return this.teamScore > this.competitorTeamScore ? this.team.id : this.competitorTeam.id;
931
+ }
932
+ else {
933
+ return this.teamScore > this.competitorTeamScore ? this.teamId : this.competitorTeamId;
934
+ }
935
+ }
936
+ static toFront(data) { }
937
+ static toBack(data) { }
938
+ };
939
+ __decorate([
940
+ ToFrontHook
941
+ ], Game, "toFront", null);
942
+ __decorate([
943
+ ToBackHook
944
+ ], Game, "toBack", null);
945
+ Game = __decorate([
946
+ ModelInstance({
947
+ mappingFields: {
948
+ id: 'id',
949
+ status: 'status',
950
+ team: 'team',
951
+ team_id: 'teamId',
952
+ competitor_team: 'competitorTeam',
953
+ competitor_team_id: 'competitorTeamId',
954
+ competitor_team_name: 'competitorTeamName',
955
+ datetime: 'datetime',
956
+ location: 'location',
957
+ team_score: 'teamScore',
958
+ competitor_team_score: 'competitorTeamScore',
959
+ result_type: 'resultType',
960
+ playoff_number: 'playoffNumber',
961
+ tournament_id: 'tournamentId',
962
+ tournament_tour: 'tournamentTour',
963
+ basketball_game_config: 'basketballGameConfig',
964
+ volleyball_game_config: 'volleyballGameConfig',
965
+ score_by_period: 'scoreByPeriod',
966
+ playoff_stage: 'playoffStage',
967
+ tournament_stage_id: 'tournamentStageId',
968
+ tournament_playoff_id: 'tournamentPlayoffId',
969
+ tournament_court: 'tournamentCourt',
970
+ media_count: 'mediaCount',
971
+ media: 'media',
972
+ },
973
+ relation: {
974
+ status: enumField(GameStatuses),
975
+ team: Team,
976
+ competitorTeam: Team,
977
+ datetime: DateTimeField,
978
+ resultType: enumField(GameResultTypes),
979
+ basketballGameConfig: BasketballGameConfig,
980
+ volleyballGameConfig: VolleyballGameConfig,
981
+ tournamentCourt: LeagueCourt,
982
+ media: listField(MediaItem),
983
+ }
984
+ })
985
+ ], Game);
986
+
987
+ var TeamUserRole;
988
+ (function (TeamUserRole) {
989
+ TeamUserRole[TeamUserRole["member"] = 1] = "member";
990
+ TeamUserRole[TeamUserRole["moderator"] = 2] = "moderator";
991
+ TeamUserRole[TeamUserRole["admin"] = 3] = "admin";
992
+ })(TeamUserRole || (TeamUserRole = {}));
993
+ let TeamUser = class TeamUser extends BaseModel {
994
+ static toFront(data) { }
995
+ static toBack(teamPlayer) { }
996
+ };
997
+ __decorate([
998
+ ToFrontHook
999
+ ], TeamUser, "toFront", null);
1000
+ __decorate([
1001
+ ToBackHook
1002
+ ], TeamUser, "toBack", null);
1003
+ TeamUser = __decorate([
1004
+ ModelInstance({
1005
+ mappingFields: {
1006
+ id: 'id',
1007
+ team_id: 'teamId',
1008
+ user: 'user',
1009
+ role: 'role',
1010
+ number: 'number',
1011
+ team: 'team',
1012
+ },
1013
+ relation: {
1014
+ user: User,
1015
+ team: Team,
1016
+ role: enumField(TeamUserRole)
1017
+ }
1018
+ })
1019
+ ], TeamUser);
1020
+
1021
+ let TournamentGroup = class TournamentGroup extends BaseModel {
1022
+ static toFront(data) { }
1023
+ static toBack(data) { }
1024
+ };
1025
+ __decorate([
1026
+ ToFrontHook
1027
+ ], TournamentGroup, "toFront", null);
1028
+ __decorate([
1029
+ ToBackHook
1030
+ ], TournamentGroup, "toBack", null);
1031
+ TournamentGroup = __decorate([
1032
+ ModelInstance({
1033
+ mappingFields: {
1034
+ id: 'id',
1035
+ name: 'name',
1036
+ tournament_stage_id: 'tournamentStageId'
1037
+ }
1038
+ })
1039
+ ], TournamentGroup);
1040
+
1041
+ let TournamentTeam = class TournamentTeam extends BaseModel {
1042
+ get gamesWonPercent() {
1043
+ if (!this.gamesCount) {
1044
+ return 0;
1045
+ }
1046
+ return Math.floor(1000 * this.wonGamesCount / this.gamesCount) / 10;
1047
+ }
1048
+ static toFront(data) { }
1049
+ static toBack(data) { }
1050
+ };
1051
+ __decorate([
1052
+ ToFrontHook
1053
+ ], TournamentTeam, "toFront", null);
1054
+ __decorate([
1055
+ ToBackHook
1056
+ ], TournamentTeam, "toBack", null);
1057
+ TournamentTeam = __decorate([
1058
+ ModelInstance({
1059
+ mappingFields: {
1060
+ id: 'id',
1061
+ team_id: 'teamId',
1062
+ tournament_id: 'tournamentId',
1063
+ tournament: 'tournament',
1064
+ team: 'team',
1065
+ group: 'group',
1066
+ games_count: 'gamesCount',
1067
+ won_games_count: 'wonGamesCount',
1068
+ last_games_count: 'lastGamesCount',
1069
+ last_games_won: 'lastGamesWon',
1070
+ score_sum: 'scoreSum',
1071
+ missed_sum: 'missedSum',
1072
+ score_points_sum: 'scorePointsSum',
1073
+ missed_points_sum: 'missedPointsSum',
1074
+ points: 'points',
1075
+ users_count: 'usersCount',
1076
+ games: 'games',
1077
+ notifications_count: 'notificationsCount',
1078
+ },
1079
+ relation: {
1080
+ tournament: Tournament,
1081
+ team: Team,
1082
+ group: TournamentGroup,
1083
+ games: Game,
1084
+ }
1085
+ })
1086
+ ], TournamentTeam);
1087
+
1088
+ let TournamentDisqualification = class TournamentDisqualification extends BaseModel {
1089
+ static toFront(data) { }
1090
+ static toBack(data) { }
1091
+ };
1092
+ __decorate([
1093
+ ToFrontHook
1094
+ ], TournamentDisqualification, "toFront", null);
1095
+ __decorate([
1096
+ ToBackHook
1097
+ ], TournamentDisqualification, "toBack", null);
1098
+ TournamentDisqualification = __decorate([
1099
+ ModelInstance({
1100
+ mappingFields: {
1101
+ id: 'id',
1102
+ tournament_team_user_id: 'tournamentTeamUserId',
1103
+ date_from: 'dateFrom',
1104
+ date_to: 'dateTo',
1105
+ matches_count: 'matchesCount',
1106
+ },
1107
+ relation: {
1108
+ dateFrom: DateField,
1109
+ dateTo: DateField,
1110
+ }
1111
+ })
1112
+ ], TournamentDisqualification);
1113
+
1114
+ let TournamentTeamUser = class TournamentTeamUser extends BaseModel {
1115
+ get fullName() {
1116
+ return [this.lastName, this.firstName, this.middleName].filter(s => s).join(' ');
1117
+ }
1118
+ get shortName() {
1119
+ return [this.lastName, this.firstName].filter(s => s).join(' ');
1120
+ }
1121
+ get initials() {
1122
+ return [this.lastName, this.firstName].filter(s => s).map(s => s.substr(0, 1)).join('');
1123
+ }
1124
+ static toFront(data) { }
1125
+ static toBack(data) { }
1126
+ };
1127
+ __decorate([
1128
+ ToFrontHook
1129
+ ], TournamentTeamUser, "toFront", null);
1130
+ __decorate([
1131
+ ToBackHook
1132
+ ], TournamentTeamUser, "toBack", null);
1133
+ TournamentTeamUser = __decorate([
1134
+ ModelInstance({
1135
+ mappingFields: {
1136
+ id: 'id',
1137
+ tournament_team: 'tournamentTeam',
1138
+ team_user: 'teamUser',
1139
+ disqualified: 'disqualified',
1140
+ first_name: 'firstName',
1141
+ last_name: 'lastName',
1142
+ middle_name: 'middleName',
1143
+ photo: 'photo',
1144
+ disqualification: 'disqualification',
1145
+ has_changes: 'hasChanges',
1146
+ },
1147
+ relation: {
1148
+ tournamentTeam: TournamentTeam,
1149
+ teamUser: TeamUser,
1150
+ photo: File,
1151
+ disqualification: TournamentDisqualification,
1152
+ }
1153
+ })
1154
+ ], TournamentTeamUser);
1155
+
1156
+ let GameUser = class GameUser extends BaseModel {
1157
+ static toFront(data) { }
1158
+ static toBack(data) { }
1159
+ };
1160
+ __decorate([
1161
+ ToFrontHook
1162
+ ], GameUser, "toFront", null);
1163
+ __decorate([
1164
+ ToBackHook
1165
+ ], GameUser, "toBack", null);
1166
+ GameUser = __decorate([
1167
+ ModelInstance({
1168
+ mappingFields: {
1169
+ id: 'id',
1170
+ game_id: 'gameId',
1171
+ team_user: 'teamUser',
1172
+ tournament_team_user: 'tournamentTeamUser',
1173
+ updated_at: 'updatedAt'
1174
+ },
1175
+ relation: {
1176
+ teamUser: TeamUser,
1177
+ tournamentTeamUser: TournamentTeamUser,
1178
+ updatedAt: DateTimeField,
1179
+ }
1180
+ })
1181
+ ], GameUser);
1182
+
1183
+ function updateItemInArray(data, item, force = false, checkFunction) {
1184
+ if (!Array.isArray(data)) {
1185
+ return data;
1186
+ }
1187
+ return data.map(v => {
1188
+ if (checkFunction && isFunction(checkFunction)) {
1189
+ if (!checkFunction(v)) {
1190
+ return v;
1191
+ }
1192
+ }
1193
+ else if (v.id !== item.id) {
1194
+ return v;
1195
+ }
1196
+ if (v.updatedAt && item.updatedAt && !force) {
1197
+ return v.updatedAt > item.updatedAt ? v : item;
1198
+ }
1199
+ return item;
1200
+ });
1201
+ }
1202
+ function updateItemsInArray(data, items, force = false, checkFunction) {
1203
+ items.forEach(item => {
1204
+ data = updateItemInArray(data, item, force, checkFunction);
1205
+ });
1206
+ return data;
1207
+ }
1208
+ function patchItemInArray(data, item, checkFunction) {
1209
+ if (!Array.isArray(data)) {
1210
+ return data;
1211
+ }
1212
+ return data.map(v => {
1213
+ if (checkFunction && isFunction(checkFunction)) {
1214
+ if (!checkFunction(v)) {
1215
+ return v;
1216
+ }
1217
+ }
1218
+ else if (v.id !== item.id) {
1219
+ return v;
1220
+ }
1221
+ return Object.assign(v, item);
1222
+ });
1223
+ }
1224
+ function addItemInArray(data, item, atEnd = false, checkFunction) {
1225
+ if (!Array.isArray(data)) {
1226
+ return [item];
1227
+ }
1228
+ if (data.find(i => isFunction(checkFunction) ? checkFunction(i) : i.id === item.id)) {
1229
+ return data;
1230
+ }
1231
+ return atEnd
1232
+ ? [...data, item]
1233
+ : [item, ...data];
1234
+ }
1235
+ function addItemsInArray(data, items, atEnd = false, checkFunction) {
1236
+ (!atEnd
1237
+ ? Object.assign([], items).reverse()
1238
+ : items).forEach(item => {
1239
+ data = addItemInArray(data, item, atEnd, checkFunction);
1240
+ });
1241
+ return data;
1242
+ }
1243
+ function deleteItemFromArray(data, item) {
1244
+ if (!Array.isArray(data)) {
1245
+ return [];
1246
+ }
1247
+ if (isFunction(item)) {
1248
+ return data.filter(i => !item(i));
1249
+ }
1250
+ else {
1251
+ return data.filter(v => v.id !== item.id);
1252
+ }
1253
+ }
1254
+ function isFunction(functionToCheck) {
1255
+ return functionToCheck && {}.toString.call(functionToCheck) === '[object Function]';
1256
+ }
1257
+
1258
+ class Store {
1259
+ constructor(engine) {
1260
+ this.engine = engine;
1261
+ this.data = {};
1262
+ }
1263
+ get(key) {
1264
+ return this.getSubject(key).pipe(filter(item => item !== undefined));
1265
+ }
1266
+ value(key) {
1267
+ return this.getSubject(key).value;
1268
+ }
1269
+ save(key, value) {
1270
+ this.getSubject(key).next(value);
1271
+ if (this.engine) {
1272
+ this.engine.save(key, value);
1273
+ }
1274
+ }
1275
+ appendItem(key, value, checkFunction) {
1276
+ this.save(key, addItemInArray(this.value(key) || [], value, true, checkFunction));
1277
+ }
1278
+ appendItems(key, value, checkFunction) {
1279
+ this.save(key, addItemsInArray(this.value(key) || [], value, true));
1280
+ }
1281
+ prependItem(key, value, checkFunction) {
1282
+ this.save(key, addItemInArray(this.value(key) || [], value, false, checkFunction));
1283
+ }
1284
+ prependItems(key, value, checkFunction) {
1285
+ this.save(key, addItemsInArray(this.value(key) || [], value, false, checkFunction));
1286
+ }
1287
+ updateItem(key, value, force, checkFunction) {
1288
+ this.save(key, updateItemInArray(this.value(key) || [], value, force, checkFunction));
1289
+ }
1290
+ updateItems(key, value, force, checkFunction) {
1291
+ this.save(key, updateItemsInArray(this.value(key) || [], value, force, checkFunction));
1292
+ }
1293
+ deleteItem(key, value) {
1294
+ this.save(key, deleteItemFromArray(this.value(key) || [], value));
1295
+ }
1296
+ dispose() {
1297
+ for (const key of Object.keys(this.data)) {
1298
+ this.data[key].complete();
1299
+ delete this.data[key];
1300
+ }
1301
+ }
1302
+ clearStorageData() {
1303
+ if (this.engine) {
1304
+ this.engine.clear();
1305
+ }
1306
+ }
1307
+ getEngine() {
1308
+ return this.engine;
1309
+ }
1310
+ getSubject(key) {
1311
+ if (!this.data[key]) {
1312
+ this.data[key] = new BehaviorSubject(this.engine ? this.engine.get(key) : undefined);
1313
+ }
1314
+ return this.data[key];
1315
+ }
1316
+ }
1317
+
1318
+ let BaseService = class BaseService {
1319
+ constructor() {
1320
+ this.store = new Store();
1321
+ }
1322
+ dispose() {
1323
+ this.store.dispose();
1324
+ }
1325
+ };
1326
+ BaseService.ɵprov = ɵɵdefineInjectable({ factory: function BaseService_Factory() { return new BaseService(); }, token: BaseService, providedIn: "root" });
1327
+ BaseService = __decorate([
1328
+ Injectable({ providedIn: 'root' })
1329
+ ], BaseService);
1330
+
1331
+ const CONFIG_STORE_KEY = 'config';
1332
+ const CONFIG_DATA = 'mtg-core-config-data';
1333
+ let ConfigService = class ConfigService extends BaseService {
1334
+ constructor(configData) {
1335
+ super();
1336
+ this.configData = configData;
1337
+ if (configData) {
1338
+ this.initialize(configData);
1339
+ }
1340
+ }
1341
+ get config$() {
1342
+ return this.store.get(CONFIG_STORE_KEY);
1343
+ }
1344
+ get config() {
1345
+ return this.store.value(CONFIG_STORE_KEY) || {};
1346
+ }
1347
+ initialize(data) {
1348
+ this.store.save(CONFIG_STORE_KEY, data);
1349
+ }
1350
+ set(key, value) {
1351
+ this.store.save(CONFIG_STORE_KEY, Object.assign(Object.assign({}, this.config), { [key]: value }));
1352
+ }
1353
+ get(key) {
1354
+ return this.store.value(CONFIG_STORE_KEY) && this.store.value(CONFIG_STORE_KEY)[key];
1355
+ }
1356
+ };
1357
+ ConfigService.ctorParameters = () => [
1358
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [CONFIG_DATA,] }] }
1359
+ ];
1360
+ ConfigService.ɵprov = ɵɵdefineInjectable({ factory: function ConfigService_Factory() { return new ConfigService(ɵɵinject("mtg-core-config-data", 8)); }, token: ConfigService, providedIn: "root" });
1361
+ ConfigService = __decorate([
1362
+ Injectable({ providedIn: 'root' }),
1363
+ __param(0, Optional()), __param(0, Inject(CONFIG_DATA))
1364
+ ], ConfigService);
1365
+
1366
+ let BasketballStatistic = class BasketballStatistic extends BaseModel {
1367
+ get totalFouls() {
1368
+ return this.personalFouls + this.technicalFouls + this.unsportsmanlikeFouls;
1369
+ }
1370
+ static toFront(data) { }
1371
+ static toBack(data) { }
1372
+ };
1373
+ __decorate([
1374
+ ToFrontHook
1375
+ ], BasketballStatistic, "toFront", null);
1376
+ __decorate([
1377
+ ToBackHook
1378
+ ], BasketballStatistic, "toBack", null);
1379
+ BasketballStatistic = __decorate([
1380
+ ModelInstance({
1381
+ mappingFields: {
1382
+ tournament_team_user: 'tournamentTeamUser',
1383
+ team: 'team',
1384
+ team_user: 'teamUser',
1385
+ user: 'user',
1386
+ tournament_team: 'tournamentTeam',
1387
+ month: 'month',
1388
+ win_lose: 'winLose',
1389
+ games_count: 'gamesCount',
1390
+ won_games_count: 'wonGamesCount',
1391
+ points: 'points',
1392
+ two_points_made: 'twoPointsMade',
1393
+ three_points_made: 'threePointsMade',
1394
+ free_throws_made: 'freeThrowsMade',
1395
+ one_points_made: 'onePointsMade',
1396
+ two_point_attempts: 'twoPointAttempts',
1397
+ three_point_attempts: 'threePointAttempts',
1398
+ free_throw_attempts: 'freeThrowAttempts',
1399
+ one_point_attempts: 'onePointAttempts',
1400
+ two_point_percent: 'twoPointPercent',
1401
+ three_point_percent: 'threePointPercent',
1402
+ free_throw_percent: 'freeThrowPercent',
1403
+ one_point_percent: 'onePointPercent',
1404
+ assists: 'assists',
1405
+ blocks: 'blocks',
1406
+ rebounds: 'rebounds',
1407
+ offensive_rebounds: 'offensiveRebounds',
1408
+ defensive_rebounds: 'defensiveRebounds',
1409
+ steals: 'steals',
1410
+ turnovers: 'turnovers',
1411
+ personal_fouls: 'personalFouls',
1412
+ technical_fouls: 'technicalFouls',
1413
+ unsportsmanlike_fouls: 'unsportsmanlikeFouls',
1414
+ newbie: 'newbie',
1415
+ },
1416
+ relation: {
1417
+ tournamentTeamUser: TournamentTeamUser,
1418
+ team: Team,
1419
+ teamUser: TeamUser,
1420
+ user: User,
1421
+ tournamentTeam: TournamentTeam,
1422
+ month: DateField
1423
+ }
1424
+ })
1425
+ ], BasketballStatistic);
1426
+
1427
+ let BasketballGameTeamStatistic = class BasketballGameTeamStatistic extends BaseModel {
1428
+ static toFront(data) { }
1429
+ static toBack(data) { }
1430
+ };
1431
+ __decorate([
1432
+ ToFrontHook
1433
+ ], BasketballGameTeamStatistic, "toFront", null);
1434
+ __decorate([
1435
+ ToBackHook
1436
+ ], BasketballGameTeamStatistic, "toBack", null);
1437
+ BasketballGameTeamStatistic = __decorate([
1438
+ ModelInstance({
1439
+ mappingFields: {
1440
+ team: 'team',
1441
+ competitor_team: 'competitorTeam'
1442
+ },
1443
+ relation: {
1444
+ team: BasketballStatistic,
1445
+ competitorTeam: BasketballStatistic
1446
+ }
1447
+ })
1448
+ ], BasketballGameTeamStatistic);
1449
+
1450
+ let BasketballGameStatistic = class BasketballGameStatistic extends BaseModel {
1451
+ get id() {
1452
+ return this.gameUserId;
1453
+ }
1454
+ static toFront(data) { }
1455
+ static toBack(data) { }
1456
+ get totalFouls() {
1457
+ return (this.personalFouls || 0) + (this.technicalFouls || 0) + (this.unsportsmanlikeFouls || 0);
1458
+ }
1459
+ };
1460
+ __decorate([
1461
+ ToFrontHook
1462
+ ], BasketballGameStatistic, "toFront", null);
1463
+ __decorate([
1464
+ ToBackHook
1465
+ ], BasketballGameStatistic, "toBack", null);
1466
+ BasketballGameStatistic = __decorate([
1467
+ ModelInstance({
1468
+ mappingFields: {
1469
+ game_user_id: 'gameUserId',
1470
+ points: 'points',
1471
+ free_throws_made: 'freeThrowsMade',
1472
+ two_points_made: 'twoPointsMade',
1473
+ three_points_made: 'threePointsMade',
1474
+ one_points_made: 'onePointsMade',
1475
+ two_point_attempts: 'twoPointAttempts',
1476
+ three_point_attempts: 'threePointAttempts',
1477
+ free_throw_attempts: 'freeThrowAttempts',
1478
+ one_point_attempts: 'onePointAttempts',
1479
+ assists: 'assists',
1480
+ blocks: 'blocks',
1481
+ rebounds: 'rebounds',
1482
+ offensive_rebounds: 'offensiveRebounds',
1483
+ defensive_rebounds: 'defensiveRebounds',
1484
+ steals: 'steals',
1485
+ turnovers: 'turnovers',
1486
+ personal_fouls: 'personalFouls',
1487
+ technical_fouls: 'technicalFouls',
1488
+ unsportsmanlike_fouls: 'unsportsmanlikeFouls',
1489
+ updated_at: 'updatedAt',
1490
+ },
1491
+ relation: {
1492
+ updatedAt: DateTimeField,
1493
+ }
1494
+ })
1495
+ ], BasketballGameStatistic);
1496
+
1497
+ var BasketballGameLogTypes;
1498
+ (function (BasketballGameLogTypes) {
1499
+ BasketballGameLogTypes[BasketballGameLogTypes["enter_game"] = 1] = "enter_game";
1500
+ BasketballGameLogTypes[BasketballGameLogTypes["exit_game"] = 2] = "exit_game";
1501
+ BasketballGameLogTypes[BasketballGameLogTypes["remove_game"] = 3] = "remove_game";
1502
+ BasketballGameLogTypes[BasketballGameLogTypes["two_point_made"] = 4] = "two_point_made";
1503
+ BasketballGameLogTypes[BasketballGameLogTypes["three_point_made"] = 5] = "three_point_made";
1504
+ BasketballGameLogTypes[BasketballGameLogTypes["free_throw_made"] = 6] = "free_throw_made";
1505
+ BasketballGameLogTypes[BasketballGameLogTypes["two_point_attempt"] = 7] = "two_point_attempt";
1506
+ BasketballGameLogTypes[BasketballGameLogTypes["three_point_attempt"] = 8] = "three_point_attempt";
1507
+ BasketballGameLogTypes[BasketballGameLogTypes["free_throw_attempt"] = 9] = "free_throw_attempt";
1508
+ BasketballGameLogTypes[BasketballGameLogTypes["assist"] = 10] = "assist";
1509
+ BasketballGameLogTypes[BasketballGameLogTypes["block"] = 11] = "block";
1510
+ BasketballGameLogTypes[BasketballGameLogTypes["rebound"] = 12] = "rebound";
1511
+ BasketballGameLogTypes[BasketballGameLogTypes["offensive_rebound"] = 13] = "offensive_rebound";
1512
+ BasketballGameLogTypes[BasketballGameLogTypes["defensive_rebound"] = 14] = "defensive_rebound";
1513
+ BasketballGameLogTypes[BasketballGameLogTypes["steal"] = 15] = "steal";
1514
+ BasketballGameLogTypes[BasketballGameLogTypes["turnover"] = 16] = "turnover";
1515
+ BasketballGameLogTypes[BasketballGameLogTypes["personal_foul"] = 17] = "personal_foul";
1516
+ BasketballGameLogTypes[BasketballGameLogTypes["technical_foul"] = 18] = "technical_foul";
1517
+ BasketballGameLogTypes[BasketballGameLogTypes["unsportsmanlike_foul"] = 19] = "unsportsmanlike_foul";
1518
+ BasketballGameLogTypes[BasketballGameLogTypes["one_point_attempt"] = 20] = "one_point_attempt";
1519
+ BasketballGameLogTypes[BasketballGameLogTypes["one_point_made"] = 21] = "one_point_made";
1520
+ BasketballGameLogTypes[BasketballGameLogTypes["timeout"] = 22] = "timeout";
1521
+ })(BasketballGameLogTypes || (BasketballGameLogTypes = {}));
1522
+ let BasketballGameLog = class BasketballGameLog extends BaseModel {
1523
+ constructor() {
1524
+ super(...arguments);
1525
+ this.active = true;
1526
+ }
1527
+ isPointsType() {
1528
+ return [
1529
+ BasketballGameLogTypes.two_point_made,
1530
+ BasketballGameLogTypes.three_point_made,
1531
+ BasketballGameLogTypes.free_throw_made,
1532
+ BasketballGameLogTypes.one_point_made,
1533
+ ].indexOf(this.logType) > -1;
1534
+ }
1535
+ isReboundType() {
1536
+ return [
1537
+ BasketballGameLogTypes.rebound,
1538
+ BasketballGameLogTypes.offensive_rebound,
1539
+ BasketballGameLogTypes.defensive_rebound
1540
+ ].indexOf(this.logType) > -1;
1541
+ }
1542
+ isFoulType() {
1543
+ return [
1544
+ BasketballGameLogTypes.personal_foul,
1545
+ BasketballGameLogTypes.technical_foul,
1546
+ BasketballGameLogTypes.unsportsmanlike_foul
1547
+ ].indexOf(this.logType) > -1;
1548
+ }
1549
+ getScore() {
1550
+ const scoreMapping = {
1551
+ [BasketballGameLogTypes.one_point_made]: 1,
1552
+ [BasketballGameLogTypes.free_throw_made]: 1,
1553
+ [BasketballGameLogTypes.two_point_made]: 2,
1554
+ [BasketballGameLogTypes.three_point_made]: 3
1555
+ };
1556
+ return scoreMapping[this.logType];
1557
+ }
1558
+ compare(model) {
1559
+ if (this.time === model.time && this.period === model.period) {
1560
+ return this.datetime.getTime() < model.datetime.getTime() ? 1 : -1;
1561
+ }
1562
+ if (this.period === model.period) {
1563
+ return this.time < model.time ? 1 : -1;
1564
+ }
1565
+ return this.period < model.period ? 1 : -1;
1566
+ }
1567
+ get timeFormatted() {
1568
+ const minutes = Math.floor(this.time / 60);
1569
+ const seconds = this.time - minutes * 60;
1570
+ return `${minutes < 10 ? '0' : ''}${minutes}:${seconds < 10 ? '0' : ''}${seconds}`;
1571
+ }
1572
+ static toFront(value) { }
1573
+ static toBack(value) { }
1574
+ };
1575
+ __decorate([
1576
+ ToFrontHook
1577
+ ], BasketballGameLog, "toFront", null);
1578
+ __decorate([
1579
+ ToBackHook
1580
+ ], BasketballGameLog, "toBack", null);
1581
+ BasketballGameLog = __decorate([
1582
+ ModelInstance({
1583
+ mappingFields: {
1584
+ id: 'id',
1585
+ unique_id: 'uniqueId',
1586
+ game_id: 'gameId',
1587
+ game_user_id: 'gameUserId',
1588
+ team_id: 'teamId',
1589
+ log_type: 'logType',
1590
+ datetime: 'datetime',
1591
+ time: 'time',
1592
+ period: 'period',
1593
+ active: 'active',
1594
+ is_highlight: 'isHighlight',
1595
+ },
1596
+ relation: {
1597
+ datetime: DateTimeField,
1598
+ logType: enumField(BasketballGameLogTypes),
1599
+ }
1600
+ })
1601
+ ], BasketballGameLog);
1602
+
1603
+ let BasketballGameApi = class BasketballGameApi {
1604
+ constructor(httpClient, configService) {
1605
+ this.httpClient = httpClient;
1606
+ this.configService = configService;
1607
+ }
1608
+ getById(gameId) {
1609
+ return __awaiter(this, void 0, void 0, function* () {
1610
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_basketball_game/${gameId}/`).pipe(map(result => Game.toFront(result))).toPromise();
1611
+ });
1612
+ }
1613
+ getUsers(gameId) {
1614
+ return __awaiter(this, void 0, void 0, function* () {
1615
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_game/${gameId}/users/`).pipe(map(result => GameUser.toFront(result))).toPromise();
1616
+ });
1617
+ }
1618
+ getTeamStatistic(gameId) {
1619
+ return __awaiter(this, void 0, void 0, function* () {
1620
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_basketball_game/${gameId}/team_statistic/`).pipe(map(result => BasketballGameTeamStatistic.toFront(result))).toPromise();
1621
+ });
1622
+ }
1623
+ getUserStatistic(gameId) {
1624
+ return __awaiter(this, void 0, void 0, function* () {
1625
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_basketball_game/${gameId}/user_statistic/`).pipe(map(result => BasketballGameStatistic.toFront(result))).toPromise();
1626
+ });
1627
+ }
1628
+ getLogs(gameId) {
1629
+ return __awaiter(this, void 0, void 0, function* () {
1630
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_basketball_game/${gameId}/logs/`).pipe(map(result => BasketballGameLog.toFront(result))).toPromise();
1631
+ });
1632
+ }
1633
+ };
1634
+ BasketballGameApi.ctorParameters = () => [
1635
+ { type: HttpClient },
1636
+ { type: ConfigService }
1637
+ ];
1638
+ BasketballGameApi.ɵprov = ɵɵdefineInjectable({ factory: function BasketballGameApi_Factory() { return new BasketballGameApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: BasketballGameApi, providedIn: "root" });
1639
+ BasketballGameApi = __decorate([
1640
+ Injectable({ providedIn: 'root' })
1641
+ ], BasketballGameApi);
1642
+
1643
+ var TournamentEventTypes;
1644
+ (function (TournamentEventTypes) {
1645
+ TournamentEventTypes[TournamentEventTypes["game_closed"] = 1] = "game_closed";
1646
+ TournamentEventTypes[TournamentEventTypes["media_added"] = 2] = "media_added";
1647
+ })(TournamentEventTypes || (TournamentEventTypes = {}));
1648
+ let TournamentEvent = class TournamentEvent extends BaseModel {
1649
+ static toFront(data) { }
1650
+ static toBack(data) { }
1651
+ };
1652
+ __decorate([
1653
+ ToFrontHook
1654
+ ], TournamentEvent, "toFront", null);
1655
+ __decorate([
1656
+ ToBackHook
1657
+ ], TournamentEvent, "toBack", null);
1658
+ TournamentEvent = __decorate([
1659
+ ModelInstance({
1660
+ mappingFields: {
1661
+ id: 'id',
1662
+ game: 'game',
1663
+ tournament: 'tournament',
1664
+ event: 'event',
1665
+ datetime: 'datetime'
1666
+ },
1667
+ relation: {
1668
+ game: Game,
1669
+ tournament: Tournament,
1670
+ datetime: DateField,
1671
+ event: enumField(TournamentEventTypes)
1672
+ }
1673
+ })
1674
+ ], TournamentEvent);
1675
+
1676
+ let LeagueApi = class LeagueApi {
1677
+ constructor(httpClient, configService) {
1678
+ this.httpClient = httpClient;
1679
+ this.configService = configService;
1680
+ }
1681
+ getByAlias(alias) {
1682
+ return __awaiter(this, void 0, void 0, function* () {
1683
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/league/${alias}/`).pipe(map(result => League.toFront(result))).toPromise();
1684
+ });
1685
+ }
1686
+ getByDomain(domain) {
1687
+ return __awaiter(this, void 0, void 0, function* () {
1688
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/league/by_domain/${domain}/`).pipe(map(result => League.toFront(result))).toPromise();
1689
+ });
1690
+ }
1691
+ getTournaments(leagueId) {
1692
+ return __awaiter(this, void 0, void 0, function* () {
1693
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/league/${leagueId}/tournaments/`).pipe(map(result => Tournament.toFront(result))).toPromise();
1694
+ });
1695
+ }
1696
+ getEvents(leagueId, page, size, filters) {
1697
+ return __awaiter(this, void 0, void 0, function* () {
1698
+ let params = new HttpParams().set('page', page.toString())
1699
+ .set('size', size.toString());
1700
+ if (filters) {
1701
+ if (filters.event) {
1702
+ params = params.set('event', TournamentEventTypes[filters.event]);
1703
+ }
1704
+ if (filters.search) {
1705
+ params = params.set('search', filters.search);
1706
+ }
1707
+ }
1708
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/league/${leagueId}/events/`, { params, observe: 'response' }).pipe(map(result => ({
1709
+ total: +result.headers.get('X-Page-Count'),
1710
+ data: TournamentEvent.toFront(result.body)
1711
+ }))).toPromise();
1712
+ });
1713
+ }
1714
+ };
1715
+ LeagueApi.ctorParameters = () => [
1716
+ { type: HttpClient },
1717
+ { type: ConfigService }
1718
+ ];
1719
+ LeagueApi.ɵprov = ɵɵdefineInjectable({ factory: function LeagueApi_Factory() { return new LeagueApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: LeagueApi, providedIn: "root" });
1720
+ LeagueApi = __decorate([
1721
+ Injectable({ providedIn: 'root' })
1722
+ ], LeagueApi);
1723
+
1724
+ let MediaApi = class MediaApi {
1725
+ constructor(httpClient, configService) {
1726
+ this.httpClient = httpClient;
1727
+ this.configService = configService;
1728
+ }
1729
+ getMedia(mediaId) {
1730
+ return __awaiter(this, void 0, void 0, function* () {
1731
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/media/${mediaId}/`).pipe(map(result => MediaItem.toFront(result))).toPromise();
1732
+ });
1733
+ }
1734
+ getTournamentGameMedia(tournamentId, page, size, filters) {
1735
+ return __awaiter(this, void 0, void 0, function* () {
1736
+ let params = new HttpParams().set('page', page.toString()).set('size', size.toString());
1737
+ if (filters) {
1738
+ if (filters.tournamentTour) {
1739
+ params = params.set('tournament_tour', filters.tournamentTour.toString());
1740
+ }
1741
+ if (filters.teamId) {
1742
+ params = params.set('team_id', filters.teamId.toString());
1743
+ }
1744
+ if (filters.tournamentStageId) {
1745
+ params = params.set('tournament_stage_id', filters.tournamentStageId.toString());
1746
+ }
1747
+ if (filters.playoffId) {
1748
+ params = params.set('playoff_id', filters.playoffId.toString());
1749
+ }
1750
+ if (filters.playoffStage) {
1751
+ params = params.set('playoff_stage', filters.playoffStage.toString());
1752
+ }
1753
+ if (filters.status) {
1754
+ params = params.set('status', GameStatuses[filters.status]);
1755
+ }
1756
+ }
1757
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/game_media/`, { observe: 'response', params }).pipe(map(response => {
1758
+ return {
1759
+ total: +response.headers.get('X-Page-Count'),
1760
+ data: Game.toFront(response.body)
1761
+ };
1762
+ })).toPromise();
1763
+ });
1764
+ }
1765
+ getLeagueGameMedia(leagueId, page, size, filters) {
1766
+ return __awaiter(this, void 0, void 0, function* () {
1767
+ let params = new HttpParams().set('page', page.toString()).set('size', size.toString());
1768
+ if (filters) {
1769
+ if (filters.tournamentTour) {
1770
+ params = params.set('tournament_tour', filters.tournamentTour.toString());
1771
+ }
1772
+ if (filters.teamId) {
1773
+ params = params.set('team_id', filters.teamId.toString());
1774
+ }
1775
+ if (filters.tournamentStageId) {
1776
+ params = params.set('tournament_stage_id', filters.tournamentStageId.toString());
1777
+ }
1778
+ if (filters.playoffId) {
1779
+ params = params.set('playoff_id', filters.playoffId.toString());
1780
+ }
1781
+ if (filters.playoffStage) {
1782
+ params = params.set('playoff_stage', filters.playoffStage.toString());
1783
+ }
1784
+ if (filters.status) {
1785
+ params = params.set('status', GameStatuses[filters.status]);
1786
+ }
1787
+ }
1788
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/league/${leagueId}/game_media/`, { observe: 'response', params }).pipe(map(response => {
1789
+ return {
1790
+ total: +response.headers.get('X-Page-Count'),
1791
+ data: Game.toFront(response.body)
1792
+ };
1793
+ })).toPromise();
1794
+ });
1795
+ }
1796
+ getGameMediaById(gameId) {
1797
+ return __awaiter(this, void 0, void 0, function* () {
1798
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/game_media/${gameId}/`).pipe(map(result => Game.toFront(result))).toPromise();
1799
+ });
1800
+ }
1801
+ getGameMedia(gameId) {
1802
+ return __awaiter(this, void 0, void 0, function* () {
1803
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_game/${gameId}/media/`).pipe(map(result => MediaItem.toFront(result))).toPromise();
1804
+ });
1805
+ }
1806
+ createZip(mediaIds) {
1807
+ return __awaiter(this, void 0, void 0, function* () {
1808
+ return this.httpClient
1809
+ .post(`${this.configService.get('apiUrl')}/api/v1/media/zip/`, mediaIds, { responseType: 'blob' })
1810
+ .toPromise();
1811
+ });
1812
+ }
1813
+ };
1814
+ MediaApi.ctorParameters = () => [
1815
+ { type: HttpClient },
1816
+ { type: ConfigService }
1817
+ ];
1818
+ MediaApi.ɵprov = ɵɵdefineInjectable({ factory: function MediaApi_Factory() { return new MediaApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: MediaApi, providedIn: "root" });
1819
+ MediaApi = __decorate([
1820
+ Injectable({ providedIn: 'root' })
1821
+ ], MediaApi);
1822
+
1823
+ var PollStatuses;
1824
+ (function (PollStatuses) {
1825
+ PollStatuses[PollStatuses["open"] = 1] = "open";
1826
+ PollStatuses[PollStatuses["closed"] = 2] = "closed";
1827
+ PollStatuses[PollStatuses["archived"] = 3] = "archived";
1828
+ })(PollStatuses || (PollStatuses = {}));
1829
+ let PollVariant = class PollVariant extends BaseModel {
1830
+ static toFront(data) { }
1831
+ static toBack(data) { }
1832
+ };
1833
+ __decorate([
1834
+ ToFrontHook
1835
+ ], PollVariant, "toFront", null);
1836
+ __decorate([
1837
+ ToBackHook
1838
+ ], PollVariant, "toBack", null);
1839
+ PollVariant = __decorate([
1840
+ ModelInstance({
1841
+ mappingFields: {
1842
+ uuid: 'uuid',
1843
+ name: 'name'
1844
+ }
1845
+ })
1846
+ ], PollVariant);
1847
+ let PollAnswer = class PollAnswer extends BaseModel {
1848
+ static toFront(data) { }
1849
+ static toBack(data) { }
1850
+ };
1851
+ __decorate([
1852
+ ToFrontHook
1853
+ ], PollAnswer, "toFront", null);
1854
+ __decorate([
1855
+ ToBackHook
1856
+ ], PollAnswer, "toBack", null);
1857
+ PollAnswer = __decorate([
1858
+ ModelInstance({
1859
+ mappingFields: {
1860
+ id: 'id',
1861
+ answer_uuid: 'answerUuid',
1862
+ user: 'user',
1863
+ poll_id: 'pollId',
1864
+ },
1865
+ relation: {
1866
+ user: User
1867
+ }
1868
+ })
1869
+ ], PollAnswer);
1870
+ let Poll = class Poll extends BaseModel {
1871
+ constructor() {
1872
+ super(...arguments);
1873
+ this.variantsWithAnswers = [];
1874
+ }
1875
+ set variants(value) {
1876
+ this._variants = value || [];
1877
+ if (this._answers) {
1878
+ this.calculateAnswersPercentage();
1879
+ }
1880
+ }
1881
+ get variants() {
1882
+ return this._variants;
1883
+ }
1884
+ set answers(value) {
1885
+ this._answers = value || [];
1886
+ if (this._variants) {
1887
+ this.calculateAnswersPercentage();
1888
+ }
1889
+ }
1890
+ get answers() {
1891
+ return this._answers;
1892
+ }
1893
+ calculateAnswersPercentage() {
1894
+ if (!this._answers.length) {
1895
+ return;
1896
+ }
1897
+ const variants = this._variants.map(v => v.uuid);
1898
+ const answersByVariant = this._answers.reduce((acc, item) => {
1899
+ if (variants.indexOf(item.answerUuid) < 0) {
1900
+ return acc;
1901
+ }
1902
+ if (!acc[item.answerUuid]) {
1903
+ acc[item.answerUuid] = 0;
1904
+ }
1905
+ acc[item.answerUuid]++;
1906
+ return acc;
1907
+ }, {});
1908
+ this.variantsWithAnswers = this._variants.map(item => ({
1909
+ variant: item,
1910
+ percent: answersByVariant[item.uuid] ? Math.round(100 * answersByVariant[item.uuid] / this._answers.length) : 0
1911
+ }))
1912
+ .sort((a, b) => a.percent > b.percent ? -1 : 1);
1913
+ }
1914
+ static toFront(data) { }
1915
+ static toBack(data) { }
1916
+ };
1917
+ __decorate([
1918
+ ToFrontHook
1919
+ ], Poll, "toFront", null);
1920
+ __decorate([
1921
+ ToBackHook
1922
+ ], Poll, "toBack", null);
1923
+ Poll = __decorate([
1924
+ ModelInstance({
1925
+ mappingFields: {
1926
+ id: 'id',
1927
+ active: 'active',
1928
+ status: 'status',
1929
+ team_id: 'teamId',
1930
+ name: 'name',
1931
+ description: 'description',
1932
+ variants: 'variants',
1933
+ author: 'author',
1934
+ answers: 'answers',
1935
+ multiple_answer: 'multipleAnswer',
1936
+ anonymous: 'anonymous',
1937
+ created_at: 'createdAt'
1938
+ },
1939
+ relation: {
1940
+ status: enumField(PollStatuses),
1941
+ variants: PollVariant,
1942
+ author: User,
1943
+ answers: PollAnswer,
1944
+ createdAt: DateTimeField,
1945
+ }
1946
+ })
1947
+ ], Poll);
1948
+
1949
+ let TeamInvite = class TeamInvite extends BaseModel {
1950
+ static toFront(data) { }
1951
+ static toBack(data) { }
1952
+ };
1953
+ __decorate([
1954
+ ToFrontHook
1955
+ ], TeamInvite, "toFront", null);
1956
+ __decorate([
1957
+ ToBackHook
1958
+ ], TeamInvite, "toBack", null);
1959
+ TeamInvite = __decorate([
1960
+ ModelInstance({
1961
+ mappingFields: {
1962
+ id: 'id',
1963
+ user_id: 'userId',
1964
+ user: 'user',
1965
+ team: 'team',
1966
+ team_id: 'teamId',
1967
+ user_accept: 'userAccept',
1968
+ team_accept: 'teamAccept',
1969
+ users_count: 'usersCount',
1970
+ games_count: 'gamesCount',
1971
+ won_games_count: 'wonGamesCount',
1972
+ score_sum: 'scoreSum',
1973
+ created_at: 'createdAt',
1974
+ updated_at: 'updatedAt',
1975
+ },
1976
+ relation: {
1977
+ user: User,
1978
+ team: Team,
1979
+ createdAt: DateTimeField,
1980
+ updateAt: DateTimeField,
1981
+ }
1982
+ })
1983
+ ], TeamInvite);
1984
+
1985
+ var GameInviteStatus;
1986
+ (function (GameInviteStatus) {
1987
+ GameInviteStatus[GameInviteStatus["accepted"] = 1] = "accepted";
1988
+ GameInviteStatus[GameInviteStatus["declined"] = 2] = "declined";
1989
+ })(GameInviteStatus || (GameInviteStatus = {}));
1990
+ let GameInvite = class GameInvite extends BaseModel {
1991
+ static toFront(data) { }
1992
+ static toBack(data) { }
1993
+ };
1994
+ __decorate([
1995
+ ToFrontHook
1996
+ ], GameInvite, "toFront", null);
1997
+ __decorate([
1998
+ ToBackHook
1999
+ ], GameInvite, "toBack", null);
2000
+ GameInvite = __decorate([
2001
+ ModelInstance({
2002
+ mappingFields: {
2003
+ id: 'id',
2004
+ team_user: 'teamUser',
2005
+ game_id: 'gameId',
2006
+ game: 'game',
2007
+ status: 'status',
2008
+ },
2009
+ relation: {
2010
+ game: Game,
2011
+ teamUser: TeamUser,
2012
+ status: enumField(GameInviteStatus),
2013
+ }
2014
+ })
2015
+ ], GameInvite);
2016
+
2017
+ var TeamEventTypes;
2018
+ (function (TeamEventTypes) {
2019
+ TeamEventTypes[TeamEventTypes["training"] = 1] = "training";
2020
+ TeamEventTypes[TeamEventTypes["other"] = 2] = "other";
2021
+ })(TeamEventTypes || (TeamEventTypes = {}));
2022
+
2023
+ const TeamEventTypeLocalization = {
2024
+ [TeamEventTypes.training]: 'Тренировка',
2025
+ [TeamEventTypes.other]: 'Другое'
2026
+ };
2027
+
2028
+ let TeamEvent = class TeamEvent extends BaseModel {
2029
+ get name() {
2030
+ if (this.eventType === TeamEventTypes.other) {
2031
+ return this.eventCustomName;
2032
+ }
2033
+ return TeamEventTypeLocalization[this.eventType];
2034
+ }
2035
+ get isClosed() {
2036
+ return this.datetime.getTime() < new Date().getTime();
2037
+ }
2038
+ static toFront(data) { }
2039
+ static toBack(data) { }
2040
+ };
2041
+ __decorate([
2042
+ ToFrontHook
2043
+ ], TeamEvent, "toFront", null);
2044
+ __decorate([
2045
+ ToBackHook
2046
+ ], TeamEvent, "toBack", null);
2047
+ TeamEvent = __decorate([
2048
+ ModelInstance({
2049
+ mappingFields: {
2050
+ id: 'id',
2051
+ team_id: 'teamId',
2052
+ team: 'team',
2053
+ event_type: 'eventType',
2054
+ event_custom_name: 'eventCustomName',
2055
+ description: 'description',
2056
+ datetime: 'datetime',
2057
+ location: 'location',
2058
+ },
2059
+ relation: {
2060
+ eventType: enumField(TeamEventTypes),
2061
+ team: Team,
2062
+ datetime: DateTimeField,
2063
+ }
2064
+ })
2065
+ ], TeamEvent);
2066
+
2067
+ var TeamEventInviteStatuses;
2068
+ (function (TeamEventInviteStatuses) {
2069
+ TeamEventInviteStatuses[TeamEventInviteStatuses["accepted"] = 1] = "accepted";
2070
+ TeamEventInviteStatuses[TeamEventInviteStatuses["declined"] = 2] = "declined";
2071
+ })(TeamEventInviteStatuses || (TeamEventInviteStatuses = {}));
2072
+ let TeamEventInvite = class TeamEventInvite {
2073
+ static toFront(data) { }
2074
+ static toBack(data) { }
2075
+ };
2076
+ __decorate([
2077
+ ToFrontHook
2078
+ ], TeamEventInvite, "toFront", null);
2079
+ __decorate([
2080
+ ToBackHook
2081
+ ], TeamEventInvite, "toBack", null);
2082
+ TeamEventInvite = __decorate([
2083
+ ModelInstance({
2084
+ mappingFields: {
2085
+ id: 'id',
2086
+ team_event_id: 'teamEventId',
2087
+ team_user_id: 'teamUserId',
2088
+ status: 'status',
2089
+ },
2090
+ relation: {
2091
+ status: enumField(TeamEventInviteStatuses)
2092
+ }
2093
+ })
2094
+ ], TeamEventInvite);
2095
+
2096
+ let TournamentTeamUserInvite = class TournamentTeamUserInvite extends BaseModel {
2097
+ static toFront(data) { }
2098
+ static toBack(data) { }
2099
+ };
2100
+ __decorate([
2101
+ ToFrontHook
2102
+ ], TournamentTeamUserInvite, "toFront", null);
2103
+ __decorate([
2104
+ ToBackHook
2105
+ ], TournamentTeamUserInvite, "toBack", null);
2106
+ TournamentTeamUserInvite = __decorate([
2107
+ ModelInstance({
2108
+ mappingFields: {
2109
+ id: 'id',
2110
+ tournament_team_invite_id: 'tournamentTeamInviteId',
2111
+ tournament_team_id: 'tournamentTeamId',
2112
+ team_user: 'teamUser',
2113
+ accepted: 'accepted'
2114
+ },
2115
+ relation: {
2116
+ teamUser: TeamUser
2117
+ }
2118
+ })
2119
+ ], TournamentTeamUserInvite);
2120
+
2121
+ let TournamentInvite = class TournamentInvite extends BaseModel {
2122
+ get isOpen() {
2123
+ return (this.teamAccept === null || this.organizationAccept === null) && this.teamAccept !== false && this.organizationAccept !== false;
2124
+ }
2125
+ static toFront(data) { }
2126
+ static toBack(data) { }
2127
+ };
2128
+ __decorate([
2129
+ ToFrontHook
2130
+ ], TournamentInvite, "toFront", null);
2131
+ __decorate([
2132
+ ToBackHook
2133
+ ], TournamentInvite, "toBack", null);
2134
+ TournamentInvite = __decorate([
2135
+ ModelInstance({
2136
+ mappingFields: {
2137
+ id: 'id',
2138
+ team: 'team',
2139
+ tournament: 'tournament',
2140
+ team_accept: 'teamAccept',
2141
+ organization_accept: 'organizationAccept',
2142
+ user_invites_count: 'userInvitesCount',
2143
+ user_invites: 'userInvites',
2144
+ notifications_count: 'notificationsCount',
2145
+ },
2146
+ relation: {
2147
+ team: Team,
2148
+ tournament: Tournament,
2149
+ userInvites: TournamentTeamUserInvite,
2150
+ }
2151
+ })
2152
+ ], TournamentInvite);
2153
+
2154
+ var NotificationType;
2155
+ (function (NotificationType) {
2156
+ NotificationType[NotificationType["team_updated"] = 1] = "team_updated";
2157
+ NotificationType[NotificationType["team_invited"] = 2] = "team_invited";
2158
+ NotificationType[NotificationType["team_join_request"] = 3] = "team_join_request";
2159
+ NotificationType[NotificationType["team_join_declined_by_team"] = 4] = "team_join_declined_by_team";
2160
+ NotificationType[NotificationType["team_join_declined_by_user"] = 5] = "team_join_declined_by_user";
2161
+ NotificationType[NotificationType["team_join_canceled_by_team"] = 6] = "team_join_canceled_by_team";
2162
+ NotificationType[NotificationType["team_join_canceled_by_user"] = 7] = "team_join_canceled_by_user";
2163
+ NotificationType[NotificationType["team_joined_for_user"] = 8] = "team_joined_for_user";
2164
+ NotificationType[NotificationType["team_joined_for_team"] = 9] = "team_joined_for_team";
2165
+ NotificationType[NotificationType["team_user_role_changed_for_user"] = 10] = "team_user_role_changed_for_user";
2166
+ NotificationType[NotificationType["team_user_role_changed_for_team"] = 11] = "team_user_role_changed_for_team";
2167
+ NotificationType[NotificationType["team_user_number_changed"] = 12] = "team_user_number_changed";
2168
+ NotificationType[NotificationType["team_user_deleted_for_user"] = 13] = "team_user_deleted_for_user";
2169
+ NotificationType[NotificationType["team_user_deleted_for_team"] = 14] = "team_user_deleted_for_team";
2170
+ NotificationType[NotificationType["team_user_left"] = 15] = "team_user_left";
2171
+ NotificationType[NotificationType["game_updated"] = 16] = "game_updated";
2172
+ NotificationType[NotificationType["game_invited"] = 17] = "game_invited";
2173
+ NotificationType[NotificationType["game_invite_accepted"] = 18] = "game_invite_accepted";
2174
+ NotificationType[NotificationType["game_invite_declined"] = 19] = "game_invite_declined";
2175
+ NotificationType[NotificationType["game_remind"] = 20] = "game_remind";
2176
+ NotificationType[NotificationType["game_won"] = 21] = "game_won";
2177
+ NotificationType[NotificationType["game_losing"] = 22] = "game_losing";
2178
+ NotificationType[NotificationType["game_tech_defeat"] = 23] = "game_tech_defeat";
2179
+ NotificationType[NotificationType["game_tech_victory"] = 24] = "game_tech_victory";
2180
+ NotificationType[NotificationType["poll_created"] = 25] = "poll_created";
2181
+ NotificationType[NotificationType["poll_closed"] = 26] = "poll_closed";
2182
+ NotificationType[NotificationType["team_event_invited"] = 27] = "team_event_invited";
2183
+ NotificationType[NotificationType["team_event_accepted"] = 28] = "team_event_accepted";
2184
+ NotificationType[NotificationType["team_event_declined"] = 29] = "team_event_declined";
2185
+ NotificationType[NotificationType["team_event_remind"] = 30] = "team_event_remind";
2186
+ NotificationType[NotificationType["tournament_invited"] = 31] = "tournament_invited";
2187
+ NotificationType[NotificationType["tournament_joined"] = 32] = "tournament_joined";
2188
+ NotificationType[NotificationType["tournament_join_declined"] = 33] = "tournament_join_declined";
2189
+ NotificationType[NotificationType["tournament_join_canceled"] = 34] = "tournament_join_canceled";
2190
+ NotificationType[NotificationType["tournament_user_invited"] = 35] = "tournament_user_invited";
2191
+ NotificationType[NotificationType["tournament_user_accepted_for_team"] = 36] = "tournament_user_accepted_for_team";
2192
+ NotificationType[NotificationType["tournament_user_accepted_for_user"] = 37] = "tournament_user_accepted_for_user";
2193
+ NotificationType[NotificationType["tournament_user_added"] = 38] = "tournament_user_added";
2194
+ NotificationType[NotificationType["tournament_user_declined_for_team"] = 39] = "tournament_user_declined_for_team";
2195
+ NotificationType[NotificationType["tournament_user_declined_for_user"] = 40] = "tournament_user_declined_for_user";
2196
+ NotificationType[NotificationType["tournament_user_invite_deleted"] = 41] = "tournament_user_invite_deleted";
2197
+ NotificationType[NotificationType["tournament_user_deleted"] = 42] = "tournament_user_deleted";
2198
+ NotificationType[NotificationType["tournament_user_disqualified_for_team"] = 43] = "tournament_user_disqualified_for_team";
2199
+ NotificationType[NotificationType["tournament_user_disqualified_for_user"] = 44] = "tournament_user_disqualified_for_user";
2200
+ NotificationType[NotificationType["tournament_user_disqualification_updated_for_team"] = 45] = "tournament_user_disqualification_updated_for_team";
2201
+ NotificationType[NotificationType["tournament_user_disqualification_updated_for_user"] = 46] = "tournament_user_disqualification_updated_for_user";
2202
+ NotificationType[NotificationType["tournament_team_deleted"] = 47] = "tournament_team_deleted";
2203
+ NotificationType[NotificationType["org_tournament_invite_created"] = 48] = "org_tournament_invite_created";
2204
+ NotificationType[NotificationType["org_tournament_invite_declined"] = 49] = "org_tournament_invite_declined";
2205
+ NotificationType[NotificationType["org_tournament_invite_deleted"] = 50] = "org_tournament_invite_deleted";
2206
+ NotificationType[NotificationType["org_tournament_invite_changed"] = 51] = "org_tournament_invite_changed";
2207
+ NotificationType[NotificationType["org_tournament_user_deleted"] = 52] = "org_tournament_user_deleted";
2208
+ NotificationType[NotificationType["org_tournament_user_invited"] = 53] = "org_tournament_user_invited";
2209
+ NotificationType[NotificationType["org_tournament_user_has_changes"] = 54] = "org_tournament_user_has_changes";
2210
+ NotificationType[NotificationType["org_tournament_team_leave"] = 55] = "org_tournament_team_leave";
2211
+ })(NotificationType || (NotificationType = {}));
2212
+ var NotificationServiceEnum;
2213
+ (function (NotificationServiceEnum) {
2214
+ NotificationServiceEnum[NotificationServiceEnum["public"] = 1] = "public";
2215
+ NotificationServiceEnum[NotificationServiceEnum["org"] = 2] = "org";
2216
+ })(NotificationServiceEnum || (NotificationServiceEnum = {}));
2217
+ let Notification = class Notification extends BaseModel {
2218
+ get important() {
2219
+ return true;
2220
+ }
2221
+ static toFront(value) { }
2222
+ static toBack(value) { }
2223
+ };
2224
+ __decorate([
2225
+ ToFrontHook
2226
+ ], Notification, "toFront", null);
2227
+ __decorate([
2228
+ ToBackHook
2229
+ ], Notification, "toBack", null);
2230
+ Notification = __decorate([
2231
+ ModelInstance({
2232
+ mappingFields: {
2233
+ id: 'id',
2234
+ event_type: 'event',
2235
+ data: 'data',
2236
+ initiator: 'initiator',
2237
+ team: 'team',
2238
+ team_invite: 'teamInvite',
2239
+ team_user: 'teamUser',
2240
+ poll: 'poll',
2241
+ game: 'game',
2242
+ game_invite: 'gameInvite',
2243
+ team_event: 'teamEvent',
2244
+ team_event_invite: 'teamEventInvite',
2245
+ tournament: 'tournament',
2246
+ tournament_invite: 'tournamentInvite',
2247
+ tournament_team: 'tournamentTeam',
2248
+ viewed: 'viewed',
2249
+ protected: 'protected',
2250
+ service: 'service',
2251
+ created_at: 'createdAt',
2252
+ },
2253
+ relation: {
2254
+ event: enumField(NotificationType),
2255
+ initiator: User,
2256
+ team: Team,
2257
+ teamInvite: TeamInvite,
2258
+ teamUser: TeamUser,
2259
+ poll: Poll,
2260
+ game: Game,
2261
+ gameInvite: GameInvite,
2262
+ teamEvent: TeamEvent,
2263
+ teamEventInvite: TeamEventInvite,
2264
+ tournament: Tournament,
2265
+ tournamentInvite: TournamentInvite,
2266
+ tournamentTeam: TournamentTeam,
2267
+ service: enumField(NotificationServiceEnum),
2268
+ createdAt: DateTimeField,
2269
+ }
2270
+ })
2271
+ ], Notification);
2272
+
2273
+ var NotificationAllowTypes;
2274
+ (function (NotificationAllowTypes) {
2275
+ NotificationAllowTypes[NotificationAllowTypes["all"] = 1] = "all";
2276
+ NotificationAllowTypes[NotificationAllowTypes["important"] = 2] = "important";
2277
+ NotificationAllowTypes[NotificationAllowTypes["none"] = 3] = "none";
2278
+ })(NotificationAllowTypes || (NotificationAllowTypes = {}));
2279
+ let NotificationSettings = class NotificationSettings extends BaseModel {
2280
+ static toFront(data) { }
2281
+ static toBack(data) { }
2282
+ };
2283
+ __decorate([
2284
+ ToFrontHook
2285
+ ], NotificationSettings, "toFront", null);
2286
+ __decorate([
2287
+ ToBackHook
2288
+ ], NotificationSettings, "toBack", null);
2289
+ NotificationSettings = __decorate([
2290
+ ModelInstance({
2291
+ mappingFields: {
2292
+ user_id: 'userId',
2293
+ popup: 'popup',
2294
+ sound: 'sound',
2295
+ browser: 'browser',
2296
+ email: 'email'
2297
+ },
2298
+ relation: {
2299
+ sound: enumField(NotificationAllowTypes),
2300
+ browser: enumField(NotificationAllowTypes),
2301
+ }
2302
+ })
2303
+ ], NotificationSettings);
2304
+
2305
+ let NotificationBaseApi = class NotificationBaseApi {
2306
+ constructor(httpClient, configService) {
2307
+ this.httpClient = httpClient;
2308
+ this.configService = configService;
2309
+ }
2310
+ getCount() {
2311
+ return __awaiter(this, void 0, void 0, function* () {
2312
+ return this.httpClient
2313
+ .get(`${this.configService.get('apiUrl')}${this.apiUrl}/notification/count/`)
2314
+ .pipe(map(data => +data))
2315
+ .toPromise();
2316
+ });
2317
+ }
2318
+ getList(page, size, filters = {}) {
2319
+ return __awaiter(this, void 0, void 0, function* () {
2320
+ let params = new HttpParams()
2321
+ .set('page', page.toString())
2322
+ .set('size', size.toString());
2323
+ for (const key of Object.keys(filters)) {
2324
+ params = params.set(key, filters[key]);
2325
+ }
2326
+ return this.httpClient
2327
+ .get(`${this.configService.get('apiUrl')}${this.apiUrl}/notification/`, { params, observe: 'response' })
2328
+ .pipe(map(response => {
2329
+ const data = Notification.toFront(response.body);
2330
+ return {
2331
+ total: +response.headers.get('x-page-count'),
2332
+ data
2333
+ };
2334
+ })).toPromise();
2335
+ });
2336
+ }
2337
+ markViewed(notificationId, viewed) {
2338
+ return __awaiter(this, void 0, void 0, function* () {
2339
+ return this.httpClient
2340
+ .post(`${this.configService.get('apiUrl')}${this.apiUrl}/notification/${notificationId}/viewed/`, { viewed })
2341
+ .pipe(map(data => Notification.toFront(data)))
2342
+ .toPromise();
2343
+ });
2344
+ }
2345
+ markAllViewed() {
2346
+ return __awaiter(this, void 0, void 0, function* () {
2347
+ return this.httpClient
2348
+ .post(`${this.configService.get('apiUrl')}${this.apiUrl}/notification/viewed/`, {})
2349
+ .pipe(map(data => Notification.toFront(data)))
2350
+ .toPromise();
2351
+ });
2352
+ }
2353
+ getNotificationSettings() {
2354
+ return __awaiter(this, void 0, void 0, function* () {
2355
+ return this.httpClient.get(`${this.configService.get('apiUrl')}${this.apiUrl}/notification_settings/`)
2356
+ .pipe(map(data => NotificationSettings.toFront(data)))
2357
+ .toPromise();
2358
+ });
2359
+ }
2360
+ updateNotificationSettings(data) {
2361
+ return __awaiter(this, void 0, void 0, function* () {
2362
+ return this.httpClient.post(`${this.configService.get('apiUrl')}${this.apiUrl}/notification_settings/`, NotificationSettings.toBack(data))
2363
+ .pipe(map(result => NotificationSettings.toFront(result)))
2364
+ .toPromise();
2365
+ });
2366
+ }
2367
+ };
2368
+ NotificationBaseApi.ctorParameters = () => [
2369
+ { type: HttpClient },
2370
+ { type: ConfigService }
2371
+ ];
2372
+ NotificationBaseApi.ɵprov = ɵɵdefineInjectable({ factory: function NotificationBaseApi_Factory() { return new NotificationBaseApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: NotificationBaseApi, providedIn: "root" });
2373
+ NotificationBaseApi = __decorate([
2374
+ Injectable({ providedIn: 'root' })
2375
+ ], NotificationBaseApi);
2376
+
2377
+ let NotificationApi = class NotificationApi extends NotificationBaseApi {
2378
+ constructor() {
2379
+ super(...arguments);
2380
+ this.apiUrl = '/api/v1';
2381
+ }
2382
+ };
2383
+ NotificationApi.ɵprov = ɵɵdefineInjectable({ factory: function NotificationApi_Factory() { return new NotificationApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: NotificationApi, providedIn: "root" });
2384
+ NotificationApi = __decorate([
2385
+ Injectable({ providedIn: 'root' })
2386
+ ], NotificationApi);
2387
+
2388
+ let OrgNotificationApi = class OrgNotificationApi extends NotificationBaseApi {
2389
+ constructor() {
2390
+ super(...arguments);
2391
+ this.apiUrl = '/org/api/v1';
2392
+ }
2393
+ };
2394
+ OrgNotificationApi.ɵprov = ɵɵdefineInjectable({ factory: function OrgNotificationApi_Factory() { return new OrgNotificationApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: OrgNotificationApi, providedIn: "root" });
2395
+ OrgNotificationApi = __decorate([
2396
+ Injectable({ providedIn: 'root' })
2397
+ ], OrgNotificationApi);
2398
+
2399
+ let ReferenceApi = class ReferenceApi {
2400
+ constructor(httpClient, configService) {
2401
+ this.httpClient = httpClient;
2402
+ this.configService = configService;
2403
+ }
2404
+ getCities() {
2405
+ return __awaiter(this, void 0, void 0, function* () {
2406
+ return this.httpClient
2407
+ .get(`${this.configService.get('apiUrl')}/api/v1/reference/cities/`)
2408
+ .pipe(map(data => City.toFront(data))).toPromise();
2409
+ });
2410
+ }
2411
+ getSports() {
2412
+ return __awaiter(this, void 0, void 0, function* () {
2413
+ return this.httpClient
2414
+ .get(`${this.configService.get('apiUrl')}/api/v1/sport/`)
2415
+ .pipe(map(data => Sport.toFront(data))).toPromise();
2416
+ });
2417
+ }
2418
+ };
2419
+ ReferenceApi.ctorParameters = () => [
2420
+ { type: HttpClient },
2421
+ { type: ConfigService }
2422
+ ];
2423
+ ReferenceApi.ɵprov = ɵɵdefineInjectable({ factory: function ReferenceApi_Factory() { return new ReferenceApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: ReferenceApi, providedIn: "root" });
2424
+ ReferenceApi = __decorate([
2425
+ Injectable({ providedIn: 'root' })
2426
+ ], ReferenceApi);
2427
+
2428
+ let TournamentNews = class TournamentNews extends BaseModel {
2429
+ static toFront(data) { }
2430
+ static toBack(data) { }
2431
+ };
2432
+ __decorate([
2433
+ ToFrontHook
2434
+ ], TournamentNews, "toFront", null);
2435
+ __decorate([
2436
+ ToBackHook
2437
+ ], TournamentNews, "toBack", null);
2438
+ TournamentNews = __decorate([
2439
+ ModelInstance({
2440
+ mappingFields: {
2441
+ id: 'id',
2442
+ title: 'title',
2443
+ picture: 'picture',
2444
+ text: 'text',
2445
+ author: 'author',
2446
+ created_at: 'createdAt',
2447
+ },
2448
+ relation: {
2449
+ picture: File,
2450
+ author: User,
2451
+ createdAt: DateTimeField,
2452
+ }
2453
+ })
2454
+ ], TournamentNews);
2455
+
2456
+ let GameTimelineStageItem = class GameTimelineStageItem {
2457
+ static toFront(data) { }
2458
+ static toBack(data) { }
2459
+ };
2460
+ __decorate([
2461
+ ToFrontHook
2462
+ ], GameTimelineStageItem, "toFront", null);
2463
+ __decorate([
2464
+ ToBackHook
2465
+ ], GameTimelineStageItem, "toBack", null);
2466
+ GameTimelineStageItem = __decorate([
2467
+ ModelInstance({
2468
+ mappingFields: {
2469
+ stage_id: 'stageId',
2470
+ tours_count: 'toursCount',
2471
+ playoff_stages_count: 'playoffStagesCount',
2472
+ }
2473
+ })
2474
+ ], GameTimelineStageItem);
2475
+ let GameTimelineStages = class GameTimelineStages extends BaseModel {
2476
+ static toFront(data) { }
2477
+ static toBack(data) { }
2478
+ };
2479
+ __decorate([
2480
+ ToFrontHook
2481
+ ], GameTimelineStages, "toFront", null);
2482
+ __decorate([
2483
+ ToBackHook
2484
+ ], GameTimelineStages, "toBack", null);
2485
+ GameTimelineStages = __decorate([
2486
+ ModelInstance({
2487
+ mappingFields: {
2488
+ tours_count: 'toursCount',
2489
+ playoff_stages_count: 'playoffStagesCount',
2490
+ current_tour: 'currentTour',
2491
+ current_playoff_stage: 'currentPlayoffStage',
2492
+ stages: 'stages',
2493
+ tournament_stage_id: 'tournamentStageId',
2494
+ },
2495
+ relation: {
2496
+ stages: listField(GameTimelineStageItem)
2497
+ }
2498
+ })
2499
+ ], GameTimelineStages);
2500
+
2501
+ var TournamentStageStatuses;
2502
+ (function (TournamentStageStatuses) {
2503
+ TournamentStageStatuses[TournamentStageStatuses["open"] = 0] = "open";
2504
+ TournamentStageStatuses[TournamentStageStatuses["in_progress"] = 1] = "in_progress";
2505
+ TournamentStageStatuses[TournamentStageStatuses["closed"] = 2] = "closed";
2506
+ })(TournamentStageStatuses || (TournamentStageStatuses = {}));
2507
+ let TournamentStage = class TournamentStage extends BaseModel {
2508
+ static toFront(data) { }
2509
+ static toBack(data) { }
2510
+ };
2511
+ __decorate([
2512
+ ToFrontHook
2513
+ ], TournamentStage, "toFront", null);
2514
+ __decorate([
2515
+ ToBackHook
2516
+ ], TournamentStage, "toBack", null);
2517
+ TournamentStage = __decorate([
2518
+ ModelInstance({
2519
+ mappingFields: {
2520
+ id: 'id',
2521
+ name: 'name',
2522
+ date: 'date',
2523
+ tournament_id: 'tournamentId',
2524
+ status: 'status',
2525
+ },
2526
+ relation: {
2527
+ date: DateField,
2528
+ status: enumField(TournamentStageStatuses)
2529
+ }
2530
+ })
2531
+ ], TournamentStage);
2532
+
2533
+ function generateArray(length) {
2534
+ if (length <= 0) {
2535
+ return [];
2536
+ }
2537
+ return Array.apply(null, Array(length)).map((_, i) => i + 1);
2538
+ }
2539
+ function getArrayChunks(array, length) {
2540
+ const chunks = [];
2541
+ const chunkLength = Math.ceil(array.length / length);
2542
+ if (chunkLength === 0) {
2543
+ return [array];
2544
+ }
2545
+ for (let i = 0; i < chunkLength; i++) {
2546
+ chunks.push(array.slice(i * length, (i + 1) * length));
2547
+ }
2548
+ return chunks;
2549
+ }
2550
+
2551
+ let PlayoffSettings = class PlayoffSettings extends BaseModel {
2552
+ static toFront(data) { }
2553
+ static toBack(data) { }
2554
+ };
2555
+ __decorate([
2556
+ ToFrontHook
2557
+ ], PlayoffSettings, "toFront", null);
2558
+ __decorate([
2559
+ ToBackHook
2560
+ ], PlayoffSettings, "toBack", null);
2561
+ PlayoffSettings = __decorate([
2562
+ ModelInstance({
2563
+ mappingFields: {
2564
+ rounds: 'rounds',
2565
+ final_rounds: 'finalRounds',
2566
+ third_place_rounds: 'thirdPlaceRounds',
2567
+ teams_count: 'teamsCount'
2568
+ }
2569
+ })
2570
+ ], PlayoffSettings);
2571
+ let Playoff = class Playoff extends BaseModel {
2572
+ constructor() {
2573
+ super(...arguments);
2574
+ this.stages = [];
2575
+ }
2576
+ static toFront(data) { }
2577
+ static toBack(data) { }
2578
+ get stagesCount() {
2579
+ return Math.log(this.settings.teamsCount) / Math.log(2);
2580
+ }
2581
+ getPlayoffStages() {
2582
+ if (this.stages.length === 0 && this.settings.teamsCount) {
2583
+ const stagesCount = Math.log(this.settings.teamsCount) / Math.log(2);
2584
+ this.stages = generateArray(stagesCount).map(stage => {
2585
+ const playoffStage = this.settings.teamsCount / Math.pow(2, stage);
2586
+ let title = '';
2587
+ if (playoffStage === 1) {
2588
+ title = 'Финал';
2589
+ }
2590
+ else {
2591
+ title = `1 / ${playoffStage}`;
2592
+ }
2593
+ return {
2594
+ value: stage,
2595
+ title
2596
+ };
2597
+ });
2598
+ }
2599
+ return this.stages;
2600
+ }
2601
+ };
2602
+ __decorate([
2603
+ ToFrontHook
2604
+ ], Playoff, "toFront", null);
2605
+ __decorate([
2606
+ ToBackHook
2607
+ ], Playoff, "toBack", null);
2608
+ Playoff = __decorate([
2609
+ ModelInstance({
2610
+ mappingFields: {
2611
+ id: 'id',
2612
+ name: 'name',
2613
+ settings: 'settings',
2614
+ tournament_id: 'tournamentId',
2615
+ tournament_stage_id: 'tournamentStageId',
2616
+ is_official: 'isOfficial'
2617
+ },
2618
+ relation: {
2619
+ settings: PlayoffSettings
2620
+ }
2621
+ })
2622
+ ], Playoff);
2623
+
2624
+ let VolleyballStatistic = class VolleyballStatistic extends BaseModel {
2625
+ static toFront(data) { }
2626
+ static toBack(data) { }
2627
+ };
2628
+ __decorate([
2629
+ ToFrontHook
2630
+ ], VolleyballStatistic, "toFront", null);
2631
+ __decorate([
2632
+ ToBackHook
2633
+ ], VolleyballStatistic, "toBack", null);
2634
+ VolleyballStatistic = __decorate([
2635
+ ModelInstance({
2636
+ mappingFields: {
2637
+ team: 'team',
2638
+ team_user: 'teamUser',
2639
+ tournament_team_user: 'tournamentTeamUser',
2640
+ tournament_team: 'tournamentTeam',
2641
+ user: 'user',
2642
+ month: 'month',
2643
+ win_lose: 'winLose',
2644
+ games_count: 'gamesCount',
2645
+ won_games_count: 'wonGamesCount',
2646
+ serve_hits: 'serveHits',
2647
+ serve_faults: 'serveFaults',
2648
+ serve_aces: 'serveAces',
2649
+ serve_percent: 'servePercent',
2650
+ ace_percent: 'acePercent',
2651
+ stuff_blocks: 'stuffBlocks',
2652
+ block_faults: 'blockFaults',
2653
+ block_rebounds: 'blockRebounds',
2654
+ block_percent: 'blockPercent',
2655
+ attack_spikes: 'attackSpikes',
2656
+ attack_faults: 'attackFaults',
2657
+ attack_shots: 'attackShots',
2658
+ attack_percent: 'attackPercent',
2659
+ receives: 'receives',
2660
+ receive_faults: 'receiveFaults',
2661
+ excellent_receives: 'excellentReceives',
2662
+ receive_percent: 'receivePercent',
2663
+ serve_receives: 'serveReceives',
2664
+ serve_receive_faults: 'serveReceiveFaults',
2665
+ excellent_serve_receives: 'excellentServeReceives',
2666
+ serve_receive_percent: 'serveReceivePercent',
2667
+ points: 'points',
2668
+ faults: 'faults',
2669
+ newbie: 'newbie',
2670
+ },
2671
+ relation: {
2672
+ team: Team,
2673
+ teamUser: TeamUser,
2674
+ tournamentTeamUser: TournamentTeamUser,
2675
+ tournamentTeam: TournamentTeam,
2676
+ user: User,
2677
+ month: DateField,
2678
+ }
2679
+ })
2680
+ ], VolleyballStatistic);
2681
+
2682
+ let TournamentStageTeam = class TournamentStageTeam extends BaseModel {
2683
+ get gamesWonPercent() {
2684
+ if (!this.gamesCount) {
2685
+ return 0;
2686
+ }
2687
+ return Math.floor(1000 * this.wonGamesCount / this.gamesCount) / 10;
2688
+ }
2689
+ static toFront(data) { }
2690
+ static toBack(data) { }
2691
+ };
2692
+ __decorate([
2693
+ ToFrontHook
2694
+ ], TournamentStageTeam, "toFront", null);
2695
+ __decorate([
2696
+ ToBackHook
2697
+ ], TournamentStageTeam, "toBack", null);
2698
+ TournamentStageTeam = __decorate([
2699
+ ModelInstance({
2700
+ mappingFields: {
2701
+ id: 'id',
2702
+ tournament_team: 'tournamentTeam',
2703
+ group: 'group',
2704
+ tournament_stage_id: 'tournamentStageId',
2705
+ games_count: 'gamesCount',
2706
+ won_games_count: 'wonGamesCount',
2707
+ score_sum: 'scoreSum',
2708
+ missed_sum: 'missedSum',
2709
+ last_games_count: 'lastGamesCount',
2710
+ last_games_won: 'lastGamesWon',
2711
+ points: 'points',
2712
+ final_standing: 'finalStanding',
2713
+ received_points: 'receivedPoints',
2714
+ },
2715
+ relation: {
2716
+ tournamentTeam: TournamentTeam,
2717
+ group: TournamentGroup
2718
+ }
2719
+ })
2720
+ ], TournamentStageTeam);
2721
+
2722
+ let TournamentApi = class TournamentApi {
2723
+ constructor(httpClient, configService) {
2724
+ this.httpClient = httpClient;
2725
+ this.configService = configService;
2726
+ }
2727
+ getByAlias(alias) {
2728
+ return __awaiter(this, void 0, void 0, function* () {
2729
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${alias}/`)
2730
+ .pipe(map(result => Tournament.toFront(result)))
2731
+ .toPromise();
2732
+ });
2733
+ }
2734
+ getNews(tournamentId) {
2735
+ return __awaiter(this, void 0, void 0, function* () {
2736
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/news/`)
2737
+ .pipe(map(result => TournamentNews.toFront(result)))
2738
+ .toPromise();
2739
+ });
2740
+ }
2741
+ getEvents(tournamentId, page, size, filters) {
2742
+ return __awaiter(this, void 0, void 0, function* () {
2743
+ let params = new HttpParams().set('page', page.toString())
2744
+ .set('size', size.toString());
2745
+ if (filters) {
2746
+ if (filters.event) {
2747
+ params = params.set('event', TournamentEventTypes[filters.event]);
2748
+ }
2749
+ if (filters.search) {
2750
+ params = params.set('search', filters.search);
2751
+ }
2752
+ }
2753
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/events/`, { params, observe: 'response' })
2754
+ .pipe(map(result => ({
2755
+ total: +result.headers.get('X-Page-Count'),
2756
+ data: TournamentEvent.toFront(result.body)
2757
+ })))
2758
+ .toPromise();
2759
+ });
2760
+ }
2761
+ getTournamentStages(tournamentId) {
2762
+ return __awaiter(this, void 0, void 0, function* () {
2763
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/stages/`).pipe(map(data => TournamentStage.toFront(data))).toPromise();
2764
+ });
2765
+ }
2766
+ getPlayoff(tournamentId) {
2767
+ return __awaiter(this, void 0, void 0, function* () {
2768
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/playoff/`).pipe(map(result => Playoff.toFront(result))).toPromise();
2769
+ });
2770
+ }
2771
+ getPlayoffGames(playoffId) {
2772
+ return __awaiter(this, void 0, void 0, function* () {
2773
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_playoff/${playoffId}/games/`).pipe(map(result => Game.toFront(result))).toPromise();
2774
+ });
2775
+ }
2776
+ getGamesStages(tournamentId) {
2777
+ return __awaiter(this, void 0, void 0, function* () {
2778
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/games_stages/`)
2779
+ .pipe(map(data => GameTimelineStages.toFront(data)))
2780
+ .toPromise();
2781
+ });
2782
+ }
2783
+ getGames(tournamentId, page, size, filters = {}) {
2784
+ return __awaiter(this, void 0, void 0, function* () {
2785
+ let params = new HttpParams().set('page', page.toString());
2786
+ if (size) {
2787
+ params = params.set('size', size.toString());
2788
+ }
2789
+ if (filters.tournamentStageId) {
2790
+ params = params.set('tournament_stage_id', filters.tournamentStageId.toString());
2791
+ }
2792
+ if (filters.tournamentTour) {
2793
+ params = params.set('tournament_tour', filters.tournamentTour.toString());
2794
+ }
2795
+ if (filters.playoffStage) {
2796
+ params = params.set('playoff_stage', filters.playoffStage.toString());
2797
+ }
2798
+ if (filters.teamId) {
2799
+ params = params.set('team_id', filters.teamId.toString());
2800
+ }
2801
+ if (filters.status) {
2802
+ params = params.set('status', GameStatuses[filters.status]);
2803
+ }
2804
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/games/`, { params, observe: 'response' })
2805
+ .pipe(map(result => ({
2806
+ total: +result.headers.get('X-Page-Count'),
2807
+ data: Game.toFront(result.body)
2808
+ }))).toPromise();
2809
+ });
2810
+ }
2811
+ getTeams(tournamentId) {
2812
+ return __awaiter(this, void 0, void 0, function* () {
2813
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/teams/`)
2814
+ .pipe(map(result => TournamentTeam.toFront(result)))
2815
+ .toPromise();
2816
+ });
2817
+ }
2818
+ getStageTeams(tournamentId) {
2819
+ return __awaiter(this, void 0, void 0, function* () {
2820
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/stage_teams/`)
2821
+ .pipe(map(result => TournamentStageTeam.toFront(result)))
2822
+ .toPromise();
2823
+ });
2824
+ }
2825
+ getTeamById(tournamentTeamId) {
2826
+ return __awaiter(this, void 0, void 0, function* () {
2827
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_team/${tournamentTeamId}/`)
2828
+ .pipe(map(result => TournamentTeam.toFront(result)))
2829
+ .toPromise();
2830
+ });
2831
+ }
2832
+ getUserById(userId) {
2833
+ return __awaiter(this, void 0, void 0, function* () {
2834
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_team_user/${userId}/`)
2835
+ .pipe(map(result => TournamentTeamUser.toFront(result)))
2836
+ .toPromise();
2837
+ });
2838
+ }
2839
+ getUserGames(tournamentUserId) {
2840
+ return __awaiter(this, void 0, void 0, function* () {
2841
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_team_user/${tournamentUserId}/games/`)
2842
+ .pipe(map(result => Game.toFront(result)))
2843
+ .toPromise();
2844
+ });
2845
+ }
2846
+ getBasketballStatistic(filters) {
2847
+ return __awaiter(this, void 0, void 0, function* () {
2848
+ let params = new HttpParams();
2849
+ if (filters) {
2850
+ for (const key of Object.keys(filters)) {
2851
+ if (filters[key]) {
2852
+ params = params.set(key, filters[key]);
2853
+ }
2854
+ }
2855
+ if (filters.per_game !== undefined) {
2856
+ params = params.set('per_game', filters.per_game ? '1' : '0');
2857
+ }
2858
+ }
2859
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/basketball_statistic/`, { params }).pipe(map(result => BasketballStatistic.toFront(result))).toPromise();
2860
+ });
2861
+ }
2862
+ getVolleyballStatistic(filters) {
2863
+ return __awaiter(this, void 0, void 0, function* () {
2864
+ let params = new HttpParams();
2865
+ if (filters) {
2866
+ for (const key of Object.keys(filters)) {
2867
+ if (filters[key]) {
2868
+ params = params.set(key, filters[key]);
2869
+ }
2870
+ }
2871
+ if (filters.per_game !== undefined) {
2872
+ params = params.set('per_game', filters.per_game ? '1' : '0');
2873
+ }
2874
+ }
2875
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/volleyball_statistic/`, { params }).pipe(map(result => VolleyballStatistic.toFront(result))).toPromise();
2876
+ });
2877
+ }
2878
+ };
2879
+ TournamentApi.ctorParameters = () => [
2880
+ { type: HttpClient },
2881
+ { type: ConfigService }
2882
+ ];
2883
+ TournamentApi.ɵprov = ɵɵdefineInjectable({ factory: function TournamentApi_Factory() { return new TournamentApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: TournamentApi, providedIn: "root" });
2884
+ TournamentApi = __decorate([
2885
+ Injectable({ providedIn: 'root' })
2886
+ ], TournamentApi);
2887
+
2888
+ let TournamentJoinData = class TournamentJoinData extends BaseModel {
2889
+ get usersCount() {
2890
+ return this.validUsersCount + this.invalidUsersCount;
2891
+ }
2892
+ get valid() {
2893
+ return this.hasAccess && !this.inviteSent && !this.alreadyInTournament;
2894
+ }
2895
+ static toFront(data) { }
2896
+ static toBack(data) { }
2897
+ };
2898
+ __decorate([
2899
+ ToFrontHook
2900
+ ], TournamentJoinData, "toFront", null);
2901
+ __decorate([
2902
+ ToBackHook
2903
+ ], TournamentJoinData, "toBack", null);
2904
+ TournamentJoinData = __decorate([
2905
+ ModelInstance({
2906
+ mappingFields: {
2907
+ valid_users_count: 'validUsersCount',
2908
+ invalid_users_count: 'invalidUsersCount',
2909
+ has_access: 'hasAccess',
2910
+ invite_sent: 'inviteSent',
2911
+ already_in_tournament: 'alreadyInTournament'
2912
+ }
2913
+ })
2914
+ ], TournamentJoinData);
2915
+ let TournamentJoinTeam = class TournamentJoinTeam extends BaseModel {
2916
+ static toFront(data) { }
2917
+ static toBack(data) { }
2918
+ };
2919
+ __decorate([
2920
+ ToFrontHook
2921
+ ], TournamentJoinTeam, "toFront", null);
2922
+ __decorate([
2923
+ ToBackHook
2924
+ ], TournamentJoinTeam, "toBack", null);
2925
+ TournamentJoinTeam = __decorate([
2926
+ ModelInstance({
2927
+ mappingFields: {
2928
+ team: 'team',
2929
+ join_data: 'joinData'
2930
+ },
2931
+ relation: {
2932
+ team: Team,
2933
+ joinData: TournamentJoinData
2934
+ }
2935
+ })
2936
+ ], TournamentJoinTeam);
2937
+
2938
+ let TournamentJoinApi = class TournamentJoinApi {
2939
+ constructor(httpClient, configService) {
2940
+ this.httpClient = httpClient;
2941
+ this.configService = configService;
2942
+ }
2943
+ getTeamsForJoin(tournamentId) {
2944
+ return __awaiter(this, void 0, void 0, function* () {
2945
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/teams_for_join/`).pipe(map(response => TournamentJoinTeam.toFront(response))).toPromise();
2946
+ });
2947
+ }
2948
+ getTeamUsers(teamId) {
2949
+ return __awaiter(this, void 0, void 0, function* () {
2950
+ return this.httpClient
2951
+ .get(`${this.configService.get('apiUrl')}/api/v1/team/${teamId}/users/`)
2952
+ .pipe(map(data => TeamUser.toFront(data))).toPromise();
2953
+ });
2954
+ }
2955
+ joinTournament(tournamentId, teamId, invites) {
2956
+ return __awaiter(this, void 0, void 0, function* () {
2957
+ const body = {
2958
+ team: { id: teamId },
2959
+ user_invites: TournamentTeamUserInvite.toBack(invites)
2960
+ };
2961
+ return this.httpClient.post(`${this.configService.get('apiUrl')}/api/v1/tournament/${tournamentId}/join/`, body)
2962
+ .pipe(map(data => TournamentInvite.toFront(data)))
2963
+ .toPromise();
2964
+ });
2965
+ }
2966
+ };
2967
+ TournamentJoinApi.ctorParameters = () => [
2968
+ { type: HttpClient },
2969
+ { type: ConfigService }
2970
+ ];
2971
+ TournamentJoinApi.ɵprov = ɵɵdefineInjectable({ factory: function TournamentJoinApi_Factory() { return new TournamentJoinApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: TournamentJoinApi, providedIn: "root" });
2972
+ TournamentJoinApi = __decorate([
2973
+ Injectable({ providedIn: 'root' })
2974
+ ], TournamentJoinApi);
2975
+
2976
+ let TournamentStageApi = class TournamentStageApi {
2977
+ constructor(httpClient, configService) {
2978
+ this.httpClient = httpClient;
2979
+ this.configService = configService;
2980
+ }
2981
+ getById(id) {
2982
+ return __awaiter(this, void 0, void 0, function* () {
2983
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_stage/${id}/`)
2984
+ .pipe(map(result => TournamentStage.toFront(result)))
2985
+ .toPromise();
2986
+ });
2987
+ }
2988
+ getGroups(stageId) {
2989
+ return __awaiter(this, void 0, void 0, function* () {
2990
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_stage/${stageId}/groups/`)
2991
+ .pipe(map(result => TournamentGroup.toFront(result)))
2992
+ .toPromise();
2993
+ });
2994
+ }
2995
+ getPlayoffs(stageId) {
2996
+ return __awaiter(this, void 0, void 0, function* () {
2997
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_stage/${stageId}/playoff/`)
2998
+ .pipe(map(result => Playoff.toFront(result)))
2999
+ .toPromise();
3000
+ });
3001
+ }
3002
+ getTeams(stageId) {
3003
+ return __awaiter(this, void 0, void 0, function* () {
3004
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_stage/${stageId}/teams/`)
3005
+ .pipe(map(result => TournamentStageTeam.toFront(result)))
3006
+ .toPromise();
3007
+ });
3008
+ }
3009
+ };
3010
+ TournamentStageApi.ctorParameters = () => [
3011
+ { type: HttpClient },
3012
+ { type: ConfigService }
3013
+ ];
3014
+ TournamentStageApi.ɵprov = ɵɵdefineInjectable({ factory: function TournamentStageApi_Factory() { return new TournamentStageApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: TournamentStageApi, providedIn: "root" });
3015
+ TournamentStageApi = __decorate([
3016
+ Injectable({ providedIn: 'root' })
3017
+ ], TournamentStageApi);
3018
+
3019
+ let VolleyballGameTeamStatistic = class VolleyballGameTeamStatistic extends BaseModel {
3020
+ static toFront(data) { }
3021
+ static toBack(data) { }
3022
+ };
3023
+ __decorate([
3024
+ ToFrontHook
3025
+ ], VolleyballGameTeamStatistic, "toFront", null);
3026
+ __decorate([
3027
+ ToBackHook
3028
+ ], VolleyballGameTeamStatistic, "toBack", null);
3029
+ VolleyballGameTeamStatistic = __decorate([
3030
+ ModelInstance({
3031
+ mappingFields: {
3032
+ team: 'team',
3033
+ competitor_team: 'competitorTeam',
3034
+ },
3035
+ relation: {
3036
+ team: VolleyballStatistic,
3037
+ competitorTeam: VolleyballStatistic,
3038
+ }
3039
+ })
3040
+ ], VolleyballGameTeamStatistic);
3041
+
3042
+ let VolleyballGameStatistic = class VolleyballGameStatistic extends BaseModel {
3043
+ get id() {
3044
+ return this.gameUserId;
3045
+ }
3046
+ get attacks() {
3047
+ return this.attackSpikes + this.attackShots;
3048
+ }
3049
+ get blocks() {
3050
+ return this.stuffBlocks + this.blockRebounds;
3051
+ }
3052
+ get totalReceives() {
3053
+ return this.receives + this.excellentReceives;
3054
+ }
3055
+ static toFront(data) { }
3056
+ static toBack(data) { }
3057
+ };
3058
+ __decorate([
3059
+ ToFrontHook
3060
+ ], VolleyballGameStatistic, "toFront", null);
3061
+ __decorate([
3062
+ ToBackHook
3063
+ ], VolleyballGameStatistic, "toBack", null);
3064
+ VolleyballGameStatistic = __decorate([
3065
+ ModelInstance({
3066
+ mappingFields: {
3067
+ game_user_id: 'gameUserId',
3068
+ serve_hits: 'serveHits',
3069
+ serve_faults: 'serveFaults',
3070
+ serve_aces: 'serveAces',
3071
+ stuff_blocks: 'stuffBlocks',
3072
+ block_faults: 'blockFaults',
3073
+ block_rebounds: 'blockRebounds',
3074
+ attack_spikes: 'attackSpikes',
3075
+ attack_faults: 'attackFaults',
3076
+ attack_shots: 'attackShots',
3077
+ receives: 'receives',
3078
+ receive_faults: 'receiveFaults',
3079
+ excellent_receives: 'excellentReceives',
3080
+ serve_receives: 'serveReceives',
3081
+ serve_receive_faults: 'serveReceiveFaults',
3082
+ excellent_serve_receives: 'excellentServeReceives',
3083
+ points: 'points',
3084
+ faults: 'faults',
3085
+ }
3086
+ })
3087
+ ], VolleyballGameStatistic);
3088
+
3089
+ var VolleyballGameLogType;
3090
+ (function (VolleyballGameLogType) {
3091
+ VolleyballGameLogType[VolleyballGameLogType["enter_game"] = 1] = "enter_game";
3092
+ VolleyballGameLogType[VolleyballGameLogType["exit_game"] = 2] = "exit_game";
3093
+ VolleyballGameLogType[VolleyballGameLogType["remove_game"] = 3] = "remove_game";
3094
+ VolleyballGameLogType[VolleyballGameLogType["serve_hit"] = 4] = "serve_hit";
3095
+ VolleyballGameLogType[VolleyballGameLogType["serve_fault"] = 5] = "serve_fault";
3096
+ VolleyballGameLogType[VolleyballGameLogType["serve_ace"] = 6] = "serve_ace";
3097
+ VolleyballGameLogType[VolleyballGameLogType["stuff_block"] = 7] = "stuff_block";
3098
+ VolleyballGameLogType[VolleyballGameLogType["block_fault"] = 8] = "block_fault";
3099
+ VolleyballGameLogType[VolleyballGameLogType["block_rebound"] = 9] = "block_rebound";
3100
+ VolleyballGameLogType[VolleyballGameLogType["attack_spike"] = 10] = "attack_spike";
3101
+ VolleyballGameLogType[VolleyballGameLogType["attack_fault"] = 11] = "attack_fault";
3102
+ VolleyballGameLogType[VolleyballGameLogType["attack_shot"] = 12] = "attack_shot";
3103
+ VolleyballGameLogType[VolleyballGameLogType["receive"] = 13] = "receive";
3104
+ VolleyballGameLogType[VolleyballGameLogType["receive_fault"] = 14] = "receive_fault";
3105
+ VolleyballGameLogType[VolleyballGameLogType["excellent_receive"] = 15] = "excellent_receive";
3106
+ VolleyballGameLogType[VolleyballGameLogType["point"] = 16] = "point";
3107
+ VolleyballGameLogType[VolleyballGameLogType["fault"] = 17] = "fault";
3108
+ VolleyballGameLogType[VolleyballGameLogType["serve_receive"] = 18] = "serve_receive";
3109
+ VolleyballGameLogType[VolleyballGameLogType["serve_receive_fault"] = 19] = "serve_receive_fault";
3110
+ VolleyballGameLogType[VolleyballGameLogType["excellent_serve_receive"] = 20] = "excellent_serve_receive";
3111
+ VolleyballGameLogType[VolleyballGameLogType["timeout"] = 21] = "timeout";
3112
+ })(VolleyballGameLogType || (VolleyballGameLogType = {}));
3113
+ const SCORE_LOG_TYPES = [
3114
+ VolleyballGameLogType.serve_ace, VolleyballGameLogType.stuff_block,
3115
+ VolleyballGameLogType.attack_spike, VolleyballGameLogType.point
3116
+ ];
3117
+ const FAULT_LOG_TYPES = [
3118
+ VolleyballGameLogType.serve_fault, VolleyballGameLogType.attack_fault,
3119
+ VolleyballGameLogType.block_fault, VolleyballGameLogType.receive_fault,
3120
+ VolleyballGameLogType.fault, VolleyballGameLogType.serve_receive_fault
3121
+ ];
3122
+ let VolleyballGameLog = class VolleyballGameLog extends BaseModel {
3123
+ constructor() {
3124
+ super(...arguments);
3125
+ this.active = true;
3126
+ }
3127
+ compare(model) {
3128
+ if (this.rally === model.rally && this.set === model.set) {
3129
+ if (this.datetime && model.datetime) {
3130
+ return this.datetime.getTime() < model.datetime.getTime() ? 1 : -1;
3131
+ }
3132
+ else {
3133
+ return this.id < model.id ? 1 : -1;
3134
+ }
3135
+ }
3136
+ if (this.set === model.set) {
3137
+ return this.rally < model.rally ? 1 : -1;
3138
+ }
3139
+ return this.set < model.set ? 1 : -1;
3140
+ }
3141
+ isScoreType() {
3142
+ return SCORE_LOG_TYPES.includes(this.logType);
3143
+ }
3144
+ isFaultType() {
3145
+ return FAULT_LOG_TYPES.includes(this.logType);
3146
+ }
3147
+ isServe() {
3148
+ return [
3149
+ VolleyballGameLogType.serve_hit,
3150
+ VolleyballGameLogType.serve_ace,
3151
+ VolleyballGameLogType.serve_fault
3152
+ ].includes(this.logType);
3153
+ }
3154
+ isAttack() {
3155
+ return [
3156
+ VolleyballGameLogType.attack_fault,
3157
+ VolleyballGameLogType.attack_spike,
3158
+ VolleyballGameLogType.attack_shot
3159
+ ].includes(this.logType);
3160
+ }
3161
+ isReceive() {
3162
+ return [
3163
+ VolleyballGameLogType.receive_fault,
3164
+ VolleyballGameLogType.receive,
3165
+ VolleyballGameLogType.excellent_receive
3166
+ ].includes(this.logType);
3167
+ }
3168
+ isServeReceive() {
3169
+ return [
3170
+ VolleyballGameLogType.serve_receive_fault,
3171
+ VolleyballGameLogType.serve_receive,
3172
+ VolleyballGameLogType.excellent_serve_receive
3173
+ ].includes(this.logType);
3174
+ }
3175
+ isBlock() {
3176
+ return [
3177
+ VolleyballGameLogType.block_fault,
3178
+ VolleyballGameLogType.block_rebound,
3179
+ VolleyballGameLogType.stuff_block
3180
+ ].includes(this.logType);
3181
+ }
3182
+ isEnterExit() {
3183
+ return [
3184
+ VolleyballGameLogType.enter_game,
3185
+ VolleyballGameLogType.exit_game,
3186
+ VolleyballGameLogType.timeout
3187
+ ].includes(this.logType);
3188
+ }
3189
+ isComboType() {
3190
+ return ![
3191
+ VolleyballGameLogType.receive,
3192
+ VolleyballGameLogType.serve_receive
3193
+ ].includes(this.logType);
3194
+ }
3195
+ static toFront(data) { }
3196
+ static toBack(data) { }
3197
+ };
3198
+ __decorate([
3199
+ ToFrontHook
3200
+ ], VolleyballGameLog, "toFront", null);
3201
+ __decorate([
3202
+ ToBackHook
3203
+ ], VolleyballGameLog, "toBack", null);
3204
+ VolleyballGameLog = __decorate([
3205
+ ModelInstance({
3206
+ mappingFields: {
3207
+ id: 'id',
3208
+ unique_id: 'uniqueId',
3209
+ game_id: 'gameId',
3210
+ game_user_id: 'gameUserId',
3211
+ log_type: 'logType',
3212
+ set: 'set',
3213
+ rally: 'rally',
3214
+ position: 'position',
3215
+ team_id: 'teamId',
3216
+ datetime: 'datetime',
3217
+ },
3218
+ relation: {
3219
+ logType: enumField(VolleyballGameLogType),
3220
+ datetime: DateTimeField
3221
+ }
3222
+ })
3223
+ ], VolleyballGameLog);
3224
+
3225
+ let VolleyballGameApi = class VolleyballGameApi {
3226
+ constructor(httpClient, configService) {
3227
+ this.httpClient = httpClient;
3228
+ this.configService = configService;
3229
+ }
3230
+ getById(gameId) {
3231
+ return __awaiter(this, void 0, void 0, function* () {
3232
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_volleyball_game/${gameId}/`).pipe(map(result => Game.toFront(result))).toPromise();
3233
+ });
3234
+ }
3235
+ getUsers(gameId) {
3236
+ return __awaiter(this, void 0, void 0, function* () {
3237
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_game/${gameId}/users/`).pipe(map(result => GameUser.toFront(result))).toPromise();
3238
+ });
3239
+ }
3240
+ getTeamStatistic(gameId) {
3241
+ return __awaiter(this, void 0, void 0, function* () {
3242
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_volleyball_game/${gameId}/team_statistic/`).pipe(map(result => VolleyballGameTeamStatistic.toFront(result))).toPromise();
3243
+ });
3244
+ }
3245
+ getUserStatistic(gameId) {
3246
+ return __awaiter(this, void 0, void 0, function* () {
3247
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_volleyball_game/${gameId}/user_statistic/`).pipe(map(result => VolleyballGameStatistic.toFront(result))).toPromise();
3248
+ });
3249
+ }
3250
+ getLogs(gameId) {
3251
+ return __awaiter(this, void 0, void 0, function* () {
3252
+ return this.httpClient.get(`${this.configService.get('apiUrl')}/api/v1/tournament_volleyball_game/${gameId}/logs/`).pipe(map(result => VolleyballGameLog.toFront(result))).toPromise();
3253
+ });
3254
+ }
3255
+ };
3256
+ VolleyballGameApi.ctorParameters = () => [
3257
+ { type: HttpClient },
3258
+ { type: ConfigService }
3259
+ ];
3260
+ VolleyballGameApi.ɵprov = ɵɵdefineInjectable({ factory: function VolleyballGameApi_Factory() { return new VolleyballGameApi(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: VolleyballGameApi, providedIn: "root" });
3261
+ VolleyballGameApi = __decorate([
3262
+ Injectable({ providedIn: 'root' })
3263
+ ], VolleyballGameApi);
3264
+
3265
+ const BasketballGameLogTypeLocalization = {
3266
+ [BasketballGameLogTypes.enter_game]: 'Выход на площадку',
3267
+ [BasketballGameLogTypes.exit_game]: 'Ушел с площадки',
3268
+ [BasketballGameLogTypes.remove_game]: 'Удаление с площадки',
3269
+ [BasketballGameLogTypes.two_point_attempt]: 'Бросок 2 очка',
3270
+ [BasketballGameLogTypes.three_point_attempt]: 'Бросок 3 очка',
3271
+ [BasketballGameLogTypes.free_throw_attempt]: 'Штрафной бросок',
3272
+ [BasketballGameLogTypes.one_point_attempt]: 'Бросок 1 очко',
3273
+ [BasketballGameLogTypes.two_point_made]: '2 очка',
3274
+ [BasketballGameLogTypes.three_point_made]: '3 очка',
3275
+ [BasketballGameLogTypes.free_throw_made]: '1 очко, штрафной',
3276
+ [BasketballGameLogTypes.one_point_made]: '1 очко',
3277
+ [BasketballGameLogTypes.assist]: 'Передача',
3278
+ [BasketballGameLogTypes.block]: 'Блокшот',
3279
+ [BasketballGameLogTypes.rebound]: 'Подбор',
3280
+ [BasketballGameLogTypes.offensive_rebound]: 'Подбор в нападении',
3281
+ [BasketballGameLogTypes.defensive_rebound]: 'Подбор в защите',
3282
+ [BasketballGameLogTypes.steal]: 'Перехват',
3283
+ [BasketballGameLogTypes.turnover]: 'Потеря',
3284
+ [BasketballGameLogTypes.personal_foul]: 'Фол',
3285
+ [BasketballGameLogTypes.technical_foul]: 'Технический фол',
3286
+ [BasketballGameLogTypes.unsportsmanlike_foul]: 'Неспортиный фол',
3287
+ [BasketballGameLogTypes.timeout]: 'Таймаут',
3288
+ };
3289
+
3290
+ const OvertimeTypeLocalization = {
3291
+ [OvertimeTypes.to_score_diff]: 'До разницы в N мячей',
3292
+ [OvertimeTypes.to_score_total]: 'До N очков',
3293
+ [OvertimeTypes.time]: 'По времени'
3294
+ };
3295
+
3296
+ const TeamUserRoleLocalization = {
3297
+ [TeamUserRole.moderator]: 'Модератор',
3298
+ [TeamUserRole.member]: 'Пользователь',
3299
+ [TeamUserRole.admin]: 'Владелец',
3300
+ };
3301
+
3302
+ const GameBasketballPositionLocalization = {
3303
+ [GameBasketballPosition.point_guard]: 'Разыгрывающий защитник',
3304
+ [GameBasketballPosition.shooting_guard]: 'Атакующий защитник',
3305
+ [GameBasketballPosition.small_forward]: 'Легкий форвард',
3306
+ [GameBasketballPosition.power_forward]: 'Мощный форвард',
3307
+ [GameBasketballPosition.center]: 'Центровой',
3308
+ };
3309
+ const GameBasketballPositionShortLocalization = {
3310
+ [GameBasketballPosition.point_guard]: 'PG',
3311
+ [GameBasketballPosition.shooting_guard]: 'SG',
3312
+ [GameBasketballPosition.small_forward]: 'SF',
3313
+ [GameBasketballPosition.power_forward]: 'PF',
3314
+ [GameBasketballPosition.center]: 'C',
3315
+ };
3316
+ const WorkHandLocalization = {
3317
+ [WorkHand.left]: 'Левая',
3318
+ [WorkHand.right]: 'Правая'
3319
+ };
3320
+ const GameVolleyballPositionLocalization = {
3321
+ [GameVolleyballPosition.setter]: 'Связующий',
3322
+ [GameVolleyballPosition.libero]: 'Либеро',
3323
+ [GameVolleyballPosition.middle_player]: 'Центральный блокирующий',
3324
+ [GameVolleyballPosition.receiver_attacker]: 'Доигровщик',
3325
+ [GameVolleyballPosition.dioganal]: 'Диагональный',
3326
+ };
3327
+ const GameVolleyballPositionShortLocalization = {
3328
+ [GameVolleyballPosition.setter]: 'S',
3329
+ [GameVolleyballPosition.libero]: 'L',
3330
+ [GameVolleyballPosition.middle_player]: 'MP',
3331
+ [GameVolleyballPosition.receiver_attacker]: 'RA',
3332
+ [GameVolleyballPosition.dioganal]: 'D',
3333
+ };
3334
+ const GameVolleyballPositionShortRuLocalization = {
3335
+ [GameVolleyballPosition.setter]: 'связ.',
3336
+ [GameVolleyballPosition.libero]: 'либеро',
3337
+ [GameVolleyballPosition.middle_player]: 'блок.',
3338
+ [GameVolleyballPosition.receiver_attacker]: 'доигр.',
3339
+ [GameVolleyballPosition.dioganal]: 'диаг.',
3340
+ };
3341
+ const VolleyballWorkHandLocalization = {
3342
+ [VolleyballWorkHand.left]: 'Левая',
3343
+ [VolleyballWorkHand.right]: 'Правая'
3344
+ };
3345
+
3346
+ const VolleyballGameLogTypeLocalization = {
3347
+ [VolleyballGameLogType.enter_game]: 'Выход на площадку',
3348
+ [VolleyballGameLogType.exit_game]: 'Уход с площадки',
3349
+ [VolleyballGameLogType.remove_game]: 'Удаление с площадки',
3350
+ [VolleyballGameLogType.serve_ace]: 'Эйс',
3351
+ [VolleyballGameLogType.serve_hit]: 'Подача',
3352
+ [VolleyballGameLogType.serve_fault]: 'Ошибка на подаче',
3353
+ [VolleyballGameLogType.attack_spike]: 'Результативная атака',
3354
+ [VolleyballGameLogType.attack_shot]: 'Успешная атака',
3355
+ [VolleyballGameLogType.attack_fault]: 'Ошибка атаки',
3356
+ [VolleyballGameLogType.stuff_block]: 'Результативный блок',
3357
+ [VolleyballGameLogType.block_rebound]: 'Успешный блок',
3358
+ [VolleyballGameLogType.block_fault]: 'Ошибка на блоке',
3359
+ [VolleyballGameLogType.excellent_receive]: 'Отличный прием',
3360
+ [VolleyballGameLogType.receive]: 'Прием',
3361
+ [VolleyballGameLogType.receive_fault]: 'Ошибка на приеме',
3362
+ [VolleyballGameLogType.serve_receive]: 'Прием подачи',
3363
+ [VolleyballGameLogType.excellent_serve_receive]: 'Отличный прием подачи',
3364
+ [VolleyballGameLogType.serve_receive_fault]: 'Ошибка приема подачи',
3365
+ [VolleyballGameLogType.point]: 'Очко',
3366
+ [VolleyballGameLogType.fault]: 'Ошибка',
3367
+ [VolleyballGameLogType.timeout]: 'Таймаут',
3368
+ };
3369
+
3370
+ let TeamInviteExternal = class TeamInviteExternal extends BaseModel {
3371
+ static toFront(data) { }
3372
+ static toBack(data) { }
3373
+ };
3374
+ __decorate([
3375
+ ToFrontHook
3376
+ ], TeamInviteExternal, "toFront", null);
3377
+ __decorate([
3378
+ ToBackHook
3379
+ ], TeamInviteExternal, "toBack", null);
3380
+ TeamInviteExternal = __decorate([
3381
+ ModelInstance({
3382
+ mappingFields: {
3383
+ id: 'id',
3384
+ team_id: 'teamId',
3385
+ email: 'email',
3386
+ first_name: 'firstName',
3387
+ last_name: 'lastName',
3388
+ },
3389
+ })
3390
+ ], TeamInviteExternal);
3391
+
3392
+ let CentrifugoService = class CentrifugoService {
3393
+ constructor(httpClient, configService) {
3394
+ this.httpClient = httpClient;
3395
+ this.configService = configService;
3396
+ this.channels$ = {};
3397
+ this.subscriptions = {};
3398
+ }
3399
+ listen(channel) {
3400
+ if (channel in this.channels$) {
3401
+ return this.channels$[channel];
3402
+ }
3403
+ this.channels$[channel] = new Subject();
3404
+ const subscription = this.connect().subscribe(connected => {
3405
+ this.subscriptions[channel] = this.addEngineSubscription(channel);
3406
+ setTimeout(() => {
3407
+ subscription.unsubscribe();
3408
+ });
3409
+ });
3410
+ return this.channels$[channel];
3411
+ }
3412
+ unsubscribe(channel) {
3413
+ if (this.subscriptions[channel]) {
3414
+ this.subscriptions[channel].unsubscribe();
3415
+ delete this.subscriptions[channel];
3416
+ }
3417
+ if (this.channels$[channel]) {
3418
+ this.channels$[channel].complete();
3419
+ delete this.channels$[channel];
3420
+ }
3421
+ }
3422
+ connect() {
3423
+ if (!this.initializeEngineSubject) {
3424
+ this.initializeEngineSubject = new ReplaySubject(1);
3425
+ this.httpClient.get('/api/v1/centrifugo/')
3426
+ .subscribe(config => {
3427
+ this.initializeEngine({
3428
+ url: this.configService.get('centrifugoUrl'),
3429
+ user: config.user,
3430
+ timestamp: config.timestamp,
3431
+ token: config.token,
3432
+ transports: ['websocket']
3433
+ });
3434
+ this.centrifuge.connect();
3435
+ this.centrifuge.on('connect', () => {
3436
+ this.initializeEngineSubject.next(true);
3437
+ });
3438
+ });
3439
+ }
3440
+ return this.initializeEngineSubject;
3441
+ }
3442
+ publish(channel, message) {
3443
+ return new Observable(observer => {
3444
+ this.connect().subscribe(() => {
3445
+ if (!this.subscriptions[channel]) {
3446
+ this.subscriptions[channel] = this.addEngineSubscription(channel);
3447
+ }
3448
+ this.subscriptions[channel].publish(message).then(res => {
3449
+ observer.next(res);
3450
+ observer.complete();
3451
+ }, error => {
3452
+ throw error;
3453
+ });
3454
+ });
3455
+ });
3456
+ }
3457
+ disconnect() {
3458
+ this.centrifuge.disconnect();
3459
+ this.initializeEngineSubject = undefined;
3460
+ this.channels$ = {};
3461
+ this.subscriptions = {};
3462
+ }
3463
+ initializeEngine(config) {
3464
+ console.log(config);
3465
+ this.centrifuge = new Centrifuge(config);
3466
+ }
3467
+ addEngineSubscription(channel) {
3468
+ return this.centrifuge.subscribe(channel, this.resolveMessage.bind(this));
3469
+ }
3470
+ resolveMessage(response) {
3471
+ const channel = response.channel;
3472
+ if (!this.channels$[channel]) {
3473
+ return;
3474
+ }
3475
+ this.channels$[channel].next(response.data);
3476
+ }
3477
+ };
3478
+ CentrifugoService.ctorParameters = () => [
3479
+ { type: HttpClient },
3480
+ { type: ConfigService }
3481
+ ];
3482
+ CentrifugoService.ɵprov = ɵɵdefineInjectable({ factory: function CentrifugoService_Factory() { return new CentrifugoService(ɵɵinject(HttpClient), ɵɵinject(ConfigService)); }, token: CentrifugoService, providedIn: "root" });
3483
+ CentrifugoService = __decorate([
3484
+ Injectable({ providedIn: 'root' })
3485
+ ], CentrifugoService);
3486
+
3487
+ class StorageEngineField {
3488
+ constructor(defaultValue, modelClass) {
3489
+ this.modelClass = modelClass;
3490
+ this.defaultValue = defaultValue;
3491
+ }
3492
+ toFront(value) {
3493
+ if (this.modelClass) {
3494
+ return this.modelClass.toFront(value);
3495
+ }
3496
+ return value;
3497
+ }
3498
+ toBack(value) {
3499
+ if (this.modelClass) {
3500
+ return this.modelClass.toBack(value);
3501
+ }
3502
+ return value;
3503
+ }
3504
+ }
3505
+ class StorageEngine {
3506
+ constructor(name, fields) {
3507
+ this.name = name;
3508
+ this.fields = fields;
3509
+ }
3510
+ addField(key, field) {
3511
+ this.fields[key] = field;
3512
+ }
3513
+ save(key, value) {
3514
+ if (!this.fields[key]) {
3515
+ return;
3516
+ }
3517
+ this.setItem(`${this.name}_${key}`, this.fields[key].toBack(value));
3518
+ }
3519
+ get(key) {
3520
+ if (!this.fields[key]) {
3521
+ return;
3522
+ }
3523
+ let value = this.getItem(`${this.name}_${key}`);
3524
+ if (value === null) {
3525
+ value = this.fields[key].defaultValue;
3526
+ }
3527
+ if (value === null || value === undefined) {
3528
+ return value;
3529
+ }
3530
+ return this.fields[key].toFront(value);
3531
+ }
3532
+ clear() {
3533
+ for (const field of Object.keys(this.fields)) {
3534
+ this.removeItem(field);
3535
+ }
3536
+ }
3537
+ getItem(key) {
3538
+ throw new Error(`Function getItem for store engine ${typeof this} not implemented`);
3539
+ }
3540
+ setItem(key, value) {
3541
+ throw new Error(`Function setItem for store engine ${typeof this} not implemented`);
3542
+ }
3543
+ removeItem(key) {
3544
+ throw new Error(`Function deleteItem for store engine ${typeof this} not implemented`);
3545
+ }
3546
+ }
3547
+
3548
+ class LocalStorageEngine extends StorageEngine {
3549
+ setItem(key, value) {
3550
+ localStorage.setItem(key, JSON.stringify(value));
3551
+ }
3552
+ getItem(key) {
3553
+ try {
3554
+ return JSON.parse(localStorage.getItem(key));
3555
+ }
3556
+ catch (e) {
3557
+ return;
3558
+ }
3559
+ }
3560
+ removeItem(key) {
3561
+ localStorage.removeItem(key);
3562
+ }
3563
+ }
3564
+
3565
+ function componentDestroyed(component) {
3566
+ if (component.constructor.__componentDestroyed$) {
3567
+ return component.constructor.__componentDestroyed$;
3568
+ }
3569
+ throw new Error('Use @UntilDestroy decorator in class');
3570
+ }
3571
+ function UntilDestroy(cmpType) {
3572
+ const def = getDef(cmpType);
3573
+ const original = def.onDestroy;
3574
+ cmpType.__componentDestroyed$ = new Subject();
3575
+ def.onDestroy = function () {
3576
+ cmpType.__componentDestroyed$.next();
3577
+ cmpType.__componentDestroyed$.complete();
3578
+ original.apply(this);
3579
+ };
3580
+ }
3581
+ function getDef(type) {
3582
+ return type.ɵcmp || type.ɵdir;
3583
+ }
3584
+
3585
+ function getCookie(name) {
3586
+ const value = `; ${document.cookie}`;
3587
+ const parts = value.split(`; ${name}=`);
3588
+ if (parts.length === 2) {
3589
+ return parts.pop().split(';').shift();
3590
+ }
3591
+ return null;
3592
+ }
3593
+
3594
+ function isTouchDevice() {
3595
+ const prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
3596
+ const mq = (q) => {
3597
+ return window.matchMedia(q).matches;
3598
+ };
3599
+ if (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch) {
3600
+ return true;
3601
+ }
3602
+ // include the 'heartz' as a way to have a non matching MQ to help terminate the join
3603
+ // https://git.io/vznFH
3604
+ const query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
3605
+ return mq(query);
3606
+ }
3607
+
3608
+ function getEnumOptions(enumClass) {
3609
+ return Object.keys(enumClass)
3610
+ .map(v => enumClass[v])
3611
+ .filter(v => isNaN(+v) === false)
3612
+ .map(v => +v);
3613
+ }
3614
+
3615
+ function handleError(error, force = false, production = true) {
3616
+ if (!(error && (error.status === 0 || error.status === 404)) || (force && error.status !== 0)) {
3617
+ captureException(error);
3618
+ }
3619
+ if (!production) {
3620
+ console.error(error);
3621
+ }
3622
+ }
3623
+
3624
+ function getIconsData(folder) {
3625
+ return [
3626
+ { rel: 'apple-touch-icon', sizes: '180x180', href: `/assets/favicon/${folder}apple-touch-icon.png` },
3627
+ { rel: 'icon', type: 'image/png', sizes: '32x32', href: `/assets/favicon/${folder}favicon-32x32.png` },
3628
+ { rel: 'icon', type: 'image/png', sizes: '16x16', href: `/assets/favicon/${folder}favicon-16x16.png` },
3629
+ { rel: 'shortcut icon', href: `/assets/favicon/${folder}favicon.ico` },
3630
+ { rel: 'manifest', href: `/assets/favicon/${folder}site.webmanifest` },
3631
+ { rel: 'mask-icon', href: `/assets/favicon/${folder}safari-pinned-tab.svg`, color: '#ff0000' }
3632
+ ];
3633
+ }
3634
+ function changeFavicons(document, leagueAlias) {
3635
+ let folder = '';
3636
+ if (leagueAlias === 'ablmoscow') {
3637
+ folder = 'abl/';
3638
+ }
3639
+ const data = getIconsData(folder);
3640
+ for (const item of data) {
3641
+ const link = document.createElement('link');
3642
+ for (const key of Object.keys(item)) {
3643
+ link.setAttribute(key, item[key]);
3644
+ }
3645
+ document.head.appendChild(link);
3646
+ }
3647
+ }
3648
+
3649
+ function markFormGroupTouched(formGroup) {
3650
+ Object.values(formGroup.controls).forEach(control => {
3651
+ control.markAsTouched();
3652
+ control.markAsDirty();
3653
+ if (control instanceof FormGroup) {
3654
+ markFormGroupTouched(control);
3655
+ }
3656
+ else if (control.controls) {
3657
+ control.controls.forEach(c => {
3658
+ if (c instanceof FormGroup) {
3659
+ markFormGroupTouched(c);
3660
+ }
3661
+ else {
3662
+ c.markAsTouched();
3663
+ c.markAsDirty();
3664
+ }
3665
+ });
3666
+ }
3667
+ });
3668
+ }
3669
+
3670
+ const minLengthArrayValidator = (minLength) => {
3671
+ return (c) => {
3672
+ return c.value.length < minLength
3673
+ ? { minLengthArray: { valid: false } }
3674
+ : null;
3675
+ };
3676
+ };
3677
+ const validatePhone = (control) => {
3678
+ if (!control.value) {
3679
+ return null;
3680
+ }
3681
+ const value = `${control.value}`.replace(/\D/gi, '');
3682
+ return value.length === 11 ? null : { invalidPhone: { valid: false } };
3683
+ };
3684
+ const validateDate = (control) => {
3685
+ const re = /\d{2}\.\d{2}\.\d{4}/gi;
3686
+ if (!control.value || re.test(control.value)) {
3687
+ return null;
3688
+ }
3689
+ return { invalidDate: { valid: false } };
3690
+ };
3691
+ const validateEmail = (authService, selfCheck = true, ignore = []) => {
3692
+ const subject = of(null).pipe(delay(500));
3693
+ return (control) => {
3694
+ if (ignore.indexOf(control.value) > -1) {
3695
+ return of(null);
3696
+ }
3697
+ return subject.pipe(switchMap(() => authService.checkEmail(control.value, selfCheck).pipe(map(valid => valid ? null : { emailTaken: true }))));
3698
+ };
3699
+ };
3700
+ const validateUrl = (control) => {
3701
+ const re = /^(?:http(s)?:\/\/)[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/;
3702
+ if (!control.value || re.test(control.value)) {
3703
+ return null;
3704
+ }
3705
+ return { invalidUrl: true };
3706
+ };
3707
+ function fileSizeValidator(maxFileSize) {
3708
+ return (control) => {
3709
+ if (!control.value) {
3710
+ return null;
3711
+ }
3712
+ };
3713
+ }
3714
+
3715
+ let HttpCookieInterceptor = class HttpCookieInterceptor {
3716
+ constructor(injector, platformId) {
3717
+ this.injector = injector;
3718
+ this.platformId = platformId;
3719
+ this.isBrowser = isPlatformBrowser(this.platformId);
3720
+ }
3721
+ intercept(req, next) {
3722
+ if (!this.isBrowser) {
3723
+ return next.handle(req);
3724
+ }
3725
+ req = req.clone({ withCredentials: true });
3726
+ const csrf = getCookie('csrftoken');
3727
+ if (csrf) {
3728
+ req = req.clone({
3729
+ setHeaders: { 'X-CSRFToken': csrf }
3730
+ });
3731
+ }
3732
+ return next.handle(req);
3733
+ }
3734
+ };
3735
+ HttpCookieInterceptor.ctorParameters = () => [
3736
+ { type: Injector },
3737
+ { type: String, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }
3738
+ ];
3739
+ HttpCookieInterceptor = __decorate([
3740
+ Injectable(),
3741
+ __param(1, Inject(PLATFORM_ID))
3742
+ ], HttpCookieInterceptor);
3743
+
3744
+ /**
3745
+ * Generated bundle index. Do not edit.
3746
+ */
3747
+
3748
+ export { BaseModel, BaseService, BasketballGameApi, BasketballGameConfig, BasketballGameLog, BasketballGameLogTypeLocalization, BasketballGameLogTypes, BasketballGameStatistic, BasketballGameTeamStatistic, BasketballProfile, BasketballStatistic, BasketballStatisticTypes, CONFIG_DATA, CentrifugoService, City, ConfigService, DateField, DateTimeField, FAULT_LOG_TYPES, File, FileEngine, Game, GameBasketballPosition, GameBasketballPositionLocalization, GameBasketballPositionShortLocalization, GameInvite, GameInviteStatus, GameResultTypes, GameStatuses, GameTimelineStageItem, GameTimelineStages, GameUser, GameVolleyballPosition, GameVolleyballPositionLocalization, GameVolleyballPositionShortLocalization, GameVolleyballPositionShortRuLocalization, HttpCookieInterceptor, League, LeagueApi, LeagueCourt, LocalStorageEngine, MediaApi, MediaItem, ModelInstance, Notification, NotificationAllowTypes, NotificationApi, NotificationBaseApi, NotificationServiceEnum, NotificationSettings, NotificationType, OrgNotificationApi, Organization, OvertimeTypeLocalization, OvertimeTypes, Playoff, PlayoffSettings, Poll, PollAnswer, PollStatuses, PollVariant, ReferenceApi, SCORE_LOG_TYPES, Sport, SportTypes, StorageEngine, StorageEngineField, Store, Team, TeamEvent, TeamEventInvite, TeamEventInviteStatuses, TeamEventTypeLocalization, TeamEventTypes, TeamInvite, TeamInviteExternal, TeamUser, TeamUserRole, TeamUserRoleLocalization, ToBackHook, ToFrontHook, Tournament, TournamentApi, TournamentDisqualification, TournamentEvent, TournamentEventTypes, TournamentGender, TournamentGroup, TournamentInvite, TournamentJoinApi, TournamentJoinData, TournamentJoinTeam, TournamentNews, TournamentSettings, TournamentStage, TournamentStageApi, TournamentStageStatuses, TournamentStageTeam, TournamentStatuses, TournamentTeam, TournamentTeamUser, TournamentTeamUserInvite, TournamentTeamWinner, TournamentTypes, UntilDestroy, User, UserGender, UserProfile, VolleyballGameApi, VolleyballGameConfig, VolleyballGameLog, VolleyballGameLogType, VolleyballGameLogTypeLocalization, VolleyballGameStatistic, VolleyballGameTeamStatistic, VolleyballGameTypes, VolleyballProfile, VolleyballStatistic, VolleyballWorkHand, VolleyballWorkHandLocalization, WorkHand, WorkHandLocalization, addItemInArray, changeFavicons, componentDestroyed, deleteItemFromArray, enumField, fileSizeValidator, generateArray, getArrayChunks, getCookie, getEnumOptions, getIconsData, handleError, isTouchDevice, listField, markFormGroupTouched, minLengthArrayValidator, patchItemInArray, updateItemInArray, updateItemsInArray, validateDate, validateEmail, validatePhone, validateUrl };
3749
+ //# sourceMappingURL=mtgame-core.js.map