@cedros/pay-react 1.1.29 → 1.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/README.md +8 -0
  2. package/dist/{AISettingsSection-DtAgMsDw.mjs → AISettingsSection-BMh3hAb5.mjs} +4 -4
  3. package/dist/{AISettingsSection-B7qrycfY.js → AISettingsSection-C0zqPbd6.js} +1 -1
  4. package/dist/{AutosaveIndicator-BEvABoKU.mjs → AutosaveIndicator-3ctAnz8Y.mjs} +1 -1
  5. package/dist/AutosaveIndicator-DXRPr4P7.js +1 -0
  6. package/dist/{CedrosPayAdminDashboard-CBuvNAtB.mjs → CedrosPayAdminDashboard-DaJ9JoGn.mjs} +20 -20
  7. package/dist/CedrosPayAdminDashboard-Uvyh9p7A.js +1 -0
  8. package/dist/{ChatLogsSection-Ber5o8hF.mjs → ChatLogsSection-BtJixYAp.mjs} +2 -2
  9. package/dist/ChatLogsSection-FC3O536G.js +1 -0
  10. package/dist/{ComplianceSection-ZCr0wsvw.mjs → ComplianceSection-BMnb1p4w.mjs} +3 -3
  11. package/dist/ComplianceSection-BioTKm7k.js +1 -0
  12. package/dist/{CustomersSection-D9UknSKC.mjs → CustomersSection-dmwoBhcf.mjs} +2 -2
  13. package/dist/CustomersSection-z6ARxuex.js +1 -0
  14. package/dist/DisputesSection-BjHHQAi7.js +1 -0
  15. package/dist/{DisputesSection-C_eySK-W.mjs → DisputesSection-CHyLne76.mjs} +2 -2
  16. package/dist/{Dropdown-B90Zabxr.mjs → Dropdown-BRSZlhik.mjs} +1 -1
  17. package/dist/Dropdown-j8o0OO5L.js +1 -0
  18. package/dist/ErrorBanner-CAgPnj62.js +1 -0
  19. package/dist/{ErrorBanner-CZXsHi3H.mjs → ErrorBanner-lZJhCmDX.mjs} +1 -1
  20. package/dist/{FAQSection-Bv_Hdt8B.mjs → FAQSection-Di2xE9Sm.mjs} +3 -3
  21. package/dist/FAQSection-b34DMzgV.js +1 -0
  22. package/dist/{ImagesSection-DpdXQ6qu.mjs → ImagesSection-D63PEjR6.mjs} +2 -2
  23. package/dist/ImagesSection-DGBA7iKY.js +1 -0
  24. package/dist/{InventorySection-DZMu9DMw.mjs → InventorySection-Dp5Yu4TA.mjs} +2 -2
  25. package/dist/InventorySection-bVCECzX5.js +1 -0
  26. package/dist/LazyCedrosPayAdminDashboard-BqJDNrDI.mjs +9 -0
  27. package/dist/LazyCedrosPayAdminDashboard-CpfTtOBc.js +1 -0
  28. package/dist/{MessagingSection-D_cOBfFt.mjs → MessagingSection-BLCnCpEv.mjs} +3 -3
  29. package/dist/MessagingSection-DU0dYNMy.js +1 -0
  30. package/dist/{OrdersSection-wfPavit9.mjs → OrdersSection-Bd56F3cj.mjs} +2 -2
  31. package/dist/OrdersSection-FOFEAgs1.js +1 -0
  32. package/dist/{PaymentSettingsSection-DunzBo9n.mjs → PaymentSettingsSection-52iw47Su.mjs} +3 -3
  33. package/dist/{PaymentSettingsSection-BdBDgaRg.js → PaymentSettingsSection-B5J56VAk.js} +1 -1
  34. package/dist/ReturnsSection-BjpIVFfN.js +1 -0
  35. package/dist/{ReturnsSection-B4FL7bUv.mjs → ReturnsSection-DUVeKrCd.mjs} +2 -2
  36. package/dist/{SettingsSection-Cz2Yjdhr.js → SettingsSection-DKkHykaC.js} +1 -1
  37. package/dist/{SettingsSection-DoeNDbqd.mjs → SettingsSection-vK9WIwXE.mjs} +1 -1
  38. package/dist/ShippingSection-B5lk7zpS.js +1 -0
  39. package/dist/{ShippingSection-BlVsYC6B.mjs → ShippingSection-CZRrXrlh.mjs} +2 -2
  40. package/dist/{SingleCategorySettings-B406nnF-.mjs → SingleCategorySettings-C8xJ47_T.mjs} +4 -4
  41. package/dist/SingleCategorySettings-g7D-9lG1.js +3 -0
  42. package/dist/StatsBar-CWXw2ZT3.js +1 -0
  43. package/dist/{StatsBar-D4v-I_Dj.mjs → StatsBar-D4cOKG2e.mjs} +1 -1
  44. package/dist/StorefrontSection-BWnMB9k-.js +1 -0
  45. package/dist/{StorefrontSection-BK_rhrAi.mjs → StorefrontSection-uXSVbEAa.mjs} +4 -4
  46. package/dist/{SubscriptionsSection-D8V9RBv-.mjs → SubscriptionsSection-Ci_AZrWA.mjs} +3 -3
  47. package/dist/SubscriptionsSection-DQfXkuDv.js +1 -0
  48. package/dist/{TaxSection-Cj6TXL6x.mjs → TaxSection-BTukS_cU.mjs} +2 -2
  49. package/dist/TaxSection-cuPQISxZ.js +1 -0
  50. package/dist/Token22Section-CCfkDm8W.js +1 -0
  51. package/dist/{Token22Section-DtYAcT54.mjs → Token22Section-DRsPJuTq.mjs} +2 -2
  52. package/dist/{WebhooksSection-DBAIxtBy.mjs → WebhooksSection-A8Y4ZGcj.mjs} +2 -2
  53. package/dist/WebhooksSection-CnEmaGH1.js +1 -0
  54. package/dist/admin.js +1 -1
  55. package/dist/admin.mjs +4 -5
  56. package/dist/crypto-only.js +1 -1
  57. package/dist/crypto-only.mjs +4 -3
  58. package/dist/{sectionIds-DBavltrL.mjs → icons-C3yDMnKE.mjs} +129 -253
  59. package/dist/icons-Cjgd9YVo.js +1 -0
  60. package/dist/index.js +1 -1
  61. package/dist/index.mjs +24 -23
  62. package/dist/sectionIds-D46-_-h-.js +1 -0
  63. package/dist/sectionIds-YktNxmRt.mjs +124 -0
  64. package/dist/{sections-C2zEJr5G.js → sections-511_XBh4.js} +1 -1
  65. package/dist/{sections-BHph7CYj.mjs → sections-CRaMa8ZB.mjs} +2 -2
  66. package/dist/sections-more-Cgw2qJlA.js +1 -0
  67. package/dist/{sections-more-CMFgfU4d.mjs → sections-more-Ixw6mM6R.mjs} +5 -5
  68. package/dist/src/admin.d.ts +4 -4
  69. package/dist/src/admin.d.ts.map +1 -1
  70. package/dist/src/standalone-admin.d.ts +8 -0
  71. package/dist/src/standalone-admin.d.ts.map +1 -0
  72. package/dist/standalone-admin.d.ts +2 -0
  73. package/dist/standalone-admin.js +1 -0
  74. package/dist/standalone-admin.mjs +4 -0
  75. package/package.json +7 -1
  76. package/dist/AutosaveIndicator-DiyeAg93.js +0 -1
  77. package/dist/CedrosPayAdminDashboard-CAwEvn66.js +0 -1
  78. package/dist/ChatLogsSection-DLxMMi9I.js +0 -1
  79. package/dist/ComplianceSection-Buu0zTiL.js +0 -1
  80. package/dist/CustomersSection-BywmMLur.js +0 -1
  81. package/dist/DisputesSection-DwkHGv2a.js +0 -1
  82. package/dist/Dropdown-CtY91emj.js +0 -1
  83. package/dist/ErrorBanner-Cx2dUhps.js +0 -1
  84. package/dist/FAQSection-DlPLnIJD.js +0 -1
  85. package/dist/ImagesSection-B4Jzet79.js +0 -1
  86. package/dist/InventorySection-BgRdpn1l.js +0 -1
  87. package/dist/MessagingSection-CxV-pf-f.js +0 -1
  88. package/dist/OrdersSection-BbAX79Ff.js +0 -1
  89. package/dist/ReturnsSection-7k4LZ8yp.js +0 -1
  90. package/dist/ShippingSection-C-HI8rOb.js +0 -1
  91. package/dist/SingleCategorySettings-BqC2UXt3.js +0 -3
  92. package/dist/StatsBar-m6GSRNxs.js +0 -1
  93. package/dist/StorefrontSection-Axvh_KeS.js +0 -1
  94. package/dist/SubscriptionsSection-EeULMWIB.js +0 -1
  95. package/dist/TaxSection-CzHPhaHl.js +0 -1
  96. package/dist/Token22Section-DqRKVG_G.js +0 -1
  97. package/dist/WebhooksSection-D--iPZuM.js +0 -1
  98. package/dist/sectionIds-B_tFiNvF.js +0 -1
  99. package/dist/sections-more-C1VNVwkp.js +0 -1
@@ -1,9 +1,9 @@
1
1
  import { jsxs as s, jsx as t, Fragment as _ } from "react/jsx-runtime";
2
2
  import { useMemo as B, useState as h, useEffect as z } from "react";
3
- import { S as M } from "./SingleCategorySettings-B406nnF-.mjs";
3
+ import { S as M } from "./SingleCategorySettings-C8xJ47_T.mjs";
4
4
  import { C as U } from "./configApi-BUXZOMWK.mjs";
5
- import { E as j } from "./ErrorBanner-CZXsHi3H.mjs";
6
- import { S as H } from "./StatsBar-D4v-I_Dj.mjs";
5
+ import { E as j } from "./ErrorBanner-lZJhCmDX.mjs";
6
+ import { S as H } from "./StatsBar-D4cOKG2e.mjs";
7
7
  const q = "https://github.com/conorholds/cedros-pay/tree/main/ui/docs/cross-channel-setup.md";
