@cedros/pay-react 1.1.25 → 1.1.26

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 (94) hide show
  1. package/dist/{AISettingsSection-Dg1kazTI.mjs → AISettingsSection-BlIv3CzS.mjs} +2 -2
  2. package/dist/{AISettingsSection-BvSSiK2G.js → AISettingsSection-DELur7D2.js} +1 -1
  3. package/dist/{AutosaveIndicator-BHfkV59p.mjs → AutosaveIndicator-Bed0-ekg.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-D2l7U8R1.js → AutosaveIndicator-Dn_qA2hK.js} +1 -1
  5. package/dist/ChatLogsSection-BH5tLA4T.js +1 -0
  6. package/dist/ChatLogsSection-v4zwzCTC.mjs +201 -0
  7. package/dist/{ComplianceSection-BSE2f3Wo.mjs → ComplianceSection-CemgfDrL.mjs} +282 -166
  8. package/dist/ComplianceSection-DP2a9-S0.js +1 -0
  9. package/dist/CustomersSection-CBwy_waO.js +1 -0
  10. package/dist/CustomersSection-D_j7OrfS.mjs +207 -0
  11. package/dist/DisputesSection-BLjIk60n.js +1 -0
  12. package/dist/DisputesSection-BcAbXp3K.mjs +230 -0
  13. package/dist/{FAQSection-uZG5V3pJ.mjs → FAQSection-Dn38OhB_.mjs} +1 -1
  14. package/dist/{FAQSection-6nGI0FK9.js → FAQSection-wNeH0i6Q.js} +1 -1
  15. package/dist/ImagesSection-0ZzKlzMJ.js +1 -0
  16. package/dist/ImagesSection-Ctw9Icym.mjs +216 -0
  17. package/dist/InventorySection-DmhjUlRZ.mjs +150 -0
  18. package/dist/InventorySection-zV6lTmue.js +1 -0
  19. package/dist/{MessagingSection-M0lj5yo4.mjs → MessagingSection-B1FaGxkp.mjs} +2 -2
  20. package/dist/{MessagingSection-DrXb578q.js → MessagingSection-B_wdFR0j.js} +1 -1
  21. package/dist/{OrdersSection-DteItv_O.mjs → OrdersSection-Bj8bPdg8.mjs} +1 -1
  22. package/dist/{OrdersSection-_-rIw6XW.js → OrdersSection-Dw2FX-1d.js} +1 -1
  23. package/dist/{PaymentSettingsSection-enTbUI95.js → PaymentSettingsSection-BYF4D-GR.js} +1 -1
  24. package/dist/{PaymentSettingsSection-CdtdLFTg.mjs → PaymentSettingsSection-EnMxeWjv.mjs} +1 -1
  25. package/dist/ReturnsSection-BC0L8r2e.mjs +267 -0
  26. package/dist/ReturnsSection-D_pJVxuG.js +1 -0
  27. package/dist/{SettingsSection-mcT4LEhO.mjs → SettingsSection-KYdEizq_.mjs} +1 -1
  28. package/dist/{SettingsSection-DUTEd6uV.js → SettingsSection-vdYFSNxB.js} +1 -1
  29. package/dist/ShippingSection-1DRSTu49.js +1 -0
  30. package/dist/ShippingSection-BOgto6_9.mjs +434 -0
  31. package/dist/{SingleCategorySettings-D2LVM5mn.js → SingleCategorySettings-DwCnBdRf.js} +1 -1
  32. package/dist/{SingleCategorySettings-BvHBVfSe.mjs → SingleCategorySettings-suJ8z9d8.mjs} +2 -2
  33. package/dist/{StorefrontSection-BqQ36JIS.mjs → StorefrontSection-BRvIGBEJ.mjs} +2 -2
  34. package/dist/{StorefrontSection-Du7hV2Gc.js → StorefrontSection-RumGkb3C.js} +1 -1
  35. package/dist/{SubscriptionsSection-C4BRN1dP.js → SubscriptionsSection-C2aLLn7L.js} +1 -1
  36. package/dist/{SubscriptionsSection-BYiCBwKZ.mjs → SubscriptionsSection-D60qrX9a.mjs} +1 -1
  37. package/dist/TaxSection-C7-pv-Rl.mjs +294 -0
  38. package/dist/TaxSection-Dt1DnM51.js +1 -0
  39. package/dist/{Token22Section-BHvOhz5d.mjs → Token22Section-CrHLQ0EB.mjs} +1 -1
  40. package/dist/{Token22Section-0c22NM5G.js → Token22Section-DY3mUwTY.js} +1 -1
  41. package/dist/WebhooksSection-CKeiJ7Py.js +1 -0
  42. package/dist/WebhooksSection-COPW4Ec0.mjs +223 -0
  43. package/dist/crypto-only.js +1 -1
  44. package/dist/crypto-only.mjs +1 -1
  45. package/dist/index-C0g-JxJk.js +84 -0
  46. package/dist/{index-BkDimQDF.mjs → index-DXnuQp5x.mjs} +7068 -6768
  47. package/dist/index.js +1 -1
  48. package/dist/index.mjs +1 -1
  49. package/dist/{sections-By4H1baL.mjs → sections-C1NpK7hk.mjs} +2 -2
  50. package/dist/{sections-5jO2aHAo.js → sections-DVVSZBhW.js} +1 -1
  51. package/dist/src/components/ComplianceGatePage.d.ts +3 -1
  52. package/dist/src/components/ComplianceGatePage.d.ts.map +1 -1
  53. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +1 -1
  54. package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +1 -1
  55. package/dist/src/components/admin/ChatLogsSection.d.ts +3 -0
  56. package/dist/src/components/admin/ChatLogsSection.d.ts.map +1 -0
  57. package/dist/src/components/admin/ComplianceKycTab.d.ts +3 -0
  58. package/dist/src/components/admin/ComplianceKycTab.d.ts.map +1 -0
  59. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts +8 -0
  60. package/dist/src/components/admin/ComplianceRequirementsEditor.d.ts.map +1 -0
  61. package/dist/src/components/admin/ComplianceSection.d.ts.map +1 -1
  62. package/dist/src/components/admin/CustomersSection.d.ts +3 -0
  63. package/dist/src/components/admin/CustomersSection.d.ts.map +1 -0
  64. package/dist/src/components/admin/DisputesSection.d.ts +3 -0
  65. package/dist/src/components/admin/DisputesSection.d.ts.map +1 -0
  66. package/dist/src/components/admin/ImagesSection.d.ts +3 -0
  67. package/dist/src/components/admin/ImagesSection.d.ts.map +1 -0
  68. package/dist/src/components/admin/InventorySection.d.ts +3 -0
  69. package/dist/src/components/admin/InventorySection.d.ts.map +1 -0
  70. package/dist/src/components/admin/NftMetadataPreview.d.ts +20 -0
  71. package/dist/src/components/admin/NftMetadataPreview.d.ts.map +1 -0
  72. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  73. package/dist/src/components/admin/ReturnsSection.d.ts +3 -0
  74. package/dist/src/components/admin/ReturnsSection.d.ts.map +1 -0
  75. package/dist/src/components/admin/ShippingSection.d.ts +3 -0
  76. package/dist/src/components/admin/ShippingSection.d.ts.map +1 -0
  77. package/dist/src/components/admin/TaxSection.d.ts +3 -0
  78. package/dist/src/components/admin/TaxSection.d.ts.map +1 -0
  79. package/dist/src/components/admin/WebhooksSection.d.ts +3 -0
  80. package/dist/src/components/admin/WebhooksSection.d.ts.map +1 -0
  81. package/dist/src/components/admin/complianceTypes.d.ts +15 -1
  82. package/dist/src/components/admin/complianceTypes.d.ts.map +1 -1
  83. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts +36 -0
  84. package/dist/src/ecommerce/adapters/CommerceAdapter.d.ts.map +1 -1
  85. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  86. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts +8 -5
  87. package/dist/src/ecommerce/components/chat/ShopChatPanel.d.ts.map +1 -1
  88. package/dist/src/ecommerce/index.d.ts +2 -2
  89. package/dist/src/ecommerce/index.d.ts.map +1 -1
  90. package/dist/src/hooks/useComplianceCheck.d.ts +1 -1
  91. package/dist/src/hooks/useComplianceCheck.d.ts.map +1 -1
  92. package/package.json +1 -1
  93. package/dist/ComplianceSection-D6ETKG6b.js +0 -1
  94. package/dist/index-C7MWL6O8.js +0 -84
