@opexa/portal-sdk 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.sdk={},l.objectId))})(this,function(l,u){"use strict";var Mt=Object.defineProperty;var Dt=(l,u,w)=>u in l?Mt(l,u,{enumerable:!0,configurable:!0,writable:!0,value:w}):l[u]=w;var m=(l,u,w)=>Dt(l,typeof u!="symbol"?u+"":u,w);const w={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,GameSession:204,MayaSession:230};function o(n,...e){let t="";for(const[a,r]of n.entries()){const s=e.at(a)??"";t=`${t}${r}${s}`}return t.trim()}const _=o`
1
+ (function(l,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],u):(l=typeof globalThis<"u"?globalThis:l||self,u(l.sdk={},l.objectId))})(this,function(l,u){"use strict";var Nt=Object.defineProperty;var Dt=(l,u,w)=>u in l?Nt(l,u,{enumerable:!0,configurable:!0,writable:!0,value:w}):l[u]=w;var m=(l,u,w)=>Dt(l,typeof u!="symbol"?u+"":u,w);const w={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,GameSession:204,MayaSession:230};function o(n,...e){let t="";for(const[a,r]of n.entries()){const s=e.at(a)??"";t=`${t}${r}${s}`}return t.trim()}const _=o`
2
2
  fragment FileFragment on File {
3
3
  id
4
4
  url
5
5
  status
6
6
  dateTimeCreated
7
7
  }
8
- `,_e=o`
8
+ `,Ce=o`
9
9
  ${_}
10
10
 
11
11
  query File($id: ObjectId!) {
@@ -15,7 +15,7 @@
15
15
  }
16
16
  }
17
17
  }
18
- `,Te=o`
18
+ `,_e=o`
19
19
  mutation UploadPrivateImageFile($input: UploadFileInput!) {
20
20
  uploadPrivateImageFile(input: $input) {
21
21
  ... on FileFormatNotSupportedError {
@@ -29,7 +29,7 @@
29
29
  }
30
30
  }
31
31
  }
32
- `,ve=o`
32
+ `,Te=o`
33
33
  query Wallet {
34
34
  wallet {
35
35
  id
@@ -39,7 +39,7 @@
39
39
  dateTimeLastUpdated
40
40
  }
41
41
  }
42
- `,Me=o`
42
+ `,ve=o`
43
43
  query PointsWallet {
44
44
  pointsWallet {
45
45
  id
@@ -48,7 +48,7 @@
48
48
  dateTimeCreated
49
49
  }
50
50
  }
51
- `,De=o`
51
+ `,Me=o`
52
52
  mutation PointsToCashConversion($input: PointsToCashConversionInput!) {
53
53
  pointsToCashConversion(input: $input) {
54
54
  ... on InsufficientPointsError {
@@ -63,7 +63,7 @@
63
63
  name
64
64
  provider
65
65
  }
66
- `,N=o`
66
+ `,D=o`
67
67
  ${T}
68
68
 
69
69
  query Games($first: Int, $after: Cursor, $filter: GameFilterInput) {
@@ -91,7 +91,7 @@
91
91
  id
92
92
  }
93
93
  }
94
- `,R=o`
94
+ `,Ne=o`
95
95
  query GameSession($id: ObjectId!) {
96
96
  node(id: $id) {
97
97
  ... on GameSession {
@@ -104,7 +104,7 @@
104
104
  }
105
105
  }
106
106
  }
107
- `,G=o`
107
+ `,R=o`
108
108
  mutation CreateGameSession($input: CreateGameSessionInput!) {
109
109
  createGameSession(input: $input) {
110
110
  ... on GameDoesNotExistError {
@@ -112,11 +112,26 @@
112
112
  }
113
113
  }
114
114
  }
115
- `,Ne=o`
115
+ `,De=o`
116
116
  mutation EndGameSession($input: EndGameSessionInput!) {
117
117
  endGameSession(input: $input)
118
118
  }
119
119
  `,Ie=o`
120
+ query GameSession($id: ObjectId!) {
121
+ node(id: $id) {
122
+ ... on GameSession {
123
+ id
124
+ game {
125
+ id
126
+ }
127
+ status
128
+ launchUrl
129
+ dateTimeCreated
130
+ dateTimeLastUpdated
131
+ }
132
+ }
133
+ }
134
+ `,Re=o`
120
135
  mutation EndGameSession($input: EndGameSessionInput!) {
121
136
  endGameSession(input: $input) {
122
137
  ... on GameSessionDoesNotExistError {
@@ -130,7 +145,7 @@
130
145
  }
131
146
  }
132
147
  }
133
- `,Re=o`
148
+ `,Ge=o`
134
149
  query Announcements($first: Int, $after: Cursor, $filter: AnnouncementFilterInput) {
135
150
  announcements(first: $first, after: $after, filter: $filter) {
136
151
  edges {
@@ -156,7 +171,7 @@
156
171
  }
157
172
  }
158
173
  }
159
- `,Ge=o`
174
+ `,Pe=o`
160
175
  query WithdrawalRecords($first: Int, $after: Cursor, $filter: WithdrawalRecordFilterInput) {
161
176
  member {
162
177
  withdrawalRecords(first: $first, after: $after, filter: $filter) {
@@ -223,7 +238,7 @@
223
238
  }
224
239
  }
225
240
  }
226
- `,Pe=o`
241
+ `,xe=o`
227
242
  mutation CreateGCashWithdrawal($input: CreateGCashWithdrawalInput!) {
228
243
  createGCashWithdrawal(input: $input) {
229
244
  ... on AccountNotVerifiedError {
@@ -246,7 +261,7 @@
246
261
  }
247
262
  }
248
263
  }
249
- `,xe=o`
264
+ `,$e=o`
250
265
  mutation CreateMayaWithdrawal($input: CreateMayaWithdrawalInput!) {
251
266
  createMayaWithdrawal(input: $input) {
252
267
  ... on AccountNotVerifiedError {
@@ -269,7 +284,7 @@
269
284
  }
270
285
  }
271
286
  }
272
- `,$e=o`
287
+ `,Be=o`
273
288
  mutation CreateMayaAppWithdrawal($input: CreateMayaAppWithdrawalInput!) {
274
289
  createMayaAppWithdrawal(input: $input) {
275
290
  ... on AccountNotVerifiedError {
@@ -289,7 +304,7 @@
289
304
  }
290
305
  }
291
306
  }
292
- `,Be=o`
307
+ `,We=o`
293
308
  mutation CreateBankWithdrawal($input: CreateBankWithdrawalInput!) {
294
309
  createBankWithdrawal(input: $input) {
295
310
  ... on MobileNumberNotVerifiedError {
@@ -312,11 +327,11 @@
312
327
  }
313
328
  }
314
329
  }
315
- `,We=o`
330
+ `,Ue=o`
316
331
  query RemainingDailyWithdrawalsCount {
317
332
  remainingDailyWithdrawalsCount
318
333
  }
319
- `,Ue=o`
334
+ `,Oe=o`
320
335
  query DepositRecords($after: Cursor, $first: Int, $filter: DepositRecordFilterInput) {
321
336
  member {
322
337
  depositRecords(after: $after, first: $first, filter: $filter) {
@@ -345,7 +360,7 @@
345
360
  }
346
361
  }
347
362
  }
348
- `,Oe=o`
363
+ `,qe=o`
349
364
  mutation CreateGCashDeposit($input: CreateGCashDepositInput!) {
350
365
  createGCashDeposit(input: $input) {
351
366
  ... on DepositPromoMaximumAmountExceededError {
@@ -374,7 +389,7 @@
374
389
  }
375
390
  }
376
391
  }
377
- `,qe=o`
392
+ `,Fe=o`
378
393
  mutation CreateMayaDeposit($input: CreateMayaDepositInput!) {
379
394
  createMayaDeposit(input: $input) {
380
395
  ... on DepositPromoMaximumAmountExceededError {
@@ -403,7 +418,7 @@
403
418
  }
404
419
  }
405
420
  }
406
- `,Fe=o`
421
+ `,Le=o`
407
422
  mutation CreateMayaAppDeposit($input: CreateMayaAppDepositInput!) {
408
423
  createMayaAppDeposit(input: $input) {
409
424
  ... on DepositPromoMaximumAmountExceededError {
@@ -432,7 +447,7 @@
432
447
  }
433
448
  }
434
449
  }
435
- `,Le=o`
450
+ `,Ve=o`
436
451
  query Deposit($id: ObjectId!) {
437
452
  node(id: $id) {
438
453
  ... on GCashDeposit {
@@ -464,13 +479,13 @@
464
479
  }
465
480
  }
466
481
  }
467
- `,Ve=o`
482
+ `,Ye=o`
468
483
  query DepositsCount {
469
484
  member {
470
485
  depositsCount
471
486
  }
472
487
  }
473
- `,Ye=o`
488
+ `,He=o`
474
489
  ${T}
475
490
 
476
491
  query BetRecords($first: Int, $after: Cursor, $filter: BetRecordFilterInput) {
@@ -510,7 +525,7 @@
510
525
  }
511
526
  }
512
527
  }
513
- `,He=o`
528
+ `,je=o`
514
529
  query LatestBetRecords {
515
530
  latestBetRecords {
516
531
  id
@@ -530,7 +545,7 @@
530
545
  }
531
546
 
532
547
  ${T}
533
- `,je=o`
548
+ `,Qe=o`
534
549
  query TransactionRecords($first: Int, $after: Cursor, $filter: TransactionRecordFilter) {
535
550
  member {
536
551
  transactionRecords(first: $first, after: $after, filter: $filter) {
@@ -575,7 +590,7 @@
575
590
  dateTimeCreated
576
591
  dateTimeLastUpdated
577
592
  }
578
- `,Qe=o`
593
+ `,Ke=o`
579
594
  ${v}
580
595
 
581
596
  query Promos {
@@ -583,7 +598,7 @@
583
598
  ...PromoFragment
584
599
  }
585
600
  }
586
- `,Ke=o`
601
+ `,ze=o`
587
602
  ${v}
588
603
 
589
604
  query AvailablePromos($filter: PromoFilterInput) {
@@ -591,7 +606,7 @@
591
606
  ...PromoFragment
592
607
  }
593
608
  }
594
- `,P=o`
609
+ `,G=o`
595
610
  ${_}
596
611
 
597
612
  fragment CashbackFragment on Cashback {
@@ -607,15 +622,15 @@
607
622
  dateTimeCreated
608
623
  dateTimeLastUpdated
609
624
  }
610
- `,ze=o`
611
- ${P}
625
+ `,Je=o`
626
+ ${G}
612
627
 
613
628
  query Cashbacks {
614
629
  cashbacks {
615
630
  ...CashbackFragment
616
631
  }
617
632
  }
618
- `,Je=o`
633
+ `,Xe=o`
619
634
  ${v}
620
635
 
621
636
  query Bonus {
@@ -644,8 +659,8 @@
644
659
  dateTimeLastUpdated
645
660
  }
646
661
  }
647
- `,Xe=o`
648
- ${P}
662
+ `,Ze=o`
663
+ ${G}
649
664
 
650
665
  query CashbackBonuses {
651
666
  cashbackBonuses {
@@ -658,7 +673,7 @@
658
673
  dateTimeLastUpdated
659
674
  }
660
675
  }
