@cedros/pay-react 1.1.30 → 1.1.31

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 (129) hide show
  1. package/README.md +53 -30
  2. package/dist/{AISettingsSection-C0zqPbd6.js → AISettingsSection-B12x5sV5.js} +2 -2
  3. package/dist/{AISettingsSection-BMh3hAb5.mjs → AISettingsSection-DXWDF4Cf.mjs} +4 -4
  4. package/dist/AutosaveIndicator-CJdkhZis.js +1 -0
  5. package/dist/{AutosaveIndicator-3ctAnz8Y.mjs → AutosaveIndicator-D966vOrP.mjs} +1 -1
  6. package/dist/CedrosContext-3Dz7_9Ct.js +3 -0
  7. package/dist/{CedrosContext-5Gjveoba.mjs → CedrosContext-DQc_k5PG.mjs} +430 -314
  8. package/dist/ChatLogsSection-CH37u0nX.js +1 -0
  9. package/dist/{ChatLogsSection-BtJixYAp.mjs → ChatLogsSection-DR7mpuQS.mjs} +2 -2
  10. package/dist/{ComplianceSection-BMnb1p4w.mjs → ComplianceSection-C61_Hf-X.mjs} +3 -3
  11. package/dist/ComplianceSection-DS4e2IBp.js +1 -0
  12. package/dist/CryptoButton-BQceZhbn.js +1 -0
  13. package/dist/{CryptoButton-Cl2kZbOP.mjs → CryptoButton-BuO_RZLj.mjs} +4 -5
  14. package/dist/CustomersSection-Bzs9Qon3.js +1 -0
  15. package/dist/{CustomersSection-dmwoBhcf.mjs → CustomersSection-CWWvusxs.mjs} +2 -2
  16. package/dist/DisputesSection-ClcYIHga.js +1 -0
  17. package/dist/{DisputesSection-CHyLne76.mjs → DisputesSection-D8rcS5Vs.mjs} +2 -2
  18. package/dist/{Dropdown-BRSZlhik.mjs → Dropdown-0y3S40Xf.mjs} +1 -1
  19. package/dist/Dropdown-BuKiVR_L.js +1 -0
  20. package/dist/{ErrorBanner-lZJhCmDX.mjs → ErrorBanner-DAjYj6Dx.mjs} +1 -1
  21. package/dist/ErrorBanner-DxrRVqwe.js +1 -0
  22. package/dist/FAQSection-0UnN2BZs.js +1 -0
  23. package/dist/{FAQSection-Di2xE9Sm.mjs → FAQSection-Dck0NM-A.mjs} +3 -3
  24. package/dist/{ImagesSection-D63PEjR6.mjs → ImagesSection-Bn9GrRRa.mjs} +2 -2
  25. package/dist/ImagesSection-CSwBHvNl.js +1 -0
  26. package/dist/{InventorySection-Dp5Yu4TA.mjs → InventorySection-Dytfmtn8.mjs} +2 -2
  27. package/dist/InventorySection-ymxaMcIg.js +1 -0
  28. package/dist/{MessagingSection-BLCnCpEv.mjs → MessagingSection-CHFbSxJL.mjs} +3 -3
  29. package/dist/MessagingSection-Dtfv0DvU.js +1 -0
  30. package/dist/OrdersSection-BuzTs9XG.js +1 -0
  31. package/dist/{OrdersSection-Bd56F3cj.mjs → OrdersSection-vYNuVF5X.mjs} +2 -2
  32. package/dist/{PaymentSettingsSection-B5J56VAk.js → PaymentSettingsSection-BOaW8lLv.js} +1 -1
  33. package/dist/{PaymentSettingsSection-52iw47Su.mjs → PaymentSettingsSection-BqdGrXen.mjs} +3 -3
  34. package/dist/{ReturnsSection-DUVeKrCd.mjs → ReturnsSection-CRzhXKtI.mjs} +2 -2
  35. package/dist/ReturnsSection-i5W_3so1.js +1 -0
  36. package/dist/{SettingsSection-vK9WIwXE.mjs → SettingsSection-6o3d8DrH.mjs} +1 -1
  37. package/dist/{SettingsSection-DKkHykaC.js → SettingsSection-CIhO51Zj.js} +1 -1
  38. package/dist/ShippingSection-BUzPW1AG.js +1 -0
  39. package/dist/{ShippingSection-CZRrXrlh.mjs → ShippingSection-CbNzGyCP.mjs} +2 -2
  40. package/dist/SingleCategorySettings-BxVUUy8R.js +3 -0
  41. package/dist/{SingleCategorySettings-C8xJ47_T.mjs → SingleCategorySettings-Qj_ptB_x.mjs} +4 -4
  42. package/dist/{StatsBar-D4cOKG2e.mjs → StatsBar-CwCBHBn-.mjs} +1 -1
  43. package/dist/StatsBar-DDUWoizP.js +1 -0
  44. package/dist/StorefrontSection-CZZj5he9.js +1 -0
  45. package/dist/{StorefrontSection-uXSVbEAa.mjs → StorefrontSection-DIYDmj59.mjs} +4 -4
  46. package/dist/SubscriptionsSection-Bof5MElz.js +1 -0
  47. package/dist/{SubscriptionsSection-Ci_AZrWA.mjs → SubscriptionsSection-lMVHdV5X.mjs} +3 -3
  48. package/dist/TaxSection-Be-9v60Z.js +1 -0
  49. package/dist/{TaxSection-BTukS_cU.mjs → TaxSection-dD7PzQvG.mjs} +2 -2
  50. package/dist/Token22Section-Di5fHsrU.js +1 -0
  51. package/dist/{Token22Section-DRsPJuTq.mjs → Token22Section-Dos0CYEk.mjs} +2 -2
  52. package/dist/{WalletManager-D-eoqUDy.mjs → WalletManager-CGR69MiR.mjs} +1 -1
  53. package/dist/{WalletManager-DXChB9LA.js → WalletManager-ZJbGQHrn.js} +1 -1
  54. package/dist/{WebhooksSection-A8Y4ZGcj.mjs → WebhooksSection-5gqXzIhq.mjs} +2 -2
  55. package/dist/WebhooksSection-CiLDyl7c.js +1 -0
  56. package/dist/admin.js +1 -1
  57. package/dist/admin.mjs +1 -1
  58. package/dist/crypto-only.js +1 -1
  59. package/dist/crypto-only.mjs +102 -105
  60. package/dist/{index-9QF_UfSN.mjs → index-CU6M10Rs.mjs} +13 -14
  61. package/dist/{index-Cq9ya93W.js → index-DVxx_62C.js} +10 -10
  62. package/dist/index.js +1 -1
  63. package/dist/index.mjs +31 -34
  64. package/dist/pay-react.css +1 -1
  65. package/dist/plugin-BIkt3boU.mjs +339 -0
  66. package/dist/plugin-Dw8_Q8rE.js +1 -0
  67. package/dist/sections-D1d83mfH.js +1 -0
  68. package/dist/{sections-more-Ixw6mM6R.mjs → sections-DcUfZQNE.mjs} +263 -270
  69. package/dist/src/admin/plugin.d.ts.map +1 -1
  70. package/dist/src/admin/sectionIds.d.ts.map +1 -1
  71. package/dist/src/admin.d.ts +0 -7
  72. package/dist/src/admin.d.ts.map +1 -1
  73. package/dist/src/components/admin/index.d.ts +0 -1
  74. package/dist/src/components/admin/index.d.ts.map +1 -1
  75. package/dist/src/index.d.ts +0 -1
  76. package/dist/src/index.d.ts.map +1 -1
  77. package/dist/stripe-only.js +1 -1
  78. package/dist/stripe-only.mjs +18 -19
  79. package/dist/styles-BwaDljnz.js +1 -0
  80. package/dist/{styles-DGagylUj.mjs → styles-fihm6qVA.mjs} +51 -52
  81. package/dist/testing/index.js +1 -1
  82. package/dist/testing/index.mjs +1 -1
  83. package/package.json +6 -8
  84. package/dist/AutosaveIndicator-DXRPr4P7.js +0 -1
  85. package/dist/CedrosContext-CCakH2SZ.js +0 -3
  86. package/dist/CedrosPayAdminDashboard-DaJ9JoGn.mjs +0 -250
  87. package/dist/CedrosPayAdminDashboard-Uvyh9p7A.js +0 -1
  88. package/dist/ChatLogsSection-FC3O536G.js +0 -1
  89. package/dist/ComplianceSection-BioTKm7k.js +0 -1
  90. package/dist/CryptoButton-DxFCYDlJ.js +0 -1
  91. package/dist/CustomersSection-z6ARxuex.js +0 -1
  92. package/dist/DisputesSection-BjHHQAi7.js +0 -1
  93. package/dist/Dropdown-j8o0OO5L.js +0 -1
  94. package/dist/ErrorBanner-CAgPnj62.js +0 -1
  95. package/dist/FAQSection-b34DMzgV.js +0 -1
  96. package/dist/ImagesSection-DGBA7iKY.js +0 -1
  97. package/dist/InventorySection-bVCECzX5.js +0 -1
  98. package/dist/LazyCedrosPayAdminDashboard-BqJDNrDI.mjs +0 -9
  99. package/dist/LazyCedrosPayAdminDashboard-CpfTtOBc.js +0 -1
  100. package/dist/MessagingSection-DU0dYNMy.js +0 -1
  101. package/dist/OrdersSection-FOFEAgs1.js +0 -1
  102. package/dist/ReturnsSection-BjpIVFfN.js +0 -1
  103. package/dist/ShippingSection-B5lk7zpS.js +0 -1
  104. package/dist/SingleCategorySettings-g7D-9lG1.js +0 -3
  105. package/dist/StatsBar-CWXw2ZT3.js +0 -1
  106. package/dist/StorefrontSection-BWnMB9k-.js +0 -1
  107. package/dist/SubscriptionsSection-DQfXkuDv.js +0 -1
  108. package/dist/TaxSection-cuPQISxZ.js +0 -1
  109. package/dist/ThemeContext-CFXyYx7A.js +0 -1
  110. package/dist/ThemeContext-l0bqcOGW.mjs +0 -126
  111. package/dist/Token22Section-CCfkDm8W.js +0 -1
  112. package/dist/WebhooksSection-CnEmaGH1.js +0 -1
  113. package/dist/icons-C3yDMnKE.mjs +0 -235
  114. package/dist/icons-Cjgd9YVo.js +0 -1
  115. package/dist/sectionIds-D46-_-h-.js +0 -1
  116. package/dist/sectionIds-YktNxmRt.mjs +0 -124
  117. package/dist/sections-511_XBh4.js +0 -1
  118. package/dist/sections-CRaMa8ZB.mjs +0 -9
  119. package/dist/sections-more-Cgw2qJlA.js +0 -1
  120. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +0 -40
  121. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +0 -1
  122. package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +0 -4
  123. package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +0 -1
  124. package/dist/src/standalone-admin.d.ts +0 -8
  125. package/dist/src/standalone-admin.d.ts.map +0 -1
  126. package/dist/standalone-admin.d.ts +0 -2
  127. package/dist/standalone-admin.js +0 -1
  128. package/dist/standalone-admin.mjs +0 -4
  129. package/dist/styles--fxb3lCl.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-C8xJ47_T.mjs";