@@ -1 +1 @@
1
- "use strict";var ke=Object.create;var xe=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var Re=(t,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of Te(i))!Be.call(t,a)&&a!==n&&xe(t,a,{get:()=>i[a],enumerable:!(s=Ae(i,a))||s.enumerable});return t};var me=(t,i,n)=>(n=t!=null?ke(Ne(t)):{},Re(i||!t||!t.__esModule?xe(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),fe=require("./index-C7MWL6O8.js"),ee=require("./configApi-DkduMQg1.js"),Ce=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"address",label:"Address"},{value:"textarea",label:"Long Text"},{value:"dropdown",label:"Dropdown"},{value:"file_upload",label:"File Upload"}],be={fields:[],requiresApproval:!0},U={width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",boxSizing:"border-box"},G={display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},Q={padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.85rem"};function ze(){return{id:Math.random().toString(36).slice(2),label:"",fieldType:"text",required:!1,options:[],placeholder:""}}function je({field:t,onSave:i,onCancel:n}){const[s,a]=r.useState(t),[c,y]=r.useState(""),p=o=>a(d=>({...d,...o})),b=()=>{const o=c.trim();o&&(p({options:[...s.options,o]}),y(""))};return e.jsxs("div",{style:{padding:"0.75rem",border:"1px solid rgba(37,99,235,0.3)",borderRadius:6,background:"#eff6ff",marginTop:6},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.6rem",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Label *"}),e.jsx("input",{style:U,value:s.label,onChange:o=>p({label:o.target.value}),placeholder:"e.g., Full Name"})]}),e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Field Type"}),e.jsx("select",{style:U,value:s.fieldType,onChange:o=>p({fieldType:o.target.value,options:[]}),children:Ce.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"0.6rem",alignItems:"end",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Placeholder"}),e.jsx("input",{style:U,value:s.placeholder??"",onChange:o=>p({placeholder:o.target.value}),placeholder:"Optional hint text"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",paddingBottom:2},children:[e.jsx("input",{type:"checkbox",checked:s.required,onChange:o=>p({required:o.target.checked})})," Required"]})]}),s.fieldType==="dropdown"&&e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsx("label",{style:G,children:"Options"}),s.options.map((o,d)=>e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:4},children:[e.jsx("span",{style:{flex:1,fontSize:"0.85rem",padding:"0.25rem 0.5rem",background:"white",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4},children:o}),e.jsx("button",{type:"button",onClick:()=>p({options:s.options.filter((u,v)=>v!==d)}),style:{padding:"0.2rem 0.5rem",borderRadius:4,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"x"})]},d)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{style:{...U,flex:1},value:c,onChange:o=>y(o.target.value),onKeyDown:o=>o.key==="Enter"&&(o.preventDefault(),b()),placeholder:"Add option..."}),e.jsx("button",{type:"button",onClick:b,style:Q,children:"Add"})]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>i(s),disabled:!s.label.trim(),style:{padding:"0.35rem 1rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:s.label.trim()?"pointer":"not-allowed",fontSize:"0.85rem",opacity:s.label.trim()?1:.5},children:"Save Field"}),e.jsx("button",{type:"button",onClick:n,style:Q,children:"Cancel"})]})]})}function Ie({fields:t,instructions:i}){const n={...U,fontSize:"0.85rem",background:"white",opacity:.6};return e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"rgba(0,0,0,0.02)"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"rgba(0,0,0,0.4)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"0.75rem"},children:"Preview — Redeemer View"}),i&&e.jsx("div",{style:{padding:"0.6rem 0.75rem",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,fontSize:"0.85rem",marginBottom:"0.75rem",color:"#92400e"},children:i}),t.length===0&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic"},children:"No fields added yet."}),t.map(s=>e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsxs("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:[s.label||"Unlabelled field",s.required&&e.jsx("span",{style:{color:"#dc2626",marginLeft:2},children:"*"})]}),s.fieldType==="textarea"&&e.jsx("textarea",{disabled:!0,rows:2,placeholder:s.placeholder??"",style:{...n,resize:"none"}}),s.fieldType==="file_upload"&&e.jsx("div",{style:{padding:"0.5rem",border:"1px dashed rgba(0,0,0,0.25)",borderRadius:4,fontSize:"0.8rem",color:"rgba(0,0,0,0.4)",textAlign:"center"},children:"File upload"}),s.fieldType==="dropdown"&&e.jsxs("select",{disabled:!0,style:n,children:[e.jsx("option",{children:s.placeholder||"Select..."}),s.options.map((a,c)=>e.jsx("option",{children:a},c))]}),!["textarea","file_upload","dropdown"].includes(s.fieldType)&&e.jsx("input",{disabled:!0,type:s.fieldType==="email"?"email":s.fieldType==="phone"?"tel":"text",placeholder:s.placeholder??"",style:n})]},s.id))]})}function De({value:t,onChange:i}){const n=t!==null,s=t??be,[a,c]=r.useState(null),[y,p]=r.useState(null),[b,o]=r.useState(!1),d=h=>i({...s,...h}),u=()=>{c(null),p(null)},v=h=>{i(h?{...be}:null),u()},x=()=>{const h=ze();p(h),c("new")},f=h=>{p({...h}),c(h.id)},j=h=>{d({fields:a==="new"?[...s.fields,h]:s.fields.map(S=>S.id===h.id?h:S)}),u()},k=h=>{a===h&&u(),d({fields:s.fields.filter(S=>S.id!==h)})};return e.jsxs("div",{children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",marginBottom:n?"1rem":4,fontSize:"0.9rem",fontWeight:500},children:[e.jsx("input",{type:"checkbox",checked:n,onChange:h=>v(h.target.checked)}),"Enable Redemption Form"]}),!n&&e.jsx("div",{style:{fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:"No redemption form — token holders cannot request physical redemption."}),n&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Instructions shown to redeemer"}),e.jsx("textarea",{value:s.instructions??"",onChange:h=>d({instructions:h.target.value||void 0}),placeholder:"Describe requirements, turnaround times, etc.",rows:3,style:{...U,resize:"vertical"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"1rem",alignItems:"center",padding:"0.6rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"rgba(0,0,0,0.02)"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",whiteSpace:"nowrap"},children:[e.jsx("input",{type:"checkbox",checked:s.requiresApproval,onChange:h=>d({requiresApproval:h.target.checked})})," Requires admin approval"]}),e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Estimated processing days"}),e.jsx("input",{type:"number",min:0,value:s.estimatedProcessingDays??"",onChange:h=>d({estimatedProcessingDays:h.target.value?Number(h.target.value):void 0}),placeholder:"e.g., 5",style:{...U,maxWidth:120}})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:500,marginBottom:"0.5rem"},children:["Form Fields (",s.fields.length,")"]}),s.fields.length===0&&a!=="new"&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic",marginBottom:"0.5rem"},children:"No fields yet. Add fields below."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem"},children:[s.fields.map(h=>e.jsxs("div",{children:[e.jsxs("div",{style:{padding:"0.5rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"white",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"0.9rem"},children:h.label||e.jsx("em",{style:{color:"rgba(0,0,0,0.35)"},children:"Unlabelled"})}),e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dbeafe",color:"#1d4ed8",fontSize:"0.75rem"},children:Ce.find(S=>S.value===h.fieldType)?.label??h.fieldType}),h.required&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#fef3c7",color:"#92400e",fontSize:"0.75rem"},children:"required"})]}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{type:"button",onClick:()=>f(h),style:{...Q,padding:"0.25rem 0.6rem",fontSize:"0.8rem"},children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>k(h.id),style:{padding:"0.25rem 0.6rem",borderRadius:4,border:"1px solid rgba(220,38,38,0.3)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"Delete"})]})]}),a===h.id&&y&&e.jsx(je,{field:y,onSave:j,onCancel:u})]},h.id)),a==="new"&&y&&e.jsx(je,{field:y,onSave:j,onCancel:u})]}),a===null&&e.jsx("button",{type:"button",onClick:x,style:{...Q,marginTop:"0.5rem"},children:"+ Add Field"})]}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>o(h=>!h),style:{...Q,background:b?"rgba(0,0,0,0.05)":"white"},children:b?"Hide Preview":"Show Preview"}),b&&e.jsx("div",{style:{marginTop:"0.75rem"},children:e.jsx(Ie,{fields:s.fields,instructions:s.instructions})})]})]})]})}const Pe=[{value:"securities",label:"Securities (fungible)"},{value:"commodities",label:"Commodities (fungible)"},{value:"property",label:"Property (non-fungible)"},{value:"collectibles",label:"Collectibles (non-fungible)"}],Me=t=>t==="securities"||t==="commodities";function Fe({c:t,onDeployPool:i,onEdit:n,onDelete:s}){const a=t.tokenizationConfig,c=Me(a.assetClass);return e.jsxs("div",{style:{padding:"0.75rem 1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"white"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:t.name}),e.jsx("span",{style:{marginLeft:8,fontSize:"0.8rem",padding:"2px 8px",borderRadius:10,background:c?"#dbeafe":"#fef3c7",color:c?"#1d4ed8":"#92400e"},children:a.assetClass}),a.tokenSymbol&&e.jsx("span",{style:{marginLeft:6,fontSize:"0.8rem",color:"rgba(0,0,0,0.5)"},children:a.tokenSymbol})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.8rem"},children:[a.mintAddress?e.jsx("span",{style:{color:"#16a34a"},children:"Mint initialized"}):e.jsx("span",{style:{color:"rgba(0,0,0,0.4)"},children:"No mint"}),c&&a.mintAddress&&(a.liquidityPoolAddress?e.jsxs("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dcfce7",color:"#15803d",fontSize:"0.75rem"},children:["Pool Active · ",a.liquidityPoolAddress.slice(0,4),"...",a.liquidityPoolAddress.slice(-4)]}):e.jsx("button",{type:"button",onClick:i,style:{padding:0,border:"none",background:"none",color:"#2563eb",cursor:"pointer",fontSize:"0.8rem",textDecoration:"underline"},children:"Deploy Pool"}))]})]}),t.description&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.5)",marginTop:4},children:t.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6},children:[e.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:[e.jsxs("span",{children:["Fee: ",a.transferFeeBps," bps"]}),a.treasuryAddress&&e.jsxs("span",{children:["Treasury: ",a.treasuryAddress.slice(0,8),"..."]}),a.allowedJurisdictions?.length>0&&e.jsxs("span",{style:{padding:"1px 7px",borderRadius:10,background:"#f3f4f6",color:"rgba(0,0,0,0.55)"},children:[a.allowedJurisdictions.length," jurisdiction",a.allowedJurisdictions.length!==1?"s":"",": ",a.allowedJurisdictions.join(", ")]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[n&&e.jsx("button",{type:"button",onClick:n,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#2563eb"},children:"Edit"}),s&&e.jsx("button",{type:"button",onClick:s,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#dc2626"},children:"Delete"})]})]})]})}const pe={name:"",description:"",assetClass:"securities",tokenSymbol:"",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500,treasuryAddress:"",regulatoryNotice:"",jurisdictions:"",redemptionConfig:null};function Ee({serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:s}){const[a,c]=r.useState([]),[y,p]=r.useState(!0),[b,o]=r.useState(null),[d,u]=r.useState(!1),[v,x]=r.useState(!1),[f,j]=r.useState(pe),[k,h]=r.useState(null),S=r.useCallback(async(g,m)=>{if(n?.isAuthenticated())return n.fetchWithAuth(g,m);const N={"Content-Type":"application/json"};i&&(N["X-API-Key"]=i);const C=await fetch(`${t}${g}`,{...m,headers:{...N,...m?.headers}});if(!C.ok){const z=await C.text().catch(()=>`HTTP ${C.status}`);throw new Error(z)}return C.json()},[t,i,n]),T=r.useCallback(async()=>{try{p(!0),o(null);const g=await S("/admin/collections");c((g.collections||[]).filter(m=>m.tokenizationConfig))}catch(g){o(g instanceof Error?g.message:"Failed to load asset classes")}finally{p(!1)}},[S]);r.useEffect(()=>{T()},[T]);const l=()=>({name:f.name.trim(),description:f.description||void 0,active:!0,productIds:[],tokenizationConfig:{assetClass:f.assetClass,tokenSymbol:f.tokenSymbol||void 0,tokenDecimals:f.tokenDecimals,transferFeeBps:f.transferFeeBps,maxTransferFee:f.maxTransferFee,treasuryAddress:f.treasuryAddress||void 0,regulatoryNotice:f.regulatoryNotice||void 0,allowedJurisdictions:f.jurisdictions?f.jurisdictions.split(",").map(g=>g.trim().toUpperCase()).filter(Boolean):[],redemptionConfig:f.redemptionConfig||void 0}}),w=async()=>{if(f.name.trim()){x(!0),o(null);try{k?await S(`/admin/collections/${encodeURIComponent(k)}`,{method:"PUT",body:JSON.stringify(l())}):await S("/admin/collections",{method:"POST",body:JSON.stringify(l())}),j(pe),u(!1),h(null),await T()}catch(g){o(g instanceof Error?g.message:`Failed to ${k?"update":"create"} asset class`)}finally{x(!1)}}},_=g=>{const m=g.tokenizationConfig;j({name:g.name,description:g.description??"",assetClass:m.assetClass,tokenSymbol:m.tokenSymbol??"",tokenDecimals:m.tokenDecimals,transferFeeBps:m.transferFeeBps,maxTransferFee:m.maxTransferFee,treasuryAddress:m.treasuryAddress??"",regulatoryNotice:m.regulatoryNotice??"",jurisdictions:m.allowedJurisdictions.join(", "),redemptionConfig:m.redemptionConfig??null}),h(g.id),u(!0)},A=async g=>{if(window.confirm(`Delete asset class "${g.name}"? This cannot be undone.`)){o(null);try{await S(`/admin/collections/${encodeURIComponent(g.id)}`,{method:"DELETE"}),await T()}catch(m){o(m instanceof Error?m.message:"Failed to delete asset class")}}};return y?e.jsx("div",{style:{padding:"1rem 0",color:"rgba(0,0,0,0.5)"},children:"Loading asset classes..."}):e.jsxs("div",{children:[b&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:b}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsxs("h4",{style:{margin:0},children:["Asset Classes (",a.length,")"]}),e.jsx("button",{type:"button",onClick:()=>{u(!d),d&&(h(null),j(pe))},style:{padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:d?"rgba(0,0,0,0.05)":"white",cursor:"pointer",fontSize:"0.85rem"},children:d?"Cancel":"+ New Asset Class"})]}),d&&e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,marginBottom:"1rem",background:"rgba(0,0,0,0.02)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Name *"}),e.jsx("input",{type:"text",value:f.name,onChange:g=>j(m=>({...m,name:g.target.value})),placeholder:"e.g., Gold Tokens",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Asset Class *"}),e.jsx("select",{value:f.assetClass,onChange:g=>j(m=>({...m,assetClass:g.target.value})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"},children:Pe.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Description"}),e.jsx("input",{type:"text",value:f.description,onChange:g=>j(m=>({...m,description:g.target.value})),placeholder:"Brief description of this asset class",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Token Symbol"}),e.jsx("input",{type:"text",value:f.tokenSymbol,onChange:g=>j(m=>({...m,tokenSymbol:g.target.value})),placeholder:"e.g., GOLD",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Transfer Fee (bps)"}),e.jsx("input",{type:"number",value:f.transferFeeBps,onChange:g=>j(m=>({...m,transferFeeBps:Number(g.target.value)})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Treasury Address"}),e.jsx("input",{type:"text",value:f.treasuryAddress,onChange:g=>j(m=>({...m,treasuryAddress:g.target.value})),placeholder:"Solana address",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Allowed Jurisdictions"}),e.jsx("input",{type:"text",value:f.jurisdictions,onChange:g=>j(m=>({...m,jurisdictions:g.target.value})),placeholder:"US, CA, GB (comma-separated, leave empty for all)",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Regulatory Notice"}),e.jsx("textarea",{value:f.regulatoryNotice,onChange:g=>j(m=>({...m,regulatoryNotice:g.target.value})),placeholder:"Shown to buyers before purchase",rows:2,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:600,marginBottom:8},children:"Redemption Form"}),e.jsx(De,{value:f.redemptionConfig,onChange:g=>j(m=>({...m,redemptionConfig:g}))})]}),e.jsx("button",{type:"button",onClick:w,disabled:v||!f.name.trim(),style:{padding:"0.5rem 1.5rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:v?"wait":"pointer",fontSize:"0.9rem",opacity:v?.6:1},children:v?"Saving...":k?"Save Changes":"Create Asset Class"})]}),a.length===0?e.jsx("div",{style:{padding:"2rem",textAlign:"center",color:"rgba(0,0,0,0.4)",fontSize:"0.9rem"},children:"No asset classes configured. Create one to start tokenizing off-chain assets."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:a.map(g=>e.jsx(Fe,{c:g,onDeployPool:s,onEdit:()=>_(g),onDelete:()=>A(g)},g.id))})]})}const Le=[{value:"",label:"All statuses"},{value:"pending_info",label:"Pending Info"},{value:"info_submitted",label:"Info Submitted"},{value:"under_review",label:"Under Review"},{value:"approved",label:"Approved"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}];function $e(t){switch(t){case"pending_info":return"cedros-admin__badge cedros-admin__badge--muted";case"info_submitted":return"cedros-admin__badge cedros-admin__badge--info";case"under_review":return"cedros-admin__badge cedros-admin__badge--warning";case"approved":return"cedros-admin__badge cedros-admin__badge--success";case"completed":return"cedros-admin__badge cedros-admin__badge--success";case"rejected":return"cedros-admin__badge cedros-admin__badge--failed";default:return"cedros-admin__badge cedros-admin__badge--muted"}}function qe(t){return t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function Oe(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function K(t){return t.length>12?`${t.slice(0,8)}…`:t}function _e(t){return`https://solscan.io/tx/${t}`}function We({redemption:t,onAction:i,onComplete:n,actionBusy:s}){const[a,c]=r.useState(t.adminNotes??""),y=Object.entries(t.formData??{});return e.jsx("div",{style:{padding:"1rem 1.25rem",background:"rgba(0,0,0,0.02)",borderTop:"1px solid rgba(0,0,0,0.08)"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1.5rem"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"0.8rem",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em",opacity:.6},children:"Form Data"}),y.length===0?e.jsx("div",{style:{fontSize:"0.85rem",opacity:.5},children:"No form data submitted."}):e.jsx("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",fontSize:"0.85rem"},children:y.map(([p,b])=>e.jsxs(e.Fragment,{children:[e.jsx("dt",{style:{fontWeight:500,color:"rgba(0,0,0,0.6)",whiteSpace:"nowrap"},children:p},`k-${p}`),e.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:String(b??"—")},`v-${p}`)]}))}),(t.tokenMintSignature||t.tokenBurnSignature)&&e.jsxs("div",{style:{marginTop:12,fontSize:"0.8rem"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4,opacity:.6,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Signatures"}),t.tokenMintSignature&&e.jsxs("div",{children:["Mint:"," ",e.jsx("a",{href:_e(t.tokenMintSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:K(t.tokenMintSignature)})]}),t.tokenBurnSignature&&e.jsxs("div",{children:["Burn:"," ",e.jsx("a",{href:_e(t.tokenBurnSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:K(t.tokenBurnSignature)})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Admin Notes"}),e.jsx("textarea",{value:a,onChange:p=>c(p.target.value),rows:4,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.85rem",resize:"vertical",boxSizing:"border-box"},placeholder:"Internal notes (not shown to user)..."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:8,flexWrap:"wrap"},children:[t.status==="info_submitted"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"under_review",a),children:s?"Saving...":"Mark Under Review"}),t.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"approved",a),children:s?"Saving...":"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"rejected",a),children:s?"Saving...":"Reject"})]}),t.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>n(t.id),children:s?"Processing...":"Complete"})]})]})]})})}function Ue({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState([]),[c,y]=r.useState(!0),[p,b]=r.useState(null),[o,d]=r.useState(""),[u,v]=r.useState(null),[x,f]=r.useState(null),j=r.useCallback(async(l,w)=>{if(n?.isAuthenticated())return n.fetchWithAuth(l,w);const _={"Content-Type":"application/json"};i&&(_["X-API-Key"]=i);const A=await fetch(`${t}${l}`,{...w,headers:{..._,...w?.headers}});if(!A.ok){const g=await A.text().catch(()=>`HTTP ${A.status}`);throw new Error(g)}return A.json()},[t,i,n]),k=r.useCallback(async()=>{y(!0),b(null);try{const l=o?`?status=${encodeURIComponent(o)}&limit=50&offset=0`:"?limit=50&offset=0",w=await j(`/admin/asset-redemptions${l}`);a(w.redemptions??[])}catch(l){b(l instanceof Error?l.message:"Failed to load redemptions")}finally{y(!1)}},[j,o]);r.useEffect(()=>{k()},[k]);const h=r.useCallback(async(l,w,_)=>{f(l),b(null);try{await j(`/admin/asset-redemptions/${l}/status`,{method:"PATCH",body:JSON.stringify({status:w,adminNotes:_})}),v(null),await k()}catch(A){b(A instanceof Error?A.message:"Failed to update status")}finally{f(null)}},[j,k]),S=r.useCallback(async l=>{f(l),b(null);try{await j(`/admin/asset-redemptions/${l}/complete`,{method:"POST"}),v(null),await k()}catch(w){b(w instanceof Error?w.message:"Failed to complete redemption")}finally{f(null)}},[j,k]),T=l=>{v(w=>w===l?null:l)};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1rem",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Status"}),e.jsx("select",{value:o,onChange:l=>{d(l.target.value),v(null)},style:{padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",minWidth:160},children:Le.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))})]}),e.jsx("div",{style:{alignSelf:"flex-end"},children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline",onClick:k,disabled:c,children:c?"Loading...":"Refresh"})})]}),p&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:p}),c?e.jsx("div",{className:"cedros-admin__loading",children:"Loading redemptions..."}):s.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No redemption requests found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"User"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:s.map(l=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{cursor:"pointer"},onClick:()=>T(l.id),children:[e.jsx("td",{children:Oe(l.createdAt)}),e.jsx("td",{children:e.jsx("code",{title:l.orderId,children:K(l.orderId)})}),e.jsx("td",{children:e.jsx("code",{title:l.productId,children:K(l.productId)})}),e.jsx("td",{children:e.jsx("code",{title:l.collectionId,children:K(l.collectionId)})}),e.jsx("td",{children:l.userId?e.jsx("code",{title:l.userId,children:K(l.userId)}):e.jsx("span",{style:{opacity:.4},children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:$e(l.status),children:qe(l.status)})}),e.jsx("td",{onClick:w=>w.stopPropagation(),children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[(l.status==="info_submitted"||l.status==="under_review"||l.status==="approved")&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>T(l.id),children:u===l.id?"Close":"Review"}),l.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:x===l.id,onClick:()=>h(l.id,"approved",l.adminNotes??""),children:"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:x===l.id,onClick:()=>h(l.id,"rejected",l.adminNotes??""),children:"Reject"})]}),l.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:x===l.id,onClick:()=>S(l.id),children:x===l.id?"Processing...":"Complete"})]})})]},l.id),u===l.id&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:0},children:e.jsx(We,{redemption:l,onAction:h,onComplete:S,actionBusy:x===l.id})})},`${l.id}-detail`)]}))})]})})]})}const Ye={CA:{cashOutCents:1500,expirationProhibited:!0,escheatmentYears:3,notes:"Cash-out threshold increases to $15 on April 1, 2026."},CO:{cashOutCents:500,escheatmentYears:5},CT:{cashOutCents:300,escheatmentYears:3},FL:{expirationProhibited:!0,escheatmentYears:5},ME:{cashOutCents:500,escheatmentYears:3},MA:{cashOutCents:500,escheatmentYears:3,notes:"Cash-out also required when 90% of value is used."},MT:{cashOutCents:500,escheatmentYears:5},NJ:{cashOutCents:500,escheatmentYears:3},OR:{cashOutCents:500,escheatmentYears:3,notes:"May require at least one prior transaction."},RI:{cashOutCents:100,escheatmentYears:3},TX:{cashOutCents:250,escheatmentYears:3},VT:{cashOutCents:100,escheatmentYears:3},WA:{cashOutCents:500,escheatmentYears:5},PR:{cashOutCents:500,escheatmentYears:5}},ye={escheatmentYears:5},re=1e6,Ge={AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",DC:"District of Columbia",PR:"Puerto Rico"};function Ke({serverUrl:t,authManager:i}){const[n,s]=r.useState(null),[a,c]=r.useState(null),[y,p]=r.useState(null),[b,o]=r.useState(!0),d=r.useCallback(async()=>{try{const j=(await new ee.ConfigApiClient(t,void 0,i).getConfig("gift_cards")).config??{};s(j.business_state||null),c(j.min_gift_card_value_cents!=null?Number(j.min_gift_card_value_cents):null),p(j.max_gift_card_value_cents!=null?Number(j.max_gift_card_value_cents):null)}catch{}finally{o(!1)}},[t,i]);if(r.useEffect(()=>{d()},[d]),b)return e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading compliance data..."});const u=n?Ye[n]??ye:null,v=n?Ge[n]??n:null;return e.jsx("div",{children:n?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:["Compliance Guidance — ",v]}),e.jsxs("div",{style:{display:"grid",gap:"1rem",maxWidth:720},children:[e.jsx(Je,{reg:u,minValueCents:a}),e.jsx(Ve,{reg:u}),e.jsx(Xe,{reg:u}),e.jsx(Ze,{maxValueCents:y})]}),e.jsx(Qe,{reg:u,minValueCents:a,maxValueCents:y})]}):e.jsx(He,{})})}function He(){return e.jsxs("div",{style:{padding:"2rem",textAlign:"center"},children:[e.jsx("p",{style:{fontSize:15,opacity:.7,marginBottom:"0.5rem"},children:"No business state configured."}),e.jsxs("p",{style:{fontSize:13,opacity:.5},children:["Set your ",e.jsx("strong",{children:"business_state"})," in the Gift Cards config category to see state-specific compliance guidance."]})]})}function te({title:t,children:i}){return e.jsxs("div",{style:{border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,padding:"1rem 1.25rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.5rem",fontSize:14,fontWeight:600},children:t}),e.jsx("div",{style:{fontSize:13,lineHeight:1.6},children:i})]})}function Je({reg:t,minValueCents:i}){if(!t.cashOutCents)return e.jsx(te,{title:"Cash-Out Threshold",children:e.jsx("p",{style:{margin:0},children:"Your state does not have a specific cash-out threshold for gift cards. Federal law does not require cash redemption."})});const n=(t.cashOutCents/100).toFixed(2),s=i!=null&&i>t.cashOutCents;return e.jsxs(te,{title:"Cash-Out Threshold",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Your state requires cash redemption for gift cards with a remaining balance of ",e.jsxs("strong",{children:["$",n]})," or less."]}),e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Since this system uses ",e.jsx("strong",{children:"one-shot full redemption"})," (entire gift card value is converted to credits at once), cash-out is avoided by setting the minimum gift card face value above the threshold."]}),s?e.jsxs(oe,{ok:!0,children:["Min value ($",((i??0)/100).toFixed(2),") exceeds threshold"]}):e.jsxs(oe,{ok:!1,children:["Set ",e.jsx("code",{children:"min_gift_card_value_cents"})," above ",t.cashOutCents," to avoid cash-out obligations"]}),t.notes&&e.jsx("p",{style:{margin:"0.5rem 0 0",opacity:.7,fontStyle:"italic"},children:t.notes})]})}function Ve({reg:t}){return e.jsx(te,{title:"Expiration Rules",children:t.expirationProhibited?e.jsxs("p",{style:{margin:0},children:["Your state ",e.jsx("strong",{children:"prohibits"})," gift card expiration. Do not set expiration dates on gift cards."]}):e.jsxs("p",{style:{margin:0},children:["Federal law (CARD Act) requires gift cards to remain valid for at least ",e.jsx("strong",{children:"5 years"})," from purchase or last reload. Your state follows the federal minimum."]})})}function Xe({reg:t}){const i=t.escheatmentYears??ye.escheatmentYears;return e.jsxs(te,{title:"Escheatment (Unclaimed Property)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Gift card balances unredeemed for ",e.jsxs("strong",{children:[i," years"]})," may need to be reported and remitted to the state as unclaimed property."]}),e.jsxs("p",{style:{margin:0,opacity:.7},children:["The system tracks ",e.jsx("code",{children:"last_activity_at"})," on gift card redemptions to help identify dormant balances approaching the escheatment window."]})]})}function Ze({maxValueCents:t}){const i=t??re,n=i<=re;return e.jsxs(te,{title:"Anti-Money Laundering (AML)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["FinCEN requires closed-loop prepaid cards to stay at or below ",e.jsx("strong",{children:"$10,000"})," per card. The server enforces this cap on product creation."]}),n?e.jsxs(oe,{ok:!0,children:["Max value ($",(i/100).toFixed(2),") within AML limit"]}):e.jsxs(oe,{ok:!1,children:[e.jsx("code",{children:"max_gift_card_value_cents"})," exceeds $10,000 AML cap"]})]})}function oe({ok:t,children:i}){return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:6,fontSize:13,fontWeight:500,background:t?"rgba(34,197,94,0.1)":"rgba(234,179,8,0.15)",color:t?"#16a34a":"#a16207"},children:[e.jsx("span",{children:t?"✓":"⚠"}),i]})}function Qe({reg:t,minValueCents:i,maxValueCents:n}){const a=[{label:"AML: Max card value ≤ $10,000",ok:(n??re)<=re},...t.cashOutCents?[{label:`Cash-out: Min value > $${(t.cashOutCents/100).toFixed(2)} threshold`,ok:i!=null&&i>t.cashOutCents}]:[],{label:t.expirationProhibited?"Expiration: State prohibits expiration (no action needed)":"Expiration: Federal 5-year minimum applies",ok:!0},{label:`Escheatment: ${t.escheatmentYears??ye.escheatmentYears}-year dormancy tracking enabled`,ok:!0}];return e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{fontSize:14,fontWeight:600,marginBottom:"0.75rem"},children:"Compliance Checklist"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.map((c,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:c.ok?"#16a34a":"#d97706",fontWeight:600},children:c.ok?"✓":"⚠"}),e.jsx("span",{children:c.label})]},y))})]})}function et({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState(null),[c,y]=r.useState(!0),[p,b]=r.useState(null),o=r.useCallback(async x=>{if(n?.isAuthenticated())return n.fetchWithAuth(x);const f={"Content-Type":"application/json"};i&&(f["X-API-Key"]=i);const j=await fetch(`${t}${x}`,{headers:f});if(!j.ok)throw new Error(`HTTP ${j.status}`);return j.json()},[t,i,n]),d=r.useCallback(async()=>{y(!0),b(null);try{const[x,f]=await Promise.all([o("/admin/gift-cards?limit=50"),o("/admin/gift-card-redemptions?limit=50").catch(()=>({redemptions:[]}))]),j=x.giftCards??[],k=f.redemptions??[],h=new Date,S=j.filter(m=>m.active&&(!m.expiresAt||new Date(m.expiresAt)>h)).length,T=j.filter(m=>m.expiresAt&&new Date(m.expiresAt)<=h).length,l=j.reduce((m,N)=>m+N.initialBalance,0),w=j.reduce((m,N)=>m+N.balance,0),_=k.reduce((m,N)=>m+N.faceValueCents,0),A=k.filter(m=>m.tokenMinted).length,g=j[0]?.currency||k[0]?.currency||"USD";a({totalCards:j.length,activeCards:S,expiredCards:T,totalIssuedCents:l,totalRemainingCents:w,totalRedeemedCents:_,redemptionCount:k.length,tokensMinted:A,currency:g.toUpperCase()})}catch(x){b(x instanceof Error?x.message:"Failed to load analytics")}finally{y(!1)}},[o]);r.useEffect(()=>{d()},[d]);const u=x=>`$${(x/100).toFixed(2)}`;if(c)return e.jsx("div",{className:"cedros-admin__loading",children:"Loading analytics..."});if(p)return e.jsxs("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,fontSize:13,color:"#b91c1c"},children:[p,e.jsx("button",{className:"cedros-admin__button cedros-admin__button--sm",style:{marginLeft:8},onClick:d,children:"Retry"})]});if(!s)return null;const v=s.totalIssuedCents>0?((s.totalIssuedCents-s.totalRemainingCents)/s.totalIssuedCents*100).toFixed(1):"0.0";return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Gift Card & Token Analytics"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[e.jsx($,{label:"Total Cards",value:String(s.totalCards)}),e.jsx($,{label:"Active",value:String(s.activeCards),accent:"green"}),e.jsx($,{label:"Expired",value:String(s.expiredCards),accent:s.expiredCards>0?"amber":void 0}),e.jsx($,{label:"Total Issued",value:u(s.totalIssuedCents),sub:s.currency}),e.jsx($,{label:"Remaining Balance",value:u(s.totalRemainingCents),sub:s.currency}),e.jsx($,{label:"Usage Rate",value:`${v}%`,sub:"issued vs. spent"}),e.jsx($,{label:"Redemptions",value:String(s.redemptionCount)}),e.jsx($,{label:"Tokens Minted",value:String(s.tokensMinted),sub:`of ${s.redemptionCount} redemptions`})]}),s.totalIssuedCents>0&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Balance Breakdown"}),e.jsxs("div",{style:{display:"flex",height:24,borderRadius:6,overflow:"hidden",background:"rgba(0,0,0,0.05)"},children:[e.jsx("div",{style:{width:`${(s.totalIssuedCents-s.totalRemainingCents)/s.totalIssuedCents*100}%`,background:"#2563eb",minWidth:2},title:`Spent: ${u(s.totalIssuedCents-s.totalRemainingCents)}`}),e.jsx("div",{style:{width:`${s.totalRemainingCents/s.totalIssuedCents*100}%`,background:"#60a5fa",minWidth:2},title:`Remaining: ${u(s.totalRemainingCents)}`})]}),e.jsxs("div",{style:{display:"flex",gap:"1rem",marginTop:6,fontSize:12,opacity:.7},children:[e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"#2563eb",borderRadius:2,marginRight:4}}),"Spent"]}),e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"#60a5fa",borderRadius:2,marginRight:4}}),"Remaining"]})]})]})]})}function $({label:t,value:i,sub:n,accent:s}){const a=s==="green"?"#166534":s==="amber"?"#92400e":void 0;return e.jsxs("div",{style:{padding:"0.75rem 1rem",borderRadius:8,border:"1px solid rgba(0,0,0,0.08)",background:"rgba(0,0,0,0.01)"},children:[e.jsx("div",{style:{fontSize:12,opacity:.6,marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:a},children:i}),n&&e.jsx("div",{style:{fontSize:11,opacity:.5,marginTop:2},children:n})]})}function tt({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState([]),[c,y]=r.useState(!0),[p,b]=r.useState(null),[o,d]=r.useState("list"),[u,v]=r.useState(null),[x,f]=r.useState(!1),[j,k]=r.useState(null),h=r.useCallback(async(_,A)=>{if(n?.isAuthenticated())return n.fetchWithAuth(_,A);const g={"Content-Type":"application/json"};i&&(g["X-API-Key"]=i);const m=await fetch(`${t}${_}`,{...A,headers:{...g,...A?.headers}});if(!m.ok){const N=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(N)}return m.json()},[t,i,n]),S=r.useCallback(async()=>{y(!0),b(null);try{const A=await h(`/admin/gift-cards${x?"?activeOnly=true&limit=50":"?limit=50"}`);a(A.giftCards??[])}catch(_){b(_ instanceof Error?_.message:"Failed to load gift cards")}finally{y(!1)}},[h,x]);r.useEffect(()=>{S()},[S]);const T=(_,A)=>`$${(_/100).toFixed(2)} ${A.toUpperCase()}`,l=_=>{try{return new Date(_).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}catch{return _}},w=_=>{v(_),d("adjust"),k(null)};return o==="create"?e.jsx(st,{onSubmit:async _=>{await h("/admin/gift-cards",{method:"POST",body:JSON.stringify(_)}),d("list"),S()},onCancel:()=>d("list")}):o==="adjust"&&u?e.jsx(nt,{card:u,formatCents:T,onSubmit:async _=>{await h(`/admin/gift-cards/${encodeURIComponent(u.code)}/adjust`,{method:"POST",body:JSON.stringify({newBalance:_})}),d("list"),S()},onToggleActive:async()=>{await h(`/admin/gift-cards/${encodeURIComponent(u.code)}`,{method:"PUT",body:JSON.stringify({initialBalance:u.initialBalance,balance:u.balance,currency:u.currency,active:!u.active,expiresAt:u.expiresAt,metadata:u.metadata})}),d("list"),S()},onCancel:()=>{d("list"),v(null)}}):e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{margin:0},children:"Gift Card Inventory"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsxs("label",{style:{fontSize:13,display:"flex",alignItems:"center",gap:4},children:[e.jsx("input",{type:"checkbox",checked:x,onChange:_=>f(_.target.checked)}),"Active only"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{d("create"),k(null)},children:"+ New Gift Card"})]})]}),p&&e.jsxs("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:[p,e.jsx("button",{className:"cedros-admin__button cedros-admin__button--sm",style:{marginLeft:8},onClick:S,children:"Retry"})]}),j&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(22,163,74,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#166534"},children:j}),c?e.jsx("div",{className:"cedros-admin__loading",children:"Loading..."}):s.length?e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Code"}),e.jsx("th",{children:"Balance"}),e.jsx("th",{children:"Initial"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Expires"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:s.map(_=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[_.code.slice(0,12),"..."]})}),e.jsx("td",{style:{fontWeight:600},children:T(_.balance,_.currency)}),e.jsx("td",{style:{opacity:.7},children:T(_.initialBalance,_.currency)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${_.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:_.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:13},children:_.expiresAt?l(_.expiresAt):"—"}),e.jsx("td",{style:{fontSize:13},children:l(_.createdAt)}),e.jsx("td",{children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>w(_),children:"Manage"})})]},_.code))})]})}):e.jsx("div",{className:"cedros-admin__empty",style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift cards found."})]})}function st({onSubmit:t,onCancel:i}){const[n,s]=r.useState({code:"",initialBalance:"",currency:"USD",expiresAt:""}),[a,c]=r.useState(!1),[y,p]=r.useState(null),b=async o=>{o.preventDefault();const d=Math.round(parseFloat(n.initialBalance)*100);if(!d||d<0){p("Initial balance must be positive");return}c(!0),p(null);try{await t({...n.code.trim()?{code:n.code.trim().toUpperCase()}:{},initialBalance:d,currency:n.currency.toUpperCase(),...n.expiresAt?{expiresAt:new Date(n.expiresAt).toISOString()}:{}})}catch(u){p(u instanceof Error?u.message:"Failed to create gift card")}finally{c(!1)}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Create Gift Card"}),y&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:y}),e.jsxs("form",{onSubmit:b,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Code (optional, auto-generated if empty)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.code,onChange:o=>s(d=>({...d,code:o.target.value})),placeholder:"Leave blank to auto-generate"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Initial Balance ($)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n.initialBalance,onChange:o=>s(d=>({...d,initialBalance:o.target.value})),placeholder:"25.00",step:"0.01",min:"0",required:!0})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Currency"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.currency,onChange:o=>s(d=>({...d,currency:o.target.value})),maxLength:3,required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Expiration date (optional)"}),e.jsx("input",{type:"date",className:"cedros-admin__input",value:n.expiresAt,onChange:o=>s(d=>({...d,expiresAt:o.target.value}))})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:a,children:a?"Creating...":"Create Gift Card"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:i,children:"Cancel"})]})]})]})}function nt({card:t,formatCents:i,onSubmit:n,onToggleActive:s,onCancel:a}){const[c,y]=r.useState((t.balance/100).toFixed(2)),[p,b]=r.useState(!1),[o,d]=r.useState(null),u=async x=>{x.preventDefault();const f=Math.round(parseFloat(c)*100);if(isNaN(f)||f<0){d("Balance must be >= 0");return}b(!0),d(null);try{await n(f)}catch(j){d(j instanceof Error?j.message:"Failed to adjust balance")}finally{b(!1)}},v=async()=>{b(!0),d(null);try{await s()}catch(x){d(x instanceof Error?x.message:"Failed to update status"),b(!1)}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Manage Gift Card"}),o&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:o}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.5rem",maxWidth:500,marginBottom:"1.5rem",fontSize:13},children:[e.jsx("div",{style:{fontWeight:500},children:"Code"}),e.jsx("div",{style:{fontFamily:"monospace",wordBreak:"break-all"},children:t.code}),e.jsx("div",{style:{fontWeight:500},children:"Current Balance"}),e.jsx("div",{style:{fontWeight:600},children:i(t.balance,t.currency)}),e.jsx("div",{style:{fontWeight:500},children:"Initial Balance"}),e.jsx("div",{children:i(t.initialBalance,t.currency)}),e.jsx("div",{style:{fontWeight:500},children:"Status"}),e.jsx("div",{children:e.jsx("span",{className:`cedros-admin__badge ${t.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:t.active?"Active":"Inactive"})}),t.expiresAt&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500},children:"Expires"}),e.jsx("div",{children:new Date(t.expiresAt).toLocaleDateString()})]})]}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:250},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"New Balance ($)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:c,onChange:x=>y(x.target.value),step:"0.01",min:"0",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:p,children:p?"Saving...":"Adjust Balance"}),e.jsx("button",{type:"button",className:`cedros-admin__button ${t.active?"cedros-admin__button--danger":"cedros-admin__button--outline"}`,onClick:v,disabled:p,children:t.active?"Deactivate":"Reactivate"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:a,children:"Back"})]})]})]})}const it=0;class we{dlmmModule=null;bnClass=null;keypairClass=null;async loadDLMM(){if(this.dlmmModule)return this.dlmmModule;try{const i=await Promise.resolve().then(()=>require("./pay-react_false-DaeIe3_l.js"));return this.dlmmModule=i.default??i,this.dlmmModule}catch{throw new Error("Install @meteora-ag/dlmm to enable pool deployment: npm install @meteora-ag/dlmm")}}async loadBN(){if(this.bnClass)return this.bnClass;const i=await Promise.resolve().then(()=>require("./bn-CHyy7EgJ.js")).then(n=>n.bn);return this.bnClass=i.default??i,this.bnClass}async loadKeypair(){if(this.keypairClass)return this.keypairClass;const{Keypair:i}=await import("@solana/web3.js");return this.keypairClass=i,this.keypairClass}async computeBinId(i,n,s,a=1){const c=await this.loadDLMM(),y=c.getPricePerLamport(n,s,i);return c.getBinIdFromPrice(y,a,!0)}async findPresetParameter(i,n,s){const a=await this.loadDLMM(),c=s?{cluster:s}:void 0,{presetParameter2:y}=await a.getAllPresetParameters(i,c),p=y.find(b=>b.account.binStep===n);if(!p)throw new Error(`No PresetParameter2 found for binStep=${n}. Available: ${y.map(b=>b.account.binStep).join(", ")}`);return p.publicKey}async createPool(i,n,s,a,c,y=1,p){const b=await this.loadDLMM(),o=await this.loadBN(),d=p?{cluster:p}:void 0,u=await this.findPresetParameter(i,y,p),v=await b.createLbPair2(i,n,s,a,u,new o(c),d),x=v.instructions[0]?.keys?.[1]?.pubkey;if(!x)throw new Error("Failed to extract pool address from transaction");return{transaction:v,poolAddress:x}}async addBuybackLiquidity(i,n,s,a,c,y){const p=await this.loadDLMM(),b=await this.loadBN(),o=await this.loadKeypair(),d=y?{cluster:y}:void 0,u=await p.create(i,s,d),v=o.generate(),x=c-1,f=c;return{transaction:await u.initializePositionAndAddLiquidityByStrategy({positionPubKey:v.publicKey,totalXAmount:new b(0),totalYAmount:new b(a),strategy:{maxBinId:f,minBinId:x,strategyType:it},user:n,slippage:1}),positionKeypair:v}}async getPoolStatus(i,n,s){const a=await this.loadDLMM(),c=s?{cluster:s}:void 0,y=await a.create(i,n,c),p=await y.getActiveBin();return{address:n.toBase58(),activeBinId:p.binId,activeBinPrice:p.price,binStep:y.lbPair.binStep}}}const he=6,at=1,rt="https://solscan.io/account",ot="https://app.meteora.ag/dlmm";function lt({serverUrl:t,authManager:i,poolAddress:n,buybackRateBps:s,usdcAmount:a,deployedAt:c,mintAddress:y,tokenDecimals:p=2,onConfigUpdated:b}){const[o,d]=r.useState("none"),[u,v]=r.useState(s!=null?s/100:80),[x,f]=r.useState(100),[j,k]=r.useState(!1),[h,S]=r.useState(!1),[T,l]=r.useState(null),[w,_]=r.useState(null),A=s!=null?`$${(s/1e4).toFixed(2)}`:"Unknown",g=a!=null?`$${(a/10**he).toFixed(2)}`:null,m=c?new Date(c).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null,N=n.length>16?`${n.slice(0,8)}...${n.slice(-8)}`:n,C=async()=>{k(!0),_(null),l(null);try{const B=new ee.ConfigApiClient(t,void 0,i),R=Math.round(u*100);await B.patchConfig("gift_cards",{buyback_rate_bps:R},`Buyback rate adjusted to ${u} cents`),l("Buyback rate updated"),d("none"),b()}catch(B){_(B instanceof Error?B.message:"Failed to update rate")}finally{k(!1)}},z=async()=>{if(y){S(!0),_(null),l(null);try{const{Connection:B,PublicKey:R,Keypair:M}=await import("@solana/web3.js"),F=new ee.ConfigApiClient(t,void 0,i),I=await F.getConfig("x402"),D=I.config?.rpc_url||"",P=I.config?.token_mint||"";if(!D||!P)throw new Error("RPC URL or USDC mint not configured");const L=new B(D,"confirmed"),O=window.solana;if(!O?.publicKey||!O.signTransaction)throw new Error("Wallet not connected");const se=new we,le=new R(O.publicKey.toBase58()),E=u/100,de=await se.computeBinId(E,p,he,at),ne=new R(n),H=Math.round(x*10**he),{transaction:J,positionKeypair:W}=await se.addBuybackLiquidity(L,le,ne,H,de),V=M.fromSecretKey(W.secretKey);J.partialSign(V);const Y=await O.signTransaction(J),X=await L.sendRawTransaction(Y.serialize());await L.confirmTransaction(X,"confirmed");const Z=a??0;await F.patchConfig("gift_cards",{liquidity_usdc_amount:Z+H},`Added ${x} USDC liquidity`),l(`Added $${x} USDC liquidity`),d("none"),b()}catch(B){_(B instanceof Error?B.message:"Failed to add liquidity")}finally{S(!1)}}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Liquidity Pool Active"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Pool Address"}),e.jsxs("div",{style:{fontSize:13,fontFamily:"monospace",wordBreak:"break-all"},children:[N,e.jsxs("span",{style:{marginLeft:8,display:"inline-flex",gap:6},children:[e.jsx(dt,{text:n}),e.jsx(ve,{href:`${rt}/${n}`,label:"Solscan"}),e.jsx(ve,{href:`${ot}/${n}`,label:"Meteora"})]})]}),e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Buyback Rate"}),e.jsxs("div",{style:{fontSize:13},children:[A," per $1.00"]}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"USDC Deposited"}),e.jsx("div",{style:{fontSize:13},children:g})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Deployed"}),e.jsx("div",{style:{fontSize:13},children:m})]})]}),e.jsxs("div",{style:{marginTop:"1.25rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>d(o==="adjust_rate"?"none":"adjust_rate"),disabled:h||j,children:"Adjust Rate"}),e.jsx("button",{className:"cedros-admin__button",onClick:()=>d(o==="add_liquidity"?"none":"add_liquidity"),disabled:h||j||!y,children:"Add Liquidity"})]}),o==="adjust_rate"&&e.jsxs("div",{style:{marginTop:"1rem",padding:"1rem",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"New buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:u,onChange:B=>v(Math.max(1,Math.min(99,parseInt(B.target.value)||80))),min:"1",max:"99",style:{maxWidth:200}}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["Profit per redemption: $",((100-u)/100).toFixed(2)]})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:C,disabled:j,style:{marginTop:"0.75rem"},children:j?"Saving...":"Save Rate"})]}),o==="add_liquidity"&&e.jsxs("div",{style:{marginTop:"1rem",padding:"1rem",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount to add"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:x,onChange:B=>f(Math.max(1,parseFloat(B.target.value)||100)),min:"1",step:"1",style:{maxWidth:200}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:z,disabled:h,style:{marginTop:"0.75rem"},children:h?"Adding liquidity...":`Add $${x} USDC`}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Requires a connected wallet and USDC balance."})]}),T&&e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:6,background:"rgba(22,163,74,0.1)",color:"#16a34a",fontSize:13},children:T}),w&&e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:w})]})}function dt({text:t}){const[i,n]=r.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})};return e.jsx("button",{type:"button",onClick:s,style:{background:"none",border:"none",cursor:"pointer",fontSize:12,opacity:.7,padding:0},children:i?"Copied":"Copy"})}function ve({href:t,label:i}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,opacity:.7},children:i})}const ie=6,ge=1;function ct({serverUrl:t,authManager:i,mintConfigured:n,mintAddress:s,tokenDecimals:a=2}){const[c,y]=r.useState({liquidityPoolAddress:null,buybackRateBps:null,rpcUrl:null,usdcMint:null,usdcAmount:null,deployedAt:null}),[p,b]=r.useState(!0),[o,d]=r.useState(80),[u,v]=r.useState(250),[x,f]=r.useState("idle"),[j,k]=r.useState(null),[h,S]=r.useState(null),[T,l]=r.useState(null),w=r.useRef(new we),_=r.useCallback(async()=>{try{const R=new ee.ConfigApiClient(t,void 0,i),[M,F]=await Promise.all([R.getConfig("gift_cards"),R.getConfig("x402")]),I=M.config??{},D=F.config??{},P=I.liquidity_pool_address||null;y({liquidityPoolAddress:P,buybackRateBps:I.buyback_rate_bps!=null?Number(I.buyback_rate_bps):null,rpcUrl:D.rpc_url||null,usdcMint:D.token_mint||null,usdcAmount:I.liquidity_usdc_amount!=null?Number(I.liquidity_usdc_amount):null,deployedAt:I.liquidity_deployed_at||null}),P&&S(P),I.buyback_rate_bps!=null&&d(Number(I.buyback_rate_bps)/100)}catch{}finally{b(!1)}},[t,i]);r.useEffect(()=>{_()},[_]);const A=typeof window<"u"&&!!window.solana?.publicKey,g=!!c.rpcUrl,m=!!c.usdcMint,N=n&&A&&g&&m&&x==="idle",C=async R=>{if(!(!s||!c.rpcUrl||!c.usdcMint)){f(R),k(null),l(null);try{const{Connection:M,PublicKey:F,Keypair:I}=await import("@solana/web3.js"),D=new M(c.rpcUrl,"confirmed"),P=window.solana;if(!P?.publicKey||!P.signTransaction)throw new Error("Wallet not connected");const L=w.current,O=new F(P.publicKey.toBase58()),se=o/100,le=await L.computeBinId(se,a,ie,ge);let E=h;if(R==="creating_pool"){const W=new F(s),V=new F(c.usdcMint),Y=await L.computeBinId(1,a,ie,ge),{transaction:X,poolAddress:Z}=await L.createPool(D,O,W,V,Y,ge),ce=await P.signTransaction(X),ue=await D.sendRawTransaction(ce.serialize());await D.confirmTransaction(ue,"confirmed"),E=Z.toBase58(),S(E)}if(R==="creating_pool"||R==="adding_liquidity"){if(f("adding_liquidity"),!E)throw new Error("Pool address not available");const W=new F(E),V=Math.round(u*10**ie),{transaction:Y,positionKeypair:X}=await L.addBuybackLiquidity(D,O,W,V,le),Z=I.fromSecretKey(X.secretKey);Y.partialSign(Z);const ce=await P.signTransaction(Y),ue=await D.sendRawTransaction(ce.serialize());await D.confirmTransaction(ue,"confirmed")}if(f("saving_config"),!E)throw new Error("Pool address not available");const de=new ee.ConfigApiClient(t,void 0,i),ne=Math.round(o*100),H=Math.round(u*10**ie),J=new Date().toISOString();await de.patchConfig("gift_cards",{liquidity_pool_address:E,buyback_rate_bps:ne,liquidity_usdc_amount:H,liquidity_deployed_at:J},"Meteora DLMM pool deployed for gift card buyback"),y(W=>({...W,liquidityPoolAddress:E,buybackRateBps:ne,usdcAmount:H,deployedAt:J})),f("done")}catch(M){l(x==="idle"?R:x),k(M instanceof Error?M.message:"Deployment failed"),f("error")}}},z=()=>{N&&C("creating_pool")},B=()=>{!T||T==="idle"||T==="done"||T==="error"||C(T)};return p?e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading pool configuration..."}):c.liquidityPoolAddress?e.jsx(lt,{serverUrl:t,authManager:i,poolAddress:c.liquidityPoolAddress,buybackRateBps:c.buybackRateBps,usdcAmount:c.usdcAmount,deployedAt:c.deployedAt,mintAddress:s,tokenDecimals:a,onConfigUpdated:_}):x!=="idle"&&x!=="error"?e.jsx(mt,{step:x,poolAddress:h}):e.jsx(ut,{buybackCents:o,setBuybackCents:d,usdcAmount:u,setUsdcAmount:v,mintConfigured:n,walletConnected:A,hasRpcUrl:g,hasUsdcMint:m,canDeploy:N,onDeploy:z,errorMessage:j,canRetry:!!T&&T!=="creating_pool",onRetry:B})}function ut({buybackCents:t,setBuybackCents:i,usdcAmount:n,setUsdcAmount:s,mintConfigured:a,walletConnected:c,hasRpcUrl:y,hasUsdcMint:p,canDeploy:b,onDeploy:o,errorMessage:d,canRetry:u,onRetry:v}){const x=((100-t)/100).toFixed(2);return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Deploy Buyback Liquidity Pool"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Meteora DLMM pool to buy back gift card tokens at a discount. You earn the spread when tokens are resold at face value."}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:t,onChange:f=>i(Math.max(1,Math.min(99,parseInt(f.target.value)||80))),min:"1",max:"99"}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["You earn $",x," profit per gift card redeemed"]})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n,onChange:f=>s(Math.max(1,parseFloat(f.target.value)||250)),min:"1",step:"1"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Minimum recommended: $250"})]})]}),e.jsxs("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",gap:6},children:[e.jsx(ae,{label:"Token-22 mint initialized",met:a}),e.jsx(ae,{label:"Wallet connected",met:c}),e.jsx(ae,{label:"RPC URL configured",met:y}),e.jsx(ae,{label:"USDC mint configured",met:p})]}),d&&e.jsx("div",{style:{padding:"0.5rem 0.75rem",marginBottom:"0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:d}),e.jsx("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:u?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:v,children:"Retry (Resume from Failed Step)"}):e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:o,disabled:!b,children:"Deploy Liquidity Pool"})})]})}const Se=[{key:"creating_pool",label:"Creating DLMM pool..."},{key:"adding_liquidity",label:"Depositing USDC liquidity..."},{key:"saving_config",label:"Saving configuration..."},{key:"done",label:"Complete"}];function mt({step:t,poolAddress:i}){return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Deploying Pool..."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:Se.map((n,s)=>{const a=Se.findIndex(b=>b.key===t),c=s,y=c<a||t==="done",p=c===a&&t!=="done";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontWeight:600},children:y?"✓":p?"▶":"○"}),e.jsx("span",{style:{opacity:y||p?1:.4},children:n.label})]},n.key)})}),i&&e.jsxs("div",{style:{marginTop:"1rem",fontSize:13,opacity:.7},children:["Pool: ",e.jsx("code",{style:{fontSize:12},children:i})]})]})}function ae({label:t,met:i}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:i?"#16a34a":"#dc2626",fontWeight:600},children:i?"✓":"✗"}),e.jsx("span",{style:{opacity:i?.8:.5},children:t})]})}function pt({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState(null),[c,y]=r.useState([]),[p,b]=r.useState(!0),[o,d]=r.useState(null),[u,v]=r.useState("mint"),[x,f]=r.useState({treasuryAddress:"",tokenSymbol:"storeUSD",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500}),[j,k]=r.useState(!1),[h,S]=r.useState(!1),[T,l]=r.useState(null),w=r.useCallback(async(C,z)=>{if(n?.isAuthenticated())return n.fetchWithAuth(C,z);const B={"Content-Type":"application/json"};i&&(B["X-API-Key"]=i);const R=await fetch(`${t}${C}`,{...z,headers:{...B,...z?.headers}});if(!R.ok){const M=await R.text().catch(()=>`HTTP ${R.status}`);throw new Error(M)}return R.json()},[t,i,n]),_=r.useCallback(async()=>{try{d(null);const C=await w("/admin/token22/status");a(C)}catch{d("Failed to load Token-22 status")}finally{b(!1)}},[w]),A=r.useCallback(async()=>{try{const C=await w("/admin/gift-card-redemptions?limit=50");y(C.redemptions||[])}catch{y([])}},[w]);r.useEffect(()=>{_(),A()},[_,A]);const g=async C=>{if(C.preventDefault(),!!x.treasuryAddress){k(!0),l(null);try{const z=await w("/admin/token22/initialize",{method:"POST",body:JSON.stringify({treasuryAddress:x.treasuryAddress,tokenSymbol:x.tokenSymbol,tokenDecimals:x.tokenDecimals,transferFeeBps:x.transferFeeBps,maxTransferFee:x.maxTransferFee})});l(`Mint created: ${z.mintAddress}`),_()}catch(z){l(`Error: ${z instanceof Error?z.message:"Failed to initialize"}`)}finally{k(!1)}}},m=async()=>{S(!0),l(null);try{const C=await w("/admin/token22/harvest-fees",{method:"POST"});l(C.message)}catch(C){l(`Error: ${C instanceof Error?C.message:"Failed to harvest"}`)}finally{S(!1)}},N=C=>{try{return new Date(C).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return C}};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(fe.ErrorBanner,{message:o,onRetry:_}),e.jsx("div",{style:{display:"flex",gap:0,borderBottom:"1px solid rgba(0,0,0,0.1)",marginBottom:"1rem"},children:["mint","inventory","analytics","redemptions","compliance","liquidity","asset-classes","asset-redemptions"].map(C=>{const z={mint:"Token-22 Mint",inventory:"Gift Cards",analytics:"Analytics",redemptions:"Redemptions",compliance:"Compliance",liquidity:"Liquidity","asset-classes":"Asset Classes","asset-redemptions":"Asset Redemptions"};return e.jsx("button",{type:"button",onClick:()=>v(C),style:{padding:"0.5rem 1rem",background:"none",border:"none",borderBottom:u===C?"2px solid currentColor":"2px solid transparent",fontWeight:u===C?600:400,cursor:"pointer",opacity:u===C?1:.6},children:z[C]},C)})}),p?e.jsxs("div",{className:"cedros-admin__loading",children:[fe.Icons.loading," Loading..."]}):u==="mint"?e.jsx(ht,{mintStatus:s,initForm:x,setInitForm:f,isInitializing:j,isHarvesting:h,actionMessage:T,onInitialize:g,onHarvestFees:m,formatDate:N}):u==="inventory"?e.jsx(tt,{serverUrl:t,apiKey:i,authManager:n}):u==="analytics"?e.jsx(et,{serverUrl:t,apiKey:i,authManager:n}):u==="redemptions"?e.jsx(gt,{redemptions:c,formatDate:N}):u==="compliance"?e.jsx(Ke,{serverUrl:t,apiKey:i,authManager:n}):u==="liquidity"?e.jsx(ct,{serverUrl:t,authManager:n,mintConfigured:!!s?.configured,mintAddress:s?.mintAddress,tokenDecimals:s?.tokenDecimals}):u==="asset-classes"?e.jsx(Ee,{serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:()=>v("liquidity")}):e.jsx(Ue,{serverUrl:t,apiKey:i,authManager:n})]})}function ht({mintStatus:t,initForm:i,setInitForm:n,isInitializing:s,isHarvesting:a,actionMessage:c,onInitialize:y,onHarvestFees:p,formatDate:b}){return t?.configured?e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Token-22 Mint Status"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx(q,{label:"Mint Address",value:t.mintAddress,mono:!0}),e.jsx(q,{label:"Token Symbol",value:t.tokenSymbol}),e.jsx(q,{label:"Decimals",value:String(t.tokenDecimals)}),e.jsx(q,{label:"Transfer Fee",value:`${t.transferFeeBps} bps (${((t.transferFeeBps??0)/100).toFixed(2)}%)`}),e.jsx(q,{label:"Max Transfer Fee",value:String(t.maxTransferFee)}),e.jsx(q,{label:"Treasury",value:t.treasuryAddress,mono:!0}),e.jsx(q,{label:"Authority",value:t.mintAuthority,mono:!0}),e.jsx(q,{label:"Created",value:t.createdAt?b(t.createdAt):"—"})]}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",gap:"0.75rem",alignItems:"center"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:p,disabled:a,children:a?"Harvesting...":"Harvest Transfer Fees"}),c&&e.jsx("span",{style:{fontSize:13,opacity:.8},children:c})]})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Initialize Token-22 Mint"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Token-22 mint with transfer fee extension for the secondary market. This is a one-time operation per tenant."}),e.jsxs("form",{onSubmit:y,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Treasury address (Solana)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.treasuryAddress,onChange:o=>n(d=>({...d,treasuryAddress:o.target.value})),placeholder:"e.g., 7xKX...",required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.tokenSymbol,onChange:o=>n(d=>({...d,tokenSymbol:o.target.value})),placeholder:"storeUSD"})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.tokenDecimals,onChange:o=>n(d=>({...d,tokenDecimals:parseInt(o.target.value)||2})),min:"0",max:"9"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Transfer fee (basis points)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.transferFeeBps,onChange:o=>n(d=>({...d,transferFeeBps:parseInt(o.target.value)||0})),min:"0",max:"10000"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"e.g., 250 = 2.5% fee on secondary market transfers"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max transfer fee (atomic)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.maxTransferFee,onChange:o=>n(d=>({...d,maxTransferFee:parseInt(o.target.value)||0})),min:"0"})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:s,children:s?"Creating Mint...":"Initialize Mint"}),c&&e.jsx("span",{style:{marginLeft:"0.75rem",fontSize:13,opacity:.8},children:c})]})]})]})}function q({label:t,value:i,mono:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:t}),e.jsx("div",{style:{fontSize:13,fontFamily:n?"monospace":"inherit",wordBreak:n?"break-all":"normal",opacity:i?1:.5},children:i||"—"})]})}function gt({redemptions:t,formatDate:i}){return t.length?e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Buyer"}),e.jsx("th",{children:"Recipient"}),e.jsx("th",{children:"Value"}),e.jsx("th",{children:"Token Minted"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:i(n.createdAt)}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.orderId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsx("code",{style:{fontSize:12},children:n.productId})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.buyerUserId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.recipientUserId.slice(0,8),"..."]})}),e.jsxs("td",{children:["$",(n.faceValueCents/100).toFixed(2)," ",n.currency.toUpperCase()]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${n.tokenMinted?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:n.tokenMinted?"Yes":"No"})})]},n.id))})]})}):e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift card redemptions yet."})}exports.Token22Section=pt;
1
+ "use strict";var ke=Object.create;var xe=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Ne=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var Re=(t,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of Te(i))!Be.call(t,a)&&a!==n&&xe(t,a,{get:()=>i[a],enumerable:!(s=Ae(i,a))||s.enumerable});return t};var me=(t,i,n)=>(n=t!=null?ke(Ne(t)):{},Re(i||!t||!t.__esModule?xe(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),fe=require("./index-C0g-JxJk.js"),ee=require("./configApi-DkduMQg1.js"),Ce=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"address",label:"Address"},{value:"textarea",label:"Long Text"},{value:"dropdown",label:"Dropdown"},{value:"file_upload",label:"File Upload"}],be={fields:[],requiresApproval:!0},U={width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",boxSizing:"border-box"},G={display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},Q={padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.85rem"};function ze(){return{id:Math.random().toString(36).slice(2),label:"",fieldType:"text",required:!1,options:[],placeholder:""}}function je({field:t,onSave:i,onCancel:n}){const[s,a]=r.useState(t),[c,y]=r.useState(""),p=o=>a(d=>({...d,...o})),b=()=>{const o=c.trim();o&&(p({options:[...s.options,o]}),y(""))};return e.jsxs("div",{style:{padding:"0.75rem",border:"1px solid rgba(37,99,235,0.3)",borderRadius:6,background:"#eff6ff",marginTop:6},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.6rem",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Label *"}),e.jsx("input",{style:U,value:s.label,onChange:o=>p({label:o.target.value}),placeholder:"e.g., Full Name"})]}),e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Field Type"}),e.jsx("select",{style:U,value:s.fieldType,onChange:o=>p({fieldType:o.target.value,options:[]}),children:Ce.map(o=>e.jsx("option",{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"0.6rem",alignItems:"end",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Placeholder"}),e.jsx("input",{style:U,value:s.placeholder??"",onChange:o=>p({placeholder:o.target.value}),placeholder:"Optional hint text"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",paddingBottom:2},children:[e.jsx("input",{type:"checkbox",checked:s.required,onChange:o=>p({required:o.target.checked})})," Required"]})]}),s.fieldType==="dropdown"&&e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsx("label",{style:G,children:"Options"}),s.options.map((o,d)=>e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:4},children:[e.jsx("span",{style:{flex:1,fontSize:"0.85rem",padding:"0.25rem 0.5rem",background:"white",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4},children:o}),e.jsx("button",{type:"button",onClick:()=>p({options:s.options.filter((u,v)=>v!==d)}),style:{padding:"0.2rem 0.5rem",borderRadius:4,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"x"})]},d)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{style:{...U,flex:1},value:c,onChange:o=>y(o.target.value),onKeyDown:o=>o.key==="Enter"&&(o.preventDefault(),b()),placeholder:"Add option..."}),e.jsx("button",{type:"button",onClick:b,style:Q,children:"Add"})]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>i(s),disabled:!s.label.trim(),style:{padding:"0.35rem 1rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:s.label.trim()?"pointer":"not-allowed",fontSize:"0.85rem",opacity:s.label.trim()?1:.5},children:"Save Field"}),e.jsx("button",{type:"button",onClick:n,style:Q,children:"Cancel"})]})]})}function Ie({fields:t,instructions:i}){const n={...U,fontSize:"0.85rem",background:"white",opacity:.6};return e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"rgba(0,0,0,0.02)"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"rgba(0,0,0,0.4)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"0.75rem"},children:"Preview — Redeemer View"}),i&&e.jsx("div",{style:{padding:"0.6rem 0.75rem",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,fontSize:"0.85rem",marginBottom:"0.75rem",color:"#92400e"},children:i}),t.length===0&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic"},children:"No fields added yet."}),t.map(s=>e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsxs("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:[s.label||"Unlabelled field",s.required&&e.jsx("span",{style:{color:"#dc2626",marginLeft:2},children:"*"})]}),s.fieldType==="textarea"&&e.jsx("textarea",{disabled:!0,rows:2,placeholder:s.placeholder??"",style:{...n,resize:"none"}}),s.fieldType==="file_upload"&&e.jsx("div",{style:{padding:"0.5rem",border:"1px dashed rgba(0,0,0,0.25)",borderRadius:4,fontSize:"0.8rem",color:"rgba(0,0,0,0.4)",textAlign:"center"},children:"File upload"}),s.fieldType==="dropdown"&&e.jsxs("select",{disabled:!0,style:n,children:[e.jsx("option",{children:s.placeholder||"Select..."}),s.options.map((a,c)=>e.jsx("option",{children:a},c))]}),!["textarea","file_upload","dropdown"].includes(s.fieldType)&&e.jsx("input",{disabled:!0,type:s.fieldType==="email"?"email":s.fieldType==="phone"?"tel":"text",placeholder:s.placeholder??"",style:n})]},s.id))]})}function De({value:t,onChange:i}){const n=t!==null,s=t??be,[a,c]=r.useState(null),[y,p]=r.useState(null),[b,o]=r.useState(!1),d=h=>i({...s,...h}),u=()=>{c(null),p(null)},v=h=>{i(h?{...be}:null),u()},x=()=>{const h=ze();p(h),c("new")},f=h=>{p({...h}),c(h.id)},j=h=>{d({fields:a==="new"?[...s.fields,h]:s.fields.map(S=>S.id===h.id?h:S)}),u()},k=h=>{a===h&&u(),d({fields:s.fields.filter(S=>S.id!==h)})};return e.jsxs("div",{children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",marginBottom:n?"1rem":4,fontSize:"0.9rem",fontWeight:500},children:[e.jsx("input",{type:"checkbox",checked:n,onChange:h=>v(h.target.checked)}),"Enable Redemption Form"]}),!n&&e.jsx("div",{style:{fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:"No redemption form — token holders cannot request physical redemption."}),n&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Instructions shown to redeemer"}),e.jsx("textarea",{value:s.instructions??"",onChange:h=>d({instructions:h.target.value||void 0}),placeholder:"Describe requirements, turnaround times, etc.",rows:3,style:{...U,resize:"vertical"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"1rem",alignItems:"center",padding:"0.6rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"rgba(0,0,0,0.02)"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",whiteSpace:"nowrap"},children:[e.jsx("input",{type:"checkbox",checked:s.requiresApproval,onChange:h=>d({requiresApproval:h.target.checked})})," Requires admin approval"]}),e.jsxs("div",{children:[e.jsx("label",{style:G,children:"Estimated processing days"}),e.jsx("input",{type:"number",min:0,value:s.estimatedProcessingDays??"",onChange:h=>d({estimatedProcessingDays:h.target.value?Number(h.target.value):void 0}),placeholder:"e.g., 5",style:{...U,maxWidth:120}})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:500,marginBottom:"0.5rem"},children:["Form Fields (",s.fields.length,")"]}),s.fields.length===0&&a!=="new"&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic",marginBottom:"0.5rem"},children:"No fields yet. Add fields below."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem"},children:[s.fields.map(h=>e.jsxs("div",{children:[e.jsxs("div",{style:{padding:"0.5rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"white",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"0.9rem"},children:h.label||e.jsx("em",{style:{color:"rgba(0,0,0,0.35)"},children:"Unlabelled"})}),e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dbeafe",color:"#1d4ed8",fontSize:"0.75rem"},children:Ce.find(S=>S.value===h.fieldType)?.label??h.fieldType}),h.required&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#fef3c7",color:"#92400e",fontSize:"0.75rem"},children:"required"})]}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{type:"button",onClick:()=>f(h),style:{...Q,padding:"0.25rem 0.6rem",fontSize:"0.8rem"},children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>k(h.id),style:{padding:"0.25rem 0.6rem",borderRadius:4,border:"1px solid rgba(220,38,38,0.3)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"Delete"})]})]}),a===h.id&&y&&e.jsx(je,{field:y,onSave:j,onCancel:u})]},h.id)),a==="new"&&y&&e.jsx(je,{field:y,onSave:j,onCancel:u})]}),a===null&&e.jsx("button",{type:"button",onClick:x,style:{...Q,marginTop:"0.5rem"},children:"+ Add Field"})]}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>o(h=>!h),style:{...Q,background:b?"rgba(0,0,0,0.05)":"white"},children:b?"Hide Preview":"Show Preview"}),b&&e.jsx("div",{style:{marginTop:"0.75rem"},children:e.jsx(Ie,{fields:s.fields,instructions:s.instructions})})]})]})]})}const Pe=[{value:"securities",label:"Securities (fungible)"},{value:"commodities",label:"Commodities (fungible)"},{value:"property",label:"Property (non-fungible)"},{value:"collectibles",label:"Collectibles (non-fungible)"}],Me=t=>t==="securities"||t==="commodities";function Fe({c:t,onDeployPool:i,onEdit:n,onDelete:s}){const a=t.tokenizationConfig,c=Me(a.assetClass);return e.jsxs("div",{style:{padding:"0.75rem 1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"white"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:t.name}),e.jsx("span",{style:{marginLeft:8,fontSize:"0.8rem",padding:"2px 8px",borderRadius:10,background:c?"#dbeafe":"#fef3c7",color:c?"#1d4ed8":"#92400e"},children:a.assetClass}),a.tokenSymbol&&e.jsx("span",{style:{marginLeft:6,fontSize:"0.8rem",color:"rgba(0,0,0,0.5)"},children:a.tokenSymbol})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.8rem"},children:[a.mintAddress?e.jsx("span",{style:{color:"#16a34a"},children:"Mint initialized"}):e.jsx("span",{style:{color:"rgba(0,0,0,0.4)"},children:"No mint"}),c&&a.mintAddress&&(a.liquidityPoolAddress?e.jsxs("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dcfce7",color:"#15803d",fontSize:"0.75rem"},children:["Pool Active · ",a.liquidityPoolAddress.slice(0,4),"...",a.liquidityPoolAddress.slice(-4)]}):e.jsx("button",{type:"button",onClick:i,style:{padding:0,border:"none",background:"none",color:"#2563eb",cursor:"pointer",fontSize:"0.8rem",textDecoration:"underline"},children:"Deploy Pool"}))]})]}),t.description&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.5)",marginTop:4},children:t.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6},children:[e.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:[e.jsxs("span",{children:["Fee: ",a.transferFeeBps," bps"]}),a.treasuryAddress&&e.jsxs("span",{children:["Treasury: ",a.treasuryAddress.slice(0,8),"..."]}),a.allowedJurisdictions?.length>0&&e.jsxs("span",{style:{padding:"1px 7px",borderRadius:10,background:"#f3f4f6",color:"rgba(0,0,0,0.55)"},children:[a.allowedJurisdictions.length," jurisdiction",a.allowedJurisdictions.length!==1?"s":"",": ",a.allowedJurisdictions.join(", ")]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[n&&e.jsx("button",{type:"button",onClick:n,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#2563eb"},children:"Edit"}),s&&e.jsx("button",{type:"button",onClick:s,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#dc2626"},children:"Delete"})]})]})]})}const pe={name:"",description:"",assetClass:"securities",tokenSymbol:"",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500,treasuryAddress:"",regulatoryNotice:"",jurisdictions:"",redemptionConfig:null};function Ee({serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:s}){const[a,c]=r.useState([]),[y,p]=r.useState(!0),[b,o]=r.useState(null),[d,u]=r.useState(!1),[v,x]=r.useState(!1),[f,j]=r.useState(pe),[k,h]=r.useState(null),S=r.useCallback(async(g,m)=>{if(n?.isAuthenticated())return n.fetchWithAuth(g,m);const N={"Content-Type":"application/json"};i&&(N["X-API-Key"]=i);const C=await fetch(`${t}${g}`,{...m,headers:{...N,...m?.headers}});if(!C.ok){const z=await C.text().catch(()=>`HTTP ${C.status}`);throw new Error(z)}return C.json()},[t,i,n]),T=r.useCallback(async()=>{try{p(!0),o(null);const g=await S("/admin/collections");c((g.collections||[]).filter(m=>m.tokenizationConfig))}catch(g){o(g instanceof Error?g.message:"Failed to load asset classes")}finally{p(!1)}},[S]);r.useEffect(()=>{T()},[T]);const l=()=>({name:f.name.trim(),description:f.description||void 0,active:!0,productIds:[],tokenizationConfig:{assetClass:f.assetClass,tokenSymbol:f.tokenSymbol||void 0,tokenDecimals:f.tokenDecimals,transferFeeBps:f.transferFeeBps,maxTransferFee:f.maxTransferFee,treasuryAddress:f.treasuryAddress||void 0,regulatoryNotice:f.regulatoryNotice||void 0,allowedJurisdictions:f.jurisdictions?f.jurisdictions.split(",").map(g=>g.trim().toUpperCase()).filter(Boolean):[],redemptionConfig:f.redemptionConfig||void 0}}),w=async()=>{if(f.name.trim()){x(!0),o(null);try{k?await S(`/admin/collections/${encodeURIComponent(k)}`,{method:"PUT",body:JSON.stringify(l())}):await S("/admin/collections",{method:"POST",body:JSON.stringify(l())}),j(pe),u(!1),h(null),await T()}catch(g){o(g instanceof Error?g.message:`Failed to ${k?"update":"create"} asset class`)}finally{x(!1)}}},_=g=>{const m=g.tokenizationConfig;j({name:g.name,description:g.description??"",assetClass:m.assetClass,tokenSymbol:m.tokenSymbol??"",tokenDecimals:m.tokenDecimals,transferFeeBps:m.transferFeeBps,maxTransferFee:m.maxTransferFee,treasuryAddress:m.treasuryAddress??"",regulatoryNotice:m.regulatoryNotice??"",jurisdictions:m.allowedJurisdictions.join(", "),redemptionConfig:m.redemptionConfig??null}),h(g.id),u(!0)},A=async g=>{if(window.confirm(`Delete asset class "${g.name}"? This cannot be undone.`)){o(null);try{await S(`/admin/collections/${encodeURIComponent(g.id)}`,{method:"DELETE"}),await T()}catch(m){o(m instanceof Error?m.message:"Failed to delete asset class")}}};return y?e.jsx("div",{style:{padding:"1rem 0",color:"rgba(0,0,0,0.5)"},children:"Loading asset classes..."}):e.jsxs("div",{children:[b&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:b}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsxs("h4",{style:{margin:0},children:["Asset Classes (",a.length,")"]}),e.jsx("button",{type:"button",onClick:()=>{u(!d),d&&(h(null),j(pe))},style:{padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:d?"rgba(0,0,0,0.05)":"white",cursor:"pointer",fontSize:"0.85rem"},children:d?"Cancel":"+ New Asset Class"})]}),d&&e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,marginBottom:"1rem",background:"rgba(0,0,0,0.02)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Name *"}),e.jsx("input",{type:"text",value:f.name,onChange:g=>j(m=>({...m,name:g.target.value})),placeholder:"e.g., Gold Tokens",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Asset Class *"}),e.jsx("select",{value:f.assetClass,onChange:g=>j(m=>({...m,assetClass:g.target.value})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"},children:Pe.map(g=>e.jsx("option",{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Description"}),e.jsx("input",{type:"text",value:f.description,onChange:g=>j(m=>({...m,description:g.target.value})),placeholder:"Brief description of this asset class",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Token Symbol"}),e.jsx("input",{type:"text",value:f.tokenSymbol,onChange:g=>j(m=>({...m,tokenSymbol:g.target.value})),placeholder:"e.g., GOLD",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Transfer Fee (bps)"}),e.jsx("input",{type:"number",value:f.transferFeeBps,onChange:g=>j(m=>({...m,transferFeeBps:Number(g.target.value)})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Treasury Address"}),e.jsx("input",{type:"text",value:f.treasuryAddress,onChange:g=>j(m=>({...m,treasuryAddress:g.target.value})),placeholder:"Solana address",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Allowed Jurisdictions"}),e.jsx("input",{type:"text",value:f.jurisdictions,onChange:g=>j(m=>({...m,jurisdictions:g.target.value})),placeholder:"US, CA, GB (comma-separated, leave empty for all)",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Regulatory Notice"}),e.jsx("textarea",{value:f.regulatoryNotice,onChange:g=>j(m=>({...m,regulatoryNotice:g.target.value})),placeholder:"Shown to buyers before purchase",rows:2,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:600,marginBottom:8},children:"Redemption Form"}),e.jsx(De,{value:f.redemptionConfig,onChange:g=>j(m=>({...m,redemptionConfig:g}))})]}),e.jsx("button",{type:"button",onClick:w,disabled:v||!f.name.trim(),style:{padding:"0.5rem 1.5rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:v?"wait":"pointer",fontSize:"0.9rem",opacity:v?.6:1},children:v?"Saving...":k?"Save Changes":"Create Asset Class"})]}),a.length===0?e.jsx("div",{style:{padding:"2rem",textAlign:"center",color:"rgba(0,0,0,0.4)",fontSize:"0.9rem"},children:"No asset classes configured. Create one to start tokenizing off-chain assets."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:a.map(g=>e.jsx(Fe,{c:g,onDeployPool:s,onEdit:()=>_(g),onDelete:()=>A(g)},g.id))})]})}const Le=[{value:"",label:"All statuses"},{value:"pending_info",label:"Pending Info"},{value:"info_submitted",label:"Info Submitted"},{value:"under_review",label:"Under Review"},{value:"approved",label:"Approved"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}];function $e(t){switch(t){case"pending_info":return"cedros-admin__badge cedros-admin__badge--muted";case"info_submitted":return"cedros-admin__badge cedros-admin__badge--info";case"under_review":return"cedros-admin__badge cedros-admin__badge--warning";case"approved":return"cedros-admin__badge cedros-admin__badge--success";case"completed":return"cedros-admin__badge cedros-admin__badge--success";case"rejected":return"cedros-admin__badge cedros-admin__badge--failed";default:return"cedros-admin__badge cedros-admin__badge--muted"}}function qe(t){return t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())}function Oe(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function K(t){return t.length>12?`${t.slice(0,8)}…`:t}function _e(t){return`https://solscan.io/tx/${t}`}function We({redemption:t,onAction:i,onComplete:n,actionBusy:s}){const[a,c]=r.useState(t.adminNotes??""),y=Object.entries(t.formData??{});return e.jsx("div",{style:{padding:"1rem 1.25rem",background:"rgba(0,0,0,0.02)",borderTop:"1px solid rgba(0,0,0,0.08)"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1.5rem"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"0.8rem",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em",opacity:.6},children:"Form Data"}),y.length===0?e.jsx("div",{style:{fontSize:"0.85rem",opacity:.5},children:"No form data submitted."}):e.jsx("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",fontSize:"0.85rem"},children:y.map(([p,b])=>e.jsxs(e.Fragment,{children:[e.jsx("dt",{style:{fontWeight:500,color:"rgba(0,0,0,0.6)",whiteSpace:"nowrap"},children:p},`k-${p}`),e.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:String(b??"—")},`v-${p}`)]}))}),(t.tokenMintSignature||t.tokenBurnSignature)&&e.jsxs("div",{style:{marginTop:12,fontSize:"0.8rem"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4,opacity:.6,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Signatures"}),t.tokenMintSignature&&e.jsxs("div",{children:["Mint:"," ",e.jsx("a",{href:_e(t.tokenMintSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:K(t.tokenMintSignature)})]}),t.tokenBurnSignature&&e.jsxs("div",{children:["Burn:"," ",e.jsx("a",{href:_e(t.tokenBurnSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:K(t.tokenBurnSignature)})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Admin Notes"}),e.jsx("textarea",{value:a,onChange:p=>c(p.target.value),rows:4,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.85rem",resize:"vertical",boxSizing:"border-box"},placeholder:"Internal notes (not shown to user)..."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:8,flexWrap:"wrap"},children:[t.status==="info_submitted"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"under_review",a),children:s?"Saving...":"Mark Under Review"}),t.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"approved",a),children:s?"Saving...":"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:s,onClick:()=>i(t.id,"rejected",a),children:s?"Saving...":"Reject"})]}),t.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:s,onClick:()=>n(t.id),children:s?"Processing...":"Complete"})]})]})]})})}function Ue({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState([]),[c,y]=r.useState(!0),[p,b]=r.useState(null),[o,d]=r.useState(""),[u,v]=r.useState(null),[x,f]=r.useState(null),j=r.useCallback(async(l,w)=>{if(n?.isAuthenticated())return n.fetchWithAuth(l,w);const _={"Content-Type":"application/json"};i&&(_["X-API-Key"]=i);const A=await fetch(`${t}${l}`,{...w,headers:{..._,...w?.headers}});if(!A.ok){const g=await A.text().catch(()=>`HTTP ${A.status}`);throw new Error(g)}return A.json()},[t,i,n]),k=r.useCallback(async()=>{y(!0),b(null);try{const l=o?`?status=${encodeURIComponent(o)}&limit=50&offset=0`:"?limit=50&offset=0",w=await j(`/admin/asset-redemptions${l}`);a(w.redemptions??[])}catch(l){b(l instanceof Error?l.message:"Failed to load redemptions")}finally{y(!1)}},[j,o]);r.useEffect(()=>{k()},[k]);const h=r.useCallback(async(l,w,_)=>{f(l),b(null);try{await j(`/admin/asset-redemptions/${l}/status`,{method:"PATCH",body:JSON.stringify({status:w,adminNotes:_})}),v(null),await k()}catch(A){b(A instanceof Error?A.message:"Failed to update status")}finally{f(null)}},[j,k]),S=r.useCallback(async l=>{f(l),b(null);try{await j(`/admin/asset-redemptions/${l}/complete`,{method:"POST"}),v(null),await k()}catch(w){b(w instanceof Error?w.message:"Failed to complete redemption")}finally{f(null)}},[j,k]),T=l=>{v(w=>w===l?null:l)};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1rem",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Status"}),e.jsx("select",{value:o,onChange:l=>{d(l.target.value),v(null)},style:{padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",minWidth:160},children:Le.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))})]}),e.jsx("div",{style:{alignSelf:"flex-end"},children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline",onClick:k,disabled:c,children:c?"Loading...":"Refresh"})})]}),p&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:p}),c?e.jsx("div",{className:"cedros-admin__loading",children:"Loading redemptions..."}):s.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No redemption requests found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"User"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:s.map(l=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{cursor:"pointer"},onClick:()=>T(l.id),children:[e.jsx("td",{children:Oe(l.createdAt)}),e.jsx("td",{children:e.jsx("code",{title:l.orderId,children:K(l.orderId)})}),e.jsx("td",{children:e.jsx("code",{title:l.productId,children:K(l.productId)})}),e.jsx("td",{children:e.jsx("code",{title:l.collectionId,children:K(l.collectionId)})}),e.jsx("td",{children:l.userId?e.jsx("code",{title:l.userId,children:K(l.userId)}):e.jsx("span",{style:{opacity:.4},children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:$e(l.status),children:qe(l.status)})}),e.jsx("td",{onClick:w=>w.stopPropagation(),children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[(l.status==="info_submitted"||l.status==="under_review"||l.status==="approved")&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>T(l.id),children:u===l.id?"Close":"Review"}),l.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:x===l.id,onClick:()=>h(l.id,"approved",l.adminNotes??""),children:"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:x===l.id,onClick:()=>h(l.id,"rejected",l.adminNotes??""),children:"Reject"})]}),l.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:x===l.id,onClick:()=>S(l.id),children:x===l.id?"Processing...":"Complete"})]})})]},l.id),u===l.id&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:0},children:e.jsx(We,{redemption:l,onAction:h,onComplete:S,actionBusy:x===l.id})})},`${l.id}-detail`)]}))})]})})]})}const Ye={CA:{cashOutCents:1500,expirationProhibited:!0,escheatmentYears:3,notes:"Cash-out threshold increases to $15 on April 1, 2026."},CO:{cashOutCents:500,escheatmentYears:5},CT:{cashOutCents:300,escheatmentYears:3},FL:{expirationProhibited:!0,escheatmentYears:5},ME:{cashOutCents:500,escheatmentYears:3},MA:{cashOutCents:500,escheatmentYears:3,notes:"Cash-out also required when 90% of value is used."},MT:{cashOutCents:500,escheatmentYears:5},NJ:{cashOutCents:500,escheatmentYears:3},OR:{cashOutCents:500,escheatmentYears:3,notes:"May require at least one prior transaction."},RI:{cashOutCents:100,escheatmentYears:3},TX:{cashOutCents:250,escheatmentYears:3},VT:{cashOutCents:100,escheatmentYears:3},WA:{cashOutCents:500,escheatmentYears:5},PR:{cashOutCents:500,escheatmentYears:5}},ye={escheatmentYears:5},re=1e6,Ge={AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",DC:"District of Columbia",PR:"Puerto Rico"};function Ke({serverUrl:t,authManager:i}){const[n,s]=r.useState(null),[a,c]=r.useState(null),[y,p]=r.useState(null),[b,o]=r.useState(!0),d=r.useCallback(async()=>{try{const j=(await new ee.ConfigApiClient(t,void 0,i).getConfig("gift_cards")).config??{};s(j.business_state||null),c(j.min_gift_card_value_cents!=null?Number(j.min_gift_card_value_cents):null),p(j.max_gift_card_value_cents!=null?Number(j.max_gift_card_value_cents):null)}catch{}finally{o(!1)}},[t,i]);if(r.useEffect(()=>{d()},[d]),b)return e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading compliance data..."});const u=n?Ye[n]??ye:null,v=n?Ge[n]??n:null;return e.jsx("div",{children:n?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:["Compliance Guidance — ",v]}),e.jsxs("div",{style:{display:"grid",gap:"1rem",maxWidth:720},children:[e.jsx(Je,{reg:u,minValueCents:a}),e.jsx(Ve,{reg:u}),e.jsx(Xe,{reg:u}),e.jsx(Ze,{maxValueCents:y})]}),e.jsx(Qe,{reg:u,minValueCents:a,maxValueCents:y})]}):e.jsx(He,{})})}function He(){return e.jsxs("div",{style:{padding:"2rem",textAlign:"center"},children:[e.jsx("p",{style:{fontSize:15,opacity:.7,marginBottom:"0.5rem"},children:"No business state configured."}),e.jsxs("p",{style:{fontSize:13,opacity:.5},children:["Set your ",e.jsx("strong",{children:"business_state"})," in the Gift Cards config category to see state-specific compliance guidance."]})]})}function te({title:t,children:i}){return e.jsxs("div",{style:{border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,padding:"1rem 1.25rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.5rem",fontSize:14,fontWeight:600},children:t}),e.jsx("div",{style:{fontSize:13,lineHeight:1.6},children:i})]})}function Je({reg:t,minValueCents:i}){if(!t.cashOutCents)return e.jsx(te,{title:"Cash-Out Threshold",children:e.jsx("p",{style:{margin:0},children:"Your state does not have a specific cash-out threshold for gift cards. Federal law does not require cash redemption."})});const n=(t.cashOutCents/100).toFixed(2),s=i!=null&&i>t.cashOutCents;return e.jsxs(te,{title:"Cash-Out Threshold",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Your state requires cash redemption for gift cards with a remaining balance of ",e.jsxs("strong",{children:["$",n]})," or less."]}),e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Since this system uses ",e.jsx("strong",{children:"one-shot full redemption"})," (entire gift card value is converted to credits at once), cash-out is avoided by setting the minimum gift card face value above the threshold."]}),s?e.jsxs(oe,{ok:!0,children:["Min value ($",((i??0)/100).toFixed(2),") exceeds threshold"]}):e.jsxs(oe,{ok:!1,children:["Set ",e.jsx("code",{children:"min_gift_card_value_cents"})," above ",t.cashOutCents," to avoid cash-out obligations"]}),t.notes&&e.jsx("p",{style:{margin:"0.5rem 0 0",opacity:.7,fontStyle:"italic"},children:t.notes})]})}function Ve({reg:t}){return e.jsx(te,{title:"Expiration Rules",children:t.expirationProhibited?e.jsxs("p",{style:{margin:0},children:["Your state ",e.jsx("strong",{children:"prohibits"})," gift card expiration. Do not set expiration dates on gift cards."]}):e.jsxs("p",{style:{margin:0},children:["Federal law (CARD Act) requires gift cards to remain valid for at least ",e.jsx("strong",{children:"5 years"})," from purchase or last reload. Your state follows the federal minimum."]})})}function Xe({reg:t}){const i=t.escheatmentYears??ye.escheatmentYears;return e.jsxs(te,{title:"Escheatment (Unclaimed Property)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Gift card balances unredeemed for ",e.jsxs("strong",{children:[i," years"]})," may need to be reported and remitted to the state as unclaimed property."]}),e.jsxs("p",{style:{margin:0,opacity:.7},children:["The system tracks ",e.jsx("code",{children:"last_activity_at"})," on gift card redemptions to help identify dormant balances approaching the escheatment window."]})]})}function Ze({maxValueCents:t}){const i=t??re,n=i<=re;return e.jsxs(te,{title:"Anti-Money Laundering (AML)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["FinCEN requires closed-loop prepaid cards to stay at or below ",e.jsx("strong",{children:"$10,000"})," per card. The server enforces this cap on product creation."]}),n?e.jsxs(oe,{ok:!0,children:["Max value ($",(i/100).toFixed(2),") within AML limit"]}):e.jsxs(oe,{ok:!1,children:[e.jsx("code",{children:"max_gift_card_value_cents"})," exceeds $10,000 AML cap"]})]})}function oe({ok:t,children:i}){return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:6,fontSize:13,fontWeight:500,background:t?"rgba(34,197,94,0.1)":"rgba(234,179,8,0.15)",color:t?"#16a34a":"#a16207"},children:[e.jsx("span",{children:t?"✓":"⚠"}),i]})}function Qe({reg:t,minValueCents:i,maxValueCents:n}){const a=[{label:"AML: Max card value ≤ $10,000",ok:(n??re)<=re},...t.cashOutCents?[{label:`Cash-out: Min value > $${(t.cashOutCents/100).toFixed(2)} threshold`,ok:i!=null&&i>t.cashOutCents}]:[],{label:t.expirationProhibited?"Expiration: State prohibits expiration (no action needed)":"Expiration: Federal 5-year minimum applies",ok:!0},{label:`Escheatment: ${t.escheatmentYears??ye.escheatmentYears}-year dormancy tracking enabled`,ok:!0}];return e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{fontSize:14,fontWeight:600,marginBottom:"0.75rem"},children:"Compliance Checklist"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:a.map((c,y)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:c.ok?"#16a34a":"#d97706",fontWeight:600},children:c.ok?"✓":"⚠"}),e.jsx("span",{children:c.label})]},y))})]})}function et({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState(null),[c,y]=r.useState(!0),[p,b]=r.useState(null),o=r.useCallback(async x=>{if(n?.isAuthenticated())return n.fetchWithAuth(x);const f={"Content-Type":"application/json"};i&&(f["X-API-Key"]=i);const j=await fetch(`${t}${x}`,{headers:f});if(!j.ok)throw new Error(`HTTP ${j.status}`);return j.json()},[t,i,n]),d=r.useCallback(async()=>{y(!0),b(null);try{const[x,f]=await Promise.all([o("/admin/gift-cards?limit=50"),o("/admin/gift-card-redemptions?limit=50").catch(()=>({redemptions:[]}))]),j=x.giftCards??[],k=f.redemptions??[],h=new Date,S=j.filter(m=>m.active&&(!m.expiresAt||new Date(m.expiresAt)>h)).length,T=j.filter(m=>m.expiresAt&&new Date(m.expiresAt)<=h).length,l=j.reduce((m,N)=>m+N.initialBalance,0),w=j.reduce((m,N)=>m+N.balance,0),_=k.reduce((m,N)=>m+N.faceValueCents,0),A=k.filter(m=>m.tokenMinted).length,g=j[0]?.currency||k[0]?.currency||"USD";a({totalCards:j.length,activeCards:S,expiredCards:T,totalIssuedCents:l,totalRemainingCents:w,totalRedeemedCents:_,redemptionCount:k.length,tokensMinted:A,currency:g.toUpperCase()})}catch(x){b(x instanceof Error?x.message:"Failed to load analytics")}finally{y(!1)}},[o]);r.useEffect(()=>{d()},[d]);const u=x=>`$${(x/100).toFixed(2)}`;if(c)return e.jsx("div",{className:"cedros-admin__loading",children:"Loading analytics..."});if(p)return e.jsxs("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,fontSize:13,color:"#b91c1c"},children:[p,e.jsx("button",{className:"cedros-admin__button cedros-admin__button--sm",style:{marginLeft:8},onClick:d,children:"Retry"})]});if(!s)return null;const v=s.totalIssuedCents>0?((s.totalIssuedCents-s.totalRemainingCents)/s.totalIssuedCents*100).toFixed(1):"0.0";return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Gift Card & Token Analytics"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:"0.75rem",marginBottom:"1.5rem"},children:[e.jsx($,{label:"Total Cards",value:String(s.totalCards)}),e.jsx($,{label:"Active",value:String(s.activeCards),accent:"green"}),e.jsx($,{label:"Expired",value:String(s.expiredCards),accent:s.expiredCards>0?"amber":void 0}),e.jsx($,{label:"Total Issued",value:u(s.totalIssuedCents),sub:s.currency}),e.jsx($,{label:"Remaining Balance",value:u(s.totalRemainingCents),sub:s.currency}),e.jsx($,{label:"Usage Rate",value:`${v}%`,sub:"issued vs. spent"}),e.jsx($,{label:"Redemptions",value:String(s.redemptionCount)}),e.jsx($,{label:"Tokens Minted",value:String(s.tokensMinted),sub:`of ${s.redemptionCount} redemptions`})]}),s.totalIssuedCents>0&&e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginBottom:6},children:"Balance Breakdown"}),e.jsxs("div",{style:{display:"flex",height:24,borderRadius:6,overflow:"hidden",background:"rgba(0,0,0,0.05)"},children:[e.jsx("div",{style:{width:`${(s.totalIssuedCents-s.totalRemainingCents)/s.totalIssuedCents*100}%`,background:"#2563eb",minWidth:2},title:`Spent: ${u(s.totalIssuedCents-s.totalRemainingCents)}`}),e.jsx("div",{style:{width:`${s.totalRemainingCents/s.totalIssuedCents*100}%`,background:"#60a5fa",minWidth:2},title:`Remaining: ${u(s.totalRemainingCents)}`})]}),e.jsxs("div",{style:{display:"flex",gap:"1rem",marginTop:6,fontSize:12,opacity:.7},children:[e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"#2563eb",borderRadius:2,marginRight:4}}),"Spent"]}),e.jsxs("span",{children:[e.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"#60a5fa",borderRadius:2,marginRight:4}}),"Remaining"]})]})]})]})}function $({label:t,value:i,sub:n,accent:s}){const a=s==="green"?"#166534":s==="amber"?"#92400e":void 0;return e.jsxs("div",{style:{padding:"0.75rem 1rem",borderRadius:8,border:"1px solid rgba(0,0,0,0.08)",background:"rgba(0,0,0,0.01)"},children:[e.jsx("div",{style:{fontSize:12,opacity:.6,marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:a},children:i}),n&&e.jsx("div",{style:{fontSize:11,opacity:.5,marginTop:2},children:n})]})}function tt({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState([]),[c,y]=r.useState(!0),[p,b]=r.useState(null),[o,d]=r.useState("list"),[u,v]=r.useState(null),[x,f]=r.useState(!1),[j,k]=r.useState(null),h=r.useCallback(async(_,A)=>{if(n?.isAuthenticated())return n.fetchWithAuth(_,A);const g={"Content-Type":"application/json"};i&&(g["X-API-Key"]=i);const m=await fetch(`${t}${_}`,{...A,headers:{...g,...A?.headers}});if(!m.ok){const N=await m.text().catch(()=>`HTTP ${m.status}`);throw new Error(N)}return m.json()},[t,i,n]),S=r.useCallback(async()=>{y(!0),b(null);try{const A=await h(`/admin/gift-cards${x?"?activeOnly=true&limit=50":"?limit=50"}`);a(A.giftCards??[])}catch(_){b(_ instanceof Error?_.message:"Failed to load gift cards")}finally{y(!1)}},[h,x]);r.useEffect(()=>{S()},[S]);const T=(_,A)=>`$${(_/100).toFixed(2)} ${A.toUpperCase()}`,l=_=>{try{return new Date(_).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}catch{return _}},w=_=>{v(_),d("adjust"),k(null)};return o==="create"?e.jsx(st,{onSubmit:async _=>{await h("/admin/gift-cards",{method:"POST",body:JSON.stringify(_)}),d("list"),S()},onCancel:()=>d("list")}):o==="adjust"&&u?e.jsx(nt,{card:u,formatCents:T,onSubmit:async _=>{await h(`/admin/gift-cards/${encodeURIComponent(u.code)}/adjust`,{method:"POST",body:JSON.stringify({newBalance:_})}),d("list"),S()},onToggleActive:async()=>{await h(`/admin/gift-cards/${encodeURIComponent(u.code)}`,{method:"PUT",body:JSON.stringify({initialBalance:u.initialBalance,balance:u.balance,currency:u.currency,active:!u.active,expiresAt:u.expiresAt,metadata:u.metadata})}),d("list"),S()},onCancel:()=>{d("list"),v(null)}}):e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{margin:0},children:"Gift Card Inventory"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",alignItems:"center"},children:[e.jsxs("label",{style:{fontSize:13,display:"flex",alignItems:"center",gap:4},children:[e.jsx("input",{type:"checkbox",checked:x,onChange:_=>f(_.target.checked)}),"Active only"]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",onClick:()=>{d("create"),k(null)},children:"+ New Gift Card"})]})]}),p&&e.jsxs("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:[p,e.jsx("button",{className:"cedros-admin__button cedros-admin__button--sm",style:{marginLeft:8},onClick:S,children:"Retry"})]}),j&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(22,163,74,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#166534"},children:j}),c?e.jsx("div",{className:"cedros-admin__loading",children:"Loading..."}):s.length?e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Code"}),e.jsx("th",{children:"Balance"}),e.jsx("th",{children:"Initial"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Expires"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:s.map(_=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[_.code.slice(0,12),"..."]})}),e.jsx("td",{style:{fontWeight:600},children:T(_.balance,_.currency)}),e.jsx("td",{style:{opacity:.7},children:T(_.initialBalance,_.currency)}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${_.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:_.active?"Active":"Inactive"})}),e.jsx("td",{style:{fontSize:13},children:_.expiresAt?l(_.expiresAt):"—"}),e.jsx("td",{style:{fontSize:13},children:l(_.createdAt)}),e.jsx("td",{children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>w(_),children:"Manage"})})]},_.code))})]})}):e.jsx("div",{className:"cedros-admin__empty",style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift cards found."})]})}function st({onSubmit:t,onCancel:i}){const[n,s]=r.useState({code:"",initialBalance:"",currency:"USD",expiresAt:""}),[a,c]=r.useState(!1),[y,p]=r.useState(null),b=async o=>{o.preventDefault();const d=Math.round(parseFloat(n.initialBalance)*100);if(!d||d<0){p("Initial balance must be positive");return}c(!0),p(null);try{await t({...n.code.trim()?{code:n.code.trim().toUpperCase()}:{},initialBalance:d,currency:n.currency.toUpperCase(),...n.expiresAt?{expiresAt:new Date(n.expiresAt).toISOString()}:{}})}catch(u){p(u instanceof Error?u.message:"Failed to create gift card")}finally{c(!1)}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Create Gift Card"}),y&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:y}),e.jsxs("form",{onSubmit:b,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Code (optional, auto-generated if empty)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.code,onChange:o=>s(d=>({...d,code:o.target.value})),placeholder:"Leave blank to auto-generate"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Initial Balance ($)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n.initialBalance,onChange:o=>s(d=>({...d,initialBalance:o.target.value})),placeholder:"25.00",step:"0.01",min:"0",required:!0})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Currency"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:n.currency,onChange:o=>s(d=>({...d,currency:o.target.value})),maxLength:3,required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Expiration date (optional)"}),e.jsx("input",{type:"date",className:"cedros-admin__input",value:n.expiresAt,onChange:o=>s(d=>({...d,expiresAt:o.target.value}))})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:a,children:a?"Creating...":"Create Gift Card"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:i,children:"Cancel"})]})]})]})}function nt({card:t,formatCents:i,onSubmit:n,onToggleActive:s,onCancel:a}){const[c,y]=r.useState((t.balance/100).toFixed(2)),[p,b]=r.useState(!1),[o,d]=r.useState(null),u=async x=>{x.preventDefault();const f=Math.round(parseFloat(c)*100);if(isNaN(f)||f<0){d("Balance must be >= 0");return}b(!0),d(null);try{await n(f)}catch(j){d(j instanceof Error?j.message:"Failed to adjust balance")}finally{b(!1)}},v=async()=>{b(!0),d(null);try{await s()}catch(x){d(x instanceof Error?x.message:"Failed to update status"),b(!1)}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Manage Gift Card"}),o&&e.jsx("div",{style:{padding:"0.75rem",background:"rgba(220,38,38,0.08)",borderRadius:6,marginBottom:"1rem",fontSize:13,color:"#b91c1c"},children:o}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.5rem",maxWidth:500,marginBottom:"1.5rem",fontSize:13},children:[e.jsx("div",{style:{fontWeight:500},children:"Code"}),e.jsx("div",{style:{fontFamily:"monospace",wordBreak:"break-all"},children:t.code}),e.jsx("div",{style:{fontWeight:500},children:"Current Balance"}),e.jsx("div",{style:{fontWeight:600},children:i(t.balance,t.currency)}),e.jsx("div",{style:{fontWeight:500},children:"Initial Balance"}),e.jsx("div",{children:i(t.initialBalance,t.currency)}),e.jsx("div",{style:{fontWeight:500},children:"Status"}),e.jsx("div",{children:e.jsx("span",{className:`cedros-admin__badge ${t.active?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:t.active?"Active":"Inactive"})}),t.expiresAt&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500},children:"Expires"}),e.jsx("div",{children:new Date(t.expiresAt).toLocaleDateString()})]})]}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"cedros-admin__field",style:{maxWidth:250},children:[e.jsx("label",{className:"cedros-admin__field-label",children:"New Balance ($)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:c,onChange:x=>y(x.target.value),step:"0.01",min:"0",required:!0})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:p,children:p?"Saving...":"Adjust Balance"}),e.jsx("button",{type:"button",className:`cedros-admin__button ${t.active?"cedros-admin__button--danger":"cedros-admin__button--outline"}`,onClick:v,disabled:p,children:t.active?"Deactivate":"Reactivate"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--outline",onClick:a,children:"Back"})]})]})]})}const it=0;class we{dlmmModule=null;bnClass=null;keypairClass=null;async loadDLMM(){if(this.dlmmModule)return this.dlmmModule;try{const i=await Promise.resolve().then(()=>require("./pay-react_false-DaeIe3_l.js"));return this.dlmmModule=i.default??i,this.dlmmModule}catch{throw new Error("Install @meteora-ag/dlmm to enable pool deployment: npm install @meteora-ag/dlmm")}}async loadBN(){if(this.bnClass)return this.bnClass;const i=await Promise.resolve().then(()=>require("./bn-CHyy7EgJ.js")).then(n=>n.bn);return this.bnClass=i.default??i,this.bnClass}async loadKeypair(){if(this.keypairClass)return this.keypairClass;const{Keypair:i}=await import("@solana/web3.js");return this.keypairClass=i,this.keypairClass}async computeBinId(i,n,s,a=1){const c=await this.loadDLMM(),y=c.getPricePerLamport(n,s,i);return c.getBinIdFromPrice(y,a,!0)}async findPresetParameter(i,n,s){const a=await this.loadDLMM(),c=s?{cluster:s}:void 0,{presetParameter2:y}=await a.getAllPresetParameters(i,c),p=y.find(b=>b.account.binStep===n);if(!p)throw new Error(`No PresetParameter2 found for binStep=${n}. Available: ${y.map(b=>b.account.binStep).join(", ")}`);return p.publicKey}async createPool(i,n,s,a,c,y=1,p){const b=await this.loadDLMM(),o=await this.loadBN(),d=p?{cluster:p}:void 0,u=await this.findPresetParameter(i,y,p),v=await b.createLbPair2(i,n,s,a,u,new o(c),d),x=v.instructions[0]?.keys?.[1]?.pubkey;if(!x)throw new Error("Failed to extract pool address from transaction");return{transaction:v,poolAddress:x}}async addBuybackLiquidity(i,n,s,a,c,y){const p=await this.loadDLMM(),b=await this.loadBN(),o=await this.loadKeypair(),d=y?{cluster:y}:void 0,u=await p.create(i,s,d),v=o.generate(),x=c-1,f=c;return{transaction:await u.initializePositionAndAddLiquidityByStrategy({positionPubKey:v.publicKey,totalXAmount:new b(0),totalYAmount:new b(a),strategy:{maxBinId:f,minBinId:x,strategyType:it},user:n,slippage:1}),positionKeypair:v}}async getPoolStatus(i,n,s){const a=await this.loadDLMM(),c=s?{cluster:s}:void 0,y=await a.create(i,n,c),p=await y.getActiveBin();return{address:n.toBase58(),activeBinId:p.binId,activeBinPrice:p.price,binStep:y.lbPair.binStep}}}const he=6,at=1,rt="https://solscan.io/account",ot="https://app.meteora.ag/dlmm";function lt({serverUrl:t,authManager:i,poolAddress:n,buybackRateBps:s,usdcAmount:a,deployedAt:c,mintAddress:y,tokenDecimals:p=2,onConfigUpdated:b}){const[o,d]=r.useState("none"),[u,v]=r.useState(s!=null?s/100:80),[x,f]=r.useState(100),[j,k]=r.useState(!1),[h,S]=r.useState(!1),[T,l]=r.useState(null),[w,_]=r.useState(null),A=s!=null?`$${(s/1e4).toFixed(2)}`:"Unknown",g=a!=null?`$${(a/10**he).toFixed(2)}`:null,m=c?new Date(c).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null,N=n.length>16?`${n.slice(0,8)}...${n.slice(-8)}`:n,C=async()=>{k(!0),_(null),l(null);try{const B=new ee.ConfigApiClient(t,void 0,i),R=Math.round(u*100);await B.patchConfig("gift_cards",{buyback_rate_bps:R},`Buyback rate adjusted to ${u} cents`),l("Buyback rate updated"),d("none"),b()}catch(B){_(B instanceof Error?B.message:"Failed to update rate")}finally{k(!1)}},z=async()=>{if(y){S(!0),_(null),l(null);try{const{Connection:B,PublicKey:R,Keypair:M}=await import("@solana/web3.js"),F=new ee.ConfigApiClient(t,void 0,i),I=await F.getConfig("x402"),D=I.config?.rpc_url||"",P=I.config?.token_mint||"";if(!D||!P)throw new Error("RPC URL or USDC mint not configured");const L=new B(D,"confirmed"),O=window.solana;if(!O?.publicKey||!O.signTransaction)throw new Error("Wallet not connected");const se=new we,le=new R(O.publicKey.toBase58()),E=u/100,de=await se.computeBinId(E,p,he,at),ne=new R(n),H=Math.round(x*10**he),{transaction:J,positionKeypair:W}=await se.addBuybackLiquidity(L,le,ne,H,de),V=M.fromSecretKey(W.secretKey);J.partialSign(V);const Y=await O.signTransaction(J),X=await L.sendRawTransaction(Y.serialize());await L.confirmTransaction(X,"confirmed");const Z=a??0;await F.patchConfig("gift_cards",{liquidity_usdc_amount:Z+H},`Added ${x} USDC liquidity`),l(`Added $${x} USDC liquidity`),d("none"),b()}catch(B){_(B instanceof Error?B.message:"Failed to add liquidity")}finally{S(!1)}}};return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Liquidity Pool Active"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Pool Address"}),e.jsxs("div",{style:{fontSize:13,fontFamily:"monospace",wordBreak:"break-all"},children:[N,e.jsxs("span",{style:{marginLeft:8,display:"inline-flex",gap:6},children:[e.jsx(dt,{text:n}),e.jsx(ve,{href:`${rt}/${n}`,label:"Solscan"}),e.jsx(ve,{href:`${ot}/${n}`,label:"Meteora"})]})]}),e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Buyback Rate"}),e.jsxs("div",{style:{fontSize:13},children:[A," per $1.00"]}),g&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"USDC Deposited"}),e.jsx("div",{style:{fontSize:13},children:g})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Deployed"}),e.jsx("div",{style:{fontSize:13},children:m})]})]}),e.jsxs("div",{style:{marginTop:"1.25rem",display:"flex",gap:"0.5rem"},children:[e.jsx("button",{className:"cedros-admin__button",onClick:()=>d(o==="adjust_rate"?"none":"adjust_rate"),disabled:h||j,children:"Adjust Rate"}),e.jsx("button",{className:"cedros-admin__button",onClick:()=>d(o==="add_liquidity"?"none":"add_liquidity"),disabled:h||j||!y,children:"Add Liquidity"})]}),o==="adjust_rate"&&e.jsxs("div",{style:{marginTop:"1rem",padding:"1rem",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"New buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:u,onChange:B=>v(Math.max(1,Math.min(99,parseInt(B.target.value)||80))),min:"1",max:"99",style:{maxWidth:200}}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["Profit per redemption: $",((100-u)/100).toFixed(2)]})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:C,disabled:j,style:{marginTop:"0.75rem"},children:j?"Saving...":"Save Rate"})]}),o==="add_liquidity"&&e.jsxs("div",{style:{marginTop:"1rem",padding:"1rem",borderRadius:8,border:"1px solid var(--cedros-admin-border, #e5e7eb)"},children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount to add"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:x,onChange:B=>f(Math.max(1,parseFloat(B.target.value)||100)),min:"1",step:"1",style:{maxWidth:200}})]}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:z,disabled:h,style:{marginTop:"0.75rem"},children:h?"Adding liquidity...":`Add $${x} USDC`}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Requires a connected wallet and USDC balance."})]}),T&&e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:6,background:"rgba(22,163,74,0.1)",color:"#16a34a",fontSize:13},children:T}),w&&e.jsx("div",{style:{marginTop:"0.75rem",padding:"0.5rem 0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:w})]})}function dt({text:t}){const[i,n]=r.useState(!1),s=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})};return e.jsx("button",{type:"button",onClick:s,style:{background:"none",border:"none",cursor:"pointer",fontSize:12,opacity:.7,padding:0},children:i?"Copied":"Copy"})}function ve({href:t,label:i}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,opacity:.7},children:i})}const ie=6,ge=1;function ct({serverUrl:t,authManager:i,mintConfigured:n,mintAddress:s,tokenDecimals:a=2}){const[c,y]=r.useState({liquidityPoolAddress:null,buybackRateBps:null,rpcUrl:null,usdcMint:null,usdcAmount:null,deployedAt:null}),[p,b]=r.useState(!0),[o,d]=r.useState(80),[u,v]=r.useState(250),[x,f]=r.useState("idle"),[j,k]=r.useState(null),[h,S]=r.useState(null),[T,l]=r.useState(null),w=r.useRef(new we),_=r.useCallback(async()=>{try{const R=new ee.ConfigApiClient(t,void 0,i),[M,F]=await Promise.all([R.getConfig("gift_cards"),R.getConfig("x402")]),I=M.config??{},D=F.config??{},P=I.liquidity_pool_address||null;y({liquidityPoolAddress:P,buybackRateBps:I.buyback_rate_bps!=null?Number(I.buyback_rate_bps):null,rpcUrl:D.rpc_url||null,usdcMint:D.token_mint||null,usdcAmount:I.liquidity_usdc_amount!=null?Number(I.liquidity_usdc_amount):null,deployedAt:I.liquidity_deployed_at||null}),P&&S(P),I.buyback_rate_bps!=null&&d(Number(I.buyback_rate_bps)/100)}catch{}finally{b(!1)}},[t,i]);r.useEffect(()=>{_()},[_]);const A=typeof window<"u"&&!!window.solana?.publicKey,g=!!c.rpcUrl,m=!!c.usdcMint,N=n&&A&&g&&m&&x==="idle",C=async R=>{if(!(!s||!c.rpcUrl||!c.usdcMint)){f(R),k(null),l(null);try{const{Connection:M,PublicKey:F,Keypair:I}=await import("@solana/web3.js"),D=new M(c.rpcUrl,"confirmed"),P=window.solana;if(!P?.publicKey||!P.signTransaction)throw new Error("Wallet not connected");const L=w.current,O=new F(P.publicKey.toBase58()),se=o/100,le=await L.computeBinId(se,a,ie,ge);let E=h;if(R==="creating_pool"){const W=new F(s),V=new F(c.usdcMint),Y=await L.computeBinId(1,a,ie,ge),{transaction:X,poolAddress:Z}=await L.createPool(D,O,W,V,Y,ge),ce=await P.signTransaction(X),ue=await D.sendRawTransaction(ce.serialize());await D.confirmTransaction(ue,"confirmed"),E=Z.toBase58(),S(E)}if(R==="creating_pool"||R==="adding_liquidity"){if(f("adding_liquidity"),!E)throw new Error("Pool address not available");const W=new F(E),V=Math.round(u*10**ie),{transaction:Y,positionKeypair:X}=await L.addBuybackLiquidity(D,O,W,V,le),Z=I.fromSecretKey(X.secretKey);Y.partialSign(Z);const ce=await P.signTransaction(Y),ue=await D.sendRawTransaction(ce.serialize());await D.confirmTransaction(ue,"confirmed")}if(f("saving_config"),!E)throw new Error("Pool address not available");const de=new ee.ConfigApiClient(t,void 0,i),ne=Math.round(o*100),H=Math.round(u*10**ie),J=new Date().toISOString();await de.patchConfig("gift_cards",{liquidity_pool_address:E,buyback_rate_bps:ne,liquidity_usdc_amount:H,liquidity_deployed_at:J},"Meteora DLMM pool deployed for gift card buyback"),y(W=>({...W,liquidityPoolAddress:E,buybackRateBps:ne,usdcAmount:H,deployedAt:J})),f("done")}catch(M){l(x==="idle"?R:x),k(M instanceof Error?M.message:"Deployment failed"),f("error")}}},z=()=>{N&&C("creating_pool")},B=()=>{!T||T==="idle"||T==="done"||T==="error"||C(T)};return p?e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading pool configuration..."}):c.liquidityPoolAddress?e.jsx(lt,{serverUrl:t,authManager:i,poolAddress:c.liquidityPoolAddress,buybackRateBps:c.buybackRateBps,usdcAmount:c.usdcAmount,deployedAt:c.deployedAt,mintAddress:s,tokenDecimals:a,onConfigUpdated:_}):x!=="idle"&&x!=="error"?e.jsx(mt,{step:x,poolAddress:h}):e.jsx(ut,{buybackCents:o,setBuybackCents:d,usdcAmount:u,setUsdcAmount:v,mintConfigured:n,walletConnected:A,hasRpcUrl:g,hasUsdcMint:m,canDeploy:N,onDeploy:z,errorMessage:j,canRetry:!!T&&T!=="creating_pool",onRetry:B})}function ut({buybackCents:t,setBuybackCents:i,usdcAmount:n,setUsdcAmount:s,mintConfigured:a,walletConnected:c,hasRpcUrl:y,hasUsdcMint:p,canDeploy:b,onDeploy:o,errorMessage:d,canRetry:u,onRetry:v}){const x=((100-t)/100).toFixed(2);return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Deploy Buyback Liquidity Pool"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Meteora DLMM pool to buy back gift card tokens at a discount. You earn the spread when tokens are resold at face value."}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:t,onChange:f=>i(Math.max(1,Math.min(99,parseInt(f.target.value)||80))),min:"1",max:"99"}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["You earn $",x," profit per gift card redeemed"]})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n,onChange:f=>s(Math.max(1,parseFloat(f.target.value)||250)),min:"1",step:"1"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Minimum recommended: $250"})]})]}),e.jsxs("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",gap:6},children:[e.jsx(ae,{label:"Token-22 mint initialized",met:a}),e.jsx(ae,{label:"Wallet connected",met:c}),e.jsx(ae,{label:"RPC URL configured",met:y}),e.jsx(ae,{label:"USDC mint configured",met:p})]}),d&&e.jsx("div",{style:{padding:"0.5rem 0.75rem",marginBottom:"0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:d}),e.jsx("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:u?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:v,children:"Retry (Resume from Failed Step)"}):e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:o,disabled:!b,children:"Deploy Liquidity Pool"})})]})}const Se=[{key:"creating_pool",label:"Creating DLMM pool..."},{key:"adding_liquidity",label:"Depositing USDC liquidity..."},{key:"saving_config",label:"Saving configuration..."},{key:"done",label:"Complete"}];function mt({step:t,poolAddress:i}){return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Deploying Pool..."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:Se.map((n,s)=>{const a=Se.findIndex(b=>b.key===t),c=s,y=c<a||t==="done",p=c===a&&t!=="done";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontWeight:600},children:y?"✓":p?"▶":"○"}),e.jsx("span",{style:{opacity:y||p?1:.4},children:n.label})]},n.key)})}),i&&e.jsxs("div",{style:{marginTop:"1rem",fontSize:13,opacity:.7},children:["Pool: ",e.jsx("code",{style:{fontSize:12},children:i})]})]})}function ae({label:t,met:i}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:i?"#16a34a":"#dc2626",fontWeight:600},children:i?"✓":"✗"}),e.jsx("span",{style:{opacity:i?.8:.5},children:t})]})}function pt({serverUrl:t,apiKey:i,authManager:n}){const[s,a]=r.useState(null),[c,y]=r.useState([]),[p,b]=r.useState(!0),[o,d]=r.useState(null),[u,v]=r.useState("mint"),[x,f]=r.useState({treasuryAddress:"",tokenSymbol:"storeUSD",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500}),[j,k]=r.useState(!1),[h,S]=r.useState(!1),[T,l]=r.useState(null),w=r.useCallback(async(C,z)=>{if(n?.isAuthenticated())return n.fetchWithAuth(C,z);const B={"Content-Type":"application/json"};i&&(B["X-API-Key"]=i);const R=await fetch(`${t}${C}`,{...z,headers:{...B,...z?.headers}});if(!R.ok){const M=await R.text().catch(()=>`HTTP ${R.status}`);throw new Error(M)}return R.json()},[t,i,n]),_=r.useCallback(async()=>{try{d(null);const C=await w("/admin/token22/status");a(C)}catch{d("Failed to load Token-22 status")}finally{b(!1)}},[w]),A=r.useCallback(async()=>{try{const C=await w("/admin/gift-card-redemptions?limit=50");y(C.redemptions||[])}catch{y([])}},[w]);r.useEffect(()=>{_(),A()},[_,A]);const g=async C=>{if(C.preventDefault(),!!x.treasuryAddress){k(!0),l(null);try{const z=await w("/admin/token22/initialize",{method:"POST",body:JSON.stringify({treasuryAddress:x.treasuryAddress,tokenSymbol:x.tokenSymbol,tokenDecimals:x.tokenDecimals,transferFeeBps:x.transferFeeBps,maxTransferFee:x.maxTransferFee})});l(`Mint created: ${z.mintAddress}`),_()}catch(z){l(`Error: ${z instanceof Error?z.message:"Failed to initialize"}`)}finally{k(!1)}}},m=async()=>{S(!0),l(null);try{const C=await w("/admin/token22/harvest-fees",{method:"POST"});l(C.message)}catch(C){l(`Error: ${C instanceof Error?C.message:"Failed to harvest"}`)}finally{S(!1)}},N=C=>{try{return new Date(C).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return C}};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(fe.ErrorBanner,{message:o,onRetry:_}),e.jsx("div",{style:{display:"flex",gap:0,borderBottom:"1px solid rgba(0,0,0,0.1)",marginBottom:"1rem"},children:["mint","inventory","analytics","redemptions","compliance","liquidity","asset-classes","asset-redemptions"].map(C=>{const z={mint:"Token-22 Mint",inventory:"Gift Cards",analytics:"Analytics",redemptions:"Redemptions",compliance:"Compliance",liquidity:"Liquidity","asset-classes":"Asset Classes","asset-redemptions":"Asset Redemptions"};return e.jsx("button",{type:"button",onClick:()=>v(C),style:{padding:"0.5rem 1rem",background:"none",border:"none",borderBottom:u===C?"2px solid currentColor":"2px solid transparent",fontWeight:u===C?600:400,cursor:"pointer",opacity:u===C?1:.6},children:z[C]},C)})}),p?e.jsxs("div",{className:"cedros-admin__loading",children:[fe.Icons.loading," Loading..."]}):u==="mint"?e.jsx(ht,{mintStatus:s,initForm:x,setInitForm:f,isInitializing:j,isHarvesting:h,actionMessage:T,onInitialize:g,onHarvestFees:m,formatDate:N}):u==="inventory"?e.jsx(tt,{serverUrl:t,apiKey:i,authManager:n}):u==="analytics"?e.jsx(et,{serverUrl:t,apiKey:i,authManager:n}):u==="redemptions"?e.jsx(gt,{redemptions:c,formatDate:N}):u==="compliance"?e.jsx(Ke,{serverUrl:t,apiKey:i,authManager:n}):u==="liquidity"?e.jsx(ct,{serverUrl:t,authManager:n,mintConfigured:!!s?.configured,mintAddress:s?.mintAddress,tokenDecimals:s?.tokenDecimals}):u==="asset-classes"?e.jsx(Ee,{serverUrl:t,apiKey:i,authManager:n,onNavigateToLiquidity:()=>v("liquidity")}):e.jsx(Ue,{serverUrl:t,apiKey:i,authManager:n})]})}function ht({mintStatus:t,initForm:i,setInitForm:n,isInitializing:s,isHarvesting:a,actionMessage:c,onInitialize:y,onHarvestFees:p,formatDate:b}){return t?.configured?e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Token-22 Mint Status"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx(q,{label:"Mint Address",value:t.mintAddress,mono:!0}),e.jsx(q,{label:"Token Symbol",value:t.tokenSymbol}),e.jsx(q,{label:"Decimals",value:String(t.tokenDecimals)}),e.jsx(q,{label:"Transfer Fee",value:`${t.transferFeeBps} bps (${((t.transferFeeBps??0)/100).toFixed(2)}%)`}),e.jsx(q,{label:"Max Transfer Fee",value:String(t.maxTransferFee)}),e.jsx(q,{label:"Treasury",value:t.treasuryAddress,mono:!0}),e.jsx(q,{label:"Authority",value:t.mintAuthority,mono:!0}),e.jsx(q,{label:"Created",value:t.createdAt?b(t.createdAt):"—"})]}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",gap:"0.75rem",alignItems:"center"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:p,disabled:a,children:a?"Harvesting...":"Harvest Transfer Fees"}),c&&e.jsx("span",{style:{fontSize:13,opacity:.8},children:c})]})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Initialize Token-22 Mint"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Token-22 mint with transfer fee extension for the secondary market. This is a one-time operation per tenant."}),e.jsxs("form",{onSubmit:y,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Treasury address (Solana)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.treasuryAddress,onChange:o=>n(d=>({...d,treasuryAddress:o.target.value})),placeholder:"e.g., 7xKX...",required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:i.tokenSymbol,onChange:o=>n(d=>({...d,tokenSymbol:o.target.value})),placeholder:"storeUSD"})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.tokenDecimals,onChange:o=>n(d=>({...d,tokenDecimals:parseInt(o.target.value)||2})),min:"0",max:"9"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Transfer fee (basis points)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.transferFeeBps,onChange:o=>n(d=>({...d,transferFeeBps:parseInt(o.target.value)||0})),min:"0",max:"10000"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"e.g., 250 = 2.5% fee on secondary market transfers"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max transfer fee (atomic)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:i.maxTransferFee,onChange:o=>n(d=>({...d,maxTransferFee:parseInt(o.target.value)||0})),min:"0"})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:s,children:s?"Creating Mint...":"Initialize Mint"}),c&&e.jsx("span",{style:{marginLeft:"0.75rem",fontSize:13,opacity:.8},children:c})]})]})]})}function q({label:t,value:i,mono:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:t}),e.jsx("div",{style:{fontSize:13,fontFamily:n?"monospace":"inherit",wordBreak:n?"break-all":"normal",opacity:i?1:.5},children:i||"—"})]})}function gt({redemptions:t,formatDate:i}){return t.length?e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Buyer"}),e.jsx("th",{children:"Recipient"}),e.jsx("th",{children:"Value"}),e.jsx("th",{children:"Token Minted"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:i(n.createdAt)}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.orderId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsx("code",{style:{fontSize:12},children:n.productId})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.buyerUserId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.recipientUserId.slice(0,8),"..."]})}),e.jsxs("td",{children:["$",(n.faceValueCents/100).toFixed(2)," ",n.currency.toUpperCase()]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${n.tokenMinted?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:n.tokenMinted?"Yes":"No"})})]},n.id))})]})}):e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift card redemptions yet."})}exports.Token22Section=pt;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),a=require("./index-C0g-JxJk.js"),Q=n=>n==="success"?"success":n==="failed"?"failed":n==="pending"||n==="processing"?"pending":"muted",j=(n,d=48)=>n.length>d?`${n.slice(0,d)}…`:n;function P({serverUrl:n,apiKey:d,authManager:b}){const[l,q]=s.useState("active"),[p,f]=s.useState([]),[h,E]=s.useState(0),[m,L]=s.useState("all"),[W,_]=s.useState(!0),[g,k]=s.useState([]),[v,C]=s.useState(0),[N,S]=s.useState(!1),[T,F]=s.useState(!1),[w,c]=s.useState(null),[A,o]=s.useState(null),r=s.useCallback(async(t,i)=>{if(b?.isAuthenticated())return b.fetchWithAuth(t,i);const D={"Content-Type":"application/json"};d&&(D["X-API-Key"]=d);const x=await fetch(`${n}${t}`,{...i,headers:{...D,...i?.headers}});if(!x.ok)throw new Error(`Request failed: ${x.status}`);if(x.status!==204)return x.json()},[n,d,b]),u=s.useCallback(async()=>{_(!0),c(null);try{const t=new URLSearchParams({limit:"100"});m!=="all"&&t.set("status",m);const i=await r(`/admin/webhooks?${t.toString()}`);f(i.webhooks??[]),E(i.count??0)}catch{c("Failed to load webhooks"),f([])}finally{_(!1)}},[r,m]);s.useEffect(()=>{u()},[u]);const y=s.useCallback(async()=>{S(!0),c(null);try{const t=await r("/admin/webhooks/dlq?limit=100");k(t.webhooks??[]),C(t.count??0),F(!0)}catch{c("Failed to load DLQ webhooks"),k([])}finally{S(!1)}},[r]),$=t=>{q(t),c(null),o(null),t==="dlq"&&!T&&y()},z=async t=>{o(null);try{await r(`/admin/webhooks/${encodeURIComponent(t)}/retry`,{method:"POST"}),u()}catch{o("Failed to retry webhook")}},R=async t=>{if(window.confirm("Delete this webhook?")){o(null);try{await r(`/admin/webhooks/${encodeURIComponent(t)}`,{method:"DELETE"}),u()}catch{o("Failed to delete webhook")}}},I=async t=>{o(null);try{await r(`/admin/webhooks/dlq/${encodeURIComponent(t)}/retry`,{method:"POST"}),y()}catch{o("Failed to retry DLQ webhook")}},B=async t=>{if(window.confirm("Delete this DLQ entry?")){o(null);try{await r(`/admin/webhooks/dlq/${encodeURIComponent(t)}`,{method:"DELETE"}),y()}catch{o("Failed to delete DLQ entry")}}};return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Webhooks"})}),e.jsx(a.ErrorBanner,{message:w}),e.jsx(a.ErrorBanner,{message:A}),e.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"1rem",borderBottom:"1px solid var(--cedros-admin-border, #e0e0e0)"},children:["active","dlq"].map(t=>e.jsx("button",{type:"button",onClick:()=>$(t),style:{padding:"0.5rem 1rem",fontSize:"0.85rem",fontWeight:l===t?600:400,background:"none",border:"none",borderBottom:l===t?"2px solid var(--cedros-admin-primary, #000)":"2px solid transparent",cursor:"pointer",color:l===t?"var(--cedros-admin-text, #333)":"var(--cedros-admin-text-muted, #888)",marginBottom:"-1px"},children:t==="active"?`Active Webhooks${h>0?` (${h})`:""}`:`Dead Letter Queue${v>0?` (${v})`:""}`},t))}),l==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",value:m,onChange:t=>{L(t.target.value)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"success",children:"Success"})]}),e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:[h," webhook",h!==1?"s":""]})]}),W?e.jsxs("div",{className:"cedros-admin__loading",children:[a.Icons.loading," Loading webhooks..."]}):p.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No webhooks 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:"URL"}),e.jsx("th",{children:"Event Type"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Attempts"}),e.jsx("th",{children:"Last Error"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:p.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{maxWidth:"200px"},children:e.jsx("span",{title:t.url,style:{fontSize:"0.8rem",fontFamily:"monospace"},children:j(t.url,40)})}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.eventType}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${Q(t.status)}`,children:t.status})}),e.jsxs("td",{style:{fontSize:"0.85rem"},children:[t.attempts,"/",t.maxAttempts]}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"180px",color:"var(--cedros-admin-text-muted, #888)"},children:t.lastError?e.jsx("span",{title:t.lastError,children:j(t.lastError,40)}):"—"}),e.jsx("td",{style:{fontSize:"0.8rem"},children:a.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>z(t.id),children:"Retry"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>R(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]}),l==="dlq"&&e.jsx(e.Fragment,{children:N?e.jsxs("div",{className:"cedros-admin__loading",children:[a.Icons.loading," Loading DLQ..."]}):g.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"Dead Letter Queue is empty."}):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:"URL"}),e.jsx("th",{children:"Event Type"}),e.jsx("th",{children:"Attempts"}),e.jsx("th",{children:"Final Error"}),e.jsx("th",{children:"Moved to DLQ"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:g.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{maxWidth:"200px"},children:e.jsx("span",{title:t.url,style:{fontSize:"0.8rem",fontFamily:"monospace"},children:j(t.url,40)})}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.eventType}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.totalAttempts}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"200px",color:"var(--cedros-admin-text-muted, #888)"},children:e.jsx("span",{title:t.finalError,children:j(t.finalError,40)})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:a.formatDateTime(t.movedToDlqAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>I(t.id),children:"Retry"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>B(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})})]})}exports.WebhooksSection=P;