ts-client-lib 0.0.7

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 (64) hide show
  1. package/README.md +76 -0
  2. package/auth/TSJWT.d.ts +29 -0
  3. package/auth/TSJWT.js +44 -0
  4. package/auth/TSOAuth.d.ts +132 -0
  5. package/auth/TSOAuth.js +230 -0
  6. package/devices/TSCordova.d.ts +5 -0
  7. package/devices/TSCordova.js +52 -0
  8. package/entities/TSCountries.d.ts +14 -0
  9. package/entities/TSCountries.js +1188 -0
  10. package/entities/TSCurrencies.d.ts +35 -0
  11. package/entities/TSCurrencies.js +604 -0
  12. package/entities/TSMobilePhones.d.ts +167 -0
  13. package/entities/TSMobilePhones.js +206 -0
  14. package/entities/TSMoney.d.ts +149 -0
  15. package/entities/TSMoney.js +311 -0
  16. package/entities/currency-amount.d.ts +13 -0
  17. package/entities/currency-amount.js +43 -0
  18. package/finance/TSBonus.d.ts +197 -0
  19. package/finance/TSBonus.js +530 -0
  20. package/finance/TSKYC.d.ts +563 -0
  21. package/finance/TSKYC.js +1066 -0
  22. package/finance/TSTax.d.ts +49 -0
  23. package/finance/TSTax.js +106 -0
  24. package/finance/bonus-money.d.ts +41 -0
  25. package/finance/bonus-money.js +61 -0
  26. package/games/TSBetSlip.d.ts +72 -0
  27. package/games/TSBetSlip.js +179 -0
  28. package/games/TSBetSystem.d.ts +4 -0
  29. package/games/TSBetSystem.js +48 -0
  30. package/games/TSLotto.d.ts +35 -0
  31. package/games/TSLotto.js +205 -0
  32. package/games/TSPool.d.ts +28 -0
  33. package/games/TSPool.js +88 -0
  34. package/package.json +93 -0
  35. package/utils/TSArray.d.ts +9 -0
  36. package/utils/TSArray.js +87 -0
  37. package/utils/TSBoolean.d.ts +4 -0
  38. package/utils/TSBoolean.js +24 -0
  39. package/utils/TSCache.d.ts +167 -0
  40. package/utils/TSCache.js +531 -0
  41. package/utils/TSDate.d.ts +8 -0
  42. package/utils/TSDate.js +67 -0
  43. package/utils/TSHeuristic.d.ts +20 -0
  44. package/utils/TSHeuristic.js +197 -0
  45. package/utils/TSLZS.d.ts +42 -0
  46. package/utils/TSLZS.js +343 -0
  47. package/utils/TSLog.d.ts +40 -0
  48. package/utils/TSLog.js +110 -0
  49. package/utils/TSNumber.d.ts +6 -0
  50. package/utils/TSNumber.js +68 -0
  51. package/utils/TSObject.d.ts +29 -0
  52. package/utils/TSObject.js +312 -0
  53. package/utils/TSPagination.d.ts +282 -0
  54. package/utils/TSPagination.js +425 -0
  55. package/utils/TSPaginationMulti.d.ts +77 -0
  56. package/utils/TSPaginationMulti.js +356 -0
  57. package/utils/TSString.d.ts +10 -0
  58. package/utils/TSString.js +107 -0
  59. package/utils/TSValidator.d.ts +16 -0
  60. package/utils/TSValidator.js +74 -0
  61. package/utils/TSWorker.d.ts +3 -0
  62. package/utils/TSWorker.js +32 -0
  63. package/utils/diacritics-removal-map.d.ts +5 -0
  64. package/utils/diacritics-removal-map.js +341 -0