661
- `,Ze=o`
676
+ `,et=o`
662
677
  mutation ClaimCashbackBonus($input: ClaimCashbackBonusInput!) {
663
678
  claimCashbackBonus(input: $input) {
664
679
  ... on CashbackBonusDoesNotExistError {
@@ -666,13 +681,13 @@
666
681
  }
667
682
  }
668
683
  }
669
- `,et=o`
684
+ `,tt=o`
670
685
  query Member {
671
686
  member {
672
687
  dateTimeLastActive
673
688
  }
674
689
  }
675
- `,tt=o`
690
+ `,at=o`
676
691
  query MemberAccount {
677
692
  memberAccount: self {
678
693
  ... on MemberAccount {
@@ -696,7 +711,7 @@
696
711
  }
697
712
  }
698
713
  }
699
- `,at=o`
714
+ `,rt=o`
700
715
  ${_}
701
716
 
702
717
  query MemberVerification {
@@ -720,7 +735,7 @@
720
735
  }
721
736
  }
722
737
  }
723
- `,rt=o`
738
+ `,nt=o`
724
739
  mutation RegisterMemberAccount(
725
740
  $input: RegisterMemberAccountInput!
726
741
  $referralCode: String
@@ -756,7 +771,7 @@
756
771
  }
757
772
  }
758
773
  }
759
- `,nt=o`
774
+ `,ot=o`
760
775
  mutation UpdateMemberAccount($input: UpdateMemberAccountInput!) {
761
776
  updateMemberAccount(input: $input) {
762
777
  ... on AccountNameNotAvailableError {
@@ -782,7 +797,7 @@
782
797
  }
783
798
  }
784
799
  }
785
- `,ot=o`
800
+ `,it=o`
786
801
  mutation ResetPassword($input: ResetPasswordInput!, $verificationCode: String) {
787
802
  resetPassword(input: $input, verificationCode: $verificationCode) {
788
803
  ... on AccountNotFoundError {
@@ -793,11 +808,11 @@
793
808
  }
794
809
  }
795
810
  }
796
- `,it=o`
811
+ `,st=o`
797
812
  mutation DeleteMemberAccount($input: DeleteMemberAccountInput!) {
798
813
  deleteMemberAccount(input: $input)
799
814
  }
800
- `,st=o`
815
+ `,dt=o`
801
816
  mutation VerifyMobileNumber($input: VerifyMobileNumberInput!) {
802
817
  verifyMobileNumber(input: $input) {
803
818
  ... on InvalidSMSVerificationCodeError {
@@ -808,7 +823,7 @@
808
823
  }
809
824
  }
810
825
  }
811
- `,dt=o`
826
+ `,mt=o`
812
827
  mutation CreateMemberVerification($input: CreateMemberVerificationInput!) {
813
828
  createMemberVerification(input: $input) {
814
829
  ... on FileDoesNotExistError {
@@ -822,7 +837,7 @@
822
837
  }
823
838
  }
824
839
  }
825
- `,mt=o`
840
+ `,ct=o`
826
841
  mutation UpdateMemberVerification($input: UpdateMemberVerificationInput!) {
827
842
  updateMemberVerification(input: $input) {
828
843
  ... on FileDoesNotExistError {
@@ -839,7 +854,7 @@
839
854
  }
840
855
  }
841
856
  }
842
- `,ct=o`
857
+ `,ut=o`
843
858
  query ProfileCompletion {
844
859
  profileCompletion {
845
860
  completionPercentage
@@ -850,7 +865,7 @@
850
865
  accountPassword
851
866
  }
852
867
  }
853
- `,ut=o`
868
+ `,lt=o`
854
869
  mutation SendVerificationCode($input: SendVerificationCodeInput!) {
855
870
  sendVerificationCode(input: $input) {
856
871
  ... on InvalidPlatformError {
@@ -861,7 +876,7 @@
861
876
  }
862
877
  }
863
878
  }
864
- `,lt=o`
879
+ `,pt=o`
865
880
  fragment DepositGatewaySettingsCoreData on DepositGatewaySettings {
866
881
  minimumAmount
867
882
  maximumAmount
@@ -915,7 +930,7 @@
915
930
  multiplier
916
931
  }
917
932
  }
918
- `,pt=o`
933
+ `,ft=o`
919
934
  query MayaSession($id: ObjectId!) {
920
935
  mayaSession(id: $id) {
921
936
  id
@@ -923,5 +938,5 @@
923
938
  dateTimeCreated
924
939
  }
925
940
  }
