@cedros/pay-react 1.1.24 → 1.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AISettingsSection-IXS1Wt_1.js → AISettingsSection-BvSSiK2G.js} +1 -1
- package/dist/{AISettingsSection-Dw0ZlxMf.mjs → AISettingsSection-Dg1kazTI.mjs} +2 -2
- package/dist/{AutosaveIndicator-BJsg_kFZ.mjs → AutosaveIndicator-BHfkV59p.mjs} +1 -1
- package/dist/{AutosaveIndicator-CY_YHM1D.js → AutosaveIndicator-D2l7U8R1.js} +1 -1
- package/dist/CedrosContext-C2RjHLaQ.js +6 -0
- package/dist/{CedrosContext-DQUbL8yP.mjs → CedrosContext-CY6zvjvJ.mjs} +768 -617
- package/dist/ComplianceSection-BSE2f3Wo.mjs +534 -0
- package/dist/ComplianceSection-D6ETKG6b.js +1 -0
- package/dist/{CryptoButton-D1BCZBk4.mjs → CryptoButton-BV9owVe2.mjs} +2 -2
- package/dist/{CryptoButton-C1AAOOfj.js → CryptoButton-DpiCnyXE.js} +1 -1
- package/dist/{FAQSection-BmgmzDN5.js → FAQSection-6nGI0FK9.js} +1 -1
- package/dist/{FAQSection-C78MnK4k.mjs → FAQSection-uZG5V3pJ.mjs} +1 -1
- package/dist/{MessagingSection-CWLZcg11.js → MessagingSection-DrXb578q.js} +1 -1
- package/dist/{MessagingSection-De3t8bSI.mjs → MessagingSection-M0lj5yo4.mjs} +2 -2
- package/dist/{OrdersSection-_xKVzjSZ.mjs → OrdersSection-DteItv_O.mjs} +6 -6
- package/dist/{OrdersSection-BKOxsZw0.js → OrdersSection-_-rIw6XW.js} +1 -1
- package/dist/{PaymentSettingsSection-KjU_dN_d.mjs → PaymentSettingsSection-CdtdLFTg.mjs} +1 -1
- package/dist/{PaymentSettingsSection-BTEn9Dxb.js → PaymentSettingsSection-enTbUI95.js} +1 -1
- package/dist/SettingsSection-DUTEd6uV.js +1 -0
- package/dist/{SettingsSection-8QHZB59k.mjs → SettingsSection-mcT4LEhO.mjs} +19 -13
- package/dist/{SingleCategorySettings--LK0TZW0.mjs → SingleCategorySettings-BvHBVfSe.mjs} +4 -4
- package/dist/{SingleCategorySettings-CRXTMTo5.js → SingleCategorySettings-D2LVM5mn.js} +1 -1
- package/dist/{StorefrontSection-CeCpr8hn.mjs → StorefrontSection-BqQ36JIS.mjs} +2 -2
- package/dist/{StorefrontSection-C9DzCmOf.js → StorefrontSection-Du7hV2Gc.js} +1 -1
- package/dist/{SubscriptionsSection-C2xk8ApF.mjs → SubscriptionsSection-BYiCBwKZ.mjs} +7 -7
- package/dist/{SubscriptionsSection-Dn5SY6S_.js → SubscriptionsSection-C4BRN1dP.js} +1 -1
- package/dist/Token22Section-0c22NM5G.js +1 -0
- package/dist/Token22Section-BHvOhz5d.mjs +2260 -0
- package/dist/{WalletManager-Bwk3rgr1.js → WalletManager-B3UdQ5pQ.js} +1 -1
- package/dist/{WalletManager-CXvQ0Zu9.mjs → WalletManager-BIwH8Dw_.mjs} +1 -1
- package/dist/{configApi-Ch0Rr7TD.mjs → configApi-6XhAJGKX.mjs} +31 -0
- package/dist/{configApi-CxEbCAgG.js → configApi-DkduMQg1.js} +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +85 -83
- package/dist/{index-BHF82XBB.mjs → index-BkDimQDF.mjs} +7987 -7322
- package/dist/index-C7MWL6O8.js +84 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +42 -40
- package/dist/{sections-8e5Y3ukY.js → sections-5jO2aHAo.js} +1 -1
- package/dist/{sections-C1rb9YRh.mjs → sections-By4H1baL.mjs} +2 -2
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/components/ComplianceGatePage.d.ts +38 -0
- package/dist/src/components/ComplianceGatePage.d.ts.map +1 -0
- package/dist/src/components/SubscribeButton.d.ts +1 -5
- package/dist/src/components/SubscribeButton.d.ts.map +1 -1
- package/dist/src/components/admin/AdminAuthManager.d.ts +7 -3
- package/dist/src/components/admin/AdminAuthManager.d.ts.map +1 -1
- package/dist/src/components/admin/AssetClassesTab.d.ts.map +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSanctionsApi.d.ts.map +1 -0
- package/dist/src/components/admin/ComplianceSection.d.ts +3 -0
- package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts +3 -0
- package/dist/src/components/admin/GiftCardAnalytics.d.ts.map +1 -0
- package/dist/src/components/admin/GiftCardManager.d.ts +3 -0
- package/dist/src/components/admin/GiftCardManager.d.ts.map +1 -0
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
- package/dist/src/components/admin/PoolManagementView.d.ts +14 -0
- package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -0
- package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
- package/dist/src/components/admin/RefundsSection.d.ts.map +1 -1
- package/dist/src/components/admin/SettingsSection.d.ts.map +1 -1
- package/dist/src/components/admin/Token22Section.d.ts.map +1 -1
- package/dist/src/components/admin/complianceTypes.d.ts +60 -0
- package/dist/src/components/admin/complianceTypes.d.ts.map +1 -0
- package/dist/src/components/admin/configApi.d.ts.map +1 -1
- package/dist/src/components/admin/icons.d.ts +1 -0
- package/dist/src/components/admin/icons.d.ts.map +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts +1 -1
- package/dist/src/components/admin/useAdminAuth.d.ts.map +1 -1
- package/dist/src/context/CedrosContext.d.ts.map +1 -1
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts +36 -0
- package/dist/src/ecommerce/components/catalog/TokenDisplay.d.ts.map +1 -0
- package/dist/src/ecommerce/components/checkout/CheckoutForm.d.ts.map +1 -1
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts +15 -0
- package/dist/src/ecommerce/components/checkout/SendAsGiftSection.d.ts.map +1 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts +19 -0
- package/dist/src/ecommerce/components/gift-cards/GiftCardBalanceChecker.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts +13 -0
- package/dist/src/ecommerce/components/orders/MyRedemptionsPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts +15 -0
- package/dist/src/ecommerce/components/orders/MyTokensPage.d.ts.map +1 -0
- package/dist/src/ecommerce/components/orders/OrderDetails.d.ts.map +1 -1
- package/dist/src/ecommerce/hooks/useCartInventory.d.ts.map +1 -1
- package/dist/src/ecommerce/index.d.ts +10 -0
- package/dist/src/ecommerce/index.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts +3 -0
- package/dist/src/ecommerce/state/checkout/checkoutSchema.d.ts.map +1 -1
- package/dist/src/ecommerce/state/checkout/useCheckout.d.ts.map +1 -1
- package/dist/src/ecommerce/types.d.ts +6 -0
- package/dist/src/ecommerce/types.d.ts.map +1 -1
- package/dist/src/ecommerce/utils/cartItemMetadata.d.ts.map +1 -1
- package/dist/src/hooks/useComplianceCheck.d.ts +30 -0
- package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -0
- package/dist/src/hooks/useSubscriptionManagement.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/CreditsManager.d.ts.map +1 -1
- package/dist/src/managers/ManagerCache.d.ts +2 -2
- package/dist/src/managers/ManagerCache.d.ts.map +1 -1
- package/dist/src/managers/StripeManager.d.ts +7 -1
- package/dist/src/managers/StripeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionChangeManager.d.ts.map +1 -1
- package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +14 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/subscription.d.ts +21 -33
- package/dist/src/types/subscription.d.ts.map +1 -1
- package/dist/src/utils/exponentialBackoff.d.ts +22 -0
- package/dist/src/utils/exponentialBackoff.d.ts.map +1 -1
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +2 -2
- package/dist/styles-BT4bhFey.js +1 -0
- package/dist/{styles-Ag-7ZvAB.mjs → styles-D4SQkuV3.mjs} +606 -609
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/{walletPool-C_0P4mTw.mjs → walletPool-DE-t1wSW.mjs} +1 -1
- package/dist/{walletPool-Ddv33tej.js → walletPool-IS7R3MR1.js} +1 -1
- package/package.json +1 -1
- package/dist/CedrosContext-7dwmEeUY.js +0 -6
- package/dist/SettingsSection-cKF0tLnS.js +0 -1
- package/dist/Token22Section-DUUl59dZ.js +0 -1
- package/dist/Token22Section-HygkDNtL.mjs +0 -1685
- package/dist/index-OaWkrl0G.js +0 -84
- package/dist/styles-21F1-oqx.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("./index-OaWkrl0G.js"),o=require("./Toggle-CsPSF8Dr.js"),O=require("./useAutosave-B2p6iwh8.js"),M=require("./AutosaveIndicator-CY_YHM1D.js"),b={enabled:!0,relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}},$=[{value:"most_recent",label:"Most Recent",description:"Show the most recently added products (excluding current product)."},{value:"by_category",label:"By Category",description:"Show products from the same category as the current product."},{value:"manual",label:"Manual Selection",description:"Specify related products per-product using relatedProductIds in metadata."},{value:"ai",label:"AI Recommendations",description:"Let AI analyze products and suggest the best matches. Requires AI to be configured in AI Settings."}],S=[{value:"large",label:"Large",description:"Portrait cards (4:5) with full product info, description, and tags."},{value:"square",label:"Square",description:"Square cards (1:1) showing title and price only."},{value:"compact",label:"Compact",description:"Compact cards (3:4) with smaller text to fit more products."}],C=[{value:"center",label:"Center"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],q=[{id:"shop-page",label:"Shop Page"},{id:"catalog",label:"Catalog"},{id:"layouts",label:"Layouts"},{id:"product-pages",label:"Product Pages"},{id:"checkout",label:"Checkout"}];function H({serverUrl:h,apiKey:d,authManager:c}){const[m,P]=l.useState("shop-page"),[a,i]=l.useState(b),[I,z]=l.useState(!0),[W,B]=l.useState(!0),[L,y]=l.useState(null),x=l.useCallback(async()=>{try{y(null);let t;const s="/admin/config/shop";if(c?.isAuthenticated())t=await c.fetchWithAuth(s);else{const r={"Content-Type":"application/json"};d&&(r["X-API-Key"]=d);const n=await fetch(`${h}${s}`,{headers:r});if(!n.ok)throw new Error(`Failed to fetch settings: ${n.status}`);t=await n.json()}i({...b,...t.config})}catch{i(b),y("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[h,d,c]);l.useEffect(()=>{x()},[x]);const D=l.useCallback(async t=>{const s="/admin/config/shop",r=JSON.stringify({config:t});try{if(c?.isAuthenticated())await c.fetchWithAuth(s,{method:"PUT",body:r});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const p=await fetch(`${h}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw y("Failed to save storefront settings"),new Error("Save failed")}},[h,d,c]),{status:N,error:R}=O.useAutosave({data:a,onSave:D,debounceMs:1500,enabled:!W}),A=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,mode:t}}))},E=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,maxItems:t}}))},_=(t,s)=>{i(r=>({...r,relatedProducts:{...r.relatedProducts,layout:{...r.relatedProducts.layout,[t]:s}}}))},f=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},v=(t,s)=>{const r=a.catalog.sort,n=Object.values(r).filter(Boolean).length;!s&&n<=1||i(p=>({...p,catalog:{...p.catalog,sort:{...p.catalog.sort,[t]:s}}}))},F=(t,s)=>{i(r=>({...r,checkout:{...r.checkout,[t]:s}}))},k=(t,s)=>{i(r=>({...r,shopLayout:{...r.shopLayout,[t]:s}}))},T=(t,s)=>{i(r=>({...r,categoryLayout:{...r.categoryLayout,[t]:s}}))},u=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},j=(t,s)=>{i(r=>({...r,inventory:{...r.inventory,[t]:s}}))},w=(t,s)=>{i(r=>({...r,shopPage:{...r.shopPage,[t]:s}}))};return I?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[g.Icons.loading," Loading storefront settings..."]})}):e.jsxs("div",{className:"cedros-admin__storefront-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Storefront"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure catalog filters, product layouts, and checkout settings."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:a.enabled?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:a.enabled?"Enabled":"Disabled"}),e.jsx(o.Toggle,{checked:a.enabled,onChange:t=>i(s=>({...s,enabled:t}))})]})]}),!a.enabled&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)"},children:"The storefront is disabled. Enable it using the toggle above to activate your store."}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",style:{opacity:a.enabled?1:.5,pointerEvents:a.enabled?"auto":"none"},children:[q.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${m===t.id?"cedros-admin__tab--active":""}`,onClick:()=>P(t.id),children:t.label},t.id)),e.jsx("div",{style:{flex:1}}),e.jsx(M.AutosaveIndicator,{status:N,error:R})]}),e.jsx(g.ErrorBanner,{message:L,onRetry:x}),m==="shop-page"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Shop Page Content"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Customize the title and description shown on your shop page."}),e.jsxs("div",{className:"cedros-admin__field",style:{marginBottom:"1.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.shopPage.title,onChange:t=>w("title",t.target.value),placeholder:"Shop"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"The main heading displayed on your shop page."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Description"}),e.jsx("textarea",{className:"cedros-admin__textarea",value:a.shopPage.description,onChange:t=>w("description",t.target.value),placeholder:"Browse our collection of products...",rows:3,style:{resize:"vertical"}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"A short description or subtitle shown below the title. Leave empty to hide."})]})]}),m==="catalog"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Catalog Filters"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which filters appear in the shop and category page sidebars."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.tags,onChange:t=>f("tags",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Tags"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter products by tags (multi-select checkboxes)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.priceRange,onChange:t=>f("priceRange",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price Range"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter by minimum and maximum price"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.inStock,onChange:t=>f("inStock",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"In Stock"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show only products that are in stock"})]})]})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Sort Options"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sort options appear in the shop and category pages. At least one must be enabled."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.featured,onChange:t=>v("featured",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Featured"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Default sort order (as returned by backend)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceAsc,onChange:t=>v("priceAsc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: Low to High"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price ascending"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceDesc,onChange:t=>v("priceDesc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: High to Low"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price descending"})]})]})]})]})]}),m==="layouts"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Product Layouts"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Configure product card layouts for shop and category pages."}),e.jsxs("div",{style:{marginBottom:"2rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Shop Page"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.shopLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"shopLayout",value:t.value,checked:s,onChange:()=>k("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.shopLayout.imageCrop,onChange:t=>k("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]}),e.jsxs("div",{style:{paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Category Pages"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.categoryLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"categoryLayout",value:t.value,checked:s,onChange:()=>T("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.categoryLayout.imageCrop,onChange:t=>T("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),m==="product-pages"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Related Products"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure how related products are displayed on product detail pages."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",marginBottom:"1.5rem"},children:$.map(t=>{const s=a.relatedProducts.mode===t.value,r=t.badge==="Coming Soon";return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"1rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:8,cursor:r?"not-allowed":"pointer",opacity:r?.6:1,background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedProductsMode",value:t.value,checked:s,onChange:()=>!r&&A(t.value),disabled:r,style:{marginTop:2}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("span",{style:{fontWeight:600},children:t.label}),t.badge&&e.jsx("span",{style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#6366f1",color:"#fff"},children:t.badge})]}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:13,opacity:.75},children:t.description})]})]},t.value)})}),a.relatedProducts.mode==="manual"&&e.jsxs("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #f5f5f5)",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("strong",{style:{fontSize:14},children:"How to set related products:"}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.8},children:["When editing a product, add a ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"relatedProductIds"})," field to its metadata containing a comma-separated list of product IDs."]}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.6},children:["Example: ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"prod_123,prod_456,prod_789"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Related Products"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.relatedProducts.maxItems,onChange:t=>E(Math.max(1,Math.min(12,parseInt(t.target.value)||4))),min:1,max:12}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How many related products to show (1-12)"})]}),e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Display Layout"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.relatedProducts.layout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedLayout",value:t.value,checked:s,onChange:()=>_("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.relatedProducts.layout.imageCrop,onChange:t=>_("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Page Sections"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sections appear on product detail pages."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showDescription,onChange:t=>u("showDescription",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Description"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Expandable description accordion"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showSpecs,onChange:t=>u("showSpecs",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Specifications"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product attributes and details"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showShipping,onChange:t=>u("showShipping",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Shipping & Returns"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Shipping and return policy information"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showRelatedProducts,onChange:t=>u("showRelatedProducts",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Related Products"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product recommendations section"})]})]})]})]})]}),m==="checkout"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Checkout Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure checkout and cart page features."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.checkout.promoCodes,onChange:t=>F("promoCodes",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Promo Codes"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show promo/coupon code input on cart and checkout pages"})]})]})})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Inventory Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure inventory verification and reservation behavior."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.preCheckoutVerification,onChange:t=>j("preCheckoutVerification",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Pre-Checkout Verification"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Verify inventory availability before processing payment"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.holdsEnabled,onChange:t=>j("holdsEnabled",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Inventory Holds"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Reserve inventory when items are added to cart"})]})]})]}),a.inventory.holdsEnabled&&e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200,marginTop:"1rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Hold Duration (minutes)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.inventory.holdDurationMinutes,onChange:t=>j("holdDurationMinutes",Math.max(5,Math.min(60,parseInt(t.target.value)||15))),min:5,max:60}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How long to reserve inventory in carts (5-60 minutes)"})]})]})]})]})}exports.StorefrontSection=H;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),g=require("./index-C7MWL6O8.js"),o=require("./Toggle-CsPSF8Dr.js"),O=require("./useAutosave-B2p6iwh8.js"),M=require("./AutosaveIndicator-D2l7U8R1.js"),b={enabled:!0,relatedProducts:{mode:"most_recent",maxItems:4,layout:{layout:"large",imageCrop:"center"}},catalog:{filters:{tags:!0,priceRange:!0,inStock:!0},sort:{featured:!0,priceAsc:!0,priceDesc:!0}},checkout:{promoCodes:!0},shopLayout:{layout:"large",imageCrop:"center"},categoryLayout:{layout:"large",imageCrop:"center"},sections:{showDescription:!0,showSpecs:!0,showShipping:!0,showRelatedProducts:!0},inventory:{preCheckoutVerification:!0,holdsEnabled:!1,holdDurationMinutes:15},shopPage:{title:"Shop",description:""}},$=[{value:"most_recent",label:"Most Recent",description:"Show the most recently added products (excluding current product)."},{value:"by_category",label:"By Category",description:"Show products from the same category as the current product."},{value:"manual",label:"Manual Selection",description:"Specify related products per-product using relatedProductIds in metadata."},{value:"ai",label:"AI Recommendations",description:"Let AI analyze products and suggest the best matches. Requires AI to be configured in AI Settings."}],S=[{value:"large",label:"Large",description:"Portrait cards (4:5) with full product info, description, and tags."},{value:"square",label:"Square",description:"Square cards (1:1) showing title and price only."},{value:"compact",label:"Compact",description:"Compact cards (3:4) with smaller text to fit more products."}],C=[{value:"center",label:"Center"},{value:"top",label:"Top"},{value:"bottom",label:"Bottom"},{value:"left",label:"Left"},{value:"right",label:"Right"}],q=[{id:"shop-page",label:"Shop Page"},{id:"catalog",label:"Catalog"},{id:"layouts",label:"Layouts"},{id:"product-pages",label:"Product Pages"},{id:"checkout",label:"Checkout"}];function H({serverUrl:h,apiKey:d,authManager:c}){const[m,P]=l.useState("shop-page"),[a,i]=l.useState(b),[I,z]=l.useState(!0),[W,B]=l.useState(!0),[L,y]=l.useState(null),x=l.useCallback(async()=>{try{y(null);let t;const s="/admin/config/shop";if(c?.isAuthenticated())t=await c.fetchWithAuth(s);else{const r={"Content-Type":"application/json"};d&&(r["X-API-Key"]=d);const n=await fetch(`${h}${s}`,{headers:r});if(!n.ok)throw new Error(`Failed to fetch settings: ${n.status}`);t=await n.json()}i({...b,...t.config})}catch{i(b),y("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[h,d,c]);l.useEffect(()=>{x()},[x]);const D=l.useCallback(async t=>{const s="/admin/config/shop",r=JSON.stringify({config:t});try{if(c?.isAuthenticated())await c.fetchWithAuth(s,{method:"PUT",body:r});else{const n={"Content-Type":"application/json"};d&&(n["X-API-Key"]=d);const p=await fetch(`${h}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw y("Failed to save storefront settings"),new Error("Save failed")}},[h,d,c]),{status:N,error:R}=O.useAutosave({data:a,onSave:D,debounceMs:1500,enabled:!W}),A=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,mode:t}}))},E=t=>{i(s=>({...s,relatedProducts:{...s.relatedProducts,maxItems:t}}))},_=(t,s)=>{i(r=>({...r,relatedProducts:{...r.relatedProducts,layout:{...r.relatedProducts.layout,[t]:s}}}))},f=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},v=(t,s)=>{const r=a.catalog.sort,n=Object.values(r).filter(Boolean).length;!s&&n<=1||i(p=>({...p,catalog:{...p.catalog,sort:{...p.catalog.sort,[t]:s}}}))},F=(t,s)=>{i(r=>({...r,checkout:{...r.checkout,[t]:s}}))},k=(t,s)=>{i(r=>({...r,shopLayout:{...r.shopLayout,[t]:s}}))},T=(t,s)=>{i(r=>({...r,categoryLayout:{...r.categoryLayout,[t]:s}}))},u=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},j=(t,s)=>{i(r=>({...r,inventory:{...r.inventory,[t]:s}}))},w=(t,s)=>{i(r=>({...r,shopPage:{...r.shopPage,[t]:s}}))};return I?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[g.Icons.loading," Loading storefront settings..."]})}):e.jsxs("div",{className:"cedros-admin__storefront-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Storefront"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure catalog filters, product layouts, and checkout settings."})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:a.enabled?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:a.enabled?"Enabled":"Disabled"}),e.jsx(o.Toggle,{checked:a.enabled,onChange:t=>i(s=>({...s,enabled:t}))})]})]}),!a.enabled&&e.jsx("div",{style:{padding:"0.75rem 1rem",marginBottom:"1rem",backgroundColor:"var(--cedros-admin-warning-bg, #fef3c7)",border:"1px solid var(--cedros-admin-warning-border, #f59e0b)",borderRadius:"0.375rem",fontSize:"0.875rem",color:"var(--cedros-admin-warning-text, #92400e)"},children:"The storefront is disabled. Enable it using the toggle above to activate your store."}),e.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",style:{opacity:a.enabled?1:.5,pointerEvents:a.enabled?"auto":"none"},children:[q.map(t=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${m===t.id?"cedros-admin__tab--active":""}`,onClick:()=>P(t.id),children:t.label},t.id)),e.jsx("div",{style:{flex:1}}),e.jsx(M.AutosaveIndicator,{status:N,error:R})]}),e.jsx(g.ErrorBanner,{message:L,onRetry:x}),m==="shop-page"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Shop Page Content"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Customize the title and description shown on your shop page."}),e.jsxs("div",{className:"cedros-admin__field",style:{marginBottom:"1.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.shopPage.title,onChange:t=>w("title",t.target.value),placeholder:"Shop"}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"The main heading displayed on your shop page."})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Page Description"}),e.jsx("textarea",{className:"cedros-admin__textarea",value:a.shopPage.description,onChange:t=>w("description",t.target.value),placeholder:"Browse our collection of products...",rows:3,style:{resize:"vertical"}}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"A short description or subtitle shown below the title. Leave empty to hide."})]})]}),m==="catalog"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Catalog Filters"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which filters appear in the shop and category page sidebars."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.tags,onChange:t=>f("tags",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Tags"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter products by tags (multi-select checkboxes)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.priceRange,onChange:t=>f("priceRange",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price Range"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Filter by minimum and maximum price"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.filters.inStock,onChange:t=>f("inStock",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"In Stock"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show only products that are in stock"})]})]})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Sort Options"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sort options appear in the shop and category pages. At least one must be enabled."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.featured,onChange:t=>v("featured",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Featured"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Default sort order (as returned by backend)"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceAsc,onChange:t=>v("priceAsc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: Low to High"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price ascending"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.catalog.sort.priceDesc,onChange:t=>v("priceDesc",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Price: High to Low"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Sort products by price descending"})]})]})]})]})]}),m==="layouts"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Product Layouts"}),e.jsx("p",{style:{marginBottom:"1.5rem",fontSize:14,opacity:.7},children:"Configure product card layouts for shop and category pages."}),e.jsxs("div",{style:{marginBottom:"2rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Shop Page"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.shopLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"shopLayout",value:t.value,checked:s,onChange:()=>k("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.shopLayout.imageCrop,onChange:t=>k("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]}),e.jsxs("div",{style:{paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Category Pages"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.categoryLayout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"categoryLayout",value:t.value,checked:s,onChange:()=>T("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.categoryLayout.imageCrop,onChange:t=>T("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),m==="product-pages"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Related Products"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure how related products are displayed on product detail pages."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",marginBottom:"1.5rem"},children:$.map(t=>{const s=a.relatedProducts.mode===t.value,r=t.badge==="Coming Soon";return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"1rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:8,cursor:r?"not-allowed":"pointer",opacity:r?.6:1,background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedProductsMode",value:t.value,checked:s,onChange:()=>!r&&A(t.value),disabled:r,style:{marginTop:2}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("span",{style:{fontWeight:600},children:t.label}),t.badge&&e.jsx("span",{style:{fontSize:11,padding:"2px 6px",borderRadius:4,background:"#6366f1",color:"#fff"},children:t.badge})]}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:13,opacity:.75},children:t.description})]})]},t.value)})}),a.relatedProducts.mode==="manual"&&e.jsxs("div",{style:{padding:"1rem",marginBottom:"1.5rem",background:"var(--cedros-admin-bg-accent, #f5f5f5)",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("strong",{style:{fontSize:14},children:"How to set related products:"}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.8},children:["When editing a product, add a ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"relatedProductIds"})," field to its metadata containing a comma-separated list of product IDs."]}),e.jsxs("p",{style:{margin:"0.5rem 0 0",fontSize:13,opacity:.6},children:["Example: ",e.jsx("code",{style:{background:"rgba(0,0,0,0.1)",padding:"2px 4px",borderRadius:3},children:"prod_123,prod_456,prod_789"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Related Products"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.relatedProducts.maxItems,onChange:t=>E(Math.max(1,Math.min(12,parseInt(t.target.value)||4))),min:1,max:12}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How many related products to show (1-12)"})]}),e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.75rem"},children:"Display Layout"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem",marginBottom:"1rem"},children:S.map(t=>{const s=a.relatedProducts.layout.layout===t.value;return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"0.75rem",padding:"0.75rem",border:`2px solid ${s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #e5e5e5)"}`,borderRadius:6,cursor:"pointer",background:s?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0,transition:"border-color 0.15s, background 0.15s"},children:[e.jsx("input",{type:"radio",name:"relatedLayout",value:t.value,checked:s,onChange:()=>_("layout",t.value),style:{marginTop:2}}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:t.label}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:12,opacity:.6},children:t.description})]})]},t.value)})}),e.jsx(g.FormDropdown,{value:a.relatedProducts.layout.imageCrop,onChange:t=>_("imageCrop",t),options:C,label:"Image Crop",style:{maxWidth:180}})]})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Page Sections"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Choose which sections appear on product detail pages."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showDescription,onChange:t=>u("showDescription",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Description"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Expandable description accordion"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showSpecs,onChange:t=>u("showSpecs",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Specifications"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product attributes and details"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showShipping,onChange:t=>u("showShipping",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Shipping & Returns"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Shipping and return policy information"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.sections.showRelatedProducts,onChange:t=>u("showRelatedProducts",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Related Products"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Product recommendations section"})]})]})]})]})]}),m==="checkout"&&e.jsxs("div",{className:"cedros-admin__section",style:{marginTop:"1rem"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Checkout Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure checkout and cart page features."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.checkout.promoCodes,onChange:t=>F("promoCodes",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Promo Codes"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Show promo/coupon code input on cart and checkout pages"})]})]})})]}),e.jsxs("div",{style:{marginTop:"2rem",paddingTop:"1.5rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[e.jsx("h4",{style:{marginBottom:"0.5rem",fontWeight:600},children:"Inventory Settings"}),e.jsx("p",{style:{marginBottom:"1rem",fontSize:14,opacity:.7},children:"Configure inventory verification and reservation behavior."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.preCheckoutVerification,onChange:t=>j("preCheckoutVerification",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Pre-Checkout Verification"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Verify inventory availability before processing payment"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx(o.Toggle,{checked:a.inventory.holdsEnabled,onChange:t=>j("holdsEnabled",t)}),e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:500},children:"Inventory Holds"}),e.jsx("p",{style:{margin:"0.125rem 0 0",fontSize:13,opacity:.6},children:"Reserve inventory when items are added to cart"})]})]})]}),a.inventory.holdsEnabled&&e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:200,marginTop:"1rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Hold Duration (minutes)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:a.inventory.holdDurationMinutes,onChange:t=>j("holdDurationMinutes",Math.max(5,Math.min(60,parseInt(t.target.value)||15))),min:5,max:60}),e.jsx("p",{style:{margin:"0.25rem 0 0",fontSize:12,opacity:.6},children:"How long to reserve inventory in carts (5-60 minutes)"})]})]})]})]})}exports.StorefrontSection=H;
|
|
@@ -1,6 +1,6 @@
|
|
|
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, E as Z,
|
|
3
|
+
import { I as h, E as Z, j as K } from "./index-BkDimQDF.mjs";
|
|
4
4
|
const l = {
|
|
5
5
|
enabled: !1,
|
|
6
6
|
plans: [],
|
|
@@ -147,7 +147,7 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
147
147
|
...n,
|
|
148
148
|
plans: n.plans.filter((s) => s.id !== e)
|
|
149
149
|
})), I === e && P(null));
|
|
150
|
-
},
|
|
150
|
+
}, j = (e, n) => {
|
|
151
151
|
const s = r.plans.findIndex((p) => p.id === e);
|
|
152
152
|
if (s === -1 || n === "up" && s === 0 || n === "down" && s === r.plans.length - 1) return;
|
|
153
153
|
const t = [...r.plans], o = n === "up" ? s - 1 : s + 1;
|
|
@@ -172,7 +172,7 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
172
172
|
h.loading,
|
|
173
173
|
" Loading subscription settings..."
|
|
174
174
|
] }) });
|
|
175
|
-
const
|
|
175
|
+
const H = r.plans.filter((e) => e.isActive).length, O = r.plans.reduce((e, n) => e + (n.activeSubscribers ?? 0), 0), B = d.enabled, V = r.plans.filter((e) => e.isActive).map((e) => ({
|
|
176
176
|
label: e.title,
|
|
177
177
|
value: e.activeSubscribers ?? 0,
|
|
178
178
|
description: "subscribers"
|
|
@@ -184,8 +184,8 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
184
184
|
{
|
|
185
185
|
stats: [
|
|
186
186
|
{ label: "Status", value: B ? "Enabled" : "Disabled", variant: B ? "success" : "muted" },
|
|
187
|
-
{ label: "Active Plans", value:
|
|
188
|
-
{ label: "Total Subscribers", value:
|
|
187
|
+
{ label: "Active Plans", value: H, variant: H > 0 ? "success" : "muted" },
|
|
188
|
+
{ label: "Total Subscribers", value: O, variant: O > 0 ? "success" : "muted" },
|
|
189
189
|
...V
|
|
190
190
|
],
|
|
191
191
|
isLoading: y
|
|
@@ -379,7 +379,7 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
379
379
|
"button",
|
|
380
380
|
{
|
|
381
381
|
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
382
|
-
onClick: () =>
|
|
382
|
+
onClick: () => j(e.id, "up"),
|
|
383
383
|
disabled: n === 0,
|
|
384
384
|
title: "Move up",
|
|
385
385
|
style: { padding: "4px 8px" },
|
|
@@ -390,7 +390,7 @@ function le({ serverUrl: N, apiKey: _, authManager: v }) {
|
|
|
390
390
|
"button",
|
|
391
391
|
{
|
|
392
392
|
className: "cedros-admin__button cedros-admin__button--ghost",
|
|
393
|
-
onClick: () =>
|
|
393
|
+
onClick: () => j(e.id, "down"),
|
|
394
394
|
disabled: n === r.plans.length - 1,
|
|
395
395
|
title: "Move down",
|
|
396
396
|
style: { padding: "4px 8px" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),u=require("./index-OaWkrl0G.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:""},X={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function Y(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function G({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[p,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,j]=d.useState(null),[l,m]=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),[F,C]=d.useState(""),w=d.useCallback(async()=>{try{j(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}),m({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),m({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([])),j("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const I=d.useCallback(async e=>{try{j(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 j("Failed to save subscription settings"),!1}},[f,b,v]),E=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(()=>F!==D,[D,F]),S=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 I(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,I,r]);d.useEffect(()=>{if(p!=="page"||_||!E)return;const e=setTimeout(S,600);return()=>clearTimeout(e)},[p,E,_,S]),d.useEffect(()=>{if(p!=="plans"||_||!U)return;const e=setTimeout(S,800);return()=>clearTimeout(e)},[p,U,_,S]);const O=()=>{const e={...X,id:Y(),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(g=>g.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(g=>({...g,plans:s}))},Q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},J=(e,t,n)=>{const s=r.plans.find(g=>g.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},q=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,g)=>g!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[u.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(u.ErrorBanner,{message:z,onRetry:w}),a.jsx(u.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:[p==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[u.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 ${p==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),p==="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=>m(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=>m(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=>m(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=>m(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=>m(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=>m(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),p==="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?u.Icons.chevronDown:u.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:u.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:u.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:u.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:g=>J(e.id,o,g.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:()=>q(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:u.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=G;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),u=require("./index-C7MWL6O8.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:""},X={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function Y(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function G({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[p,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,j]=d.useState(null),[l,m]=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),[F,C]=d.useState(""),w=d.useCallback(async()=>{try{j(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}),m({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),m({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([])),j("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const I=d.useCallback(async e=>{try{j(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 j("Failed to save subscription settings"),!1}},[f,b,v]),E=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(()=>F!==D,[D,F]),S=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 I(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,I,r]);d.useEffect(()=>{if(p!=="page"||_||!E)return;const e=setTimeout(S,600);return()=>clearTimeout(e)},[p,E,_,S]),d.useEffect(()=>{if(p!=="plans"||_||!U)return;const e=setTimeout(S,800);return()=>clearTimeout(e)},[p,U,_,S]);const O=()=>{const e={...X,id:Y(),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(g=>g.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(g=>({...g,plans:s}))},Q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},J=(e,t,n)=>{const s=r.plans.find(g=>g.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},q=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,g)=>g!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[u.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(u.ErrorBanner,{message:z,onRetry:w}),a.jsx(u.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:[p==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[u.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 ${p==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${p==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),p==="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=>m(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=>m(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=>m(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=>m(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=>m(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=>m(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),p==="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?u.Icons.chevronDown:u.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:u.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:u.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:u.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:g=>J(e.id,o,g.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:()=>q(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:u.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=G;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var ke=Object.create;var xe=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var Re=(t,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of Te(i))!Be.call(t,a)&&a!==n&&xe(t,a,{get:()=>i[a],enumerable:!(s=Ae(i,a))||s.enumerable});return t};var me=(t,i,n)=>(n=t!=null?ke(Ne(t)):{},Re(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"),fe=require("./index-C7MWL6O8.js"),ee=require("./configApi-DkduMQg1.js"),Ce=[{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"}],be={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 ze(){return{id:Math.random().toString(36).slice(2),label:"",fieldType:"text",required:!1,options:[],placeholder:""}}function je({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:Ce.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 Ie({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 De({value:t,onChange:i}){const n=t!==null,s=t??be,[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?{...be}:null),u()},x=()=>{const h=ze();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:Ce.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(je,{field:y,onSave:j,onCancel:u})]},h.id)),a==="new"&&y&&e.jsx(je,{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(Ie,{fields:s.fields,instructions:s.instructions})})]})]})]})}const Pe=[{value:"securities",label:"Securities (fungible)"},{value:"commodities",label:"Commodities (fungible)"},{value:"property",label:"Property (non-fungible)"},{value:"collectibles",label:"Collectibles (non-fungible)"}],Me=t=>t==="securities"||t==="commodities";function Fe({c:t,onDeployPool:i,onEdit:n,onDelete:s}){const a=t.tokenizationConfig,c=Me(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 Ee({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:Pe.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(De,{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(Fe,{c:g,onDeployPool:s,onEdit:()=>_(g),onDelete:()=>A(g)},g.id))})]})}const Le=[{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 $e(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 qe(t){return t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function Oe(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 _e(t){return`https://solscan.io/tx/${t}`}function We({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:_e(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:_e(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 Ue({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:Le.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:Oe(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:$e(l.status),children:qe(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(We,{redemption:l,onAction:h,onComplete:S,actionBusy:x===l.id})})},`${l.id}-detail`)]}))})]})})]})}const Ye={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,Ge={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 Ke({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?Ye[n]??ye:null,v=n?Ge[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(Je,{reg:u,minValueCents:a}),e.jsx(Ve,{reg:u}),e.jsx(Xe,{reg:u}),e.jsx(Ze,{maxValueCents:y})]}),e.jsx(Qe,{reg:u,minValueCents:a,maxValueCents:y})]}):e.jsx(He,{})})}function He(){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 Je({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 Ve({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 Xe({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 Ze({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 Qe({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 et({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 tt({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(st,{onSubmit:async _=>{await h("/admin/gift-cards",{method:"POST",body:JSON.stringify(_)}),d("list"),S()},onCancel:()=>d("list")}):o==="adjust"&&u?e.jsx(nt,{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 st({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 nt({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 it=0;class we{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:it},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,at=1,rt="https://solscan.io/account",ot="https://app.meteora.ag/dlmm";function lt({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 we,le=new R(O.publicKey.toBase58()),E=u/100,de=await se.computeBinId(E,p,he,at),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(dt,{text:n}),e.jsx(ve,{href:`${rt}/${n}`,label:"Solscan"}),e.jsx(ve,{href:`${ot}/${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 dt({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 ve({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 ct({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 we),_=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(lt,{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(mt,{step:x,poolAddress:h}):e.jsx(ut,{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 ut({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 Se=[{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 mt({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:Se.map((n,s)=>{const a=Se.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 pt({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(fe.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:[fe.Icons.loading," Loading..."]}):u==="mint"?e.jsx(ht,{mintStatus:s,initForm:x,setInitForm:f,isInitializing:j,isHarvesting:h,actionMessage:T,onInitialize:g,onHarvestFees:m,formatDate:N}):u==="inventory"?e.jsx(tt,{serverUrl:t,apiKey:i,authManager:n}):u==="analytics"?e.jsx(et,{serverUrl:t,apiKey:i,authManager:n}):u==="redemptions"?e.jsx(gt,{redemptions:c,formatDate:N}):u==="compliance"?e.jsx(Ke,{serverUrl:t,apiKey:i,authManager:n}):u==="liquidity"?e.jsx(ct,{serverUrl:t,authManager:n,mintConfigured:!!s?.configured,mintAddress:s?.mintAddress,tokenDecimals:s?.tokenDecimals}):u==="asset-classes"?e.jsx(Ee,{serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:()=>v("liquidity")}):e.jsx(Ue,{serverUrl:t,apiKey:i,authManager:n})]})}function ht({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 gt({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=pt;
|