8
8
  function V({ title: e, description: i, steps: r }) {
9
9
  return /* @__PURE__ */ s(
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),L=require("./SingleCategorySettings-BqC2UXt3.js"),F=require("./configApi-BS5UJfzm.js"),W=require("./ErrorBanner-Cx2dUhps.js"),q=require("./StatsBar-m6GSRNxs.js"),O="https://github.com/conorholds/cedros-pay/tree/main/ui/docs/cross-channel-setup.md";function M({title:t,description:i,steps:n}){return e.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e7eb)",borderRadius:"0.75rem",padding:"1rem",background:"var(--cedros-admin-surface, #ffffff)"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:"0.35rem"},children:t}),e.jsx("div",{style:{color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.9rem",marginBottom:"0.75rem",lineHeight:1.5},children:i}),e.jsx("ol",{style:{margin:0,paddingLeft:"1.1rem",lineHeight:1.6,fontSize:"0.9rem"},children:n.map(o=>e.jsx("li",{children:o},o))})]})}function R({children:t}){return e.jsx("code",{style:{display:"block",padding:"0.65rem 0.75rem",background:"rgba(15, 23, 42, 0.04)",borderRadius:"0.5rem",marginTop:"0.5rem",wordBreak:"break-all"},children:t})}function z({serverUrl:t}){const i=`${t.replace(/\/$/,"")}/webhook/stripe`,n=`${t.replace(/\/$/,"")}/paywall/v1/native-store/apple/notifications`,o=`${t.replace(/\/$/,"")}/paywall/v1/native-store/google/notifications`,r=[{title:"Stripe Web Checkout",description:"Use this for website payments and any mobile redirect Checkout flows. Cedros owns the checkout session creation, but Stripe still needs your API keys and webhook endpoint configured.",steps:["Add your Stripe publishable key, secret key, and webhook signing secret in Payment Options → Stripe.","Create a Stripe webhook endpoint that sends subscription and checkout events to the Cedros webhook URL shown below.","If your app uses custom deep links for Stripe redirects, add the scheme in Stripe → allowed redirect schemes."]},{title:"Apple App Store Billing",description:"Use this for digital goods and subscriptions distributed through the Apple App Store. Cedros verifies purchases and handles server notifications, but you still need to create App Store Connect products and credentials.",steps:["In Products, map each store-managed product to its Apple product ID and choose the correct store-managed kind.","In Payment Options → App Stores, enter your App Store Server API issuer ID, key ID, private key, and bundle ID.","Create the matching products and subscriptions in App Store Connect, then point App Store Server Notifications at the Cedros Apple notification URL.","If you rely on reader, US external purchase link, or similar exceptions, configure those policies in the app build and only after Apple approves the relevant entitlement."]},{title:"Google Play Billing",description:"Use this for digital goods and subscriptions distributed through Google Play. Cedros verifies purchases, acknowledges them server-side, and processes RTDNs, but you still need Play Console catalog and service-account setup.",steps:["In Products, map each Play product ID and, for subscriptions, the package name, base plan ID, and optional offer ID.","In Payment Options → App Stores, enter your Google Play service-account email, private key, package name, push service-account email, and push audience.","Create the matching one-time products or subscriptions in Google Play Console and point RTDN delivery at the Cedros Google notification URL.","If you participate in User Choice Billing, Alternative Billing Only, or External Offers programs, configure those policies explicitly in the app build only for approved storefronts."]}];return e.jsxs("div",{style:{display:"grid",gap:"1rem",marginBottom:"1rem"},children:[e.jsxs("div",{style:{padding:"1rem",borderRadius:"0.75rem",background:"var(--cedros-admin-subtle, rgba(15, 23, 42, 0.03))",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:"0.4rem"},children:"Turnkey setup path"}),e.jsx("div",{style:{color:"var(--cedros-admin-text-muted, #64748b)",lineHeight:1.6,fontSize:"0.9rem"},children:"Create the product once in Cedros, configure each payment channel here, then point Stripe, App Store Connect, and Google Play Console at the Cedros endpoints below. Cedros packages can then load the same product catalog and apply the right rail at runtime."}),e.jsx(R,{children:i}),e.jsx(R,{children:n}),e.jsx(R,{children:o}),e.jsx("div",{style:{marginTop:"0.5rem",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.8rem",lineHeight:1.5},children:"Store notifications must target a tenant-specific Cedros deployment URL. If your deployment injects tenant context via domain, path prefix, or headers, use that tenant-scoped URL here instead of a generic shared endpoint."}),e.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",marginTop:"0.75rem",fontSize:"0.85rem",fontWeight:600,textDecoration:"underline",color:"inherit"},children:"Open the full cross-channel setup guide"})]}),e.jsx("div",{style:{display:"grid",gap:"1rem",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))"},children:r.map(a=>e.jsx(M,{...a},a.title))})]})}function p(t){return typeof t=="string"&&t.trim().length>0}function G(t){switch(t){case"complete":return"Complete";case"manual":return"Manual check";case"incomplete":default:return"Needs setup"}}function N(t){switch(t){case"complete":return{background:"rgba(34, 197, 94, 0.12)",color:"#166534",border:"rgba(34, 197, 94, 0.24)"};case"manual":return{background:"rgba(245, 158, 11, 0.12)",color:"#92400e",border:"rgba(245, 158, 11, 0.24)"};case"incomplete":default:return{background:"rgba(239, 68, 68, 0.12)",color:"#991b1b",border:"rgba(239, 68, 68, 0.24)"}}}function U(t){const i=t.metadata?.store_policy_fulfillment_type;if(i==="digital_in_app"||i==="physical_goods"||i==="real_world_service"||i==="reader_content"||i==="other")return i;switch(t.fulfillment?.type){case"shipping":return"physical_goods";case"service":return"real_world_service";case"digital_download":return"digital_in_app";default:return}}function H(t){let i=0,n=0,o=0,r=0,a=0;return t.forEach(d=>{if(U(d)!=="digital_in_app")return;i+=1;const s=d.storeBilling,x=!!s?.apple?.productId,y=!!s?.google?.productId,b=s?.kind==="auto_renewable_subscription"&&y,k=!!s?.google?.basePlanId;x&&y&&(!b||k)&&(n+=1),x||(o+=1),y||(r+=1),b&&!k&&(a+=1)}),{digitalCount:i,fullyMappedCount:n,missingAppleCount:o,missingGoogleCount:r,missingBasePlanCount:a}}function V(t){return t.some(i=>i.status==="incomplete")?"incomplete":t.some(i=>i.status==="manual")?"manual":"complete"}async function Q(t){const{serverUrl:i,apiKey:n,authManager:o}=t;if(o?.isAuthenticated())return(await o.fetchWithAuth("/admin/products?limit=500")).products??[];const r={"Content-Type":"application/json"};n&&(r["X-API-Key"]=n);const a=await fetch(`${i.replace(/\/$/,"")}/admin/products?limit=500`,{headers:r});if(!a.ok)throw new Error(`Failed to fetch products (${a.status})`);return(await a.json()).products??[]}function X({section:t}){const i=V(t.items),n=N(i);return e.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e7eb)",borderRadius:"0.75rem",padding:"1rem",background:"var(--cedros-admin-surface, #ffffff)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",marginBottom:"0.5rem"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700},children:t.title}),e.jsx("div",{style:{color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.9rem",lineHeight:1.5},children:t.description})]}),e.jsx("span",{style:{background:n.background,color:n.color,border:`1px solid ${n.border}`,borderRadius:"999px",padding:"0.2rem 0.6rem",fontSize:"0.78rem",fontWeight:600,whiteSpace:"nowrap"},children:G(i)})]}),e.jsx("div",{style:{display:"grid",gap:"0.65rem",marginTop:"0.85rem"},children:t.items.map(o=>{const r=N(o.status);return e.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e7eb)",borderRadius:"0.65rem",padding:"0.8rem",background:"rgba(15, 23, 42, 0.015)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",marginBottom:"0.35rem"},children:[e.jsx("div",{style:{fontWeight:600},children:o.title}),e.jsx("span",{style:{background:r.background,color:r.color,border:`1px solid ${r.border}`,borderRadius:"999px",padding:"0.15rem 0.5rem",fontSize:"0.75rem",fontWeight:600,whiteSpace:"nowrap"},children:G(o.status)})]}),e.jsx("div",{style:{color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.88rem",lineHeight:1.5},children:o.detail})]},`${t.title}-${o.title}`)})})]})}function J({serverUrl:t,apiKey:i,authManager:n}){const o=u.useMemo(()=>new F.ConfigApiClient(t,void 0,n),[t,n]),[r,a]=u.useState([]),[d,A]=u.useState({}),[s,x]=u.useState({}),[y,b]=u.useState(!0),[k,D]=u.useState(null),[B,E]=u.useState(0);u.useEffect(()=>{let l=!1;return(async()=>{b(!0),D(null);try{const[g,m,C]=await Promise.all([o.getConfig("stripe",!0),o.getConfig("native_store",!0),Q({serverUrl:t,apiKey:i,authManager:n})]);if(l)return;A(g.config??{}),x(m.config??{}),a(C)}catch(g){if(l)return;D(g instanceof Error?g.message:"Failed to load payment readiness data")}finally{l||b(!1)}})(),()=>{l=!0}},[i,n,o,B,t]);const v=u.useMemo(()=>{const l=p(d.secret_key)&&p(d.publishable_key),S=p(d.webhook_secret),g=s.apple_enabled===!0,m=g&&p(s.apple_issuer_id)&&p(s.apple_key_id)&&p(s.apple_private_key)&&p(s.apple_bundle_id),C=s.google_enabled===!0,h=C&&p(s.google_service_account_email)&&p(s.google_private_key)&&p(s.google_package_name)&&p(s.google_push_service_account_email)&&p(s.google_push_audience),{digitalCount:c,fullyMappedCount:P,missingAppleCount:j,missingGoogleCount:w,missingBasePlanCount:_}=H(r),$=[{title:"Website / Stripe",description:"Web checkout and browser-based mobile Stripe flows rely on your Stripe keys and webhook wiring.",items:[{title:"Stripe API keys",status:l?"complete":"incomplete",detail:l?"Publishable and secret keys are configured in Cedros.":"Add both the Stripe publishable key and secret key in Payment Options → Stripe."},{title:"Stripe webhook signing secret",status:S?"complete":"incomplete",detail:S?"Cedros has a webhook signing secret configured.":"Add the Stripe webhook signing secret so Cedros can trust subscription and checkout lifecycle events."},{title:"Stripe dashboard webhook endpoint",status:l&&S?"manual":"incomplete",detail:l&&S?`Confirm Stripe sends events to ${t.replace(/\/$/,"")}/webhook/stripe and that test events succeed.`:"Finish the Stripe config above, then create the webhook in Stripe Dashboard and point it at Cedros."}]},{title:"Apple App Store",description:"Apple digital goods require App Store billing plus matching App Store Connect catalog and server credentials.",items:[{title:"Apple native-store credentials",status:m?"complete":"incomplete",detail:m?"Issuer ID, key ID, private key, and bundle ID are configured.":g?"Apple billing is enabled, but Cedros is still missing one or more App Store Server API credentials.":"Enable Apple App Store billing and add the App Store Server API credentials in Payment Options → App Stores."},{title:"Apple product mapping",status:c===0?"manual":j===0?"complete":"incomplete",detail:c===0?"No digital in-app products are classified yet. Create or classify a digital product before shipping on the App Store.":j===0?`All ${c} digital in-app products have an Apple product ID.`:`${j} of ${c} digital in-app products still need an Apple product ID.`},{title:"App Store Connect server notifications",status:m?"manual":"incomplete",detail:m?`Confirm App Store Server Notifications point to ${t.replace(/\/$/,"")}/paywall/v1/native-store/apple/notifications using your tenant-scoped Cedros URL.`:"Finish the Apple credentials first, then configure App Store Server Notifications in App Store Connect."}]},{title:"Google Play",description:"Google digital goods require Play Billing plus Play Console product mapping, service-account access, and RTDN wiring.",items:[{title:"Google Play API and RTDN credentials",status:h?"complete":"incomplete",detail:h?"Service account, package name, RTDN push identity, and audience are configured.":C?"Google Play billing is enabled, but Cedros is still missing one or more API or RTDN verification fields.":"Enable Google Play billing and add the Android Publisher / RTDN credentials in Payment Options → App Stores."},{title:"Google product and base-plan mapping",status:c===0?"manual":w===0&&_===0?"complete":"incomplete",detail:c===0?"No digital in-app products are classified yet. Create or classify a digital product before shipping on Google Play.":w===0&&_===0?`All ${c} digital in-app products have a Google Play mapping${_===0?"":" and required base plans"}.`:`${w} products still need a Google product ID and ${_} subscription products still need a base plan ID.`},{title:"Play Console RTDN delivery",status:h?"manual":"incomplete",detail:h?`Confirm Real-time developer notifications are configured to reach ${t.replace(/\/$/,"")}/paywall/v1/native-store/google/notifications through your approved Pub/Sub push identity.`:"Finish the Google Play credentials first, then configure RTDN delivery in Google Play Console and Google Cloud Pub/Sub."}]},{title:"Cedros product catalog",description:"Cedros packages can only route correctly when the catalog itself is classified and mapped cleanly.",items:[{title:"Products created in Cedros",status:r.length>0?"complete":"incomplete",detail:r.length>0?`${r.length} products are present in the Cedros catalog.`:"Create at least one product in Admin → Products."},{title:"Digital product app-store mapping coverage",status:c===0?"manual":P===c?"complete":"incomplete",detail:c===0?"No digital in-app products are currently classified. If you sell only physical goods or real-world services, this is expected.":`${P} of ${c} digital in-app products currently have both Apple/Google mapping requirements satisfied.`},{title:"Manual end-to-end store test purchases",status:l||m||h?"manual":"incomplete",detail:l||m||h?"Run at least one website purchase, one App Store sandbox purchase, and one Google Play test purchase before shipping.":"Finish the payment channel setup first, then run real test purchases through every channel you plan to support."}]}];return{sections:$,stats:{products:r.length,digitalProducts:c,fullyMappedProducts:P,autoVerifiedChecks:$.flatMap(I=>I.items).filter(I=>I.status==="complete").length}}},[s,r,t,d]);return e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{marginBottom:"1rem"},children:[e.jsx("h3",{className:"cedros-admin__page-title",children:"Readiness Checklist"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Cedros can verify configuration and product mapping automatically, but external console wiring and test purchases still require a human check."})]}),e.jsx(W.ErrorBanner,{message:k,onRetry:()=>{E(l=>l+1)}}),e.jsx(q.StatsBar,{stats:[{label:"Products",value:v.stats.products},{label:"Digital App Products",value:v.stats.digitalProducts},{label:"Fully Mapped",value:v.stats.fullyMappedProducts},{label:"Auto-Verified Checks",value:v.stats.autoVerifiedChecks}],isLoading:y}),e.jsx("div",{style:{display:"grid",gap:"1rem",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",marginTop:"1rem"},children:v.sections.map(l=>e.jsx(X,{section:l},l.title))})]})}function f({href:t,children:i}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:i})}const T=[{id:"app_stores",label:"App Stores",category:"native_store",description:e.jsx(e.Fragment,{children:"Configure Apple App Store and Google Play verification, lifecycle notifications, and server credentials. Use the setup guide below to connect App Store Connect and Google Play Console to Cedros."})},{id:"stripe",label:"Stripe",category:"stripe",description:e.jsxs(e.Fragment,{children:["Configure your Stripe integration for card payments. Get your API keys from the"," ",e.jsx(f,{href:"https://dashboard.stripe.com/apikeys",children:"Stripe Dashboard"}),"."]})},{id:"crypto",label:"Crypto",category:"x402",description:e.jsxs(e.Fragment,{children:["Configure Solana wallet and token settings for crypto payments. Get a fast RPC endpoint from"," ",e.jsx(f,{href:"https://www.helius.dev",children:"Helius"})," or"," ",e.jsx(f,{href:"https://www.quicknode.com/chains/sol",children:"QuickNode"}),". Set up a payment address using"," ",e.jsx(f,{href:"https://phantom.app",children:"Phantom"})," or"," ",e.jsx(f,{href:"https://solflare.com",children:"Solflare"})," wallet."]})},{id:"credits",label:"Credits",category:"cedros_login",description:e.jsxs(e.Fragment,{children:["Configure Cedros Login integration for credits payments. See the"," ",e.jsx(f,{href:"https://docs.cedros.dev/credits",children:"Credits API documentation"}),"."]})}];function K({serverUrl:t,apiKey:i,authManager:n}){const[o,r]=u.useState("app_stores"),a=T.find(d=>d.id===o);return e.jsxs("div",{className:"cedros-admin__payment-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Payment Options"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure the payment rails Cedros can use across web, iOS, Android, and crypto flows."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:T.map(d=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${o===d.id?"cedros-admin__tab--active":""}`,onClick:()=>r(d.id),children:d.label},d.id))}),e.jsxs("div",{style:{marginTop:"1rem"},children:[o==="app_stores"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{serverUrl:t}),e.jsx(J,{serverUrl:t,apiKey:i,authManager:n})]}),e.jsx(L.SingleCategorySettings,{serverUrl:t,apiKey:i,authManager:n,category:a.category,title:`${a.label} Settings`,description:a.description,showEnabledToggle:!0},a.category)]})]})}exports.PaymentSettingsSection=K;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("react"),L=require("./SingleCategorySettings-g7D-9lG1.js"),F=require("./configApi-BS5UJfzm.js"),W=require("./ErrorBanner-CAgPnj62.js"),q=require("./StatsBar-CWXw2ZT3.js"),O="https://github.com/conorholds/cedros-pay/tree/main/ui/docs/cross-channel-setup.md";function M({title:t,description:i,steps:n}){return e.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e7eb)",borderRadius:"0.75rem",padding:"1rem",background:"var(--cedros-admin-surface, #ffffff)"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:"0.35rem"},children:t}),e.jsx("div",{style:{color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.9rem",marginBottom:"0.75rem",lineHeight:1.5},children:i}),e.jsx("ol",{style:{margin:0,paddingLeft:"1.1rem",lineHeight:1.6,fontSize:"0.9rem"},children:n.map(o=>e.jsx("li",{children:o},o))})]})}function R({children:t}){return e.jsx("code",{style:{display:"block",padding:"0.65rem 0.75rem",background:"rgba(15, 23, 42, 0.04)",borderRadius:"0.5rem",marginTop:"0.5rem",wordBreak:"break-all"},children:t})}function z({serverUrl:t}){const i=`${t.replace(/\/$/,"")}/webhook/stripe`,n=`${t.replace(/\/$/,"")}/paywall/v1/native-store/apple/notifications`,o=`${t.replace(/\/$/,"")}/paywall/v1/native-store/google/notifications`,r=[{title:"Stripe Web Checkout",description:"Use this for website payments and any mobile redirect Checkout flows. Cedros owns the checkout session creation, but Stripe still needs your API keys and webhook endpoint configured.",steps:["Add your Stripe publishable key, secret key, and webhook signing secret in Payment Options → Stripe.","Create a Stripe webhook endpoint that sends subscription and checkout events to the Cedros webhook URL shown below.","If your app uses custom deep links for Stripe redirects, add the scheme in Stripe → allowed redirect schemes."]},{title:"Apple App Store Billing",description:"Use this for digital goods and subscriptions distributed through the Apple App Store. Cedros verifies purchases and handles server notifications, but you still need to create App Store Connect products and credentials.",steps:["In Products, map each store-managed product to its Apple product ID and choose the correct store-managed kind.","In Payment Options → App Stores, enter your App Store Server API issuer ID, key ID, private key, and bundle ID.","Create the matching products and subscriptions in App Store Connect, then point App Store Server Notifications at the Cedros Apple notification URL.","If you rely on reader, US external purchase link, or similar exceptions, configure those policies in the app build and only after Apple approves the relevant entitlement."]},{title:"Google Play Billing",description:"Use this for digital goods and subscriptions distributed through Google Play. Cedros verifies purchases, acknowledges them server-side, and processes RTDNs, but you still need Play Console catalog and service-account setup.",steps:["In Products, map each Play product ID and, for subscriptions, the package name, base plan ID, and optional offer ID.","In Payment Options → App Stores, enter your Google Play service-account email, private key, package name, push service-account email, and push audience.","Create the matching one-time products or subscriptions in Google Play Console and point RTDN delivery at the Cedros Google notification URL.","If you participate in User Choice Billing, Alternative Billing Only, or External Offers programs, configure those policies explicitly in the app build only for approved storefronts."]}];return e.jsxs("div",{style:{display:"grid",gap:"1rem",marginBottom:"1rem"},children:[e.jsxs("div",{style:{padding:"1rem",borderRadius:"0.75rem",background:"var(--cedros-admin-subtle, rgba(15, 23, 42, 0.03))",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsx("div",{style:{fontWeight:700,marginBottom:"0.4rem"},children:"Turnkey setup path"}),e.jsx("div",{style:{color:"var(--cedros-admin-text-muted, #64748b)",lineHeight:1.6,fontSize:"0.9rem"},children:"Create the product once in Cedros, configure each payment channel here, then point Stripe, App Store Connect, and Google Play Console at the Cedros endpoints below. Cedros packages can then load the same product catalog and apply the right rail at runtime."}),e.jsx(R,{children:i}),e.jsx(R,{children:n}),e.jsx(R,{children:o}),e.jsx("div",{style:{marginTop:"0.5rem",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.8rem",lineHeight:1.5},children:"Store notifications must target a tenant-specific Cedros deployment URL. If your deployment injects tenant context via domain, path prefix, or headers, use that tenant-scoped URL here instead of a generic shared endpoint."}),e.jsx("a",{href:O,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",marginTop:"0.75rem",fontSize:"0.85rem",fontWeight:600,textDecoration:"underline",color:"inherit"},children:"Open the full cross-channel setup guide"})]}),e.jsx("div",{style:{display:"grid",gap:"1rem",gridTemplateColumns:"repeat(auto-fit, minmax(260px, 1fr))"},children:r.map(a=>e.jsx(M,{...a},a.title))})]})}function p(t){return typeof t=="string"&&t.trim().length>0}function G(t){switch(t){case"complete":return"Complete";case"manual":return"Manual check";case"incomplete":default:return"Needs setup"}}function N(t){switch(t){case"complete":return{background:"rgba(34, 197, 94, 0.12)",color:"#166534",border:"rgba(34, 197, 94, 0.24)"};case"manual":return{background:"rgba(245, 158, 11, 0.12)",color:"#92400e",border:"rgba(245, 158, 11, 0.24)"};case"incomplete":default:return{background:"rgba(239, 68, 68, 0.12)",color:"#991b1b",border:"rgba(239, 68, 68, 0.24)"}}}function U(t){const i=t.metadata?.store_policy_fulfillment_type;if(i==="digital_in_app"||i==="physical_goods"||i==="real_world_service"||i==="reader_content"||i==="other")return i;switch(t.fulfillment?.type){case"shipping":return"physical_goods";case"service":return"real_world_service";case"digital_download":return"digital_in_app";default:return}}function H(t){let i=0,n=0,o=0,r=0,a=0;return t.forEach(d=>{if(U(d)!=="digital_in_app")return;i+=1;const s=d.storeBilling,x=!!s?.apple?.productId,y=!!s?.google?.productId,b=s?.kind==="auto_renewable_subscription"&&y,k=!!s?.google?.basePlanId;x&&y&&(!b||k)&&(n+=1),x||(o+=1),y||(r+=1),b&&!k&&(a+=1)}),{digitalCount:i,fullyMappedCount:n,missingAppleCount:o,missingGoogleCount:r,missingBasePlanCount:a}}function V(t){return t.some(i=>i.status==="incomplete")?"incomplete":t.some(i=>i.status==="manual")?"manual":"complete"}async function Q(t){const{serverUrl:i,apiKey:n,authManager:o}=t;if(o?.isAuthenticated())return(await o.fetchWithAuth("/admin/products?limit=500")).products??[];const r={"Content-Type":"application/json"};n&&(r["X-API-Key"]=n);const a=await fetch(`${i.replace(/\/$/,"")}/admin/products?limit=500`,{headers:r});if(!a.ok)throw new Error(`Failed to fetch products (${a.status})`);return(await a.json()).products??[]}function X({section:t}){const i=V(t.items),n=N(i);return e.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e7eb)",borderRadius:"0.75rem",padding:"1rem",background:"var(--cedros-admin-surface, #ffffff)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"1rem",marginBottom:"0.5rem"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:700},children:t.title}),e.jsx("div",{style:{color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.9rem",lineHeight:1.5},children:t.description})]}),e.jsx("span",{style:{background:n.background,color:n.color,border:`1px solid ${n.border}`,borderRadius:"999px",padding:"0.2rem 0.6rem",fontSize:"0.78rem",fontWeight:600,whiteSpace:"nowrap"},children:G(i)})]}),e.jsx("div",{style:{display:"grid",gap:"0.65rem",marginTop:"0.85rem"},children:t.items.map(o=>{const r=N(o.status);return e.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e7eb)",borderRadius:"0.65rem",padding:"0.8rem",background:"rgba(15, 23, 42, 0.015)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1rem",marginBottom:"0.35rem"},children:[e.jsx("div",{style:{fontWeight:600},children:o.title}),e.jsx("span",{style:{background:r.background,color:r.color,border:`1px solid ${r.border}`,borderRadius:"999px",padding:"0.15rem 0.5rem",fontSize:"0.75rem",fontWeight:600,whiteSpace:"nowrap"},children:G(o.status)})]}),e.jsx("div",{style:{color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.88rem",lineHeight:1.5},children:o.detail})]},`${t.title}-${o.title}`)})})]})}function J({serverUrl:t,apiKey:i,authManager:n}){const o=u.useMemo(()=>new F.ConfigApiClient(t,void 0,n),[t,n]),[r,a]=u.useState([]),[d,A]=u.useState({}),[s,x]=u.useState({}),[y,b]=u.useState(!0),[k,D]=u.useState(null),[B,E]=u.useState(0);u.useEffect(()=>{let l=!1;return(async()=>{b(!0),D(null);try{const[g,m,C]=await Promise.all([o.getConfig("stripe",!0),o.getConfig("native_store",!0),Q({serverUrl:t,apiKey:i,authManager:n})]);if(l)return;A(g.config??{}),x(m.config??{}),a(C)}catch(g){if(l)return;D(g instanceof Error?g.message:"Failed to load payment readiness data")}finally{l||b(!1)}})(),()=>{l=!0}},[i,n,o,B,t]);const v=u.useMemo(()=>{const l=p(d.secret_key)&&p(d.publishable_key),S=p(d.webhook_secret),g=s.apple_enabled===!0,m=g&&p(s.apple_issuer_id)&&p(s.apple_key_id)&&p(s.apple_private_key)&&p(s.apple_bundle_id),C=s.google_enabled===!0,h=C&&p(s.google_service_account_email)&&p(s.google_private_key)&&p(s.google_package_name)&&p(s.google_push_service_account_email)&&p(s.google_push_audience),{digitalCount:c,fullyMappedCount:P,missingAppleCount:j,missingGoogleCount:w,missingBasePlanCount:_}=H(r),$=[{title:"Website / Stripe",description:"Web checkout and browser-based mobile Stripe flows rely on your Stripe keys and webhook wiring.",items:[{title:"Stripe API keys",status:l?"complete":"incomplete",detail:l?"Publishable and secret keys are configured in Cedros.":"Add both the Stripe publishable key and secret key in Payment Options → Stripe."},{title:"Stripe webhook signing secret",status:S?"complete":"incomplete",detail:S?"Cedros has a webhook signing secret configured.":"Add the Stripe webhook signing secret so Cedros can trust subscription and checkout lifecycle events."},{title:"Stripe dashboard webhook endpoint",status:l&&S?"manual":"incomplete",detail:l&&S?`Confirm Stripe sends events to ${t.replace(/\/$/,"")}/webhook/stripe and that test events succeed.`:"Finish the Stripe config above, then create the webhook in Stripe Dashboard and point it at Cedros."}]},{title:"Apple App Store",description:"Apple digital goods require App Store billing plus matching App Store Connect catalog and server credentials.",items:[{title:"Apple native-store credentials",status:m?"complete":"incomplete",detail:m?"Issuer ID, key ID, private key, and bundle ID are configured.":g?"Apple billing is enabled, but Cedros is still missing one or more App Store Server API credentials.":"Enable Apple App Store billing and add the App Store Server API credentials in Payment Options → App Stores."},{title:"Apple product mapping",status:c===0?"manual":j===0?"complete":"incomplete",detail:c===0?"No digital in-app products are classified yet. Create or classify a digital product before shipping on the App Store.":j===0?`All ${c} digital in-app products have an Apple product ID.`:`${j} of ${c} digital in-app products still need an Apple product ID.`},{title:"App Store Connect server notifications",status:m?"manual":"incomplete",detail:m?`Confirm App Store Server Notifications point to ${t.replace(/\/$/,"")}/paywall/v1/native-store/apple/notifications using your tenant-scoped Cedros URL.`:"Finish the Apple credentials first, then configure App Store Server Notifications in App Store Connect."}]},{title:"Google Play",description:"Google digital goods require Play Billing plus Play Console product mapping, service-account access, and RTDN wiring.",items:[{title:"Google Play API and RTDN credentials",status:h?"complete":"incomplete",detail:h?"Service account, package name, RTDN push identity, and audience are configured.":C?"Google Play billing is enabled, but Cedros is still missing one or more API or RTDN verification fields.":"Enable Google Play billing and add the Android Publisher / RTDN credentials in Payment Options → App Stores."},{title:"Google product and base-plan mapping",status:c===0?"manual":w===0&&_===0?"complete":"incomplete",detail:c===0?"No digital in-app products are classified yet. Create or classify a digital product before shipping on Google Play.":w===0&&_===0?`All ${c} digital in-app products have a Google Play mapping${_===0?"":" and required base plans"}.`:`${w} products still need a Google product ID and ${_} subscription products still need a base plan ID.`},{title:"Play Console RTDN delivery",status:h?"manual":"incomplete",detail:h?`Confirm Real-time developer notifications are configured to reach ${t.replace(/\/$/,"")}/paywall/v1/native-store/google/notifications through your approved Pub/Sub push identity.`:"Finish the Google Play credentials first, then configure RTDN delivery in Google Play Console and Google Cloud Pub/Sub."}]},{title:"Cedros product catalog",description:"Cedros packages can only route correctly when the catalog itself is classified and mapped cleanly.",items:[{title:"Products created in Cedros",status:r.length>0?"complete":"incomplete",detail:r.length>0?`${r.length} products are present in the Cedros catalog.`:"Create at least one product in Admin → Products."},{title:"Digital product app-store mapping coverage",status:c===0?"manual":P===c?"complete":"incomplete",detail:c===0?"No digital in-app products are currently classified. If you sell only physical goods or real-world services, this is expected.":`${P} of ${c} digital in-app products currently have both Apple/Google mapping requirements satisfied.`},{title:"Manual end-to-end store test purchases",status:l||m||h?"manual":"incomplete",detail:l||m||h?"Run at least one website purchase, one App Store sandbox purchase, and one Google Play test purchase before shipping.":"Finish the payment channel setup first, then run real test purchases through every channel you plan to support."}]}];return{sections:$,stats:{products:r.length,digitalProducts:c,fullyMappedProducts:P,autoVerifiedChecks:$.flatMap(I=>I.items).filter(I=>I.status==="complete").length}}},[s,r,t,d]);return e.jsxs("div",{style:{marginBottom:"1rem"},children:[e.jsxs("div",{className:"cedros-admin__page-header",style:{marginBottom:"1rem"},children:[e.jsx("h3",{className:"cedros-admin__page-title",children:"Readiness Checklist"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Cedros can verify configuration and product mapping automatically, but external console wiring and test purchases still require a human check."})]}),e.jsx(W.ErrorBanner,{message:k,onRetry:()=>{E(l=>l+1)}}),e.jsx(q.StatsBar,{stats:[{label:"Products",value:v.stats.products},{label:"Digital App Products",value:v.stats.digitalProducts},{label:"Fully Mapped",value:v.stats.fullyMappedProducts},{label:"Auto-Verified Checks",value:v.stats.autoVerifiedChecks}],isLoading:y}),e.jsx("div",{style:{display:"grid",gap:"1rem",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",marginTop:"1rem"},children:v.sections.map(l=>e.jsx(X,{section:l},l.title))})]})}function f({href:t,children:i}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"},children:i})}const T=[{id:"app_stores",label:"App Stores",category:"native_store",description:e.jsx(e.Fragment,{children:"Configure Apple App Store and Google Play verification, lifecycle notifications, and server credentials. Use the setup guide below to connect App Store Connect and Google Play Console to Cedros."})},{id:"stripe",label:"Stripe",category:"stripe",description:e.jsxs(e.Fragment,{children:["Configure your Stripe integration for card payments. Get your API keys from the"," ",e.jsx(f,{href:"https://dashboard.stripe.com/apikeys",children:"Stripe Dashboard"}),"."]})},{id:"crypto",label:"Crypto",category:"x402",description:e.jsxs(e.Fragment,{children:["Configure Solana wallet and token settings for crypto payments. Get a fast RPC endpoint from"," ",e.jsx(f,{href:"https://www.helius.dev",children:"Helius"})," or"," ",e.jsx(f,{href:"https://www.quicknode.com/chains/sol",children:"QuickNode"}),". Set up a payment address using"," ",e.jsx(f,{href:"https://phantom.app",children:"Phantom"})," or"," ",e.jsx(f,{href:"https://solflare.com",children:"Solflare"})," wallet."]})},{id:"credits",label:"Credits",category:"cedros_login",description:e.jsxs(e.Fragment,{children:["Configure Cedros Login integration for credits payments. See the"," ",e.jsx(f,{href:"https://docs.cedros.dev/credits",children:"Credits API documentation"}),"."]})}];function K({serverUrl:t,apiKey:i,authManager:n}){const[o,r]=u.useState("app_stores"),a=T.find(d=>d.id===o);return e.jsxs("div",{className:"cedros-admin__payment-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Payment Options"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure the payment rails Cedros can use across web, iOS, Android, and crypto flows."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:T.map(d=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${o===d.id?"cedros-admin__tab--active":""}`,onClick:()=>r(d.id),children:d.label},d.id))}),e.jsxs("div",{style:{marginTop:"1rem"},children:[o==="app_stores"&&e.jsxs(e.Fragment,{children:[e.jsx(z,{serverUrl:t}),e.jsx(J,{serverUrl:t,apiKey:i,authManager:n})]}),e.jsx(L.SingleCategorySettings,{serverUrl:t,apiKey:i,authManager:n,category:a.category,title:`${a.label} Settings`,description:a.description,showEnabledToggle:!0},a.category)]})]})}exports.PaymentSettingsSection=K;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),A=require("./icons-Cjgd9YVo.js"),q=require("./ErrorBanner-CAgPnj62.js"),p=require("./dateHelpers-BKW_lGND.js"),w=["requested","approved","rejected","received","refunded"],I=s=>{switch(s){case"approved":return"success";case"refunded":return"success";case"rejected":return"failed";case"received":return"muted";case"requested":return"pending";default:return"muted"}};function D({returnRequest:s,onBack:h,onStatusUpdated:c,onError:u,fetchWithAuth:a}){const[r,g]=d.useState(s.status),[m,j]=d.useState(!1),l=async()=>{if(!(!r||r===s.status)){j(!0);try{const n=await a(`/admin/returns/${encodeURIComponent(s.id)}/status`,{method:"PUT",body:JSON.stringify({status:r})});c(n)}catch{u("Failed to update return status")}finally{j(!1)}}};return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:h,style:{marginBottom:"1rem"},children:"← Back to returns"}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Return ",e.jsx("code",{style:{fontSize:"0.8rem"},children:s.id.slice(0,12)}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(s.status)}`,style:{marginLeft:"0.5rem"},children:s.status})]})}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px",marginBottom:"1rem"},children:e.jsx("table",{className:"cedros-admin__table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"35%"},children:"Order ID"}),e.jsx("td",{children:e.jsx("code",{children:s.orderId})})]}),s.reason&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Reason"}),e.jsx("td",{children:s.reason})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Created"}),e.jsx("td",{children:p.formatDateTime(s.createdAt)})]}),s.statusUpdatedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Status Updated"}),e.jsx("td",{children:p.formatDateTime(s.statusUpdatedAt)})]}),s.updatedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Last Updated"}),e.jsx("td",{children:p.formatDateTime(s.updatedAt)})]})]})})}),e.jsxs("h4",{style:{fontSize:"0.85rem",fontWeight:600,margin:"0 0 0.5rem"},children:["Items (",s.items.length,")"]}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px",marginBottom:"1.25rem"},children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Product ID"}),e.jsx("th",{children:"Variant ID"}),e.jsx("th",{children:"Qty"})]})}),e.jsx("tbody",{children:s.items.map((n,o)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{style:{fontSize:"0.75rem"},children:n.productId})}),e.jsx("td",{children:n.variantId?e.jsx("code",{style:{fontSize:"0.75rem"},children:n.variantId}):e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:n.quantity})]},o))})]})}),Object.keys(s.metadata).length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{style:{fontSize:"0.85rem",fontWeight:600,margin:"0 0 0.5rem"},children:"Metadata"}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px",marginBottom:"1.25rem"},children:e.jsx("table",{className:"cedros-admin__table",children:e.jsx("tbody",{children:Object.entries(s.metadata).map(([n,o])=>e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"40%"},children:n}),e.jsx("td",{children:o})]},n))})})})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",maxWidth:"400px"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Update Status"}),e.jsx("select",{className:"cedros-admin__input",value:r,onChange:n=>g(n.target.value),children:w.map(n=>e.jsx("option",{value:n,children:n},n))})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:l,disabled:m||r===s.status,children:m?"Updating...":"Update"})]})]})}function T({serverUrl:s,apiKey:h,pageSize:c=20,authManager:u}){const[a,r]=d.useState([]),[g,m]=d.useState(!0),[j,l]=d.useState(null),[n,o]=d.useState(0),[_,R]=d.useState("all"),[S,y]=d.useState(null),[C,v]=d.useState(!1),f=d.useCallback(async(t,i)=>{if(u?.isAuthenticated())return u.fetchWithAuth(t,i);const x={"Content-Type":"application/json"};h&&(x["X-API-Key"]=h);const b=await fetch(`${s}${t}`,{...i,headers:{...x,...i?.headers}});if(!b.ok)throw new Error(`Request failed: ${b.status}`);return b.json()},[s,h,u]),N=d.useCallback(async()=>{m(!0),l(null);try{const t=new URLSearchParams;t.set("limit",String(c)),t.set("offset",String(n)),_!=="all"&&t.set("status",_);const i=await f(`/admin/returns?${t.toString()}`);r(i.returns??[])}catch{l("Failed to load returns"),r([])}finally{m(!1)}},[f,c,n,_]);d.useEffect(()=>{N()},[N]);const U=async t=>{v(!0),l(null);try{const i=await f(`/admin/returns/${encodeURIComponent(t)}`);y(i)}catch{l("Failed to load return details")}finally{v(!1)}},W=t=>{y(t),r(i=>i.map(x=>x.id===t.id?t:x))};return S?e.jsx(D,{returnRequest:S,onBack:()=>y(null),onStatusUpdated:W,onError:l,fetchWithAuth:f}):e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Returns"})}),e.jsx(q.ErrorBanner,{message:j}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",value:_,onChange:t=>{R(t.target.value),o(0)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),w.map(t=>e.jsx("option",{value:t,children:t.charAt(0).toUpperCase()+t.slice(1)},t))]}),e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:[a.length," result",a.length!==1?"s":""]})]}),g||C?e.jsxs("div",{className:"cedros-admin__loading",children:[A.Icons.loading," Loading returns..."]}):a.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No returns found."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Order ID"}),e.jsx("th",{children:"Items"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:a.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{style:{fontSize:"0.75rem"},children:t.orderId})}),e.jsx("td",{children:t.items.length}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})}),e.jsx("td",{style:{maxWidth:"180px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.reason??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:p.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>U(t.id),children:"View"})})]},t.id))})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"0.75rem",fontSize:"0.85rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:n===0,onClick:()=>o(Math.max(0,n-c)),children:"Previous"}),e.jsxs("span",{children:["Showing ",a.length," return",a.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:a.length<c,onClick:()=>o(n+c),children:"Next"})]})]})]})}exports.ReturnsSection=T;
@@ -1,7 +1,7 @@
1
1
  import { jsx as e, jsxs as n, Fragment as U } from "react/jsx-runtime";
2
2
  import { useState as l, useCallback as R, useEffect as D } from "react";
3
- import { I as O } from "./sectionIds-DBavltrL.mjs";
4
- import { E as $ } from "./ErrorBanner-CZXsHi3H.mjs";
3
+ import { I as O } from "./icons-C3yDMnKE.mjs";
4
+ import { E as $ } from "./ErrorBanner-lZJhCmDX.mjs";
5
5
  import { f as b } from "./dateHelpers-yvPkofYQ.mjs";
6
6
  const C = ["requested", "approved", "rejected", "received", "refunded"], W = (d) => {
7
7
  switch (d) {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),d=require("./SingleCategorySettings-BqC2UXt3.js"),r=[{id:"logging",label:"Logging",category:"logging",description:"Configure log levels, format, and environment settings."},{id:"metrics",label:"Metrics",category:"metrics",description:"Configure metrics collection and API access for monitoring."},{id:"security",label:"Security",category:"security",description:"Configure CORS, rate limiting, and other security settings."},{id:"storage",label:"Storage",category:"storage",description:"Configure S3-compatible storage for product images."}];function l({serverUrl:n,apiKey:o,authManager:c}){const[s,a]=g.useState("logging"),t=r.find(i=>i.id===s);return e.jsxs("div",{className:"cedros-admin__server-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Server"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure logging, metrics, security, and storage settings."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:r.map(i=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${s===i.id?"cedros-admin__tab--active":""}`,onClick:()=>a(i.id),children:i.label},i.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(d.SingleCategorySettings,{serverUrl:n,apiKey:o,authManager:c,category:t.category,title:`${t.label} Settings`,description:t.description},t.category)})]})}exports.SettingsSection=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),d=require("./SingleCategorySettings-g7D-9lG1.js"),r=[{id:"logging",label:"Logging",category:"logging",description:"Configure log levels, format, and environment settings."},{id:"metrics",label:"Metrics",category:"metrics",description:"Configure metrics collection and API access for monitoring."},{id:"security",label:"Security",category:"security",description:"Configure CORS, rate limiting, and other security settings."},{id:"storage",label:"Storage",category:"storage",description:"Configure S3-compatible storage for product images."}];function l({serverUrl:n,apiKey:o,authManager:c}){const[s,a]=g.useState("logging"),t=r.find(i=>i.id===s);return e.jsxs("div",{className:"cedros-admin__server-settings",children:[e.jsxs("div",{className:"cedros-admin__page-header",children:[e.jsx("h2",{className:"cedros-admin__page-title",children:"Store Server"}),e.jsx("p",{className:"cedros-admin__page-description",children:"Configure logging, metrics, security, and storage settings."})]}),e.jsx("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:r.map(i=>e.jsx("button",{type:"button",className:`cedros-admin__tab ${s===i.id?"cedros-admin__tab--active":""}`,onClick:()=>a(i.id),children:i.label},i.id))}),e.jsx("div",{style:{marginTop:"1rem"},children:e.jsx(d.SingleCategorySettings,{serverUrl:n,apiKey:o,authManager:c,category:t.category,title:`${t.label} Settings`,description:t.description},t.category)})]})}exports.SettingsSection=l;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as s, jsx as i } from "react/jsx-runtime";
