@ecency/sdk 1.1.22 → 1.2.0

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 (120) hide show
  1. package/dist/index.cjs +1671 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +1075 -0
  4. package/dist/index.d.ts +1075 -10
  5. package/dist/index.mjs +1589 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +29 -16
  8. package/dist/ecency-sdk.es.js +0 -1458
  9. package/dist/modules/accounts/index.d.ts +0 -3
  10. package/dist/modules/accounts/mutations/bookmarks/index.d.ts +0 -2
  11. package/dist/modules/accounts/mutations/bookmarks/use-account-bookmark-add.d.ts +0 -6
  12. package/dist/modules/accounts/mutations/bookmarks/use-account-bookmark-delete.d.ts +0 -1
  13. package/dist/modules/accounts/mutations/favourites/index.d.ts +0 -2
  14. package/dist/modules/accounts/mutations/favourites/use-account-favourite-add.d.ts +0 -1
  15. package/dist/modules/accounts/mutations/favourites/use-account-favourite-delete.d.ts +0 -1
  16. package/dist/modules/accounts/mutations/index.d.ts +0 -9
  17. package/dist/modules/accounts/mutations/use-account-relations-update.d.ts +0 -9
  18. package/dist/modules/accounts/mutations/use-account-revoke-key.d.ts +0 -19
  19. package/dist/modules/accounts/mutations/use-account-revoke-posting.d.ts +0 -10
  20. package/dist/modules/accounts/mutations/use-account-update-key-auths.d.ts +0 -19
  21. package/dist/modules/accounts/mutations/use-account-update-password.d.ts +0 -12
  22. package/dist/modules/accounts/mutations/use-account-update-recovery.d.ts +0 -11
  23. package/dist/modules/accounts/mutations/use-account-update.d.ts +0 -7
  24. package/dist/modules/accounts/queries/check-username-wallets-pending-query-options.d.ts +0 -16
  25. package/dist/modules/accounts/queries/get-account-full-query-options.d.ts +0 -245
  26. package/dist/modules/accounts/queries/get-account-pending-recovery-query-options.d.ts +0 -8
  27. package/dist/modules/accounts/queries/get-account-recoveries-query-options.d.ts +0 -9
  28. package/dist/modules/accounts/queries/get-account-subscriptions-query-options.d.ts +0 -10
  29. package/dist/modules/accounts/queries/get-active-account-bookmarks-query-options.d.ts +0 -9
  30. package/dist/modules/accounts/queries/get-active-account-favourites-query-options.d.ts +0 -9
  31. package/dist/modules/accounts/queries/get-relationship-between-accounts-query-options.d.ts +0 -9
  32. package/dist/modules/accounts/queries/index.d.ts +0 -9
  33. package/dist/modules/accounts/queries/search-accounts-by-username-query-options.d.ts +0 -8
  34. package/dist/modules/accounts/types/account-bookmark.d.ts +0 -7
  35. package/dist/modules/accounts/types/account-favourite.d.ts +0 -5
  36. package/dist/modules/accounts/types/account-follow-stats.d.ts +0 -5
  37. package/dist/modules/accounts/types/account-profile.d.ts +0 -19
  38. package/dist/modules/accounts/types/account-recovery.d.ts +0 -8
  39. package/dist/modules/accounts/types/account-relationship.d.ts +0 -6
  40. package/dist/modules/accounts/types/account-reputation.d.ts +0 -4
  41. package/dist/modules/accounts/types/full-account.d.ts +0 -52
  42. package/dist/modules/accounts/types/index.d.ts +0 -8
  43. package/dist/modules/analytics/index.d.ts +0 -2
  44. package/dist/modules/analytics/mutations/index.d.ts +0 -1
  45. package/dist/modules/analytics/mutations/use-record-activity.d.ts +0 -3
  46. package/dist/modules/communities/index.d.ts +0 -3
  47. package/dist/modules/communities/queries/get-communities-query-options.d.ts +0 -9
  48. package/dist/modules/communities/queries/get-community-context-query-options.d.ts +0 -20
  49. package/dist/modules/communities/queries/index.d.ts +0 -2
  50. package/dist/modules/communities/types/community.d.ts +0 -33
  51. package/dist/modules/communities/types/index.d.ts +0 -1
  52. package/dist/modules/communities/utils/index.d.ts +0 -11
  53. package/dist/modules/core/config.d.ts +0 -15
  54. package/dist/modules/core/entities/index.d.ts +0 -1
  55. package/dist/modules/core/entities/user.d.ts +0 -9
  56. package/dist/modules/core/index.d.ts +0 -7
  57. package/dist/modules/core/mock-storage.d.ts +0 -9
  58. package/dist/modules/core/mutations/broadcast-json.d.ts +0 -1
  59. package/dist/modules/core/mutations/index.d.ts +0 -2
  60. package/dist/modules/core/mutations/use-broadcast-mutation.d.ts +0 -3
  61. package/dist/modules/core/queries/get-dynamic-props-query-options.d.ts +0 -9
  62. package/dist/modules/core/queries/index.d.ts +0 -1
  63. package/dist/modules/core/queries-manager.d.ts +0 -21
  64. package/dist/modules/core/storage.d.ts +0 -6
  65. package/dist/modules/core/types/dynamic-props.d.ts +0 -15
  66. package/dist/modules/core/types/index.d.ts +0 -1
  67. package/dist/modules/core/utils/decoder-encoder.d.ts +0 -2
  68. package/dist/modules/core/utils/index.d.ts +0 -2
  69. package/dist/modules/core/utils/parse-asset.d.ts +0 -17
  70. package/dist/modules/games/index.d.ts +0 -3
  71. package/dist/modules/games/mutations/game-claim.d.ts +0 -2
  72. package/dist/modules/games/mutations/index.d.ts +0 -1
  73. package/dist/modules/games/queries/game-status-check-query-options.d.ts +0 -9
  74. package/dist/modules/games/queries/index.d.ts +0 -1
  75. package/dist/modules/games/types/game-claim.d.ts +0 -3
  76. package/dist/modules/games/types/get-game-status.d.ts +0 -7
  77. package/dist/modules/games/types/index.d.ts +0 -2
  78. package/dist/modules/integrations/3speak/index.d.ts +0 -6
  79. package/dist/modules/integrations/3speak/queries/get-account-token-query-options.d.ts +0 -8
  80. package/dist/modules/integrations/3speak/queries/get-account-videos-query-options.d.ts +0 -9
  81. package/dist/modules/integrations/3speak/queries/index.d.ts +0 -2
  82. package/dist/modules/integrations/3speak/types/index.d.ts +0 -1
  83. package/dist/modules/integrations/3speak/types/three-speak-video.d.ts +0 -52
  84. package/dist/modules/integrations/hiveposh/index.d.ts +0 -1
  85. package/dist/modules/integrations/hiveposh/queries/get-hiveposh-links-query-options.d.ts +0 -44
  86. package/dist/modules/integrations/hiveposh/queries/index.d.ts +0 -1
  87. package/dist/modules/integrations/hivesigner/index.d.ts +0 -5
  88. package/dist/modules/integrations/hivesigner/queries/get-decode-memo-query-options.d.ts +0 -8
  89. package/dist/modules/integrations/hivesigner/queries/index.d.ts +0 -1
  90. package/dist/modules/integrations/index.d.ts +0 -4
  91. package/dist/modules/integrations/plausible/index.d.ts +0 -1
  92. package/dist/modules/integrations/plausible/queries/get-stats-query-options.d.ts +0 -29
  93. package/dist/modules/integrations/plausible/queries/index.d.ts +0 -1
  94. package/dist/modules/keychain/index.d.ts +0 -2
  95. package/dist/modules/keychain/keychain.d.ts +0 -10
  96. package/dist/modules/operations/index.d.ts +0 -2
  97. package/dist/modules/operations/mutations/index.d.ts +0 -3
  98. package/dist/modules/operations/mutations/sign-operation-by-hivesigner.d.ts +0 -4
  99. package/dist/modules/operations/mutations/sign-operation-by-key.d.ts +0 -5
  100. package/dist/modules/operations/mutations/sign-operation-by-keychain.d.ts +0 -5
  101. package/dist/modules/operations/queries/get-chain-properties-query-options.d.ts +0 -8
  102. package/dist/modules/operations/queries/index.d.ts +0 -1
  103. package/dist/modules/posts/index.d.ts +0 -3
  104. package/dist/modules/posts/mutations/add-fragment.d.ts +0 -5
  105. package/dist/modules/posts/mutations/edit-fragment.d.ts +0 -5
  106. package/dist/modules/posts/mutations/index.d.ts +0 -3
  107. package/dist/modules/posts/mutations/remove-fragment.d.ts +0 -1
  108. package/dist/modules/posts/queries/get-fragments-query-options.d.ts +0 -9
  109. package/dist/modules/posts/queries/get-promoted-posts-query-options.d.ts +0 -8
  110. package/dist/modules/posts/queries/get-trending-tags-query-options.d.ts +0 -12
  111. package/dist/modules/posts/queries/index.d.ts +0 -3
  112. package/dist/modules/posts/types/fragment.d.ts +0 -7
  113. package/dist/modules/posts/types/index.d.ts +0 -2
  114. package/dist/modules/posts/types/trending-tag.d.ts +0 -6
  115. package/dist/modules/resource-credits/index.d.ts +0 -2
  116. package/dist/modules/resource-credits/queries/get-account-rc-query-options.d.ts +0 -8
  117. package/dist/modules/resource-credits/queries/get-rc-stats-query-options.d.ts +0 -8
  118. package/dist/modules/resource-credits/queries/index.d.ts +0 -2
  119. package/dist/modules/resource-credits/types/index.d.ts +0 -1
  120. package/dist/modules/resource-credits/types/stats.d.ts +0 -67
