@cedros/pay-react 1.1.31 → 1.1.32

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 (67) hide show
  1. package/dist/{AISettingsSection-DXWDF4Cf.mjs → AISettingsSection-ChBtZVz7.mjs} +4 -4
  2. package/dist/{AISettingsSection-B12x5sV5.js → AISettingsSection-DSROL7Lg.js} +1 -1
  3. package/dist/{AutosaveIndicator-D966vOrP.mjs → AutosaveIndicator-BTa2YPNH.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-CJdkhZis.js → AutosaveIndicator-BgDnlrCW.js} +1 -1
  5. package/dist/{ChatLogsSection-CH37u0nX.js → ChatLogsSection-B5AdoZls.js} +1 -1
  6. package/dist/{ChatLogsSection-DR7mpuQS.mjs → ChatLogsSection-D8FX7Dmn.mjs} +2 -2
  7. package/dist/{ComplianceSection-C61_Hf-X.mjs → ComplianceSection-A1hgI_X2.mjs} +3 -3
  8. package/dist/{ComplianceSection-DS4e2IBp.js → ComplianceSection-UWfkNrmW.js} +1 -1
  9. package/dist/{CustomersSection-CWWvusxs.mjs → CustomersSection-BuSVgS16.mjs} +2 -2
  10. package/dist/{CustomersSection-Bzs9Qon3.js → CustomersSection-Rh552kcC.js} +1 -1
  11. package/dist/{DisputesSection-ClcYIHga.js → DisputesSection-BtMdxOuD.js} +1 -1
  12. package/dist/{DisputesSection-D8rcS5Vs.mjs → DisputesSection-DqWrBCyC.mjs} +2 -2
  13. package/dist/{Dropdown-BuKiVR_L.js → Dropdown-CWYy2Rtt.js} +1 -1
  14. package/dist/{Dropdown-0y3S40Xf.mjs → Dropdown-DHCHYuTB.mjs} +1 -1
  15. package/dist/{ErrorBanner-DAjYj6Dx.mjs → ErrorBanner-7naZtdtD.mjs} +1 -1
  16. package/dist/{ErrorBanner-DxrRVqwe.js → ErrorBanner-BOS1XAPu.js} +1 -1
  17. package/dist/{FAQSection-0UnN2BZs.js → FAQSection-DczKj0C3.js} +1 -1
  18. package/dist/{FAQSection-Dck0NM-A.mjs → FAQSection-x0ya8PvI.mjs} +3 -3
  19. package/dist/{ImagesSection-Bn9GrRRa.mjs → ImagesSection-CMvHgbtL.mjs} +2 -2
  20. package/dist/{ImagesSection-CSwBHvNl.js → ImagesSection-tRpBN-ls.js} +1 -1
  21. package/dist/{InventorySection-Dytfmtn8.mjs → InventorySection-5PEOXciZ.mjs} +2 -2
  22. package/dist/{InventorySection-ymxaMcIg.js → InventorySection-clEVFr_r.js} +1 -1
  23. package/dist/{MessagingSection-Dtfv0DvU.js → MessagingSection-BpwTsNW1.js} +1 -1
  24. package/dist/{MessagingSection-CHFbSxJL.mjs → MessagingSection-Bt84iW-5.mjs} +3 -3
  25. package/dist/{OrdersSection-BuzTs9XG.js → OrdersSection-Bsou3cwl.js} +1 -1
  26. package/dist/{OrdersSection-vYNuVF5X.mjs → OrdersSection-kJzPO6CP.mjs} +2 -2
  27. package/dist/{PaymentSettingsSection-BOaW8lLv.js → PaymentSettingsSection-CUgUJ7tm.js} +1 -1
  28. package/dist/{PaymentSettingsSection-BqdGrXen.mjs → PaymentSettingsSection-s_XMFPik.mjs} +3 -3
  29. package/dist/{ReturnsSection-CRzhXKtI.mjs → ReturnsSection-BcwsQbrU.mjs} +2 -2
  30. package/dist/{ReturnsSection-i5W_3so1.js → ReturnsSection-BwHv1HkV.js} +1 -1
  31. package/dist/{SettingsSection-CIhO51Zj.js → SettingsSection-B_feZEzU.js} +1 -1
  32. package/dist/{SettingsSection-6o3d8DrH.mjs → SettingsSection-OI1G3b40.mjs} +1 -1
  33. package/dist/{ShippingSection-CbNzGyCP.mjs → ShippingSection-B2GtSEvn.mjs} +2 -2
  34. package/dist/{ShippingSection-BUzPW1AG.js → ShippingSection-DyTGH_Fh.js} +1 -1
  35. package/dist/{SingleCategorySettings-Qj_ptB_x.mjs → SingleCategorySettings-Cd76sY00.mjs} +4 -4
  36. package/dist/{SingleCategorySettings-BxVUUy8R.js → SingleCategorySettings-Ci6hJ0Xu.js} +1 -1
  37. package/dist/{StatsBar-CwCBHBn-.mjs → StatsBar-B_lf0ph0.mjs} +1 -1
  38. package/dist/{StatsBar-DDUWoizP.js → StatsBar-CVqsD8j2.js} +1 -1
  39. package/dist/{StorefrontSection-CZZj5he9.js → StorefrontSection-BxaWrsPc.js} +1 -1
  40. package/dist/{StorefrontSection-DIYDmj59.mjs → StorefrontSection-DW0q9GsC.mjs} +4 -4
  41. package/dist/{SubscriptionsSection-lMVHdV5X.mjs → SubscriptionsSection-CNHPCync.mjs} +3 -3
  42. package/dist/{SubscriptionsSection-Bof5MElz.js → SubscriptionsSection-QMoSKKot.js} +1 -1
  43. package/dist/{TaxSection-Be-9v60Z.js → TaxSection-BKhh7kOv.js} +1 -1
  44. package/dist/{TaxSection-dD7PzQvG.mjs → TaxSection-BwLpiery.mjs} +2 -2
  45. package/dist/Token22Section-B_URxab9.js +1 -0
  46. package/dist/{Token22Section-Dos0CYEk.mjs → Token22Section-DyNDKGdU.mjs} +227 -212
  47. package/dist/{WebhooksSection-CiLDyl7c.js → WebhooksSection-BIs2Qh-o.js} +1 -1
  48. package/dist/{WebhooksSection-5gqXzIhq.mjs → WebhooksSection-bDVQE9Qp.mjs} +2 -2
  49. package/dist/admin.js +1 -1
  50. package/dist/admin.mjs +1 -1
  51. package/dist/crypto-only.js +1 -1
  52. package/dist/crypto-only.mjs +1 -1
  53. package/dist/index.js +1 -1
  54. package/dist/index.mjs +1 -1
  55. package/dist/{plugin-BIkt3boU.mjs → plugin-CuoGEYWr.mjs} +23 -23
  56. package/dist/{plugin-Dw8_Q8rE.js → plugin-DNhaPAbC.js} +1 -1
  57. package/dist/{sections-D1d83mfH.js → sections-BYdyCKFF.js} +1 -1
  58. package/dist/{sections-DcUfZQNE.mjs → sections-vLd_ind5.mjs} +4 -4
  59. package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
  60. package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -1
  61. package/dist/src/managers/MeteoraPoolManager.d.ts.map +1 -1
  62. package/dist/src/utils/optionalPeerImport.d.ts +6 -0
  63. package/dist/src/utils/optionalPeerImport.d.ts.map +1 -0
  64. package/package.json +1 -1
  65. package/dist/Token22Section-Di5fHsrU.js +0 -1
  66. package/dist/pay-react_false-CPX8Vyp9.mjs +0 -5
  67. package/dist/pay-react_false-DaeIe3_l.js +0 -1
@@ -1,9 +1,9 @@
1
1
  import { jsx as n, jsxs as r } from "react/jsx-runtime";
2
2
  import { useState as u, useRef as S, useCallback as A, useEffect as T, useMemo as q } from "react";
