@cedros/login-react 0.0.47 → 0.0.48

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.
@@ -0,0 +1,948 @@
1
+ import { jsxs as a, jsx as t, Fragment as G } from "react/jsx-runtime";
2
+ import { useState as y, useCallback as U, useEffect as g, useMemo as ee } from "react";
3
+ import { u as V } from "./useAdminDeposits-C76B2Q_8.js";
4
+ import { S as z } from "./StatsBar-BX-hHtTq.js";
5
+ function ge({
6
+ refreshInterval: e = 0,
7
+ refreshSignal: o,
8
+ className: c = "",
9
+ onLoad: i
10
+ }) {
11
+ const { getStats: l, isLoading: n, error: v, clearError: w } = V(), [A, q] = y(null), [$, k] = y(null), b = U(async () => {
12
+ try {
13
+ const u = await l();
14
+ q(u), i?.(u), k(null);
15
+ } catch (u) {
16
+ const D = u && typeof u == "object" && "message" in u ? String(u.message) : "Failed to load stats";
17
+ k(D);
18
+ }
19
+ }, [l, i]);
20
+ g(() => {
21
+ b();
22
+ }, [b]), g(() => {
23
+ o !== void 0 && b();
24
+ }, [o, b]), g(() => {
25
+ if (o !== void 0 || e <= 0) return;
26
+ const u = setInterval(b, e);
27
+ return () => clearInterval(u);
28
+ }, [e, o, b]);
29
+ const W = $ || v;
30
+ return W ? /* @__PURE__ */ a("div", { className: `cedros-admin-stats ${c}`, children: [
31
+ /* @__PURE__ */ t("p", { className: "cedros-admin-error", children: W }),
32
+ /* @__PURE__ */ t(
33
+ "button",
34
+ {
35
+ type: "button",
36
+ className: "cedros-button cedros-button-outline",
37
+ onClick: () => {
38
+ w(), k(null), b();
39
+ },
40
+ children: "Retry"
41
+ }
42
+ )
43
+ ] }) : n && !A ? /* @__PURE__ */ t("div", { className: `cedros-admin-stats ${c}`, children: /* @__PURE__ */ t(
44
+ z,
45
+ {
46
+ stats: [
47
+ { label: "Total Withdrawn", value: 0 },
48
+ { label: "Pending Withdraw", value: 0 },
49
+ { label: "In Privacy Period", value: 0 },
50
+ { label: "Microbatch (SOL)", value: "0.0000" }
51
+ ],
52
+ isLoading: !0
53
+ }
54
+ ) }) : A ? /* @__PURE__ */ t("div", { className: `cedros-admin-stats ${c}`, children: /* @__PURE__ */ t(
55
+ z,
56
+ {
57
+ stats: [
58
+ { label: "Total Withdrawn", value: A.totalWithdrawnCount },
59
+ { label: "Pending Withdraw", value: A.pendingWithdrawalCount },
60
+ { label: "In Privacy Period", value: A.inPrivacyPeriodCount ?? 0 },
61
+ { label: "Microbatch (SOL)", value: A.readyForWithdrawalSol?.toFixed(4) ?? "0.0000" }
62
+ ],
63
+ isLoading: n,
64
+ onRefresh: b
65
+ }
66
+ ) }) : null;
67
+ }
68
+ function te(e) {
69
+ return e == null ? "—" : `${(e / 1e9).toFixed(4)} SOL`;
70
+ }
71
+ function ae(e) {
72
+ return new Date(e).toLocaleDateString(void 0, {
73
+ year: "numeric",
74
+ month: "short",
75
+ day: "numeric",
76
+ hour: "2-digit",
77
+ minute: "2-digit"
78
+ });
79
+ }
80
+ function re(e) {
81
+ return e.length <= 12 ? e : `${e.slice(0, 6)}...${e.slice(-4)}`;
82
+ }
83
+ function ne(e) {
84
+ const o = new Date(e), i = (/* @__PURE__ */ new Date()).getTime() - o.getTime(), l = Math.floor(i / 6e4), n = Math.floor(l / 60), v = Math.floor(n / 24);
85
+ return v > 0 ? `${v}d ago` : n > 0 ? `${n}h ago` : l > 0 ? `${l}m ago` : "just now";
86
+ }
87
+ function se(e) {
88
+ return e ? new Date(e) > /* @__PURE__ */ new Date() : !0;
89
+ }
90
+ function ie({
91
+ item: e,
92
+ processingId: o,
93
+ onConfirm: c,
94
+ onCancel: i
95
+ }) {
96
+ return /* @__PURE__ */ t(
97
+ "div",
98
+ {
99
+ className: "cedros-admin-modal-overlay",
100
+ onClick: i,
101
+ onKeyDown: (l) => l.key === "Escape" && i(),
102
+ role: "dialog",
103
+ "aria-modal": "true",
104
+ "aria-labelledby": "early-withdrawal-title",
105
+ children: /* @__PURE__ */ a(
106
+ "div",
107
+ {
108
+ className: "cedros-admin-modal cedros-admin-modal-warning",
109
+ onClick: (l) => l.stopPropagation(),
110
+ onKeyDown: () => {
111
+ },
112
+ role: "document",
113
+ children: [
114
+ /* @__PURE__ */ t("h3", { id: "early-withdrawal-title", className: "cedros-admin-modal-title", children: "Early Withdrawal Warning" }),
115
+ /* @__PURE__ */ a("div", { className: "cedros-admin-modal-content", children: [
116
+ /* @__PURE__ */ t("p", { className: "cedros-admin-modal-warning-text", children: /* @__PURE__ */ t("strong", { children: "This deposit is still within its privacy period." }) }),
117
+ /* @__PURE__ */ t("p", { children: "Processing this withdrawal early may compromise user privacy. The privacy period exists to provide plausible deniability for deposits." }),
118
+ /* @__PURE__ */ a("p", { className: "cedros-admin-modal-details", children: [
119
+ "User: ",
120
+ re(e.userId),
121
+ /* @__PURE__ */ t("br", {}),
122
+ "Amount: ",
123
+ te(e.amountLamports),
124
+ /* @__PURE__ */ t("br", {}),
125
+ "Available at: ",
126
+ e.withdrawalAvailableAt ? ae(e.withdrawalAvailableAt) : "—"
127
+ ] }),
128
+ /* @__PURE__ */ t("p", { children: "Are you sure you want to process this withdrawal early?" })
129
+ ] }),
130
+ /* @__PURE__ */ a("div", { className: "cedros-admin-modal-actions", children: [
131
+ /* @__PURE__ */ t(
132
+ "button",
133
+ {
134
+ type: "button",
135
+ className: "cedros-button cedros-button-outline",
136
+ onClick: i,
137
+ children: "Cancel"
138
+ }
139
+ ),
140
+ /* @__PURE__ */ t(
141
+ "button",
142
+ {
143
+ type: "button",
144
+ className: "cedros-button cedros-button-danger",
145
+ onClick: () => c(e, !0),
146
+ disabled: o === e.id,
147
+ children: o === e.id ? "Processing..." : "Process Early"
148
+ }
149
+ )
150
+ ] })
151
+ ]
152
+ }
153
+ )
154
+ }
155
+ );
156
+ }
157
+ function de({
158
+ item: e,
159
+ processingId: o,
160
+ processingAll: c,
161
+ onItemClick: i,
162
+ onProcess: l
163
+ }) {
164
+ const n = se(e.withdrawalAvailableAt), v = o === e.id;
165
+ return /* @__PURE__ */ a(
166
+ "div",
167
+ {
168
+ className: `cedros-admin-withdrawal-row ${n ? "cedros-admin-withdrawal-row-early" : ""}`,
169
+ onClick: () => i?.(e),
170
+ onKeyDown: (w) => {
171
+ (w.key === "Enter" || w.key === " ") && (w.preventDefault(), i?.(e));
172
+ },
173
+ role: i ? "button" : void 0,
174
+ tabIndex: i ? 0 : void 0,
175
+ children: [
176
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-td", title: e.userId, children: re(e.userId) }),
177
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-td", children: te(e.amountLamports) }),
178
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-td", children: e.withdrawalAvailableAt ? ae(e.withdrawalAvailableAt) : "—" }),
179
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-td cedros-admin-withdrawal-waiting", children: e.withdrawalAvailableAt ? n ? "In privacy period" : ne(e.withdrawalAvailableAt) : "—" }),
180
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-td cedros-admin-withdrawal-td-action", children: /* @__PURE__ */ t(
181
+ "button",
182
+ {
183
+ type: "button",
184
+ className: `cedros-button cedros-button-sm ${n ? "cedros-button-warning" : "cedros-button-primary"}`,
185
+ onClick: (w) => {
186
+ w.stopPropagation(), l(e);
187
+ },
188
+ disabled: v || c,
189
+ title: n ? "Early withdrawal (requires confirmation)" : "Process this withdrawal",
190
+ children: v ? "..." : n ? "Early" : "Process"
191
+ }
192
+ ) })
193
+ ]
194
+ },
195
+ e.id
196
+ );
197
+ }
198
+ function Ae({
199
+ pageSize: e = 20,
200
+ refreshInterval: o = 0,
201
+ refreshSignal: c,
202
+ className: i = "",
203
+ onLoad: l,
204
+ onItemClick: n,
205
+ onWithdrawalProcessed: v,
206
+ onAllProcessed: w
207
+ }) {
208
+ const {
209
+ listPendingWithdrawals: A,
210
+ processWithdrawal: q,
211
+ processAllWithdrawals: $,
212
+ isLoading: k,
213
+ error: b,
214
+ clearError: W
215
+ } = V(), [u, D] = y([]), [F, I] = y(0), [m, R] = y(0), [N, T] = y(null), [f, d] = y("withdrawalAvailableAt"), [h, O] = y("asc"), C = (r) => {
216
+ f === r ? O(h === "asc" ? "desc" : "asc") : (d(r), O(r === "withdrawalAvailableAt" ? "asc" : "desc"));
217
+ }, K = ee(() => [...u].sort((r, L) => {
218
+ let P, H;
219
+ switch (f) {
220
+ case "userId":
221
+ P = r.userId.toLowerCase(), H = L.userId.toLowerCase();
222
+ break;
223
+ case "amountLamports":
224
+ P = r.amountLamports ?? 0, H = L.amountLamports ?? 0;
225
+ break;
226
+ case "withdrawalAvailableAt":
227
+ P = r.withdrawalAvailableAt ? new Date(r.withdrawalAvailableAt).getTime() : 0, H = L.withdrawalAvailableAt ? new Date(L.withdrawalAvailableAt).getTime() : 0;
228
+ break;
229
+ default:
230
+ return 0;
231
+ }
232
+ return P < H ? h === "asc" ? -1 : 1 : P > H ? h === "asc" ? 1 : -1 : 0;
233
+ }), [u, f, h]), [j, s] = y(null), [p, E] = y(!1), [x, S] = y(null), [J, B] = y(null), M = U(async () => {
234
+ try {
235
+ const r = await A({ limit: e, offset: m });
236
+ D(r.deposits), I(r.total), l?.(r), T(null);
237
+ } catch (r) {
238
+ const L = r && typeof r == "object" && "message" in r ? String(r.message) : "Failed to load pending withdrawals";
239
+ T(L);
240
+ }
241
+ }, [e, m, A, l]);
242
+ g(() => {
243
+ R(0);
244
+ }, [e]), g(() => {
245
+ M();
246
+ }, [M]), g(() => {
247
+ c !== void 0 && M();
248
+ }, [c, M]), g(() => {
249
+ if (c !== void 0 || o <= 0) return;
250
+ const r = setInterval(M, o);
251
+ return () => clearInterval(r);
252
+ }, [o, c, M]), g(() => {
253
+ if (!x) return;
254
+ const r = setTimeout(() => S(null), 5e3);
255
+ return () => clearTimeout(r);
256
+ }, [x]);
257
+ const Q = Math.ceil(F / e), _ = Math.floor(m / e) + 1, X = (r) => {
258
+ const L = (r - 1) * e;
259
+ R(Math.max(0, Math.min(L, Math.max(0, F - 1))));
260
+ }, Y = async (r, L = !1) => {
261
+ if (!L && se(r.withdrawalAvailableAt)) {
262
+ B(r);
263
+ return;
264
+ }
265
+ s(r.id), S(null);
266
+ try {
267
+ const P = await q(r.id, { force: L });
268
+ P.success ? (S({
269
+ type: "success",
270
+ message: `Withdrawal processed: ${P.txSignature?.slice(0, 12)}...`
271
+ }), v?.(P), await M()) : S({
272
+ type: "error",
273
+ message: P.error || "Failed to process withdrawal"
274
+ });
275
+ } catch (P) {
276
+ S({
277
+ type: "error",
278
+ message: P instanceof Error ? P.message : "Failed to process withdrawal"
279
+ });
280
+ } finally {
281
+ s(null), B(null);
282
+ }
283
+ }, oe = async () => {
284
+ if (u.length !== 0) {
285
+ E(!0), S(null);
286
+ try {
287
+ const r = await $();
288
+ r.totalSucceeded > 0 ? S({
289
+ type: "success",
290
+ message: `Processed ${r.totalSucceeded}/${r.totalProcessed} withdrawals`
291
+ }) : r.totalFailed > 0 && S({
292
+ type: "error",
293
+ message: `Failed to process ${r.totalFailed} withdrawals`
294
+ }), w?.(r), await M();
295
+ } catch (r) {
296
+ S({
297
+ type: "error",
298
+ message: r instanceof Error ? r.message : "Failed to process withdrawals"
299
+ });
300
+ } finally {
301
+ E(!1);
302
+ }
303
+ }
304
+ }, Z = N || b;
305
+ return Z ? /* @__PURE__ */ a(
306
+ "div",
307
+ {
308
+ className: `cedros-admin-withdrawal-queue cedros-admin-withdrawal-queue-error ${i}`,
309
+ children: [
310
+ /* @__PURE__ */ t("p", { className: "cedros-admin-error", children: Z }),
311
+ /* @__PURE__ */ t(
312
+ "button",
313
+ {
314
+ type: "button",
315
+ className: "cedros-button cedros-button-outline",
316
+ onClick: () => {
317
+ W(), T(null), M();
318
+ },
319
+ children: "Retry"
320
+ }
321
+ )
322
+ ]
323
+ }
324
+ ) : k && u.length === 0 && !j && !p ? /* @__PURE__ */ a(
325
+ "div",
326
+ {
327
+ className: `cedros-admin-withdrawal-queue cedros-admin-withdrawal-queue-loading ${i}`,
328
+ children: [
329
+ /* @__PURE__ */ t("span", { className: "cedros-admin-loading-indicator" }),
330
+ /* @__PURE__ */ t("span", { className: "cedros-admin-loading-text", children: "Loading withdrawal queue..." })
331
+ ]
332
+ }
333
+ ) : /* @__PURE__ */ a("div", { className: `cedros-admin-withdrawal-queue ${i}`, children: [
334
+ J && /* @__PURE__ */ t(
335
+ ie,
336
+ {
337
+ item: J,
338
+ processingId: j,
339
+ onConfirm: Y,
340
+ onCancel: () => B(null)
341
+ }
342
+ ),
343
+ x && /* @__PURE__ */ t(
344
+ "div",
345
+ {
346
+ className: `cedros-admin-result cedros-admin-result-${x.type}`,
347
+ role: "status",
348
+ "aria-live": "polite",
349
+ children: x.message
350
+ }
351
+ ),
352
+ /* @__PURE__ */ a("div", { className: "cedros-admin-withdrawal-queue-header", children: [
353
+ /* @__PURE__ */ t("h4", { className: "cedros-admin-withdrawal-queue-title", children: "Pending Withdrawals" }),
354
+ /* @__PURE__ */ a("div", { className: "cedros-admin-withdrawal-queue-actions", children: [
355
+ /* @__PURE__ */ a("span", { className: "cedros-admin-queue-count", children: [
356
+ F,
357
+ " pending"
358
+ ] }),
359
+ /* @__PURE__ */ t(
360
+ "button",
361
+ {
362
+ type: "button",
363
+ className: "cedros-admin__stats-bar-refresh",
364
+ onClick: M,
365
+ disabled: k || p,
366
+ title: "Refresh queue",
367
+ "aria-label": "Refresh queue",
368
+ children: k && !p ? "..." : "↻"
369
+ }
370
+ ),
371
+ /* @__PURE__ */ t(
372
+ "button",
373
+ {
374
+ type: "button",
375
+ className: "cedros-button cedros-button-primary cedros-button-sm",
376
+ onClick: oe,
377
+ disabled: k || p || u.length === 0,
378
+ title: "Process all ready withdrawals",
379
+ children: p ? "Processing..." : "Process All"
380
+ }
381
+ )
382
+ ] })
383
+ ] }),
384
+ u.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin-empty", children: /* @__PURE__ */ t("p", { className: "cedros-admin-empty-message", children: "No pending withdrawals." }) }) : /* @__PURE__ */ a(G, { children: [
385
+ /* @__PURE__ */ a("div", { className: "cedros-admin-withdrawal-table", children: [
386
+ /* @__PURE__ */ a("div", { className: "cedros-admin-withdrawal-thead", children: [
387
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-th", children: /* @__PURE__ */ a(
388
+ "button",
389
+ {
390
+ type: "button",
391
+ className: `cedros-admin-sort-button ${f === "userId" ? "cedros-admin-sort-active" : ""}`,
392
+ onClick: () => C("userId"),
393
+ "aria-label": "Sort by user",
394
+ children: [
395
+ "User",
396
+ " ",
397
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: f === "userId" ? h === "asc" ? "↑" : "↓" : "↕" })
398
+ ]
399
+ }
400
+ ) }),
401
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-th", children: /* @__PURE__ */ a(
402
+ "button",
403
+ {
404
+ type: "button",
405
+ className: `cedros-admin-sort-button ${f === "amountLamports" ? "cedros-admin-sort-active" : ""}`,
406
+ onClick: () => C("amountLamports"),
407
+ "aria-label": "Sort by amount",
408
+ children: [
409
+ "Amount",
410
+ " ",
411
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: f === "amountLamports" ? h === "asc" ? "↑" : "↓" : "↕" })
412
+ ]
413
+ }
414
+ ) }),
415
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-th", children: /* @__PURE__ */ a(
416
+ "button",
417
+ {
418
+ type: "button",
419
+ className: `cedros-admin-sort-button ${f === "withdrawalAvailableAt" ? "cedros-admin-sort-active" : ""}`,
420
+ onClick: () => C("withdrawalAvailableAt"),
421
+ "aria-label": "Sort by ready since",
422
+ children: [
423
+ "Ready Since",
424
+ " ",
425
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: f === "withdrawalAvailableAt" ? h === "asc" ? "↑" : "↓" : "↕" })
426
+ ]
427
+ }
428
+ ) }),
429
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-th", children: "Waiting" }),
430
+ /* @__PURE__ */ t("div", { className: "cedros-admin-withdrawal-th cedros-admin-withdrawal-th-action", children: "Action" })
431
+ ] }),
432
+ K.map((r) => /* @__PURE__ */ t(
433
+ de,
434
+ {
435
+ item: r,
436
+ processingId: j,
437
+ processingAll: p,
438
+ onItemClick: n,
439
+ onProcess: Y
440
+ },
441
+ r.id
442
+ ))
443
+ ] }),
444
+ Q > 1 && /* @__PURE__ */ a("div", { className: "cedros-admin-pagination", children: [
445
+ /* @__PURE__ */ t(
446
+ "button",
447
+ {
448
+ type: "button",
449
+ className: "cedros-button cedros-button-outline cedros-button-sm",
450
+ onClick: () => X(_ - 1),
451
+ disabled: _ <= 1,
452
+ children: "Previous"
453
+ }
454
+ ),
455
+ /* @__PURE__ */ a("span", { className: "cedros-admin-page-info", children: [
456
+ "Page ",
457
+ _,
458
+ " of ",
459
+ Q,
460
+ " (",
461
+ F,
462
+ " total)"
463
+ ] }),
464
+ /* @__PURE__ */ t(
465
+ "button",
466
+ {
467
+ type: "button",
468
+ className: "cedros-button cedros-button-outline cedros-button-sm",
469
+ onClick: () => X(_ + 1),
470
+ disabled: _ >= Q,
471
+ children: "Next"
472
+ }
473
+ )
474
+ ] })
475
+ ] })
476
+ ] });
477
+ }
478
+ function ce(e) {
479
+ return e == null ? "—" : `${(e / 1e9).toFixed(4)} SOL`;
480
+ }
481
+ function le(e) {
482
+ return new Date(e).toLocaleDateString(void 0, {
483
+ year: "numeric",
484
+ month: "short",
485
+ day: "numeric",
486
+ hour: "2-digit",
487
+ minute: "2-digit"
488
+ });
489
+ }
490
+ function ue(e) {
491
+ return e.length <= 12 ? e : `${e.slice(0, 6)}...${e.slice(-4)}`;
492
+ }
493
+ function me(e) {
494
+ const o = new Date(e), c = /* @__PURE__ */ new Date(), i = o.getTime() - c.getTime();
495
+ if (i <= 0) return "Ready";
496
+ const l = Math.floor(i / 6e4), n = Math.floor(l / 60), v = Math.floor(n / 24);
497
+ if (v > 0) {
498
+ const w = n % 24;
499
+ return w > 0 ? `${v}d ${w}h` : `${v}d`;
500
+ }
501
+ if (n > 0) {
502
+ const w = l % 60;
503
+ return w > 0 ? `${n}h ${w}m` : `${n}h`;
504
+ }
505
+ return `${l}m`;
506
+ }
507
+ function Pe({
508
+ pageSize: e = 20,
509
+ refreshInterval: o = 0,
510
+ refreshSignal: c,
511
+ className: i = "",
512
+ onLoad: l,
513
+ onItemClick: n
514
+ }) {
515
+ const { listInPrivacyPeriod: v, isLoading: w, error: A, clearError: q } = V(), [$, k] = y([]), [b, W] = y(0), [u, D] = y(0), [F, I] = y(null), m = U(async () => {
516
+ try {
517
+ const d = await v({ limit: e, offset: u });
518
+ k(d.deposits), W(d.total), l?.(d), I(null);
519
+ } catch (d) {
520
+ const h = d && typeof d == "object" && "message" in d ? String(d.message) : "Failed to load deposits";
521
+ I(h);
522
+ }
523
+ }, [e, u, v, l]);
524
+ g(() => {
525
+ D(0);
526
+ }, [e]), g(() => {
527
+ m();
528
+ }, [m]), g(() => {
529
+ c !== void 0 && m();
530
+ }, [c, m]), g(() => {
531
+ if (c !== void 0 || o <= 0) return;
532
+ const d = setInterval(m, o);
533
+ return () => clearInterval(d);
534
+ }, [o, c, m]);
535
+ const R = Math.ceil(b / e), N = Math.floor(u / e) + 1, T = (d) => {
536
+ const h = (d - 1) * e;
537
+ D(Math.max(0, Math.min(h, Math.max(0, b - 1))));
538
+ }, f = F || A;
539
+ return f ? /* @__PURE__ */ a(
540
+ "div",
541
+ {
542
+ className: `cedros-admin-privacy-deposits cedros-admin-privacy-deposits-error ${i}`,
543
+ children: [
544
+ /* @__PURE__ */ t("p", { className: "cedros-admin-error", children: f }),
545
+ /* @__PURE__ */ t(
546
+ "button",
547
+ {
548
+ type: "button",
549
+ className: "cedros-button cedros-button-outline",
550
+ onClick: () => {
551
+ q(), I(null), m();
552
+ },
553
+ children: "Retry"
554
+ }
555
+ )
556
+ ]
557
+ }
558
+ ) : w && $.length === 0 ? /* @__PURE__ */ a(
559
+ "div",
560
+ {
561
+ className: `cedros-admin-privacy-deposits cedros-admin-privacy-deposits-loading ${i}`,
562
+ children: [
563
+ /* @__PURE__ */ t("span", { className: "cedros-admin-loading-indicator" }),
564
+ /* @__PURE__ */ t("span", { className: "cedros-admin-loading-text", children: "Loading deposits..." })
565
+ ]
566
+ }
567
+ ) : /* @__PURE__ */ a("div", { className: `cedros-admin-privacy-deposits ${i}`, children: [
568
+ /* @__PURE__ */ a("div", { className: "cedros-admin-privacy-deposits-header", children: [
569
+ /* @__PURE__ */ t("h4", { className: "cedros-admin-privacy-deposits-title", children: "In Privacy Period" }),
570
+ /* @__PURE__ */ a("div", { className: "cedros-admin-privacy-deposits-actions", children: [
571
+ /* @__PURE__ */ a("span", { className: "cedros-admin-queue-count", children: [
572
+ b,
573
+ " deposit",
574
+ b !== 1 ? "s" : ""
575
+ ] }),
576
+ /* @__PURE__ */ t(
577
+ "button",
578
+ {
579
+ type: "button",
580
+ className: "cedros-admin__stats-bar-refresh",
581
+ onClick: m,
582
+ disabled: w,
583
+ title: "Refresh list",
584
+ "aria-label": "Refresh list",
585
+ children: w ? "..." : "↻"
586
+ }
587
+ )
588
+ ] })
589
+ ] }),
590
+ $.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin-empty", children: /* @__PURE__ */ t("p", { className: "cedros-admin-empty-message", children: "No deposits in privacy period." }) }) : /* @__PURE__ */ a(G, { children: [
591
+ /* @__PURE__ */ a("div", { className: "cedros-admin-privacy-table", children: [
592
+ /* @__PURE__ */ a("div", { className: "cedros-admin-privacy-thead", children: [
593
+ /* @__PURE__ */ t("div", { className: "cedros-admin-privacy-th", children: /* @__PURE__ */ a(
594
+ "button",
595
+ {
596
+ type: "button",
597
+ className: "cedros-admin-sort-button",
598
+ "aria-label": "Sort by user",
599
+ children: [
600
+ "User ",
601
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: "↕" })
602
+ ]
603
+ }
604
+ ) }),
605
+ /* @__PURE__ */ t("div", { className: "cedros-admin-privacy-th", children: /* @__PURE__ */ a(
606
+ "button",
607
+ {
608
+ type: "button",
609
+ className: "cedros-admin-sort-button",
610
+ "aria-label": "Sort by amount",
611
+ children: [
612
+ "Amount ",
613
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: "↕" })
614
+ ]
615
+ }
616
+ ) }),
617
+ /* @__PURE__ */ t("div", { className: "cedros-admin-privacy-th", children: /* @__PURE__ */ a(
618
+ "button",
619
+ {
620
+ type: "button",
621
+ className: "cedros-admin-sort-button",
622
+ "aria-label": "Sort by deposited",
623
+ children: [
624
+ "Deposited ",
625
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: "↕" })
626
+ ]
627
+ }
628
+ ) }),
629
+ /* @__PURE__ */ t("div", { className: "cedros-admin-privacy-th", children: /* @__PURE__ */ a(
630
+ "button",
631
+ {
632
+ type: "button",
633
+ className: "cedros-admin-sort-button",
634
+ "aria-label": "Sort by ready in",
635
+ children: [
636
+ "Ready In ",
637
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: "↕" })
638
+ ]
639
+ }
640
+ ) })
641
+ ] }),
642
+ $.map((d) => /* @__PURE__ */ a(
643
+ "div",
644
+ {
645
+ className: "cedros-admin-privacy-row",
646
+ onClick: () => n?.(d),
647
+ onKeyDown: (h) => {
648
+ (h.key === "Enter" || h.key === " ") && (h.preventDefault(), n?.(d));
649
+ },
650
+ role: n ? "button" : void 0,
651
+ tabIndex: n ? 0 : void 0,
652
+ children: [
653
+ /* @__PURE__ */ t("div", { className: "cedros-admin-privacy-td", title: d.userId, children: ue(d.userId) }),
654
+ /* @__PURE__ */ t("div", { className: "cedros-admin-privacy-td", children: ce(d.amountLamports) }),
655
+ /* @__PURE__ */ t("div", { className: "cedros-admin-privacy-td", children: d.completedAt ? le(d.completedAt) : "—" }),
656
+ /* @__PURE__ */ t("div", { className: "cedros-admin-privacy-td cedros-admin-privacy-remaining", children: d.withdrawalAvailableAt ? me(d.withdrawalAvailableAt) : "—" })
657
+ ]
658
+ },
659
+ d.id
660
+ ))
661
+ ] }),
662
+ R > 1 && /* @__PURE__ */ a("div", { className: "cedros-admin-pagination", children: [
663
+ /* @__PURE__ */ t(
664
+ "button",
665
+ {
666
+ type: "button",
667
+ className: "cedros-button cedros-button-outline cedros-button-sm",
668
+ onClick: () => T(N - 1),
669
+ disabled: N <= 1,
670
+ children: "Previous"
671
+ }
672
+ ),
673
+ /* @__PURE__ */ a("span", { className: "cedros-admin-page-info", children: [
674
+ "Page ",
675
+ N,
676
+ " of ",
677
+ R,
678
+ " (",
679
+ b,
680
+ " total)"
681
+ ] }),
682
+ /* @__PURE__ */ t(
683
+ "button",
684
+ {
685
+ type: "button",
686
+ className: "cedros-button cedros-button-outline cedros-button-sm",
687
+ onClick: () => T(N + 1),
688
+ disabled: N >= R,
689
+ children: "Next"
690
+ }
691
+ )
692
+ ] })
693
+ ] })
694
+ ] });
695
+ }
696
+ function he(e) {
697
+ return e == null ? "—" : `${(e / 1e9).toFixed(4)} SOL`;
698
+ }
699
+ function we(e) {
700
+ return new Date(e).toLocaleDateString(void 0, {
701
+ year: "numeric",
702
+ month: "short",
703
+ day: "numeric",
704
+ hour: "2-digit",
705
+ minute: "2-digit"
706
+ });
707
+ }
708
+ function be(e) {
709
+ return e.length <= 16 ? e : `${e.slice(0, 8)}...${e.slice(-6)}`;
710
+ }
711
+ function pe(e) {
712
+ return e.length <= 12 ? e : `${e.slice(0, 6)}...${e.slice(-4)}`;
713
+ }
714
+ function $e({
715
+ pageSize: e = 20,
716
+ refreshInterval: o = 0,
717
+ refreshSignal: c,
718
+ className: i = "",
719
+ onLoad: l,
720
+ onItemClick: n
721
+ }) {
722
+ const { listDeposits: v, isLoading: w, error: A, clearError: q } = V(), [$, k] = y([]), [b, W] = y(0), [u, D] = y(0), [F, I] = y(null), [m, R] = y("completedAt"), [N, T] = y("desc"), f = (s) => {
723
+ m === s ? T(N === "asc" ? "desc" : "asc") : (R(s), T("desc"));
724
+ }, d = ee(() => [...$].sort((s, p) => {
725
+ let E, x;
726
+ switch (m) {
727
+ case "userId":
728
+ E = s.userId.toLowerCase(), x = p.userId.toLowerCase();
729
+ break;
730
+ case "amountLamports":
731
+ E = s.amountLamports ?? 0, x = p.amountLamports ?? 0;
732
+ break;
733
+ case "completedAt":
734
+ E = s.completedAt ? new Date(s.completedAt).getTime() : 0, x = p.completedAt ? new Date(p.completedAt).getTime() : 0;
735
+ break;
736
+ case "withdrawalTxSignature":
737
+ E = s.withdrawalTxSignature || "", x = p.withdrawalTxSignature || "";
738
+ break;
739
+ default:
740
+ return 0;
741
+ }
742
+ return E < x ? N === "asc" ? -1 : 1 : E > x ? N === "asc" ? 1 : -1 : 0;
743
+ }), [$, m, N]), h = U(async () => {
744
+ try {
745
+ const s = await v({ status: "withdrawn", limit: e, offset: u });
746
+ k(s.deposits), W(s.total), l?.(s), I(null);
747
+ } catch (s) {
748
+ const p = s && typeof s == "object" && "message" in s ? String(s.message) : "Failed to load withdrawal history";
749
+ I(p);
750
+ }
751
+ }, [e, u, v, l]);
752
+ g(() => {
753
+ D(0);
754
+ }, [e]), g(() => {
755
+ h();
756
+ }, [h]), g(() => {
757
+ c !== void 0 && h();
758
+ }, [c, h]), g(() => {
759
+ if (c !== void 0 || o <= 0) return;
760
+ const s = setInterval(h, o);
761
+ return () => clearInterval(s);
762
+ }, [o, c, h]);
763
+ const O = Math.ceil(b / e), C = Math.floor(u / e) + 1, K = (s) => {
764
+ const p = (s - 1) * e;
765
+ D(Math.max(0, Math.min(p, Math.max(0, b - 1))));
766
+ }, j = F || A;
767
+ return j ? /* @__PURE__ */ a(
768
+ "div",
769
+ {
770
+ className: `cedros-admin-withdrawal-history cedros-admin-withdrawal-history-error ${i}`,
771
+ children: [
772
+ /* @__PURE__ */ t("p", { className: "cedros-admin-error", children: j }),
773
+ /* @__PURE__ */ t(
774
+ "button",
775
+ {
776
+ type: "button",
777
+ className: "cedros-button cedros-button-outline",
778
+ onClick: () => {
779
+ q(), I(null), h();
780
+ },
781
+ children: "Retry"
782
+ }
783
+ )
784
+ ]
785
+ }
786
+ ) : w && $.length === 0 ? /* @__PURE__ */ a(
787
+ "div",
788
+ {
789
+ className: `cedros-admin-withdrawal-history cedros-admin-withdrawal-history-loading ${i}`,
790
+ children: [
791
+ /* @__PURE__ */ t("span", { className: "cedros-admin-loading-indicator" }),
792
+ /* @__PURE__ */ t("span", { className: "cedros-admin-loading-text", children: "Loading withdrawal history..." })
793
+ ]
794
+ }
795
+ ) : /* @__PURE__ */ a("div", { className: `cedros-admin-withdrawal-history ${i}`, children: [
796
+ /* @__PURE__ */ a("div", { className: "cedros-admin-withdrawal-history-header", children: [
797
+ /* @__PURE__ */ t("h4", { className: "cedros-admin-withdrawal-history-title", children: "Withdrawal History" }),
798
+ /* @__PURE__ */ a("div", { className: "cedros-admin-withdrawal-history-actions", children: [
799
+ /* @__PURE__ */ a("span", { className: "cedros-admin-queue-count", children: [
800
+ b,
801
+ " withdrawal",
802
+ b !== 1 ? "s" : ""
803
+ ] }),
804
+ /* @__PURE__ */ t(
805
+ "button",
806
+ {
807
+ type: "button",
808
+ className: "cedros-admin__stats-bar-refresh",
809
+ onClick: h,
810
+ disabled: w,
811
+ title: "Refresh list",
812
+ "aria-label": "Refresh list",
813
+ children: w ? "..." : "↻"
814
+ }
815
+ )
816
+ ] })
817
+ ] }),
818
+ $.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin-empty", children: /* @__PURE__ */ t("p", { className: "cedros-admin-empty-message", children: "No withdrawals processed yet." }) }) : /* @__PURE__ */ a(G, { children: [
819
+ /* @__PURE__ */ a("div", { className: "cedros-admin-history-table", children: [
820
+ /* @__PURE__ */ a("div", { className: "cedros-admin-history-thead", children: [
821
+ /* @__PURE__ */ t("div", { className: "cedros-admin-history-th", children: /* @__PURE__ */ a(
822
+ "button",
823
+ {
824
+ type: "button",
825
+ className: `cedros-admin-sort-button ${m === "userId" ? "cedros-admin-sort-active" : ""}`,
826
+ onClick: () => f("userId"),
827
+ "aria-label": "Sort by user",
828
+ children: [
829
+ "User",
830
+ " ",
831
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: m === "userId" ? N === "asc" ? "↑" : "↓" : "↕" })
832
+ ]
833
+ }
834
+ ) }),
835
+ /* @__PURE__ */ t("div", { className: "cedros-admin-history-th", children: /* @__PURE__ */ a(
836
+ "button",
837
+ {
838
+ type: "button",
839
+ className: `cedros-admin-sort-button ${m === "amountLamports" ? "cedros-admin-sort-active" : ""}`,
840
+ onClick: () => f("amountLamports"),
841
+ "aria-label": "Sort by amount",
842
+ children: [
843
+ "Amount",
844
+ " ",
845
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: m === "amountLamports" ? N === "asc" ? "↑" : "↓" : "↕" })
846
+ ]
847
+ }
848
+ ) }),
849
+ /* @__PURE__ */ t("div", { className: "cedros-admin-history-th", children: /* @__PURE__ */ a(
850
+ "button",
851
+ {
852
+ type: "button",
853
+ className: `cedros-admin-sort-button ${m === "completedAt" ? "cedros-admin-sort-active" : ""}`,
854
+ onClick: () => f("completedAt"),
855
+ "aria-label": "Sort by processed",
856
+ children: [
857
+ "Processed",
858
+ " ",
859
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: m === "completedAt" ? N === "asc" ? "↑" : "↓" : "↕" })
860
+ ]
861
+ }
862
+ ) }),
863
+ /* @__PURE__ */ t("div", { className: "cedros-admin-history-th", children: /* @__PURE__ */ a(
864
+ "button",
865
+ {
866
+ type: "button",
867
+ className: `cedros-admin-sort-button ${m === "withdrawalTxSignature" ? "cedros-admin-sort-active" : ""}`,
868
+ onClick: () => f("withdrawalTxSignature"),
869
+ "aria-label": "Sort by transaction",
870
+ children: [
871
+ "Transaction",
872
+ " ",
873
+ /* @__PURE__ */ t("span", { className: "cedros-admin-sort-icon", children: m === "withdrawalTxSignature" ? N === "asc" ? "↑" : "↓" : "↕" })
874
+ ]
875
+ }
876
+ ) })
877
+ ] }),
878
+ d.map((s) => /* @__PURE__ */ a(
879
+ "div",
880
+ {
881
+ className: "cedros-admin-history-row",
882
+ onClick: () => n?.(s),
883
+ onKeyDown: (p) => {
884
+ (p.key === "Enter" || p.key === " ") && (p.preventDefault(), n?.(s));
885
+ },
886
+ role: n ? "button" : void 0,
887
+ tabIndex: n ? 0 : void 0,
888
+ children: [
889
+ /* @__PURE__ */ t("div", { className: "cedros-admin-history-td", title: s.userId, children: pe(s.userId) }),
890
+ /* @__PURE__ */ t("div", { className: "cedros-admin-history-td", children: he(s.amountLamports) }),
891
+ /* @__PURE__ */ t("div", { className: "cedros-admin-history-td", children: s.completedAt ? we(s.completedAt) : "—" }),
892
+ /* @__PURE__ */ t("div", { className: "cedros-admin-history-td", children: s.withdrawalTxSignature ? /* @__PURE__ */ t(
893
+ "a",
894
+ {
895
+ href: `https://orbmarkets.io/tx/${s.withdrawalTxSignature}`,
896
+ target: "_blank",
897
+ rel: "noopener noreferrer",
898
+ className: "cedros-admin-tx-link",
899
+ onClick: (p) => p.stopPropagation(),
900
+ title: s.withdrawalTxSignature,
901
+ children: be(s.withdrawalTxSignature)
902
+ }
903
+ ) : "—" })
904
+ ]
905
+ },
906
+ s.id
907
+ ))
908
+ ] }),
909
+ O > 1 && /* @__PURE__ */ a("div", { className: "cedros-admin-pagination", children: [
910
+ /* @__PURE__ */ t(
911
+ "button",
912
+ {
913
+ type: "button",
914
+ className: "cedros-button cedros-button-outline cedros-button-sm",
915
+ onClick: () => K(C - 1),
916
+ disabled: C <= 1,
917
+ children: "Previous"
918
+ }
919
+ ),
920
+ /* @__PURE__ */ a("span", { className: "cedros-admin-page-info", children: [
921
+ "Page ",
922
+ C,
923
+ " of ",
924
+ O,
925
+ " (",
926
+ b,
927
+ " total)"
928
+ ] }),
929
+ /* @__PURE__ */ t(
930
+ "button",
931
+ {
932
+ type: "button",
933
+ className: "cedros-button cedros-button-outline cedros-button-sm",
934
+ onClick: () => K(C + 1),
935
+ disabled: C >= O,
936
+ children: "Next"
937
+ }
938
+ )
939
+ ] })
940
+ ] })
941
+ ] });
942
+ }
943
+ export {
944
+ ge as A,
945
+ Pe as a,
946
+ Ae as b,
947
+ $e as c
948
+ };