@@ -1,1458 +0,0 @@
1
- var V = Object.defineProperty;
2
- var W = (e, t, n) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var T = (e, t, n) => W(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { QueryClient as F, useMutation as d, useQuery as S, useInfiniteQuery as z, queryOptions as p, useQueryClient as P, infiniteQueryOptions as R } from "@tanstack/react-query";
5
- import { Client as $, PrivateKey as _, cryptoUtils as L, RCAPI as X } from "@hiveio/dhive";
6
- import K from "hivesigner";
7
- import * as f from "remeda";
8
- class Y {
9
- constructor() {
10
- T(this, "length", 0);
11
- }
12
- clear() {
13
- throw new Error("Method not implemented.");
14
- }
15
- getItem(t) {
16
- return this[t];
17
- }
18
- key(t) {
19
- return Object.keys(this)[t];
20
- }
21
- removeItem(t) {
22
- delete this[t];
23
- }
24
- setItem(t, n) {
25
- this[t] = n;
26
- }
27
- }
28
- const c = {
29
- privateApiHost: "https://ecency.com",
30
- storage: typeof window > "u" ? new Y() : window.localStorage,
31
- storagePrefix: "ecency",
32
- hiveClient: new $(
33
- [
34
- "https://api.hive.blog",
35
- "https://api.deathwing.me",
36
- "https://rpc.mahdiyari.info",
37
- "https://api.openhive.network",
38
- "https://techcoderx.com",
39
- "https://hive-api.arcange.eu",
40
- "https://api.syncad.com",
41
- "https://anyx.io",
42
- "https://api.c0ff33a.uk",
43
- "https://hiveapi.actifit.io",
44
- "https://hive-api.3speak.tv"
45
- ],
46
- {
47
- timeout: 2e3,
48
- failoverThreshold: 2,
49
- consoleOnFailover: !0
50
- }
51
- ),
52
- heliusApiKey: void 0,
53
- queryClient: new F(),
54
- plausibleHost: "https://pl.ecency.com",
55
- spkNode: "https://spk.good-karma.xyz"
56
- };
57
- var j;
58
- ((e) => {
59
- function t(n) {
60
- c.queryClient = n;
61
- }
62
- e.setQueryClient = t;
63
- })(j || (j = {}));
64
- function Z(e) {
65
- let t = atob(e);
66
- if (t[0] === "{")
67
- return JSON.parse(t);
68
- }
69
- var E = /* @__PURE__ */ ((e) => (e.HIVE = "HIVE", e.HBD = "HBD", e.VESTS = "VESTS", e.SPK = "SPK", e))(E || {}), B = /* @__PURE__ */ ((e) => (e["@@000000021"] = "HIVE", e["@@000000013"] = "HBD", e["@@000000037"] = "VESTS", e))(B || {});
70
- function m(e) {
71
- if (typeof e == "string") {
72
- const t = e.split(" ");
73
- return {
74
- amount: parseFloat(t[0]),
75
- // @ts-ignore
76
- symbol: E[t[1]]
77
- };
78
- } else
79
- return {
80
- amount: parseFloat(e.amount.toString()) / Math.pow(10, e.precision),
81
- // @ts-ignore
82
- symbol: B[e.nai]
83
- };
84
- }
85
- const w = (e) => {
86
- try {
87
- const t = c.storage.getItem(
88
- c.storagePrefix + "_user_" + e
89
- );
90
- return Z(JSON.parse(t));
91
- } catch (t) {
92
- console.error(t);
93
- return;
94
- }
95
- }, l = (e) => w(e) && w(e).accessToken, H = (e) => w(e) && w(e).postingKey, J = (e) => w(e) && w(e).loginType, _e = (e) => w(e) && w(e).refreshToken;
96
- function ee() {
97
- return new Promise((e) => {
98
- var t;
99
- (t = window.hive_keychain) == null || t.requestHandshake(() => {
100
- e();
101
- });
102
- });
103
- }
104
- const C = (e, t, n, o = null) => new Promise((r, a) => {
105
- var s;
106
- (s = window.hive_keychain) == null || s.requestBroadcast(
107
- e,
108
- t,
109
- n,
110
- (i) => {
111
- i.success || a({ message: "Operation cancelled" }), r(i);
112
- },
113
- o
114
- );
115
- }), te = (e, t, n, o, r, a = null) => new Promise((s, i) => {
116
- var u;
117
- (u = window.hive_keychain) == null || u.requestCustomJson(
118
- e,
119
- t,
120
- n,
121
- o,
122
- r,
123
- (h) => {
124
- h.success || i({ message: "Operation cancelled" }), s(h);
125
- },
126
- a
127
- );
128
- }), ve = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
129
- __proto__: null,
130
- broadcast: C,
131
- customJson: te,
132
- handshake: ee
133
- }, Symbol.toStringTag, { value: "Module" }));
134
- function ne(e = [], t, n, o = () => {
135
- }) {
136
- return d({
137
- onSuccess: o,
138
- mutationKey: [...e, t],
139
- mutationFn: async (r) => {
140
- if (!t)
141
- throw new Error(
142
- "[Core][Broadcast] Attempted to call broadcast API with anon user"
143
- );
144
- const a = H(t);
145
- if (a) {
146
- const u = _.fromString(a);
147
- return c.hiveClient.broadcast.sendOperations(
148
- n(r),
149
- u
150
- );
151
- }
152
- const s = J(t);
153
- if (s && s == "keychain")
154
- return C(
155
- t,
156
- n(r),
157
- "Posting"
158
- ).then((u) => u.result);
159
- let i = l(t);
160
- if (i)
161
- return (await new K.Client({
162
- accessToken: i
163
- }).broadcast(n(r))).result;
164
- throw new Error(
165
- "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
166
- );
167
- }
168
- });
169
- }
170
- async function oe(e, t, n) {
171
- if (!e)
172
- throw new Error(
173
- "[Core][Broadcast] Attempted to call broadcast API with anon user"
174
- );
175
- const o = {
176
- id: t,
177
- required_auths: [],
178
- required_posting_auths: [e],
179
- json: JSON.stringify(n)
180
- }, r = H(e);
181
- if (r) {
182
- const i = _.fromString(r);
183
- return c.hiveClient.broadcast.json(
184
- o,
185
- i
186
- );
187
- }
188
- const a = J(e);
189
- if (a && a == "keychain")
190
- return C(e, [["custom_json", o]], "Posting").then((i) => i.result);
191
- let s = l(e);
192
- if (s)
193
- return (await new K.Client({
194
- accessToken: s
195
- }).customJson([], [e], t, JSON.stringify(n))).result;
196
- throw new Error(
197
- "[SDK][Broadcast] – cannot broadcast w/o posting key or token"
198
- );
199
- }
200
- function me() {
201
- return new F({
202
- defaultOptions: {
203
- queries: {
204
- // With SSR, we usually want to set some default staleTime
205
- // above 0 to avoid refetching immediately on the client
206
- // staleTime: 60 * 1000,
207
- refetchOnWindowFocus: !1,
208
- refetchOnMount: !1
209
- }
210
- }
211
- });
212
- }
213
- const y = () => c.queryClient;
214
- var Q;
215
- ((e) => {
216
- function t(i) {
217
- return y().getQueryData(i);
218
- }
219
- e.getQueryData = t;
220
- function n(i) {
221
- return y().getQueryData(i);
222
- }
223
- e.getInfiniteQueryData = n;
224
- async function o(i) {
225
- return await y().prefetchQuery(i), t(i.queryKey);
226
- }
227
- e.prefetchQuery = o;
228
- async function r(i) {
229
- return await y().prefetchInfiniteQuery(i), n(i.queryKey);
230
- }
231
- e.prefetchInfiniteQuery = r;
232
- function a(i) {
233
- return {
234
- prefetch: () => o(i),
235
- getData: () => t(i.queryKey),
236
- useClientQuery: () => S(i),
237
- fetchAndGet: () => y().fetchQuery(i)
238
- };
239
- }
240
- e.generateClientServerQuery = a;
241
- function s(i) {
242
- return {
243
- prefetch: () => r(i),
244
- getData: () => n(i.queryKey),
245
- useClientQuery: () => z(i),
246
- fetchAndGet: () => y().fetchInfiniteQuery(i)
247
- };
248
- }
249
- e.generateClientServerInfiniteQuery = s;
250
- })(Q || (Q = {}));
251
- function we() {
252
- return p({
253
- queryKey: ["core", "dynamic-props"],
254
- refetchInterval: 6e4,
255
- staleTime: 6e4,
256
- refetchOnMount: !0,
257
- queryFn: async () => {
258
- const e = await c.hiveClient.database.getDynamicGlobalProperties().then((v) => ({
259
- total_vesting_fund_hive: v.total_vesting_fund_hive || v.total_vesting_fund_steem,
260
- total_vesting_shares: v.total_vesting_shares,
261
- hbd_print_rate: v.hbd_print_rate || v.sbd_print_rate,
262
- hbd_interest_rate: v.hbd_interest_rate,
263
- head_block_number: v.head_block_number,
264
- vesting_reward_percent: v.vesting_reward_percent,
265
- virtual_supply: v.virtual_supply
266
- })), t = await c.hiveClient.database.call("get_feed_history"), n = await c.hiveClient.database.call(
267
- "get_chain_properties"
268
- ), o = await c.hiveClient.database.call(
269
- "get_reward_fund",
270
- ["post"]
271
- ), r = m(e.total_vesting_fund_hive).amount / m(e.total_vesting_shares).amount * 1e6, a = m(t.current_median_history.base).amount, s = m(t.current_median_history.quote).amount, i = parseFloat(o.recent_claims), u = m(o.reward_balance).amount, h = e.hbd_print_rate, k = e.hbd_interest_rate, O = e.head_block_number, I = m(
272
- e.total_vesting_fund_hive
273
- ).amount, M = m(
274
- e.total_vesting_shares
275
- ).amount, x = m(e.virtual_supply).amount, U = e.vesting_reward_percent, G = n.account_creation_fee;
276
- return {
277
- hivePerMVests: r,
278
- base: a,
279
- quote: s,
280
- fundRecentClaims: i,
281
- fundRewardBalance: u,
282
- hbdPrintRate: h,
283
- hbdInterestRate: k,
284
- headBlock: O,
285
- totalVestingFund: I,
286
- totalVestingShares: M,
287
- virtualSupply: x,
288
- vestingRewardPercent: U,
289
- accountCreationFee: G
290
- };
291
- }
292
- });
293
- }
294
- function b(e) {
295
- return p({
296
- queryKey: ["get-account-full", e],
297
- queryFn: async () => {
298
- if (!e)
299
- throw new Error("[SDK] Username is empty");
300
- const t = await c.hiveClient.database.getAccounts([
301
- e
302
- ]);
303
- if (!t[0])
304
- throw new Error("[SDK] No account with given username");
305
- const n = JSON.parse(t[0].posting_json_metadata).profile;
306
- let o;
307
- try {
308
- o = await c.hiveClient.database.call(
309
- "get_follow_count",
310
- [e]
311
- );
312
- } catch {
313
- }
314
- const r = await c.hiveClient.call(
315
- "condenser_api",
316
- "get_account_reputations",
317
- [e, 1]
318
- );
319
- return {
320
- name: t[0].name,
321
- owner: t[0].owner,
322
- active: t[0].active,
323
- posting: t[0].posting,
324
- memo_key: t[0].memo_key,
325
- post_count: t[0].post_count,
326
- created: t[0].created,
327
- posting_json_metadata: t[0].posting_json_metadata,
328
- last_vote_time: t[0].last_vote_time,
329
- last_post: t[0].last_post,
330
- json_metadata: t[0].json_metadata,
331
- reward_hive_balance: t[0].reward_hive_balance,
332
- reward_hbd_balance: t[0].reward_hbd_balance,
333
- reward_vesting_hive: t[0].reward_vesting_hive,
334
- reward_vesting_balance: t[0].reward_vesting_balance,
335
- balance: t[0].balance,
336
- hbd_balance: t[0].hbd_balance,
337
- savings_balance: t[0].savings_balance,
338
- savings_hbd_balance: t[0].savings_hbd_balance,
339
- savings_hbd_last_interest_payment: t[0].savings_hbd_last_interest_payment,
340
- savings_hbd_seconds_last_update: t[0].savings_hbd_seconds_last_update,
341
- savings_hbd_seconds: t[0].savings_hbd_seconds,
342
- next_vesting_withdrawal: t[0].next_vesting_withdrawal,
343
- pending_claimed_accounts: t[0].pending_claimed_accounts,
344
- vesting_shares: t[0].vesting_shares,
345
- delegated_vesting_shares: t[0].delegated_vesting_shares,
346
- received_vesting_shares: t[0].received_vesting_shares,
347
- vesting_withdraw_rate: t[0].vesting_withdraw_rate,
348
- to_withdraw: t[0].to_withdraw,
349
- withdrawn: t[0].withdrawn,
350
- witness_votes: t[0].witness_votes,
351
- proxy: t[0].proxy,
352
- recovery_account: t[0].recovery_account,
353
- proxied_vsf_votes: t[0].proxied_vsf_votes,
354
- voting_manabar: t[0].voting_manabar,
355
- voting_power: t[0].voting_power,
356
- downvote_manabar: t[0].downvote_manabar,
357
- follow_stats: o,
358
- reputation: r[0].reputation,
359
- profile: {
360
- ...n,
361
- reputation: r[0].reputation
362
- }
363
- };
364
- },
365
- enabled: !!e,
366
- staleTime: 6e4
367
- });
368
- }
369
- function be(e, t = 5, n = []) {
370
- return p({
371
- queryKey: ["accounts", "search", e, n],
372
- enabled: !!e,
373
- queryFn: async () => (await c.hiveClient.database.call(
374
- "lookup_accounts",
375
- [e, t]
376
- )).filter(
377
- (r) => n.length > 0 ? !n.includes(r) : !0
378
- )
379
- });
380
- }
381
- function Se(e) {
382
- return p({
383
- queryKey: ["accounts", "check-wallet-pending", e],
384
- queryFn: async () => await (await fetch(
385
- c.privateApiHost + "/private-api/wallets-chkuser",
386
- {
387
- method: "POST",
388
- headers: {
389
- "Content-Type": "application/json"
390
- },
391
- body: JSON.stringify({
392
- username: e
393
- })
394
- }
395
- )).json(),
396
- enabled: !!e,
397
- refetchOnMount: !0
398
- });
399
- }
400
- function re(e, t) {
401
- return p({
402
- queryKey: ["accounts", "relations", e, t],
403
- enabled: !!e && !!t,
404
- refetchOnMount: !1,
405
- refetchInterval: 36e5,
406
- queryFn: async () => await c.hiveClient.call(
407
- "bridge",
408
- "get_relationship_between_accounts",
409
- [e, t]
410
- )
411
- });
412
- }
413
- function ke(e) {
414
- return p({
415
- queryKey: ["accounts", "subscriptions", e],
416
- enabled: !!e,
417
- queryFn: async () => await c.hiveClient.call(
418
- "bridge",
419
- "list_all_subscriptions",
420
- {
421
- account: e
422
- }
423
- ) ?? []
424
- });
425
- }
426
- function Ke(e) {
427
- return p({
428
- queryKey: ["accounts", "bookmarks", e],
429
- enabled: !!e,
430
- queryFn: async () => {
431
- if (!e)
432
- throw new Error("[SDK][Accounts][Bookmarks] – no active user");
433
- return await (await fetch(
434
- c.privateApiHost + "/private-api/bookmarks",
435
- {
436
- method: "POST",
437
- headers: {
438
- "Content-Type": "application/json"
439
- },
440
- body: JSON.stringify({ code: l(e) })
441
- }
442
- )).json();
443
- }
444
- });
445
- }
446
- function Ce(e) {
447
- return p({
448
- queryKey: ["accounts", "favourites", e],
449
- enabled: !!e,
450
- queryFn: async () => {
451
- if (!e)
452
- throw new Error("[SDK][Accounts][Favourites] – no active user");
453
- return await (await fetch(
454
- c.privateApiHost + "/private-api/favorites",
455
- {
456
- method: "POST",
457
- headers: {
458
- "Content-Type": "application/json"
459
- },
460
- body: JSON.stringify({ code: l(e) })
461
- }
462
- )).json();
463
- }
464
- });
465
- }
466
- function Oe(e) {
467
- return p({
468
- enabled: !!e,
469
- queryKey: ["accounts", "recoveries", e],
470
- queryFn: async () => (await fetch(
471
- c.privateApiHost + "/private-api/recoveries",
472
- {
473
- method: "POST",
474
- headers: {
475
- "Content-Type": "application/json"
476
- },
477
- body: JSON.stringify({ code: l(e) })
478
- }
479
- )).json()
480
- });
481
- }
482
- function qe(e) {
483
- return p({
484
- enabled: !!e,
485
- queryKey: ["accounts", "recoveries", e, "pending-request"],
486
- queryFn: () => c.hiveClient.call(
487
- "database_api",
488
- "find_change_recovery_account_requests",
489
- { accounts: [e] }
490
- )
491
- });
492
- }
493
- function ie(e) {
494
- return e == null ? void 0 : e.map(({ meta: t, ...n }) => {
495
- if (!t || typeof t != "object")
496
- return { ...n, meta: t };
497
- const { privateKey: o, username: r, ...a } = t;
498
- return { ...n, meta: a };
499
- });
500
- }
501
- function D({
502
- profile: e,
503
- tokens: t,
504
- data: n
505
- }) {
506
- const o = f.pipe(
507
- JSON.parse((n == null ? void 0 : n.posting_json_metadata) || "{}").profile,
508
- f.mergeDeep(e ?? {})
509
- );
510
- return t && t.length > 0 && (o.tokens = t), o.tokens = ie(o.tokens), o;
511
- }
512
- function Ae(e) {
513
- const t = P(), { data: n } = S(b(e));
514
- return ne(
515
- ["accounts", "update"],
516
- e,
517
- (o) => {
518
- if (!n)
519
- throw new Error("[SDK][Accounts] – cannot update not existing account");
520
- return [
521
- [
522
- "account_update2",
523
- {
524
- account: e,
525
- json_metadata: "",
526
- extensions: [],
527
- posting_json_metadata: JSON.stringify({
528
- profile: D({ ...o, data: n })
529
- })
530
- }
531
- ]
532
- ];
533
- },
534
- (o, r) => t.setQueryData(
535
- b(e).queryKey,
536
- (a) => {
537
- if (!a)
538
- return a;
539
- const s = f.clone(a);
540
- return s.profile = D({ ...r, data: a }), s;
541
- }
542
- )
543
- );
544
- }
545
- function Te(e, t, n, o) {
546
- return d({
547
- mutationKey: ["accounts", "relation", "update", e, t],
548
- mutationFn: async (r) => {
549
- const a = re(
550
- e,
551
- t
552
- );
553
- await y().prefetchQuery(a);
554
- const s = y().getQueryData(
555
- a.queryKey
556
- );
557
- return await oe(e, "follow", [
558
- "follow",
559
- {
560
- follower: e,
561
- following: t,
562
- what: [
563
- ...r === "toggle-ignore" && !(s != null && s.ignores) ? ["ignore"] : [],
564
- ...r === "toggle-follow" && !(s != null && s.follows) ? ["blog"] : []
565
- ]
566
- }
567
- ]), {
568
- ...s,
569
- ignores: r === "toggle-ignore" ? !(s != null && s.ignores) : s == null ? void 0 : s.ignores,
570
- follows: r === "toggle-follow" ? !(s != null && s.follows) : s == null ? void 0 : s.follows
571
- };
572
- },
573
- onError: o,
574
- onSuccess(r) {
575
- n(r), y().setQueryData(
576
- ["accounts", "relations", e, t],
577
- r
578
- );
579
- }
580
- });
581
- }
582
- function je(e, t, n) {
583
- return d({
584
- mutationKey: ["accounts", "bookmarks", "add", e],
585
- mutationFn: async ({ author: o, permlink: r }) => {
586
- if (!e)
587
- throw new Error("[SDK][Account][Bookmarks] – no active user");
588
- return (await fetch(
589
- c.privateApiHost + "/private-api/bookmarks-add",
590
- {
591
- method: "POST",
592
- headers: {
593
- "Content-Type": "application/json"
594
- },
595
- body: JSON.stringify({
596
- author: o,
597
- permlink: r,
598
- code: l(e)
599
- })
600
- }
601
- )).json();
602
- },
603
- onSuccess: () => {
604
- t(), y().invalidateQueries({
605
- queryKey: ["accounts", "bookmarks", e]
606
- });
607
- },
608
- onError: n
609
- });
610
- }
611
- function Qe(e, t, n) {
612
- return d({
613
- mutationKey: ["accounts", "bookmarks", "delete", e],
614
- mutationFn: async (o) => {
615
- if (!e)
616
- throw new Error("[SDK][Account][Bookmarks] – no active user");
617
- return (await fetch(
618
- c.privateApiHost + "/private-api/bookmarks-delete",
619
- {
620
- method: "POST",
621
- headers: {
622
- "Content-Type": "application/json"
623
- },
624
- body: JSON.stringify({
625
- id: o,
626
- code: l(e)
627
- })
628
- }
629
- )).json();
630
- },
631
- onSuccess: () => {
632
- t(), y().invalidateQueries({
633
- queryKey: ["accounts", "bookmarks", e]
634
- });
635
- },
636
- onError: n
637
- });
638
- }
639
- function De(e, t, n) {
640
- return d({
641
- mutationKey: ["accounts", "favourites", "add", e],
642
- mutationFn: async (o) => {
643
- if (!e)
644
- throw new Error("[SDK][Account][Bookmarks] – no active user");
645
- return (await fetch(
646
- c.privateApiHost + "/private-api/favorites-add",
647
- {
648
- method: "POST",
649
- headers: {
650
- "Content-Type": "application/json"
651
- },
652
- body: JSON.stringify({
653
- account: o,
654
- code: l(e)
655
- })
656
- }
657
- )).json();
658
- },
659
- onSuccess: () => {
660
- t(), y().invalidateQueries({
661
- queryKey: ["accounts", "favourites", e]
662
- });
663
- },
664
- onError: n
665
- });
666
- }
667
- function Fe(e, t, n) {
668
- return d({
669
- mutationKey: ["accounts", "favourites", "add", e],
670
- mutationFn: async (o) => {
671
- if (!e)
672
- throw new Error("[SDK][Account][Bookmarks] – no active user");
673
- return (await fetch(
674
- c.privateApiHost + "/private-api/favorites-delete",
675
- {
676
- method: "POST",
677
- headers: {
678
- "Content-Type": "application/json"
679
- },
680
- body: JSON.stringify({
681
- account: o,
682
- code: l(e)
683
- })
684
- }
685
- )).json();
686
- },
687
- onSuccess: () => {
688
- t(), y().invalidateQueries({
689
- queryKey: ["accounts", "favourites", e]
690
- });
691
- },
692
- onError: n
693
- });
694
- }
695
- function se(e, t) {
696
- const n = f.fromEntries(
697
- e.map(([o, r]) => [o.toString(), r])
698
- );
699
- return f.pipe(
700
- n,
701
- f.merge(f.fromEntries(t)),
702
- f.entries(),
703
- f.sortBy(([o]) => o)
704
- );
705
- }
706
- function ae(e, t) {
707
- const { data: n } = S(b(e));
708
- return d({
709
- mutationKey: ["accounts", "keys-update", e],
710
- mutationFn: async ({ keys: o, keepCurrent: r = !1, currentKey: a }) => {
711
- if (!n)
712
- throw new Error(
713
- "[SDK][Update password] – cannot update keys for anon user"
714
- );
715
- const s = (i) => {
716
- const u = f.clone(n[i]);
717
- return u.key_auths = se(
718
- r ? u.key_auths : [],
719
- o.map(
720
- (h, k) => [h[i].createPublic().toString(), k + 1]
721
- )
722
- ), u;
723
- };
724
- return c.hiveClient.broadcast.updateAccount(
725
- {
726
- account: e,
727
- json_metadata: n.json_metadata,
728
- owner: s("owner"),
729
- active: s("active"),
730
- posting: s("posting"),
731
- memo_key: r ? n.memo_key : o[0].memo_key.createPublic().toString()
732
- },
733
- a
734
- );
735
- },
736
- ...t
737
- });
738
- }
739
- function Pe(e, t) {
740
- const { data: n } = S(b(e)), { mutateAsync: o } = ae(e);
741
- return d({
742
- mutationKey: ["accounts", "password-update", e],
743
- mutationFn: async ({
744
- newPassword: r,
745
- currentPassword: a,
746
- keepCurrent: s
747
- }) => {
748
- if (!n)
749
- throw new Error(
750
- "[SDK][Update password] – cannot update password for anon user"
751
- );
752
- const i = _.fromLogin(
753
- e,
754
- a,
755
- "owner"
756
- );
757
- return o({
758
- currentKey: i,
759
- keepCurrent: s,
760
- keys: [
761
- {
762
- owner: _.fromLogin(e, r, "owner"),
763
- active: _.fromLogin(e, r, "active"),
764
- posting: _.fromLogin(e, r, "posting"),
765
- memo_key: _.fromLogin(e, r, "memo")
766
- }
767
- ]
768
- });
769
- },
770
- ...t
771
- });
772
- }
773
- function Ee(e, t) {
774
- const n = P(), { data: o } = S(b(e));
775
- return d({
776
- mutationKey: ["accounts", "revoke-posting", o == null ? void 0 : o.name],
777
- mutationFn: async ({ accountName: r, type: a, key: s }) => {
778
- if (!o)
779
- throw new Error(
780
- "[SDK][Accounts] – cannot revoke posting for anonymous user"
781
- );
782
- const i = f.pipe(
783
- {},
784
- f.mergeDeep(o.posting)
785
- );
786
- i.account_auths = i.account_auths.filter(
787
- ([h]) => h !== r
788
- );
789
- const u = {
790
- account: o.name,
791
- posting: i,
792
- memo_key: o.memo_key,
793
- json_metadata: o.json_metadata
794
- };
795
- if (a === "key" && s)
796
- return c.hiveClient.broadcast.updateAccount(u, s);
797
- if (a === "keychain")
798
- return C(
799
- o.name,
800
- [["account_update", u]],
801
- "Active"
802
- );
803
- {
804
- const h = {
805
- callback: `https://ecency.com/@${o.name}/permissions`
806
- };
807
- return K.sendOperation(
808
- ["account_update", u],
809
- h,
810
- () => {
811
- }
812
- );
813
- }
814
- },
815
- onError: t.onError,
816
- onSuccess: (r, a, s) => {
817
- var i;
818
- (i = t.onSuccess) == null || i.call(t, r, a, s), n.setQueryData(
819
- b(e).queryKey,
820
- (u) => {
821
- var h, k;
822
- return {
823
- ...u,
824
- posting: {
825
- ...u == null ? void 0 : u.posting,
826
- account_auths: ((k = (h = u == null ? void 0 : u.posting) == null ? void 0 : h.account_auths) == null ? void 0 : k.filter(
827
- ([O]) => O !== a.accountName
828
- )) ?? []
829
- }
830
- };
831
- }
832
- );
833
- }
834
- });
835
- }
836
- function Be(e, t) {
837
- const { data: n } = S(b(e));
838
- return d({
839
- mutationKey: ["accounts", "recovery", n == null ? void 0 : n.name],
840
- mutationFn: async ({ accountName: o, type: r, key: a, email: s }) => {
841
- if (!n)
842
- throw new Error(
843
- "[SDK][Accounts] – cannot change recovery for anonymous user"
844
- );
845
- const i = {
846
- account_to_recover: n.name,
847
- new_recovery_account: o,
848
- extensions: []
849
- };
850
- if (r === "ecency")
851
- return fetch(c.privateApiHost + "/private-api/recoveries-add", {
852
- method: "POST",
853
- body: JSON.stringify({
854
- code: l(n.name),
855
- email: s,
856
- publicKeys: [
857
- ...n.owner.key_auths,
858
- ...n.active.key_auths,
859
- ...n.posting.key_auths,
860
- n.memo_key
861
- ]
862
- })
863
- });
864
- if (r === "key" && a)
865
- return c.hiveClient.broadcast.sendOperations(
866
- [["change_recovery_account", i]],
867
- a
868
- );
869
- if (r === "keychain")
870
- return C(
871
- n.name,
872
- [["change_recovery_account", i]],
873
- "Active"
874
- );
875
- {
876
- const u = {
877
- callback: `https://ecency.com/@${n.name}/permissions`
878
- };
879
- return K.sendOperation(
880
- ["change_recovery_account", i],
881
- u,
882
- () => {
883
- }
884
- );
885
- }
886
- },
887
- onError: t.onError,
888
- onSuccess: t.onSuccess
889
- });
890
- }
891
- function He(e, t) {
892
- const { data: n } = S(b(e));
893
- return d({
894
- mutationKey: ["accounts", "revoke-key", n == null ? void 0 : n.name],
895
- mutationFn: async ({ currentKey: o, revokingKey: r }) => {
896
- if (!n)
897
- throw new Error(
898
- "[SDK][Update password] – cannot update keys for anon user"
899
- );
900
- const a = (s) => {
901
- const i = f.clone(n[s]);
902
- return i.key_auths = i.key_auths.filter(
903
- ([u]) => u !== r.toString()
904
- ), i;
905
- };
906
- return c.hiveClient.broadcast.updateAccount(
907
- {
908
- account: n.name,
909
- json_metadata: n.json_metadata,
910
- owner: a("owner"),
911
- active: a("active"),
912
- posting: a("posting"),
913
- memo_key: n.memo_key
914
- },
915
- o
916
- );
917
- },
918
- ...t
919
- });
920
- }
921
- function Je(e) {
922
- return d({
923
- mutationKey: ["operations", "sign", e],
924
- mutationFn: ({
925
- operation: t,
926
- keyOrSeed: n
927
- }) => {
928
- if (!e)
929
- throw new Error("[Operations][Sign] – cannot sign op with anon user");
930
- let o;
931
- return n.split(" ").length === 12 ? o = _.fromLogin(e, n, "active") : L.isWif(n) ? o = _.fromString(n) : o = _.from(n), c.hiveClient.broadcast.sendOperations(
932
- [t],
933
- o
934
- );
935
- }
936
- });
937
- }
938
- function Ne(e, t = "Active") {
939
- return d({
940
- mutationKey: ["operations", "sign-keychain", e],
941
- mutationFn: ({ operation: n }) => {
942
- if (!e)
943
- throw new Error(
944
- "[SDK][Keychain] – cannot sign operation with anon user"
945
- );
946
- return C(e, [n], t);
947
- }
948
- });
949
- }
950
- function Ie(e = "/") {
951
- return d({
952
- mutationKey: ["operations", "sign-hivesigner", e],
953
- mutationFn: async ({ operation: t }) => K.sendOperation(t, { callback: e }, () => {
954
- })
955
- });
956
- }
957
- function Me() {
958
- return p({
959
- queryKey: ["operations", "chain-properties"],
960
- queryFn: async () => await c.hiveClient.database.getChainProperties()
961
- });
962
- }
963
- function xe(e = 20) {
964
- return R({
965
- queryKey: ["posts", "trending-tags"],
966
- queryFn: async ({ pageParam: { afterTag: t } }) => c.hiveClient.database.call("get_trending_tags", [t, e]).then(
967
- (n) => n.filter((o) => o.name !== "").filter((o) => !o.name.startsWith("hive-")).map((o) => o.name)
968
- ),
969
- initialPageParam: { afterTag: "" },
970
- getNextPageParam: (t) => ({
971
- afterTag: t == null ? void 0 : t[(t == null ? void 0 : t.length) - 1]
972
- }),
973
- staleTime: 1 / 0,
974
- refetchOnMount: !0
975
- });
976
- }
977
- function A(e) {
978
- return p({
979
- queryKey: ["posts", "fragments", e],
980
- queryFn: async () => (await fetch(
981
- c.privateApiHost + "/private-api/fragments",
982
- {
983
- method: "POST",
984
- body: JSON.stringify({
985
- code: l(e)
986
- }),
987
- headers: {
988
- "Content-Type": "application/json"
989
- }
990
- }
991
- )).json(),
992
- enabled: !!e
993
- });
994
- }
995
- function Ue(e = "feed") {
996
- return p({
997
- queryKey: ["posts", "promoted", e],
998
- queryFn: async () => {
999
- const t = new URL(
1000
- c.privateApiHost + "/private-api/promoted-entries"
1001
- );
1002
- return e === "waves" && t.searchParams.append("short_content", "1"), await (await fetch(t.toString(), {
1003
- method: "GET",
1004
- headers: {
1005
- "Content-Type": "application/json"
1006
- }
1007
- })).json();
1008
- }
1009
- });
1010
- }
1011
- function Ge(e) {
1012
- return d({
1013
- mutationKey: ["posts", "add-fragment", e],
1014
- mutationFn: async ({ title: t, body: n }) => (await fetch(
1015
- c.privateApiHost + "/private-api/fragments-add",
1016
- {
1017
- method: "POST",
1018
- body: JSON.stringify({
1019
- code: l(e),
1020
- title: t,
1021
- body: n
1022
- }),
1023
- headers: {
1024
- "Content-Type": "application/json"
1025
- }
1026
- }
1027
- )).json(),
1028
- onSuccess(t) {
1029
- y().setQueryData(
1030
- A(e).queryKey,
1031
- (n) => [t, ...n ?? []]
1032
- );
1033
- }
1034
- });
1035
- }
1036
- function Ve(e, t) {
1037
- return d({
1038
- mutationKey: ["posts", "edit-fragment", e, t],
1039
- mutationFn: async ({ title: n, body: o }) => (await fetch(
1040
- c.privateApiHost + "/private-api/fragments-update",
1041
- {
1042
- method: "POST",
1043
- body: JSON.stringify({
1044
- code: l(e),
1045
- id: t,
1046
- title: n,
1047
- body: o
1048
- }),
1049
- headers: {
1050
- "Content-Type": "application/json"
1051
- }
1052
- }
1053
- )).json(),
1054
- onSuccess(n) {
1055
- y().setQueryData(
1056
- A(e).queryKey,
1057
- (o) => {
1058
- if (!o)
1059
- return [];
1060
- const r = o.findIndex(({ id: a }) => a === t);
1061
- return r >= 0 && (o[r] = n), [...o];
1062
- }
1063
- );
1064
- }
1065
- });
1066
- }
1067
- function We(e, t) {
1068
- return d({
1069
- mutationKey: ["posts", "remove-fragment", e],
1070
- mutationFn: async () => fetch(c.privateApiHost + "/private-api/fragments-delete", {
1071
- method: "POST",
1072
- body: JSON.stringify({
1073
- code: l(e),
1074
- id: t
1075
- }),
1076
- headers: {
1077
- "Content-Type": "application/json"
1078
- }
1079
- }),
1080
- onSuccess() {
1081
- y().setQueryData(
1082
- A(e).queryKey,
1083
- (n) => [...n ?? []].filter(({ id: o }) => o !== t)
1084
- );
1085
- }
1086
- });
1087
- }
1088
- function N(e, t) {
1089
- return d({
1090
- mutationKey: ["analytics", t],
1091
- mutationFn: async () => {
1092
- if (!t)
1093
- throw new Error("[SDK][Analytics] – no activity type provided");
1094
- await fetch(c.plausibleHost + "/api/event", {
1095
- method: "POST",
1096
- headers: {
1097
- "Content-Type": "application/json"
1098
- },
1099
- body: JSON.stringify({
1100
- name: t,
1101
- url: window.location.href,
1102
- domain: window.location.host,
1103
- props: {
1104
- username: e
1105
- }
1106
- })
1107
- });
1108
- }
1109
- });
1110
- }
1111
- const ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1112
- __proto__: null,
1113
- useRecordActivity: N
1114
- }, Symbol.toStringTag, { value: "Module" }));
1115
- function ce(e, t) {
1116
- return p({
1117
- queryKey: ["integrations", "hivesigner", "decode-memo", e],
1118
- queryFn: async () => {
1119
- const n = l(e);
1120
- if (n)
1121
- return new K.Client({
1122
- accessToken: n
1123
- }).decode(t);
1124
- }
1125
- });
1126
- }
1127
- const ue = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1128
- __proto__: null,
1129
- getDecodeMemoQueryOptions: ce
1130
- }, Symbol.toStringTag, { value: "Module" })), pe = {
1131
- queries: ue
1132
- };
1133
- function q(e) {
1134
- return p({
1135
- queryKey: ["integrations", "3speak", "authenticate", e],
1136
- enabled: !!e,
1137
- queryFn: async () => {
1138
- if (!e)
1139
- throw new Error("[SDK][Integrations][3Speak] – anon user");
1140
- const t = await fetch(
1141
- `https://studio.3speak.tv/mobile/login?username=${e}&hivesigner=true`,
1142
- {
1143
- headers: {
1144
- "Content-Type": "application/json"
1145
- }
1146
- }
1147
- ), n = pe.queries.getDecodeMemoQueryOptions(
1148
- e,
1149
- (await t.json()).memo
1150
- );
1151
- await y().prefetchQuery(n);
1152
- const { memoDecoded: o } = y().getQueryData(
1153
- n.queryKey
1154
- );
1155
- return o.replace("#", "");
1156
- }
1157
- });
1158
- }
1159
- function ye(e) {
1160
- return p({
1161
- queryKey: ["integrations", "3speak", "videos", e],
1162
- enabled: !!e,
1163
- queryFn: async () => {
1164
- await y().prefetchQuery(
1165
- q(e)
1166
- );
1167
- const t = y().getQueryData(
1168
- q(e).queryKey
1169
- );
1170
- return await (await fetch(
1171
- "https://studio.3speak.tv/mobile/api/my-videos",
1172
- {
1173
- headers: {
1174
- "Content-Type": "application/json",
1175
- Authorization: `Bearer ${t}`
1176
- }
1177
- }
1178
- )).json();
1179
- }
1180
- });
1181
- }
1182
- const de = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1183
- __proto__: null,
1184
- getAccountTokenQueryOptions: q,
1185
- getAccountVideosQueryOptions: ye
1186
- }, Symbol.toStringTag, { value: "Module" })), Re = {
1187
- queries: de
1188
- };
1189
- function $e(e) {
1190
- return p({
1191
- queryKey: ["integrations", "hiveposh", "links", e],
1192
- queryFn: async () => {
1193
- const n = await (await fetch(
1194
- `https://hiveposh.com/api/v0/linked-accounts/${e}`,
1195
- {
1196
- headers: {
1197
- "Content-Type": "application/json"
1198
- }
1199
- }
1200
- )).json();
1201
- return {
1202
- twitter: {
1203
- username: n.twitter_username,
1204
- profile: n.twitter_profile
1205
- },
1206
- reddit: {
1207
- username: n.reddit_username,
1208
- profile: n.reddit_profile
1209
- }
1210
- };
1211
- }
1212
- });
1213
- }
1214
- function Le({
1215
- url: e,
1216
- dimensions: t = [],
1217
- metrics: n = ["visitors", "pageviews", "visit_duration"],
1218
- enabled: o = !0
1219
- }) {
1220
- return p({
1221
- queryKey: ["integrations", "plausible", e, t, n],
1222
- queryFn: async () => await (await fetch("https://ecency.com/api/stats", {
1223
- method: "POST",
1224
- body: JSON.stringify({
1225
- metrics: n,
1226
- url: encodeURIComponent(e),
1227
- dimensions: t
1228
- }),
1229
- headers: {
1230
- "Content-Type": "application/json"
1231
- }
1232
- })).json(),
1233
- enabled: !!e && o
1234
- });
1235
- }
1236
- function Xe() {
1237
- return p({
1238
- queryKey: ["resource-credits", "stats"],
1239
- queryFn: async () => (await c.hiveClient.call(
1240
- "rc_api",
1241
- "get_rc_stats",
1242
- {}
1243
- )).rc_stats
1244
- });
1245
- }
1246
- function Ye(e) {
1247
- return p({
1248
- queryKey: ["resource-credits", "account", e],
1249
- queryFn: async () => new X(c.hiveClient).findRCAccounts([e]),
1250
- enabled: !!e
1251
- });
1252
- }
1253
- function Ze(e, t) {
1254
- return p({
1255
- queryKey: ["games", "status-check", t, e],
1256
- enabled: !!e,
1257
- queryFn: async () => {
1258
- if (!e)
1259
- throw new Error("[SDK][Games] – anon user in status check");
1260
- return await (await fetch(
1261
- c.privateApiHost + "/private-api/get-game",
1262
- {
1263
- method: "POST",
1264
- body: JSON.stringify({
1265
- game_type: t,
1266
- code: l(e)
1267
- }),
1268
- headers: {
1269
- "Content-Type": "application/json"
1270
- }
1271
- }
1272
- )).json();
1273
- }
1274
- });
1275
- }
1276
- function et(e, t, n) {
1277
- const { mutateAsync: o } = N(
1278
- e,
1279
- "spin-rolled"
1280
- );
1281
- return d({
1282
- mutationKey: ["games", "post", t, e],
1283
- mutationFn: async () => {
1284
- if (!e)
1285
- throw new Error("[SDK][Games] – anon user in game post");
1286
- return await (await fetch(
1287
- c.privateApiHost + "/private-api/post-game",
1288
- {
1289
- method: "POST",
1290
- body: JSON.stringify({
1291
- game_type: t,
1292
- code: l(e),
1293
- key: n
1294
- }),
1295
- headers: {
1296
- "Content-Type": "application/json"
1297
- }
1298
- }
1299
- )).json();
1300
- },
1301
- onSuccess() {
1302
- o();
1303
- }
1304
- });
1305
- }
1306
- function tt(e, t, n = 100, o = void 0, r = !0) {
1307
- return p({
1308
- queryKey: ["communities", "list", e, t, n],
1309
- enabled: r,
1310
- queryFn: async () => {
1311
- const a = await c.hiveClient.call(
1312
- "bridge",
1313
- "list_communities",
1314
- {
1315
- last: "",
1316
- limit: n,
1317
- sort: e === "hot" ? "rank" : e,
1318
- query: t || null,
1319
- observer: o
1320
- }
1321
- );
1322
- return a ? e === "hot" ? a.sort(() => Math.random() - 0.5) : a : [];
1323
- }
1324
- });
1325
- }
1326
- function nt(e, t) {
1327
- return p({
1328
- queryKey: ["community", "context", e, t],
1329
- enabled: !!e && !!t,
1330
- queryFn: async () => {
1331
- const n = await c.hiveClient.call(
1332
- "bridge",
1333
- "get_community_context",
1334
- {
1335
- account: e,
1336
- name: t
1337
- }
1338
- );
1339
- return {
1340
- role: (n == null ? void 0 : n.role) ?? "guest",
1341
- subscribed: (n == null ? void 0 : n.subscribed) ?? !1
1342
- };
1343
- }
1344
- });
1345
- }
1346
- var g = /* @__PURE__ */ ((e) => (e.OWNER = "owner", e.ADMIN = "admin", e.MOD = "mod", e.MEMBER = "member", e.GUEST = "guest", e.MUTED = "muted", e))(g || {});
1347
- const ot = {
1348
- owner: [
1349
- "admin",
1350
- "mod",
1351
- "member",
1352
- "guest",
1353
- "muted"
1354
- /* MUTED */
1355
- ],
1356
- admin: [
1357
- "mod",
1358
- "member",
1359
- "guest",
1360
- "muted"
1361
- /* MUTED */
1362
- ],
1363
- mod: [
1364
- "member",
1365
- "guest",
1366
- "muted"
1367
- /* MUTED */
1368
- ]
1369
- };
1370
- function rt(e, t) {
1371
- return e.startsWith("hive-3") || t === 3 ? "Council" : e.startsWith("hive-2") || t === 2 ? "Journal" : "Topic";
1372
- }
1373
- function it({
1374
- communityType: e,
1375
- userRole: t,
1376
- subscribed: n
1377
- }) {
1378
- const o = t === g.MUTED ? !1 : e === "Topic" ? !0 : [g.OWNER, g.ADMIN, g.MOD, g.MEMBER].includes(
1379
- t
1380
- ), r = (() => {
1381
- if (t === g.MUTED) return !1;
1382
- switch (e) {
1383
- case "Topic":
1384
- return !0;
1385
- case "Journal":
1386
- return t !== g.GUEST || n;
1387
- case "Council":
1388
- return o;
1389
- }
1390
- })(), a = [g.OWNER, g.ADMIN, g.MOD].includes(t);
1391
- return {
1392
- canPost: o,
1393
- canComment: r,
1394
- isModerator: a
1395
- };
1396
- }
1397
- export {
1398
- c as CONFIG,
1399
- j as ConfigManager,
1400
- ze as EcencyAnalytics,
1401
- Q as EcencyQueriesManager,
1402
- pe as HiveSignerIntegration,
1403
- ve as Keychain,
1404
- g as ROLES,
1405
- Re as ThreeSpeakIntegration,
1406
- oe as broadcastJson,
1407
- Se as checkUsernameWalletsPendingQueryOptions,
1408
- se as dedupeAndSortKeyAuths,
1409
- l as getAccessToken,
1410
- b as getAccountFullQueryOptions,
1411
- qe as getAccountPendingRecoveryQueryOptions,
1412
- Ye as getAccountRcQueryOptions,
1413
- Oe as getAccountRecoveriesQueryOptions,
1414
- ke as getAccountSubscriptionsQueryOptions,
1415
- Ke as getActiveAccountBookmarksQueryOptions,
1416
- Ce as getActiveAccountFavouritesQueryOptions,
1417
- Me as getChainPropertiesQueryOptions,
1418
- tt as getCommunitiesQueryOptions,
1419
- nt as getCommunityContextQueryOptions,
1420
- it as getCommunityPermissions,
1421
- rt as getCommunityType,
1422
- we as getDynamicPropsQueryOptions,
1423
- A as getFragmentsQueryOptions,
1424
- Ze as getGameStatusCheckQueryOptions,
1425
- $e as getHivePoshLinksQueryOptions,
1426
- J as getLoginType,
1427
- H as getPostingKey,
1428
- Ue as getPromotedPostsQuery,
1429
- y as getQueryClient,
1430
- Xe as getRcStatsQueryOptions,
1431
- _e as getRefreshToken,
1432
- re as getRelationshipBetweenAccountsQueryOptions,
1433
- be as getSearchAccountsByUsernameQueryOptions,
1434
- Le as getStatsQueryOptions,
1435
- xe as getTrendingTagsQueryOptions,
1436
- w as getUser,
1437
- me as makeQueryClient,
1438
- ot as roleMap,
1439
- De as useAccountFavouriteAdd,
1440
- Fe as useAccountFavouriteDelete,
1441
- Te as useAccountRelationsUpdate,
1442
- He as useAccountRevokeKey,
1443
- Ee as useAccountRevokePosting,
1444
- Ae as useAccountUpdate,
1445
- ae as useAccountUpdateKeyAuths,
1446
- Pe as useAccountUpdatePassword,
1447
- Be as useAccountUpdateRecovery,
1448
- Ge as useAddFragment,
1449
- je as useBookmarkAdd,
1450
- Qe as useBookmarkDelete,
1451
- ne as useBroadcastMutation,
1452
- Ve as useEditFragment,
1453
- et as useGameClaim,
1454
- We as useRemoveFragment,
1455
- Ie as useSignOperationByHivesigner,
1456
- Je as useSignOperationByKey,
1457
- Ne as useSignOperationByKeychain
1458
- };