@opexa/portal-sdk 0.0.72 → 0.0.74
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 +48 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +225 -421
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/sdk.d.ts +1 -219
- package/dist/sdk/types.d.ts +13 -383
- package/dist/services/account.service.d.ts +2 -1
- package/dist/services/auth.service.d.ts +0 -4
- package/dist/services/queries.d.ts +1 -0
- package/dist/services/types.d.ts +18 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(g,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],l):(g=typeof globalThis<"u"?globalThis:g||self,l(g.sdk={},g.objectId))})(this,function(g,l){"use strict";var qt=Object.defineProperty;var
|
|
1
|
+
(function(g,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@opexa/object-id")):typeof define=="function"&&define.amd?define(["exports","@opexa/object-id"],l):(g=typeof globalThis<"u"?globalThis:g||self,l(g.sdk={},g.objectId))})(this,function(g,l){"use strict";var qt=Object.defineProperty;var Ft=(g,l,w)=>l in g?qt(g,l,{enumerable:!0,configurable:!0,writable:!0,value:w}):g[l]=w;var d=(g,l,w)=>Ft(g,typeof l!="symbol"?l+"":l,w);const w={Account:8,Deposit:9,Withdrawal:14,Verification:15,File:16,Game:203,GameSession:204,MayaSession:230};function o(n,...e){let t="";for(const[r,a]of n.entries()){const s=e.at(r)??"";t=`${t}${a}${s}`}return t.trim()}const V=o`
|
|
2
2
|
fragment FileFragment on File {
|
|
3
3
|
id
|
|
4
4
|
url
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
`,
|
|
32
|
+
`,Me=o`
|
|
33
33
|
query Wallet {
|
|
34
34
|
wallet {
|
|
35
35
|
id
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
dateTimeLastUpdated
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
`,
|
|
42
|
+
`,Ne=o`
|
|
43
43
|
query PointsWallet {
|
|
44
44
|
pointsWallet {
|
|
45
45
|
id
|
|
@@ -336,11 +336,11 @@
|
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
}
|
|
339
|
-
`,
|
|
339
|
+
`,Be=o`
|
|
340
340
|
query RemainingDailyWithdrawalsCount {
|
|
341
341
|
remainingDailyWithdrawalsCount
|
|
342
342
|
}
|
|
343
|
-
`,
|
|
343
|
+
`,qe=o`
|
|
344
344
|
query DepositRecords($after: Cursor, $first: Int, $filter: DepositRecordFilterInput) {
|
|
345
345
|
member {
|
|
346
346
|
depositRecords(after: $after, first: $first, filter: $filter) {
|
|
@@ -784,6 +784,33 @@
|
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
`,it=o`
|
|
787
|
+
mutation RegisterMemberAccountViaMobile(
|
|
788
|
+
$input: RegisterMemberAccountViaMobileInput!
|
|
789
|
+
$referralCode: String
|
|
790
|
+
$reCAPTCHAResponse: String
|
|
791
|
+
$verificationCode: String
|
|
792
|
+
) {
|
|
793
|
+
registerMemberAccountViaMobile(
|
|
794
|
+
input: $input
|
|
795
|
+
referralCode: $referralCode
|
|
796
|
+
verificationCode: $verificationCode
|
|
797
|
+
reCAPTCHAResponse: $reCAPTCHAResponse
|
|
798
|
+
) {
|
|
799
|
+
... on InvalidPlatformError {
|
|
800
|
+
__typename
|
|
801
|
+
}
|
|
802
|
+
... on InvalidReCAPTCHAResponseError {
|
|
803
|
+
__typename
|
|
804
|
+
}
|
|
805
|
+
... on InvalidSMSVerificationCodeError {
|
|
806
|
+
__typename
|
|
807
|
+
}
|
|
808
|
+
... on MobileNumberNotAvailableError {
|
|
809
|
+
__typename
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
`,st=o`
|
|
787
814
|
mutation RegisterMemberAccount(
|
|
788
815
|
$input: RegisterMemberAccountInput_next!
|
|
789
816
|
$reCAPTCHAResponse: String
|
|
@@ -815,7 +842,7 @@
|
|
|
815
842
|
}
|
|
816
843
|
}
|
|
817
844
|
}
|
|
818
|
-
`,
|
|
845
|
+
`,ct=o`
|
|
819
846
|
mutation RegisterMayaMemberAccount($input: RegisterMayaMemberAccountInput!) {
|
|
820
847
|
registerMayaMemberAccount(input: $input) {
|
|
821
848
|
... on AccountNameNotAvailableError {
|
|
@@ -823,7 +850,7 @@
|
|
|
823
850
|
}
|
|
824
851
|
}
|
|
825
852
|
}
|
|
826
|
-
`,
|
|
853
|
+
`,dt=o`
|
|
827
854
|
mutation UpdateMemberAccount($input: UpdateMemberAccountInput!) {
|
|
828
855
|
updateMemberAccount(input: $input) {
|
|
829
856
|
... on AccountNameNotAvailableError {
|
|
@@ -849,7 +876,7 @@
|
|
|
849
876
|
}
|
|
850
877
|
}
|
|
851
878
|
}
|
|
852
|
-
`,
|
|
879
|
+
`,mt=o`
|
|
853
880
|
mutation ResetPassword($input: ResetPasswordInput!, $verificationCode: String) {
|
|
854
881
|
resetPassword(input: $input, verificationCode: $verificationCode) {
|
|
855
882
|
... on AccountNotFoundError {
|
|
@@ -860,11 +887,11 @@
|
|
|
860
887
|
}
|
|
861
888
|
}
|
|
862
889
|
}
|
|
863
|
-
`,
|
|
890
|
+
`,ut=o`
|
|
864
891
|
mutation DeleteMemberAccount($input: DeleteMemberAccountInput!) {
|
|
865
892
|
deleteMemberAccount(input: $input)
|
|
866
893
|
}
|
|
867
|
-
`,
|
|
894
|
+
`,lt=o`
|
|
868
895
|
mutation VerifyMobileNumber($input: VerifyMobileNumberInput!) {
|
|
869
896
|
verifyMobileNumber(input: $input) {
|
|
870
897
|
... on InvalidSMSVerificationCodeError {
|
|
@@ -875,7 +902,7 @@
|
|
|
875
902
|
}
|
|
876
903
|
}
|
|
877
904
|
}
|
|
878
|
-
`,
|
|
905
|
+
`,pt=o`
|
|
879
906
|
mutation CreateMemberVerification($input: CreateMemberVerificationInput!) {
|
|
880
907
|
createMemberVerification(input: $input) {
|
|
881
908
|
... on FileDoesNotExistError {
|
|
@@ -889,7 +916,7 @@
|
|
|
889
916
|
}
|
|
890
917
|
}
|
|
891
918
|
}
|
|
892
|
-
`,
|
|
919
|
+
`,ft=o`
|
|
893
920
|
mutation UpdateMemberVerification($input: UpdateMemberVerificationInput!) {
|
|
894
921
|
updateMemberVerification(input: $input) {
|
|
895
922
|
... on FileDoesNotExistError {
|
|
@@ -906,7 +933,7 @@
|
|
|
906
933
|
}
|
|
907
934
|
}
|
|
908
935
|
}
|
|
909
|
-
`,
|
|
936
|
+
`,ht=o`
|
|
910
937
|
query ProfileCompletion {
|
|
911
938
|
profileCompletion {
|
|
912
939
|
completionPercentage
|
|
@@ -917,7 +944,7 @@
|
|
|
917
944
|
accountPassword
|
|
918
945
|
}
|
|
919
946
|
}
|
|
920
|
-
`,
|
|
947
|
+
`,yt=o`
|
|
921
948
|
mutation SendVerificationCode($input: SendVerificationCodeInput!) {
|
|
922
949
|
sendVerificationCode(input: $input) {
|
|
923
950
|
... on InvalidPlatformError {
|
|
@@ -928,7 +955,7 @@
|
|
|
928
955
|
}
|
|
929
956
|
}
|
|
930
957
|
}
|
|
931
|
-
`,
|
|
958
|
+
`,wt=o`
|
|
932
959
|
fragment DepositGatewaySettingsCoreData on DepositGatewaySettings {
|
|
933
960
|
minimumAmount
|
|
934
961
|
maximumAmount
|
|
@@ -982,7 +1009,7 @@
|
|
|
982
1009
|
multiplier
|
|
983
1010
|
}
|
|
984
1011
|
}
|
|
985
|
-
`,
|
|
1012
|
+
`,gt=o`
|
|
986
1013
|
query MayaSession($id: ObjectId!) {
|
|
987
1014
|
mayaSession(id: $id) {
|
|
988
1015
|
id
|
|
@@ -990,7 +1017,7 @@
|
|
|
990
1017
|
dateTimeCreated
|
|
991
1018
|
}
|
|
992
1019
|
}
|
|
993
|
-
`,
|
|
1020
|
+
`,bt=o`
|
|
994
1021
|
mutation ValidateMayaSession {
|
|
995
1022
|
validateMayaSession: validMayaSession
|
|
996
1023
|
}
|
|
@@ -1019,11 +1046,11 @@
|
|
|
1019
1046
|
}
|
|
1020
1047
|
}
|
|
1021
1048
|
}
|
|
1022
|
-
`,
|
|
1049
|
+
`,At=o`
|
|
1023
1050
|
query ReferralCode {
|
|
1024
1051
|
referralCode
|
|
1025
1052
|
}
|
|
1026
|
-
`,
|
|
1053
|
+
`,Et=o`
|
|
1027
1054
|
mutation UpdateReferralCode($input: UpdateReferralCodeInput!) {
|
|
1028
1055
|
updateReferralCode(input: $input) {
|
|
1029
1056
|
... on ReferralCodeNotAvailableError {
|
|
@@ -1031,7 +1058,7 @@
|
|
|
1031
1058
|
}
|
|
1032
1059
|
}
|
|
1033
1060
|
}
|
|
1034
|
-
`,
|
|
1061
|
+
`,kt=o`
|
|
1035
1062
|
query Referrals($first: Int, $after: Cursor, $filter: ReferralFilterInput) {
|
|
1036
1063
|
member {
|
|
1037
1064
|
referrals(first: $first, after: $after, filter: $filter) {
|
|
@@ -1065,5 +1092,5 @@
|
|
|
1065
1092
|
}
|
|
1066
1093
|
}
|
|
1067
1094
|
}
|
|
1068
|
-
`;function m(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",ReferralCodeNotAvailableError:"Referral code is no longer available",AccountBlacklisted:"Account is blacklisted",AccountNotFound:"Account not found",InvalidToken:"Invalid token",InvalidTokenOrSecretAnswer:"Invalid token or secret answer",SessionExpired:"Session expired"}[n]}}class kt{constructor(e){d(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(ot,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:m(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async registerMemberAccount__next(e){const t=await this.client.request(it,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:m(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async updateMemberAccount(e){const t=await this.client.request(ct,e);return t.ok?t.data.updateMemberAccount?{ok:!1,error:m(t.data.updateMemberAccount.__typename)}:{ok:!0}:t}async deleteMemberAccount(e){const t=await this.client.request(mt,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(dt,e);return t.ok?t.data.resetPassword?{ok:!1,error:m(t.data.resetPassword.__typename)}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(ft);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(yt)}async sendVerificationCode(e){const t=await this.client.request(ht,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:m(t.data.sendVerificationCode.__typename)}:{ok:!0}:t}async verifyMobileNumber(e){const t=await this.client.request(ut,e);return t.ok?t.data.verifyMobileNumber?{ok:!1,error:m(t.data.verifyMobileNumber.__typename)}:{ok:!0}:t}async createMemberVerification(e){const t=await this.client.request(lt,e);return t.ok?t.data.createMemberVerification?{ok:!1,error:m(t.data.createMemberVerification.__typename)}:{ok:!0}:t}async updateMemberVerification(e){const t=await this.client.request(pt,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:m(t.data.updateMemberVerification.__typename)}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(nt);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(xe,e);return t.ok?{ok:!0,data:t.data.announcements}:t}async registerMayaMemberAccount(e){const t=await this.client.request(st,e);return t.ok?t.data.registerMayaMemberAccount?{ok:!1,error:m(t.data.registerMayaMemberAccount.__typename)}:{ok:!0}:t}async referralCode(){const e=await this.client.request(bt);return e.ok?{ok:!0,data:e.data.referralCode}:e}async updateReferralCode(e){const t=await this.client.request(At,e);return t.ok?t.data.updateReferralCode?{ok:!1,error:m(t.data.updateReferralCode.__typename)}:{ok:!0}:t}}function k(n){return n.startsWith("+63")?n:n.startsWith("63")?`+${n}`:n.startsWith("0")?`+63${n.substring(1)}`:`+63${n}`}function f(n,e){const t=Y[n]?Y[n]:Y[500];return{name:t.name,message:e??t.message}}const Y={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 _t{constructor(e){d(this,"url");d(this,"platform");this.url=e.url,this.platform=e.platform}get headers(){const e=new Headers;return e.append("Accept","application/json, text/plain"),e.append("Content-Type","application/json"),e.append("Platform-Code",this.platform),e.append("Role","MEMBER"),e}async createSession(e){const t=new Headers(this.headers);if(e.name){const r=`${e.name}:${e.password}`,a=Buffer.from(r).toString("base64");t.set("Authorization",`Basic ${a}`)}if(e.mobileNumber){const a=`${k(e.mobileNumber)}:${e.authenticationCode}`,s=Buffer.from(a).toString("base64");console.log(`MobileNumberOTP ${s}`),t.set("Authorization",`MobileNumberOTP ${s}`)}e.sessionId&&t.set("Authorization",`MayaSession ${e.sessionId}`);try{const r=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),a=await r.json();return r.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:m("AccountBlacklisted")}:{ok:!1,error:f(r.status)}}catch{return{ok:!1,error:f(500)}}}async authenticate(e){const t=new Headers(this.headers);if(e.type==="SECURITY_QUESTION"){t.set("Authorization",`Bearer ${e.token}`);try{const r=await fetch(`${this.url}/session/${e.token}/authenticate`,{method:"POST",headers:t,body:JSON.stringify({secretAnswer:e.secretAnswer})}),a=await r.json();return r.ok?{ok:!0,data:a}:r.status===401||r.status===403?{ok:!1,error:m("InvalidTokenOrSecretAnswer")}:{ok:!1,error:f(r.status)}}catch{return{ok:!1,error:f(500)}}}throw new Error("Invalid input 'type'")}async refreshSession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{const r=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:t}),a=await r.json();return r.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:m("AccountBlacklisted")}:r.status===403||r.status===401?{ok:!1,error:m("InvalidToken")}:{ok:!1,error:f(r.status)}}catch{return{ok:!1,error:f(500)}}}async destroySession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{const r=await fetch(`${this.url}/session`,{method:"DELETE",headers:t});return r.ok?{ok:!0}:{ok:!1,error:f(r.status)}}catch{return{ok:!1,error:f(500)}}}async verifySession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{return(await fetch(`${this.url}/session`,{method:"GET",headers:t})).ok}catch{return!0}}async sendVerificationCode(e){const t=k(e);try{const r=await fetch(`${this.url}/sendVerificationCode`,{method:"POST",headers:this.headers,body:JSON.stringify({channel:"SMS",recipient:t})});return r.ok?{ok:!0}:{ok:!1,error:f(r.status)}}catch{return{ok:!1,error:f(500)}}}async sendVerificationCode__next(e){const t=k(e);try{const r=await fetch(`${this.url}/otps`,{method:"POST",headers:this.headers,body:JSON.stringify({channel:"SMS",recipient:t})});if(r.status===403){const a=await r.json();return{ok:!1,error:f(r.status,a.message)}}return r.ok?{ok:!0}:{ok:!1,error:f(r.status)}}catch{return{ok:!1,error:f(500)}}}}class Ct{constructor(e){d(this,"url");d(this,"siteId");d(this,"platformId");this.url=e.url,this.siteId=e.site,this.platformId=e.platform}async self(){const e=await this.getJson(`/sites/${this.siteId}`);return e.ok?{ok:!0,data:e.data.data}:e}async games(e){var a,s,c,u,p,y,S,h,v,N,M,I,R,E,D,P,C,x,G,$,T,O,F,L;const t=new URLSearchParams;e!=null&&e.first&&t.set("first",e.first.toString()),e!=null&&e.after&&t.set("after",e.after),e!=null&&e.search&&t.set("search",e.search),(s=(a=e==null?void 0:e.filter)==null?void 0:a.type)!=null&&s.equal&&t.set("filter[type][eq]",e.filter.type.equal),(u=(c=e==null?void 0:e.filter)==null?void 0:c.type)!=null&&u.notEqual&&t.set("filter[type][neq]",e.filter.type.notEqual),(y=(p=e==null?void 0:e.filter)==null?void 0:p.type)!=null&&y.in&&t.set("filter[type][in]",e.filter.type.in.join(",")),(h=(S=e==null?void 0:e.filter)==null?void 0:S.type)!=null&&h.notIn&&t.set("filter[type][nin]",e.filter.type.notIn.join(",")),(N=(v=e==null?void 0:e.filter)==null?void 0:v.provider)!=null&&N.equal&&t.set("filter[provider][eq]",e.filter.provider.equal),(I=(M=e==null?void 0:e.filter)==null?void 0:M.provider)!=null&&I.notEqual&&t.set("filter[provider][neq]",e.filter.provider.notEqual),(E=(R=e==null?void 0:e.filter)==null?void 0:R.provider)!=null&&E.in&&t.set("filter[provider][in]",e.filter.provider.in.join(",")),(P=(D=e==null?void 0:e.filter)==null?void 0:D.provider)!=null&&P.notIn&&t.set("filter[provider][nin]",e.filter.provider.notIn.join(",")),(x=(C=e==null?void 0:e.filter)==null?void 0:C.tags)!=null&&x.equal&&t.set("filter[tags][eq]",e.filter.tags.equal.toLowerCase()),($=(G=e==null?void 0:e.filter)==null?void 0:G.tags)!=null&&$.notEqual&&t.set("filter[tags][neq]",e.filter.tags.notEqual.toLowerCase()),(O=(T=e==null?void 0:e.filter)==null?void 0:T.tags)!=null&&O.in&&t.set("filter[tags][in]",e.filter.tags.in.map(_=>_.toLowerCase()).join(",")),(L=(F=e==null?void 0:e.filter)==null?void 0:F.tags)!=null&&L.notIn&&t.set("filter[tags][nin]",e.filter.tags.notIn.map(_=>_.toLowerCase()).join(","));const r=await this.getJson("/games",t);return r.ok?{ok:!0,data:{edges:r.data.data.map(_=>({node:_,cursor:_.cursor})),totalCount:r.data.totalCount??0,pageInfo:{hasNextPage:!!r.data.next,endCursor:r.data.next}}}:r}async game(e){var r;const t=await this.getJson(`/games/${e}`);return((r=t.error)==null?void 0:r.name)==="HttpNotFound"?{ok:!0,data:null}:t.ok?{ok:!0,data:t.data.data}:t}async getJson(e,t){const r=new Request(`${this.url}${e}?${(t==null?void 0:t.toString())??""}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","Site-ID":this.siteId,"Platform-ID":this.platformId}});try{const a=await fetch(r);return a.ok?{ok:!0,data:await a.json()}:{ok:!1,error:f(a.status)}}catch{return{ok:!1,error:f(500)}}}}class Tt{constructor(e){d(this,"client");this.client=e}async file(e){const t=await this.client.request(Te,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(ve,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:m(t.data.uploadPrivateImageFile.__typename)}:{ok:!0}:t}}class vt{constructor(e){d(this,"client");this.client=e}async games(e){const t=await this.client.request(K,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(J,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(z,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(X,e);return t.ok?t.data.createGameSession?{ok:!1,error:m(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Pe,e);return t.ok?t.data.endGameSession?{ok:!1,error:m(t.data.endGameSession.__typename)}:{ok:!0}:t}}class Nt{constructor(e){d(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(Qe);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}class Mt{constructor(e){d(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(je,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(Ke,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(Be,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(rt);return e.ok?{ok:e.ok,data:e.data.member}:e}async pointsWalletTransactions(e){const t=await this.client.request(Re,e);return t.ok?{ok:t.ok,data:t.data.member.pointsWalletTransactions}:t}async activityRecords(e){const t=await this.client.request(St,e);return t.ok?{ok:t.ok,data:t.data.member.activityRecords}:t}async referrals(e){const t=await this.client.request(Et,e);return t.ok?{ok:t.ok,data:t.data.member.referrals}:t}}class It{constructor(e){d(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 Rt{constructor(e){d(this,"client");this.client=e}async promos(){const e=await this.client.request(Je);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(Xe);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(et);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(tt,e);return t.ok?t.data.claimCashbackBonus?{ok:!1,error:m(t.data.claimCashbackBonus.__typename)}:{ok:!0}:{ok:t.ok,error:t.error}}async bonus(){const e=await this.client.request(Ze);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(Ne);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(He,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Fe,e);return t.ok?t.data.createGCashDeposit?{ok:!1,error:m(t.data.createGCashDeposit.__typename)}:{ok:!0}:t}async createMayaDeposit(e){const t=await this.client.request(Le,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:m(t.data.createMayaDeposit.__typename)}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request(Ve,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:m(t.data.createMayaAppDeposit.__typename)}:{ok:!0}:t}async createGCashWithdrawal(e){const t=await this.client.request($e,e);return t.ok?t.data.createGCashWithdrawal?{ok:!1,error:m(t.data.createGCashWithdrawal.__typename)}:{ok:!0}:t}async createMayaWithdrawal(e){const t=await this.client.request(Oe,e);return t.ok?t.data.createMayaWithdrawal?{ok:!1,error:m(t.data.createMayaWithdrawal.__typename)}:{ok:!0}:t}async createMayaAppWithdrawal(e){const t=await this.client.request(Ue,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:m(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:m(t.data.createBankWithdrawal.__typename)}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(qe);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(Ie,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:m(t.data.pointsToCashConversion.__typename)}:{ok:!0}:t}async mayaSession(e){const t=await this.client.request(wt,e);return t.ok?{ok:t.ok,data:t.data.mayaSession}:t}async games(e){const t=await this.client.request(K,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(J,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(z,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(X,e);return t.ok?t.data.createGameSession?{ok:!1,error:m(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}async validateMayaSession(){const e=await this.client.request(gt);return e.ok?e.data.validateMayaSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:e}}function Dt(n,e,t){return n<e?e:n>t?t:n}function j(n){return Object.prototype.toString.call(n)==="[object Object]"&&Object(n)===n}function Pt(n){const e=[];function t(r,a=[]){for(const s in r){const c=r[s];j(c)?t(c,[...a,s]):Array.isArray(c)?t(xt(c),[...a,s]):e.push({key:[...a,s],value:c})}}return t(n),e}function xt(n){return n.reduce((e,t,r)=>(e[r]=t,e),{})}class U{constructor(e,t){d(this,"url");d(this,"options");d(this,"middlewares");var a;const r=new Headers((a=t==null?void 0:t.fetchOptions)==null?void 0:a.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:r},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){const r=JSON.stringify({query:e,variables:t}),a=new Headers(this.options.headers);a.set("Content-Type","application/json"),a.set("Accept","application/json");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:r,headers:a,method:"POST"}));return await this.exec(s)}async upload(e,t){const r=this.createUploadBody(e,t),a=new Headers(this.options.headers);a.delete("Content-Type");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:r,headers:a,method:"POST"}));return await this.exec(s)}async exec(e){var t,r,a,s,c,u;try{const p=await fetch(e);if(!p.ok)return{ok:!1,error:f(p.status)};const y=await p.json(),S=y.data,h=(t=y.errors)==null?void 0:t.at(0);return h?((r=h.extensions)==null?void 0:r.code)==="FORBIDDEN"||((a=h.extensions)==null?void 0:a.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:f(403,h.message)}:((s=h.extensions)==null?void 0:s.code)==="UNAUTHORIZED"?{ok:!1,error:f(401,h.message)}:((c=h.extensions)==null?void 0:c.code)==="BAD_USER_INPUT"||((u=h.extensions)==null?void 0:u.code)==="BAD_REQUEST"?{ok:!1,error:f(400,h.message)}:{ok:!1,error:f(500,h.message)}:{ok:!0,data:S}}catch{return{ok:!1,error:f(500)}}}async runMiddlewares(e){let t=e.clone();for(const r of this.middlewares)t=await r(t);return t}createUploadBody(e,t){const r=Pt(t).filter(c=>c.value instanceof File||c.value instanceof Blob),a=new FormData;a.append("operations",JSON.stringify({query:e,variables:t}));const s={};return r.forEach((c,u)=>{s[u.toString()]=[`variables.${c.key.join(".")}`]}),a.append("map",JSON.stringify(s)),r.forEach((c,u)=>{a.append(u.toString(),c.value)}),a}}async function b(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 ee{constructor(e){d(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 Q(n){return new Date(n.getTime())}function W(n,e){const t=Q(n);return t.setDate(t.getDate()+e),t}function q(n,e){const t=Q(n);return t.setMinutes(t.getMinutes()+e),t}function te(n,e){return n.getTime()>e.getTime()}function re(n){return new Promise(e=>{setTimeout(e,n)})}function ae(n,e){const{until:t,interval:r=1e3,maxAttempt:a=3}=e;async function s(c,u){const p=u??a,y=await n(...c);return t(y)?y:p>1?(await re(r*((a-p)/2)),s(c,p-1)):y}return async(...c)=>await s(c)}function B(n,e){const t=Q(n);return t.setMinutes(t.getMinutes()-e),t}class Gt{constructor(e){d(this,"logger");d(this,"storageKey","session");d(this,"authService");d(this,"walletService");d(this,"_refreshing",!1);this.authService=e.authService,this.walletService=e.walletService,this.logger=new ee({enabled:e.logs??!1})}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){var a;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 c=await ae(()=>this.walletService.mayaSession({id:e.sessionId}),{until:S=>{var h;return S.ok&&((h=S.data)==null?void 0:h.member)!=null},interval:1e3,maxAttempt:5})();if(!c.ok)return c;if(!((a=c.data)!=null&&a.member))return{ok:!1,error:{name:"HttpForbidden",message:"Forbidden"}};const p=await ae(()=>this.authService.createSession(e),{until:S=>S.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:q(y,8).getTime(),refreshTokenExpiresAt:B(W(y,30),2).getTime()})),{ok:!0,data:null}}if(e.type==="MOBILE_NUMBER"){const s=await this.authService.createSession(e);if(s.ok){const c=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...s.data,accessTokenExpiresAt:q(c,8).getTime(),refreshTokenExpiresAt:B(W(c,30),2).getTime()})),{ok:!0,data:null}}return s}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 r=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:q(r,8).getTime(),refreshTokenExpiresAt:B(W(r,30),2).getTime()})),{ok:!0,data:null}}async createFromAuthenticator(e){const t=await this.authService.authenticate(e);if(t.ok){const r=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:q(r,8).getTime(),refreshTokenExpiresAt:B(W(r,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 re(1e3),await this.get();const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),r=new Date;const a=new Date(t.accessTokenExpiresAt),s=new Date(t.refreshTokenExpiresAt);if(te(r,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{name:"SessionExpired",message:"Session expired."}};if(te(r,a)){this.logger.info("Refreshing session..."),this.refreshing=!0;const c=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!c.ok)return this.logger.error(`Failed to refresh session: ${c.error.message}`),c.error.name==="InvalidToken"||c.error.name==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:c.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),r=new Date,t={...t,...c.data,accessTokenExpiresAt:q(r,8).getTime(),refreshTokenExpiresAt:B(W(r,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 r,a,s;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.get();if(((r=e.error)==null?void 0:r.name)==="InvalidToken"||((a=e.error)==null?void 0:a.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 A(n){const e={};for(const t in n){const r=n[t];if(r!==null&&r!==void 0){if(j(r)){e[t]=A(r);continue}if(Array.isArray(r)){e[t]=r.map(a=>j(a)?A(a):a);continue}e[t]=r}}return e}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 $t{constructor(e){d(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new It({url:t?"https://static.development.opexa.io":"https://static.opexa.io"})}get transform(){return{site:this.site.bind(this),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),game__next:this.game__next.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),pointsWalletTransaction:this.pointsWalletTransaction.bind(this),activityRecord:this.activityRecord.bind(this),referrals:this.referrals.bind(this)}}site(e){const t={id:e.id,name:e.name,logo:e.logo??void 0,fields:e.config.fields};return A(t)}platform(e){var t,r,a,s,c,u,p,y,S,h,v,N,M,I,R,E,D,P,C,x,G,$,T,O,F,L,_,ne,oe,ie,se,ce,de,me,ue,le,pe,fe,he,ye,we,ge,Se,be,Ae,Ee,ke,_e,Ce;return{paymentSettings:{minimumFirstDepositAmount:i(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.iosEnabled)??!1,webEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:i((c=e.bankDepositGatewaySettings)==null?void 0:c.minimumAmount),maximumAmount:i((u=e.bankDepositGatewaySettings)==null?void 0:u.maximumAmount)},gcash:{androidEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.androidEnabled)??!1,iosEnabled:((y=e.gcashDepositGatewaySettings)==null?void 0:y.iosEnabled)??!1,webEnabled:((S=e.gcashDepositGatewaySettings)==null?void 0:S.webEnabled)??!1,mobileWebEnabled:((h=e.gcashDepositGatewaySettings)==null?void 0:h.mobileWebEnabled)??!1,minimumAmount:i((v=e.gcashDepositGatewaySettings)==null?void 0:v.minimumAmount),maximumAmount:i((N=e.gcashDepositGatewaySettings)==null?void 0:N.maximumAmount)},maya:{androidEnabled:((M=e.mayaDepositGatewaySettings)==null?void 0:M.androidEnabled)??!1,iosEnabled:((I=e.mayaDepositGatewaySettings)==null?void 0:I.iosEnabled)??!1,webEnabled:((R=e.mayaDepositGatewaySettings)==null?void 0:R.webEnabled)??!1,mobileWebEnabled:((E=e.mayaDepositGatewaySettings)==null?void 0:E.mobileWebEnabled)??!1,minimumAmount:i((D=e.mayaDepositGatewaySettings)==null?void 0:D.minimumAmount),maximumAmount:i((P=e.mayaDepositGatewaySettings)==null?void 0:P.maximumAmount)},mayaApp:{androidEnabled:((C=e.mayaAppDepositGatewaySettings)==null?void 0:C.androidEnabled)??!1,iosEnabled:((x=e.mayaAppDepositGatewaySettings)==null?void 0:x.iosEnabled)??!1,webEnabled:((G=e.mayaAppDepositGatewaySettings)==null?void 0:G.webEnabled)??!1,mobileWebEnabled:(($=e.mayaAppDepositGatewaySettings)==null?void 0:$.mobileWebEnabled)??!1,minimumAmount:i((T=e.mayaAppDepositGatewaySettings)==null?void 0:T.minimumAmount),maximumAmount:i((O=e.mayaAppDepositGatewaySettings)==null?void 0:O.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((F=e.bankWithdrawalGatewaySettings)==null?void 0:F.androidEnabled)??!1,iosEnabled:((L=e.bankWithdrawalGatewaySettings)==null?void 0:L.iosEnabled)??!1,webEnabled:((_=e.bankWithdrawalGatewaySettings)==null?void 0:_.webEnabled)??!1,mobileWebEnabled:((ne=e.bankWithdrawalGatewaySettings)==null?void 0:ne.mobileWebEnabled)??!1,minimumAmount:i((oe=e.bankWithdrawalGatewaySettings)==null?void 0:oe.minimumAmount),maximumAmount:i((ie=e.bankWithdrawalGatewaySettings)==null?void 0:ie.maximumAmount)},gcash:{androidEnabled:((se=e.gcashWithdrawalGatewaySettings)==null?void 0:se.androidEnabled)??!1,iosEnabled:((ce=e.gcashWithdrawalGatewaySettings)==null?void 0:ce.iosEnabled)??!1,webEnabled:((de=e.gcashWithdrawalGatewaySettings)==null?void 0:de.webEnabled)??!1,mobileWebEnabled:((me=e.gcashWithdrawalGatewaySettings)==null?void 0:me.mobileWebEnabled)??!1,minimumAmount:i((ue=e.gcashWithdrawalGatewaySettings)==null?void 0:ue.minimumAmount),maximumAmount:i((le=e.gcashWithdrawalGatewaySettings)==null?void 0:le.maximumAmount,1e6)},maya:{androidEnabled:((pe=e.mayaWithdrawalGatewaySettings)==null?void 0:pe.androidEnabled)??!1,iosEnabled:((fe=e.mayaWithdrawalGatewaySettings)==null?void 0:fe.iosEnabled)??!1,webEnabled:((he=e.mayaWithdrawalGatewaySettings)==null?void 0:he.webEnabled)??!1,mobileWebEnabled:((ye=e.mayaWithdrawalGatewaySettings)==null?void 0:ye.mobileWebEnabled)??!1,minimumAmount:i((we=e.mayaWithdrawalGatewaySettings)==null?void 0:we.minimumAmount),maximumAmount:i((ge=e.mayaWithdrawalGatewaySettings)==null?void 0:ge.maximumAmount)},mayaApp:{androidEnabled:((Se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Se.androidEnabled)??!1,iosEnabled:((be=e.mayaAppWithdrawalGatewaySettings)==null?void 0:be.iosEnabled)??!1,webEnabled:((Ae=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ae.webEnabled)??!1,mobileWebEnabled:((Ee=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ee.mobileWebEnabled)??!1,minimumAmount:i((ke=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ke.minimumAmount),maximumAmount:i((_e=e.mayaAppWithdrawalGatewaySettings)==null?void 0:_e.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:i((Ce=e.pointsClubSettings)==null?void 0:Ce.multiplier,0)}}}account(e){const t={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||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)};return A(t)}wallet(e){return{id:e.id,balance:i(e.balance,0),currency:e.currency,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}verificationDetails(e){return{id:e.id,status:e.status,address:e.address,permanentAddress:e.permanentAddress,nationality:e.nationality,natureOfWork:e.natureOfWork,placeOfBirth:e.placeOfBirth,sourceOfIncome:e.sourceOfIncome,selfieImage:this.file(e.selfieImage),idFrontImage:this.file(e.idFrontImage)}}profileCompletion(e){return{accountPassword:e.accountPassword??!1,accountVerification:e.accountVerification??!1,mobileNumberVerification:e.mobileNumberVerification??!1,personalInformation:e.personalInformation??!1,transactionPassword:e.transactionPassword??!1,completionPercentage:i(e.completionPercentage,0)}}announcement(e){return{id:e.id,type:e.type,title:e.title,status:e.status,message:e.message,activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}withdrawalRecord(e){const t={id:e.id,type:e.type,bank:e.bank,status:e.status,amount:i(e.amount,0),netAmount:i(e.netAmount,0),fee:i(e.fee,0),reference:e.reference??void 0,withdrawalNumber:e.withdrawalNumber,recipientMobileNumber:e.recipientMobileNumber??void 0,dateTimeConfirmed:e.dateTimeConfirmed?new Date(e.dateTimeConfirmed):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}deposit(e){const t={id:e.id,type:e.type,status:e.status,checkoutUrl:e.checkoutUrl??void 0};return A(t)}depositRecord(e){const t={id:e.id,type:e.type,status:e.status,amount:i(e.amount,0),fee:i(e.fee,0),netAmount:i(e.netAmount,0),reference:e.reference??void 0,depositNumber:e.depositNumber,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}betRecord(e){var r;const t={id:e.id,bet:i(e.bet,0),payout:i(e.payout,0),status:e.status,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:{name:e.game.name,type:e.game.type,images:this.staticService.gameThumbnails(e.game),provider:e.game.provider},serialCode:e.serialCode,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:((r=e.metadata)==null?void 0:r.odds)??void 0}};return A(t)}latestBetRecord(e){return{id:e.id,member:e.member,game:{name:e.game.name,type:e.game.type,images:this.staticService.gameThumbnails(e.game),provider:e.game.provider},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){const t={id:e.id,type:e.type,amount:i(e.amount,0),content:e.content??void 0,currentBalance:i(e.currentBalance,0),referenceNumber:e.referenceNumber,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}game(e){return{id:e.id,type:e.type,name:e.name,images:this.staticService.gameThumbnails(e),provider:e.provider}}game__next(e){return{id:e.id,type:e.type,tags:e.tags??[],name:e.name,images:[e.customImage,e.image].filter(Boolean),provider:e.provider,reference:e.reference,externalId:e.externalId}}gameSession(e){const t={id:e.id,status:e.status,launchUrl:e.launchUrl??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}promo(e){return{id:e.id,type:e.type,name:e.name,status:e.status,description:e.description,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{id:e.id,name:e.name,description:e.description,status:e.status,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),turnoverContributionPercentagePerGameProvider:Object.entries(e.turnoverContributionPercentagePerGameProvider).reduce((r,[a,s])=>(r[a]=i(s,0),r),{})}}bonus(e){const t={id:e.id,promo:this.promo(e.promo),deposit:e.deposit?{type:e.deposit.type,status:e.deposit.status,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)};return A(t)}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){const t={id:e.id,url:e.url??void 0,status:e.status,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}pointsWallet(e){return{id:e.id,points:i(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWalletTransaction(e){return{id:e.id,type:e.type,amount:i(e.amount,0),balance:i(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}activityRecord(e){const t={id:e.id,type:e.type,amount:e.amount?i(e.amount,0):void 0,domain:e.domain??void 0,details:e.details,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}referrals(e){return{id:e.id,level:e.level,upline:e.upline,downline:e.downline,turnover:i(e.turnover,0),commision:i(e.commision,0),dateTimeCreated:new Date(e.dateTimeCreated)}}}class Ot{constructor(e){d(this,"cmsPortalService");d(this,"authService");d(this,"gameService");d(this,"fileService");d(this,"walletService");d(this,"accountService");d(this,"reportService");d(this,"portalService");d(this,"sessionManager");d(this,"transformer");d(this,"logger");const{site:t,sitePlatform:r,platform:a,environment:s,logs:c}=e,u=s==="production";this.transformer=new $t({environment:s}),this.logger=new ee({enabled:c??!1});const p=u?"https://auth.opexa.io":"https://auth.development.opexa.io",y=u?"https://wallet.opexa.io/graphql":"https://wallet.development.opexa.io/graphql",S=u?"https://report.opexa.io/graphql":"https://report.development.opexa.io/graphql",h=u?"https://account.opexa.io/graphql":"https://account.development.opexa.io/graphql",v=u?"https://portal.opexa.io/graphql":"https://portal.development.opexa.io/graphql",N=u?"https://file.opexa.io/graphql":"https://file.development.opexa.io/graphql",M=u?"https://game.opexa.io/graphql":"https://game.development.opexa.io/graphql",I=u?"https://portal-api.opexacms.io/v1":"https://portal-api.development.opexacms.io/v1",R=new Ct({url:I,site:t,platform:r}),E={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":a}}},D=new vt(new U(M,E)),P=new Tt(new U(N,E)),C=new Rt(new U(y,E)),x=new kt(new U(h,E)),G=new Mt(new U(S,E)),$=new Nt(new U(v,E)),T=new _t({url:p,platform:a}),O=new Gt({logs:c,authService:T,walletService:C});this.authService=T,this.gameService=D,this.fileService=P,this.walletService=C,this.accountService=x,this.reportService=G,this.portalService=$,this.sessionManager=O,this.cmsPortalService=R}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 b(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 sendAuthenticationCode(e){return this.authService.sendVerificationCode(e)}async authenticate(e){switch(e.type){case"SECURITY_QUESTION":return await this.sessionManager.createFromAuthenticator({type:"SECURITY_QUESTION",token:e.token,secretAnswer:await b(e.secretAnswer)});default:return{ok:!1,error:{name:"HttpBadRequest",message:"Invalid input 'type'"}}}}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=Dt(e.interval??3e4,3e4,6e4);let r=null;const a=()=>setTimeout(async()=>{await this.sessionManager.verify()||await e.onInvalid(),r=a()},t);return r=a(),function(){r&&clearTimeout(r)}}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 validateMayaSession(){return await this.walletService.validateMayaSession()}async site(){const e=await this.cmsPortalService.self();return e.ok?{ok:!0,data:this.transformer.transform.site(e.data)}: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??l.ObjectId.generate(w.Account).toString(),r=await this.accountService.registerMemberAccount({input:{id:t,btag:e.btag,name:e.name,domain:e.domain,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await b(e.password),mobileNumber:k(e.mobileNumber)},referralCode:e.referralCode,verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return r.ok?{ok:!0,data:{id:t}}:r}async createAccount__next(e){const t=e.id??l.ObjectId.generate(w.Account).toString(),r=await this.accountService.registerMemberAccount__next({input:{id:t,name:e.name,password:await b(e.password),mobileNumber:e.mobileNumber?k(e.mobileNumber):void 0},reCAPTCHAResponse:e.reCAPTCHAResponse});return r.ok?{ok:!0,data:{id:t}}:r}async registerMayaAccount(e){return await this.accountService.registerMayaMemberAccount({input:{name:e.name,password:await b(e.password),domain:e.domain}})}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await b(t.password):void 0,transactionPassword:t.transactionPassword?await b(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:k(t.mobileNumber)},secretAnswer:t.secretAnswer?await b(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??l.ObjectId.generate(w.Verification).toString(),r=await this.accountService.createMemberVerification({input:{id:t,...e}});return r.ok?{ok:!0,data:{id:t}}:r}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:k(e.mobileNumber),newPassword:await b(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:k(e)}})}async sendVerificationCode__next(e){return this.authService.sendVerificationCode__next(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:r,node:a})=>({...this.transformer.transform.announcement(a),cursor:r})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??l.ObjectId.generate(w.Withdrawal).toString();if(e.type==="BANK"){const r=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await b(e.transactionPassword)}});if(!r.ok)return r}if(e.type==="GCASH"){const r=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await b(e.transactionPassword),recipientMobileNumber:k(e.recipientMobileNumber)}});if(!r.ok)return r}if(e.type==="MAYA"){const r=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await b(e.transactionPassword),recipientMobileNumber:k(e.recipientMobileNumber)}});if(!r.ok)return r}if(e.type==="MAYA_APP"){const r=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await b(e.transactionPassword)}});if(!r.ok)return r}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:r,node:a})=>({...this.transformer.transform.withdrawalRecord(a),cursor:r})),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??l.ObjectId.generate(w.Deposit).toString();if(e.type==="MAYA"){const r=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="MAYA_APP"){const r=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="GCASH"){const r=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}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:r,node:a})=>({...this.transformer.transform.depositRecord(a),cursor:r})),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,...(e==null?void 0:e.filter)&&{filter:{...e.filter.status&&{game:e.filter.status},...e.filter.serialCode&&{game:e.filter.serialCode},...e.filter.vendorRoundId&&{game:e.filter.vendorRoundId},...e.filter.dateTimeCreated&&{dateTimeCreated:e.filter.dateTimeCreated},...e.filter.gameType&&{game__type:e.filter.gameType},...e.filter.gameProvider&&{game__provider:e.filter.gameProvider}}}});return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.betRecord(a),cursor:r})),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:r,node:a})=>({...this.transformer.transform.transactionRecord(a),cursor:r})),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 game(e){return this.game__next(e)}async game__next(e){const t=await this.cmsPortalService.game(e);return t.ok?{ok:!0,data:t.data?this.transformer.transform.game__next(t.data):null}:t}async games(e){const t=await this.walletService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.game(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async games__next(e){const t=await this.cmsPortalService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.game__next(a),cursor:r})),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:r,node:a})=>({...this.transformer.transform.game(a),cursor:r})),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 gameSession__next(e){const t=await this.walletService.gameSession({id:e});if(!t.ok)return t;if(t.data)return{ok:!0,data:this.transformer.transform.gameSession(t.data)};const r=await this.gameService.gameSession({id:e});return r.ok?{ok:!0,data:r.data?this.transformer.transform.gameSession(r.data):null}:r}async createGameSession(e){const t=e.id??l.ObjectId.generate(w.GameSession).toString(),r=await this.walletService.createGameSession({input:{id:t,game:e.game}});return r.ok?{ok:!0,data:{id:t}}:r}async createGameSession__legacy(e){const t=e.id??l.ObjectId.generate(w.GameSession).toString(),r=await this.gameService.createGameSession({input:{id:t,game:e.game}});return r.ok?{ok:!0,data:{id:t}}:r}async createGameSession__next(e){const t=e.id??l.ObjectId.generate(w.GameSession).toString();if(e.game.startsWith("SPORTS:")){const u=await l.ObjectId.generateFromKey(w.Game,e.game).then(y=>y.toString()),p=await this.gameService.createGameSession({input:{id:t,game:u}});return p.ok?{ok:!0,data:{id:t}}:p}const r=await this.game__next(e.game);if(!r.data)return{ok:!1,error:{name:"GameDoesNotExistError",message:"Game does not exist"}};const{provider:a,reference:s}=r.data,c=Wt(a)?await this.walletService.createGameSession({input:{id:t,game:s}}):await this.gameService.createGameSession({input:{id:t,game:s}});return c.ok?{ok:!0,data:{id:t}}:c}async endGameSession(e){return await this.walletService.endGameSession({input:{id:e}})}async endGameSession__legacy(e){return await this.gameService.endGameSession({input:{id:e}})}async endGameSession__next(e){const t=await this.walletService.endGameSession({input:{id:e}});return t.ok?t: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??l.ObjectId.generate(w.File).toString(),r=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return r.ok?{ok:!0,data:{id:t}}:r}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()}})}async pointsWalletTransactions(e){const t=await this.reportService.pointsWalletTransactions(e);return t.ok?{ok:!0,data:{pointsWalletTransactions:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.pointsWalletTransaction(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async activityRecords(e){const t=await this.reportService.activityRecords(e);return t.ok?{ok:!0,data:{activityRecords:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.activityRecord(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async referralCode(){const e=await this.accountService.referralCode();return e.ok?{ok:!0,data:e.data??null}:e}async updateReferralCode(e){return await this.accountService.updateReferralCode({input:e})}async referrals(e){const t=await this.reportService.referrals(e);return t.ok?{ok:!0,data:{referrals:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.referrals(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}}const Ut=["RTG","DARWIN","DRBINGO","MEGABALL","EVOLUTION","EVOLUTION_NETENT","EVOLUTION_REDTIGER"];function Wt(n){return Ut.some(e=>e===n)}Object.defineProperty(g,"ObjectId",{enumerable:!0,get:()=>l.ObjectId}),g.ObjectType=w,g.Sdk=Ot,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
1095
|
+
`;function m(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",ReferralCodeNotAvailableError:"Referral code is no longer available",AccountBlacklisted:"Account is blacklisted",AccountNotFound:"Account not found",InvalidToken:"Invalid token",InvalidTokenOrSecretAnswer:"Invalid token or secret answer",SessionExpired:"Session expired"}[n]}}class Ct{constructor(e){d(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(ot,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:m(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async registerMemberAccountViaMobile(e){const t=await this.client.request(it,e);return t.ok?t.data.registerMemberAccountViaMobile?{ok:!1,error:m(t.data.registerMemberAccountViaMobile.__typename)}:{ok:!0}:t}async registerMemberAccount__next(e){const t=await this.client.request(st,e);return t.ok?t.data.registerMemberAccount?{ok:!1,error:m(t.data.registerMemberAccount.__typename)}:{ok:!0}:t}async updateMemberAccount(e){const t=await this.client.request(dt,e);return t.ok?t.data.updateMemberAccount?{ok:!1,error:m(t.data.updateMemberAccount.__typename)}:{ok:!0}:t}async deleteMemberAccount(e){const t=await this.client.request(ut,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(mt,e);return t.ok?t.data.resetPassword?{ok:!1,error:m(t.data.resetPassword.__typename)}:{ok:!0}:t}async profileCompletion(){const e=await this.client.request(ht);return e.ok?{ok:!0,data:e.data.profileCompletion}:e}async platform(){return await this.client.request(wt)}async sendVerificationCode(e){const t=await this.client.request(yt,e);return t.ok?t.data.sendVerificationCode?{ok:!1,error:m(t.data.sendVerificationCode.__typename)}:{ok:!0}:t}async verifyMobileNumber(e){const t=await this.client.request(lt,e);return t.ok?t.data.verifyMobileNumber?{ok:!1,error:m(t.data.verifyMobileNumber.__typename)}:{ok:!0}:t}async createMemberVerification(e){const t=await this.client.request(pt,e);return t.ok?t.data.createMemberVerification?{ok:!1,error:m(t.data.createMemberVerification.__typename)}:{ok:!0}:t}async updateMemberVerification(e){const t=await this.client.request(ft,e);return t.ok?t.data.updateMemberVerification?{ok:!1,error:m(t.data.updateMemberVerification.__typename)}:{ok:!0}:t}async memberVerification(){const e=await this.client.request(nt);return e.ok?{ok:!0,data:e.data.memberAccount.verification}:e}async announcements(e){const t=await this.client.request(xe,e);return t.ok?{ok:!0,data:t.data.announcements}:t}async registerMayaMemberAccount(e){const t=await this.client.request(ct,e);return t.ok?t.data.registerMayaMemberAccount?{ok:!1,error:m(t.data.registerMayaMemberAccount.__typename)}:{ok:!0}:t}async referralCode(){const e=await this.client.request(At);return e.ok?{ok:!0,data:e.data.referralCode}:e}async updateReferralCode(e){const t=await this.client.request(Et,e);return t.ok?t.data.updateReferralCode?{ok:!1,error:m(t.data.updateReferralCode.__typename)}:{ok:!0}:t}}function k(n){return n.startsWith("+63")?n:n.startsWith("63")?`+${n}`:n.startsWith("0")?`+63${n.substring(1)}`:`+63${n}`}function h(n,e){const t=Y[n]?Y[n]:Y[500];return{name:t.name,message:e??t.message}}const Y={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 _t{constructor(e){d(this,"url");d(this,"platform");this.url=e.url,this.platform=e.platform}get headers(){const e=new Headers;return e.append("Accept","application/json, text/plain"),e.append("Content-Type","application/json"),e.append("Platform-Code",this.platform),e.append("Role","MEMBER"),e}async createSession(e){const t=new Headers(this.headers);if(e.name){const r=`${e.name}:${e.password}`,a=Buffer.from(r).toString("base64");t.set("Authorization",`Basic ${a}`)}if(e.mobileNumber){const a=`${k(e.mobileNumber)}:${e.verificationCode}`,s=Buffer.from(a).toString("base64");console.log(`MobileNumberOTP ${s}`),t.set("Authorization",`MobileNumberOTP ${s}`)}e.sessionId&&t.set("Authorization",`MayaSession ${e.sessionId}`);try{const r=await fetch(`${this.url}/sessions`,{method:"POST",headers:t}),a=await r.json();return r.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:m("AccountBlacklisted")}:{ok:!1,error:h(r.status)}}catch{return{ok:!1,error:h(500)}}}async authenticate(e){const t=new Headers(this.headers);if(e.type==="SECURITY_QUESTION"){t.set("Authorization",`Bearer ${e.token}`);try{const r=await fetch(`${this.url}/session/${e.token}/authenticate`,{method:"POST",headers:t,body:JSON.stringify({secretAnswer:e.secretAnswer})}),a=await r.json();return r.ok?{ok:!0,data:a}:r.status===401||r.status===403?{ok:!1,error:m("InvalidTokenOrSecretAnswer")}:{ok:!1,error:h(r.status)}}catch{return{ok:!1,error:h(500)}}}throw new Error("Invalid input 'type'")}async refreshSession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{const r=await fetch(`${this.url}/session:refresh`,{method:"POST",headers:t}),a=await r.json();return r.ok?{ok:!0,data:a}:a.code==="ACCOUNT_BLACKLISTED"?{ok:!1,error:m("AccountBlacklisted")}:r.status===403||r.status===401?{ok:!1,error:m("InvalidToken")}:{ok:!1,error:h(r.status)}}catch{return{ok:!1,error:h(500)}}}async destroySession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{const r=await fetch(`${this.url}/session`,{method:"DELETE",headers:t});return r.ok?{ok:!0}:{ok:!1,error:h(r.status)}}catch{return{ok:!1,error:h(500)}}}async verifySession(e){const t=new Headers(this.headers);t.append("Authorization",`Bearer ${e}`);try{return(await fetch(`${this.url}/session`,{method:"GET",headers:t})).ok}catch{return!0}}async sendVerificationCode(e){const t=k(e);try{const r=await fetch(`${this.url}/otps`,{method:"POST",headers:this.headers,body:JSON.stringify({channel:"SMS",recipient:t})});if(r.status===403){const a=await r.json();return{ok:!1,error:h(r.status,a.message)}}return r.ok?{ok:!0}:{ok:!1,error:h(r.status)}}catch{return{ok:!1,error:h(500)}}}}class Tt{constructor(e){d(this,"url");d(this,"siteId");d(this,"platformId");this.url=e.url,this.siteId=e.site,this.platformId=e.platform}async self(){const e=await this.getJson(`/sites/${this.siteId}`);return e.ok?{ok:!0,data:e.data.data}:e}async games(e){var a,s,c,u,p,y,b,f,v,M,N,I,R,E,D,P,_,x,G,$,T,O,F,L;const t=new URLSearchParams;e!=null&&e.first&&t.set("first",e.first.toString()),e!=null&&e.after&&t.set("after",e.after),e!=null&&e.search&&t.set("search",e.search),(s=(a=e==null?void 0:e.filter)==null?void 0:a.type)!=null&&s.equal&&t.set("filter[type][eq]",e.filter.type.equal),(u=(c=e==null?void 0:e.filter)==null?void 0:c.type)!=null&&u.notEqual&&t.set("filter[type][neq]",e.filter.type.notEqual),(y=(p=e==null?void 0:e.filter)==null?void 0:p.type)!=null&&y.in&&t.set("filter[type][in]",e.filter.type.in.join(",")),(f=(b=e==null?void 0:e.filter)==null?void 0:b.type)!=null&&f.notIn&&t.set("filter[type][nin]",e.filter.type.notIn.join(",")),(M=(v=e==null?void 0:e.filter)==null?void 0:v.provider)!=null&&M.equal&&t.set("filter[provider][eq]",e.filter.provider.equal),(I=(N=e==null?void 0:e.filter)==null?void 0:N.provider)!=null&&I.notEqual&&t.set("filter[provider][neq]",e.filter.provider.notEqual),(E=(R=e==null?void 0:e.filter)==null?void 0:R.provider)!=null&&E.in&&t.set("filter[provider][in]",e.filter.provider.in.join(",")),(P=(D=e==null?void 0:e.filter)==null?void 0:D.provider)!=null&&P.notIn&&t.set("filter[provider][nin]",e.filter.provider.notIn.join(",")),(x=(_=e==null?void 0:e.filter)==null?void 0:_.tags)!=null&&x.equal&&t.set("filter[tags][eq]",e.filter.tags.equal.toLowerCase()),($=(G=e==null?void 0:e.filter)==null?void 0:G.tags)!=null&&$.notEqual&&t.set("filter[tags][neq]",e.filter.tags.notEqual.toLowerCase()),(O=(T=e==null?void 0:e.filter)==null?void 0:T.tags)!=null&&O.in&&t.set("filter[tags][in]",e.filter.tags.in.map(C=>C.toLowerCase()).join(",")),(L=(F=e==null?void 0:e.filter)==null?void 0:F.tags)!=null&&L.notIn&&t.set("filter[tags][nin]",e.filter.tags.notIn.map(C=>C.toLowerCase()).join(","));const r=await this.getJson("/games",t);return r.ok?{ok:!0,data:{edges:r.data.data.map(C=>({node:C,cursor:C.cursor})),totalCount:r.data.totalCount??0,pageInfo:{hasNextPage:!!r.data.next,endCursor:r.data.next}}}:r}async game(e){var r;const t=await this.getJson(`/games/${e}`);return((r=t.error)==null?void 0:r.name)==="HttpNotFound"?{ok:!0,data:null}:t.ok?{ok:!0,data:t.data.data}:t}async getJson(e,t){const r=new Request(`${this.url}${e}?${(t==null?void 0:t.toString())??""}`,{method:"GET",headers:{Accept:"application/json","Content-Type":"application/json","Site-ID":this.siteId,"Platform-ID":this.platformId}});try{const a=await fetch(r);return a.ok?{ok:!0,data:await a.json()}:{ok:!1,error:h(a.status)}}catch{return{ok:!1,error:h(500)}}}}class vt{constructor(e){d(this,"client");this.client=e}async file(e){const t=await this.client.request(Te,e);return t.ok?{ok:!0,data:t.data.node}:t}async uploadPrivateImageFile(e){const t=await this.client.upload(ve,e);return t.ok?t.data.uploadPrivateImageFile?{ok:!1,error:m(t.data.uploadPrivateImageFile.__typename)}:{ok:!0}:t}}class Mt{constructor(e){d(this,"client");this.client=e}async games(e){const t=await this.client.request(K,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(J,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(z,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(X,e);return t.ok?t.data.createGameSession?{ok:!1,error:m(t.data.createGameSession.__typename)}:{ok:!0}:t}async endGameSession(e){const t=await this.client.request(Pe,e);return t.ok?t.data.endGameSession?{ok:!1,error:m(t.data.endGameSession.__typename)}:{ok:!0}:t}}class Nt{constructor(e){d(this,"client");this.client=e}async latestBetRecords(){const e=await this.client.request(Qe);return e.ok?{ok:!0,data:e.data.latestBetRecords}:e}}class It{constructor(e){d(this,"client");this.client=e}async betRecords(e){const t=await this.client.request(je,e);return t.ok?{ok:t.ok,data:t.data.member.betRecords}:t}async transactionRecords(e){const t=await this.client.request(Ke,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(qe,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(rt);return e.ok?{ok:e.ok,data:e.data.member}:e}async pointsWalletTransactions(e){const t=await this.client.request(Re,e);return t.ok?{ok:t.ok,data:t.data.member.pointsWalletTransactions}:t}async activityRecords(e){const t=await this.client.request(St,e);return t.ok?{ok:t.ok,data:t.data.member.activityRecords}:t}async referrals(e){const t=await this.client.request(kt,e);return t.ok?{ok:t.ok,data:t.data.member.referrals}:t}}class Rt{constructor(e){d(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 Dt{constructor(e){d(this,"client");this.client=e}async promos(){const e=await this.client.request(Je);return e.ok?{ok:e.ok,data:e.data.promos}:e}async cashbacks(){const e=await this.client.request(Xe);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(et);return e.ok?{ok:e.ok,data:e.data.cashbackBonuses}:e}async claimCashbackBonus(e){const t=await this.client.request(tt,e);return t.ok?t.data.claimCashbackBonus?{ok:!1,error:m(t.data.claimCashbackBonus.__typename)}:{ok:!0}:{ok:t.ok,error:t.error}}async bonus(){const e=await this.client.request(Ze);return e.ok?{ok:e.ok,data:e.data.bonus}:e}async wallet(){const e=await this.client.request(Me);return e.ok?{ok:e.ok,data:e.data.wallet}:e}async deposit(e){const t=await this.client.request(He,e);return t.ok?{ok:t.ok,data:t.data.node}:t}async createGCashDeposit(e){const t=await this.client.request(Fe,e);return t.ok?t.data.createGCashDeposit?{ok:!1,error:m(t.data.createGCashDeposit.__typename)}:{ok:!0}:t}async createMayaDeposit(e){const t=await this.client.request(Le,e);return t.ok?t.data.createMayaDeposit?{ok:!1,error:m(t.data.createMayaDeposit.__typename)}:{ok:!0}:t}async createMayaAppDeposit(e){const t=await this.client.request(Ve,e);return t.ok?t.data.createMayaAppDeposit?{ok:!1,error:m(t.data.createMayaAppDeposit.__typename)}:{ok:!0}:t}async createGCashWithdrawal(e){const t=await this.client.request($e,e);return t.ok?t.data.createGCashWithdrawal?{ok:!1,error:m(t.data.createGCashWithdrawal.__typename)}:{ok:!0}:t}async createMayaWithdrawal(e){const t=await this.client.request(Oe,e);return t.ok?t.data.createMayaWithdrawal?{ok:!1,error:m(t.data.createMayaWithdrawal.__typename)}:{ok:!0}:t}async createMayaAppWithdrawal(e){const t=await this.client.request(Ue,e);return t.ok?t.data.createMayaAppWithdrawal?{ok:!1,error:m(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:m(t.data.createBankWithdrawal.__typename)}:{ok:!0}:t}async remainingDailyWithdrawalsCount(){const e=await this.client.request(Be);return e.ok?{ok:e.ok,data:e.data.remainingDailyWithdrawalsCount}:e}async pointsWallet(){const e=await this.client.request(Ne);return e.ok?{ok:e.ok,data:e.data.pointsWallet}:e}async pointsToCashConversion(e){const t=await this.client.request(Ie,e);return t.ok?t.data.pointsToCashConversion?{ok:!1,error:m(t.data.pointsToCashConversion.__typename)}:{ok:!0}:t}async mayaSession(e){const t=await this.client.request(gt,e);return t.ok?{ok:t.ok,data:t.data.mayaSession}:t}async games(e){const t=await this.client.request(K,e);return t.ok?{ok:t.ok,data:t.data.games}:t}async gamesByName(e){const t=await this.client.request(J,e);return t.ok?{ok:t.ok,data:t.data.gamesByName}:t}async gameSession(e){const t=await this.client.request(z,e);return t.ok?{ok:!0,data:t.data.node}:t}async createGameSession(e){const t=await this.client.request(X,e);return t.ok?t.data.createGameSession?{ok:!1,error:m(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}async validateMayaSession(){const e=await this.client.request(bt);return e.ok?e.data.validateMayaSession?{ok:!0}:{ok:!1,error:{name:"UnknownError",message:"Something went wrong."}}:e}}function Pt(n,e,t){return n<e?e:n>t?t:n}function j(n){return Object.prototype.toString.call(n)==="[object Object]"&&Object(n)===n}function xt(n){const e=[];function t(r,a=[]){for(const s in r){const c=r[s];j(c)?t(c,[...a,s]):Array.isArray(c)?t(Gt(c),[...a,s]):e.push({key:[...a,s],value:c})}}return t(n),e}function Gt(n){return n.reduce((e,t,r)=>(e[r]=t,e),{})}class U{constructor(e,t){d(this,"url");d(this,"options");d(this,"middlewares");var a;const r=new Headers((a=t==null?void 0:t.fetchOptions)==null?void 0:a.headers);this.url=e,this.options={...t==null?void 0:t.fetchOptions,headers:r},this.middlewares=(t==null?void 0:t.middlewares)??[]}async request(e,t){const r=JSON.stringify({query:e,variables:t}),a=new Headers(this.options.headers);a.set("Content-Type","application/json"),a.set("Accept","application/json");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:r,headers:a,method:"POST"}));return await this.exec(s)}async upload(e,t){const r=this.createUploadBody(e,t),a=new Headers(this.options.headers);a.delete("Content-Type");const s=await this.runMiddlewares(new Request(this.url,{...this.options,body:r,headers:a,method:"POST"}));return await this.exec(s)}async exec(e){var t,r,a,s,c,u;try{const p=await fetch(e);if(!p.ok)return{ok:!1,error:h(p.status)};const y=await p.json(),b=y.data,f=(t=y.errors)==null?void 0:t.at(0);return f?((r=f.extensions)==null?void 0:r.code)==="FORBIDDEN"||((a=f.extensions)==null?void 0:a.code)==="ACCESS_TOKEN_EXPIRED"?{ok:!1,error:h(403,f.message)}:((s=f.extensions)==null?void 0:s.code)==="UNAUTHORIZED"?{ok:!1,error:h(401,f.message)}:((c=f.extensions)==null?void 0:c.code)==="BAD_USER_INPUT"||((u=f.extensions)==null?void 0:u.code)==="BAD_REQUEST"?{ok:!1,error:h(400,f.message)}:{ok:!1,error:h(500,f.message)}:{ok:!0,data:b}}catch{return{ok:!1,error:h(500)}}}async runMiddlewares(e){let t=e.clone();for(const r of this.middlewares)t=await r(t);return t}createUploadBody(e,t){const r=xt(t).filter(c=>c.value instanceof File||c.value instanceof Blob),a=new FormData;a.append("operations",JSON.stringify({query:e,variables:t}));const s={};return r.forEach((c,u)=>{s[u.toString()]=[`variables.${c.key.join(".")}`]}),a.append("map",JSON.stringify(s)),r.forEach((c,u)=>{a.append(u.toString(),c.value)}),a}}async function S(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 ee{constructor(e){d(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 Q(n){return new Date(n.getTime())}function W(n,e){const t=Q(n);return t.setDate(t.getDate()+e),t}function B(n,e){const t=Q(n);return t.setMinutes(t.getMinutes()+e),t}function te(n,e){return n.getTime()>e.getTime()}function re(n){return new Promise(e=>{setTimeout(e,n)})}function ae(n,e){const{until:t,interval:r=1e3,maxAttempt:a=3}=e;async function s(c,u){const p=u??a,y=await n(...c);return t(y)?y:p>1?(await re(r*((a-p)/2)),s(c,p-1)):y}return async(...c)=>await s(c)}function q(n,e){const t=Q(n);return t.setMinutes(t.getMinutes()-e),t}class $t{constructor(e){d(this,"logger");d(this,"storageKey","session");d(this,"authService");d(this,"walletService");d(this,"_refreshing",!1);this.authService=e.authService,this.walletService=e.walletService,this.logger=new ee({enabled:e.logs??!1})}get refreshing(){return this._refreshing}set refreshing(e){this._refreshing=e}async create(e){var a;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 c=await ae(()=>this.walletService.mayaSession({id:e.sessionId}),{until:b=>{var f;return b.ok&&((f=b.data)==null?void 0:f.member)!=null},interval:1e3,maxAttempt:5})();if(!c.ok)return c;if(!((a=c.data)!=null&&a.member))return{ok:!1,error:{name:"HttpForbidden",message:"Forbidden"}};const p=await ae(()=>this.authService.createSession(e),{until:b=>b.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:B(y,8).getTime(),refreshTokenExpiresAt:q(W(y,30),2).getTime()})),{ok:!0,data:null}}if(e.type==="MOBILE_NUMBER"){const s=await this.authService.createSession(e);if(s.ok){const c=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...s.data,accessTokenExpiresAt:B(c,8).getTime(),refreshTokenExpiresAt:q(W(c,30),2).getTime()})),{ok:!0,data:null}}return s}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 r=new Date;return window.localStorage.setItem(this.storageKey,JSON.stringify({...t.data,accessTokenExpiresAt:B(r,8).getTime(),refreshTokenExpiresAt:q(W(r,30),2).getTime()})),{ok:!0,data:null}}async createFromAuthenticator(e){const t=await this.authService.authenticate(e);if(t.ok){const r=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:B(r,8).getTime(),refreshTokenExpiresAt:q(W(r,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 re(1e3),await this.get();const e=window.localStorage.getItem(this.storageKey);if(!e)return{ok:!0,data:null};try{let t=JSON.parse(e),r=new Date;const a=new Date(t.accessTokenExpiresAt),s=new Date(t.refreshTokenExpiresAt);if(te(r,s))return this.logger.warn("Session expired. Logging out.."),window.localStorage.removeItem(this.storageKey),{ok:!1,error:{name:"SessionExpired",message:"Session expired."}};if(te(r,a)){this.logger.info("Refreshing session..."),this.refreshing=!0;const c=await this.authService.refreshSession(t.refreshToken);if(this.refreshing=!1,!c.ok)return this.logger.error(`Failed to refresh session: ${c.error.message}`),c.error.name==="InvalidToken"||c.error.name==="AccountBlacklisted"?(window.localStorage.removeItem(this.storageKey),{ok:!1,error:c.error}):(this.logger.warn("Old session returned."),{ok:!0,data:t});this.logger.success("Session refreshed!"),r=new Date,t={...t,...c.data,accessTokenExpiresAt:B(r,8).getTime(),refreshTokenExpiresAt:q(W(r,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 r,a,s;if(this.isServer)return this.logger.warn("'localStorage' is not available on the server."),!0;const e=await this.get();if(((r=e.error)==null?void 0:r.name)==="InvalidToken"||((a=e.error)==null?void 0:a.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 A(n){const e={};for(const t in n){const r=n[t];if(r!==null&&r!==void 0){if(j(r)){e[t]=A(r);continue}if(Array.isArray(r)){e[t]=r.map(a=>j(a)?A(a):a);continue}e[t]=r}}return e}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 Ot{constructor(e){d(this,"staticService");const t=(e==null?void 0:e.environment)==="development";this.staticService=new Rt({url:t?"https://static.development.opexa.io":"https://static.opexa.io"})}get transform(){return{site:this.site.bind(this),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),game__next:this.game__next.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),pointsWalletTransaction:this.pointsWalletTransaction.bind(this),activityRecord:this.activityRecord.bind(this),referrals:this.referrals.bind(this)}}site(e){const t={id:e.id,name:e.name,logo:e.logo??void 0,fields:e.config.fields};return A(t)}platform(e){var t,r,a,s,c,u,p,y,b,f,v,M,N,I,R,E,D,P,_,x,G,$,T,O,F,L,C,ne,oe,ie,se,ce,de,me,ue,le,pe,fe,he,ye,we,ge,be,Se,Ae,Ee,ke,Ce,_e;return{paymentSettings:{minimumFirstDepositAmount:i(e.minimumFirstDepositAmount),restrictWithdrawalsToVerifiedMembers:e.restrictWithdrawalsToVerifiedMembers,depositGateway:{bank:{androidEnabled:((t=e.bankDepositGatewaySettings)==null?void 0:t.androidEnabled)??!1,iosEnabled:((r=e.bankDepositGatewaySettings)==null?void 0:r.iosEnabled)??!1,webEnabled:((a=e.bankDepositGatewaySettings)==null?void 0:a.webEnabled)??!1,mobileWebEnabled:((s=e.bankDepositGatewaySettings)==null?void 0:s.mobileWebEnabled)??!1,minimumAmount:i((c=e.bankDepositGatewaySettings)==null?void 0:c.minimumAmount),maximumAmount:i((u=e.bankDepositGatewaySettings)==null?void 0:u.maximumAmount)},gcash:{androidEnabled:((p=e.gcashDepositGatewaySettings)==null?void 0:p.androidEnabled)??!1,iosEnabled:((y=e.gcashDepositGatewaySettings)==null?void 0:y.iosEnabled)??!1,webEnabled:((b=e.gcashDepositGatewaySettings)==null?void 0:b.webEnabled)??!1,mobileWebEnabled:((f=e.gcashDepositGatewaySettings)==null?void 0:f.mobileWebEnabled)??!1,minimumAmount:i((v=e.gcashDepositGatewaySettings)==null?void 0:v.minimumAmount),maximumAmount:i((M=e.gcashDepositGatewaySettings)==null?void 0:M.maximumAmount)},maya:{androidEnabled:((N=e.mayaDepositGatewaySettings)==null?void 0:N.androidEnabled)??!1,iosEnabled:((I=e.mayaDepositGatewaySettings)==null?void 0:I.iosEnabled)??!1,webEnabled:((R=e.mayaDepositGatewaySettings)==null?void 0:R.webEnabled)??!1,mobileWebEnabled:((E=e.mayaDepositGatewaySettings)==null?void 0:E.mobileWebEnabled)??!1,minimumAmount:i((D=e.mayaDepositGatewaySettings)==null?void 0:D.minimumAmount),maximumAmount:i((P=e.mayaDepositGatewaySettings)==null?void 0:P.maximumAmount)},mayaApp:{androidEnabled:((_=e.mayaAppDepositGatewaySettings)==null?void 0:_.androidEnabled)??!1,iosEnabled:((x=e.mayaAppDepositGatewaySettings)==null?void 0:x.iosEnabled)??!1,webEnabled:((G=e.mayaAppDepositGatewaySettings)==null?void 0:G.webEnabled)??!1,mobileWebEnabled:(($=e.mayaAppDepositGatewaySettings)==null?void 0:$.mobileWebEnabled)??!1,minimumAmount:i((T=e.mayaAppDepositGatewaySettings)==null?void 0:T.minimumAmount),maximumAmount:i((O=e.mayaAppDepositGatewaySettings)==null?void 0:O.maximumAmount)}},withdrawalGateway:{bank:{androidEnabled:((F=e.bankWithdrawalGatewaySettings)==null?void 0:F.androidEnabled)??!1,iosEnabled:((L=e.bankWithdrawalGatewaySettings)==null?void 0:L.iosEnabled)??!1,webEnabled:((C=e.bankWithdrawalGatewaySettings)==null?void 0:C.webEnabled)??!1,mobileWebEnabled:((ne=e.bankWithdrawalGatewaySettings)==null?void 0:ne.mobileWebEnabled)??!1,minimumAmount:i((oe=e.bankWithdrawalGatewaySettings)==null?void 0:oe.minimumAmount),maximumAmount:i((ie=e.bankWithdrawalGatewaySettings)==null?void 0:ie.maximumAmount)},gcash:{androidEnabled:((se=e.gcashWithdrawalGatewaySettings)==null?void 0:se.androidEnabled)??!1,iosEnabled:((ce=e.gcashWithdrawalGatewaySettings)==null?void 0:ce.iosEnabled)??!1,webEnabled:((de=e.gcashWithdrawalGatewaySettings)==null?void 0:de.webEnabled)??!1,mobileWebEnabled:((me=e.gcashWithdrawalGatewaySettings)==null?void 0:me.mobileWebEnabled)??!1,minimumAmount:i((ue=e.gcashWithdrawalGatewaySettings)==null?void 0:ue.minimumAmount),maximumAmount:i((le=e.gcashWithdrawalGatewaySettings)==null?void 0:le.maximumAmount,1e6)},maya:{androidEnabled:((pe=e.mayaWithdrawalGatewaySettings)==null?void 0:pe.androidEnabled)??!1,iosEnabled:((fe=e.mayaWithdrawalGatewaySettings)==null?void 0:fe.iosEnabled)??!1,webEnabled:((he=e.mayaWithdrawalGatewaySettings)==null?void 0:he.webEnabled)??!1,mobileWebEnabled:((ye=e.mayaWithdrawalGatewaySettings)==null?void 0:ye.mobileWebEnabled)??!1,minimumAmount:i((we=e.mayaWithdrawalGatewaySettings)==null?void 0:we.minimumAmount),maximumAmount:i((ge=e.mayaWithdrawalGatewaySettings)==null?void 0:ge.maximumAmount)},mayaApp:{androidEnabled:((be=e.mayaAppWithdrawalGatewaySettings)==null?void 0:be.androidEnabled)??!1,iosEnabled:((Se=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Se.iosEnabled)??!1,webEnabled:((Ae=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ae.webEnabled)??!1,mobileWebEnabled:((Ee=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ee.mobileWebEnabled)??!1,minimumAmount:i((ke=e.mayaAppWithdrawalGatewaySettings)==null?void 0:ke.minimumAmount),maximumAmount:i((Ce=e.mayaAppWithdrawalGatewaySettings)==null?void 0:Ce.maximumAmount,1e6)}}},pointsClubSettings:{multiplier:i((_e=e.pointsClubSettings)==null?void 0:_e.multiplier,0)}}}account(e){const t={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||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)};return A(t)}wallet(e){return{id:e.id,balance:i(e.balance,0),currency:e.currency,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}verificationDetails(e){return{id:e.id,status:e.status,address:e.address,permanentAddress:e.permanentAddress,nationality:e.nationality,natureOfWork:e.natureOfWork,placeOfBirth:e.placeOfBirth,sourceOfIncome:e.sourceOfIncome,selfieImage:this.file(e.selfieImage),idFrontImage:this.file(e.idFrontImage)}}profileCompletion(e){return{accountPassword:e.accountPassword??!1,accountVerification:e.accountVerification??!1,mobileNumberVerification:e.mobileNumberVerification??!1,personalInformation:e.personalInformation??!1,transactionPassword:e.transactionPassword??!1,completionPercentage:i(e.completionPercentage,0)}}announcement(e){return{id:e.id,type:e.type,title:e.title,status:e.status,message:e.message,activationEndDateTime:new Date(e.activationEndDateTime),activationStartDateTime:new Date(e.activationStartDateTime),dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)}}withdrawalRecord(e){const t={id:e.id,type:e.type,bank:e.bank,status:e.status,amount:i(e.amount,0),netAmount:i(e.netAmount,0),fee:i(e.fee,0),reference:e.reference??void 0,withdrawalNumber:e.withdrawalNumber,recipientMobileNumber:e.recipientMobileNumber??void 0,dateTimeConfirmed:e.dateTimeConfirmed?new Date(e.dateTimeConfirmed):void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}deposit(e){const t={id:e.id,type:e.type,status:e.status,checkoutUrl:e.checkoutUrl??void 0};return A(t)}depositRecord(e){const t={id:e.id,type:e.type,status:e.status,amount:i(e.amount,0),fee:i(e.fee,0),netAmount:i(e.netAmount,0),reference:e.reference??void 0,depositNumber:e.depositNumber,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}betRecord(e){var r;const t={id:e.id,bet:i(e.bet,0),payout:i(e.payout,0),status:e.status,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:{name:e.game.name,type:e.game.type,images:this.staticService.gameThumbnails(e.game),provider:e.game.provider},serialCode:e.serialCode,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:((r=e.metadata)==null?void 0:r.odds)??void 0}};return A(t)}latestBetRecord(e){return{id:e.id,member:e.member,game:{name:e.game.name,type:e.game.type,images:this.staticService.gameThumbnails(e.game),provider:e.game.provider},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){const t={id:e.id,type:e.type,amount:i(e.amount,0),content:e.content??void 0,currentBalance:i(e.currentBalance,0),referenceNumber:e.referenceNumber,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}game(e){return{id:e.id,type:e.type,name:e.name,images:this.staticService.gameThumbnails(e),provider:e.provider}}game__next(e){return{id:e.id,type:e.type,tags:e.tags??[],name:e.name,images:[e.customImage,e.image].filter(Boolean),provider:e.provider,reference:e.reference,externalId:e.externalId}}gameSession(e){const t={id:e.id,status:e.status,launchUrl:e.launchUrl??void 0,dateTimeCreated:new Date(e.dateTimeCreated),dateTimeLastUpdated:new Date(e.dateTimeLastUpdated)};return A(t)}promo(e){return{id:e.id,type:e.type,name:e.name,status:e.status,description:e.description,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{id:e.id,name:e.name,description:e.description,status:e.status,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),turnoverContributionPercentagePerGameProvider:Object.entries(e.turnoverContributionPercentagePerGameProvider).reduce((r,[a,s])=>(r[a]=i(s,0),r),{})}}bonus(e){const t={id:e.id,promo:this.promo(e.promo),deposit:e.deposit?{type:e.deposit.type,status:e.deposit.status,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)};return A(t)}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){const t={id:e.id,url:e.url??void 0,status:e.status,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}pointsWallet(e){return{id:e.id,points:i(e.points,0),account:e.account,dateTimeCreated:new Date(e.dateTimeCreated)}}pointsWalletTransaction(e){return{id:e.id,type:e.type,amount:i(e.amount,0),balance:i(e.balance,0),dateTimeCreated:new Date(e.dateTimeCreated)}}activityRecord(e){const t={id:e.id,type:e.type,amount:e.amount?i(e.amount,0):void 0,domain:e.domain??void 0,details:e.details,dateTimeCreated:new Date(e.dateTimeCreated)};return A(t)}referrals(e){return{id:e.id,level:e.level,upline:e.upline,downline:e.downline,turnover:i(e.turnover,0),commision:i(e.commision,0),dateTimeCreated:new Date(e.dateTimeCreated)}}}class Ut{constructor(e){d(this,"cmsPortalService");d(this,"authService");d(this,"gameService");d(this,"fileService");d(this,"walletService");d(this,"accountService");d(this,"reportService");d(this,"portalService");d(this,"sessionManager");d(this,"transformer");d(this,"logger");const{site:t,sitePlatform:r,platform:a,environment:s,logs:c}=e,u=s==="production";this.transformer=new Ot({environment:s}),this.logger=new ee({enabled:c??!1});const p=u?"https://auth.opexa.io":"https://auth.development.opexa.io",y=u?"https://wallet.opexa.io/graphql":"https://wallet.development.opexa.io/graphql",b=u?"https://report.opexa.io/graphql":"https://report.development.opexa.io/graphql",f=u?"https://account.opexa.io/graphql":"https://account.development.opexa.io/graphql",v=u?"https://portal.opexa.io/graphql":"https://portal.development.opexa.io/graphql",M=u?"https://file.opexa.io/graphql":"https://file.development.opexa.io/graphql",N=u?"https://game.opexa.io/graphql":"https://game.development.opexa.io/graphql",I=u?"https://portal-api.opexacms.io/v1":"https://portal-api.development.opexacms.io/v1",R=new Tt({url:I,site:t,platform:r}),E={middlewares:[this.authMiddleware],fetchOptions:{headers:{Role:"MEMBER","Platform-Code":a}}},D=new Mt(new U(N,E)),P=new vt(new U(M,E)),_=new Dt(new U(y,E)),x=new Ct(new U(f,E)),G=new It(new U(b,E)),$=new Nt(new U(v,E)),T=new _t({url:p,platform:a}),O=new $t({logs:c,authService:T,walletService:_});this.authService=T,this.gameService=D,this.fileService=P,this.walletService=_,this.accountService=x,this.reportService=G,this.portalService=$,this.sessionManager=O,this.cmsPortalService=R}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 S(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 S(e.secretAnswer)});default:return{ok:!1,error:{name:"HttpBadRequest",message:"Invalid input 'type'"}}}}async signOut(){await this.sessionManager.destroy()}watchSession(e){const t=Pt(e.interval??3e4,3e4,6e4);let r=null;const a=()=>setTimeout(async()=>{await this.sessionManager.verify()||await e.onInvalid(),r=a()},t);return r=a(),function(){r&&clearTimeout(r)}}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 validateMayaSession(){return await this.walletService.validateMayaSession()}async site(){const e=await this.cmsPortalService.self();return e.ok?{ok:!0,data:this.transformer.transform.site(e.data)}: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??l.ObjectId.generate(w.Account).toString(),r=await this.accountService.registerMemberAccount({input:{id:t,btag:e.btag,name:e.name,domain:e.domain,birthDay:typeof e.dateOfBirth=="string"?e.dateOfBirth:e.dateOfBirth.toISOString(),password:await S(e.password),mobileNumber:k(e.mobileNumber)},referralCode:e.referralCode,verificationCode:e.verificationCode,reCAPTCHAResponse:e.reCAPTCHAResponse});return r.ok?{ok:!0,data:{id:t}}:r}async createAccount__next(e){const t=e.id??l.ObjectId.generate(w.Account).toString();if(e.type==="MOBILE_NUMBER"){const a=await this.accountService.registerMemberAccountViaMobile({input:{id:t,mobileNumber:k(e.mobileNumber)},referralCode:e.referralCode,reCAPTCHAResponse:e.reCAPTCHAResponse,verificationCode:e.verificationCode});return a.ok?{ok:!0,data:{id:t}}:a}const r=await this.accountService.registerMemberAccount__next({input:{id:t,name:e.name,password:await S(e.password),mobileNumber:e.mobileNumber?k(e.mobileNumber):void 0},reCAPTCHAResponse:e.reCAPTCHAResponse});return r.ok?{ok:!0,data:{id:t}}:r}async registerMayaAccount(e){return await this.accountService.registerMayaMemberAccount({input:{name:e.name,password:await S(e.password),domain:e.domain}})}async updateAccount(e,t){return await this.accountService.updateMemberAccount({input:{id:e,data:{...t,password:t.password?await S(t.password):void 0,transactionPassword:t.transactionPassword?await S(t.transactionPassword):void 0,...t.mobileNumber&&{mobileNumber:k(t.mobileNumber)},secretAnswer:t.secretAnswer?await S(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??l.ObjectId.generate(w.Verification).toString(),r=await this.accountService.createMemberVerification({input:{id:t,...e}});return r.ok?{ok:!0,data:{id:t}}:r}async updateVerificationDetails(e,t){return await this.accountService.updateMemberVerification({input:{id:e,data:{...t}}})}async resetPassword(e){return await this.accountService.resetPassword({input:{mobileNumber:k(e.mobileNumber),newPassword:await S(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:k(e)}})}async sendVerificationCode__next(e){return this.authService.sendVerificationCode(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:r,node:a})=>({...this.transformer.transform.announcement(a),cursor:r})),totalCount:t.data.totalCount,endCursor:t.data.pageInfo.endCursor??void 0,hasNextPage:t.data.pageInfo.hasNextPage}}:t}async createWithdrawal(e){const t=e.id??l.ObjectId.generate(w.Withdrawal).toString();if(e.type==="BANK"){const r=await this.walletService.createBankWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await S(e.transactionPassword)}});if(!r.ok)return r}if(e.type==="GCASH"){const r=await this.walletService.createGCashWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await S(e.transactionPassword),recipientMobileNumber:k(e.recipientMobileNumber)}});if(!r.ok)return r}if(e.type==="MAYA"){const r=await this.walletService.createMayaWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await S(e.transactionPassword),recipientMobileNumber:k(e.recipientMobileNumber)}});if(!r.ok)return r}if(e.type==="MAYA_APP"){const r=await this.walletService.createMayaAppWithdrawal({input:{id:t,amount:e.amount.toString(),transactionPassword:await S(e.transactionPassword)}});if(!r.ok)return r}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:r,node:a})=>({...this.transformer.transform.withdrawalRecord(a),cursor:r})),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??l.ObjectId.generate(w.Deposit).toString();if(e.type==="MAYA"){const r=await this.walletService.createMayaDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="MAYA_APP"){const r=await this.walletService.createMayaAppDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}if(e.type==="GCASH"){const r=await this.walletService.createGCashDeposit({input:{id:t,amount:e.amount.toString(),promo:e.promo}});if(!r.ok)return r}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:r,node:a})=>({...this.transformer.transform.depositRecord(a),cursor:r})),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,...(e==null?void 0:e.filter)&&{filter:{...e.filter.status&&{game:e.filter.status},...e.filter.serialCode&&{game:e.filter.serialCode},...e.filter.vendorRoundId&&{game:e.filter.vendorRoundId},...e.filter.dateTimeCreated&&{dateTimeCreated:e.filter.dateTimeCreated},...e.filter.gameType&&{game__type:e.filter.gameType},...e.filter.gameProvider&&{game__provider:e.filter.gameProvider}}}});return t.ok?{ok:!0,data:{betRecords:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.betRecord(a),cursor:r})),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:r,node:a})=>({...this.transformer.transform.transactionRecord(a),cursor:r})),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 game(e){return this.game__next(e)}async game__next(e){const t=await this.cmsPortalService.game(e);return t.ok?{ok:!0,data:t.data?this.transformer.transform.game__next(t.data):null}:t}async games(e){const t=await this.walletService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.game(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async games__next(e){const t=await this.cmsPortalService.games(e);return t.ok?{ok:!0,data:{games:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.game__next(a),cursor:r})),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:r,node:a})=>({...this.transformer.transform.game(a),cursor:r})),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 gameSession__next(e){const t=await this.walletService.gameSession({id:e});if(!t.ok)return t;if(t.data)return{ok:!0,data:this.transformer.transform.gameSession(t.data)};const r=await this.gameService.gameSession({id:e});return r.ok?{ok:!0,data:r.data?this.transformer.transform.gameSession(r.data):null}:r}async createGameSession(e){const t=e.id??l.ObjectId.generate(w.GameSession).toString(),r=await this.walletService.createGameSession({input:{id:t,game:e.game}});return r.ok?{ok:!0,data:{id:t}}:r}async createGameSession__legacy(e){const t=e.id??l.ObjectId.generate(w.GameSession).toString(),r=await this.gameService.createGameSession({input:{id:t,game:e.game}});return r.ok?{ok:!0,data:{id:t}}:r}async createGameSession__next(e){const t=e.id??l.ObjectId.generate(w.GameSession).toString();if(e.game.startsWith("SPORTS:")){const u=await l.ObjectId.generateFromKey(w.Game,e.game).then(y=>y.toString()),p=await this.gameService.createGameSession({input:{id:t,game:u}});return p.ok?{ok:!0,data:{id:t}}:p}const r=await this.game__next(e.game);if(!r.data)return{ok:!1,error:{name:"GameDoesNotExistError",message:"Game does not exist"}};const{provider:a,reference:s}=r.data,c=Bt(a)?await this.walletService.createGameSession({input:{id:t,game:s}}):await this.gameService.createGameSession({input:{id:t,game:s}});return c.ok?{ok:!0,data:{id:t}}:c}async endGameSession(e){return await this.walletService.endGameSession({input:{id:e}})}async endGameSession__legacy(e){return await this.gameService.endGameSession({input:{id:e}})}async endGameSession__next(e){const t=await this.walletService.endGameSession({input:{id:e}});return t.ok?t: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??l.ObjectId.generate(w.File).toString(),r=await this.fileService.uploadPrivateImageFile({input:{id:t,file:e.file}});return r.ok?{ok:!0,data:{id:t}}:r}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()}})}async pointsWalletTransactions(e){const t=await this.reportService.pointsWalletTransactions(e);return t.ok?{ok:!0,data:{pointsWalletTransactions:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.pointsWalletTransaction(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async activityRecords(e){const t=await this.reportService.activityRecords(e);return t.ok?{ok:!0,data:{activityRecords:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.activityRecord(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}async referralCode(){const e=await this.accountService.referralCode();return e.ok?{ok:!0,data:e.data??null}:e}async updateReferralCode(e){return await this.accountService.updateReferralCode({input:e})}async referrals(e){const t=await this.reportService.referrals(e);return t.ok?{ok:!0,data:{referrals:t.data.edges.map(({cursor:r,node:a})=>({...this.transformer.transform.referrals(a),cursor:r})),totalCount:t.data.totalCount,hasNextPage:t.data.pageInfo.hasNextPage,endCursor:t.data.pageInfo.endCursor??void 0}}:t}}const Wt=["RTG","DARWIN","DRBINGO","MEGABALL","EVOLUTION","EVOLUTION_NETENT","EVOLUTION_REDTIGER"];function Bt(n){return Wt.some(e=>e===n)}Object.defineProperty(g,"ObjectId",{enumerable:!0,get:()=>l.ObjectId}),g.ObjectType=w,g.Sdk=Ut,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|
|
1069
1096
|
//# sourceMappingURL=index.js.map
|