@@ -0,0 +1,530 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.findSelectionBonuses = exports.findBestDepositBonus = exports.getEligibleBonuses = exports.checkManyBonusEligibility = exports.checkBonusEligibility = exports.BonusEligibility = exports.hasCurrencyCode = exports.assertKnownCurrenciesOnTemplate = exports.assertCoherentMoneyFields = exports.toMoneyJSON = exports.parseMoneyJSON = void 0;
15
+ var TSMoney_1 = require("../entities/TSMoney");
16
+ var TSCurrencies_1 = require("../entities/TSCurrencies");
17
+ var bonus_money_1 = require("./bonus-money");
18
+ var bonus_money_2 = require("./bonus-money");
19
+ Object.defineProperty(exports, "parseMoneyJSON", { enumerable: true, get: function () { return bonus_money_2.parseMoneyJSON; } });
20
+ Object.defineProperty(exports, "toMoneyJSON", { enumerable: true, get: function () { return bonus_money_2.toMoneyJSON; } });
21
+ Object.defineProperty(exports, "assertCoherentMoneyFields", { enumerable: true, get: function () { return bonus_money_2.assertCoherentMoneyFields; } });
22
+ Object.defineProperty(exports, "assertKnownCurrenciesOnTemplate", { enumerable: true, get: function () { return bonus_money_2.assertKnownCurrenciesOnTemplate; } });
23
+ Object.defineProperty(exports, "hasCurrencyCode", { enumerable: true, get: function () { return bonus_money_2.hasCurrencyCode; } });
24
+ // ═══════════════════════════════════════════════════════════════════════════
25
+ // STATIC CLASS
26
+ // ═══════════════════════════════════════════════════════════════════════════
27
+ var BonusEligibility = /** @class */ (function () {
28
+ function BonusEligibility() {
29
+ }
30
+ /** Parse a date value that may be a Date, ISO string, or numeric timestamp string. */
31
+ BonusEligibility.parseDate = function (value) {
32
+ if (value instanceof Date)
33
+ return value;
34
+ // GraphQL String! scalar serializes Date.valueOf() → numeric timestamp string (e.g. "1770903772810")
35
+ if (typeof value === 'string') {
36
+ var num = Number(value);
37
+ if (!isNaN(num) && num > 1e12)
38
+ return new Date(num); // ms timestamp
39
+ }
40
+ if (typeof value === 'number')
41
+ return new Date(value);
42
+ return new Date(value);
43
+ };
44
+ // ─────────────────────────────────────────────────────────────────────────
45
+ // PUBLIC API
46
+ // ─────────────────────────────────────────────────────────────────────────
47
+ /**
48
+ * Check eligibility for a single bonus template.
49
+ */
50
+ BonusEligibility.check = function (template, context) {
51
+ if (context === void 0) { context = {}; }
52
+ if (template.valueMoney || template.maxValueMoney || template.minDepositMoney) {
53
+ (0, bonus_money_1.assertCoherentMoneyFields)(template);
54
+ }
55
+ (0, bonus_money_1.assertKnownCurrenciesOnTemplate)(template);
56
+ var reasons = [];
57
+ for (var _i = 0, _a = this.rules; _i < _a.length; _i++) {
58
+ var rule = _a[_i];
59
+ if (!rule.check(template, context)) {
60
+ reasons.push(rule.message(template, context));
61
+ }
62
+ }
63
+ var eligible = reasons.length === 0;
64
+ var calculatedValue = eligible ? this.calculateValue(template, context) : undefined;
65
+ var calculatedValueMoney = eligible ? this.calculateValueMoney(template, context) : undefined;
66
+ var turnoverRequired = eligible ? this.calculateTurnover(template, context) : undefined;
67
+ var turnoverRequiredMoney = eligible ? this.calculateTurnoverMoney(template, context) : undefined;
68
+ return {
69
+ template: template,
70
+ eligible: eligible,
71
+ reasons: reasons,
72
+ calculatedValue: calculatedValue,
73
+ calculatedValueMoney: calculatedValueMoney,
74
+ turnoverRequired: turnoverRequired,
75
+ turnoverRequiredMoney: turnoverRequiredMoney
76
+ };
77
+ };
78
+ /**
79
+ * Check eligibility for multiple templates.
80
+ * Returns all results, sorted by priority (highest first).
81
+ */
82
+ BonusEligibility.checkMany = function (templates, context) {
83
+ var _this = this;
84
+ if (context === void 0) { context = {}; }
85
+ return templates
86
+ .map(function (t) { return _this.check(t, context); })
87
+ .sort(function (a, b) { var _a, _b; return ((_a = b.template.priority) !== null && _a !== void 0 ? _a : 0) - ((_b = a.template.priority) !== null && _b !== void 0 ? _b : 0); });
88
+ };
89
+ /**
90
+ * Get only eligible bonuses from a list.
91
+ */
92
+ BonusEligibility.getEligible = function (templates, context) {
93
+ if (context === void 0) { context = {}; }
94
+ return this.checkMany(templates, context).filter(function (r) { return r.eligible; });
95
+ };
96
+ /**
97
+ * Find the best bonus for a deposit amount.
98
+ */
99
+ BonusEligibility.findBestForDeposit = function (templates, amount, currency, context) {
100
+ if (context === void 0) { context = {}; }
101
+ var ctx = __assign(__assign({}, context), { depositAmount: amount, currency: currency });
102
+ var depositTypes = ['first_deposit', 'reload', 'welcome', 'top_up'];
103
+ var depositTemplates = templates.filter(function (t) { return depositTypes.indexOf(t.type) !== -1; });
104
+ var eligible = this.getEligible(depositTemplates, ctx);
105
+ if (eligible.length === 0)
106
+ return null;
107
+ return eligible.sort(function (a, b) { var _a, _b; return ((_a = b.calculatedValue) !== null && _a !== void 0 ? _a : 0) - ((_b = a.calculatedValue) !== null && _b !== void 0 ? _b : 0); })[0];
108
+ };
109
+ /**
110
+ * Find eligible selection/combo bonuses based on selection count.
111
+ */
112
+ BonusEligibility.findForSelections = function (templates, selectionCount, context) {
113
+ if (context === void 0) { context = {}; }
114
+ var ctx = __assign(__assign({}, context), { selectionCount: selectionCount });
115
+ var selectionTypes = ['selection', 'combo', 'bundle'];
116
+ var selectionTemplates = templates.filter(function (t) { return selectionTypes.indexOf(t.type) !== -1; });
117
+ return this.getEligible(selectionTemplates, ctx);
118
+ };
119
+ /**
120
+ * Check if user qualifies for any bonus of a specific type.
121
+ */
122
+ BonusEligibility.hasEligibleOfType = function (templates, type, context) {
123
+ var _a;
124
+ if (context === void 0) { context = {}; }
125
+ var typeTemplates = templates.filter(function (t) { return t.type === type; });
126
+ var eligible = this.getEligible(typeTemplates, context);
127
+ return (_a = eligible[0]) !== null && _a !== void 0 ? _a : null;
128
+ };
129
+ /**
130
+ * Group eligible bonuses by type.
131
+ */
132
+ BonusEligibility.groupByType = function (templates, context) {
133
+ if (context === void 0) { context = {}; }
134
+ var results = this.checkMany(templates, context);
135
+ var grouped = new Map();
136
+ for (var _i = 0, results_1 = results; _i < results_1.length; _i++) {
137
+ var result = results_1[_i];
138
+ var type = result.template.type;
139
+ if (!grouped.has(type)) {
140
+ grouped.set(type, []);
141
+ }
142
+ grouped.get(type).push(result);
143
+ }
144
+ return grouped;
145
+ };
146
+ // ─────────────────────────────────────────────────────────────────────────
147
+ // CALCULATION HELPERS
148
+ // ─────────────────────────────────────────────────────────────────────────
149
+ BonusEligibility.calculateValue = function (template, context) {
150
+ var _a, _b;
151
+ var baseAmount = (_b = (_a = context.depositAmount) !== null && _a !== void 0 ? _a : context.activityAmount) !== null && _b !== void 0 ? _b : 0;
152
+ switch (template.valueType) {
153
+ case 'fixed':
154
+ return template.value;
155
+ case 'percentage': {
156
+ var calculated = baseAmount * (template.value / 100);
157
+ return template.maxValue ? Math.min(calculated, template.maxValue) : calculated;
158
+ }
159
+ case 'tiered': {
160
+ var multiplier = this.getTierMultiplier(template, context);
161
+ return template.value * multiplier;
162
+ }
163
+ case 'dynamic': {
164
+ return this.calculateDynamicValue(template, context);
165
+ }
166
+ default:
167
+ return template.value;
168
+ }
169
+ };
170
+ BonusEligibility.calculateTurnover = function (template, context) {
171
+ var bonusValue = this.calculateValue(template, context);
172
+ return bonusValue * template.turnoverMultiplier;
173
+ };
174
+ /**
175
+ * Bonus value as **TSMoney**. `fixed` uses minor integer units; other value types use `fromDecimal`
176
+ * on the same numeric result as `calculateValue`.
177
+ */
178
+ BonusEligibility.calculateValueMoney = function (template, context) {
179
+ var code = String(template.currency);
180
+ (0, TSCurrencies_1.resolveCurrency)(code);
181
+ var raw = this.calculateValue(template, context);
182
+ switch (template.valueType) {
183
+ case 'fixed':
184
+ return TSMoney_1.TSMoney.fromInteger(template.value, code);
185
+ case 'percentage':
186
+ case 'tiered':
187
+ case 'dynamic':
188
+ return TSMoney_1.TSMoney.fromDecimal(raw, code);
189
+ default:
190
+ return TSMoney_1.TSMoney.fromInteger(template.value, code);
191
+ }
192
+ };
193
+ BonusEligibility.calculateTurnoverMoney = function (template, context) {
194
+ var bonus = this.calculateValueMoney(template, context);
195
+ return bonus.multiply(template.turnoverMultiplier);
196
+ };
197
+ BonusEligibility.getContributionRate = function (template, category) {
198
+ var _a;
199
+ if (!template.activityContributions)
200
+ return 100;
201
+ return (_a = template.activityContributions[category]) !== null && _a !== void 0 ? _a : 0;
202
+ };
203
+ BonusEligibility.calculateTurnoverContribution = function (template, amount, category) {
204
+ var rate = this.getContributionRate(template, category);
205
+ return amount * (rate / 100);
206
+ };
207
+ // ─────────────────────────────────────────────────────────────────────────
208
+ // PRIVATE HELPERS
209
+ // ─────────────────────────────────────────────────────────────────────────
210
+ BonusEligibility.getTierMultiplier = function (_template, context) {
211
+ var _a, _b, _c;
212
+ var tierMultipliers = {
213
+ 'bronze': 1.0,
214
+ 'silver': 1.25,
215
+ 'gold': 1.5,
216
+ 'platinum': 2.0,
217
+ 'diamond': 2.5
218
+ };
219
+ return (_c = tierMultipliers[(_b = (_a = context.userTier) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : '']) !== null && _c !== void 0 ? _c : 1.0;
220
+ };
221
+ BonusEligibility.calculateDynamicValue = function (template, context) {
222
+ var _a, _b;
223
+ if (template.type === 'combo' && context.selectionCount) {
224
+ var baseValue = template.value;
225
+ var multiplier = (_a = template.comboMultiplier) !== null && _a !== void 0 ? _a : 1.1;
226
+ var minActions = (_b = template.minActions) !== null && _b !== void 0 ? _b : 3;
227
+ var extraSelections = Math.max(0, context.selectionCount - minActions);
228
+ return baseValue * Math.pow(multiplier, extraSelections);
229
+ }
230
+ if (template.type === 'streak' && context.consecutiveDays) {
231
+ return template.value * Math.min(context.consecutiveDays, 7);
232
+ }
233
+ return template.value;
234
+ };
235
+ // ─────────────────────────────────────────────────────────────────────────
236
+ // CUSTOM RULE EXTENSION
237
+ // ─────────────────────────────────────────────────────────────────────────
238
+ BonusEligibility.addRule = function (rule) {
239
+ this.rules.push(rule);
240
+ };
241
+ BonusEligibility.removeRule = function (name) {
242
+ var index = this.rules.findIndex(function (r) { return r.name === name; });
243
+ if (index !== -1) {
244
+ this.rules.splice(index, 1);
245
+ }
246
+ };
247
+ BonusEligibility.getRuleNames = function () {
248
+ return this.rules.map(function (r) { return r.name; });
249
+ };
250
+ BonusEligibility.rules = [
251
+ // Active check
252
+ {
253
+ name: 'is_active',
254
+ check: function (t) { return t.isActive === true; },
255
+ message: function () { return 'Bonus is not active'; }
256
+ },
257
+ // Date range
258
+ {
259
+ name: 'date_range',
260
+ check: function (t, c) {
261
+ var now = c.currentDate || new Date();
262
+ var from = BonusEligibility.parseDate(t.validFrom);
263
+ var until = BonusEligibility.parseDate(t.validUntil);
264
+ return now >= from && now <= until;
265
+ },
266
+ message: function (t, c) {
267
+ var now = c.currentDate || new Date();
268
+ var from = BonusEligibility.parseDate(t.validFrom);
269
+ if (now < from)
270
+ return "Bonus starts on ".concat(from.toLocaleDateString());
271
+ return 'Bonus has expired';
272
+ }
273
+ },
274
+ // Currency
275
+ {
276
+ name: 'currency',
277
+ check: function (t, c) {
278
+ var _a;
279
+ if (!c.currency)
280
+ return true;
281
+ if (!((_a = t.supportedCurrencies) === null || _a === void 0 ? void 0 : _a.length))
282
+ return true;
283
+ return t.supportedCurrencies.indexOf(c.currency) !== -1;
284
+ },
285
+ message: function (t, c) { var _a; return "Currency ".concat(c.currency, " not supported. Supported: ").concat((_a = t.supportedCurrencies) === null || _a === void 0 ? void 0 : _a.join(', ')); }
286
+ },
287
+ // Min deposit
288
+ {
289
+ name: 'min_deposit',
290
+ check: function (t, c) {
291
+ if (!t.minDeposit)
292
+ return true;
293
+ if (!c.depositAmount)
294
+ return true;
295
+ return c.depositAmount >= t.minDeposit;
296
+ },
297
+ message: function (t) { return "Minimum deposit of ".concat(t.minDeposit, " ").concat(t.currency, " required"); }
298
+ },
299
+ // User tier
300
+ {
301
+ name: 'tier',
302
+ check: function (t, c) {
303
+ var _a;
304
+ if (!((_a = t.eligibleTiers) === null || _a === void 0 ? void 0 : _a.length))
305
+ return true;
306
+ if (!c.userTier)
307
+ return false;
308
+ return t.eligibleTiers.indexOf(c.userTier) !== -1;
309
+ },
310
+ message: function (t) { var _a; return "Required tier: ".concat((_a = t.eligibleTiers) === null || _a === void 0 ? void 0 : _a.join(' or ')); }
311
+ },
312
+ // KYC Tier
313
+ {
314
+ name: 'kyc_tier',
315
+ check: function (t, c) {
316
+ var _a, _b;
317
+ if (!t.requiredKYCTier)
318
+ return true;
319
+ if (!c.kycTier)
320
+ return false;
321
+ // Import KYCEligibility for tier comparison would create circular dep
322
+ // Use simple tier level comparison
323
+ var tierLevels = {
324
+ 'none': 0, 'basic': 1, 'standard': 2,
325
+ 'enhanced': 3, 'full': 4, 'professional': 5
326
+ };
327
+ var required = (_a = tierLevels[t.requiredKYCTier]) !== null && _a !== void 0 ? _a : 0;
328
+ var current = (_b = tierLevels[c.kycTier]) !== null && _b !== void 0 ? _b : 0;
329
+ return current >= required;
330
+ },
331
+ message: function (t) { return "KYC tier '".concat(t.requiredKYCTier, "' or higher required"); }
332
+ },
333
+ // Country
334
+ {
335
+ name: 'country',
336
+ check: function (t, c) {
337
+ var _a, _b;
338
+ if (!c.country)
339
+ return true;
340
+ if (((_a = t.excludedCountries) === null || _a === void 0 ? void 0 : _a.indexOf(c.country)) !== -1)
341
+ return false;
342
+ if (((_b = t.eligibleCountries) === null || _b === void 0 ? void 0 : _b.length) && t.eligibleCountries.indexOf(c.country) === -1)
343
+ return false;
344
+ return true;
345
+ },
346
+ message: function (_t, c) { return "Country ".concat(c.country, " not eligible"); }
347
+ },
348
+ // Verification
349
+ {
350
+ name: 'verification',
351
+ check: function (t, c) {
352
+ if (!t.requiresVerification)
353
+ return true;
354
+ return c.isVerified === true;
355
+ },
356
+ message: function () { return 'Account verification required'; }
357
+ },
358
+ // Account age
359
+ {
360
+ name: 'account_age',
361
+ check: function (t, c) {
362
+ if (!t.minAccountAgeDays)
363
+ return true;
364
+ if (c.accountAgeDays === undefined)
365
+ return true;
366
+ return c.accountAgeDays >= t.minAccountAgeDays;
367
+ },
368
+ message: function (t) { return "Account must be at least ".concat(t.minAccountAgeDays, " days old"); }
369
+ },
370
+ // First deposit (type-specific)
371
+ {
372
+ name: 'first_deposit',
373
+ check: function (t, c) {
374
+ if (t.type !== 'first_deposit' && t.type !== 'welcome')
375
+ return true;
376
+ return c.isFirstDeposit === true;
377
+ },
378
+ message: function () { return 'Only available for first deposit'; }
379
+ },
380
+ // First purchase (type-specific)
381
+ {
382
+ name: 'first_purchase',
383
+ check: function (t, c) {
384
+ if (t.type !== 'first_purchase')
385
+ return true;
386
+ return c.isFirstPurchase === true;
387
+ },
388
+ message: function () { return 'Only available for first purchase'; }
389
+ },
390
+ // Selection count
391
+ {
392
+ name: 'selection_count',
393
+ check: function (t, c) {
394
+ var _a, _b, _c;
395
+ if (['selection', 'combo', 'bundle'].indexOf(t.type) === -1)
396
+ return true;
397
+ var count = (_c = (_a = c.selectionCount) !== null && _a !== void 0 ? _a : (_b = c.selections) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
398
+ if (t.minSelections && count < t.minSelections)
399
+ return false;
400
+ if (t.maxSelections && count > t.maxSelections)
401
+ return false;
402
+ return true;
403
+ },
404
+ message: function (t, c) {
405
+ var _a, _b, _c;
406
+ var count = (_c = (_a = c.selectionCount) !== null && _a !== void 0 ? _a : (_b = c.selections) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
407
+ if (t.minSelections && count < t.minSelections) {
408
+ return "Minimum ".concat(t.minSelections, " selections required (you have ").concat(count, ")");
409
+ }
410
+ return "Maximum ".concat(t.maxSelections, " selections allowed (you have ").concat(count, ")");
411
+ }
412
+ },
413
+ // Selection value range
414
+ {
415
+ name: 'selection_value_range',
416
+ check: function (t, c) {
417
+ var _a;
418
+ if (['selection', 'combo', 'bundle'].indexOf(t.type) === -1)
419
+ return true;
420
+ if (!((_a = c.selections) === null || _a === void 0 ? void 0 : _a.length))
421
+ return true;
422
+ for (var _i = 0, _b = c.selections; _i < _b.length; _i++) {
423
+ var sel = _b[_i];
424
+ if (sel.value === undefined)
425
+ continue;
426
+ if (t.min !== undefined && sel.value < t.min)
427
+ return false;
428
+ if (t.max !== undefined && sel.value > t.max)
429
+ return false;
430
+ }
431
+ return true;
432
+ },
433
+ message: function (t, c) {
434
+ if (!c.selections)
435
+ return 'Invalid selections';
436
+ for (var _i = 0, _a = c.selections; _i < _a.length; _i++) {
437
+ var sel = _a[_i];
438
+ if (sel.value === undefined)
439
+ continue;
440
+ if (t.min !== undefined && sel.value < t.min) {
441
+ return "Selection value ".concat(sel.value, " is below minimum ").concat(t.min);
442
+ }
443
+ if (t.max !== undefined && sel.value > t.max) {
444
+ return "Selection value ".concat(sel.value, " exceeds maximum ").concat(t.max);
445
+ }
446
+ }
447
+ return 'Selection value out of range';
448
+ }
449
+ },
450
+ // Selection total range
451
+ {
452
+ name: 'selection_total_range',
453
+ check: function (t, c) {
454
+ var _a;
455
+ if (['selection', 'combo', 'bundle'].indexOf(t.type) === -1)
456
+ return true;
457
+ var total = c.selectionsTotal;
458
+ if (total === undefined && ((_a = c.selections) === null || _a === void 0 ? void 0 : _a.length)) {
459
+ var isMultiplicative = t.type === 'combo';
460
+ if (isMultiplicative) {
461
+ total = c.selections.reduce(function (acc, s) { var _a; return acc * ((_a = s.value) !== null && _a !== void 0 ? _a : 1); }, 1);
462
+ }
463
+ else {
464
+ total = c.selections.reduce(function (acc, s) { var _a; return acc + ((_a = s.value) !== null && _a !== void 0 ? _a : 0); }, 0);
465
+ }
466
+ }
467
+ if (total === undefined)
468
+ return true;
469
+ if (t.minTotal !== undefined && total < t.minTotal)
470
+ return false;
471
+ if (t.maxTotal !== undefined && total > t.maxTotal)
472
+ return false;
473
+ return true;
474
+ },
475
+ message: function (t, c) {
476
+ var _a;
477
+ var total = c.selectionsTotal;
478
+ if (total === undefined && ((_a = c.selections) === null || _a === void 0 ? void 0 : _a.length)) {
479
+ var isMultiplicative = t.type === 'combo';
480
+ if (isMultiplicative) {
481
+ total = c.selections.reduce(function (acc, s) { var _a; return acc * ((_a = s.value) !== null && _a !== void 0 ? _a : 1); }, 1);
482
+ }
483
+ else {
484
+ total = c.selections.reduce(function (acc, s) { var _a; return acc + ((_a = s.value) !== null && _a !== void 0 ? _a : 0); }, 0);
485
+ }
486
+ }
487
+ if (t.minTotal !== undefined && total !== undefined && total < t.minTotal) {
488
+ return "Combined total ".concat(total.toFixed(2), " is below minimum ").concat(t.minTotal);
489
+ }
490
+ if (t.maxTotal !== undefined && total !== undefined && total > t.maxTotal) {
491
+ return "Combined total ".concat(total.toFixed(2), " exceeds maximum ").concat(t.maxTotal);
492
+ }
493
+ return 'Combined total out of range';
494
+ }
495
+ },
496
+ // Activity category
497
+ {
498
+ name: 'activity_category',
499
+ check: function (t, c) {
500
+ var _a;
501
+ if (!((_a = t.eligibleCategories) === null || _a === void 0 ? void 0 : _a.length))
502
+ return true;
503
+ if (!c.activityCategory)
504
+ return true;
505
+ return t.eligibleCategories.indexOf(c.activityCategory) !== -1;
506
+ },
507
+ message: function (t) { var _a; return "Activity category not eligible. Allowed: ".concat((_a = t.eligibleCategories) === null || _a === void 0 ? void 0 : _a.join(', ')); }
508
+ },
509
+ // Total uses limit
510
+ {
511
+ name: 'total_uses',
512
+ check: function (t) {
513
+ if (!t.maxUsesTotal || t.currentUsesTotal === undefined)
514
+ return true;
515
+ return t.currentUsesTotal < t.maxUsesTotal;
516
+ },
517
+ message: function () { return 'Bonus no longer available (limit reached)'; }
518
+ }
519
+ ];
520
+ return BonusEligibility;
521
+ }());
522
+ exports.BonusEligibility = BonusEligibility;
523
+ // ═══════════════════════════════════════════════════════════════════════════
524
+ // CONVENIENCE EXPORTS
525
+ // ═══════════════════════════════════════════════════════════════════════════
526
+ exports.checkBonusEligibility = BonusEligibility.check.bind(BonusEligibility);
527
+ exports.checkManyBonusEligibility = BonusEligibility.checkMany.bind(BonusEligibility);
528
+ exports.getEligibleBonuses = BonusEligibility.getEligible.bind(BonusEligibility);
529
+ exports.findBestDepositBonus = BonusEligibility.findBestForDeposit.bind(BonusEligibility);
530
+ exports.findSelectionBonuses = BonusEligibility.findForSelections.bind(BonusEligibility);