@ultrade/ultrade-js-sdk 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +117 -0
  2. package/dist/argsAsObj/affiliates.args.d.ts +22 -0
  3. package/dist/argsAsObj/auth.args.d.ts +24 -0
  4. package/dist/argsAsObj/client.args.d.ts +21 -0
  5. package/dist/argsAsObj/index.d.ts +8 -0
  6. package/dist/argsAsObj/market.args.d.ts +53 -0
  7. package/dist/argsAsObj/social.args.d.ts +39 -0
  8. package/dist/argsAsObj/system.args.d.ts +7 -0
  9. package/dist/argsAsObj/trading.args.d.ts +12 -0
  10. package/dist/argsAsObj/wallet.args.d.ts +31 -0
  11. package/dist/client.d.ts +112 -0
  12. package/dist/const/auth.const.d.ts +1 -0
  13. package/dist/const/client.const.d.ts +8 -0
  14. package/dist/const/index.d.ts +2 -0
  15. package/dist/enum/account.enum.d.ts +42 -0
  16. package/dist/enum/affiliates.enum.d.ts +5 -0
  17. package/dist/enum/common.enum.d.ts +15 -0
  18. package/dist/enum/index.d.ts +6 -0
  19. package/dist/enum/market.enum.d.ts +252 -0
  20. package/dist/enum/social.enum.d.ts +6 -0
  21. package/dist/{src/enums.d.ts → enum/socket.enum.d.ts} +0 -16
  22. package/dist/index.d.ts +6 -0
  23. package/dist/index.js +1 -1
  24. package/dist/interface/account.interface.d.ts +64 -0
  25. package/dist/interface/affiliates.interface.d.ts +42 -0
  26. package/dist/interface/auth.interface.d.ts +19 -0
  27. package/dist/interface/client.interface.d.ts +12 -0
  28. package/dist/interface/index.d.ts +11 -0
  29. package/dist/interface/market.interface.d.ts +232 -0
  30. package/dist/interface/notification.interface.d.ts +6 -0
  31. package/dist/interface/social.interface.d.ts +145 -0
  32. package/dist/interface/socket.interface.d.ts +47 -0
  33. package/dist/interface/system.interface.d.ts +20 -0
  34. package/dist/interface/trading.interface.d.ts +38 -0
  35. package/dist/interface/wallet.interface.d.ts +143 -0
  36. package/dist/{src/localStorage.d.ts → localStorage.d.ts} +1 -1
  37. package/dist/{src/sockets.d.ts → sockets.d.ts} +1 -1
  38. package/dist/{src → utils}/algodService.d.ts +6 -8
  39. package/dist/utils/algorand.util.d.ts +4 -0
  40. package/dist/utils/client.util.d.ts +6 -0
  41. package/dist/utils/index.d.ts +3 -0
  42. package/package.json +9 -6
  43. package/dist/src/client.d.ts +0 -143
  44. package/dist/src/index.d.ts +0 -2
  45. package/dist/src/interfaces.d.ts +0 -136
  46. package/dist/src/utils.d.ts +0 -2
