@cedros/pay-react 1.1.28 → 1.1.29
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-DELur7D2.js → AISettingsSection-B7qrycfY.js} +2 -2
- package/dist/{AISettingsSection-BlIv3CzS.mjs → AISettingsSection-DtAgMsDw.mjs} +6 -4
- package/dist/{AutosaveIndicator-Bed0-ekg.mjs → AutosaveIndicator-BEvABoKU.mjs} +1 -1
- package/dist/AutosaveIndicator-DiyeAg93.js +1 -0
- package/dist/CedrosContext-5Gjveoba.mjs +2555 -0
- package/dist/CedrosContext-CCakH2SZ.js +3 -0
- package/dist/CedrosPayAdminDashboard-CAwEvn66.js +1 -0
- package/dist/CedrosPayAdminDashboard-CBuvNAtB.mjs +250 -0
- package/dist/{ChatLogsSection-v4zwzCTC.mjs → ChatLogsSection-Ber5o8hF.mjs} +19 -17
- package/dist/ChatLogsSection-DLxMMi9I.js +1 -0
- package/dist/ComplianceSection-Buu0zTiL.js +1 -0
- package/dist/{ComplianceSection-CemgfDrL.mjs → ComplianceSection-ZCr0wsvw.mjs} +18 -15
- package/dist/{CryptoButton-BV9owVe2.mjs → CryptoButton-Cl2kZbOP.mjs} +26 -24
- package/dist/CryptoButton-DxFCYDlJ.js +1 -0
- package/dist/CustomersSection-BywmMLur.js +1 -0
- package/dist/{CustomersSection-D_j7OrfS.mjs → CustomersSection-D9UknSKC.mjs} +21 -19
- package/dist/{DisputesSection-BcAbXp3K.mjs → DisputesSection-C_eySK-W.mjs} +19 -17
- package/dist/DisputesSection-DwkHGv2a.js +1 -0
- package/dist/Dropdown-B90Zabxr.mjs +111 -0
- package/dist/Dropdown-CtY91emj.js +1 -0
- package/dist/ErrorBanner-CZXsHi3H.mjs +22 -0
- package/dist/ErrorBanner-Cx2dUhps.js +1 -0
- package/dist/{FAQSection-Dn38OhB_.mjs → FAQSection-Bv_Hdt8B.mjs} +8 -6
- package/dist/FAQSection-DlPLnIJD.js +1 -0
- package/dist/ImagesSection-B4Jzet79.js +1 -0
- package/dist/{ImagesSection-Ctw9Icym.mjs → ImagesSection-DpdXQ6qu.mjs} +6 -4
- package/dist/InventorySection-BgRdpn1l.js +1 -0
- package/dist/{InventorySection-DmhjUlRZ.mjs → InventorySection-DZMu9DMw.mjs} +25 -23
- package/dist/MessagingSection-CxV-pf-f.js +1 -0
- package/dist/{MessagingSection-B1FaGxkp.mjs → MessagingSection-D_cOBfFt.mjs} +5 -4
- package/dist/OrdersSection-BbAX79Ff.js +1 -0
- package/dist/{OrdersSection-Bj8bPdg8.mjs → OrdersSection-wfPavit9.mjs} +27 -24
- package/dist/PaymentSettingsSection-BdBDgaRg.js +1 -0
- package/dist/PaymentSettingsSection-DunzBo9n.mjs +648 -0
- package/dist/ReturnsSection-7k4LZ8yp.js +1 -0
- package/dist/{ReturnsSection-BC0L8r2e.mjs → ReturnsSection-B4FL7bUv.mjs} +11 -9
- package/dist/{SettingsSection-vdYFSNxB.js → SettingsSection-Cz2Yjdhr.js} +1 -1
- package/dist/{SettingsSection-KYdEizq_.mjs → SettingsSection-DoeNDbqd.mjs} +1 -1
- package/dist/{ShippingSection-BOgto6_9.mjs → ShippingSection-BlVsYC6B.mjs} +5 -3
- package/dist/ShippingSection-C-HI8rOb.js +1 -0
- package/dist/{SingleCategorySettings-suJ8z9d8.mjs → SingleCategorySettings-B406nnF-.mjs} +143 -140
- package/dist/SingleCategorySettings-BqC2UXt3.js +3 -0
- package/dist/StatsBar-D4v-I_Dj.mjs +25 -0
- package/dist/StatsBar-m6GSRNxs.js +1 -0
- package/dist/StorefrontSection-Axvh_KeS.js +1 -0
- package/dist/{StorefrontSection-BRvIGBEJ.mjs → StorefrontSection-BK_rhrAi.mjs} +121 -119
- package/dist/{SubscriptionsSection-D60qrX9a.mjs → SubscriptionsSection-D8V9RBv-.mjs} +11 -9
- package/dist/SubscriptionsSection-EeULMWIB.js +1 -0
- package/dist/{TaxSection-C7-pv-Rl.mjs → TaxSection-Cj6TXL6x.mjs} +23 -21
- package/dist/TaxSection-CzHPhaHl.js +1 -0
- package/dist/ThemeContext-CFXyYx7A.js +1 -0
- package/dist/ThemeContext-l0bqcOGW.mjs +126 -0
- package/dist/Token22Section-DqRKVG_G.js +1 -0
- package/dist/{Token22Section-CrHLQ0EB.mjs → Token22Section-DtYAcT54.mjs} +7 -6
- package/dist/{WalletManager-BIwH8Dw_.mjs → WalletManager-D-eoqUDy.mjs} +21 -19
- package/dist/WalletManager-DXChB9LA.js +1 -0
- package/dist/WebhooksSection-D--iPZuM.js +1 -0
- package/dist/{WebhooksSection-COPW4Ec0.mjs → WebhooksSection-DBAIxtBy.mjs} +40 -38
- package/dist/admin.d.ts +2 -0
- package/dist/admin.js +1 -0
- package/dist/admin.mjs +8 -0
- package/dist/configApi-BS5UJfzm.js +1 -0
- package/dist/{configApi-6XhAJGKX.mjs → configApi-BUXZOMWK.mjs} +57 -3
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +214 -202
- package/dist/dateHelpers-BKW_lGND.js +1 -0
- package/dist/dateHelpers-yvPkofYQ.mjs +6 -0
- package/dist/fetchWithTimeout-CG0EKbhf.js +1 -0
- package/dist/fetchWithTimeout-DmMOwL0Q.mjs +195 -0
- package/dist/index-9QF_UfSN.mjs +18668 -0
- package/dist/index-Cq9ya93W.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +74 -64
- package/dist/safeHref-DqJPLPl5.mjs +12 -0
- package/dist/safeHref-DyHIpVjY.js +1 -0
- package/dist/sectionIds-B_tFiNvF.js +1 -0
- package/dist/sectionIds-DBavltrL.mjs +359 -0
- package/dist/sections-BHph7CYj.mjs +9 -0
- package/dist/sections-C2zEJr5G.js +1 -0
- package/dist/sections-more-C1VNVwkp.js +1 -0
- package/dist/sections-more-CMFgfU4d.mjs +3082 -0
- package/dist/src/admin/index.d.ts +3 -3
- package/dist/src/admin/index.d.ts.map +1 -1
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/admin/types.d.ts +2 -6
- package/dist/src/admin/types.d.ts.map +1 -1
- package/dist/src/admin.d.ts +9 -0
- package/dist/src/admin.d.ts.map +1 -0
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +4 -0
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +1 -0
- package/dist/src/components/admin/PaymentReadinessChecklist.d.ts +9 -0
- package/dist/src/components/admin/PaymentReadinessChecklist.d.ts.map +1 -0
- package/dist/src/components/admin/PaymentSettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/PaymentSetupGuide.d.ts +6 -0
- package/dist/src/components/admin/PaymentSetupGuide.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/configApi.d.ts +1 -1
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +3 -50
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/index.d.ts +1 -1
- package/dist/src/components/admin/index.d.ts.map +1 -1
- package/dist/src/components/admin/types.d.ts +43 -0
- package/dist/src/components/admin/types.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts +2 -0
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts +2 -0
- package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts.map +1 -0
- package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
- package/dist/src/ecommerce/components/general/ErrorBoundary.d.ts +1 -1
- package/dist/src/ecommerce/components/ui/button.d.ts +1 -1
- package/dist/src/ecommerce/components/ui/sheet.d.ts +1 -1
- package/dist/src/ecommerce/config/context.d.ts +2 -0
- package/dist/src/ecommerce/config/context.d.ts.map +1 -1
- package/dist/src/ecommerce/config/types.d.ts +2 -0
- package/dist/src/ecommerce/config/types.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +2 -0
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/featureFlags.d.ts +41 -0
- package/dist/src/featureFlags.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts +1 -0
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +47 -1
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/validateConfig.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +35 -33
- package/dist/styles--fxb3lCl.js +1 -0
- package/dist/{styles-D4SQkuV3.mjs → styles-DGagylUj.mjs} +53 -51
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/tokenMintValidator-DAjQld0r.mjs +98 -0
- package/dist/tokenMintValidator-DNBhoefh.js +4 -0
- package/dist/{walletPool-DE-t1wSW.mjs → walletPool-9MylB2QK.mjs} +1 -1
- package/dist/walletPool-BjTXX6Vn.js +1 -0
- package/package.json +3 -3
- package/dist/AutosaveIndicator-Dn_qA2hK.js +0 -1
- package/dist/CedrosContext-C2RjHLaQ.js +0 -6
- package/dist/CedrosContext-CY6zvjvJ.mjs +0 -2801
- package/dist/ChatLogsSection-BH5tLA4T.js +0 -1
- package/dist/ComplianceSection-DP2a9-S0.js +0 -1
- package/dist/CryptoButton-DpiCnyXE.js +0 -1
- package/dist/CustomersSection-CBwy_waO.js +0 -1
- package/dist/DisputesSection-BLjIk60n.js +0 -1
- package/dist/FAQSection-wNeH0i6Q.js +0 -1
- package/dist/ImagesSection-0ZzKlzMJ.js +0 -1
- package/dist/InventorySection-zV6lTmue.js +0 -1
- package/dist/MessagingSection-B_wdFR0j.js +0 -1
- package/dist/OrdersSection-Dw2FX-1d.js +0 -1
- package/dist/PaymentSettingsSection-BYF4D-GR.js +0 -1
- package/dist/PaymentSettingsSection-EnMxeWjv.mjs +0 -94
- package/dist/ReturnsSection-D_pJVxuG.js +0 -1
- package/dist/ShippingSection-1DRSTu49.js +0 -1
- package/dist/SingleCategorySettings-DwCnBdRf.js +0 -3
- package/dist/StorefrontSection-RumGkb3C.js +0 -1
- package/dist/SubscriptionsSection-C2aLLn7L.js +0 -1
- package/dist/TaxSection-Dt1DnM51.js +0 -1
- package/dist/Token22Section-DY3mUwTY.js +0 -1
- package/dist/WalletManager-B3UdQ5pQ.js +0 -1
- package/dist/WebhooksSection-CKeiJ7Py.js +0 -1
- package/dist/configApi-DkduMQg1.js +0 -1
- package/dist/index-C0g-JxJk.js +0 -84
- package/dist/index-DXnuQp5x.mjs +0 -22128
- package/dist/sections-C1NpK7hk.mjs +0 -9
- package/dist/sections-DVVSZBhW.js +0 -1
- package/dist/styles-BT4bhFey.js +0 -1
- package/dist/walletPool-IS7R3MR1.js +0 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as a, jsxs as i } from "react/jsx-runtime";
|
|
2
2
|
import { useState as g, useCallback as F, useEffect as D, useMemo as E } from "react";
|
|
3
|
-
import { I as h
|
|
3
|
+
import { I as h } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as Z } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
5
|
+
import { S as K } from "./StatsBar-D4v-I_Dj.mjs";
|
|
4
6
|
const l = {
|
|
5
7
|
enabled: !1,
|
|
6
8
|
plans: [],
|
|
@@ -24,7 +26,7 @@ const l = {
|
|
|
24
26
|
function ae() {
|
|
25
27
|
return `plan_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
|
|
26
28
|
}
|
|
27
|
-
function
|
|
29
|
+
function de({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
28
30
|
const [r, b] = g(l), [y, Q] = g(!0), [I, P] = g(null), [u, U] = g("plans"), [S, C] = g("idle"), [J, x] = g(null), [d, m] = g({
|
|
29
31
|
enabled: l.enabled,
|
|
30
32
|
pageTitle: l.pageTitle,
|
|
@@ -147,7 +149,7 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
147
149
|
...n,
|
|
148
150
|
plans: n.plans.filter((s) => s.id !== e)
|
|
149
151
|
})), I === e && P(null));
|
|
150
|
-
},
|
|
152
|
+
}, H = (e, n) => {
|
|
151
153
|
const s = r.plans.findIndex((p) => p.id === e);
|
|
152
154
|
if (s === -1 || n === "up" && s === 0 || n === "down" && s === r.plans.length - 1) return;
|
|
153
155
|
const t = [...r.plans], o = n === "up" ? s - 1 : s + 1;
|
|
@@ -172,7 +174,7 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
172
174
|
h.loading,
|
|
173
175
|
" Loading subscription settings..."
|
|
174
176
|
] }) });
|
|
175
|
-
const
|
|
177
|
+
const O = r.plans.filter((e) => e.isActive).length, j = r.plans.reduce((e, n) => e + (n.activeSubscribers ?? 0), 0), B = d.enabled, V = r.plans.filter((e) => e.isActive).map((e) => ({
|
|
176
178
|
label: e.title,
|
|
177
179
|
value: e.activeSubscribers ?? 0,
|
|
178
180
|
description: "subscribers"
|
|
@@ -184,8 +186,8 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
184
186
|
{
|
|
185
187
|
stats: [
|
|
186
188
|
{ label: "Status", value: B ? "Enabled" : "Disabled", variant: B ? "success" : "muted" },
|
|
187
|
-
{ label: "Active Plans", value:
|
|
188
|
-
{ label: "Total Subscribers", value:
|
|
189
|
+
{ label: "Active Plans", value: O, variant: O > 0 ? "success" : "muted" },
|
|
190
|
+
{ label: "Total Subscribers", value: j, variant: j > 0 ? "success" : "muted" },
|
|
189
191
|
...V
|
|
190
192
|
],
|
|
191
193
|
isLoading: y
|
|
@@ -379,7 +381,7 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
379
381
|
"button",
|
|
380
382
|
{
|
|
381
383
|
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
382
|
-
onClick: () =>
|
|
384
|
+
onClick: () => H(e.id, "up"),
|
|
383
385
|
disabled: n === 0,
|
|
384
386
|
title: "Move up",
|
|
385
387
|
style: { padding: "4px 8px" },
|
|
@@ -390,7 +392,7 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
390
392
|
"button",
|
|
391
393
|
{
|
|
392
394
|
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
393
|
-
onClick: () =>
|
|
395
|
+
onClick: () => H(e.id, "down"),
|
|
394
396
|
disabled: n === r.plans.length - 1,
|
|
395
397
|
title: "Move down",
|
|
396
398
|
style: { padding: "4px 8px" },
|
|
@@ -612,5 +614,5 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
612
614
|
] });
|
|
613
615
|
}
|
|
614
616
|
export {
|
|
615
|
-
|
|
617
|
+
de as SubscriptionsSection
|
|
616
618
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),m=require("./sectionIds-B_tFiNvF.js"),X=require("./ErrorBanner-Cx2dUhps.js"),Y=require("./StatsBar-m6GSRNxs.js"),i={enabled:!1,plans:[],pageTitle:"Choose Your Plan",pageSubtitle:"Select the plan that best fits your needs.",annualSavingsBadge:"2 months free",popularBadgeText:"Best Deal",footerNotice:""},G={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function V(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Z({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[u,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,S]=d.useState(null),[l,g]=d.useState({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),[x,P]=d.useState(l),[I,C]=d.useState(""),w=d.useCallback(async()=>{try{S(null);let e;const t="/admin/subscriptions/settings";if(f?.isAuthenticated())e=await f.fetchWithAuth(t);else{const n={"Content-Type":"application/json"};b&&(n["X-API-Key"]=b);const s=await fetch(`${v}${t}`,{headers:n});if(!s.ok)throw new Error(`Failed to fetch settings: ${s.status}`);e=await s.json()}h({...i,...e}),g({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),P({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),C(JSON.stringify(e.plans??[]))}catch{h(i),g({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),P({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),C(JSON.stringify([])),S("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const E=d.useCallback(async e=>{try{S(null);const t="/admin/subscriptions/settings",n=JSON.stringify(e);if(f?.isAuthenticated())await f.fetchWithAuth(t,{method:"PUT",body:n});else{const s={"Content-Type":"application/json"};b&&(s["X-API-Key"]=b);const o=await fetch(`${v}${t}`,{method:"PUT",headers:s,body:n});if(!o.ok)throw new Error(`Failed to save settings: ${o.status}`)}return!0}catch{return S("Failed to save subscription settings"),!1}},[f,b,v]),F=d.useMemo(()=>x.enabled!==l.enabled||x.pageTitle!==l.pageTitle||x.pageSubtitle!==l.pageSubtitle||x.annualSavingsBadge!==l.annualSavingsBadge||x.popularBadgeText!==l.popularBadgeText||x.footerNotice!==l.footerNotice,[l,x]),D=d.useMemo(()=>JSON.stringify(r.plans),[r.plans]),U=d.useMemo(()=>I!==D,[D,I]),j=d.useCallback(async()=>{const e={...r,enabled:l.enabled,pageTitle:l.pageTitle,pageSubtitle:l.pageSubtitle,annualSavingsBadge:l.annualSavingsBadge,popularBadgeText:l.popularBadgeText,footerNotice:l.footerNotice};B("saving");const t=await E(e);h(e),t&&(P({enabled:e.enabled,pageTitle:e.pageTitle,pageSubtitle:e.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge,popularBadgeText:e.popularBadgeText,footerNotice:e.footerNotice}),C(JSON.stringify(e.plans))),B(t?"saved":"error"),setTimeout(()=>B("idle"),1500)},[l,E,r]);d.useEffect(()=>{if(u!=="page"||_||!F)return;const e=setTimeout(j,600);return()=>clearTimeout(e)},[u,F,_,j]),d.useEffect(()=>{if(u!=="plans"||_||!U)return;const e=setTimeout(j,800);return()=>clearTimeout(e)},[u,U,_,j]);const O=()=>{const e={...G,id:V(),sortOrder:r.plans.length};h(t=>({...t,plans:[...t.plans,e]})),T(e.id)},c=(e,t)=>{h(n=>({...n,plans:n.plans.map(s=>s.id===e?{...s,...t}:s)}))},H=e=>{confirm("Delete this plan? This cannot be undone.")&&(h(t=>({...t,plans:t.plans.filter(n=>n.id!==e)})),k===e&&T(null))},$=(e,t)=>{const n=r.plans.findIndex(p=>p.id===e);if(n===-1||t==="up"&&n===0||t==="down"&&n===r.plans.length-1)return;const s=[...r.plans],o=t==="up"?n-1:n+1;[s[n],s[o]]=[s[o],s[n]],h(p=>({...p,plans:s}))},q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},Q=(e,t,n)=>{const s=r.plans.find(p=>p.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},J=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,p)=>p!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading subscription settings..."]})});const M=r.plans.filter(e=>e.isActive).length,L=r.plans.reduce((e,t)=>e+(t.activeSubscribers??0),0),N=l.enabled,W=r.plans.filter(e=>e.isActive).map(e=>({label:e.title,value:e.activeSubscribers??0,description:"subscribers"}));return a.jsxs("div",{className:"cedros-admin__page",children:[a.jsx(X.ErrorBanner,{message:z,onRetry:w}),a.jsx(Y.StatsBar,{stats:[{label:"Status",value:N?"Enabled":"Disabled",variant:N?"success":"muted"},{label:"Active Plans",value:M,variant:M>0?"success":"muted"},{label:"Total Subscribers",value:L,variant:L>0?"success":"muted"},...W],isLoading:_}),a.jsxs("div",{className:"cedros-admin__section",children:[a.jsxs("div",{className:"cedros-admin__section-header",children:[a.jsx("h3",{className:"cedros-admin__section-title",children:"Subscription Settings"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[u==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[m.Icons.plus,"Add Plan"]}),a.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${y}`,children:[y==="saving"&&"Saving...",y==="saved"&&"Saved",y==="error"&&"Error"]})]})]}),a.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[a.jsx("button",{type:"button",className:`cedros-admin__tab ${u==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${u==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),u==="page"&&a.jsxs("div",{children:[a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Subscriptions"}),a.jsxs("label",{className:"cedros-admin__toggle",children:[a.jsx("input",{type:"checkbox",className:"cedros-admin__toggle-input",checked:l.enabled,onChange:e=>g(t=>({...t,enabled:e.target.checked}))}),a.jsx("span",{className:"cedros-admin__toggle-track",children:a.jsx("span",{className:"cedros-admin__toggle-thumb"})}),a.jsx("span",{className:"cedros-admin__toggle-label",children:"Enable Subscriptions"})]})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageTitle||"",onChange:e=>g(t=>({...t,pageTitle:e.target.value})),placeholder:"Choose Your Plan"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Subtitle"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageSubtitle||"",onChange:e=>g(t=>({...t,pageSubtitle:e.target.value})),placeholder:"Select the plan that best fits your needs."})]})]}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Savings Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.annualSavingsBadge||"",onChange:e=>g(t=>({...t,annualSavingsBadge:e.target.value})),placeholder:"2 months free"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Popular Plan Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.popularBadgeText||"",onChange:e=>g(t=>({...t,popularBadgeText:e.target.value})),placeholder:"Best Deal"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Footer Notice (optional)"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.footerNotice||"",onChange:e=>g(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),u==="plans"&&a.jsxs("div",{children:[!N&&a.jsx("div",{style:{padding:"1.5rem",textAlign:"center",opacity:.6},children:"Subscriptions are disabled. Enable them to configure plans."}),r.plans.length===0?a.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6,border:"1px dashed currentColor",borderRadius:8},children:'No plans configured. Click "Add Plan" to create your first subscription tier.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:r.plans.map((e,t)=>{const n=k===e.id;return a.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:8,overflow:"hidden",background:e.isPopular?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",padding:"0.75rem 1rem",cursor:"pointer"},onClick:()=>T(n?null:e.id),children:[a.jsx("span",{style:{opacity:.5},children:n?m.Icons.chevronDown:m.Icons.chevronRight}),a.jsxs("div",{style:{flex:1},children:[a.jsx("span",{style:{fontWeight:600},children:e.title||"Untitled Plan"}),e.isPopular&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"var(--cedros-admin-primary, #171717)",color:"#fff"},children:"Popular"}),!e.isActive&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"#9ca3af",color:"#fff"},children:"Inactive"})]}),a.jsxs("span",{style:{opacity:.6,fontSize:14},children:["$",e.priceMonthlyUsd,"/mo · $",e.priceAnnualUsd,"/yr"]}),a.jsxs("div",{style:{display:"flex",gap:"0.25rem"},onClick:s=>s.stopPropagation(),children:[a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"up"),disabled:t===0,title:"Move up",style:{padding:"4px 8px"},children:m.Icons.chevronUp}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"down"),disabled:t===r.plans.length-1,title:"Move down",style:{padding:"4px 8px"},children:m.Icons.chevronDown}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>H(e.id),title:"Delete plan",style:{padding:"4px 8px",color:"#dc2626"},children:m.Icons.trash})]})]}),n&&a.jsxs("div",{style:{padding:"1rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Plan Name"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.title,onChange:s=>c(e.id,{title:s.target.value}),placeholder:"e.g., Starter"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Button Text"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.buttonText||"",onChange:s=>c(e.id,{buttonText:s.target.value}),placeholder:"Purchase"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.description,onChange:s=>c(e.id,{description:s.target.value}),placeholder:"For entry-level developers managing lightweight workloads"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Monthly Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceMonthlyUsd||"",onChange:s=>c(e.id,{priceMonthlyUsd:parseFloat(s.target.value)||0}),placeholder:"10",min:"0",step:"0.01"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceAnnualUsd||"",onChange:s=>c(e.id,{priceAnnualUsd:parseFloat(s.target.value)||0}),placeholder:"100",min:"0",step:"0.01"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Feature Highlight"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.featureHighlight||"",onChange:s=>c(e.id,{featureHighlight:s.target.value}),placeholder:"100 prompts every 5 hours"}),a.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Bold text shown above feature list"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isPopular||!1,onChange:s=>c(e.id,{isPopular:s.target.checked})}),"Mark as Popular (featured styling)"]})}),a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isActive,onChange:s=>c(e.id,{isActive:s.target.checked})}),"Active (available for purchase)"]})})]}),a.jsxs("div",{className:"cedros-admin__form-row",style:{marginTop:"0.5rem"},children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.inventoryQuantity!=null,onChange:s=>c(e.id,{inventoryQuantity:s.target.checked?100:null})}),"Limit quantity available"]})}),e.inventoryQuantity!=null&&a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Total Available"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.inventoryQuantity??"",onChange:s=>c(e.id,{inventoryQuantity:parseInt(s.target.value)||0}),min:"0",style:{width:100}}),e.inventorySold!=null&&e.inventorySold>0&&a.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:[e.inventorySold," sold · ",Math.max(0,e.inventoryQuantity-e.inventorySold)," remaining"]})]})]}),a.jsxs("div",{style:{marginTop:"1rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[a.jsxs("label",{className:"cedros-admin__field-label",style:{margin:0},children:["Feature List (",e.features.length,")"]}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>q(e.id),style:{fontSize:12,padding:"4px 8px"},children:"+ Add Feature"})]}),e.features.length===0?a.jsx("div",{style:{padding:"1rem",textAlign:"center",opacity:.5,fontSize:13,border:"1px dashed currentColor",borderRadius:6},children:'No features. Click "Add Feature" to add bullet points.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:e.features.map((s,o)=>a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsxs("span",{style:{opacity:.4,fontSize:12},children:[o+1,"."]}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:s,onChange:p=>Q(e.id,o,p.target.value),placeholder:"e.g., Powered by MiniMax M2.1",style:{flex:1}}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>J(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:m.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=Z;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { jsxs as n, jsx as t, Fragment as q } from "react/jsx-runtime";
|
|
2
|
-
import { useState as i, useCallback as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { useState as i, useCallback as D, useEffect as O } from "react";
|
|
3
|
+
import { I as J } from "./sectionIds-DBavltrL.mjs";
|
|
4
|
+
import { E as M } from "./ErrorBanner-CZXsHi3H.mjs";
|
|
5
|
+
import { f as V } from "./dateHelpers-yvPkofYQ.mjs";
|
|
6
|
+
const X = (l) => (l / 100).toFixed(2) + "%", k = (l) => Math.round(parseFloat(l) * 100), C = { name: "", country: "", region: "", ratePercent: "", active: !0 };
|
|
7
|
+
function Z({ serverUrl: l, apiKey: f, pageSize: c = 50, authManager: b }) {
|
|
8
|
+
const [m, R] = i([]), [A, S] = i(!0), [U, o] = i(null), [u, P] = i(0), [B, g] = i(!1), [p, y] = i(null), [r, s] = i(C), [T, E] = i(!1), [F, w] = i(null), [v, x] = i(null), h = D(async (e, a) => {
|
|
9
|
+
if (b?.isAuthenticated())
|
|
10
|
+
return b.fetchWithAuth(e, a);
|
|
9
11
|
const d = { "Content-Type": "application/json" };
|
|
10
|
-
|
|
12
|
+
f && (d["X-API-Key"] = f);
|
|
11
13
|
const N = await fetch(`${l}${e}`, { ...a, headers: { ...d, ...a?.headers } });
|
|
12
14
|
if (!N.ok) throw new Error(`Request failed: ${N.status}`);
|
|
13
15
|
return N.json();
|
|
14
|
-
}, [l,
|
|
16
|
+
}, [l, f, b]), _ = D(async () => {
|
|
15
17
|
S(!0), o(null);
|
|
16
18
|
try {
|
|
17
19
|
const e = new URLSearchParams();
|
|
@@ -25,8 +27,8 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
25
27
|
}
|
|
26
28
|
}, [h, c, u]);
|
|
27
29
|
O(() => {
|
|
28
|
-
|
|
29
|
-
}, [
|
|
30
|
+
_();
|
|
31
|
+
}, [_]);
|
|
30
32
|
const I = () => {
|
|
31
33
|
s(C), y(null), g(!1);
|
|
32
34
|
}, L = () => {
|
|
@@ -52,16 +54,16 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
52
54
|
name: r.name.trim(),
|
|
53
55
|
country: r.country.trim().toUpperCase(),
|
|
54
56
|
region: r.region.trim() || void 0,
|
|
55
|
-
rateBps:
|
|
57
|
+
rateBps: k(r.ratePercent),
|
|
56
58
|
active: r.active
|
|
57
59
|
};
|
|
58
|
-
|
|
60
|
+
p ? await h(`/admin/tax/rates/${encodeURIComponent(p.id)}`, {
|
|
59
61
|
method: "PUT",
|
|
60
62
|
body: JSON.stringify(d)
|
|
61
63
|
}) : await h("/admin/tax/rates", {
|
|
62
64
|
method: "POST",
|
|
63
65
|
body: JSON.stringify(d)
|
|
64
|
-
}), I(),
|
|
66
|
+
}), I(), _();
|
|
65
67
|
} catch (d) {
|
|
66
68
|
o(d instanceof Error ? d.message : "Failed to save tax rate");
|
|
67
69
|
} finally {
|
|
@@ -74,7 +76,7 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
74
76
|
}
|
|
75
77
|
w(e), o(null);
|
|
76
78
|
try {
|
|
77
|
-
await h(`/admin/tax/rates/${encodeURIComponent(e)}`, { method: "DELETE" }), x(null),
|
|
79
|
+
await h(`/admin/tax/rates/${encodeURIComponent(e)}`, { method: "DELETE" }), x(null), _();
|
|
78
80
|
} catch {
|
|
79
81
|
o("Failed to delete tax rate");
|
|
80
82
|
} finally {
|
|
@@ -94,7 +96,7 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
94
96
|
}
|
|
95
97
|
)
|
|
96
98
|
] }),
|
|
97
|
-
/* @__PURE__ */ t(
|
|
99
|
+
/* @__PURE__ */ t(M, { message: U }),
|
|
98
100
|
B && /* @__PURE__ */ n(
|
|
99
101
|
"form",
|
|
100
102
|
{
|
|
@@ -107,7 +109,7 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
107
109
|
maxWidth: "500px"
|
|
108
110
|
},
|
|
109
111
|
children: [
|
|
110
|
-
/* @__PURE__ */ t("h4", { style: { margin: "0 0 0.75rem", fontSize: "0.9rem", fontWeight: 600 }, children:
|
|
112
|
+
/* @__PURE__ */ t("h4", { style: { margin: "0 0 0.75rem", fontSize: "0.9rem", fontWeight: 600 }, children: p ? "Edit Tax Rate" : "New Tax Rate" }),
|
|
111
113
|
/* @__PURE__ */ n("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
112
114
|
/* @__PURE__ */ n("div", { className: "cedros-admin__field", children: [
|
|
113
115
|
/* @__PURE__ */ t("label", { className: "cedros-admin__field-label", children: "Name *" }),
|
|
@@ -173,7 +175,7 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
173
175
|
),
|
|
174
176
|
r.ratePercent && !isNaN(parseFloat(r.ratePercent)) && /* @__PURE__ */ n("span", { style: { fontSize: "0.8rem", color: "var(--cedros-admin-text-muted, #888)", marginLeft: "0.5rem" }, children: [
|
|
175
177
|
"= ",
|
|
176
|
-
|
|
178
|
+
k(r.ratePercent),
|
|
177
179
|
" bps"
|
|
178
180
|
] })
|
|
179
181
|
] }),
|
|
@@ -196,7 +198,7 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
196
198
|
type: "submit",
|
|
197
199
|
className: "cedros-admin__button cedros-admin__button--primary",
|
|
198
200
|
disabled: T,
|
|
199
|
-
children: T ? "Saving..." :
|
|
201
|
+
children: T ? "Saving..." : p ? "Update" : "Create"
|
|
200
202
|
}
|
|
201
203
|
),
|
|
202
204
|
/* @__PURE__ */ t(
|
|
@@ -213,7 +215,7 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
213
215
|
}
|
|
214
216
|
),
|
|
215
217
|
A ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
|
|
216
|
-
|
|
218
|
+
J.loading,
|
|
217
219
|
" Loading tax rates..."
|
|
218
220
|
] }) : m.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No tax rates configured." }) : /* @__PURE__ */ n(q, { children: [
|
|
219
221
|
/* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
|
|
@@ -290,5 +292,5 @@ function H({ serverUrl: l, apiKey: b, pageSize: c = 50, authManager: f }) {
|
|
|
290
292
|
] });
|
|
291
293
|
}
|
|
292
294
|
export {
|
|
293
|
-
|
|
295
|
+
Z as TaxSection
|
|
294
296
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),L=require("./sectionIds-B_tFiNvF.js"),$=require("./ErrorBanner-Cx2dUhps.js"),O=require("./dateHelpers-BKW_lGND.js"),W=c=>(c/100).toFixed(2)+"%",w=c=>Math.round(parseFloat(c)*100),v={name:"",country:"",region:"",ratePercent:"",active:!0};function M({serverUrl:c,apiKey:_,pageSize:o=50,authManager:p}){const[l,N]=a.useState([]),[I,S]=a.useState(!0),[k,d]=a.useState(null),[m,C]=a.useState(0),[D,b]=a.useState(!1),[h,f]=a.useState(null),[n,r]=a.useState(v),[R,T]=a.useState(!1),[P,E]=a.useState(null),[g,y]=a.useState(null),u=a.useCallback(async(t,s)=>{if(p?.isAuthenticated())return p.fetchWithAuth(t,s);const i={"Content-Type":"application/json"};_&&(i["X-API-Key"]=_);const j=await fetch(`${c}${t}`,{...s,headers:{...i,...s?.headers}});if(!j.ok)throw new Error(`Request failed: ${j.status}`);return j.json()},[c,_,p]),x=a.useCallback(async()=>{S(!0),d(null);try{const t=new URLSearchParams;t.set("limit",String(o)),t.set("offset",String(m));const s=await u(`/admin/tax/rates?${t.toString()}`);N(s.rates??[])}catch{d("Failed to load tax rates"),N([])}finally{S(!1)}},[u,o,m]);a.useEffect(()=>{x()},[x]);const F=()=>{r(v),f(null),b(!1)},q=()=>{f(null),r(v),b(!0)},A=t=>{f(t),r({name:t.name,country:t.country,region:t.region??"",ratePercent:(t.rateBps/100).toFixed(2),active:t.active}),b(!0)},U=async t=>{t.preventDefault();const s=parseFloat(n.ratePercent);if(isNaN(s)||s<0||s>100){d("Rate must be a number between 0 and 100");return}T(!0),d(null);try{const i={name:n.name.trim(),country:n.country.trim().toUpperCase(),region:n.region.trim()||void 0,rateBps:w(n.ratePercent),active:n.active};h?await u(`/admin/tax/rates/${encodeURIComponent(h.id)}`,{method:"PUT",body:JSON.stringify(i)}):await u("/admin/tax/rates",{method:"POST",body:JSON.stringify(i)}),F(),x()}catch(i){d(i instanceof Error?i.message:"Failed to save tax rate")}finally{T(!1)}},B=async t=>{if(g!==t){y(t);return}E(t),d(null);try{await u(`/admin/tax/rates/${encodeURIComponent(t)}`,{method:"DELETE"}),y(null),x()}catch{d("Failed to delete tax rate")}finally{E(null)}};return e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Tax Rates"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:q,children:"+ Add Rate"})]}),e.jsx($.ErrorBanner,{message:k}),D&&e.jsxs("form",{onSubmit:U,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:h?"Edit Tax Rate":"New Tax Rate"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.name,onChange:t=>r(s=>({...s,name:t.target.value})),required:!0,placeholder:"e.g. US Sales Tax"})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Country (2-letter) *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.country,onChange:t=>r(s=>({...s,country:t.target.value.toUpperCase().slice(0,2)})),required:!0,maxLength:2,placeholder:"US",style:{textTransform:"uppercase"}})]}),e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Region (optional)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.region,onChange:t=>r(s=>({...s,region:t.target.value})),placeholder:"e.g. CA"})]})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Rate (%) *"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n.ratePercent,onChange:t=>r(s=>({...s,ratePercent:t.target.value})),required:!0,min:"0",max:"100",step:"0.01",placeholder:"8.25",style:{maxWidth:"140px"}}),n.ratePercent&&!isNaN(parseFloat(n.ratePercent))&&e.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)",marginLeft:"0.5rem"},children:["= ",w(n.ratePercent)," bps"]})]}),e.jsx("div",{className:"cedros-admin__field",children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer",fontSize:"0.85rem"},children:[e.jsx("input",{type:"checkbox",checked:n.active,onChange:t=>r(s=>({...s,active:t.target.checked}))}),"Active"]})})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:R,children:R?"Saving...":h?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:F,children:"Cancel"})]})]}),I?e.jsxs("div",{className:"cedros-admin__loading",children:[L.Icons.loading," Loading tax rates..."]}):l.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No tax rates configured."}):e.jsxs(e.Fragment,{children:[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:"Name"}),e.jsx("th",{children:"Country"}),e.jsx("th",{children:"Region"}),e.jsx("th",{children:"Rate"}),e.jsx("th",{children:"Active"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:l.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{style:{fontWeight:500},children:t.country.toUpperCase()}),e.jsx("td",{children:t.region??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:W(t.rateBps)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.active?"success":"muted"}`,children:t.active?"Active":"Inactive"})}),e.jsx("td",{children:O.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>A(t),children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",style:g===t.id?{color:"var(--cedros-admin-error, #e53e3e)"}:void 0,disabled:P===t.id,onClick:()=>B(t.id),onBlur:()=>y(null),children:P===t.id?"Deleting...":g===t.id?"Confirm?":"Delete"})]})})]},t.id))})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"0.75rem",fontSize:"0.85rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:m===0,onClick:()=>C(Math.max(0,m-o)),children:"Previous"}),e.jsxs("span",{children:["Showing ",l.length," rate",l.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:l.length<o,onClick:()=>C(m+o),children:"Next"})]})]})]})}exports.TaxSection=M;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const l=require("react/jsx-runtime"),o=require("react"),B=Object.freeze({surfaceBackground:"rgba(255, 255, 255, 0)",surfaceText:"#111827",surfaceBorder:"rgba(15, 23, 42, 0.08)",stripeBackground:"linear-gradient(135deg, #635bff 0%, #4f46e5 100%)",stripeText:"#ffffff",stripeShadow:"rgba(79, 70, 229, 0.25)",cryptoBackground:"linear-gradient(135deg, #14f195 0%, #9945ff 100%)",cryptoText:"#ffffff",cryptoShadow:"rgba(99, 102, 241, 0.25)",errorBackground:"#fee2e2",errorBorder:"#fca5a5",errorText:"#b91c1c",successBackground:"#dcfce7",successBorder:"#86efac",successText:"#166534",modalOverlay:"rgba(0, 0, 0, 0.5)",modalBackground:"#ffffff",modalBorder:"rgba(15, 23, 42, 0.08)",buttonBorderRadius:"8px",buttonPadding:"0.75rem 1.5rem",buttonFontSize:"1rem",buttonFontWeight:"600"}),p=Object.freeze({surfaceBackground:"rgba(17, 24, 39, 0.6)",surfaceText:"#f9fafb",surfaceBorder:"rgba(148, 163, 184, 0.25)",stripeBackground:"linear-gradient(135deg, #4f46e5 0%, #3730a3 100%)",stripeText:"#f5f3ff",stripeShadow:"rgba(99, 102, 241, 0.35)",cryptoBackground:"linear-gradient(135deg, #1dd4a6 0%, #6d28d9 100%)",cryptoText:"#ecfeff",cryptoShadow:"rgba(75, 85, 99, 0.35)",errorBackground:"#7f1d1d",errorBorder:"#fca5a5",errorText:"#fecaca",successBackground:"#14532d",successBorder:"#4ade80",successText:"#bbf7d0",modalOverlay:"rgba(0, 0, 0, 0.75)",modalBackground:"#1f2937",modalBorder:"rgba(148, 163, 184, 0.25)",buttonBorderRadius:"8px",buttonPadding:"0.75rem 1.5rem",buttonFontSize:"1rem",buttonFontWeight:"600"}),h={surfaceBackground:"--cedros-surface-bg",surfaceText:"--cedros-surface-text",surfaceBorder:"--cedros-surface-border",stripeBackground:"--cedros-stripe-bg",stripeText:"--cedros-stripe-text",stripeShadow:"--cedros-stripe-shadow",cryptoBackground:"--cedros-crypto-bg",cryptoText:"--cedros-crypto-text",cryptoShadow:"--cedros-crypto-shadow",errorBackground:"--cedros-error-bg",errorBorder:"--cedros-error-border",errorText:"--cedros-error-text",successBackground:"--cedros-success-bg",successBorder:"--cedros-success-border",successText:"--cedros-success-text",modalOverlay:"--cedros-modal-overlay",modalBackground:"--cedros-modal-bg",modalBorder:"--cedros-modal-border",buttonBorderRadius:"--cedros-button-radius",buttonPadding:"--cedros-button-padding",buttonFontSize:"--cedros-button-font-size",buttonFontWeight:"--cedros-button-font-weight"},u=o.createContext(null);function x(r,e){return{...r==="dark"?p:B,...e}}function T(r){const e=Object.entries(r).map(([t,a])=>[h[t],a]);return Object.fromEntries(e)}function k({initialMode:r="light",overrides:e,unstyled:t=!1,children:a}){const[c,g]=o.useState(r),[f,i]=o.useState(e),s=o.useRef(e);o.useEffect(()=>{if(e===s.current)return;(!e||!s.current?e!==s.current:Object.keys({...e,...s.current}).some(d=>e[d]!==s.current?.[d]))&&(s.current=e,i(e))},[e]);const b=o.useMemo(()=>{const n=x(c,f),d=t?{}:T(n),m=t?"":`cedros-theme-root cedros-theme cedros-theme--${c}`;return{mode:c,setMode:g,tokens:n,className:m,style:d,unstyled:t}},[c,f,t]);return l.jsx(u.Provider,{value:b,children:a})}function y(){const r=o.useContext(u);if(!r)throw new Error("useCedrosTheme must be used within CedrosProvider");return r}function C(){return o.useContext(u)}exports.CedrosThemeProvider=k;exports.useCedrosTheme=y;exports.useCedrosThemeOptional=C;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { jsx as B } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as g, useState as f, useRef as l, useEffect as x, useMemo as h, createContext as T } from "react";
|
|
3
|
+
const k = Object.freeze({
|
|
4
|
+
surfaceBackground: "rgba(255, 255, 255, 0)",
|
|
5
|
+
surfaceText: "#111827",
|
|
6
|
+
surfaceBorder: "rgba(15, 23, 42, 0.08)",
|
|
7
|
+
stripeBackground: "linear-gradient(135deg, #635bff 0%, #4f46e5 100%)",
|
|
8
|
+
stripeText: "#ffffff",
|
|
9
|
+
stripeShadow: "rgba(79, 70, 229, 0.25)",
|
|
10
|
+
cryptoBackground: "linear-gradient(135deg, #14f195 0%, #9945ff 100%)",
|
|
11
|
+
cryptoText: "#ffffff",
|
|
12
|
+
cryptoShadow: "rgba(99, 102, 241, 0.25)",
|
|
13
|
+
errorBackground: "#fee2e2",
|
|
14
|
+
errorBorder: "#fca5a5",
|
|
15
|
+
errorText: "#b91c1c",
|
|
16
|
+
successBackground: "#dcfce7",
|
|
17
|
+
successBorder: "#86efac",
|
|
18
|
+
successText: "#166534",
|
|
19
|
+
modalOverlay: "rgba(0, 0, 0, 0.5)",
|
|
20
|
+
modalBackground: "#ffffff",
|
|
21
|
+
modalBorder: "rgba(15, 23, 42, 0.08)",
|
|
22
|
+
buttonBorderRadius: "8px",
|
|
23
|
+
buttonPadding: "0.75rem 1.5rem",
|
|
24
|
+
buttonFontSize: "1rem",
|
|
25
|
+
buttonFontWeight: "600"
|
|
26
|
+
}), y = Object.freeze({
|
|
27
|
+
surfaceBackground: "rgba(17, 24, 39, 0.6)",
|
|
28
|
+
surfaceText: "#f9fafb",
|
|
29
|
+
surfaceBorder: "rgba(148, 163, 184, 0.25)",
|
|
30
|
+
stripeBackground: "linear-gradient(135deg, #4f46e5 0%, #3730a3 100%)",
|
|
31
|
+
stripeText: "#f5f3ff",
|
|
32
|
+
stripeShadow: "rgba(99, 102, 241, 0.35)",
|
|
33
|
+
cryptoBackground: "linear-gradient(135deg, #1dd4a6 0%, #6d28d9 100%)",
|
|
34
|
+
cryptoText: "#ecfeff",
|
|
35
|
+
cryptoShadow: "rgba(75, 85, 99, 0.35)",
|
|
36
|
+
errorBackground: "#7f1d1d",
|
|
37
|
+
errorBorder: "#fca5a5",
|
|
38
|
+
errorText: "#fecaca",
|
|
39
|
+
successBackground: "#14532d",
|
|
40
|
+
successBorder: "#4ade80",
|
|
41
|
+
successText: "#bbf7d0",
|
|
42
|
+
modalOverlay: "rgba(0, 0, 0, 0.75)",
|
|
43
|
+
modalBackground: "#1f2937",
|
|
44
|
+
modalBorder: "rgba(148, 163, 184, 0.25)",
|
|
45
|
+
buttonBorderRadius: "8px",
|
|
46
|
+
buttonPadding: "0.75rem 1.5rem",
|
|
47
|
+
buttonFontSize: "1rem",
|
|
48
|
+
buttonFontWeight: "600"
|
|
49
|
+
}), O = {
|
|
50
|
+
surfaceBackground: "--cedros-surface-bg",
|
|
51
|
+
surfaceText: "--cedros-surface-text",
|
|
52
|
+
surfaceBorder: "--cedros-surface-border",
|
|
53
|
+
stripeBackground: "--cedros-stripe-bg",
|
|
54
|
+
stripeText: "--cedros-stripe-text",
|
|
55
|
+
stripeShadow: "--cedros-stripe-shadow",
|
|
56
|
+
cryptoBackground: "--cedros-crypto-bg",
|
|
57
|
+
cryptoText: "--cedros-crypto-text",
|
|
58
|
+
cryptoShadow: "--cedros-crypto-shadow",
|
|
59
|
+
errorBackground: "--cedros-error-bg",
|
|
60
|
+
errorBorder: "--cedros-error-border",
|
|
61
|
+
errorText: "--cedros-error-text",
|
|
62
|
+
successBackground: "--cedros-success-bg",
|
|
63
|
+
successBorder: "--cedros-success-border",
|
|
64
|
+
successText: "--cedros-success-text",
|
|
65
|
+
modalOverlay: "--cedros-modal-overlay",
|
|
66
|
+
modalBackground: "--cedros-modal-bg",
|
|
67
|
+
modalBorder: "--cedros-modal-border",
|
|
68
|
+
buttonBorderRadius: "--cedros-button-radius",
|
|
69
|
+
buttonPadding: "--cedros-button-padding",
|
|
70
|
+
buttonFontSize: "--cedros-button-font-size",
|
|
71
|
+
buttonFontWeight: "--cedros-button-font-weight"
|
|
72
|
+
}, n = T(null);
|
|
73
|
+
function w(r, e) {
|
|
74
|
+
return {
|
|
75
|
+
...r === "dark" ? y : k,
|
|
76
|
+
...e
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function C(r) {
|
|
80
|
+
const e = Object.entries(r).map(([o, d]) => [
|
|
81
|
+
O[o],
|
|
82
|
+
d
|
|
83
|
+
]);
|
|
84
|
+
return Object.fromEntries(e);
|
|
85
|
+
}
|
|
86
|
+
function z({
|
|
87
|
+
initialMode: r = "light",
|
|
88
|
+
overrides: e,
|
|
89
|
+
unstyled: o = !1,
|
|
90
|
+
children: d
|
|
91
|
+
}) {
|
|
92
|
+
const [s, b] = f(r), [u, i] = f(e), t = l(e);
|
|
93
|
+
x(() => {
|
|
94
|
+
if (e === t.current)
|
|
95
|
+
return;
|
|
96
|
+
(!e || !t.current ? e !== t.current : Object.keys({ ...e, ...t.current }).some(
|
|
97
|
+
(c) => e[c] !== t.current?.[c]
|
|
98
|
+
)) && (t.current = e, i(e));
|
|
99
|
+
}, [e]);
|
|
100
|
+
const m = h(() => {
|
|
101
|
+
const a = w(s, u), c = o ? {} : C(a), p = o ? "" : `cedros-theme-root cedros-theme cedros-theme--${s}`;
|
|
102
|
+
return {
|
|
103
|
+
mode: s,
|
|
104
|
+
setMode: b,
|
|
105
|
+
tokens: a,
|
|
106
|
+
className: p,
|
|
107
|
+
style: c,
|
|
108
|
+
unstyled: o
|
|
109
|
+
};
|
|
110
|
+
}, [s, u, o]);
|
|
111
|
+
return /* @__PURE__ */ B(n.Provider, { value: m, children: d });
|
|
112
|
+
}
|
|
113
|
+
function F() {
|
|
114
|
+
const r = g(n);
|
|
115
|
+
if (!r)
|
|
116
|
+
throw new Error("useCedrosTheme must be used within CedrosProvider");
|
|
117
|
+
return r;
|
|
118
|
+
}
|
|
119
|
+
function P() {
|
|
120
|
+
return g(n);
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
z as C,
|
|
124
|
+
P as a,
|
|
125
|
+
F as u
|
|
126
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var we=Object.create;var xe=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Ne=Object.prototype.hasOwnProperty;var Be=(t,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of Ae(i))!Ne.call(t,a)&&a!==n&&xe(t,a,{get:()=>i[a],enumerable:!(s=ke(i,a))||s.enumerable});return t};var me=(t,i,n)=>(n=t!=null?we(Te(t)):{},Be(i||!t||!t.__esModule?xe(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),Re=require("./sectionIds-B_tFiNvF.js"),ze=require("./ErrorBanner-Cx2dUhps.js"),ee=require("./configApi-BS5UJfzm.js"),Se=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"address",label:"Address"},{value:"textarea",label:"Long Text"},{value:"dropdown",label:"Dropdown"},{value:"file_upload",label:"File Upload"}],fe={fields:[],requiresApproval:!0},U={width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",boxSizing:"border-box"},G={display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},Q={padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.85rem"};function Ie(){return{id:Math.random().toString(36).slice(2),label:"",fieldType:"text",required:!1,options:[],placeholder:""}}function be({field:t,onSave:i,onCancel:n}){const[s,a]=r.useState(t),[c,y]=r.useState(""),p=o=>a(d=>({...d,...o})),b=()=>{const o=c.trim();o&&(p({options:[...s.options,o]}),y(""))};return e.jsxs("div",{style:{padding:"0.75rem",border:"1px solid rgba(37,99,235,0.3)",borderRadius:6,background:"#eff6ff",marginTop:6},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.6rem",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Label *"}),e.jsx("input",{style:U,value:s.label,onChange:o=>p({label:o.target.value}),placeholder:"e.g., Full Name"})]}),e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Field Type"}),e.jsx("select",{style:U,value:s.fieldType,onChange:o=>p({fieldType:o.target.value,options:[]}),children:Se.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"0.6rem",alignItems:"end",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Placeholder"}),e.jsx("input",{style:U,value:s.placeholder??"",onChange:o=>p({placeholder:o.target.value}),placeholder:"Optional hint text"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",paddingBottom:2},children:[e.jsx("input",{type:"checkbox",checked:s.required,onChange:o=>p({required:o.target.checked})})," Required"]})]}),s.fieldType==="dropdown"&&e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsx("label",{style:G,children:"Options"}),s.options.map((o,d)=>e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:4},children:[e.jsx("span",{style:{flex:1,fontSize:"0.85rem",padding:"0.25rem 0.5rem",background:"white",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4},children:o}),e.jsx("button",{type:"button",onClick:()=>p({options:s.options.filter((u,v)=>v!==d)}),style:{padding:"0.2rem 0.5rem",borderRadius:4,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"x"})]},d)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{style:{...U,flex:1},value:c,onChange:o=>y(o.target.value),onKeyDown:o=>o.key==="Enter"&&(o.preventDefault(),b()),placeholder:"Add option..."}),e.jsx("button",{type:"button",onClick:b,style:Q,children:"Add"})]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>i(s),disabled:!s.label.trim(),style:{padding:"0.35rem 1rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:s.label.trim()?"pointer":"not-allowed",fontSize:"0.85rem",opacity:s.label.trim()?1:.5},children:"Save Field"}),e.jsx("button",{type:"button",onClick:n,style:Q,children:"Cancel"})]})]})}function De({fields:t,instructions:i}){const n={...U,fontSize:"0.85rem",background:"white",opacity:.6};return e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"rgba(0,0,0,0.02)"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"rgba(0,0,0,0.4)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"0.75rem"},children:"Preview — Redeemer View"}),i&&e.jsx("div",{style:{padding:"0.6rem 0.75rem",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,fontSize:"0.85rem",marginBottom:"0.75rem",color:"#92400e"},children:i}),t.length===0&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic"},children:"No fields added yet."}),t.map(s=>e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsxs("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:[s.label||"Unlabelled field",s.required&&e.jsx("span",{style:{color:"#dc2626",marginLeft:2},children:"*"})]}),s.fieldType==="textarea"&&e.jsx("textarea",{disabled:!0,rows:2,placeholder:s.placeholder??"",style:{...n,resize:"none"}}),s.fieldType==="file_upload"&&e.jsx("div",{style:{padding:"0.5rem",border:"1px dashed rgba(0,0,0,0.25)",borderRadius:4,fontSize:"0.8rem",color:"rgba(0,0,0,0.4)",textAlign:"center"},children:"File upload"}),s.fieldType==="dropdown"&&e.jsxs("select",{disabled:!0,style:n,children:[e.jsx("option",{children:s.placeholder||"Select..."}),s.options.map((a,c)=>e.jsx("option",{children:a},c))]}),!["textarea","file_upload","dropdown"].includes(s.fieldType)&&e.jsx("input",{disabled:!0,type:s.fieldType==="email"?"email":s.fieldType==="phone"?"tel":"text",placeholder:s.placeholder??"",style:n})]},s.id))]})}function Pe({value:t,onChange:i}){const n=t!==null,s=t??fe,[a,c]=r.useState(null),[y,p]=r.useState(null),[b,o]=r.useState(!1),d=h=>i({...s,...h}),u=()=>{c(null),p(null)},v=h=>{i(h?{...fe}:null),u()},x=()=>{const h=Ie();p(h),c("new")},f=h=>{p({...h}),c(h.id)},j=h=>{d({fields:a==="new"?[...s.fields,h]:s.fields.map(S=>S.id===h.id?h:S)}),u()},k=h=>{a===h&&u(),d({fields:s.fields.filter(S=>S.id!==h)})};return e.jsxs("div",{children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",marginBottom:n?"1rem":4,fontSize:"0.9rem",fontWeight:500},children:[e.jsx("input",{type:"checkbox",checked:n,onChange:h=>v(h.target.checked)}),"Enable Redemption Form"]}),!n&&e.jsx("div",{style:{fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:"No redemption form — token holders cannot request physical redemption."}),n&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Instructions shown to redeemer"}),e.jsx("textarea",{value:s.instructions??"",onChange:h=>d({instructions:h.target.value||void 0}),placeholder:"Describe requirements, turnaround times, etc.",rows:3,style:{...U,resize:"vertical"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"1rem",alignItems:"center",padding:"0.6rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"rgba(0,0,0,0.02)"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",whiteSpace:"nowrap"},children:[e.jsx("input",{type:"checkbox",checked:s.requiresApproval,onChange:h=>d({requiresApproval:h.target.checked})})," Requires admin approval"]}),e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Estimated processing days"}),e.jsx("input",{type:"number",min:0,value:s.estimatedProcessingDays??"",onChange:h=>d({estimatedProcessingDays:h.target.value?Number(h.target.value):void 0}),placeholder:"e.g., 5",style:{...U,maxWidth:120}})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:500,marginBottom:"0.5rem"},children:["Form Fields (",s.fields.length,")"]}),s.fields.length===0&&a!=="new"&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic",marginBottom:"0.5rem"},children:"No fields yet. Add fields below."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem"},children:[s.fields.map(h=>e.jsxs("div",{children:[e.jsxs("div",{style:{padding:"0.5rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"white",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"0.9rem"},children:h.label||e.jsx("em",{style:{color:"rgba(0,0,0,0.35)"},children:"Unlabelled"})}),e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dbeafe",color:"#1d4ed8",fontSize:"0.75rem"},children:Se.find(S=>S.value===h.fieldType)?.label??h.fieldType}),h.required&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#fef3c7",color:"#92400e",fontSize:"0.75rem"},children:"required"})]}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{type:"button",onClick:()=>f(h),style:{...Q,padding:"0.25rem 0.6rem",fontSize:"0.8rem"},children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>k(h.id),style:{padding:"0.25rem 0.6rem",borderRadius:4,border:"1px solid rgba(220,38,38,0.3)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"Delete"})]})]}),a===h.id&&y&&e.jsx(be,{field:y,onSave:j,onCancel:u})]},h.id)),a==="new"&&y&&e.jsx(be,{field:y,onSave:j,onCancel:u})]}),a===null&&e.jsx("button",{type:"button",onClick:x,style:{...Q,marginTop:"0.5rem"},children:"+ Add Field"})]}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>o(h=>!h),style:{...Q,background:b?"rgba(0,0,0,0.05)":"white"},children:b?"Hide Preview":"Show Preview"}),b&&e.jsx("div",{style:{marginTop:"0.75rem"},children:e.jsx(De,{fields:s.fields,instructions:s.instructions})})]})]})]})}const Me=[{value:"securities",label:"Securities (fungible)"},{value:"commodities",label:"Commodities (fungible)"},{value:"property",label:"Property (non-fungible)"},{value:"collectibles",label:"Collectibles (non-fungible)"}],Fe=t=>t==="securities"||t==="commodities";function Ee({c:t,onDeployPool:i,onEdit:n,onDelete:s}){const a=t.tokenizationConfig,c=Fe(a.assetClass);return e.jsxs("div",{style:{padding:"0.75rem 1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"white"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:t.name}),e.jsx("span",{style:{marginLeft:8,fontSize:"0.8rem",padding:"2px 8px",borderRadius:10,background:c?"#dbeafe":"#fef3c7",color:c?"#1d4ed8":"#92400e"},children:a.assetClass}),a.tokenSymbol&&e.jsx("span",{style:{marginLeft:6,fontSize:"0.8rem",color:"rgba(0,0,0,0.5)"},children:a.tokenSymbol})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.8rem"},children:[a.mintAddress?e.jsx("span",{style:{color:"#16a34a"},children:"Mint initialized"}):e.jsx("span",{style:{color:"rgba(0,0,0,0.4)"},children:"No mint"}),c&&a.mintAddress&&(a.liquidityPoolAddress?e.jsxs("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dcfce7",color:"#15803d",fontSize:"0.75rem"},children:["Pool Active · ",a.liquidityPoolAddress.slice(0,4),"...",a.liquidityPoolAddress.slice(-4)]}):e.jsx("button",{type:"button",onClick:i,style:{padding:0,border:"none",background:"none",color:"#2563eb",cursor:"pointer",fontSize:"0.8rem",textDecoration:"underline"},children:"Deploy Pool"}))]})]}),t.description&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.5)",marginTop:4},children:t.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6},children:[e.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:[e.jsxs("span",{children:["Fee: ",a.transferFeeBps," bps"]}),a.treasuryAddress&&e.jsxs("span",{children:["Treasury: ",a.treasuryAddress.slice(0,8),"..."]}),a.allowedJurisdictions?.length>0&&e.jsxs("span",{style:{padding:"1px 7px",borderRadius:10,background:"#f3f4f6",color:"rgba(0,0,0,0.55)"},children:[a.allowedJurisdictions.length," jurisdiction",a.allowedJurisdictions.length!==1?"s":"",": ",a.allowedJurisdictions.join(", ")]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[n&&e.jsx("button",{type:"button",onClick:n,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#2563eb"},children:"Edit"}),s&&e.jsx("button",{type:"button",onClick:s,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#dc2626"},children:"Delete"})]})]})]})}const pe={name:"",description:"",assetClass:"securities",tokenSymbol:"",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500,treasuryAddress:"",regulatoryNotice:"",jurisdictions:"",redemptionConfig:null};function Le({serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:s}){const[a,c]=r.useState([]),[y,p]=r.useState(!0),[b,o]=r.useState(null),[d,u]=r.useState(!1),[v,x]=r.useState(!1),[f,j]=r.useState(pe),[k,h]=r.useState(null),S=r.useCallback(async(g,m)=>{if(n?.isAuthenticated())return n.fetchWithAuth(g,m);const N={"Content-Type":"application/json"};i&&(N["X-API-Key"]=i);const C=await fetch(`${t}${g}`,{...m,headers:{...N,...m?.headers}});if(!C.ok){const z=await C.text().catch(()=>`HTTP ${C.status}`);throw new Error(z)}return C.json()},[t,i,n]),T=r.useCallback(async()=>{try{p(!0),o(null);const g=await S("/admin/collections");c((g.collections||[]).filter(m=>m.tokenizationConfig))}catch(g){o(g instanceof Error?g.message:"Failed to load asset classes")}finally{p(!1)}},[S]);r.useEffect(()=>{T()},[T]);const l=()=>({name:f.name.trim(),description:f.description||void 0,active:!0,productIds:[],tokenizationConfig:{assetClass:f.assetClass,tokenSymbol:f.tokenSymbol||void 0,tokenDecimals:f.tokenDecimals,transferFeeBps:f.transferFeeBps,maxTransferFee:f.maxTransferFee,treasuryAddress:f.treasuryAddress||void 0,regulatoryNotice:f.regulatoryNotice||void 0,allowedJurisdictions:f.jurisdictions?f.jurisdictions.split(",").map(g=>g.trim().toUpperCase()).filter(Boolean):[],redemptionConfig:f.redemptionConfig||void 0}}),w=async()=>{if(f.name.trim()){x(!0),o(null);try{k?await S(`/admin/collections/${encodeURIComponent(k)}`,{method:"PUT",body:JSON.stringify(l())}):await S("/admin/collections",{method:"POST",body:JSON.stringify(l())}),j(pe),u(!1),h(null),await T()}catch(g){o(g instanceof Error?g.message:`Failed to ${k?"update":"create"} asset class`)}finally{x(!1)}}},_=g=>{const m=g.tokenizationConfig;j({name:g.name,description:g.description??"",assetClass:m.assetClass,tokenSymbol:m.tokenSymbol??"",tokenDecimals:m.tokenDecimals,transferFeeBps:m.transferFeeBps,maxTransferFee:m.maxTransferFee,treasuryAddress:m.treasuryAddress??"",regulatoryNotice:m.regulatoryNotice??"",jurisdictions:m.allowedJurisdictions.join(", "),redemptionConfig:m.redemptionConfig??null}),h(g.id),u(!0)},A=async g=>{if(window.confirm(`Delete asset class "${g.name}"? This cannot be undone.`)){o(null);try{await S(`/admin/collections/${encodeURIComponent(g.id)}`,{method:"DELETE"}),await T()}catch(m){o(m instanceof Error?m.message:"Failed to delete asset class")}}};return y?e.jsx("div",{style:{padding:"1rem 0",color:"rgba(0,0,0,0.5)"},children:"Loading asset classes..."}):e.jsxs("div",{children:[b&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:b}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsxs("h4",{style:{margin:0},children:["Asset Classes (",a.length,")"]}),e.jsx("button",{type:"button",onClick:()=>{u(!d),d&&(h(null),j(pe))},style:{padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:d?"rgba(0,0,0,0.05)":"white",cursor:"pointer",fontSize:"0.85rem"},children:d?"Cancel":"+ New Asset Class"})]}),d&&e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,marginBottom:"1rem",background:"rgba(0,0,0,0.02)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Name *"}),e.jsx("input",{type:"text",value:f.name,onChange:g=>j(m=>({...m,name:g.target.value})),placeholder:"e.g., Gold Tokens",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Asset Class *"}),e.jsx("select",{value:f.assetClass,onChange:g=>j(m=>({...m,assetClass:g.target.value})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"},children:Me.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Description"}),e.jsx("input",{type:"text",value:f.description,onChange:g=>j(m=>({...m,description:g.target.value})),placeholder:"Brief description of this asset class",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Token Symbol"}),e.jsx("input",{type:"text",value:f.tokenSymbol,onChange:g=>j(m=>({...m,tokenSymbol:g.target.value})),placeholder:"e.g., GOLD",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Transfer Fee (bps)"}),e.jsx("input",{type:"number",value:f.transferFeeBps,onChange:g=>j(m=>({...m,transferFeeBps:Number(g.target.value)})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Treasury Address"}),e.jsx("input",{type:"text",value:f.treasuryAddress,onChange:g=>j(m=>({...m,treasuryAddress:g.target.value})),placeholder:"Solana address",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Allowed Jurisdictions"}),e.jsx("input",{type:"text",value:f.jurisdictions,onChange:g=>j(m=>({...m,jurisdictions:g.target.value})),placeholder:"US, CA, GB (comma-separated, leave empty for all)",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Regulatory Notice"}),e.jsx("textarea",{value:f.regulatoryNotice,onChange:g=>j(m=>({...m,regulatoryNotice:g.target.value})),placeholder:"Shown to buyers before purchase",rows:2,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:600,marginBottom:8},children:"Redemption Form"}),e.jsx(Pe,{value:f.redemptionConfig,onChange:g=>j(m=>({...m,redemptionConfig:g}))})]}),e.jsx("button",{type:"button",onClick:w,disabled:v||!f.name.trim(),style:{padding:"0.5rem 1.5rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:v?"wait":"pointer",fontSize:"0.9rem",opacity:v?.6:1},children:v?"Saving...":k?"Save Changes":"Create Asset Class"})]}),a.length===0?e.jsx("div",{style:{padding:"2rem",textAlign:"center",color:"rgba(0,0,0,0.4)",fontSize:"0.9rem"},children:"No asset classes configured. Create one to start tokenizing off-chain assets."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:a.map(g=>e.jsx(Ee,{c:g,onDeployPool:s,onEdit:()=>_(g),onDelete:()=>A(g)},g.id))})]})}const $e=[{value:"",label:"All statuses"},{value:"pending_info",label:"Pending Info"},{value:"info_submitted",label:"Info Submitted"},{value:"under_review",label:"Under Review"},{value:"approved",label:"Approved"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}];function qe(t){switch(t){case"pending_info":return"cedros-admin__badge cedros-admin__badge--muted";case"info_submitted":return"cedros-admin__badge cedros-admin__badge--info";case"under_review":return"cedros-admin__badge cedros-admin__badge--warning";case"approved":return"cedros-admin__badge cedros-admin__badge--success";case"completed":return"cedros-admin__badge cedros-admin__badge--success";case"rejected":return"cedros-admin__badge cedros-admin__badge--failed";default:return"cedros-admin__badge cedros-admin__badge--muted"}}function Oe(t){return t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function We(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function K(t){return t.length>12?`${t.slice(0,8)}…`:t}function je(t){return`https://solscan.io/tx/${t}`}function Ue({redemption:t,onAction:i,onComplete:n,actionBusy:s}){const[a,c]=r.useState(t.adminNotes??""),y=Object.entries(t.formData??{});return e.jsx("div",{style:{padding:"1rem 1.25rem",background:"rgba(0,0,0,0.02)",borderTop:"1px solid rgba(0,0,0,0.08)"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1.5rem"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"0.8rem",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em",opacity:.6},children:"Form Data"}),y.length===0?e.jsx("div",{style:{fontSize:"0.85rem",opacity:.5},children:"No form data submitted."}):e.jsx("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",fontSize:"0.85rem"},children:y.map(([p,b])=>e.jsxs(e.Fragment,{children:[e.jsx("dt",{style:{fontWeight:500,color:"rgba(0,0,0,0.6)",whiteSpace:"nowrap"},children:p},`k-${p}`),e.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:String(b??"—")},`v-${p}`)]}))}),(t.tokenMintSignature||t.tokenBurnSignature)&&e.jsxs("div",{style:{marginTop:12,fontSize:"0.8rem"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4,opacity:.6,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Signatures"}),t.tokenMintSignature&&e.jsxs("div",{children:["Mint:"," ",e.jsx("a",{href:je(t.tokenMintSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:K(t.tokenMintSignature)})]}),t.tokenBurnSignature&&e.jsxs("div",{children:["Burn:"," ",e.jsx("a",{href:je(t.tokenBurnSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:K(t.tokenBurnSignature)})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Admin Notes"}),e.jsx("textarea",{value:a,onChange:p=>c(p.target.value),rows:4,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.85rem",resize:"vertical",boxSizing:"border-box"},placeholder:"Internal notes (not shown to user)..."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:8,flexWrap:"wrap"},children:[t.status==="info_submitted"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"under_review",a),children:s?"Saving...":"Mark Under Review"}),t.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"approved",a),children:s?"Saving...":"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"rejected",a),children:s?"Saving...":"Reject"})]}),t.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>n(t.id),children:s?"Processing...":"Complete"})]})]})]})})}function Ye({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState([]),[c,y]=r.useState(!0),[p,b]=r.useState(null),[o,d]=r.useState(""),[u,v]=r.useState(null),[x,f]=r.useState(null),j=r.useCallback(async(l,w)=>{if(n?.isAuthenticated())return n.fetchWithAuth(l,w);const _={"Content-Type":"application/json"};i&&(_["X-API-Key"]=i);const A=await fetch(`${t}${l}`,{...w,headers:{..._,...w?.headers}});if(!A.ok){const g=await A.text().catch(()=>`HTTP ${A.status}`);throw new Error(g)}return A.json()},[t,i,n]),k=r.useCallback(async()=>{y(!0),b(null);try{const l=o?`?status=${encodeURIComponent(o)}&limit=50&offset=0`:"?limit=50&offset=0",w=await j(`/admin/asset-redemptions${l}`);a(w.redemptions??[])}catch(l){b(l instanceof Error?l.message:"Failed to load redemptions")}finally{y(!1)}},[j,o]);r.useEffect(()=>{k()},[k]);const h=r.useCallback(async(l,w,_)=>{f(l),b(null);try{await j(`/admin/asset-redemptions/${l}/status`,{method:"PATCH",body:JSON.stringify({status:w,adminNotes:_})}),v(null),await k()}catch(A){b(A instanceof Error?A.message:"Failed to update status")}finally{f(null)}},[j,k]),S=r.useCallback(async l=>{f(l),b(null);try{await j(`/admin/asset-redemptions/${l}/complete`,{method:"POST"}),v(null),await k()}catch(w){b(w instanceof Error?w.message:"Failed to complete redemption")}finally{f(null)}},[j,k]),T=l=>{v(w=>w===l?null:l)};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1rem",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Status"}),e.jsx("select",{value:o,onChange:l=>{d(l.target.value),v(null)},style:{padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",minWidth:160},children:$e.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))})]}),e.jsx("div",{style:{alignSelf:"flex-end"},children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline",onClick:k,disabled:c,children:c?"Loading...":"Refresh"})})]}),p&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:p}),c?e.jsx("div",{className:"cedros-admin__loading",children:"Loading redemptions..."}):s.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No redemption requests 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:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"User"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:s.map(l=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{cursor:"pointer"},onClick:()=>T(l.id),children:[e.jsx("td",{children:We(l.createdAt)}),e.jsx("td",{children:e.jsx("code",{title:l.orderId,children:K(l.orderId)})}),e.jsx("td",{children:e.jsx("code",{title:l.productId,children:K(l.productId)})}),e.jsx("td",{children:e.jsx("code",{title:l.collectionId,children:K(l.collectionId)})}),e.jsx("td",{children:l.userId?e.jsx("code",{title:l.userId,children:K(l.userId)}):e.jsx("span",{style:{opacity:.4},children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:qe(l.status),children:Oe(l.status)})}),e.jsx("td",{onClick:w=>w.stopPropagation(),children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[(l.status==="info_submitted"||l.status==="under_review"||l.status==="approved")&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>T(l.id),children:u===l.id?"Close":"Review"}),l.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:x===l.id,onClick:()=>h(l.id,"approved",l.adminNotes??""),children:"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:x===l.id,onClick:()=>h(l.id,"rejected",l.adminNotes??""),children:"Reject"})]}),l.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:x===l.id,onClick:()=>S(l.id),children:x===l.id?"Processing...":"Complete"})]})})]},l.id),u===l.id&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:0},children:e.jsx(Ue,{redemption:l,onAction:h,onComplete:S,actionBusy:x===l.id})})},`${l.id}-detail`)]}))})]})})]})}const Ge={CA:{cashOutCents:1500,expirationProhibited:!0,escheatmentYears:3,notes:"Cash-out threshold increases to $15 on April 1, 2026."},CO:{cashOutCents:500,escheatmentYears:5},CT:{cashOutCents:300,escheatmentYears:3},FL:{expirationProhibited:!0,escheatmentYears:5},ME:{cashOutCents:500,escheatmentYears:3},MA:{cashOutCents:500,escheatmentYears:3,notes:"Cash-out also required when 90% of value is used."},MT:{cashOutCents:500,escheatmentYears:5},NJ:{cashOutCents:500,escheatmentYears:3},OR:{cashOutCents:500,escheatmentYears:3,notes:"May require at least one prior transaction."},RI:{cashOutCents:100,escheatmentYears:3},TX:{cashOutCents:250,escheatmentYears:3},VT:{cashOutCents:100,escheatmentYears:3},WA:{cashOutCents:500,escheatmentYears:5},PR:{cashOutCents:500,escheatmentYears:5}},ye={escheatmentYears:5},re=1e6,Ke={AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",DC:"District of Columbia",PR:"Puerto Rico"};function He({serverUrl:t,authManager:i}){const[n,s]=r.useState(null),[a,c]=r.useState(null),[y,p]=r.useState(null),[b,o]=r.useState(!0),d=r.useCallback(async()=>{try{const j=(await new ee.ConfigApiClient(t,void 0,i).getConfig("gift_cards")).config??{};s(j.business_state||null),c(j.min_gift_card_value_cents!=null?Number(j.min_gift_card_value_cents):null),p(j.max_gift_card_value_cents!=null?Number(j.max_gift_card_value_cents):null)}catch{}finally{o(!1)}},[t,i]);if(r.useEffect(()=>{d()},[d]),b)return e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading compliance data..."});const u=n?Ge[n]??ye:null,v=n?Ke[n]??n:null;return e.jsx("div",{children:n?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:["Compliance Guidance — ",v]}),e.jsxs("div",{style:{display:"grid",gap:"1rem",maxWidth:720},children:[e.jsx(Ve,{reg:u,minValueCents:a}),e.jsx(Xe,{reg:u}),e.jsx(Ze,{reg:u}),e.jsx(Qe,{maxValueCents:y})]}),e.jsx(et,{reg:u,minValueCents:a,maxValueCents:y})]}):e.jsx(Je,{})})}function Je(){return e.jsxs("div",{style:{padding:"2rem",textAlign:"center"},children:[e.jsx("p",{style:{fontSize:15,opacity:.7,marginBottom:"0.5rem"},children:"No business state configured."}),e.jsxs("p",{style:{fontSize:13,opacity:.5},children:["Set your ",e.jsx("strong",{children:"business_state"})," in the Gift Cards config category to see state-specific compliance guidance."]})]})}function te({title:t,children:i}){return e.jsxs("div",{style:{border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,padding:"1rem 1.25rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.5rem",fontSize:14,fontWeight:600},children:t}),e.jsx("div",{style:{fontSize:13,lineHeight:1.6},children:i})]})}function Ve({reg:t,minValueCents:i}){if(!t.cashOutCents)return e.jsx(te,{title:"Cash-Out Threshold",children:e.jsx("p",{style:{margin:0},children:"Your state does not have a specific cash-out threshold for gift cards. Federal law does not require cash redemption."})});const n=(t.cashOutCents/100).toFixed(2),s=i!=null&&i>t.cashOutCents;return e.jsxs(te,{title:"Cash-Out Threshold",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Your state requires cash redemption for gift cards with a remaining balance of ",e.jsxs("strong",{children:["$",n]})," or less."]}),e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Since this system uses ",e.jsx("strong",{children:"one-shot full redemption"})," (entire gift card value is converted to credits at once), cash-out is avoided by setting the minimum gift card face value above the threshold."]}),s?e.jsxs(oe,{ok:!0,children:["Min value ($",((i??0)/100).toFixed(2),") exceeds threshold"]}):e.jsxs(oe,{ok:!1,children:["Set ",e.jsx("code",{children:"min_gift_card_value_cents"})," above ",t.cashOutCents," to avoid cash-out obligations"]}),t.notes&&e.jsx("p",{style:{margin:"0.5rem 0 0",opacity:.7,fontStyle:"italic"},children:t.notes})]})}function Xe({reg:t}){return e.jsx(te,{title:"Expiration Rules",children:t.expirationProhibited?e.jsxs("p",{style:{margin:0},children:["Your state ",e.jsx("strong",{children:"prohibits"})," gift card expiration. Do not set expiration dates on gift cards."]}):e.jsxs("p",{style:{margin:0},children:["Federal law (CARD Act) requires gift cards to remain valid for at least ",e.jsx("strong",{children:"5 years"})," from purchase or last reload. Your state follows the federal minimum."]})})}function Ze({reg:t}){const i=t.escheatmentYears??ye.escheatmentYears;return e.jsxs(te,{title:"Escheatment (Unclaimed Property)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Gift card balances unredeemed for ",e.jsxs("strong",{children:[i," years"]})," may need to be reported and remitted to the state as unclaimed property."]}),e.jsxs("p",{style:{margin:0,opacity:.7},children:["The system tracks ",e.jsx("code",{children:"last_activity_at"})," on gift card redemptions to help identify dormant balances approaching the escheatment window."]})]})}function Qe({maxValueCents:t}){const i=t??re,n=i<=re;return e.jsxs(te,{title:"Anti-Money Laundering (AML)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["FinCEN requires closed-loop prepaid cards to stay at or below ",e.jsx("strong",{children:"$10,000"})," per card. The server enforces this cap on product creation."]}),n?e.jsxs(oe,{ok:!0,children:["Max value ($",(i/100).toFixed(2),") within AML limit"]}):e.jsxs(oe,{ok:!1,children:[e.jsx("code",{children:"max_gift_card_value_cents"})," exceeds $10,000 AML cap"]})]})}function oe({ok:t,children:i}){return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:6,fontSize:13,fontWeight:500,background:t?"rgba(34,197,94,0.1)":"rgba(234,179,8,0.15)",color:t?"#16a34a":"#a16207"},children:[e.jsx("span",{children:t?"✓":"⚠"}),i]})}function et({reg:t,minValueCents:i,maxValueCents:n}){const a=[{label:"AML: Max card value ≤ $10,000",ok:(n??re)<=re},...t.cashOutCents?[{label:`Cash-out: Min value > $${(t.cashOutCents/100).toFixed(2)} threshold`,ok:i!=null&&i>t.cashOutCents}]:[],{label:t.expirationProhibited?"Expiration: State prohibits expiration (no action needed)":"Expiration: Federal 5-year minimum applies",ok:!0},{label:`Escheatment: ${t.escheatmentYears??ye.escheatmentYears}-year dormancy tracking enabled`,ok:!0}];return e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{fontSize:14,fontWeight:600,marginBottom:"0.75rem"},children:"Compliance Checklist"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.map((c,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:c.ok?"#16a34a":"#d97706",fontWeight:600},children:c.ok?"✓":"⚠"}),e.jsx("span",{children:c.label})]},y))})]})}function tt({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState(null),[c,y]=r.useState(!0),[p,b]=r.useState(null),o=r.useCallback(async x=>{if(n?.isAuthenticated())return n.fetchWithAuth(x);const f={"Content-Type":"application/json"};i&&(f["X-API-Key"]=i);const j=await fetch(`${t}${x}`,{headers:f});if(!j.ok)throw new Error(`HTTP ${j.status}`);return j.json()},[t,i,n]),d=r.useCallback(async()=>{y(!0),b(null);try{const[x,f]=await Promise.all([o("/admin/gift-cards?limit=50"),o("/admin/gift-card-redemptions?limit=50").catch(()=>({redemptions:[]}))]),j=x.giftCards??[],k=f.redemptions??[],h=new Date,S=j.filter(m=>m.active&&(!m.expiresAt||new Date(m.expiresAt)>h)).length,T=j.filter(m=>m.expiresAt&&new Date(m.expiresAt)<=h).length,l=j.reduce((m,N)=>m+N.initialBalance,0),w=j.reduce((m,N)=>m+N.balance,0),_=k.reduce((m,N)=>m+N.faceValueCents,0),A=k.filter(m=>m.tokenMinted).length,g=j[0]?.currency||k[0]?.currency||"USD";a({totalCards:j.length,activeCards:S,expiredCards:T,totalIssuedCents:l,totalRemainingCents:w,totalRedeemedCents:_,redemptionCount:k.length,tokensMinted:A,currency:g.toUpperCase()})}catch(x){b(x instanceof Error?x.message:"Failed to load analytics")}finally{y(!1)}},[o]);r.useEffect(()=>{d()},[d]);const u=x=>`$${(x/100).toFixed(2)}`;if(c)return e.jsx("div",{className:"cedros-admin__loading",children:"Loading analytics..."});if(p)return e.jsxs("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,fontSize:13,color:"#b91c1c"},children:[p,e.jsx("button",{className:"cedros-admin__button cedros-admin__button--sm",style:{marginLeft:8},onClick:d,children:"Retry"})]});if(!s)return null;const v=s.totalIssuedCents>0?((s.totalIssuedCents-s.totalRemainingCents)/s.totalIssuedCents*100).toFixed(1):"0.0";return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Gift Card & Token Analytics"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[e.jsx($,{label:"Total Cards",value:String(s.totalCards)}),e.jsx($,{label:"Active",value:String(s.activeCards),accent:"green"}),e.jsx($,{label:"Expired",value:String(s.expiredCards),accent:s.expiredCards>0?"amber":void 0}),e.jsx($,{label:"Total Issued",value:u(s.totalIssuedCents),sub:s.currency}),e.jsx($,{label:"Remaining Balance",value:u(s.totalRemainingCents),sub:s.currency}),e.jsx($,{label:"Usage Rate",value:`${v}%`,sub:"issued vs. spent"}),e.jsx($,{label:"Redemptions",value:String(s.redemptionCount)}),e.jsx($,{label:"Tokens Minted",value:String(s.tokensMinted),sub:`of ${s.redemptionCount} redemptions`})]}),s.totalIssuedCents>0&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Balance Breakdown"}),e.jsxs("div",{style:{display:"flex",height:24,borderRadius:6,overflow:"hidden",background:"rgba(0,0,0,0.05)"},children:[e.jsx("div",{style:{width:`${(s.totalIssuedCents-s.totalRemainingCents)/s.totalIssuedCents*100}%`,background:"#2563eb",minWidth:2},title:`Spent: ${u(s.totalIssuedCents-s.totalRemainingCents)}`}),e.jsx("div",{style:{width:`${s.totalRemainingCents/s.totalIssuedCents*100}%`,background:"#60a5fa",minWidth:2},title:`Remaining: ${u(s.totalRemainingCents)}`})]}),e.jsxs("div",{style:{display:"flex",gap:"1rem",marginTop:6,fontSize:12,opacity:.7},children:[e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"#2563eb",borderRadius:2,marginRight:4}}),"Spent"]}),e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"#60a5fa",borderRadius:2,marginRight:4}}),"Remaining"]})]})]})]})}function $({label:t,value:i,sub:n,accent:s}){const a=s==="green"?"#166534":s==="amber"?"#92400e":void 0;return e.jsxs("div",{style:{padding:"0.75rem 1rem",borderRadius:8,border:"1px solid rgba(0,0,0,0.08)",background:"rgba(0,0,0,0.01)"},children:[e.jsx("div",{style:{fontSize:12,opacity:.6,marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:a},children:i}),n&&e.jsx("div",{style:{fontSize:11,opacity:.5,marginTop:2},children:n})]})}function st({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState([]),[c,y]=r.useState(!0),[p,b]=r.useState(null),[o,d]=r.useState("list"),[u,v]=r.useState(null),[x,f]=r.useState(!1),[j,k]=r.useState(null),h=r.useCallback(async(_,A)=>{if(n?.isAuthenticated())return n.fetchWithAuth(_,A);const g={"Content-Type":"application/json"};i&&(g["X-API-Key"]=i);const m=await fetch(`${t}${_}`,{...A,headers:{...g,...A?.headers}});if(!m.ok){const N=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(N)}return m.json()},[t,i,n]),S=r.useCallback(async()=>{y(!0),b(null);try{const A=await h(`/admin/gift-cards${x?"?activeOnly=true&limit=50":"?limit=50"}`);a(A.giftCards??[])}catch(_){b(_ instanceof Error?_.message:"Failed to load gift cards")}finally{y(!1)}},[h,x]);r.useEffect(()=>{S()},[S]);const T=(_,A)=>`$${(_/100).toFixed(2)} ${A.toUpperCase()}`,l=_=>{try{return new Date(_).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}catch{return _}},w=_=>{v(_),d("adjust"),k(null)};return o==="create"?e.jsx(nt,{onSubmit:async _=>{await h("/admin/gift-cards",{method:"POST",body:JSON.stringify(_)}),d("list"),S()},onCancel:()=>d("list")}):o==="adjust"&&u?e.jsx(it,{card:u,formatCents:T,onSubmit:async _=>{await h(`/admin/gift-cards/${encodeURIComponent(u.code)}/adjust`,{method:"POST",body:JSON.stringify({newBalance:_})}),d("list"),S()},onToggleActive:async()=>{await h(`/admin/gift-cards/${encodeURIComponent(u.code)}`,{method:"PUT",body:JSON.stringify({initialBalance:u.initialBalance,balance:u.balance,currency:u.currency,active:!u.active,expiresAt:u.expiresAt,metadata:u.metadata})}),d("list"),S()},onCancel:()=>{d("list"),v(null)}}):e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{margin:0},children:"Gift Card Inventory"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsxs("label",{style:{fontSize:13,display:"flex",alignItems:"center",gap:4},children:[e.jsx("input",{type:"checkbox",checked:x,onChange:_=>f(_.target.checked)}),"Active only"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{d("create"),k(null)},children:"+ New Gift Card"})]})]}),p&&e.jsxs("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:[p,e.jsx("button",{className:"cedros-admin__button cedros-admin__button--sm",style:{marginLeft:8},onClick:S,children:"Retry"})]}),j&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(22,163,74,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#166534"},children:j}),c?e.jsx("div",{className:"cedros-admin__loading",children:"Loading..."}):s.length?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:"Code"}),e.jsx("th",{children:"Balance"}),e.jsx("th",{children:"Initial"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Expires"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:s.map(_=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[_.code.slice(0,12),"..."]})}),e.jsx("td",{style:{fontWeight:600},children:T(_.balance,_.currency)}),e.jsx("td",{style:{opacity:.7},children:T(_.initialBalance,_.currency)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${_.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:_.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:13},children:_.expiresAt?l(_.expiresAt):"—"}),e.jsx("td",{style:{fontSize:13},children:l(_.createdAt)}),e.jsx("td",{children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>w(_),children:"Manage"})})]},_.code))})]})}):e.jsx("div",{className:"cedros-admin__empty",style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift cards found."})]})}function nt({onSubmit:t,onCancel:i}){const[n,s]=r.useState({code:"",initialBalance:"",currency:"USD",expiresAt:""}),[a,c]=r.useState(!1),[y,p]=r.useState(null),b=async o=>{o.preventDefault();const d=Math.round(parseFloat(n.initialBalance)*100);if(!d||d<0){p("Initial balance must be positive");return}c(!0),p(null);try{await t({...n.code.trim()?{code:n.code.trim().toUpperCase()}:{},initialBalance:d,currency:n.currency.toUpperCase(),...n.expiresAt?{expiresAt:new Date(n.expiresAt).toISOString()}:{}})}catch(u){p(u instanceof Error?u.message:"Failed to create gift card")}finally{c(!1)}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Create Gift Card"}),y&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:y}),e.jsxs("form",{onSubmit:b,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Code (optional, auto-generated if empty)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.code,onChange:o=>s(d=>({...d,code:o.target.value})),placeholder:"Leave blank to auto-generate"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Initial Balance ($)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n.initialBalance,onChange:o=>s(d=>({...d,initialBalance:o.target.value})),placeholder:"25.00",step:"0.01",min:"0",required:!0})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Currency"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.currency,onChange:o=>s(d=>({...d,currency:o.target.value})),maxLength:3,required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Expiration date (optional)"}),e.jsx("input",{type:"date",className:"cedros-admin__input",value:n.expiresAt,onChange:o=>s(d=>({...d,expiresAt:o.target.value}))})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:a,children:a?"Creating...":"Create Gift Card"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:i,children:"Cancel"})]})]})]})}function it({card:t,formatCents:i,onSubmit:n,onToggleActive:s,onCancel:a}){const[c,y]=r.useState((t.balance/100).toFixed(2)),[p,b]=r.useState(!1),[o,d]=r.useState(null),u=async x=>{x.preventDefault();const f=Math.round(parseFloat(c)*100);if(isNaN(f)||f<0){d("Balance must be >= 0");return}b(!0),d(null);try{await n(f)}catch(j){d(j instanceof Error?j.message:"Failed to adjust balance")}finally{b(!1)}},v=async()=>{b(!0),d(null);try{await s()}catch(x){d(x instanceof Error?x.message:"Failed to update status"),b(!1)}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Manage Gift Card"}),o&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:o}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.5rem",maxWidth:500,marginBottom:"1.5rem",fontSize:13},children:[e.jsx("div",{style:{fontWeight:500},children:"Code"}),e.jsx("div",{style:{fontFamily:"monospace",wordBreak:"break-all"},children:t.code}),e.jsx("div",{style:{fontWeight:500},children:"Current Balance"}),e.jsx("div",{style:{fontWeight:600},children:i(t.balance,t.currency)}),e.jsx("div",{style:{fontWeight:500},children:"Initial Balance"}),e.jsx("div",{children:i(t.initialBalance,t.currency)}),e.jsx("div",{style:{fontWeight:500},children:"Status"}),e.jsx("div",{children:e.jsx("span",{className:`cedros-admin__badge ${t.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:t.active?"Active":"Inactive"})}),t.expiresAt&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500},children:"Expires"}),e.jsx("div",{children:new Date(t.expiresAt).toLocaleDateString()})]})]}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:250},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"New Balance ($)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:c,onChange:x=>y(x.target.value),step:"0.01",min:"0",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:p,children:p?"Saving...":"Adjust Balance"}),e.jsx("button",{type:"button",className:`cedros-admin__button ${t.active?"cedros-admin__button--danger":"cedros-admin__button--outline"}`,onClick:v,disabled:p,children:t.active?"Deactivate":"Reactivate"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:a,children:"Back"})]})]})]})}const at=0;class Ce{dlmmModule=null;bnClass=null;keypairClass=null;async loadDLMM(){if(this.dlmmModule)return this.dlmmModule;try{const i=await Promise.resolve().then(()=>require("./pay-react_false-DaeIe3_l.js"));return this.dlmmModule=i.default??i,this.dlmmModule}catch{throw new Error("Install @meteora-ag/dlmm to enable pool deployment: npm install @meteora-ag/dlmm")}}async loadBN(){if(this.bnClass)return this.bnClass;const i=await Promise.resolve().then(()=>require("./bn-CHyy7EgJ.js")).then(n=>n.bn);return this.bnClass=i.default??i,this.bnClass}async loadKeypair(){if(this.keypairClass)return this.keypairClass;const{Keypair:i}=await import("@solana/web3.js");return this.keypairClass=i,this.keypairClass}async computeBinId(i,n,s,a=1){const c=await this.loadDLMM(),y=c.getPricePerLamport(n,s,i);return c.getBinIdFromPrice(y,a,!0)}async findPresetParameter(i,n,s){const a=await this.loadDLMM(),c=s?{cluster:s}:void 0,{presetParameter2:y}=await a.getAllPresetParameters(i,c),p=y.find(b=>b.account.binStep===n);if(!p)throw new Error(`No PresetParameter2 found for binStep=${n}. Available: ${y.map(b=>b.account.binStep).join(", ")}`);return p.publicKey}async createPool(i,n,s,a,c,y=1,p){const b=await this.loadDLMM(),o=await this.loadBN(),d=p?{cluster:p}:void 0,u=await this.findPresetParameter(i,y,p),v=await b.createLbPair2(i,n,s,a,u,new o(c),d),x=v.instructions[0]?.keys?.[1]?.pubkey;if(!x)throw new Error("Failed to extract pool address from transaction");return{transaction:v,poolAddress:x}}async addBuybackLiquidity(i,n,s,a,c,y){const p=await this.loadDLMM(),b=await this.loadBN(),o=await this.loadKeypair(),d=y?{cluster:y}:void 0,u=await p.create(i,s,d),v=o.generate(),x=c-1,f=c;return{transaction:await u.initializePositionAndAddLiquidityByStrategy({positionPubKey:v.publicKey,totalXAmount:new b(0),totalYAmount:new b(a),strategy:{maxBinId:f,minBinId:x,strategyType:at},user:n,slippage:1}),positionKeypair:v}}async getPoolStatus(i,n,s){const a=await this.loadDLMM(),c=s?{cluster:s}:void 0,y=await a.create(i,n,c),p=await y.getActiveBin();return{address:n.toBase58(),activeBinId:p.binId,activeBinPrice:p.price,binStep:y.lbPair.binStep}}}const he=6,rt=1,ot="https://solscan.io/account",lt="https://app.meteora.ag/dlmm";function dt({serverUrl:t,authManager:i,poolAddress:n,buybackRateBps:s,usdcAmount:a,deployedAt:c,mintAddress:y,tokenDecimals:p=2,onConfigUpdated:b}){const[o,d]=r.useState("none"),[u,v]=r.useState(s!=null?s/100:80),[x,f]=r.useState(100),[j,k]=r.useState(!1),[h,S]=r.useState(!1),[T,l]=r.useState(null),[w,_]=r.useState(null),A=s!=null?`$${(s/1e4).toFixed(2)}`:"Unknown",g=a!=null?`$${(a/10**he).toFixed(2)}`:null,m=c?new Date(c).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null,N=n.length>16?`${n.slice(0,8)}...${n.slice(-8)}`:n,C=async()=>{k(!0),_(null),l(null);try{const B=new ee.ConfigApiClient(t,void 0,i),R=Math.round(u*100);await B.patchConfig("gift_cards",{buyback_rate_bps:R},`Buyback rate adjusted to ${u} cents`),l("Buyback rate updated"),d("none"),b()}catch(B){_(B instanceof Error?B.message:"Failed to update rate")}finally{k(!1)}},z=async()=>{if(y){S(!0),_(null),l(null);try{const{Connection:B,PublicKey:R,Keypair:M}=await import("@solana/web3.js"),F=new ee.ConfigApiClient(t,void 0,i),I=await F.getConfig("x402"),D=I.config?.rpc_url||"",P=I.config?.token_mint||"";if(!D||!P)throw new Error("RPC URL or USDC mint not configured");const L=new B(D,"confirmed"),O=window.solana;if(!O?.publicKey||!O.signTransaction)throw new Error("Wallet not connected");const se=new Ce,le=new R(O.publicKey.toBase58()),E=u/100,de=await se.computeBinId(E,p,he,rt),ne=new R(n),H=Math.round(x*10**he),{transaction:J,positionKeypair:W}=await se.addBuybackLiquidity(L,le,ne,H,de),V=M.fromSecretKey(W.secretKey);J.partialSign(V);const Y=await O.signTransaction(J),X=await L.sendRawTransaction(Y.serialize());await L.confirmTransaction(X,"confirmed");const Z=a??0;await F.patchConfig("gift_cards",{liquidity_usdc_amount:Z+H},`Added ${x} USDC liquidity`),l(`Added $${x} USDC liquidity`),d("none"),b()}catch(B){_(B instanceof Error?B.message:"Failed to add liquidity")}finally{S(!1)}}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Liquidity Pool Active"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Pool Address"}),e.jsxs("div",{style:{fontSize:13,fontFamily:"monospace",wordBreak:"break-all"},children:[N,e.jsxs("span",{style:{marginLeft:8,display:"inline-flex",gap:6},children:[e.jsx(ct,{text:n}),e.jsx(_e,{href:`${ot}/${n}`,label:"Solscan"}),e.jsx(_e,{href:`${lt}/${n}`,label:"Meteora"})]})]}),e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Buyback Rate"}),e.jsxs("div",{style:{fontSize:13},children:[A," per $1.00"]}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"USDC Deposited"}),e.jsx("div",{style:{fontSize:13},children:g})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Deployed"}),e.jsx("div",{style:{fontSize:13},children:m})]})]}),e.jsxs("div",{style:{marginTop:"1.25rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>d(o==="adjust_rate"?"none":"adjust_rate"),disabled:h||j,children:"Adjust Rate"}),e.jsx("button",{className:"cedros-admin__button",onClick:()=>d(o==="add_liquidity"?"none":"add_liquidity"),disabled:h||j||!y,children:"Add Liquidity"})]}),o==="adjust_rate"&&e.jsxs("div",{style:{marginTop:"1rem",padding:"1rem",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"New buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:u,onChange:B=>v(Math.max(1,Math.min(99,parseInt(B.target.value)||80))),min:"1",max:"99",style:{maxWidth:200}}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["Profit per redemption: $",((100-u)/100).toFixed(2)]})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:C,disabled:j,style:{marginTop:"0.75rem"},children:j?"Saving...":"Save Rate"})]}),o==="add_liquidity"&&e.jsxs("div",{style:{marginTop:"1rem",padding:"1rem",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount to add"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:x,onChange:B=>f(Math.max(1,parseFloat(B.target.value)||100)),min:"1",step:"1",style:{maxWidth:200}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:z,disabled:h,style:{marginTop:"0.75rem"},children:h?"Adding liquidity...":`Add $${x} USDC`}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Requires a connected wallet and USDC balance."})]}),T&&e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:6,background:"rgba(22,163,74,0.1)",color:"#16a34a",fontSize:13},children:T}),w&&e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:w})]})}function ct({text:t}){const[i,n]=r.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})};return e.jsx("button",{type:"button",onClick:s,style:{background:"none",border:"none",cursor:"pointer",fontSize:12,opacity:.7,padding:0},children:i?"Copied":"Copy"})}function _e({href:t,label:i}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,opacity:.7},children:i})}const ie=6,ge=1;function ut({serverUrl:t,authManager:i,mintConfigured:n,mintAddress:s,tokenDecimals:a=2}){const[c,y]=r.useState({liquidityPoolAddress:null,buybackRateBps:null,rpcUrl:null,usdcMint:null,usdcAmount:null,deployedAt:null}),[p,b]=r.useState(!0),[o,d]=r.useState(80),[u,v]=r.useState(250),[x,f]=r.useState("idle"),[j,k]=r.useState(null),[h,S]=r.useState(null),[T,l]=r.useState(null),w=r.useRef(new Ce),_=r.useCallback(async()=>{try{const R=new ee.ConfigApiClient(t,void 0,i),[M,F]=await Promise.all([R.getConfig("gift_cards"),R.getConfig("x402")]),I=M.config??{},D=F.config??{},P=I.liquidity_pool_address||null;y({liquidityPoolAddress:P,buybackRateBps:I.buyback_rate_bps!=null?Number(I.buyback_rate_bps):null,rpcUrl:D.rpc_url||null,usdcMint:D.token_mint||null,usdcAmount:I.liquidity_usdc_amount!=null?Number(I.liquidity_usdc_amount):null,deployedAt:I.liquidity_deployed_at||null}),P&&S(P),I.buyback_rate_bps!=null&&d(Number(I.buyback_rate_bps)/100)}catch{}finally{b(!1)}},[t,i]);r.useEffect(()=>{_()},[_]);const A=typeof window<"u"&&!!window.solana?.publicKey,g=!!c.rpcUrl,m=!!c.usdcMint,N=n&&A&&g&&m&&x==="idle",C=async R=>{if(!(!s||!c.rpcUrl||!c.usdcMint)){f(R),k(null),l(null);try{const{Connection:M,PublicKey:F,Keypair:I}=await import("@solana/web3.js"),D=new M(c.rpcUrl,"confirmed"),P=window.solana;if(!P?.publicKey||!P.signTransaction)throw new Error("Wallet not connected");const L=w.current,O=new F(P.publicKey.toBase58()),se=o/100,le=await L.computeBinId(se,a,ie,ge);let E=h;if(R==="creating_pool"){const W=new F(s),V=new F(c.usdcMint),Y=await L.computeBinId(1,a,ie,ge),{transaction:X,poolAddress:Z}=await L.createPool(D,O,W,V,Y,ge),ce=await P.signTransaction(X),ue=await D.sendRawTransaction(ce.serialize());await D.confirmTransaction(ue,"confirmed"),E=Z.toBase58(),S(E)}if(R==="creating_pool"||R==="adding_liquidity"){if(f("adding_liquidity"),!E)throw new Error("Pool address not available");const W=new F(E),V=Math.round(u*10**ie),{transaction:Y,positionKeypair:X}=await L.addBuybackLiquidity(D,O,W,V,le),Z=I.fromSecretKey(X.secretKey);Y.partialSign(Z);const ce=await P.signTransaction(Y),ue=await D.sendRawTransaction(ce.serialize());await D.confirmTransaction(ue,"confirmed")}if(f("saving_config"),!E)throw new Error("Pool address not available");const de=new ee.ConfigApiClient(t,void 0,i),ne=Math.round(o*100),H=Math.round(u*10**ie),J=new Date().toISOString();await de.patchConfig("gift_cards",{liquidity_pool_address:E,buyback_rate_bps:ne,liquidity_usdc_amount:H,liquidity_deployed_at:J},"Meteora DLMM pool deployed for gift card buyback"),y(W=>({...W,liquidityPoolAddress:E,buybackRateBps:ne,usdcAmount:H,deployedAt:J})),f("done")}catch(M){l(x==="idle"?R:x),k(M instanceof Error?M.message:"Deployment failed"),f("error")}}},z=()=>{N&&C("creating_pool")},B=()=>{!T||T==="idle"||T==="done"||T==="error"||C(T)};return p?e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading pool configuration..."}):c.liquidityPoolAddress?e.jsx(dt,{serverUrl:t,authManager:i,poolAddress:c.liquidityPoolAddress,buybackRateBps:c.buybackRateBps,usdcAmount:c.usdcAmount,deployedAt:c.deployedAt,mintAddress:s,tokenDecimals:a,onConfigUpdated:_}):x!=="idle"&&x!=="error"?e.jsx(pt,{step:x,poolAddress:h}):e.jsx(mt,{buybackCents:o,setBuybackCents:d,usdcAmount:u,setUsdcAmount:v,mintConfigured:n,walletConnected:A,hasRpcUrl:g,hasUsdcMint:m,canDeploy:N,onDeploy:z,errorMessage:j,canRetry:!!T&&T!=="creating_pool",onRetry:B})}function mt({buybackCents:t,setBuybackCents:i,usdcAmount:n,setUsdcAmount:s,mintConfigured:a,walletConnected:c,hasRpcUrl:y,hasUsdcMint:p,canDeploy:b,onDeploy:o,errorMessage:d,canRetry:u,onRetry:v}){const x=((100-t)/100).toFixed(2);return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Deploy Buyback Liquidity Pool"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Meteora DLMM pool to buy back gift card tokens at a discount. You earn the spread when tokens are resold at face value."}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:t,onChange:f=>i(Math.max(1,Math.min(99,parseInt(f.target.value)||80))),min:"1",max:"99"}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["You earn $",x," profit per gift card redeemed"]})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n,onChange:f=>s(Math.max(1,parseFloat(f.target.value)||250)),min:"1",step:"1"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Minimum recommended: $250"})]})]}),e.jsxs("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",gap:6},children:[e.jsx(ae,{label:"Token-22 mint initialized",met:a}),e.jsx(ae,{label:"Wallet connected",met:c}),e.jsx(ae,{label:"RPC URL configured",met:y}),e.jsx(ae,{label:"USDC mint configured",met:p})]}),d&&e.jsx("div",{style:{padding:"0.5rem 0.75rem",marginBottom:"0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:d}),e.jsx("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:u?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:v,children:"Retry (Resume from Failed Step)"}):e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:o,disabled:!b,children:"Deploy Liquidity Pool"})})]})}const ve=[{key:"creating_pool",label:"Creating DLMM pool..."},{key:"adding_liquidity",label:"Depositing USDC liquidity..."},{key:"saving_config",label:"Saving configuration..."},{key:"done",label:"Complete"}];function pt({step:t,poolAddress:i}){return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Deploying Pool..."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:ve.map((n,s)=>{const a=ve.findIndex(b=>b.key===t),c=s,y=c<a||t==="done",p=c===a&&t!=="done";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontWeight:600},children:y?"✓":p?"▶":"○"}),e.jsx("span",{style:{opacity:y||p?1:.4},children:n.label})]},n.key)})}),i&&e.jsxs("div",{style:{marginTop:"1rem",fontSize:13,opacity:.7},children:["Pool: ",e.jsx("code",{style:{fontSize:12},children:i})]})]})}function ae({label:t,met:i}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:i?"#16a34a":"#dc2626",fontWeight:600},children:i?"✓":"✗"}),e.jsx("span",{style:{opacity:i?.8:.5},children:t})]})}function ht({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState(null),[c,y]=r.useState([]),[p,b]=r.useState(!0),[o,d]=r.useState(null),[u,v]=r.useState("mint"),[x,f]=r.useState({treasuryAddress:"",tokenSymbol:"storeUSD",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500}),[j,k]=r.useState(!1),[h,S]=r.useState(!1),[T,l]=r.useState(null),w=r.useCallback(async(C,z)=>{if(n?.isAuthenticated())return n.fetchWithAuth(C,z);const B={"Content-Type":"application/json"};i&&(B["X-API-Key"]=i);const R=await fetch(`${t}${C}`,{...z,headers:{...B,...z?.headers}});if(!R.ok){const M=await R.text().catch(()=>`HTTP ${R.status}`);throw new Error(M)}return R.json()},[t,i,n]),_=r.useCallback(async()=>{try{d(null);const C=await w("/admin/token22/status");a(C)}catch{d("Failed to load Token-22 status")}finally{b(!1)}},[w]),A=r.useCallback(async()=>{try{const C=await w("/admin/gift-card-redemptions?limit=50");y(C.redemptions||[])}catch{y([])}},[w]);r.useEffect(()=>{_(),A()},[_,A]);const g=async C=>{if(C.preventDefault(),!!x.treasuryAddress){k(!0),l(null);try{const z=await w("/admin/token22/initialize",{method:"POST",body:JSON.stringify({treasuryAddress:x.treasuryAddress,tokenSymbol:x.tokenSymbol,tokenDecimals:x.tokenDecimals,transferFeeBps:x.transferFeeBps,maxTransferFee:x.maxTransferFee})});l(`Mint created: ${z.mintAddress}`),_()}catch(z){l(`Error: ${z instanceof Error?z.message:"Failed to initialize"}`)}finally{k(!1)}}},m=async()=>{S(!0),l(null);try{const C=await w("/admin/token22/harvest-fees",{method:"POST"});l(C.message)}catch(C){l(`Error: ${C instanceof Error?C.message:"Failed to harvest"}`)}finally{S(!1)}},N=C=>{try{return new Date(C).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return C}};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(ze.ErrorBanner,{message:o,onRetry:_}),e.jsx("div",{style:{display:"flex",gap:0,borderBottom:"1px solid rgba(0,0,0,0.1)",marginBottom:"1rem"},children:["mint","inventory","analytics","redemptions","compliance","liquidity","asset-classes","asset-redemptions"].map(C=>{const z={mint:"Token-22 Mint",inventory:"Gift Cards",analytics:"Analytics",redemptions:"Redemptions",compliance:"Compliance",liquidity:"Liquidity","asset-classes":"Asset Classes","asset-redemptions":"Asset Redemptions"};return e.jsx("button",{type:"button",onClick:()=>v(C),style:{padding:"0.5rem 1rem",background:"none",border:"none",borderBottom:u===C?"2px solid currentColor":"2px solid transparent",fontWeight:u===C?600:400,cursor:"pointer",opacity:u===C?1:.6},children:z[C]},C)})}),p?e.jsxs("div",{className:"cedros-admin__loading",children:[Re.Icons.loading," Loading..."]}):u==="mint"?e.jsx(gt,{mintStatus:s,initForm:x,setInitForm:f,isInitializing:j,isHarvesting:h,actionMessage:T,onInitialize:g,onHarvestFees:m,formatDate:N}):u==="inventory"?e.jsx(st,{serverUrl:t,apiKey:i,authManager:n}):u==="analytics"?e.jsx(tt,{serverUrl:t,apiKey:i,authManager:n}):u==="redemptions"?e.jsx(yt,{redemptions:c,formatDate:N}):u==="compliance"?e.jsx(He,{serverUrl:t,apiKey:i,authManager:n}):u==="liquidity"?e.jsx(ut,{serverUrl:t,authManager:n,mintConfigured:!!s?.configured,mintAddress:s?.mintAddress,tokenDecimals:s?.tokenDecimals}):u==="asset-classes"?e.jsx(Le,{serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:()=>v("liquidity")}):e.jsx(Ye,{serverUrl:t,apiKey:i,authManager:n})]})}function gt({mintStatus:t,initForm:i,setInitForm:n,isInitializing:s,isHarvesting:a,actionMessage:c,onInitialize:y,onHarvestFees:p,formatDate:b}){return t?.configured?e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Token-22 Mint Status"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx(q,{label:"Mint Address",value:t.mintAddress,mono:!0}),e.jsx(q,{label:"Token Symbol",value:t.tokenSymbol}),e.jsx(q,{label:"Decimals",value:String(t.tokenDecimals)}),e.jsx(q,{label:"Transfer Fee",value:`${t.transferFeeBps} bps (${((t.transferFeeBps??0)/100).toFixed(2)}%)`}),e.jsx(q,{label:"Max Transfer Fee",value:String(t.maxTransferFee)}),e.jsx(q,{label:"Treasury",value:t.treasuryAddress,mono:!0}),e.jsx(q,{label:"Authority",value:t.mintAuthority,mono:!0}),e.jsx(q,{label:"Created",value:t.createdAt?b(t.createdAt):"—"})]}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",gap:"0.75rem",alignItems:"center"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:p,disabled:a,children:a?"Harvesting...":"Harvest Transfer Fees"}),c&&e.jsx("span",{style:{fontSize:13,opacity:.8},children:c})]})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Initialize Token-22 Mint"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Token-22 mint with transfer fee extension for the secondary market. This is a one-time operation per tenant."}),e.jsxs("form",{onSubmit:y,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Treasury address (Solana)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.treasuryAddress,onChange:o=>n(d=>({...d,treasuryAddress:o.target.value})),placeholder:"e.g., 7xKX...",required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.tokenSymbol,onChange:o=>n(d=>({...d,tokenSymbol:o.target.value})),placeholder:"storeUSD"})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.tokenDecimals,onChange:o=>n(d=>({...d,tokenDecimals:parseInt(o.target.value)||2})),min:"0",max:"9"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Transfer fee (basis points)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.transferFeeBps,onChange:o=>n(d=>({...d,transferFeeBps:parseInt(o.target.value)||0})),min:"0",max:"10000"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"e.g., 250 = 2.5% fee on secondary market transfers"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max transfer fee (atomic)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.maxTransferFee,onChange:o=>n(d=>({...d,maxTransferFee:parseInt(o.target.value)||0})),min:"0"})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:s,children:s?"Creating Mint...":"Initialize Mint"}),c&&e.jsx("span",{style:{marginLeft:"0.75rem",fontSize:13,opacity:.8},children:c})]})]})]})}function q({label:t,value:i,mono:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:t}),e.jsx("div",{style:{fontSize:13,fontFamily:n?"monospace":"inherit",wordBreak:n?"break-all":"normal",opacity:i?1:.5},children:i||"—"})]})}function yt({redemptions:t,formatDate:i}){return t.length?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:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Buyer"}),e.jsx("th",{children:"Recipient"}),e.jsx("th",{children:"Value"}),e.jsx("th",{children:"Token Minted"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:i(n.createdAt)}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.orderId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsx("code",{style:{fontSize:12},children:n.productId})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.buyerUserId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.recipientUserId.slice(0,8),"..."]})}),e.jsxs("td",{children:["$",(n.faceValueCents/100).toFixed(2)," ",n.currency.toUpperCase()]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${n.tokenMinted?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:n.tokenMinted?"Yes":"No"})})]},n.id))})]})}):e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift card redemptions yet."})}exports.Token22Section=ht;
|