3
- import { I as w } from "./plugin-BIkt3boU.mjs";
4
- import { E as J } from "./ErrorBanner-DAjYj6Dx.mjs";
5
- import { F as Y } from "./Dropdown-0y3S40Xf.mjs";
6
- import { A as X } from "./AutosaveIndicator-D966vOrP.mjs";
3
+ import { I as w } from "./plugin-CuoGEYWr.mjs";
4
+ import { E as J } from "./ErrorBanner-7naZtdtD.mjs";
5
+ import { F as Y } from "./Dropdown-DHCHYuTB.mjs";
6
+ import { A as X } from "./AutosaveIndicator-BTa2YPNH.mjs";
7
7
  const C = [
8
8
  { id: "not_set", label: "Disabled", provider: null },
9
9
  { id: "gemini-2.5-flash", label: "Gemini 2.5 Flash", provider: "gemini" },
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),v=require("./plugin-Dw8_Q8rE.js"),G=require("./ErrorBanner-DxrRVqwe.js"),z=require("./Dropdown-BuKiVR_L.js"),B=require("./AutosaveIndicator-CJdkhZis.js"),w=[{id:"not_set",label:"Disabled",provider:null},{id:"gemini-2.5-flash",label:"Gemini 2.5 Flash",provider:"gemini"},{id:"gemini-2.5-pro",label:"Gemini 2.5 Pro",provider:"gemini"},{id:"openai-4o",label:"OpenAI 4o",provider:"openai"},{id:"openai-5.1",label:"OpenAI 5.1",provider:"openai"},{id:"openai-5.2",label:"OpenAI 5.2",provider:"openai"}],P=[{task:"site_chat",label:"Site Chat",description:"The conversational model that crafts responses to customer messages",defaultPrompt:`You are a friendly and helpful shopping assistant for our store. Your role is to:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),v=require("./plugin-DNhaPAbC.js"),G=require("./ErrorBanner-BOS1XAPu.js"),z=require("./Dropdown-CWYy2Rtt.js"),B=require("./AutosaveIndicator-BgDnlrCW.js"),w=[{id:"not_set",label:"Disabled",provider:null},{id:"gemini-2.5-flash",label:"Gemini 2.5 Flash",provider:"gemini"},{id:"gemini-2.5-pro",label:"Gemini 2.5 Pro",provider:"gemini"},{id:"openai-4o",label:"OpenAI 4o",provider:"openai"},{id:"openai-5.1",label:"OpenAI 5.1",provider:"openai"},{id:"openai-5.2",label:"OpenAI 5.2",provider:"openai"}],P=[{task:"site_chat",label:"Site Chat",description:"The conversational model that crafts responses to customer messages",defaultPrompt:`You are a friendly and helpful shopping assistant for our store. Your role is to:
2
2
 
3
3
  - Help customers find products that match their needs
4
4
  - Answer questions about products, shipping, returns, and store policies
@@ -1,5 +1,5 @@
1
1
  import { jsxs as n, jsx as r, Fragment as i } from "react/jsx-runtime";
2
- import { I as d } from "./plugin-BIkt3boU.mjs";
2
+ import { I as d } from "./plugin-CuoGEYWr.mjs";
3
3
  function l({ status: e, error: a }) {
4
4
  return e === "idle" ? null : /* @__PURE__ */ n(
5
5
  "span",
@@ -1 +1 @@
1
- "use strict";const e=require("react/jsx-runtime"),i=require("./plugin-Dw8_Q8rE.js");function a({status:n,error:r}){return n==="idle"?null:e.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${n}`,style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8125rem",color:n==="error"?"var(--cedros-admin-error, #ef4444)":"var(--cedros-admin-text-muted, #64748b)"},children:[n==="pending"&&e.jsx("span",{style:{opacity:.7},children:"Unsaved changes"}),n==="saving"&&e.jsxs(e.Fragment,{children:[i.Icons.loading,e.jsx("span",{children:"Saving..."})]}),n==="saved"&&e.jsxs(e.Fragment,{children:[i.Icons.check,e.jsx("span",{style:{color:"var(--cedros-admin-success, #22c55e)"},children:"Saved"})]}),n==="error"&&e.jsxs("span",{children:["Save failed",r?`: ${r}`:""]})]})}exports.AutosaveIndicator=a;
1
+ "use strict";const e=require("react/jsx-runtime"),i=require("./plugin-DNhaPAbC.js");function a({status:n,error:r}){return n==="idle"?null:e.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${n}`,style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8125rem",color:n==="error"?"var(--cedros-admin-error, #ef4444)":"var(--cedros-admin-text-muted, #64748b)"},children:[n==="pending"&&e.jsx("span",{style:{opacity:.7},children:"Unsaved changes"}),n==="saving"&&e.jsxs(e.Fragment,{children:[i.Icons.loading,e.jsx("span",{children:"Saving..."})]}),n==="saved"&&e.jsxs(e.Fragment,{children:[i.Icons.check,e.jsx("span",{style:{color:"var(--cedros-admin-success, #22c55e)"},children:"Saved"})]}),n==="error"&&e.jsxs("span",{children:["Save failed",r?`: ${r}`:""]})]})}exports.AutosaveIndicator=a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),I=require("./plugin-Dw8_Q8rE.js"),D=require("./ErrorBanner-DxrRVqwe.js"),o=require("./dateHelpers-BKW_lGND.js");function $({serverUrl:_,apiKey:l,pageSize:i=20,authManager:m}){const[g,p]=n.useState([]),[h,w]=n.useState(0),[r,u]=n.useState(0),[A,b]=n.useState(!0),[k,x]=n.useState(null),[d,T]=n.useState("all"),[y,v]=n.useState(null),[L,S]=n.useState(!1),f=n.useCallback(async t=>{if(m?.isAuthenticated())return m.fetchWithAuth(t);const a={"Content-Type":"application/json"};l&&(a["X-API-Key"]=l);const s=await fetch(`${_}${t}`,{headers:a});if(!s.ok)throw new Error(`Request failed: ${s.status}`);return s.json()},[_,l,m]),C=n.useCallback(async()=>{b(!0),x(null);try{const t=new URLSearchParams;t.set("limit",String(i)),t.set("offset",String(r)),d!=="all"&&t.set("status",d);const a=await f(`/admin/chats?${t.toString()}`);p(a.sessions??[]),w(a.total??0)}catch{x("Failed to load chat sessions"),p([])}finally{b(!1)}},[f,i,r,d]);n.useEffect(()=>{C()},[C]);const E=async t=>{S(!0);try{const a=await f(`/admin/chats/${encodeURIComponent(t)}`);v(a)}catch{x("Failed to load chat session")}finally{S(!1)}},j=Math.max(1,Math.ceil(h/i)),N=Math.floor(r/i)+1;if(y){const{session:t,messages:a}=y;return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>v(null),style:{marginBottom:"1rem"},children:"← Back to sessions"}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Chat Session",e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--muted",style:{marginLeft:"0.5rem"},children:[t.messageCount," messages"]})]})}),e.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)",marginBottom:"1rem"},children:[t.customerEmail&&e.jsxs("span",{children:["Customer: ",e.jsx("strong",{children:t.customerEmail})," · "]}),"Started ",o.formatDateTime(t.createdAt)," · Last message ",o.formatDateTime(t.lastMessageAt)]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",maxWidth:"640px"},children:a.map(s=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:s.role==="user"?"flex-end":"flex-start"},children:[e.jsx("div",{style:{maxWidth:"85%",padding:"0.5rem 0.75rem",borderRadius:"0.75rem",fontSize:"0.85rem",lineHeight:"1.4",background:s.role==="user"?"var(--cedros-admin-bg-dark, #1a1a1a)":"var(--cedros-admin-bg-muted, #f5f5f5)",color:s.role==="user"?"#fff":"var(--cedros-admin-text, #333)"},children:e.jsx("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.content})}),s.products&&s.products.length>0&&e.jsx("div",{style:{maxWidth:"85%",marginTop:"0.25rem",display:"flex",flexWrap:"wrap",gap:"0.25rem"},children:s.products.map(c=>e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--muted",style:{fontSize:"0.75rem"},children:[c.name,c.priceCents!=null?` ($${(c.priceCents/100).toFixed(2)})`:""]},c.id))}),s.actions&&s.actions.length>0&&e.jsx("div",{style:{maxWidth:"85%",marginTop:"0.25rem",fontSize:"0.75rem",fontStyle:"italic",color:"var(--cedros-admin-text-muted, #888)"},children:s.actions.join(" · ")}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #aaa)",marginTop:"0.15rem"},children:o.formatDateTime(s.createdAt)})]},s.id))})]})}return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Chat Logs"})}),e.jsx(D.ErrorBanner,{message:k}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",value:d,onChange:t=>{T(t.target.value),u(0)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"archived",children:"Archived"})]}),e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:[h," session",h!==1?"s":""]})]}),A||L?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading chat sessions..."]}):g.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No chat sessions 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:"Customer"}),e.jsx("th",{children:"Messages"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Last Message"}),e.jsx("th",{children:"Started"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:g.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.customerEmail?e.jsx("span",{title:t.customerId,children:t.customerEmail}):t.customerId?e.jsxs("code",{style:{fontSize:"0.75rem"},children:[t.customerId.slice(0,12),"..."]}):e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"Anonymous"})}),e.jsx("td",{children:t.messageCount}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.status==="active"?"success":"muted"}`,children:t.status})}),e.jsx("td",{children:o.formatDateTime(t.lastMessageAt)}),e.jsx("td",{children:o.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:()=>E(t.id),children:"View"})})]},t.id))})]})}),j>1&&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:r===0,onClick:()=>u(Math.max(0,r-i)),children:"Previous"}),e.jsxs("span",{children:["Page ",N," of ",j]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:N>=j,onClick:()=>u(r+i),children:"Next"})]})]})]})}exports.ChatLogsSection=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),I=require("./plugin-DNhaPAbC.js"),D=require("./ErrorBanner-BOS1XAPu.js"),o=require("./dateHelpers-BKW_lGND.js");function $({serverUrl:_,apiKey:l,pageSize:i=20,authManager:m}){const[g,p]=n.useState([]),[h,w]=n.useState(0),[r,u]=n.useState(0),[A,b]=n.useState(!0),[k,x]=n.useState(null),[d,T]=n.useState("all"),[y,v]=n.useState(null),[L,S]=n.useState(!1),f=n.useCallback(async t=>{if(m?.isAuthenticated())return m.fetchWithAuth(t);const a={"Content-Type":"application/json"};l&&(a["X-API-Key"]=l);const s=await fetch(`${_}${t}`,{headers:a});if(!s.ok)throw new Error(`Request failed: ${s.status}`);return s.json()},[_,l,m]),C=n.useCallback(async()=>{b(!0),x(null);try{const t=new URLSearchParams;t.set("limit",String(i)),t.set("offset",String(r)),d!=="all"&&t.set("status",d);const a=await f(`/admin/chats?${t.toString()}`);p(a.sessions??[]),w(a.total??0)}catch{x("Failed to load chat sessions"),p([])}finally{b(!1)}},[f,i,r,d]);n.useEffect(()=>{C()},[C]);const E=async t=>{S(!0);try{const a=await f(`/admin/chats/${encodeURIComponent(t)}`);v(a)}catch{x("Failed to load chat session")}finally{S(!1)}},j=Math.max(1,Math.ceil(h/i)),N=Math.floor(r/i)+1;if(y){const{session:t,messages:a}=y;return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>v(null),style:{marginBottom:"1rem"},children:"← Back to sessions"}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Chat Session",e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--muted",style:{marginLeft:"0.5rem"},children:[t.messageCount," messages"]})]})}),e.jsxs("div",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)",marginBottom:"1rem"},children:[t.customerEmail&&e.jsxs("span",{children:["Customer: ",e.jsx("strong",{children:t.customerEmail})," · "]}),"Started ",o.formatDateTime(t.createdAt)," · Last message ",o.formatDateTime(t.lastMessageAt)]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",maxWidth:"640px"},children:a.map(s=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:s.role==="user"?"flex-end":"flex-start"},children:[e.jsx("div",{style:{maxWidth:"85%",padding:"0.5rem 0.75rem",borderRadius:"0.75rem",fontSize:"0.85rem",lineHeight:"1.4",background:s.role==="user"?"var(--cedros-admin-bg-dark, #1a1a1a)":"var(--cedros-admin-bg-muted, #f5f5f5)",color:s.role==="user"?"#fff":"var(--cedros-admin-text, #333)"},children:e.jsx("span",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.content})}),s.products&&s.products.length>0&&e.jsx("div",{style:{maxWidth:"85%",marginTop:"0.25rem",display:"flex",flexWrap:"wrap",gap:"0.25rem"},children:s.products.map(c=>e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--muted",style:{fontSize:"0.75rem"},children:[c.name,c.priceCents!=null?` ($${(c.priceCents/100).toFixed(2)})`:""]},c.id))}),s.actions&&s.actions.length>0&&e.jsx("div",{style:{maxWidth:"85%",marginTop:"0.25rem",fontSize:"0.75rem",fontStyle:"italic",color:"var(--cedros-admin-text-muted, #888)"},children:s.actions.join(" · ")}),e.jsx("div",{style:{fontSize:"0.7rem",color:"var(--cedros-admin-text-muted, #aaa)",marginTop:"0.15rem"},children:o.formatDateTime(s.createdAt)})]},s.id))})]})}return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Chat Logs"})}),e.jsx(D.ErrorBanner,{message:k}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",value:d,onChange:t=>{T(t.target.value),u(0)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"archived",children:"Archived"})]}),e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:[h," session",h!==1?"s":""]})]}),A||L?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading chat sessions..."]}):g.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No chat sessions 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:"Customer"}),e.jsx("th",{children:"Messages"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Last Message"}),e.jsx("th",{children:"Started"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:g.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.customerEmail?e.jsx("span",{title:t.customerId,children:t.customerEmail}):t.customerId?e.jsxs("code",{style:{fontSize:"0.75rem"},children:[t.customerId.slice(0,12),"..."]}):e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"Anonymous"})}),e.jsx("td",{children:t.messageCount}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${t.status==="active"?"success":"muted"}`,children:t.status})}),e.jsx("td",{children:o.formatDateTime(t.lastMessageAt)}),e.jsx("td",{children:o.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:()=>E(t.id),children:"View"})})]},t.id))})]})}),j>1&&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:r===0,onClick:()=>u(Math.max(0,r-i)),children:"Previous"}),e.jsxs("span",{children:["Page ",N," of ",j]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:N>=j,onClick:()=>u(r+i),children:"Next"})]})]})]})}exports.ChatLogsSection=$;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as s, jsx as e, Fragment as W } from "react/jsx-runtime";
2
2
  import { useState as i, useCallback as k, useEffect as j } from "react";
3
- import { I as B } from "./plugin-BIkt3boU.mjs";
4
- import { E as M } from "./ErrorBanner-DAjYj6Dx.mjs";
3
+ import { I as B } from "./plugin-CuoGEYWr.mjs";
4
+ import { E as M } from "./ErrorBanner-7naZtdtD.mjs";
5
5
  import { f as d } from "./dateHelpers-yvPkofYQ.mjs";
6
6
  function H({ serverUrl: b, apiKey: m, pageSize: o = 20, authManager: h }) {
7
7
  const [y, v] = i([]), [u, I] = i(0), [r, f] = i(0), [E, x] = i(!0), [L, _] = i(null), [c, $] = i("all"), [S, C] = i(null), [F, N] = i(!1), p = k(async (t) => {
@@ -1,8 +1,8 @@
1
1
  import { jsxs as n, jsx as e, Fragment as j } from "react/jsx-runtime";
2
2
  import { useState as i, useCallback as L, useEffect as U } from "react";
3
- import { I as $ } from "./plugin-BIkt3boU.mjs";
4
- import { E as me } from "./ErrorBanner-DAjYj6Dx.mjs";
5
- import { S as Z } from "./StatsBar-CwCBHBn-.mjs";
3
+ import { I as $ } from "./plugin-CuoGEYWr.mjs";
4
+ import { E as me } from "./ErrorBanner-7naZtdtD.mjs";
5
+ import { S as Z } from "./StatsBar-B_lf0ph0.mjs";
6
6
  import { g as v } from "./fetchWithTimeout-DmMOwL0Q.mjs";
7
7
  import { f as E } from "./dateHelpers-yvPkofYQ.mjs";
8
8
  const b = (s) => s.length > 12 ? `${s.slice(0, 6)}...${s.slice(-4)}` : s, he = (s) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),I=require("./plugin-Dw8_Q8rE.js"),ce=require("./ErrorBanner-DxrRVqwe.js"),V=require("./StatsBar-DDUWoizP.js"),_=require("./fetchWithTimeout-CG0EKbhf.js"),R=require("./dateHelpers-BKW_lGND.js"),j=a=>a.length>12?`${a.slice(0,6)}...${a.slice(-4)}`:a,de=a=>{switch(a){case"active":return"success";case"frozen":return"failed";case"thawed":return"pending";default:return"muted"}},X=a=>{switch(a){case"freeze":return"failed";case"thaw":return"success";case"sweep_freeze":return"failed";case"report_generated":return"muted";default:return"muted"}},oe=a=>{switch(a){case"verified":return"success";case"pending":return"pending";case"expired":return"failed";case"none":default:return"muted"}},le="https://explorer.solana.com/tx/",me={apiUrl:"",refreshIntervalSecs:3600,enabled:!1};function he({serverUrl:a,apiKey:m,authManager:h}){const[r,o]=n.useState(me),[y,C]=n.useState(!0),[u,g]=n.useState(!1),[i,w]=n.useState(!1),[N,p]=n.useState(null),[A,f]=n.useState(null),b=n.useCallback(async(s,l)=>{if(h?.isAuthenticated())return h.fetchWithAuth(s,l);const S={"Content-Type":"application/json"};m&&(S["X-API-Key"]=m);const T=await fetch(`${a}${s}`,{...l,headers:{...S,...l?.headers}});if(!T.ok)throw new Error(`Request failed: ${T.status}`);return T.json()},[a,m,h]);n.useEffect(()=>{(async()=>{try{const s=await b("/admin/compliance/sanctions-api");o(s)}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Failed to fetch settings:",s)}finally{C(!1)}})()},[b]);const k=async()=>{g(!0),p(null),f(null);try{await b("/admin/compliance/sanctions-api",{method:"PUT",body:JSON.stringify(r)}),f("Settings saved")}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Save failed:",s),p("Failed to save settings")}finally{g(!1)}},d=async()=>{w(!0),p(null),f(null);try{await b("/admin/compliance/sanctions-api/refresh",{method:"POST"}),f("Sanctions list refreshed")}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Refresh failed:",s),p("Failed to refresh sanctions list")}finally{w(!1)}};return y?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading sanctions API settings..."]}):e.jsxs("div",{style:{maxWidth:"500px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Dynamic Sanctions API"})}),N&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem"},children:N}),A&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--success",style:{padding:"0.5rem"},children:A}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:r.enabled,onChange:s=>o(l=>({...l,enabled:s.target.checked}))}),"Enable dynamic sanctions list"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["API URL",e.jsx("input",{type:"url",className:"cedros-admin__input",placeholder:"https://sunscreen.cedros.io",value:r.apiUrl,onChange:s=>o(l=>({...l,apiUrl:s.target.value}))})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Refresh interval (seconds, min 60)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:60,value:r.refreshIntervalSecs,onChange:s=>o(l=>({...l,refreshIntervalSecs:Number(s.target.value)})),style:{width:"160px"}})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:k,disabled:u,children:u?"Saving...":"Save Settings"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:d,disabled:i||!r.enabled||!r.apiUrl,children:i?"Refreshing...":"Force Refresh"})]})]})}function ue({serverUrl:a,apiKey:m,authManager:h}){const[r,o]=n.useState(""),[y,C]=n.useState(!1),[u,g]=n.useState(null),[i,w]=n.useState(null),[N,p]=n.useState(!1),A=n.useCallback(async(d,s)=>{if(h?.isAuthenticated())return h.fetchWithAuth(d,s);const l={"Content-Type":"application/json"};m&&(l["X-API-Key"]=m);const S=await fetch(`${a}${d}`,{...s,headers:{...l,...s?.headers}});if(!S.ok)throw new Error(`Request failed: ${S.status}`);return S.json()},[a,m,h]),f=async()=>{const d=r.trim();if(d){C(!0),g(null),w(null),p(!0);try{const s=await A(`/admin/compliance/user-status/${encodeURIComponent(d)}`);w(s)}catch(s){_.getLogger().error("[ComplianceKycTab] Lookup failed:",s),g("Failed to fetch user compliance status. Ensure cedros-login is configured.")}finally{C(!1)}}},b=d=>{d.key==="Enter"&&f()},k=d=>{switch(d){case"verified":return"Verified";case"pending":return"Pending";case"expired":return"Expired";case"none":default:return"Not Started"}};return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"KYC & Accredited Investor Status"})}),e.jsx("p",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)",marginBottom:"1rem"},children:"Look up a user's KYC verification and accredited investor status from cedros-login."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsxs("label",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["User ID",e.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"user_abc123",value:r,onChange:d=>o(d.target.value),onKeyDown:b})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:f,disabled:y||!r.trim(),children:y?"Looking up...":"Look Up"})]}),u&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem",marginBottom:"1rem"},children:u}),y&&e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Fetching compliance status..."]}),i&&!y&&e.jsxs("div",{style:{maxWidth:"500px"},children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsx("table",{className:"cedros-admin__table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"40%"},children:"User ID"}),e.jsx("td",{children:e.jsx("code",{children:i.userId})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"KYC Status"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${oe(i.kycStatus)}`,children:k(i.kycStatus)})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Accredited Investor"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${i.accreditedInvestor?"success":"muted"}`,children:i.accreditedInvestor?"Yes":"No"})})]}),i.accreditedVerifiedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Accredited Since"}),e.jsx("td",{children:R.formatDateTime(i.accreditedVerifiedAt)})]})]})})}),e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem",borderRadius:"4px",fontSize:"0.85rem",background:i.kycStatus==="verified"?"var(--cedros-admin-bg-success, #f0fdf4)":"var(--cedros-admin-bg-muted, #f5f5f5)",color:"var(--cedros-admin-text, #333)"},children:i.kycStatus==="verified"&&i.accreditedInvestor?"This user is fully verified and accredited. They can access all compliance-gated products.":i.kycStatus==="verified"?"This user has KYC verification but is not an accredited investor.":i.kycStatus==="pending"?"This user has submitted KYC documents. Verification is in progress.":i.kycStatus==="expired"?"This user's KYC verification has expired. They will need to re-verify.":"This user has not started KYC verification."})]}),N&&!i&&!y&&!u&&e.jsx("div",{className:"cedros-admin__empty",children:"No compliance record found for this user."})]})}function xe({serverUrl:a,apiKey:m,pageSize:h=50,authManager:r}){const[o,y]=n.useState("holders"),[C,u]=n.useState(null),[g,i]=n.useState([]),[w,N]=n.useState(!0),[p,A]=n.useState(""),[f,b]=n.useState([]),[k,d]=n.useState(!0),[s,l]=n.useState(null),[S,T]=n.useState(!1),[W,M]=n.useState(""),[B,Q]=n.useState(""),[O,H]=n.useState({enabled:!0,batchSize:100}),[Z,ee]=n.useState(!0),[q,Y]=n.useState(!1),[x,z]=n.useState(null),[$,D]=n.useState(""),[F,K]=n.useState(!1),v=n.useCallback(async(t,c)=>{if(r?.isAuthenticated())return r.fetchWithAuth(t,c);const L={"Content-Type":"application/json"};m&&(L["X-API-Key"]=m);const U=await fetch(`${a}${t}`,{...c,headers:{...L,...c?.headers}});if(!U.ok)throw new Error(`Request failed: ${U.status}`);return U.json()},[a,m,r]),E=n.useCallback(async()=>{try{const t=p?`&status=${p}`:"",c=await v(`/admin/compliance/holders?limit=${h}&offset=0${t}`);i(c.holders||[])}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch holders:",t),i([]),u("Failed to load token holders")}finally{N(!1)}},[v,h,p]),P=n.useCallback(async()=>{try{const t=await v(`/admin/compliance/actions?limit=${h}&offset=0`);b(t.actions||[])}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch actions:",t),b([]),u("Failed to load compliance actions")}finally{d(!1)}},[v,h]),J=n.useCallback(async()=>{try{const t=await v("/admin/compliance/sweep-settings");H(t)}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch sweep settings:",t)}finally{ee(!1)}},[v]),te=async()=>{Y(!0);try{await v("/admin/compliance/sweep-settings",{method:"PUT",body:JSON.stringify(O)})}catch(t){_.getLogger().error("[ComplianceSection] Failed to save sweep settings:",t),u("Failed to save sweep settings")}finally{Y(!1)}};n.useEffect(()=>{E()},[E]),n.useEffect(()=>{P()},[P]),n.useEffect(()=>{J()},[J]);const se=async()=>{if(!(!x||!$.trim())){K(!0);try{const t=x.action==="freeze"?"/admin/compliance/freeze":"/admin/compliance/thaw";await v(t,{method:"POST",body:JSON.stringify({holderId:x.holder.id,reason:$})}),z(null),D(""),await E(),await P()}catch(t){_.getLogger().error(`[ComplianceSection] ${x.action} failed:`,t),u(`Failed to ${x.action} holder`)}finally{K(!1)}}},ne=async()=>{T(!0);try{const t=new URLSearchParams;W&&t.set("from",new Date(W).toISOString()),B&&t.set("to",new Date(B).toISOString());const c=await v(`/admin/compliance/report?${t.toString()}`);l(c.report)}catch(t){_.getLogger().error("[ComplianceSection] Failed to generate report:",t),u("Failed to generate compliance report")}finally{T(!1)}},ae=()=>{if(!s)return;const t=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),c=URL.createObjectURL(t),L=document.createElement("a");L.href=c,L.download=`compliance-report-${new Date().toISOString().slice(0,10)}.json`,L.click(),URL.revokeObjectURL(c)},ie=g.length,G=g.filter(t=>t.status==="frozen").length,re=g.filter(t=>t.status==="active").length;return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(ce.ErrorBanner,{message:C,onRetry:()=>{E(),P()}}),e.jsx(V.StatsBar,{stats:[{label:"Total Holders",value:ie},{label:"Active",value:re,variant:"success"},{label:"Frozen",value:G,variant:G>0?"warning":"muted"},{label:"Actions Logged",value:f.length}],isLoading:w||k}),e.jsx("div",{className:"cedros-admin__tabs",style:{display:"flex",gap:"0.5rem",marginBottom:"1rem"},children:["holders","actions","reports","sweep-settings","sanctions-api","kyc"].map(t=>{const c=t==="holders"?"Token Holders":t==="actions"?"Actions Log":t==="reports"?"Reports":t==="sweep-settings"?"Sweep Settings":t==="sanctions-api"?"Sanctions API":"KYC & Accreditation";return e.jsx("button",{type:"button",className:`cedros-admin__button ${o===t?"cedros-admin__button--primary":"cedros-admin__button--ghost"}`,onClick:()=>y(t),children:c},t)})}),o==="holders"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__section-header",style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Token Holders"}),e.jsxs("select",{value:p,onChange:t=>{A(t.target.value),N(!0)},className:"cedros-admin__input",style:{width:"auto",padding:"0.25rem 0.5rem",fontSize:"0.85rem"},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"frozen",children:"Frozen"}),e.jsx("option",{value:"thawed",children:"Thawed"})]})]}),w?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading holders..."]}):g.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No token holders found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"Mint"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:g.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:e.jsx("code",{title:t.collectionId,children:j(t.collectionId)})}),e.jsx("td",{children:e.jsx("code",{title:t.mintAddress,children:j(t.mintAddress)})}),e.jsx("td",{children:t.amountMinted}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${de(t.status)}`,children:t.status})}),e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:t.status==="active"||t.status==="thawed"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger cedros-admin__button--sm",onClick:()=>{z({holder:t,action:"freeze"}),D("")},children:"Freeze"}):t.status==="frozen"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{z({holder:t,action:"thaw"}),D("")},children:"Thaw"}):null})]},t.id))})]})})]}),o==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Actions"})}),k?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading actions..."]}):f.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No compliance actions recorded."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"}),e.jsx("th",{children:"Tx Signature"})]})}),e.jsx("tbody",{children:f.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${X(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:j(t.actor)})}),e.jsx("td",{children:t.txSignature?e.jsx("a",{href:`${le}${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin__link",children:j(t.txSignature)}):"—"})]},t.id))})]})})]}),o==="reports"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Report"})}),e.jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"flex-end",marginBottom:"1rem"},children:[e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["From",e.jsx("input",{type:"date",className:"cedros-admin__input",value:W,onChange:t=>M(t.target.value)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["To",e.jsx("input",{type:"date",className:"cedros-admin__input",value:B,onChange:t=>Q(t.target.value)})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:ne,disabled:S,children:S?"Generating...":"Generate Report"})]}),s&&e.jsxs("div",{children:[e.jsx(V.StatsBar,{stats:[{label:"Total Holders",value:s.totalHolders},{label:"Frozen",value:s.totalFrozen,variant:s.totalFrozen>0?"warning":"muted"},{label:"Freezes",value:s.freezeCount},{label:"Thaws",value:s.thawCount},{label:"Sweep Freezes",value:s.sweepFreezeCount,variant:s.sweepFreezeCount>0?"warning":"muted"}],isLoading:!1}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"1rem 0 0.5rem"},children:[e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:["Generated ",R.formatDateTime(s.generatedAt)," · ",s.actionsInPeriod," actions in period"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:ae,children:"Download JSON"})]}),s.actions.length>0&&e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:s.actions.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${X(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:j(t.actor)})})]},t.id))})]})})]})]}),o==="sweep-settings"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Sanctions Sweep Settings"})}),Z?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading settings..."]}):e.jsxs("div",{style:{maxWidth:"400px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:O.enabled,onChange:t=>H(c=>({...c,enabled:t.target.checked}))}),"Enable automated sanctions sweep"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Batch size (1 – 10,000)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:1,max:1e4,value:O.batchSize,onChange:t=>H(c=>({...c,batchSize:Number(t.target.value)})),style:{width:"160px"}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:te,disabled:q,style:{alignSelf:"flex-start"},children:q?"Saving...":"Save Settings"})]})]}),o==="sanctions-api"&&e.jsx(he,{serverUrl:a,apiKey:m,authManager:r}),o==="kyc"&&e.jsx(ue,{serverUrl:a,apiKey:m,authManager:r}),x&&e.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>!F&&z(null),children:e.jsxs("div",{className:"cedros-admin__modal",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"cedros-admin__modal-header",children:[e.jsxs("h4",{className:"cedros-admin__modal-title",children:[x.action==="freeze"?"Freeze":"Thaw"," Token Account"]}),e.jsx("button",{type:"button",className:"cedros-admin__modal-close",onClick:()=>!F&&z(null),children:I.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__modal-body",children:[e.jsxs("p",{style:{marginBottom:"0.5rem",fontSize:"0.9rem"},children:["Wallet: ",e.jsx("code",{children:j(x.holder.walletAddress)})]}),e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem"},children:["Mint: ",e.jsx("code",{children:j(x.holder.mintAddress)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Reason (required)",e.jsx("textarea",{className:"cedros-admin__input",rows:3,value:$,onChange:t=>D(t.target.value),placeholder:`Reason for ${x.action}...`,maxLength:1024})]})]}),e.jsxs("div",{className:"cedros-admin__modal-footer",children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>z(null),disabled:F,children:"Cancel"}),e.jsx("button",{className:`cedros-admin__button ${x.action==="freeze"?"cedros-admin__button--danger":"cedros-admin__button--primary"}`,onClick:se,disabled:F||!$.trim(),children:F?"Processing...":x.action==="freeze"?"Freeze Account":"Thaw Account"})]})]})})]})}exports.ComplianceSection=xe;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),I=require("./plugin-DNhaPAbC.js"),ce=require("./ErrorBanner-BOS1XAPu.js"),V=require("./StatsBar-CVqsD8j2.js"),_=require("./fetchWithTimeout-CG0EKbhf.js"),R=require("./dateHelpers-BKW_lGND.js"),j=a=>a.length>12?`${a.slice(0,6)}...${a.slice(-4)}`:a,de=a=>{switch(a){case"active":return"success";case"frozen":return"failed";case"thawed":return"pending";default:return"muted"}},X=a=>{switch(a){case"freeze":return"failed";case"thaw":return"success";case"sweep_freeze":return"failed";case"report_generated":return"muted";default:return"muted"}},oe=a=>{switch(a){case"verified":return"success";case"pending":return"pending";case"expired":return"failed";case"none":default:return"muted"}},le="https://explorer.solana.com/tx/",me={apiUrl:"",refreshIntervalSecs:3600,enabled:!1};function he({serverUrl:a,apiKey:m,authManager:h}){const[r,o]=n.useState(me),[y,C]=n.useState(!0),[u,g]=n.useState(!1),[i,w]=n.useState(!1),[N,p]=n.useState(null),[A,f]=n.useState(null),b=n.useCallback(async(s,l)=>{if(h?.isAuthenticated())return h.fetchWithAuth(s,l);const S={"Content-Type":"application/json"};m&&(S["X-API-Key"]=m);const T=await fetch(`${a}${s}`,{...l,headers:{...S,...l?.headers}});if(!T.ok)throw new Error(`Request failed: ${T.status}`);return T.json()},[a,m,h]);n.useEffect(()=>{(async()=>{try{const s=await b("/admin/compliance/sanctions-api");o(s)}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Failed to fetch settings:",s)}finally{C(!1)}})()},[b]);const k=async()=>{g(!0),p(null),f(null);try{await b("/admin/compliance/sanctions-api",{method:"PUT",body:JSON.stringify(r)}),f("Settings saved")}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Save failed:",s),p("Failed to save settings")}finally{g(!1)}},d=async()=>{w(!0),p(null),f(null);try{await b("/admin/compliance/sanctions-api/refresh",{method:"POST"}),f("Sanctions list refreshed")}catch(s){_.getLogger().error("[ComplianceSanctionsApi] Refresh failed:",s),p("Failed to refresh sanctions list")}finally{w(!1)}};return y?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading sanctions API settings..."]}):e.jsxs("div",{style:{maxWidth:"500px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Dynamic Sanctions API"})}),N&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem"},children:N}),A&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--success",style:{padding:"0.5rem"},children:A}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:r.enabled,onChange:s=>o(l=>({...l,enabled:s.target.checked}))}),"Enable dynamic sanctions list"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["API URL",e.jsx("input",{type:"url",className:"cedros-admin__input",placeholder:"https://sunscreen.cedros.io",value:r.apiUrl,onChange:s=>o(l=>({...l,apiUrl:s.target.value}))})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Refresh interval (seconds, min 60)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:60,value:r.refreshIntervalSecs,onChange:s=>o(l=>({...l,refreshIntervalSecs:Number(s.target.value)})),style:{width:"160px"}})]}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:k,disabled:u,children:u?"Saving...":"Save Settings"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:d,disabled:i||!r.enabled||!r.apiUrl,children:i?"Refreshing...":"Force Refresh"})]})]})}function ue({serverUrl:a,apiKey:m,authManager:h}){const[r,o]=n.useState(""),[y,C]=n.useState(!1),[u,g]=n.useState(null),[i,w]=n.useState(null),[N,p]=n.useState(!1),A=n.useCallback(async(d,s)=>{if(h?.isAuthenticated())return h.fetchWithAuth(d,s);const l={"Content-Type":"application/json"};m&&(l["X-API-Key"]=m);const S=await fetch(`${a}${d}`,{...s,headers:{...l,...s?.headers}});if(!S.ok)throw new Error(`Request failed: ${S.status}`);return S.json()},[a,m,h]),f=async()=>{const d=r.trim();if(d){C(!0),g(null),w(null),p(!0);try{const s=await A(`/admin/compliance/user-status/${encodeURIComponent(d)}`);w(s)}catch(s){_.getLogger().error("[ComplianceKycTab] Lookup failed:",s),g("Failed to fetch user compliance status. Ensure cedros-login is configured.")}finally{C(!1)}}},b=d=>{d.key==="Enter"&&f()},k=d=>{switch(d){case"verified":return"Verified";case"pending":return"Pending";case"expired":return"Expired";case"none":default:return"Not Started"}};return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"KYC & Accredited Investor Status"})}),e.jsx("p",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)",marginBottom:"1rem"},children:"Look up a user's KYC verification and accredited investor status from cedros-login."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"flex-end",marginBottom:"1.5rem",maxWidth:"500px"},children:[e.jsxs("label",{style:{flex:1,display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["User ID",e.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"user_abc123",value:r,onChange:d=>o(d.target.value),onKeyDown:b})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:f,disabled:y||!r.trim(),children:y?"Looking up...":"Look Up"})]}),u&&e.jsx("div",{className:"cedros-admin__badge cedros-admin__badge--failed",style:{padding:"0.5rem",marginBottom:"1rem"},children:u}),y&&e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Fetching compliance status..."]}),i&&!y&&e.jsxs("div",{style:{maxWidth:"500px"},children:[e.jsx("div",{className:"cedros-admin__table-container",children:e.jsx("table",{className:"cedros-admin__table",children:e.jsxs("tbody",{children:[e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600,width:"40%"},children:"User ID"}),e.jsx("td",{children:e.jsx("code",{children:i.userId})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"KYC Status"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${oe(i.kycStatus)}`,children:k(i.kycStatus)})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Accredited Investor"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${i.accreditedInvestor?"success":"muted"}`,children:i.accreditedInvestor?"Yes":"No"})})]}),i.accreditedVerifiedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Accredited Since"}),e.jsx("td",{children:R.formatDateTime(i.accreditedVerifiedAt)})]})]})})}),e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.75rem",borderRadius:"4px",fontSize:"0.85rem",background:i.kycStatus==="verified"?"var(--cedros-admin-bg-success, #f0fdf4)":"var(--cedros-admin-bg-muted, #f5f5f5)",color:"var(--cedros-admin-text, #333)"},children:i.kycStatus==="verified"&&i.accreditedInvestor?"This user is fully verified and accredited. They can access all compliance-gated products.":i.kycStatus==="verified"?"This user has KYC verification but is not an accredited investor.":i.kycStatus==="pending"?"This user has submitted KYC documents. Verification is in progress.":i.kycStatus==="expired"?"This user's KYC verification has expired. They will need to re-verify.":"This user has not started KYC verification."})]}),N&&!i&&!y&&!u&&e.jsx("div",{className:"cedros-admin__empty",children:"No compliance record found for this user."})]})}function xe({serverUrl:a,apiKey:m,pageSize:h=50,authManager:r}){const[o,y]=n.useState("holders"),[C,u]=n.useState(null),[g,i]=n.useState([]),[w,N]=n.useState(!0),[p,A]=n.useState(""),[f,b]=n.useState([]),[k,d]=n.useState(!0),[s,l]=n.useState(null),[S,T]=n.useState(!1),[W,M]=n.useState(""),[B,Q]=n.useState(""),[O,H]=n.useState({enabled:!0,batchSize:100}),[Z,ee]=n.useState(!0),[q,Y]=n.useState(!1),[x,z]=n.useState(null),[$,D]=n.useState(""),[F,K]=n.useState(!1),v=n.useCallback(async(t,c)=>{if(r?.isAuthenticated())return r.fetchWithAuth(t,c);const L={"Content-Type":"application/json"};m&&(L["X-API-Key"]=m);const U=await fetch(`${a}${t}`,{...c,headers:{...L,...c?.headers}});if(!U.ok)throw new Error(`Request failed: ${U.status}`);return U.json()},[a,m,r]),E=n.useCallback(async()=>{try{const t=p?`&status=${p}`:"",c=await v(`/admin/compliance/holders?limit=${h}&offset=0${t}`);i(c.holders||[])}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch holders:",t),i([]),u("Failed to load token holders")}finally{N(!1)}},[v,h,p]),P=n.useCallback(async()=>{try{const t=await v(`/admin/compliance/actions?limit=${h}&offset=0`);b(t.actions||[])}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch actions:",t),b([]),u("Failed to load compliance actions")}finally{d(!1)}},[v,h]),J=n.useCallback(async()=>{try{const t=await v("/admin/compliance/sweep-settings");H(t)}catch(t){_.getLogger().error("[ComplianceSection] Failed to fetch sweep settings:",t)}finally{ee(!1)}},[v]),te=async()=>{Y(!0);try{await v("/admin/compliance/sweep-settings",{method:"PUT",body:JSON.stringify(O)})}catch(t){_.getLogger().error("[ComplianceSection] Failed to save sweep settings:",t),u("Failed to save sweep settings")}finally{Y(!1)}};n.useEffect(()=>{E()},[E]),n.useEffect(()=>{P()},[P]),n.useEffect(()=>{J()},[J]);const se=async()=>{if(!(!x||!$.trim())){K(!0);try{const t=x.action==="freeze"?"/admin/compliance/freeze":"/admin/compliance/thaw";await v(t,{method:"POST",body:JSON.stringify({holderId:x.holder.id,reason:$})}),z(null),D(""),await E(),await P()}catch(t){_.getLogger().error(`[ComplianceSection] ${x.action} failed:`,t),u(`Failed to ${x.action} holder`)}finally{K(!1)}}},ne=async()=>{T(!0);try{const t=new URLSearchParams;W&&t.set("from",new Date(W).toISOString()),B&&t.set("to",new Date(B).toISOString());const c=await v(`/admin/compliance/report?${t.toString()}`);l(c.report)}catch(t){_.getLogger().error("[ComplianceSection] Failed to generate report:",t),u("Failed to generate compliance report")}finally{T(!1)}},ae=()=>{if(!s)return;const t=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),c=URL.createObjectURL(t),L=document.createElement("a");L.href=c,L.download=`compliance-report-${new Date().toISOString().slice(0,10)}.json`,L.click(),URL.revokeObjectURL(c)},ie=g.length,G=g.filter(t=>t.status==="frozen").length,re=g.filter(t=>t.status==="active").length;return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(ce.ErrorBanner,{message:C,onRetry:()=>{E(),P()}}),e.jsx(V.StatsBar,{stats:[{label:"Total Holders",value:ie},{label:"Active",value:re,variant:"success"},{label:"Frozen",value:G,variant:G>0?"warning":"muted"},{label:"Actions Logged",value:f.length}],isLoading:w||k}),e.jsx("div",{className:"cedros-admin__tabs",style:{display:"flex",gap:"0.5rem",marginBottom:"1rem"},children:["holders","actions","reports","sweep-settings","sanctions-api","kyc"].map(t=>{const c=t==="holders"?"Token Holders":t==="actions"?"Actions Log":t==="reports"?"Reports":t==="sweep-settings"?"Sweep Settings":t==="sanctions-api"?"Sanctions API":"KYC & Accreditation";return e.jsx("button",{type:"button",className:`cedros-admin__button ${o===t?"cedros-admin__button--primary":"cedros-admin__button--ghost"}`,onClick:()=>y(t),children:c},t)})}),o==="holders"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin__section-header",style:{display:"flex",alignItems:"center",gap:"0.75rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Token Holders"}),e.jsxs("select",{value:p,onChange:t=>{A(t.target.value),N(!0)},className:"cedros-admin__input",style:{width:"auto",padding:"0.25rem 0.5rem",fontSize:"0.85rem"},children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"active",children:"Active"}),e.jsx("option",{value:"frozen",children:"Frozen"}),e.jsx("option",{value:"thawed",children:"Thawed"})]})]}),w?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading holders..."]}):g.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No token holders found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"Mint"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:g.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:e.jsx("code",{title:t.collectionId,children:j(t.collectionId)})}),e.jsx("td",{children:e.jsx("code",{title:t.mintAddress,children:j(t.mintAddress)})}),e.jsx("td",{children:t.amountMinted}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${de(t.status)}`,children:t.status})}),e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:t.status==="active"||t.status==="thawed"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger cedros-admin__button--sm",onClick:()=>{z({holder:t,action:"freeze"}),D("")},children:"Freeze"}):t.status==="frozen"?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{z({holder:t,action:"thaw"}),D("")},children:"Thaw"}):null})]},t.id))})]})})]}),o==="actions"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Actions"})}),k?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading actions..."]}):f.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No compliance actions recorded."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"}),e.jsx("th",{children:"Tx Signature"})]})}),e.jsx("tbody",{children:f.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${X(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:j(t.actor)})}),e.jsx("td",{children:t.txSignature?e.jsx("a",{href:`${le}${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-admin__link",children:j(t.txSignature)}):"—"})]},t.id))})]})})]}),o==="reports"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Compliance Report"})}),e.jsxs("div",{style:{display:"flex",gap:"0.75rem",alignItems:"flex-end",marginBottom:"1rem"},children:[e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["From",e.jsx("input",{type:"date",className:"cedros-admin__input",value:W,onChange:t=>M(t.target.value)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["To",e.jsx("input",{type:"date",className:"cedros-admin__input",value:B,onChange:t=>Q(t.target.value)})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:ne,disabled:S,children:S?"Generating...":"Generate Report"})]}),s&&e.jsxs("div",{children:[e.jsx(V.StatsBar,{stats:[{label:"Total Holders",value:s.totalHolders},{label:"Frozen",value:s.totalFrozen,variant:s.totalFrozen>0?"warning":"muted"},{label:"Freezes",value:s.freezeCount},{label:"Thaws",value:s.thawCount},{label:"Sweep Freezes",value:s.sweepFreezeCount,variant:s.sweepFreezeCount>0?"warning":"muted"}],isLoading:!1}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",margin:"1rem 0 0.5rem"},children:[e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:["Generated ",R.formatDateTime(s.generatedAt)," · ",s.actionsInPeriod," actions in period"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:ae,children:"Download JSON"})]}),s.actions.length>0&&e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Timestamp"}),e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Wallet"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:s.actions.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:R.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${X(t.actionType)}`,children:t.actionType})}),e.jsx("td",{children:e.jsx("code",{title:t.walletAddress,children:j(t.walletAddress)})}),e.jsx("td",{children:t.reason||"—"}),e.jsx("td",{children:e.jsx("code",{children:j(t.actor)})})]},t.id))})]})})]})]}),o==="sweep-settings"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Sanctions Sweep Settings"})}),Z?e.jsxs("div",{className:"cedros-admin__loading",children:[I.Icons.loading," Loading settings..."]}):e.jsxs("div",{style:{maxWidth:"400px",display:"flex",flexDirection:"column",gap:"1rem"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"0.5rem",fontSize:"0.9rem"},children:[e.jsx("input",{type:"checkbox",checked:O.enabled,onChange:t=>H(c=>({...c,enabled:t.target.checked}))}),"Enable automated sanctions sweep"]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Batch size (1 – 10,000)",e.jsx("input",{type:"number",className:"cedros-admin__input",min:1,max:1e4,value:O.batchSize,onChange:t=>H(c=>({...c,batchSize:Number(t.target.value)})),style:{width:"160px"}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:te,disabled:q,style:{alignSelf:"flex-start"},children:q?"Saving...":"Save Settings"})]})]}),o==="sanctions-api"&&e.jsx(he,{serverUrl:a,apiKey:m,authManager:r}),o==="kyc"&&e.jsx(ue,{serverUrl:a,apiKey:m,authManager:r}),x&&e.jsx("div",{className:"cedros-admin__modal-overlay",onClick:()=>!F&&z(null),children:e.jsxs("div",{className:"cedros-admin__modal",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"cedros-admin__modal-header",children:[e.jsxs("h4",{className:"cedros-admin__modal-title",children:[x.action==="freeze"?"Freeze":"Thaw"," Token Account"]}),e.jsx("button",{type:"button",className:"cedros-admin__modal-close",onClick:()=>!F&&z(null),children:I.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__modal-body",children:[e.jsxs("p",{style:{marginBottom:"0.5rem",fontSize:"0.9rem"},children:["Wallet: ",e.jsx("code",{children:j(x.holder.walletAddress)})]}),e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem"},children:["Mint: ",e.jsx("code",{children:j(x.holder.mintAddress)})]}),e.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:"0.25rem",fontSize:"0.85rem"},children:["Reason (required)",e.jsx("textarea",{className:"cedros-admin__input",rows:3,value:$,onChange:t=>D(t.target.value),placeholder:`Reason for ${x.action}...`,maxLength:1024})]})]}),e.jsxs("div",{className:"cedros-admin__modal-footer",children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>z(null),disabled:F,children:"Cancel"}),e.jsx("button",{className:`cedros-admin__button ${x.action==="freeze"?"cedros-admin__button--danger":"cedros-admin__button--primary"}`,onClick:se,disabled:F||!$.trim(),children:F?"Processing...":x.action==="freeze"?"Freeze Account":"Thaw Account"})]})]})})]})}exports.ComplianceSection=xe;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as s, jsx as t, Fragment as $ } from "react/jsx-runtime";
2
2
  import { useState as o, useCallback as I, useEffect as O } from "react";
3
- import { I as B } from "./plugin-BIkt3boU.mjs";
4
- import { E as q } from "./ErrorBanner-DAjYj6Dx.mjs";
3
+ import { I as B } from "./plugin-CuoGEYWr.mjs";
4
+ import { E as q } from "./ErrorBanner-7naZtdtD.mjs";
5
5
  import { f as J } from "./dateHelpers-yvPkofYQ.mjs";
6
6
  function G({ serverUrl: N, apiKey: p, pageSize: r = 20, authManager: f }) {
7
7
  const [_, v] = o([]), [k, x] = o(!0), [D, m] = o(null), [i, w] = o(0), [L, b] = o(!1), [S, E] = o(!1), [d, A] = o(null), [c, j] = o(""), [a, l] = o({ email: "", name: "", phone: "" }), h = I(async (e, n) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),P=require("./plugin-Dw8_Q8rE.js"),T=require("./ErrorBanner-DxrRVqwe.js"),O=require("./dateHelpers-BKW_lGND.js");function W({serverUrl:y,apiKey:h,pageSize:r=20,authManager:x}){const[_,g]=n.useState([]),[k,C]=n.useState(!0),[q,l]=n.useState(null),[i,N]=n.useState(0),[A,p]=n.useState(!1),[v,S]=n.useState(!1),[o,w]=n.useState(null),[c,F]=n.useState(""),[a,d]=n.useState({email:"",name:"",phone:""}),m=n.useCallback(async(t,s)=>{if(x?.isAuthenticated())return x.fetchWithAuth(t,s);const E={"Content-Type":"application/json"};h&&(E["X-API-Key"]=h);const b=await fetch(`${y}${t}`,{...s,headers:{...E,...s?.headers}});if(!b.ok)throw new Error(`Request failed: ${b.status}`);return b.json()},[y,h,x]),f=n.useCallback(async()=>{C(!0),l(null);try{const t=await m(`/admin/customers?limit=${r}&offset=${i}`);g(t.customers??[])}catch{l("Failed to load customers"),g([])}finally{C(!1)}},[m,r,i]);n.useEffect(()=>{f()},[f]);const j=()=>{d({email:"",name:"",phone:""}),w(null),p(!1)},D=t=>{w(t),d({email:t.email,name:t.name??"",phone:t.phone??""}),p(!0)},I=async t=>{t.preventDefault(),S(!0),l(null);try{o?await m(`/admin/customers/${encodeURIComponent(o.id)}`,{method:"PUT",body:JSON.stringify({email:a.email,name:a.name||null,phone:a.phone||null,addresses:o.addresses})}):await m("/admin/customers",{method:"POST",body:JSON.stringify({email:a.email,name:a.name||null,phone:a.phone||null,addresses:[]})}),j(),f()}catch(s){l(s instanceof Error?s.message:"Failed to save customer")}finally{S(!1)}},u=c.trim()?_.filter(t=>{const s=c.toLowerCase();return t.email.toLowerCase().includes(s)||(t.name??"").toLowerCase().includes(s)||t.id.toLowerCase().includes(s)}):_,L=t=>[t.line1,t.city,t.state,t.postalCode,t.country].filter(Boolean).join(", ");return e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Customers"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{j(),p(!0)},children:"+ Add Customer"})]}),e.jsx(T.ErrorBanner,{message:q}),e.jsx("div",{style:{marginBottom:"1rem",maxWidth:"400px"},children:e.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"Search by email, name, or ID...",value:c,onChange:t=>F(t.target.value),style:{fontSize:"0.85rem"}})}),A&&e.jsxs("form",{onSubmit:I,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:o?"Edit Customer":"New Customer"}),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:"Email *"}),e.jsx("input",{type:"email",className:"cedros-admin__input",value:a.email,onChange:t=>d(s=>({...s,email:t.target.value})),required:!0,placeholder:"customer@example.com"})]}),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:a.name,onChange:t=>d(s=>({...s,name:t.target.value})),placeholder:"Jane Doe"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Phone"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.phone,onChange:t=>d(s=>({...s,phone:t.target.value})),placeholder:"+1 555 123 4567"})]})]}),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:v,children:v?"Saving...":o?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:j,children:"Cancel"})]})]}),k?e.jsxs("div",{className:"cedros-admin__loading",children:[P.Icons.loading," Loading customers..."]}):u.length===0?e.jsx("div",{className:"cedros-admin__empty",children:c?"No matching customers.":"No customers 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:"Email"}),e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Phone"}),e.jsx("th",{children:"Address"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:u.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.email}),e.jsx("td",{children:t.name??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:t.phone??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.addresses.length>0?L(t.addresses[0]):"—"}),e.jsx("td",{children:O.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:()=>D(t),children:"Edit"})})]},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:i===0,onClick:()=>N(Math.max(0,i-r)),children:"Previous"}),e.jsxs("span",{children:["Showing ",u.length," customer",u.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:_.length<r,onClick:()=>N(i+r),children:"Next"})]})]})]})}exports.CustomersSection=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),P=require("./plugin-DNhaPAbC.js"),T=require("./ErrorBanner-BOS1XAPu.js"),O=require("./dateHelpers-BKW_lGND.js");function W({serverUrl:y,apiKey:h,pageSize:r=20,authManager:x}){const[_,g]=n.useState([]),[k,C]=n.useState(!0),[q,l]=n.useState(null),[i,N]=n.useState(0),[A,p]=n.useState(!1),[v,S]=n.useState(!1),[o,w]=n.useState(null),[c,F]=n.useState(""),[a,d]=n.useState({email:"",name:"",phone:""}),m=n.useCallback(async(t,s)=>{if(x?.isAuthenticated())return x.fetchWithAuth(t,s);const E={"Content-Type":"application/json"};h&&(E["X-API-Key"]=h);const b=await fetch(`${y}${t}`,{...s,headers:{...E,...s?.headers}});if(!b.ok)throw new Error(`Request failed: ${b.status}`);return b.json()},[y,h,x]),f=n.useCallback(async()=>{C(!0),l(null);try{const t=await m(`/admin/customers?limit=${r}&offset=${i}`);g(t.customers??[])}catch{l("Failed to load customers"),g([])}finally{C(!1)}},[m,r,i]);n.useEffect(()=>{f()},[f]);const j=()=>{d({email:"",name:"",phone:""}),w(null),p(!1)},D=t=>{w(t),d({email:t.email,name:t.name??"",phone:t.phone??""}),p(!0)},I=async t=>{t.preventDefault(),S(!0),l(null);try{o?await m(`/admin/customers/${encodeURIComponent(o.id)}`,{method:"PUT",body:JSON.stringify({email:a.email,name:a.name||null,phone:a.phone||null,addresses:o.addresses})}):await m("/admin/customers",{method:"POST",body:JSON.stringify({email:a.email,name:a.name||null,phone:a.phone||null,addresses:[]})}),j(),f()}catch(s){l(s instanceof Error?s.message:"Failed to save customer")}finally{S(!1)}},u=c.trim()?_.filter(t=>{const s=c.toLowerCase();return t.email.toLowerCase().includes(s)||(t.name??"").toLowerCase().includes(s)||t.id.toLowerCase().includes(s)}):_,L=t=>[t.line1,t.city,t.state,t.postalCode,t.country].filter(Boolean).join(", ");return e.jsxs("div",{children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Customers"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{j(),p(!0)},children:"+ Add Customer"})]}),e.jsx(T.ErrorBanner,{message:q}),e.jsx("div",{style:{marginBottom:"1rem",maxWidth:"400px"},children:e.jsx("input",{type:"text",className:"cedros-admin__input",placeholder:"Search by email, name, or ID...",value:c,onChange:t=>F(t.target.value),style:{fontSize:"0.85rem"}})}),A&&e.jsxs("form",{onSubmit:I,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:o?"Edit Customer":"New Customer"}),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:"Email *"}),e.jsx("input",{type:"email",className:"cedros-admin__input",value:a.email,onChange:t=>d(s=>({...s,email:t.target.value})),required:!0,placeholder:"customer@example.com"})]}),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:a.name,onChange:t=>d(s=>({...s,name:t.target.value})),placeholder:"Jane Doe"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Phone"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:a.phone,onChange:t=>d(s=>({...s,phone:t.target.value})),placeholder:"+1 555 123 4567"})]})]}),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:v,children:v?"Saving...":o?"Update":"Create"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:j,children:"Cancel"})]})]}),k?e.jsxs("div",{className:"cedros-admin__loading",children:[P.Icons.loading," Loading customers..."]}):u.length===0?e.jsx("div",{className:"cedros-admin__empty",children:c?"No matching customers.":"No customers 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:"Email"}),e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Phone"}),e.jsx("th",{children:"Address"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:u.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:t.email}),e.jsx("td",{children:t.name??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{children:t.phone??e.jsx("span",{style:{color:"var(--cedros-admin-text-muted, #888)"},children:"—"})}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.addresses.length>0?L(t.addresses[0]):"—"}),e.jsx("td",{children:O.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:()=>D(t),children:"Edit"})})]},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:i===0,onClick:()=>N(Math.max(0,i-r)),children:"Previous"}),e.jsxs("span",{children:["Showing ",u.length," customer",u.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:_.length<r,onClick:()=>N(i+r),children:"Next"})]})]})]})}exports.CustomersSection=W;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),k=require("./plugin-Dw8_Q8rE.js"),$=require("./ErrorBanner-DxrRVqwe.js"),g=require("./dateHelpers-BKW_lGND.js"),I=d=>{switch(d){case"won":return"success";case"lost":return"failed";case"needs_response":case"warning_needs_response":return"pending";default:return"muted"}},C=(d,i)=>`${i.toUpperCase()} ${(d/100).toFixed(2)}`;function F({serverUrl:d,apiKey:i,pageSize:a=20,authManager:x}){const[r,y]=s.useState([]),[W,b]=s.useState(!0),[D,l]=s.useState(null),[c,j]=s.useState(0),[o,U]=s.useState("all"),[h,p]=s.useState(null),[u,v]=s.useState(""),[S,N]=s.useState(!1),m=s.useCallback(async(t,n)=>{if(x?.isAuthenticated())return x.fetchWithAuth(t,n);const w={"Content-Type":"application/json"};i&&(w["X-API-Key"]=i);const f=await fetch(`${d}${t}`,{...n,headers:{...w,...n?.headers}});if(!f.ok)throw new Error(`Request failed: ${f.status}`);return f.json()},[d,i,x]),_=s.useCallback(async()=>{b(!0),l(null);try{const t=new URLSearchParams;t.set("limit",String(a)),t.set("offset",String(c)),o!=="all"&&t.set("status",o);const n=await m(`/admin/disputes?${t.toString()}`);y(n.disputes??[])}catch{l("Failed to load disputes"),y([])}finally{b(!1)}},[m,a,c,o]);s.useEffect(()=>{_()},[_]);const A=async t=>{try{const n=await m(`/admin/disputes/${encodeURIComponent(t)}`);p(n),v(n.status)}catch{l("Failed to load dispute details")}},R=async()=>{if(!(!h||!u.trim())){N(!0);try{const t=await m(`/admin/disputes/${encodeURIComponent(h.id)}/status`,{method:"PUT",body:JSON.stringify({status:u})});p(t),_()}catch{l("Failed to update dispute status")}finally{N(!1)}}};if(h){const t=h;return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>p(null),style:{marginBottom:"1rem"},children:"← Back to disputes"}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Dispute ",e.jsx("code",{style:{fontSize:"0.8rem"},children:t.id.slice(0,12)})]})}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px"},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:"Status"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Amount"}),e.jsx("td",{children:C(t.amount,t.currency)})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Source"}),e.jsx("td",{children:t.source})]}),t.reason&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Reason"}),e.jsx("td",{children:t.reason})]}),t.orderId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Order ID"}),e.jsx("td",{children:e.jsx("code",{children:t.orderId})})]}),t.chargeId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Charge ID"}),e.jsx("td",{children:e.jsx("code",{children:t.chargeId})})]}),t.paymentIntentId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Payment Intent"}),e.jsx("td",{children:e.jsx("code",{children:t.paymentIntentId})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Created"}),e.jsx("td",{children:g.formatDateTime(t.createdAt)})]}),t.statusUpdatedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Status Updated"}),e.jsx("td",{children:g.formatDateTime(t.statusUpdatedAt)})]})]})})}),e.jsxs("div",{style:{marginTop:"1rem",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.jsxs("select",{className:"cedros-admin__input",value:u,onChange:n=>v(n.target.value),children:[e.jsx("option",{value:"needs_response",children:"Needs Response"}),e.jsx("option",{value:"under_review",children:"Under Review"}),e.jsx("option",{value:"won",children:"Won"}),e.jsx("option",{value:"lost",children:"Lost"}),e.jsx("option",{value:"warning_closed",children:"Warning Closed"})]})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:R,disabled:S||u===t.status,children:S?"Updating...":"Update"})]})]})}return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Disputes & Chargebacks"})}),e.jsx($.ErrorBanner,{message:D}),e.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:e.jsxs("select",{className:"cedros-admin__input",value:o,onChange:t=>{U(t.target.value),j(0)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"needs_response",children:"Needs Response"}),e.jsx("option",{value:"under_review",children:"Under Review"}),e.jsx("option",{value:"won",children:"Won"}),e.jsx("option",{value:"lost",children:"Lost"})]})}),W?e.jsxs("div",{className:"cedros-admin__loading",children:[k.Icons.loading," Loading disputes..."]}):r.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No disputes 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:"ID"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Source"}),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("code",{style:{fontSize:"0.75rem"},children:t.id.slice(0,12)})}),e.jsx("td",{children:C(t.amount,t.currency)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})}),e.jsx("td",{children:t.reason??"—"}),e.jsx("td",{children:t.source}),e.jsx("td",{children:g.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:()=>A(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:c===0,onClick:()=>j(Math.max(0,c-a)),children:"Previous"}),e.jsxs("span",{children:["Showing ",r.length," dispute",r.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r.length<a,onClick:()=>j(c+a),children:"Next"})]})]})]})}exports.DisputesSection=F;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),k=require("./plugin-DNhaPAbC.js"),$=require("./ErrorBanner-BOS1XAPu.js"),g=require("./dateHelpers-BKW_lGND.js"),I=d=>{switch(d){case"won":return"success";case"lost":return"failed";case"needs_response":case"warning_needs_response":return"pending";default:return"muted"}},C=(d,i)=>`${i.toUpperCase()} ${(d/100).toFixed(2)}`;function F({serverUrl:d,apiKey:i,pageSize:a=20,authManager:x}){const[r,y]=s.useState([]),[W,b]=s.useState(!0),[D,l]=s.useState(null),[c,j]=s.useState(0),[o,U]=s.useState("all"),[h,p]=s.useState(null),[u,v]=s.useState(""),[S,N]=s.useState(!1),m=s.useCallback(async(t,n)=>{if(x?.isAuthenticated())return x.fetchWithAuth(t,n);const w={"Content-Type":"application/json"};i&&(w["X-API-Key"]=i);const f=await fetch(`${d}${t}`,{...n,headers:{...w,...n?.headers}});if(!f.ok)throw new Error(`Request failed: ${f.status}`);return f.json()},[d,i,x]),_=s.useCallback(async()=>{b(!0),l(null);try{const t=new URLSearchParams;t.set("limit",String(a)),t.set("offset",String(c)),o!=="all"&&t.set("status",o);const n=await m(`/admin/disputes?${t.toString()}`);y(n.disputes??[])}catch{l("Failed to load disputes"),y([])}finally{b(!1)}},[m,a,c,o]);s.useEffect(()=>{_()},[_]);const A=async t=>{try{const n=await m(`/admin/disputes/${encodeURIComponent(t)}`);p(n),v(n.status)}catch{l("Failed to load dispute details")}},R=async()=>{if(!(!h||!u.trim())){N(!0);try{const t=await m(`/admin/disputes/${encodeURIComponent(h.id)}/status`,{method:"PUT",body:JSON.stringify({status:u})});p(t),_()}catch{l("Failed to update dispute status")}finally{N(!1)}}};if(h){const t=h;return e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>p(null),style:{marginBottom:"1rem"},children:"← Back to disputes"}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Dispute ",e.jsx("code",{style:{fontSize:"0.8rem"},children:t.id.slice(0,12)})]})}),e.jsx("div",{className:"cedros-admin__table-container",style:{maxWidth:"500px"},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:"Status"}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Amount"}),e.jsx("td",{children:C(t.amount,t.currency)})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Source"}),e.jsx("td",{children:t.source})]}),t.reason&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Reason"}),e.jsx("td",{children:t.reason})]}),t.orderId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Order ID"}),e.jsx("td",{children:e.jsx("code",{children:t.orderId})})]}),t.chargeId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Charge ID"}),e.jsx("td",{children:e.jsx("code",{children:t.chargeId})})]}),t.paymentIntentId&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Payment Intent"}),e.jsx("td",{children:e.jsx("code",{children:t.paymentIntentId})})]}),e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Created"}),e.jsx("td",{children:g.formatDateTime(t.createdAt)})]}),t.statusUpdatedAt&&e.jsxs("tr",{children:[e.jsx("td",{style:{fontWeight:600},children:"Status Updated"}),e.jsx("td",{children:g.formatDateTime(t.statusUpdatedAt)})]})]})})}),e.jsxs("div",{style:{marginTop:"1rem",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.jsxs("select",{className:"cedros-admin__input",value:u,onChange:n=>v(n.target.value),children:[e.jsx("option",{value:"needs_response",children:"Needs Response"}),e.jsx("option",{value:"under_review",children:"Under Review"}),e.jsx("option",{value:"won",children:"Won"}),e.jsx("option",{value:"lost",children:"Lost"}),e.jsx("option",{value:"warning_closed",children:"Warning Closed"})]})]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:R,disabled:S||u===t.status,children:S?"Updating...":"Update"})]})]})}return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Disputes & Chargebacks"})}),e.jsx($.ErrorBanner,{message:D}),e.jsx("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:e.jsxs("select",{className:"cedros-admin__input",value:o,onChange:t=>{U(t.target.value),j(0)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"needs_response",children:"Needs Response"}),e.jsx("option",{value:"under_review",children:"Under Review"}),e.jsx("option",{value:"won",children:"Won"}),e.jsx("option",{value:"lost",children:"Lost"})]})}),W?e.jsxs("div",{className:"cedros-admin__loading",children:[k.Icons.loading," Loading disputes..."]}):r.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No disputes 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:"ID"}),e.jsx("th",{children:"Amount"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Source"}),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("code",{style:{fontSize:"0.75rem"},children:t.id.slice(0,12)})}),e.jsx("td",{children:C(t.amount,t.currency)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${I(t.status)}`,children:t.status})}),e.jsx("td",{children:t.reason??"—"}),e.jsx("td",{children:t.source}),e.jsx("td",{children:g.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:()=>A(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:c===0,onClick:()=>j(Math.max(0,c-a)),children:"Previous"}),e.jsxs("span",{children:["Showing ",r.length," dispute",r.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:r.length<a,onClick:()=>j(c+a),children:"Next"})]})]})]})}exports.DisputesSection=F;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as n, jsx as e, Fragment as E } from "react/jsx-runtime";
2
2
  import { useState as d, useCallback as x, useEffect as L } from "react";
3
- import { I as j } from "./plugin-BIkt3boU.mjs";
4
- import { E as B } from "./ErrorBanner-DAjYj6Dx.mjs";
3
+ import { I as j } from "./plugin-CuoGEYWr.mjs";
4
+ import { E as B } from "./ErrorBanner-7naZtdtD.mjs";
5
5
  import { f as v } from "./dateHelpers-yvPkofYQ.mjs";
6
6
  const U = (i) => {
7
7
  switch (i) {
@@ -1 +1 @@
1
- "use strict";const n=require("react/jsx-runtime"),c=require("react"),p=require("./plugin-Dw8_Q8rE.js");function v({value:r,onChange:_,options:l,placeholder:f="Filter",disabled:i}){const[s,a]=c.useState(!1),m=c.useRef(null),t=l.find(e=>e.value===r)?.label||f;return c.useEffect(()=>{const e=u=>{m.current&&!m.current.contains(u.target)&&a(!1)};if(s)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]),c.useEffect(()=>{const e=u=>{u.key==="Escape"&&a(!1)};if(s)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[s]),n.jsxs("div",{className:"cedros-admin__dropdown",ref:m,children:[n.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger",onClick:()=>!i&&a(!s),"aria-expanded":s,"aria-haspopup":"listbox",disabled:i,children:[n.jsx("span",{children:t}),n.jsx("span",{className:`cedros-admin__dropdown-chevron ${s?"cedros-admin__dropdown-chevron--open":""}`,children:p.Icons.chevronDown})]}),s&&n.jsx("div",{className:"cedros-admin__dropdown-menu",role:"listbox",children:l.map(e=>n.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${e.value===r?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{e.disabled||(_(e.value),a(!1))},role:"option","aria-selected":e.value===r,disabled:e.disabled,children:[e.label,e.value===r&&n.jsx("span",{className:"cedros-admin__dropdown-check",children:p.Icons.check})]},e.value))})]})}function b({value:r,onChange:_,options:l,label:f,description:i,disabled:s,className:a,style:m}){const[o,t]=c.useState(!1),e=c.useRef(null),h=l.find(d=>d.value===r)?.label||"Select...";return c.useEffect(()=>{const d=w=>{e.current&&!e.current.contains(w.target)&&t(!1)};if(o)return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[o]),c.useEffect(()=>{const d=w=>{w.key==="Escape"&&t(!1)};if(o)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[o]),n.jsxs("div",{className:`cedros-admin__field ${a||""}`,style:m,children:[n.jsx("label",{className:"cedros-admin__field-label",children:f}),n.jsxs("div",{className:"cedros-admin__dropdown cedros-admin__dropdown--form",ref:e,children:[n.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger cedros-admin__dropdown-trigger--form",onClick:()=>!s&&t(!o),"aria-expanded":o,"aria-haspopup":"listbox",disabled:s,children:[n.jsx("span",{children:h}),n.jsx("span",{className:`cedros-admin__dropdown-chevron ${o?"cedros-admin__dropdown-chevron--open":""}`,children:p.Icons.chevronDown})]}),o&&n.jsx("div",{className:"cedros-admin__dropdown-menu cedros-admin__dropdown-menu--form",role:"listbox",children:l.map(d=>n.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${d.value===r?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{d.disabled||(_(d.value),t(!1))},role:"option","aria-selected":d.value===r,disabled:d.disabled,children:[d.label,d.value===r&&n.jsx("span",{className:"cedros-admin__dropdown-check",children:p.Icons.check})]},d.value))})]}),i&&n.jsx("p",{className:"cedros-admin__field-description",children:i})]})}exports.FilterDropdown=v;exports.FormDropdown=b;
1
+ "use strict";const n=require("react/jsx-runtime"),c=require("react"),p=require("./plugin-DNhaPAbC.js");function v({value:r,onChange:_,options:l,placeholder:f="Filter",disabled:i}){const[s,a]=c.useState(!1),m=c.useRef(null),t=l.find(e=>e.value===r)?.label||f;return c.useEffect(()=>{const e=u=>{m.current&&!m.current.contains(u.target)&&a(!1)};if(s)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[s]),c.useEffect(()=>{const e=u=>{u.key==="Escape"&&a(!1)};if(s)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[s]),n.jsxs("div",{className:"cedros-admin__dropdown",ref:m,children:[n.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger",onClick:()=>!i&&a(!s),"aria-expanded":s,"aria-haspopup":"listbox",disabled:i,children:[n.jsx("span",{children:t}),n.jsx("span",{className:`cedros-admin__dropdown-chevron ${s?"cedros-admin__dropdown-chevron--open":""}`,children:p.Icons.chevronDown})]}),s&&n.jsx("div",{className:"cedros-admin__dropdown-menu",role:"listbox",children:l.map(e=>n.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${e.value===r?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{e.disabled||(_(e.value),a(!1))},role:"option","aria-selected":e.value===r,disabled:e.disabled,children:[e.label,e.value===r&&n.jsx("span",{className:"cedros-admin__dropdown-check",children:p.Icons.check})]},e.value))})]})}function b({value:r,onChange:_,options:l,label:f,description:i,disabled:s,className:a,style:m}){const[o,t]=c.useState(!1),e=c.useRef(null),h=l.find(d=>d.value===r)?.label||"Select...";return c.useEffect(()=>{const d=w=>{e.current&&!e.current.contains(w.target)&&t(!1)};if(o)return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[o]),c.useEffect(()=>{const d=w=>{w.key==="Escape"&&t(!1)};if(o)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[o]),n.jsxs("div",{className:`cedros-admin__field ${a||""}`,style:m,children:[n.jsx("label",{className:"cedros-admin__field-label",children:f}),n.jsxs("div",{className:"cedros-admin__dropdown cedros-admin__dropdown--form",ref:e,children:[n.jsxs("button",{type:"button",className:"cedros-admin__dropdown-trigger cedros-admin__dropdown-trigger--form",onClick:()=>!s&&t(!o),"aria-expanded":o,"aria-haspopup":"listbox",disabled:s,children:[n.jsx("span",{children:h}),n.jsx("span",{className:`cedros-admin__dropdown-chevron ${o?"cedros-admin__dropdown-chevron--open":""}`,children:p.Icons.chevronDown})]}),o&&n.jsx("div",{className:"cedros-admin__dropdown-menu cedros-admin__dropdown-menu--form",role:"listbox",children:l.map(d=>n.jsxs("button",{type:"button",className:`cedros-admin__dropdown-item ${d.value===r?"cedros-admin__dropdown-item--selected":""}`,onClick:()=>{d.disabled||(_(d.value),t(!1))},role:"option","aria-selected":d.value===r,disabled:d.disabled,children:[d.label,d.value===r&&n.jsx("span",{className:"cedros-admin__dropdown-check",children:p.Icons.check})]},d.value))})]}),i&&n.jsx("p",{className:"cedros-admin__field-description",children:i})]})}exports.FilterDropdown=v;exports.FormDropdown=b;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
2
  import { useState as v, useRef as b, useEffect as u } from "react";
3
- import { I as _ } from "./plugin-BIkt3boU.mjs";
3
+ import { I as _ } from "./plugin-CuoGEYWr.mjs";
4
4
  function L({ value: s, onChange: f, options: i, placeholder: h = "Filter", disabled: t }) {
5
5
  const [n, c] = v(!1), m = b(null), l = i.find((e) => e.value === s)?.label || h;
6
6
  return u(() => {
@@ -1,5 +1,5 @@
1
1
  import { jsxs as e, jsx as o } from "react/jsx-runtime";
2
- import { I as s } from "./plugin-BIkt3boU.mjs";
2
+ import { I as s } from "./plugin-CuoGEYWr.mjs";
3
3
  function i({ message: r, onRetry: n }) {
4
4
  return r ? /* @__PURE__ */ e("div", { className: "cedros-admin__error-banner", children: [
5
5
  /* @__PURE__ */ o("span", { children: r }),
@@ -1 +1 @@
1
- "use strict";const r=require("react/jsx-runtime"),s=require("./plugin-Dw8_Q8rE.js");function i({message:n,onRetry:e}){return n?r.jsxs("div",{className:"cedros-admin__error-banner",children:[r.jsx("span",{children:n}),e&&r.jsxs("button",{type:"button",className:"cedros-admin__error-banner-retry",onClick:e,children:[s.Icons.refresh," Retry"]})]}):null}exports.ErrorBanner=i;
1
+ "use strict";const r=require("react/jsx-runtime"),s=require("./plugin-DNhaPAbC.js");function i({message:n,onRetry:e}){return n?r.jsxs("div",{className:"cedros-admin__error-banner",children:[r.jsx("span",{children:n}),e&&r.jsxs("button",{type:"button",className:"cedros-admin__error-banner-retry",onClick:e,children:[s.Icons.refresh," Retry"]})]}):null}exports.ErrorBanner=i;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),r=require("./plugin-Dw8_Q8rE.js"),R=require("./ErrorBanner-DxrRVqwe.js"),U=require("./StatsBar-DDUWoizP.js");function V({serverUrl:h,apiKey:d,pageSize:g=20,authManager:o}){const[u,N]=c.useState([]),[Q,w]=c.useState(!0),[S,f]=c.useState(!1),[p,A]=c.useState(null),[F,C]=c.useState(!1),[x,P]=c.useState(""),[v,O]=c.useState("all"),[q,b]=c.useState(null),[E,j]=c.useState(null),[n,l]=c.useState({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),_=c.useCallback(async()=>{w(!0);try{j(null);let s;const t=`/admin/faqs?limit=${g}`;if(o?.isAuthenticated())s=await o.fetchWithAuth(t);else{const i={"Content-Type":"application/json"};d&&(i["X-API-Key"]=d);const a=await fetch(`${h}${t}`,{headers:i});if(!a.ok)throw new Error(`Failed to fetch FAQs: ${a.status}`);s=await a.json()}N(s.faqs||[])}catch{N([]),j("Failed to load FAQs")}finally{w(!1)}},[h,d,g,o]);c.useEffect(()=>{_()},[_]);const $=async s=>{if(s.preventDefault(),!(!n.question.trim()||!n.answer.trim())){C(!0);try{const t=n.keywordsCsv.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),i={question:n.question.trim(),answer:n.answer.trim(),keywords:t,active:n.active,useInChat:n.useInChat,displayOnPage:n.displayOnPage};if(p){const a=`/admin/faqs/${p.id}`;if(o?.isAuthenticated())await o.fetchWithAuth(a,{method:"PUT",body:JSON.stringify(i)});else{const m={"Content-Type":"application/json"};d&&(m["X-API-Key"]=d);const I=await fetch(`${h}${a}`,{method:"PUT",headers:m,body:JSON.stringify(i)});if(!I.ok)throw new Error(`Failed to update FAQ: ${I.status}`)}}else if(o?.isAuthenticated())await o.fetchWithAuth("/admin/faqs",{method:"POST",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};d&&(a["X-API-Key"]=d);const m=await fetch(`${h}/admin/faqs`,{method:"POST",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to create FAQ: ${m.status}`)}y(),_()}catch{j(p?"Failed to update FAQ":"Failed to create FAQ")}finally{C(!1)}}},T=async s=>{try{const t=`/admin/faqs/${s}`;if(o?.isAuthenticated())await o.fetchWithAuth(t,{method:"DELETE"});else{const i={"Content-Type":"application/json"};d&&(i["X-API-Key"]=d);const a=await fetch(`${h}${t}`,{method:"DELETE",headers:i});if(!a.ok)throw new Error(`Failed to delete FAQ: ${a.status}`)}_()}catch{j("Failed to delete FAQ")}b(null)},D=async s=>{try{const t=`/admin/faqs/${s.id}`,i={...s,active:!s.active};if(o?.isAuthenticated())await o.fetchWithAuth(t,{method:"PUT",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};d&&(a["X-API-Key"]=d);const m=await fetch(`${h}${t}`,{method:"PUT",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to update FAQ: ${m.status}`)}_()}catch{j("Failed to update FAQ status")}},y=()=>{l({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),A(null),f(!1)},L=s=>{l({question:s.question,answer:s.answer,keywordsCsv:s.keywords.join(", "),active:s.active,useInChat:s.useInChat??!0,displayOnPage:s.displayOnPage??!0}),A(s),f(!0)},B=u.length,W=u.filter(s=>s.active).length,J=u.filter(s=>s.active&&s.useInChat).length,X=u.filter(s=>s.active&&s.displayOnPage).length,k=c.useMemo(()=>u.filter(s=>{if(v==="active"&&!s.active||v==="inactive"&&s.active)return!1;if(x){const t=x.toLowerCase();return s.question.toLowerCase().includes(t)||s.answer.toLowerCase().includes(t)||s.keywords.some(i=>i.includes(t))}return!0}),[u,v,x]);return e.jsxs("div",{className:"cedros-admin__faqs",children:[e.jsx(R.ErrorBanner,{message:E,onRetry:_}),e.jsx(U.StatsBar,{stats:[{label:"Total FAQs",value:B},{label:"Active",value:W,variant:"success"},{label:"In Chat",value:J},{label:"On Page",value:X}]}),e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{className:"cedros-admin__section-header-left",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Knowledge Base"}),e.jsx("p",{className:"cedros-admin__section-subtitle",children:"Manage FAQs for the AI chat assistant and public FAQ page."})]}),e.jsx("div",{className:"cedros-admin__section-header-right",children:e.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{y(),f(!0)},children:[r.Icons.plus," Add FAQ"]})})]}),e.jsxs("div",{className:"cedros-admin__filters",style:{display:"flex",gap:"1rem",marginBottom:"1rem"},children:[e.jsx("input",{type:"text",placeholder:"Search FAQs...",value:x,onChange:s=>P(s.target.value),className:"cedros-admin__input",style:{flex:1,maxWidth:300}}),e.jsxs("select",{value:v,onChange:s=>O(s.target.value),className:"cedros-admin__select",children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"active",children:"Active Only"}),e.jsx("option",{value:"inactive",children:"Inactive Only"})]})]}),S&&e.jsx("div",{className:"cedros-admin__form-container",style:{marginBottom:"1.5rem"},children:e.jsxs("form",{onSubmit:$,className:"cedros-admin__form",children:[e.jsxs("div",{className:"cedros-admin__form-header",children:[e.jsx("h4",{children:p?"Edit FAQ":"Add New FAQ"}),e.jsx("button",{type:"button",className:"cedros-admin__button--icon",onClick:y,children:r.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Question *"}),e.jsx("input",{type:"text",value:n.question,onChange:s=>l(t=>({...t,question:s.target.value})),className:"cedros-admin__input",placeholder:"What is your return policy?",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Answer *"}),e.jsx("textarea",{value:n.answer,onChange:s=>l(t=>({...t,answer:s.target.value})),className:"cedros-admin__textarea",placeholder:"We accept returns within 30 days...",rows:4,required:!0}),e.jsx("span",{className:"cedros-admin__hint",children:"Supports markdown formatting."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Keywords"}),e.jsx("input",{type:"text",value:n.keywordsCsv,onChange:s=>l(t=>({...t,keywordsCsv:s.target.value})),className:"cedros-admin__input",placeholder:"returns, refund, policy"}),e.jsx("span",{className:"cedros-admin__hint",children:"Comma-separated keywords to help AI find this FAQ."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.active,onChange:s=>l(t=>({...t,active:s.target.checked}))}),e.jsx("span",{children:"Active"})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Inactive FAQs won't appear anywhere."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Visibility"}),e.jsxs("div",{className:"cedros-admin__checkbox-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.useInChat,onChange:s=>l(t=>({...t,useInChat:s.target.checked}))}),e.jsx("span",{children:"Use in AI Chat"})]}),e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.displayOnPage,onChange:s=>l(t=>({...t,displayOnPage:s.target.checked}))}),e.jsx("span",{children:"Display on FAQ Page"})]})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Choose where this FAQ should appear."})]}),e.jsxs("div",{className:"cedros-admin__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-admin__button",onClick:y,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:F||!n.question.trim()||!n.answer.trim(),children:F?r.Icons.loading:p?"Update FAQ":"Create FAQ"})]})]})}),Q?e.jsxs("div",{className:"cedros-admin__loading",children:[r.Icons.loading,e.jsx("span",{children:"Loading FAQs..."})]}):k.length===0?e.jsx("div",{className:"cedros-admin__empty",children:e.jsx("p",{children:x||v!=="all"?"No FAQs match your filters.":"No FAQs yet. Add one to get started."})}):e.jsx("div",{className:"cedros-admin__faq-list",children:k.map(s=>e.jsxs("div",{className:`cedros-admin__faq-item ${s.active?"":"cedros-admin__faq-item--inactive"}`,children:[e.jsxs("div",{className:"cedros-admin__faq-content",children:[e.jsxs("div",{className:"cedros-admin__faq-question",children:[e.jsx("span",{className:`cedros-admin__status-dot ${s.active?"cedros-admin__status-dot--active":"cedros-admin__status-dot--inactive"}`}),s.question]}),e.jsx("div",{className:"cedros-admin__faq-answer",children:s.answer}),e.jsxs("div",{className:"cedros-admin__faq-meta",children:[s.keywords.length>0&&e.jsx("div",{className:"cedros-admin__faq-keywords",children:s.keywords.map(t=>e.jsx("span",{className:"cedros-admin__tag",children:t},t))}),e.jsxs("div",{className:"cedros-admin__faq-visibility",children:[s.useInChat&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--chat",title:"Used in AI Chat",children:[r.Icons.chat," Chat"]}),s.displayOnPage&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--page",title:"Displayed on FAQ Page",children:[r.Icons.globe," Page"]})]})]})]}),e.jsxs("div",{className:"cedros-admin__faq-actions",children:[e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>D(s),title:s.active?"Deactivate":"Activate",children:s.active?r.Icons.eyeOff:r.Icons.eye}),e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>L(s),title:"Edit",children:r.Icons.edit}),e.jsx("button",{className:"cedros-admin__button--icon cedros-admin__btn--danger",onClick:()=>b(s.id),title:"Delete",children:r.Icons.trash})]}),q===s.id&&e.jsx("div",{className:"cedros-admin__confirm-overlay",children:e.jsxs("div",{className:"cedros-admin__confirm-dialog",children:[e.jsx("p",{children:"Delete this FAQ?"}),e.jsxs("div",{className:"cedros-admin__confirm-actions",children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>b(null),children:"Cancel"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger",onClick:()=>T(s.id),children:"Delete"})]})]})})]},s.id))})]})]})}exports.FAQSection=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),r=require("./plugin-DNhaPAbC.js"),R=require("./ErrorBanner-BOS1XAPu.js"),U=require("./StatsBar-CVqsD8j2.js");function V({serverUrl:h,apiKey:d,pageSize:g=20,authManager:o}){const[u,N]=c.useState([]),[Q,w]=c.useState(!0),[S,f]=c.useState(!1),[p,A]=c.useState(null),[F,C]=c.useState(!1),[x,P]=c.useState(""),[v,O]=c.useState("all"),[q,b]=c.useState(null),[E,j]=c.useState(null),[n,l]=c.useState({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),_=c.useCallback(async()=>{w(!0);try{j(null);let s;const t=`/admin/faqs?limit=${g}`;if(o?.isAuthenticated())s=await o.fetchWithAuth(t);else{const i={"Content-Type":"application/json"};d&&(i["X-API-Key"]=d);const a=await fetch(`${h}${t}`,{headers:i});if(!a.ok)throw new Error(`Failed to fetch FAQs: ${a.status}`);s=await a.json()}N(s.faqs||[])}catch{N([]),j("Failed to load FAQs")}finally{w(!1)}},[h,d,g,o]);c.useEffect(()=>{_()},[_]);const $=async s=>{if(s.preventDefault(),!(!n.question.trim()||!n.answer.trim())){C(!0);try{const t=n.keywordsCsv.split(",").map(a=>a.trim().toLowerCase()).filter(Boolean),i={question:n.question.trim(),answer:n.answer.trim(),keywords:t,active:n.active,useInChat:n.useInChat,displayOnPage:n.displayOnPage};if(p){const a=`/admin/faqs/${p.id}`;if(o?.isAuthenticated())await o.fetchWithAuth(a,{method:"PUT",body:JSON.stringify(i)});else{const m={"Content-Type":"application/json"};d&&(m["X-API-Key"]=d);const I=await fetch(`${h}${a}`,{method:"PUT",headers:m,body:JSON.stringify(i)});if(!I.ok)throw new Error(`Failed to update FAQ: ${I.status}`)}}else if(o?.isAuthenticated())await o.fetchWithAuth("/admin/faqs",{method:"POST",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};d&&(a["X-API-Key"]=d);const m=await fetch(`${h}/admin/faqs`,{method:"POST",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to create FAQ: ${m.status}`)}y(),_()}catch{j(p?"Failed to update FAQ":"Failed to create FAQ")}finally{C(!1)}}},T=async s=>{try{const t=`/admin/faqs/${s}`;if(o?.isAuthenticated())await o.fetchWithAuth(t,{method:"DELETE"});else{const i={"Content-Type":"application/json"};d&&(i["X-API-Key"]=d);const a=await fetch(`${h}${t}`,{method:"DELETE",headers:i});if(!a.ok)throw new Error(`Failed to delete FAQ: ${a.status}`)}_()}catch{j("Failed to delete FAQ")}b(null)},D=async s=>{try{const t=`/admin/faqs/${s.id}`,i={...s,active:!s.active};if(o?.isAuthenticated())await o.fetchWithAuth(t,{method:"PUT",body:JSON.stringify(i)});else{const a={"Content-Type":"application/json"};d&&(a["X-API-Key"]=d);const m=await fetch(`${h}${t}`,{method:"PUT",headers:a,body:JSON.stringify(i)});if(!m.ok)throw new Error(`Failed to update FAQ: ${m.status}`)}_()}catch{j("Failed to update FAQ status")}},y=()=>{l({question:"",answer:"",keywordsCsv:"",active:!0,useInChat:!0,displayOnPage:!0}),A(null),f(!1)},L=s=>{l({question:s.question,answer:s.answer,keywordsCsv:s.keywords.join(", "),active:s.active,useInChat:s.useInChat??!0,displayOnPage:s.displayOnPage??!0}),A(s),f(!0)},B=u.length,W=u.filter(s=>s.active).length,J=u.filter(s=>s.active&&s.useInChat).length,X=u.filter(s=>s.active&&s.displayOnPage).length,k=c.useMemo(()=>u.filter(s=>{if(v==="active"&&!s.active||v==="inactive"&&s.active)return!1;if(x){const t=x.toLowerCase();return s.question.toLowerCase().includes(t)||s.answer.toLowerCase().includes(t)||s.keywords.some(i=>i.includes(t))}return!0}),[u,v,x]);return e.jsxs("div",{className:"cedros-admin__faqs",children:[e.jsx(R.ErrorBanner,{message:E,onRetry:_}),e.jsx(U.StatsBar,{stats:[{label:"Total FAQs",value:B},{label:"Active",value:W,variant:"success"},{label:"In Chat",value:J},{label:"On Page",value:X}]}),e.jsxs("div",{className:"cedros-admin__section",children:[e.jsxs("div",{className:"cedros-admin__section-header",children:[e.jsxs("div",{className:"cedros-admin__section-header-left",children:[e.jsx("h3",{className:"cedros-admin__section-title",children:"Knowledge Base"}),e.jsx("p",{className:"cedros-admin__section-subtitle",children:"Manage FAQs for the AI chat assistant and public FAQ page."})]}),e.jsx("div",{className:"cedros-admin__section-header-right",children:e.jsxs("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:()=>{y(),f(!0)},children:[r.Icons.plus," Add FAQ"]})})]}),e.jsxs("div",{className:"cedros-admin__filters",style:{display:"flex",gap:"1rem",marginBottom:"1rem"},children:[e.jsx("input",{type:"text",placeholder:"Search FAQs...",value:x,onChange:s=>P(s.target.value),className:"cedros-admin__input",style:{flex:1,maxWidth:300}}),e.jsxs("select",{value:v,onChange:s=>O(s.target.value),className:"cedros-admin__select",children:[e.jsx("option",{value:"all",children:"All Status"}),e.jsx("option",{value:"active",children:"Active Only"}),e.jsx("option",{value:"inactive",children:"Inactive Only"})]})]}),S&&e.jsx("div",{className:"cedros-admin__form-container",style:{marginBottom:"1.5rem"},children:e.jsxs("form",{onSubmit:$,className:"cedros-admin__form",children:[e.jsxs("div",{className:"cedros-admin__form-header",children:[e.jsx("h4",{children:p?"Edit FAQ":"Add New FAQ"}),e.jsx("button",{type:"button",className:"cedros-admin__button--icon",onClick:y,children:r.Icons.close})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Question *"}),e.jsx("input",{type:"text",value:n.question,onChange:s=>l(t=>({...t,question:s.target.value})),className:"cedros-admin__input",placeholder:"What is your return policy?",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Answer *"}),e.jsx("textarea",{value:n.answer,onChange:s=>l(t=>({...t,answer:s.target.value})),className:"cedros-admin__textarea",placeholder:"We accept returns within 30 days...",rows:4,required:!0}),e.jsx("span",{className:"cedros-admin__hint",children:"Supports markdown formatting."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Keywords"}),e.jsx("input",{type:"text",value:n.keywordsCsv,onChange:s=>l(t=>({...t,keywordsCsv:s.target.value})),className:"cedros-admin__input",placeholder:"returns, refund, policy"}),e.jsx("span",{className:"cedros-admin__hint",children:"Comma-separated keywords to help AI find this FAQ."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.active,onChange:s=>l(t=>({...t,active:s.target.checked}))}),e.jsx("span",{children:"Active"})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Inactive FAQs won't appear anywhere."})]}),e.jsxs("div",{className:"cedros-admin__form-group",children:[e.jsx("label",{className:"cedros-admin__label",children:"Visibility"}),e.jsxs("div",{className:"cedros-admin__checkbox-group",children:[e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.useInChat,onChange:s=>l(t=>({...t,useInChat:s.target.checked}))}),e.jsx("span",{children:"Use in AI Chat"})]}),e.jsxs("label",{className:"cedros-admin__checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n.displayOnPage,onChange:s=>l(t=>({...t,displayOnPage:s.target.checked}))}),e.jsx("span",{children:"Display on FAQ Page"})]})]}),e.jsx("span",{className:"cedros-admin__hint",children:"Choose where this FAQ should appear."})]}),e.jsxs("div",{className:"cedros-admin__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-admin__button",onClick:y,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:F||!n.question.trim()||!n.answer.trim(),children:F?r.Icons.loading:p?"Update FAQ":"Create FAQ"})]})]})}),Q?e.jsxs("div",{className:"cedros-admin__loading",children:[r.Icons.loading,e.jsx("span",{children:"Loading FAQs..."})]}):k.length===0?e.jsx("div",{className:"cedros-admin__empty",children:e.jsx("p",{children:x||v!=="all"?"No FAQs match your filters.":"No FAQs yet. Add one to get started."})}):e.jsx("div",{className:"cedros-admin__faq-list",children:k.map(s=>e.jsxs("div",{className:`cedros-admin__faq-item ${s.active?"":"cedros-admin__faq-item--inactive"}`,children:[e.jsxs("div",{className:"cedros-admin__faq-content",children:[e.jsxs("div",{className:"cedros-admin__faq-question",children:[e.jsx("span",{className:`cedros-admin__status-dot ${s.active?"cedros-admin__status-dot--active":"cedros-admin__status-dot--inactive"}`}),s.question]}),e.jsx("div",{className:"cedros-admin__faq-answer",children:s.answer}),e.jsxs("div",{className:"cedros-admin__faq-meta",children:[s.keywords.length>0&&e.jsx("div",{className:"cedros-admin__faq-keywords",children:s.keywords.map(t=>e.jsx("span",{className:"cedros-admin__tag",children:t},t))}),e.jsxs("div",{className:"cedros-admin__faq-visibility",children:[s.useInChat&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--chat",title:"Used in AI Chat",children:[r.Icons.chat," Chat"]}),s.displayOnPage&&e.jsxs("span",{className:"cedros-admin__badge cedros-admin__badge--page",title:"Displayed on FAQ Page",children:[r.Icons.globe," Page"]})]})]})]}),e.jsxs("div",{className:"cedros-admin__faq-actions",children:[e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>D(s),title:s.active?"Deactivate":"Activate",children:s.active?r.Icons.eyeOff:r.Icons.eye}),e.jsx("button",{className:"cedros-admin__button--icon",onClick:()=>L(s),title:"Edit",children:r.Icons.edit}),e.jsx("button",{className:"cedros-admin__button--icon cedros-admin__btn--danger",onClick:()=>b(s.id),title:"Delete",children:r.Icons.trash})]}),q===s.id&&e.jsx("div",{className:"cedros-admin__confirm-overlay",children:e.jsxs("div",{className:"cedros-admin__confirm-dialog",children:[e.jsx("p",{children:"Delete this FAQ?"}),e.jsxs("div",{className:"cedros-admin__confirm-actions",children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>b(null),children:"Cancel"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--danger",onClick:()=>T(s.id),children:"Delete"})]})]})})]},s.id))})]})]})}exports.FAQSection=V;
@@ -1,8 +1,8 @@
1
1
  import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