@@ -0,0 +1,252 @@
1
+ export declare enum ORDER_STATUS {
2
+ OPEN_ORDER = 1,
3
+ CANCELLED = 2,
4
+ MATCHED = 3,
5
+ SELF_MATCHED = 4
6
+ }
7
+ export declare enum OrderStatus {
8
+ 'Open' = 1,
9
+ 'Canceled' = 2,
10
+ 'Completed' = 3,
11
+ 'SelfMatch' = 4,
12
+ 'Expired' = 5
13
+ }
14
+ export declare enum OrderTypeEnum {
15
+ 'Limit' = 0,
16
+ 'IOC' = 1,
17
+ 'POST' = 2,
18
+ 'Market' = 3
19
+ }
20
+ export declare enum OrderUpdateStaus {
21
+ 'created' = 1,
22
+ 'partially_filled' = 2,
23
+ 'removed' = 3
24
+ }
25
+ export declare enum BLOCKCHAINS {
26
+ "ALGORAND" = "Algorand",
27
+ "SOLANA" = "Solana",
28
+ "5IRECHAIN_THUNDER_TESTNET" = "5ireChain Thunder Testnet",
29
+ "ACALA" = "Acala",
30
+ "ALFAJORES" = "Alfajores",
31
+ "APOTHEM_NETWORK" = "Apothem Network",
32
+ "ARBITRUM_GOERLI" = "Arbitrum Goerli",
33
+ "ARBITRUM_NOVA" = "Arbitrum Nova",
34
+ "ARBITRUM_ONE" = "Arbitrum",
35
+ "ARBITRUM_SEPOLIA" = "Arbitrum Sepolia",
36
+ "ASTAR" = "Astar",
37
+ "ASTAR_ZKEVM_TESTNET_ZKATANA" = "Astar zkEVM Testnet zKatana",
38
+ "AURORA" = "Aurora",
39
+ "AURORA_TESTNET" = "Aurora Testnet",
40
+ "AVALANCHE" = "Avalanche",
41
+ "AVALANCHE_FUJI" = "Avalanche Fuji",
42
+ "BAHAMUT" = "Bahamut",
43
+ "BASE" = "Base",
44
+ "BASE_GOERLI" = "Base Goerli",
45
+ "BASE_SEPOLIA" = "Base Sepolia",
46
+ "BEAR_NETWORK_CHAIN_MAINNET" = "Bear Network Chain Mainnet",
47
+ "BEAR_NETWORK_CHAIN_TESTNET" = "Bear Network Chain Testnet",
48
+ "BERACHAIN_ARTIO" = "Berachain Artio",
49
+ "BERESHEET_BEREEVM_TESTNET" = "Beresheet BereEVM Testnet",
50
+ "BINANCE_SMART_CHAIN_TESTNET" = "BNB Chain Testnet",
51
+ "BITTORRENT" = "BitTorrent",
52
+ "BITTORRENT_CHAIN_TESTNET" = "BitTorrent Chain Testnet",
53
+ "BLACKFORT_EXCHANGE_NETWORK" = "BlackFort Exchange Network",
54
+ "BLACKFORT_EXCHANGE_NETWORK_TESTNET" = "BlackFort Exchange Network Testnet",
55
+ "BLAST_SEPOLIA" = "Blast Sepolia",
56
+ "BNB_SMART_CHAIN" = "BNB Chain",
57
+ "BOBA_NETWORK" = "Boba Network",
58
+ "BRONOS" = "Bronos",
59
+ "BRONOS_TESTNET" = "Bronos Testnet",
60
+ "CANTO" = "Canto",
61
+ "CELO" = "Celo",
62
+ "CHILIZ_CHAIN" = "Chiliz Chain",
63
+ "CHILIZ_SPICY_TESTNET" = "Chiliz Spicy Testnet",
64
+ "CONFLUX_ESPACE" = "Conflux eSpace",
65
+ "CONFLUX_ESPACE_TESTNET" = "Conflux eSpace Testnet",
66
+ "CORE_DAO" = "Core Dao",
67
+ "COSTON" = "Coston",
68
+ "COSTON2" = "Coston2",
69
+ "CRONOS_MAINNET" = "Cronos Mainnet",
70
+ "CRONOS_TESTNET" = "Cronos Testnet",
71
+ "CROSSBELL" = "Crossbell",
72
+ "DEFICHAIN_EVM_MAINNET" = "DeFiChain EVM Mainnet",
73
+ "DEFICHAIN_EVM_TESTNET" = "DeFiChain EVM Testnet",
74
+ "DFK_CHAIN" = "DFK Chain",
75
+ "DOGECHAIN" = "Dogechain",
76
+ "EDGEWARE_EDGEEVM_MAINNET" = "Edgeware EdgeEVM Mainnet",
77
+ "EKTA" = "Ekta",
78
+ "EKTA_TESTNET" = "Ekta Testnet",
79
+ "EOS_EVM" = "EOS EVM",
80
+ "EOS_EVM_TESTNET" = "EOS EVM Testnet",
81
+ "ETHEREUM" = "Ethereum",
82
+ "ETHEREUM_CLASSIC" = "Ethereum Classic",
83
+ "EVMOS" = "Evmos",
84
+ "EVMOS_TESTNET" = "Evmos Testnet",
85
+ "FANTOM" = "Fantom",
86
+ "FANTOM_SONIC_OPEN_TESTNET" = "Fantom Sonic Open Testnet",
87
+ "FANTOM_TESTNET" = "Fantom Testnet",
88
+ "FIBO_CHAIN" = "Fibo Chain",
89
+ "FILECOIN_CALIBRATION" = "Filecoin Calibration",
90
+ "FILECOIN_HYPERSPACE" = "Filecoin Hyperspace",
91
+ "FILECOIN_MAINNET" = "Filecoin Mainnet",
92
+ "FLARE_MAINNET" = "Flare Mainnet",
93
+ "FOUNDRY" = "Foundry",
94
+ "FUSE" = "Fuse",
95
+ "FUSE_SPARKNET" = "Fuse Sparknet",
96
+ "GNOSIS" = "Gnosis",
97
+ "GNOSIS_CHIADO" = "Gnosis Chiado",
98
+ "GOERLI" = "Goerli",
99
+ "HAQQ_MAINNET" = "HAQQ Mainnet",
100
+ "HAQQ_TESTEDGE_2" = "HAQQ Testedge 2",
101
+ "HARDHAT" = "Hardhat",
102
+ "HARMONY_ONE" = "Harmony One",
103
+ "HEDERA_MAINNET" = "Hedera Mainnet",
104
+ "HEDERA_PREVIEWNET" = "Hedera Previewnet",
105
+ "HEDERA_TESTNET" = "Hedera Testnet",
106
+ "HOLESKY" = "Holesky",
107
+ "HORIZEN_GOBI_TESTNET" = "Horizen Gobi Testnet",
108
+ "IOTEX" = "IoTeX",
109
+ "IOTEX_TESTNET" = "IoTeX Testnet",
110
+ "JIBCHAIN_L1" = "JIBCHAIN L1",
111
+ "KARURA" = "Karura",
112
+ "KAVA_EVM" = "Kava EVM",
113
+ "KAVA_EVM_TESTNET" = "Kava EVM Testnet",
114
+ "KCC_MAINNET" = "KCC Mainnet",
115
+ "KLAYTN" = "Klaytn",
116
+ "KLAYTN_BAOBAB_TESTNET" = "Klaytn Baobab Testnet",
117
+ "KROMA" = "Kroma",
118
+ "KROMA_SEPOLIA" = "Kroma Sepolia",
119
+ "LIGHTLINK_PEGASUS_TESTNET" = "LightLink Pegasus Testnet",
120
+ "LIGHTLINK_PHOENIX" = "LightLink Phoenix",
121
+ "LINEA_GOERLI_TESTNET" = "Linea Goerli Testnet",
122
+ "LINEA_MAINNET" = "Linea Mainnet",
123
+ "LOCALHOST" = "Localhost",
124
+ "LUKSO" = "LUKSO",
125
+ "MANDALA_TC9" = "Mandala TC9",
126
+ "MANTA_PACIFIC_MAINNET" = "Manta Pacific Mainnet",
127
+ "MANTA_PACIFIC_TESTNET" = "Manta Pacific Testnet",
128
+ "MANTLE" = "Mantle",
129
+ "MANTLE_TESTNET" = "Mantle Testnet",
130
+ "METACHAIN_MAINNET" = "MetaChain Mainnet",
131
+ "METER" = "Meter",
132
+ "METER_TESTNET" = "Meter Testnet",
133
+ "METIS" = "Metis",
134
+ "METIS_GOERLI" = "Metis Goerli",
135
+ "MEVERSE_CHAIN_MAINNET" = "MEVerse Chain Mainnet",
136
+ "MEVERSE_CHAIN_TESTNET" = "MEVerse Chain Testnet",
137
+ "MODE_TESTNET" = "Mode Testnet",
138
+ "MOONBASE_ALPHA" = "Moonbase Alpha",
139
+ "MOONBEAM" = "Moonbeam",
140
+ "MOONBEAM_DEVELOPMENT_NODE" = "Moonbeam Development Node",
141
+ "MOONRIVER" = "Moonriver",
142
+ "NEON_EVM_DEVNET" = "Neon EVM DevNet",
143
+ "NEON_EVM_MAINNET" = "Neon EVM MainNet",
144
+ "NEXI" = "Nexi",
145
+ "NEXILIX_SMART_CHAIN" = "Nexilix Smart Chain",
146
+ "OASIS_SAPPHIRE" = "Oasis Sapphire",
147
+ "OASIS_SAPPHIRE_TESTNET" = "Oasis Sapphire Testnet",
148
+ "OASIS_TESTNET" = "Oasis Testnet",
149
+ "OASYS" = "Oasys",
150
+ "OKC" = "OKC",
151
+ "OORT_MAINNETDEV" = "OORT MainnetDev",
152
+ "OPBNB" = "opBNB",
153
+ "OPBNB_TESTNET" = "opBNB Testnet",
154
+ "OPTIMISM_GOERLI" = "Optimism Goerli",
155
+ "OP_MAINNET" = "Optimism",
156
+ "OP_SEPOLIA" = "Optimism Sepolia",
157
+ "PALM" = "Palm",
158
+ "PALM_TESTNET" = "Palm Testnet",
159
+ "PGN" = "PGN",
160
+ "PGN_" = "PGN ",
161
+ "PLINGA" = "Plinga",
162
+ "POLYGON" = "Polygon",
163
+ "POLYGON_AMOY" = "Polygon Amoy",
164
+ "POLYGON_MUMBAI" = "Polygon Mumbai",
165
+ "POLYGON_ZKEVM" = "Polygon zkEVM",
166
+ "POLYGON_ZKEVM_TESTNET" = "Polygon zkEVM Testnet",
167
+ "PULSECHAIN" = "PulseChain",
168
+ "PULSECHAIN_V4" = "PulseChain V4",
169
+ "Q_MAINNET" = "Q Mainnet",
170
+ "Q_TESTNET" = "Q Testnet",
171
+ "ROLLUX_MAINNET" = "Rollux Mainnet",
172
+ "ROLLUX_TESTNET" = "Rollux Testnet",
173
+ "RONIN" = "Ronin",
174
+ "ROOTSTOCK_MAINNET" = "Rootstock Mainnet",
175
+ "SAIGON_TESTNET" = "Saigon Testnet",
176
+ "SCROLL" = "Scroll",
177
+ "SCROLL_SEPOLIA" = "Scroll Sepolia",
178
+ "SCROLL_TESTNET" = "Scroll Testnet",
179
+ "SEPOLIA" = "Ethereum Sepolia",
180
+ "SHARDEUM_SPHINX" = "Shardeum Sphinx",
181
+ "SHIBARIUM" = "Shibarium",
182
+ "SHIMMER" = "Shimmer",
183
+ "SHIMMER_TESTNET" = "Shimmer Testnet",
184
+ "SKALE_|_BLOCK_BRAWLERS" = "SKALE | Block Brawlers",
185
+ "SKALE_|_CALYPSO_NFT_HUB" = "SKALE | Calypso NFT Hub",
186
+ "SKALE_|_CALYPSO_NFT_HUB_TESTNET" = "SKALE | Calypso NFT Hub Testnet",
187
+ "SKALE_|_CHAOS_TESTNET" = "SKALE | Chaos Testnet",
188
+ "SKALE_|_CRYPTOBLADES" = "SKALE | CryptoBlades",
189
+ "SKALE_|_CRYPTO_COLOSSEUM" = "SKALE | Crypto Colosseum",
190
+ "SKALE_|_EUROPA_LIQUIDITY_HUB" = "SKALE | Europa Liquidity Hub",
191
+ "SKALE_|_EUROPA_LIQUIDITY_HUB_TESTNET" = "SKALE | Europa Liquidity Hub Testnet",
192
+ "SKALE_|_EXORDE" = "SKALE | Exorde",
193
+ "SKALE_|_HUMAN_PROTOCOL" = "SKALE | Human Protocol",
194
+ "SKALE_|_NEBULA_GAMING_HUB" = "SKALE | Nebula Gaming Hub",
195
+ "SKALE_|_NEBULA_GAMING_HUB_TESTNET" = "SKALE | Nebula Gaming Hub Testnet",
196
+ "SKALE_|_RAZOR_NETWORK" = "SKALE | Razor Network",
197
+ "SKALE_|_TITAN_COMMUNITY_HUB" = "SKALE | Titan Community Hub",
198
+ "SKALE_|_TITAN_COMMUNITY_HUB_TESTNET" = "SKALE | Titan Community Hub Testnet",
199
+ "SONGBIRD_MAINNET" = "Songbird Mainnet",
200
+ "SYSCOIN_MAINNET" = "Syscoin Mainnet",
201
+ "SYSCOIN_TANENBAUM_TESTNET" = "Syscoin Tanenbaum Testnet",
202
+ "TAIKO_(ALPHA-3_TESTNET)" = "Taiko (Alpha-3 Testnet)",
203
+ "TAIKO_JOLNIR_(ALPHA-5_TESTNET)" = "Taiko Jolnir (Alpha-5 Testnet)",
204
+ "TAIKO_KATLA_(ALPHA-6_TESTNET)" = "Taiko Katla (Alpha-6 Testnet)",
205
+ "TARAXA_MAINNET" = "Taraxa Mainnet",
206
+ "TARAXA_TESTNET" = "Taraxa Testnet",
207
+ "TELOS" = "Telos",
208
+ "TENET" = "Tenet",
209
+ "VECHAIN" = "Vechain",
210
+ "WANCHAIN" = "Wanchain",
211
+ "WANCHAIN_TESTNET" = "Wanchain Testnet",
212
+ "WEMIX" = "WEMIX",
213
+ "WEMIX_TESTNET" = "WEMIX Testnet",
214
+ "X1_TESTNET" = "X1 Testnet",
215
+ "XINFIN_NETWORK" = "XinFin Network",
216
+ "ZETACHAIN_ATHENS_TESTNET" = "ZetaChain Athens Testnet",
217
+ "ZHEJIANG" = "Zhejiang",
218
+ "ZILLIQA" = "Zilliqa",
219
+ "ZILLIQA_TESTNET" = "Zilliqa Testnet",
220
+ "ZKFAIR_MAINNET" = "ZKFair Mainnet",
221
+ "ZKFAIR_TESTNET" = "ZKFair Testnet",
222
+ "ZKSYNC_ERA" = "zkSync Era",
223
+ "ZKSYNC_ERA_TESTNET" = "zkSync Era Testnet",
224
+ "ZKSYNC_SEPOLIA_TESTNET" = "zkSync Sepolia Testnet",
225
+ "ZORA" = "Zora",
226
+ "ZORA_GOERLI_TESTNET" = "Zora Goerli Testnet",
227
+ "ZORA_SEPOLIA" = "Zora Sepolia"
228
+ }
229
+ export declare enum OperationStatusEnum {
230
+ Pending = "pending",
231
+ Completed = "completed",
232
+ Failed = "failed",
233
+ Received = "received",
234
+ Success = "success",
235
+ Failure = "failure",
236
+ Dropped = "dropped",
237
+ Replaced = "replaced",
238
+ Stuck = "stuck",
239
+ Confirmed = "confirmed"
240
+ }
241
+ export declare enum TransactionType {
242
+ USER_TO_TMC = "user_to_tmc",
243
+ TMC_TO_USER = "tmc_to_user",
244
+ RELAYER_TO_TMC = "relayer_to_tmc",
245
+ RELAYER_TO_CODEX = "relayer_to_codex",
246
+ RELAYER_TO_CIRCLE = "relayer_to_circle"
247
+ }
248
+ export declare enum ACTION_TYPE {
249
+ D = "deposit",
250
+ W = "withdraw",
251
+ T = "transfer"
252
+ }
@@ -0,0 +1,6 @@
1
+ export declare enum SOCIAL_ACTION_SOURCE {
2
+ COMPANY = "COMPANY",
3
+ TWITTER = "TWITTER",
4
+ DISCORD = "DISCORD",
5
+ TELEGRAM = "TELEGRAM"
6
+ }
@@ -1,13 +1,3 @@
1
- export declare enum DIRECT_SETTLE {
2
- YES = "Y",
3
- NO = "N"
4
- }
5
- export declare enum ORDER_STATUS {
6
- OPEN_ORDER = 1,
7
- CANCELLED = 2,
8
- MATCHED = 3,
9
- SELF_MATCHED = 4
10
- }
11
1
  export declare enum STREAMS {
12
2
  QUOTE = 1,
13
3
  LAST_PRICE = 2,
@@ -26,9 +16,3 @@ export declare enum STREAMS {
26
16
  POINT_SYSTEM_SETTINGS_UPDATE = 15
27
17
  }
28
18
  export declare const PRIVATE_STREAMS: STREAMS[];
29
- export declare enum SOCIAL_ACTION_SOURCE {
30
- COMPANY = "COMPANY",
31
- TWITTER = "TWITTER",
32
- DISCORD = "DISCORD",
33
- TELEGRAM = "TELEGRAM"
34
- }
@@ -0,0 +1,6 @@
1
+ export * from './client';
2
+ export { SocketManager } from './sockets';
3
+ export * from "./const/index.ts";
4
+ export * from "./enum/index.ts";
5
+ export * from "./interface/index.ts";
6
+ export * from "./argsAsObj";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- function Z(){throw new Error("setTimeout has not been defined")}function j(){throw new Error("clearTimeout has not been defined")}var I=Z,_=j;typeof globalThis.setTimeout=="function"&&(I=setTimeout);typeof globalThis.clearTimeout=="function"&&(_=clearTimeout);function ee(r){if(I===setTimeout)return setTimeout(r,0);if((I===Z||!I)&&setTimeout)return I=setTimeout,setTimeout(r,0);try{return I(r,0)}catch{try{return I.call(null,r,0)}catch{return I.call(this,r,0)}}}function Ee(r){if(_===clearTimeout)return clearTimeout(r);if((_===j||!_)&&clearTimeout)return _=clearTimeout,clearTimeout(r);try{return _(r)}catch{try{return _.call(null,r)}catch{return _.call(this,r)}}}var A=[],W=!1,E,B=-1;function Te(){!W||!E||(W=!1,E.length?A=E.concat(A):B=-1,A.length&&te())}function te(){if(!W){var r=ee(Te);W=!0;for(var e=A.length;e;){for(E=A,A=[];++B<e;)E&&E[B].run();B=-1,e=A.length}E=null,W=!1,Ee(r)}}function Ce(r){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];A.push(new re(r,e)),A.length===1&&!W&&ee(te)}function re(r,e){this.fun=r,this.array=e}re.prototype.run=function(){this.fun.apply(null,this.array)};var ve="browser",Pe="browser",Se=!0,We={},Ue=[],De="",Re={},Be={},Me={};function T(){}var Ne=T,Le=T,Oe=T,$e=T,Ye=T,Fe=T,Ke=T;function qe(r){throw new Error("process.binding is not supported")}function Ve(){return"/"}function Xe(r){throw new Error("process.chdir is not supported")}function Ge(){return 0}var S=globalThis.performance||{},ze=S.now||S.mozNow||S.msNow||S.oNow||S.webkitNow||function(){return new Date().getTime()};function He(r){var e=ze.call(S)*.001,t=Math.floor(e),i=Math.floor(e%1*1e9);return r&&(t=t-r[0],i=i-r[1],i<0&&(t--,i+=1e9)),[t,i]}var Je=new Date;function Qe(){var r=new Date,e=r-Je;return e/1e3}var b={nextTick:Ce,title:ve,browser:Se,env:We,argv:Ue,version:De,versions:Re,on:Ne,addListener:Le,once:Oe,off:$e,removeListener:Ye,removeAllListeners:Fe,emit:Ke,binding:qe,cwd:Ve,chdir:Xe,umask:Ge,hrtime:He,platform:Pe,release:Be,config:Me,uptime:Qe},Q={};Object.keys(Q).forEach(r=>{let e=r.split("."),t=b;for(let i=0;i<e.length;i++){let n=e[i];i===e.length-1?t[n]=Q[r]:t=t[n]||(t[n]={})}});var x=[],m=[],Ze=typeof Uint8Array<"u"?Uint8Array:Array,V=!1;function ae(){V=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=r.length;e<t;++e)x[e]=r[e],m[r.charCodeAt(e)]=e;m[45]=62,m[95]=63}function je(r){V||ae();var e,t,i,n,s,a,c=r.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=r[c-2]==="="?2:r[c-1]==="="?1:0,a=new Ze(c*3/4-s),i=s>0?c-4:c;var l=0;for(e=0,t=0;e<i;e+=4,t+=3)n=m[r.charCodeAt(e)]<<18|m[r.charCodeAt(e+1)]<<12|m[r.charCodeAt(e+2)]<<6|m[r.charCodeAt(e+3)],a[l++]=n>>16&255,a[l++]=n>>8&255,a[l++]=n&255;return s===2?(n=m[r.charCodeAt(e)]<<2|m[r.charCodeAt(e+1)]>>4,a[l++]=n&255):s===1&&(n=m[r.charCodeAt(e)]<<10|m[r.charCodeAt(e+1)]<<4|m[r.charCodeAt(e+2)]>>2,a[l++]=n>>8&255,a[l++]=n&255),a}function et(r){return x[r>>18&63]+x[r>>12&63]+x[r>>6&63]+x[r&63]}function tt(r,e,t){for(var i,n=[],s=e;s<t;s+=3)i=(r[s]<<16)+(r[s+1]<<8)+r[s+2],n.push(et(i));return n.join("")}function ie(r){V||ae();for(var e,t=r.length,i=t%3,n="",s=[],a=16383,c=0,l=t-i;c<l;c+=a)s.push(tt(r,c,c+a>l?l:c+a));return i===1?(e=r[t-1],n+=x[e>>2],n+=x[e<<4&63],n+="=="):i===2&&(e=(r[t-2]<<8)+r[t-1],n+=x[e>>10],n+=x[e>>4&63],n+=x[e<<2&63],n+="="),s.push(n),s.join("")}o.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function M(){return o.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function k(r,e){if(M()<e)throw new RangeError("Invalid typed array length");return o.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(e),r.__proto__=o.prototype):(r===null&&(r=new o(e)),r.length=e),r}function o(r,e,t){if(!o.TYPED_ARRAY_SUPPORT&&!(this instanceof o))return new o(r,e,t);if(typeof r=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return X(this,r)}return oe(this,r,e,t)}o.poolSize=8192;o._augment=function(r){return r.__proto__=o.prototype,r};function oe(r,e,t,i){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?nt(r,e,t,i):typeof e=="string"?it(r,e,t):st(r,e)}o.from=function(r,e,t){return oe(null,r,e,t)};o.kMaxLength=M();o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&o[Symbol.species]);function le(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function rt(r,e,t,i){return le(e),e<=0?k(r,e):t!==void 0?typeof i=="string"?k(r,e).fill(t,i):k(r,e).fill(t):k(r,e)}o.alloc=function(r,e,t){return rt(null,r,e,t)};function X(r,e){if(le(e),r=k(r,e<0?0:G(e)|0),!o.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)r[t]=0;return r}o.allocUnsafe=function(r){return X(null,r)};o.allocUnsafeSlow=function(r){return X(null,r)};function it(r,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!o.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var i=ce(e,t)|0;r=k(r,i);var n=r.write(e,t);return n!==i&&(r=r.slice(0,n)),r}function q(r,e){var t=e.length<0?0:G(e.length)|0;r=k(r,t);for(var i=0;i<t;i+=1)r[i]=e[i]&255;return r}function nt(r,e,t,i){if(e.byteLength,t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(i||0))throw new RangeError("'length' is out of bounds");return t===void 0&&i===void 0?e=new Uint8Array(e):i===void 0?e=new Uint8Array(e,t):e=new Uint8Array(e,t,i),o.TYPED_ARRAY_SUPPORT?(r=e,r.__proto__=o.prototype):r=q(r,e),r}function st(r,e){if(y(e)){var t=G(e.length)|0;return r=k(r,t),r.length===0||e.copy(r,0,0,t),r}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||_t(e.length)?k(r,0):q(r,e);if(e.type==="Buffer"&&Array.isArray(e.data))return q(r,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function G(r){if(r>=M())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+M().toString(16)+" bytes");return r|0}o.isBuffer=Et;function y(r){return!!(r!=null&&r._isBuffer)}o.compare=function(e,t){if(!y(e)||!y(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,n=t.length,s=0,a=Math.min(i,n);s<a;++s)if(e[s]!==t[s]){i=e[s],n=t[s];break}return i<n?-1:n<i?1:0};o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};o.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return o.alloc(0);var i;if(t===void 0)for(t=0,i=0;i<e.length;++i)t+=e[i].length;var n=o.allocUnsafe(t),s=0;for(i=0;i<e.length;++i){var a=e[i];if(!y(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,s),s+=a.length}return n};function ce(r,e){if(y(r))return r.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var t=r.length;if(t===0)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return N(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return me(r).length;default:if(i)return N(r).length;e=(""+e).toLowerCase(),i=!0}}o.byteLength=ce;function at(r,e,t){var i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(r||(r="utf8");;)switch(r){case"hex":return mt(this,e,t);case"utf8":case"utf-8":return fe(this,e,t);case"ascii":return dt(this,e,t);case"latin1":case"binary":return gt(this,e,t);case"base64":return ft(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return wt(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),i=!0}}o.prototype._isBuffer=!0;function C(r,e,t){var i=r[e];r[e]=r[t],r[t]=i}o.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)C(this,t,t+1);return this};o.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)C(this,t,t+3),C(this,t+1,t+2);return this};o.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)C(this,t,t+7),C(this,t+1,t+6),C(this,t+2,t+5),C(this,t+3,t+4);return this};o.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?fe(this,0,e):at.apply(this,arguments)};o.prototype.equals=function(e){if(!y(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:o.compare(this,e)===0};o.prototype.compare=function(e,t,i,n,s){if(!y(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),n===void 0&&(n=0),s===void 0&&(s=this.length),t<0||i>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=i)return 0;if(n>=s)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,n>>>=0,s>>>=0,this===e)return 0;for(var a=s-n,c=i-t,l=Math.min(a,c),u=this.slice(n,s),h=e.slice(t,i),f=0;f<l;++f)if(u[f]!==h[f]){a=u[f],c=h[f];break}return a<c?-1:c<a?1:0};function ue(r,e,t,i,n){if(r.length===0)return-1;if(typeof t=="string"?(i=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=n?0:r.length-1),t<0&&(t=r.length+t),t>=r.length){if(n)return-1;t=r.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=o.from(e,i)),y(e))return e.length===0?-1:ne(r,e,t,i,n);if(typeof e=="number")return e=e&255,o.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(r,e,t):Uint8Array.prototype.lastIndexOf.call(r,e,t):ne(r,[e],t,i,n);throw new TypeError("val must be string, number or Buffer")}function ne(r,e,t,i,n){var s=1,a=r.length,c=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(r.length<2||e.length<2)return-1;s=2,a/=2,c/=2,t/=2}function l(g,P){return s===1?g[P]:g.readUInt16BE(P*s)}var u;if(n){var h=-1;for(u=t;u<a;u++)if(l(r,u)===l(e,h===-1?0:u-h)){if(h===-1&&(h=u),u-h+1===c)return h*s}else h!==-1&&(u-=u-h),h=-1}else for(t+c>a&&(t=a-c),u=t;u>=0;u--){for(var f=!0,w=0;w<c;w++)if(l(r,u+w)!==l(e,w)){f=!1;break}if(f)return u}return-1}o.prototype.includes=function(e,t,i){return this.indexOf(e,t,i)!==-1};o.prototype.indexOf=function(e,t,i){return ue(this,e,t,i,!0)};o.prototype.lastIndexOf=function(e,t,i){return ue(this,e,t,i,!1)};function ot(r,e,t,i){t=Number(t)||0;var n=r.length-t;i?(i=Number(i),i>n&&(i=n)):i=n;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");i>s/2&&(i=s/2);for(var a=0;a<i;++a){var c=parseInt(e.substr(a*2,2),16);if(isNaN(c))return a;r[t+a]=c}return a}function lt(r,e,t,i){return $(N(e,r.length-t),r,t,i)}function he(r,e,t,i){return $(kt(e),r,t,i)}function ct(r,e,t,i){return he(r,e,t,i)}function ut(r,e,t,i){return $(me(e),r,t,i)}function ht(r,e,t,i){return $(It(e,r.length-t),r,t,i)}o.prototype.write=function(e,t,i,n){if(t===void 0)n="utf8",i=this.length,t=0;else if(i===void 0&&typeof t=="string")n=t,i=this.length,t=0;else if(isFinite(t))t=t|0,isFinite(i)?(i=i|0,n===void 0&&(n="utf8")):(n=i,i=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-t;if((i===void 0||i>s)&&(i=s),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return ot(this,e,t,i);case"utf8":case"utf-8":return lt(this,e,t,i);case"ascii":return he(this,e,t,i);case"latin1":case"binary":return ct(this,e,t,i);case"base64":return ut(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ht(this,e,t,i);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}};o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function ft(r,e,t){return e===0&&t===r.length?ie(r):ie(r.slice(e,t))}function fe(r,e,t){t=Math.min(r.length,t);for(var i=[],n=e;n<t;){var s=r[n],a=null,c=s>239?4:s>223?3:s>191?2:1;if(n+c<=t){var l,u,h,f;switch(c){case 1:s<128&&(a=s);break;case 2:l=r[n+1],(l&192)===128&&(f=(s&31)<<6|l&63,f>127&&(a=f));break;case 3:l=r[n+1],u=r[n+2],(l&192)===128&&(u&192)===128&&(f=(s&15)<<12|(l&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(a=f));break;case 4:l=r[n+1],u=r[n+2],h=r[n+3],(l&192)===128&&(u&192)===128&&(h&192)===128&&(f=(s&15)<<18|(l&63)<<12|(u&63)<<6|h&63,f>65535&&f<1114112&&(a=f))}}a===null?(a=65533,c=1):a>65535&&(a-=65536,i.push(a>>>10&1023|55296),a=56320|a&1023),i.push(a),n+=c}return pt(i)}var se=4096;function pt(r){var e=r.length;if(e<=se)return String.fromCharCode.apply(String,r);for(var t="",i=0;i<e;)t+=String.fromCharCode.apply(String,r.slice(i,i+=se));return t}function dt(r,e,t){var i="";t=Math.min(r.length,t);for(var n=e;n<t;++n)i+=String.fromCharCode(r[n]&127);return i}function gt(r,e,t){var i="";t=Math.min(r.length,t);for(var n=e;n<t;++n)i+=String.fromCharCode(r[n]);return i}function mt(r,e,t){var i=r.length;(!e||e<0)&&(e=0),(!t||t<0||t>i)&&(t=i);for(var n="",s=e;s<t;++s)n+=bt(r[s]);return n}function wt(r,e,t){for(var i=r.slice(e,t),n="",s=0;s<i.length;s+=2)n+=String.fromCharCode(i[s]+i[s+1]*256);return n}o.prototype.slice=function(e,t){var i=this.length;e=~~e,t=t===void 0?i:~~t,e<0?(e+=i,e<0&&(e=0)):e>i&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),t<e&&(t=e);var n;if(o.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=o.prototype;else{var s=t-e;n=new o(s,void 0);for(var a=0;a<s;++a)n[a]=this[a+e]}return n};function p(r,e,t){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}o.prototype.readUIntLE=function(e,t,i){e=e|0,t=t|0,i||p(e,t,this.length);for(var n=this[e],s=1,a=0;++a<t&&(s*=256);)n+=this[e+a]*s;return n};o.prototype.readUIntBE=function(e,t,i){e=e|0,t=t|0,i||p(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n};o.prototype.readUInt8=function(e,t){return t||p(e,1,this.length),this[e]};o.prototype.readUInt16LE=function(e,t){return t||p(e,2,this.length),this[e]|this[e+1]<<8};o.prototype.readUInt16BE=function(e,t){return t||p(e,2,this.length),this[e]<<8|this[e+1]};o.prototype.readUInt32LE=function(e,t){return t||p(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};o.prototype.readUInt32BE=function(e,t){return t||p(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};o.prototype.readIntLE=function(e,t,i){e=e|0,t=t|0,i||p(e,t,this.length);for(var n=this[e],s=1,a=0;++a<t&&(s*=256);)n+=this[e+a]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*t)),n};o.prototype.readIntBE=function(e,t,i){e=e|0,t=t|0,i||p(e,t,this.length);for(var n=t,s=1,a=this[e+--n];n>0&&(s*=256);)a+=this[e+--n]*s;return s*=128,a>=s&&(a-=Math.pow(2,8*t)),a};o.prototype.readInt8=function(e,t){return t||p(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};o.prototype.readInt16LE=function(e,t){t||p(e,2,this.length);var i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};o.prototype.readInt16BE=function(e,t){t||p(e,2,this.length);var i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};o.prototype.readInt32LE=function(e,t){return t||p(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};o.prototype.readInt32BE=function(e,t){return t||p(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};o.prototype.readFloatLE=function(e,t){return t||p(e,4,this.length),Y(this,e,!0,23,4)};o.prototype.readFloatBE=function(e,t){return t||p(e,4,this.length),Y(this,e,!1,23,4)};o.prototype.readDoubleLE=function(e,t){return t||p(e,8,this.length),Y(this,e,!0,52,8)};o.prototype.readDoubleBE=function(e,t){return t||p(e,8,this.length),Y(this,e,!1,52,8)};function d(r,e,t,i,n,s){if(!y(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<s)throw new RangeError('"value" argument is out of bounds');if(t+i>r.length)throw new RangeError("Index out of range")}o.prototype.writeUIntLE=function(e,t,i,n){if(e=+e,t=t|0,i=i|0,!n){var s=Math.pow(2,8*i)-1;d(this,e,t,i,s,0)}var a=1,c=0;for(this[t]=e&255;++c<i&&(a*=256);)this[t+c]=e/a&255;return t+i};o.prototype.writeUIntBE=function(e,t,i,n){if(e=+e,t=t|0,i=i|0,!n){var s=Math.pow(2,8*i)-1;d(this,e,t,i,s,0)}var a=i-1,c=1;for(this[t+a]=e&255;--a>=0&&(c*=256);)this[t+a]=e/c&255;return t+i};o.prototype.writeUInt8=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function L(r,e,t,i){e<0&&(e=65535+e+1);for(var n=0,s=Math.min(r.length-t,2);n<s;++n)r[t+n]=(e&255<<8*(i?n:1-n))>>>(i?n:1-n)*8}o.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):L(this,e,t,!0),t+2};o.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):L(this,e,t,!1),t+2};function O(r,e,t,i){e<0&&(e=4294967295+e+1);for(var n=0,s=Math.min(r.length-t,4);n<s;++n)r[t+n]=e>>>(i?n:3-n)*8&255}o.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):O(this,e,t,!0),t+4};o.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):O(this,e,t,!1),t+4};o.prototype.writeIntLE=function(e,t,i,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*i-1);d(this,e,t,i,s-1,-s)}var a=0,c=1,l=0;for(this[t]=e&255;++a<i&&(c*=256);)e<0&&l===0&&this[t+a-1]!==0&&(l=1),this[t+a]=(e/c>>0)-l&255;return t+i};o.prototype.writeIntBE=function(e,t,i,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*i-1);d(this,e,t,i,s-1,-s)}var a=i-1,c=1,l=0;for(this[t+a]=e&255;--a>=0&&(c*=256);)e<0&&l===0&&this[t+a+1]!==0&&(l=1),this[t+a]=(e/c>>0)-l&255;return t+i};o.prototype.writeInt8=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};o.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):L(this,e,t,!0),t+2};o.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):L(this,e,t,!1),t+2};o.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):O(this,e,t,!0),t+4};o.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t|0,i||d(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):O(this,e,t,!1),t+4};function pe(r,e,t,i,n,s){if(t+i>r.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function de(r,e,t,i,n){return n||pe(r,e,t,4,34028234663852886e22,-34028234663852886e22),xe(r,e,t,i,23,4),t+4}o.prototype.writeFloatLE=function(e,t,i){return de(this,e,t,!0,i)};o.prototype.writeFloatBE=function(e,t,i){return de(this,e,t,!1,i)};function ge(r,e,t,i,n){return n||pe(r,e,t,8,17976931348623157e292,-17976931348623157e292),xe(r,e,t,i,52,8),t+8}o.prototype.writeDoubleLE=function(e,t,i){return ge(this,e,t,!0,i)};o.prototype.writeDoubleBE=function(e,t,i){return ge(this,e,t,!1,i)};o.prototype.copy=function(e,t,i,n){if(i||(i=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<i&&(n=i),n===i||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(i<0||i>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-i&&(n=e.length-t+i);var s=n-i,a;if(this===e&&i<t&&t<n)for(a=s-1;a>=0;--a)e[a+t]=this[a+i];else if(s<1e3||!o.TYPED_ARRAY_SUPPORT)for(a=0;a<s;++a)e[a+t]=this[a+i];else Uint8Array.prototype.set.call(e,this.subarray(i,i+s),t);return s};o.prototype.fill=function(e,t,i,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,i=this.length):typeof i=="string"&&(n=i,i=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!o.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<i)throw new RangeError("Out of range index");if(i<=t)return this;t=t>>>0,i=i===void 0?this.length:i>>>0,e||(e=0);var a;if(typeof e=="number")for(a=t;a<i;++a)this[a]=e;else{var c=y(e)?e:N(new o(e,n).toString()),l=c.length;for(a=0;a<i-t;++a)this[a+t]=c[a%l]}return this};var xt=/[^+\/0-9A-Za-z-_]/g;function yt(r){if(r=At(r).replace(xt,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function At(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function bt(r){return r<16?"0"+r.toString(16):r.toString(16)}function N(r,e){e=e||1/0;for(var t,i=r.length,n=null,s=[],a=0;a<i;++a){if(t=r.charCodeAt(a),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(a+1===i){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function kt(r){for(var e=[],t=0;t<r.length;++t)e.push(r.charCodeAt(t)&255);return e}function It(r,e){for(var t,i,n,s=[],a=0;a<r.length&&!((e-=2)<0);++a)t=r.charCodeAt(a),i=t>>8,n=t%256,s.push(n),s.push(i);return s}function me(r){return je(yt(r))}function $(r,e,t,i){for(var n=0;n<i&&!(n+t>=e.length||n>=r.length);++n)e[n+t]=r[n];return n}function _t(r){return r!==r}function Et(r){return r!=null&&(!!r._isBuffer||we(r)||Tt(r))}function we(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Tt(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&we(r.slice(0,0))}function Y(r,e,t,i,n){var s,a,c=n*8-i-1,l=(1<<c)-1,u=l>>1,h=-7,f=t?n-1:0,w=t?-1:1,g=r[e+f];for(f+=w,s=g&(1<<-h)-1,g>>=-h,h+=c;h>0;s=s*256+r[e+f],f+=w,h-=8);for(a=s&(1<<-h)-1,s>>=-h,h+=i;h>0;a=a*256+r[e+f],f+=w,h-=8);if(s===0)s=1-u;else{if(s===l)return a?NaN:(g?-1:1)*(1/0);a=a+Math.pow(2,i),s=s-u}return(g?-1:1)*a*Math.pow(2,s-i)}function xe(r,e,t,i,n,s){var a,c,l,u=s*8-n-1,h=(1<<u)-1,f=h>>1,w=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=i?0:s-1,P=i?1:-1,_e=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+f>=1?e+=w/l:e+=w*Math.pow(2,1-f),e*l>=2&&(a++,l/=2),a+f>=h?(c=0,a=h):a+f>=1?(c=(e*l-1)*Math.pow(2,n),a=a+f):(c=e*Math.pow(2,f-1)*Math.pow(2,n),a=0));n>=8;r[t+g]=c&255,g+=P,c/=256,n-=8);for(a=a<<n|c,u+=n;u>0;r[t+g]=a&255,g+=P,a/=256,u-=8);r[t+g-P]|=_e*128}import Mt from"axios";import{DEFAULT_ORDER_EXPIRATION_DAYS as Nt,ORDER_MSG_VERSION as Lt}from"@ultrade/shared/browser/constants";import{getRandomInt as J}from"@ultrade/shared/browser/common";import{getCancelOrderDataJsonBytes as Ot,makeLoginMsg as $t,makeTradingKeyMsg as ke,makeCreateOrderMsg as Yt}from"@ultrade/shared/browser/helpers/codex.helper";import{makeWithdrawMsg as Ft}from"@ultrade/shared/browser/helpers/withdraw.helper";var U=class{constructor(e,t,i,n){this.onDisconnect=i;this.onConnectError=n;this.socket=null;this.socketPool={};this.websocketUrl=e,this.socketIOFactory=t,this.initializeSocket()}initializeSocket(){this.socket===null&&(this.socket=this.socketIOFactory(this.websocketUrl,{reconnection:!0,reconnectionDelay:1e3,reconnectionAttempts:9999,transports:["websocket"]}),this.onDisconnect&&this.socket.on("disconnect",()=>{this.onDisconnect(this.socket.id)}),this.onConnectError&&this.socket.on("connect_error",e=>{this.onConnectError(e)}))}getSocket(){return this.socket}subscribe(e,t){let i=Date.now();return this.socket===null&&this.initializeSocket(),this.socket.onAny((n,...s)=>{t(n,s)}),this.socket.io.on("reconnect",()=>{this.socket.emit("subscribe",e)}),this.socket.emit("subscribe",e),this.socketPool[i]=e,i}unsubscribe(e){let t=this.socketPool[e];t&&this.socket&&(this.socket.emit("unsubscribe",t),delete this.socketPool[e]),Object.keys(this.socketPool).length===0&&this.socket&&this.disconnect()}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null)}isConnected(){return this.socket!==null&&this.socket.connected}on(e,t){this.socket&&this.socket.on(e,t)}off(e,t){this.socket&&(t?this.socket.off(e,t):this.socket.off(e))}emit(e,...t){this.socket&&this.socket.emit(e,...t)}emitCurrentPair(e){this.emit("currentPair",e)}emitOrderFilter(e){this.emit("orderFilter",e)}onReconnect(e){return this.socket?(this.socket.io.off("reconnect"),this.socket.io.on("reconnect",e),()=>{this.socket&&this.socket.io.off("reconnect",e)}):()=>{}}offReconnect(e){this.socket&&(e?this.socket.io.off("reconnect",e):this.socket.io.off("reconnect"))}};import{decodeStateArray as St,getTxnParams as Wt}from"@ultrade/shared/browser/helpers/algo.helper";import D from"algosdk";import Ut from"axios";import ye,{encodeAddress as Ct}from"algosdk";var vt={priceCoin_locked:{type:"uint"},priceCoin_available:{type:"uint"},baseCoin_locked:{type:"uint"},baseCoin_available:{type:"uint"},companyId:{type:"uint"},WLFeeShare:{type:"uint"},WLCustomFee:{type:"uint"},slotMap:{type:"uint"}},Ae=r=>{let e=new Map,t=0;for(let[i,n]of Object.entries(vt)){if(t>=r.length)throw new Error("Array index out of bounds");let s;switch(n.type){case"address":s=Ct(r.slice(t,t+32)),t+=32;break;case"bytes":s=r.slice(t,t+n.size),s=ye.decodeUint64(s,"mixed"),t+=n.size;break;case"uint":s=ye.decodeUint64(r.slice(t,t+8),"mixed"),t+=8;break;case"string":s=Pt(r.slice(t,t+n.size)),t+=n.size;break}e.set(i,s)}return Object.fromEntries(e)},Pt=r=>o.from(r).toString("utf-8");var F=class{constructor(e,t,i){this.client=e,this.authCredentials=t,this.indexerDomain=i}isAppOptedIn(e,t){return!!e?.find(i=>i.id===t)}isAssetOptedIn(e,t){return Object.keys(e).includes(t.toString())}async optInAsset(e,t){let i=await this.getTxnParams();return D.makeAssetTransferTxnWithSuggestedParamsFromObject({suggestedParams:{...i},from:e,to:e,assetIndex:t,amount:0})}async makeAppCallTransaction(e,t,i,n,s){let a=[],c=[],l=[e];return D.makeApplicationNoOpTxn(t,s||await this.getTxnParams(),i,n,a,c,l)}makeTransferTransaction(e,t,i,n,s){if(i<=0)return null;let a={suggestedParams:{...e},from:n,to:s,amount:i};return t===0?D.makePaymentTxnWithSuggestedParamsFromObject(a):(a.assetIndex=t,D.makeAssetTransferTxnWithSuggestedParamsFromObject(a))}get signer(){return this.authCredentials.signer}set signer(e){this.authCredentials.signer=e}async signAndSend(e){Array.isArray(e)||(e=[e]);let t=this.getCurrentAccount();if(t){let i=e.map(n=>n.signTxn(t.sk));return this.client.sendRawTransaction(i).do()}return this.authCredentials.signer.signAndSend(e)}async signAndSendData(e,t,i,n){let s=typeof e=="string"?e:JSON.stringify(e),a=typeof e=="string"?{message:s}:{...e},c=await t(s,n);return i({...a,signature:c})}async getTxnParams(){return await Wt(this.client)}getCurrentAccount(){return this.authCredentials.mnemonic?D.mnemonicToSecretKey(this.authCredentials.mnemonic):null}async getAccountInfo(e){return this.client.accountInformation(e).do()}constructArgsForAppCall(...e){let t=[];return e.forEach(i=>{t.push(new Uint8Array(i.toBuffer?i.toBuffer():o.from(i.toString())))}),t}validateCredentials(){if(!this.authCredentials.mnemonic&&!this.authCredentials.signer)throw"You need specify mnemonic or signer to execute the method"}async getAppState(e){try{let t=await this.client.getApplicationByID(e).do();return St(t.params["global-state"])}catch(t){console.log(`Attempt to load app by id ${e}`),console.log(t.message)}}async getSuperAppId(e){return(await this.getAppState(e))?.UL_SUPERADMIN_APP||0}async getPairBalances(e,t){let{data:i}=await Ut.get(`${this.indexerDomain}/v2/accounts/${t}?include-all=true`);if(i.account.hasOwnProperty("apps-local-state")){let n=i.account["apps-local-state"].find(c=>c.id===e&&c.deleted===!1);if(!n)return null;let s=n["key-value"].find(c=>c.key==="YWNjb3VudEluZm8="),a=o.from(s.value.bytes,"base64");return Ae(a)}}async calculateTransferAmount(e,t,i,n,s,a){let c=await this.getPairBalances(e,t),l=(i==="B"?c?.priceCoin_available:c?.baseCoin_available)??0;i==="B"&&(n=n/10**a*s);let u=Math.ceil(n-l);return u<0?0:u}};var z=[5,8,10,11];import Dt from"react-secure-storage";var Rt=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host,be=r=>`${r}_${Rt}`,Bt=new Proxy(Dt,{get(r,e,t){return typeof e=="string"&&typeof r[e]=="function"?function(...i){return typeof e=="string"&&["setItem","getItem","removeItem"].includes(e)&&(i[0]=be(i[0])),r[e].apply(r,i)}:Reflect.get(r,e,t)}}),H=new Proxy(localStorage,{get(r,e,t){return typeof e=="string"&&typeof r[e]=="function"?function(...i){return typeof e=="string"&&["setItem","getItem","removeItem","key"].includes(e)&&(i[0]=be(i[0])),r[e].apply(r,i)}:Reflect.get(r,e,t)}}),K=class{constructor(){this.keys={mainWallet:"main-wallet",tradingKey:"trading-key"};this.isBrowser=typeof window<"u",this.isBrowser||(this.clearMainWallet=()=>{},this.getMainWallet=()=>null,this.setMainWallet=()=>{})}setMainWallet(e){H.setItem(this.keys.mainWallet,JSON.stringify(e))}getMainWallet(){let e=H.getItem(this.keys.mainWallet);if(!e)return null;let t=JSON.parse(e),i=Bt.getItem(`${this.keys.tradingKey}-${t.address}`);return i&&(i.expiredAt===0||Number(new Date(i.expiredAt))-Date.now()>1)&&(t.tradingKey=i.address),t}clearMainWallet(){H.removeItem(this.keys.mainWallet)}};import{TradingKeyType as Kt}from"@ultrade/shared/browser/interfaces";import{PROVIDERS as v}from"@ultrade/shared/browser/interfaces";import{OrderStatus as R}from"@ultrade/shared/browser/enums";import{makeDtwMsg as qt,makeTransferMsg as Vt}from"@ultrade/shared/browser/helpers/codex";var Xt="By signing this message you are logging into your trading account and agreeing to all terms and conditions of the platform.",Ie=class{constructor(e,t){this.axiosInterceptor=e=>{let t=["/market/balances","/market/order","/market/orders","/market/account/kyc/status","/market/account/kyc/init","/market/withdrawal-fee","/market/operation-details","/wallet/key","/wallet/transactions","/wallet/transfer","/wallet/withdraw","/wallet/whitelist","/wallet/withdrawal-wallets"],i=l=>l.withWalletCredentials||t.some(u=>l.url.includes(u)),n=l=>{let u=["/market/order"];return l.withWalletCredentials||u.some(h=>l.url.includes(h))},s=l=>["/wallet/signin","/market/account/kyc/init","/notifications"].some(h=>l.url.includes(h)),a=l=>["/social/"].some(h=>l.url.includes(h)),c=l=>t.some(u=>l.url.includes(u));return e.interceptors.request.use(l=>{if(this.wallet&&i(l)&&(l.headers["X-Wallet-Address"]=this.wallet.address,l.headers["X-Wallet-Token"]=this.wallet.token),this.wallet&&c(l)&&(l.headers.CompanyId=this.companyId),this.wallet&&n(l)){let u=this.wallet?.tradingKey;u&&(l.headers["X-Trading-Key"]=u)}return s(l)&&(l.headers.CompanyId=this.companyId),a(l)&&!l.headers.CompanyId&&(l.headers.CompanyId=this.isUltradeID?1:this.companyId),l},l=>Promise.reject(l)),e.interceptors.response.use(l=>l.data,async l=>(console.log("Request was failed",l),[401].includes(l?.response?.status)&&i(l.config)&&(this.wallet=null,this.localStorageService.clearMainWallet()),Promise.reject(l))),e};e.network==="mainnet"?(this.algodNode="https://mainnet-api.algonode.cloud",this.apiUrl="https://mainnet-api.algonode.cloud",this.algodIndexer="https://mainnet-idx.algonode.cloud"):e.network==="testnet"?(this.apiUrl="https://testnet-apigw.ultradedev.net",this.algodNode="https://testnet-api.algonode.cloud",this.algodIndexer="https://testnet-idx.algonode.cloud"):(this.apiUrl="http://localhost:5001",this.algodNode="http://localhost:4001",this.algodIndexer="http://localhost:8980"),e.apiUrl!==void 0&&(this.apiUrl=e.apiUrl),e.companyId!==void 0&&(this.companyId=e.companyId),this.websocketUrl=e.websocketUrl,this.client=new F(e.algoSdkClient,t||{},this.algodIndexer),this._axios=this.axiosInterceptor(Mt.create({baseURL:this.apiUrl})),this.localStorageService=new K,this.wallet=this.localStorageService.getMainWallet(),this.isUltradeID=!1,this.socketManager=new U(this.websocketUrl,e.socketIO,i=>{console.log(`Socket ${i} disconnected at`,new Date)},i=>{console.log(`Socket connect_error due to ${i}`)}),console.log("SDK Wallet",this.wallet)}get useUltradeID(){return this.isUltradeID}set useUltradeID(e){this.isUltradeID=e}get isLogged(){return!!this.wallet?.token}get mainWallet(){return this.wallet}set mainWallet(e){this.wallet=e,e?this.localStorageService.setMainWallet(e):this.localStorageService.clearMainWallet()}setSigner(e){this.client.signer=e}subscribe(e,t){let i=e.streams.some(n=>z.includes(n));return i&&!this.mainWallet?.token&&!this.mainWallet?.tradingKey?(e.streams=e.streams.filter(n=>!z.includes(n)),this.socketManager.subscribe(e,t)):i?(e.options={...e.options,token:this.mainWallet?.token,tradingKey:this.mainWallet?.tradingKey},this.socketManager.subscribe(e,t)):this.socketManager.subscribe(e,t)}unsubscribe(e){this.socketManager.unsubscribe(e)}getPairList(e){let t=e?`&companyId=${e}`:"";return this._axios.get(`/market/markets?includeAllOrders=false${t}`)}getExchangeInfo(e){return this._axios.get(`/market/market?symbol=${e}`)}getPrice(e){return this._axios.get(`/market/price?symbol=${e}`)}getDepth(e,t){return this._axios.get(`/market/depth?symbol=${e}&depth=${t}`)}getSymbols(e){return this._axios.get(`/market/symbols${e?"?mask="+e:""}`)}getLastTrades(e){return this._axios.get(`/market/last-trades?symbol=${e}`)}getHistory(e,t,i,n,s=500,a=1){return this._axios.get(`/market/history?symbol=${e}&interval=${t}&startTime=${i??""}&endTime=${n??""}&limit=${s}&page=${a}`)}getOrders(e,t,i=50,n,s){let a=t?t===1?R.Open:[R.Canceled,R.Matched,R.SelfMatched,R.Expired].join(","):"",c=e?`&symbol=${e}`:"",l=a?`&status=${a}`:"",u=s?`&startTime=${s}`:"",h=n?`&endTime=${n}`:"";return this._axios.get(`/market/orders?limit=${i}${c}${l}${u}${h}`)}getOrderById(e){return this._axios.get(`/market/order/${e}`)}getSettings(){let e=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host;return this._axios.get("/market/settings",{headers:{"wl-domain":e}})}getBalances(){return this._axios.get("/market/balances")}getChains(){return this._axios.get("/market/chains")}getCodexAssets(){return this._axios.get("/market/assets")}getCCTPAssets(){return this._axios.get("/market/cctp-assets")}getCCTPUnifiedAssets(){return this._axios.get("/market/cctp-unified-assets")}getWithdrawalFee(e,t){return this._axios.get(`/market/withdrawal-fee?assetAddress=${e}&chainId=${t}`)}getKycStatus(){return this._axios.get("/market/account/kyc/status")}getKycInitLink(e){return this._axios.post("/market/account/kyc/init",{embeddedAppUrl:e})}getDollarValues(e=[]){return this._axios.get(`/market/dollar-price?assetIds=${JSON.stringify(e)}`)}getTransactionDetalis(e){return this._axios.get(`/market/operation-details?operationId=${e}`)}getWalletTransactions(e,t,i=100){return this._axios.get(`/wallet/transactions?type=${e}&limit=${i}&page=${t}`,{withWalletCredentials:!0})}getTradingKeys(){return this._axios.get("/wallet/keys",{withWalletCredentials:!0})}getTransfers(e,t=100){return this._axios.get(`/wallet/transfers?limit=${t}&page=${e}`,{withWalletCredentials:!0})}getPendingTransactions(){return this._axios.get("/wallet/transactions/pending",{withWalletCredentials:!0})}getWhitelist(){return this._axios.get("/wallet/whitelist",{withWalletCredentials:!0})}addWhitelist(e){e={...e,expiredDate:e.expiredDate&&Math.round(e.expiredDate/1e3)};let i=o.from(qt(e)).toString("hex");return this.client.signAndSendData(i,this.client.signer.signMessage,({signature:n})=>this._axios.post("/wallet/whitelist",{message:i,signature:n}),"hex")}deleteWhitelist(e){let t={whitelistId:e};return this.client.signAndSendData(t,this.client.signer.signMessage,({signature:i})=>this._axios.delete("/wallet/whitelist",{data:{data:t,signature:i}}))}getAllWithdrawalWallets(){return this._axios.get("/wallet/withdrawal-wallets")}getWithdrawalWalletByAddress(e){return this._axios.get(`/wallet/withdrawal-wallets/${e}`)}createWithdrawalWallet(e){return this._axios.post("/wallet/withdrawal-wallets",e)}updateWithdrawalWallet(e){return this._axios.patch("/wallet/withdrawal-wallets",e)}deleteWithdrawalWallet(e){return this._axios.delete(`/wallet/withdrawal-wallets/${e}`)}getVersion(){return this._axios.get("/system/version")}getMaintenance(){return this._axios.get("/system/maintenance")}getNotifications(){return this._axios.get("/notifications",{withWalletCredentials:!0})}getNotificationsUnreadCount(){return this._axios.get("/notifications/count",{withWalletCredentials:!0})}readNotifications(e){return this._axios.put("/notifications",{notifications:e},{withWalletCredentials:!0})}getAffiliatesStatus(e){return this._axios.get(`/affiliates/${e}/dashboardStatus`,{withWalletCredentials:!0})}createAffiliate(e){return this._axios.post(`/affiliates/${e}`,{},{withWalletCredentials:!0})}getAffiliateProgress(e){return this._axios.get(`/affiliates/${e}/tradingVolumeProgress`,{withWalletCredentials:!0})}getAffiliateInfo(e,t){return this._axios.get(`/affiliates/${e}/dashboard?range=${t}`,{withWalletCredentials:!0})}countAffiliateDepost(e){return this._axios.post(`/affiliates/${e}/deposit `,{},{withWalletCredentials:!0})}countAffiliateClick(e){return this._axios.post("/affiliates/click",{referralToken:e},{withWalletCredentials:!0})}getSocialAccount(){return this._axios.get("/social/account",{withWalletCredentials:!0})}addSocialEmail(e,t){return this._axios.put("/social/account/email",{email:e,embeddedAppUrl:t},{withWalletCredentials:!0})}verifySocialEmail(e,t){return this._axios.put("/social/account/verifyEmail",{email:e,hash:t},{withWalletCredentials:!0})}getLeaderboards(){return this._axios.get("/social/leaderboard",{withWalletCredentials:!0})}getUnlocks(){return this._axios.get("/social/unlocks",{withWalletCredentials:!0})}getSocialSettings(){return this._axios.get("/social/settings",{withWalletCredentials:!0})}getSeason(e){return this._axios.get("/social/seasons/active",{withWalletCredentials:!0,headers:{CompanyId:e}})}getPastSeasons(){return this._axios.get("/social/seasons/history",{withWalletCredentials:!0})}addTelegram(e){return this._axios.post("/social/telegram/connect",e,{withWalletCredentials:!0})}disconnectTelegram(e){return this._axios.put("/social/telegram/disconnect",e,{withWalletCredentials:!0})}getDiscordConnectionUrl(e){let t=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"";return this._axios.get(`/social/discord/connect${t}`,{withWalletCredentials:!0}).then(({url:i})=>i)}disconnectDiscord(){return this._axios.put("/social/discord/disconnect",{},{withWalletCredentials:!0})}getTwitterConnectionUrl(e,t){let i=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"",n=t?`&scopes=${t}`:"";return this._axios.get(`/social/twitter/connect${i}${n}`,{withWalletCredentials:!0}).then(({url:s})=>s)}disconnectTwitter(){return this._axios.put("/social/twitter/disconnect",{},{withWalletCredentials:!0})}getTweets(){return this._axios.get("/social/twitter/tweets",{withWalletCredentials:!0})}actionWithTweet(e){return this._axios.post("/social/twitter/tweet/actions",e,{withWalletCredentials:!0})}async getActions(){return this._axios.get("/social/actions",{withWalletCredentials:!0})}async getActionHistory(){return this._axios.get("/social/actions/history",{withWalletCredentials:!0})}getAIStyles(){return this._axios.get("/social/twitter/tweets/styles",{withWalletCredentials:!0})}getAIComment(e,t){return this._axios.get(`/social/twitter/tweets/${t}/generateComment?styleId=${e}`,{withWalletCredentials:!0})}getTechnologyByProvider(e){switch(e){case v.PERA:return"ALGORAND";case v.METAMASK:return"EVM";case v.SOLFLARE:case v.COINBASE:case v.PHANTOM:case v.BACKPACK:case v.MOBILE:return"SOLANA";default:throw new Error("Not implemented")}}login({address:e,provider:t,chain:i,referralToken:n,loginMessage:s}){let c=s||Xt,l={address:e,technology:this.getTechnologyByProvider(t)},u=o.from($t(l,c)).toString("hex");return this.client.signAndSendData(u,this.client.signer.signMessage,({signature:h})=>this._axios.put("/wallet/signin",{data:l,message:u,encoding:"hex",signature:h,referralToken:n}).then(f=>(this.mainWallet={address:e,provider:t,token:f,chain:i},f)),"hex")}addTradingKey(e){let i=o.from(ke(e,!0)).toString("hex"),{device:n,type:s}=e;return this.client.signAndSendData(i,this.client.signer.signMessage,({signature:a})=>this._axios.post("/wallet/key",{data:{device:n,type:s},encoding:"hex",message:i,signature:a}).then(c=>(this.mainWallet&&c.type===Kt.User&&(this.mainWallet.tradingKey=c.address),c)),"hex")}revokeTradingKey(e){let i=o.from(ke(e,!1)).toString("hex"),{device:n,type:s}=e;return this.client.signAndSendData(i,this.client.signer.signMessage,({signature:a})=>this._axios.delete("/wallet/key",{data:{data:{device:n,type:s},encoding:"hex",message:i,signature:a}}).then(()=>{this.mainWallet&&e.tkAddress===this.mainWallet.tradingKey&&(this.mainWallet.tradingKey=void 0)}),"hex")}withdraw(e,t){let n={...e,random:J(1,Number.MAX_SAFE_INTEGER)},s=o.from(Ft(n,t)).toString("hex");return this.client.signAndSendData(s,this.client.signer.signMessage,({signature:a})=>this._axios.post("/wallet/withdraw",{encoding:"hex",message:s,signature:a,destinationAddress:n.recipient}),"hex")}transfer(e){let i={...e,random:J(1,Number.MAX_SAFE_INTEGER)},n=o.from(Vt(i)).toString("hex");return this.client.signAndSendData(n,this.client.signer.signMessage,({signature:s})=>this._axios.post("/wallet/transfer",{message:n,signature:s}),"hex")}async createOrder(e){let t=Nt*24*60*60,i=Math.floor(Date.now()/1e3)+t,n={...e,version:Lt,expiredTime:i,random:J(1,Number.MAX_SAFE_INTEGER)};console.log("CreateOrderData",n);let s="hex",a=o.from(Yt(n)).toString(s);return await this.client.signAndSendData(a,this.client.signer.signMessageByToken,({signature:c})=>this._axios.post("/market/order",{encoding:s,message:a,signature:c}),s)}async cancelOrder(e){let t={orderId:e.orderId},i="hex",n=o.from(Ot(e)).toString(i);return this.client.signAndSendData(n,this.client.signer.signMessageByToken,({signature:s})=>this._axios.delete("/market/order",{data:{data:t,message:n,signature:s}}),i)}async cancelMultipleOrders({orderIds:e,pairId:t}){let i={orderIds:e,pairId:t};return this.client.signAndSendData(i,this.client.signer.signMessageByToken,({signature:n})=>this._axios.delete("/market/orders",{data:{data:i,signature:n}}))}async ping(){let e=this._axios.get("/system/time");return Math.round(Date.now()-e.currentTime)}};export{Ie as Client,U as SocketManager};
1
+ function re(){throw new Error("setTimeout has not been defined")}function ie(){throw new Error("clearTimeout has not been defined")}var P=re,R=ie;typeof globalThis.setTimeout=="function"&&(P=setTimeout);typeof globalThis.clearTimeout=="function"&&(R=clearTimeout);function ne(i){if(P===setTimeout)return setTimeout(i,0);if((P===re||!P)&&setTimeout)return P=setTimeout,setTimeout(i,0);try{return P(i,0)}catch{try{return P.call(null,i,0)}catch{return P.call(this,i,0)}}}function De(i){if(R===clearTimeout)return clearTimeout(i);if((R===ie||!R)&&clearTimeout)return R=clearTimeout,clearTimeout(i);try{return R(i)}catch{try{return R.call(null,i)}catch{return R.call(this,i)}}}var y=[],v=!1,k,C=-1;function Me(){!v||!k||(v=!1,k.length?y=k.concat(y):C=-1,y.length&&ae())}function ae(){if(!v){var i=ne(Me);v=!0;for(var e=y.length;e;){for(k=y,y=[];++C<e;)k&&k[C].run();C=-1,e=y.length}k=null,v=!1,De(i)}}function We(i){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];y.push(new se(i,e)),y.length===1&&!v&&ne(ae)}function se(i,e){this.fun=i,this.array=e}se.prototype.run=function(){this.fun.apply(null,this.array)};var Ne="browser",ve="browser",Ue=!0,Fe={},Oe=[],Ge="",Ce={},Le={},Ve={};function S(){}var Ye=S,$e=S,Xe=S,Be=S,qe=S,Ze=S,ze=S;function Qe(i){throw new Error("process.binding is not supported")}function Je(){return"/"}function je(i){throw new Error("process.chdir is not supported")}function Ke(){return 0}var N=globalThis.performance||{},He=N.now||N.mozNow||N.msNow||N.oNow||N.webkitNow||function(){return new Date().getTime()};function et(i){var e=He.call(N)*.001,t=Math.floor(e),r=Math.floor(e%1*1e9);return i&&(t=t-i[0],r=r-i[1],r<0&&(t--,r+=1e9)),[t,r]}var tt=new Date;function rt(){var i=new Date,e=i-tt;return e/1e3}var g={nextTick:We,title:Ne,browser:Ue,env:Fe,argv:Oe,version:Ge,versions:Ce,on:Ye,addListener:$e,once:Xe,off:Be,removeListener:qe,removeAllListeners:Ze,emit:ze,binding:Qe,cwd:Je,chdir:je,umask:Ke,hrtime:et,platform:ve,release:Le,config:Ve,uptime:rt},te={};Object.keys(te).forEach(i=>{let e=i.split("."),t=g;for(let r=0;r<e.length;r++){let n=e[r];r===e.length-1?t[n]=te[i]:t=t[n]||(t[n]={})}});var _=[],A=[],it=typeof Uint8Array<"u"?Uint8Array:Array,z=!1;function ue(){z=!0;for(var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=i.length;e<t;++e)_[e]=i[e],A[i.charCodeAt(e)]=e;A[45]=62,A[95]=63}function nt(i){z||ue();var e,t,r,n,s,o,c=i.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s=i[c-2]==="="?2:i[c-1]==="="?1:0,o=new it(c*3/4-s),r=s>0?c-4:c;var u=0;for(e=0,t=0;e<r;e+=4,t+=3)n=A[i.charCodeAt(e)]<<18|A[i.charCodeAt(e+1)]<<12|A[i.charCodeAt(e+2)]<<6|A[i.charCodeAt(e+3)],o[u++]=n>>16&255,o[u++]=n>>8&255,o[u++]=n&255;return s===2?(n=A[i.charCodeAt(e)]<<2|A[i.charCodeAt(e+1)]>>4,o[u++]=n&255):s===1&&(n=A[i.charCodeAt(e)]<<10|A[i.charCodeAt(e+1)]<<4|A[i.charCodeAt(e+2)]>>2,o[u++]=n>>8&255,o[u++]=n&255),o}function at(i){return _[i>>18&63]+_[i>>12&63]+_[i>>6&63]+_[i&63]}function st(i,e,t){for(var r,n=[],s=e;s<t;s+=3)r=(i[s]<<16)+(i[s+1]<<8)+i[s+2],n.push(at(r));return n.join("")}function oe(i){z||ue();for(var e,t=i.length,r=t%3,n="",s=[],o=16383,c=0,u=t-r;c<u;c+=o)s.push(st(i,c,c+o>u?u:c+o));return r===1?(e=i[t-1],n+=_[e>>2],n+=_[e<<4&63],n+="=="):r===2&&(e=(i[t-2]<<8)+i[t-1],n+=_[e>>10],n+=_[e>>4&63],n+=_[e<<2&63],n+="="),s.push(n),s.join("")}l.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;function L(){return l.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function w(i,e){if(L()<e)throw new RangeError("Invalid typed array length");return l.TYPED_ARRAY_SUPPORT?(i=new Uint8Array(e),i.__proto__=l.prototype):(i===null&&(i=new l(e)),i.length=e),i}function l(i,e,t){if(!l.TYPED_ARRAY_SUPPORT&&!(this instanceof l))return new l(i,e,t);if(typeof i=="number"){if(typeof e=="string")throw new Error("If encoding is specified then the first argument must be a string");return Q(this,i)}return de(this,i,e,t)}l.poolSize=8192;l._augment=function(i){return i.__proto__=l.prototype,i};function de(i,e,t,r){if(typeof e=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer?ct(i,e,t,r):typeof e=="string"?lt(i,e,t):ut(i,e)}l.from=function(i,e,t){return de(null,i,e,t)};l.kMaxLength=L();l.TYPED_ARRAY_SUPPORT&&(l.prototype.__proto__=Uint8Array.prototype,l.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&l[Symbol.species]);function me(i){if(typeof i!="number")throw new TypeError('"size" argument must be a number');if(i<0)throw new RangeError('"size" argument must not be negative')}function ot(i,e,t,r){return me(e),e<=0?w(i,e):t!==void 0?typeof r=="string"?w(i,e).fill(t,r):w(i,e).fill(t):w(i,e)}l.alloc=function(i,e,t){return ot(null,i,e,t)};function Q(i,e){if(me(e),i=w(i,e<0?0:J(e)|0),!l.TYPED_ARRAY_SUPPORT)for(var t=0;t<e;++t)i[t]=0;return i}l.allocUnsafe=function(i){return Q(null,i)};l.allocUnsafeSlow=function(i){return Q(null,i)};function lt(i,e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!l.isEncoding(t))throw new TypeError('"encoding" must be a valid string encoding');var r=ge(e,t)|0;i=w(i,r);var n=i.write(e,t);return n!==r&&(i=i.slice(0,n)),i}function Z(i,e){var t=e.length<0?0:J(e.length)|0;i=w(i,t);for(var r=0;r<t;r+=1)i[r]=e[r]&255;return i}function ct(i,e,t,r){if(e.byteLength,t<0||e.byteLength<t)throw new RangeError("'offset' is out of bounds");if(e.byteLength<t+(r||0))throw new RangeError("'length' is out of bounds");return t===void 0&&r===void 0?e=new Uint8Array(e):r===void 0?e=new Uint8Array(e,t):e=new Uint8Array(e,t,r),l.TYPED_ARRAY_SUPPORT?(i=e,i.__proto__=l.prototype):i=Z(i,e),i}function ut(i,e){if(b(e)){var t=J(e.length)|0;return i=w(i,t),i.length===0||e.copy(i,0,0,t),i}if(e){if(typeof ArrayBuffer<"u"&&e.buffer instanceof ArrayBuffer||"length"in e)return typeof e.length!="number"||St(e.length)?w(i,0):Z(i,e);if(e.type==="Buffer"&&Array.isArray(e.data))return Z(i,e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function J(i){if(i>=L())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+L().toString(16)+" bytes");return i|0}l.isBuffer=Dt;function b(i){return!!(i!=null&&i._isBuffer)}l.compare=function(e,t){if(!b(e)||!b(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,s=0,o=Math.min(r,n);s<o;++s)if(e[s]!==t[s]){r=e[s],n=t[s];break}return r<n?-1:n<r?1:0};l.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};l.concat=function(e,t){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return l.alloc(0);var r;if(t===void 0)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=l.allocUnsafe(t),s=0;for(r=0;r<e.length;++r){var o=e[r];if(!b(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,s),s+=o.length}return n};function ge(i,e){if(b(i))return i.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(i)||i instanceof ArrayBuffer))return i.byteLength;typeof i!="string"&&(i=""+i);var t=i.length;if(t===0)return 0;for(var r=!1;;)switch(e){case"ascii":case"latin1":case"binary":return t;case"utf8":case"utf-8":case void 0:return V(i).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t*2;case"hex":return t>>>1;case"base64":return Ae(i).length;default:if(r)return V(i).length;e=(""+e).toLowerCase(),r=!0}}l.byteLength=ge;function dt(i,e,t){var r=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(i||(i="utf8");;)switch(i){case"hex":return xt(this,e,t);case"utf8":case"utf-8":return he(this,e,t);case"ascii":return It(this,e,t);case"latin1":case"binary":return At(this,e,t);case"base64":return Tt(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _t(this,e,t);default:if(r)throw new TypeError("Unknown encoding: "+i);i=(i+"").toLowerCase(),r=!0}}l.prototype._isBuffer=!0;function D(i,e,t){var r=i[e];i[e]=i[t],i[t]=r}l.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)D(this,t,t+1);return this};l.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)D(this,t,t+3),D(this,t+1,t+2);return this};l.prototype.swap64=function(){var e=this.length;if(e%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)D(this,t,t+7),D(this,t+1,t+6),D(this,t+2,t+5),D(this,t+3,t+4);return this};l.prototype.toString=function(){var e=this.length|0;return e===0?"":arguments.length===0?he(this,0,e):dt.apply(this,arguments)};l.prototype.equals=function(e){if(!b(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:l.compare(this,e)===0};l.prototype.compare=function(e,t,r,n,s){if(!b(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),r===void 0&&(r=e?e.length:0),n===void 0&&(n=0),s===void 0&&(s=this.length),t<0||r>e.length||n<0||s>this.length)throw new RangeError("out of range index");if(n>=s&&t>=r)return 0;if(n>=s)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,s>>>=0,this===e)return 0;for(var o=s-n,c=r-t,u=Math.min(o,c),d=this.slice(n,s),m=e.slice(t,r),p=0;p<u;++p)if(d[p]!==m[p]){o=d[p],c=m[p];break}return o<c?-1:c<o?1:0};function pe(i,e,t,r,n){if(i.length===0)return-1;if(typeof t=="string"?(r=t,t=0):t>2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=n?0:i.length-1),t<0&&(t=i.length+t),t>=i.length){if(n)return-1;t=i.length-1}else if(t<0)if(n)t=0;else return-1;if(typeof e=="string"&&(e=l.from(e,r)),b(e))return e.length===0?-1:le(i,e,t,r,n);if(typeof e=="number")return e=e&255,l.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?n?Uint8Array.prototype.indexOf.call(i,e,t):Uint8Array.prototype.lastIndexOf.call(i,e,t):le(i,[e],t,r,n);throw new TypeError("val must be string, number or Buffer")}function le(i,e,t,r,n){var s=1,o=i.length,c=e.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(i.length<2||e.length<2)return-1;s=2,o/=2,c/=2,t/=2}function u(I,W){return s===1?I[W]:I.readUInt16BE(W*s)}var d;if(n){var m=-1;for(d=t;d<o;d++)if(u(i,d)===u(e,m===-1?0:d-m)){if(m===-1&&(m=d),d-m+1===c)return m*s}else m!==-1&&(d-=d-m),m=-1}else for(t+c>o&&(t=o-c),d=t;d>=0;d--){for(var p=!0,x=0;x<c;x++)if(u(i,d+x)!==u(e,x)){p=!1;break}if(p)return d}return-1}l.prototype.includes=function(e,t,r){return this.indexOf(e,t,r)!==-1};l.prototype.indexOf=function(e,t,r){return pe(this,e,t,r,!0)};l.prototype.lastIndexOf=function(e,t,r){return pe(this,e,t,r,!1)};function mt(i,e,t,r){t=Number(t)||0;var n=i.length-t;r?(r=Number(r),r>n&&(r=n)):r=n;var s=e.length;if(s%2!==0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var c=parseInt(e.substr(o*2,2),16);if(isNaN(c))return o;i[t+o]=c}return o}function gt(i,e,t,r){return X(V(e,i.length-t),i,t,r)}function fe(i,e,t,r){return X(Rt(e),i,t,r)}function pt(i,e,t,r){return fe(i,e,t,r)}function ft(i,e,t,r){return X(Ae(e),i,t,r)}function ht(i,e,t,r){return X(kt(e,i.length-t),i,t,r)}l.prototype.write=function(e,t,r,n){if(t===void 0)n="utf8",r=this.length,t=0;else if(r===void 0&&typeof t=="string")n=t,r=this.length,t=0;else if(isFinite(t))t=t|0,isFinite(r)?(r=r|0,n===void 0&&(n="utf8")):(n=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s=this.length-t;if((r===void 0||r>s)&&(r=s),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return mt(this,e,t,r);case"utf8":case"utf-8":return gt(this,e,t,r);case"ascii":return fe(this,e,t,r);case"latin1":case"binary":return pt(this,e,t,r);case"base64":return ft(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ht(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}};l.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Tt(i,e,t){return e===0&&t===i.length?oe(i):oe(i.slice(e,t))}function he(i,e,t){t=Math.min(i.length,t);for(var r=[],n=e;n<t;){var s=i[n],o=null,c=s>239?4:s>223?3:s>191?2:1;if(n+c<=t){var u,d,m,p;switch(c){case 1:s<128&&(o=s);break;case 2:u=i[n+1],(u&192)===128&&(p=(s&31)<<6|u&63,p>127&&(o=p));break;case 3:u=i[n+1],d=i[n+2],(u&192)===128&&(d&192)===128&&(p=(s&15)<<12|(u&63)<<6|d&63,p>2047&&(p<55296||p>57343)&&(o=p));break;case 4:u=i[n+1],d=i[n+2],m=i[n+3],(u&192)===128&&(d&192)===128&&(m&192)===128&&(p=(s&15)<<18|(u&63)<<12|(d&63)<<6|m&63,p>65535&&p<1114112&&(o=p))}}o===null?(o=65533,c=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|o&1023),r.push(o),n+=c}return Et(r)}var ce=4096;function Et(i){var e=i.length;if(e<=ce)return String.fromCharCode.apply(String,i);for(var t="",r=0;r<e;)t+=String.fromCharCode.apply(String,i.slice(r,r+=ce));return t}function It(i,e,t){var r="";t=Math.min(i.length,t);for(var n=e;n<t;++n)r+=String.fromCharCode(i[n]&127);return r}function At(i,e,t){var r="";t=Math.min(i.length,t);for(var n=e;n<t;++n)r+=String.fromCharCode(i[n]);return r}function xt(i,e,t){var r=i.length;(!e||e<0)&&(e=0),(!t||t<0||t>r)&&(t=r);for(var n="",s=e;s<t;++s)n+=Pt(i[s]);return n}function _t(i,e,t){for(var r=i.slice(e,t),n="",s=0;s<r.length;s+=2)n+=String.fromCharCode(r[s]+r[s+1]*256);return n}l.prototype.slice=function(e,t){var r=this.length;e=~~e,t=t===void 0?r:~~t,e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),t<e&&(t=e);var n;if(l.TYPED_ARRAY_SUPPORT)n=this.subarray(e,t),n.__proto__=l.prototype;else{var s=t-e;n=new l(s,void 0);for(var o=0;o<s;++o)n[o]=this[o+e]}return n};function T(i,e,t){if(i%1!==0||i<0)throw new RangeError("offset is not uint");if(i+e>t)throw new RangeError("Trying to access beyond buffer length")}l.prototype.readUIntLE=function(e,t,r){e=e|0,t=t|0,r||T(e,t,this.length);for(var n=this[e],s=1,o=0;++o<t&&(s*=256);)n+=this[e+o]*s;return n};l.prototype.readUIntBE=function(e,t,r){e=e|0,t=t|0,r||T(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n};l.prototype.readUInt8=function(e,t){return t||T(e,1,this.length),this[e]};l.prototype.readUInt16LE=function(e,t){return t||T(e,2,this.length),this[e]|this[e+1]<<8};l.prototype.readUInt16BE=function(e,t){return t||T(e,2,this.length),this[e]<<8|this[e+1]};l.prototype.readUInt32LE=function(e,t){return t||T(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};l.prototype.readUInt32BE=function(e,t){return t||T(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};l.prototype.readIntLE=function(e,t,r){e=e|0,t=t|0,r||T(e,t,this.length);for(var n=this[e],s=1,o=0;++o<t&&(s*=256);)n+=this[e+o]*s;return s*=128,n>=s&&(n-=Math.pow(2,8*t)),n};l.prototype.readIntBE=function(e,t,r){e=e|0,t=t|0,r||T(e,t,this.length);for(var n=t,s=1,o=this[e+--n];n>0&&(s*=256);)o+=this[e+--n]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*t)),o};l.prototype.readInt8=function(e,t){return t||T(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};l.prototype.readInt16LE=function(e,t){t||T(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};l.prototype.readInt16BE=function(e,t){t||T(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};l.prototype.readInt32LE=function(e,t){return t||T(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};l.prototype.readInt32BE=function(e,t){return t||T(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};l.prototype.readFloatLE=function(e,t){return t||T(e,4,this.length),B(this,e,!0,23,4)};l.prototype.readFloatBE=function(e,t){return t||T(e,4,this.length),B(this,e,!1,23,4)};l.prototype.readDoubleLE=function(e,t){return t||T(e,8,this.length),B(this,e,!0,52,8)};l.prototype.readDoubleBE=function(e,t){return t||T(e,8,this.length),B(this,e,!1,52,8)};function E(i,e,t,r,n,s){if(!b(i))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>n||e<s)throw new RangeError('"value" argument is out of bounds');if(t+r>i.length)throw new RangeError("Index out of range")}l.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t=t|0,r=r|0,!n){var s=Math.pow(2,8*r)-1;E(this,e,t,r,s,0)}var o=1,c=0;for(this[t]=e&255;++c<r&&(o*=256);)this[t+c]=e/o&255;return t+r};l.prototype.writeUIntBE=function(e,t,r,n){if(e=+e,t=t|0,r=r|0,!n){var s=Math.pow(2,8*r)-1;E(this,e,t,r,s,0)}var o=r-1,c=1;for(this[t+o]=e&255;--o>=0&&(c*=256);)this[t+o]=e/c&255;return t+r};l.prototype.writeUInt8=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,1,255,0),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function Y(i,e,t,r){e<0&&(e=65535+e+1);for(var n=0,s=Math.min(i.length-t,2);n<s;++n)i[t+n]=(e&255<<8*(r?n:1-n))>>>(r?n:1-n)*8}l.prototype.writeUInt16LE=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Y(this,e,t,!0),t+2};l.prototype.writeUInt16BE=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,2,65535,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Y(this,e,t,!1),t+2};function $(i,e,t,r){e<0&&(e=4294967295+e+1);for(var n=0,s=Math.min(i.length-t,4);n<s;++n)i[t+n]=e>>>(r?n:3-n)*8&255}l.prototype.writeUInt32LE=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):$(this,e,t,!0),t+4};l.prototype.writeUInt32BE=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,4,4294967295,0),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):$(this,e,t,!1),t+4};l.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*r-1);E(this,e,t,r,s-1,-s)}var o=0,c=1,u=0;for(this[t]=e&255;++o<r&&(c*=256);)e<0&&u===0&&this[t+o-1]!==0&&(u=1),this[t+o]=(e/c>>0)-u&255;return t+r};l.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t=t|0,!n){var s=Math.pow(2,8*r-1);E(this,e,t,r,s-1,-s)}var o=r-1,c=1,u=0;for(this[t+o]=e&255;--o>=0&&(c*=256);)e<0&&u===0&&this[t+o+1]!==0&&(u=1),this[t+o]=(e/c>>0)-u&255;return t+r};l.prototype.writeInt8=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,1,127,-128),l.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};l.prototype.writeInt16LE=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Y(this,e,t,!0),t+2};l.prototype.writeInt16BE=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,2,32767,-32768),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Y(this,e,t,!1),t+2};l.prototype.writeInt32LE=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,4,2147483647,-2147483648),l.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):$(this,e,t,!0),t+4};l.prototype.writeInt32BE=function(e,t,r){return e=+e,t=t|0,r||E(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),l.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):$(this,e,t,!1),t+4};function Te(i,e,t,r,n,s){if(t+r>i.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function Ee(i,e,t,r,n){return n||Te(i,e,t,4,34028234663852886e22,-34028234663852886e22),_e(i,e,t,r,23,4),t+4}l.prototype.writeFloatLE=function(e,t,r){return Ee(this,e,t,!0,r)};l.prototype.writeFloatBE=function(e,t,r){return Ee(this,e,t,!1,r)};function Ie(i,e,t,r,n){return n||Te(i,e,t,8,17976931348623157e292,-17976931348623157e292),_e(i,e,t,r,52,8),t+8}l.prototype.writeDoubleLE=function(e,t,r){return Ie(this,e,t,!0,r)};l.prototype.writeDoubleBE=function(e,t,r){return Ie(this,e,t,!1,r)};l.prototype.copy=function(e,t,r,n){if(r||(r=0),!n&&n!==0&&(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||e.length===0||this.length===0)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var s=n-r,o;if(this===e&&r<t&&t<n)for(o=s-1;o>=0;--o)e[o+t]=this[o+r];else if(s<1e3||!l.TYPED_ARRAY_SUPPORT)for(o=0;o<s;++o)e[o+t]=this[o+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s};l.prototype.fill=function(e,t,r,n){if(typeof e=="string"){if(typeof t=="string"?(n=t,t=0,r=this.length):typeof r=="string"&&(n=r,r=this.length),e.length===1){var s=e.charCodeAt(0);s<256&&(e=s)}if(n!==void 0&&typeof n!="string")throw new TypeError("encoding must be a string");if(typeof n=="string"&&!l.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else typeof e=="number"&&(e=e&255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;t=t>>>0,r=r===void 0?this.length:r>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o<r;++o)this[o]=e;else{var c=b(e)?e:V(new l(e,n).toString()),u=c.length;for(o=0;o<r-t;++o)this[o+t]=c[o%u]}return this};var bt=/[^+\/0-9A-Za-z-_]/g;function yt(i){if(i=wt(i).replace(bt,""),i.length<2)return"";for(;i.length%4!==0;)i=i+"=";return i}function wt(i){return i.trim?i.trim():i.replace(/^\s+|\s+$/g,"")}function Pt(i){return i<16?"0"+i.toString(16):i.toString(16)}function V(i,e){e=e||1/0;for(var t,r=i.length,n=null,s=[],o=0;o<r;++o){if(t=i.charCodeAt(o),t>55295&&t<57344){if(!n){if(t>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}n=t;continue}if(t<56320){(e-=3)>-1&&s.push(239,191,189),n=t;continue}t=(n-55296<<10|t-56320)+65536}else n&&(e-=3)>-1&&s.push(239,191,189);if(n=null,t<128){if((e-=1)<0)break;s.push(t)}else if(t<2048){if((e-=2)<0)break;s.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;s.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;s.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return s}function Rt(i){for(var e=[],t=0;t<i.length;++t)e.push(i.charCodeAt(t)&255);return e}function kt(i,e){for(var t,r,n,s=[],o=0;o<i.length&&!((e-=2)<0);++o)t=i.charCodeAt(o),r=t>>8,n=t%256,s.push(n),s.push(r);return s}function Ae(i){return nt(yt(i))}function X(i,e,t,r){for(var n=0;n<r&&!(n+t>=e.length||n>=i.length);++n)e[n+t]=i[n];return n}function St(i){return i!==i}function Dt(i){return i!=null&&(!!i._isBuffer||xe(i)||Mt(i))}function xe(i){return!!i.constructor&&typeof i.constructor.isBuffer=="function"&&i.constructor.isBuffer(i)}function Mt(i){return typeof i.readFloatLE=="function"&&typeof i.slice=="function"&&xe(i.slice(0,0))}function B(i,e,t,r,n){var s,o,c=n*8-r-1,u=(1<<c)-1,d=u>>1,m=-7,p=t?n-1:0,x=t?-1:1,I=i[e+p];for(p+=x,s=I&(1<<-m)-1,I>>=-m,m+=c;m>0;s=s*256+i[e+p],p+=x,m-=8);for(o=s&(1<<-m)-1,s>>=-m,m+=r;m>0;o=o*256+i[e+p],p+=x,m-=8);if(s===0)s=1-d;else{if(s===u)return o?NaN:(I?-1:1)*(1/0);o=o+Math.pow(2,r),s=s-d}return(I?-1:1)*o*Math.pow(2,s-r)}function _e(i,e,t,r,n,s){var o,c,u,d=s*8-n-1,m=(1<<d)-1,p=m>>1,x=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=r?0:s-1,W=r?1:-1,h=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,o=m):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),o+p>=1?e+=x/u:e+=x*Math.pow(2,1-p),e*u>=2&&(o++,u/=2),o+p>=m?(c=0,o=m):o+p>=1?(c=(e*u-1)*Math.pow(2,n),o=o+p):(c=e*Math.pow(2,p-1)*Math.pow(2,n),o=0));n>=8;i[t+I]=c&255,I+=W,c/=256,n-=8);for(o=o<<n|c,d+=n;d>0;i[t+I]=o&255,I+=W,o/=256,d-=8);i[t+I-W]|=h*128}import rr from"axios";import{DEFAULT_ORDER_EXPIRATION_DAYS as ir,ORDER_MSG_VERSION as nr}from"@ultrade/shared/browser/constants";import{getRandomInt as ee}from"@ultrade/shared/browser/common";import{getCancelOrderDataJsonBytes as ar,makeLoginMsg as sr,makeTradingKeyMsg as ke,makeCreateOrderMsg as or}from"@ultrade/shared/browser/helpers/codex.helper";import{makeWithdrawMsg as lr}from"@ultrade/shared/browser/helpers/withdraw.helper";import{TradingKeyType as cr}from"@ultrade/shared/browser/interfaces";import{PROVIDERS as M}from"@ultrade/shared/browser/interfaces";import{OrderStatus as G}from"@ultrade/shared/browser/enums";import{makeDtwMsg as ur,makeTransferMsg as dr}from"@ultrade/shared/browser/helpers/codex";var U=class{constructor(e,t,r,n){this.onDisconnect=r;this.onConnectError=n;this.socket=null;this.socketPool={};this.websocketUrl=e,this.socketIOFactory=t,this.initializeSocket()}initializeSocket(){this.socket===null&&(this.socket=this.socketIOFactory(this.websocketUrl,{reconnection:!0,reconnectionDelay:1e3,reconnectionAttempts:9999,transports:["websocket"]}),this.onDisconnect&&this.socket.on("disconnect",()=>{this.onDisconnect(this.socket.id)}),this.onConnectError&&this.socket.on("connect_error",e=>{this.onConnectError(e)}))}getSocket(){return this.socket}subscribe(e,t){let r=Date.now();return this.socket===null&&this.initializeSocket(),this.socket.onAny((n,...s)=>{t(n,s)}),this.socket.io.on("reconnect",()=>{this.socket.emit("subscribe",e)}),this.socket.emit("subscribe",e),this.socketPool[r]=e,r}unsubscribe(e){let t=this.socketPool[e];t&&this.socket&&(this.socket.emit("unsubscribe",t),delete this.socketPool[e]),Object.keys(this.socketPool).length===0&&this.socket&&this.disconnect()}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null)}isConnected(){return this.socket!==null&&this.socket.connected}on(e,t){this.socket&&this.socket.on(e,t)}off(e,t){this.socket&&(t?this.socket.off(e,t):this.socket.off(e))}emit(e,...t){this.socket&&this.socket.emit(e,...t)}emitCurrentPair(e){this.emit("currentPair",e)}emitOrderFilter(e){this.emit("orderFilter",e)}onReconnect(e){return this.socket?(this.socket.io.off("reconnect"),this.socket.io.on("reconnect",e),()=>{this.socket&&this.socket.io.off("reconnect",e)}):()=>{}}offReconnect(e){this.socket&&(e?this.socket.io.off("reconnect",e):this.socket.io.off("reconnect"))}};import Wt from"react-secure-storage";var Nt=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host,be=i=>`${i}_${Nt}`,vt=new Proxy(Wt,{get(i,e,t){return typeof e=="string"&&typeof i[e]=="function"?function(...r){return typeof e=="string"&&["setItem","getItem","removeItem"].includes(e)&&(r[0]=be(r[0])),i[e].apply(i,r)}:Reflect.get(i,e,t)}}),j=new Proxy(localStorage,{get(i,e,t){return typeof e=="string"&&typeof i[e]=="function"?function(...r){return typeof e=="string"&&["setItem","getItem","removeItem","key"].includes(e)&&(r[0]=be(r[0])),i[e].apply(i,r)}:Reflect.get(i,e,t)}}),q=class{constructor(){this.keys={mainWallet:"main-wallet",tradingKey:"trading-key"};this.isBrowser=typeof window<"u",this.isBrowser||(this.clearMainWallet=()=>{},this.getMainWallet=()=>null,this.setMainWallet=()=>{})}setMainWallet(e){j.setItem(this.keys.mainWallet,JSON.stringify(e))}getMainWallet(){let e=j.getItem(this.keys.mainWallet);if(!e)return null;let t=JSON.parse(e),r=vt.getItem(`${this.keys.tradingKey}-${t.address}`);return r&&(r.expiredAt===0||Number(new Date(r.expiredAt))-Date.now()>1)&&(t.tradingKey=r.address),t}clearMainWallet(){j.removeItem(this.keys.mainWallet)}};var Ut=(t=>(t.YES="Y",t.NO="N",t))(Ut||{}),Ft=(d=>(d.MFT_AUDIO_LINK="mft.audioLink",d.MFT_TITLE="mft.title",d.VIEW_BASE_COIN_ICON_LINK="view.baseCoinIconLink",d.VIEW_BASE_COIN_MARKET_LINK="view.baseCoinMarketLink",d.VIEW_PRICE_COIN_ICON_LINK="view.priceCoinIconLink",d.VIEW_PRICE_COIN_MARKET_LINK="view.priceCoinMarketLink",d.MAKER_FEE="makerFee",d.TAKER_FEE="takerFee",d.MODE_PRE_SALE="mode.preSale",d))(Ft||{});var Ot=(n=>(n[n.OPEN_ORDER=1]="OPEN_ORDER",n[n.CANCELLED=2]="CANCELLED",n[n.MATCHED=3]="MATCHED",n[n.SELF_MATCHED=4]="SELF_MATCHED",n))(Ot||{}),Gt=(s=>(s[s.Open=1]="Open",s[s.Canceled=2]="Canceled",s[s.Completed=3]="Completed",s[s.SelfMatch=4]="SelfMatch",s[s.Expired=5]="Expired",s))(Gt||{}),Ct=(n=>(n[n.Limit=0]="Limit",n[n.IOC=1]="IOC",n[n.POST=2]="POST",n[n.Market=3]="Market",n))(Ct||{}),Lt=(r=>(r[r.created=1]="created",r[r.partially_filled=2]="partially_filled",r[r.removed=3]="removed",r))(Lt||{}),Vt=(a=>(a.ALGORAND="Algorand",a.SOLANA="Solana",a["5IRECHAIN_THUNDER_TESTNET"]="5ireChain Thunder Testnet",a.ACALA="Acala",a.ALFAJORES="Alfajores",a.APOTHEM_NETWORK="Apothem Network",a.ARBITRUM_GOERLI="Arbitrum Goerli",a.ARBITRUM_NOVA="Arbitrum Nova",a.ARBITRUM_ONE="Arbitrum",a.ARBITRUM_SEPOLIA="Arbitrum Sepolia",a.ASTAR="Astar",a.ASTAR_ZKEVM_TESTNET_ZKATANA="Astar zkEVM Testnet zKatana",a.AURORA="Aurora",a.AURORA_TESTNET="Aurora Testnet",a.AVALANCHE="Avalanche",a.AVALANCHE_FUJI="Avalanche Fuji",a.BAHAMUT="Bahamut",a.BASE="Base",a.BASE_GOERLI="Base Goerli",a.BASE_SEPOLIA="Base Sepolia",a.BEAR_NETWORK_CHAIN_MAINNET="Bear Network Chain Mainnet",a.BEAR_NETWORK_CHAIN_TESTNET="Bear Network Chain Testnet",a.BERACHAIN_ARTIO="Berachain Artio",a.BERESHEET_BEREEVM_TESTNET="Beresheet BereEVM Testnet",a.BINANCE_SMART_CHAIN_TESTNET="BNB Chain Testnet",a.BITTORRENT="BitTorrent",a.BITTORRENT_CHAIN_TESTNET="BitTorrent Chain Testnet",a.BLACKFORT_EXCHANGE_NETWORK="BlackFort Exchange Network",a.BLACKFORT_EXCHANGE_NETWORK_TESTNET="BlackFort Exchange Network Testnet",a.BLAST_SEPOLIA="Blast Sepolia",a.BNB_SMART_CHAIN="BNB Chain",a.BOBA_NETWORK="Boba Network",a.BRONOS="Bronos",a.BRONOS_TESTNET="Bronos Testnet",a.CANTO="Canto",a.CELO="Celo",a.CHILIZ_CHAIN="Chiliz Chain",a.CHILIZ_SPICY_TESTNET="Chiliz Spicy Testnet",a.CONFLUX_ESPACE="Conflux eSpace",a.CONFLUX_ESPACE_TESTNET="Conflux eSpace Testnet",a.CORE_DAO="Core Dao",a.COSTON="Coston",a.COSTON2="Coston2",a.CRONOS_MAINNET="Cronos Mainnet",a.CRONOS_TESTNET="Cronos Testnet",a.CROSSBELL="Crossbell",a.DEFICHAIN_EVM_MAINNET="DeFiChain EVM Mainnet",a.DEFICHAIN_EVM_TESTNET="DeFiChain EVM Testnet",a.DFK_CHAIN="DFK Chain",a.DOGECHAIN="Dogechain",a.EDGEWARE_EDGEEVM_MAINNET="Edgeware EdgeEVM Mainnet",a.EKTA="Ekta",a.EKTA_TESTNET="Ekta Testnet",a.EOS_EVM="EOS EVM",a.EOS_EVM_TESTNET="EOS EVM Testnet",a.ETHEREUM="Ethereum",a.ETHEREUM_CLASSIC="Ethereum Classic",a.EVMOS="Evmos",a.EVMOS_TESTNET="Evmos Testnet",a.FANTOM="Fantom",a.FANTOM_SONIC_OPEN_TESTNET="Fantom Sonic Open Testnet",a.FANTOM_TESTNET="Fantom Testnet",a.FIBO_CHAIN="Fibo Chain",a.FILECOIN_CALIBRATION="Filecoin Calibration",a.FILECOIN_HYPERSPACE="Filecoin Hyperspace",a.FILECOIN_MAINNET="Filecoin Mainnet",a.FLARE_MAINNET="Flare Mainnet",a.FOUNDRY="Foundry",a.FUSE="Fuse",a.FUSE_SPARKNET="Fuse Sparknet",a.GNOSIS="Gnosis",a.GNOSIS_CHIADO="Gnosis Chiado",a.GOERLI="Goerli",a.HAQQ_MAINNET="HAQQ Mainnet",a.HAQQ_TESTEDGE_2="HAQQ Testedge 2",a.HARDHAT="Hardhat",a.HARMONY_ONE="Harmony One",a.HEDERA_MAINNET="Hedera Mainnet",a.HEDERA_PREVIEWNET="Hedera Previewnet",a.HEDERA_TESTNET="Hedera Testnet",a.HOLESKY="Holesky",a.HORIZEN_GOBI_TESTNET="Horizen Gobi Testnet",a.IOTEX="IoTeX",a.IOTEX_TESTNET="IoTeX Testnet",a.JIBCHAIN_L1="JIBCHAIN L1",a.KARURA="Karura",a.KAVA_EVM="Kava EVM",a.KAVA_EVM_TESTNET="Kava EVM Testnet",a.KCC_MAINNET="KCC Mainnet",a.KLAYTN="Klaytn",a.KLAYTN_BAOBAB_TESTNET="Klaytn Baobab Testnet",a.KROMA="Kroma",a.KROMA_SEPOLIA="Kroma Sepolia",a.LIGHTLINK_PEGASUS_TESTNET="LightLink Pegasus Testnet",a.LIGHTLINK_PHOENIX="LightLink Phoenix",a.LINEA_GOERLI_TESTNET="Linea Goerli Testnet",a.LINEA_MAINNET="Linea Mainnet",a.LOCALHOST="Localhost",a.LUKSO="LUKSO",a.MANDALA_TC9="Mandala TC9",a.MANTA_PACIFIC_MAINNET="Manta Pacific Mainnet",a.MANTA_PACIFIC_TESTNET="Manta Pacific Testnet",a.MANTLE="Mantle",a.MANTLE_TESTNET="Mantle Testnet",a.METACHAIN_MAINNET="MetaChain Mainnet",a.METER="Meter",a.METER_TESTNET="Meter Testnet",a.METIS="Metis",a.METIS_GOERLI="Metis Goerli",a.MEVERSE_CHAIN_MAINNET="MEVerse Chain Mainnet",a.MEVERSE_CHAIN_TESTNET="MEVerse Chain Testnet",a.MODE_TESTNET="Mode Testnet",a.MOONBASE_ALPHA="Moonbase Alpha",a.MOONBEAM="Moonbeam",a.MOONBEAM_DEVELOPMENT_NODE="Moonbeam Development Node",a.MOONRIVER="Moonriver",a.NEON_EVM_DEVNET="Neon EVM DevNet",a.NEON_EVM_MAINNET="Neon EVM MainNet",a.NEXI="Nexi",a.NEXILIX_SMART_CHAIN="Nexilix Smart Chain",a.OASIS_SAPPHIRE="Oasis Sapphire",a.OASIS_SAPPHIRE_TESTNET="Oasis Sapphire Testnet",a.OASIS_TESTNET="Oasis Testnet",a.OASYS="Oasys",a.OKC="OKC",a.OORT_MAINNETDEV="OORT MainnetDev",a.OPBNB="opBNB",a.OPBNB_TESTNET="opBNB Testnet",a.OPTIMISM_GOERLI="Optimism Goerli",a.OP_MAINNET="Optimism",a.OP_SEPOLIA="Optimism Sepolia",a.PALM="Palm",a.PALM_TESTNET="Palm Testnet",a.PGN="PGN",a.PGN_="PGN ",a.PLINGA="Plinga",a.POLYGON="Polygon",a.POLYGON_AMOY="Polygon Amoy",a.POLYGON_MUMBAI="Polygon Mumbai",a.POLYGON_ZKEVM="Polygon zkEVM",a.POLYGON_ZKEVM_TESTNET="Polygon zkEVM Testnet",a.PULSECHAIN="PulseChain",a.PULSECHAIN_V4="PulseChain V4",a.Q_MAINNET="Q Mainnet",a.Q_TESTNET="Q Testnet",a.ROLLUX_MAINNET="Rollux Mainnet",a.ROLLUX_TESTNET="Rollux Testnet",a.RONIN="Ronin",a.ROOTSTOCK_MAINNET="Rootstock Mainnet",a.SAIGON_TESTNET="Saigon Testnet",a.SCROLL="Scroll",a.SCROLL_SEPOLIA="Scroll Sepolia",a.SCROLL_TESTNET="Scroll Testnet",a.SEPOLIA="Ethereum Sepolia",a.SHARDEUM_SPHINX="Shardeum Sphinx",a.SHIBARIUM="Shibarium",a.SHIMMER="Shimmer",a.SHIMMER_TESTNET="Shimmer Testnet",a["SKALE_|_BLOCK_BRAWLERS"]="SKALE | Block Brawlers",a["SKALE_|_CALYPSO_NFT_HUB"]="SKALE | Calypso NFT Hub",a["SKALE_|_CALYPSO_NFT_HUB_TESTNET"]="SKALE | Calypso NFT Hub Testnet",a["SKALE_|_CHAOS_TESTNET"]="SKALE | Chaos Testnet",a["SKALE_|_CRYPTOBLADES"]="SKALE | CryptoBlades",a["SKALE_|_CRYPTO_COLOSSEUM"]="SKALE | Crypto Colosseum",a["SKALE_|_EUROPA_LIQUIDITY_HUB"]="SKALE | Europa Liquidity Hub",a["SKALE_|_EUROPA_LIQUIDITY_HUB_TESTNET"]="SKALE | Europa Liquidity Hub Testnet",a["SKALE_|_EXORDE"]="SKALE | Exorde",a["SKALE_|_HUMAN_PROTOCOL"]="SKALE | Human Protocol",a["SKALE_|_NEBULA_GAMING_HUB"]="SKALE | Nebula Gaming Hub",a["SKALE_|_NEBULA_GAMING_HUB_TESTNET"]="SKALE | Nebula Gaming Hub Testnet",a["SKALE_|_RAZOR_NETWORK"]="SKALE | Razor Network",a["SKALE_|_TITAN_COMMUNITY_HUB"]="SKALE | Titan Community Hub",a["SKALE_|_TITAN_COMMUNITY_HUB_TESTNET"]="SKALE | Titan Community Hub Testnet",a.SONGBIRD_MAINNET="Songbird Mainnet",a.SYSCOIN_MAINNET="Syscoin Mainnet",a.SYSCOIN_TANENBAUM_TESTNET="Syscoin Tanenbaum Testnet",a["TAIKO_(ALPHA-3_TESTNET)"]="Taiko (Alpha-3 Testnet)",a["TAIKO_JOLNIR_(ALPHA-5_TESTNET)"]="Taiko Jolnir (Alpha-5 Testnet)",a["TAIKO_KATLA_(ALPHA-6_TESTNET)"]="Taiko Katla (Alpha-6 Testnet)",a.TARAXA_MAINNET="Taraxa Mainnet",a.TARAXA_TESTNET="Taraxa Testnet",a.TELOS="Telos",a.TENET="Tenet",a.VECHAIN="Vechain",a.WANCHAIN="Wanchain",a.WANCHAIN_TESTNET="Wanchain Testnet",a.WEMIX="WEMIX",a.WEMIX_TESTNET="WEMIX Testnet",a.X1_TESTNET="X1 Testnet",a.XINFIN_NETWORK="XinFin Network",a.ZETACHAIN_ATHENS_TESTNET="ZetaChain Athens Testnet",a.ZHEJIANG="Zhejiang",a.ZILLIQA="Zilliqa",a.ZILLIQA_TESTNET="Zilliqa Testnet",a.ZKFAIR_MAINNET="ZKFair Mainnet",a.ZKFAIR_TESTNET="ZKFair Testnet",a.ZKSYNC_ERA="zkSync Era",a.ZKSYNC_ERA_TESTNET="zkSync Era Testnet",a.ZKSYNC_SEPOLIA_TESTNET="zkSync Sepolia Testnet",a.ZORA="Zora",a.ZORA_GOERLI_TESTNET="Zora Goerli Testnet",a.ZORA_SEPOLIA="Zora Sepolia",a))(Vt||{}),Yt=(m=>(m.Pending="pending",m.Completed="completed",m.Failed="failed",m.Received="received",m.Success="success",m.Failure="failure",m.Dropped="dropped",m.Replaced="replaced",m.Stuck="stuck",m.Confirmed="confirmed",m))(Yt||{}),$t=(s=>(s.USER_TO_TMC="user_to_tmc",s.TMC_TO_USER="tmc_to_user",s.RELAYER_TO_TMC="relayer_to_tmc",s.RELAYER_TO_CODEX="relayer_to_codex",s.RELAYER_TO_CIRCLE="relayer_to_circle",s))($t||{}),Xt=(r=>(r.D="deposit",r.W="withdraw",r.T="transfer",r))(Xt||{});var Bt=(n=>(n.COMPANY="COMPANY",n.TWITTER="TWITTER",n.DISCORD="DISCORD",n.TELEGRAM="TELEGRAM",n))(Bt||{});var qt=(h=>(h[h.QUOTE=1]="QUOTE",h[h.LAST_PRICE=2]="LAST_PRICE",h[h.DEPTH=3]="DEPTH",h[h.LAST_CANDLESTICK=4]="LAST_CANDLESTICK",h[h.ORDERS=5]="ORDERS",h[h.TRADES=6]="TRADES",h[h.SYSTEM=7]="SYSTEM",h[h.WALLET_TRANSACTIONS=8]="WALLET_TRANSACTIONS",h[h.ALL_STAT=9]="ALL_STAT",h[h.CODEX_ASSETS=12]="CODEX_ASSETS",h[h.CODEX_BALANCES=10]="CODEX_BALANCES",h[h.LAST_LOOK=11]="LAST_LOOK",h[h.SETTINGS_UPDATE=13]="SETTINGS_UPDATE",h[h.NEW_NOTIFICATION=14]="NEW_NOTIFICATION",h[h.POINT_SYSTEM_SETTINGS_UPDATE=15]="POINT_SYSTEM_SETTINGS_UPDATE",h))(qt||{}),K=[5,8,10,11];var Zt=(r=>(r.OFF="disable",r.ULTRADE="ultrade",r.ALL="all",r))(Zt||{}),zt=(f=>(f.ENABLED="company.enabled",f.APP_TITLE="company.appTitle",f.DOMAIN="company.domain",f.DIRECT_SETTLE="company.directSettlement",f.KYC="markets.kycTradeRequirementEnabled",f.GEOBLOCK="company.geoblock",f.LOGO="appearance.logo",f.THEMES="appearance.themes",f.NEW_TAB="appearance.newTab",f.TARGET="appearance.target",f.REPORT_BUTTONS="appearance.reportButtons",f.CUSTOM_MENU_ITEMS="appearance.customMenuItems",f.APPEARANCE_CHART_TYPE="appearance.chartType",f.APPEARANCE_CHART_INT="appearance.chartInt",f.AMM="product.amm",f.OBDEX="product.obdex",f.POINTS="product.pointSystem",f.AFFILIATE_DASHBOARD_THRESHOLD="product.affiliateDashboardThreshold",f.AFFILIATE_DEFAULT_FEE_SHARE="product.affiliateDefaultFeeShare",f.AFFILIATE_DASHBOARD_VISIBILITY="product.affiliateDashboardVisibility",f.AMM_FEE="company.ammFee",f.FEE_SHARE="company.feeShare",f.MIN_FEE="company.minFee",f.MAKER_FEE="company.makerFee",f.TAKER_FEE="company.takerFee",f.PINNED_PAIRS="markets.pinnedPairs",f.TWITTER_ENABLED="point-system.twitterEnabled",f.TWITTER_JOB_ENABLED="point-system.twitterJobEnabled",f.TWITTER_HASHTAGS="point-system.twitterHashtags",f.TWITTER_ACCOUNT_NAME="point-system.twitterAccountName",f.DISCORD_ENABLED="point-system.discordEnabled",f.TELEGRAM_ENABLED="point-system.telegramEnabled",f.TELEGRAM_GROUP_NAME="point-system.telegramGroupName",f.TELEGRAM_BOT_NAME="point-system.telegramBotName",f.GUIDE_LINK="point-system.guideLink",f))(zt||{});var Qt=(r=>(r.DISABLED="disabled",r.ENABLED_FOR_ALL="enabled for all",r.ENABLED_FOR_AFFILIATES="enabled for affiliates",r))(Qt||{});import{decodeStateArray as Jt,getTxnParams as jt}from"@ultrade/shared/browser/helpers/algo.helper";import F from"algosdk";import Kt from"axios";var O=class{constructor(e,t,r){this.client=e,this.authCredentials=t,this.indexerDomain=r}isAppOptedIn(e,t){return!!e?.find(r=>r.id===t)}isAssetOptedIn(e,t){return Object.keys(e).includes(t.toString())}async optInAsset(e,t){let r=await this.getTxnParams();return F.makeAssetTransferTxnWithSuggestedParamsFromObject({suggestedParams:{...r},from:e,to:e,assetIndex:t,amount:0})}async makeAppCallTransaction(e,t,r,n,s){let o=[],c=[],u=[e];return F.makeApplicationNoOpTxn(t,s||await this.getTxnParams(),r,n,o,c,u)}makeTransferTransaction(e,t,r,n,s){if(r<=0)return null;let o={suggestedParams:{...e},from:n,to:s,amount:r};return t===0?F.makePaymentTxnWithSuggestedParamsFromObject(o):(o.assetIndex=t,F.makeAssetTransferTxnWithSuggestedParamsFromObject(o))}get signer(){return this.authCredentials.signer}set signer(e){this.authCredentials.signer=e}async signAndSend(e){Array.isArray(e)||(e=[e]);let t=this.getCurrentAccount();if(t){let r=e.map(n=>n.signTxn(t.sk));return this.client.sendRawTransaction(r).do()}return this.authCredentials.signer.signAndSend(e)}async signAndSendData(e,t,r,n){let s=typeof e=="string"?e:JSON.stringify(e),o=typeof e=="string"?{message:s}:{...e},c=await t(s,n);return r({...o,signature:c})}async getTxnParams(){return await jt(this.client)}getCurrentAccount(){return this.authCredentials.mnemonic?F.mnemonicToSecretKey(this.authCredentials.mnemonic):null}async getAccountInfo(e){return this.client.accountInformation(e).do()}constructArgsForAppCall(...e){let t=[];return e.forEach(r=>{t.push(new Uint8Array(r.toBuffer?r.toBuffer():l.from(r.toString())))}),t}validateCredentials(){if(!this.authCredentials.mnemonic&&!this.authCredentials.signer)throw"You need specify mnemonic or signer to execute the method"}async getAppState(e){try{let t=await this.client.getApplicationByID(e).do();return Jt(t.params["global-state"])}catch(t){console.log(`Attempt to load app by id ${e}`),console.log(t.message)}}async getSuperAppId(e){return(await this.getAppState(e))?.UL_SUPERADMIN_APP||0}async getPairBalances(e,t){let{data:r}=await Kt.get(`${this.indexerDomain}/v2/accounts/${t}?include-all=true`);if(r.account.hasOwnProperty("apps-local-state")){let n=r.account["apps-local-state"].find(c=>c.id===e&&c.deleted===!1);if(!n)return null;let s=n["key-value"].find(c=>c.key==="YWNjb3VudEluZm8="),o=l.from(s.value.bytes,"base64");return ye(o)}}async calculateTransferAmount(e,t,r,n,s,o){let c=await this.getPairBalances(e,t),u=(r==="B"?c?.priceCoin_available:c?.baseCoin_available)??0;r==="B"&&(n=n/10**o*s);let d=Math.ceil(n-u);return d<0?0:d}};import we,{encodeAddress as Ht}from"algosdk";var er={priceCoin_locked:{type:"uint"},priceCoin_available:{type:"uint"},baseCoin_locked:{type:"uint"},baseCoin_available:{type:"uint"},companyId:{type:"uint"},WLFeeShare:{type:"uint"},WLCustomFee:{type:"uint"},slotMap:{type:"uint"}},ye=i=>{let e=new Map,t=0;for(let[r,n]of Object.entries(er)){if(t>=i.length)throw new Error("Array index out of bounds");let s;switch(n.type){case"address":s=Ht(i.slice(t,t+32)),t+=32;break;case"bytes":s=i.slice(t,t+n.size),s=we.decodeUint64(s,"mixed"),t+=n.size;break;case"uint":s=we.decodeUint64(i.slice(t,t+8),"mixed"),t+=8;break;case"string":s=tr(i.slice(t,t+n.size)),t+=n.size;break}e.set(r,s)}return Object.fromEntries(e)},tr=i=>l.from(i).toString("utf-8");var Pe="By signing this message you are logging into your trading account and agreeing to all terms and conditions of the platform.";var Re={mainnet:{algodNode:"https://mainnet-api.algonode.cloud",apiUrl:"https://mainnet-api.algonode.cloud",algodIndexer:"https://mainnet-idx.algonode.cloud"},testnet:{algodNode:"https://testnet-api.algonode.cloud",apiUrl:"https://testnet-apigw.ultradedev.net",algodIndexer:"https://testnet-idx.algonode.cloud"},local:{algodNode:"http://localhost:4001",apiUrl:"http://localhost:5001",algodIndexer:"http://localhost:8980"}},H=["/market/balances","/market/order","/market/orders","/market/account/kyc/status","/market/account/kyc/init","/market/withdrawal-fee","/market/operation-details","/wallet/key","/wallet/transactions","/wallet/transfer","/wallet/withdraw","/wallet/whitelist","/wallet/withdrawal-wallets"];var Se=class{constructor(e,t){this.axiosInterceptor=e=>{let t=c=>c.withWalletCredentials||(c.url?H.some(u=>c.url.includes(u)):!1),r=c=>{let u=["/market/order"];return c.withWalletCredentials||(c.url?u.some(d=>c.url.includes(d)):!1)},n=c=>{let u=["/wallet/signin","/market/account/kyc/init","/notifications"];return c.url?u.some(d=>c.url.includes(d)):!1},s=c=>{let u=["/social/"];return c.url?u.some(d=>c.url.includes(d)):!1},o=c=>c.url?H.some(u=>c.url.includes(u)):!1;return e.interceptors.request.use(c=>{if(this.wallet&&t(c)&&(c.headers["X-Wallet-Address"]=this.wallet.address,c.headers["X-Wallet-Token"]=this.wallet.token),this.wallet&&o(c)&&(c.headers.CompanyId=this.companyId),this.wallet&&r(c)){let u=this.wallet?.tradingKey;u&&(c.headers["X-Trading-Key"]=u)}return n(c)&&(c.headers.CompanyId=this.companyId),s(c)&&!c.headers.CompanyId&&(c.headers.CompanyId=this.isUltradeID?1:this.companyId),c},c=>Promise.reject(c)),e.interceptors.response.use(c=>c.data,async c=>(console.log("Request was failed",c),[401].includes(c?.response?.status)&&c.config&&t(c.config)&&(this.wallet=null,this.localStorageService.clearMainWallet()),Promise.reject(c))),e};let r=Re[e.network];this.algodNode=r.algodNode,this.apiUrl=r.apiUrl,this.algodIndexer=r.algodIndexer,e.apiUrl!==void 0&&(this.apiUrl=e.apiUrl),e.companyId!==void 0&&(this.companyId=e.companyId),this.websocketUrl=e.websocketUrl,this.client=new O(e.algoSdkClient,t||{},this.algodIndexer),this._axios=this.axiosInterceptor(rr.create({baseURL:this.apiUrl})),this.localStorageService=new q,this.wallet=this.localStorageService.getMainWallet(),this.isUltradeID=!1,this.socketManager=new U(this.websocketUrl,e.socketIO,n=>{console.log(`Socket ${n} disconnected at`,new Date)},n=>{console.log(`Socket connect_error due to ${n}`)}),console.log("SDK Wallet",this.wallet)}get useUltradeID(){return this.isUltradeID}set useUltradeID(e){this.isUltradeID=e}get isLogged(){return!!this.wallet?.token}get mainWallet(){return this.wallet}set mainWallet(e){this.wallet=e,e?this.localStorageService.setMainWallet(e):this.localStorageService.clearMainWallet()}setSigner(e){this.client.signer=e}subscribe(e,t){let r=e.streams.some(n=>K.includes(n));return r&&!this.mainWallet?.token&&!this.mainWallet?.tradingKey?(e.streams=e.streams.filter(n=>!K.includes(n)),this.socketManager.subscribe(e,t)):r?(e.options={...e.options,token:this.mainWallet?.token,tradingKey:this.mainWallet?.tradingKey},this.socketManager.subscribe(e,t)):this.socketManager.subscribe(e,t)}unsubscribe(e){this.socketManager.unsubscribe(e)}getPairList(e){let t=e?`&companyId=${e}`:"";return this._axios.get(`/market/markets?includeAllOrders=false${t}`)}getPair(e){return this._axios.get(`/market/market?symbol=${e}`)}getPrice(e){return this._axios.get(`/market/price?symbol=${e}`)}getDepth(e,t){return this._axios.get(`/market/depth?symbol=${e}&depth=${t}`)}getSymbols(e){return this._axios.get(`/market/symbols${e?"?mask="+e:""}`)}getLastTrades(e){return this._axios.get(`/market/last-trades?symbol=${e}`)}getHistory(e,t,r,n,s=500,o=1){return this._axios.get(`/market/history?symbol=${e}&interval=${t}&startTime=${r??""}&endTime=${n??""}&limit=${s}&page=${o}`)}getOrders(e,t,r=50,n,s){let o=t?t===1?G.Open:[G.Canceled,G.Matched,G.SelfMatched,G.Expired].join(","):"",c=e?`&symbol=${e}`:"",u=o?`&status=${o}`:"",d=s?`&startTime=${s}`:"",m=n?`&endTime=${n}`:"";return this._axios.get(`/market/orders?limit=${r}${c}${u}${d}${m}`)}getOrderById(e){return this._axios.get(`/market/order/${e}`)}getSettings(){let e=new URL(window.location!==window.parent.location?document.referrer:document.location.href).host;return this._axios.get("/market/settings",{headers:{"wl-domain":e}})}getBalances(){return this._axios.get("/market/balances")}getChains(){return this._axios.get("/market/chains")}getCodexAssets(){return this._axios.get("/market/assets")}getCCTPAssets(){return this._axios.get("/market/cctp-assets")}getCCTPUnifiedAssets(){return this._axios.get("/market/cctp-unified-assets")}getWithdrawalFee(e,t){return this._axios.get(`/market/withdrawal-fee?assetAddress=${e}&chainId=${t}`)}getKycStatus(){return this._axios.get("/market/account/kyc/status")}getKycInitLink(e){return this._axios.post("/market/account/kyc/init",{embeddedAppUrl:e})}getDollarValues(e=[]){return this._axios.get(`/market/dollar-price?assetIds=${JSON.stringify(e)}`)}getTransactionDetalis(e){return this._axios.get(`/market/operation-details?operationId=${e}`)}getWalletTransactions(e,t,r=100){return this._axios.get(`/wallet/transactions?type=${e}&limit=${r}&page=${t}`,{withWalletCredentials:!0})}getTradingKeys(){return this._axios.get("/wallet/keys",{withWalletCredentials:!0})}getTransfers(e,t=100){return this._axios.get(`/wallet/transfers?limit=${t}&page=${e}`,{withWalletCredentials:!0})}getPendingTransactions(){return this._axios.get("/wallet/transactions/pending",{withWalletCredentials:!0})}getWhitelist(){return this._axios.get("/wallet/whitelist",{withWalletCredentials:!0})}async addWhitelist(e){e={...e,expiredDate:e.expiredDate&&Math.round(e.expiredDate/1e3)};let r=l.from(ur(e)).toString("hex");return await this.client.signAndSendData(r,this.client.signer.signMessage,({signature:n})=>this._axios.post("/wallet/whitelist",{message:r,signature:n}),"hex")}deleteWhitelist(e){let t={whitelistId:e};return this.client.signAndSendData(t,this.client.signer.signMessage,({signature:r})=>this._axios.delete("/wallet/whitelist",{data:{data:t,signature:r}}))}getAllWithdrawalWallets(){return this._axios.get("/wallet/withdrawal-wallets")}getWithdrawalWalletByAddress(e){return this._axios.get(`/wallet/withdrawal-wallets/${e}`)}createWithdrawalWallet(e){return this._axios.post("/wallet/withdrawal-wallets",e)}updateWithdrawalWallet(e){return this._axios.patch("/wallet/withdrawal-wallets",e)}deleteWithdrawalWallet(e){return this._axios.delete(`/wallet/withdrawal-wallets/${e}`)}getVersion(){return this._axios.get("/system/version")}getMaintenance(){return this._axios.get("/system/maintenance")}getNotifications(){return this._axios.get("/notifications",{withWalletCredentials:!0})}getNotificationsUnreadCount(){return this._axios.get("/notifications/count",{withWalletCredentials:!0})}readNotifications(e){return this._axios.put("/notifications",{notifications:e},{withWalletCredentials:!0})}getAffiliatesStatus(e){return this._axios.get(`/affiliates/${e}/dashboardStatus`,{withWalletCredentials:!0})}createAffiliate(e){return this._axios.post(`/affiliates/${e}`,{},{withWalletCredentials:!0})}getAffiliateProgress(e){return this._axios.get(`/affiliates/${e}/tradingVolumeProgress`,{withWalletCredentials:!0})}getAffiliateInfo(e,t){return this._axios.get(`/affiliates/${e}/dashboard?range=${t}`,{withWalletCredentials:!0})}async countAffiliateDepost(e){await this._axios.post(`/affiliates/${e}/deposit`,{},{withWalletCredentials:!0})}async countAffiliateClick(e){await this._axios.post("/affiliates/click",{referralToken:e},{withWalletCredentials:!0})}getSocialAccount(){return this._axios.get("/social/account",{withWalletCredentials:!0})}async addSocialEmail(e,t){await this._axios.put("/social/account/email",{email:e,embeddedAppUrl:t},{withWalletCredentials:!0})}async verifySocialEmail(e,t){await this._axios.put("/social/account/verifyEmail",{email:e,hash:t},{withWalletCredentials:!0})}getLeaderboards(){return this._axios.get("/social/leaderboard",{withWalletCredentials:!0})}getUnlocks(){return this._axios.get("/social/unlocks",{withWalletCredentials:!0})}getSocialSettings(){return this._axios.get("/social/settings",{withWalletCredentials:!0})}getSeason(e){return this._axios.get("/social/seasons/active",{withWalletCredentials:!0,headers:{CompanyId:e}})}getPastSeasons(){return this._axios.get("/social/seasons/history",{withWalletCredentials:!0})}addTelegram(e){return this._axios.post("/social/telegram/connect",e,{withWalletCredentials:!0})}async disconnectTelegram(e){await this._axios.put("/social/telegram/disconnect",e,{withWalletCredentials:!0})}async getDiscordConnectionUrl(e){let t=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"";return(await this._axios.get(`/social/discord/connect${t}`,{withWalletCredentials:!0})).url}async disconnectDiscord(){await this._axios.put("/social/discord/disconnect",{},{withWalletCredentials:!0})}async getTwitterConnectionUrl(e,t){let r=e?`?embeddedAppUrl=${encodeURIComponent(e)}`:"",n=t?`&scopes=${t}`:"";return(await this._axios.get(`/social/twitter/connect${r}${n}`,{withWalletCredentials:!0})).url}async disconnectTwitter(){await this._axios.put("/social/twitter/disconnect",{},{withWalletCredentials:!0})}getTweets(){return this._axios.get("/social/twitter/tweets",{withWalletCredentials:!0})}async actionWithTweet(e){await this._axios.post("/social/twitter/tweet/actions",e,{withWalletCredentials:!0})}getActions(){return this._axios.get("/social/actions",{withWalletCredentials:!0})}getActionHistory(){return this._axios.get("/social/actions/history",{withWalletCredentials:!0})}getAIStyles(){return this._axios.get("/social/twitter/tweets/styles",{withWalletCredentials:!0})}getAIComment(e,t){return this._axios.get(`/social/twitter/tweets/${t}/generateComment?styleId=${e}`,{withWalletCredentials:!0})}getTechnologyByProvider(e){switch(e){case M.PERA:return"ALGORAND";case M.METAMASK:return"EVM";case M.SOLFLARE:case M.COINBASE:case M.PHANTOM:case M.BACKPACK:case M.MOBILE:return"SOLANA";default:throw new Error("Not implemented")}}async login({address:e,provider:t,chain:r,referralToken:n,loginMessage:s}){let c=s||Pe,u={address:e,technology:this.getTechnologyByProvider(t)},d=l.from(sr(u,c)).toString("hex");return await this.client.signAndSendData(d,this.client.signer.signMessage,async({signature:m})=>{let p=await this._axios.put("/wallet/signin",{data:u,message:d,encoding:"hex",signature:m,referralToken:n});return this.mainWallet={address:e,provider:t,token:p,chain:r},p},"hex")}async addTradingKey(e){let r=l.from(ke(e,!0)).toString("hex"),{device:n,type:s}=e;return await this.client.signAndSendData(r,this.client.signer.signMessage,async({signature:o})=>{let c=await this._axios.post("/wallet/key",{data:{device:n,type:s},encoding:"hex",message:r,signature:o});return this.mainWallet&&c.type===cr.User&&(this.mainWallet.tradingKey=c.address),c},"hex")}async revokeTradingKey(e){let r=l.from(ke(e,!1)).toString("hex"),{device:n,type:s}=e;return await this.client.signAndSendData(r,this.client.signer.signMessage,async({signature:o})=>(await this._axios.delete("/wallet/key",{data:{data:{device:n,type:s},encoding:"hex",message:r,signature:o}}),this.mainWallet&&e.tkAddress===this.mainWallet.tradingKey&&(this.mainWallet.tradingKey=void 0),{signature:o}),"hex")}async withdraw(e,t){let n={...e,random:ee(1,Number.MAX_SAFE_INTEGER)},s=l.from(lr(n,t)).toString("hex");return await this.client.signAndSendData(s,this.client.signer.signMessage,({signature:o})=>this._axios.post("/wallet/withdraw",{encoding:"hex",message:s,signature:o,destinationAddress:n.recipient}),"hex")}async transfer(e){let r={...e,random:ee(1,Number.MAX_SAFE_INTEGER)},n=l.from(dr(r)).toString("hex");return await this.client.signAndSendData(n,this.client.signer.signMessage,({signature:s})=>this._axios.post("/wallet/transfer",{message:n,signature:s}),"hex")}async createOrder(e){let t=ir*24*60*60,r=Math.floor(Date.now()/1e3)+t,n={...e,version:nr,expiredTime:r,random:ee(1,Number.MAX_SAFE_INTEGER)};console.log("CreateOrderData",n);let s="hex",o=l.from(or(n)).toString(s);return await this.client.signAndSendData(o,this.client.signer.signMessageByToken,({signature:c})=>this._axios.post("/market/order",{encoding:s,message:o,signature:c}),s)}async cancelOrder(e){let t={orderId:e.orderId},r="hex",n=l.from(ar(e)).toString(r);return await this.client.signAndSendData(n,this.client.signer.signMessageByToken,({signature:s})=>this._axios.delete("/market/order",{data:{data:t,message:n,signature:s}}),r)}async cancelMultipleOrders({orderIds:e,pairId:t}){let r={orderIds:e,pairId:t};return await this.client.signAndSendData(r,this.client.signer.signMessageByToken,({signature:n})=>this._axios.delete("/market/orders",{data:{data:r,signature:n}}))}async ping(){let e=await this._axios.get("/system/time");return Math.round(Date.now()-e.currentTime)}};export{Xt as ACTION_TYPE,Qt as AffDashboardVisibilitySettingEnum,Vt as BLOCKCHAINS,Se as Client,Pe as DEFAULT_LOGIN_MESSAGE,Ut as DIRECT_SETTLE,Re as NETWORK_CONFIGS,Ot as ORDER_STATUS,Yt as OperationStatusEnum,Gt as OrderStatus,Ct as OrderTypeEnum,Lt as OrderUpdateStaus,Zt as POINTS_SETTING,K as PRIVATE_STREAMS,Ft as PairSettingsIds,Bt as SOCIAL_ACTION_SOURCE,qt as STREAMS,zt as SettingIds,U as SocketManager,$t as TransactionType,H as tokenizedUrls};
2
2
  /*! Bundled license information:
3
3
 
4
4
  @esbuild-plugins/node-globals-polyfill/Buffer.js:
@@ -0,0 +1,64 @@
1
+ import { AffDashboardVisibilitySettingEnum, POINTS_SETTING, SettingIds } from "../enum/index.ts";
2
+ export interface UserNotification {
3
+ id: number;
4
+ globalNotificationId: number;
5
+ priority: any;
6
+ status: any;
7
+ type: any;
8
+ message: string;
9
+ createdAt: Date;
10
+ }
11
+ export interface SettingsInit {
12
+ [SettingIds.LOGO]: string;
13
+ [SettingIds.TARGET]?: string;
14
+ [SettingIds.NEW_TAB]?: string;
15
+ [SettingIds.REPORT_BUTTONS]?: string;
16
+ [SettingIds.CUSTOM_MENU_ITEMS]?: string;
17
+ [SettingIds.THEMES]: string;
18
+ [SettingIds.AMM_FEE]?: string;
19
+ [SettingIds.APP_TITLE]: string;
20
+ [SettingIds.DIRECT_SETTLE]?: string;
21
+ [SettingIds.KYC]?: string;
22
+ [SettingIds.DOMAIN]: string;
23
+ [SettingIds.ENABLED]: string;
24
+ [SettingIds.FEE_SHARE]: string;
25
+ [SettingIds.GEOBLOCK]?: string;
26
+ [SettingIds.MAKER_FEE]?: string;
27
+ [SettingIds.MIN_FEE]?: string;
28
+ [SettingIds.TAKER_FEE]?: string;
29
+ [SettingIds.PINNED_PAIRS]?: string;
30
+ [SettingIds.AMM]: string;
31
+ [SettingIds.OBDEX]: string;
32
+ [SettingIds.POINTS]?: POINTS_SETTING;
33
+ [SettingIds.AFFILIATE_DASHBOARD_THRESHOLD]: string;
34
+ [SettingIds.AFFILIATE_DEFAULT_FEE_SHARE]: string;
35
+ [SettingIds.AFFILIATE_DASHBOARD_VISIBILITY]?: AffDashboardVisibilitySettingEnum;
36
+ [SettingIds.TELEGRAM_ENABLED]?: string;
37
+ [SettingIds.TELEGRAM_GROUP_NAME]?: string;
38
+ [SettingIds.TELEGRAM_BOT_NAME]?: string;
39
+ [SettingIds.DISCORD_ENABLED]?: string;
40
+ [SettingIds.TWITTER_ENABLED]?: string;
41
+ [SettingIds.TWITTER_JOB_ENABLED]?: string;
42
+ [SettingIds.TWITTER_HASHTAGS]?: string;
43
+ [SettingIds.TWITTER_ACCOUNT_NAME]?: string;
44
+ [SettingIds.APPEARANCE_CHART_TYPE]?: string;
45
+ [SettingIds.APPEARANCE_CHART_INT]?: string;
46
+ currentCountry?: string;
47
+ partnerId: number;
48
+ isUltrade: boolean;
49
+ companyId: number;
50
+ }
51
+ import { ILoginData, ITradingKeyData } from "../../../shared/dist/browser/interfaces";
52
+ import { TradingKeyView } from "../../../shared/dist/browser/interfaces";
53
+ export interface ILoginResponse {
54
+ token: string;
55
+ }
56
+ export interface IRevokeTradingKeyResponse {
57
+ signature: string;
58
+ }
59
+ export interface IAccountForClient {
60
+ getSettings(): Promise<SettingsInit>;
61
+ login(data: ILoginData): Promise<string>;
62
+ addTradingKey(data: ITradingKeyData): Promise<TradingKeyView>;
63
+ revokeTradingKey(data: ITradingKeyData): Promise<IRevokeTradingKeyResponse>;
64
+ }