@cedros/pay-react 1.1.23 → 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AISettingsSection-DAztmwnN.js → AISettingsSection-BvSSiK2G.js} +1 -1
- package/dist/{AISettingsSection-DpMIk431.mjs → AISettingsSection-Dg1kazTI.mjs} +2 -2
- package/dist/{AutosaveIndicator-BRCqAWqP.mjs → AutosaveIndicator-BHfkV59p.mjs} +1 -1
- package/dist/{AutosaveIndicator-BnQkKxzr.js → AutosaveIndicator-D2l7U8R1.js} +1 -1
- package/dist/CedrosContext-C2RjHLaQ.js +6 -0
- package/dist/{CedrosContext-BlArEF7k.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
- package/dist/ComplianceSection-BSE2f3Wo.mjs +534 -0
- package/dist/ComplianceSection-D6ETKG6b.js +1 -0
- package/dist/{CryptoButton-CREryx1l.mjs → CryptoButton-BV9owVe2.mjs} +51 -51
- package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
- package/dist/{FAQSection-yw64HLy3.js → FAQSection-6nGI0FK9.js} +1 -1
- package/dist/{FAQSection-Ruzs7a-0.mjs → FAQSection-uZG5V3pJ.mjs} +1 -1
- package/dist/{MessagingSection-Dp_SaXsv.js → MessagingSection-DrXb578q.js} +1 -1
- package/dist/{MessagingSection-BLRjfBQT.mjs → MessagingSection-M0lj5yo4.mjs} +2 -2
- package/dist/{OrdersSection-l-MtP9EN.mjs → OrdersSection-DteItv_O.mjs} +6 -6
- package/dist/{OrdersSection-C2dyWqrR.js → OrdersSection-_-rIw6XW.js} +1 -1
- package/dist/{PaymentSettingsSection-Bbq93UtC.mjs → PaymentSettingsSection-CdtdLFTg.mjs} +1 -1
- package/dist/{PaymentSettingsSection-C5bhLgU7.js → PaymentSettingsSection-enTbUI95.js} +1 -1
- package/dist/SettingsSection-DUTEd6uV.js +1 -0
- package/dist/{SettingsSection-DorqCFXE.mjs → SettingsSection-mcT4LEhO.mjs} +19 -13
- package/dist/{SingleCategorySettings-BAND8Zkw.mjs → SingleCategorySettings-BvHBVfSe.mjs} +4 -4
- package/dist/{SingleCategorySettings-Cg-zuJfr.js → SingleCategorySettings-D2LVM5mn.js} +1 -1
- package/dist/{StorefrontSection-FSOxBclu.mjs → StorefrontSection-BqQ36JIS.mjs} +2 -2
- package/dist/{StorefrontSection-QZPEZ6Lz.js → StorefrontSection-Du7hV2Gc.js} +1 -1
- package/dist/{SubscriptionsSection-C4TDXCX2.mjs → SubscriptionsSection-BYiCBwKZ.mjs} +7 -7
- package/dist/{SubscriptionsSection-DYr99VzB.js → SubscriptionsSection-C4BRN1dP.js} +1 -1
- package/dist/Token22Section-0c22NM5G.js +1 -0
- package/dist/Token22Section-BHvOhz5d.mjs +2260 -0
- package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
- package/dist/{WalletManager-peBN6RDH.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
- package/dist/{bn-CHdpZHQm.mjs → bn-Bv2sKQMU.mjs} +1 -1
- package/dist/{bn-RbgIlcHc.js → bn-CHyy7EgJ.js} +1 -1
- package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
- package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +85 -83
- package/dist/{index-CKNB7XsA.mjs → index-BkDimQDF.mjs} +7988 -7323
- package/dist/index-C7MWL6O8.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +42 -40
- package/dist/{sections-Cklkxd85.js → sections-5jO2aHAo.js} +1 -1
- package/dist/sections-By4H1baL.mjs +9 -0
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/components/ComplianceGatePage.d.ts +38 -0
- package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
- package/dist/src/components/SubscribeButton.d.ts +1 -5
- package/dist/src/components/SubscribeButton.d.ts.map +1 -1
- package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
- package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
- package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
- package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
- package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
- package/dist/src/components/admin/complianceTypes.d.ts +60 -0
- package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +1 -0
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
- package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
- package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +10 -0
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/src/ecommerce/types.d.ts +6 -0
- package/dist/src/ecommerce/types.d.ts.map +1 -1
- package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
- package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
- package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/CreditsManager.d.ts.map +1 -1
- package/dist/src/managers/ManagerCache.d.ts +2 -2
- package/dist/src/managers/ManagerCache.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts +7 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +21 -33
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/exponentialBackoff.d.ts +22 -0
- package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +2 -2
- package/dist/styles-BT4bhFey.js +1 -0
- package/dist/{styles-2VMpwuaI.mjs → styles-D4SQkuV3.mjs} +647 -650
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-DgQsh7Se.mjs → walletPool-DE-t1wSW.mjs} +1 -1
- package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
- package/package.json +6 -1
- package/dist/CedrosContext-7dwmEeUY.js +0 -6
- package/dist/SettingsSection-D_pKPRrP.js +0 -1
- package/dist/Token22Section-Cmn2lKcd.mjs +0 -1685
- package/dist/Token22Section-D3nnUyim.js +0 -1
- package/dist/index-vEe2Y39x.js +0 -84
- package/dist/sections-Dt6vxDU4.mjs +0 -8
- package/dist/styles-21F1-oqx.js +0 -1
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e, Fragment as E } from "react/jsx-runtime";
|
|
2
|
+
import { useState as i, useCallback as T, useEffect as j } from "react";
|
|
3
|
+
import { I as k, E as me, j as K, k as O } from "./index-BkDimQDF.mjs";
|
|
4
|
+
import { i as p } from "./CedrosContext-CY6zvjvJ.mjs";
|
|
5
|
+
const m = (s) => s.length > 12 ? `${s.slice(0, 6)}...${s.slice(-4)}` : s, he = (s) => {
|
|
6
|
+
switch (s) {
|
|
7
|
+
case "active":
|
|
8
|
+
return "success";
|
|
9
|
+
case "frozen":
|
|
10
|
+
return "failed";
|
|
11
|
+
case "thawed":
|
|
12
|
+
return "pending";
|
|
13
|
+
default:
|
|
14
|
+
return "muted";
|
|
15
|
+
}
|
|
16
|
+
}, ee = (s) => {
|
|
17
|
+
switch (s) {
|
|
18
|
+
case "freeze":
|
|
19
|
+
return "failed";
|
|
20
|
+
case "thaw":
|
|
21
|
+
return "success";
|
|
22
|
+
case "sweep_freeze":
|
|
23
|
+
return "failed";
|
|
24
|
+
case "report_generated":
|
|
25
|
+
return "muted";
|
|
26
|
+
default:
|
|
27
|
+
return "muted";
|
|
28
|
+
}
|
|
29
|
+
}, ue = "https://explorer.solana.com/tx/", pe = {
|
|
30
|
+
apiUrl: "",
|
|
31
|
+
refreshIntervalSecs: 3600,
|
|
32
|
+
enabled: !1
|
|
33
|
+
};
|
|
34
|
+
function ge({ serverUrl: s, apiKey: g, authManager: f }) {
|
|
35
|
+
const [c, o] = i(pe), [H, B] = i(!0), [_, b] = i(!1), [A, C] = i(!1), [x, h] = i(null), [R, y] = i(null), v = T(async (a, d) => {
|
|
36
|
+
if (f?.isAuthenticated())
|
|
37
|
+
return f.fetchWithAuth(a, d);
|
|
38
|
+
const z = { "Content-Type": "application/json" };
|
|
39
|
+
g && (z["X-API-Key"] = g);
|
|
40
|
+
const S = await fetch(`${s}${a}`, { ...d, headers: { ...z, ...d?.headers } });
|
|
41
|
+
if (!S.ok) throw new Error(`Request failed: ${S.status}`);
|
|
42
|
+
return S.json();
|
|
43
|
+
}, [s, g, f]);
|
|
44
|
+
j(() => {
|
|
45
|
+
(async () => {
|
|
46
|
+
try {
|
|
47
|
+
const a = await v("/admin/compliance/sanctions-api");
|
|
48
|
+
o(a);
|
|
49
|
+
} catch (a) {
|
|
50
|
+
p().error("[ComplianceSanctionsApi] Failed to fetch settings:", a);
|
|
51
|
+
} finally {
|
|
52
|
+
B(!1);
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
}, [v]);
|
|
56
|
+
const L = async () => {
|
|
57
|
+
b(!0), h(null), y(null);
|
|
58
|
+
try {
|
|
59
|
+
await v("/admin/compliance/sanctions-api", {
|
|
60
|
+
method: "PUT",
|
|
61
|
+
body: JSON.stringify(c)
|
|
62
|
+
}), y("Settings saved");
|
|
63
|
+
} catch (a) {
|
|
64
|
+
p().error("[ComplianceSanctionsApi] Save failed:", a), h("Failed to save settings");
|
|
65
|
+
} finally {
|
|
66
|
+
b(!1);
|
|
67
|
+
}
|
|
68
|
+
}, U = async () => {
|
|
69
|
+
C(!0), h(null), y(null);
|
|
70
|
+
try {
|
|
71
|
+
await v("/admin/compliance/sanctions-api/refresh", { method: "POST" }), y("Sanctions list refreshed");
|
|
72
|
+
} catch (a) {
|
|
73
|
+
p().error("[ComplianceSanctionsApi] Refresh failed:", a), h("Failed to refresh sanctions list");
|
|
74
|
+
} finally {
|
|
75
|
+
C(!1);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
return H ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
79
|
+
k.loading,
|
|
80
|
+
" Loading sanctions API settings..."
|
|
81
|
+
] }) : /* @__PURE__ */ n("div", { style: { maxWidth: "500px", display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
82
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Dynamic Sanctions API" }) }),
|
|
83
|
+
x && /* @__PURE__ */ e("div", { className: "cedros-admin__badge cedros-admin__badge--failed", style: { padding: "0.5rem" }, children: x }),
|
|
84
|
+
R && /* @__PURE__ */ e("div", { className: "cedros-admin__badge cedros-admin__badge--success", style: { padding: "0.5rem" }, children: R }),
|
|
85
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", fontSize: "0.9rem" }, children: [
|
|
86
|
+
/* @__PURE__ */ e(
|
|
87
|
+
"input",
|
|
88
|
+
{
|
|
89
|
+
type: "checkbox",
|
|
90
|
+
checked: c.enabled,
|
|
91
|
+
onChange: (a) => o((d) => ({ ...d, enabled: a.target.checked }))
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
"Enable dynamic sanctions list"
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", fontSize: "0.85rem" }, children: [
|
|
97
|
+
"API URL",
|
|
98
|
+
/* @__PURE__ */ e(
|
|
99
|
+
"input",
|
|
100
|
+
{
|
|
101
|
+
type: "url",
|
|
102
|
+
className: "cedros-admin__input",
|
|
103
|
+
placeholder: "https://sunscreen.cedros.io",
|
|
104
|
+
value: c.apiUrl,
|
|
105
|
+
onChange: (a) => o((d) => ({ ...d, apiUrl: a.target.value }))
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] }),
|
|
109
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", fontSize: "0.85rem" }, children: [
|
|
110
|
+
"Refresh interval (seconds, min 60)",
|
|
111
|
+
/* @__PURE__ */ e(
|
|
112
|
+
"input",
|
|
113
|
+
{
|
|
114
|
+
type: "number",
|
|
115
|
+
className: "cedros-admin__input",
|
|
116
|
+
min: 60,
|
|
117
|
+
value: c.refreshIntervalSecs,
|
|
118
|
+
onChange: (a) => o((d) => ({ ...d, refreshIntervalSecs: Number(a.target.value) })),
|
|
119
|
+
style: { width: "160px" }
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
] }),
|
|
123
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.5rem" }, children: [
|
|
124
|
+
/* @__PURE__ */ e(
|
|
125
|
+
"button",
|
|
126
|
+
{
|
|
127
|
+
className: "cedros-admin__button cedros-admin__button--primary",
|
|
128
|
+
onClick: L,
|
|
129
|
+
disabled: _,
|
|
130
|
+
children: _ ? "Saving..." : "Save Settings"
|
|
131
|
+
}
|
|
132
|
+
),
|
|
133
|
+
/* @__PURE__ */ e(
|
|
134
|
+
"button",
|
|
135
|
+
{
|
|
136
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
137
|
+
onClick: U,
|
|
138
|
+
disabled: A || !c.enabled || !c.apiUrl,
|
|
139
|
+
children: A ? "Refreshing..." : "Force Refresh"
|
|
140
|
+
}
|
|
141
|
+
)
|
|
142
|
+
] })
|
|
143
|
+
] });
|
|
144
|
+
}
|
|
145
|
+
function ve({ serverUrl: s, apiKey: g, pageSize: f = 50, authManager: c }) {
|
|
146
|
+
const [o, H] = i("holders"), [B, _] = i(null), [b, A] = i([]), [C, x] = i(!0), [h, R] = i(""), [y, v] = i([]), [L, U] = i(!0), [a, d] = i(null), [z, S] = i(!1), [W, te] = i(""), [J, ne] = i(""), [G, q] = i({ enabled: !0, batchSize: 100 }), [ae, ie] = i(!0), [X, Q] = i(!1), [l, w] = i(null), [I, $] = i(""), [F, V] = i(!1), u = T(async (t, r) => {
|
|
147
|
+
if (c?.isAuthenticated())
|
|
148
|
+
return c.fetchWithAuth(t, r);
|
|
149
|
+
const N = { "Content-Type": "application/json" };
|
|
150
|
+
g && (N["X-API-Key"] = g);
|
|
151
|
+
const M = await fetch(`${s}${t}`, { ...r, headers: { ...N, ...r?.headers } });
|
|
152
|
+
if (!M.ok) throw new Error(`Request failed: ${M.status}`);
|
|
153
|
+
return M.json();
|
|
154
|
+
}, [s, g, c]), P = T(async () => {
|
|
155
|
+
try {
|
|
156
|
+
const t = h ? `&status=${h}` : "", r = await u(
|
|
157
|
+
`/admin/compliance/holders?limit=${f}&offset=0${t}`
|
|
158
|
+
);
|
|
159
|
+
A(r.holders || []);
|
|
160
|
+
} catch (t) {
|
|
161
|
+
p().error("[ComplianceSection] Failed to fetch holders:", t), A([]), _("Failed to load token holders");
|
|
162
|
+
} finally {
|
|
163
|
+
x(!1);
|
|
164
|
+
}
|
|
165
|
+
}, [u, f, h]), D = T(async () => {
|
|
166
|
+
try {
|
|
167
|
+
const t = await u(
|
|
168
|
+
`/admin/compliance/actions?limit=${f}&offset=0`
|
|
169
|
+
);
|
|
170
|
+
v(t.actions || []);
|
|
171
|
+
} catch (t) {
|
|
172
|
+
p().error("[ComplianceSection] Failed to fetch actions:", t), v([]), _("Failed to load compliance actions");
|
|
173
|
+
} finally {
|
|
174
|
+
U(!1);
|
|
175
|
+
}
|
|
176
|
+
}, [u, f]), Y = T(async () => {
|
|
177
|
+
try {
|
|
178
|
+
const t = await u("/admin/compliance/sweep-settings");
|
|
179
|
+
q(t);
|
|
180
|
+
} catch (t) {
|
|
181
|
+
p().error("[ComplianceSection] Failed to fetch sweep settings:", t);
|
|
182
|
+
} finally {
|
|
183
|
+
ie(!1);
|
|
184
|
+
}
|
|
185
|
+
}, [u]), se = async () => {
|
|
186
|
+
Q(!0);
|
|
187
|
+
try {
|
|
188
|
+
await u("/admin/compliance/sweep-settings", {
|
|
189
|
+
method: "PUT",
|
|
190
|
+
body: JSON.stringify(G)
|
|
191
|
+
});
|
|
192
|
+
} catch (t) {
|
|
193
|
+
p().error("[ComplianceSection] Failed to save sweep settings:", t), _("Failed to save sweep settings");
|
|
194
|
+
} finally {
|
|
195
|
+
Q(!1);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
j(() => {
|
|
199
|
+
P();
|
|
200
|
+
}, [P]), j(() => {
|
|
201
|
+
D();
|
|
202
|
+
}, [D]), j(() => {
|
|
203
|
+
Y();
|
|
204
|
+
}, [Y]);
|
|
205
|
+
const re = async () => {
|
|
206
|
+
if (!(!l || !I.trim())) {
|
|
207
|
+
V(!0);
|
|
208
|
+
try {
|
|
209
|
+
const t = l.action === "freeze" ? "/admin/compliance/freeze" : "/admin/compliance/thaw";
|
|
210
|
+
await u(t, {
|
|
211
|
+
method: "POST",
|
|
212
|
+
body: JSON.stringify({ holderId: l.holder.id, reason: I })
|
|
213
|
+
}), w(null), $(""), await P(), await D();
|
|
214
|
+
} catch (t) {
|
|
215
|
+
p().error(`[ComplianceSection] ${l.action} failed:`, t), _(`Failed to ${l.action} holder`);
|
|
216
|
+
} finally {
|
|
217
|
+
V(!1);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}, le = async () => {
|
|
221
|
+
S(!0);
|
|
222
|
+
try {
|
|
223
|
+
const t = new URLSearchParams();
|
|
224
|
+
W && t.set("from", new Date(W).toISOString()), J && t.set("to", new Date(J).toISOString());
|
|
225
|
+
const r = await u(
|
|
226
|
+
`/admin/compliance/report?${t.toString()}`
|
|
227
|
+
);
|
|
228
|
+
d(r.report);
|
|
229
|
+
} catch (t) {
|
|
230
|
+
p().error("[ComplianceSection] Failed to generate report:", t), _("Failed to generate compliance report");
|
|
231
|
+
} finally {
|
|
232
|
+
S(!1);
|
|
233
|
+
}
|
|
234
|
+
}, ce = () => {
|
|
235
|
+
if (!a) return;
|
|
236
|
+
const t = new Blob([JSON.stringify(a, null, 2)], { type: "application/json" }), r = URL.createObjectURL(t), N = document.createElement("a");
|
|
237
|
+
N.href = r, N.download = `compliance-report-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.json`, N.click(), URL.revokeObjectURL(r);
|
|
238
|
+
}, oe = b.length, Z = b.filter((t) => t.status === "frozen").length, de = b.filter((t) => t.status === "active").length;
|
|
239
|
+
return /* @__PURE__ */ n("div", { className: "cedros-admin__page", children: [
|
|
240
|
+
/* @__PURE__ */ e(me, { message: B, onRetry: () => {
|
|
241
|
+
P(), D();
|
|
242
|
+
} }),
|
|
243
|
+
/* @__PURE__ */ e(
|
|
244
|
+
K,
|
|
245
|
+
{
|
|
246
|
+
stats: [
|
|
247
|
+
{ label: "Total Holders", value: oe },
|
|
248
|
+
{ label: "Active", value: de, variant: "success" },
|
|
249
|
+
{ label: "Frozen", value: Z, variant: Z > 0 ? "warning" : "muted" },
|
|
250
|
+
{ label: "Actions Logged", value: y.length }
|
|
251
|
+
],
|
|
252
|
+
isLoading: C || L
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__tabs", style: { display: "flex", gap: "0.5rem", marginBottom: "1rem" }, children: ["holders", "actions", "reports", "sweep-settings", "sanctions-api"].map((t) => /* @__PURE__ */ e(
|
|
256
|
+
"button",
|
|
257
|
+
{
|
|
258
|
+
type: "button",
|
|
259
|
+
className: `cedros-admin__button ${o === t ? "cedros-admin__button--primary" : "cedros-admin__button--ghost"}`,
|
|
260
|
+
onClick: () => H(t),
|
|
261
|
+
children: t === "holders" ? "Token Holders" : t === "actions" ? "Actions Log" : t === "reports" ? "Reports" : t === "sweep-settings" ? "Sweep Settings" : "Sanctions API"
|
|
262
|
+
},
|
|
263
|
+
t
|
|
264
|
+
)) }),
|
|
265
|
+
o === "holders" && /* @__PURE__ */ n(E, { children: [
|
|
266
|
+
/* @__PURE__ */ n("div", { className: "cedros-admin__section-header", style: { display: "flex", alignItems: "center", gap: "0.75rem" }, children: [
|
|
267
|
+
/* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Token Holders" }),
|
|
268
|
+
/* @__PURE__ */ n(
|
|
269
|
+
"select",
|
|
270
|
+
{
|
|
271
|
+
value: h,
|
|
272
|
+
onChange: (t) => {
|
|
273
|
+
R(t.target.value), x(!0);
|
|
274
|
+
},
|
|
275
|
+
className: "cedros-admin__input",
|
|
276
|
+
style: { width: "auto", padding: "0.25rem 0.5rem", fontSize: "0.85rem" },
|
|
277
|
+
children: [
|
|
278
|
+
/* @__PURE__ */ e("option", { value: "", children: "All statuses" }),
|
|
279
|
+
/* @__PURE__ */ e("option", { value: "active", children: "Active" }),
|
|
280
|
+
/* @__PURE__ */ e("option", { value: "frozen", children: "Frozen" }),
|
|
281
|
+
/* @__PURE__ */ e("option", { value: "thawed", children: "Thawed" })
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
)
|
|
285
|
+
] }),
|
|
286
|
+
C ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
287
|
+
k.loading,
|
|
288
|
+
" Loading holders..."
|
|
289
|
+
] }) : b.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No token holders found." }) : /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
290
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
|
|
291
|
+
/* @__PURE__ */ e("th", { children: "Wallet" }),
|
|
292
|
+
/* @__PURE__ */ e("th", { children: "Collection" }),
|
|
293
|
+
/* @__PURE__ */ e("th", { children: "Mint" }),
|
|
294
|
+
/* @__PURE__ */ e("th", { children: "Amount" }),
|
|
295
|
+
/* @__PURE__ */ e("th", { children: "Status" }),
|
|
296
|
+
/* @__PURE__ */ e("th", { children: "Created" }),
|
|
297
|
+
/* @__PURE__ */ e("th", { children: "Actions" })
|
|
298
|
+
] }) }),
|
|
299
|
+
/* @__PURE__ */ e("tbody", { children: b.map((t) => /* @__PURE__ */ n("tr", { children: [
|
|
300
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { title: t.walletAddress, children: m(t.walletAddress) }) }),
|
|
301
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { title: t.collectionId, children: m(t.collectionId) }) }),
|
|
302
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { title: t.mintAddress, children: m(t.mintAddress) }) }),
|
|
303
|
+
/* @__PURE__ */ e("td", { children: t.amountMinted }),
|
|
304
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${he(t.status)}`, children: t.status }) }),
|
|
305
|
+
/* @__PURE__ */ e("td", { children: O(t.createdAt) }),
|
|
306
|
+
/* @__PURE__ */ e("td", { children: t.status === "active" || t.status === "thawed" ? /* @__PURE__ */ e(
|
|
307
|
+
"button",
|
|
308
|
+
{
|
|
309
|
+
className: "cedros-admin__button cedros-admin__button--danger cedros-admin__button--sm",
|
|
310
|
+
onClick: () => {
|
|
311
|
+
w({ holder: t, action: "freeze" }), $("");
|
|
312
|
+
},
|
|
313
|
+
children: "Freeze"
|
|
314
|
+
}
|
|
315
|
+
) : t.status === "frozen" ? /* @__PURE__ */ e(
|
|
316
|
+
"button",
|
|
317
|
+
{
|
|
318
|
+
className: "cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",
|
|
319
|
+
onClick: () => {
|
|
320
|
+
w({ holder: t, action: "thaw" }), $("");
|
|
321
|
+
},
|
|
322
|
+
children: "Thaw"
|
|
323
|
+
}
|
|
324
|
+
) : null })
|
|
325
|
+
] }, t.id)) })
|
|
326
|
+
] }) })
|
|
327
|
+
] }),
|
|
328
|
+
o === "actions" && /* @__PURE__ */ n(E, { children: [
|
|
329
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Compliance Actions" }) }),
|
|
330
|
+
L ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
331
|
+
k.loading,
|
|
332
|
+
" Loading actions..."
|
|
333
|
+
] }) : y.length === 0 ? /* @__PURE__ */ e("div", { className: "cedros-admin__empty", children: "No compliance actions recorded." }) : /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
334
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
|
|
335
|
+
/* @__PURE__ */ e("th", { children: "Timestamp" }),
|
|
336
|
+
/* @__PURE__ */ e("th", { children: "Type" }),
|
|
337
|
+
/* @__PURE__ */ e("th", { children: "Wallet" }),
|
|
338
|
+
/* @__PURE__ */ e("th", { children: "Reason" }),
|
|
339
|
+
/* @__PURE__ */ e("th", { children: "Actor" }),
|
|
340
|
+
/* @__PURE__ */ e("th", { children: "Tx Signature" })
|
|
341
|
+
] }) }),
|
|
342
|
+
/* @__PURE__ */ e("tbody", { children: y.map((t) => /* @__PURE__ */ n("tr", { children: [
|
|
343
|
+
/* @__PURE__ */ e("td", { children: O(t.createdAt) }),
|
|
344
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${ee(t.actionType)}`, children: t.actionType }) }),
|
|
345
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { title: t.walletAddress, children: m(t.walletAddress) }) }),
|
|
346
|
+
/* @__PURE__ */ e("td", { children: t.reason || "—" }),
|
|
347
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: m(t.actor) }) }),
|
|
348
|
+
/* @__PURE__ */ e("td", { children: t.txSignature ? /* @__PURE__ */ e(
|
|
349
|
+
"a",
|
|
350
|
+
{
|
|
351
|
+
href: `${ue}${t.txSignature}`,
|
|
352
|
+
target: "_blank",
|
|
353
|
+
rel: "noopener noreferrer",
|
|
354
|
+
className: "cedros-admin__link",
|
|
355
|
+
children: m(t.txSignature)
|
|
356
|
+
}
|
|
357
|
+
) : "—" })
|
|
358
|
+
] }, t.id)) })
|
|
359
|
+
] }) })
|
|
360
|
+
] }),
|
|
361
|
+
o === "reports" && /* @__PURE__ */ n(E, { children: [
|
|
362
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Compliance Report" }) }),
|
|
363
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.75rem", alignItems: "flex-end", marginBottom: "1rem" }, children: [
|
|
364
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", fontSize: "0.85rem" }, children: [
|
|
365
|
+
"From",
|
|
366
|
+
/* @__PURE__ */ e("input", { type: "date", className: "cedros-admin__input", value: W, onChange: (t) => te(t.target.value) })
|
|
367
|
+
] }),
|
|
368
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", fontSize: "0.85rem" }, children: [
|
|
369
|
+
"To",
|
|
370
|
+
/* @__PURE__ */ e("input", { type: "date", className: "cedros-admin__input", value: J, onChange: (t) => ne(t.target.value) })
|
|
371
|
+
] }),
|
|
372
|
+
/* @__PURE__ */ e(
|
|
373
|
+
"button",
|
|
374
|
+
{
|
|
375
|
+
className: "cedros-admin__button cedros-admin__button--primary",
|
|
376
|
+
onClick: le,
|
|
377
|
+
disabled: z,
|
|
378
|
+
children: z ? "Generating..." : "Generate Report"
|
|
379
|
+
}
|
|
380
|
+
)
|
|
381
|
+
] }),
|
|
382
|
+
a && /* @__PURE__ */ n("div", { children: [
|
|
383
|
+
/* @__PURE__ */ e(
|
|
384
|
+
K,
|
|
385
|
+
{
|
|
386
|
+
stats: [
|
|
387
|
+
{ label: "Total Holders", value: a.totalHolders },
|
|
388
|
+
{ label: "Frozen", value: a.totalFrozen, variant: a.totalFrozen > 0 ? "warning" : "muted" },
|
|
389
|
+
{ label: "Freezes", value: a.freezeCount },
|
|
390
|
+
{ label: "Thaws", value: a.thawCount },
|
|
391
|
+
{ label: "Sweep Freezes", value: a.sweepFreezeCount, variant: a.sweepFreezeCount > 0 ? "warning" : "muted" }
|
|
392
|
+
],
|
|
393
|
+
isLoading: !1
|
|
394
|
+
}
|
|
395
|
+
),
|
|
396
|
+
/* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", margin: "1rem 0 0.5rem" }, children: [
|
|
397
|
+
/* @__PURE__ */ n("span", { style: { fontSize: "0.85rem", color: "var(--cedros-admin-text-muted, #888)" }, children: [
|
|
398
|
+
"Generated ",
|
|
399
|
+
O(a.generatedAt),
|
|
400
|
+
" · ",
|
|
401
|
+
a.actionsInPeriod,
|
|
402
|
+
" actions in period"
|
|
403
|
+
] }),
|
|
404
|
+
/* @__PURE__ */ e("button", { className: "cedros-admin__button cedros-admin__button--ghost", onClick: ce, children: "Download JSON" })
|
|
405
|
+
] }),
|
|
406
|
+
a.actions.length > 0 && /* @__PURE__ */ e("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
407
|
+
/* @__PURE__ */ e("thead", { children: /* @__PURE__ */ n("tr", { children: [
|
|
408
|
+
/* @__PURE__ */ e("th", { children: "Timestamp" }),
|
|
409
|
+
/* @__PURE__ */ e("th", { children: "Type" }),
|
|
410
|
+
/* @__PURE__ */ e("th", { children: "Wallet" }),
|
|
411
|
+
/* @__PURE__ */ e("th", { children: "Reason" }),
|
|
412
|
+
/* @__PURE__ */ e("th", { children: "Actor" })
|
|
413
|
+
] }) }),
|
|
414
|
+
/* @__PURE__ */ e("tbody", { children: a.actions.map((t) => /* @__PURE__ */ n("tr", { children: [
|
|
415
|
+
/* @__PURE__ */ e("td", { children: O(t.createdAt) }),
|
|
416
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("span", { className: `cedros-admin__badge cedros-admin__badge--${ee(t.actionType)}`, children: t.actionType }) }),
|
|
417
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { title: t.walletAddress, children: m(t.walletAddress) }) }),
|
|
418
|
+
/* @__PURE__ */ e("td", { children: t.reason || "—" }),
|
|
419
|
+
/* @__PURE__ */ e("td", { children: /* @__PURE__ */ e("code", { children: m(t.actor) }) })
|
|
420
|
+
] }, t.id)) })
|
|
421
|
+
] }) })
|
|
422
|
+
] })
|
|
423
|
+
] }),
|
|
424
|
+
o === "sweep-settings" && /* @__PURE__ */ n(E, { children: [
|
|
425
|
+
/* @__PURE__ */ e("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ e("h3", { className: "cedros-admin__section-title", children: "Sanctions Sweep Settings" }) }),
|
|
426
|
+
ae ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
427
|
+
k.loading,
|
|
428
|
+
" Loading settings..."
|
|
429
|
+
] }) : /* @__PURE__ */ n("div", { style: { maxWidth: "400px", display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
430
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: "0.5rem", fontSize: "0.9rem" }, children: [
|
|
431
|
+
/* @__PURE__ */ e(
|
|
432
|
+
"input",
|
|
433
|
+
{
|
|
434
|
+
type: "checkbox",
|
|
435
|
+
checked: G.enabled,
|
|
436
|
+
onChange: (t) => q((r) => ({ ...r, enabled: t.target.checked }))
|
|
437
|
+
}
|
|
438
|
+
),
|
|
439
|
+
"Enable automated sanctions sweep"
|
|
440
|
+
] }),
|
|
441
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", fontSize: "0.85rem" }, children: [
|
|
442
|
+
"Batch size (1 – 10,000)",
|
|
443
|
+
/* @__PURE__ */ e(
|
|
444
|
+
"input",
|
|
445
|
+
{
|
|
446
|
+
type: "number",
|
|
447
|
+
className: "cedros-admin__input",
|
|
448
|
+
min: 1,
|
|
449
|
+
max: 1e4,
|
|
450
|
+
value: G.batchSize,
|
|
451
|
+
onChange: (t) => q((r) => ({ ...r, batchSize: Number(t.target.value) })),
|
|
452
|
+
style: { width: "160px" }
|
|
453
|
+
}
|
|
454
|
+
)
|
|
455
|
+
] }),
|
|
456
|
+
/* @__PURE__ */ e(
|
|
457
|
+
"button",
|
|
458
|
+
{
|
|
459
|
+
className: "cedros-admin__button cedros-admin__button--primary",
|
|
460
|
+
onClick: se,
|
|
461
|
+
disabled: X,
|
|
462
|
+
style: { alignSelf: "flex-start" },
|
|
463
|
+
children: X ? "Saving..." : "Save Settings"
|
|
464
|
+
}
|
|
465
|
+
)
|
|
466
|
+
] })
|
|
467
|
+
] }),
|
|
468
|
+
o === "sanctions-api" && /* @__PURE__ */ e(ge, { serverUrl: s, apiKey: g, authManager: c }),
|
|
469
|
+
l && /* @__PURE__ */ e("div", { className: "cedros-admin__modal-overlay", onClick: () => !F && w(null), children: /* @__PURE__ */ n("div", { className: "cedros-admin__modal", onClick: (t) => t.stopPropagation(), children: [
|
|
470
|
+
/* @__PURE__ */ n("div", { className: "cedros-admin__modal-header", children: [
|
|
471
|
+
/* @__PURE__ */ n("h4", { className: "cedros-admin__modal-title", children: [
|
|
472
|
+
l.action === "freeze" ? "Freeze" : "Thaw",
|
|
473
|
+
" Token Account"
|
|
474
|
+
] }),
|
|
475
|
+
/* @__PURE__ */ e(
|
|
476
|
+
"button",
|
|
477
|
+
{
|
|
478
|
+
type: "button",
|
|
479
|
+
className: "cedros-admin__modal-close",
|
|
480
|
+
onClick: () => !F && w(null),
|
|
481
|
+
children: k.close
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
] }),
|
|
485
|
+
/* @__PURE__ */ n("div", { className: "cedros-admin__modal-body", children: [
|
|
486
|
+
/* @__PURE__ */ n("p", { style: { marginBottom: "0.5rem", fontSize: "0.9rem" }, children: [
|
|
487
|
+
"Wallet: ",
|
|
488
|
+
/* @__PURE__ */ e("code", { children: m(l.holder.walletAddress) })
|
|
489
|
+
] }),
|
|
490
|
+
/* @__PURE__ */ n("p", { style: { marginBottom: "0.75rem", fontSize: "0.9rem" }, children: [
|
|
491
|
+
"Mint: ",
|
|
492
|
+
/* @__PURE__ */ e("code", { children: m(l.holder.mintAddress) })
|
|
493
|
+
] }),
|
|
494
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", flexDirection: "column", gap: "0.25rem", fontSize: "0.85rem" }, children: [
|
|
495
|
+
"Reason (required)",
|
|
496
|
+
/* @__PURE__ */ e(
|
|
497
|
+
"textarea",
|
|
498
|
+
{
|
|
499
|
+
className: "cedros-admin__input",
|
|
500
|
+
rows: 3,
|
|
501
|
+
value: I,
|
|
502
|
+
onChange: (t) => $(t.target.value),
|
|
503
|
+
placeholder: `Reason for ${l.action}...`,
|
|
504
|
+
maxLength: 1024
|
|
505
|
+
}
|
|
506
|
+
)
|
|
507
|
+
] })
|
|
508
|
+
] }),
|
|
509
|
+
/* @__PURE__ */ n("div", { className: "cedros-admin__modal-footer", children: [
|
|
510
|
+
/* @__PURE__ */ e(
|
|
511
|
+
"button",
|
|
512
|
+
{
|
|
513
|
+
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
514
|
+
onClick: () => w(null),
|
|
515
|
+
disabled: F,
|
|
516
|
+
children: "Cancel"
|
|
517
|
+
}
|
|
518
|
+
),
|
|
519
|
+
/* @__PURE__ */ e(
|
|
520
|
+
"button",
|
|
521
|
+
{
|
|
522
|
+
className: `cedros-admin__button ${l.action === "freeze" ? "cedros-admin__button--danger" : "cedros-admin__button--primary"}`,
|
|
523
|
+
onClick: re,
|
|
524
|
+
disabled: F || !I.trim(),
|
|
525
|
+
children: F ? "Processing..." : l.action === "freeze" ? "Freeze Account" : "Thaw Account"
|
|
526
|
+
}
|
|
527
|
+
)
|
|
528
|
+
] })
|
|
529
|
+
] }) })
|
|
530
|
+
] });
|
|
531
|
+
}
|
|
532
|
+
export {
|
|
533
|
+
ve as ComplianceSection
|
|
534
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),l=require("./index-C7MWL6O8.js"),g=require("./CedrosContext-C2RjHLaQ.js"),m=i=>i.length>12?`${i.slice(0,6)}...${i.slice(-4)}`:i,ie=i=>{switch(i){case"active":return"success";case"frozen":return"failed";case"thawed":return"pending";default:return"muted"}},X=i=>{switch(i){case"freeze":return"failed";case"thaw":return"success";case"sweep_freeze":return"failed";case"report_generated":return"muted";default:return"muted"}},re="https://explorer.solana.com/tx/",le={apiUrl:"",refreshIntervalSecs:3600,enabled:!1};function ce({serverUrl:i,apiKey:x,authManager:p}){const[c,o]=s.useState(le),[$,P]=s.useState(!0),[f,j]=s.useState(!1),[w,N]=s.useState(!1),[C,h]=s.useState(null),[T,_]=s.useState(null),b=s.useCallback(async(n,d)=>{if(p?.isAuthenticated())return p.fetchWithAuth(n,d);const A={"Content-Type":"application/json"};x&&(A["X-API-Key"]=x);const y=await fetch(`${i}${n}`,{...d,headers:{...A,...d?.headers}});if(!y.ok)throw new Error(`Request failed: ${y.status}`);return y.json()},[i,x,p]);s.useEffect(()=>{(async()=>{try{const n=await b("/admin/compliance/sanctions-api");o(n)}catch(n){g.getLogger().error("[ComplianceSanctionsApi] Failed to fetch settings:",n)}finally{P(!1)}})()},[b]);const F=async()=>{j(!0),h(null),_(null);try{await b("/admin/compliance/sanctions-api",{method:"PUT",body:JSON.stringify(c)}),_("Settings saved")}catch(n){g.getLogger().error("[ComplianceSanctionsApi] Save failed:",n),h("Failed to save settings")}finally{j(!1)}},D=async()=>{N(!0),h(null),_(null);try{await b("/admin/compliance/sanctions-api/refresh",{method:"POST"}),_("Sanctions list refreshed")}catch(n){g.getLogger().error("[ComplianceSanctionsApi] Refresh failed:",n),h("Failed to refresh sanctions list")}finally{N(!1)}};return $?e.jsxs("div",{className:"cedros-admin__loading",children:[l.Icons.loading," Loading sanctions API settings..."]}):e.jsxs("div",{style:{maxWidth:"500px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Dynamic Sanctions API"})}),C&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem"},children:C}),T&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--success",style:{padding:"0.5rem"},children:T}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:c.enabled,onChange:n=>o(d=>({...d,enabled:n.target.checked}))}),"Enable dynamic sanctions list"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["API URL",e.jsx("input",{type:"url",className:"cedros-admin__input",placeholder:"https://sunscreen.cedros.io",value:c.apiUrl,onChange:n=>o(d=>({...d,apiUrl:n.target.value}))})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Refresh interval (seconds, min 60)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:60,value:c.refreshIntervalSecs,onChange:n=>o(d=>({...d,refreshIntervalSecs:Number(n.target.value)})),style:{width:"160px"}})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:F,disabled:f,children:f?"Saving...":"Save Settings"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:D,disabled:w||!c.enabled||!c.apiUrl,children:w?"Refreshing...":"Force Refresh"})]})]})}function oe({serverUrl:i,apiKey:x,pageSize:p=50,authManager:c}){const[o,$]=s.useState("holders"),[P,f]=s.useState(null),[j,w]=s.useState([]),[N,C]=s.useState(!0),[h,T]=s.useState(""),[_,b]=s.useState([]),[F,D]=s.useState(!0),[n,d]=s.useState(null),[A,y]=s.useState(!1),[E,Q]=s.useState(""),[O,V]=s.useState(""),[H,B]=s.useState({enabled:!0,batchSize:100}),[Y,Z]=s.useState(!0),[W,q]=s.useState(!1),[r,S]=s.useState(null),[L,k]=s.useState(""),[z,J]=s.useState(!1),u=s.useCallback(async(t,a)=>{if(c?.isAuthenticated())return c.fetchWithAuth(t,a);const v={"Content-Type":"application/json"};x&&(v["X-API-Key"]=x);const U=await fetch(`${i}${t}`,{...a,headers:{...v,...a?.headers}});if(!U.ok)throw new Error(`Request failed: ${U.status}`);return U.json()},[i,x,c]),R=s.useCallback(async()=>{try{const t=h?`&status=${h}`:"",a=await u(`/admin/compliance/holders?limit=${p}&offset=0${t}`);w(a.holders||[])}catch(t){g.getLogger().error("[ComplianceSection] Failed to fetch holders:",t),w([]),f("Failed to load token holders")}finally{C(!1)}},[u,p,h]),I=s.useCallback(async()=>{try{const t=await u(`/admin/compliance/actions?limit=${p}&offset=0`);b(t.actions||[])}catch(t){g.getLogger().error("[ComplianceSection] Failed to fetch actions:",t),b([]),f("Failed to load compliance actions")}finally{D(!1)}},[u,p]),G=s.useCallback(async()=>{try{const t=await u("/admin/compliance/sweep-settings");B(t)}catch(t){g.getLogger().error("[ComplianceSection] Failed to fetch sweep settings:",t)}finally{Z(!1)}},[u]),K=async()=>{q(!0);try{await u("/admin/compliance/sweep-settings",{method:"PUT",body:JSON.stringify(H)})}catch(t){g.getLogger().error("[ComplianceSection] Failed to save sweep settings:",t),f("Failed to save sweep settings")}finally{q(!1)}};s.useEffect(()=>{R()},[R]),s.useEffect(()=>{I()},[I]),s.useEffect(()=>{G()},[G]);const ee=async()=>{if(!(!r||!L.trim())){J(!0);try{const t=r.action==="freeze"?"/admin/compliance/freeze":"/admin/compliance/thaw";await u(t,{method:"POST",body:JSON.stringify({holderId:r.holder.id,reason:L})}),S(null),k(""),await R(),await I()}catch(t){g.getLogger().error(`[ComplianceSection] ${r.action} failed:`,t),f(`Failed to ${r.action} holder`)}finally{J(!1)}}},te=async()=>{y(!0);try{const t=new URLSearchParams;E&&t.set("from",new Date(E).toISOString()),O&&t.set("to",new Date(O).toISOString());const a=await u(`/admin/compliance/report?${t.toString()}`);d(a.report)}catch(t){g.getLogger().error("[ComplianceSection] Failed to generate report:",t),f("Failed to generate compliance report")}finally{y(!1)}},se=()=>{if(!n)return;const t=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),a=URL.createObjectURL(t),v=document.createElement("a");v.href=a,v.download=`compliance-report-${new Date().toISOString().slice(0,10)}.json`,v.click(),URL.revokeObjectURL(a)},ne=j.length,M=j.filter(t=>t.status==="frozen").length,ae=j.filter(t=>t.status==="active").length;return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(l.ErrorBanner,{message:P,onRetry:()=>{R(),I()}}),e.jsx(l.StatsBar,{stats:[{label:"Total Holders",value:ne},{label:"Active",value:ae,variant:"success"},{label:"Frozen",value:M,variant:M>0?"warning":"muted"},{label:"Actions Logged",value:_.length}],isLoading:N||F}),e.jsx("div",{className:"cedros-admin__tabs",style:{display:"flex",gap:"0.5rem",marginBottom:"1rem"},children:["holders","actions","reports","sweep-settings","sanctions-api"].map(t=>{const a=t==="holders"?"Token Holders":t==="actions"?"Actions Log":t==="reports"?"Reports":t==="sweep-settings"?"Sweep Settings":"Sanctions API";return e.jsx("button",{type:"button",className:`cedros-admin__button ${o===t?"cedros-admin__button--primary":"cedros-admin__button--ghost"}`,onClick:()=>$(t),children:a},t)})}),o==="holders"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__section-header",style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Token Holders"}),e.jsxs("select",{value:h,onChange:t=>{T(t.target.value),C(!0)},className:"cedros-admin__input",style:{width:"auto",padding:"0.25rem 0.5rem",fontSize:"0.85rem"},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"frozen",children:"Frozen"}),e.jsx("option",{value:"thawed",children:"Thawed"})]})]}),N?e.jsxs("div",{className:"cedros-admin__loading",children:[l.Icons.loading," Loading holders..."]}):j.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No token holders found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"Mint"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:j.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:m(t.walletAddress)})}),e.jsx("td",{children:e.jsx("code",{title:t.collectionId,children:m(t.collectionId)})}),e.jsx("td",{children:e.jsx("code",{title:t.mintAddress,children:m(t.mintAddress)})}),e.jsx("td",{children:t.amountMinted}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${ie(t.status)}`,children:t.status})}),e.jsx("td",{children:l.formatDateTime(t.createdAt)}),e.jsx("td",{children:t.status==="active"||t.status==="thawed"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger cedros-admin__button--sm",onClick:()=>{S({holder:t,action:"freeze"}),k("")},children:"Freeze"}):t.status==="frozen"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{S({holder:t,action:"thaw"}),k("")},children:"Thaw"}):null})]},t.id))})]})})]}),o==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Actions"})}),F?e.jsxs("div",{className:"cedros-admin__loading",children:[l.Icons.loading," Loading actions..."]}):_.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No compliance actions recorded."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"}),e.jsx("th",{children:"Tx Signature"})]})}),e.jsx("tbody",{children:_.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:l.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${X(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:m(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:m(t.actor)})}),e.jsx("td",{children:t.txSignature?e.jsx("a",{href:`${re}${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin__link",children:m(t.txSignature)}):"—"})]},t.id))})]})})]}),o==="reports"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Report"})}),e.jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"flex-end",marginBottom:"1rem"},children:[e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["From",e.jsx("input",{type:"date",className:"cedros-admin__input",value:E,onChange:t=>Q(t.target.value)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["To",e.jsx("input",{type:"date",className:"cedros-admin__input",value:O,onChange:t=>V(t.target.value)})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:te,disabled:A,children:A?"Generating...":"Generate Report"})]}),n&&e.jsxs("div",{children:[e.jsx(l.StatsBar,{stats:[{label:"Total Holders",value:n.totalHolders},{label:"Frozen",value:n.totalFrozen,variant:n.totalFrozen>0?"warning":"muted"},{label:"Freezes",value:n.freezeCount},{label:"Thaws",value:n.thawCount},{label:"Sweep Freezes",value:n.sweepFreezeCount,variant:n.sweepFreezeCount>0?"warning":"muted"}],isLoading:!1}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"1rem 0 0.5rem"},children:[e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:["Generated ",l.formatDateTime(n.generatedAt)," · ",n.actionsInPeriod," actions in period"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:se,children:"Download JSON"})]}),n.actions.length>0&&e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:n.actions.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:l.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${X(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:m(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:m(t.actor)})})]},t.id))})]})})]})]}),o==="sweep-settings"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Sanctions Sweep Settings"})}),Y?e.jsxs("div",{className:"cedros-admin__loading",children:[l.Icons.loading," Loading settings..."]}):e.jsxs("div",{style:{maxWidth:"400px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:H.enabled,onChange:t=>B(a=>({...a,enabled:t.target.checked}))}),"Enable automated sanctions sweep"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Batch size (1 – 10,000)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:1,max:1e4,value:H.batchSize,onChange:t=>B(a=>({...a,batchSize:Number(t.target.value)})),style:{width:"160px"}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:K,disabled:W,style:{alignSelf:"flex-start"},children:W?"Saving...":"Save Settings"})]})]}),o==="sanctions-api"&&e.jsx(ce,{serverUrl:i,apiKey:x,authManager:c}),r&&e.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>!z&&S(null),children:e.jsxs("div",{className:"cedros-admin__modal",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"cedros-admin__modal-header",children:[e.jsxs("h4",{className:"cedros-admin__modal-title",children:[r.action==="freeze"?"Freeze":"Thaw"," Token Account"]}),e.jsx("button",{type:"button",className:"cedros-admin__modal-close",onClick:()=>!z&&S(null),children:l.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__modal-body",children:[e.jsxs("p",{style:{marginBottom:"0.5rem",fontSize:"0.9rem"},children:["Wallet: ",e.jsx("code",{children:m(r.holder.walletAddress)})]}),e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem"},children:["Mint: ",e.jsx("code",{children:m(r.holder.mintAddress)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Reason (required)",e.jsx("textarea",{className:"cedros-admin__input",rows:3,value:L,onChange:t=>k(t.target.value),placeholder:`Reason for ${r.action}...`,maxLength:1024})]})]}),e.jsxs("div",{className:"cedros-admin__modal-footer",children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>S(null),disabled:z,children:"Cancel"}),e.jsx("button",{className:`cedros-admin__button ${r.action==="freeze"?"cedros-admin__button--danger":"cedros-admin__button--primary"}`,onClick:ee,disabled:z||!L.trim(),children:z?"Processing...":r.action==="freeze"?"Freeze Account":"Thaw Account"})]})]})})]})}exports.ComplianceSection=oe;
|