2
2
  import { useState as g } from "react";
3
- import { S as l } from "./SingleCategorySettings-B406nnF-.mjs";
3
+ import { S as l } from "./SingleCategorySettings-C8xJ47_T.mjs";
4
4
  const o = [
5
5
  {
6
6
  id: "logging",
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),z=require("./icons-Cjgd9YVo.js"),v=require("./ErrorBanner-CAgPnj62.js"),q=require("./dateHelpers-BKW_lGND.js"),W={name:"",description:"",countries:"",active:!0},J={name:"",rateType:"flat",amountAtomic:"",currency:"USD",minSubtotal:"",maxSubtotal:"",active:!0},A=(x,u)=>`${u.toUpperCase()} ${(x/100).toFixed(2)}`;function te({serverUrl:x,apiKey:u,authManager:S}){const[R,E]=a.useState([]),[M,P]=a.useState(!0),[w,h]=a.useState(null),[I,r]=a.useState(null),[G,_]=a.useState(!1),[f,b]=a.useState(null),[o,c]=a.useState(W),[k,T]=a.useState(!1),[n,F]=a.useState(null),[D,U]=a.useState([]),[H,$]=a.useState(!1),[K,m]=a.useState(!1),[g,p]=a.useState(null),[i,d]=a.useState(J),[B,L]=a.useState(!1),l=a.useCallback(async(t,s)=>{if(S?.isAuthenticated())return S.fetchWithAuth(t,s);const j={"Content-Type":"application/json"};u&&(j["X-API-Key"]=u);const C=await fetch(`${x}${t}`,{...s,headers:{...j,...s?.headers}});if(!C.ok)throw new Error(`Request failed: ${C.status}`);return C.json()},[x,u,S]),y=a.useCallback(async()=>{P(!0),h(null);try{const t=await l("/admin/shipping/profiles?limit=50&offset=0");E(t.profiles??[])}catch{h("Failed to load shipping profiles"),E([])}finally{P(!1)}},[l]);a.useEffect(()=>{y()},[y]);const X=t=>{b(t),c({name:t.name,description:t.description??"",countries:t.countries.join(", "),active:t.active}),_(!0)},Q=async t=>{t.preventDefault(),T(!0),r(null);try{const s={name:o.name,description:o.description||void 0,countries:o.countries.split(",").map(j=>j.trim()).filter(Boolean),active:o.active};f?await l(`/admin/shipping/profiles/${encodeURIComponent(f.id)}`,{method:"PUT",body:JSON.stringify(s)}):await l("/admin/shipping/profiles",{method:"POST",body:JSON.stringify(s)}),_(!1),b(null),y()}catch(s){r(s instanceof Error?s.message:"Failed to save profile")}finally{T(!1)}},V=async t=>{if(window.confirm("Delete this shipping profile?")){r(null);try{await l(`/admin/shipping/profiles/${encodeURIComponent(t)}`,{method:"DELETE"}),y()}catch{r("Failed to delete profile")}}},N=a.useCallback(async t=>{$(!0),h(null);try{const s=await l(`/admin/shipping/profiles/${encodeURIComponent(t.id)}/rates?limit=50&offset=0`);U(s.rates??[])}catch{h("Failed to load rates"),U([])}finally{$(!1)}},[l]),O=t=>{F(t),m(!1),p(null),N(t)},Y=t=>{p(t),d({name:t.name,rateType:t.rateType,amountAtomic:String(t.amountAtomic),currency:t.currency,minSubtotal:t.minSubtotal!=null?String(t.minSubtotal):"",maxSubtotal:t.maxSubtotal!=null?String(t.maxSubtotal):"",active:t.active}),m(!0)},Z=async t=>{if(t.preventDefault(),!!n){L(!0),r(null);try{const s={name:i.name,rateType:i.rateType,amountAtomic:parseInt(i.amountAtomic,10),currency:i.currency,active:i.active,profileId:n.id,minSubtotal:i.minSubtotal?parseInt(i.minSubtotal,10):void 0,maxSubtotal:i.maxSubtotal?parseInt(i.maxSubtotal,10):void 0};g?await l(`/admin/shipping/rates/${encodeURIComponent(g.id)}`,{method:"PUT",body:JSON.stringify(s)}):await l(`/admin/shipping/profiles/${encodeURIComponent(n.id)}/rates`,{method:"POST",body:JSON.stringify(s)}),m(!1),p(null),N(n)}catch(s){r(s instanceof Error?s.message:"Failed to save rate")}finally{L(!1)}}},ee=async t=>{if(!(!window.confirm("Delete this rate?")||!n)){r(null);try{await l(`/admin/shipping/rates/${encodeURIComponent(t)}`,{method:"DELETE"}),N(n)}catch{r("Failed to delete rate")}}};return n?e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>{F(null),m(!1),h(null),r(null)},style:{marginBottom:"1rem"},children:"← Back to profiles"}),e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("h3",{className:"cedros-admin__section-title",children:[n.name,e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${n.active?"success":"muted"}`,style:{marginLeft:"0.5rem"},children:n.active?"Active":"Inactive"})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{p(null),d(J),m(!0)},children:"+ Add Rate"})]}),e.jsx(v.ErrorBanner,{message:w}),e.jsx(v.ErrorBanner,{message:I}),e.jsxs("p",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)",margin:"0 0 1rem"},children:[n.description&&e.jsxs(e.Fragment,{children:[n.description," · "]}),"Countries: ",n.countries.length>0?n.countries.join(", "):"All"]}),K&&e.jsxs("form",{onSubmit:Z,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"520px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:g?"Edit Rate":"New Rate"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",required:!0,value:i.name,onChange:t=>d(s=>({...s,name:t.target.value})),placeholder:"Standard Shipping"})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Rate Type *"}),e.jsxs("select",{className:"cedros-admin__input",value:i.rateType,onChange:t=>d(s=>({...s,rateType:t.target.value})),children:[e.jsx("option",{value:"flat",children:"Flat"}),e.jsx("option",{value:"price",children:"Price-based"}),e.jsx("option",{value:"weight",children:"Weight-based"})]})]}),e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Amount (atomic) *"}),e.jsx("input",{type:"number",className:"cedros-admin__input",required:!0,min:0,value:i.amountAtomic,onChange:t=>d(s=>({...s,amountAtomic:t.target.value})),placeholder:"500"})]}),e.jsxs("div",{className:"cedros-admin__field",style:{width:"80px"},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Currency"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.currency,maxLength:3,onChange:t=>d(s=>({...s,currency:t.target.value.toUpperCase()})),placeholder:"USD"})]})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Min Subtotal"}),e.jsx("input",{type:"number",className:"cedros-admin__input",min:0,value:i.minSubtotal,onChange:t=>d(s=>({...s,minSubtotal:t.target.value})),placeholder:"0"})]}),e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max Subtotal"}),e.jsx("input",{type:"number",className:"cedros-admin__input",min:0,value:i.maxSubtotal,onChange:t=>d(s=>({...s,maxSubtotal:t.target.value})),placeholder:"10000"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("input",{type:"checkbox",id:"rate-active",checked:i.active,onChange:t=>d(s=>({...s,active:t.target.checked}))}),e.jsx("label",{htmlFor:"rate-active",className:"cedros-admin__field-label",style:{margin:0},children:"Active"})]})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:B,children:B?"Saving...":g?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>{m(!1),p(null)},children:"Cancel"})]})]}),H?e.jsxs("div",{className:"cedros-admin__loading",children:[z.Icons.loading," Loading rates..."]}):D.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No rates yet. Add one above."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Min / Max Subtotal"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:D.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.rateType}),e.jsx("td",{style:{fontSize:"0.85rem"},children:A(t.amountAtomic,t.currency)}),e.jsxs("td",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)"},children:[t.minSubtotal!=null?A(t.minSubtotal,t.currency):"—"," / ",t.maxSubtotal!=null?A(t.maxSubtotal,t.currency):"—"]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.active?"success":"muted"}`,children:t.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:q.formatDateTime(t.updatedAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>Y(t),children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>ee(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Shipping"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{b(null),c(W),_(!0)},children:"+ Add Profile"})]}),e.jsx(v.ErrorBanner,{message:w}),e.jsx(v.ErrorBanner,{message:I}),G&&e.jsxs("form",{onSubmit:Q,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:f?"Edit Profile":"New Profile"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",required:!0,value:o.name,onChange:t=>c(s=>({...s,name:t.target.value})),placeholder:"Domestic Shipping"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:o.description,onChange:t=>c(s=>({...s,description:t.target.value})),placeholder:"Optional description"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Countries (comma-separated ISO codes)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:o.countries,onChange:t=>c(s=>({...s,countries:t.target.value})),placeholder:"US, CA, GB"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem"},children:[e.jsx("input",{type:"checkbox",id:"profile-active",checked:o.active,onChange:t=>c(s=>({...s,active:t.target.checked}))}),e.jsx("label",{htmlFor:"profile-active",className:"cedros-admin__field-label",style:{margin:0},children:"Active"})]})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:k,children:k?"Saving...":f?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>{_(!1),b(null)},children:"Cancel"})]})]}),M?e.jsxs("div",{className:"cedros-admin__loading",children:[z.Icons.loading," Loading profiles..."]}):R.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No shipping profiles 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:"Name"}),e.jsx("th",{children:"Countries"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:R.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("button",{type:"button",style:{background:"none",border:"none",cursor:"pointer",fontWeight:600,padding:0,color:"var(--cedros-admin-text, #333)",fontSize:"0.9rem"},onClick:()=>O(t),children:t.name})}),e.jsx("td",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.countries.length>0?t.countries.join(", "):"All"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.active?"success":"muted"}`,children:t.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:q.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>O(t),children:"Rates"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>X(t),children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>V(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]})}exports.ShippingSection=te;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as a, jsx as t, Fragment as ae } from "react/jsx-runtime";
2
2
  import { useState as l, useCallback as w, useEffect as ne } from "react";
3
- import { I as q } from "./sectionIds-DBavltrL.mjs";
4
- import { E as x } from "./ErrorBanner-CZXsHi3H.mjs";
3
+ import { I as q } from "./icons-C3yDMnKE.mjs";
4
+ import { E as x } from "./ErrorBanner-lZJhCmDX.mjs";
5
5
  import { f as J } from "./dateHelpers-yvPkofYQ.mjs";
6
6
  const M = { name: "", description: "", countries: "", active: !0 }, G = { name: "", rateType: "flat", amountAtomic: "", currency: "USD", minSubtotal: "", maxSubtotal: "", active: !0 }, P = (f, h) => `${h.toUpperCase()} ${(f / 100).toFixed(2)}`;
7
7
  function ce({ serverUrl: f, apiKey: h, authManager: C }) {
@@ -1,11 +1,11 @@
1
1
  import { jsxs as i, jsx as r, Fragment as W } from "react/jsx-runtime";
2
2
  import { useState as S, useEffect as j, useMemo as H, useCallback as z } from "react";
3
- import { I as E } from "./sectionIds-DBavltrL.mjs";
4
- import { E as Q } from "./ErrorBanner-CZXsHi3H.mjs";
3
+ import { I as E } from "./icons-C3yDMnKE.mjs";
4
+ import { E as Q } from "./ErrorBanner-lZJhCmDX.mjs";
5
5
  import { R as B, i as P, a as Z, C as L } from "./configApi-BUXZOMWK.mjs";
6
6
  import { u as ee } from "./useAutosave-YwMqRzqy.mjs";
7
- import { A as re } from "./AutosaveIndicator-BEvABoKU.mjs";
8
- import { F as te } from "./Dropdown-B90Zabxr.mjs";
7
+ import { A as re } from "./AutosaveIndicator-3ctAnz8Y.mjs";
8
+ import { F as te } from "./Dropdown-BRSZlhik.mjs";
9
9
  import { S as F } from "./tokenMintValidator-DAjQld0r.mjs";
10
10
  import { f as ne } from "./dateHelpers-yvPkofYQ.mjs";
11
11
  const ie = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
@@ -0,0 +1,3 @@
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),k=require("./icons-Cjgd9YVo.js"),K=require("./ErrorBanner-CAgPnj62.js"),N=require("./configApi-BS5UJfzm.js"),L=require("./useAutosave-B2p6iwh8.js"),$=require("./AutosaveIndicator-DXRPr4P7.js"),J=require("./Dropdown-j8o0OO5L.js"),V=require("./tokenMintValidator-DNBhoefh.js"),P=require("./dateHelpers-BKW_lGND.js"),Z=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function M(b){return!b||b.trim()===""?{valid:!0}:Z.test(b.trim())?{valid:!0}:{valid:!1,error:"Invalid Solana address"}}function X({label:b,value:f,onChange:h,decimals:n,onDecimalsChange:j,disabled:o=!1,description:a,customSymbol:d="",customIcon:u="",onCustomSymbolChange:c,onCustomIconChange:x}){const[v,E]=l.useState(!1),p=Object.entries(V.STABLECOIN_METADATA),y=!!V.STABLECOIN_METADATA[f],S=v||!!f&&!y,C=t=>{if(t==="custom")E(!0),y&&h("");else{E(!1),h(t);const s=V.STABLECOIN_METADATA[t];s&&j&&j(s.decimals),c&&c(""),x&&x("")}};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:b}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"0.5rem"},children:[p.map(([t,s])=>e.jsxs("button",{type:"button",onClick:()=>C(t),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:f===t?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:f===t?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:f===t?600:400},children:[e.jsx("img",{src:s.icon,alt:s.symbol,style:{width:20,height:20,borderRadius:"50%"},onError:r=>{r.target.style.display="none"}}),e.jsx("span",{children:s.symbol})]},t)),e.jsxs("button",{type:"button",onClick:()=>C("custom"),disabled:o,style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem 0.75rem",border:S?"2px solid var(--cedros-admin-primary, #171717)":"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem",background:S?"var(--cedros-admin-primary-bg, #f5f5f5)":"var(--cedros-admin-bg, #fff)",cursor:o?"not-allowed":"pointer",opacity:o?.5:1,fontWeight:S?600:400},children:[e.jsx("span",{style:{fontSize:"1rem"},children:"+"}),e.jsx("span",{children:"Custom"})]})]}),S&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",padding:"1rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.5rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Mint Address"}),(()=>{const t=M(f);return e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${t.valid?"":"cedros-admin__input--error"}`,value:f,onChange:s=>h(s.target.value),placeholder:"e.g., EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",disabled:o,style:{fontFamily:"monospace",fontSize:"0.875rem",borderColor:t.valid?void 0:"var(--cedros-admin-error, #dc2626)"}}),!t.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:t.error})]})})()]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:d,onChange:t=>c?.(t.target.value),placeholder:"e.g., MYTOKEN",disabled:o,style:{textTransform:"uppercase"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Icon URL"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:u,onChange:t=>x?.(t.target.value),placeholder:"https://example.com/token-logo.png",disabled:o,style:{flex:1}}),u&&e.jsx("img",{src:u,alt:"Token icon preview",style:{width:32,height:32,borderRadius:"50%",border:"1px solid var(--cedros-admin-border, #e5e7eb)",objectFit:"cover"},onError:t=>{t.target.style.display="none"}})]}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Shown to customers during checkout"})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.75rem",fontWeight:500,marginBottom:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)"},children:"Token Decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n??6,onChange:t=>j?.(parseInt(t.target.value,10)||0),min:0,max:18,disabled:o,style:{width:"100px"}}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #94a3b8)",marginTop:"0.25rem"},children:"Most SPL tokens use 6 decimals (like USDC)"})]})]}),f&&y&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",fontFamily:"monospace",wordBreak:"break-all"},children:f}),a&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:a})]})]})}function Y({label:b,value:f,onChange:h,disabled:n=!1,description:j}){const[o,a]=l.useState(new Set),[d,u]=l.useState(null),[c,x]=l.useState(""),v=Array.isArray(f)?f:[],E=t=>{a(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},p=()=>{h([...v,""]),u(v.length),x("")},I=(t,s)=>{const r=[...v];r[t]=s,h(r)},y=t=>{const s=v.filter((r,g)=>g!==t);h(s),a(r=>{const g=new Set;return r.forEach(_=>{_<t?g.add(_):_>t&&g.add(_-1)}),g})},T=t=>{u(t),x(v[t]||"")},S=()=>{d!==null&&(I(d,c),u(null),x(""))},C=()=>{d!==null&&v[d]===""&&y(d),u(null),x("")};return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[e.jsx("label",{className:"cedros-admin__field-label",style:{marginBottom:0},children:b}),e.jsxs("button",{type:"button",onClick:p,disabled:n,style:{display:"flex",alignItems:"center",gap:"0.25rem",padding:"0.25rem 0.5rem",fontSize:"0.75rem",border:"1px solid var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.375rem",background:"var(--cedros-admin-bg, #fff)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1},children:[k.Icons.plus,"Add"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[v.length===0&&e.jsx("div",{style:{padding:"1rem",textAlign:"center",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"0.875rem",border:"1px dashed var(--cedros-admin-border, #d4d4d4)",borderRadius:"0.5rem"},children:'No items. Click "Add" to create one.'}),v.map((t,s)=>{const r=o.has(s),g=d===s,_=t===N.REDACTED_VALUE;return e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",padding:"0.5rem",background:"var(--cedros-admin-bg-muted, #f9fafb)",borderRadius:"0.375rem",border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:g?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"cedros-admin__input",value:c,onChange:i=>x(i.target.value),placeholder:"Enter wallet keypair...",autoFocus:!0,style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem"},onKeyDown:i=>{i.key==="Enter"&&S(),i.key==="Escape"&&C()}}),e.jsx("button",{type:"button",onClick:S,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-success, #22c55e)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Save",children:k.Icons.check}),e.jsx("button",{type:"button",onClick:C,style:{padding:"0.375rem",border:"none",background:"var(--cedros-admin-text-muted, #64748b)",color:"#fff",borderRadius:"0.25rem",cursor:"pointer"},title:"Cancel",children:k.Icons.close})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{flex:1,fontFamily:"monospace",fontSize:"0.75rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r&&!_?t:_?"[REDACTED]":"••••••••••••••••••••"}),e.jsx("button",{type:"button",onClick:()=>E(s),disabled:n||_,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n||_?"not-allowed":"pointer",opacity:n||_?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:r?"Hide":"Show",children:r?k.Icons.eyeOff:k.Icons.eye}),e.jsx("button",{type:"button",onClick:()=>T(s),disabled:n,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,color:"var(--cedros-admin-text-muted, #64748b)"},title:"Edit",children:k.Icons.settings}),e.jsx("button",{type:"button",onClick:()=>y(s),disabled:n,style:{padding:"0.375rem",border:"none",background:"transparent",cursor:n?"not-allowed":"pointer",opacity:n?.5:1,color:"var(--cedros-admin-error, #ef4444)"},title:"Delete",children:k.Icons.trash})]})},s)})]}),j&&e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.5rem"},children:j})]})}function H(b,f,h){const n=N.isSecretField(b,f),j=f.replace(/_/g," ").replace(/\b\w/g,u=>u.toUpperCase()),a=N.CONFIG_CATEGORIES[b]?.fields?.[f],d={isSecret:n,label:j,description:a?.description,hidden:a?.hidden,showWhen:a?.showWhen};return a?.type==="dropdown"&&a.options?{...d,type:"dropdown",options:a.options}:a?.type==="token_mint"?{...d,type:"token_mint"}:a?.type==="toggle"?{...d,type:"toggle"}:a?.type==="secret_array"?{...d,type:"secret_array",isSecret:!0}:a?.type==="solana_address"?{...d,type:"solana_address"}:a?.type==="number"?{...d,type:"number",unit:a.unit}:typeof h=="boolean"?{...d,type:"boolean"}:typeof h=="number"?{...d,type:"number",unit:a?.unit}:Array.isArray(h)?{...d,type:"array"}:typeof h=="object"&&h!==null?{...d,type:"object"}:{...d,type:"string"}}function Q({category:b,config:f,originalConfig:h,isLoading:n=!1,onSave:j}){const[o,a]=l.useState(f),[d,u]=l.useState(new Set);l.useEffect(()=>{a(f)},[f]);const c=l.useMemo(()=>{const t={...o};for(const s of Object.keys(t))if(N.isSecretField(b,s)){const r=h[s],g=t[s];(g===N.REDACTED_VALUE||g===r)&&(t[s]=N.REDACTED_VALUE)}return t},[o,h,b]),x=l.useMemo(()=>{const t=o.token_mint;return typeof t!="string"||!t?!1:!M(t).valid},[o]),{status:v,error:E}=L.useAutosave({data:c,onSave:j,debounceMs:1500,enabled:!x}),p=l.useCallback((t,s)=>{a(r=>({...r,[t]:s}))},[]),I=l.useCallback(t=>{u(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},[]),y=t=>t?e.jsx("div",{style:{fontSize:"0.75rem",color:"var(--cedros-admin-text-muted, #64748b)",marginTop:"0.25rem"},children:t}):null,T=(t,s)=>{const r=H(b,t,h[t]??s);if(r.type==="dropdown"&&r.options)return e.jsx(J.FormDropdown,{value:s,onChange:i=>p(t,i),options:r.options.map(i=>({value:i,label:i})),label:r.label,description:r.description,disabled:n});if(r.type==="token_mint")return e.jsx(X,{label:r.label,value:s,onChange:i=>p(t,i),decimals:o.token_decimals??6,onDecimalsChange:i=>p("token_decimals",i),disabled:n,description:r.description,customSymbol:o.custom_token_symbol||"",customIcon:o.custom_token_icon||"",onCustomSymbolChange:i=>p("custom_token_symbol",i),onCustomIconChange:i=>p("custom_token_icon",i)});if(r.type==="toggle")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("button",{type:"button",role:"switch","aria-checked":s,onClick:()=>p(t,!s),disabled:n,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:s?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:n?"not-allowed":"pointer",position:"relative",transition:"background-color 0.2s",opacity:n?.5:1,flexShrink:0},children:e.jsx("span",{style:{position:"absolute",top:2,left:s?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})}),e.jsx("span",{className:"cedros-admin__field-label",style:{marginBottom:0},children:r.label})]}),y(r.description)]});if(r.type==="solana_address"){const i=s||"",w=M(i);return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{type:"text",className:`cedros-admin__input ${w.valid?"":"cedros-admin__input--error"}`,value:i,onChange:D=>p(t,D.target.value),disabled:n,placeholder:"e.g. 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",style:{width:"100%",fontFamily:"monospace",fontSize:"0.875rem",borderColor:w.valid?void 0:"var(--cedros-admin-error, #dc2626)",paddingRight:i&&w.valid?"2rem":void 0}}),i&&w.valid&&e.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",color:"var(--cedros-admin-success, #16a34a)",fontSize:"1rem"},title:"Valid Solana address",children:"✓"})]}),!w.valid&&e.jsx("span",{style:{color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.75rem",marginTop:"0.25rem",display:"block"},children:w.error}),y(r.description)]})}if(r.type==="boolean")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__checkbox",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:i=>p(t,i.target.checked),disabled:n}),r.label]}),y(r.description)]});if(r.type==="number")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.unit&&e.jsxs("span",{className:"cedros-admin__field-unit",children:[" (",r.unit,")"]})]}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s,onChange:i=>p(t,parseFloat(i.target.value)||0),disabled:n}),y(r.description)]});if(r.type==="secret_array")return e.jsx(Y,{label:r.label,value:s,onChange:i=>p(t,i),disabled:n,description:r.description});if(r.type==="array"){const i=s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea",value:i.join(`
2
+ `),onChange:w=>p(t,w.target.value.split(`
3
+ `).filter(Boolean)),placeholder:"One item per line",rows:3,disabled:n}),y(r.description)]})}if(r.type==="object")return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:r.label}),e.jsx("textarea",{className:"cedros-admin__textarea cedros-admin__textarea--mono",value:JSON.stringify(s,null,2),onChange:i=>{try{p(t,JSON.parse(i.target.value))}catch{}},rows:5,disabled:n}),y(r.description)]});const g=d.has(t),_=r.isSecret&&!g&&s===N.REDACTED_VALUE?N.REDACTED_VALUE:s;return e.jsxs("div",{className:"cedros-admin__field",children:[e.jsxs("label",{className:"cedros-admin__field-label",children:[r.label,r.isSecret&&e.jsx("span",{className:"cedros-admin__field-secret",children:" (secret)"})]}),e.jsxs("div",{className:"cedros-admin__input-group",children:[e.jsx("input",{type:r.isSecret&&!g?"password":"text",className:"cedros-admin__input",value:_,onChange:i=>p(t,i.target.value),disabled:n,placeholder:r.isSecret?"••••••••":""}),r.isSecret&&e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>I(t),style:{padding:"0.5rem",minWidth:"auto"},title:g?"Hide":"Show",children:g?k.Icons.eyeOff:k.Icons.eye})]}),y(r.description)]})},S=Object.keys(o),C=t=>{const s=H(b,t,h[t]??o[t]);if(s.hidden||s.showWhen&&!o[s.showWhen])return!1;if(t==="token_decimals"){const r=o.token_mint;if(r&&V.STABLECOIN_METADATA[r])return!1}return!0};return e.jsxs("div",{className:"cedros-admin__config-editor",children:[e.jsx("div",{className:"cedros-admin__config-fields",children:S.filter(C).map(t=>e.jsx("div",{className:"cedros-admin__config-field",children:T(t,o[t])},t))}),e.jsx("div",{className:"cedros-admin__config-actions",children:e.jsx("div",{className:"cedros-admin__autosave-status",children:e.jsx($.AutosaveIndicator,{status:v,error:E})})})]})}function ee({serverUrl:b,apiKey:f,authManager:h,category:n,title:j,description:o,enabledField:a="enabled",showEnabledToggle:d=!1}){const u=l.useMemo(()=>new N.ConfigApiClient(b,void 0,h),[b,h]),[c,x]=l.useState(null),[v,E]=l.useState([]),[p,I]=l.useState(!1),[y,T]=l.useState(!0),[S,C]=l.useState(null),[t,s]=l.useState(null),[r,g]=l.useState(!1),_=N.CONFIG_CATEGORIES[n]||{label:n,icon:"⚙️"},i=j||_.label,w=o||_.description,D=l.useCallback(async()=>{T(!0),C(null);try{const m=await u.getConfig(n,!0);x(m)}catch{x(null),C("Failed to load settings")}finally{T(!1)}},[u,n]);l.useEffect(()=>{D()},[D]);const B=l.useCallback(async()=>{try{const m=await u.getHistory(n,20);E(m.history)}catch{E([])}},[u,n]);l.useEffect(()=>{p&&B()},[p,B]);const U=l.useCallback(async m=>{await u.updateConfig(n,m,"Updated via admin dashboard")},[u,n]),F=l.useCallback(async m=>u.validateConfig(n,m),[u,n]),[z,O]=l.useState(!1),G=l.useCallback(async()=>{if(!c||z)return;const m=!!c.config[a],R=!m,W={...c.config,[a]:R};O(!0),x({...c,config:W});try{await u.updateConfig(n,W,`${R?"Enabled":"Disabled"} via admin dashboard`)}catch(q){x({...c,config:{...c.config,[a]:m}}),C(q instanceof Error?q.message:"Failed to save enabled state")}finally{O(!1)}},[c,u,n,a,z]),A=!!c?.config[a];return y&&!c?e.jsx("div",{className:"cedros-admin__section",children:e.jsxs("div",{className:"cedros-admin__loading",children:[k.Icons.loading," Loading ",i," settings..."]})}):e.jsxs("div",{className:"cedros-admin__section",children:[e.jsx(K.ErrorBanner,{message:S,onRetry:D}),e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"cedros-admin__section-title",children:[e.jsx("span",{style:{marginRight:"0.5rem"},children:_.icon}),i]}),w&&e.jsx("p",{className:"cedros-admin__text-muted",style:{marginTop:"0.25rem"},children:w})]}),d&&c&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("span",{style:{fontSize:"0.875rem",color:A?"var(--cedros-admin-text, #171717)":"var(--cedros-admin-muted, #737373)"},children:A?"Enabled":"Disabled"}),e.jsx("button",{type:"button",role:"switch","aria-checked":A,onClick:G,disabled:z,style:{width:44,height:24,borderRadius:12,border:"none",backgroundColor:A?"var(--cedros-admin-primary, #171717)":"var(--cedros-admin-border, #d4d4d4)",cursor:z?"wait":"pointer",position:"relative",transition:"background-color 0.2s",flexShrink:0,opacity:z?.6:1},children:e.jsx("span",{style:{position:"absolute",top:2,left:A?22:2,width:20,height:20,borderRadius:"50%",backgroundColor:"#fff",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})]}),c&&e.jsxs("div",{className:"cedros-admin__settings-editor",style:{marginTop:"1rem",opacity:d&&!A?.6:1,pointerEvents:d&&!A?"none":"auto"},children:[d&&!A&&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)",pointerEvents:"auto"},children:"This payment method is disabled. Enable it using the toggle above to accept payments."}),e.jsx(Q,{category:c.category,config:c.config,originalConfig:c.config,onSave:U,onValidate:F})]}),p&&e.jsxs("div",{className:"cedros-admin__settings-history",style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{marginBottom:"0.75rem",fontWeight:600},children:"Change History"}),v.length===0?e.jsx("p",{className:"cedros-admin__text-muted",children:"No history entries found."}):e.jsx("div",{className:"cedros-admin__settings-timeline",children:v.map(m=>e.jsxs("div",{className:"cedros-admin__settings-timeline-item",children:[e.jsx("div",{className:"cedros-admin__settings-timeline-dot"}),e.jsxs("div",{className:"cedros-admin__settings-timeline-content",children:[e.jsxs("div",{className:"cedros-admin__settings-timeline-header",children:[e.jsx("code",{children:m.configKey}),e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${m.action.toLowerCase()}`,children:m.action})]}),e.jsxs("div",{className:"cedros-admin__settings-timeline-meta",children:[P.formatDateTime(m.changedAt)," by ",m.changedBy]})]})]},m.id))})]}),t&&e.jsx("div",{style:{marginTop:"1rem",padding:"0.75rem 1rem",borderRadius:"0.375rem",backgroundColor:t.valid?"var(--cedros-admin-success-bg, #dcfce7)":"var(--cedros-admin-error-bg, #fef2f2)",border:`1px solid ${t.valid?"var(--cedros-admin-success-border, #86efac)":"var(--cedros-admin-error-border, #fecaca)"}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:600,color:t.valid?"var(--cedros-admin-success, #16a34a)":"var(--cedros-admin-error, #dc2626)",marginBottom:t.errors.length>0||t.warnings.length>0?"0.5rem":0},children:t.valid?"✓ Configuration is valid":"✗ Validation failed"}),t.errors.length>0&&e.jsx("ul",{style:{margin:0,paddingLeft:"1.25rem",color:"var(--cedros-admin-error, #dc2626)",fontSize:"0.875rem"},children:t.errors.map((m,R)=>e.jsx("li",{children:m},R))}),t.warnings.length>0&&e.jsx("ul",{style:{margin:t.errors.length>0?"0.5rem 0 0":0,paddingLeft:"1.25rem",color:"var(--cedros-admin-warning, #ca8a04)",fontSize:"0.875rem"},children:t.warnings.map((m,R)=>e.jsx("li",{children:m},R))})]}),e.jsx("button",{type:"button",onClick:()=>s(null),style:{background:"none",border:"none",cursor:"pointer",padding:"0.25rem",color:"var(--cedros-admin-text-muted, #64748b)",fontSize:"1.25rem",lineHeight:1},title:"Dismiss",children:"×"})]})}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>I(!p),children:p?"Hide History":"History"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r||!c,onClick:async()=>{if(c){g(!0),s(null);try{const m=await F(c.config);s(m)}catch(m){s({valid:!1,errors:[m instanceof Error?m.message:"Validation failed"],warnings:[]})}finally{g(!1)}}},children:r?"Validating...":"Validate"})]})]})}exports.SingleCategorySettings=ee;
@@ -0,0 +1 @@
1
+ "use strict";const s=require("react/jsx-runtime"),n=require("./icons-Cjgd9YVo.js");function i({stats:c,isLoading:e=!1,onRefresh:r}){return s.jsxs("div",{className:"cedros-admin__stats-bar",children:[s.jsx("div",{className:"cedros-admin__stats-bar-grid",children:c.map((a,d)=>s.jsxs("div",{className:"cedros-admin__stats-bar-item",children:[s.jsx("span",{className:"cedros-admin__stats-bar-label",children:a.label}),s.jsx("span",{className:`cedros-admin__stats-bar-value ${a.variant?`cedros-admin__stats-bar-value--${a.variant}`:""}`,children:e?s.jsx("span",{className:"cedros-admin__skeleton cedros-admin__skeleton--value"}):a.value}),a.description&&s.jsx("span",{className:"cedros-admin__stats-bar-desc",children:a.description})]},d))}),r&&s.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:r,disabled:e,title:"Refresh stats",children:e?n.Icons.loading:n.Icons.refresh})]})}exports.StatsBar=i;
@@ -1,5 +1,5 @@
1
1
  import { jsxs as d, jsx as s } from "react/jsx-runtime";
2
- import { I as n } from "./sectionIds-DBavltrL.mjs";
2
+ import { I as n } from "./icons-C3yDMnKE.mjs";
3
3
  function m({ stats: c, isLoading: e = !1, onRefresh: r }) {
4
4
  return /* @__PURE__ */ d("div", { className: "cedros-admin__stats-bar", children: [
5
5
  /* @__PURE__ */ s("div", { className: "cedros-admin__stats-bar-grid", children: c.map((a, i) => /* @__PURE__ */ d("div", { className: "cedros-admin__stats-bar-item", children: [
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),O=require("./icons-Cjgd9YVo.js"),q=require("./ErrorBanner-CAgPnj62.js"),j=require("./Dropdown-j8o0OO5L.js"),o=require("./Toggle-CsPSF8Dr.js"),M=require("./useAutosave-B2p6iwh8.js"),$=require("./AutosaveIndicator-DXRPr4P7.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:""}},H=[{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"}],V=[{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 X({serverUrl:g,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),[D,u]=l.useState(null),y=l.useCallback(async()=>{try{u(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(`${g}${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),u("Could not load saved settings. Showing defaults.")}finally{z(!1),setTimeout(()=>B(!1),100)}},[g,d,c]);l.useEffect(()=>{y()},[y]);const L=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(`${g}${s}`,{method:"PUT",headers:n,body:r});if(!p.ok)throw new Error(`Failed to save settings: ${p.status}`)}}catch{throw u("Failed to save storefront settings"),new Error("Save failed")}},[g,d,c]),{status:N,error:R}=M.useAutosave({data:a,onSave:L,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}}}))},x=(t,s)=>{i(r=>({...r,catalog:{...r.catalog,filters:{...r.catalog.filters,[t]:s}}}))},f=(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}}))},h=(t,s)=>{i(r=>({...r,sections:{...r.sections,[t]:s}}))},v=(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:[O.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:[V.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($.AutosaveIndicator,{status:N,error:R})]}),e.jsx(q.ErrorBanner,{message:D,onRetry:y}),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=>x("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=>x("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=>x("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=>f("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=>f("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=>f("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(j.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(j.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:H.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(j.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=>h("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=>h("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=>h("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=>h("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=>v("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=>v("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=>v("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=X;
@@ -1,11 +1,11 @@
1
1
  import { jsx as t, jsxs as r } from "react/jsx-runtime";
2
2
  import { useState as h, useCallback as z, useEffect as j } from "react";
3
- import { I as H } from "./sectionIds-DBavltrL.mjs";
4
- import { E as V } from "./ErrorBanner-CZXsHi3H.mjs";
5
- import { F as x } from "./Dropdown-B90Zabxr.mjs";
3
+ import { I as H } from "./icons-C3yDMnKE.mjs";
4
+ import { E as V } from "./ErrorBanner-lZJhCmDX.mjs";
5
+ import { F as x } from "./Dropdown-BRSZlhik.mjs";
6
6
  import { T as d } from "./Toggle-DAxIdpY4.mjs";
7
7
  import { u as q } from "./useAutosave-YwMqRzqy.mjs";
8
- import { A as X } from "./AutosaveIndicator-BEvABoKU.mjs";
8
+ import { A as X } from "./AutosaveIndicator-3ctAnz8Y.mjs";
9
9
  const C = {
10
10
  enabled: !0,
11
11
  relatedProducts: {
@@ -1,8 +1,8 @@
1
1
  import { jsx as a, jsxs as i } from "react/jsx-runtime";
2
2
  import { useState as g, useCallback as F, useEffect as D, useMemo as E } from "react";
3
- import { I as h } from "./sectionIds-DBavltrL.mjs";
4
- import { E as Z } from "./ErrorBanner-CZXsHi3H.mjs";
5
- import { S as K } from "./StatsBar-D4v-I_Dj.mjs";
3
+ import { I as h } from "./icons-C3yDMnKE.mjs";
4
+ import { E as Z } from "./ErrorBanner-lZJhCmDX.mjs";
5
+ import { S as K } from "./StatsBar-D4cOKG2e.mjs";
6
6
  const l = {
7
7
  enabled: !1,
8
8
  plans: [],
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),m=require("./icons-Cjgd9YVo.js"),X=require("./ErrorBanner-CAgPnj62.js"),Y=require("./StatsBar-CWXw2ZT3.js"),i={enabled:!1,plans:[],pageTitle:"Choose Your Plan",pageSubtitle:"Select the plan that best fits your needs.",annualSavingsBadge:"2 months free",popularBadgeText:"Best Deal",footerNotice:""},G={title:"New Plan",description:"",priceMonthlyUsd:0,priceAnnualUsd:0,features:[],featureHighlight:"",buttonText:"Purchase",isPopular:!1,isActive:!0,sortOrder:0};function V(){return`plan_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Z({serverUrl:v,apiKey:b,authManager:f}){const[r,h]=d.useState(i),[_,R]=d.useState(!0),[k,T]=d.useState(null),[u,A]=d.useState("plans"),[y,B]=d.useState("idle"),[z,S]=d.useState(null),[l,g]=d.useState({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),[x,P]=d.useState(l),[E,C]=d.useState(""),w=d.useCallback(async()=>{try{S(null);let e;const t="/admin/subscriptions/settings";if(f?.isAuthenticated())e=await f.fetchWithAuth(t);else{const n={"Content-Type":"application/json"};b&&(n["X-API-Key"]=b);const s=await fetch(`${v}${t}`,{headers:n});if(!s.ok)throw new Error(`Failed to fetch settings: ${s.status}`);e=await s.json()}h({...i,...e}),g({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),P({enabled:e.enabled??i.enabled,pageTitle:e.pageTitle??i.pageTitle,pageSubtitle:e.pageSubtitle??i.pageSubtitle,annualSavingsBadge:e.annualSavingsBadge??i.annualSavingsBadge,popularBadgeText:e.popularBadgeText??i.popularBadgeText,footerNotice:e.footerNotice??i.footerNotice}),C(JSON.stringify(e.plans??[]))}catch{h(i),g({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),P({enabled:i.enabled,pageTitle:i.pageTitle,pageSubtitle:i.pageSubtitle,annualSavingsBadge:i.annualSavingsBadge,popularBadgeText:i.popularBadgeText,footerNotice:i.footerNotice}),C(JSON.stringify([])),S("Failed to load subscription settings")}finally{R(!1)}},[v,b,f]);d.useEffect(()=>{w()},[w]);const F=d.useCallback(async e=>{try{S(null);const t="/admin/subscriptions/settings",n=JSON.stringify(e);if(f?.isAuthenticated())await f.fetchWithAuth(t,{method:"PUT",body:n});else{const s={"Content-Type":"application/json"};b&&(s["X-API-Key"]=b);const o=await fetch(`${v}${t}`,{method:"PUT",headers:s,body:n});if(!o.ok)throw new Error(`Failed to save settings: ${o.status}`)}return!0}catch{return S("Failed to save subscription settings"),!1}},[f,b,v]),I=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(()=>E!==D,[D,E]),j=d.useCallback(async()=>{const e={...r,enabled:l.enabled,pageTitle:l.pageTitle,pageSubtitle:l.pageSubtitle,annualSavingsBadge:l.annualSavingsBadge,popularBadgeText:l.popularBadgeText,footerNotice:l.footerNotice};B("saving");const t=await F(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,F,r]);d.useEffect(()=>{if(u!=="page"||_||!I)return;const e=setTimeout(j,600);return()=>clearTimeout(e)},[u,I,_,j]),d.useEffect(()=>{if(u!=="plans"||_||!U)return;const e=setTimeout(j,800);return()=>clearTimeout(e)},[u,U,_,j]);const O=()=>{const e={...G,id:V(),sortOrder:r.plans.length};h(t=>({...t,plans:[...t.plans,e]})),T(e.id)},c=(e,t)=>{h(n=>({...n,plans:n.plans.map(s=>s.id===e?{...s,...t}:s)}))},H=e=>{confirm("Delete this plan? This cannot be undone.")&&(h(t=>({...t,plans:t.plans.filter(n=>n.id!==e)})),k===e&&T(null))},$=(e,t)=>{const n=r.plans.findIndex(p=>p.id===e);if(n===-1||t==="up"&&n===0||t==="down"&&n===r.plans.length-1)return;const s=[...r.plans],o=t==="up"?n-1:n+1;[s[n],s[o]]=[s[o],s[n]],h(p=>({...p,plans:s}))},q=e=>{c(e,{features:[...r.plans.find(t=>t.id===e)?.features||[],""]})},Q=(e,t,n)=>{const s=r.plans.find(p=>p.id===e);if(!s)return;const o=[...s.features];o[t]=n,c(e,{features:o})},J=(e,t)=>{const n=r.plans.find(o=>o.id===e);if(!n)return;const s=n.features.filter((o,p)=>p!==t);c(e,{features:s})};if(_)return a.jsx("div",{className:"cedros-admin__page",children:a.jsxs("div",{className:"cedros-admin__loading",children:[m.Icons.loading," Loading subscription settings..."]})});const M=r.plans.filter(e=>e.isActive).length,L=r.plans.reduce((e,t)=>e+(t.activeSubscribers??0),0),N=l.enabled,W=r.plans.filter(e=>e.isActive).map(e=>({label:e.title,value:e.activeSubscribers??0,description:"subscribers"}));return a.jsxs("div",{className:"cedros-admin__page",children:[a.jsx(X.ErrorBanner,{message:z,onRetry:w}),a.jsx(Y.StatsBar,{stats:[{label:"Status",value:N?"Enabled":"Disabled",variant:N?"success":"muted"},{label:"Active Plans",value:M,variant:M>0?"success":"muted"},{label:"Total Subscribers",value:L,variant:L>0?"success":"muted"},...W],isLoading:_}),a.jsxs("div",{className:"cedros-admin__section",children:[a.jsxs("div",{className:"cedros-admin__section-header",children:[a.jsx("h3",{className:"cedros-admin__section-title",children:"Subscription Settings"}),a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[u==="plans"&&a.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--action",onClick:O,disabled:!N,children:[m.Icons.plus,"Add Plan"]}),a.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${y}`,children:[y==="saving"&&"Saving...",y==="saved"&&"Saved",y==="error"&&"Error"]})]})]}),a.jsxs("div",{className:"cedros-admin__tabs cedros-admin__tabs--line",children:[a.jsx("button",{type:"button",className:`cedros-admin__tab ${u==="plans"?"cedros-admin__tab--active":""}`,onClick:()=>A("plans"),children:"Plans"}),a.jsx("button",{type:"button",className:`cedros-admin__tab ${u==="page"?"cedros-admin__tab--active":""}`,onClick:()=>A("page"),children:"Page Settings"})]}),u==="page"&&a.jsxs("div",{children:[a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Subscriptions"}),a.jsxs("label",{className:"cedros-admin__toggle",children:[a.jsx("input",{type:"checkbox",className:"cedros-admin__toggle-input",checked:l.enabled,onChange:e=>g(t=>({...t,enabled:e.target.checked}))}),a.jsx("span",{className:"cedros-admin__toggle-track",children:a.jsx("span",{className:"cedros-admin__toggle-thumb"})}),a.jsx("span",{className:"cedros-admin__toggle-label",children:"Enable Subscriptions"})]})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Title"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageTitle||"",onChange:e=>g(t=>({...t,pageTitle:e.target.value})),placeholder:"Choose Your Plan"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Page Subtitle"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.pageSubtitle||"",onChange:e=>g(t=>({...t,pageSubtitle:e.target.value})),placeholder:"Select the plan that best fits your needs."})]})]}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Savings Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.annualSavingsBadge||"",onChange:e=>g(t=>({...t,annualSavingsBadge:e.target.value})),placeholder:"2 months free"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Popular Plan Badge"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.popularBadgeText||"",onChange:e=>g(t=>({...t,popularBadgeText:e.target.value})),placeholder:"Best Deal"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Footer Notice (optional)"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:l.footerNotice||"",onChange:e=>g(t=>({...t,footerNotice:e.target.value})),placeholder:"For information regarding invoices, taxes..."})]})})]}),u==="plans"&&a.jsxs("div",{children:[!N&&a.jsx("div",{style:{padding:"1.5rem",textAlign:"center",opacity:.6},children:"Subscriptions are disabled. Enable them to configure plans."}),r.plans.length===0?a.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6,border:"1px dashed currentColor",borderRadius:8},children:'No plans configured. Click "Add Plan" to create your first subscription tier.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:r.plans.map((e,t)=>{const n=k===e.id;return a.jsxs("div",{style:{border:"1px solid var(--cedros-admin-border, #e5e5e5)",borderRadius:8,overflow:"hidden",background:e.isPopular?"var(--cedros-admin-bg-accent, #f5f5f5)":void 0},children:[a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"1rem",padding:"0.75rem 1rem",cursor:"pointer"},onClick:()=>T(n?null:e.id),children:[a.jsx("span",{style:{opacity:.5},children:n?m.Icons.chevronDown:m.Icons.chevronRight}),a.jsxs("div",{style:{flex:1},children:[a.jsx("span",{style:{fontWeight:600},children:e.title||"Untitled Plan"}),e.isPopular&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"var(--cedros-admin-primary, #171717)",color:"#fff"},children:"Popular"}),!e.isActive&&a.jsx("span",{style:{marginLeft:"0.5rem",fontSize:11,padding:"2px 6px",borderRadius:4,background:"#9ca3af",color:"#fff"},children:"Inactive"})]}),a.jsxs("span",{style:{opacity:.6,fontSize:14},children:["$",e.priceMonthlyUsd,"/mo · $",e.priceAnnualUsd,"/yr"]}),a.jsxs("div",{style:{display:"flex",gap:"0.25rem"},onClick:s=>s.stopPropagation(),children:[a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"up"),disabled:t===0,title:"Move up",style:{padding:"4px 8px"},children:m.Icons.chevronUp}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>$(e.id,"down"),disabled:t===r.plans.length-1,title:"Move down",style:{padding:"4px 8px"},children:m.Icons.chevronDown}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>H(e.id),title:"Delete plan",style:{padding:"4px 8px",color:"#dc2626"},children:m.Icons.trash})]})]}),n&&a.jsxs("div",{style:{padding:"1rem",borderTop:"1px solid var(--cedros-admin-border, #e5e5e5)"},children:[a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Plan Name"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.title,onChange:s=>c(e.id,{title:s.target.value}),placeholder:"e.g., Starter"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Button Text"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.buttonText||"",onChange:s=>c(e.id,{buttonText:s.target.value}),placeholder:"Purchase"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Description"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.description,onChange:s=>c(e.id,{description:s.target.value}),placeholder:"For entry-level developers managing lightweight workloads"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Monthly Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceMonthlyUsd||"",onChange:s=>c(e.id,{priceMonthlyUsd:parseFloat(s.target.value)||0}),placeholder:"10",min:"0",step:"0.01"})]}),a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Annual Price (USD)"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.priceAnnualUsd||"",onChange:s=>c(e.id,{priceAnnualUsd:parseFloat(s.target.value)||0}),placeholder:"100",min:"0",step:"0.01"})]})]}),a.jsx("div",{className:"cedros-admin__form-row",children:a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Feature Highlight"}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:e.featureHighlight||"",onChange:s=>c(e.id,{featureHighlight:s.target.value}),placeholder:"100 prompts every 5 hours"}),a.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Bold text shown above feature list"})]})}),a.jsxs("div",{className:"cedros-admin__form-row",children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isPopular||!1,onChange:s=>c(e.id,{isPopular:s.target.checked})}),"Mark as Popular (featured styling)"]})}),a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.isActive,onChange:s=>c(e.id,{isActive:s.target.checked})}),"Active (available for purchase)"]})})]}),a.jsxs("div",{className:"cedros-admin__form-row",style:{marginTop:"0.5rem"},children:[a.jsx("div",{className:"cedros-admin__field",children:a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:e.inventoryQuantity!=null,onChange:s=>c(e.id,{inventoryQuantity:s.target.checked?100:null})}),"Limit quantity available"]})}),e.inventoryQuantity!=null&&a.jsxs("div",{className:"cedros-admin__field",children:[a.jsx("label",{className:"cedros-admin__field-label",children:"Total Available"}),a.jsx("input",{type:"number",className:"cedros-admin__input",value:e.inventoryQuantity??"",onChange:s=>c(e.id,{inventoryQuantity:parseInt(s.target.value)||0}),min:"0",style:{width:100}}),e.inventorySold!=null&&e.inventorySold>0&&a.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:[e.inventorySold," sold · ",Math.max(0,e.inventoryQuantity-e.inventorySold)," remaining"]})]})]}),a.jsxs("div",{style:{marginTop:"1rem"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"0.5rem"},children:[a.jsxs("label",{className:"cedros-admin__field-label",style:{margin:0},children:["Feature List (",e.features.length,")"]}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>q(e.id),style:{fontSize:12,padding:"4px 8px"},children:"+ Add Feature"})]}),e.features.length===0?a.jsx("div",{style:{padding:"1rem",textAlign:"center",opacity:.5,fontSize:13,border:"1px dashed currentColor",borderRadius:6},children:'No features. Click "Add Feature" to add bullet points.'}):a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:e.features.map((s,o)=>a.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[a.jsxs("span",{style:{opacity:.4,fontSize:12},children:[o+1,"."]}),a.jsx("input",{type:"text",className:"cedros-admin__input",value:s,onChange:p=>Q(e.id,o,p.target.value),placeholder:"e.g., Powered by MiniMax M2.1",style:{flex:1}}),a.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>J(e.id,o),style:{padding:"4px 8px",color:"#dc2626"},title:"Remove feature",children:m.Icons.trash})]},o))})]})]})]},e.id)})})]})]})]})}exports.SubscriptionsSection=Z;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as n, jsx as t, Fragment as q } from "react/jsx-runtime";
2
2
  import { useState as i, useCallback as D, useEffect as O } from "react";
3
- import { I as J } from "./sectionIds-DBavltrL.mjs";
4
- import { E as M } from "./ErrorBanner-CZXsHi3H.mjs";
3
+ import { I as J } from "./icons-C3yDMnKE.mjs";
4
+ import { E as M } from "./ErrorBanner-lZJhCmDX.mjs";
5
5
  import { f as V } from "./dateHelpers-yvPkofYQ.mjs";
6
6
  const X = (l) => (l / 100).toFixed(2) + "%", k = (l) => Math.round(parseFloat(l) * 100), C = { name: "", country: "", region: "", ratePercent: "", active: !0 };
7
7
  function Z({ serverUrl: l, apiKey: f, pageSize: c = 50, authManager: b }) {
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),L=require("./icons-Cjgd9YVo.js"),$=require("./ErrorBanner-CAgPnj62.js"),O=require("./dateHelpers-BKW_lGND.js"),W=c=>(c/100).toFixed(2)+"%",w=c=>Math.round(parseFloat(c)*100),v={name:"",country:"",region:"",ratePercent:"",active:!0};function M({serverUrl:c,apiKey:_,pageSize:o=50,authManager:p}){const[l,N]=a.useState([]),[I,S]=a.useState(!0),[k,d]=a.useState(null),[m,C]=a.useState(0),[D,b]=a.useState(!1),[h,f]=a.useState(null),[n,r]=a.useState(v),[R,T]=a.useState(!1),[P,E]=a.useState(null),[g,y]=a.useState(null),u=a.useCallback(async(t,s)=>{if(p?.isAuthenticated())return p.fetchWithAuth(t,s);const i={"Content-Type":"application/json"};_&&(i["X-API-Key"]=_);const j=await fetch(`${c}${t}`,{...s,headers:{...i,...s?.headers}});if(!j.ok)throw new Error(`Request failed: ${j.status}`);return j.json()},[c,_,p]),x=a.useCallback(async()=>{S(!0),d(null);try{const t=new URLSearchParams;t.set("limit",String(o)),t.set("offset",String(m));const s=await u(`/admin/tax/rates?${t.toString()}`);N(s.rates??[])}catch{d("Failed to load tax rates"),N([])}finally{S(!1)}},[u,o,m]);a.useEffect(()=>{x()},[x]);const F=()=>{r(v),f(null),b(!1)},q=()=>{f(null),r(v),b(!0)},A=t=>{f(t),r({name:t.name,country:t.country,region:t.region??"",ratePercent:(t.rateBps/100).toFixed(2),active:t.active}),b(!0)},U=async t=>{t.preventDefault();const s=parseFloat(n.ratePercent);if(isNaN(s)||s<0||s>100){d("Rate must be a number between 0 and 100");return}T(!0),d(null);try{const i={name:n.name.trim(),country:n.country.trim().toUpperCase(),region:n.region.trim()||void 0,rateBps:w(n.ratePercent),active:n.active};h?await u(`/admin/tax/rates/${encodeURIComponent(h.id)}`,{method:"PUT",body:JSON.stringify(i)}):await u("/admin/tax/rates",{method:"POST",body:JSON.stringify(i)}),F(),x()}catch(i){d(i instanceof Error?i.message:"Failed to save tax rate")}finally{T(!1)}},B=async t=>{if(g!==t){y(t);return}E(t),d(null);try{await u(`/admin/tax/rates/${encodeURIComponent(t)}`,{method:"DELETE"}),y(null),x()}catch{d("Failed to delete tax rate")}finally{E(null)}};return e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Tax Rates"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:q,children:"+ Add Rate"})]}),e.jsx($.ErrorBanner,{message:k}),D&&e.jsxs("form",{onSubmit:U,style:{border:"1px solid var(--cedros-admin-border, #e0e0e0)",borderRadius:"4px",padding:"1rem",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsx("h4",{style:{margin:"0 0 0.75rem",fontSize:"0.9rem",fontWeight:600},children:h?"Edit Tax Rate":"New Tax Rate"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Name *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.name,onChange:t=>r(s=>({...s,name:t.target.value})),required:!0,placeholder:"e.g. US Sales Tax"})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Country (2-letter) *"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.country,onChange:t=>r(s=>({...s,country:t.target.value.toUpperCase().slice(0,2)})),required:!0,maxLength:2,placeholder:"US",style:{textTransform:"uppercase"}})]}),e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Region (optional)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.region,onChange:t=>r(s=>({...s,region:t.target.value})),placeholder:"e.g. CA"})]})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Rate (%) *"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n.ratePercent,onChange:t=>r(s=>({...s,ratePercent:t.target.value})),required:!0,min:"0",max:"100",step:"0.01",placeholder:"8.25",style:{maxWidth:"140px"}}),n.ratePercent&&!isNaN(parseFloat(n.ratePercent))&&e.jsxs("span",{style:{fontSize:"0.8rem",color:"var(--cedros-admin-text-muted, #888)",marginLeft:"0.5rem"},children:["= ",w(n.ratePercent)," bps"]})]}),e.jsx("div",{className:"cedros-admin__field",children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",cursor:"pointer",fontSize:"0.85rem"},children:[e.jsx("input",{type:"checkbox",checked:n.active,onChange:t=>r(s=>({...s,active:t.target.checked}))}),"Active"]})})]}),e.jsxs("div",{style:{marginTop:"0.75rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:R,children:R?"Saving...":h?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:F,children:"Cancel"})]})]}),I?e.jsxs("div",{className:"cedros-admin__loading",children:[L.Icons.loading," Loading tax rates..."]}):l.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No tax rates configured."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Country"}),e.jsx("th",{children:"Region"}),e.jsx("th",{children:"Rate"}),e.jsx("th",{children:"Active"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:l.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.name}),e.jsx("td",{style:{fontWeight:500},children:t.country.toUpperCase()}),e.jsx("td",{children:t.region??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:W(t.rateBps)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.active?"success":"muted"}`,children:t.active?"Active":"Inactive"})}),e.jsx("td",{children:O.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>A(t),children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",style:g===t.id?{color:"var(--cedros-admin-error, #e53e3e)"}:void 0,disabled:P===t.id,onClick:()=>B(t.id),onBlur:()=>y(null),children:P===t.id?"Deleting...":g===t.id?"Confirm?":"Delete"})]})})]},t.id))})]})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:"0.75rem",fontSize:"0.85rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:m===0,onClick:()=>C(Math.max(0,m-o)),children:"Previous"}),e.jsxs("span",{children:["Showing ",l.length," rate",l.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:l.length<o,onClick:()=>C(m+o),children:"Next"})]})]})]})}exports.TaxSection=M;