2
  import { useState as r, useCallback as R, useEffect as V, useMemo as G } from "react";
3
- import { I as l } from "./plugin-BIkt3boU.mjs";
4
- import { E as H } from "./ErrorBanner-DAjYj6Dx.mjs";
5
- import { S as Y } from "./StatsBar-CwCBHBn-.mjs";
3
+ import { I as l } from "./plugin-CuoGEYWr.mjs";
4
+ import { E as H } from "./ErrorBanner-7naZtdtD.mjs";
5
+ import { S as Y } from "./StatsBar-B_lf0ph0.mjs";
6
6
  function te({ serverUrl: u, apiKey: d, pageSize: A = 20, authManager: o }) {
7
7
  const [_, F] = r([]), [S, C] = r(!0), [E, N] = r(!1), [v, k] = r(null), [Q, I] = r(!1), [y, $] = r(""), [f, x] = r("all"), [q, w] = r(null), [T, b] = r(null), [n, m] = r({
8
8
  question: "",
@@ -1,7 +1,7 @@
1
1
  import { jsxs as l, jsx as t, Fragment as R } from "react/jsx-runtime";
2
2
  import { useState as h, useRef as j, useCallback as U } from "react";
3
- import { I as u } from "./plugin-BIkt3boU.mjs";
4
- import { E as z } from "./ErrorBanner-DAjYj6Dx.mjs";
3
+ import { I as u } from "./plugin-CuoGEYWr.mjs";
4
+ import { E as z } from "./ErrorBanner-7naZtdtD.mjs";
5
5
  import { f as B } from "./dateHelpers-yvPkofYQ.mjs";
6
6
  import { g as I } from "./fetchWithTimeout-DmMOwL0Q.mjs";
7
7
  async function W(r, n, i, c) {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),h=require("./plugin-Dw8_Q8rE.js"),A=require("./ErrorBanner-DxrRVqwe.js"),O=require("./dateHelpers-BKW_lGND.js"),v=require("./fetchWithTimeout-CG0EKbhf.js");async function R(s,l,n,c){const o=new FormData;if(o.append("file",c),n?.isAuthenticated())return n.fetchWithAuth("/admin/images/upload",{method:"POST",body:o,headers:{}});const r={};l&&(r["X-API-Key"]=l);const d=await fetch(`${s}/admin/images/upload`,{method:"POST",headers:r,body:o});if(!d.ok)throw new Error(`Upload failed: ${d.status}`);return d.json()}async function F(s,l,n,c){const o=JSON.stringify({url:c});if(n?.isAuthenticated()){await n.fetchWithAuth("/admin/images",{method:"DELETE",body:o});return}const r={"Content-Type":"application/json"};l&&(r["X-API-Key"]=l);const d=await fetch(`${s}/admin/images`,{method:"DELETE",headers:r,body:o});if(!d.ok)throw new Error(`Delete failed: ${d.status}`)}function z({serverUrl:s,apiKey:l,authManager:n}){const[c,o]=i.useState([]),[r,d]=i.useState(!1),[x,j]=i.useState(null),[D,m]=i.useState(null),[_,S]=i.useState(null),[p,f]=i.useState(!1),[u,g]=i.useState(null),b=i.useRef(null),w=i.useCallback(async t=>{d(!0),m(null);try{const a=await R(s,l,n,t);o(y=>[{url:a.url,thumbUrl:a.thumbUrl,uploadedAt:new Date().toISOString()},...y]),g(null),b.current&&(b.current.value="")}catch(a){v.getLogger().error("[ImagesSection] Upload failed:",a,{serverUrl:s.slice(0,20)+"..."}),m("Upload failed. Check file type and try again.")}finally{d(!1)}},[s,l,n]),C=t=>{const a=t.target.files?.[0]??null;g(a),m(null)},I=()=>{u&&w(u)},U=t=>{t.preventDefault(),f(!0)},N=()=>f(!1),k=t=>{t.preventDefault(),f(!1);const a=t.dataTransfer.files?.[0];a&&a.type.startsWith("image/")?(g(a),m(null)):a&&m("Only image files are accepted.")},T=i.useCallback(async t=>{j(t),m(null);try{await F(s,l,n,t),o(a=>a.filter(y=>y.url!==t))}catch(a){v.getLogger().error("[ImagesSection] Delete failed:",a,{serverUrl:s.slice(0,20)+"..."}),m("Failed to delete image.")}finally{j(null)}},[s,l,n]),E=async t=>{try{await navigator.clipboard.writeText(t),S(t),setTimeout(()=>S(null),2e3)}catch{m("Could not copy to clipboard.")}},L=["cedros-admin__drop-zone",p?"cedros-admin__drop-zone--active":""].filter(Boolean).join(" ");return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(A.ErrorBanner,{message:D}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Image Upload"})}),e.jsxs("div",{className:L,onDragOver:U,onDragLeave:N,onDrop:k,role:"region","aria-label":"Image drop zone",style:{border:"2px dashed",borderColor:p?"var(--cedros-accent, #6366f1)":"var(--cedros-border, #e2e8f0)",borderRadius:"0.5rem",padding:"1.5rem",textAlign:"center",marginBottom:"1rem",transition:"border-color 0.15s",backgroundColor:p?"var(--cedros-accent-subtle, rgba(99,102,241,0.06))":void 0},children:[e.jsx("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",opacity:.7},children:"Drag and drop an image here, or select a file below"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"center",alignItems:"center",flexWrap:"wrap"},children:[e.jsx("input",{ref:b,id:"cedros-image-file-input",type:"file",accept:"image/*",className:"cedros-admin__input",style:{maxWidth:260},onChange:C,"aria-label":"Select image file"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:I,disabled:!u||r,"aria-busy":r,children:r?e.jsxs(e.Fragment,{children:[h.Icons.loading," Uploading..."]}):"Upload"})]}),u&&!r&&e.jsxs("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",opacity:.65},children:["Selected: ",u.name," (",(u.size/1024).toFixed(1)," KB)"]})]}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Uploaded This Session",c.length>0&&e.jsx("span",{className:"cedros-admin__section-badge",style:{marginLeft:"0.5rem"},children:c.length})]})}),c.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No images uploaded yet."}):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:"Preview"}),e.jsx("th",{children:"URL"}),e.jsx("th",{children:"Uploaded"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:c.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{width:72},children:e.jsx("img",{src:t.thumbUrl,alt:"Thumbnail preview",style:{width:56,height:56,objectFit:"cover",borderRadius:"0.25rem",display:"block"}})}),e.jsx("td",{style:{maxWidth:320,wordBreak:"break-all"},children:e.jsx("code",{style:{fontSize:"0.8rem"},children:t.url})}),e.jsx("td",{style:{whiteSpace:"nowrap"},children:O.formatDateTime(t.uploadedAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem"},children:[e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>E(t.url),"aria-label":"Copy URL to clipboard",title:"Copy URL",children:[_===t.url?h.Icons.check:h.Icons.eye,_===t.url?"Copied":"Copy URL"]}),e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--destructive",onClick:()=>T(t.url),disabled:x===t.url,"aria-label":"Delete image",title:"Delete",children:[x===t.url?h.Icons.loading:h.Icons.trash,"Delete"]})]})})]},t.url))})]})})]})}exports.ImagesSection=z;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),h=require("./plugin-DNhaPAbC.js"),A=require("./ErrorBanner-BOS1XAPu.js"),O=require("./dateHelpers-BKW_lGND.js"),v=require("./fetchWithTimeout-CG0EKbhf.js");async function R(s,l,n,c){const o=new FormData;if(o.append("file",c),n?.isAuthenticated())return n.fetchWithAuth("/admin/images/upload",{method:"POST",body:o,headers:{}});const r={};l&&(r["X-API-Key"]=l);const d=await fetch(`${s}/admin/images/upload`,{method:"POST",headers:r,body:o});if(!d.ok)throw new Error(`Upload failed: ${d.status}`);return d.json()}async function F(s,l,n,c){const o=JSON.stringify({url:c});if(n?.isAuthenticated()){await n.fetchWithAuth("/admin/images",{method:"DELETE",body:o});return}const r={"Content-Type":"application/json"};l&&(r["X-API-Key"]=l);const d=await fetch(`${s}/admin/images`,{method:"DELETE",headers:r,body:o});if(!d.ok)throw new Error(`Delete failed: ${d.status}`)}function z({serverUrl:s,apiKey:l,authManager:n}){const[c,o]=i.useState([]),[r,d]=i.useState(!1),[x,j]=i.useState(null),[D,m]=i.useState(null),[_,S]=i.useState(null),[p,f]=i.useState(!1),[u,g]=i.useState(null),b=i.useRef(null),w=i.useCallback(async t=>{d(!0),m(null);try{const a=await R(s,l,n,t);o(y=>[{url:a.url,thumbUrl:a.thumbUrl,uploadedAt:new Date().toISOString()},...y]),g(null),b.current&&(b.current.value="")}catch(a){v.getLogger().error("[ImagesSection] Upload failed:",a,{serverUrl:s.slice(0,20)+"..."}),m("Upload failed. Check file type and try again.")}finally{d(!1)}},[s,l,n]),C=t=>{const a=t.target.files?.[0]??null;g(a),m(null)},I=()=>{u&&w(u)},U=t=>{t.preventDefault(),f(!0)},N=()=>f(!1),k=t=>{t.preventDefault(),f(!1);const a=t.dataTransfer.files?.[0];a&&a.type.startsWith("image/")?(g(a),m(null)):a&&m("Only image files are accepted.")},T=i.useCallback(async t=>{j(t),m(null);try{await F(s,l,n,t),o(a=>a.filter(y=>y.url!==t))}catch(a){v.getLogger().error("[ImagesSection] Delete failed:",a,{serverUrl:s.slice(0,20)+"..."}),m("Failed to delete image.")}finally{j(null)}},[s,l,n]),E=async t=>{try{await navigator.clipboard.writeText(t),S(t),setTimeout(()=>S(null),2e3)}catch{m("Could not copy to clipboard.")}},L=["cedros-admin__drop-zone",p?"cedros-admin__drop-zone--active":""].filter(Boolean).join(" ");return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(A.ErrorBanner,{message:D}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Image Upload"})}),e.jsxs("div",{className:L,onDragOver:U,onDragLeave:N,onDrop:k,role:"region","aria-label":"Image drop zone",style:{border:"2px dashed",borderColor:p?"var(--cedros-accent, #6366f1)":"var(--cedros-border, #e2e8f0)",borderRadius:"0.5rem",padding:"1.5rem",textAlign:"center",marginBottom:"1rem",transition:"border-color 0.15s",backgroundColor:p?"var(--cedros-accent-subtle, rgba(99,102,241,0.06))":void 0},children:[e.jsx("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",opacity:.7},children:"Drag and drop an image here, or select a file below"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",justifyContent:"center",alignItems:"center",flexWrap:"wrap"},children:[e.jsx("input",{ref:b,id:"cedros-image-file-input",type:"file",accept:"image/*",className:"cedros-admin__input",style:{maxWidth:260},onChange:C,"aria-label":"Select image file"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--primary",onClick:I,disabled:!u||r,"aria-busy":r,children:r?e.jsxs(e.Fragment,{children:[h.Icons.loading," Uploading..."]}):"Upload"})]}),u&&!r&&e.jsxs("p",{style:{marginTop:"0.5rem",fontSize:"0.8rem",opacity:.65},children:["Selected: ",u.name," (",(u.size/1024).toFixed(1)," KB)"]})]}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsxs("h3",{className:"cedros-admin__section-title",children:["Uploaded This Session",c.length>0&&e.jsx("span",{className:"cedros-admin__section-badge",style:{marginLeft:"0.5rem"},children:c.length})]})}),c.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No images uploaded yet."}):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:"Preview"}),e.jsx("th",{children:"URL"}),e.jsx("th",{children:"Uploaded"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:c.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{width:72},children:e.jsx("img",{src:t.thumbUrl,alt:"Thumbnail preview",style:{width:56,height:56,objectFit:"cover",borderRadius:"0.25rem",display:"block"}})}),e.jsx("td",{style:{maxWidth:320,wordBreak:"break-all"},children:e.jsx("code",{style:{fontSize:"0.8rem"},children:t.url})}),e.jsx("td",{style:{whiteSpace:"nowrap"},children:O.formatDateTime(t.uploadedAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem"},children:[e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost",onClick:()=>E(t.url),"aria-label":"Copy URL to clipboard",title:"Copy URL",children:[_===t.url?h.Icons.check:h.Icons.eye,_===t.url?"Copied":"Copy URL"]}),e.jsxs("button",{type:"button",className:"cedros-admin__button cedros-admin__button--destructive",onClick:()=>T(t.url),disabled:x===t.url,"aria-label":"Delete image",title:"Delete",children:[x===t.url?h.Icons.loading:h.Icons.trash,"Delete"]})]})})]},t.url))})]})})]})}exports.ImagesSection=z;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as n, jsx as t, Fragment as P } from "react/jsx-runtime";
2
2
  import { useState as o, useCallback as S, useEffect as w } from "react";
3
- import { I as j } from "./plugin-BIkt3boU.mjs";
4
- import { E as R } from "./ErrorBanner-DAjYj6Dx.mjs";
3
+ import { I as j } from "./plugin-CuoGEYWr.mjs";
4
+ import { E as R } from "./ErrorBanner-7naZtdtD.mjs";
5
5
  import { f as T } from "./dateHelpers-yvPkofYQ.mjs";
6
6
  import { g as E } from "./fetchWithTimeout-DmMOwL0Q.mjs";
7
7
  const a = 50;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),b=require("./plugin-Dw8_Q8rE.js"),L=require("./ErrorBanner-DxrRVqwe.js"),B=require("./dateHelpers-BKW_lGND.js"),S=require("./fetchWithTimeout-CG0EKbhf.js"),c=50;function k({serverUrl:o,apiKey:m,authManager:h}){const[y,N]=s.useState([]),[A,_]=s.useState(!0),[P,g]=s.useState(null),[d,w]=s.useState(""),[i,j]=s.useState([]),[E,p]=s.useState(!1),[I,f]=s.useState(null),[a,x]=s.useState(0),l=s.useCallback(async t=>{if(h?.isAuthenticated())return h.fetchWithAuth(t);const n={"Content-Type":"application/json"};m&&(n["X-API-Key"]=m);const r=await fetch(`${o}${t}`,{headers:n});if(!r.ok)throw new Error(`Request failed: ${r.status}`);return r.json()},[o,m,h]);s.useEffect(()=>{let t=!1;return _(!0),g(null),l("/admin/products?limit=100&offset=0").then(n=>{if(t)return;const r=Array.isArray(n)?n:n.products??[];N(r)}).catch(n=>{t||(S.getLogger().error("[InventorySection] Failed to load products:",n,{serverUrl:o.slice(0,20)+"..."}),g("Failed to load products"))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[l,o]);const v=s.useCallback(async(t,n)=>{if(t){p(!0),f(null);try{const r=`/admin/products/${encodeURIComponent(t)}/inventory/adjustments?limit=${c}&offset=${n}`,F=await l(r);j(F.adjustments??[])}catch(r){S.getLogger().error("[InventorySection] Failed to load adjustments:",r,{productId:t,serverUrl:o.slice(0,20)+"..."}),f("Failed to load inventory adjustments"),j([])}finally{p(!1)}}},[l,o]);s.useEffect(()=>{d&&v(d,a)},[v,d,a]);const C=t=>{w(t),x(0),j([]),f(null)},q=()=>x(t=>Math.max(0,t-c)),$=()=>x(t=>t+c),u=y.find(t=>t.id===d);return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(L.ErrorBanner,{message:P??I}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Inventory Adjustments"})}),e.jsx("div",{className:"cedros-admin__add-form",style:{marginBottom:"1rem"},children:e.jsx("div",{className:"cedros-admin__form-row",children:e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{htmlFor:"inventory-product-select",className:"cedros-admin__field-label",children:"Select Product"}),A?e.jsxs("div",{className:"cedros-admin__loading",children:[b.Icons.loading," Loading products..."]}):e.jsxs("select",{id:"inventory-product-select",className:"cedros-admin__input",value:d,onChange:t=>C(t.target.value),"aria-label":"Select product to view inventory adjustments",children:[e.jsx("option",{value:"",children:"-- Choose a product --"}),y.map(t=>e.jsx("option",{value:t.id,children:t.title??t.description??t.id},t.id))]})]})})}),d?E?e.jsxs("div",{className:"cedros-admin__loading",children:[b.Icons.loading," Loading adjustments..."]}):e.jsxs(e.Fragment,{children:[u&&e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",opacity:.7},children:["Showing adjustments for: ",e.jsx("strong",{children:u.title??u.description??u.id})]}),i.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No inventory adjustments 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:"Date"}),e.jsx("th",{children:"Delta"}),e.jsx("th",{children:"Before"}),e.jsx("th",{children:"After"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:i.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:B.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{style:{fontWeight:600,color:t.delta>0?"var(--cedros-success, #16a34a)":t.delta<0?"var(--cedros-danger, #dc2626)":void 0},"aria-label":`Delta: ${t.delta>0?"plus":""}${t.delta}`,children:t.delta>0?`+${t.delta}`:t.delta})}),e.jsx("td",{children:t.quantityBefore}),e.jsx("td",{children:t.quantityAfter}),e.jsx("td",{children:t.reason??e.jsx("span",{style:{opacity:.45},children:"—"})}),e.jsx("td",{children:t.actor??e.jsx("span",{style:{opacity:.45},children:"—"})})]},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:a===0,onClick:q,children:"Previous"}),e.jsxs("span",{children:["Page ",Math.floor(a/c)+1," · ",i.length," record",i.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:i.length<c,onClick:$,children:"Next"})]})]})]}):e.jsx("div",{className:"cedros-admin__empty",children:"Select a product to view its inventory adjustments."})]})}exports.InventorySection=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),b=require("./plugin-DNhaPAbC.js"),L=require("./ErrorBanner-BOS1XAPu.js"),B=require("./dateHelpers-BKW_lGND.js"),S=require("./fetchWithTimeout-CG0EKbhf.js"),c=50;function k({serverUrl:o,apiKey:m,authManager:h}){const[y,N]=s.useState([]),[A,_]=s.useState(!0),[P,g]=s.useState(null),[d,w]=s.useState(""),[i,j]=s.useState([]),[E,p]=s.useState(!1),[I,f]=s.useState(null),[a,x]=s.useState(0),l=s.useCallback(async t=>{if(h?.isAuthenticated())return h.fetchWithAuth(t);const n={"Content-Type":"application/json"};m&&(n["X-API-Key"]=m);const r=await fetch(`${o}${t}`,{headers:n});if(!r.ok)throw new Error(`Request failed: ${r.status}`);return r.json()},[o,m,h]);s.useEffect(()=>{let t=!1;return _(!0),g(null),l("/admin/products?limit=100&offset=0").then(n=>{if(t)return;const r=Array.isArray(n)?n:n.products??[];N(r)}).catch(n=>{t||(S.getLogger().error("[InventorySection] Failed to load products:",n,{serverUrl:o.slice(0,20)+"..."}),g("Failed to load products"))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[l,o]);const v=s.useCallback(async(t,n)=>{if(t){p(!0),f(null);try{const r=`/admin/products/${encodeURIComponent(t)}/inventory/adjustments?limit=${c}&offset=${n}`,F=await l(r);j(F.adjustments??[])}catch(r){S.getLogger().error("[InventorySection] Failed to load adjustments:",r,{productId:t,serverUrl:o.slice(0,20)+"..."}),f("Failed to load inventory adjustments"),j([])}finally{p(!1)}}},[l,o]);s.useEffect(()=>{d&&v(d,a)},[v,d,a]);const C=t=>{w(t),x(0),j([]),f(null)},q=()=>x(t=>Math.max(0,t-c)),$=()=>x(t=>t+c),u=y.find(t=>t.id===d);return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(L.ErrorBanner,{message:P??I}),e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Inventory Adjustments"})}),e.jsx("div",{className:"cedros-admin__add-form",style:{marginBottom:"1rem"},children:e.jsx("div",{className:"cedros-admin__form-row",children:e.jsxs("div",{className:"cedros-admin__field",style:{flex:1},children:[e.jsx("label",{htmlFor:"inventory-product-select",className:"cedros-admin__field-label",children:"Select Product"}),A?e.jsxs("div",{className:"cedros-admin__loading",children:[b.Icons.loading," Loading products..."]}):e.jsxs("select",{id:"inventory-product-select",className:"cedros-admin__input",value:d,onChange:t=>C(t.target.value),"aria-label":"Select product to view inventory adjustments",children:[e.jsx("option",{value:"",children:"-- Choose a product --"}),y.map(t=>e.jsx("option",{value:t.id,children:t.title??t.description??t.id},t.id))]})]})})}),d?E?e.jsxs("div",{className:"cedros-admin__loading",children:[b.Icons.loading," Loading adjustments..."]}):e.jsxs(e.Fragment,{children:[u&&e.jsxs("p",{style:{marginBottom:"0.75rem",fontSize:"0.9rem",opacity:.7},children:["Showing adjustments for: ",e.jsx("strong",{children:u.title??u.description??u.id})]}),i.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No inventory adjustments 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:"Date"}),e.jsx("th",{children:"Delta"}),e.jsx("th",{children:"Before"}),e.jsx("th",{children:"After"}),e.jsx("th",{children:"Reason"}),e.jsx("th",{children:"Actor"})]})}),e.jsx("tbody",{children:i.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:B.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsx("span",{style:{fontWeight:600,color:t.delta>0?"var(--cedros-success, #16a34a)":t.delta<0?"var(--cedros-danger, #dc2626)":void 0},"aria-label":`Delta: ${t.delta>0?"plus":""}${t.delta}`,children:t.delta>0?`+${t.delta}`:t.delta})}),e.jsx("td",{children:t.quantityBefore}),e.jsx("td",{children:t.quantityAfter}),e.jsx("td",{children:t.reason??e.jsx("span",{style:{opacity:.45},children:"—"})}),e.jsx("td",{children:t.actor??e.jsx("span",{style:{opacity:.45},children:"—"})})]},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:a===0,onClick:q,children:"Previous"}),e.jsxs("span",{children:["Page ",Math.floor(a/c)+1," · ",i.length," record",i.length!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",disabled:i.length<c,onClick:$,children:"Next"})]})]})]}):e.jsx("div",{className:"cedros-admin__empty",children:"Select a product to view its inventory adjustments."})]})}exports.InventorySection=k;