3
+ import { S as M } from "./SingleCategorySettings-Qj_ptB_x.mjs";
4
4
  import { C as U } from "./configApi-BUXZOMWK.mjs";
5
- import { E as j } from "./ErrorBanner-lZJhCmDX.mjs";
6
- import { S as H } from "./StatsBar-D4cOKG2e.mjs";
5
+ import { E as j } from "./ErrorBanner-DAjYj6Dx.mjs";
6
+ import { S as H } from "./StatsBar-CwCBHBn-.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,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 "./icons-C3yDMnKE.mjs";
4
- import { E as $ } from "./ErrorBanner-lZJhCmDX.mjs";
3
+ import { I as O } from "./plugin-BIkt3boU.mjs";
4
+ import { E as $ } from "./ErrorBanner-DAjYj6Dx.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) {
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),A=require("./plugin-Dw8_Q8rE.js"),q=require("./ErrorBanner-DxrRVqwe.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:l,onError:u,fetchWithAuth:a}){const[r,g]=d.useState(s.status),[m,j]=d.useState(!1),c=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})});l(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:c,disabled:m||r===s.status,children:m?"Updating...":"Update"})]})]})}function T({serverUrl:s,apiKey:h,pageSize:l=20,authManager:u}){const[a,r]=d.useState([]),[g,m]=d.useState(!0),[j,c]=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),c(null);try{const t=new URLSearchParams;t.set("limit",String(l)),t.set("offset",String(n)),_!=="all"&&t.set("status",_);const i=await f(`/admin/returns?${t.toString()}`);r(i.returns??[])}catch{c("Failed to load returns"),r([])}finally{m(!1)}},[f,l,n,_]);d.useEffect(()=>{N()},[N]);const U=async t=>{v(!0),c(null);try{const i=await f(`/admin/returns/${encodeURIComponent(t)}`);y(i)}catch{c("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:c,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-l)),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<l,onClick:()=>o(n+l),children:"Next"})]})]})]})}exports.ReturnsSection=T;
@@ -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-C8xJ47_T.mjs";
3
+ import { S as l } from "./SingleCategorySettings-Qj_ptB_x.mjs";
4
4
  const o = [
5
5
  {
6
6
  id: "logging",
@@ -1 +1 @@
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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),g=require("react"),d=require("./SingleCategorySettings-BxVUUy8R.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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),z=require("./plugin-Dw8_Q8rE.js"),v=require("./ErrorBanner-DxrRVqwe.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 "./icons-C3yDMnKE.mjs";
4
- import { E as x } from "./ErrorBanner-lZJhCmDX.mjs";
3
+ import { I as q } from "./plugin-BIkt3boU.mjs";
4
+ import { E as x } from "./ErrorBanner-DAjYj6Dx.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 }) {
@@ -0,0 +1,3 @@
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),k=require("./plugin-Dw8_Q8rE.js"),K=require("./ErrorBanner-DxrRVqwe.js"),N=require("./configApi-BS5UJfzm.js"),L=require("./useAutosave-B2p6iwh8.js"),$=require("./AutosaveIndicator-CJdkhZis.js"),J=require("./Dropdown-BuKiVR_L.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;
@@ -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 "./icons-C3yDMnKE.mjs";
4
- import { E as Q } from "./ErrorBanner-lZJhCmDX.mjs";
3
+ import { I as E } from "./plugin-BIkt3boU.mjs";
4
+ import { E as Q } from "./ErrorBanner-DAjYj6Dx.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-3ctAnz8Y.mjs";
8
- import { F as te } from "./Dropdown-BRSZlhik.mjs";
7
+ import { A as re } from "./AutosaveIndicator-D966vOrP.mjs";
8
+ import { F as te } from "./Dropdown-0y3S40Xf.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}$/;
@@ -1,5 +1,5 @@
1
1
  import { jsxs as d, jsx as s } from "react/jsx-runtime";
2
- import { I as n } from "./icons-C3yDMnKE.mjs";
2
+ import { I as n } from "./plugin-BIkt3boU.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";const s=require("react/jsx-runtime"),n=require("./plugin-Dw8_Q8rE.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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("react"),O=require("./plugin-Dw8_Q8rE.js"),q=require("./ErrorBanner-DxrRVqwe.js"),j=require("./Dropdown-BuKiVR_L.js"),o=require("./Toggle-CsPSF8Dr.js"),M=require("./useAutosave-B2p6iwh8.js"),$=require("./AutosaveIndicator-CJdkhZis.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 "./icons-C3yDMnKE.mjs";
4
- import { E as V } from "./ErrorBanner-lZJhCmDX.mjs";
5
- import { F as x } from "./Dropdown-BRSZlhik.mjs";
3
+ import { I as H } from "./plugin-BIkt3boU.mjs";
4
+ import { E as V } from "./ErrorBanner-DAjYj6Dx.mjs";
5
+ import { F as x } from "./Dropdown-0y3S40Xf.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-3ctAnz8Y.mjs";
8
+ import { A as X } from "./AutosaveIndicator-D966vOrP.mjs";
9
9
  const C = {
10
10
  enabled: !0,
11
11
  relatedProducts: {
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),m=require("./plugin-Dw8_Q8rE.js"),X=require("./ErrorBanner-DxrRVqwe.js"),Y=require("./StatsBar-DDUWoizP.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,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 "./icons-C3yDMnKE.mjs";
4
- import { E as Z } from "./ErrorBanner-lZJhCmDX.mjs";
5
- import { S as K } from "./StatsBar-D4cOKG2e.mjs";
3
+ import { I as h } from "./plugin-BIkt3boU.mjs";
4
+ import { E as Z } from "./ErrorBanner-DAjYj6Dx.mjs";
5
+ import { S as K } from "./StatsBar-CwCBHBn-.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 e=require("react/jsx-runtime"),a=require("react"),L=require("./plugin-Dw8_Q8rE.js"),$=require("./ErrorBanner-DxrRVqwe.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:l=50,authManager:p}){const[o,N]=a.useState([]),[I,S]=a.useState(!0),[k,d]=a.useState(null),[m,C]=a.useState(0),[D,b]=a.useState(!1),[h,g]=a.useState(null),[n,r]=a.useState(v),[R,T]=a.useState(!1),[P,E]=a.useState(null),[f,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(l)),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,l,m]);a.useEffect(()=>{x()},[x]);const F=()=>{r(v),g(null),b(!1)},q=()=>{g(null),r(v),b(!0)},A=t=>{g(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(f!==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..."]}):o.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:o.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:f===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...":f===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-l)),children:"Previous"}),e.jsxs("span",{children:["Showing ",o.length," rate",o.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:o.length<l,onClick:()=>C(m+l),children:"Next"})]})]})]})}exports.TaxSection=M;
@@ -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 "./icons-C3yDMnKE.mjs";
4
- import { E as M } from "./ErrorBanner-lZJhCmDX.mjs";
3
+ import { I as J } from "./plugin-BIkt3boU.mjs";
4
+ import { E as M } from "./ErrorBanner-DAjYj6Dx.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 }) {