926
- `;function c(n){return{name:n,message:{AccountNameNotAvailableError:"Username is no longer available",AccountNotFoundError:"Account does not exist",AccountNotVerifiedError:"Account is not verified",CashbackBonusDoesNotExistError:"Cashback bonus does not exists",DepositPromoMaximumAmountExceededError:"Deposit amount exceeds maximum amount",DepositPromoMinimumAmountNotMetError:"Deposit amount does not meet minimum amount",EmailAddressNotAvailableError:"Email is no longer available",FileDoesNotExistError:"File does not exist",FileFormatNotSupportedError:"File format is not supported",FileNameTooLongError:"File name is too long",FileNotReadyError:"File is not yet ready",FileSizeTooBigError:"File size is too big",GameDoesNotExistError:"Game does not exist",HasActiveBonusError:"Account has active bonus",InsufficientPointsError:"Insufficient points",InvalidPlatformError:"Invalid platform",InvalidReCAPTCHAResponseError:"Invalid reCAPTCHA",InvalidSMSVerificationCodeError:"Invalid SMS verification code",InvalidTransactionPasswordError:"Invalid transaction password",InvalidVerificationCodeError:"Invalid verification code",InvalidWithdrawalAmountError:"Invalid withdrawal amount",MaximumDepositAmountExceededError:"Maximum deposit amount exceeded",MemberVerificationAlreadyApprovedError:"Member verification is already approved",MemberVerificationAlreadyExistsError:"Member verification already exists",MemberVerificationDoesNotExistError:"Member verification does not exist",MinimumAgeRequirementError:"Minimum age requirement not met",MinimumDepositAmountNotMetError:"Minimum deposit amount not met",MinimumFirstDepositAmountNotMetError:"Minimum first deposit amount not met",MobileNumberAlreadyVerifiedError:"Mobile number is already verified",MobileNumberNotAvailableError:"Mobile number is no longer available",MobileNumberNotVerifiedError:"Mobile number is not verified",NickNameNotAvailableError:"Nickname is no longer available",NotEnoughBalanceError:"Insufficient balance",NotReadyToSendVerficationCodeError:"Not ready to send verification code",PromoNotEnabledError:"Promo is not enabled",RealNameAlreadySetError:"Real name is already set",ValidIdAlreadySetError:"Valid ID is already set",WalletDoesNotExistError:"Wallet does not exist",WithdrawalDailyLimitExceededError:"Daily withdrawal limit exceeded",GameProviderError:"Game provider error",GameSessionAlreadyClosedError:"Game session is already closed",GameSessionDoesNotExistError:"Game session does not exist",AccountBlacklisted:"Account is blacklisted",AccountNotFound:"Account not found",InvalidToken:"Invalid token",InvalidTokenOrSecretAnswer:"Invalid token or secret answer",SessionExpired:"Session expired"}[n]}}class ft{constructor(e){m(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(tt);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(rt,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:c(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async updateMemberAccount(e){const t=await this.client.request(nt,e);return t.ok?t.data.updateMemberAccount?{ok:!1,error:c(t.data.updateMemberAccount.__typename)}:{ok:!0}:t}async deleteMemberAccount(e){const t=await this.client.request(it,e);return t.ok?t.data.deleteMemberAccount?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}async resetPassword(e){const t=await this.client.request(ot,e);return t.ok?t.data.resetPassword?{ok:!1,error:c(t.data.resetPassword.__typename)}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(ct);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(lt)}async sendVerificationCode(e){const t=await this.client.request(ut,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:c(t.data.sendVerificationCode.__typename)}:{ok:!0}:t}async verifyMobileNumber(e){const t=await this.client.request(st,e);return t.ok?t.data.verifyMobileNumber?{ok:!1,error:c(t.data.verifyMobileNumber.__typename)}:{ok:!0}:t}async createMemberVerification(e){const t=await this.client.request(dt,e);return t.ok?t.data.createMemberVerification?{ok:!1,error:c(t.data.createMemberVerification.__typename)}:{ok:!0}:t}async updateMemberVerification(e){const t=await this.client.request(mt,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:c(t.data.updateMemberVerification.__typename)}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(at);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(Re,e);return t.ok?{ok:!0,data:t.data.announcements}:t}}function f(n,e){const t=M[n]?M[n]:M[500];return{name:t.name,message:e??t.message}}const M={400:{name:"HttpBadRequest",message:"Bad Request"},401:{name:"HttpUnauthorized",message:"Unauthorized"},403:{name:"HttpForbidden",message:"Forbidden"},404:{name:"HttpNotFound",message:"Not Found"},408:{name:"HttpRequestTimeout",message:"Request Timeout"},429:{name:"HttpTooManyRequests",message:"Too Many Requests"},500:{name:"HttpInternalServerError",message:"Internal Server Error"}};class ht{constructor(e){m(this,"url");m(this,"platform");this.url=e.url,this.platform=e.platform}async createSession(e){const t=new Headers({"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER"});if(e.name){const a=`${e.name}:${e.password}`,r=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${r}`)}if(e.mobileNumber){const a=`${e.mobileNumber}:${e.verificationCode}`,r=Buffer.from(a).toString("base64");t.set("Authorization",`MobileNumberOTP ${r}`)}e.sessionId&&t.set("Authorization",`Maya ${e.sessionId}`);try{const a=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),r=await a.json();return a.ok?{ok:!0,data:r}:r.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:c("AccountBlacklisted")}:{ok:!1,error:f(a.status)}}catch{return{ok:!1,error:f(500)}}}async authenticate(e){const t=new Headers({"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER"});if(e.type==="SECURITY_QUESTION"){t.set("Authorization",`Bearer ${e.token}`);try{const a=await fetch(`${this.url}/session/${e.token}/authenticate`,{method:"POST",headers:t,body:JSON.stringify({secretAnswer:e.secretAnswer})}),r=await a.json();return a.ok?{ok:!0,data:r}:a.status===401||a.status===403?{ok:!1,error:c("InvalidTokenOrSecretAnswer")}:{ok:!1,error:f(a.status)}}catch{return{ok:!1,error:f(500)}}}throw new Error("Invalid input 'type'")}async refreshSession(e){try{const t=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}}),a=await t.json();return t.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:c("AccountBlacklisted")}:t.status===403||t.status===401?{ok:!1,error:c("InvalidToken")}:{ok:!1,error:f(t.status)}}catch{return{ok:!1,error:f(500)}}}async destroySession(e){try{const t=await fetch(`${this.url}/session`,{method:"DELETE",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}});return t.ok?{ok:!0}:{ok:!1,error:f(t.status)}}catch{return{ok:!1,error:f(500)}}}async verifySession(e){try{return(await fetch(`${this.url}/session`,{method:"GET",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}})).ok}catch{return!0}}}class wt{constructor(e){m(this,"client");this.client=e}async file(e){const t=await this.client.request(_e,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(Te,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:c(t.data.uploadPrivateImageFile.__typename)}:{ok:!0}:t}}class yt{constructor(e){m(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(Ye,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(je,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(Ge,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Ue,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(Ve);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async member(){const e=await this.client.request(et);return e.ok?{ok:e.ok,data:e.data.member}:e}}class bt{constructor(e){m(this,"url");this.url=e.url}gameThumbnails(e){return[`${this.url}/images/${e.provider.toLowerCase()}/thumbnail-${e.id}.webp`,`${this.url}/images/${e.provider.toLowerCase()}/thumbnail-${e.provider.toLowerCase()}.webp`]}}class x{constructor(e){m(this,"client");this.client=e}async promos(){const e=await this.client.request(Qe);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(ze);return e.ok?{ok:e.ok,data:e.data.cashbacks}:e}async availablePromos(e){const t=await this.client.request(Ke,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(Xe);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(Ze,e);return t.ok?t.data.claimCashbackBonus?{ok:!1,error:c(t.data.claimCashbackBonus.__typename)}:{ok:!0}:{ok:t.ok,error:t.error}}async bonus(){const e=await this.client.request(Je);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(ve);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(Le,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Oe,e);return t.ok?t.data.createGCashDeposit?{ok:!1,error:c(t.data.createGCashDeposit.__typename)}:{ok:!0}:t}async createMayaDeposit(e){const t=await this.client.request(qe,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:c(t.data.createMayaDeposit.__typename)}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request(Fe,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:c(t.data.createMayaAppDeposit.__typename)}:{ok:!0}:t}async createGCashWithdrawal(e){const t=await this.client.request(Pe,e);return t.ok?t.data.createGCashWithdrawal?{ok:!1,error:c(t.data.createGCashWithdrawal.__typename)}:{ok:!0}:t}async createMayaWithdrawal(e){const t=await this.client.request(xe,e);return t.ok?t.data.createMayaWithdrawal?{ok:!1,error:c(t.data.createMayaWithdrawal.__typename)}:{ok:!0}:t}async createMayaAppWithdrawal(e){const t=await this.client.request($e,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:c(t.data.createMayaAppWithdrawal.__typename)}:{ok:!0}:t}async createBankWithdrawal(e){const t=await this.client.request(Be,e);return t.ok?t.data.createBankWithdrawal?{ok:!1,error:c(t.data.createBankWithdrawal.__typename)}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(We);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Me);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(De,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:c(t.data.pointsToCashConversion.__typename)}:{ok:!0}:t}async mayaSession(e){const t=await this.client.request(pt,e);return t.ok?{ok:t.ok,data:t.data.mayaSession}:t}async games(e){const t=await this.client.request(N,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(I,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(R,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(G,e);return t.ok?t.data.createGameSession?{ok:!1,error:c(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Ne,e);return t.ok?t.data.endGameSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}}class gt{constructor(e){m(this,"client");this.client=e}async games(e){const t=await this.client.request(N,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(I,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(R,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(G,e);return t.ok?t.data.createGameSession?{ok:!1,error:c(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Ie,e);return t.ok?t.data.endGameSession?{ok:!1,error:c(t.data.endGameSession.__typename)}:{ok:!0}:t}}class Et{constructor(e){m(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(He);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}function At(n,e,t){return n<e?e:n>t?t:n}function St(n){return Object.prototype.toString.call(n)==="[object Object]"&&Object(n)===n}function kt(n){const e=[];function t(a,r=[]){for(const s in a){const d=a[s];St(d)?t(d,[...r,s]):Array.isArray(d)?t(Ct(d),[...r,s]):e.push({key:[...r,s],value:d})}}return t(n),e}function Ct(n){return n.reduce((e,t,a)=>(e[a]=t,e),{})}class A{constructor(e,t){m(this,"url");m(this,"options");m(this,"middlewares");var r;const a=new Headers((r=t==null?void 0:t.fetchOptions)==null?void 0:r.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:a},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){const a=JSON.stringify({query:e,variables:t}),r=new Headers(this.options.headers);r.set("Content-Type","application/json"),r.set("Accept","application/json");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(s)}async upload(e,t){const a=this.createUploadBody(e,t),r=new Headers(this.options.headers);r.delete("Content-Type");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(s)}async exec(e){var t,a,r,s,d,p;try{const y=await fetch(e);if(!y.ok)return{ok:!1,error:f(y.status)};const h=await y.json(),E=h.data,b=(t=h.errors)==null?void 0:t.at(0);return b?((a=b.extensions)==null?void 0:a.code)==="FORBIDDEN"||((r=b.extensions)==null?void 0:r.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:f(403,b.message)}:((s=b.extensions)==null?void 0:s.code)==="UNAUTHORIZED"?{ok:!1,error:f(401,b.message)}:((d=b.extensions)==null?void 0:d.code)==="BAD_USER_INPUT"||((p=b.extensions)==null?void 0:p.code)==="BAD_REQUEST"?{ok:!1,error:f(400,b.message)}:{ok:!1,error:f(500,b.message)}:{ok:!0,data:E}}catch{return{ok:!1,error:f(500)}}}async runMiddlewares(e){let t=e.clone();for(const a of this.middlewares)t=await a(t);return t}createUploadBody(e,t){const a=kt(t).filter(d=>d.value instanceof File||d.value instanceof Blob),r=new FormData;r.append("operations",JSON.stringify({query:e,variables:t}));const s={};return a.forEach((d,p)=>{s[p.toString()]=[`variables.${d.key.join(".")}`]}),r.append("map",JSON.stringify(s)),a.forEach((d,p)=>{r.append(p.toString(),d.value)}),r}}async function g(n){const e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(s=>s.toString(16).padStart(2,"0")).join("")}class ${constructor(e){m(this,"enabled");this.enabled=(e==null?void 0:e.enabled)??!0}info(e){this.enabled&&console.log(`\x1B[34m[info] ${e}`)}warn(e){this.enabled&&console.log(`\x1B[33m[warn] ${e}`)}error(e){this.enabled&&console.log(`\x1B[31m[error] ${e}`)}success(e){this.enabled&&console.log(`\x1B[32m[success] ${e}`)}}function D(n){return new Date(n.getTime())}function S(n,e){const t=D(n);return t.setDate(t.getDate()+e),t}function k(n,e){const t=D(n);return t.setMinutes(t.getMinutes()+e),t}function B(n,e){return n.getTime()>e.getTime()}function W(n){return new Promise(e=>{setTimeout(e,n)})}function U(n,e){const{until:t,interval:a=1e3,maxAttempt:r=3}=e;async function s(d,p){const y=p??r,h=await n(...d);return t(h)?h:y>1?(await W(a*((r-y)/2)),s(d,y-1)):h}return async(...d)=>await s(d)}function C(n,e){const t=D(n);return t.setMinutes(t.getMinutes()-e),t}class _t{constructor(e){m(this,"logger");m(this,"storageKey","session");m(this,"authService");m(this,"walletService");m(this,"_refreshing",!1);this.authService=new ht({url:e.authUrl,platform:e.platform}),this.walletService=new x(new A(e.walletUrl,{middlewares:[t=>(t.headers.set("Platform",e.platform),t.headers.set("Role","MEMBER"),t)]})),this.logger=new $({enabled:e.log??!1})}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!1,error:{name:"UnknownError",message:"Server sign in is not supported."}};if(e.type==="MAYA"){const s=await U(()=>this.walletService.mayaSession({id:e.sessionId}),{until:h=>{var E;return h.ok&&((E=h.data)==null?void 0:E.member)!=null},interval:1e3,maxAttempt:5})();if(!s.ok)return s;const p=await U(()=>this.authService.createSession(e),{until:h=>h.ok,interval:1e3,maxAttempt:5})();if(!p.ok)return p;const y=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...p.data,accessTokenExpiresAt:k(y,8).getTime(),refreshTokenExpiresAt:C(S(y,30),2).getTime()})),{ok:!0,data:null}}if(e.type==="MOBILE_NUMBER"){const r=await this.authService.createSession(e);if(r.ok){const s=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...r.data,accessTokenExpiresAt:k(s,8).getTime(),refreshTokenExpiresAt:C(S(s,30),2).getTime()})),{ok:!0,data:null}}return r}const t=await this.authService.createSession(e);if(!t.ok)return t;if(t.data.authenticator)return{ok:!0,data:{authenticator:t.data.authenticator}};const a=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:k(a,8).getTime(),refreshTokenExpiresAt:C(S(a,30),2).getTime()})),{ok:!0,data:null}}async createFromAuthenticator(e){const t=await this.authService.authenticate(e);if(t.ok){const a=new Date;return this.isServer?this.logger.warn("'localStorage' is not available on the server."):window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:k(a,8).getTime(),refreshTokenExpiresAt:C(S(a,30),2).getTime()})),{ok:!0}}else return t}async get(){if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!0,data:null};if(this.refreshing)return await W(1e3),await this.get();const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),a=new Date;const r=new Date(t.accessTokenExpiresAt),s=new Date(t.refreshTokenExpiresAt);if(B(a,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{name:"SessionExpired",message:"Session expired."}};if(B(a,r)){this.logger.info("Refreshing session..."),this.refreshing=!0;const d=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!d.ok)return this.logger.error(`Failed to refresh session: ${d.error.message}`),d.error.name==="InvalidToken"||d.error.name==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:d.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),a=new Date,t={...t,...d.data,accessTokenExpiresAt:k(a,8).getTime(),refreshTokenExpiresAt:C(S(a,30),2).getTime()},window.localStorage.setItem(this.storageKey,JSON.stringify(t))}return{ok:!0,data:t}}catch{return{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}}}async destroy(){var t;if(this.isServer){this.logger.warn("'localStorage' is not available on the server.");return}const e=await this.get();(t=e.data)!=null&&t.accessToken&&await this.authService.destroySession(e.data.accessToken),window.localStorage.removeItem(this.storageKey)}async verify(){var a,r,s;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.get();if(((a=e.error)==null?void 0:a.name)==="InvalidToken"||((r=e.error)==null?void 0:r.name)==="SessionExpired"||((s=e.error)==null?void 0:s.name)==="AccountBlacklisted")return!1;if(!e.data)return!0;const t=await this.authService.verifySession(e.data.accessToken);return t||window.localStorage.removeItem(this.storageKey),t}get isServer(){return typeof window>"u"}}function i(n,e){if(typeof n=="number"&&!Number.isNaN(n))return n;if(typeof n=="string"){const t=Number.parseFloat(n);if(!Number.isNaN(t))return t}return e}class Tt{constructor(e){m(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new bt({url:t?"https://static.development.opexa.io":"https://static.opexa.io"})}get transform(){return{platform:this.platform.bind(this),account:this.account.bind(this),wallet:this.wallet.bind(this),verificationDetails:this.verificationDetails.bind(this),profileCompletion:this.profileCompletion.bind(this),announcement:this.announcement.bind(this),withdrawalRecord:this.withdrawalRecord.bind(this),deposit:this.deposit.bind(this),depositRecord:this.depositRecord.bind(this),betRecord:this.betRecord.bind(this),latestBetRecord:this.latestBetRecord.bind(this),transactionRecord:this.transactionRecord.bind(this),game:this.game.bind(this),gameSession:this.gameSession.bind(this),promo:this.promo.bind(this),cashback:this.cashback.bind(this),bonus:this.bonus.bind(this),cashbackBonus:this.cashbackBonus.bind(this),file:this.file.bind(this),pointsWallet:this.pointsWallet.bind(this)}}platform(e){var t,a,r,s,d,p,y,h,E,b,O,q,F,L,V,Y,H,j,Q,K,z,J,X,Z,ee,te,ae,re,ne,oe,ie,se,de,me,ce,ue,le,pe,fe,he,we,ye,be,ge,Ee,Ae,Se,ke,Ce;return{paymentSettings:{minimumFirstDepositAmount:i(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.iosEnabled)??!1,webEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:i((d=e.bankDepositGatewaySettings)==null?void 0:d.minimumAmount),maximumAmount:i((p=e.bankDepositGatewaySettings)==null?void 0:p.maximumAmount)},gcash:{androidEnabled:((y=e.gcashDepositGatewaySettings)==null?void 0:y.androidEnabled)??!1,iosEnabled:((h=e.gcashDepositGatewaySettings)==null?void 0:h.iosEnabled)??!1,webEnabled:((E=e.gcashDepositGatewaySettings)==null?void 0:E.webEnabled)??!1,mobileWebEnabled:((b=e.gcashDepositGatewaySettings)==null?void 0:b.mobileWebEnabled)??!1,minimumAmount:i((O=e.gcashDepositGatewaySettings)==null?void 0:O.minimumAmount),maximumAmount:i((q=e.gcashDepositGatewaySettings)==null?void 0:q.maximumAmount)},maya:{androidEnabled:((F=e.mayaDepositGatewaySettings)==null?void 0:F.androidEnabled)??!1,iosEnabled:((L=e.mayaDepositGatewaySettings)==null?void 0:L.iosEnabled)??!1,webEnabled:((V=e.mayaDepositGatewaySettings)==null?void 0:V.webEnabled)??!1,mobileWebEnabled:((Y=e.mayaDepositGatewaySettings)==null?void 0:Y.mobileWebEnabled)??!1,minimumAmount:i((H=e.mayaDepositGatewaySettings)==null?void 0:H.minimumAmount),maximumAmount:i((j=e.mayaDepositGatewaySettings)==null?void 0:j.maximumAmount)},mayaApp:{androidEnabled:((Q=e.mayaAppDepositGatewaySettings)==null?void 0:Q.androidEnabled)??!1,iosEnabled:((K=e.mayaAppDepositGatewaySettings)==null?void 0:K.iosEnabled)??!1,webEnabled:((z=e.mayaAppDepositGatewaySettings)==null?void 0:z.webEnabled)??!1,mobileWebEnabled:((J=e.mayaAppDepositGatewaySettings)==null?void 0:J.mobileWebEnabled)??!1,minimumAmount:i((X=e.mayaAppDepositGatewaySettings)==null?void 0:X.minimumAmount),maximumAmount:i((Z=e.mayaAppDepositGatewaySettings)==null?void 0:Z.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((ee=e.bankWithdrawalGatewaySettings)==null?void 0:ee.androidEnabled)??!1,iosEnabled:((te=e.bankWithdrawalGatewaySettings)==null?void 0:te.iosEnabled)??!1,webEnabled:((ae=e.bankWithdrawalGatewaySettings)==null?void 0:ae.webEnabled)??!1,mobileWebEnabled:((re=e.bankWithdrawalGatewaySettings)==null?void 0:re.mobileWebEnabled)??!1,minimumAmount:i((ne=e.bankWithdrawalGatewaySettings)==null?void 0:ne.minimumAmount),maximumAmount:i((oe=e.bankWithdrawalGatewaySettings)==null?void 0:oe.maximumAmount)},gcash:{androidEnabled:((ie=e.gcashWithdrawalGatewaySettings)==null?void 0:ie.androidEnabled)??!1,iosEnabled:((se=e.gcashWithdrawalGatewaySettings)==null?void 0:se.iosEnabled)??!1,webEnabled:((de=e.gcashWithdrawalGatewaySettings)==null?void 0:de.webEnabled)??!1,mobileWebEnabled:((me=e.gcashWithdrawalGatewaySettings)==null?void 0:me.mobileWebEnabled)??!1,minimumAmount:i((ce=e.gcashWithdrawalGatewaySettings)==null?void 0:ce.minimumAmount),maximumAmount:i((ue=e.gcashWithdrawalGatewaySettings)==null?void 0:ue.maximumAmount,1e6)},maya:{androidEnabled:((le=e.mayaWithdrawalGatewaySettings)==null?void 0:le.androidEnabled)??!1,iosEnabled:((pe=e.mayaWithdrawalGatewaySettings)==null?void 0:pe.iosEnabled)??!1,webEnabled:((fe=e.mayaWithdrawalGatewaySettings)==null?void 0:fe.webEnabled)??!1,mobileWebEnabled:((he=e.mayaWithdrawalGatewaySettings)==null?void 0:he.mobileWebEnabled)??!1,minimumAmount:i((we=e.mayaWithdrawalGatewaySettings)==null?void 0:we.minimumAmount),maximumAmount:i((ye=e.mayaWithdrawalGatewaySettings)==null?void 0:ye.maximumAmount)},mayaApp:{androidEnabled:((be=e.mayaAppWithdrawalGatewaySettings)==null?void 0:be.androidEnabled)??!1,iosEnabled:((ge=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ge.iosEnabled)??!1,webEnabled:((Ee=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ee.webEnabled)??!1,mobileWebEnabled:((Ae=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ae.mobileWebEnabled)??!1,minimumAmount:i((Se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Se.minimumAmount),maximumAmount:i((ke=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ke.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:i((Ce=e.pointsClubSettings)==null?void 0:Ce.multiplier,0)}}}account(e){return{id:e.id,name:e.name,status:e.status,verified:e.verified,nickName:e.nickName??void 0,realName:e.realName??void 0,dateOfBirth:e.birthDay?new Date(e.birthDay):void 0,emailAddress:e.emailAddress??void 0,mobileNumber:e.mobileNumber??void 0,mobileNumberVerified:e.mobileNumberVerified??!1,mobileNumberVerificationRequired:e.mobileNumberVerificationRequired??!1,validId:e.validId?e.validId:void 0,verificationStatus:e.verificationStatus,transactionPassword:e.transactionPassword,secretAnswerSubmitted:e.secretAnswerSubmitted??!1,dateTimeLastActive:e.dateTimeLastActive?new Date(e.dateTimeLastActive):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}wallet(e){return{...e,balance:i(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}verificationDetails(e){return{...e,selfieImage:this.file(e.selfieImage),idFrontImage:this.file(e.idFrontImage)}}profileCompletion(e){return{...e,completionPercentage:i(e,0)}}announcement(e){return{...e,activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}withdrawalRecord(e){return{...e,amount:i(e.amount,0),netAmount:i(e.netAmount,0),fee:i(e.fee,0),reference:e.reference??void 0,bank:e.bank??void 0,recipientMobileNumber:e.recipientMobileNumber??void 0,dateTimeConfirmed:e.dateTimeConfirmed?new Date(e.dateTimeConfirmed):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}deposit(e){return{id:e.id,type:e.type,status:e.status,checkoutUrl:e.checkoutUrl??void 0}}depositRecord(e){return{...e,amount:i(e.amount,0),fee:i(e.fee,0),netAmount:i(e.netAmount,0),reference:e.reference??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}betRecord(e){var t;return{...e,bet:i(e.bet,0),payout:i(e.payout,0),jackpotContribution:i(e.jackpotContribution,0),jackpotPayout:i(e.jackpotPayout,0),winloss:i(e.winloss),validBet:i(e.validBet,0),vendorRoundId:e.vendorRoundId??void 0,game:this.game(e.game),dateTimeSettled:e.dateTimeSettled?new Date(e.dateTimeSettled):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated),betContent:e.betContent??void 0,contestName:e.contestName??void 0,externalCategory:e.externalCategory??void 0,metadata:{odds:((t=e.metadata)==null?void 0:t.odds)??void 0}}}latestBetRecord(e){return{...e,game:this.game(e.game),bet:i(e.bet,0),payout:i(e.payout,0),validBet:i(e.validBet,0),dateTimeSettled:new Date(e.dateTimeSettled),dateTimeCreated:new Date(e.dateTimeCreated)}}transactionRecord(e){return{...e,amount:i(e.amount,0),content:e.content??void 0,currentBalance:i(e.currentBalance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}game(e){const t=this.staticService.gameThumbnails(e);return{...e,images:t}}gameSession(e){return{...e,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}promo(e){return{...e,banner:this.file(e.banner),maximumBonusAmount:i(e.maximumBonusAmount),minimumBonusAmount:i(e.minimumBonusAmount),activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashback(e){return{...e,banner:this.file(e.banner),activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}bonus(e){return{...e,promo:this.promo(e.promo),deposit:e.deposit?{...e.deposit,fee:i(e.deposit.fee,0),amount:i(e.deposit.amount,0),netAmount:i(e.deposit.netAmount,0),reference:e.deposit.reference??void 0,dateTimeCreated:new Date(e.deposit.dateTimeCreated),dateTimeLastUpdated:new Date(e.deposit.dateTimeLastUpdated)}:void 0,balance:i(e.balance,0),amount:i(e.amount,0),expiration:new Date(e.expiration),turnoverRequirement:i(e.turnoverRequirement,0),currentTurnoverRequirementContribution:i(e.currentTurnoverRequirementContribution,0),currentTurnoverRequirementContributionPercentage:i(e.currentTurnoverRequirementContributionPercentage,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashbackBonus(e){return{id:e.id,balance:i(e.balance,0),cashback:this.cashback(e.cashback),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}file(e){return{...e,url:e.url??void 0,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWallet(e){return{id:e.id,points:i(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}}class vt{constructor(e){m(this,"gameService");m(this,"fileService");m(this,"walletService");m(this,"reportService");m(this,"portalService");m(this,"accountService");m(this,"sessionManager");m(this,"transformer");m(this,"logger");const t=e.environment==="development";this.sessionManager=new _t({authUrl:t?"https://auth.development.opexa.io":"https://auth.opexa.io",walletUrl:t?"https://wallet.development.opexa.io/graphql":"https://wallet.opexa.io/graphql",platform:e.platform,log:e.log});const a={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":e.platform}}};this.gameService=new gt(new A(t?"https://game.development.opexa.io/graphql":"https://game.opexa.io/graphql",a)),this.fileService=new wt(new A(t?"https://file.development.opexa.io/graphql":"https://file.opexa.io/graphql",a)),this.walletService=new x(new A(t?"https://wallet.development.opexa.io/graphql":"https://wallet.opexa.io/graphql",a)),this.reportService=new yt(new A(t?"https://report.development.opexa.io/graphql":"https://report.opexa.io/graphql",a)),this.accountService=new ft(new A(t?"https://account.development.opexa.io/graphql":"https://account.opexa.io/graphql",a)),this.portalService=new Et(new A(t?"https://portal.development.opexa.io/graphql":"https://portal.opexa.io/graphql",a)),this.transformer=new Tt(e),this.logger=new $({enabled:e.log??!1})}get authMiddleware(){return async e=>{this.logger.info("Checking for session");const t=await this.sessionManager.get();return t.data?(e.headers.append("Authorization",`Bearer ${t.data.accessToken}`),this.logger.info("Session found"),this.logger.success("Added 'Authorization' header")):this.logger.info("No session found"),e}}async signIn(e){switch(e.type){case"NAME_AND_PASSWORD":{const t=await this.sessionManager.create({...e,password:await g(e.password)});return t.ok?t.data?{ok:!0,data:{"2FAEnabled":!0,authenticator:t.data.authenticator}}:{ok:!0,data:{"2FAEnabled":!1}}:t}default:{const t=await this.sessionManager.create(e);return t.ok?{ok:!0}:t}}}async authenticate(e){switch(e.type){case"SECURITY_QUESTION":return await this.sessionManager.createFromAuthenticator({type:"SECURITY_QUESTION",token:e.token,secretAnswer:await g(e.secretAnswer)});default:return{ok:!1,error:{name:"HttpBadRequest",message:"Invalid input 'type'"}}}}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=At(e.interval??3e4,3e4,6e4);let a=null;const r=()=>setTimeout(async()=>{await this.sessionManager.verify()||await e.onInvalid(),a=r()},t);return a=r(),function(){a&&clearTimeout(a)}}async session(){const e=await this.sessionManager.get();return e.ok?{ok:!0,data:e.data?{id:e.data.session.id,dateTimeCreated:new Date(e.data.session.dateTimeCreated)}:null}:e}async platform(){const e=await this.accountService.platform();return e.ok?{ok:!0,data:this.transformer.transform.platform(e.data)}:e}async account(){const[e,t]=await Promise.all([this.accountService.memberAccount(),this.reportService.member()]);return e.ok?t.ok?{ok:!0,data:this.transformer.transform.account({...e.data,...t.data})}:{ok:!1,error:t.error}:{ok:!1,error:e.error}}async createAccount(e){const t=e.id??u.ObjectId.generate(w.Account).toString(),a=await this.accountService.registerMemberAccount({input:{id:t,name:e.name,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await g(e.password),mobileNumber:this.addAreaCode(e.mobileNumber),domain:e.domain,btag:e.referralCode},verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return a.ok?{ok:!0,data:{id:t}}:a}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await g(t.password):void 0,transactionPassword:t.transactionPassword?await g(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:this.addAreaCode(t.mobileNumber)},secretAnswer:t.secretAnswer?await g(t.secretAnswer):void 0}}})}async deleteAccount(e){return await this.accountService.deleteMemberAccount({input:{id:e}})}async verificationDetails(){const e=await this.accountService.memberVerification();return e.ok?{ok:!0,data:e.data?this.transformer.transform.verificationDetails(e.data):null}:e}async submitVerificationDetails(e){const t=e.id??u.ObjectId.generate(w.Verification).toString(),a=await this.accountService.createMemberVerification({input:{id:t,...e}});return a.ok?{ok:!0,data:{id:t}}:a}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:this.addAreaCode(e.mobileNumber),newPassword:await g(e.newPassword)},verificationCode:e.verificationCode})}async verifyMobileNumber(e){return await this.accountService.verifyMobileNumber({input:{verificationCode:e}})}async profileCompletion(){const e=await this.accountService.profileCompletion();return e.ok?{ok:!0,data:this.transformer.transform.profileCompletion(e.data)}:e}async sendVerificationCode(e){return await this.accountService.sendVerificationCode({input:{channel:"SMS",recipient:this.addAreaCode(e)}})}async wallet(){const e=await this.walletService.wallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.wallet(e.data):null}:e}async announcements(e){const t=await this.accountService.announcements({...e,filter:{visibility:{in:["MEMBER","GLOBAL"]},activationStartDateTime:{greaterThanOrEqual:new Date}}});return t.ok?{ok:!0,data:{announcements:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.announcement(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??u.ObjectId.generate(w.Withdrawal).toString();if(e.type==="BANK"){const a=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword)}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword),recipientMobileNumber:this.addAreaCode(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA"){const a=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword),recipientMobileNumber:this.addAreaCode(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword)}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async withdrawalRecords(e){const t=await this.reportService.withdrawalRecords(e);return t.ok?{ok:!0,data:{withdrawalRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.withdrawalRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async remainingDailyWithdrawalsCount(){return await this.walletService.remainingDailyWithdrawalsCount()}async createDeposit(e){const t=e.id??u.ObjectId.generate(w.Deposit).toString();if(e.type==="MAYA"){const a=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async deposit(e){const t=await this.walletService.deposit({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.deposit(t.data):null}:t}async depositRecords(e){const t=await this.reportService.depositRecords(e);return t.ok?{ok:!0,data:{depositRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.depositRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async depositsCount(){return await this.reportService.depositsCount()}async betRecords(e){const t=await this.reportService.betRecords(e);return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.betRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async latestBetRecords(){const e=await this.portalService.latestBetRecords();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.latestBetRecord)}:e}async transactionRecords(e){const t=await this.reportService.transactionRecords(e);return t.ok?{ok:!0,data:{transactionRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.transactionRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async promos(){const e=await this.walletService.promos();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.promo)}:e}async availablePromos(){const e=await this.walletService.availablePromos();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.promo)}:e}async cashbacks(){const e=await this.walletService.cashbacks();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.cashback)}:e}async bonus(){const e=await this.walletService.bonus();return e.ok?{ok:!0,data:e.data?this.transformer.transform.bonus(e.data):null}:e}async cashbackBonuses(){const e=await this.walletService.cashbackBonuses();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.cashbackBonus)}:e}async claimCashbackBonus(e){return await this.walletService.claimCashbackBonus({input:{id:e}})}async games(e){const t=await this.walletService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.game(r),cursor:a})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async games__legacy(e){const t=await this.gameService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.game(r),cursor:a})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async gamesByName(e){const t=await this.walletService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gamesByName__legacy(e){const t=await this.gameService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gameSession(e){const t=await this.walletService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async gameSession__legacy(e){const t=await this.gameService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async createGameSession(e){const t=e.id??u.ObjectId.generate(w.GameSession).toString(),a=await this.walletService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async createGameSession__legacy(e){const t=e.id??u.ObjectId.generate(w.GameSession).toString(),a=await this.gameService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async endGameSession(e){return await this.walletService.endGameSession({input:{id:e}})}async endGameSession__legacy(e){return await this.gameService.endGameSession({input:{id:e}})}async file(e){const t=await this.fileService.file({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.file(t.data):null}:t}async uploadImageFile(e){const t=e.id??u.ObjectId.generate(w.File).toString(),a=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return a.ok?{ok:!0,data:{id:t}}:a}async pointsWallet(){const e=await this.walletService.pointsWallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.pointsWallet(e.data):null}:e}async pointsToCashConversion(e){return await this.walletService.pointsToCashConversion({input:{amount:e.toString()}})}addAreaCode(e){return e.startsWith("+63")?e:e.startsWith("63")?`+${e}`:e.startsWith("0")?`+63${e.substring(1)}`:`+63${e}`}}Object.defineProperty(l,"ObjectId",{enumerable:!0,get:()=>u.ObjectId}),l.ObjectType=w,l.Sdk=vt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
941
+ `;function c(n){return{name:n,message:{AccountNameNotAvailableError:"Username is no longer available",AccountNotFoundError:"Account does not exist",AccountNotVerifiedError:"Account is not verified",CashbackBonusDoesNotExistError:"Cashback bonus does not exists",DepositPromoMaximumAmountExceededError:"Deposit amount exceeds maximum amount",DepositPromoMinimumAmountNotMetError:"Deposit amount does not meet minimum amount",EmailAddressNotAvailableError:"Email is no longer available",FileDoesNotExistError:"File does not exist",FileFormatNotSupportedError:"File format is not supported",FileNameTooLongError:"File name is too long",FileNotReadyError:"File is not yet ready",FileSizeTooBigError:"File size is too big",GameDoesNotExistError:"Game does not exist",HasActiveBonusError:"Account has active bonus",InsufficientPointsError:"Insufficient points",InvalidPlatformError:"Invalid platform",InvalidReCAPTCHAResponseError:"Invalid reCAPTCHA",InvalidSMSVerificationCodeError:"Invalid SMS verification code",InvalidTransactionPasswordError:"Invalid transaction password",InvalidVerificationCodeError:"Invalid verification code",InvalidWithdrawalAmountError:"Invalid withdrawal amount",MaximumDepositAmountExceededError:"Maximum deposit amount exceeded",MemberVerificationAlreadyApprovedError:"Member verification is already approved",MemberVerificationAlreadyExistsError:"Member verification already exists",MemberVerificationDoesNotExistError:"Member verification does not exist",MinimumAgeRequirementError:"Minimum age requirement not met",MinimumDepositAmountNotMetError:"Minimum deposit amount not met",MinimumFirstDepositAmountNotMetError:"Minimum first deposit amount not met",MobileNumberAlreadyVerifiedError:"Mobile number is already verified",MobileNumberNotAvailableError:"Mobile number is no longer available",MobileNumberNotVerifiedError:"Mobile number is not verified",NickNameNotAvailableError:"Nickname is no longer available",NotEnoughBalanceError:"Insufficient balance",NotReadyToSendVerficationCodeError:"Not ready to send verification code",PromoNotEnabledError:"Promo is not enabled",RealNameAlreadySetError:"Real name is already set",ValidIdAlreadySetError:"Valid ID is already set",WalletDoesNotExistError:"Wallet does not exist",WithdrawalDailyLimitExceededError:"Daily withdrawal limit exceeded",GameProviderError:"Game provider error",GameSessionAlreadyClosedError:"Game session is already closed",GameSessionDoesNotExistError:"Game session does not exist",AccountBlacklisted:"Account is blacklisted",AccountNotFound:"Account not found",InvalidToken:"Invalid token",InvalidTokenOrSecretAnswer:"Invalid token or secret answer",SessionExpired:"Session expired"}[n]}}class ht{constructor(e){m(this,"client");this.client=e}async memberAccount(){const e=await this.client.request(at);return e.ok?{ok:!0,data:e.data.memberAccount}:e}async registerMemberAccount(e){const t=await this.client.request(nt,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:c(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async updateMemberAccount(e){const t=await this.client.request(ot,e);return t.ok?t.data.updateMemberAccount?{ok:!1,error:c(t.data.updateMemberAccount.__typename)}:{ok:!0}:t}async deleteMemberAccount(e){const t=await this.client.request(st,e);return t.ok?t.data.deleteMemberAccount?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}async resetPassword(e){const t=await this.client.request(it,e);return t.ok?t.data.resetPassword?{ok:!1,error:c(t.data.resetPassword.__typename)}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(ut);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(pt)}async sendVerificationCode(e){const t=await this.client.request(lt,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:c(t.data.sendVerificationCode.__typename)}:{ok:!0}:t}async verifyMobileNumber(e){const t=await this.client.request(dt,e);return t.ok?t.data.verifyMobileNumber?{ok:!1,error:c(t.data.verifyMobileNumber.__typename)}:{ok:!0}:t}async createMemberVerification(e){const t=await this.client.request(mt,e);return t.ok?t.data.createMemberVerification?{ok:!1,error:c(t.data.createMemberVerification.__typename)}:{ok:!0}:t}async updateMemberVerification(e){const t=await this.client.request(ct,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:c(t.data.updateMemberVerification.__typename)}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(rt);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(Ge,e);return t.ok?{ok:!0,data:t.data.announcements}:t}}function f(n,e){const t=M[n]?M[n]:M[500];return{name:t.name,message:e??t.message}}const M={400:{name:"HttpBadRequest",message:"Bad Request"},401:{name:"HttpUnauthorized",message:"Unauthorized"},403:{name:"HttpForbidden",message:"Forbidden"},404:{name:"HttpNotFound",message:"Not Found"},408:{name:"HttpRequestTimeout",message:"Request Timeout"},429:{name:"HttpTooManyRequests",message:"Too Many Requests"},500:{name:"HttpInternalServerError",message:"Internal Server Error"}};class wt{constructor(e){m(this,"url");m(this,"platform");this.url=e.url,this.platform=e.platform}async createSession(e){const t=new Headers({"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER"});if(e.name){const a=`${e.name}:${e.password}`,r=Buffer.from(a).toString("base64");t.set("Authorization",`Basic ${r}`)}if(e.mobileNumber){const a=`${e.mobileNumber}:${e.verificationCode}`,r=Buffer.from(a).toString("base64");t.set("Authorization",`MobileNumberOTP ${r}`)}e.sessionId&&t.set("Authorization",`Maya ${e.sessionId}`);try{const a=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),r=await a.json();return a.ok?{ok:!0,data:r}:r.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:c("AccountBlacklisted")}:{ok:!1,error:f(a.status)}}catch{return{ok:!1,error:f(500)}}}async authenticate(e){const t=new Headers({"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER"});if(e.type==="SECURITY_QUESTION"){t.set("Authorization",`Bearer ${e.token}`);try{const a=await fetch(`${this.url}/session/${e.token}/authenticate`,{method:"POST",headers:t,body:JSON.stringify({secretAnswer:e.secretAnswer})}),r=await a.json();return a.ok?{ok:!0,data:r}:a.status===401||a.status===403?{ok:!1,error:c("InvalidTokenOrSecretAnswer")}:{ok:!1,error:f(a.status)}}catch{return{ok:!1,error:f(500)}}}throw new Error("Invalid input 'type'")}async refreshSession(e){try{const t=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}}),a=await t.json();return t.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:c("AccountBlacklisted")}:t.status===403||t.status===401?{ok:!1,error:c("InvalidToken")}:{ok:!1,error:f(t.status)}}catch{return{ok:!1,error:f(500)}}}async destroySession(e){try{const t=await fetch(`${this.url}/session`,{method:"DELETE",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}});return t.ok?{ok:!0}:{ok:!1,error:f(t.status)}}catch{return{ok:!1,error:f(500)}}}async verifySession(e){try{return(await fetch(`${this.url}/session`,{method:"GET",headers:{"Content-Type":"application/json","Platform-Code":this.platform,Role:"MEMBER",Authorization:`Bearer ${e}`}})).ok}catch{return!0}}}class yt{constructor(e){m(this,"client");this.client=e}async file(e){const t=await this.client.request(Ce,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(_e,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:c(t.data.uploadPrivateImageFile.__typename)}:{ok:!0}:t}}class bt{constructor(e){m(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(He,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(Qe,e);return t.ok?{ok:t.ok,data:t.data.member.transactionRecords}:t}async withdrawalRecords(e){const t=await this.client.request(Pe,e);return t.ok?{ok:t.ok,data:t.data.member.withdrawalRecords}:t}async depositRecords(e){const t=await this.client.request(Oe,e);return t.ok?{ok:t.ok,data:t.data.member.depositRecords}:t}async depositsCount(){const e=await this.client.request(Ye);return e.ok?{ok:e.ok,data:e.data.member.depositsCount}:e}async member(){const e=await this.client.request(tt);return e.ok?{ok:e.ok,data:e.data.member}:e}}class gt{constructor(e){m(this,"url");this.url=e.url}gameThumbnails(e){return[`${this.url}/images/${e.provider.toLowerCase()}/thumbnail-${e.id}.webp`,`${this.url}/images/${e.provider.toLowerCase()}/thumbnail-${e.provider.toLowerCase()}.webp`]}}class P{constructor(e){m(this,"client");this.client=e}async promos(){const e=await this.client.request(Ke);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(Je);return e.ok?{ok:e.ok,data:e.data.cashbacks}:e}async availablePromos(e){const t=await this.client.request(ze,e);return t.ok?{ok:t.ok,data:t.data.availablePromos}:t}async cashbackBonuses(){const e=await this.client.request(Ze);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(et,e);return t.ok?t.data.claimCashbackBonus?{ok:!1,error:c(t.data.claimCashbackBonus.__typename)}:{ok:!0}:{ok:t.ok,error:t.error}}async bonus(){const e=await this.client.request(Xe);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(Te);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(Ve,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(qe,e);return t.ok?t.data.createGCashDeposit?{ok:!1,error:c(t.data.createGCashDeposit.__typename)}:{ok:!0}:t}async createMayaDeposit(e){const t=await this.client.request(Fe,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:c(t.data.createMayaDeposit.__typename)}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request(Le,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:c(t.data.createMayaAppDeposit.__typename)}:{ok:!0}:t}async createGCashWithdrawal(e){const t=await this.client.request(xe,e);return t.ok?t.data.createGCashWithdrawal?{ok:!1,error:c(t.data.createGCashWithdrawal.__typename)}:{ok:!0}:t}async createMayaWithdrawal(e){const t=await this.client.request($e,e);return t.ok?t.data.createMayaWithdrawal?{ok:!1,error:c(t.data.createMayaWithdrawal.__typename)}:{ok:!0}:t}async createMayaAppWithdrawal(e){const t=await this.client.request(Be,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:c(t.data.createMayaAppWithdrawal.__typename)}:{ok:!0}:t}async createBankWithdrawal(e){const t=await this.client.request(We,e);return t.ok?t.data.createBankWithdrawal?{ok:!1,error:c(t.data.createBankWithdrawal.__typename)}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(Ue);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(ve);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(Me,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:c(t.data.pointsToCashConversion.__typename)}:{ok:!0}:t}async mayaSession(e){const t=await this.client.request(ft,e);return t.ok?{ok:t.ok,data:t.data.mayaSession}:t}async games(e){const t=await this.client.request(D,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(I,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(Ne,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(R,e);return t.ok?t.data.createGameSession?{ok:!1,error:c(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(De,e);return t.ok?t.data.endGameSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:t}}class Et{constructor(e){m(this,"client");this.client=e}async games(e){const t=await this.client.request(D,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(I,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(Ie,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(R,e);return t.ok?t.data.createGameSession?{ok:!1,error:c(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Re,e);return t.ok?t.data.endGameSession?{ok:!1,error:c(t.data.endGameSession.__typename)}:{ok:!0}:t}}class St{constructor(e){m(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(je);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}function At(n,e,t){return n<e?e:n>t?t:n}function kt(n){return Object.prototype.toString.call(n)==="[object Object]"&&Object(n)===n}function Ct(n){const e=[];function t(a,r=[]){for(const s in a){const d=a[s];kt(d)?t(d,[...r,s]):Array.isArray(d)?t(_t(d),[...r,s]):e.push({key:[...r,s],value:d})}}return t(n),e}function _t(n){return n.reduce((e,t,a)=>(e[a]=t,e),{})}class S{constructor(e,t){m(this,"url");m(this,"options");m(this,"middlewares");var r;const a=new Headers((r=t==null?void 0:t.fetchOptions)==null?void 0:r.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:a},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){const a=JSON.stringify({query:e,variables:t}),r=new Headers(this.options.headers);r.set("Content-Type","application/json"),r.set("Accept","application/json");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(s)}async upload(e,t){const a=this.createUploadBody(e,t),r=new Headers(this.options.headers);r.delete("Content-Type");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:a,headers:r,method:"POST"}));return await this.exec(s)}async exec(e){var t,a,r,s,d,p;try{const y=await fetch(e);if(!y.ok)return{ok:!1,error:f(y.status)};const h=await y.json(),E=h.data,b=(t=h.errors)==null?void 0:t.at(0);return b?((a=b.extensions)==null?void 0:a.code)==="FORBIDDEN"||((r=b.extensions)==null?void 0:r.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:f(403,b.message)}:((s=b.extensions)==null?void 0:s.code)==="UNAUTHORIZED"?{ok:!1,error:f(401,b.message)}:((d=b.extensions)==null?void 0:d.code)==="BAD_USER_INPUT"||((p=b.extensions)==null?void 0:p.code)==="BAD_REQUEST"?{ok:!1,error:f(400,b.message)}:{ok:!1,error:f(500,b.message)}:{ok:!0,data:E}}catch{return{ok:!1,error:f(500)}}}async runMiddlewares(e){let t=e.clone();for(const a of this.middlewares)t=await a(t);return t}createUploadBody(e,t){const a=Ct(t).filter(d=>d.value instanceof File||d.value instanceof Blob),r=new FormData;r.append("operations",JSON.stringify({query:e,variables:t}));const s={};return a.forEach((d,p)=>{s[p.toString()]=[`variables.${d.key.join(".")}`]}),r.append("map",JSON.stringify(s)),a.forEach((d,p)=>{r.append(p.toString(),d.value)}),r}}async function g(n){const e=new TextEncoder().encode(n),t=await crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(t)).map(s=>s.toString(16).padStart(2,"0")).join("")}class x{constructor(e){m(this,"enabled");this.enabled=(e==null?void 0:e.enabled)??!0}info(e){this.enabled&&console.log(`\x1B[34m[info] ${e}`)}warn(e){this.enabled&&console.log(`\x1B[33m[warn] ${e}`)}error(e){this.enabled&&console.log(`\x1B[31m[error] ${e}`)}success(e){this.enabled&&console.log(`\x1B[32m[success] ${e}`)}}function N(n){return new Date(n.getTime())}function A(n,e){const t=N(n);return t.setDate(t.getDate()+e),t}function k(n,e){const t=N(n);return t.setMinutes(t.getMinutes()+e),t}function $(n,e){return n.getTime()>e.getTime()}function B(n){return new Promise(e=>{setTimeout(e,n)})}function W(n,e){const{until:t,interval:a=1e3,maxAttempt:r=3}=e;async function s(d,p){const y=p??r,h=await n(...d);return t(h)?h:y>1?(await B(a*((r-y)/2)),s(d,y-1)):h}return async(...d)=>await s(d)}function C(n,e){const t=N(n);return t.setMinutes(t.getMinutes()-e),t}class Tt{constructor(e){m(this,"logger");m(this,"storageKey","session");m(this,"authService");m(this,"walletService");m(this,"_refreshing",!1);this.authService=new wt({url:e.authUrl,platform:e.platform}),this.walletService=new P(new S(e.walletUrl,{middlewares:[t=>(t.headers.set("Platform",e.platform),t.headers.set("Role","MEMBER"),t)]})),this.logger=new x({enabled:e.log??!1})}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!1,error:{name:"UnknownError",message:"Server sign in is not supported."}};if(e.type==="MAYA"){const s=await W(()=>this.walletService.mayaSession({id:e.sessionId}),{until:h=>{var E;return h.ok&&((E=h.data)==null?void 0:E.member)!=null},interval:1e3,maxAttempt:5})();if(!s.ok)return s;const p=await W(()=>this.authService.createSession(e),{until:h=>h.ok,interval:1e3,maxAttempt:5})();if(!p.ok)return p;const y=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...p.data,accessTokenExpiresAt:k(y,8).getTime(),refreshTokenExpiresAt:C(A(y,30),2).getTime()})),{ok:!0,data:null}}if(e.type==="MOBILE_NUMBER"){const r=await this.authService.createSession(e);if(r.ok){const s=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...r.data,accessTokenExpiresAt:k(s,8).getTime(),refreshTokenExpiresAt:C(A(s,30),2).getTime()})),{ok:!0,data:null}}return r}const t=await this.authService.createSession(e);if(!t.ok)return t;if(t.data.authenticator)return{ok:!0,data:{authenticator:t.data.authenticator}};const a=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:k(a,8).getTime(),refreshTokenExpiresAt:C(A(a,30),2).getTime()})),{ok:!0,data:null}}async createFromAuthenticator(e){const t=await this.authService.authenticate(e);if(t.ok){const a=new Date;return this.isServer?this.logger.warn("'localStorage' is not available on the server."):window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:k(a,8).getTime(),refreshTokenExpiresAt:C(A(a,30),2).getTime()})),{ok:!0}}else return t}async get(){if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),{ok:!0,data:null};if(this.refreshing)return await B(1e3),await this.get();const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),a=new Date;const r=new Date(t.accessTokenExpiresAt),s=new Date(t.refreshTokenExpiresAt);if($(a,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{name:"SessionExpired",message:"Session expired."}};if($(a,r)){this.logger.info("Refreshing session..."),this.refreshing=!0;const d=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!d.ok)return this.logger.error(`Failed to refresh session: ${d.error.message}`),d.error.name==="InvalidToken"||d.error.name==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:d.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),a=new Date,t={...t,...d.data,accessTokenExpiresAt:k(a,8).getTime(),refreshTokenExpiresAt:C(A(a,30),2).getTime()},window.localStorage.setItem(this.storageKey,JSON.stringify(t))}return{ok:!0,data:t}}catch{return{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}}}async destroy(){var t;if(this.isServer){this.logger.warn("'localStorage' is not available on the server.");return}const e=await this.get();(t=e.data)!=null&&t.accessToken&&await this.authService.destroySession(e.data.accessToken),window.localStorage.removeItem(this.storageKey)}async verify(){var a,r,s;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.get();if(((a=e.error)==null?void 0:a.name)==="InvalidToken"||((r=e.error)==null?void 0:r.name)==="SessionExpired"||((s=e.error)==null?void 0:s.name)==="AccountBlacklisted")return!1;if(!e.data)return!0;const t=await this.authService.verifySession(e.data.accessToken);return t||window.localStorage.removeItem(this.storageKey),t}get isServer(){return typeof window>"u"}}function i(n,e){if(typeof n=="number"&&!Number.isNaN(n))return n;if(typeof n=="string"){const t=Number.parseFloat(n);if(!Number.isNaN(t))return t}return e}class vt{constructor(e){m(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new gt({url:t?"https://static.development.opexa.io":"https://static.opexa.io"})}get transform(){return{platform:this.platform.bind(this),account:this.account.bind(this),wallet:this.wallet.bind(this),verificationDetails:this.verificationDetails.bind(this),profileCompletion:this.profileCompletion.bind(this),announcement:this.announcement.bind(this),withdrawalRecord:this.withdrawalRecord.bind(this),deposit:this.deposit.bind(this),depositRecord:this.depositRecord.bind(this),betRecord:this.betRecord.bind(this),latestBetRecord:this.latestBetRecord.bind(this),transactionRecord:this.transactionRecord.bind(this),game:this.game.bind(this),gameSession:this.gameSession.bind(this),promo:this.promo.bind(this),cashback:this.cashback.bind(this),bonus:this.bonus.bind(this),cashbackBonus:this.cashbackBonus.bind(this),file:this.file.bind(this),pointsWallet:this.pointsWallet.bind(this)}}platform(e){var t,a,r,s,d,p,y,h,E,b,U,O,q,F,L,V,Y,H,j,Q,K,z,J,X,Z,ee,te,ae,re,ne,oe,ie,se,de,me,ce,ue,le,pe,fe,he,we,ye,be,ge,Ee,Se,Ae,ke;return{paymentSettings:{minimumFirstDepositAmount:i(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.iosEnabled)??!1,webEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:i((d=e.bankDepositGatewaySettings)==null?void 0:d.minimumAmount),maximumAmount:i((p=e.bankDepositGatewaySettings)==null?void 0:p.maximumAmount)},gcash:{androidEnabled:((y=e.gcashDepositGatewaySettings)==null?void 0:y.androidEnabled)??!1,iosEnabled:((h=e.gcashDepositGatewaySettings)==null?void 0:h.iosEnabled)??!1,webEnabled:((E=e.gcashDepositGatewaySettings)==null?void 0:E.webEnabled)??!1,mobileWebEnabled:((b=e.gcashDepositGatewaySettings)==null?void 0:b.mobileWebEnabled)??!1,minimumAmount:i((U=e.gcashDepositGatewaySettings)==null?void 0:U.minimumAmount),maximumAmount:i((O=e.gcashDepositGatewaySettings)==null?void 0:O.maximumAmount)},maya:{androidEnabled:((q=e.mayaDepositGatewaySettings)==null?void 0:q.androidEnabled)??!1,iosEnabled:((F=e.mayaDepositGatewaySettings)==null?void 0:F.iosEnabled)??!1,webEnabled:((L=e.mayaDepositGatewaySettings)==null?void 0:L.webEnabled)??!1,mobileWebEnabled:((V=e.mayaDepositGatewaySettings)==null?void 0:V.mobileWebEnabled)??!1,minimumAmount:i((Y=e.mayaDepositGatewaySettings)==null?void 0:Y.minimumAmount),maximumAmount:i((H=e.mayaDepositGatewaySettings)==null?void 0:H.maximumAmount)},mayaApp:{androidEnabled:((j=e.mayaAppDepositGatewaySettings)==null?void 0:j.androidEnabled)??!1,iosEnabled:((Q=e.mayaAppDepositGatewaySettings)==null?void 0:Q.iosEnabled)??!1,webEnabled:((K=e.mayaAppDepositGatewaySettings)==null?void 0:K.webEnabled)??!1,mobileWebEnabled:((z=e.mayaAppDepositGatewaySettings)==null?void 0:z.mobileWebEnabled)??!1,minimumAmount:i((J=e.mayaAppDepositGatewaySettings)==null?void 0:J.minimumAmount),maximumAmount:i((X=e.mayaAppDepositGatewaySettings)==null?void 0:X.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((Z=e.bankWithdrawalGatewaySettings)==null?void 0:Z.androidEnabled)??!1,iosEnabled:((ee=e.bankWithdrawalGatewaySettings)==null?void 0:ee.iosEnabled)??!1,webEnabled:((te=e.bankWithdrawalGatewaySettings)==null?void 0:te.webEnabled)??!1,mobileWebEnabled:((ae=e.bankWithdrawalGatewaySettings)==null?void 0:ae.mobileWebEnabled)??!1,minimumAmount:i((re=e.bankWithdrawalGatewaySettings)==null?void 0:re.minimumAmount),maximumAmount:i((ne=e.bankWithdrawalGatewaySettings)==null?void 0:ne.maximumAmount)},gcash:{androidEnabled:((oe=e.gcashWithdrawalGatewaySettings)==null?void 0:oe.androidEnabled)??!1,iosEnabled:((ie=e.gcashWithdrawalGatewaySettings)==null?void 0:ie.iosEnabled)??!1,webEnabled:((se=e.gcashWithdrawalGatewaySettings)==null?void 0:se.webEnabled)??!1,mobileWebEnabled:((de=e.gcashWithdrawalGatewaySettings)==null?void 0:de.mobileWebEnabled)??!1,minimumAmount:i((me=e.gcashWithdrawalGatewaySettings)==null?void 0:me.minimumAmount),maximumAmount:i((ce=e.gcashWithdrawalGatewaySettings)==null?void 0:ce.maximumAmount,1e6)},maya:{androidEnabled:((ue=e.mayaWithdrawalGatewaySettings)==null?void 0:ue.androidEnabled)??!1,iosEnabled:((le=e.mayaWithdrawalGatewaySettings)==null?void 0:le.iosEnabled)??!1,webEnabled:((pe=e.mayaWithdrawalGatewaySettings)==null?void 0:pe.webEnabled)??!1,mobileWebEnabled:((fe=e.mayaWithdrawalGatewaySettings)==null?void 0:fe.mobileWebEnabled)??!1,minimumAmount:i((he=e.mayaWithdrawalGatewaySettings)==null?void 0:he.minimumAmount),maximumAmount:i((we=e.mayaWithdrawalGatewaySettings)==null?void 0:we.maximumAmount)},mayaApp:{androidEnabled:((ye=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ye.androidEnabled)??!1,iosEnabled:((be=e.mayaAppWithdrawalGatewaySettings)==null?void 0:be.iosEnabled)??!1,webEnabled:((ge=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ge.webEnabled)??!1,mobileWebEnabled:((Ee=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ee.mobileWebEnabled)??!1,minimumAmount:i((Se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Se.minimumAmount),maximumAmount:i((Ae=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ae.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:i((ke=e.pointsClubSettings)==null?void 0:ke.multiplier,0)}}}account(e){return{id:e.id,name:e.name,status:e.status,verified:e.verified,nickName:e.nickName??void 0,realName:e.realName??void 0,dateOfBirth:e.birthDay?new Date(e.birthDay):void 0,emailAddress:e.emailAddress??void 0,mobileNumber:e.mobileNumber??void 0,mobileNumberVerified:e.mobileNumberVerified??!1,mobileNumberVerificationRequired:e.mobileNumberVerificationRequired??!1,validId:e.validId?e.validId:void 0,verificationStatus:e.verificationStatus,transactionPassword:e.transactionPassword,secretAnswerSubmitted:e.secretAnswerSubmitted??!1,dateTimeLastActive:e.dateTimeLastActive?new Date(e.dateTimeLastActive):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}wallet(e){return{...e,balance:i(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}verificationDetails(e){return{...e,selfieImage:this.file(e.selfieImage),idFrontImage:this.file(e.idFrontImage)}}profileCompletion(e){return{...e,completionPercentage:i(e,0)}}announcement(e){return{...e,activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}withdrawalRecord(e){return{...e,amount:i(e.amount,0),netAmount:i(e.netAmount,0),fee:i(e.fee,0),reference:e.reference??void 0,bank:e.bank??void 0,recipientMobileNumber:e.recipientMobileNumber??void 0,dateTimeConfirmed:e.dateTimeConfirmed?new Date(e.dateTimeConfirmed):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}deposit(e){return{id:e.id,type:e.type,status:e.status,checkoutUrl:e.checkoutUrl??void 0}}depositRecord(e){return{...e,amount:i(e.amount,0),fee:i(e.fee,0),netAmount:i(e.netAmount,0),reference:e.reference??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}betRecord(e){var t;return{...e,bet:i(e.bet,0),payout:i(e.payout,0),jackpotContribution:i(e.jackpotContribution,0),jackpotPayout:i(e.jackpotPayout,0),winloss:i(e.winloss),validBet:i(e.validBet,0),vendorRoundId:e.vendorRoundId??void 0,game:this.game(e.game),dateTimeSettled:e.dateTimeSettled?new Date(e.dateTimeSettled):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated),betContent:e.betContent??void 0,contestName:e.contestName??void 0,externalCategory:e.externalCategory??void 0,metadata:{odds:((t=e.metadata)==null?void 0:t.odds)??void 0}}}latestBetRecord(e){return{...e,game:this.game(e.game),bet:i(e.bet,0),payout:i(e.payout,0),validBet:i(e.validBet,0),dateTimeSettled:new Date(e.dateTimeSettled),dateTimeCreated:new Date(e.dateTimeCreated)}}transactionRecord(e){return{...e,amount:i(e.amount,0),content:e.content??void 0,currentBalance:i(e.currentBalance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}game(e){const t=this.staticService.gameThumbnails(e);return{...e,images:t}}gameSession(e){return{...e,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}promo(e){return{...e,banner:this.file(e.banner),maximumBonusAmount:i(e.maximumBonusAmount),minimumBonusAmount:i(e.minimumBonusAmount),activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashback(e){return{...e,banner:this.file(e.banner),activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}bonus(e){return{...e,promo:this.promo(e.promo),deposit:e.deposit?{...e.deposit,fee:i(e.deposit.fee,0),amount:i(e.deposit.amount,0),netAmount:i(e.deposit.netAmount,0),reference:e.deposit.reference??void 0,dateTimeCreated:new Date(e.deposit.dateTimeCreated),dateTimeLastUpdated:new Date(e.deposit.dateTimeLastUpdated)}:void 0,balance:i(e.balance,0),amount:i(e.amount,0),expiration:new Date(e.expiration),turnoverRequirement:i(e.turnoverRequirement,0),currentTurnoverRequirementContribution:i(e.currentTurnoverRequirementContribution,0),currentTurnoverRequirementContributionPercentage:i(e.currentTurnoverRequirementContributionPercentage,0),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}cashbackBonus(e){return{id:e.id,balance:i(e.balance,0),cashback:this.cashback(e.cashback),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}file(e){return{...e,url:e.url??void 0,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWallet(e){return{id:e.id,points:i(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}}class Mt{constructor(e){m(this,"gameService");m(this,"fileService");m(this,"walletService");m(this,"reportService");m(this,"portalService");m(this,"accountService");m(this,"sessionManager");m(this,"transformer");m(this,"logger");const t=e.environment==="development";this.sessionManager=new Tt({authUrl:t?"https://auth.development.opexa.io":"https://auth.opexa.io",walletUrl:t?"https://wallet.development.opexa.io/graphql":"https://wallet.opexa.io/graphql",platform:e.platform,log:e.log});const a={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":e.platform}}};this.gameService=new Et(new S(t?"https://game.development.opexa.io/graphql":"https://game.opexa.io/graphql",a)),this.fileService=new yt(new S(t?"https://file.development.opexa.io/graphql":"https://file.opexa.io/graphql",a)),this.walletService=new P(new S(t?"https://wallet.development.opexa.io/graphql":"https://wallet.opexa.io/graphql",a)),this.reportService=new bt(new S(t?"https://report.development.opexa.io/graphql":"https://report.opexa.io/graphql",a)),this.accountService=new ht(new S(t?"https://account.development.opexa.io/graphql":"https://account.opexa.io/graphql",a)),this.portalService=new St(new S(t?"https://portal.development.opexa.io/graphql":"https://portal.opexa.io/graphql",a)),this.transformer=new vt(e),this.logger=new x({enabled:e.log??!1})}get authMiddleware(){return async e=>{this.logger.info("Checking for session");const t=await this.sessionManager.get();return t.data?(e.headers.append("Authorization",`Bearer ${t.data.accessToken}`),this.logger.info("Session found"),this.logger.success("Added 'Authorization' header")):this.logger.info("No session found"),e}}async signIn(e){switch(e.type){case"NAME_AND_PASSWORD":{const t=await this.sessionManager.create({...e,password:await g(e.password)});return t.ok?t.data?{ok:!0,data:{"2FAEnabled":!0,authenticator:t.data.authenticator}}:{ok:!0,data:{"2FAEnabled":!1}}:t}default:{const t=await this.sessionManager.create(e);return t.ok?{ok:!0}:t}}}async authenticate(e){switch(e.type){case"SECURITY_QUESTION":return await this.sessionManager.createFromAuthenticator({type:"SECURITY_QUESTION",token:e.token,secretAnswer:await g(e.secretAnswer)});default:return{ok:!1,error:{name:"HttpBadRequest",message:"Invalid input 'type'"}}}}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=At(e.interval??3e4,3e4,6e4);let a=null;const r=()=>setTimeout(async()=>{await this.sessionManager.verify()||await e.onInvalid(),a=r()},t);return a=r(),function(){a&&clearTimeout(a)}}async session(){const e=await this.sessionManager.get();return e.ok?{ok:!0,data:e.data?{id:e.data.session.id,dateTimeCreated:new Date(e.data.session.dateTimeCreated)}:null}:e}async platform(){const e=await this.accountService.platform();return e.ok?{ok:!0,data:this.transformer.transform.platform(e.data)}:e}async account(){const[e,t]=await Promise.all([this.accountService.memberAccount(),this.reportService.member()]);return e.ok?t.ok?{ok:!0,data:this.transformer.transform.account({...e.data,...t.data})}:{ok:!1,error:t.error}:{ok:!1,error:e.error}}async createAccount(e){const t=e.id??u.ObjectId.generate(w.Account).toString(),a=await this.accountService.registerMemberAccount({input:{id:t,name:e.name,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await g(e.password),mobileNumber:this.addAreaCode(e.mobileNumber),domain:e.domain,btag:e.referralCode},verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return a.ok?{ok:!0,data:{id:t}}:a}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await g(t.password):void 0,transactionPassword:t.transactionPassword?await g(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:this.addAreaCode(t.mobileNumber)},secretAnswer:t.secretAnswer?await g(t.secretAnswer):void 0}}})}async deleteAccount(e){return await this.accountService.deleteMemberAccount({input:{id:e}})}async verificationDetails(){const e=await this.accountService.memberVerification();return e.ok?{ok:!0,data:e.data?this.transformer.transform.verificationDetails(e.data):null}:e}async submitVerificationDetails(e){const t=e.id??u.ObjectId.generate(w.Verification).toString(),a=await this.accountService.createMemberVerification({input:{id:t,...e}});return a.ok?{ok:!0,data:{id:t}}:a}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:this.addAreaCode(e.mobileNumber),newPassword:await g(e.newPassword)},verificationCode:e.verificationCode})}async verifyMobileNumber(e){return await this.accountService.verifyMobileNumber({input:{verificationCode:e}})}async profileCompletion(){const e=await this.accountService.profileCompletion();return e.ok?{ok:!0,data:this.transformer.transform.profileCompletion(e.data)}:e}async sendVerificationCode(e){return await this.accountService.sendVerificationCode({input:{channel:"SMS",recipient:this.addAreaCode(e)}})}async wallet(){const e=await this.walletService.wallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.wallet(e.data):null}:e}async announcements(e){const t=await this.accountService.announcements({...e,filter:{visibility:{in:["MEMBER","GLOBAL"]},activationStartDateTime:{greaterThanOrEqual:new Date}}});return t.ok?{ok:!0,data:{announcements:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.announcement(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??u.ObjectId.generate(w.Withdrawal).toString();if(e.type==="BANK"){const a=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword)}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword),recipientMobileNumber:this.addAreaCode(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA"){const a=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword),recipientMobileNumber:this.addAreaCode(e.recipientMobileNumber)}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await g(e.transactionPassword)}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async withdrawalRecords(e){const t=await this.reportService.withdrawalRecords(e);return t.ok?{ok:!0,data:{withdrawalRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.withdrawalRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async remainingDailyWithdrawalsCount(){return await this.walletService.remainingDailyWithdrawalsCount()}async createDeposit(e){const t=e.id??u.ObjectId.generate(w.Deposit).toString();if(e.type==="MAYA"){const a=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="MAYA_APP"){const a=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}if(e.type==="GCASH"){const a=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!a.ok)return a}return{ok:!0,data:{id:t}}}async deposit(e){const t=await this.walletService.deposit({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.deposit(t.data):null}:t}async depositRecords(e){const t=await this.reportService.depositRecords(e);return t.ok?{ok:!0,data:{depositRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.depositRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async depositsCount(){return await this.reportService.depositsCount()}async betRecords(e){const t=await this.reportService.betRecords(e);return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.betRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async latestBetRecords(){const e=await this.portalService.latestBetRecords();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.latestBetRecord)}:e}async transactionRecords(e){const t=await this.reportService.transactionRecords(e);return t.ok?{ok:!0,data:{transactionRecords:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.transactionRecord(r),cursor:a})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async promos(){const e=await this.walletService.promos();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.promo)}:e}async availablePromos(){const e=await this.walletService.availablePromos();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.promo)}:e}async cashbacks(){const e=await this.walletService.cashbacks();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.cashback)}:e}async bonus(){const e=await this.walletService.bonus();return e.ok?{ok:!0,data:e.data?this.transformer.transform.bonus(e.data):null}:e}async cashbackBonuses(){const e=await this.walletService.cashbackBonuses();return e.ok?{ok:!0,data:e.data.map(this.transformer.transform.cashbackBonus)}:e}async claimCashbackBonus(e){return await this.walletService.claimCashbackBonus({input:{id:e}})}async games(e){const t=await this.walletService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.game(r),cursor:a})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async games__legacy(e){const t=await this.gameService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:a,node:r})=>({...this.transformer.transform.game(r),cursor:a})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async gamesByName(e){const t=await this.walletService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gamesByName__legacy(e){const t=await this.gameService.gamesByName(e);return t.ok?{ok:!0,data:t.data.map(this.transformer.transform.game)}:t}async gameSession(e){const t=await this.walletService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession(t.data):null}:t}async gameSession__legacy(e){const t=await this.gameService.gameSession({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.gameSession({...t.data,game:t.data.game.id}):null}:t}async createGameSession(e){const t=e.id??u.ObjectId.generate(w.GameSession).toString(),a=await this.walletService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async createGameSession__legacy(e){const t=e.id??u.ObjectId.generate(w.GameSession).toString(),a=await this.gameService.createGameSession({input:{id:t,game:e.game}});return a.ok?{ok:!0,data:{id:t}}:a}async endGameSession(e){return await this.walletService.endGameSession({input:{id:e}})}async endGameSession__legacy(e){return await this.gameService.endGameSession({input:{id:e}})}async file(e){const t=await this.fileService.file({id:e});return t.ok?{ok:!0,data:t.data?this.transformer.transform.file(t.data):null}:t}async uploadImageFile(e){const t=e.id??u.ObjectId.generate(w.File).toString(),a=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return a.ok?{ok:!0,data:{id:t}}:a}async pointsWallet(){const e=await this.walletService.pointsWallet();return e.ok?{ok:!0,data:e.data?this.transformer.transform.pointsWallet(e.data):null}:e}async pointsToCashConversion(e){return await this.walletService.pointsToCashConversion({input:{amount:e.toString()}})}addAreaCode(e){return e.startsWith("+63")?e:e.startsWith("63")?`+${e}`:e.startsWith("0")?`+63${e.substring(1)}`:`+63${e}`}}Object.defineProperty(l,"ObjectId",{enumerable:!0,get:()=>u.ObjectId}),l.ObjectType=w,l.Sdk=Mt,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})});
927
942
  //# sourceMappingURL=index.js.map