@cedros/login-react 0.0.13 → 0.0.14

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 (185) hide show
  1. package/dist/AdminDepositList-CyT4VBH8.js +311 -0
  2. package/dist/AdminDepositList-CyT4VBH8.js.map +1 -0
  3. package/dist/AdminDepositList-b2AXtLg0.cjs +1 -0
  4. package/dist/AdminDepositList-b2AXtLg0.cjs.map +1 -0
  5. package/dist/{AdminWithdrawalHistory-BGjfrIe3.js → AdminWithdrawalHistory-Cud-yuWy.js} +295 -283
  6. package/dist/AdminWithdrawalHistory-Cud-yuWy.js.map +1 -0
  7. package/dist/AdminWithdrawalHistory-DL9zbu2b.cjs +1 -0
  8. package/dist/AdminWithdrawalHistory-DL9zbu2b.cjs.map +1 -0
  9. package/dist/{AuthenticationSettings-5Vi7Ib_A.cjs → AuthenticationSettings-D739nNul.cjs} +1 -1
  10. package/dist/{AuthenticationSettings-5Vi7Ib_A.cjs.map → AuthenticationSettings-D739nNul.cjs.map} +1 -1
  11. package/dist/AuthenticationSettings-DtLoxQ2z.cjs +1 -0
  12. package/dist/{AuthenticationSettings-BPAh1my6.cjs.map → AuthenticationSettings-DtLoxQ2z.cjs.map} +1 -1
  13. package/dist/{AuthenticationSettings-CJg8CJY9.js → AuthenticationSettings-Dx3JCI3m.js} +1 -1
  14. package/dist/{AuthenticationSettings-CJg8CJY9.js.map → AuthenticationSettings-Dx3JCI3m.js.map} +1 -1
  15. package/dist/{AuthenticationSettings-CR_i6TTS.js → AuthenticationSettings-vowmQPXz.js} +170 -140
  16. package/dist/{AuthenticationSettings-CR_i6TTS.js.map → AuthenticationSettings-vowmQPXz.js.map} +1 -1
  17. package/dist/{AutosaveStatus-CYkC2aI_.cjs → AutosaveStatus-CCrZszKA.cjs} +1 -1
  18. package/dist/{AutosaveStatus-CYkC2aI_.cjs.map → AutosaveStatus-CCrZszKA.cjs.map} +1 -1
  19. package/dist/{AutosaveStatus-N4uNS6-2.js → AutosaveStatus-Ciyt350A.js} +1 -1
  20. package/dist/{AutosaveStatus-N4uNS6-2.js.map → AutosaveStatus-Ciyt350A.js.map} +1 -1
  21. package/dist/{CreditSystemSettings-CIf_SfJq.js → CreditSystemSettings-BQ3h4CyM.js} +1 -1
  22. package/dist/{CreditSystemSettings-CIf_SfJq.js.map → CreditSystemSettings-BQ3h4CyM.js.map} +1 -1
  23. package/dist/{CreditSystemSettings-BnAOK_tT.cjs → CreditSystemSettings-C6dUsu72.cjs} +1 -1
  24. package/dist/{CreditSystemSettings-BnAOK_tT.cjs.map → CreditSystemSettings-C6dUsu72.cjs.map} +1 -1
  25. package/dist/{CreditSystemSettings-Ck5WIMp3.cjs → CreditSystemSettings-CBot8EPW.cjs} +1 -1
  26. package/dist/{CreditSystemSettings-Ck5WIMp3.cjs.map → CreditSystemSettings-CBot8EPW.cjs.map} +1 -1
  27. package/dist/{CreditSystemSettings-CePYGgev.js → CreditSystemSettings-bVuNLsqp.js} +1 -1
  28. package/dist/{CreditSystemSettings-CePYGgev.js.map → CreditSystemSettings-bVuNLsqp.js.map} +1 -1
  29. package/dist/DepositsSection-BkKUS4vk.cjs +1 -0
  30. package/dist/DepositsSection-BkKUS4vk.cjs.map +1 -0
  31. package/dist/{DepositsSection-DA89uR9A.js → DepositsSection-DD9MKUFt.js} +20 -14
  32. package/dist/DepositsSection-DD9MKUFt.js.map +1 -0
  33. package/dist/EmailRegisterForm-Pvm3I8GP.cjs +1 -0
  34. package/dist/{EmailRegisterForm-CxktR-4J.cjs.map → EmailRegisterForm-Pvm3I8GP.cjs.map} +1 -1
  35. package/dist/{EmailRegisterForm-BrDL3BZy.js → EmailRegisterForm-nI0BOIxR.js} +2 -2
  36. package/dist/{EmailRegisterForm-BrDL3BZy.js.map → EmailRegisterForm-nI0BOIxR.js.map} +1 -1
  37. package/dist/{EmailSettings-DZywTTRq.cjs → EmailSettings-B9qwPSiM.cjs} +1 -1
  38. package/dist/{EmailSettings-DZywTTRq.cjs.map → EmailSettings-B9qwPSiM.cjs.map} +1 -1
  39. package/dist/{EmailSettings-DbMDfVaM.js → EmailSettings-CCA8dNCi.js} +1 -1
  40. package/dist/{EmailSettings-DbMDfVaM.js.map → EmailSettings-CCA8dNCi.js.map} +1 -1
  41. package/dist/{EmailSettings-B8xwgd6_.cjs → EmailSettings-RbgAq9FB.cjs} +1 -1
  42. package/dist/{EmailSettings-B8xwgd6_.cjs.map → EmailSettings-RbgAq9FB.cjs.map} +1 -1
  43. package/dist/{EmailSettings-Bna7Z53E.js → EmailSettings-mxlKNcPl.js} +1 -1
  44. package/dist/{EmailSettings-Bna7Z53E.js.map → EmailSettings-mxlKNcPl.js.map} +1 -1
  45. package/dist/{EmbeddedWalletSettings-DivEPn39.cjs → EmbeddedWalletSettings-B4h-8rxB.cjs} +1 -1
  46. package/dist/{EmbeddedWalletSettings-DivEPn39.cjs.map → EmbeddedWalletSettings-B4h-8rxB.cjs.map} +1 -1
  47. package/dist/{EmbeddedWalletSettings-BEztqO19.js → EmbeddedWalletSettings-BInZvFZf.js} +1 -1
  48. package/dist/{EmbeddedWalletSettings-BEztqO19.js.map → EmbeddedWalletSettings-BInZvFZf.js.map} +1 -1
  49. package/dist/{EmbeddedWalletSettings-ANbhj3Lt.js → EmbeddedWalletSettings-CXlZFFDw.js} +1 -1
  50. package/dist/{EmbeddedWalletSettings-ANbhj3Lt.js.map → EmbeddedWalletSettings-CXlZFFDw.js.map} +1 -1
  51. package/dist/{EmbeddedWalletSettings-D6M7pwgk.cjs → EmbeddedWalletSettings-D5JXae1L.cjs} +1 -1
  52. package/dist/{EmbeddedWalletSettings-D6M7pwgk.cjs.map → EmbeddedWalletSettings-D5JXae1L.cjs.map} +1 -1
  53. package/dist/{GoogleLoginButton-B3uRMJ_n.js → GoogleLoginButton-CXwp4LsQ.js} +1 -1
  54. package/dist/{GoogleLoginButton-B3uRMJ_n.js.map → GoogleLoginButton-CXwp4LsQ.js.map} +1 -1
  55. package/dist/GoogleLoginButton-zS_69-KV.cjs +1 -0
  56. package/dist/{GoogleLoginButton-BydKswn4.cjs.map → GoogleLoginButton-zS_69-KV.cjs.map} +1 -1
  57. package/dist/PermissionsSection-BPbE-hNx.cjs +1 -0
  58. package/dist/{PermissionsSection-CKXXDfqi.cjs.map → PermissionsSection-BPbE-hNx.cjs.map} +1 -1
  59. package/dist/{PermissionsSection-BGaj_sI7.js → PermissionsSection-CighC1p6.js} +3 -3
  60. package/dist/{PermissionsSection-BGaj_sI7.js.map → PermissionsSection-CighC1p6.js.map} +1 -1
  61. package/dist/{ServerSettings-B2RKhJtZ.js → ServerSettings-BE8fsE5k.js} +1 -1
  62. package/dist/{ServerSettings-B2RKhJtZ.js.map → ServerSettings-BE8fsE5k.js.map} +1 -1
  63. package/dist/{ServerSettings-BZXlm1BX.cjs → ServerSettings-CYTlQ2xy.cjs} +1 -1
  64. package/dist/{ServerSettings-BZXlm1BX.cjs.map → ServerSettings-CYTlQ2xy.cjs.map} +1 -1
  65. package/dist/{ServerSettings-DZUKo6By.cjs → ServerSettings-DFs9jQ3f.cjs} +1 -1
  66. package/dist/{ServerSettings-DZUKo6By.cjs.map → ServerSettings-DFs9jQ3f.cjs.map} +1 -1
  67. package/dist/{ServerSettings-Bqm4-bt2.js → ServerSettings-pSmWDC1d.js} +1 -1
  68. package/dist/{ServerSettings-Bqm4-bt2.js.map → ServerSettings-pSmWDC1d.js.map} +1 -1
  69. package/dist/{SettingsPageLayout-DpgNEkuu.js → SettingsPageLayout--GZ_iHLc.js} +1 -1
  70. package/dist/{SettingsPageLayout-DpgNEkuu.js.map → SettingsPageLayout--GZ_iHLc.js.map} +1 -1
  71. package/dist/{SettingsPageLayout-COSYLMu7.cjs → SettingsPageLayout-j5lMjEID.cjs} +1 -1
  72. package/dist/{SettingsPageLayout-COSYLMu7.cjs.map → SettingsPageLayout-j5lMjEID.cjs.map} +1 -1
  73. package/dist/SolanaLoginButton-BjOxpE1C.cjs +1 -0
  74. package/dist/{SolanaLoginButton-fAW7kRUu.cjs.map → SolanaLoginButton-BjOxpE1C.cjs.map} +1 -1
  75. package/dist/{SolanaLoginButton-C_u9OppS.js → SolanaLoginButton-P22QjBaO.js} +1 -1
  76. package/dist/{SolanaLoginButton-C_u9OppS.js.map → SolanaLoginButton-P22QjBaO.js.map} +1 -1
  77. package/dist/{TeamSection-CvrCoa9D.js → TeamSection-BIECkp7g.js} +2 -2
  78. package/dist/{TeamSection-CvrCoa9D.js.map → TeamSection-BIECkp7g.js.map} +1 -1
  79. package/dist/{TeamSection-DlUD5kp5.cjs → TeamSection-BOH9pv_E.cjs} +1 -1
  80. package/dist/{TeamSection-DlUD5kp5.cjs.map → TeamSection-BOH9pv_E.cjs.map} +1 -1
  81. package/dist/UsersSection-e6q7FHzx.cjs +1 -0
  82. package/dist/UsersSection-e6q7FHzx.cjs.map +1 -0
  83. package/dist/UsersSection-t-zm0jZW.js +33 -0
  84. package/dist/UsersSection-t-zm0jZW.js.map +1 -0
  85. package/dist/{WebhookSettings-bUg2u_p0.js → WebhookSettings-Bb70MbFj.js} +1 -1
  86. package/dist/{WebhookSettings-bUg2u_p0.js.map → WebhookSettings-Bb70MbFj.js.map} +1 -1
  87. package/dist/{WebhookSettings-BWl_wsvg.cjs → WebhookSettings-C-gvNAW1.cjs} +1 -1
  88. package/dist/{WebhookSettings-BWl_wsvg.cjs.map → WebhookSettings-C-gvNAW1.cjs.map} +1 -1
  89. package/dist/{WebhookSettings-DXNH5bal.cjs → WebhookSettings-CGyDKjrm.cjs} +1 -1
  90. package/dist/{WebhookSettings-DXNH5bal.cjs.map → WebhookSettings-CGyDKjrm.cjs.map} +1 -1
  91. package/dist/{WebhookSettings-BT5q6AZ8.js → WebhookSettings-kIstSjZi.js} +1 -1
  92. package/dist/{WebhookSettings-BT5q6AZ8.js.map → WebhookSettings-kIstSjZi.js.map} +1 -1
  93. package/dist/WithdrawalsSection-sljIyeaz.cjs +1 -0
  94. package/dist/WithdrawalsSection-sljIyeaz.cjs.map +1 -0
  95. package/dist/WithdrawalsSection-yRDTVFsb.js +27 -0
  96. package/dist/WithdrawalsSection-yRDTVFsb.js.map +1 -0
  97. package/dist/admin-only.cjs +1 -1
  98. package/dist/admin-only.js +1 -1
  99. package/dist/email-only.cjs +1 -1
  100. package/dist/email-only.d.ts +13 -2
  101. package/dist/email-only.js +3 -3
  102. package/dist/google-only.cjs +1 -1
  103. package/dist/google-only.d.ts +13 -2
  104. package/dist/google-only.js +3 -3
  105. package/dist/index.cjs +12 -12
  106. package/dist/index.cjs.map +1 -1
  107. package/dist/index.d.ts +31 -8
  108. package/dist/index.js +1066 -1092
  109. package/dist/index.js.map +1 -1
  110. package/dist/{plugin-BtYBW6JY.cjs → plugin-8_dpq7tC.cjs} +1 -1
  111. package/dist/{plugin-BtYBW6JY.cjs.map → plugin-8_dpq7tC.cjs.map} +1 -1
  112. package/dist/{plugin-5qRh-YhX.js → plugin-D1NdppqC.js} +1 -1
  113. package/dist/{plugin-5qRh-YhX.js.map → plugin-D1NdppqC.js.map} +1 -1
  114. package/dist/{shamir-AeLLfw0p.cjs → shamir-4DyQMJCk.cjs} +1 -1
  115. package/dist/{shamir-AeLLfw0p.cjs.map → shamir-4DyQMJCk.cjs.map} +1 -1
  116. package/dist/{shamir-B0wConeK.js → shamir-L-s-Tp1Z.js} +1 -1
  117. package/dist/{shamir-B0wConeK.js.map → shamir-L-s-Tp1Z.js.map} +1 -1
  118. package/dist/silentWalletEnroll-BgTb4H5I.cjs +1 -0
  119. package/dist/{silentWalletEnroll-B8pgdKZO.cjs.map → silentWalletEnroll-BgTb4H5I.cjs.map} +1 -1
  120. package/dist/{silentWalletEnroll-DR2kPw7W.js → silentWalletEnroll-DWt6Pr3B.js} +3 -3
  121. package/dist/{silentWalletEnroll-DR2kPw7W.js.map → silentWalletEnroll-DWt6Pr3B.js.map} +1 -1
  122. package/dist/solana-only.cjs +1 -1
  123. package/dist/solana-only.d.ts +13 -2
  124. package/dist/solana-only.js +3 -3
  125. package/dist/{useAdminDeposits-BDY5KJ0-.js → useAdminDeposits-BTSyeAfg.js} +1 -1
  126. package/dist/{useAdminDeposits-BDY5KJ0-.js.map → useAdminDeposits-BTSyeAfg.js.map} +1 -1
  127. package/dist/useAdminDeposits-BkkCwHWp.cjs +1 -0
  128. package/dist/{useAdminDeposits-Dvx3_UUE.cjs.map → useAdminDeposits-BkkCwHWp.cjs.map} +1 -1
  129. package/dist/{useAuth-Bge6KaWN.js → useAuth-C3dpk0po.js} +597 -561
  130. package/dist/useAuth-C3dpk0po.js.map +1 -0
  131. package/dist/useAuth-D3Pk_H3z.cjs +1 -0
  132. package/dist/useAuth-D3Pk_H3z.cjs.map +1 -0
  133. package/dist/useCedrosLogin-C9MrcZvh.cjs +1 -0
  134. package/dist/useCedrosLogin-C9MrcZvh.cjs.map +1 -0
  135. package/dist/{apiClient-B2JxVPlH.js → useCedrosLogin-_94MmGGq.js} +29 -29
  136. package/dist/useCedrosLogin-_94MmGGq.js.map +1 -0
  137. package/dist/{useOrgs-Be3KH4ib.js → useOrgs-C3pzMA9h.js} +1 -1
  138. package/dist/{useOrgs-Be3KH4ib.js.map → useOrgs-C3pzMA9h.js.map} +1 -1
  139. package/dist/useOrgs-DDVRCaVi.cjs +1 -0
  140. package/dist/{useOrgs-CVbacmaQ.cjs.map → useOrgs-DDVRCaVi.cjs.map} +1 -1
  141. package/dist/{useSystemSettings-DN5YqfNq.js → useSystemSettings-DBlAMjFi.js} +1 -1
  142. package/dist/{useSystemSettings-DN5YqfNq.js.map → useSystemSettings-DBlAMjFi.js.map} +1 -1
  143. package/dist/useSystemSettings-DRrreszl.cjs +1 -0
  144. package/dist/{useSystemSettings-D9Cr7ZTl.cjs.map → useSystemSettings-DRrreszl.cjs.map} +1 -1
  145. package/dist/useUsersStatsSummary-8qY7iP4G.cjs +1 -0
  146. package/dist/useUsersStatsSummary-8qY7iP4G.cjs.map +1 -0
  147. package/dist/{AdminUserDetail-DHFDzY8B.js → useUsersStatsSummary-NjEFvWuz.js} +431 -380
  148. package/dist/useUsersStatsSummary-NjEFvWuz.js.map +1 -0
  149. package/package.json +1 -1
  150. package/dist/AdminDepositList-Cx0xRwES.js +0 -305
  151. package/dist/AdminDepositList-Cx0xRwES.js.map +0 -1
  152. package/dist/AdminDepositList-UEcyRZkA.cjs +0 -1
  153. package/dist/AdminDepositList-UEcyRZkA.cjs.map +0 -1
  154. package/dist/AdminUserDetail-BzEIdNJh.cjs +0 -1
  155. package/dist/AdminUserDetail-BzEIdNJh.cjs.map +0 -1
  156. package/dist/AdminUserDetail-DHFDzY8B.js.map +0 -1
  157. package/dist/AdminWithdrawalHistory-0yxtMh6q.cjs +0 -1
  158. package/dist/AdminWithdrawalHistory-0yxtMh6q.cjs.map +0 -1
  159. package/dist/AdminWithdrawalHistory-BGjfrIe3.js.map +0 -1
  160. package/dist/AuthenticationSettings-BPAh1my6.cjs +0 -1
  161. package/dist/DepositsSection-DA89uR9A.js.map +0 -1
  162. package/dist/DepositsSection-i6XdhLNs.cjs +0 -1
  163. package/dist/DepositsSection-i6XdhLNs.cjs.map +0 -1
  164. package/dist/EmailRegisterForm-CxktR-4J.cjs +0 -1
  165. package/dist/GoogleLoginButton-BydKswn4.cjs +0 -1
  166. package/dist/PermissionsSection-CKXXDfqi.cjs +0 -1
  167. package/dist/SolanaLoginButton-fAW7kRUu.cjs +0 -1
  168. package/dist/UsersSection-C2U8Tb7V.cjs +0 -1
  169. package/dist/UsersSection-C2U8Tb7V.cjs.map +0 -1
  170. package/dist/UsersSection-Dbh9PTSA.js +0 -83
  171. package/dist/UsersSection-Dbh9PTSA.js.map +0 -1
  172. package/dist/WithdrawalsSection-BL_LOUq8.cjs +0 -1
  173. package/dist/WithdrawalsSection-BL_LOUq8.cjs.map +0 -1
  174. package/dist/WithdrawalsSection-CN-lLnqX.js +0 -20
  175. package/dist/WithdrawalsSection-CN-lLnqX.js.map +0 -1
  176. package/dist/apiClient-B2JxVPlH.js.map +0 -1
  177. package/dist/apiClient-CTTKhsYb.cjs +0 -1
  178. package/dist/apiClient-CTTKhsYb.cjs.map +0 -1
  179. package/dist/silentWalletEnroll-B8pgdKZO.cjs +0 -1
  180. package/dist/useAdminDeposits-Dvx3_UUE.cjs +0 -1
  181. package/dist/useAuth-Bge6KaWN.js.map +0 -1
  182. package/dist/useAuth-DhIDTLRd.cjs +0 -1
  183. package/dist/useAuth-DhIDTLRd.cjs.map +0 -1
  184. package/dist/useOrgs-CVbacmaQ.cjs +0 -1
  185. package/dist/useSystemSettings-D9Cr7ZTl.cjs +0 -1
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./useAuth-DhIDTLRd.cjs"),_=require("./apiClient-CTTKhsYb.cjs"),e=require("react/jsx-runtime"),l=require("react"),V=require("./LoadingSpinner-d6sSxgQN.cjs"),Rs=require("./sanitization-Bo_tn-L2.cjs"),K=require("./EmailRegisterForm-CxktR-4J.cjs"),Pe=require("./validation-BuGQrA-K.cjs"),G=require("./ErrorMessage-CHbYbVi2.cjs"),Bs=require("./GoogleLoginButton-BydKswn4.cjs"),Se=require("./SolanaLoginButton-fAW7kRUu.cjs"),te=require("./PermissionsSection-CKXXDfqi.cjs"),Ds=require("./useSystemSettings-D9Cr7ZTl.cjs"),Is=require("./useOrgs-CVbacmaQ.cjs"),Ee=require("./AdminUserDetail-BzEIdNJh.cjs"),We=require("./AdminDepositList-UEcyRZkA.cjs"),fe=require("./AdminWithdrawalHistory-0yxtMh6q.cjs"),Ft=require("./StatsBar-DTUZCwDD.cjs"),ge=require("./plugin-BtYBW6JY.cjs"),Ut=require("./AuthenticationSettings-BPAh1my6.cjs"),Wt=require("./EmbeddedWalletSettings-DivEPn39.cjs"),rs=require("./AutosaveStatus-CYkC2aI_.cjs"),Fs=require("./CreditSystemSettings-Ck5WIMp3.cjs"),Ot=require("./ServerSettings-DZUKo6By.cjs"),ie=require("./shamir-AeLLfw0p.cjs"),Hr=require("./useAdminDeposits-Dvx3_UUE.cjs"),qt=require("./SettingsPageLayout-COSYLMu7.cjs"),Qr=require("./EmailSettings-B8xwgd6_.cjs"),Kr=require("./WebhookSettings-BWl_wsvg.cjs");function Oe(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function zt(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(o=>typeof o=="string"):t.every(o=>Number.isSafeInteger(o)):!1}function $r(s){if(typeof s!="function")throw new Error("function expected");return!0}function qe(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function je(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function ze(s){if(!Array.isArray(s))throw new Error("array expected")}function Ve(s,t){if(!zt(!0,t))throw new Error(`${s}: array of strings expected`)}function Vt(s,t){if(!zt(!1,t))throw new Error(`${s}: array of numbers expected`)}function Gr(...s){const t=n=>n,o=(n,c)=>i=>n(c(i)),a=s.map(n=>n.encode).reduceRight(o,t),r=s.map(n=>n.decode).reduce(o,t);return{encode:a,decode:r}}function Yr(s){const t=typeof s=="string"?s.split(""):s,o=t.length;Ve("alphabet",t);const a=new Map(t.map((r,n)=>[r,n]));return{encode:r=>(ze(r),r.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=o)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${s}`);return t[n]})),decode:r=>(ze(r),r.map(n=>{qe("alphabet.decode",n);const c=a.get(n);if(c===void 0)throw new Error(`Unknown letter: "${n}". Allowed: ${s}`);return c}))}}function Jr(s=""){return qe("join",s),{encode:t=>(Ve("join.decode",t),t.join(s)),decode:t=>(qe("join.decode",t),t.split(s))}}function Xr(s,t="="){return je(s),qe("padding",t),{encode(o){for(Ve("padding.encode",o);o.length*s%8;)o.push(t);return o},decode(o){Ve("padding.decode",o);let a=o.length;if(a*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;a>0&&o[a-1]===t;a--)if((a-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return o.slice(0,a)}}}function Ts(s,t,o){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(o<2)throw new Error(`convertRadix: invalid to=${o}, base cannot be less than 2`);if(ze(s),!s.length)return[];let a=0;const r=[],n=Array.from(s,i=>{if(je(i),i<0||i>=t)throw new Error(`invalid integer: ${i}`);return i}),c=n.length;for(;;){let i=0,d=!0;for(let u=a;u<c;u++){const p=n[u],f=t*i,h=f+p;if(!Number.isSafeInteger(h)||f/t!==i||h-p!==f)throw new Error("convertRadix: carry overflow");const w=h/o;i=h%o;const g=Math.floor(w);if(n[u]=g,!Number.isSafeInteger(g)||g*o+i!==h)throw new Error("convertRadix: carry overflow");if(d)g?d=!1:a=u;else continue}if(r.push(i),d)break}for(let i=0;i<s.length-1&&s[i]===0;i++)r.push(0);return r.reverse()}const Ht=(s,t)=>t===0?s:Ht(t,s%t),He=(s,t)=>s+(t-Ht(s,t)),os=(()=>{let s=[];for(let t=0;t<40;t++)s.push(2**t);return s})();function _s(s,t,o,a){if(ze(s),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(o<=0||o>32)throw new Error(`convertRadix2: wrong to=${o}`);if(He(t,o)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${o} carryBits=${He(t,o)}`);let r=0,n=0;const c=os[t],i=os[o]-1,d=[];for(const u of s){if(je(u),u>=c)throw new Error(`convertRadix2: invalid data word=${u} from=${t}`);if(r=r<<t|u,n+t>32)throw new Error(`convertRadix2: carry overflow pos=${n} from=${t}`);for(n+=t;n>=o;n-=o)d.push((r>>n-o&i)>>>0);const p=os[n];if(p===void 0)throw new Error("invalid carry");r&=p-1}if(r=r<<o-n&i,!a&&n>=t)throw new Error("Excess padding");if(!a&&r>0)throw new Error(`Non-zero padding: ${r}`);return a&&n>0&&d.push(r>>>0),d}function Zr(s){je(s);const t=2**8;return{encode:o=>{if(!Oe(o))throw new Error("radix.encode input should be Uint8Array");return Ts(Array.from(o),t,s)},decode:o=>(Vt("radix.decode",o),Uint8Array.from(Ts(o,s,t)))}}function eo(s,t=!1){if(je(s),s<=0||s>32)throw new Error("radix2: bits should be in (0..32]");if(He(8,s)>32||He(s,8)>32)throw new Error("radix2: carry overflow");return{encode:o=>{if(!Oe(o))throw new Error("radix2.encode input should be Uint8Array");return _s(Array.from(o),8,s,!t)},decode:o=>(Vt("radix2.decode",o),Uint8Array.from(_s(o,s,8,t)))}}function so(s,t){return je(s),$r(t),{encode(o){if(!Oe(o))throw new Error("checksum.encode: input should be Uint8Array");const a=t(o).slice(0,s),r=new Uint8Array(o.length+s);return r.set(o),r.set(a,o.length),r},decode(o){if(!Oe(o))throw new Error("checksum.decode: input should be Uint8Array");const a=o.slice(0,-s),r=o.slice(-s),n=t(a).slice(0,s);for(let c=0;c<s;c++)if(n[c]!==r[c])throw new Error("Invalid checksum");return a}}}const Be={alphabet:Yr,chain:Gr,checksum:so,convertRadix:Ts,convertRadix2:_s,radix:Zr,radix2:eo,join:Jr,padding:Xr};const to=s=>s[0]==="あいこくしん";function ro(s){if(typeof s!="string")throw new TypeError("invalid mnemonic type: "+typeof s);return s.normalize("NFKD")}function oo(s){const t=ro(s),o=t.split(" ");if(![12,15,18,21,24].includes(o.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:o}}function Qt(s){ie.abytes(s,16,20,24,28,32)}const no=s=>{const t=8-s.length/4;return new Uint8Array([ie.sha256(s)[0]>>t<<t])};function Kt(s){if(!Array.isArray(s)||s.length!==2048||typeof s[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return s.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),Be.chain(Be.checksum(1,no),Be.radix2(11,!0),Be.alphabet(s))}function Us(s,t){const{words:o}=oo(s),a=Kt(t).decode(o);return Qt(a),a}function $t(s,t){return Qt(s),Kt(t).encode(s).join(to(t)?" ":" ")}function Ws(s,t){try{Us(s,t)}catch{return!1}return!0}const he=`abandon
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./useAuth-D3Pk_H3z.cjs"),M=require("./useCedrosLogin-C9MrcZvh.cjs"),e=require("react/jsx-runtime"),l=require("react"),V=require("./LoadingSpinner-d6sSxgQN.cjs"),Rs=require("./sanitization-Bo_tn-L2.cjs"),K=require("./EmailRegisterForm-Pvm3I8GP.cjs"),Pe=require("./validation-BuGQrA-K.cjs"),Y=require("./ErrorMessage-CHbYbVi2.cjs"),Bs=require("./GoogleLoginButton-zS_69-KV.cjs"),Se=require("./SolanaLoginButton-BjOxpE1C.cjs"),te=require("./PermissionsSection-BPbE-hNx.cjs"),It=require("./useSystemSettings-DRrreszl.cjs"),Ds=require("./useOrgs-DDVRCaVi.cjs"),We=require("./AdminDepositList-b2AXtLg0.cjs"),fe=require("./AdminWithdrawalHistory-DL9zbu2b.cjs"),Ee=require("./useUsersStatsSummary-8qY7iP4G.cjs"),Ft=require("./StatsBar-DTUZCwDD.cjs"),ge=require("./plugin-8_dpq7tC.cjs"),Ut=require("./AuthenticationSettings-DtLoxQ2z.cjs"),Wt=require("./EmbeddedWalletSettings-B4h-8rxB.cjs"),rs=require("./AutosaveStatus-CCrZszKA.cjs"),Is=require("./CreditSystemSettings-CBot8EPW.cjs"),Ot=require("./ServerSettings-DFs9jQ3f.cjs"),ie=require("./shamir-4DyQMJCk.cjs"),Hr=require("./useAdminDeposits-BkkCwHWp.cjs"),qt=require("./SettingsPageLayout-j5lMjEID.cjs"),Qr=require("./EmailSettings-RbgAq9FB.cjs"),Kr=require("./WebhookSettings-C-gvNAW1.cjs");function Oe(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function zt(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(o=>typeof o=="string"):t.every(o=>Number.isSafeInteger(o)):!1}function Gr(s){if(typeof s!="function")throw new Error("function expected");return!0}function qe(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function je(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function ze(s){if(!Array.isArray(s))throw new Error("array expected")}function Ve(s,t){if(!zt(!0,t))throw new Error(`${s}: array of strings expected`)}function Vt(s,t){if(!zt(!1,t))throw new Error(`${s}: array of numbers expected`)}function Yr(...s){const t=n=>n,o=(n,c)=>i=>n(c(i)),a=s.map(n=>n.encode).reduceRight(o,t),r=s.map(n=>n.decode).reduce(o,t);return{encode:a,decode:r}}function $r(s){const t=typeof s=="string"?s.split(""):s,o=t.length;Ve("alphabet",t);const a=new Map(t.map((r,n)=>[r,n]));return{encode:r=>(ze(r),r.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=o)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${s}`);return t[n]})),decode:r=>(ze(r),r.map(n=>{qe("alphabet.decode",n);const c=a.get(n);if(c===void 0)throw new Error(`Unknown letter: "${n}". Allowed: ${s}`);return c}))}}function Jr(s=""){return qe("join",s),{encode:t=>(Ve("join.decode",t),t.join(s)),decode:t=>(qe("join.decode",t),t.split(s))}}function Xr(s,t="="){return je(s),qe("padding",t),{encode(o){for(Ve("padding.encode",o);o.length*s%8;)o.push(t);return o},decode(o){Ve("padding.decode",o);let a=o.length;if(a*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;a>0&&o[a-1]===t;a--)if((a-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return o.slice(0,a)}}}function Ts(s,t,o){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(o<2)throw new Error(`convertRadix: invalid to=${o}, base cannot be less than 2`);if(ze(s),!s.length)return[];let a=0;const r=[],n=Array.from(s,i=>{if(je(i),i<0||i>=t)throw new Error(`invalid integer: ${i}`);return i}),c=n.length;for(;;){let i=0,d=!0;for(let u=a;u<c;u++){const p=n[u],f=t*i,h=f+p;if(!Number.isSafeInteger(h)||f/t!==i||h-p!==f)throw new Error("convertRadix: carry overflow");const w=h/o;i=h%o;const g=Math.floor(w);if(n[u]=g,!Number.isSafeInteger(g)||g*o+i!==h)throw new Error("convertRadix: carry overflow");if(d)g?d=!1:a=u;else continue}if(r.push(i),d)break}for(let i=0;i<s.length-1&&s[i]===0;i++)r.push(0);return r.reverse()}const Ht=(s,t)=>t===0?s:Ht(t,s%t),He=(s,t)=>s+(t-Ht(s,t)),os=(()=>{let s=[];for(let t=0;t<40;t++)s.push(2**t);return s})();function Ms(s,t,o,a){if(ze(s),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(o<=0||o>32)throw new Error(`convertRadix2: wrong to=${o}`);if(He(t,o)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${o} carryBits=${He(t,o)}`);let r=0,n=0;const c=os[t],i=os[o]-1,d=[];for(const u of s){if(je(u),u>=c)throw new Error(`convertRadix2: invalid data word=${u} from=${t}`);if(r=r<<t|u,n+t>32)throw new Error(`convertRadix2: carry overflow pos=${n} from=${t}`);for(n+=t;n>=o;n-=o)d.push((r>>n-o&i)>>>0);const p=os[n];if(p===void 0)throw new Error("invalid carry");r&=p-1}if(r=r<<o-n&i,!a&&n>=t)throw new Error("Excess padding");if(!a&&r>0)throw new Error(`Non-zero padding: ${r}`);return a&&n>0&&d.push(r>>>0),d}function Zr(s){je(s);const t=2**8;return{encode:o=>{if(!Oe(o))throw new Error("radix.encode input should be Uint8Array");return Ts(Array.from(o),t,s)},decode:o=>(Vt("radix.decode",o),Uint8Array.from(Ts(o,s,t)))}}function eo(s,t=!1){if(je(s),s<=0||s>32)throw new Error("radix2: bits should be in (0..32]");if(He(8,s)>32||He(s,8)>32)throw new Error("radix2: carry overflow");return{encode:o=>{if(!Oe(o))throw new Error("radix2.encode input should be Uint8Array");return Ms(Array.from(o),8,s,!t)},decode:o=>(Vt("radix2.decode",o),Uint8Array.from(Ms(o,s,8,t)))}}function so(s,t){return je(s),Gr(t),{encode(o){if(!Oe(o))throw new Error("checksum.encode: input should be Uint8Array");const a=t(o).slice(0,s),r=new Uint8Array(o.length+s);return r.set(o),r.set(a,o.length),r},decode(o){if(!Oe(o))throw new Error("checksum.decode: input should be Uint8Array");const a=o.slice(0,-s),r=o.slice(-s),n=t(a).slice(0,s);for(let c=0;c<s;c++)if(n[c]!==r[c])throw new Error("Invalid checksum");return a}}}const Be={alphabet:$r,chain:Yr,checksum:so,convertRadix:Ts,convertRadix2:Ms,radix:Zr,radix2:eo,join:Jr,padding:Xr};const to=s=>s[0]==="あいこくしん";function ro(s){if(typeof s!="string")throw new TypeError("invalid mnemonic type: "+typeof s);return s.normalize("NFKD")}function oo(s){const t=ro(s),o=t.split(" ");if(![12,15,18,21,24].includes(o.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:o}}function Qt(s){ie.abytes(s,16,20,24,28,32)}const no=s=>{const t=8-s.length/4;return new Uint8Array([ie.sha256(s)[0]>>t<<t])};function Kt(s){if(!Array.isArray(s)||s.length!==2048||typeof s[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return s.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),Be.chain(Be.checksum(1,no),Be.radix2(11,!0),Be.alphabet(s))}function Fs(s,t){const{words:o}=oo(s),a=Kt(t).decode(o);return Qt(a),a}function Gt(s,t){return Qt(s),Kt(t).encode(s).join(to(t)?" ":" ")}function Us(s,t){try{Fs(s,t)}catch{return!1}return!0}const he=`abandon
2
2
  ability
3
3
  able
4
4
  about
@@ -2046,16 +2046,16 @@ zebra
2046
2046
  zero
2047
2047
  zone
2048
2048
  zoo`.split(`
2049
- `),oe=12;function ao(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const o=$t(s,he).split(" ");if(o.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${o.length}`);return o}function io(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ws(t,he))throw new Error("Invalid recovery phrase: checksum mismatch");const o=Us(t,he);if(o.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${o.length}`);return D.toShamirShare(o)}function lo(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const o=$t(s,he).split(" ");if(o.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${o.length}`);return o}function co(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ws(t,he))throw new Error("Invalid recovery phrase: checksum mismatch");const o=Us(t,he);if(o.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${o.length}`);return D.toSeed(o)}function Gt(s){if(s.length!==oe)return!1;const t=s.join(" ").toLowerCase().trim();return Ws(t,he)}function De(s){return he.includes(s.toLowerCase().trim())}function uo(s,t=5){const o=s.toLowerCase().trim();return o.length===0?[]:he.filter(a=>a.startsWith(o)).slice(0,t)}function ho(s){const t=[];for(let o=0;o<s.length;o+=4)t.push(s.slice(o,o+4));return t}function po(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function mo({className:s="",variant:t="default",size:o="md",children:a,menuItems:r=[],hideSignOut:n=!1}){const{user:c,isAuthenticated:i,isLoading:d,openLoginModal:u,logout:p}=D.useAuth(),[f,h]=l.useState(!1),[w,g]=l.useState(-1),m=l.useRef(null),y=l.useRef(null),A=l.useMemo(()=>[...r,...n?[]:[{label:"Sign out",onClick:p}]],[r,n,p]);l.useEffect(()=>{if(!f)return;const x=C=>{m.current&&!m.current.contains(C.target)&&(h(!1),g(-1))},k=C=>{C.key==="Escape"&&(h(!1),g(-1),y.current?.focus())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k)}},[f]);const b=l.useCallback(x=>{if(!(!f||A.length===0))switch(x.key){case"ArrowDown":x.preventDefault(),g(k=>(k+1)%A.length);break;case"ArrowUp":x.preventDefault(),g(k=>(k-1+A.length)%A.length);break;case"Home":x.preventDefault(),g(0);break;case"End":x.preventDefault(),g(A.length-1);break;case"Enter":case" ":w>=0&&(x.preventDefault(),A[w].onClick(),h(!1),g(-1));break}},[f,w,A]),v=l.useCallback(()=>{A.length!==0&&(h(x=>!x),g(-1))},[A.length]),j={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},S={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(d)return e.jsx("button",{type:"button",className:`cedros-button ${S[t]} ${j[o]} ${s}`,disabled:!0,children:e.jsx(V.LoadingSpinner,{size:"sm"})});if(i&&c){const x=c.name||c.email||"User",k=Rs.sanitizeImageUrl(c.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:m,onKeyDown:b,children:[e.jsxs("button",{ref:y,type:"button",className:`cedros-button cedros-user-button ${j[o]} ${s}`,"aria-haspopup":"menu","aria-expanded":f,"aria-label":`User menu for ${x}`,onClick:v,children:[k?e.jsx("img",{src:k,alt:x,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(x[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:x})]}),f&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[r.map((C,N)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${w===N?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===N?0:-1,onClick:()=>{C.onClick(),h(!1)},children:[C.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:C.icon}),C.label]},N)),r.length>0&&!n&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!n&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${w===r.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===r.length?0:-1,onClick:()=>{p(),h(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${S[t]} ${j[o]} ${s}`,onClick:u,children:a||"Sign in"})}function Os(){const{config:s}=_.useCedrosLogin(),[t,o]=l.useState(!1),[a,r]=l.useState(!1),[n,c]=l.useState(null),i=l.useMemo(()=>new _.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:d,getRemainingAttempts:u}=K.useRateLimiter({maxAttempts:3,windowMs:3e5}),p=l.useCallback(async g=>{if(!Pe.validateEmail(g)){const m={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw c(m),m}try{d()}catch(m){const y={code:"RATE_LIMITED",message:m instanceof Error?m.message:"Too many attempts"};throw c(y),y}o(!0),c(null),r(!1);try{await i.post("/forgot-password",{email:g}),r(!0)}catch(m){const y=_.handleApiError(m,"Failed to send reset email");throw c(y),y}finally{o(!1)}},[i,d]),f=l.useCallback(async(g,m)=>{o(!0),c(null),r(!1);try{await i.post("/reset-password",{token:g,newPassword:m}),r(!0)}catch(y){const A=_.handleApiError(y,"Failed to reset password");throw c(A),A}finally{o(!1)}},[i]),h=l.useCallback(()=>c(null),[]),w=l.useCallback(()=>{c(null),r(!1),o(!1)},[]);return{forgotPassword:p,resetPassword:f,isLoading:t,isSuccess:a,error:n,clearError:h,reset:w,remainingAttempts:u()}}function Yt({onSuccess:s,onCancel:t,className:o=""}){const[a,r]=l.useState(""),{forgotPassword:n,isLoading:c,isSuccess:i,error:d,clearError:u}=Os(),p=l.useId(),f=async h=>{h.preventDefault();try{await n(a),s?.()}catch{}};return i?e.jsxs("div",{className:`cedros-forgot-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Check your email"}),e.jsxs("p",{className:"cedros-success-message",children:["If an account exists for ",e.jsx("strong",{children:a}),", you will receive a password reset link shortly."]}),t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:t,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:f,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Forgot password?"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your email address and we'll send you a link to reset your password."})]}),e.jsx(G.ErrorMessage,{error:d,onDismiss:u}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:p,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:p,type:"email",className:"cedros-input",value:a,onChange:h=>r(h.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:c})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:c||!a,children:c?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),"Sending..."]}):"Send reset link"}),t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:t,disabled:c,children:"Back to login"})]})]})}const fo={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t})}):(this.loading=!0,new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t});const o=document.getElementById("apple-signin-script");if(o){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]):o.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]});return}const a=document.createElement("script");a.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",a.async=!0,a.defer=!0,a.id="apple-signin-script",a.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]},a.onerror=()=>{this.loading=!1,a.remove();const r=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(n=>n.reject(r)),this.callbacks=[]},document.head.appendChild(a)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function Jt(){const{config:s,_internal:t}=_.useCedrosLogin(),[o,a]=l.useState(!1),[r,n]=l.useState(!1),[c,i]=l.useState(null),d=l.useRef(s),u=l.useMemo(()=>new _.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);l.useEffect(()=>{d.current=s},[s]),l.useEffect(()=>{if(!s.appleClientId)return;let h=!0;const w=()=>{if(h)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),h&&n(!0)}catch{h&&i({code:"SERVER_ERROR",message:"Failed to initialize Apple Sign In"})}};return fo.load().then(()=>{h&&w()}).catch(()=>{h&&i({code:"SERVER_ERROR",message:"Failed to load Apple Sign In"})}),()=>{h=!1}},[s.appleClientId]);const p=l.useCallback(async()=>{if(!s.appleClientId){const h={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw i(h),h}if(!r){const h={code:"VALIDATION_ERROR",message:"Apple Sign In not initialized"};throw i(h),h}a(!0),i(null);try{const h=await window.AppleID.auth.signIn(),w=h.authorization?.id_token;if(!w)throw new Error("No ID token received from Apple");const g=h.user?.name?`${h.user.name.firstName||""} ${h.user.name.lastName||""}`.trim():void 0,m=await u.post("/apple",{idToken:w,name:g||void 0});return d.current.callbacks?.onLoginSuccess?.(m.user,"apple"),t?.handleLoginSuccess(m.user,m.tokens),a(!1),m}catch(h){if(h.error==="popup_closed_by_user"){const m={code:"SERVER_ERROR",message:"Apple Sign In was cancelled"};throw i(m),a(!1),m}const g=_.handleApiError(h,"Apple sign-in failed");throw i(g),a(!1),g}},[s.appleClientId,r,u,t]),f=l.useCallback(()=>i(null),[]);return{signIn:p,isLoading:o,isInitialized:r,error:c,clearError:f}}function Xt(){if(typeof window>"u"||typeof navigator>"u")return!1;const s=navigator.userAgent.toLowerCase(),t=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(s)||t.includes("mac")||/macintosh/.test(s)||t==="macintel"&&navigator.maxTouchPoints>1)}function Zt({onSuccess:s,onError:t,className:o="",variant:a="default",size:r="md",disabled:n=!1,hideOnNonApple:c=!0}){const{signIn:i,isLoading:d,isInitialized:u}=Jt(),[p]=l.useState(()=>Xt());if(c&&!p)return null;const f=async()=>{try{await i(),s?.()}catch(g){const m=g instanceof Error?g:new Error(String(g));t?.(m)}},h={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},w={default:"cedros-button-apple",outline:"cedros-button-apple-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${w[a]} ${h[r]} ${o}`,onClick:f,disabled:n||!u||d,"aria-label":"Sign in with Apple",children:[d?e.jsx(V.LoadingSpinner,{size:"sm"}):e.jsx("svg",{className:"cedros-button-icon",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),e.jsx("span",{children:"Continue with Apple"})]})}function Z(s,t){if(!s)throw new Error(t)}function go(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function Qe(s){Z(typeof s=="string"&&s.length>0,"Expected base64url string");const t=go(s),o=t+"=".repeat((4-t.length%4)%4),a=atob(o),r=new Uint8Array(a.length);for(let n=0;n<a.length;n++)r[n]=a.charCodeAt(n);return r.buffer}function ye(s){const t=new Uint8Array(s);let o="";for(let r=0;r<t.length;r++)o+=String.fromCharCode(t[r]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function er(s){Z(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return Z(typeof t.type=="string","Invalid credential descriptor type"),Z(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:Qe(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function wo(s){Z(s&&typeof s=="object","Missing creation options");const t=s.publicKey;Z(t&&typeof t=="object","Missing creation options.publicKey"),Z(typeof t.challenge=="string","Missing creation challenge"),Z(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),Z(typeof t.user=="object"&&t.user!==null,"Missing user");const o=t.rp,a=t.user;Z(typeof o.name=="string","Missing rp.name"),Z(typeof a.id=="string","Missing user.id"),Z(typeof a.name=="string","Missing user.name"),Z(typeof a.displayName=="string","Missing user.displayName");const r=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(er):void 0,n=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(c=>({type:c.type,alg:c.alg})):[];return{challenge:Qe(t.challenge),rp:{name:o.name,id:typeof o.id=="string"?o.id:void 0},user:{id:Qe(a.id),name:a.name,displayName:a.displayName},pubKeyCredParams:n,timeout:typeof t.timeout=="number"?t.timeout:void 0,attestation:typeof t.attestation=="string"?t.attestation:void 0,authenticatorSelection:typeof t.authenticatorSelection=="object"&&t.authenticatorSelection!==null?t.authenticatorSelection:void 0,excludeCredentials:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0}}function bo(s){Z(s&&typeof s=="object","Missing request options");const t=s.publicKey;Z(t&&typeof t=="object","Missing request options.publicKey"),Z(typeof t.challenge=="string","Missing request challenge");const o=Array.isArray(t.allowCredentials)?t.allowCredentials.map(er):void 0;return{challenge:Qe(t.challenge),rpId:typeof t.rpId=="string"?t.rpId:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,userVerification:typeof t.userVerification=="string"?t.userVerification:void 0,allowCredentials:o,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0}}function rt(s){const t=ye(s.rawId),o=s.response,r={...{clientDataJSON:ye(o.clientDataJSON)}};if("attestationObject"in o){const n=o;if(r.attestationObject=ye(n.attestationObject),typeof n.getTransports=="function")try{r.transports=n.getTransports()}catch{}}if("authenticatorData"in o){const n=o;r.authenticatorData=ye(n.authenticatorData),r.signature=ye(n.signature),n.userHandle&&(r.userHandle=ye(n.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:r}}function yo(){if(typeof window<"u"){const s=window.location?.hostname,t=s==="localhost"||s==="127.0.0.1"||s?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!t)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function ot(s){if(!(s instanceof Error))return null;const t=s.name;return t==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:t==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:t==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function sr(){const{config:s,_internal:t}=_.useCedrosLogin(),[o,a]=l.useState(!1),[r,n]=l.useState(null),c=l.useMemo(()=>new _.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),i=l.useCallback(()=>n(null),[]),d=yo(),u=l.useCallback(async f=>{if(!d){const h={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(h),h}a(!0),n(null);try{const h=await c.post("/webauthn/auth/options",{email:f?.email}),w=bo(h.options),g=await navigator.credentials.get({publicKey:w});if(!g)throw new Error("Passkey authentication returned no credential");const m=await c.post("/webauthn/auth/verify",{challengeId:h.challengeId,credential:rt(g)});return s.callbacks?.onLoginSuccess?.(m.user,"webauthn"),t?.handleLoginSuccess(m.user,m.tokens),m}catch(h){const g=ot(h)??_.handleApiError(h,"Passkey sign-in failed");throw n(g),g}finally{a(!1)}},[c,s.callbacks,t,d]),p=l.useCallback(async f=>{if(!d){const h={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(h),h}a(!0),n(null);try{const h=await c.post("/webauthn/register/options",{}),w=wo(h.options),g=await navigator.credentials.create({publicKey:w});if(!g)throw new Error("Passkey registration returned no credential");const m=await c.post("/webauthn/register/verify",{challengeId:h.challengeId,credential:rt(g),label:f?.label});if(!m.success)throw new Error("Passkey registration failed");return{credentialId:m.credentialId,label:m.label}}catch(h){const g=ot(h)??_.handleApiError(h,"Passkey registration failed");throw n(g),g}finally{a(!1)}},[c,d]);return{isSupported:d,isLoading:o,error:r,clearError:i,authenticatePasskey:u,registerPasskey:p}}function tr({onSuccess:s,className:t="",children:o,disabled:a}){const{authenticatePasskey:r,isLoading:n,isSupported:c}=sr(),i=a||!c||n;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${t}`,onClick:async()=>{await r(),s?.()},disabled:i,"aria-disabled":i,children:[e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(xo,{})}),e.jsx("span",{children:o??(n?"Continuing...":"Continue with Passkey")})]})}function xo(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}const Ne=["login","register"];function Ge({onSuccess:s,className:t="",defaultTab:o="login"}){const{config:a}=_.useCedrosLogin(),[r,n]=l.useState(o),[c,i]=l.useState("form"),[d,u]=l.useState(()=>Se.detectSolanaWallets()),[p]=l.useState(()=>Xt());l.useEffect(()=>{const j=()=>u(Se.detectSolanaWallets());return j(),window.addEventListener("load",j),window.addEventListener("focus",j),()=>{window.removeEventListener("load",j),window.removeEventListener("focus",j)}},[]);const f=a.forms?.forgotPassword?.mode??"reset",h=l.useCallback(j=>{const S=Ne.indexOf(r);let x=S;switch(j.key){case"ArrowLeft":case"ArrowUp":x=S===0?Ne.length-1:S-1;break;case"ArrowRight":case"ArrowDown":x=S===Ne.length-1?0:S+1;break;case"Home":x=0;break;case"End":x=Ne.length-1;break;default:return}j.preventDefault();const k=Ne[x];n(k),document.getElementById(`cedros-tab-${k}`)?.focus()},[r]),w=a.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},g=w.email!==!1,m=w.google!==!1&&a.googleClientId,y=w.apple!==!1&&a.appleClientId&&p,A=w.solana!==!1&&d,b=w.webauthn!==!1,v=g&&(m||y||A||b);return c==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx(Yt,{onCancel:()=>i("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[(b||m||y||A)&&e.jsxs("div",{className:"cedros-social-buttons",children:[b&&e.jsx(tr,{onSuccess:s}),m&&e.jsx(Bs.GoogleLoginButton,{onSuccess:s}),y&&e.jsx(Zt,{onSuccess:s}),A&&e.jsx(Se.SolanaLoginButton,{onSuccess:s})]}),v&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-tabs",role:"tablist","aria-label":"Authentication method",children:[e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-login",className:`cedros-tab ${r==="login"?"cedros-tab-active":""}`,onClick:()=>n("login"),onKeyDown:h,"aria-selected":r==="login","aria-controls":"cedros-tabpanel-login",tabIndex:r==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${r==="register"?"cedros-tab-active":""}`,onClick:()=>n("register"),onKeyDown:h,"aria-selected":r==="register","aria-controls":"cedros-tabpanel-register",tabIndex:r==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${r}`,"aria-labelledby":`cedros-tab-${r}`,children:r==="login"?e.jsx(K.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>n("register"),onForgotPassword:f==="reset"?()=>i("forgotPassword"):void 0}):e.jsx(K.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>n("login")})})]})]})}class rr extends l.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",o.componentStack),this.props.onError?.(t,o)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:o,errorInfo:a}=this.state,{children:r,fallback:n,showDetails:c=!1}=this.props;return t?n||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),c&&o&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[o.toString(),a?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):r}}function Ao({className:s="",title:t="Sign in to your account"}){const{isModalOpen:o,closeModal:a}=_.useCedrosLogin(),r=l.useRef(null),n=l.useRef(null),c=l.useRef(a);if(l.useEffect(()=>{c.current=a},[a]),l.useEffect(()=>{if(!o)return;n.current=document.activeElement,r.current?.focus();const d=p=>{if(p.key==="Escape"&&c.current(),p.key==="Tab"&&r.current){const f=r.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),h=f[0],w=f[f.length-1];p.shiftKey&&document.activeElement===h?(p.preventDefault(),w?.focus()):!p.shiftKey&&document.activeElement===w&&(p.preventDefault(),h?.focus())}};document.addEventListener("keydown",d);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=u,n.current instanceof HTMLElement&&n.current.focus()}},[o]),!o)return null;const i=d=>{d.target===d.currentTarget&&a()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,onClick:i,role:"presentation",children:e.jsxs("div",{ref:r,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:t}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:a,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(rr,{children:e.jsx(Ge,{onSuccess:a})})})]})})}function vo({token:s,onSuccess:t,onLoginClick:o,className:a=""}){const[r,n]=l.useState(""),[c,i]=l.useState(""),[d,u]=l.useState(null),{resetPassword:p,isLoading:f,isSuccess:h,error:w,clearError:g}=Os(),m=r===c,y=d?.isValid&&m&&r.length>0,A=async b=>{if(b.preventDefault(),!!y)try{await p(s,r),t?.()}catch{}};return h?e.jsxs("div",{className:`cedros-reset-password-success ${a}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:o,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${a}`,onSubmit:A,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Reset your password"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your new password below."})]}),e.jsx(G.ErrorMessage,{error:w,onDismiss:g}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(K.PasswordInput,{label:"New password",value:r,onChange:b=>{n(b.target.value),u(Pe.validatePassword(b.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:f,autoComplete:"new-password",error:d&&!d.isValid?Object.values(d.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(K.PasswordInput,{label:"Confirm password",value:c,onChange:b=>i(b.target.value),disabled:f,autoComplete:"new-password",error:c&&!m?"Passwords do not match":void 0})}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:f||!y,children:f?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:o,disabled:f,children:"Back to login"})]})]})}function Ms({org:s,size:t="lg",className:o=""}){const a=Rs.sanitizeImageUrl(s.logoUrl),r=t==="lg"?"cedros-org-avatar-lg":"",n=["cedros-org-avatar",r,o].filter(Boolean).join(" "),c=["cedros-org-avatar-placeholder",r,o].filter(Boolean).join(" ");return a?e.jsx("img",{src:a,alt:s.name,className:n,referrerPolicy:"no-referrer"}):e.jsx("div",{className:c,children:s.name[0]?.toUpperCase()||"?"})}function jo({orgs:s,activeOrg:t,isLoading:o=!1,onSelect:a,onCreateClick:r,className:n="",placeholder:c="Select organization"}){const[i,d]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{const w=g=>{u.current&&!u.current.contains(g.target)&&d(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),l.useEffect(()=>{const w=g=>{g.key==="Escape"&&d(!1)};if(i)return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[i]);const p=l.useCallback(w=>{a(w),d(!1)},[a]),f=l.useCallback(()=>{d(!1),r?.()},[r]),h=l.useCallback(()=>{d(w=>!w)},[]);return o?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${n}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:u,className:`cedros-org-selector ${n}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:h,"aria-haspopup":"listbox","aria-expanded":i,children:[t?e.jsxs(e.Fragment,{children:[e.jsx(Ms,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(nt,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:c}),e.jsx(ko,{isOpen:i})]}),i&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[s.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:s.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${w.id===t?.id?"cedros-org-selector-item-active":""}`,onClick:()=>p(w.id),role:"option","aria-selected":w.id===t?.id,children:[e.jsx(Ms,{org:w,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:w.name}),e.jsx(nt,{role:w.membership.role}),w.id===t?.id&&e.jsx(No,{})]})},w.id))}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:f,children:[e.jsx(Co,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function nt({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function ko({isOpen:s}){return e.jsx("svg",{className:`cedros-org-chevron ${s?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function No(){return e.jsx("svg",{className:"cedros-org-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Co(){return e.jsx("svg",{className:"cedros-org-plus",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 3V13M3 8H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function So(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Eo(){return e.jsx("svg",{className:"cedros-org-check",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 10L8 14L16 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Po(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M10 4V16M4 10H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Lo({orgs:s,activeOrg:t,isLoading:o,onSelect:a,onCreateClick:r}){return o?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[s.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:s.map(n=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${n.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>a(n.id),children:[e.jsx(Ms,{org:n}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:n.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",n.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${n.membership.role}`,children:n.membership.role}),n.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),n.id===t?.id&&e.jsx(Eo,{})]})},n.id))}),r&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:r,children:[e.jsx(Po,{}),e.jsx("span",{children:"Create new organization"})]})]})}function To({isLoading:s,onSubmit:t,onCancel:o}){const[a,r]=l.useState(""),[n,c]=l.useState(""),[i,d]=l.useState(null),u=l.useCallback(f=>{r(f);const h=f.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);c(h)},[]),p=l.useCallback(async f=>{if(f.preventDefault(),d(null),!a.trim()){d("Organization name is required");return}if(!n.trim()){d("Organization slug is required");return}try{await t({name:a.trim(),slug:n.trim()})}catch(h){d(h.message||"Failed to create organization")}},[a,n,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:p,children:[i&&e.jsx(G.ErrorMessage,{error:i}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:a,onChange:f=>u(f.target.value),placeholder:"My Organization",maxLength:255,disabled:s,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:n,onChange:f=>c(f.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:s})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:o,disabled:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!a.trim()||!n.trim(),children:s?e.jsx(V.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function _o({isOpen:s,onClose:t,orgs:o,activeOrg:a,isLoading:r=!1,error:n,onSelect:c,onCreate:i,className:d=""}){return s?e.jsx(Mo,{onClose:t,orgs:o,activeOrg:a,isLoading:r,error:n,onSelect:c,onCreate:i,className:d}):null}function Mo({onClose:s,orgs:t,activeOrg:o,isLoading:a=!1,error:r,onSelect:n,onCreate:c,className:i}){const[d,u]=l.useState("list"),p=l.useRef(null),f=l.useRef(null);l.useEffect(()=>(f.current=document.activeElement,p.current?.querySelector(".cedros-modal-close")?.focus(),()=>{f.current?.focus()}),[]),l.useEffect(()=>{const m=y=>{if(y.key==="Escape"){s();return}if(y.key==="Tab"&&p.current){const A=p.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),b=A[0],v=A[A.length-1];y.shiftKey?document.activeElement===b&&(y.preventDefault(),v?.focus()):document.activeElement===v&&(y.preventDefault(),b?.focus())}};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[s]);const h=l.useCallback(m=>{m.target===m.currentTarget&&s()},[s]),w=l.useCallback(m=>{n(m),s()},[n,s]),g=l.useCallback(async m=>{await c?.(m),s()},[c,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:h,children:e.jsxs("div",{ref:p,className:`cedros-modal cedros-org-switcher ${i}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:d==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(So,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[r&&e.jsx(G.ErrorMessage,{error:r}),d==="list"?e.jsx(Lo,{orgs:t,activeOrg:o,isLoading:a,onSelect:w,onCreateClick:c?()=>u("create"):void 0}):e.jsx(To,{isLoading:a,onSubmit:g,onCancel:()=>u("list")})]})]})})}function Ro({sessions:s,isLoading:t=!1,error:o,onRevokeAll:a,className:r=""}){const[n,c]=l.useState(!1),[i,d]=l.useState(!1),u=l.useRef(null),p=l.useMemo(()=>s.filter(h=>!h.isCurrent).length,[s]),f=l.useCallback(async()=>{if(!a)return;const h=s.filter(g=>!g.isCurrent).length;if(!(h===0||!window.confirm(`Are you sure you want to sign out of ${h} other device(s)? This will log you out everywhere except this browser.`))){c(!0),d(!1);try{await a(),d(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(!1),u.current=null},3e3)}finally{c(!1)}}},[a,s]);return l.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${r}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):o?e.jsx("div",{className:`cedros-session-list ${r}`,children:e.jsx(G.ErrorMessage,{error:o})}):s.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${r}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${r}`,children:[i&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Wo,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(h=>e.jsx(Bo,{session:h},h.id))}),a&&p>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:f,disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${p} other device${p>1?"s":""}`})})]})}function Bo({session:s}){const t=Do(s.userAgent),o=Fo(s.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${s.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(Uo,{userAgent:s.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[t.browser," on ",t.os]}),s.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[s.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",s.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",Io(s.createdAt)]}),o&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Do(s){if(!s)return{browser:"Unknown browser",os:"Unknown device"};let t="Unknown browser";s.includes("Chrome")&&!s.includes("Edg")?t="Chrome":s.includes("Safari")&&!s.includes("Chrome")?t="Safari":s.includes("Firefox")?t="Firefox":s.includes("Edg")&&(t="Edge");let o="Unknown device";return s.includes("Windows")?o="Windows":s.includes("Mac")?o="macOS":s.includes("Linux")?o="Linux":s.includes("iPhone")||s.includes("iPad")?o="iOS":s.includes("Android")&&(o="Android"),{browser:t,os:o}}function Io(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),r=Math.floor(a/(1e3*60)),n=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return r<1?"just now":r<60?`${r} minute${r>1?"s":""} ago`:n<24?`${n} hour${n>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Fo(s){const t=new Date(s),o=new Date,a=3600*1e3;return t.getTime()-o.getTime()<a}function Uo({userAgent:s}){return s?.includes("iPhone")||s?.includes("iPad")||s?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function Wo(){return e.jsx("svg",{className:"cedros-session-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function or({words:s,onConfirm:t,className:o=""}){const[a,r]=l.useState(!1),[n,c]=l.useState(!1),i=l.useRef(null),d=ho(s),u=l.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),r(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>r(!1),2e3)}catch{}},[s]);l.useEffect(()=>()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]);const p=l.useCallback(()=>{n&&t()},[n,t]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${o}`,children:[e.jsxs("div",{className:"cedros-recovery-header",children:[e.jsx("h3",{className:"cedros-recovery-title",children:"Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-warning",children:"Write down these 12 words in order and store them securely. This is the only way to recover your wallet if you lose access."})]}),e.jsx("div",{className:"cedros-recovery-grid",children:d.map((f,h)=>e.jsx("div",{className:"cedros-word-group",children:f.map((w,g)=>{const m=h*4+g+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[m,"."]}),e.jsx("span",{className:"cedros-word-text",children:w})]},m)})},h))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,children:a?"Copied!":"Copy to Clipboard"}),e.jsx("div",{className:"cedros-recovery-security",children:e.jsxs("div",{className:"cedros-warning-box",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M10 6v4m0 4h.01M19 10a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsxs("div",{className:"cedros-warning-content",children:[e.jsx("strong",{children:"Security Warning"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Never share this phrase with anyone"}),e.jsx("li",{children:"Store it offline in a secure location"}),e.jsx("li",{children:"Anyone with this phrase can access your wallet"}),e.jsx("li",{children:"Cedros cannot recover this phrase for you"})]})]})]})}),e.jsxs("div",{className:"cedros-recovery-confirm",children:[e.jsxs("label",{className:"cedros-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:f=>c(f.target.checked),className:"cedros-checkbox"}),e.jsx("span",{children:"I have written down and securely stored my recovery phrase"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:p,disabled:!n,children:"Continue"})]})]})}function nr({onSubmit:s,onCancel:t,isSubmitting:o=!1,error:a,className:r=""}){const[n,c]=l.useState(Array(oe).fill("")),[i,d]=l.useState(null),[u,p]=l.useState([]),[f,h]=l.useState(null),w=l.useId(),g=l.useRef(null),m=l.useCallback((x,k)=>{const C=[...n];if(C[x]=k.toLowerCase().trim(),c(C),k.length>0){const N=uo(k,5);p(N)}else p([]);h(null)},[n]),y=l.useCallback(x=>{d(x),p([])},[]),A=l.useCallback(x=>{const k=n[x];k&&!De(k)&&h(`Word ${x+1} is not in the wordlist`),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{i===x&&p([])},200)},[n,i]);l.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]);const b=l.useCallback(x=>{if(i!==null){const k=[...n];k[i]=x,c(k),p([]),document.querySelector(`[data-word-index="${i+1}"]`)?.focus()}},[i,n]),v=l.useCallback(x=>{const k=x.clipboardData.getData("text"),C=po(k);C.length===oe&&(x.preventDefault(),c(C),h(null))},[]),j=l.useCallback(x=>{if(x.preventDefault(),n.filter(N=>!N).length>0){h(`Please enter all ${oe} words`);return}const C=n.map((N,L)=>({word:N,index:L+1})).filter(({word:N})=>!De(N));if(C.length>0){h(`Invalid words: ${C.map(N=>`#${N.index}`).join(", ")}`);return}if(!Gt(n)){h("Invalid recovery phrase - please check your words");return}s(n)},[n,s]),S=a||f;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${r}`,onSubmit:j,onPaste:v,children:[e.jsxs("div",{className:"cedros-recovery-input-header",children:[e.jsx("h3",{className:"cedros-recovery-input-title",children:"Enter Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-input-description",children:"Enter your 12-word recovery phrase. You can paste the entire phrase at once."})]}),e.jsx("div",{className:"cedros-word-inputs",children:Array.from({length:oe},(x,k)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[k+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${n[k]&&!De(n[k])?"cedros-word-invalid":n[k]&&De(n[k])?"cedros-word-valid":""}`,value:n[k],onChange:C=>m(k,C.target.value),onFocus:()=>y(k),onBlur:()=>A(k),"data-word-index":k,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:o,"aria-label":`Word ${k+1}`})]},k))}),i!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${w}-suggestions`,children:u.map(x=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>b(x),role:"option",children:x},x))}),S&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:S}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:o,children:o?"Recovering...":"Recover Wallet"})]})]})}function Oo({capabilities:s,className:t=""}){if(s.allSupported)return null;const o=D.getMissingCapabilitiesMessage(s),a=D.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${t}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:o}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",a.browser," ",a.version,a.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:s.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",s.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:s.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",s.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:s.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",s.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",s.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",s.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:s.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",s.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const qo=["share_c_only","full_seed","none"];function zo(s){return s&&qo.includes(s)?s:"share_c_only"}const Vo={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function ar(){const s=_.useCedrosLoginOptional(),[t,o]=l.useState(null),[a,r]=l.useState(!!s),[n,c]=l.useState(null),i=l.useMemo(()=>s?new _.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),d=l.useCallback(async()=>{if(i){r(!0),c(null);try{const u=await i.get("/discovery");u.wallet?o({enabled:u.wallet.enabled,recoveryMode:zo(u.wallet.recoveryMode),unlockTtlSeconds:u.wallet.unlockTtlSeconds}):o({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(u){const p=u instanceof Error?u.message:"Failed to fetch wallet config";c(p),o({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{r(!1)}}},[i]);return l.useEffect(()=>{i&&d()},[i,d]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:a,error:n,refetch:d}:Vo}function ir(){const{user:s}=_.useCedrosLogin(),{enroll:t}=D.useWalletMaterial(),{recoveryMode:o}=ar(),[a,r]=l.useState({step:"idle"}),[n,c]=l.useState(!1),i=l.useRef([]),d=l.useCallback(()=>{D.wipeAll(...i.current),i.current=[]},[]);l.useEffect(()=>()=>{d()},[d]);const u=l.useCallback(async(g,m,y,A)=>{r({step:"generating_seed"});const b=D.generateSeed();i.current.push(b),r({step:"splitting_shares"});const{shareA:v,shareB:j,shareC:S}=ie.splitSecret(b);i.current.push(v,j,S),r({step:"encrypting_shares"});const x=await D.aesGcmEncryptToBase64(v,D.toEncryptionKey(m)),k=ie.getPublicKeyFromSeed(b),C=ie.publicKeyToBase58(k);r({step:"uploading"});const N={solanaPubkey:C,shareAAuthMethod:g,shareACiphertext:x.ciphertext,shareANonce:x.nonce,shareB:D.uint8ArrayToBase64(j)};if(g==="password"){if(!y)throw new Error("KDF salt required for password method");N.shareAKdfSalt=D.uint8ArrayToBase64(y),N.shareAKdfParams=D.DEFAULT_KDF_PARAMS}if(g==="passkey"&&A&&(N.prfSalt=A),await t(N),o==="none")d(),r({step:"complete",solanaPubkey:C});else{const L=o==="full_seed"?lo(b):ao(D.toShamirShare(S));r({step:"showing_recovery",recoveryPhrase:L,solanaPubkey:C})}},[t,o,d]),p=l.useCallback(async g=>{if(!s){r({step:"error",error:"User not authenticated"});return}c(!0),d();try{const m=D.generateArgon2Salt(),y=await ie.argon2DeriveInWorker(g,m,D.DEFAULT_KDF_PARAMS);i.current.push(y),await u("password",y,m)}catch(m){r({step:"error",error:m instanceof Error?m.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),f=l.useCallback(async()=>{if(!s){r({step:"error",error:"User not authenticated"});return}c(!0),d();try{const g=D.generatePrfSalt(),m=D.uint8ArrayToBase64(g);r({step:"registering_passkey"});let y;try{const b=new TextEncoder().encode(s.id),v=s.name??s.email??"User",j=s.email??s.id;y=(await D.registerPasskeyWithPrf(b,j,v,g)).prfOutput}catch(b){if(b?.name!=="InvalidStateError")throw b;y=(await D.authenticateWithDiscoverablePrf(m)).prfOutput}i.current.push(y);const A=await D.deriveKeyFromPrf(y,g);i.current.push(A),await u("passkey",A,void 0,m)}catch(g){r({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),h=l.useCallback(()=>{const g=a.solanaPubkey;d(),r({step:"complete",solanaPubkey:g})},[a.solanaPubkey,d]),w=l.useCallback(()=>{d(),r({step:"idle"}),c(!1)},[d]);return{state:a,startEnrollmentWithPassword:p,startEnrollmentWithPasskey:f,confirmRecoveryPhrase:h,cancel:w,isEnrolling:n}}function lr({onComplete:s,onCancel:t,className:o="",forceAuthMethod:a}){const{user:r}=_.useCedrosLogin(),{state:n,startEnrollmentWithPassword:c,startEnrollmentWithPasskey:i,confirmRecoveryPhrase:d,cancel:u,isEnrolling:p}=ir(),f=()=>a||"password",[h,w]=l.useState(f),[g,m]=l.useState(""),[y,A]=l.useState(""),[b,v]=l.useState(null);l.useEffect(()=>{w(f())},[r?.id,a]);const j=l.useCallback(async C=>{if(C.preventDefault(),g!==y){v("Passwords do not match");return}const N=Pe.validatePassword(g);if(!N.isValid){const L=Object.values(N.errors)[0];v(L??"Password does not meet requirements");return}v(null),await c(g)},[g,y,c]),S=l.useCallback(async()=>{await i()},[i]),x=l.useCallback(()=>{d(),n.solanaPubkey&&s?.(n.solanaPubkey)},[d,n.solanaPubkey,s]),k=l.useCallback(()=>{u(),t?.()},[u,t]);return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Generating secure wallet..."})]})}):n.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Encrypting wallet shares..."})]})}):n.step==="registering_passkey"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsx("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:e.jsxs("div",{className:"cedros-passkey-prompt",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Authenticate with Passkey"}),e.jsx("p",{children:"Follow your browser's prompt to use your passkey."})]})})}):n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Saving wallet..."})]})}):n.step==="showing_recovery"&&n.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsx(or,{words:n.recoveryPhrase,onConfirm:x})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsxs("div",{className:"cedros-enrollment-complete",children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M16 24l6 6 12-12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{children:"Wallet Created!"}),e.jsxs("p",{className:"cedros-pubkey",children:[e.jsx("strong",{children:"Address:"})," ",n.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsxs("div",{className:"cedros-enrollment-error",children:[e.jsxs("svg",{className:"cedros-error-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 16v12m0 6h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Enrollment Failed"}),e.jsx("p",{className:"cedros-error-message",children:n.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>u(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${o}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),e.jsxs("p",{children:["Secure your wallet with a ",h==="passkey"?"passkey":"password","."]})]}),!a&&e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:h==="password",onChange:()=>w("password"),disabled:p}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:h==="passkey",onChange:()=>w("passkey"),disabled:p}),e.jsx("span",{children:"Passkey"})]})]}),h==="password"&&e.jsxs("form",{onSubmit:j,className:"cedros-enrollment-form",children:[e.jsx(K.PasswordInput,{label:"Password",value:g,onChange:C=>m(C.target.value),showStrengthMeter:!0,disabled:p,required:!0,minLength:8,placeholder:"Enter a strong password"}),e.jsx(K.PasswordInput,{label:"Confirm Password",value:y,onChange:C=>A(C.target.value),error:b??void 0,disabled:p,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,disabled:p,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:p||!g||!y,children:p?"Creating...":"Continue"})]})]}),h==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."}),e.jsx("p",{children:"You'll use the same passkey to sign transactions."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,disabled:p,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,disabled:p,children:p?"Creating...":"Use Passkey"})]})]})]})}function cr(){const{user:s}=_.useCedrosLogin(),{signTransaction:t}=D.useWalletMaterial(),[o,a]=l.useState(!1),[r,n]=l.useState(null),c=l.useCallback(async(d,u)=>{if(!s){const p="User not authenticated";throw n(p),new Error(p)}a(!0),n(null);try{const p={transaction:D.uint8ArrayToBase64(d),...u?{credential:D.toCredentialRequest(u)}:{}},f=await t(p);return D.base64ToUint8Array(f.signature)}catch(p){const f=p instanceof Error?p.message:"Signing failed";throw n(f),p}finally{a(!1)}},[s,t]),i=l.useCallback(()=>n(null),[]);return{signTransaction:c,isSigning:o,error:r,clearError:i}}function dr(){const{getMaterial:s}=D.useWalletMaterial(),[t,o]=l.useState(!1),[a,r]=l.useState(null),n=l.useCallback(async()=>{o(!0),r(null);try{const i=await s();if(!i)throw new Error("No wallet enrolled");if(i.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!i.prfSalt)throw new Error("No PRF salt configured for wallet");const d=await D.authenticateWithDiscoverablePrf(i.prfSalt);try{return{type:"prfOutput",prfOutput:D.uint8ArrayToBase64(d.prfOutput)}}finally{d.prfOutput.fill(0)}}catch(i){const d=i instanceof Error?i.message:"Passkey authentication failed";return r(d),null}finally{o(!1)}},[s]),c=l.useCallback(()=>r(null),[]);return{getPasskeyCredential:n,isAuthenticating:t,error:a,clearError:c}}function ur({mode:s,isLoading:t=!1,error:o,onPrompt:a,onRetry:r,onCancel:n,title:c,description:i,className:d=""}){const u=l.useCallback(()=>{t||a?.()},[t,a]),p=l.useCallback(()=>{r?.()},[r]),f=s==="register"?"Set Up Passkey":"Verify with Passkey",h=s==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${d}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(Qo,{}):o?e.jsx(Ko,{}):e.jsx(Ho,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:c??f}),e.jsx("p",{className:"cedros-passkey-description",children:i??h}),o&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:o})}),e.jsx("div",{className:"cedros-passkey-actions",children:o?e.jsxs(e.Fragment,{children:[r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:p,children:"Try Again"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:n,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:u,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):s==="register"?"Create Passkey":"Use Passkey"}),n&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:n,children:"Cancel"})]})}),t&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",s==="register"?"create":"verify"," your passkey."]})]})}function Ho(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}function Qo(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Ko(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01"})]})}function hr({onUnlock:s,onCancel:t,showCancel:o=!0,authMethod:a,className:r=""}){_.useCedrosLogin();const{unlock:n,getMaterial:c,isLoading:i}=D.useWalletMaterial(),{getPasskeyCredential:d,isAuthenticating:u}=dr(),[p,f]=l.useState("idle"),[h,w]=l.useState(a??null),[g,m]=l.useState(""),[y,A]=l.useState(null);l.useEffect(()=>{a!==void 0&&w(a)},[a]);const b=h==="password",v=h==="passkey",j=l.useCallback(async()=>{if(f("credential"),A(null),!h)try{const P=await c();P?w(P.shareAAuthMethod):(A("No wallet enrolled"),f("error"))}catch(P){A(P instanceof Error?P.message:"Failed to get wallet info"),f("error")}},[h,c]),S=l.useCallback(async P=>{P.preventDefault(),A(null),f("unlocking");try{let E;if(b)E={type:"password",password:g};else throw new Error("Invalid auth method");await n(E),f("unlocked"),s?.()}catch(E){A(E instanceof Error?E.message:"Failed to unlock wallet"),f("error")}},[b,g,n,s]),x=l.useCallback(async()=>{A(null),f("unlocking");try{const P=await d();if(!P){f("credential");return}await n(P),f("unlocked"),s?.()}catch(P){A(P instanceof Error?P.message:"Failed to unlock wallet"),f("error")}},[d,n,s]),k=l.useCallback(()=>{m(""),f("idle"),A(null),t?.()},[t]),C=l.useCallback(()=>{m(""),f("credential"),A(null)},[]),N=i||u,L=()=>{switch(p){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx($o,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Locked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Unlock your wallet to sign transactions."}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:j,children:"Unlock Wallet"})]});case"credential":return b?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:S,children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Enter Password"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Enter your wallet password to unlock."}),e.jsx(K.PasswordInput,{label:"Password",value:g,onChange:P=>m(P.target.value),disabled:N,autoComplete:"current-password",error:y??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:N||g.length===0,children:N?"Unlocking...":"Unlock"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,disabled:N,children:"Cancel"})]})]}):v?e.jsxs("div",{className:"cedros-wallet-unlock-passkey",children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Verify with Passkey"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Use your passkey to unlock your wallet."}),e.jsx(ur,{mode:"authenticate",isLoading:N,error:y??void 0,onPrompt:x,onRetry:x,onCancel:o?k:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(V.LoadingSpinner,{size:"xl"}),e.jsx("p",{children:"Loading wallet info..."})]});case"unlocking":return e.jsxs("div",{className:"cedros-wallet-unlock-progress",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(V.LoadingSpinner,{size:"xl"})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlocking Wallet"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Verifying your credentials..."})]});case"unlocked":return e.jsxs("div",{className:"cedros-wallet-unlock-success",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Go,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Unlocked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Your wallet is ready to sign transactions."})]});case"error":return e.jsxs("div",{className:"cedros-wallet-unlock-error",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Yo,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:y??"Failed to unlock wallet. Please try again."}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:C,children:"Try Again"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${r}`,children:L()})}function $o(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"10",y:"22",width:"28",height:"20",rx:"4",stroke:"currentColor",strokeWidth:"2",fill:"var(--cedros-muted, #f3f4f6)"}),e.jsx("path",{d:"M16 22V16a8 8 0 1 1 16 0v6",stroke:"currentColor",strokeWidth:"2",fill:"none"}),e.jsx("circle",{cx:"24",cy:"32",r:"3",fill:"currentColor"})]})}function Go(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function Yo(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function pr(){const{recover:s,getShareBForRecovery:t}=D.useWalletMaterial(),{recoveryMode:o}=ar(),[a,r]=l.useState({step:"idle"}),[n,c]=l.useState(!1),i=l.useRef([]),d=l.useCallback(()=>{D.wipeAll(...i.current),i.current=[]},[]);l.useEffect(()=>()=>{d()},[d]);const u=l.useCallback(async(f,h,w)=>{c(!0),d();try{if(r({step:"validating"}),!Gt(f))throw new Error("Invalid recovery phrase. Please check your words.");let g;if(o==="share_c_only"){const C=io(f);i.current.push(C);const N=D.uint8ArrayToBase64(C),L=await t({shareC:N}),P=D.base64ToUint8Array(L.shareB);i.current.push(P),g=ie.combineShares(D.toShamirShare(P),D.toShamirShare(C)),i.current.push(g)}else g=co(f),i.current.push(g);const m=ie.getPublicKeyFromSeed(g),y=ie.publicKeyToBase58(m),{shareA:A,shareB:b}=ie.splitSecret(g);i.current.push(A,b),r({step:"encrypting"});let v,j,S;if(h==="passkey"){const C=D.generatePrfSalt();S=D.uint8ArrayToBase64(C);const N=await D.authenticateWithDiscoverablePrf(S);i.current.push(N.prfOutput),v=await D.deriveKeyFromPrf(N.prfOutput,C),i.current.push(v)}else j=D.generateArgon2Salt(),v=await ie.argon2DeriveInWorker(w,j,D.DEFAULT_KDF_PARAMS),i.current.push(v);const x=await D.aesGcmEncryptToBase64(A,D.toEncryptionKey(v));r({step:"uploading"});const k={solanaPubkey:y,shareAAuthMethod:h,shareACiphertext:x.ciphertext,shareANonce:x.nonce,shareB:D.uint8ArrayToBase64(b)};h==="password"&&(k.shareAKdfSalt=D.uint8ArrayToBase64(j),k.shareAKdfParams=D.DEFAULT_KDF_PARAMS),h==="passkey"&&(k.prfSalt=S),await s(k),d(),r({step:"complete"})}catch(g){d(),r({step:"error",error:g instanceof Error?g.message:"Recovery failed"})}finally{c(!1)}},[s,t,o,d]),p=l.useCallback(()=>{d(),r({step:"idle"}),c(!1)},[d]);return{state:a,startRecovery:u,cancel:p,isRecovering:n}}function mr({onComplete:s,onCancel:t,className:o="",defaultAuthMethod:a="password"}){const{state:r,startRecovery:n,cancel:c,isRecovering:i}=pr(),[d,u]=l.useState([]),[p,f]=l.useState(!1),[h,w]=l.useState(a),[g,m]=l.useState(""),[y,A]=l.useState(""),[b,v]=l.useState(null),j=l.useCallback(N=>{u(N),f(!0)},[]),S=l.useCallback(async N=>{if(N.preventDefault(),v(null),h!=="passkey"){if(g!==y){v("Passwords do not match");return}if(h==="password"&&g.length<8){v("Password must be at least 8 characters");return}}await n(d,h,g)},[d,h,g,y,n]),x=l.useCallback(()=>{c(),u([]),f(!1),m(""),A(""),t?.()},[c,t]),k=l.useCallback(()=>{f(!1),m(""),A("")},[]),C=l.useCallback(()=>{s?.()},[s]);return r.step==="validating"||r.step==="encrypting"||r.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Jo,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[r.step==="validating"&&"Validating Recovery Phrase",r.step==="encrypting"&&"Encrypting Wallet",r.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[r.step==="validating"&&"Checking your recovery phrase...",r.step==="encrypting"&&"Securing your wallet with new encryption...",r.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):r.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Xo,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Wallet Recovered"}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:["Your wallet has been successfully recovered and secured with your new"," ",h==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:C,children:"Done"})})]})}):r.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Zo,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:r.error??"An error occurred during recovery. Please try again."}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Start Over"})})]})}):p?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:S,children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Set New Security"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Choose how to secure your recovered wallet."})]}),e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:h==="password",onChange:()=>w("password"),disabled:i}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:h==="passkey",onChange:()=>w("passkey"),disabled:i}),e.jsx("span",{children:"Passkey"})]})]}),h==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:g,onChange:N=>m(N.target.value),disabled:i,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:y,onChange:N=>A(N.target.value),disabled:i,"aria-invalid":b?"true":void 0,placeholder:"Confirm your password"}),b&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:b})]})]}),h==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(en,{}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-wallet-recovery-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,disabled:i,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:i||h!=="passkey"&&(g.length===0||y.length===0),children:i?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-phrase",children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recover Your Wallet"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Enter your 12-word recovery phrase to restore your wallet."})]}),e.jsx(nr,{onSubmit:j,onCancel:x,isSubmitting:!1})]})})}function Jo(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-muted, #e5e7eb)",strokeWidth:"3",fill:"none"}),e.jsx("path",{d:"M24 4a20 20 0 0 1 20 20",stroke:"var(--cedros-primary, #6366f1)",strokeWidth:"3",strokeLinecap:"round",fill:"none"})]})}function Xo(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function Zo(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function en(){return e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function fr({address:s,label:t="Wallet Address",showCopy:o=!0,showExplorerLink:a=!0,allowReveal:r=!0,className:n=""}){const c=_.useCedrosLoginOptional(),[i,d]=l.useState(!1),[u,p]=l.useState(null),[f,h]=l.useState(!1),w=l.useRef(null),g=c?.config.solana?.network??"mainnet-beta",m=l.useMemo(()=>{const v=`https://explorer.solana.com/address/${s}`;return g==="mainnet-beta"?v:`${v}?cluster=${encodeURIComponent(g)}`},[s,g]),y=r&&s.length>18,A=l.useMemo(()=>!y||f?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,y,f]),b=l.useCallback(async()=>{try{p(null),await navigator.clipboard.writeText(s),d(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{d(!1),w.current=null},2e3)}catch(v){d(!1),p(v instanceof Error?v.message:"Copy failed")}},[s]);return l.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${n}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:t}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[y&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>h(v=>!v),"aria-label":f?"Hide full wallet address":"Show full wallet address",children:f?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.7 10.7a3 3 0 0 0 4.24 4.24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.88 5.09A10.94 10.94 0 0 1 12 5c5 0 9.27 3.11 11 7-0.55 1.23-1.32 2.33-2.27 3.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.61 6.61C4.4 7.9 2.74 9.8 1 12c1.73 3.89 6 7 11 7 1.14 0 2.25-0.16 3.3-0.46",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),a&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:m,target:"_blank",rel:"noreferrer",children:"Explorer"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:b,"aria-label":"Copy wallet address",children:i?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:A}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function gr({status:s,publicKey:t,onLock:o,onEnroll:a,onUnlock:r,onRecover:n,showActions:c=!0,compact:i=!1,className:d=""}){const u=s!==void 0,p=D.useWallet(),f=u?s:p.status,h=u?t??null:p.solanaPubkey,w=u?null:p.error,g=u?()=>{}:p.refresh,m=u?()=>{}:p.clearError,y=sn(f,w);return i?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${d}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${y.color}`,title:y.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:y.label}),h&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:h,children:tn(h)})]}):e.jsxs("div",{className:`cedros-wallet-status ${d}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${y.color}`,children:e.jsx(rn,{status:f})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:y.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:y.description})]})]}),h&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(fr,{address:h})}),w&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:w}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:m,children:"Dismiss"})]}),c&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[f==="not_enrolled"&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,children:"Create Wallet"}),f==="enrolled_locked"&&r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:r,children:"Unlock Wallet"}),(f==="not_enrolled"||f==="error")&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:n,children:"Recover Wallet"}),f==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:g,children:"Retry"})]})]})}function sn(s,t){switch(s){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:t??"An error occurred with your wallet.",color:"error"}}}function tn(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function rn({status:s}){switch(s){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function on({className:s="",showActions:t=!0}){const o=D.useWallet(),[a,r]=l.useState("status"),n=l.useMemo(()=>{switch(a){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[a]),c=l.useCallback(()=>r("status"),[]),i=l.useCallback(async()=>{r("status"),await o.refresh()},[o]),d=l.useCallback(async()=>{r("status"),await o.refresh()},[o]),u=l.useCallback(async()=>{r("status"),await o.refresh()},[o]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[a!=="status"&&n&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:n.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:n.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:c,children:"Back"})]}),a==="status"&&e.jsx(gr,{onEnroll:()=>r("enroll"),onUnlock:()=>r("unlock"),onRecover:()=>r("recover_intro"),showActions:t}),a==="enroll"&&e.jsx(lr,{onComplete:()=>{i()},onCancel:c}),a==="unlock"&&e.jsx(hr,{onUnlock:()=>{d()},onCancel:c}),a==="recover_intro"&&e.jsx("div",{className:"cedros-wallet-manager-intro",children:e.jsxs("div",{className:"cedros-wallet-manager-intro-card",children:[e.jsx("h4",{className:"cedros-wallet-manager-intro-title",children:"Before you start"}),e.jsxs("ul",{className:"cedros-wallet-manager-intro-list",children:[e.jsx("li",{children:"You’ll need your 12-word recovery phrase."}),e.jsx("li",{children:"You’ll set a new password or passkey for this wallet."}),e.jsx("li",{children:"If you’re on a shared device, avoid copying the phrase into other apps."})]}),e.jsxs("div",{className:"cedros-wallet-manager-intro-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>r("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:c,children:"Cancel"})]})]})}),a==="recover"&&e.jsx(mr,{onComplete:()=>{u()},onCancel:c})]})}function nn(s){const t=Math.floor(s/86400),o=Math.floor(s%86400/3600),a=Math.floor(s%3600/60),r=s%60;return{days:t,hours:o,minutes:a,seconds:r}}function an(s){const{days:t,hours:o,minutes:a}=nn(s),r=[];return t>0&&r.push(`${t}d`),o>0&&r.push(`${o}h`),a>0&&r.push(`${a}m`),r.length===0&&r.push(`${s}s`),r.join(" ")}const ln={auth_email_enabled:{key:"auth_email_enabled",label:"Enable Email Authentication",description:"Allow users to sign up and log in with email/password.",inputType:"boolean"},auth_email_require_verification:{key:"auth_email_require_verification",label:"Require Email Verification",description:"Users must verify their email address before they can log in.",inputType:"boolean"},auth_email_block_disposable:{key:"auth_email_block_disposable",label:"Block Disposable Emails",description:"Reject registrations from known disposable email providers.",inputType:"boolean"},auth_google_enabled:{key:"auth_google_enabled",label:"Enable Google Sign-In",description:"Allow users to authenticate with their Google account.",inputType:"boolean"},auth_google_client_id:{key:"auth_google_client_id",label:"Google Client ID",description:"OAuth 2.0 client ID from Google Cloud Console.",inputType:"text"},auth_google_client_secret:{key:"auth_google_client_secret",label:"Google Client Secret",description:"OAuth 2.0 client secret from Google Cloud Console.",inputType:"secret"},auth_apple_enabled:{key:"auth_apple_enabled",label:"Enable Sign in with Apple",description:"Allow users to authenticate with their Apple ID.",inputType:"boolean"},auth_apple_client_id:{key:"auth_apple_client_id",label:"Apple Services ID",description:"The Services ID configured in your Apple Developer account.",inputType:"text"},auth_apple_team_id:{key:"auth_apple_team_id",label:"Apple Team ID",description:"Your Apple Developer Team ID.",inputType:"text"},auth_apple_key_id:{key:"auth_apple_key_id",label:"Apple Key ID",description:"The Key ID for your Sign in with Apple private key.",inputType:"text"},auth_apple_private_key:{key:"auth_apple_private_key",label:"Apple Private Key",description:"The private key file contents (PEM format) for Sign in with Apple.",inputType:"secret",multiline:!0},auth_solana_enabled:{key:"auth_solana_enabled",label:"Enable Solana Wallet Auth",description:"Allow users to authenticate by signing with their Solana wallet.",inputType:"boolean"},auth_solana_challenge_expiry:{key:"auth_solana_challenge_expiry",label:"Challenge Expiry",description:"How long a wallet signature challenge is valid.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"10 minutes",value:"600"}]},auth_webauthn_enabled:{key:"auth_webauthn_enabled",label:"Enable WebAuthn/Passkeys",description:"Allow passwordless authentication with FIDO2/WebAuthn credentials.",inputType:"boolean"},auth_webauthn_rp_id:{key:"auth_webauthn_rp_id",label:"Relying Party ID",description:"Usually your domain (e.g., example.com). Passkeys are bound to this.",inputType:"text"},auth_webauthn_rp_name:{key:"auth_webauthn_rp_name",label:"Relying Party Name",description:"Display name shown to users during passkey registration.",inputType:"text"},auth_webauthn_rp_origin:{key:"auth_webauthn_rp_origin",label:"Allowed Origins",description:"Comma-separated origins allowed for WebAuthn (e.g., https://example.com).",inputType:"text"},feature_privacy_cash:{key:"feature_privacy_cash",label:"Privacy Cash",description:"Enable Privacy Cash deposits and timed withdrawals.",inputType:"boolean"},feature_wallet_signing:{key:"feature_wallet_signing",label:"Embedded Wallet Signing",description:"Enable the embedded wallet for transaction signing.",inputType:"boolean"},feature_sso:{key:"feature_sso",label:"Enterprise SSO",description:"Enable SAML/OIDC single sign-on for enterprise customers.",inputType:"boolean"},feature_organizations:{key:"feature_organizations",label:"Organizations",description:"Enable multi-user organizations with role-based access.",inputType:"boolean"},feature_mfa:{key:"feature_mfa",label:"Two-Factor Authentication",description:"Allow users to enable TOTP-based two-factor authentication.",inputType:"boolean"},feature_instant_link:{key:"feature_instant_link",label:"Instant Link Login",description:"Allow passwordless login via magic link sent to email.",inputType:"boolean"},security_cors_origins:{key:"security_cors_origins",label:"CORS Origins",description:"Allowed origins for cross-origin requests (comma-separated). Empty = same origin only.",inputType:"text"},security_cookie_domain:{key:"security_cookie_domain",label:"Cookie Domain",description:"Domain for auth cookies. Empty uses the request origin.",inputType:"text"},security_cookie_secure:{key:"security_cookie_secure",label:"Secure Cookies",description:"Require HTTPS for cookies. Disable only for local development.",inputType:"boolean"},security_cookie_same_site:{key:"security_cookie_same_site",label:"Cookie SameSite",description:'SameSite policy for cookies. Use "none" only if needed for cross-site embeds.',inputType:"select",presets:[{label:"Strict",value:"strict"},{label:"Lax (Recommended)",value:"lax"},{label:"None (cross-site)",value:"none"}]},security_session_timeout:{key:"security_session_timeout",label:"Session Timeout",description:"How long sessions remain valid before requiring re-authentication.",inputType:"duration",min:300,presets:[{label:"1 hour",value:"3600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"30 days",value:"2592000"}]},security_jwt_issuer:{key:"security_jwt_issuer",label:"JWT Issuer",description:"Issuer claim for JWTs. Empty uses the server URL.",inputType:"text"},security_jwt_audience:{key:"security_jwt_audience",label:"JWT Audience",description:"Audience claim for JWTs. Empty uses default.",inputType:"text"},email_smtp_host:{key:"email_smtp_host",label:"SMTP Host",description:"SMTP server hostname (e.g., smtp.sendgrid.net).",inputType:"text"},email_smtp_port:{key:"email_smtp_port",label:"SMTP Port",description:"SMTP server port. Common: 587 (TLS), 465 (SSL), 25 (unencrypted).",inputType:"select",presets:[{label:"587 (TLS)",value:"587"},{label:"465 (SSL)",value:"465"},{label:"25 (Plain)",value:"25"}]},email_smtp_user:{key:"email_smtp_user",label:"SMTP Username",description:"Username for SMTP authentication.",inputType:"text"},email_smtp_password:{key:"email_smtp_password",label:"SMTP Password",description:"Password or API key for SMTP authentication.",inputType:"secret"},email_smtp_tls:{key:"email_smtp_tls",label:"Use TLS",description:"Enable TLS encryption for SMTP connections.",inputType:"boolean"},email_from_address:{key:"email_from_address",label:"From Address",description:"Default sender email address (e.g., noreply@example.com).",inputType:"text"},email_from_name:{key:"email_from_name",label:"From Name",description:'Default sender display name (e.g., "My App").',inputType:"text"},webhook_enabled:{key:"webhook_enabled",label:"Enable Webhooks",description:"Send HTTP notifications for auth events (signup, login, etc.).",inputType:"boolean"},webhook_url:{key:"webhook_url",label:"Webhook URL",description:"Endpoint to receive webhook POST requests.",inputType:"text"},webhook_secret:{key:"webhook_secret",label:"Webhook Secret",description:"Secret used to sign webhook payloads (HMAC-SHA256).",inputType:"secret"},webhook_timeout:{key:"webhook_timeout",label:"Timeout",description:"Maximum time to wait for webhook response.",inputType:"duration",min:5,presets:[{label:"10 seconds",value:"10"},{label:"30 seconds",value:"30"},{label:"60 seconds",value:"60"}]},webhook_retries:{key:"webhook_retries",label:"Max Retries",description:"Number of retry attempts for failed webhooks.",inputType:"select",presets:[{label:"0 (No retries)",value:"0"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"}]},server_frontend_url:{key:"server_frontend_url",label:"Frontend URL",description:"URL of your frontend app (for redirects and email links).",inputType:"text"},server_base_path:{key:"server_base_path",label:"Base Path",description:"Base path for auth endpoints (e.g., /auth).",inputType:"text"},server_trust_proxy:{key:"server_trust_proxy",label:"Trust Proxy",description:"Trust X-Forwarded-For headers. Enable if behind a reverse proxy.",inputType:"boolean"},privacy_period_secs:{key:"privacy_period_secs",label:"Privacy Period",description:"How long deposits are held before withdrawal to provide timing privacy. Longer periods provide better privacy but delay user access to funds.",inputType:"duration",min:0,presets:[{label:"Disabled",value:"0"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"14 days",value:"1209600"},{label:"30 days",value:"2592000"}],warningThreshold:{below:3600,message:"Very short privacy periods may not provide adequate timing protection."}},withdrawal_poll_interval_secs:{key:"withdrawal_poll_interval_secs",label:"Worker Poll Interval",description:"How often the withdrawal worker checks for deposits ready to process. Lower values process faster but increase server load.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"}],warningThreshold:{below:60,message:"Polling more than once per minute may cause excessive load."}},withdrawal_batch_size:{key:"withdrawal_batch_size",label:"Batch Size",description:"Maximum number of withdrawals to process in a single batch. Higher values improve throughput but may cause timeouts.",inputType:"select",min:1,max:100,presets:[{label:"1 (Sequential)",value:"1"},{label:"5",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100 (Max)",value:"100"}]},withdrawal_timeout_secs:{key:"withdrawal_timeout_secs",label:"Transaction Timeout",description:"How long to wait for a withdrawal transaction to confirm before considering it failed.",inputType:"duration",min:30,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"2 minutes",value:"120"},{label:"5 minutes",value:"300"}],warningThreshold:{below:30,message:"Very short timeouts may cause premature failure on slow networks."}},withdrawal_max_retries:{key:"withdrawal_max_retries",label:"Max Retries",description:"Number of times to retry a failed withdrawal before marking it as permanently failed.",inputType:"select",min:0,max:10,presets:[{label:"0 (No retries)",value:"0"},{label:"1",value:"1"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},withdrawal_percentage:{key:"withdrawal_percentage",label:"Withdrawal Percentage",description:"Percentage of ready funds to withdraw each cycle. Lower values spread withdrawals over time for better privacy.",inputType:"percentage",min:1,max:100,step:5,presets:[{label:"25%",value:"25"},{label:"50%",value:"50"},{label:"75%",value:"75"},{label:"100% (All at once)",value:"100"}],warningThreshold:{above:75,message:"High percentages may reduce timing privacy by processing most withdrawals together."}},partial_withdrawal_count:{key:"partial_withdrawal_count",label:"Partial Withdrawals",description:"Maximum partial withdrawals per batch. Partial withdrawals add noise to timing analysis. Set to 0 to disable.",inputType:"select",min:0,presets:[{label:"Disabled",value:"0"},{label:"1",value:"1"},{label:"3",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},partial_withdrawal_min_lamports:{key:"partial_withdrawal_min_lamports",label:"Min Balance for Partial",description:"Minimum account balance (in lamports) required before partial withdrawals are considered. 1 SOL = 1,000,000,000 lamports.",inputType:"select",min:0,presets:[{label:"0.1 SOL",value:"100000000"},{label:"0.5 SOL",value:"500000000"},{label:"1 SOL",value:"1000000000"},{label:"5 SOL",value:"5000000000"},{label:"10 SOL",value:"10000000000"}]},rate_limit_auth:{key:"rate_limit_auth",label:"Auth Request Limit",description:"Maximum authentication attempts (login, register, password reset) per IP per window. Protects against brute force attacks.",inputType:"select",min:1,unit:"requests",presets:[{label:"5 (Strict)",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"20",value:"20"},{label:"50 (Permissive)",value:"50"}],warningThreshold:{above:20,message:"High auth limits may allow brute force attempts."}},rate_limit_general:{key:"rate_limit_general",label:"General Request Limit",description:"Maximum general API requests per IP per window. Affects all non-auth endpoints.",inputType:"select",min:1,unit:"requests",presets:[{label:"30",value:"30"},{label:"60 (Recommended)",value:"60"},{label:"120",value:"120"},{label:"300",value:"300"}]},rate_limit_credit:{key:"rate_limit_credit",label:"Credit Request Limit",description:"Maximum credit/balance check requests per IP per window. Higher for apps that poll balance frequently.",inputType:"select",min:1,unit:"requests",presets:[{label:"10",value:"10"},{label:"30 (Recommended)",value:"30"},{label:"60",value:"60"},{label:"120",value:"120"}]},rate_limit_window:{key:"rate_limit_window",label:"Rate Limit Window",description:'Time window for rate limiting. All limits above are "per window". Shorter windows are stricter.',inputType:"duration",min:1,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"}]},deposit_quick_action_tokens:{key:"deposit_quick_action_tokens",label:"Quick Action Tokens",description:"Comma-separated token symbols shown as quick action buttons. First token is the default.",inputType:"tokenSymbolList"},deposit_custom_tokens:{key:"deposit_custom_tokens",label:"Custom Dropdown Tokens",description:'Comma-separated token symbols shown in the "Custom" dropdown. Leave empty to show all.',inputType:"tokenSymbolList"},deposit_custom_tokens_json:{key:"deposit_custom_tokens_json",label:"Custom Token Definitions",description:"Add tokens beyond the built-in list. Define symbol, mint address, decimals, and logo URL.",inputType:"tokenList"}},cn={"auth.apple":{label:"Apple Sign-In",description:"Configure Sign in with Apple OAuth integration.",icon:""},"auth.email":{label:"Email Authentication",description:"Configure email/password authentication settings.",icon:""},"auth.google":{label:"Google Sign-In",description:"Configure Google OAuth integration.",icon:""},"auth.solana":{label:"Solana Wallet Auth",description:"Configure Solana wallet signature authentication.",icon:""},"auth.webauthn":{label:"WebAuthn / Passkeys",description:"Configure FIDO2/WebAuthn passwordless authentication.",icon:""},deposit:{label:"Deposit Settings",description:"Configure token lists and deposit flow display options.",icon:""},email:{label:"Email / SMTP",description:"Configure outbound email delivery for verification, password reset, and notifications.",icon:""},features:{label:"Feature Flags",description:"Enable or disable major platform features.",icon:""},privacy:{label:"Privacy Settings",description:"Control the privacy period for deposits. Longer periods provide better timing privacy but delay fund availability.",icon:""},rate_limit:{label:"Rate Limiting",description:"Protect the system from abuse by limiting request rates. Balance security with user experience.",icon:""},security:{label:"Security",description:"Configure CORS, cookies, sessions, and JWT settings.",icon:""},server:{label:"Server",description:"Server infrastructure settings. Some may be overridden by environment variables.",icon:""},webhook:{label:"Webhooks",description:"Configure HTTP webhook notifications for auth events.",icon:""},withdrawal:{label:"Withdrawal Worker",description:"Configure how the automated withdrawal processor handles pending withdrawals. These settings affect throughput and privacy.",icon:""}};function dn({showDescriptions:s=!0,className:t="",onSave:o}){const{settings:a,isLoading:r,isUpdating:n,error:c,fetchSettings:i,updateSettings:d}=Ds.useSystemSettings(),[u,p]=l.useState({}),[f,h]=l.useState(null),[w,g]=l.useState(!1);l.useEffect(()=>{i()},[i]),l.useEffect(()=>{if(w){const S=setTimeout(()=>g(!1),3e3);return()=>clearTimeout(S)}},[w]);const m=l.useCallback((S,x)=>{p(k=>({...k,[S]:x})),h(null),g(!1)},[]),y=l.useCallback(async()=>{const S=Object.entries(u).map(([x,k])=>({key:x,value:k}));if(S.length!==0)try{await d(S),p({}),h(null),g(!0),o?.()}catch(x){h(x instanceof Error?x.message:"Failed to save settings")}},[u,d,o]),A=l.useCallback(()=>{p({}),h(null),g(!1)},[]),b=Object.keys(u).length>0,v=Object.keys(u).length;if(r&&Object.keys(a).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(c)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(G.ErrorMessage,{error:c.message})});const j=Object.keys(a).sort();return j.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${t}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${t}`,children:[f&&e.jsx(G.ErrorMessage,{error:f}),w&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),j.map(S=>e.jsx(un,{category:S,settings:a[S],edits:u,showDescription:s,onChange:m},S)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[b&&e.jsxs("span",{className:"cedros-settings-change-count",children:[v," unsaved change",v!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:A,disabled:!b||n,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:y,disabled:!b||n,children:n?e.jsx(V.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}function un({category:s,settings:t,edits:o,showDescription:a,onChange:r}){const n=cn[s]||{label:s,description:"",icon:"⚙️"};return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:n.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:n.label}),a&&n.description&&e.jsx("p",{className:"cedros-settings-section-description",children:n.description})]})]}),e.jsx("div",{className:"cedros-settings-grid",children:t.map(c=>e.jsx(hn,{setting:c,editValue:o[c.key],onChange:r},c.key))})]})}function hn({setting:s,editValue:t,onChange:o}){const a=ln[s.key],r=t??s.value,n=t!==void 0&&t!==s.value,c=l.useMemo(()=>{if(!a?.warningThreshold)return null;const i=parseInt(r,10);if(isNaN(i))return null;const{above:d,below:u,message:p}=a.warningThreshold;return d!==void 0&&i>d||u!==void 0&&i<u?p:null},[r,a?.warningThreshold]);return a?e.jsxs("div",{className:`cedros-setting-row ${n?"cedros-setting-row-changed":""} ${c?"cedros-setting-row-warning":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:a.label}),e.jsx("span",{className:"cedros-setting-description",children:a.description})]}),e.jsxs("div",{className:"cedros-setting-control",children:[a.inputType==="duration"&&e.jsx(pn,{value:r,onChange:i=>o(s.key,i),presets:a.presets,min:a.min}),a.inputType==="percentage"&&e.jsx(mn,{value:r,onChange:i=>o(s.key,i),min:a.min??1,max:a.max??100,step:a.step??5,presets:a.presets}),a.inputType==="select"&&e.jsx(fn,{value:r,onChange:i=>o(s.key,i),presets:a.presets??[],unit:a.unit}),a.inputType==="number"&&e.jsx(gn,{value:r,onChange:i=>o(s.key,i),min:a.min,max:a.max,unit:a.unit}),a.inputType==="tokenList"&&e.jsx(yn,{value:r,onChange:i=>o(s.key,i)}),a.inputType==="text"&&e.jsx("input",{type:"text",value:r,onChange:i=>o(s.key,i.target.value),className:"cedros-setting-input",placeholder:a.label}),a.inputType==="boolean"&&e.jsx(wn,{value:r,onChange:i=>o(s.key,i)}),a.inputType==="secret"&&e.jsx(bn,{value:r,onChange:i=>o(s.key,i),multiline:a.multiline}),a.inputType==="tokenSymbolList"&&e.jsx(xn,{value:r,onChange:i=>o(s.key,i)}),c&&e.jsx("div",{className:"cedros-setting-warning",children:c})]})]}):e.jsxs("div",{className:`cedros-setting-row ${n?"cedros-setting-row-changed":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:s.key}),s.description&&e.jsx("span",{className:"cedros-setting-description",children:s.description})]}),e.jsx("div",{className:"cedros-setting-input-wrapper",children:e.jsx("input",{type:"text",value:r,onChange:i=>o(s.key,i.target.value),className:"cedros-setting-input"})})]})}function pn({value:s,onChange:t,presets:o,min:a=0}){const r=parseInt(s,10)||0,n=an(r),c=l.useCallback(d=>{d.target.value&&t(d.target.value)},[t]),i=l.useCallback(d=>{const u=Math.max(a,parseInt(d.target.value,10)||0);t(String(u))},[t,a]);return e.jsxs("div",{className:"cedros-duration-input",children:[o&&o.length>0&&e.jsxs("select",{value:o.find(d=>d.value===s)?.value??"",onChange:c,className:"cedros-setting-select",children:[e.jsx("option",{value:"",children:"Custom..."}),o.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))]}),e.jsxs("div",{className:"cedros-duration-custom",children:[e.jsx("input",{type:"number",value:r,onChange:i,min:a,className:"cedros-setting-input cedros-setting-input-sm"}),e.jsx("span",{className:"cedros-setting-unit",children:"seconds"}),e.jsxs("span",{className:"cedros-duration-display",children:["= ",n]})]})]})}function mn({value:s,onChange:t,min:o,max:a,step:r,presets:n}){const c=parseInt(s,10)||o,i=l.useCallback(u=>{t(u.target.value)},[t]),d=l.useCallback(u=>{t(u)},[t]);return e.jsxs("div",{className:"cedros-percentage-input",children:[e.jsxs("div",{className:"cedros-percentage-slider-row",children:[e.jsx("input",{type:"range",value:c,onChange:i,min:o,max:a,step:r,className:"cedros-percentage-slider"}),e.jsxs("span",{className:"cedros-percentage-value",children:[c,"%"]})]}),n&&n.length>0&&e.jsx("div",{className:"cedros-preset-buttons",children:n.map(u=>e.jsx("button",{type:"button",className:`cedros-preset-button ${u.value===s?"cedros-preset-button-active":""}`,onClick:()=>d(u.value),children:u.label},u.value))})]})}function fn({value:s,onChange:t,presets:o,unit:a}){const r=!o.some(i=>i.value===s),n=l.useCallback(i=>{i.target.value!=="__custom__"&&t(i.target.value)},[t]),c=l.useCallback(i=>{t(i.target.value)},[t]);return e.jsxs("div",{className:"cedros-select-input",children:[e.jsxs("select",{value:r?"__custom__":s,onChange:n,className:"cedros-setting-select",children:[o.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value)),e.jsx("option",{value:"__custom__",children:"Custom..."})]}),r&&e.jsxs("div",{className:"cedros-select-custom",children:[e.jsx("input",{type:"number",value:s,onChange:c,className:"cedros-setting-input cedros-setting-input-sm"}),a&&e.jsx("span",{className:"cedros-setting-unit",children:a})]})]})}function gn({value:s,onChange:t,min:o,max:a,unit:r}){const n=l.useCallback(c=>{t(c.target.value)},[t]);return e.jsxs("div",{className:"cedros-number-input",children:[e.jsx("input",{type:"number",value:s,onChange:n,min:o,max:a,className:"cedros-setting-input"}),r&&e.jsx("span",{className:"cedros-setting-unit",children:r})]})}function wn({value:s,onChange:t}){const o=s==="true",a=l.useCallback(()=>{t(o?"false":"true")},[o,t]);return e.jsxs("button",{type:"button",role:"switch","aria-checked":o,className:`cedros-toggle ${o?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:a,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:o?"Enabled":"Disabled"})]})}function bn({value:s,onChange:t,multiline:o}){const[a,r]=l.useState(!1),[n,c]=l.useState(!1),i=s&&s.length>0,d=l.useCallback(()=>{r(!0),c(!0)},[]),u=l.useCallback(()=>{r(!1),c(!1)},[]),p=l.useCallback(f=>{t(f.target.value)},[t]);return!a&&i?e.jsxs("div",{className:"cedros-secret-input cedros-secret-input-masked",children:[e.jsx("span",{className:"cedros-secret-masked",children:"•".repeat(Math.min(s.length,20))}),e.jsx("button",{type:"button",className:"cedros-secret-edit-btn",onClick:d,children:"Edit"})]}):e.jsxs("div",{className:"cedros-secret-input",children:[o?e.jsx("textarea",{value:s,onChange:p,className:"cedros-setting-input cedros-setting-textarea",placeholder:"Enter secret value...",rows:4}):e.jsx("input",{type:n?"text":"password",value:s,onChange:p,className:"cedros-setting-input",placeholder:"Enter secret value..."}),e.jsxs("div",{className:"cedros-secret-actions",children:[!o&&e.jsx("button",{type:"button",className:"cedros-secret-toggle-btn",onClick:()=>c(!n),children:n?"Hide":"Show"}),a&&e.jsx("button",{type:"button",className:"cedros-secret-done-btn",onClick:u,children:"Done"})]})]})}const wr=["SOL","USDC","USDT","EURC","USD1","PYUSD","USDH","CASH","BONK","ORE"];function yn({value:s,onChange:t}){const o=l.useMemo(()=>{try{return JSON.parse(s||"[]")}catch{return[]}},[s]),a=l.useCallback(i=>{t(JSON.stringify(i))},[t]),r=l.useCallback(()=>{a([...o,{symbol:"",mint:"",decimals:6}])},[o,a]),n=l.useCallback((i,d,u)=>{const p=[...o];p[i]={...p[i],[d]:u},a(p)},[o,a]),c=l.useCallback(i=>{a(o.filter((d,u)=>u!==i))},[o,a]);return e.jsxs("div",{className:"cedros-token-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Built-in tokens:"}),e.jsx("div",{className:"cedros-token-presets-list",children:wr.map(i=>e.jsx("span",{className:"cedros-token-preset-chip",children:i},i))})]}),o.length===0&&e.jsx("p",{className:"cedros-token-list-empty",children:"No custom tokens added. Use the built-in tokens above or add your own."}),o.map((i,d)=>e.jsxs("div",{className:"cedros-token-row",children:[e.jsxs("div",{className:"cedros-token-row-fields",children:[e.jsx("input",{type:"text",placeholder:"Symbol",value:i.symbol,onChange:u=>n(d,"symbol",u.target.value.toUpperCase()),className:"cedros-setting-input cedros-token-input-symbol",maxLength:10}),e.jsx("input",{type:"text",placeholder:"Mint address",value:i.mint,onChange:u=>n(d,"mint",u.target.value),className:"cedros-setting-input cedros-token-input-mint"}),e.jsx("input",{type:"number",placeholder:"Decimals",value:i.decimals,onChange:u=>n(d,"decimals",parseInt(u.target.value,10)||0),className:"cedros-setting-input cedros-token-input-decimals",min:0,max:18}),e.jsx("input",{type:"text",placeholder:"Logo URL (optional)",value:i.logoUrl||"",onChange:u=>n(d,"logoUrl",u.target.value||void 0),className:"cedros-setting-input cedros-token-input-logo"})]}),e.jsx("button",{type:"button",className:"cedros-token-remove-btn",onClick:()=>c(d),title:"Remove token",children:"×"})]},d)),e.jsx("button",{type:"button",className:"cedros-token-add-btn",onClick:r,children:"+ Add Token"})]})}function xn({value:s,onChange:t}){const o=l.useMemo(()=>s.split(",").map(n=>n.trim()).filter(Boolean),[s]),a=l.useCallback(n=>{if(!n||o.includes(n))return;const c=[...o,n].join(", ");t(c)},[o,t]),r=l.useCallback(n=>{const c=o.filter(i=>i!==n).join(", ");t(c)},[o,t]);return e.jsxs("div",{className:"cedros-token-symbol-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Click to add:"}),e.jsx("div",{className:"cedros-token-presets-list",children:wr.map(n=>{const c=o.includes(n);return e.jsxs("button",{type:"button",className:`cedros-token-preset-chip ${c?"cedros-token-preset-chip-selected":""}`,onClick:()=>c?r(n):a(n),title:c?`Remove ${n}`:`Add ${n}`,children:[n,c&&e.jsx("span",{className:"cedros-token-chip-check",children:"✓"})]},n)})})]}),e.jsx("input",{type:"text",value:s,onChange:n=>t(n.target.value),className:"cedros-setting-input",placeholder:"USDC, SOL, BONK..."})]})}class An{client;constructor(t,o,a){this.client=new _.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a})}async getStatus(){try{return await this.client.get("/setup/status")}catch(t){throw _.handleApiError(t,"Failed to check setup status")}}async createFirstAdmin(t){try{return await this.client.post("/setup/admin",t)}catch(o){throw _.handleApiError(o,"Failed to create admin account")}}}function qs(){const{config:s}=_.useCedrosLogin(),[t,o]=l.useState(null),[a,r]=l.useState(!1),[n,c]=l.useState(!1),[i,d]=l.useState(null),u=l.useRef(0),p=l.useMemo(()=>new An(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),f=l.useRef(p);f.current=p;const h=l.useCallback(async()=>{r(!0),d(null);const g=++u.current;try{const m=await f.current.getStatus();if(g!==u.current)return;o(m)}catch(m){if(g!==u.current)return;d(m instanceof Error?m:new Error("Failed to check setup status"))}finally{g===u.current&&r(!1)}},[]),w=l.useCallback(async g=>{c(!0),d(null);try{const m=await f.current.createFirstAdmin(g);return await h(),m}catch(m){const y=m instanceof Error?m:new Error("Failed to create admin");throw d(y),y}finally{c(!1)}},[h]);return{status:t,isLoading:a,isCreating:n,error:i,checkStatus:h,createAdmin:w}}const vn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,at=8;function jn(s){const t={};return s.email?vn.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<at&&(t.password=`Password must be at least ${at} characters`):t.password="Password is required",s.confirmPassword?s.password!==s.confirmPassword&&(t.confirmPassword="Passwords do not match"):t.confirmPassword="Please confirm your password",t}function br({onComplete:s,className:t=""}){const{status:o,isLoading:a,isCreating:r,error:n,checkStatus:c,createAdmin:i}=qs(),[d,u]=l.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[p,f]=l.useState({}),[h,w]=l.useState(!1);l.useEffect(()=>{c()},[c]);const g=l.useCallback(y=>A=>{u(b=>({...b,[y]:A.target.value})),f(b=>({...b,[y]:void 0}))},[]),m=l.useCallback(async y=>{y.preventDefault();const A=jn(d);if(Object.keys(A).length>0){f(A);return}try{await i({email:d.email,password:d.password,name:d.name||void 0,orgName:d.orgName||void 0}),w(!0),s?.()}catch{}},[d,i,s]);return a?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):o&&!o.needsSetup?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):h?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:m,children:[n&&e.jsx(G.ErrorMessage,{error:n.message}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-email",className:"cedros-setup__label",children:["Email Address ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-email",type:"email",className:`cedros-setup__input ${p.email?"cedros-setup__input--error":""}`,value:d.email,onChange:g("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:r}),p.email&&e.jsx("span",{className:"cedros-setup__error",children:p.email})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-name",className:"cedros-setup__label",children:"Display Name"}),e.jsx("input",{id:"setup-name",type:"text",className:"cedros-setup__input",value:d.name,onChange:g("name"),placeholder:"Admin",autoComplete:"name",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:d.orgName,onChange:g("orgName"),placeholder:"My Organization",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${p.password?"cedros-setup__input--error":""}`,value:d.password,onChange:g("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:r}),p.password&&e.jsx("span",{className:"cedros-setup__error",children:p.password})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-confirm-password",className:"cedros-setup__label",children:["Confirm Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-confirm-password",type:"password",className:`cedros-setup__input ${p.confirmPassword?"cedros-setup__input--error":""}`,value:d.confirmPassword,onChange:g("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:r}),p.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:p.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Creating Account..."})]}):"Create Admin Account"})]}),e.jsxs("div",{className:"cedros-setup__footer",children:[e.jsx("p",{className:"cedros-setup__note",children:"This will be the first administrator account for your installation."}),o?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",o.serverVersion]})]})]})})}const kn=["security","rate_limit"];function Nn({className:s}){return e.jsx(qt.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:kn,className:s})}const it=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}],Cn={mailgun:"smtp.mailgun.org",sendgrid:"smtp.sendgrid.net",postmark:"smtp.postmarkapp.com",ses:"email-smtp.us-east-1.amazonaws.com",resend:"smtp.resend.com"},Sn=["email_provider","email_smtp_password","email_from_address","email_from_name"],En=["email_provider","email_smtp_host","email_smtp_port","email_smtp_user","email_smtp_password","email_smtp_tls","email_from_address","email_from_name"];function Pn({className:s}){const{settings:t,edits:o,isLoading:a,autosaveStatus:r,autosaveError:n,error:c,fetchSettings:i,handleChange:d,getEffectiveValue:u}=rs.useSettingsAutosave(),[p,f]=l.useState("email");l.useEffect(()=>{i()},[i]);const h=it.find(b=>b.id===p),w=h?.category??"",m=(u("email_provider")||"custom")==="custom",y=l.useMemo(()=>{const b=t[w]??[];if(p!=="email")return b;const v=m?En:Sn;return b.filter(j=>v.includes(j.key)).sort((j,S)=>v.indexOf(j.key)-v.indexOf(S.key))},[t,w,p,m]),A=(b,v)=>{if(d(b,v),b==="email_provider"&&v!=="custom"){const j=Cn[v];j&&(d("email_smtp_host",j),d("email_smtp_port","587"),d("email_smtp_tls","true"))}};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(G.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsx(rs.AutosaveStatus,{status:r,error:n})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:it.map(b=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${p===b.id?"cedros-admin-tab-active":""}`,onClick:()=>f(b.id),"aria-selected":p===b.id,role:"tab",children:b.label},b.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:y.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",h?.label??"this section","."]})}):e.jsx(rs.SettingsSection,{settings:y,edits:o,onChange:p==="email"?A:d})})]})}const ae={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]})},Ln=[{id:"users",label:"Users",icon:ae.users},{id:"team",label:"Team",icon:ae.members},{id:"deposits",label:"Deposits",icon:ae.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ae.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:ae.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ae.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ae.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ae.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:ae.server,group:"Configuration"}];function Tn({title:s="Dashboard",sections:t=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],defaultSection:o="users",refreshInterval:a=0,pageSize:r=20,onSectionChange:n,onSettingsClick:c,onLogoutClick:i,className:d=""}){const[u,p]=l.useState(o),[f,h]=l.useState(!0),{user:w,logout:g}=_.useCedrosLogin(),{activeOrg:m,role:y,isLoading:A,fetchOrgs:b,hasPermission:v}=Is.useOrgs(),{status:j,isLoading:S,checkStatus:x}=qs(),{features:k,isLoading:C}=te.useServerFeatures(),{canAccess:N}=te.useDashboardPermissions(),L=l.useCallback(B=>{p(B),n?.(B)},[n]),P=Ln.filter(B=>!(!t.includes(B.id)||B.requiredFeature&&!k[B.requiredFeature]||!N(B.id))),E=P.find(B=>B.id===u),T=!E&&!C;return l.useEffect(()=>{b(),x()},[b,x]),l.useEffect(()=>{T&&P.length>0&&p("users")},[T,P.length]),!S&&j?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${d}`,children:e.jsx(br,{onComplete:()=>x()})}):(A||S||C)&&!m?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${d}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):u==="team"&&!m?e.jsx("div",{className:`cedros-admin cedros-dashboard ${d}`,children:e.jsx(G.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${d}`,children:[e.jsxs("aside",{className:"cedros-dashboard__sidebar",children:[e.jsx("div",{className:"cedros-dashboard__sidebar-header",children:e.jsxs("div",{className:"cedros-dashboard__logo",children:[ae.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:s})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),P.filter(B=>!B.group).map(B=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===B.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(B.id),"aria-current":u===B.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:B.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:B.label})]},B.id))]}),P.some(B=>B.group==="Configuration")&&e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsxs("button",{type:"button",className:"cedros-dashboard__nav-label cedros-dashboard__nav-label--collapsible",onClick:()=>h(!f),"aria-expanded":f,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${f?"cedros-dashboard__nav-chevron--expanded":""}`,children:ae.chevronRight})]}),f&&P.filter(B=>B.group==="Configuration").map(B=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===B.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(B.id),"aria-current":u===B.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:B.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:B.label})]},B.id))]})]}),w&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(ge.ProfileDropdown,{name:w.name,email:w.email,picture:w.picture,onSettings:c,onLogout:i??g})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:s}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:ae.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:E?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(_n,{pageSize:r,currentUserId:w?.id}),u==="team"&&m&&e.jsx(Mn,{orgId:m.id,currentUserId:w?.id,hasPermission:v,role:y}),u==="deposits"&&e.jsx(Rn,{pageSize:r,refreshInterval:a}),u==="withdrawals"&&e.jsx(Bn,{pageSize:r,refreshInterval:a}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ut.AuthenticationSettings,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Wt.EmbeddedWalletSettings,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Pn,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Fs.CreditSystemSettings,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ot.ServerSettings,{})})]})]})]})}function _n({pageSize:s,currentUserId:t}){const[o,a]=l.useState(null),[r,n]=l.useState(null),[c,i]=l.useState(!1),[d,u]=l.useState(null),{getStats:p}=Ee.useAdminUsers(),{fetchSettings:f,getValue:h}=Ds.useSystemSettings(),[w,g]=l.useState(!1);l.useEffect(()=>{w||(f(),g(!0))},[f,w]);const m=l.useCallback(b=>{const v=h(b);return v===void 0?!1:v==="true"||v==="1"},[h]),y=l.useCallback(async()=>{i(!0),u(null);try{const b=await p();n(b)}catch(b){u(b instanceof Error?b.message:"Failed to load user stats")}finally{i(!1)}},[p]);l.useEffect(()=>{y()},[y]);const A=l.useMemo(()=>{const b=[{label:"Total Users",value:r?.total??"—"}],v=m("auth_email_enabled"),j=m("auth_google_enabled"),S=m("auth_apple_enabled"),x=m("auth_solana_enabled"),k=m("auth_webauthn_enabled"),C=m("feature_sso");return v&&b.push({label:"Email Users",value:r?.authMethodCounts.email??0}),j&&b.push({label:"Google Users",value:r?.authMethodCounts.google??0}),S&&b.push({label:"Apple Users",value:r?.authMethodCounts.apple??0}),x&&b.push({label:"Solana Users",value:r?.authMethodCounts.solana??0}),k&&b.push({label:"Passkey Users",value:r?.authMethodCounts.webauthn??0}),C&&b.push({label:"SSO Provider Users",value:r?.authMethodCounts.sso??0}),b},[r,m]);return o?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ee.AdminUserDetail,{userId:o.id,currentUserId:t,onBack:()=>a(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Ft.StatsBar,{stats:A,isLoading:c,onRefresh:y}),d&&e.jsx("p",{className:"cedros-admin-error-inline",children:d}),e.jsx(Ee.AdminUserList,{pageSize:s,currentUserId:t,onUserClick:b=>a(b)})]})}function Mn({orgId:s,currentUserId:t,hasPermission:o,role:a}){const[r,n]=l.useState("members"),{members:c,isLoading:i,error:d,fetchMembers:u,updateMemberRole:p,removeMember:f}=te.useMembers(s),{invites:h,isLoading:w,error:g,fetchInvites:m,createInvite:y,cancelInvite:A,resendInvite:b}=te.useInvites(s);l.useEffect(()=>{u(),m()},[u,m]);const v=o("invite:create"),j=o("invite:cancel"),S=h.length,x=c.reduce((L,P)=>(L[P.role]=(L[P.role]??0)+1,L),{}),k=x.owner??0,C=x.admin??0,N=x.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Ft.StatsBar,{stats:[{label:"Owners",value:k},{label:"Admins",value:C},{label:"Members",value:N},{label:"Pending Invites",value:S}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="members"?"cedros-admin-tab-active":""}`,onClick:()=>n("members"),"aria-selected":r==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${r==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>n("invites"),"aria-selected":r==="invites",role:"tab",children:["Pending Invites",S>0&&` (${S})`]}),a==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>n("permissions"),"aria-selected":r==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[r==="members"&&e.jsx(te.MemberList,{members:c,currentUserId:t,isLoading:i,error:d?.message,canManage:o("member:remove"),canChangeRoles:o("member:role_change"),onUpdateRole:p,onRemove:f}),r==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[v&&e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx("div",{className:"cedros-dashboard__section-header",children:e.jsx("h3",{className:"cedros-dashboard__section-title",children:"Send Invitation"})}),e.jsx(te.InviteForm,{onSubmit:y,isLoading:w,error:g?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(te.InviteList,{invites:h,isLoading:w,error:g?.message,canManage:j||v,onCancel:j?A:void 0,onResend:v?b:void 0})})]}),r==="permissions"&&a==="owner"&&e.jsx(te.PermissionsSection,{userRole:a})]})]})}function Rn({pageSize:s,refreshInterval:t}){const[o,a]=l.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(We.AdminDepositStats,{refreshInterval:t}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:o,onChange:r=>a(r.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(We.AdminDepositList,{statusFilter:o||void 0,pageSize:s,refreshInterval:t})]})]})}function Bn({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(fe.AdminWithdrawalStats,{refreshInterval:t}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(fe.AdminPrivacyPeriodDeposits,{pageSize:s,refreshInterval:t}),e.jsx(fe.AdminWithdrawalQueue,{pageSize:s,refreshInterval:t}),e.jsx(fe.AdminWithdrawalHistory,{pageSize:s,refreshInterval:t})]})]})}var xe={},ns,lt;function Dn(){return lt||(lt=1,ns=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ns}var as={},me={},ct;function we(){if(ct)return me;ct=1;let s;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return me.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},me.getSymbolTotalCodewords=function(a){return t[a]},me.getBCHDigit=function(o){let a=0;for(;o!==0;)a++,o>>>=1;return a},me.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');s=a},me.isKanjiModeEnabled=function(){return typeof s<"u"},me.toSJIS=function(a){return s(a)},me}var is={},dt;function zs(){return dt||(dt=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+o)}}s.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},s.from=function(a,r){if(s.isValid(a))return a;try{return t(a)}catch{return r}}})(is)),is}var ls,ut;function In(){if(ut)return ls;ut=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const o=Math.floor(t/8);return(this.buffer[o]>>>7-t%8&1)===1},put:function(t,o){for(let a=0;a<o;a++)this.putBit((t>>>o-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),t&&(this.buffer[o]|=128>>>this.length%8),this.length++}},ls=s,ls}var cs,ht;function Fn(){if(ht)return cs;ht=1;function s(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return s.prototype.set=function(t,o,a,r){const n=t*this.size+o;this.data[n]=a,r&&(this.reservedBit[n]=!0)},s.prototype.get=function(t,o){return this.data[t*this.size+o]},s.prototype.xor=function(t,o,a){this.data[t*this.size+o]^=a},s.prototype.isReserved=function(t,o){return this.reservedBit[t*this.size+o]},cs=s,cs}var ds={},pt;function Un(){return pt||(pt=1,(function(s){const t=we().getSymbolSize;s.getRowColCoords=function(a){if(a===1)return[];const r=Math.floor(a/7)+2,n=t(a),c=n===145?26:Math.ceil((n-13)/(2*r-2))*2,i=[n-7];for(let d=1;d<r-1;d++)i[d]=i[d-1]-c;return i.push(6),i.reverse()},s.getPositions=function(a){const r=[],n=s.getRowColCoords(a),c=n.length;for(let i=0;i<c;i++)for(let d=0;d<c;d++)i===0&&d===0||i===0&&d===c-1||i===c-1&&d===0||r.push([n[i],n[d]]);return r}})(ds)),ds}var us={},mt;function Wn(){if(mt)return us;mt=1;const s=we().getSymbolSize,t=7;return us.getPositions=function(a){const r=s(a);return[[0,0],[r-t,0],[0,r-t]]},us}var hs={},ft;function On(){return ft||(ft=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};s.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},s.from=function(r){return s.isValid(r)?parseInt(r,10):void 0},s.getPenaltyN1=function(r){const n=r.size;let c=0,i=0,d=0,u=null,p=null;for(let f=0;f<n;f++){i=d=0,u=p=null;for(let h=0;h<n;h++){let w=r.get(f,h);w===u?i++:(i>=5&&(c+=t.N1+(i-5)),u=w,i=1),w=r.get(h,f),w===p?d++:(d>=5&&(c+=t.N1+(d-5)),p=w,d=1)}i>=5&&(c+=t.N1+(i-5)),d>=5&&(c+=t.N1+(d-5))}return c},s.getPenaltyN2=function(r){const n=r.size;let c=0;for(let i=0;i<n-1;i++)for(let d=0;d<n-1;d++){const u=r.get(i,d)+r.get(i,d+1)+r.get(i+1,d)+r.get(i+1,d+1);(u===4||u===0)&&c++}return c*t.N2},s.getPenaltyN3=function(r){const n=r.size;let c=0,i=0,d=0;for(let u=0;u<n;u++){i=d=0;for(let p=0;p<n;p++)i=i<<1&2047|r.get(u,p),p>=10&&(i===1488||i===93)&&c++,d=d<<1&2047|r.get(p,u),p>=10&&(d===1488||d===93)&&c++}return c*t.N3},s.getPenaltyN4=function(r){let n=0;const c=r.data.length;for(let d=0;d<c;d++)n+=r.data[d];return Math.abs(Math.ceil(n*100/c/5)-10)*t.N4};function o(a,r,n){switch(a){case s.Patterns.PATTERN000:return(r+n)%2===0;case s.Patterns.PATTERN001:return r%2===0;case s.Patterns.PATTERN010:return n%3===0;case s.Patterns.PATTERN011:return(r+n)%3===0;case s.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case s.Patterns.PATTERN101:return r*n%2+r*n%3===0;case s.Patterns.PATTERN110:return(r*n%2+r*n%3)%2===0;case s.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}s.applyMask=function(r,n){const c=n.size;for(let i=0;i<c;i++)for(let d=0;d<c;d++)n.isReserved(d,i)||n.xor(d,i,o(r,d,i))},s.getBestMask=function(r,n){const c=Object.keys(s.Patterns).length;let i=0,d=1/0;for(let u=0;u<c;u++){n(u),s.applyMask(u,r);const p=s.getPenaltyN1(r)+s.getPenaltyN2(r)+s.getPenaltyN3(r)+s.getPenaltyN4(r);s.applyMask(u,r),p<d&&(d=p,i=u)}return i}})(hs)),hs}var Ie={},gt;function yr(){if(gt)return Ie;gt=1;const s=zs(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Ie.getBlocksCount=function(r,n){switch(n){case s.L:return t[(r-1)*4+0];case s.M:return t[(r-1)*4+1];case s.Q:return t[(r-1)*4+2];case s.H:return t[(r-1)*4+3];default:return}},Ie.getTotalCodewordsCount=function(r,n){switch(n){case s.L:return o[(r-1)*4+0];case s.M:return o[(r-1)*4+1];case s.Q:return o[(r-1)*4+2];case s.H:return o[(r-1)*4+3];default:return}},Ie}var ps={},Ce={},wt;function qn(){if(wt)return Ce;wt=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let a=1;for(let r=0;r<255;r++)s[r]=a,t[a]=r,a<<=1,a&256&&(a^=285);for(let r=255;r<512;r++)s[r]=s[r-255]})(),Ce.log=function(a){if(a<1)throw new Error("log("+a+")");return t[a]},Ce.exp=function(a){return s[a]},Ce.mul=function(a,r){return a===0||r===0?0:s[t[a]+t[r]]},Ce}var bt;function zn(){return bt||(bt=1,(function(s){const t=qn();s.mul=function(a,r){const n=new Uint8Array(a.length+r.length-1);for(let c=0;c<a.length;c++)for(let i=0;i<r.length;i++)n[c+i]^=t.mul(a[c],r[i]);return n},s.mod=function(a,r){let n=new Uint8Array(a);for(;n.length-r.length>=0;){const c=n[0];for(let d=0;d<r.length;d++)n[d]^=t.mul(r[d],c);let i=0;for(;i<n.length&&n[i]===0;)i++;n=n.slice(i)}return n},s.generateECPolynomial=function(a){let r=new Uint8Array([1]);for(let n=0;n<a;n++)r=s.mul(r,new Uint8Array([1,t.exp(n)]));return r}})(ps)),ps}var ms,yt;function Vn(){if(yt)return ms;yt=1;const s=zn();function t(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(a){this.degree=a,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(a.length+this.degree);r.set(a);const n=s.mod(r,this.genPoly),c=this.degree-n.length;if(c>0){const i=new Uint8Array(this.degree);return i.set(n,c),i}return n},ms=t,ms}var fs={},gs={},ws={},xt;function xr(){return xt||(xt=1,ws.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),ws}var de={},At;function Ar(){if(At)return de;At=1;const s="[0-9]+",t="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
2050
- ]))+`;de.KANJI=new RegExp(o,"g"),de.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),de.BYTE=new RegExp(a,"g"),de.NUMERIC=new RegExp(s,"g"),de.ALPHANUMERIC=new RegExp(t,"g");const r=new RegExp("^"+o+"$"),n=new RegExp("^"+s+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return de.testKanji=function(d){return r.test(d)},de.testNumeric=function(d){return n.test(d)},de.testAlphanumeric=function(d){return c.test(d)},de}var vt;function be(){return vt||(vt=1,(function(s){const t=xr(),o=Ar();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(n,c){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?n.ccBits[0]:c<27?n.ccBits[1]:n.ccBits[2]},s.getBestModeForData=function(n){return o.testNumeric(n)?s.NUMERIC:o.testAlphanumeric(n)?s.ALPHANUMERIC:o.testKanji(n)?s.KANJI:s.BYTE},s.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},s.isValid=function(n){return n&&n.bit&&n.ccBits};function a(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+r)}}s.from=function(n,c){if(s.isValid(n))return n;try{return a(n)}catch{return c}}})(gs)),gs}var jt;function Hn(){return jt||(jt=1,(function(s){const t=we(),o=yr(),a=zs(),r=be(),n=xr(),c=7973,i=t.getBCHDigit(c);function d(h,w,g){for(let m=1;m<=40;m++)if(w<=s.getCapacity(m,g,h))return m}function u(h,w){return r.getCharCountIndicator(h,w)+4}function p(h,w){let g=0;return h.forEach(function(m){const y=u(m.mode,w);g+=y+m.getBitsLength()}),g}function f(h,w){for(let g=1;g<=40;g++)if(p(h,g)<=s.getCapacity(g,w,r.MIXED))return g}s.from=function(w,g){return n.isValid(w)?parseInt(w,10):g},s.getCapacity=function(w,g,m){if(!n.isValid(w))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=r.BYTE);const y=t.getSymbolTotalCodewords(w),A=o.getTotalCodewordsCount(w,g),b=(y-A)*8;if(m===r.MIXED)return b;const v=b-u(m,w);switch(m){case r.NUMERIC:return Math.floor(v/10*3);case r.ALPHANUMERIC:return Math.floor(v/11*2);case r.KANJI:return Math.floor(v/13);case r.BYTE:default:return Math.floor(v/8)}},s.getBestVersionForData=function(w,g){let m;const y=a.from(g,a.M);if(Array.isArray(w)){if(w.length>1)return f(w,y);if(w.length===0)return 1;m=w[0]}else m=w;return d(m.mode,m.getLength(),y)},s.getEncodedBits=function(w){if(!n.isValid(w)||w<7)throw new Error("Invalid QR Code version");let g=w<<12;for(;t.getBCHDigit(g)-i>=0;)g^=c<<t.getBCHDigit(g)-i;return w<<12|g}})(fs)),fs}var bs={},kt;function Qn(){if(kt)return bs;kt=1;const s=we(),t=1335,o=21522,a=s.getBCHDigit(t);return bs.getEncodedBits=function(n,c){const i=n.bit<<3|c;let d=i<<10;for(;s.getBCHDigit(d)-a>=0;)d^=t<<s.getBCHDigit(d)-a;return(i<<10|d)^o},bs}var ys={},xs,Nt;function Kn(){if(Nt)return xs;Nt=1;const s=be();function t(o){this.mode=s.NUMERIC,this.data=o.toString()}return t.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(a){let r,n,c;for(r=0;r+3<=this.data.length;r+=3)n=this.data.substr(r,3),c=parseInt(n,10),a.put(c,10);const i=this.data.length-r;i>0&&(n=this.data.substr(r),c=parseInt(n,10),a.put(c,i*3+1))},xs=t,xs}var As,Ct;function $n(){if(Ct)return As;Ct=1;const s=be(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(a){this.mode=s.ALPHANUMERIC,this.data=a}return o.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(r){let n;for(n=0;n+2<=this.data.length;n+=2){let c=t.indexOf(this.data[n])*45;c+=t.indexOf(this.data[n+1]),r.put(c,11)}this.data.length%2&&r.put(t.indexOf(this.data[n]),6)},As=o,As}var vs,St;function Gn(){if(St)return vs;St=1;const s=be();function t(o){this.mode=s.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return t.getBitsLength=function(a){return a*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(o){for(let a=0,r=this.data.length;a<r;a++)o.put(this.data[a],8)},vs=t,vs}var js,Et;function Yn(){if(Et)return js;Et=1;const s=be(),t=we();function o(a){this.mode=s.KANJI,this.data=a}return o.getBitsLength=function(r){return r*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(a){let r;for(r=0;r<this.data.length;r++){let n=t.toSJIS(this.data[r]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
2051
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),a.put(n,13)}},js=o,js}var ks={exports:{}},Pt;function Jn(){return Pt||(Pt=1,(function(s){var t={single_source_shortest_paths:function(o,a,r){var n={},c={};c[a]=0;var i=t.PriorityQueue.make();i.push(a,0);for(var d,u,p,f,h,w,g,m,y;!i.empty();){d=i.pop(),u=d.value,f=d.cost,h=o[u]||{};for(p in h)h.hasOwnProperty(p)&&(w=h[p],g=f+w,m=c[p],y=typeof c[p]>"u",(y||m>g)&&(c[p]=g,i.push(p,g),n[p]=u))}if(typeof r<"u"&&typeof c[r]>"u"){var A=["Could not find a path from ",a," to ",r,"."].join("");throw new Error(A)}return n},extract_shortest_path_from_predecessor_list:function(o,a){for(var r=[],n=a;n;)r.push(n),o[n],n=o[n];return r.reverse(),r},find_path:function(o,a,r){var n=t.single_source_shortest_paths(o,a,r);return t.extract_shortest_path_from_predecessor_list(n,r)},PriorityQueue:{make:function(o){var a=t.PriorityQueue,r={},n;o=o||{};for(n in a)a.hasOwnProperty(n)&&(r[n]=a[n]);return r.queue=[],r.sorter=o.sorter||a.default_sorter,r},default_sorter:function(o,a){return o.cost-a.cost},push:function(o,a){var r={value:o,cost:a};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=t})(ks)),ks.exports}var Lt;function Xn(){return Lt||(Lt=1,(function(s){const t=be(),o=Kn(),a=$n(),r=Gn(),n=Yn(),c=Ar(),i=we(),d=Jn();function u(A){return unescape(encodeURIComponent(A)).length}function p(A,b,v){const j=[];let S;for(;(S=A.exec(v))!==null;)j.push({data:S[0],index:S.index,mode:b,length:S[0].length});return j}function f(A){const b=p(c.NUMERIC,t.NUMERIC,A),v=p(c.ALPHANUMERIC,t.ALPHANUMERIC,A);let j,S;return i.isKanjiModeEnabled()?(j=p(c.BYTE,t.BYTE,A),S=p(c.KANJI,t.KANJI,A)):(j=p(c.BYTE_KANJI,t.BYTE,A),S=[]),b.concat(v,j,S).sort(function(k,C){return k.index-C.index}).map(function(k){return{data:k.data,mode:k.mode,length:k.length}})}function h(A,b){switch(b){case t.NUMERIC:return o.getBitsLength(A);case t.ALPHANUMERIC:return a.getBitsLength(A);case t.KANJI:return n.getBitsLength(A);case t.BYTE:return r.getBitsLength(A)}}function w(A){return A.reduce(function(b,v){const j=b.length-1>=0?b[b.length-1]:null;return j&&j.mode===v.mode?(b[b.length-1].data+=v.data,b):(b.push(v),b)},[])}function g(A){const b=[];for(let v=0;v<A.length;v++){const j=A[v];switch(j.mode){case t.NUMERIC:b.push([j,{data:j.data,mode:t.ALPHANUMERIC,length:j.length},{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.ALPHANUMERIC:b.push([j,{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.KANJI:b.push([j,{data:j.data,mode:t.BYTE,length:u(j.data)}]);break;case t.BYTE:b.push([{data:j.data,mode:t.BYTE,length:u(j.data)}])}}return b}function m(A,b){const v={},j={start:{}};let S=["start"];for(let x=0;x<A.length;x++){const k=A[x],C=[];for(let N=0;N<k.length;N++){const L=k[N],P=""+x+N;C.push(P),v[P]={node:L,lastCount:0},j[P]={};for(let E=0;E<S.length;E++){const T=S[E];v[T]&&v[T].node.mode===L.mode?(j[T][P]=h(v[T].lastCount+L.length,L.mode)-h(v[T].lastCount,L.mode),v[T].lastCount+=L.length):(v[T]&&(v[T].lastCount=L.length),j[T][P]=h(L.length,L.mode)+4+t.getCharCountIndicator(L.mode,b))}}S=C}for(let x=0;x<S.length;x++)j[S[x]].end=0;return{map:j,table:v}}function y(A,b){let v;const j=t.getBestModeForData(A);if(v=t.from(b,j),v!==t.BYTE&&v.bit<j.bit)throw new Error('"'+A+'" cannot be encoded with mode '+t.toString(v)+`.
2052
- Suggested mode is: `+t.toString(j));switch(v===t.KANJI&&!i.isKanjiModeEnabled()&&(v=t.BYTE),v){case t.NUMERIC:return new o(A);case t.ALPHANUMERIC:return new a(A);case t.KANJI:return new n(A);case t.BYTE:return new r(A)}}s.fromArray=function(b){return b.reduce(function(v,j){return typeof j=="string"?v.push(y(j,null)):j.data&&v.push(y(j.data,j.mode)),v},[])},s.fromString=function(b,v){const j=f(b,i.isKanjiModeEnabled()),S=g(j),x=m(S,v),k=d.find_path(x.map,"start","end"),C=[];for(let N=1;N<k.length-1;N++)C.push(x.table[k[N]].node);return s.fromArray(w(C))},s.rawSplit=function(b){return s.fromArray(f(b,i.isKanjiModeEnabled()))}})(ys)),ys}var Tt;function Zn(){if(Tt)return as;Tt=1;const s=we(),t=zs(),o=In(),a=Fn(),r=Un(),n=Wn(),c=On(),i=yr(),d=Vn(),u=Hn(),p=Qn(),f=be(),h=Xn();function w(x,k){const C=x.size,N=n.getPositions(k);for(let L=0;L<N.length;L++){const P=N[L][0],E=N[L][1];for(let T=-1;T<=7;T++)if(!(P+T<=-1||C<=P+T))for(let M=-1;M<=7;M++)E+M<=-1||C<=E+M||(T>=0&&T<=6&&(M===0||M===6)||M>=0&&M<=6&&(T===0||T===6)||T>=2&&T<=4&&M>=2&&M<=4?x.set(P+T,E+M,!0,!0):x.set(P+T,E+M,!1,!0))}}function g(x){const k=x.size;for(let C=8;C<k-8;C++){const N=C%2===0;x.set(C,6,N,!0),x.set(6,C,N,!0)}}function m(x,k){const C=r.getPositions(k);for(let N=0;N<C.length;N++){const L=C[N][0],P=C[N][1];for(let E=-2;E<=2;E++)for(let T=-2;T<=2;T++)E===-2||E===2||T===-2||T===2||E===0&&T===0?x.set(L+E,P+T,!0,!0):x.set(L+E,P+T,!1,!0)}}function y(x,k){const C=x.size,N=u.getEncodedBits(k);let L,P,E;for(let T=0;T<18;T++)L=Math.floor(T/3),P=T%3+C-8-3,E=(N>>T&1)===1,x.set(L,P,E,!0),x.set(P,L,E,!0)}function A(x,k,C){const N=x.size,L=p.getEncodedBits(k,C);let P,E;for(P=0;P<15;P++)E=(L>>P&1)===1,P<6?x.set(P,8,E,!0):P<8?x.set(P+1,8,E,!0):x.set(N-15+P,8,E,!0),P<8?x.set(8,N-P-1,E,!0):P<9?x.set(8,15-P-1+1,E,!0):x.set(8,15-P-1,E,!0);x.set(N-8,8,1,!0)}function b(x,k){const C=x.size;let N=-1,L=C-1,P=7,E=0;for(let T=C-1;T>0;T-=2)for(T===6&&T--;;){for(let M=0;M<2;M++)if(!x.isReserved(L,T-M)){let B=!1;E<k.length&&(B=(k[E]>>>P&1)===1),x.set(L,T-M,B),P--,P===-1&&(E++,P=7)}if(L+=N,L<0||C<=L){L-=N,N=-N;break}}}function v(x,k,C){const N=new o;C.forEach(function(M){N.put(M.mode.bit,4),N.put(M.getLength(),f.getCharCountIndicator(M.mode,x)),M.write(N)});const L=s.getSymbolTotalCodewords(x),P=i.getTotalCodewordsCount(x,k),E=(L-P)*8;for(N.getLengthInBits()+4<=E&&N.put(0,4);N.getLengthInBits()%8!==0;)N.putBit(0);const T=(E-N.getLengthInBits())/8;for(let M=0;M<T;M++)N.put(M%2?17:236,8);return j(N,x,k)}function j(x,k,C){const N=s.getSymbolTotalCodewords(k),L=i.getTotalCodewordsCount(k,C),P=N-L,E=i.getBlocksCount(k,C),T=N%E,M=E-T,B=Math.floor(N/E),Y=Math.floor(P/E),le=Y+1,J=B-Y,q=new d(J);let R=0;const I=new Array(E),z=new Array(E);let X=0;const ee=new Uint8Array(x.buffer);for(let Q=0;Q<E;Q++){const ne=Q<M?Y:le;I[Q]=ee.slice(R,R+ne),z[Q]=q.encode(I[Q]),R+=ne,X=Math.max(X,ne)}const ue=new Uint8Array(N);let ce=0,W,U;for(W=0;W<X;W++)for(U=0;U<E;U++)W<I[U].length&&(ue[ce++]=I[U][W]);for(W=0;W<J;W++)for(U=0;U<E;U++)ue[ce++]=z[U][W];return ue}function S(x,k,C,N){let L;if(Array.isArray(x))L=h.fromArray(x);else if(typeof x=="string"){let B=k;if(!B){const Y=h.rawSplit(x);B=u.getBestVersionForData(Y,C)}L=h.fromString(x,B||40)}else throw new Error("Invalid data");const P=u.getBestVersionForData(L,C);if(!P)throw new Error("The amount of data is too big to be stored in a QR Code");if(!k)k=P;else if(k<P)throw new Error(`
2049
+ `),oe=12;function ao(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const o=Gt(s,he).split(" ");if(o.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${o.length}`);return o}function io(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Us(t,he))throw new Error("Invalid recovery phrase: checksum mismatch");const o=Fs(t,he);if(o.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${o.length}`);return D.toShamirShare(o)}function lo(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const o=Gt(s,he).split(" ");if(o.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${o.length}`);return o}function co(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Us(t,he))throw new Error("Invalid recovery phrase: checksum mismatch");const o=Fs(t,he);if(o.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${o.length}`);return D.toSeed(o)}function Yt(s){if(s.length!==oe)return!1;const t=s.join(" ").toLowerCase().trim();return Us(t,he)}function De(s){return he.includes(s.toLowerCase().trim())}function uo(s,t=5){const o=s.toLowerCase().trim();return o.length===0?[]:he.filter(a=>a.startsWith(o)).slice(0,t)}function ho(s){const t=[];for(let o=0;o<s.length;o+=4)t.push(s.slice(o,o+4));return t}function po(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function mo({className:s="",variant:t="default",size:o="md",children:a,menuItems:r=[],hideSignOut:n=!1}){const{user:c,isAuthenticated:i,isLoading:d,openLoginModal:u,logout:p}=D.useAuth(),[f,h]=l.useState(!1),[w,g]=l.useState(-1),m=l.useRef(null),y=l.useRef(null),A=l.useMemo(()=>[...r,...n?[]:[{label:"Sign out",onClick:p}]],[r,n,p]);l.useEffect(()=>{if(!f)return;const x=C=>{m.current&&!m.current.contains(C.target)&&(h(!1),g(-1))},k=C=>{C.key==="Escape"&&(h(!1),g(-1),y.current?.focus())};return document.addEventListener("mousedown",x),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k)}},[f]);const b=l.useCallback(x=>{if(!(!f||A.length===0))switch(x.key){case"ArrowDown":x.preventDefault(),g(k=>(k+1)%A.length);break;case"ArrowUp":x.preventDefault(),g(k=>(k-1+A.length)%A.length);break;case"Home":x.preventDefault(),g(0);break;case"End":x.preventDefault(),g(A.length-1);break;case"Enter":case" ":w>=0&&(x.preventDefault(),A[w].onClick(),h(!1),g(-1));break}},[f,w,A]),v=l.useCallback(()=>{A.length!==0&&(h(x=>!x),g(-1))},[A.length]),j={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},S={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(d)return e.jsx("button",{type:"button",className:`cedros-button ${S[t]} ${j[o]} ${s}`,disabled:!0,children:e.jsx(V.LoadingSpinner,{size:"sm"})});if(i&&c){const x=c.name||c.email||"User",k=Rs.sanitizeImageUrl(c.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:m,onKeyDown:b,children:[e.jsxs("button",{ref:y,type:"button",className:`cedros-button cedros-user-button ${j[o]} ${s}`,"aria-haspopup":"menu","aria-expanded":f,"aria-label":`User menu for ${x}`,onClick:v,children:[k?e.jsx("img",{src:k,alt:x,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(x[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:x})]}),f&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[r.map((C,N)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${w===N?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===N?0:-1,onClick:()=>{C.onClick(),h(!1)},children:[C.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:C.icon}),C.label]},N)),r.length>0&&!n&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!n&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${w===r.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===r.length?0:-1,onClick:()=>{p(),h(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${S[t]} ${j[o]} ${s}`,onClick:u,children:a||"Sign in"})}function Ws(){const{config:s}=M.useCedrosLogin(),[t,o]=l.useState(!1),[a,r]=l.useState(!1),[n,c]=l.useState(null),i=l.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:d,getRemainingAttempts:u}=K.useRateLimiter({maxAttempts:3,windowMs:3e5}),p=l.useCallback(async g=>{if(!Pe.validateEmail(g)){const m={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw c(m),m}try{d()}catch(m){const y={code:"RATE_LIMITED",message:m instanceof Error?m.message:"Too many attempts"};throw c(y),y}o(!0),c(null),r(!1);try{await i.post("/forgot-password",{email:g}),r(!0)}catch(m){const y=M.handleApiError(m,"Failed to send reset email");throw c(y),y}finally{o(!1)}},[i,d]),f=l.useCallback(async(g,m)=>{o(!0),c(null),r(!1);try{await i.post("/reset-password",{token:g,newPassword:m}),r(!0)}catch(y){const A=M.handleApiError(y,"Failed to reset password");throw c(A),A}finally{o(!1)}},[i]),h=l.useCallback(()=>c(null),[]),w=l.useCallback(()=>{c(null),r(!1),o(!1)},[]);return{forgotPassword:p,resetPassword:f,isLoading:t,isSuccess:a,error:n,clearError:h,reset:w,remainingAttempts:u()}}function $t({onSuccess:s,onCancel:t,className:o=""}){const[a,r]=l.useState(""),{forgotPassword:n,isLoading:c,isSuccess:i,error:d,clearError:u}=Ws(),p=l.useId(),f=async h=>{h.preventDefault();try{await n(a),s?.()}catch{}};return i?e.jsxs("div",{className:`cedros-forgot-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Check your email"}),e.jsxs("p",{className:"cedros-success-message",children:["If an account exists for ",e.jsx("strong",{children:a}),", you will receive a password reset link shortly."]}),t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:t,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:f,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Forgot password?"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your email address and we'll send you a link to reset your password."})]}),e.jsx(Y.ErrorMessage,{error:d,onDismiss:u}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:p,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:p,type:"email",className:"cedros-input",value:a,onChange:h=>r(h.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:c})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:c||!a,children:c?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),"Sending..."]}):"Send reset link"}),t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:t,disabled:c,children:"Back to login"})]})]})}const fo={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t})}):(this.loading=!0,new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t});const o=document.getElementById("apple-signin-script");if(o){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]):o.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]});return}const a=document.createElement("script");a.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",a.async=!0,a.defer=!0,a.id="apple-signin-script",a.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]},a.onerror=()=>{this.loading=!1,a.remove();const r=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(n=>n.reject(r)),this.callbacks=[]},document.head.appendChild(a)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function Jt(){const{config:s,_internal:t}=M.useCedrosLogin(),[o,a]=l.useState(!1),[r,n]=l.useState(!1),[c,i]=l.useState(null),d=l.useRef(s),u=l.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);l.useEffect(()=>{d.current=s},[s]),l.useEffect(()=>{if(!s.appleClientId)return;let h=!0;const w=()=>{if(h)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),h&&n(!0)}catch{h&&i({code:"SERVER_ERROR",message:"Failed to initialize Apple Sign In"})}};return fo.load().then(()=>{h&&w()}).catch(()=>{h&&i({code:"SERVER_ERROR",message:"Failed to load Apple Sign In"})}),()=>{h=!1}},[s.appleClientId]);const p=l.useCallback(async()=>{if(!s.appleClientId){const h={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw i(h),h}if(!r){const h={code:"VALIDATION_ERROR",message:"Apple Sign In not initialized"};throw i(h),h}a(!0),i(null);try{const h=await window.AppleID.auth.signIn(),w=h.authorization?.id_token;if(!w)throw new Error("No ID token received from Apple");const g=h.user?.name?`${h.user.name.firstName||""} ${h.user.name.lastName||""}`.trim():void 0,m=await u.post("/apple",{idToken:w,name:g||void 0});return d.current.callbacks?.onLoginSuccess?.(m.user,"apple"),t?.handleLoginSuccess(m.user,m.tokens),a(!1),m}catch(h){if(h.error==="popup_closed_by_user"){const m={code:"SERVER_ERROR",message:"Apple Sign In was cancelled"};throw i(m),a(!1),m}const g=M.handleApiError(h,"Apple sign-in failed");throw i(g),a(!1),g}},[s.appleClientId,r,u,t]),f=l.useCallback(()=>i(null),[]);return{signIn:p,isLoading:o,isInitialized:r,error:c,clearError:f}}function Xt(){if(typeof window>"u"||typeof navigator>"u")return!1;const s=navigator.userAgent.toLowerCase(),t=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(s)||t.includes("mac")||/macintosh/.test(s)||t==="macintel"&&navigator.maxTouchPoints>1)}function Zt({onSuccess:s,onError:t,className:o="",variant:a="default",size:r="md",disabled:n=!1,hideOnNonApple:c=!0}){const{signIn:i,isLoading:d,isInitialized:u}=Jt(),[p]=l.useState(()=>Xt());if(c&&!p)return null;const f=async()=>{try{await i(),s?.()}catch(g){const m=g instanceof Error?g:new Error(String(g));t?.(m)}},h={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},w={default:"cedros-button-apple",outline:"cedros-button-apple-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${w[a]} ${h[r]} ${o}`,onClick:f,disabled:n||!u||d,"aria-label":"Sign in with Apple",children:[d?e.jsx(V.LoadingSpinner,{size:"sm"}):e.jsx("svg",{className:"cedros-button-icon",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),e.jsx("span",{children:"Continue with Apple"})]})}function Z(s,t){if(!s)throw new Error(t)}function go(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function Qe(s){Z(typeof s=="string"&&s.length>0,"Expected base64url string");const t=go(s),o=t+"=".repeat((4-t.length%4)%4),a=atob(o),r=new Uint8Array(a.length);for(let n=0;n<a.length;n++)r[n]=a.charCodeAt(n);return r.buffer}function ye(s){const t=new Uint8Array(s);let o="";for(let r=0;r<t.length;r++)o+=String.fromCharCode(t[r]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function er(s){Z(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return Z(typeof t.type=="string","Invalid credential descriptor type"),Z(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:Qe(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function wo(s){Z(s&&typeof s=="object","Missing creation options");const t=s.publicKey;Z(t&&typeof t=="object","Missing creation options.publicKey"),Z(typeof t.challenge=="string","Missing creation challenge"),Z(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),Z(typeof t.user=="object"&&t.user!==null,"Missing user");const o=t.rp,a=t.user;Z(typeof o.name=="string","Missing rp.name"),Z(typeof a.id=="string","Missing user.id"),Z(typeof a.name=="string","Missing user.name"),Z(typeof a.displayName=="string","Missing user.displayName");const r=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(er):void 0,n=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(c=>({type:c.type,alg:c.alg})):[];return{challenge:Qe(t.challenge),rp:{name:o.name,id:typeof o.id=="string"?o.id:void 0},user:{id:Qe(a.id),name:a.name,displayName:a.displayName},pubKeyCredParams:n,timeout:typeof t.timeout=="number"?t.timeout:void 0,attestation:typeof t.attestation=="string"?t.attestation:void 0,authenticatorSelection:typeof t.authenticatorSelection=="object"&&t.authenticatorSelection!==null?t.authenticatorSelection:void 0,excludeCredentials:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0}}function bo(s){Z(s&&typeof s=="object","Missing request options");const t=s.publicKey;Z(t&&typeof t=="object","Missing request options.publicKey"),Z(typeof t.challenge=="string","Missing request challenge");const o=Array.isArray(t.allowCredentials)?t.allowCredentials.map(er):void 0;return{challenge:Qe(t.challenge),rpId:typeof t.rpId=="string"?t.rpId:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,userVerification:typeof t.userVerification=="string"?t.userVerification:void 0,allowCredentials:o,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0}}function tt(s){const t=ye(s.rawId),o=s.response,r={...{clientDataJSON:ye(o.clientDataJSON)}};if("attestationObject"in o){const n=o;if(r.attestationObject=ye(n.attestationObject),typeof n.getTransports=="function")try{r.transports=n.getTransports()}catch{}}if("authenticatorData"in o){const n=o;r.authenticatorData=ye(n.authenticatorData),r.signature=ye(n.signature),n.userHandle&&(r.userHandle=ye(n.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:r}}function yo(){if(typeof window<"u"){const s=window.location?.hostname,t=s==="localhost"||s==="127.0.0.1"||s?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!t)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function rt(s){if(!(s instanceof Error))return null;const t=s.name;return t==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:t==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:t==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function sr(){const{config:s,_internal:t}=M.useCedrosLogin(),[o,a]=l.useState(!1),[r,n]=l.useState(null),c=l.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),i=l.useCallback(()=>n(null),[]),d=yo(),u=l.useCallback(async f=>{if(!d){const h={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(h),h}a(!0),n(null);try{const h=await c.post("/webauthn/auth/options",{email:f?.email}),w=bo(h.options),g=await navigator.credentials.get({publicKey:w});if(!g)throw new Error("Passkey authentication returned no credential");const m=await c.post("/webauthn/auth/verify",{challengeId:h.challengeId,credential:tt(g)});return s.callbacks?.onLoginSuccess?.(m.user,"webauthn"),t?.handleLoginSuccess(m.user,m.tokens),m}catch(h){const g=rt(h)??M.handleApiError(h,"Passkey sign-in failed");throw n(g),g}finally{a(!1)}},[c,s.callbacks,t,d]),p=l.useCallback(async f=>{if(!d){const h={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(h),h}a(!0),n(null);try{const h=await c.post("/webauthn/register/options",{}),w=wo(h.options),g=await navigator.credentials.create({publicKey:w});if(!g)throw new Error("Passkey registration returned no credential");const m=await c.post("/webauthn/register/verify",{challengeId:h.challengeId,credential:tt(g),label:f?.label});if(!m.success)throw new Error("Passkey registration failed");return{credentialId:m.credentialId,label:m.label}}catch(h){const g=rt(h)??M.handleApiError(h,"Passkey registration failed");throw n(g),g}finally{a(!1)}},[c,d]);return{isSupported:d,isLoading:o,error:r,clearError:i,authenticatePasskey:u,registerPasskey:p}}function tr({onSuccess:s,className:t="",children:o,disabled:a}){const{authenticatePasskey:r,isLoading:n,isSupported:c}=sr(),i=a||!c||n;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${t}`,onClick:async()=>{await r(),s?.()},disabled:i,"aria-disabled":i,children:[e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(xo,{})}),e.jsx("span",{children:o??(n?"Continuing...":"Continue with Passkey")})]})}function xo(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}const Ne=["login","register"];function Ye({onSuccess:s,className:t="",defaultTab:o="login"}){const{config:a}=M.useCedrosLogin(),[r,n]=l.useState(o),[c,i]=l.useState("form"),[d,u]=l.useState(()=>Se.detectSolanaWallets()),[p]=l.useState(()=>Xt());l.useEffect(()=>{const j=()=>u(Se.detectSolanaWallets());return j(),window.addEventListener("load",j),window.addEventListener("focus",j),()=>{window.removeEventListener("load",j),window.removeEventListener("focus",j)}},[]);const f=a.forms?.forgotPassword?.mode??"reset",h=l.useCallback(j=>{const S=Ne.indexOf(r);let x=S;switch(j.key){case"ArrowLeft":case"ArrowUp":x=S===0?Ne.length-1:S-1;break;case"ArrowRight":case"ArrowDown":x=S===Ne.length-1?0:S+1;break;case"Home":x=0;break;case"End":x=Ne.length-1;break;default:return}j.preventDefault();const k=Ne[x];n(k),document.getElementById(`cedros-tab-${k}`)?.focus()},[r]),w=a.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},g=w.email!==!1,m=w.google!==!1&&a.googleClientId,y=w.apple!==!1&&a.appleClientId&&p,A=w.solana!==!1&&d,b=w.webauthn!==!1,v=g&&(m||y||A||b);return c==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx($t,{onCancel:()=>i("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[(b||m||y||A)&&e.jsxs("div",{className:"cedros-social-buttons",children:[b&&e.jsx(tr,{onSuccess:s}),m&&e.jsx(Bs.GoogleLoginButton,{onSuccess:s}),y&&e.jsx(Zt,{onSuccess:s}),A&&e.jsx(Se.SolanaLoginButton,{onSuccess:s})]}),v&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),g&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-tabs",role:"tablist","aria-label":"Authentication method",children:[e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-login",className:`cedros-tab ${r==="login"?"cedros-tab-active":""}`,onClick:()=>n("login"),onKeyDown:h,"aria-selected":r==="login","aria-controls":"cedros-tabpanel-login",tabIndex:r==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${r==="register"?"cedros-tab-active":""}`,onClick:()=>n("register"),onKeyDown:h,"aria-selected":r==="register","aria-controls":"cedros-tabpanel-register",tabIndex:r==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${r}`,"aria-labelledby":`cedros-tab-${r}`,children:r==="login"?e.jsx(K.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>n("register"),onForgotPassword:f==="reset"?()=>i("forgotPassword"):void 0}):e.jsx(K.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>n("login")})})]})]})}class rr extends l.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",o.componentStack),this.props.onError?.(t,o)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:o,errorInfo:a}=this.state,{children:r,fallback:n,showDetails:c=!1}=this.props;return t?n||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),c&&o&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[o.toString(),a?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):r}}function Ao({className:s="",title:t="Sign in to your account"}){const{isModalOpen:o,closeModal:a}=M.useCedrosLogin(),r=l.useRef(null),n=l.useRef(null),c=l.useRef(a);if(l.useEffect(()=>{c.current=a},[a]),l.useEffect(()=>{if(!o)return;n.current=document.activeElement,r.current?.focus();const d=p=>{if(p.key==="Escape"&&c.current(),p.key==="Tab"&&r.current){const f=r.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),h=f[0],w=f[f.length-1];p.shiftKey&&document.activeElement===h?(p.preventDefault(),w?.focus()):!p.shiftKey&&document.activeElement===w&&(p.preventDefault(),h?.focus())}};document.addEventListener("keydown",d);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=u,n.current instanceof HTMLElement&&n.current.focus()}},[o]),!o)return null;const i=d=>{d.target===d.currentTarget&&a()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,onClick:i,role:"presentation",children:e.jsxs("div",{ref:r,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:t}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:a,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(rr,{children:e.jsx(Ye,{onSuccess:a})})})]})})}function vo({token:s,onSuccess:t,onLoginClick:o,className:a=""}){const[r,n]=l.useState(""),[c,i]=l.useState(""),[d,u]=l.useState(null),{resetPassword:p,isLoading:f,isSuccess:h,error:w,clearError:g}=Ws(),m=r===c,y=d?.isValid&&m&&r.length>0,A=async b=>{if(b.preventDefault(),!!y)try{await p(s,r),t?.()}catch{}};return h?e.jsxs("div",{className:`cedros-reset-password-success ${a}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:o,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${a}`,onSubmit:A,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Reset your password"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your new password below."})]}),e.jsx(Y.ErrorMessage,{error:w,onDismiss:g}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(K.PasswordInput,{label:"New password",value:r,onChange:b=>{n(b.target.value),u(Pe.validatePassword(b.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:f,autoComplete:"new-password",error:d&&!d.isValid?Object.values(d.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(K.PasswordInput,{label:"Confirm password",value:c,onChange:b=>i(b.target.value),disabled:f,autoComplete:"new-password",error:c&&!m?"Passwords do not match":void 0})}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:f||!y,children:f?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:o,disabled:f,children:"Back to login"})]})]})}function _s({org:s,size:t="lg",className:o=""}){const a=Rs.sanitizeImageUrl(s.logoUrl),r=t==="lg"?"cedros-org-avatar-lg":"",n=["cedros-org-avatar",r,o].filter(Boolean).join(" "),c=["cedros-org-avatar-placeholder",r,o].filter(Boolean).join(" ");return a?e.jsx("img",{src:a,alt:s.name,className:n,referrerPolicy:"no-referrer"}):e.jsx("div",{className:c,children:s.name[0]?.toUpperCase()||"?"})}function jo({orgs:s,activeOrg:t,isLoading:o=!1,onSelect:a,onCreateClick:r,className:n="",placeholder:c="Select organization"}){const[i,d]=l.useState(!1),u=l.useRef(null);l.useEffect(()=>{const w=g=>{u.current&&!u.current.contains(g.target)&&d(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),l.useEffect(()=>{const w=g=>{g.key==="Escape"&&d(!1)};if(i)return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[i]);const p=l.useCallback(w=>{a(w),d(!1)},[a]),f=l.useCallback(()=>{d(!1),r?.()},[r]),h=l.useCallback(()=>{d(w=>!w)},[]);return o?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${n}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:u,className:`cedros-org-selector ${n}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:h,"aria-haspopup":"listbox","aria-expanded":i,children:[t?e.jsxs(e.Fragment,{children:[e.jsx(_s,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(ot,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:c}),e.jsx(ko,{isOpen:i})]}),i&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[s.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:s.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${w.id===t?.id?"cedros-org-selector-item-active":""}`,onClick:()=>p(w.id),role:"option","aria-selected":w.id===t?.id,children:[e.jsx(_s,{org:w,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:w.name}),e.jsx(ot,{role:w.membership.role}),w.id===t?.id&&e.jsx(No,{})]})},w.id))}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:f,children:[e.jsx(Co,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function ot({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function ko({isOpen:s}){return e.jsx("svg",{className:`cedros-org-chevron ${s?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function No(){return e.jsx("svg",{className:"cedros-org-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Co(){return e.jsx("svg",{className:"cedros-org-plus",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 3V13M3 8H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function So(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Eo(){return e.jsx("svg",{className:"cedros-org-check",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 10L8 14L16 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Po(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M10 4V16M4 10H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Lo({orgs:s,activeOrg:t,isLoading:o,onSelect:a,onCreateClick:r}){return o?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[s.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:s.map(n=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${n.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>a(n.id),children:[e.jsx(_s,{org:n}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:n.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",n.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${n.membership.role}`,children:n.membership.role}),n.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),n.id===t?.id&&e.jsx(Eo,{})]})},n.id))}),r&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:r,children:[e.jsx(Po,{}),e.jsx("span",{children:"Create new organization"})]})]})}function To({isLoading:s,onSubmit:t,onCancel:o}){const[a,r]=l.useState(""),[n,c]=l.useState(""),[i,d]=l.useState(null),u=l.useCallback(f=>{r(f);const h=f.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);c(h)},[]),p=l.useCallback(async f=>{if(f.preventDefault(),d(null),!a.trim()){d("Organization name is required");return}if(!n.trim()){d("Organization slug is required");return}try{await t({name:a.trim(),slug:n.trim()})}catch(h){d(h.message||"Failed to create organization")}},[a,n,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:p,children:[i&&e.jsx(Y.ErrorMessage,{error:i}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:a,onChange:f=>u(f.target.value),placeholder:"My Organization",maxLength:255,disabled:s,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:n,onChange:f=>c(f.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:s})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:o,disabled:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!a.trim()||!n.trim(),children:s?e.jsx(V.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function Mo({isOpen:s,onClose:t,orgs:o,activeOrg:a,isLoading:r=!1,error:n,onSelect:c,onCreate:i,className:d=""}){return s?e.jsx(_o,{onClose:t,orgs:o,activeOrg:a,isLoading:r,error:n,onSelect:c,onCreate:i,className:d}):null}function _o({onClose:s,orgs:t,activeOrg:o,isLoading:a=!1,error:r,onSelect:n,onCreate:c,className:i}){const[d,u]=l.useState("list"),p=l.useRef(null),f=l.useRef(null);l.useEffect(()=>(f.current=document.activeElement,p.current?.querySelector(".cedros-modal-close")?.focus(),()=>{f.current?.focus()}),[]),l.useEffect(()=>{const m=y=>{if(y.key==="Escape"){s();return}if(y.key==="Tab"&&p.current){const A=p.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),b=A[0],v=A[A.length-1];y.shiftKey?document.activeElement===b&&(y.preventDefault(),v?.focus()):document.activeElement===v&&(y.preventDefault(),b?.focus())}};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[s]);const h=l.useCallback(m=>{m.target===m.currentTarget&&s()},[s]),w=l.useCallback(m=>{n(m),s()},[n,s]),g=l.useCallback(async m=>{await c?.(m),s()},[c,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:h,children:e.jsxs("div",{ref:p,className:`cedros-modal cedros-org-switcher ${i}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:d==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(So,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[r&&e.jsx(Y.ErrorMessage,{error:r}),d==="list"?e.jsx(Lo,{orgs:t,activeOrg:o,isLoading:a,onSelect:w,onCreateClick:c?()=>u("create"):void 0}):e.jsx(To,{isLoading:a,onSubmit:g,onCancel:()=>u("list")})]})]})})}function Ro({sessions:s,isLoading:t=!1,error:o,onRevokeAll:a,className:r=""}){const[n,c]=l.useState(!1),[i,d]=l.useState(!1),u=l.useRef(null),p=l.useMemo(()=>s.filter(h=>!h.isCurrent).length,[s]),f=l.useCallback(async()=>{if(!a)return;const h=s.filter(g=>!g.isCurrent).length;if(!(h===0||!window.confirm(`Are you sure you want to sign out of ${h} other device(s)? This will log you out everywhere except this browser.`))){c(!0),d(!1);try{await a(),d(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(!1),u.current=null},3e3)}finally{c(!1)}}},[a,s]);return l.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${r}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):o?e.jsx("div",{className:`cedros-session-list ${r}`,children:e.jsx(Y.ErrorMessage,{error:o})}):s.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${r}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${r}`,children:[i&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Wo,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(h=>e.jsx(Bo,{session:h},h.id))}),a&&p>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:f,disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${p} other device${p>1?"s":""}`})})]})}function Bo({session:s}){const t=Do(s.userAgent),o=Fo(s.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${s.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(Uo,{userAgent:s.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[t.browser," on ",t.os]}),s.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[s.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",s.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",Io(s.createdAt)]}),o&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Do(s){if(!s)return{browser:"Unknown browser",os:"Unknown device"};let t="Unknown browser";s.includes("Chrome")&&!s.includes("Edg")?t="Chrome":s.includes("Safari")&&!s.includes("Chrome")?t="Safari":s.includes("Firefox")?t="Firefox":s.includes("Edg")&&(t="Edge");let o="Unknown device";return s.includes("Windows")?o="Windows":s.includes("Mac")?o="macOS":s.includes("Linux")?o="Linux":s.includes("iPhone")||s.includes("iPad")?o="iOS":s.includes("Android")&&(o="Android"),{browser:t,os:o}}function Io(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),r=Math.floor(a/(1e3*60)),n=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return r<1?"just now":r<60?`${r} minute${r>1?"s":""} ago`:n<24?`${n} hour${n>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Fo(s){const t=new Date(s),o=new Date,a=3600*1e3;return t.getTime()-o.getTime()<a}function Uo({userAgent:s}){return s?.includes("iPhone")||s?.includes("iPad")||s?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function Wo(){return e.jsx("svg",{className:"cedros-session-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function or({words:s,onConfirm:t,className:o=""}){const[a,r]=l.useState(!1),[n,c]=l.useState(!1),i=l.useRef(null),d=ho(s),u=l.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),r(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>r(!1),2e3)}catch{}},[s]);l.useEffect(()=>()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]);const p=l.useCallback(()=>{n&&t()},[n,t]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${o}`,children:[e.jsxs("div",{className:"cedros-recovery-header",children:[e.jsx("h3",{className:"cedros-recovery-title",children:"Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-warning",children:"Write down these 12 words in order and store them securely. This is the only way to recover your wallet if you lose access."})]}),e.jsx("div",{className:"cedros-recovery-grid",children:d.map((f,h)=>e.jsx("div",{className:"cedros-word-group",children:f.map((w,g)=>{const m=h*4+g+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[m,"."]}),e.jsx("span",{className:"cedros-word-text",children:w})]},m)})},h))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,children:a?"Copied!":"Copy to Clipboard"}),e.jsx("div",{className:"cedros-recovery-security",children:e.jsxs("div",{className:"cedros-warning-box",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M10 6v4m0 4h.01M19 10a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsxs("div",{className:"cedros-warning-content",children:[e.jsx("strong",{children:"Security Warning"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Never share this phrase with anyone"}),e.jsx("li",{children:"Store it offline in a secure location"}),e.jsx("li",{children:"Anyone with this phrase can access your wallet"}),e.jsx("li",{children:"Cedros cannot recover this phrase for you"})]})]})]})}),e.jsxs("div",{className:"cedros-recovery-confirm",children:[e.jsxs("label",{className:"cedros-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:f=>c(f.target.checked),className:"cedros-checkbox"}),e.jsx("span",{children:"I have written down and securely stored my recovery phrase"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:p,disabled:!n,children:"Continue"})]})]})}function nr({onSubmit:s,onCancel:t,isSubmitting:o=!1,error:a,className:r=""}){const[n,c]=l.useState(Array(oe).fill("")),[i,d]=l.useState(null),[u,p]=l.useState([]),[f,h]=l.useState(null),w=l.useId(),g=l.useRef(null),m=l.useCallback((x,k)=>{const C=[...n];if(C[x]=k.toLowerCase().trim(),c(C),k.length>0){const N=uo(k,5);p(N)}else p([]);h(null)},[n]),y=l.useCallback(x=>{d(x),p([])},[]),A=l.useCallback(x=>{const k=n[x];k&&!De(k)&&h(`Word ${x+1} is not in the wordlist`),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{i===x&&p([])},200)},[n,i]);l.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]);const b=l.useCallback(x=>{if(i!==null){const k=[...n];k[i]=x,c(k),p([]),document.querySelector(`[data-word-index="${i+1}"]`)?.focus()}},[i,n]),v=l.useCallback(x=>{const k=x.clipboardData.getData("text"),C=po(k);C.length===oe&&(x.preventDefault(),c(C),h(null))},[]),j=l.useCallback(x=>{if(x.preventDefault(),n.filter(N=>!N).length>0){h(`Please enter all ${oe} words`);return}const C=n.map((N,L)=>({word:N,index:L+1})).filter(({word:N})=>!De(N));if(C.length>0){h(`Invalid words: ${C.map(N=>`#${N.index}`).join(", ")}`);return}if(!Yt(n)){h("Invalid recovery phrase - please check your words");return}s(n)},[n,s]),S=a||f;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${r}`,onSubmit:j,onPaste:v,children:[e.jsxs("div",{className:"cedros-recovery-input-header",children:[e.jsx("h3",{className:"cedros-recovery-input-title",children:"Enter Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-input-description",children:"Enter your 12-word recovery phrase. You can paste the entire phrase at once."})]}),e.jsx("div",{className:"cedros-word-inputs",children:Array.from({length:oe},(x,k)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[k+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${n[k]&&!De(n[k])?"cedros-word-invalid":n[k]&&De(n[k])?"cedros-word-valid":""}`,value:n[k],onChange:C=>m(k,C.target.value),onFocus:()=>y(k),onBlur:()=>A(k),"data-word-index":k,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:o,"aria-label":`Word ${k+1}`})]},k))}),i!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${w}-suggestions`,children:u.map(x=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>b(x),role:"option",children:x},x))}),S&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:S}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:o,children:o?"Recovering...":"Recover Wallet"})]})]})}function Oo({capabilities:s,className:t=""}){if(s.allSupported)return null;const o=D.getMissingCapabilitiesMessage(s),a=D.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${t}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:o}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",a.browser," ",a.version,a.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:s.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",s.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:s.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",s.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:s.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",s.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",s.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",s.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:s.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",s.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const qo=["share_c_only","full_seed","none"];function zo(s){return s&&qo.includes(s)?s:"share_c_only"}const Vo={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function ar(){const s=M.useCedrosLoginOptional(),[t,o]=l.useState(null),[a,r]=l.useState(!!s),[n,c]=l.useState(null),i=l.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),d=l.useCallback(async()=>{if(i){r(!0),c(null);try{const u=await i.get("/discovery");u.wallet?o({enabled:u.wallet.enabled,recoveryMode:zo(u.wallet.recoveryMode),unlockTtlSeconds:u.wallet.unlockTtlSeconds}):o({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(u){const p=u instanceof Error?u.message:"Failed to fetch wallet config";c(p),o({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{r(!1)}}},[i]);return l.useEffect(()=>{i&&d()},[i,d]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:a,error:n,refetch:d}:Vo}function ir(){const{user:s}=M.useCedrosLogin(),{enroll:t}=D.useWalletMaterial(),{recoveryMode:o}=ar(),[a,r]=l.useState({step:"idle"}),[n,c]=l.useState(!1),i=l.useRef([]),d=l.useCallback(()=>{D.wipeAll(...i.current),i.current=[]},[]);l.useEffect(()=>()=>{d()},[d]);const u=l.useCallback(async(g,m,y,A)=>{r({step:"generating_seed"});const b=D.generateSeed();i.current.push(b),r({step:"splitting_shares"});const{shareA:v,shareB:j,shareC:S}=ie.splitSecret(b);i.current.push(v,j,S),r({step:"encrypting_shares"});const x=await D.aesGcmEncryptToBase64(v,D.toEncryptionKey(m)),k=ie.getPublicKeyFromSeed(b),C=ie.publicKeyToBase58(k);r({step:"uploading"});const N={solanaPubkey:C,shareAAuthMethod:g,shareACiphertext:x.ciphertext,shareANonce:x.nonce,shareB:D.uint8ArrayToBase64(j)};if(g==="password"){if(!y)throw new Error("KDF salt required for password method");N.shareAKdfSalt=D.uint8ArrayToBase64(y),N.shareAKdfParams=D.DEFAULT_KDF_PARAMS}if(g==="passkey"&&A&&(N.prfSalt=A),await t(N),o==="none")d(),r({step:"complete",solanaPubkey:C});else{const L=o==="full_seed"?lo(b):ao(D.toShamirShare(S));r({step:"showing_recovery",recoveryPhrase:L,solanaPubkey:C})}},[t,o,d]),p=l.useCallback(async g=>{if(!s){r({step:"error",error:"User not authenticated"});return}c(!0),d();try{const m=D.generateArgon2Salt(),y=await ie.argon2DeriveInWorker(g,m,D.DEFAULT_KDF_PARAMS);i.current.push(y),await u("password",y,m)}catch(m){r({step:"error",error:m instanceof Error?m.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),f=l.useCallback(async()=>{if(!s){r({step:"error",error:"User not authenticated"});return}c(!0),d();try{const g=D.generatePrfSalt(),m=D.uint8ArrayToBase64(g);r({step:"registering_passkey"});let y;try{const b=new TextEncoder().encode(s.id),v=s.name??s.email??"User",j=s.email??s.id;y=(await D.registerPasskeyWithPrf(b,j,v,g)).prfOutput}catch(b){if(b?.name!=="InvalidStateError")throw b;y=(await D.authenticateWithDiscoverablePrf(m)).prfOutput}i.current.push(y);const A=await D.deriveKeyFromPrf(y,g);i.current.push(A),await u("passkey",A,void 0,m)}catch(g){r({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),h=l.useCallback(()=>{const g=a.solanaPubkey;d(),r({step:"complete",solanaPubkey:g})},[a.solanaPubkey,d]),w=l.useCallback(()=>{d(),r({step:"idle"}),c(!1)},[d]);return{state:a,startEnrollmentWithPassword:p,startEnrollmentWithPasskey:f,confirmRecoveryPhrase:h,cancel:w,isEnrolling:n}}function lr({onComplete:s,onCancel:t,className:o="",forceAuthMethod:a}){const{user:r}=M.useCedrosLogin(),{state:n,startEnrollmentWithPassword:c,startEnrollmentWithPasskey:i,confirmRecoveryPhrase:d,cancel:u,isEnrolling:p}=ir(),f=()=>a||"password",[h,w]=l.useState(f),[g,m]=l.useState(""),[y,A]=l.useState(""),[b,v]=l.useState(null);l.useEffect(()=>{w(f())},[r?.id,a]);const j=l.useCallback(async C=>{if(C.preventDefault(),g!==y){v("Passwords do not match");return}const N=Pe.validatePassword(g);if(!N.isValid){const L=Object.values(N.errors)[0];v(L??"Password does not meet requirements");return}v(null),await c(g)},[g,y,c]),S=l.useCallback(async()=>{await i()},[i]),x=l.useCallback(()=>{d(),n.solanaPubkey&&s?.(n.solanaPubkey)},[d,n.solanaPubkey,s]),k=l.useCallback(()=>{u(),t?.()},[u,t]);return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Generating secure wallet..."})]})}):n.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Encrypting wallet shares..."})]})}):n.step==="registering_passkey"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsx("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:e.jsxs("div",{className:"cedros-passkey-prompt",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Authenticate with Passkey"}),e.jsx("p",{children:"Follow your browser's prompt to use your passkey."})]})})}):n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Saving wallet..."})]})}):n.step==="showing_recovery"&&n.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsx(or,{words:n.recoveryPhrase,onConfirm:x})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsxs("div",{className:"cedros-enrollment-complete",children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M16 24l6 6 12-12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{children:"Wallet Created!"}),e.jsxs("p",{className:"cedros-pubkey",children:[e.jsx("strong",{children:"Address:"})," ",n.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsxs("div",{className:"cedros-enrollment-error",children:[e.jsxs("svg",{className:"cedros-error-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 16v12m0 6h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Enrollment Failed"}),e.jsx("p",{className:"cedros-error-message",children:n.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>u(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${o}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),e.jsxs("p",{children:["Secure your wallet with a ",h==="passkey"?"passkey":"password","."]})]}),!a&&e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:h==="password",onChange:()=>w("password"),disabled:p}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:h==="passkey",onChange:()=>w("passkey"),disabled:p}),e.jsx("span",{children:"Passkey"})]})]}),h==="password"&&e.jsxs("form",{onSubmit:j,className:"cedros-enrollment-form",children:[e.jsx(K.PasswordInput,{label:"Password",value:g,onChange:C=>m(C.target.value),showStrengthMeter:!0,disabled:p,required:!0,minLength:8,placeholder:"Enter a strong password"}),e.jsx(K.PasswordInput,{label:"Confirm Password",value:y,onChange:C=>A(C.target.value),error:b??void 0,disabled:p,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,disabled:p,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:p||!g||!y,children:p?"Creating...":"Continue"})]})]}),h==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."}),e.jsx("p",{children:"You'll use the same passkey to sign transactions."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,disabled:p,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,disabled:p,children:p?"Creating...":"Use Passkey"})]})]})]})}function cr(){const{user:s}=M.useCedrosLogin(),{signTransaction:t}=D.useWalletMaterial(),[o,a]=l.useState(!1),[r,n]=l.useState(null),c=l.useCallback(async(d,u)=>{if(!s){const p="User not authenticated";throw n(p),new Error(p)}a(!0),n(null);try{const p={transaction:D.uint8ArrayToBase64(d),...u?{credential:D.toCredentialRequest(u)}:{}},f=await t(p);return D.base64ToUint8Array(f.signature)}catch(p){const f=p instanceof Error?p.message:"Signing failed";throw n(f),p}finally{a(!1)}},[s,t]),i=l.useCallback(()=>n(null),[]);return{signTransaction:c,isSigning:o,error:r,clearError:i}}function dr(){const{getMaterial:s}=D.useWalletMaterial(),[t,o]=l.useState(!1),[a,r]=l.useState(null),n=l.useCallback(async()=>{o(!0),r(null);try{const i=await s();if(!i)throw new Error("No wallet enrolled");if(i.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!i.prfSalt)throw new Error("No PRF salt configured for wallet");const d=await D.authenticateWithDiscoverablePrf(i.prfSalt);try{return{type:"prfOutput",prfOutput:D.uint8ArrayToBase64(d.prfOutput)}}finally{d.prfOutput.fill(0)}}catch(i){const d=i instanceof Error?i.message:"Passkey authentication failed";return r(d),null}finally{o(!1)}},[s]),c=l.useCallback(()=>r(null),[]);return{getPasskeyCredential:n,isAuthenticating:t,error:a,clearError:c}}function ur({mode:s,isLoading:t=!1,error:o,onPrompt:a,onRetry:r,onCancel:n,title:c,description:i,className:d=""}){const u=l.useCallback(()=>{t||a?.()},[t,a]),p=l.useCallback(()=>{r?.()},[r]),f=s==="register"?"Set Up Passkey":"Verify with Passkey",h=s==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${d}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(Qo,{}):o?e.jsx(Ko,{}):e.jsx(Ho,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:c??f}),e.jsx("p",{className:"cedros-passkey-description",children:i??h}),o&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:o})}),e.jsx("div",{className:"cedros-passkey-actions",children:o?e.jsxs(e.Fragment,{children:[r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:p,children:"Try Again"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:n,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:u,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):s==="register"?"Create Passkey":"Use Passkey"}),n&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:n,children:"Cancel"})]})}),t&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",s==="register"?"create":"verify"," your passkey."]})]})}function Ho(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}function Qo(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Ko(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01"})]})}function hr({onUnlock:s,onCancel:t,showCancel:o=!0,authMethod:a,className:r=""}){M.useCedrosLogin();const{unlock:n,getMaterial:c,isLoading:i}=D.useWalletMaterial(),{getPasskeyCredential:d,isAuthenticating:u}=dr(),[p,f]=l.useState("idle"),[h,w]=l.useState(a??null),[g,m]=l.useState(""),[y,A]=l.useState(null);l.useEffect(()=>{a!==void 0&&w(a)},[a]);const b=h==="password",v=h==="passkey",j=l.useCallback(async()=>{if(f("credential"),A(null),!h)try{const P=await c();P?w(P.shareAAuthMethod):(A("No wallet enrolled"),f("error"))}catch(P){A(P instanceof Error?P.message:"Failed to get wallet info"),f("error")}},[h,c]),S=l.useCallback(async P=>{P.preventDefault(),A(null),f("unlocking");try{let E;if(b)E={type:"password",password:g};else throw new Error("Invalid auth method");await n(E),f("unlocked"),s?.()}catch(E){A(E instanceof Error?E.message:"Failed to unlock wallet"),f("error")}},[b,g,n,s]),x=l.useCallback(async()=>{A(null),f("unlocking");try{const P=await d();if(!P){f("credential");return}await n(P),f("unlocked"),s?.()}catch(P){A(P instanceof Error?P.message:"Failed to unlock wallet"),f("error")}},[d,n,s]),k=l.useCallback(()=>{m(""),f("idle"),A(null),t?.()},[t]),C=l.useCallback(()=>{m(""),f("credential"),A(null)},[]),N=i||u,L=()=>{switch(p){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Go,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Locked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Unlock your wallet to sign transactions."}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:j,children:"Unlock Wallet"})]});case"credential":return b?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:S,children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Enter Password"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Enter your wallet password to unlock."}),e.jsx(K.PasswordInput,{label:"Password",value:g,onChange:P=>m(P.target.value),disabled:N,autoComplete:"current-password",error:y??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:N||g.length===0,children:N?"Unlocking...":"Unlock"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,disabled:N,children:"Cancel"})]})]}):v?e.jsxs("div",{className:"cedros-wallet-unlock-passkey",children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Verify with Passkey"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Use your passkey to unlock your wallet."}),e.jsx(ur,{mode:"authenticate",isLoading:N,error:y??void 0,onPrompt:x,onRetry:x,onCancel:o?k:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(V.LoadingSpinner,{size:"xl"}),e.jsx("p",{children:"Loading wallet info..."})]});case"unlocking":return e.jsxs("div",{className:"cedros-wallet-unlock-progress",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(V.LoadingSpinner,{size:"xl"})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlocking Wallet"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Verifying your credentials..."})]});case"unlocked":return e.jsxs("div",{className:"cedros-wallet-unlock-success",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Yo,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Unlocked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Your wallet is ready to sign transactions."})]});case"error":return e.jsxs("div",{className:"cedros-wallet-unlock-error",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx($o,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:y??"Failed to unlock wallet. Please try again."}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:C,children:"Try Again"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${r}`,children:L()})}function Go(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"10",y:"22",width:"28",height:"20",rx:"4",stroke:"currentColor",strokeWidth:"2",fill:"var(--cedros-muted, #f3f4f6)"}),e.jsx("path",{d:"M16 22V16a8 8 0 1 1 16 0v6",stroke:"currentColor",strokeWidth:"2",fill:"none"}),e.jsx("circle",{cx:"24",cy:"32",r:"3",fill:"currentColor"})]})}function Yo(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function $o(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function pr(){const{recover:s,getShareBForRecovery:t}=D.useWalletMaterial(),{recoveryMode:o}=ar(),[a,r]=l.useState({step:"idle"}),[n,c]=l.useState(!1),i=l.useRef([]),d=l.useCallback(()=>{D.wipeAll(...i.current),i.current=[]},[]);l.useEffect(()=>()=>{d()},[d]);const u=l.useCallback(async(f,h,w)=>{c(!0),d();try{if(r({step:"validating"}),!Yt(f))throw new Error("Invalid recovery phrase. Please check your words.");let g;if(o==="share_c_only"){const C=io(f);i.current.push(C);const N=D.uint8ArrayToBase64(C),L=await t({shareC:N}),P=D.base64ToUint8Array(L.shareB);i.current.push(P),g=ie.combineShares(D.toShamirShare(P),D.toShamirShare(C)),i.current.push(g)}else g=co(f),i.current.push(g);const m=ie.getPublicKeyFromSeed(g),y=ie.publicKeyToBase58(m),{shareA:A,shareB:b}=ie.splitSecret(g);i.current.push(A,b),r({step:"encrypting"});let v,j,S;if(h==="passkey"){const C=D.generatePrfSalt();S=D.uint8ArrayToBase64(C);const N=await D.authenticateWithDiscoverablePrf(S);i.current.push(N.prfOutput),v=await D.deriveKeyFromPrf(N.prfOutput,C),i.current.push(v)}else j=D.generateArgon2Salt(),v=await ie.argon2DeriveInWorker(w,j,D.DEFAULT_KDF_PARAMS),i.current.push(v);const x=await D.aesGcmEncryptToBase64(A,D.toEncryptionKey(v));r({step:"uploading"});const k={solanaPubkey:y,shareAAuthMethod:h,shareACiphertext:x.ciphertext,shareANonce:x.nonce,shareB:D.uint8ArrayToBase64(b)};h==="password"&&(k.shareAKdfSalt=D.uint8ArrayToBase64(j),k.shareAKdfParams=D.DEFAULT_KDF_PARAMS),h==="passkey"&&(k.prfSalt=S),await s(k),d(),r({step:"complete"})}catch(g){d(),r({step:"error",error:g instanceof Error?g.message:"Recovery failed"})}finally{c(!1)}},[s,t,o,d]),p=l.useCallback(()=>{d(),r({step:"idle"}),c(!1)},[d]);return{state:a,startRecovery:u,cancel:p,isRecovering:n}}function mr({onComplete:s,onCancel:t,className:o="",defaultAuthMethod:a="password"}){const{state:r,startRecovery:n,cancel:c,isRecovering:i}=pr(),[d,u]=l.useState([]),[p,f]=l.useState(!1),[h,w]=l.useState(a),[g,m]=l.useState(""),[y,A]=l.useState(""),[b,v]=l.useState(null),j=l.useCallback(N=>{u(N),f(!0)},[]),S=l.useCallback(async N=>{if(N.preventDefault(),v(null),h!=="passkey"){if(g!==y){v("Passwords do not match");return}if(h==="password"&&g.length<8){v("Password must be at least 8 characters");return}}await n(d,h,g)},[d,h,g,y,n]),x=l.useCallback(()=>{c(),u([]),f(!1),m(""),A(""),t?.()},[c,t]),k=l.useCallback(()=>{f(!1),m(""),A("")},[]),C=l.useCallback(()=>{s?.()},[s]);return r.step==="validating"||r.step==="encrypting"||r.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Jo,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[r.step==="validating"&&"Validating Recovery Phrase",r.step==="encrypting"&&"Encrypting Wallet",r.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[r.step==="validating"&&"Checking your recovery phrase...",r.step==="encrypting"&&"Securing your wallet with new encryption...",r.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):r.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Xo,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Wallet Recovered"}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:["Your wallet has been successfully recovered and secured with your new"," ",h==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:C,children:"Done"})})]})}):r.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Zo,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:r.error??"An error occurred during recovery. Please try again."}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Start Over"})})]})}):p?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:S,children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Set New Security"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Choose how to secure your recovered wallet."})]}),e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:h==="password",onChange:()=>w("password"),disabled:i}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:h==="passkey",onChange:()=>w("passkey"),disabled:i}),e.jsx("span",{children:"Passkey"})]})]}),h==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:g,onChange:N=>m(N.target.value),disabled:i,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:y,onChange:N=>A(N.target.value),disabled:i,"aria-invalid":b?"true":void 0,placeholder:"Confirm your password"}),b&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:b})]})]}),h==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(en,{}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-wallet-recovery-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:k,disabled:i,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:i||h!=="passkey"&&(g.length===0||y.length===0),children:i?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-phrase",children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recover Your Wallet"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Enter your 12-word recovery phrase to restore your wallet."})]}),e.jsx(nr,{onSubmit:j,onCancel:x,isSubmitting:!1})]})})}function Jo(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-muted, #e5e7eb)",strokeWidth:"3",fill:"none"}),e.jsx("path",{d:"M24 4a20 20 0 0 1 20 20",stroke:"var(--cedros-primary, #6366f1)",strokeWidth:"3",strokeLinecap:"round",fill:"none"})]})}function Xo(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function Zo(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function en(){return e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function fr({address:s,label:t="Wallet Address",showCopy:o=!0,showExplorerLink:a=!0,allowReveal:r=!0,className:n=""}){const c=M.useCedrosLoginOptional(),[i,d]=l.useState(!1),[u,p]=l.useState(null),[f,h]=l.useState(!1),w=l.useRef(null),g=c?.config.solana?.network??"mainnet-beta",m=l.useMemo(()=>{const v=`https://explorer.solana.com/address/${s}`;return g==="mainnet-beta"?v:`${v}?cluster=${encodeURIComponent(g)}`},[s,g]),y=r&&s.length>18,A=l.useMemo(()=>!y||f?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,y,f]),b=l.useCallback(async()=>{try{p(null),await navigator.clipboard.writeText(s),d(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{d(!1),w.current=null},2e3)}catch(v){d(!1),p(v instanceof Error?v.message:"Copy failed")}},[s]);return l.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${n}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:t}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[y&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>h(v=>!v),"aria-label":f?"Hide full wallet address":"Show full wallet address",children:f?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.7 10.7a3 3 0 0 0 4.24 4.24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.88 5.09A10.94 10.94 0 0 1 12 5c5 0 9.27 3.11 11 7-0.55 1.23-1.32 2.33-2.27 3.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.61 6.61C4.4 7.9 2.74 9.8 1 12c1.73 3.89 6 7 11 7 1.14 0 2.25-0.16 3.3-0.46",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),a&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:m,target:"_blank",rel:"noreferrer",children:"Explorer"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:b,"aria-label":"Copy wallet address",children:i?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:A}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function gr({status:s,publicKey:t,onLock:o,onEnroll:a,onUnlock:r,onRecover:n,showActions:c=!0,compact:i=!1,className:d=""}){const u=s!==void 0,p=D.useWallet(),f=u?s:p.status,h=u?t??null:p.solanaPubkey,w=u?null:p.error,g=u?()=>{}:p.refresh,m=u?()=>{}:p.clearError,y=sn(f,w);return i?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${d}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${y.color}`,title:y.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:y.label}),h&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:h,children:tn(h)})]}):e.jsxs("div",{className:`cedros-wallet-status ${d}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${y.color}`,children:e.jsx(rn,{status:f})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:y.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:y.description})]})]}),h&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(fr,{address:h})}),w&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:w}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:m,children:"Dismiss"})]}),c&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[f==="not_enrolled"&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,children:"Create Wallet"}),f==="enrolled_locked"&&r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:r,children:"Unlock Wallet"}),(f==="not_enrolled"||f==="error")&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:n,children:"Recover Wallet"}),f==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:g,children:"Retry"})]})]})}function sn(s,t){switch(s){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:t??"An error occurred with your wallet.",color:"error"}}}function tn(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function rn({status:s}){switch(s){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function on({className:s="",showActions:t=!0}){const o=D.useWallet(),[a,r]=l.useState("status"),n=l.useMemo(()=>{switch(a){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[a]),c=l.useCallback(()=>r("status"),[]),i=l.useCallback(async()=>{r("status"),await o.refresh()},[o]),d=l.useCallback(async()=>{r("status"),await o.refresh()},[o]),u=l.useCallback(async()=>{r("status"),await o.refresh()},[o]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[a!=="status"&&n&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:n.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:n.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:c,children:"Back"})]}),a==="status"&&e.jsx(gr,{onEnroll:()=>r("enroll"),onUnlock:()=>r("unlock"),onRecover:()=>r("recover_intro"),showActions:t}),a==="enroll"&&e.jsx(lr,{onComplete:()=>{i()},onCancel:c}),a==="unlock"&&e.jsx(hr,{onUnlock:()=>{d()},onCancel:c}),a==="recover_intro"&&e.jsx("div",{className:"cedros-wallet-manager-intro",children:e.jsxs("div",{className:"cedros-wallet-manager-intro-card",children:[e.jsx("h4",{className:"cedros-wallet-manager-intro-title",children:"Before you start"}),e.jsxs("ul",{className:"cedros-wallet-manager-intro-list",children:[e.jsx("li",{children:"You’ll need your 12-word recovery phrase."}),e.jsx("li",{children:"You’ll set a new password or passkey for this wallet."}),e.jsx("li",{children:"If you’re on a shared device, avoid copying the phrase into other apps."})]}),e.jsxs("div",{className:"cedros-wallet-manager-intro-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>r("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:c,children:"Cancel"})]})]})}),a==="recover"&&e.jsx(mr,{onComplete:()=>{u()},onCancel:c})]})}function nn(s){const t=Math.floor(s/86400),o=Math.floor(s%86400/3600),a=Math.floor(s%3600/60),r=s%60;return{days:t,hours:o,minutes:a,seconds:r}}function an(s){const{days:t,hours:o,minutes:a}=nn(s),r=[];return t>0&&r.push(`${t}d`),o>0&&r.push(`${o}h`),a>0&&r.push(`${a}m`),r.length===0&&r.push(`${s}s`),r.join(" ")}const ln={auth_email_enabled:{key:"auth_email_enabled",label:"Enable Email Authentication",description:"Allow users to sign up and log in with email/password.",inputType:"boolean"},auth_email_require_verification:{key:"auth_email_require_verification",label:"Require Email Verification",description:"Users must verify their email address before they can log in.",inputType:"boolean"},auth_email_block_disposable:{key:"auth_email_block_disposable",label:"Block Disposable Emails",description:"Reject registrations from known disposable email providers.",inputType:"boolean"},auth_google_enabled:{key:"auth_google_enabled",label:"Enable Google Sign-In",description:"Allow users to authenticate with their Google account.",inputType:"boolean"},auth_google_client_id:{key:"auth_google_client_id",label:"Google Client ID",description:"OAuth 2.0 client ID from Google Cloud Console.",inputType:"text"},auth_google_client_secret:{key:"auth_google_client_secret",label:"Google Client Secret",description:"OAuth 2.0 client secret from Google Cloud Console.",inputType:"secret"},auth_apple_enabled:{key:"auth_apple_enabled",label:"Enable Sign in with Apple",description:"Allow users to authenticate with their Apple ID.",inputType:"boolean"},auth_apple_client_id:{key:"auth_apple_client_id",label:"Apple Services ID",description:"The Services ID configured in your Apple Developer account.",inputType:"text"},auth_apple_team_id:{key:"auth_apple_team_id",label:"Apple Team ID",description:"Your Apple Developer Team ID.",inputType:"text"},auth_apple_key_id:{key:"auth_apple_key_id",label:"Apple Key ID",description:"The Key ID for your Sign in with Apple private key.",inputType:"text"},auth_apple_private_key:{key:"auth_apple_private_key",label:"Apple Private Key",description:"The private key file contents (PEM format) for Sign in with Apple.",inputType:"secret",multiline:!0},auth_solana_enabled:{key:"auth_solana_enabled",label:"Enable Solana Wallet Auth",description:"Allow users to authenticate by signing with their Solana wallet.",inputType:"boolean"},auth_solana_challenge_expiry:{key:"auth_solana_challenge_expiry",label:"Challenge Expiry",description:"How long a wallet signature challenge is valid.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"10 minutes",value:"600"}]},auth_webauthn_enabled:{key:"auth_webauthn_enabled",label:"Enable WebAuthn/Passkeys",description:"Allow passwordless authentication with FIDO2/WebAuthn credentials.",inputType:"boolean"},auth_webauthn_rp_id:{key:"auth_webauthn_rp_id",label:"Relying Party ID",description:"Usually your domain (e.g., example.com). Passkeys are bound to this.",inputType:"text"},auth_webauthn_rp_name:{key:"auth_webauthn_rp_name",label:"Relying Party Name",description:"Display name shown to users during passkey registration.",inputType:"text"},auth_webauthn_rp_origin:{key:"auth_webauthn_rp_origin",label:"Allowed Origins",description:"Comma-separated origins allowed for WebAuthn (e.g., https://example.com).",inputType:"text"},feature_privacy_cash:{key:"feature_privacy_cash",label:"Privacy Cash",description:"Enable Privacy Cash deposits and timed withdrawals.",inputType:"boolean"},feature_wallet_signing:{key:"feature_wallet_signing",label:"Embedded Wallet Signing",description:"Enable the embedded wallet for transaction signing.",inputType:"boolean"},feature_sso:{key:"feature_sso",label:"Enterprise SSO",description:"Enable SAML/OIDC single sign-on for enterprise customers.",inputType:"boolean"},feature_organizations:{key:"feature_organizations",label:"Organizations",description:"Enable multi-user organizations with role-based access.",inputType:"boolean"},feature_mfa:{key:"feature_mfa",label:"Two-Factor Authentication",description:"Allow users to enable TOTP-based two-factor authentication.",inputType:"boolean"},feature_instant_link:{key:"feature_instant_link",label:"Instant Link Login",description:"Allow passwordless login via magic link sent to email.",inputType:"boolean"},security_cors_origins:{key:"security_cors_origins",label:"CORS Origins",description:"Allowed origins for cross-origin requests (comma-separated). Empty = same origin only.",inputType:"text"},security_cookie_domain:{key:"security_cookie_domain",label:"Cookie Domain",description:"Domain for auth cookies. Empty uses the request origin.",inputType:"text"},security_cookie_secure:{key:"security_cookie_secure",label:"Secure Cookies",description:"Require HTTPS for cookies. Disable only for local development.",inputType:"boolean"},security_cookie_same_site:{key:"security_cookie_same_site",label:"Cookie SameSite",description:'SameSite policy for cookies. Use "none" only if needed for cross-site embeds.',inputType:"select",presets:[{label:"Strict",value:"strict"},{label:"Lax (Recommended)",value:"lax"},{label:"None (cross-site)",value:"none"}]},security_session_timeout:{key:"security_session_timeout",label:"Session Timeout",description:"How long sessions remain valid before requiring re-authentication.",inputType:"duration",min:300,presets:[{label:"1 hour",value:"3600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"30 days",value:"2592000"}]},security_jwt_issuer:{key:"security_jwt_issuer",label:"JWT Issuer",description:"Issuer claim for JWTs. Empty uses the server URL.",inputType:"text"},security_jwt_audience:{key:"security_jwt_audience",label:"JWT Audience",description:"Audience claim for JWTs. Empty uses default.",inputType:"text"},email_smtp_host:{key:"email_smtp_host",label:"SMTP Host",description:"SMTP server hostname (e.g., smtp.sendgrid.net).",inputType:"text"},email_smtp_port:{key:"email_smtp_port",label:"SMTP Port",description:"SMTP server port. Common: 587 (TLS), 465 (SSL), 25 (unencrypted).",inputType:"select",presets:[{label:"587 (TLS)",value:"587"},{label:"465 (SSL)",value:"465"},{label:"25 (Plain)",value:"25"}]},email_smtp_user:{key:"email_smtp_user",label:"SMTP Username",description:"Username for SMTP authentication.",inputType:"text"},email_smtp_password:{key:"email_smtp_password",label:"SMTP Password",description:"Password or API key for SMTP authentication.",inputType:"secret"},email_smtp_tls:{key:"email_smtp_tls",label:"Use TLS",description:"Enable TLS encryption for SMTP connections.",inputType:"boolean"},email_from_address:{key:"email_from_address",label:"From Address",description:"Default sender email address (e.g., noreply@example.com).",inputType:"text"},email_from_name:{key:"email_from_name",label:"From Name",description:'Default sender display name (e.g., "My App").',inputType:"text"},webhook_enabled:{key:"webhook_enabled",label:"Enable Webhooks",description:"Send HTTP notifications for auth events (signup, login, etc.).",inputType:"boolean"},webhook_url:{key:"webhook_url",label:"Webhook URL",description:"Endpoint to receive webhook POST requests.",inputType:"text"},webhook_secret:{key:"webhook_secret",label:"Webhook Secret",description:"Secret used to sign webhook payloads (HMAC-SHA256).",inputType:"secret"},webhook_timeout:{key:"webhook_timeout",label:"Timeout",description:"Maximum time to wait for webhook response.",inputType:"duration",min:5,presets:[{label:"10 seconds",value:"10"},{label:"30 seconds",value:"30"},{label:"60 seconds",value:"60"}]},webhook_retries:{key:"webhook_retries",label:"Max Retries",description:"Number of retry attempts for failed webhooks.",inputType:"select",presets:[{label:"0 (No retries)",value:"0"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"}]},server_frontend_url:{key:"server_frontend_url",label:"Frontend URL",description:"URL of your frontend app (for redirects and email links).",inputType:"text"},server_base_path:{key:"server_base_path",label:"Base Path",description:"Base path for auth endpoints (e.g., /auth).",inputType:"text"},server_trust_proxy:{key:"server_trust_proxy",label:"Trust Proxy",description:"Trust X-Forwarded-For headers. Enable if behind a reverse proxy.",inputType:"boolean"},privacy_period_secs:{key:"privacy_period_secs",label:"Privacy Period",description:"How long deposits are held before withdrawal to provide timing privacy. Longer periods provide better privacy but delay user access to funds.",inputType:"duration",min:0,presets:[{label:"Disabled",value:"0"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"},{label:"24 hours",value:"86400"},{label:"7 days",value:"604800"},{label:"14 days",value:"1209600"},{label:"30 days",value:"2592000"}],warningThreshold:{below:3600,message:"Very short privacy periods may not provide adequate timing protection."}},withdrawal_poll_interval_secs:{key:"withdrawal_poll_interval_secs",label:"Worker Poll Interval",description:"How often the withdrawal worker checks for deposits ready to process. Lower values process faster but increase server load.",inputType:"duration",min:60,presets:[{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"},{label:"1 hour",value:"3600"},{label:"6 hours",value:"21600"}],warningThreshold:{below:60,message:"Polling more than once per minute may cause excessive load."}},withdrawal_batch_size:{key:"withdrawal_batch_size",label:"Batch Size",description:"Maximum number of withdrawals to process in a single batch. Higher values improve throughput but may cause timeouts.",inputType:"select",min:1,max:100,presets:[{label:"1 (Sequential)",value:"1"},{label:"5",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"25",value:"25"},{label:"50",value:"50"},{label:"100 (Max)",value:"100"}]},withdrawal_timeout_secs:{key:"withdrawal_timeout_secs",label:"Transaction Timeout",description:"How long to wait for a withdrawal transaction to confirm before considering it failed.",inputType:"duration",min:30,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"2 minutes",value:"120"},{label:"5 minutes",value:"300"}],warningThreshold:{below:30,message:"Very short timeouts may cause premature failure on slow networks."}},withdrawal_max_retries:{key:"withdrawal_max_retries",label:"Max Retries",description:"Number of times to retry a failed withdrawal before marking it as permanently failed.",inputType:"select",min:0,max:10,presets:[{label:"0 (No retries)",value:"0"},{label:"1",value:"1"},{label:"3 (Recommended)",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},withdrawal_percentage:{key:"withdrawal_percentage",label:"Withdrawal Percentage",description:"Percentage of ready funds to withdraw each cycle. Lower values spread withdrawals over time for better privacy.",inputType:"percentage",min:1,max:100,step:5,presets:[{label:"25%",value:"25"},{label:"50%",value:"50"},{label:"75%",value:"75"},{label:"100% (All at once)",value:"100"}],warningThreshold:{above:75,message:"High percentages may reduce timing privacy by processing most withdrawals together."}},partial_withdrawal_count:{key:"partial_withdrawal_count",label:"Partial Withdrawals",description:"Maximum partial withdrawals per batch. Partial withdrawals add noise to timing analysis. Set to 0 to disable.",inputType:"select",min:0,presets:[{label:"Disabled",value:"0"},{label:"1",value:"1"},{label:"3",value:"3"},{label:"5",value:"5"},{label:"10",value:"10"}]},partial_withdrawal_min_lamports:{key:"partial_withdrawal_min_lamports",label:"Min Balance for Partial",description:"Minimum account balance (in lamports) required before partial withdrawals are considered. 1 SOL = 1,000,000,000 lamports.",inputType:"select",min:0,presets:[{label:"0.1 SOL",value:"100000000"},{label:"0.5 SOL",value:"500000000"},{label:"1 SOL",value:"1000000000"},{label:"5 SOL",value:"5000000000"},{label:"10 SOL",value:"10000000000"}]},rate_limit_auth:{key:"rate_limit_auth",label:"Auth Request Limit",description:"Maximum authentication attempts (login, register, password reset) per IP per window. Protects against brute force attacks.",inputType:"select",min:1,unit:"requests",presets:[{label:"5 (Strict)",value:"5"},{label:"10 (Recommended)",value:"10"},{label:"20",value:"20"},{label:"50 (Permissive)",value:"50"}],warningThreshold:{above:20,message:"High auth limits may allow brute force attempts."}},rate_limit_general:{key:"rate_limit_general",label:"General Request Limit",description:"Maximum general API requests per IP per window. Affects all non-auth endpoints.",inputType:"select",min:1,unit:"requests",presets:[{label:"30",value:"30"},{label:"60 (Recommended)",value:"60"},{label:"120",value:"120"},{label:"300",value:"300"}]},rate_limit_credit:{key:"rate_limit_credit",label:"Credit Request Limit",description:"Maximum credit/balance check requests per IP per window. Higher for apps that poll balance frequently.",inputType:"select",min:1,unit:"requests",presets:[{label:"10",value:"10"},{label:"30 (Recommended)",value:"30"},{label:"60",value:"60"},{label:"120",value:"120"}]},rate_limit_window:{key:"rate_limit_window",label:"Rate Limit Window",description:'Time window for rate limiting. All limits above are "per window". Shorter windows are stricter.',inputType:"duration",min:1,presets:[{label:"30 seconds",value:"30"},{label:"1 minute",value:"60"},{label:"5 minutes",value:"300"},{label:"15 minutes",value:"900"}]},deposit_quick_action_tokens:{key:"deposit_quick_action_tokens",label:"Quick Action Tokens",description:"Comma-separated token symbols shown as quick action buttons. First token is the default.",inputType:"tokenSymbolList"},deposit_custom_tokens:{key:"deposit_custom_tokens",label:"Custom Dropdown Tokens",description:'Comma-separated token symbols shown in the "Custom" dropdown. Leave empty to show all.',inputType:"tokenSymbolList"},deposit_custom_tokens_json:{key:"deposit_custom_tokens_json",label:"Custom Token Definitions",description:"Add tokens beyond the built-in list. Define symbol, mint address, decimals, and logo URL.",inputType:"tokenList"}},cn={"auth.apple":{label:"Apple Sign-In",description:"Configure Sign in with Apple OAuth integration.",icon:""},"auth.email":{label:"Email Authentication",description:"Configure email/password authentication settings.",icon:""},"auth.google":{label:"Google Sign-In",description:"Configure Google OAuth integration.",icon:""},"auth.solana":{label:"Solana Wallet Auth",description:"Configure Solana wallet signature authentication.",icon:""},"auth.webauthn":{label:"WebAuthn / Passkeys",description:"Configure FIDO2/WebAuthn passwordless authentication.",icon:""},deposit:{label:"Deposit Settings",description:"Configure token lists and deposit flow display options.",icon:""},email:{label:"Email / SMTP",description:"Configure outbound email delivery for verification, password reset, and notifications.",icon:""},features:{label:"Feature Flags",description:"Enable or disable major platform features.",icon:""},privacy:{label:"Privacy Settings",description:"Control the privacy period for deposits. Longer periods provide better timing privacy but delay fund availability.",icon:""},rate_limit:{label:"Rate Limiting",description:"Protect the system from abuse by limiting request rates. Balance security with user experience.",icon:""},security:{label:"Security",description:"Configure CORS, cookies, sessions, and JWT settings.",icon:""},server:{label:"Server",description:"Server infrastructure settings. Some may be overridden by environment variables.",icon:""},webhook:{label:"Webhooks",description:"Configure HTTP webhook notifications for auth events.",icon:""},withdrawal:{label:"Withdrawal Worker",description:"Configure how the automated withdrawal processor handles pending withdrawals. These settings affect throughput and privacy.",icon:""}};function dn({showDescriptions:s=!0,className:t="",onSave:o}){const{settings:a,isLoading:r,isUpdating:n,error:c,fetchSettings:i,updateSettings:d}=It.useSystemSettings(),[u,p]=l.useState({}),[f,h]=l.useState(null),[w,g]=l.useState(!1);l.useEffect(()=>{i()},[i]),l.useEffect(()=>{if(w){const S=setTimeout(()=>g(!1),3e3);return()=>clearTimeout(S)}},[w]);const m=l.useCallback((S,x)=>{p(k=>({...k,[S]:x})),h(null),g(!1)},[]),y=l.useCallback(async()=>{const S=Object.entries(u).map(([x,k])=>({key:x,value:k}));if(S.length!==0)try{await d(S),p({}),h(null),g(!0),o?.()}catch(x){h(x instanceof Error?x.message:"Failed to save settings")}},[u,d,o]),A=l.useCallback(()=>{p({}),h(null),g(!1)},[]),b=Object.keys(u).length>0,v=Object.keys(u).length;if(r&&Object.keys(a).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(c)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(Y.ErrorMessage,{error:c.message})});const j=Object.keys(a).sort();return j.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${t}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${t}`,children:[f&&e.jsx(Y.ErrorMessage,{error:f}),w&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),j.map(S=>e.jsx(un,{category:S,settings:a[S],edits:u,showDescription:s,onChange:m},S)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[b&&e.jsxs("span",{className:"cedros-settings-change-count",children:[v," unsaved change",v!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:A,disabled:!b||n,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:y,disabled:!b||n,children:n?e.jsx(V.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}function un({category:s,settings:t,edits:o,showDescription:a,onChange:r}){const n=cn[s]||{label:s,description:"",icon:"⚙️"};return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:n.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:n.label}),a&&n.description&&e.jsx("p",{className:"cedros-settings-section-description",children:n.description})]})]}),e.jsx("div",{className:"cedros-settings-grid",children:t.map(c=>e.jsx(hn,{setting:c,editValue:o[c.key],onChange:r},c.key))})]})}function hn({setting:s,editValue:t,onChange:o}){const a=ln[s.key],r=t??s.value,n=t!==void 0&&t!==s.value,c=l.useMemo(()=>{if(!a?.warningThreshold)return null;const i=parseInt(r,10);if(isNaN(i))return null;const{above:d,below:u,message:p}=a.warningThreshold;return d!==void 0&&i>d||u!==void 0&&i<u?p:null},[r,a?.warningThreshold]);return a?e.jsxs("div",{className:`cedros-setting-row ${n?"cedros-setting-row-changed":""} ${c?"cedros-setting-row-warning":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:a.label}),e.jsx("span",{className:"cedros-setting-description",children:a.description})]}),e.jsxs("div",{className:"cedros-setting-control",children:[a.inputType==="duration"&&e.jsx(pn,{value:r,onChange:i=>o(s.key,i),presets:a.presets,min:a.min}),a.inputType==="percentage"&&e.jsx(mn,{value:r,onChange:i=>o(s.key,i),min:a.min??1,max:a.max??100,step:a.step??5,presets:a.presets}),a.inputType==="select"&&e.jsx(fn,{value:r,onChange:i=>o(s.key,i),presets:a.presets??[],unit:a.unit}),a.inputType==="number"&&e.jsx(gn,{value:r,onChange:i=>o(s.key,i),min:a.min,max:a.max,unit:a.unit}),a.inputType==="tokenList"&&e.jsx(yn,{value:r,onChange:i=>o(s.key,i)}),a.inputType==="text"&&e.jsx("input",{type:"text",value:r,onChange:i=>o(s.key,i.target.value),className:"cedros-setting-input",placeholder:a.label}),a.inputType==="boolean"&&e.jsx(wn,{value:r,onChange:i=>o(s.key,i)}),a.inputType==="secret"&&e.jsx(bn,{value:r,onChange:i=>o(s.key,i),multiline:a.multiline}),a.inputType==="tokenSymbolList"&&e.jsx(xn,{value:r,onChange:i=>o(s.key,i)}),c&&e.jsx("div",{className:"cedros-setting-warning",children:c})]})]}):e.jsxs("div",{className:`cedros-setting-row ${n?"cedros-setting-row-changed":""}`,children:[e.jsxs("div",{className:"cedros-setting-label",children:[e.jsx("span",{className:"cedros-setting-name",children:s.key}),s.description&&e.jsx("span",{className:"cedros-setting-description",children:s.description})]}),e.jsx("div",{className:"cedros-setting-input-wrapper",children:e.jsx("input",{type:"text",value:r,onChange:i=>o(s.key,i.target.value),className:"cedros-setting-input"})})]})}function pn({value:s,onChange:t,presets:o,min:a=0}){const r=parseInt(s,10)||0,n=an(r),c=l.useCallback(d=>{d.target.value&&t(d.target.value)},[t]),i=l.useCallback(d=>{const u=Math.max(a,parseInt(d.target.value,10)||0);t(String(u))},[t,a]);return e.jsxs("div",{className:"cedros-duration-input",children:[o&&o.length>0&&e.jsxs("select",{value:o.find(d=>d.value===s)?.value??"",onChange:c,className:"cedros-setting-select",children:[e.jsx("option",{value:"",children:"Custom..."}),o.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))]}),e.jsxs("div",{className:"cedros-duration-custom",children:[e.jsx("input",{type:"number",value:r,onChange:i,min:a,className:"cedros-setting-input cedros-setting-input-sm"}),e.jsx("span",{className:"cedros-setting-unit",children:"seconds"}),e.jsxs("span",{className:"cedros-duration-display",children:["= ",n]})]})]})}function mn({value:s,onChange:t,min:o,max:a,step:r,presets:n}){const c=parseInt(s,10)||o,i=l.useCallback(u=>{t(u.target.value)},[t]),d=l.useCallback(u=>{t(u)},[t]);return e.jsxs("div",{className:"cedros-percentage-input",children:[e.jsxs("div",{className:"cedros-percentage-slider-row",children:[e.jsx("input",{type:"range",value:c,onChange:i,min:o,max:a,step:r,className:"cedros-percentage-slider"}),e.jsxs("span",{className:"cedros-percentage-value",children:[c,"%"]})]}),n&&n.length>0&&e.jsx("div",{className:"cedros-preset-buttons",children:n.map(u=>e.jsx("button",{type:"button",className:`cedros-preset-button ${u.value===s?"cedros-preset-button-active":""}`,onClick:()=>d(u.value),children:u.label},u.value))})]})}function fn({value:s,onChange:t,presets:o,unit:a}){const r=!o.some(i=>i.value===s),n=l.useCallback(i=>{i.target.value!=="__custom__"&&t(i.target.value)},[t]),c=l.useCallback(i=>{t(i.target.value)},[t]);return e.jsxs("div",{className:"cedros-select-input",children:[e.jsxs("select",{value:r?"__custom__":s,onChange:n,className:"cedros-setting-select",children:[o.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value)),e.jsx("option",{value:"__custom__",children:"Custom..."})]}),r&&e.jsxs("div",{className:"cedros-select-custom",children:[e.jsx("input",{type:"number",value:s,onChange:c,className:"cedros-setting-input cedros-setting-input-sm"}),a&&e.jsx("span",{className:"cedros-setting-unit",children:a})]})]})}function gn({value:s,onChange:t,min:o,max:a,unit:r}){const n=l.useCallback(c=>{t(c.target.value)},[t]);return e.jsxs("div",{className:"cedros-number-input",children:[e.jsx("input",{type:"number",value:s,onChange:n,min:o,max:a,className:"cedros-setting-input"}),r&&e.jsx("span",{className:"cedros-setting-unit",children:r})]})}function wn({value:s,onChange:t}){const o=s==="true",a=l.useCallback(()=>{t(o?"false":"true")},[o,t]);return e.jsxs("button",{type:"button",role:"switch","aria-checked":o,className:`cedros-toggle ${o?"cedros-toggle-on":"cedros-toggle-off"}`,onClick:a,children:[e.jsx("span",{className:"cedros-toggle-track",children:e.jsx("span",{className:"cedros-toggle-thumb"})}),e.jsx("span",{className:"cedros-toggle-label",children:o?"Enabled":"Disabled"})]})}function bn({value:s,onChange:t,multiline:o}){const[a,r]=l.useState(!1),[n,c]=l.useState(!1),i=s&&s.length>0,d=l.useCallback(()=>{r(!0),c(!0)},[]),u=l.useCallback(()=>{r(!1),c(!1)},[]),p=l.useCallback(f=>{t(f.target.value)},[t]);return!a&&i?e.jsxs("div",{className:"cedros-secret-input cedros-secret-input-masked",children:[e.jsx("span",{className:"cedros-secret-masked",children:"•".repeat(Math.min(s.length,20))}),e.jsx("button",{type:"button",className:"cedros-secret-edit-btn",onClick:d,children:"Edit"})]}):e.jsxs("div",{className:"cedros-secret-input",children:[o?e.jsx("textarea",{value:s,onChange:p,className:"cedros-setting-input cedros-setting-textarea",placeholder:"Enter secret value...",rows:4}):e.jsx("input",{type:n?"text":"password",value:s,onChange:p,className:"cedros-setting-input",placeholder:"Enter secret value..."}),e.jsxs("div",{className:"cedros-secret-actions",children:[!o&&e.jsx("button",{type:"button",className:"cedros-secret-toggle-btn",onClick:()=>c(!n),children:n?"Hide":"Show"}),a&&e.jsx("button",{type:"button",className:"cedros-secret-done-btn",onClick:u,children:"Done"})]})]})}const wr=["SOL","USDC","USDT","EURC","USD1","PYUSD","USDH","CASH","BONK","ORE"];function yn({value:s,onChange:t}){const o=l.useMemo(()=>{try{return JSON.parse(s||"[]")}catch{return[]}},[s]),a=l.useCallback(i=>{t(JSON.stringify(i))},[t]),r=l.useCallback(()=>{a([...o,{symbol:"",mint:"",decimals:6}])},[o,a]),n=l.useCallback((i,d,u)=>{const p=[...o];p[i]={...p[i],[d]:u},a(p)},[o,a]),c=l.useCallback(i=>{a(o.filter((d,u)=>u!==i))},[o,a]);return e.jsxs("div",{className:"cedros-token-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Built-in tokens:"}),e.jsx("div",{className:"cedros-token-presets-list",children:wr.map(i=>e.jsx("span",{className:"cedros-token-preset-chip",children:i},i))})]}),o.length===0&&e.jsx("p",{className:"cedros-token-list-empty",children:"No custom tokens added. Use the built-in tokens above or add your own."}),o.map((i,d)=>e.jsxs("div",{className:"cedros-token-row",children:[e.jsxs("div",{className:"cedros-token-row-fields",children:[e.jsx("input",{type:"text",placeholder:"Symbol",value:i.symbol,onChange:u=>n(d,"symbol",u.target.value.toUpperCase()),className:"cedros-setting-input cedros-token-input-symbol",maxLength:10}),e.jsx("input",{type:"text",placeholder:"Mint address",value:i.mint,onChange:u=>n(d,"mint",u.target.value),className:"cedros-setting-input cedros-token-input-mint"}),e.jsx("input",{type:"number",placeholder:"Decimals",value:i.decimals,onChange:u=>n(d,"decimals",parseInt(u.target.value,10)||0),className:"cedros-setting-input cedros-token-input-decimals",min:0,max:18}),e.jsx("input",{type:"text",placeholder:"Logo URL (optional)",value:i.logoUrl||"",onChange:u=>n(d,"logoUrl",u.target.value||void 0),className:"cedros-setting-input cedros-token-input-logo"})]}),e.jsx("button",{type:"button",className:"cedros-token-remove-btn",onClick:()=>c(d),title:"Remove token",children:"×"})]},d)),e.jsx("button",{type:"button",className:"cedros-token-add-btn",onClick:r,children:"+ Add Token"})]})}function xn({value:s,onChange:t}){const o=l.useMemo(()=>s.split(",").map(n=>n.trim()).filter(Boolean),[s]),a=l.useCallback(n=>{if(!n||o.includes(n))return;const c=[...o,n].join(", ");t(c)},[o,t]),r=l.useCallback(n=>{const c=o.filter(i=>i!==n).join(", ");t(c)},[o,t]);return e.jsxs("div",{className:"cedros-token-symbol-list-input",children:[e.jsxs("div",{className:"cedros-token-presets",children:[e.jsx("span",{className:"cedros-token-presets-label",children:"Click to add:"}),e.jsx("div",{className:"cedros-token-presets-list",children:wr.map(n=>{const c=o.includes(n);return e.jsxs("button",{type:"button",className:`cedros-token-preset-chip ${c?"cedros-token-preset-chip-selected":""}`,onClick:()=>c?r(n):a(n),title:c?`Remove ${n}`:`Add ${n}`,children:[n,c&&e.jsx("span",{className:"cedros-token-chip-check",children:"✓"})]},n)})})]}),e.jsx("input",{type:"text",value:s,onChange:n=>t(n.target.value),className:"cedros-setting-input",placeholder:"USDC, SOL, BONK..."})]})}class An{client;constructor(t,o,a){this.client=new M.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a})}async getStatus(){try{return await this.client.get("/setup/status")}catch(t){throw M.handleApiError(t,"Failed to check setup status")}}async createFirstAdmin(t){try{return await this.client.post("/setup/admin",t)}catch(o){throw M.handleApiError(o,"Failed to create admin account")}}}function Os(){const{config:s}=M.useCedrosLogin(),[t,o]=l.useState(null),[a,r]=l.useState(!1),[n,c]=l.useState(!1),[i,d]=l.useState(null),u=l.useRef(0),p=l.useMemo(()=>new An(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),f=l.useRef(p);f.current=p;const h=l.useCallback(async()=>{r(!0),d(null);const g=++u.current;try{const m=await f.current.getStatus();if(g!==u.current)return;o(m)}catch(m){if(g!==u.current)return;d(m instanceof Error?m:new Error("Failed to check setup status"))}finally{g===u.current&&r(!1)}},[]),w=l.useCallback(async g=>{c(!0),d(null);try{const m=await f.current.createFirstAdmin(g);return await h(),m}catch(m){const y=m instanceof Error?m:new Error("Failed to create admin");throw d(y),y}finally{c(!1)}},[h]);return{status:t,isLoading:a,isCreating:n,error:i,checkStatus:h,createAdmin:w}}const vn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,nt=8;function jn(s){const t={};return s.email?vn.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<nt&&(t.password=`Password must be at least ${nt} characters`):t.password="Password is required",s.confirmPassword?s.password!==s.confirmPassword&&(t.confirmPassword="Passwords do not match"):t.confirmPassword="Please confirm your password",t}function br({onComplete:s,className:t=""}){const{status:o,isLoading:a,isCreating:r,error:n,checkStatus:c,createAdmin:i}=Os(),[d,u]=l.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[p,f]=l.useState({}),[h,w]=l.useState(!1);l.useEffect(()=>{c()},[c]);const g=l.useCallback(y=>A=>{u(b=>({...b,[y]:A.target.value})),f(b=>({...b,[y]:void 0}))},[]),m=l.useCallback(async y=>{y.preventDefault();const A=jn(d);if(Object.keys(A).length>0){f(A);return}try{await i({email:d.email,password:d.password,name:d.name||void 0,orgName:d.orgName||void 0}),w(!0),s?.()}catch{}},[d,i,s]);return a?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):o&&!o.needsSetup?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):h?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:m,children:[n&&e.jsx(Y.ErrorMessage,{error:n.message}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-email",className:"cedros-setup__label",children:["Email Address ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-email",type:"email",className:`cedros-setup__input ${p.email?"cedros-setup__input--error":""}`,value:d.email,onChange:g("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:r}),p.email&&e.jsx("span",{className:"cedros-setup__error",children:p.email})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-name",className:"cedros-setup__label",children:"Display Name"}),e.jsx("input",{id:"setup-name",type:"text",className:"cedros-setup__input",value:d.name,onChange:g("name"),placeholder:"Admin",autoComplete:"name",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:d.orgName,onChange:g("orgName"),placeholder:"My Organization",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${p.password?"cedros-setup__input--error":""}`,value:d.password,onChange:g("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:r}),p.password&&e.jsx("span",{className:"cedros-setup__error",children:p.password})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-confirm-password",className:"cedros-setup__label",children:["Confirm Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-confirm-password",type:"password",className:`cedros-setup__input ${p.confirmPassword?"cedros-setup__input--error":""}`,value:d.confirmPassword,onChange:g("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:r}),p.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:p.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Creating Account..."})]}):"Create Admin Account"})]}),e.jsxs("div",{className:"cedros-setup__footer",children:[e.jsx("p",{className:"cedros-setup__note",children:"This will be the first administrator account for your installation."}),o?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",o.serverVersion]})]})]})})}const kn=["security","rate_limit"];function Nn({className:s}){return e.jsx(qt.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:kn,className:s})}const at=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}],Cn={mailgun:"smtp.mailgun.org",sendgrid:"smtp.sendgrid.net",postmark:"smtp.postmarkapp.com",ses:"email-smtp.us-east-1.amazonaws.com",resend:"smtp.resend.com"},Sn=["email_provider","email_smtp_password","email_from_address","email_from_name"],En=["email_provider","email_smtp_host","email_smtp_port","email_smtp_user","email_smtp_password","email_smtp_tls","email_from_address","email_from_name"];function Pn({className:s}){const{settings:t,edits:o,isLoading:a,autosaveStatus:r,autosaveError:n,error:c,fetchSettings:i,handleChange:d,getEffectiveValue:u}=rs.useSettingsAutosave(),[p,f]=l.useState("email");l.useEffect(()=>{i()},[i]);const h=at.find(b=>b.id===p),w=h?.category??"",m=(u("email_provider")||"custom")==="custom",y=l.useMemo(()=>{const b=t[w]??[];if(p!=="email")return b;const v=m?En:Sn;return b.filter(j=>v.includes(j.key)).sort((j,S)=>v.indexOf(j.key)-v.indexOf(S.key))},[t,w,p,m]),A=(b,v)=>{if(d(b,v),b==="email_provider"&&v!=="custom"){const j=Cn[v];j&&(d("email_smtp_host",j),d("email_smtp_port","587"),d("email_smtp_tls","true"))}};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(Y.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery and webhook notifications."})]}),e.jsx(rs.AutosaveStatus,{status:r,error:n})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:at.map(b=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${p===b.id?"cedros-admin-tab-active":""}`,onClick:()=>f(b.id),"aria-selected":p===b.id,role:"tab",children:b.label},b.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:y.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",h?.label??"this section","."]})}):e.jsx(rs.SettingsSection,{settings:y,edits:o,onChange:p==="email"?A:d})})]})}const ae={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]})},Ln=[{id:"users",label:"Users",icon:ae.users},{id:"team",label:"Team",icon:ae.members},{id:"deposits",label:"Deposits",icon:ae.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ae.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:ae.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ae.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ae.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ae.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:ae.server,group:"Configuration"}];function Tn({title:s="Dashboard",sections:t=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],defaultSection:o="users",refreshInterval:a=0,pageSize:r=20,onSectionChange:n,onSettingsClick:c,onLogoutClick:i,className:d=""}){const[u,p]=l.useState(o),[f,h]=l.useState(!0),{user:w,logout:g}=M.useCedrosLogin(),{activeOrg:m,role:y,isLoading:A,fetchOrgs:b,hasPermission:v}=Ds.useOrgs(),{status:j,isLoading:S,checkStatus:x}=Os(),{features:k,isLoading:C}=te.useServerFeatures(),{canAccess:N}=te.useDashboardPermissions(),L=l.useCallback(B=>{p(B),n?.(B)},[n]),P=Ln.filter(B=>!(!t.includes(B.id)||B.requiredFeature&&!k[B.requiredFeature]||!N(B.id))),E=P.find(B=>B.id===u),T=!E&&!C;return l.useEffect(()=>{b(),x()},[b,x]),l.useEffect(()=>{T&&P.length>0&&p("users")},[T,P.length]),!S&&j?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${d}`,children:e.jsx(br,{onComplete:()=>x()})}):(A||S||C)&&!m?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${d}`,children:[e.jsx(V.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):u==="team"&&!m?e.jsx("div",{className:`cedros-admin cedros-dashboard ${d}`,children:e.jsx(Y.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${d}`,children:[e.jsxs("aside",{className:"cedros-dashboard__sidebar",children:[e.jsx("div",{className:"cedros-dashboard__sidebar-header",children:e.jsxs("div",{className:"cedros-dashboard__logo",children:[ae.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:s})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),P.filter(B=>!B.group).map(B=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===B.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(B.id),"aria-current":u===B.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:B.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:B.label})]},B.id))]}),P.some(B=>B.group==="Configuration")&&e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsxs("button",{type:"button",className:"cedros-dashboard__nav-label cedros-dashboard__nav-label--collapsible",onClick:()=>h(!f),"aria-expanded":f,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${f?"cedros-dashboard__nav-chevron--expanded":""}`,children:ae.chevronRight})]}),f&&P.filter(B=>B.group==="Configuration").map(B=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===B.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(B.id),"aria-current":u===B.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:B.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:B.label})]},B.id))]})]}),w&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(ge.ProfileDropdown,{name:w.name,email:w.email,picture:w.picture,onSettings:c,onLogout:i??g})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:s}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:ae.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:E?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(Mn,{pageSize:r,currentUserId:w?.id}),u==="team"&&m&&e.jsx(_n,{orgId:m.id,currentUserId:w?.id,hasPermission:v,role:y}),u==="deposits"&&e.jsx(Rn,{pageSize:r,refreshInterval:a}),u==="withdrawals"&&e.jsx(Bn,{pageSize:r,refreshInterval:a}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ut.AuthenticationSettings,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Wt.EmbeddedWalletSettings,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Pn,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Is.CreditSystemSettings,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ot.ServerSettings,{})})]})]})]})}function Mn({pageSize:s,currentUserId:t}){const[o,a]=l.useState(null),{statsItems:r,isLoading:n,error:c,refresh:i}=Ee.useUsersStatsSummary();return o?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ee.AdminUserDetail,{userId:o.id,currentUserId:t,onBack:()=>a(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Ft.StatsBar,{stats:r,isLoading:n,onRefresh:i}),c&&e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx(Ee.AdminUserList,{pageSize:s,currentUserId:t,onUserClick:d=>a(d)})]})}function _n({orgId:s,currentUserId:t,hasPermission:o,role:a}){const[r,n]=l.useState("members"),{members:c,isLoading:i,error:d,fetchMembers:u,updateMemberRole:p,removeMember:f}=te.useMembers(s),{invites:h,isLoading:w,error:g,fetchInvites:m,createInvite:y,cancelInvite:A,resendInvite:b}=te.useInvites(s);l.useEffect(()=>{u(),m()},[u,m]);const v=o("invite:create"),j=o("invite:cancel"),S=h.length,x=c.reduce((L,P)=>(L[P.role]=(L[P.role]??0)+1,L),{}),k=x.owner??0,C=x.admin??0,N=x.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Ft.StatsBar,{stats:[{label:"Owners",value:k},{label:"Admins",value:C},{label:"Members",value:N},{label:"Pending Invites",value:S}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="members"?"cedros-admin-tab-active":""}`,onClick:()=>n("members"),"aria-selected":r==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${r==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>n("invites"),"aria-selected":r==="invites",role:"tab",children:["Pending Invites",S>0&&` (${S})`]}),a==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>n("permissions"),"aria-selected":r==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[r==="members"&&e.jsx(te.MemberList,{members:c,currentUserId:t,isLoading:i,error:d?.message,canManage:o("member:remove"),canChangeRoles:o("member:role_change"),onUpdateRole:p,onRemove:f}),r==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[v&&e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx("div",{className:"cedros-dashboard__section-header",children:e.jsx("h3",{className:"cedros-dashboard__section-title",children:"Send Invitation"})}),e.jsx(te.InviteForm,{onSubmit:y,isLoading:w,error:g?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(te.InviteList,{invites:h,isLoading:w,error:g?.message,canManage:j||v,onCancel:j?A:void 0,onResend:v?b:void 0})})]}),r==="permissions"&&a==="owner"&&e.jsx(te.PermissionsSection,{userRole:a})]})]})}function Rn({pageSize:s,refreshInterval:t}){const[o,a]=l.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(We.AdminDepositStats,{refreshInterval:t}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:o,onChange:r=>a(r.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(We.AdminDepositList,{statusFilter:o||void 0,pageSize:s,refreshInterval:t})]})]})}function Bn({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(fe.AdminWithdrawalStats,{refreshInterval:t}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(fe.AdminPrivacyPeriodDeposits,{pageSize:s,refreshInterval:t}),e.jsx(fe.AdminWithdrawalQueue,{pageSize:s,refreshInterval:t}),e.jsx(fe.AdminWithdrawalHistory,{pageSize:s,refreshInterval:t})]})]})}var xe={},ns,it;function Dn(){return it||(it=1,ns=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ns}var as={},me={},lt;function we(){if(lt)return me;lt=1;let s;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return me.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},me.getSymbolTotalCodewords=function(a){return t[a]},me.getBCHDigit=function(o){let a=0;for(;o!==0;)a++,o>>>=1;return a},me.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');s=a},me.isKanjiModeEnabled=function(){return typeof s<"u"},me.toSJIS=function(a){return s(a)},me}var is={},ct;function qs(){return ct||(ct=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+o)}}s.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},s.from=function(a,r){if(s.isValid(a))return a;try{return t(a)}catch{return r}}})(is)),is}var ls,dt;function In(){if(dt)return ls;dt=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const o=Math.floor(t/8);return(this.buffer[o]>>>7-t%8&1)===1},put:function(t,o){for(let a=0;a<o;a++)this.putBit((t>>>o-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),t&&(this.buffer[o]|=128>>>this.length%8),this.length++}},ls=s,ls}var cs,ut;function Fn(){if(ut)return cs;ut=1;function s(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return s.prototype.set=function(t,o,a,r){const n=t*this.size+o;this.data[n]=a,r&&(this.reservedBit[n]=!0)},s.prototype.get=function(t,o){return this.data[t*this.size+o]},s.prototype.xor=function(t,o,a){this.data[t*this.size+o]^=a},s.prototype.isReserved=function(t,o){return this.reservedBit[t*this.size+o]},cs=s,cs}var ds={},ht;function Un(){return ht||(ht=1,(function(s){const t=we().getSymbolSize;s.getRowColCoords=function(a){if(a===1)return[];const r=Math.floor(a/7)+2,n=t(a),c=n===145?26:Math.ceil((n-13)/(2*r-2))*2,i=[n-7];for(let d=1;d<r-1;d++)i[d]=i[d-1]-c;return i.push(6),i.reverse()},s.getPositions=function(a){const r=[],n=s.getRowColCoords(a),c=n.length;for(let i=0;i<c;i++)for(let d=0;d<c;d++)i===0&&d===0||i===0&&d===c-1||i===c-1&&d===0||r.push([n[i],n[d]]);return r}})(ds)),ds}var us={},pt;function Wn(){if(pt)return us;pt=1;const s=we().getSymbolSize,t=7;return us.getPositions=function(a){const r=s(a);return[[0,0],[r-t,0],[0,r-t]]},us}var hs={},mt;function On(){return mt||(mt=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};s.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},s.from=function(r){return s.isValid(r)?parseInt(r,10):void 0},s.getPenaltyN1=function(r){const n=r.size;let c=0,i=0,d=0,u=null,p=null;for(let f=0;f<n;f++){i=d=0,u=p=null;for(let h=0;h<n;h++){let w=r.get(f,h);w===u?i++:(i>=5&&(c+=t.N1+(i-5)),u=w,i=1),w=r.get(h,f),w===p?d++:(d>=5&&(c+=t.N1+(d-5)),p=w,d=1)}i>=5&&(c+=t.N1+(i-5)),d>=5&&(c+=t.N1+(d-5))}return c},s.getPenaltyN2=function(r){const n=r.size;let c=0;for(let i=0;i<n-1;i++)for(let d=0;d<n-1;d++){const u=r.get(i,d)+r.get(i,d+1)+r.get(i+1,d)+r.get(i+1,d+1);(u===4||u===0)&&c++}return c*t.N2},s.getPenaltyN3=function(r){const n=r.size;let c=0,i=0,d=0;for(let u=0;u<n;u++){i=d=0;for(let p=0;p<n;p++)i=i<<1&2047|r.get(u,p),p>=10&&(i===1488||i===93)&&c++,d=d<<1&2047|r.get(p,u),p>=10&&(d===1488||d===93)&&c++}return c*t.N3},s.getPenaltyN4=function(r){let n=0;const c=r.data.length;for(let d=0;d<c;d++)n+=r.data[d];return Math.abs(Math.ceil(n*100/c/5)-10)*t.N4};function o(a,r,n){switch(a){case s.Patterns.PATTERN000:return(r+n)%2===0;case s.Patterns.PATTERN001:return r%2===0;case s.Patterns.PATTERN010:return n%3===0;case s.Patterns.PATTERN011:return(r+n)%3===0;case s.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case s.Patterns.PATTERN101:return r*n%2+r*n%3===0;case s.Patterns.PATTERN110:return(r*n%2+r*n%3)%2===0;case s.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}s.applyMask=function(r,n){const c=n.size;for(let i=0;i<c;i++)for(let d=0;d<c;d++)n.isReserved(d,i)||n.xor(d,i,o(r,d,i))},s.getBestMask=function(r,n){const c=Object.keys(s.Patterns).length;let i=0,d=1/0;for(let u=0;u<c;u++){n(u),s.applyMask(u,r);const p=s.getPenaltyN1(r)+s.getPenaltyN2(r)+s.getPenaltyN3(r)+s.getPenaltyN4(r);s.applyMask(u,r),p<d&&(d=p,i=u)}return i}})(hs)),hs}var Ie={},ft;function yr(){if(ft)return Ie;ft=1;const s=qs(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Ie.getBlocksCount=function(r,n){switch(n){case s.L:return t[(r-1)*4+0];case s.M:return t[(r-1)*4+1];case s.Q:return t[(r-1)*4+2];case s.H:return t[(r-1)*4+3];default:return}},Ie.getTotalCodewordsCount=function(r,n){switch(n){case s.L:return o[(r-1)*4+0];case s.M:return o[(r-1)*4+1];case s.Q:return o[(r-1)*4+2];case s.H:return o[(r-1)*4+3];default:return}},Ie}var ps={},Ce={},gt;function qn(){if(gt)return Ce;gt=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let a=1;for(let r=0;r<255;r++)s[r]=a,t[a]=r,a<<=1,a&256&&(a^=285);for(let r=255;r<512;r++)s[r]=s[r-255]})(),Ce.log=function(a){if(a<1)throw new Error("log("+a+")");return t[a]},Ce.exp=function(a){return s[a]},Ce.mul=function(a,r){return a===0||r===0?0:s[t[a]+t[r]]},Ce}var wt;function zn(){return wt||(wt=1,(function(s){const t=qn();s.mul=function(a,r){const n=new Uint8Array(a.length+r.length-1);for(let c=0;c<a.length;c++)for(let i=0;i<r.length;i++)n[c+i]^=t.mul(a[c],r[i]);return n},s.mod=function(a,r){let n=new Uint8Array(a);for(;n.length-r.length>=0;){const c=n[0];for(let d=0;d<r.length;d++)n[d]^=t.mul(r[d],c);let i=0;for(;i<n.length&&n[i]===0;)i++;n=n.slice(i)}return n},s.generateECPolynomial=function(a){let r=new Uint8Array([1]);for(let n=0;n<a;n++)r=s.mul(r,new Uint8Array([1,t.exp(n)]));return r}})(ps)),ps}var ms,bt;function Vn(){if(bt)return ms;bt=1;const s=zn();function t(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(a){this.degree=a,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(a.length+this.degree);r.set(a);const n=s.mod(r,this.genPoly),c=this.degree-n.length;if(c>0){const i=new Uint8Array(this.degree);return i.set(n,c),i}return n},ms=t,ms}var fs={},gs={},ws={},yt;function xr(){return yt||(yt=1,ws.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),ws}var de={},xt;function Ar(){if(xt)return de;xt=1;const s="[0-9]+",t="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
2050
+ ]))+`;de.KANJI=new RegExp(o,"g"),de.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),de.BYTE=new RegExp(a,"g"),de.NUMERIC=new RegExp(s,"g"),de.ALPHANUMERIC=new RegExp(t,"g");const r=new RegExp("^"+o+"$"),n=new RegExp("^"+s+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return de.testKanji=function(d){return r.test(d)},de.testNumeric=function(d){return n.test(d)},de.testAlphanumeric=function(d){return c.test(d)},de}var At;function be(){return At||(At=1,(function(s){const t=xr(),o=Ar();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(n,c){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?n.ccBits[0]:c<27?n.ccBits[1]:n.ccBits[2]},s.getBestModeForData=function(n){return o.testNumeric(n)?s.NUMERIC:o.testAlphanumeric(n)?s.ALPHANUMERIC:o.testKanji(n)?s.KANJI:s.BYTE},s.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},s.isValid=function(n){return n&&n.bit&&n.ccBits};function a(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+r)}}s.from=function(n,c){if(s.isValid(n))return n;try{return a(n)}catch{return c}}})(gs)),gs}var vt;function Hn(){return vt||(vt=1,(function(s){const t=we(),o=yr(),a=qs(),r=be(),n=xr(),c=7973,i=t.getBCHDigit(c);function d(h,w,g){for(let m=1;m<=40;m++)if(w<=s.getCapacity(m,g,h))return m}function u(h,w){return r.getCharCountIndicator(h,w)+4}function p(h,w){let g=0;return h.forEach(function(m){const y=u(m.mode,w);g+=y+m.getBitsLength()}),g}function f(h,w){for(let g=1;g<=40;g++)if(p(h,g)<=s.getCapacity(g,w,r.MIXED))return g}s.from=function(w,g){return n.isValid(w)?parseInt(w,10):g},s.getCapacity=function(w,g,m){if(!n.isValid(w))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=r.BYTE);const y=t.getSymbolTotalCodewords(w),A=o.getTotalCodewordsCount(w,g),b=(y-A)*8;if(m===r.MIXED)return b;const v=b-u(m,w);switch(m){case r.NUMERIC:return Math.floor(v/10*3);case r.ALPHANUMERIC:return Math.floor(v/11*2);case r.KANJI:return Math.floor(v/13);case r.BYTE:default:return Math.floor(v/8)}},s.getBestVersionForData=function(w,g){let m;const y=a.from(g,a.M);if(Array.isArray(w)){if(w.length>1)return f(w,y);if(w.length===0)return 1;m=w[0]}else m=w;return d(m.mode,m.getLength(),y)},s.getEncodedBits=function(w){if(!n.isValid(w)||w<7)throw new Error("Invalid QR Code version");let g=w<<12;for(;t.getBCHDigit(g)-i>=0;)g^=c<<t.getBCHDigit(g)-i;return w<<12|g}})(fs)),fs}var bs={},jt;function Qn(){if(jt)return bs;jt=1;const s=we(),t=1335,o=21522,a=s.getBCHDigit(t);return bs.getEncodedBits=function(n,c){const i=n.bit<<3|c;let d=i<<10;for(;s.getBCHDigit(d)-a>=0;)d^=t<<s.getBCHDigit(d)-a;return(i<<10|d)^o},bs}var ys={},xs,kt;function Kn(){if(kt)return xs;kt=1;const s=be();function t(o){this.mode=s.NUMERIC,this.data=o.toString()}return t.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(a){let r,n,c;for(r=0;r+3<=this.data.length;r+=3)n=this.data.substr(r,3),c=parseInt(n,10),a.put(c,10);const i=this.data.length-r;i>0&&(n=this.data.substr(r),c=parseInt(n,10),a.put(c,i*3+1))},xs=t,xs}var As,Nt;function Gn(){if(Nt)return As;Nt=1;const s=be(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(a){this.mode=s.ALPHANUMERIC,this.data=a}return o.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(r){let n;for(n=0;n+2<=this.data.length;n+=2){let c=t.indexOf(this.data[n])*45;c+=t.indexOf(this.data[n+1]),r.put(c,11)}this.data.length%2&&r.put(t.indexOf(this.data[n]),6)},As=o,As}var vs,Ct;function Yn(){if(Ct)return vs;Ct=1;const s=be();function t(o){this.mode=s.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return t.getBitsLength=function(a){return a*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(o){for(let a=0,r=this.data.length;a<r;a++)o.put(this.data[a],8)},vs=t,vs}var js,St;function $n(){if(St)return js;St=1;const s=be(),t=we();function o(a){this.mode=s.KANJI,this.data=a}return o.getBitsLength=function(r){return r*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(a){let r;for(r=0;r<this.data.length;r++){let n=t.toSJIS(this.data[r]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
2051
+ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),a.put(n,13)}},js=o,js}var ks={exports:{}},Et;function Jn(){return Et||(Et=1,(function(s){var t={single_source_shortest_paths:function(o,a,r){var n={},c={};c[a]=0;var i=t.PriorityQueue.make();i.push(a,0);for(var d,u,p,f,h,w,g,m,y;!i.empty();){d=i.pop(),u=d.value,f=d.cost,h=o[u]||{};for(p in h)h.hasOwnProperty(p)&&(w=h[p],g=f+w,m=c[p],y=typeof c[p]>"u",(y||m>g)&&(c[p]=g,i.push(p,g),n[p]=u))}if(typeof r<"u"&&typeof c[r]>"u"){var A=["Could not find a path from ",a," to ",r,"."].join("");throw new Error(A)}return n},extract_shortest_path_from_predecessor_list:function(o,a){for(var r=[],n=a;n;)r.push(n),o[n],n=o[n];return r.reverse(),r},find_path:function(o,a,r){var n=t.single_source_shortest_paths(o,a,r);return t.extract_shortest_path_from_predecessor_list(n,r)},PriorityQueue:{make:function(o){var a=t.PriorityQueue,r={},n;o=o||{};for(n in a)a.hasOwnProperty(n)&&(r[n]=a[n]);return r.queue=[],r.sorter=o.sorter||a.default_sorter,r},default_sorter:function(o,a){return o.cost-a.cost},push:function(o,a){var r={value:o,cost:a};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=t})(ks)),ks.exports}var Pt;function Xn(){return Pt||(Pt=1,(function(s){const t=be(),o=Kn(),a=Gn(),r=Yn(),n=$n(),c=Ar(),i=we(),d=Jn();function u(A){return unescape(encodeURIComponent(A)).length}function p(A,b,v){const j=[];let S;for(;(S=A.exec(v))!==null;)j.push({data:S[0],index:S.index,mode:b,length:S[0].length});return j}function f(A){const b=p(c.NUMERIC,t.NUMERIC,A),v=p(c.ALPHANUMERIC,t.ALPHANUMERIC,A);let j,S;return i.isKanjiModeEnabled()?(j=p(c.BYTE,t.BYTE,A),S=p(c.KANJI,t.KANJI,A)):(j=p(c.BYTE_KANJI,t.BYTE,A),S=[]),b.concat(v,j,S).sort(function(k,C){return k.index-C.index}).map(function(k){return{data:k.data,mode:k.mode,length:k.length}})}function h(A,b){switch(b){case t.NUMERIC:return o.getBitsLength(A);case t.ALPHANUMERIC:return a.getBitsLength(A);case t.KANJI:return n.getBitsLength(A);case t.BYTE:return r.getBitsLength(A)}}function w(A){return A.reduce(function(b,v){const j=b.length-1>=0?b[b.length-1]:null;return j&&j.mode===v.mode?(b[b.length-1].data+=v.data,b):(b.push(v),b)},[])}function g(A){const b=[];for(let v=0;v<A.length;v++){const j=A[v];switch(j.mode){case t.NUMERIC:b.push([j,{data:j.data,mode:t.ALPHANUMERIC,length:j.length},{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.ALPHANUMERIC:b.push([j,{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.KANJI:b.push([j,{data:j.data,mode:t.BYTE,length:u(j.data)}]);break;case t.BYTE:b.push([{data:j.data,mode:t.BYTE,length:u(j.data)}])}}return b}function m(A,b){const v={},j={start:{}};let S=["start"];for(let x=0;x<A.length;x++){const k=A[x],C=[];for(let N=0;N<k.length;N++){const L=k[N],P=""+x+N;C.push(P),v[P]={node:L,lastCount:0},j[P]={};for(let E=0;E<S.length;E++){const T=S[E];v[T]&&v[T].node.mode===L.mode?(j[T][P]=h(v[T].lastCount+L.length,L.mode)-h(v[T].lastCount,L.mode),v[T].lastCount+=L.length):(v[T]&&(v[T].lastCount=L.length),j[T][P]=h(L.length,L.mode)+4+t.getCharCountIndicator(L.mode,b))}}S=C}for(let x=0;x<S.length;x++)j[S[x]].end=0;return{map:j,table:v}}function y(A,b){let v;const j=t.getBestModeForData(A);if(v=t.from(b,j),v!==t.BYTE&&v.bit<j.bit)throw new Error('"'+A+'" cannot be encoded with mode '+t.toString(v)+`.
2052
+ Suggested mode is: `+t.toString(j));switch(v===t.KANJI&&!i.isKanjiModeEnabled()&&(v=t.BYTE),v){case t.NUMERIC:return new o(A);case t.ALPHANUMERIC:return new a(A);case t.KANJI:return new n(A);case t.BYTE:return new r(A)}}s.fromArray=function(b){return b.reduce(function(v,j){return typeof j=="string"?v.push(y(j,null)):j.data&&v.push(y(j.data,j.mode)),v},[])},s.fromString=function(b,v){const j=f(b,i.isKanjiModeEnabled()),S=g(j),x=m(S,v),k=d.find_path(x.map,"start","end"),C=[];for(let N=1;N<k.length-1;N++)C.push(x.table[k[N]].node);return s.fromArray(w(C))},s.rawSplit=function(b){return s.fromArray(f(b,i.isKanjiModeEnabled()))}})(ys)),ys}var Lt;function Zn(){if(Lt)return as;Lt=1;const s=we(),t=qs(),o=In(),a=Fn(),r=Un(),n=Wn(),c=On(),i=yr(),d=Vn(),u=Hn(),p=Qn(),f=be(),h=Xn();function w(x,k){const C=x.size,N=n.getPositions(k);for(let L=0;L<N.length;L++){const P=N[L][0],E=N[L][1];for(let T=-1;T<=7;T++)if(!(P+T<=-1||C<=P+T))for(let _=-1;_<=7;_++)E+_<=-1||C<=E+_||(T>=0&&T<=6&&(_===0||_===6)||_>=0&&_<=6&&(T===0||T===6)||T>=2&&T<=4&&_>=2&&_<=4?x.set(P+T,E+_,!0,!0):x.set(P+T,E+_,!1,!0))}}function g(x){const k=x.size;for(let C=8;C<k-8;C++){const N=C%2===0;x.set(C,6,N,!0),x.set(6,C,N,!0)}}function m(x,k){const C=r.getPositions(k);for(let N=0;N<C.length;N++){const L=C[N][0],P=C[N][1];for(let E=-2;E<=2;E++)for(let T=-2;T<=2;T++)E===-2||E===2||T===-2||T===2||E===0&&T===0?x.set(L+E,P+T,!0,!0):x.set(L+E,P+T,!1,!0)}}function y(x,k){const C=x.size,N=u.getEncodedBits(k);let L,P,E;for(let T=0;T<18;T++)L=Math.floor(T/3),P=T%3+C-8-3,E=(N>>T&1)===1,x.set(L,P,E,!0),x.set(P,L,E,!0)}function A(x,k,C){const N=x.size,L=p.getEncodedBits(k,C);let P,E;for(P=0;P<15;P++)E=(L>>P&1)===1,P<6?x.set(P,8,E,!0):P<8?x.set(P+1,8,E,!0):x.set(N-15+P,8,E,!0),P<8?x.set(8,N-P-1,E,!0):P<9?x.set(8,15-P-1+1,E,!0):x.set(8,15-P-1,E,!0);x.set(N-8,8,1,!0)}function b(x,k){const C=x.size;let N=-1,L=C-1,P=7,E=0;for(let T=C-1;T>0;T-=2)for(T===6&&T--;;){for(let _=0;_<2;_++)if(!x.isReserved(L,T-_)){let B=!1;E<k.length&&(B=(k[E]>>>P&1)===1),x.set(L,T-_,B),P--,P===-1&&(E++,P=7)}if(L+=N,L<0||C<=L){L-=N,N=-N;break}}}function v(x,k,C){const N=new o;C.forEach(function(_){N.put(_.mode.bit,4),N.put(_.getLength(),f.getCharCountIndicator(_.mode,x)),_.write(N)});const L=s.getSymbolTotalCodewords(x),P=i.getTotalCodewordsCount(x,k),E=(L-P)*8;for(N.getLengthInBits()+4<=E&&N.put(0,4);N.getLengthInBits()%8!==0;)N.putBit(0);const T=(E-N.getLengthInBits())/8;for(let _=0;_<T;_++)N.put(_%2?17:236,8);return j(N,x,k)}function j(x,k,C){const N=s.getSymbolTotalCodewords(k),L=i.getTotalCodewordsCount(k,C),P=N-L,E=i.getBlocksCount(k,C),T=N%E,_=E-T,B=Math.floor(N/E),$=Math.floor(P/E),le=$+1,J=B-$,q=new d(J);let R=0;const I=new Array(E),z=new Array(E);let X=0;const ee=new Uint8Array(x.buffer);for(let Q=0;Q<E;Q++){const ne=Q<_?$:le;I[Q]=ee.slice(R,R+ne),z[Q]=q.encode(I[Q]),R+=ne,X=Math.max(X,ne)}const ue=new Uint8Array(N);let ce=0,W,U;for(W=0;W<X;W++)for(U=0;U<E;U++)W<I[U].length&&(ue[ce++]=I[U][W]);for(W=0;W<J;W++)for(U=0;U<E;U++)ue[ce++]=z[U][W];return ue}function S(x,k,C,N){let L;if(Array.isArray(x))L=h.fromArray(x);else if(typeof x=="string"){let B=k;if(!B){const $=h.rawSplit(x);B=u.getBestVersionForData($,C)}L=h.fromString(x,B||40)}else throw new Error("Invalid data");const P=u.getBestVersionForData(L,C);if(!P)throw new Error("The amount of data is too big to be stored in a QR Code");if(!k)k=P;else if(k<P)throw new Error(`
2053
2053
  The chosen QR Code version cannot contain this amount of data.
2054
2054
  Minimum version required to store current data is: `+P+`.
2055
- `);const E=v(k,C,L),T=s.getSymbolSize(k),M=new a(T);return w(M,k),g(M),m(M,k),A(M,C,0),k>=7&&y(M,k),b(M,E),isNaN(N)&&(N=c.getBestMask(M,A.bind(null,M,C))),c.applyMask(N,M),A(M,C,N),{modules:M,version:k,errorCorrectionLevel:C,maskPattern:N,segments:L}}return as.create=function(k,C){if(typeof k>"u"||k==="")throw new Error("No input text");let N=t.M,L,P;return typeof C<"u"&&(N=t.from(C.errorCorrectionLevel,t.M),L=u.from(C.version),P=c.from(C.maskPattern),C.toSJISFunc&&s.setToSJISFunction(C.toSJISFunc)),S(k,L,N,P)},as}var Ns={},Cs={},_t;function vr(){return _t||(_t=1,(function(s){function t(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let a=o.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+o);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(n){return[n,n]}))),a.length===6&&a.push("F","F");const r=parseInt(a.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+a.slice(0,6).join("")}}s.getOptions=function(a){a||(a={}),a.color||(a.color={});const r=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,n=a.width&&a.width>=21?a.width:void 0,c=a.scale||4;return{width:n,scale:n?4:c,margin:r,color:{dark:t(a.color.dark||"#000000ff"),light:t(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},s.getScale=function(a,r){return r.width&&r.width>=a+r.margin*2?r.width/(a+r.margin*2):r.scale},s.getImageWidth=function(a,r){const n=s.getScale(a,r);return Math.floor((a+r.margin*2)*n)},s.qrToImageData=function(a,r,n){const c=r.modules.size,i=r.modules.data,d=s.getScale(c,n),u=Math.floor((c+n.margin*2)*d),p=n.margin*d,f=[n.color.light,n.color.dark];for(let h=0;h<u;h++)for(let w=0;w<u;w++){let g=(h*u+w)*4,m=n.color.light;if(h>=p&&w>=p&&h<u-p&&w<u-p){const y=Math.floor((h-p)/d),A=Math.floor((w-p)/d);m=f[i[y*c+A]?1:0]}a[g++]=m.r,a[g++]=m.g,a[g++]=m.b,a[g]=m.a}}})(Cs)),Cs}var Mt;function ea(){return Mt||(Mt=1,(function(s){const t=vr();function o(r,n,c){r.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=c,n.width=c,n.style.height=c+"px",n.style.width=c+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}s.render=function(n,c,i){let d=i,u=c;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),c||(u=a()),d=t.getOptions(d);const p=t.getImageWidth(n.modules.size,d),f=u.getContext("2d"),h=f.createImageData(p,p);return t.qrToImageData(h.data,n,d),o(f,u,p),f.putImageData(h,0,0),u},s.renderToDataURL=function(n,c,i){let d=i;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),d||(d={});const u=s.render(n,c,d),p=d.type||"image/png",f=d.rendererOpts||{};return u.toDataURL(p,f.quality)}})(Ns)),Ns}var Ss={},Rt;function sa(){if(Rt)return Ss;Rt=1;const s=vr();function t(r,n){const c=r.a/255,i=n+'="'+r.hex+'"';return c<1?i+" "+n+'-opacity="'+c.toFixed(2).slice(1)+'"':i}function o(r,n,c){let i=r+n;return typeof c<"u"&&(i+=" "+c),i}function a(r,n,c){let i="",d=0,u=!1,p=0;for(let f=0;f<r.length;f++){const h=Math.floor(f%n),w=Math.floor(f/n);!h&&!u&&(u=!0),r[f]?(p++,f>0&&h>0&&r[f-1]||(i+=u?o("M",h+c,.5+w+c):o("m",d,0),d=0,u=!1),h+1<n&&r[f+1]||(i+=o("h",p),p=0)):d++}return i}return Ss.render=function(n,c,i){const d=s.getOptions(c),u=n.modules.size,p=n.modules.data,f=u+d.margin*2,h=d.color.light.a?"<path "+t(d.color.light,"fill")+' d="M0 0h'+f+"v"+f+'H0z"/>':"",w="<path "+t(d.color.dark,"stroke")+' d="'+a(p,u,d.margin)+'"/>',g='viewBox="0 0 '+f+" "+f+'"',y='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+g+' shape-rendering="crispEdges">'+h+w+`</svg>
2056
- `;return typeof i=="function"&&i(null,y),y},Ss}var Bt;function ta(){if(Bt)return xe;Bt=1;const s=Dn(),t=Zn(),o=ea(),a=sa();function r(n,c,i,d,u){const p=[].slice.call(arguments,1),f=p.length,h=typeof p[f-1]=="function";if(!h&&!s())throw new Error("Callback required as last argument");if(h){if(f<2)throw new Error("Too few arguments provided");f===2?(u=i,i=c,c=d=void 0):f===3&&(c.getContext&&typeof u>"u"?(u=d,d=void 0):(u=d,d=i,i=c,c=void 0))}else{if(f<1)throw new Error("Too few arguments provided");return f===1?(i=c,c=d=void 0):f===2&&!c.getContext&&(d=i,i=c,c=void 0),new Promise(function(w,g){try{const m=t.create(i,d);w(n(m,c,d))}catch(m){g(m)}})}try{const w=t.create(i,d);u(null,n(w,c,d))}catch(w){u(w)}}return xe.create=t.create,xe.toCanvas=r.bind(null,o.render),xe.toDataURL=r.bind(null,o.renderToDataURL),xe.toString=r.bind(null,function(n,c,i){return a.render(n,i)}),xe}var ra=ta();const oa=ie.getDefaultExportFromCjs(ra);function na({value:s,size:t=200,alt:o="QR code",className:a=""}){const r=l.useRef(null),[n,c]=l.useState(null);return l.useEffect(()=>{!r.current||!s||oa.toCanvas(r.current,s,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{c(null)}).catch(i=>{c(i instanceof Error?i.message:"Failed to generate QR code")})},[s,t]),n?e.jsx("div",{className:`cedros-qr-error ${a}`,style:{width:t,height:t},role:"img","aria-label":o,children:e.jsx("p",{children:"Failed to generate QR code"})}):e.jsx("canvas",{ref:r,className:`cedros-totp-qr-image ${a}`,role:"img","aria-label":o,style:{borderRadius:"0.5rem"}})}function Vs(){const{config:s,_internal:t}=_.useCedrosLogin(),[o,a]=l.useState(null),[r,n]=l.useState("idle"),[c,i]=l.useState(null),[d,u]=l.useState(!1),[p,f]=l.useState(null),h=l.useMemo(()=>new _.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),w=l.useCallback(async()=>{u(!0),f(null);try{const j=await h.get("/mfa/status");return a(j),j}catch(j){const S=_.handleApiError(j,"Failed to get TOTP status");throw f(S),S}finally{u(!1)}},[h]),g=l.useCallback(async()=>{u(!0),f(null),n("loading");try{const j=await h.post("/mfa/setup",{});return i(j),n("setup"),j}catch(j){const S=_.handleApiError(j,"Failed to start TOTP setup");throw f(S),n("error"),S}finally{u(!1)}},[h]),m=l.useCallback(async j=>{if(!/^\d{6}$/.test(j)){const S={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw f(S),S}u(!0),f(null),n("verifying");try{await h.post("/mfa/enable",{code:j}),n("success");try{const S=await h.get("/mfa/status");a(S)}catch{a({enabled:!0,recoveryCodesRemaining:0})}}catch(S){const x=_.handleApiError(S,"Invalid verification code");throw f(x),n("error"),x}finally{u(!1)}},[h]),y=l.useCallback(async j=>{if(!j){const S={code:"VALIDATION_ERROR",message:"Please enter your password"};throw f(S),S}u(!0),f(null);try{await h.post("/mfa/disable",{password:j}),a({enabled:!1,recoveryCodesRemaining:0}),i(null),n("idle")}catch(S){const x=_.handleApiError(S,"Failed to disable TOTP");throw f(x),x}finally{u(!1)}},[h]),A=l.useCallback(async j=>{if(!/^\d{6}$/.test(j)){const S={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw f(S),S}u(!0),f(null);try{return await h.post("/mfa/recovery-codes/regenerate",{code:j})}catch(S){const x=_.handleApiError(S,"Failed to regenerate recovery codes");throw f(x),x}finally{u(!1)}},[h]),b=l.useCallback(()=>f(null),[]),v=l.useCallback(()=>{f(null),i(null),n("idle"),u(!1)},[]);return{status:o,setupState:r,setupData:c,isLoading:d,error:p,getStatus:w,beginSetup:g,enableTotp:m,disableTotp:y,regenerateBackupCodes:A,clearError:b,reset:v}}function jr({onSuccess:s,onCancel:t,className:o=""}){const{setupState:a,setupData:r,isLoading:n,error:c,beginSetup:i,enableTotp:d,clearError:u,reset:p}=Vs(),[f,h]=l.useState("qr"),[w,g]=l.useState(""),[m,y]=l.useState(!1),[A,b]=l.useState(!1),v=l.useRef(null);l.useEffect(()=>{a==="idle"&&i().catch(()=>{})},[a,i]),l.useEffect(()=>{a==="success"&&s?.()},[a,s]);const j=async()=>{r?.secret&&(await navigator.clipboard.writeText(r.secret),y(!0),v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>y(!1),2e3))},S=async()=>{if(r?.recoveryCodes){const C=r.recoveryCodes.join(`
2057
- `);await navigator.clipboard.writeText(C)}},x=async()=>{try{await d(w)}catch{g("")}},k=()=>{p(),t?.()};return l.useEffect(()=>()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]),a==="loading"||a==="idle"&&n?e.jsx("div",{className:`cedros-totp-setup ${o}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(V.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):a==="error"&&!r?e.jsxs("div",{className:`cedros-totp-setup ${o}`,children:[e.jsx(G.ErrorMessage,{error:c,onDismiss:u}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:k,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>i(),children:"Try again"})]})]}):a==="success"?e.jsx("div",{className:`cedros-totp-setup ${o}`,children:e.jsxs("div",{className:"cedros-totp-success",children:[e.jsxs("svg",{className:"cedros-totp-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"var(--cedros-success)",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"var(--cedros-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication enabled"}),e.jsx("p",{className:"cedros-totp-description",children:"Your account is now protected with an additional layer of security."})]})}):r?e.jsxs("div",{className:`cedros-totp-setup ${o}`,children:[f==="qr"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Scan QR code"}),e.jsx("p",{className:"cedros-totp-description",children:"Use your authenticator app to scan this QR code."}),e.jsx("div",{className:"cedros-totp-qr",children:e.jsx(na,{value:r.otpauthUri,size:200,alt:"QR code for authenticator app"})}),e.jsxs("div",{className:"cedros-totp-manual",children:[e.jsx("p",{className:"cedros-totp-manual-label",children:"Or enter this code manually:"}),e.jsxs("div",{className:"cedros-totp-secret",children:[e.jsx("code",{className:"cedros-totp-secret-code",children:r.secret}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:j,"aria-label":"Copy secret",children:m?"Copied!":"Copy"})]})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:k,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>h("backup"),children:"Continue"})]})]}),f==="backup"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Save recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. You can use them to access your account if you lose your authenticator device."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:r.recoveryCodes.map((C,N)=>e.jsx("code",{className:"cedros-totp-backup-code",children:C},N))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:S,children:"Copy all codes"}),e.jsxs("label",{className:"cedros-checkbox-label cedros-totp-confirm",children:[e.jsx("input",{type:"checkbox",className:"cedros-checkbox",checked:A,onChange:C=>b(C.target.checked)}),e.jsx("span",{className:"cedros-checkbox-text",children:"I have saved these recovery codes"})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>h("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>h("verify"),disabled:!A,children:"Continue"})]})]}),f==="verify"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Verify setup"}),e.jsx("p",{className:"cedros-totp-description",children:"Enter the 6-digit code from your authenticator app to complete setup."}),e.jsx(K.OtpInput,{value:w,onChange:g,onComplete:x,disabled:n,error:c?.message,autoFocus:!0}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>h("backup"),disabled:n,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:x,disabled:n||w.length!==6,children:n?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function aa({onStatusChange:s,className:t=""}){const{status:o,isLoading:a,error:r,getStatus:n,disableTotp:c,regenerateBackupCodes:i,clearError:d}=Vs(),[u,p]=l.useState("status"),[f,h]=l.useState(""),[w,g]=l.useState(""),[m,y]=l.useState(null),[A,b]=l.useState(!1),[v,j]=l.useState(null);l.useEffect(()=>{n().catch(()=>{})},[n]);const S=l.useCallback(()=>{p("status"),s?.(!0)},[s]),x=async()=>{b(!0),j(null);try{await c(f),p("status"),h(""),s?.(!1)}catch(N){j(N instanceof Error?N.message:"Failed to disable 2FA"),h("")}finally{b(!1)}},k=async()=>{b(!0),j(null);try{const N=await i(w);y(N.recoveryCodes),g("")}catch(N){j(N instanceof Error?N.message:"Failed to regenerate codes"),g("")}finally{b(!1)}},C=async()=>{m&&await navigator.clipboard.writeText(m.join(`
2058
- `))};return a&&!o?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(V.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):r&&!o?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(G.ErrorMessage,{error:r,onDismiss:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>n(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(jr,{onSuccess:S,onCancel:()=>p("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),v&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(G.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v},onDismiss:()=>j(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(K.PasswordInput,{label:"Password",placeholder:"Enter your password",value:f,onChange:N=>h(N.target.value),disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{p("status"),h(""),j(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:x,disabled:A||f.length===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?m?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:m.map((N,L)=>e.jsx("code",{className:"cedros-totp-backup-code",children:N},L))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:C,children:"Copy all codes"}),e.jsx("div",{className:"cedros-totp-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>{p("status"),y(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),v&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(G.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v},onDismiss:()=>j(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(K.OtpInput,{value:w,onChange:g,onComplete:k,disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{p("status"),g(""),j(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:k,disabled:A||w.length!==6,children:A?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in."})]}),e.jsx("div",{className:`cedros-totp-badge ${o?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:o?.enabled?"Enabled":"Disabled"})]}),o?.enabled?e.jsxs("div",{className:"cedros-totp-enabled-actions",children:[e.jsxs("div",{className:"cedros-totp-description",style:{marginTop:"0.25rem"},children:["Recovery codes remaining: ",e.jsx("strong",{children:o.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>p("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>p("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>p("setup"),children:"Enable two-factor authentication"})]})})}class ia{client;constructor(t,o,a,r){this.client=new _.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(o){throw _.handleApiError(o,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(o){throw _.handleApiError(o,"Failed to update profile")}}}function kr(){const{config:s,authState:t,_internal:o}=_.useCedrosLogin(),[a,r]=l.useState(!1),[n,c]=l.useState(null),i=l.useMemo(()=>new ia(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),d=l.useCallback(()=>{c(null)},[]),u=l.useCallback(async f=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");r(!0),c(null);try{return await i.updateProfile(f)}catch(h){const w=h instanceof Error?h:new Error("Failed to update profile");throw c(w),w}finally{r(!1)}},[t,i]),p=l.useCallback(async f=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");r(!0),c(null);try{await i.changePassword(f)}catch(h){const w=h instanceof Error?h:new Error("Failed to change password");throw c(w),w}finally{r(!1)}},[t,i]);return{isLoading:a,error:n,updateProfile:u,changePassword:p,clearError:d}}function la({onPasswordChange:s,onClose:t,className:o=""}){const{user:a}=D.useAuth(),{isLoading:r,error:n,changePassword:c,clearError:i}=kr(),[d,u]=l.useState("main"),[p,f]=l.useState(""),[h,w]=l.useState(""),[g,m]=l.useState(""),[y,A]=l.useState(null),[b,v]=l.useState(null),j=Pe.validatePassword(h),S=h===g,x=p.length>0&&h.length>0&&g.length>0&&j.isValid&&S,k=l.useCallback(async()=>{if(x){A(null),v(null);try{await c({currentPassword:p,newPassword:h}),f(""),w(""),m(""),v("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{u("main"),v(null)},2e3)}catch(L){A(L instanceof Error?L.message:"Failed to change password")}}},[x,p,h,c,s]),C=l.useCallback(()=>{u("main"),f(""),w(""),m(""),A(null),i()},[i]),N=()=>a?.name?a.name.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2):a?.email?a.email[0].toUpperCase():"?";return d==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(y||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(G.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:y||n?.message||""},onDismiss:()=>{A(null),i()}})}),b&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),b]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:p,onChange:L=>f(L.target.value),disabled:r,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"New password",placeholder:"Enter new password",value:h,onChange:L=>w(L.target.value),disabled:r,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:g,onChange:L=>m(L.target.value),disabled:r,error:g.length>0&&!S?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:C,disabled:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:k,disabled:r||!x,children:r?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:a?.picture?e.jsx("img",{src:a.picture,alt:a.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:N()})}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:a?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:a?.email})]})]}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:a?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:"••••••••"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u("change-password"),children:"Change"})]})]}),t&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})})}function Nr(){const s=_.useCedrosLoginOptional(),[t,o]=l.useState(!1),[a,r]=l.useState(null),n=l.useMemo(()=>s?new _.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=l.useCallback(()=>{r(null)},[]),i=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(g)||g<=0){const m=new Error(`Invalid deposit amount: ${g}. Must be a positive integer (lamports).`);throw r(m.message),m}o(!0),r(null);try{return await n.post("/deposit",{amount_lamports:g})}catch(m){const y=_.handleApiError(m,"Failed to execute deposit");throw r(y.message),y}finally{o(!1)}},[n]),d=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get(`/deposit/status/${encodeURIComponent(g)}`)}catch(m){const y=_.handleApiError(m,"Failed to get deposit status");throw r(y.message),y}finally{o(!1)}},[n]),u=l.useCallback(async()=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get("/deposit/config")}catch(g){const m=_.handleApiError(g,"Failed to get deposit config");throw r(m.message),m}finally{o(!1)}},[n]),p=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{const m=new URLSearchParams;g?.limit!==void 0&&m.set("limit",String(g.limit)),g?.offset!==void 0&&m.set("offset",String(g.offset));const y=m.toString(),A=y?`/deposits?${y}`:"/deposits";return await n.get(A)}catch(m){const y=_.handleApiError(m,"Failed to list deposits");throw r(y.message),y}finally{o(!1)}},[n]),f=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{const m=new URLSearchParams({input_mint:g.inputMint,amount:String(g.amount),taker:g.taker});return await n.get(`/deposit/quote?${m}`)}catch(m){const y=_.handleApiError(m,"Failed to get deposit quote");throw r(y.message),y}finally{o(!1)}},[n]),h=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.post("/deposit/public",g)}catch(m){const y=_.handleApiError(m,"Failed to execute public deposit");throw r(y.message),y}finally{o(!1)}},[n]),w=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.post("/deposit/micro",g)}catch(m){const y=_.handleApiError(m,"Failed to execute micro deposit");throw r(y.message),y}finally{o(!1)}},[n]);return{deposit:i,getQuote:f,publicDeposit:h,microDeposit:w,getStatus:d,getConfig:u,listDeposits:p,isLoading:t,error:a,clearError:c}}function Hs({tokens:s,selectedToken:t,onSelect:o,openSignal:a,placeholder:r="Select token",disabled:n=!1,className:c="",searchable:i=!0}){const[d,u]=l.useState(!1),[p,f]=l.useState(""),h=l.useRef(null),w=l.useRef(null),g=l.useMemo(()=>{if(!p.trim())return s;const b=p.toLowerCase();return s.filter(v=>v.symbol.toLowerCase().includes(b)||v.name.toLowerCase().includes(b)||v.mint.toLowerCase().includes(b))},[s,p]);l.useEffect(()=>{const b=v=>{h.current&&!h.current.contains(v.target)&&(u(!1),f(""))};if(d)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[d]),l.useEffect(()=>{d&&i&&w.current&&w.current.focus()},[d,i]),l.useEffect(()=>{a===void 0||n||(u(!0),f(""))},[a,n]);const m=l.useCallback(()=>{n||(u(b=>!b),d&&f(""))},[n,d]),y=l.useCallback(b=>{o(b),u(!1),f("")},[o]),A=l.useCallback(b=>{b.key==="Escape"?(u(!1),f("")):b.key==="Enter"&&g.length===1&&y(g[0])},[g,y]);return e.jsxs("div",{ref:h,className:`cedros-token-selector ${d?"cedros-token-selector-open":""} ${n?"cedros-token-selector-disabled":""} ${c}`,onKeyDown:A,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:m,disabled:n,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs("span",{className:"cedros-token-selector-selected",children:[t.logoUrl&&e.jsx("img",{src:t.logoUrl,alt:t.symbol,className:"cedros-token-icon",onError:b=>{b.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:r}),e.jsx("span",{className:"cedros-token-selector-arrow",children:d?"▲":"▼"})]}),d&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[i&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:w,type:"text",value:p,onChange:b=>f(b.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:g.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:g.map(b=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===b.mint?"cedros-token-option-selected":""}`,onClick:()=>y(b),role:"option","aria-selected":t?.mint===b.mint,children:[b.logoUrl&&e.jsx("img",{src:b.logoUrl,alt:b.symbol,className:"cedros-token-icon",onError:v=>{v.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:b.symbol}),e.jsx("span",{className:"cedros-token-name",children:b.name})]}),t?.mint===b.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},b.mint))})})]})]})}function Ye(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const Qs="data:image/webp;base64,UklGRkACAABXRUJQVlA4IDQCAACQDQCdASo8ADwAPjEWiUMiISEUBFQgAwSgB4Z/TeLt3XMAoQH23eph0gPMB+sn+M9tvngOsA9ADwgPg3/cH9sfZciikEBuA1AB+nf+84CUkAVvA2x4xvyobR+mBaYhjUv/ewHb4hTqOnP38rzsxZX2inOSciAA/v7uqvqGdpWcjjrfMDFaNHumTog38t3yor0kbjn631VsX61cAC749wWuAX74u/f/hpeDFqS/ci8E1g94wk9UVs7BHqtv7f/M9iT1u5ITJV0Gv6tE/CW5j/nVR6yExJ6JoDRDOWQ8zVpWH92r3Lnbnc4WJpOchbRT3H5rv//6PP+F//4ehLUlR/4tkRUKZu/yOa26+sywmY+Xc1X2lXMcUv7+eQ7+FBE7bhKc7htieBfH4eR134AVaILL7PWA2FjzAjfaP1Lgirqoq/ZooE8jVD/b4g3J3O3/TG/4ajHe6clnAI/4NdwrnHX0P/quBU03HqSsQ0qsEMAuhrH/jn+YtDzmjm8q/cGJ44qvi24Hn+G1kxz2XP2S/Gp7ri5cMlo+muuwBjyNJnnEcTt/5cRdYS2cbEBZtpINWj3PuC1EOsd/8cTepSpxODcJHLzktfC1PHW3Pgoh3J5PHjW3TCQ1Wlu/wP8e8OPfNm48BODGChioj3ezblqrOBV+cI+hLi7ReJdvBF/4jY+/Un0asuWnrA6kRNpgOeO8wyl4Ryhkrff+9R1SpyPYP+5T3EuWWLZaCn0bGzyk97S3VAAAAAA=",ca=1e4,Ke=1e3,Cr=3;function da(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function ua(s,t){switch(s){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${da(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function Ks(s,t,o){return Math.min(Math.max(s,t),o)}function ha(s,t){if(t<=0)return 0;const o=Ks(s/t,0,1);return Math.round(Math.pow(o,1/Cr)*Ke)}function pa(s,t){const o=Ks(s/Ke,0,1);return t*Math.pow(o,Cr)}function Sr(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function ma(s){return s<1?2:0}function Dt(s){const t=Sr(s),o=Math.round(s/t)*t,a=ma(t);return Number(o.toFixed(a))}function $s({config:s,valueUsd:t,onChange:o,maxUsd:a=ca,disabled:r=!1,className:n=""}){const c=Ks(Number.isFinite(t)?t:0,0,a),i=l.useMemo(()=>Ye(c,s),[c,s]),d=ua(i,s),u=ha(c,a),p=u/Ke*100;return e.jsxs("div",{className:`cedros-tiered-slider ${n}`,children:[e.jsxs("div",{className:"cedros-tiered-slider-input-row",children:[e.jsxs("div",{className:"cedros-tiered-slider-input",children:[e.jsx("span",{className:"cedros-tiered-slider-currency",children:"$"}),e.jsx("input",{type:"number",value:c||"",onChange:f=>o(Dt(parseFloat(f.target.value)||0)),placeholder:"Enter amount",disabled:r,min:0,step:Sr(c),className:"cedros-deposit-flow-input cedros-tiered-slider-input-field","aria-label":"Deposit amount"})]}),e.jsxs("div",{className:"cedros-tiered-slider-tier",children:[e.jsxs("span",{className:`cedros-tiered-slider-badge cedros-tiered-slider-badge-${i}`,children:[i==="sol_micro"&&e.jsx("img",{src:Qs,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),d.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:d.detail})]})]}),e.jsx("input",{type:"range",min:0,max:Ke,step:1,value:u,onChange:f=>o(Dt(pa(parseFloat(f.target.value),a))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${p}%, var(--cedros-border) ${p}%, var(--cedros-border) 100%)`},disabled:r,"aria-label":"Deposit amount slider"}),d.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:d.note})]})}function fa(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function ga(s,t,o){const{feePolicy:a,privacyFeePercent:r,swapFeePercent:n,companyFeePercent:c}=s;let i=c;return o||(a==="user_pays_all"?(i+=n,t&&(i+=r)):a==="user_pays_privacy"&&t?i+=r:a==="user_pays_swap"&&(i+=n)),i}const Ue=1e9,Ae={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Qs},ve={mint:"other",symbol:"OTHER",name:"Other",decimals:6},Er=1e4;function wa(s,t){const o=t<s.publicMinUsd,a=t>=s.privateMinUsd,r=[],n=!o&&a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),c=!o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),i=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(n){const d=s.privacyFeeFixedLamports/Ue,u=s.privacyFeePercent,p=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Privacy",solAmount:d,percent:u,usdAmount:p+f})}if(c){const d=s.swapFeeFixedLamports/Ue,u=s.swapFeePercent,p=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Swap",solAmount:d,percent:u,usdAmount:p+f})}if(i){const d=s.companyFeeFixedLamports/Ue,u=s.companyFeePercent,p=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Service",solAmount:d,percent:u,usdAmount:p+f})}return r}function Pr(s,t,o){const a=wa(s,t),r=o<.01?.01:o;if(a.length===0)return`Total: $${r.toFixed(2)}`;const n=a.reduce((g,m)=>g+m.solAmount,0),c=a.reduce((g,m)=>g+m.percent,0),i={fee:7,sol:8,rate:7,usd:8},d=g=>{const m=g.label.padEnd(i.fee),y=g.solAmount.toFixed(4).padStart(6).padEnd(i.sol),A=(g.percent.toFixed(2)+"%").padStart(5).padEnd(i.rate),b=("$"+Math.max(g.usdAmount,.01).toFixed(2)).padEnd(i.usd);return`${m} │ ${y} │ ${A} │ ${b}`},u=`${"Fee".padEnd(i.fee)} │ ${"SOL".padEnd(i.sol)} │ ${"+ Rate".padEnd(i.rate)} │ ${"= Total".padEnd(i.usd)}`,p=`${"─".repeat(i.fee)}─┼─${"─".repeat(i.sol)}─┼─${"─".repeat(i.rate)}─┼─${"─".repeat(i.usd)}`,f=("$"+r.toFixed(2)).padEnd(i.usd),h=`${"TOTAL".padEnd(i.fee)} │ ${n.toFixed(4).padStart(6).padEnd(i.sol)} │ ${(c.toFixed(2)+"%").padStart(5).padEnd(i.rate)} │ ${f}`;return[u,p,...a.map(d),p,h].join(`
2059
- `)}function ba(s){const t=[],o=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,a=s.swapFeeFixedLamports>0||s.swapFeePercent>0,r=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return o&&t.push("Privacy Cash fee"),a&&t.push("swap fee"),r&&t.push("company service fee"),t.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function Je(s,t){if(t<=0)return 0;const o=t<s.publicMinUsd,a=t>=s.privateMinUsd,r=ga(s,a,o);let n=s.companyFeeFixedLamports;o||(a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(n+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(n+=s.swapFeeFixedLamports));const c=n/Ue*s.solPriceUsd,i=t*(r/100);return c+i}function Lr(s,t,o){return s==="sol"?"SOL":s==="single-token"?t.symbol:o.some(r=>r.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function It(s){return s.map(t=>t.trim()).filter(Boolean)}const Tr=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function _r(s,t,o){if(Tr.has(s.symbol))return 1;const a=t.tokenPrices?.[s.symbol];if(a&&a>0)return a;if(s.symbol==="SOL")return t.solPriceUsd||null;const r=o?.[s.symbol];return r&&r>0?r:null}function Mr(s,t){const o=Tr.has(t)?2:4;return s.toFixed(o)}function ya({config:s,currencyMode:t,depositMethod:o,tokens:a=[],defaultToken:r,minAmount:n,maxAmount:c=1e4,onSuccess:i,onError:d,onCancel:u,onUnlockRequired:p,onAuthorize:f,className:h="",showStepIndicator:w=!0,pollInterval:g=5e3,demoMode:m=!1,demoAutoConfirmMs:y,tokenPriceUsd:A,showExplainer:b=!1,siteName:v,explainerConfig:j}){const{deposit:S,getStatus:x,error:k,clearError:C}=Nr(),N=D.useWallet(),L=It(s.quickActionTokens),P=It(s.customTokenSymbols),E=l.useMemo(()=>{const F=s.customTokens??[];if(F.length===0)return a;const O=new Set(a.map($=>$.symbol)),H=[...a];for(const $ of F)O.has($.symbol)||(H.push({mint:$.mint,symbol:$.symbol,name:$.symbol,decimals:$.decimals,logoUrl:$.logoUrl}),O.add($.symbol));return H},[a,s.customTokens]),T=l.useMemo(()=>{if(P.length===0)return E;const F=E.filter(O=>P.includes(O.symbol));return F.length>0?F:E},[E,P]),M=s.privateDepositsEnabled,B=o?o==="sign"&&!M?"receive":o:M&&N.hasExternalWallet?"sign":"receive",Y=L[0]?E.find(F=>F.symbol===L[0]):void 0,le=t==="sol"?Ae:t==="single-token"?Y??E.find(F=>F.symbol==="USDC")??E[0]??Ae:r??Y??E.find(F=>F.symbol==="USDC")??E.find(F=>F.symbol!=="SOL")??E[0]??Ae,J=l.useCallback(()=>b?"explainer":"unlock",[b]),[q,R]=l.useState(J),[I,z]=l.useState(le),[X,ee]=l.useState(""),[ue,ce]=l.useState(null),[W,U]=l.useState(null),[Q,ne]=l.useState(null),[pe,Xs]=l.useState(null),[Xe,ke]=l.useState(!1),[Ir,Ze]=l.useState(!1),[Le,Zs]=l.useState(null);l.useEffect(()=>{R(J()),z(le),ee(""),ce(null),U(null),ne(null),Xs(null),ke(!1),Ze(!1),Zs(null),C()},[t,B,le,C,J]);const Fr=n??s.privateMinSol,Ur=c,Te=parseFloat(X),et=N.status==="enrolled_locked"||N.status==="enrolled_unlocked"||N.status==="unlocked",es=et&&N.isUnlocked,ss=et&&!N.isUnlocked,st=l.useCallback(()=>{let H=B==="sign"?[{key:"unlock",label:"Authorize"},{key:"confirm",label:"Send"},{key:"signing",label:"Signing"},{key:"success",label:"Complete"}]:[{key:"unlock",label:"Authorize"},{key:"show-address",label:"Send"},{key:"waiting",label:"Confirming"},{key:"success",label:"Complete"}];return b&&(H=[{key:"explainer",label:"Info"},...H]),H},[B,b])(),Wr=st.findIndex(F=>F.key===q),tt=l.useCallback(F=>{z(F)},[]),Or=l.useCallback(async F=>{if(!f){R(B==="sign"?"confirm":"show-address");return}Ze(!0),U(null);try{const H=await f(F,B==="sign"?Te:null,I);ne(H.sessionId),Xs(H.depositAddress),R(B==="sign"?"confirm":"show-address")}catch(O){const H=O instanceof Error?O:new Error("Authorization failed");U(H.message)}finally{Ze(!1)}},[f,B,Te,I]),qr=l.useCallback(async(F,O)=>{C(),U(null),R("signing");const H=F??Te,$=O??I;if(!m){if(ss&&p){p(),R("confirm");return}if(!es){U("Wallet not ready"),R("error");return}}try{const re=Math.floor(H*Math.pow(10,$.decimals));if(m){await new Promise(Re=>setTimeout(Re,1500));const Me={token:t==="sol"?null:$,amount:H,amountSmallestUnit:re,txSignature:`demo-tx-${Date.now()}`,sessionId:Q||`demo-session-${Date.now()}`,response:{sessionId:Q||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:re,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};ce(Me),R("success"),i?.(Me);return}const se=await S(re),_e={token:t==="sol"?null:$,amount:H,amountSmallestUnit:re,txSignature:se.txSignature,sessionId:se.sessionId,response:se,method:"sign"};ce(_e),R("success"),i?.(_e)}catch(re){const se=re instanceof Error?re:new Error("Deposit failed");U(se.message),R("error"),d?.(se)}},[S,Te,I,t,m,Q,es,ss,p,i,d,C]),zr=l.useCallback(()=>{R("waiting")},[]),ts=l.useCallback(async()=>{const F=pe||N.solanaPubkey;if(F)try{await navigator.clipboard.writeText(F),ke(!0),setTimeout(()=>ke(!1),2e3)}catch{const O=document.createElement("textarea");O.value=F,document.body.appendChild(O),O.select(),document.execCommand("copy"),document.body.removeChild(O),ke(!0),setTimeout(()=>ke(!1),2e3)}},[pe,N.solanaPubkey]);l.useEffect(()=>{if(!(q==="confirm"||q==="show-address"||q==="waiting")||!Q||m)return;let O=!1,H=0;const $=360,re=async()=>{if(!(O||H>=$)){H++;try{const se=await x(Q);if(se.status==="completed"||se.status==="detected"){const _e=se.amountLamports?se.amountLamports/Math.pow(10,I.decimals):0,Me=se.amountLamports||0,Re={token:t==="sol"?null:I,amount:_e,amountSmallestUnit:Me,txSignature:se.txSignature||"",sessionId:Q,response:se,method:"receive",depositAddress:N.solanaPubkey??void 0};ce(Re),R("success"),i?.(Re);return}}catch{}O||setTimeout(re,g)}};return re(),()=>{O=!0}},[q,Q,m,x,I,t,N.solanaPubkey,i,g]),l.useEffect(()=>{if(!m||!y||q!=="waiting"||B!=="receive"||!pe)return;const F=window.setTimeout(()=>{const O=Le??s.privateMinUsd,H=I.symbol==="SOL"&&s.solPriceUsd>0?O/s.solPriceUsd:O,$=Math.floor(H*Math.pow(10,I.decimals)),re={token:t==="sol"?null:I,amount:H,amountSmallestUnit:$,txSignature:`demo-tx-${Date.now()}`,sessionId:Q||`demo-session-${Date.now()}`,response:{sessionId:Q||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:$,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:pe??void 0};ce(re),R("success"),i?.(re)},y);return()=>window.clearTimeout(F)},[m,y,q,B,pe,Le,s,I,t,Q,i]);const Vr=l.useCallback(()=>{R(J()),ee(""),ce(null),U(null),C()},[J,C]);return s.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${h}`,children:[w&&q!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:st.map((F,O)=>{const H=Wr>=O,$=F.key===q;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${H?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${H?"active":""} ${$?"current":""}`,children:O+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${H?"active":""}`,children:F.label})]},F.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[q==="explainer"&&e.jsx(xa,{siteName:v,config:j,depositConfig:s,currencyMode:t,token:I,tokens:T,onContinue:()=>R("unlock"),onCancel:u}),q==="unlock"&&e.jsx(Aa,{token:I,tokens:T,currencyMode:t,depositMethod:B,isAuthorizing:Ir,error:W,onAuthorize:Or,onBack:b?()=>R("explainer"):void 0,onCancel:u}),q==="confirm"&&B==="sign"&&e.jsx(va,{token:I,tokens:E,quickActionSymbols:L,customTokenSymbols:P,currencyMode:t,minAmount:Fr,maxAmount:Ur,depositAddress:pe||N.solanaPubkey,walletReady:es||m,needsUnlock:ss&&!m,copied:Xe,isListening:!!Q&&!m,config:s,onCopy:ts,onTokenSelect:tt,onUnlockRequired:p,onConfirm:(F,O)=>qr(F,O),onBack:()=>R("unlock"),onCancel:u}),q==="signing"&&e.jsx(ja,{depositAddress:N.solanaPubkey}),q==="show-address"&&e.jsx(ka,{token:I,tokens:E,quickActionSymbols:L,customTokenSymbols:P,tokenPriceUsd:A,currencyMode:t,depositAddress:pe||N.solanaPubkey,copied:Xe,isListening:!!Q&&!m,config:s,onCopy:ts,onTokenSelect:tt,onAmountChange:Zs,onSent:zr,onBack:()=>R("unlock"),onCancel:u}),q==="waiting"&&e.jsx(Na,{token:I,depositAddress:pe||N.solanaPubkey,copied:Xe,feeLine:Le?`Fees: $${Math.max(Je(s,Le),.01).toFixed(2)} total`:"Fees: calculated after deposit",onCopy:ts}),q==="success"&&ue&&e.jsx(Ca,{result:ue,config:s,onNewDeposit:Vr}),q==="error"&&e.jsx(Sa,{error:W||k||"An error occurred",onRetry:()=>R("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${h}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function xa({siteName:s,config:t,depositConfig:o,currencyMode:a,token:r,tokens:n,onContinue:c,onCancel:i}){const d=t?.title??"How Deposits Work",u=t?.exchangeName??"Coinbase",p=Rs.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",f=t?.showExchangeSuggestion!==!1,h=Lr(a,r,n),w=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",g=t?.body??w,m=fa(o),y=ba(o);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:d}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:g}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:m?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:y})]})]})]}),f&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",h," using your credit card at"," ",e.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",children:u}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[i&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:i,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:c,children:"Continue"})]})]})}function Aa({token:s,tokens:t,currencyMode:o,depositMethod:a,isAuthorizing:r,error:n,onAuthorize:c,onBack:i}){const[d,u]=l.useState(""),p=Lr(o,s,t),f=h=>{h.preventDefault(),d.trim()&&c(d)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Authorize Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:a==="sign"?o==="multi-token"?"Enter your password to authorize a deposit. This allows us to process your withdrawal when the privacy period ends.":`Enter your password to authorize a ${p} deposit. This allows us to process your withdrawal when the privacy period ends.`:o==="multi-token"?"Enter your password to get your deposit address. Any supported token sent to this address will be credited to your account.":`Enter your password to get your deposit address. Any ${p} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",htmlFor:"deposit-password",children:"Password"}),e.jsx("input",{id:"deposit-password",type:"password",value:d,onChange:h=>u(h.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:r,autoComplete:"current-password"})]}),n&&e.jsx("p",{className:"cedros-deposit-flow-error",children:n}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:i,disabled:r,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!d.trim()||r,children:r?"Authorizing...":"Continue"})]})]})]})}function va({token:s,tokens:t,quickActionSymbols:o,customTokenSymbols:a,currencyMode:r,minAmount:n,maxAmount:c,depositAddress:i,walletReady:d,needsUnlock:u,copied:p,isListening:f,config:h,onCopy:w,onTokenSelect:g,onUnlockRequired:m,onConfirm:y,onBack:A}){const[b,v]=l.useState(h.privateMinUsd),[j,S]=l.useState(!1),[x,k]=l.useState(!1),[C,N]=l.useState(0),[L,P]=l.useState(null),T=Ye(b,h)==="sol_micro",M=s.symbol===ve.symbol,B=l.useMemo(()=>{const W=a.length===0?t:t.filter(ne=>a.includes(ne.symbol)),U=W.length>0?W:t;return U.some(ne=>ne.symbol===ve.symbol)?U:[...U,ve]},[t,a]),Y=Je(h,b),le=Y<.01?.01:Y,J=M?"Fees: calculated after deposit":`Fees: $${le.toFixed(2)} total`,q=M?"":Pr(h,b,Y),R=_r(T?Ae:s,h),I=R?b/R:s.symbol==="SOL"&&h.solPriceUsd>0?b/h.solPriceUsd:b,z=I?Mr(I,T?"SOL":s.symbol):null,ee=b-Y<=0&&b>0,ue=!M&&b>0&&!ee&&I>=n&&I<=c;l.useEffect(()=>{if(r==="multi-token")if(T&&s.symbol!=="SOL"){P(s);const W=t.find(U=>U.symbol==="SOL");W&&g(W)}else!T&&L&&s.symbol==="SOL"&&(g(L),P(null))},[T,s.symbol,r,t,g,L,s]);const ce=()=>{ue&&y(I,s)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),r==="multi-token"&&!T&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[o.map(W=>{const U=t.find(ne=>ne.symbol===W),Q=s.symbol===W;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${Q?"is-active":""}`,onClick:()=>{U&&(S(!1),g(U))},disabled:!U,children:[U?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:U.logoUrl,alt:`${W} logo`}),W]},W)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${j?"is-active":""}`,onClick:()=>{S(!0),N(W=>W+1)},children:"Custom"})]}),j&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Hs,{tokens:B,selectedToken:s,onSelect:g,openSignal:C})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx($s,{config:h,valueUsd:b,onChange:v,maxUsd:Er})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:M?"Sign to send tokens to this address":`Sign to send ${z??"--"} ${T?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:i||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:w,title:"Copy address",disabled:!i,children:p?"✓":"⧉"}),i&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${i}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),p&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),ee&&e.jsx("div",{className:"cedros-deposit-flow-warning",children:e.jsx("p",{children:"Deposit amount is less than the fees. Increase the amount to proceed."})}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[J,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${x?"is-open":""}`,"data-tooltip":q,"aria-label":`Fee breakdown: ${q.replaceAll(`
2060
- `,", ")}`,"aria-expanded":x,onClick:W=>{W.stopPropagation(),k(U=>!U)},onBlur:()=>k(!1),onKeyDown:W=>{W.key==="Escape"&&k(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after network confirmation."})]})]}),f&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for incoming transfers. We will confirm automatically."}),u&&e.jsxs("div",{className:"cedros-deposit-flow-warning",children:[e.jsx("p",{children:"Your wallet is locked. Unlock it to continue."}),m&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:m,children:"Unlock Wallet"})]}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:A,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:ce,disabled:!ue||!d||!i,children:"Deposit"})]})]})}function ja({depositAddress:s}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Signing Transfer"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Approve the transfer in your wallet extension..."}),s&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[s.slice(0,6),"...",s.slice(-4)]})]})]})}function ka({token:s,tokens:t,quickActionSymbols:o,customTokenSymbols:a,tokenPriceUsd:r,currencyMode:n,depositAddress:c,copied:i,isListening:d,config:u,onCopy:p,onTokenSelect:f,onAmountChange:h,onSent:w,onBack:g}){const[m,y]=l.useState(u.privateMinUsd),[A,b]=l.useState(!1),[v,j]=l.useState(!1),[S,x]=l.useState(0),[k,C]=l.useState(null),L=Ye(m,u)==="sol_micro",P=s.symbol===ve.symbol,E=l.useMemo(()=>{const I=a.length===0?t:t.filter(ee=>a.includes(ee.symbol)),z=I.length>0?I:t;return z.some(ee=>ee.symbol===ve.symbol)?z:[...z,ve]},[t,a]),T=Je(u,m),M=T<.01?.01:T,B=P?"Fees: calculated after deposit":`Fees: $${M.toFixed(2)} total`,Y=P?"":Pr(u,m,T),le=P||m>0,J=_r(L?Ae:s,u,r),q=J?m/J:null,R=q?Mr(q,s.symbol):null;return l.useEffect(()=>{if(n==="multi-token")if(L&&s.symbol!=="SOL"){C(s);const I=t.find(z=>z.symbol==="SOL");I&&f(I)}else!L&&k&&s.symbol==="SOL"&&(f(k),C(null))},[L,s.symbol,n,t,f,k,s]),l.useEffect(()=>{h(m)},[m,h]),c?e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Send Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Send funds to your deposit address. We'll confirm automatically."}),n==="multi-token"&&!L&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[o.map(I=>{const z=t.find(ee=>ee.symbol===I),X=s.symbol===I;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${X?"is-active":""}`,onClick:()=>{z&&(b(!1),f(z))},disabled:!z,children:[z?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:z.logoUrl,alt:`${I} logo`}),I]},I)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${A?"is-active":""}`,onClick:()=>{b(!0),x(I=>I+1)},children:"Custom"})]}),A&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Hs,{tokens:E,selectedToken:s,onSelect:f,openSignal:S})})]}),!P&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx($s,{config:u,valueUsd:m,onChange:y,maxUsd:Er})]}),P&&e.jsx("div",{className:"cedros-deposit-flow-note",children:"Send any token you want. We'll detect the deposit, swap it, and credit your balance automatically."}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:P?"Send any token to this address":`Send ${R??"--"} ${L?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:c}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:p,title:"Copy address",children:i?"✓":"📋"})]}),i&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[B,!P&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${v?"is-open":""}`,"data-tooltip":Y,"aria-label":`Fee breakdown: ${Y.replaceAll(`
2061
- `,", ")}`,"aria-expanded":v,onClick:I=>{I.stopPropagation(),j(z=>!z)},onBlur:()=>j(!1),onKeyDown:I=>{I.key==="Escape"&&j(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after confirmation (typically ~30s)."})]})]}),d&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for your deposit. We'll notify you when it arrives."}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:g,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:w,disabled:!le,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function Na({token:s,depositAddress:t,copied:o,feeLine:a,onCopy:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:s.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),t&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[t.slice(0,6),"...",t.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:r,title:"Copy address",children:o?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${t}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:a})]})]})]})]})}function Ca({result:s,config:t,onNewDeposit:o}){const a=s.token??Ae,r=a.symbol==="SOL"&&t.solPriceUsd>0?s.amount*t.solPriceUsd:s.amount,n=Je(t,r),c=Math.max(r-n,0),i=n<.01?.01:n;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",s.amount.toLocaleString()," ",a.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[s.txSignature.slice(0,8),"...",s.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",r.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",i.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Credits Added"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-credit",children:["+$",c.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:o,children:"Make Another Deposit"})})]})}function Sa({error:s,onRetry:t,onCancel:o}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:s}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[o&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:t,children:"Try Again"})]})]})}const Ea="data:image/webp;base64,UklGRmIEAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IIIDAADwDwCdASo8ADwAPm0qkUWkIqGWDVeYQAbEtgBOmZMBu+H816ov3b8R8R2g2FXtxdyh5s3+A60v0APLi9ktgGB/LZjWNAXqgpE6jfW0NF+P4xEhH2L7M+26iGwrTjjcQegyCZqxs+ifvZANjWd279diqZNKUrgOTVtjJGtW4IVtRhMECd5aWVgAAP7nDv3UY/8f1l//xTP/FM/8NU8c9g//sC3+bX/1HZXsNsM57VKG2LVf1a0KdncWO8uPo/Oh79m9ZqjJZwXfPXuvwkK+WDOl6+N8C2Ux6no/V/zkoucKK/JZek7MR5sS8TknXB+6BuVDXou9Rx4aUea2q2IzvLvFIujjKsVYLMab7j9zo48fhgm9YOtjmWuS0WZ4c+6ta0mr3xF4fcdAIFf6oXRSlqovOX0HUiMV//hXwSX1cfP5cLj8c7OTyT/4ce4olJARV95GoY8oF+2uU0blGul3ItlG7c2Hl2/uC6s2WZc7Zukwojx6ed8t97bZ68N1uzCLzPlG7BuYS17F19e0wXnc6vEl3q7ft0K7OEl7r8mY6Kh+Nt/5V/Lp68mFBjLem1JjvC371+lKwez4KCdXwNo2Z04FqyzGpFutY6YQ/r5Tfu7Oi+oNfN0R/W+D4aj1nqHhlqYJzpx2NK4mj0gJIXmX8EArelSQI8mV4Ux9MRPwC2PuZhLTjQZv+Vl4p0D8bSB+Z0rek3hS6G1r80fW3cn767Pz/bXanjVmm34wt1nQPqdJObrZ7vv2NWcEuQKj9d+V6DzeDrq0CtGNcanEB5MY9agi1E6BprEScTdfPXjBeMnPbpD+QO6P7IW4UZ9etCCHtX++S/fl5Iz5RzUr10ojRMw//35C0yTjSEhbe884dPwor64n//KByjUFEGsCPAAXPJp1+O+SiKfUaODq6ncjKayTHXjoXgM7XP1z4sBhIKJZJRiM7vGC/+v/Sk8/jbgZLZDAVz1vLou93y7Yd8hxcWM/BesxgWgeKvl8fjE/Ud8tQKp4425hWh66lzzwxa4J3ctA4/E50wX/eoBOgq0B7+7S6FK4wvPHSNgfh+vwSWIJsJLt/3yjBeb41RRyMDMZqFQTZPEdFpXp48ExEyDayZ6objbjTHoS5WQDnDQpRyqMNKfvd41nhEPdb/hxpzXeTIjWmfHHCT+CQYWXDqLehCh1cRyeYOBwsSlSw5PiquAbsgAARVhJRroAAABFeGlmAABJSSoACAAAAAYAEgEDAAEAAAABAAAAGgEFAAEAAABWAAAAGwEFAAEAAABeAAAAKAEDAAEAAAACAAAAEwIDAAEAAAABAAAAaYcEAAEAAABmAAAAAAAAAEgAAAABAAAASAAAAAEAAAAGAACQBwAEAAAAMDIxMAGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgAwABAAAA//8AAAKgBAABAAAAPAAAAAOgBAABAAAAPAAAAAAAAAA=",Pa="data:image/webp;base64,UklGRtgCAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IPgBAABQCwCdASo8ADwAPm0wk0ekIqGhKBQMqIANiWkADPF3uV2D8VcQGk1mg+P36i9SLnZvYAQxszEWYzEwX1RVkqG/4BGbJgMSHqhKDFsjWsGfPPrvfef11goNmCDDlBJHVVD+8gAA/vu4q03kl+E7FpjtZ2gc8pQ619Hjv9NywoRZ6az43C1wcrRr/lWzJlJhLWMHN0MkVl1ueAf6Hn8StVzeUfMBXOKkgfe2msx7QWR5PnHW/5c6/35yrtWnrURc2q6UYlGin+v8C2dQqexkW6rX2EEijTI9eEQ46PWH3/59fM2AlMvvR2abaRk5XX7V1triQncRxvMfz5YmYDN+PY/ikcZUNaiFucKoUq5riv0eKCezuFNHecE11ojwJqWRSTWpalkz5autXp6vFS+FT1tWUsB/fs1CCOZxaA1vR1grOEaiuKe1RYm7e05psWtqbXLVmm1bA8Ly9PFkVdCbc6hR3UuBBsFGnVeGOUeMn2onnfvYhBMcM9YPxGdQkwZLXOk1VuQSTk01Shf3fZrFyRlFauftFdPYhKXwqrr+meav1P+KLKBVosqmHnFFfgExsQ/rOf3TSd+mOqQfJA+cF+HojNU7nmM3uDkoCBi+//Gqp+gPNNW8M4LFrol8rxE+7WsjqMgfwv1f+Nr25RtG1Wa/KkniRCAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",La="data:image/webp;base64,UklGRhYJAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSGICAAABkJz9nzon3/nNJGnBXRvBI0sDkR7slpRBaMDl5LByx7cEyBWHtWd+8/uiK/95uEfEBKBnFwRwk6Wjm89PW2Tj9OWNo7VxASQ4DDoIML9fbdLYpbFR21tykDAY8ZCLT9okqZrsD0uqJNl5sj6CIAPwDmdqRlNlz6o0vroE5/vlPObv0kyN/dVE3pmHd31xgt0P1MgBauTHLYjrg2DoClM0DtRi4kmA6ylgrMq2cuDaZm0CoQePyTqVhVTWJ+G7EozXqSyosj4K6cIhVBhZ2MjyMNy/BFcZWeDIE8g/PLaoLLRyF/4vgrlPTMVK/DQH+cPjGpUFV17/i6BEZeGVF+Dh4F/kUYGDR4nKDBPX4AX381Deh2C1Q8vB2F4CDqnMUrkPlPMpY+obLQ/j9+k1GjNNLB0z5hJ5fD0f5Y2XTLkkPn9Hy8X4vsGMW/xvt3JqvKflYnz3nCmXxJc3qLlEXj9mzOe4xJSLcW36Oy0P47cplKl5KMvAfj6HwFKbloOxswrBfWoOyvsQjzWmPErwcKhQi6d84eHgcSGPEgSA4Dq1aMpr8PjL3CemYiV+moP8AY9darGUW/D4u+CEsUiRVyH4p8NwmbE4kZUA9y8IRuvUoijr4xB06zFZpxZDWZ+ER/cBEzW2dXDaZnUMAb06hBOmaIOxmHhlCILenWDrI6MOIio/7kIc+uk85u+SSftkasZ78/AOffYOl17RqNqbqtFqZ+A8+i8BI+tPOiRNNdkfllSNZPvJRYEXDDQI3NJerUFjl8ZmbX8ekIBBuyCAjK8d3Xh52iBbp89vHl2ecIAEh54BVlA4IMwFAADQGwCdASo8ADwAPm0qkkYkIiGhLhtqqIANiWwAqSdaNo+beZFT37f+J9yXOd2J6HfQh5gH6edIDzAfst6vXoO9AD/Lf4DrAP2V9gDzY/+57F39p/3/7k+0RmjvYp/meic9ieyvJnZVfquF/a23ZOCHGT/sfDDjQ89zOL9Gewd+s3Vh/b32Gf28Ejb5ttLg9hoDiFb2tMW81eZU9Z1LHfdRSCsRMzHz0WT4BNgUakGf9oJtrGtVJFxHJfxAatIxnW1qjDi9i3DQtJp9pVNKlMoJEWdPKv3KaaFSlhd/aMGiir9CPcex5QAA+fpjxA6zfUamE3wS2zWwLVrt/fXA5+Wvx9j5SID0zuEHU2LisPUxvtRuIUwNrsUis8zy+IMpzft+ZSg+9gdx9e6+ZvPmtj4OByz5qo26J3rXhPy8LBXSpuPb+f+mP4CoTvYDhzQXh/SIGj8Ez1+W5MJ/Tkdw09wPCs3JuR3yoqO63FH/j81xW5Abr7tCdwfXwv3CXDtOcHwUqPCd1aiU2uT6XwgdnYqYygEXGKFx8nmaUvqSn9p8HmIA9dVTOoEnqYFjrNfWY034N2vjohd16cxnkP4PYvHkIOWa/FEUug7/qbJ/GFLPxNh6y9eQ//MzzXbcPwsT2chWXPBXNVF1S9dxv5NUuEueiw2kdebblQuvUSRLN+zx3VyT2lOzWBUqrzsTmeOlxjVcTA83H99r35O4X7WXNq7HExiWXxrdM/Ih4CvPJaEHPxUE/i6WIz6+VGq4RB3sBKl3P4M7/DLWAwCnwcpX228XezqQ4cS2tttWxLTc9cPd1ofek9qF9lpB8RvakdPnj2PruFA9W3iKbNdmgnb+mIpohHuUR73KdDDOHbyfAiOjPzzqomnIU3jcSt7LKOB/Op97sCk0yd18mVG3prs351B+xmCE2Zd3RFKL+mpMz5qcuAFAfRyodbggdgmFGkEGQ33VryYFl/upr31FGdI52sqzuxd7jZIsqCcznUH/gu+xaBw7wla49EmFNf+Ss+91i9Hsys0FS//Ktru1xWgkeEweX77y6Oot5tHQsDxgy0sAI85V7FmlpiiWXQdM12MGfCBfyRM+N23SjOdReeSILYCgsM3r33/54X+lfDVNj427MvbDFtKccqazlQ+iKqC//MvYwqyiJPL1ZbVoCEP774fKZA3D3qvsVPGlp9LPchpTs4mTJugt8qXl82RwXQCDNZXnbEois53E35hkRr+IJhndoRo1o2sZDoTgykbeOKiynPH03+BcUQ8zmxTmiVlHQym/LL3kRREnUlxs2zPPGb2E+Rpdib+LxOvFSmj9RfTZoYIJnrqNnBIXV2lt7xeZ0srf98JymJxrtr8lx69oSNZIReDddL+3iiUjh6lm7EcYuclqBaKp8q68geo7H1EvKy4nSRx5Q+uz4l/ypo2hVdwi9l+BHjZZmJ7lXkpNTRJ0gZpzquzN2vh/MZQALV6FZ6q4aofA9AJy1DVLdNjV8n6s9eFA5pazxwhLW4tgWMciGf5x6G7HqFPTL1ZL3l447zLGUkqAXjkeVaNmxZ2oNKIuTy6JDc0Z61Z2dgbsg6HwCX1/ux5sk82WsnNIO4CTnWKI1aCtQZaEsBf6hIl9n7VBsgZGIcPpqn7P4mbyf3EbfdfQ32qlawLuAxmDlwRsVsPkw7j4aKbvIBykNcsVXv0/X6UXXaAtw3feJnTwDak2qY6QpMLE9e7PJeuQQ8FXpqI5HoR82kd+DOwGH5F3OpuWsmEt8v7WQG8q1LMkg6vrl3I8047zMl1Yq0VwotbrsKJocsHgsbs/PGOO9v2s8U0Sju/71XRtG5skcy2msae3wixjlGR4i6ZfldMehQD1zf/FbWN9hnHfpq1Fh8+PSA9AzUi33qli8ixISbH+tw7CcumxvegMk88HMNZlVdnIEzIfyHrSdZ2S98yX2OYZw0+JyaBbQxI0fOr6KpuMD6FVGLrdN9dgOTgOPQgAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",Ta="data:image/webp;base64,UklGRo4EAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSA4CAAABkGXb2to2V9/v6D1Jmd5CQ5GXPYXAJMrtPOJMoMzMzDgIPYY5+vVds6T/m0BEOGzAtm1IBlR2d8kXUMyaADjeuHr9V7qj3E5/XrvaOA5AHCqzFgHTFz9tUTmEyq1PF6cBqVWDOLjkwS6VPsu8KqnaewRU7j5KIjipgFiQfCf1IGch8wMlv9QhcWk4nLlL9Z4l6b3y7hmUvGQkmF1nnrMC85zrc5CozDUQtwamisNSDCmxjL5jpqxMzfhutFCCY3+5110CaI9/jhVIcPg/DxiIB/x/eKgijLxkRobTyxFEw7zVm0NqcYg5LNAzKD3n4QbmyRVqWCiXJyD9uN7z0Ha9Dw4N5gzOnHU4IMJ7egt8HuYWasIJnlg46fkYgul9qgWU+9PA2Z7b2FngnR3e49Qm1QbKzVPNnltZ8wozK2S8et0SN34wt0LOnynVCsp02xI7tKSqqXYsV7ZtD/lpeaEfNyw/k9evWuKK7XfQ9ruP9/RW/s74t872N1bw2MY8n0Acmlb/KQ04AJ8t5PkeEbpDnbmR2/5392FiOfRFlCuTkIGsMh/aPBeGZFLBYuiM1IIUZLOD0NnMNBMWZdE/4bLo32MQ0wxcJnsvhcnerRhSLvPPhcj8s5DIsmtU6Tj1L1U6zvcEElfrVlHyqGy3epC4om5Vsg3OlO50UQ2V6Qa65LWf6TZ1J/11faBLlpgAVlA4IJgBAADwCQCdASo8ADwAPm0ylEckIyIhKAoAgA2JaQATzh4OcBkEByVmbl5z9gD9U/+J2APQgLaX4twLu19/UVxAWN1IKXE4cIqJBhoyQ0yDYn61m3zk6T7FMg0AAP78+EMvGgC8jLXmcbbmqvufKjG8Tv1M9Krl47vOW74O/Rapv2DgXbg9iK6PrRQG/9d9+rF/ESxzbszVFn3GThrMBmsklj/LPWDQ0pKzG7EyjQL6p6gfUwMze+wPhzJpn8tMqlUVgq6/QSUVcgG+ztsi73rA3vl3n4baeF1INsbuosTXtnsotVYuTii6rscx9OUTvevYcPNvcL9MPhyWeCQw0qynnGtzCIw+oFRN0+TN1mqXkFyk/rFBcH+FHiI6s9XX5EWCKn5vTRt/0RbS687PiXPFC5Zk/Gk4+538IYi+HZDjvlQQWOH/vddfYTerQ5QqWJt1YuaZNThQ2u+/DtXfZPRy1iWWLR9SKFFtlGrqBKWF5nPRPWWMNA3OssvUtvCNBLBA4cn1whzy+SpbgLvnaepxiykjKsU/MhzgAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",_a="data:image/webp;base64,UklGRqwEAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSL8BAAABkGvbtmlLc5997yvbmW19gBnbDm2kjF5UmW3bthXZVZFdZ+81r+87Z1XlEaHIbSNlMstwos4XUBSTLAFQo/u01Zdf/yLDDze3zB/YwADJEoOoJAKg7oTdH4SF+XxiZlMgSESzwAJdVn2iUJzzOUMiLhQKf+/va2FtBLMBuu1zpHcsincUXhtoTKLsCTVX/KF3wrLhPLm/OWzZtjQWfZ7RhYyAC/lxMowpSzJYJAyFkZDQc21FBMUT7BqGjpHxf3m+XlEPUHE/f3vGgPzmw4awRUaTexkyJhwfNShctVgZXyJDXq4CUyjNy6Y4fVOBIkAPR2GcOE7Jm2NQ/RE9YzXht3a5VYvlOX0xF0fy+tp/ozBuQg6DzZYb6Bi7ed4rB5Mp/1Co4cNhLUo1StLxDIDqrynUoRswiF6nFnIxsDpnZ5WBW0GFZ1qZ8HfLDk5txHHsGDpSa6B0cXZEa+DsTr1M+P4qPdXwjynU4+1/a7oN3Sm6G+meSd27oHsHde++7puj+tYpv7G6b7vun6L7l6n+oZp/t7JmUNUqqhpJV5upakJVLaqqgVW1t6rmV401NGMc1djqH4rpIseSfyPFkgAAVlA4IAQCAABQDACdASo8ADwAPm0yk0akIyGhJgzogA2JaQAThroHvLxu+aPf5G2BYxv+B6XHzx6GPon/o+qz/tOAA/TM82gR0vnExWoiQRM36jlg2UIvwCSqySErzuguz9EP2x/7hsNazr91aIworWI7AAD+/TZ+6Ipl444OdT+2wU0Ov+T8oJuVP/vUbT/w1Jsv6Awnl6rvF/xetfOPt3gTQZZi0Y/AOx563J7CJkqTR/fc/n34zyeKzR80fhfv4ef+Hjhz/CX5aQo+58zg/FdE+7bLoophGfG0szI513EH+q+Gc73H1PFdJYf7CF8v5dhr3tMwEVX5Ji2ZxejK8xrf/E6nVXqlA4DrYNRP09InHc+fEqO/fH8xr+rMf4y1F9TOnwVffZblLoTP6lot0m/sh7sTiDQr0mIA8TiHoOffGDG6KzV+B3239udfhzD740gkRi/m53abX0Ku3vAgadgFFqL0vk8M/4aI+cI+0fbLW17mWGeMu21wSRRQiv5iNgGKR3vEGXAItcLDft1uUzWAfbe1X3zK/ymT7bA/76PB6UUknm+Y5MM4osurUXU/k7P38pN/3slnGfpFzjl4c3USY4mH9ZCJYUuC/kGEnq/yRPalPdODNFvW6s8MiQeQejYNRY0LsJ0WXkK8vXiDmihCivYAOPoSovesL7on+WAArDNM/BcQSQvCYABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Ma="data:image/webp;base64,UklGRnIIAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSK4BAAABkHPbtrE9+z73/RTbqWw7Lf+BbbNKbTudbZe2qy+VbVv3PmeHj05G6ohg4LaRounNMtN1voB42ABA5R7TNlx5+O7du9e3Tiwb0b4EgFyAOCQM1Z16+DWFUZC7m3uVB2zKQGBhe+77RGHonJffCL1zQuHDxQ1hrEmTatDjHIXOC2MgzpNf1tVJkWgsGhyihI7JIE74aUYp2ITFAoz9QO+ZAs7zanvkEilKbIkMJS5ANwoJmrCodYVOmBqh5zIEJjZc9xods4A4rrPGxGitrJSU71yNyH4Myl7JTEl+5zzYSH9nlkrxHBzxWUzLVEnhh+YI/gq3+UphpvA8m/s7/wg9M4bjFNg/0vplrxQ+rQEDg/xihmT23jxYJZ8UPq8OA5z77Wt405FDR4poSMjiAJhPRxUIu8D+UVonOhfNPEVHPM9juFacwo+1V6kJQ3Y9Sa8ljhPuUvRk4UdNWU9ST3b9n0W3iG5DumdS9y7o3kHVu6/75ii/dbpvrO7brvtPUf2X6f5DVf/dmpxBmauociRVbqbKCXW5qCoHVuXempxf1dZQtXFUbat/yKZTtSUBVlA4INwFAABwGgCdASo8ADwAPm0qj0WkIqEZ+zYAQAbEtgBOmZoZF+E8zGoP3X8VbcdLvma8t+jH0E+YB+ofSA8wH7VdQv0AP75/iOsG9ADy3/Y5/b/91fgI/Y7MOesb0e/q+TUR1vt7VO6mwG0imO70GM5/0P7BX6qelv7EP209lz9oDRea09ZR+SjhX7sBu/ZS7tG917rPgI3Q7XsB7luy2hAg/95C2Z1L362OH1oFziDY/K5gWoSytSAtiKvA/jW1MehBzdLzJfszPPBvGa15IYwIVRTjO2Hz5ZS9HjLMehwAAP64SgjD3qeg6NRe/Ok+iFhrG3pgglCfbam3yBaDUH36sUiQx0PB1ZZyOHq0ky+f97h6tJMvo0p9LkfXecWOFJ8J5G7yRPuL4tzGLT09QulTJw42xp2hd+lMgIa51XoHx/iftn8B2D3k92H5jOQr+uIXFHHK5FpcTG+qGEF+np0LiQa+vdW7/+ZzOLVRf7jR5X3ANPt93Ng92DW7NflVr6kMr88O/v2ZNb0vtgao2Am/R3CDKiNq89f86CT6r2L2g1oTui7H3E1yhSPQpEOz01I3fhfiMMv4weqKuoedxn/xLg5uzHa6Gte4C/dQYkG3ZFSy4CXQtRjftBrjX/Oj+HpSUPDsv0wPW+ml5NbBKDCj2f3SD8TVMf2ZfHrOkR602RVk2UmKC+H0Y9iK6k98vsgPINtz0II8X7Mj2nJkTC6IMLuQ8dNTUq9VXOnhXrdhNZoaH94ePo6baBl3hTGFAnD3/b+gR/vtbqV7wktuX6fpnjeTBe/Drp6z3neeANj/aX4CsU9w67nwYOjZhueCjxaDKUnNjLPjI1e0BoTbcOzOQ0wHJHZJ+Pt608StBu4HiJ8NjH46fnvXL3yiMoSvkAuwCE1AakA+eU1u3unyjl1/MnZQmbp8fzfsfrFesehLPcIkYdCiZ+52QbmINNTjEsvjuBuZRubBE+Laihppsxoo4efGIo0xkw0etu1+yzvkqp88w3pBq0mRl13gnnc+2zl6SmhwgmNFbz+F8qAqmdfJL8iaNSGEWlPlpczDDe62GBZMlBhQmq/XCn/1b+VazHvJXkoIFDF+wktMg+rKfLyfTlXdK0cs+Kn8h+rjMakkf3WLo1TftMLn+O+x/Gat+BGstJrM1xvCSSnHQY+NV4B4gRqyZ55gRNnqN/0lWrATOcHUaGXpkTIM/yxFjxcePcSFo+t2aJ5lShtVukETzRxaIXgRkpROeWQHWpTHOaexmXOzF0b833qJSoXMk2zB/uMrgDzKd7d3ohUz8Ra08WYKlAuMQD08bF4+jUepEspqPLoYLQ73TfmL+1LwKxyTV3gEu6WnxBPWPLnYIGYN9U47ZNlB+NgHgYtKTyii6060RAG+wN32WUVFxCZw0HMHnHFgwxD34L/anlpS7mOrjKgyuGYhFC7iHqTQHuoAO1ekBHV+rndnbETKfa1F7LxNLYq+dmJyytmQrJUCGjelorI1m/TMQNiFVrY4FCI1Gl2W1JsZsw9zA+Bh3JmjkC0H5/0JV6JotNMatJIZ4v5PqwJe3r8xd+FNS3ynccdu+xtVdc27qwVdoomciZD5oXYey9KAFSAKO594sBKZNWUJTLXnt0BJbdF8FkQYvg3DQajYY2p+ixd5Ag7o92gw0pVVDDOP+WQxiEmKqgWJyTBsnsBk2Bxi2Unsv8S/4PmE8Hy/vy+Mij+aTAKZvg716IHfHX0/JMeFfmAnsZ39Q0qkfdPtq6+CxbGZ7wKDsK/8l/MVGuyd6faJFt5wyoOXuNrr3JC9EoBmjcOzkVw/6RNP49poZ1xzsX3q7B4HGfI/XSfRQq3HeZ2j12d0E3gCAube4oExaT1sx/v8F+f61QOsGdSaqM2im6qOGkSRkrRQ7L8hvS8vEYJeVkAbFvX5ov7e/egYYNToMHj651c5/rCVYtB9Ned6GvGN8R0x3t7+lsf8+ofhHRzpyvwxd6c5pREZVOKnXzplhJ61mki4JmAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Ra="data:image/svg+xml,%3csvg%20width='88'%20height='88'%20viewBox='0%200%2088%2088'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='88'%20height='88'%20fill='url(%23paint0_linear_170_79)'/%3e%3crect%20x='25.6665'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='51.3335'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='29.3335'%20y='40.3333'%20width='29.3333'%20height='7.33333'%20fill='white'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_170_79'%20x1='-75.3077'%20y1='-55'%20x2='146.302'%20y2='148.167'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF00FF'/%3e%3cstop%20offset='0.531673'%20stop-color='%237A84FF'/%3e%3cstop%20offset='1'%20stop-color='%2305FAFF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",Ba="data:image/webp;base64,UklGRh4HAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSNwBAAABkFxbexpJnyR3z8y+ajXMkAnjnnOgbUUxEAHjkpldWQwzFUn6v3PGVNI/AUQEA7dt49gN3PXavTlfQDeNAeyqg4PL5buRyOhteXlwcJWtHU8qzUIBs+30g7/s4N8Hp7cZFAtpDc7Bbr8xplB8iFJBYvBC4fjGdgvnElqdwc6XFPGRnQxehC93wjgzbxRYf1UYA+dkiJSrG1DMV6zDoW+MkQmMkd8Owdl5AsvOM3gm0geeXwY7R/Tu0EcmM3re6cF2Rr/kTJiBMmPZh+2q/wtm4ozD9qrB0tucMhunvL0Upg1n6JmRnmda4HCckVkZeRyuMWjjF0peCD9vhK3jAgMzM/BCDQ576225m/bCwcA+qzS/PLUwDrsr1ZDdcAa3KtWQWzDYPKZoQDjeDJyoVEdOAPf0cA/Lf1F0IPy1fG8VWmXvgF4LnoOLDFoIvPiaUQuRr99pNr8dUZEj0YToQnfjreaQd7oL6T6Tuu+C7juo++6rfnOUv3W631jNb7v+P8U+1ZDAZxZG9R+q/e+GxcbPuRcRftkIq+pVVD2Srjdr94TDnJ6w7MGqedFhH1bVA6t67zk9/3ctzw+YAhvSc431KExyjjNHQ2zLcTRzq/8op0vKJd+OREbvUnJJAFZQOCBaBAAA8BUAnQEqPAA8AD5tMJRHJCMiISgb+1CADYlsAJ0zIUCfxfmY2f+0b2AbztDnPeKX0qPMp+wHrDehz0AP7J/o+tP9ADy3f23+C79yPYA/aqK9mONrQbuszbsEyALJNTfg+Z6NjG2v+ETCuvlr1q6QUqEiAMUndG/WwfnjJIOTfOBS4W1w0HjOJa1XQ2K33n2b07EOjOBapwKzyoA2erTBTnEKlFjllBy68GBjZ+UKnlzN/f5ibbb4gAD+i9OsnW0xUnmTpyhVasIKzTu0BsXnfBm4rHJqGMFJBUgTESDXEPcNjAeaHP8ck9qdNBH4L/h53tXgHeZttc7c4lwTa6U4Lziz8qUoy8ce0IMc5TFElawGj16tME0GzSSbUqgH7/tYA6huPsWM2z3GjP8b9y7paRbINxwYRtuE90I6QVsNrEkbhL1YfwxRXnuobOfSe3KFVamrvsOqwTCMqlNfjsR3pyoiZ+lYt3+AH6x4ZVNltbYI5KiVhgCu1isooK324ldloH3zhlefYKEwTCYfNjbeH5UiL7JSev+t/C+ftc3TkAHcsvrLCU6n5pYYY2Yr1kRq+r6XVzI6iXuA/TqwMk6xq1PmdzHOwKavncLjWJrk0uU/5E5WKqXM0tgl5s3pduHjb5aiAt0ikEisMyYwnIhDiSemPRdGON4RlwSb3OEpZjhuZqoyen4Sw/fULewt3hAZizeiPZx1o9LS3M/4r3v/M6/o5925VJcmxAf/yjsyjCz0mV+6NuIeWp8shrFaIGgeduVJoZ0Kys1WjSLuFg9QvF5LlkOZ2k7WrzSu4ucsUOS/X4wnQvB0RCnR1PCsU4NDdLfxvQITUgGIuVTJ7LR73PHzZam/Z21oy3euiU55ffITekwjR4SgVoPvhxbdBSyVePf/twm62pSK9IfgPGN+ttubhQub1ooVZymdQCrS3goEs6dlnl/6TVfkgxFyBfAORkZafeu/Va2vIgUBNUQd48W8oPiMFjx+SAKx1qm2IwCLnuhJGf9M4nCzu7oo43f+nBeT07IjB+FpFKRGFNvlpLEXhPclSgFkqeU1W2eNqW2zShCWkQkgfE1HAoNX3z+CQcRQJq+HkC2nSjFdFYT8UNYNS6lYcyVWzEnOos1qpsNRxnLqY2Dl5CCT3Yeg/qT8chfF9ZadFvzNTEIDlARoN//7IU23MtuLdpsAjsiGfBHuR7y4lemYPdD/9Cuff9Qn/r/xlhmB5x2Y9Z1yME3aANAb5+u3lYz01zUlWwakKVmv9fhaeu/YzQ7BXLlcb+cbaIF5t/COmObnt20zaTfjad542f7p7f2Xea134nvyPYS+EAgjM+GufHvl9tXCrrRbH0pn7kH2XEGx9VbO4mY54+QZa5kPr0j3AOEtKd7SJWjlg5TQfgIuB6KoLGainSwF+pPdiCmzEzAOa1eFwn//2VdDMeq42/bKH8U4orewhLh60ci/S0BRBuItNMc+v1+vxl0YyS5it4AAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",Da="data:image/svg+xml,%3csvg%20width='868'%20height='868'%20viewBox='0%200%20868%20868'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='434'%20cy='434'%20r='434'%20fill='%231B262D'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M234.563%20184H640.697C650.387%20184%20659.339%20189.164%20664.172%20197.542L782.495%20402.657C788.631%20413.294%20786.808%20426.72%20778.056%20435.346L452.368%20756.327C441.818%20766.724%20424.846%20766.724%20414.296%20756.327L89.0484%20435.78C80.0927%20426.954%2078.4157%20413.136%2085.0013%20402.433L211.48%20196.884C216.405%20188.879%20225.146%20184%20234.563%20184ZM588.257%20275.577V333.129H472.567V373.032C553.82%20377.296%20614.782%20394.81%20615.234%20415.802L615.231%20459.563C614.779%20480.556%20553.82%20498.069%20472.567%20502.333V600.259H395.746V502.333C314.492%20498.069%20253.531%20480.555%20253.078%20459.563L253.081%20415.802C253.533%20394.81%20314.492%20377.296%20395.746%20373.032V333.129H280.055V275.577H588.257ZM434.156%20472.268C520.868%20472.268%20593.345%20457.459%20611.082%20437.683C596.041%20420.912%20541.636%20407.713%20472.567%20404.089V445.867C460.187%20446.516%20447.336%20446.858%20434.156%20446.858C420.976%20446.858%20408.125%20446.516%20395.746%20445.867V404.089C326.676%20407.713%20272.271%20420.912%20257.23%20437.683C274.968%20457.459%20347.444%20472.268%20434.156%20472.268Z'%20fill='%23009393'/%3e%3c/svg%3e",Rr=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Qs},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Ma},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Da},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:La},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:Ba},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:_a},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Ra},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Pa},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Ea},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Ta}];function Gs(){const s=_.useCedrosLoginOptional(),[t,o]=l.useState(!1),[a,r]=l.useState(null),n=l.useMemo(()=>s?new _.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=l.useCallback(()=>{r(null)},[]),i=l.useCallback(async()=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get("/credits/balance/sol")}catch(p){const f=_.handleApiError(p,"Failed to fetch credit balance");throw r(f.message),f}finally{o(!1)}},[n]),d=l.useCallback(async()=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{return(await n.get("/credits/balance")).balances}catch(p){const f=_.handleApiError(p,"Failed to fetch credit balances");throw r(f.message),f}finally{o(!1)}},[n]),u=l.useCallback(async p=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{const f=new URLSearchParams;p?.currency&&f.set("currency",p.currency),p?.limit&&f.set("limit",p.limit.toString()),p?.offset&&f.set("offset",p.offset.toString());const h=f.toString(),w=h?`/credits/history?${h}`:"/credits/history";return await n.get(w)}catch(f){const h=_.handleApiError(f,"Failed to fetch transaction history");throw r(h.message),h}finally{o(!1)}},[n]);return{getBalance:i,getAllBalances:d,getHistory:u,isLoading:t,error:a,clearError:c}}function Ia({showAllCurrencies:s=!1,refreshInterval:t=0,compact:o=!1,className:a="",onLoad:r}){const{getBalance:n,getAllBalances:c,isLoading:i,error:d,clearError:u}=Gs(),[p,f]=l.useState([]),[h,w]=l.useState(null),g=l.useCallback(async()=>{try{if(s){const m=await c();f(m),r?.(m)}else{const m=await n();f([m]),r?.([m])}w(null)}catch(m){w(m instanceof Error?m.message:"Failed to load balance")}},[s,n,c,r]);if(l.useEffect(()=>{g()},[g]),l.useEffect(()=>{if(t<=0)return;const m=setInterval(g,t);return()=>clearInterval(m)},[t,g]),h||d)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${a}`,children:[e.jsx("p",{className:"cedros-credit-error",children:h||d}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),w(null),g()},children:"Retry"})]});if(i&&p.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${a}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(o){const m=p[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${a}`,children:[m?e.jsx("span",{className:"cedros-credit-value",title:`${m.balanceLamports} lamports`,children:m.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),i&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${a}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:g,disabled:i,title:"Refresh balance",children:i?"...":"↻"})]}),p.length===0?e.jsxs("div",{className:"cedros-credit-empty",children:[e.jsx("p",{className:"cedros-credit-empty-message",children:"No credit balance yet."}),e.jsx("p",{className:"cedros-credit-empty-hint",children:"Make a deposit to get started."})]}):e.jsx("div",{className:"cedros-credit-list",children:p.map(m=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:m.currency}),e.jsx("span",{className:"cedros-credit-amount",children:m.display})]},m.currency))})]})}const Es=[{key:"all",label:"All",txTypes:null},{key:"deposits",label:"Deposits",txTypes:["deposit"]},{key:"usage",label:"Usage",txTypes:["spend","usage","charge"]},{key:"adjustments",label:"Adjustments",txTypes:["refund","adjustment","bonus","credit"]}];function Fa(s,t){const o=s<0,a=Math.abs(s),r=t.toUpperCase()==="SOL",c=a/Math.pow(10,r?9:6),i=o?"-":"+";return r?`${i}${c.toFixed(4)} SOL`:`${i}$${c.toFixed(2)}`}function Ua(s){const t=new Date(s),o=new Date,a=o.getTime()-t.getTime(),r=Math.floor(a/(1e3*60*60*24));if(r===0){const n=Math.floor(a/36e5);if(n===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${n}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==o.getFullYear()?"numeric":void 0})}function Wa(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function Oa(s,t){const o=(s||"").toLowerCase();return o==="deposit"?"↓":o==="spend"||o==="usage"||o==="charge"?"↑":o==="refund"?"←":o==="bonus"||o==="credit"?"★":t?"+":"−"}function qa({defaultTab:s="all",pageSize:t=10,refreshInterval:o=0,className:a="",onLoad:r,onTransactionClick:n}){const{getHistory:c,isLoading:i,error:d,clearError:u}=Gs(),[p,f]=l.useState(s),[h,w]=l.useState([]),[g,m]=l.useState(0),[y,A]=l.useState(0),[b,v]=l.useState(null),j=Es.find(E=>E.key===p)||Es[0],S=l.useMemo(()=>j.txTypes===null?h:h.filter(E=>{const T=E.txType||"";return j.txTypes.some(M=>T.toLowerCase().includes(M.toLowerCase()))}),[h,j.txTypes]),x=l.useCallback(async()=>{try{const E=await c({limit:t*3,offset:y});w(E.transactions),m(E.total),r?.(E),v(null)}catch(E){v(E instanceof Error?E.message:"Failed to load history")}},[t,y,c,r]);l.useEffect(()=>{A(0)},[p]),l.useEffect(()=>{x()},[x]),l.useEffect(()=>{if(o<=0)return;const E=setInterval(x,o);return()=>clearInterval(E)},[o,x]);const k=Math.ceil(g/t),C=Math.floor(y/t)+1,N=E=>{const T=(E-1)*t;A(Math.max(0,Math.min(T,Math.max(0,g-1))))},L=E=>{f(E)};if(b||d)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${a}`,children:[e.jsx("p",{className:"cedros-tx-error",children:b||d}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),v(null),x()},children:"Retry"})]});if(i&&h.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${a}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=E=>E.txTypes===null?h.length:h.filter(T=>{const M=T.txType||"";return E.txTypes.some(B=>M.toLowerCase().includes(B.toLowerCase()))}).length;return e.jsxs("div",{className:`cedros-tx-history ${a}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Transaction History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:x,disabled:i,title:"Refresh",children:i?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:Es.map(E=>{const T=P(E),M=p===E.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${M?"cedros-tx-tab-active":""}`,onClick:()=>L(E.key),children:[E.label,T>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:T})]},E.key)})}),S.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:p==="all"?"No transactions yet.":`No ${j.label.toLowerCase()} found.`}),p==="all"&&e.jsx("p",{className:"cedros-tx-empty-hint",children:"Make a deposit to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:S.slice(0,t).map(E=>{const T=E.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${T?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>n?.(E),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),n?.(E))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${T?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:Oa(E.txType,T)}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsx("span",{className:"cedros-tx-type",children:Wa(E.txType)}),e.jsx("span",{className:`cedros-tx-amount ${T?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:Fa(E.amountLamports,E.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:E.description}),e.jsx("span",{className:"cedros-tx-date",children:Ua(E.createdAt)})]})]})]},E.id)})}),k>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>N(C-1),disabled:C<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",C," of ",k]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>N(C+1),disabled:C>=k,children:"Next"})]})]})]})}function Ys(){const s=_.useCedrosLoginOptional(),[t,o]=l.useState(!1),[a,r]=l.useState(null),[n,c]=l.useState(null),i=l.useMemo(()=>s?new _.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=l.useCallback(()=>{r(null)},[]),u=l.useCallback(async()=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await i.get("/wallet/withdraw/balances")}catch(w){const g=_.handleApiError(w,"Failed to fetch wallet balances");throw r(g.message),g}},[i]),p=l.useCallback(async(w,g)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");o(!0),r(null);try{const m=await i.post("/wallet/withdraw/sol",{destination:w,amount_lamports:g});return c(m),m}catch(m){const y=_.handleApiError(m,"Failed to withdraw SOL");throw r(y.message),y}finally{o(!1)}},[i]),f=l.useCallback(async(w,g,m)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");o(!0),r(null);try{const y=await i.post("/wallet/withdraw/spl",{destination:w,token_mint:g,amount:m});return c(y),y}catch(y){const A=_.handleApiError(y,"Failed to withdraw token");throw r(A.message),A}finally{o(!1)}},[i]),h=l.useCallback(async(w=10,g=0)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const m=Math.max(1,Math.min(100,Math.trunc(w))),y=Math.max(0,Math.trunc(g)),A=new URLSearchParams({limit:String(m),offset:String(y)});return await i.get(`/wallet/withdraw/history?${A}`)}catch(m){const y=_.handleApiError(m,"Failed to fetch withdrawal history");throw r(y.message),y}},[i]);return{withdrawSol:p,withdrawSpl:f,getBalances:u,getHistory:h,isSubmitting:t,error:a,clearError:d,lastResult:n}}const Ps="So11111111111111111111111111111111111111112",za={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Va(s){return s.length<32||s.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(s)}function Ls(s){return s.length<=16?s:`${s.slice(0,6)}...${s.slice(-6)}`}function Fe(s,t){return(Number(s)/Math.pow(10,t)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(t,6)})}function Ha({onSuccess:s,onError:t,onCancel:o,className:a=""}){const r=_.useCedrosLoginOptional(),{withdrawSol:n,withdrawSpl:c,getBalances:i,isSubmitting:d,error:u,clearError:p}=Ys(),[f,h]=l.useState("loading"),[w,g]=l.useState([]),[m,y]=l.useState(null),[A,b]=l.useState(""),[v,j]=l.useState(""),[S,x]=l.useState(null),[k,C]=l.useState(null),[N,L]=l.useState(null),P=r?.config.solana?.network??"mainnet-beta",E=l.useMemo(()=>{if(!S?.txSignature)return"";const R=`https://explorer.solana.com/tx/${S.txSignature}`;return P==="mainnet-beta"?R:`${R}?cluster=${encodeURIComponent(P)}`},[S,P]),T=l.useMemo(()=>{if(!m||!v)return"0";const R=parseFloat(v);return isNaN(R)||R<=0?"0":Math.floor(R*Math.pow(10,m.decimals)).toString()},[v,m]);l.useEffect(()=>{if(!r)return;let R=!1;return(async()=>{try{const I=await i();if(R)return;const z=[];I.solLamports>0&&z.push({symbol:"SOL",mint:Ps,decimals:9,rawBalance:String(I.solLamports),displayBalance:Fe(String(I.solLamports),9)});for(const X of I.tokens){const ee=za[X.mint]??Ls(X.mint);z.push({symbol:ee,mint:X.mint,decimals:X.decimals,rawBalance:X.amount,displayBalance:Fe(X.amount,X.decimals)})}g(z),h((z.length>0,"select"))}catch{R||(L("Failed to load wallet balances"),h("select"))}})(),()=>{R=!0}},[r,i]);const M=l.useCallback(R=>{y(R),h("form"),p(),C(null),j("")},[p]),B=l.useCallback(()=>{if(!m)return;const R=Number(m.rawBalance)/Math.pow(10,m.decimals);m.mint===Ps?j(String(Math.max(0,R-.01))):j(String(R))},[m]),Y=l.useCallback(()=>{if(C(null),!A.trim()){C("Destination address is required");return}if(!Va(A.trim())){C("Invalid Solana address");return}if(!v||parseFloat(v)<=0||isNaN(parseFloat(v))){C("Please enter a valid amount");return}if(T==="0"){C("Amount is too small");return}h("confirm")},[A,v,T]),le=l.useCallback(async()=>{if(m){h("processing"),p();try{let R;m.mint===Ps?R=await n(A.trim(),Number(T)):R=await c(A.trim(),m.mint,T),x(R),h("success"),s?.(R)}catch(R){h("confirm"),t?.(R instanceof Error?R:new Error(String(R)))}}},[m,A,T,n,c,p,s,t]),J=l.useCallback(()=>{p(),C(null),f==="form"?(h("select"),y(null),j(""),b("")):f==="confirm"&&h("form")},[f,p]),q=l.useCallback(()=>{h("select"),y(null),b(""),j(""),x(null),p(),C(null)},[p]);return r?e.jsxs("div",{className:`cedros-withdrawal ${a}`,children:[f==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),f==="select"&&e.jsxs("div",{className:"cedros-withdrawal-select",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdraw"}),e.jsx("p",{className:"cedros-withdrawal-subtitle",children:"Select a token to withdraw"})]}),N&&e.jsx(G.ErrorMessage,{error:N}),w.length===0&&!N&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:w.map(R=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>M(R),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:R.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:R.displayBalance})]},R.mint))}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:o,children:"Cancel"})]}),f==="form"&&m&&e.jsxs("div",{className:"cedros-withdrawal-form",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:J,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",m.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",m.displayBalance," ",m.symbol]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsx("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-destination",children:"Destination Address"}),e.jsx("input",{id:"cedros-withdrawal-destination",type:"text",className:"cedros-input",placeholder:"Solana address (base58)",value:A,onChange:R=>b(R.target.value),autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsxs("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-amount",children:["Amount (",m.symbol,")"]}),e.jsxs("div",{className:"cedros-withdrawal-amount-row",children:[e.jsx("input",{id:"cedros-withdrawal-amount",type:"number",className:"cedros-input",placeholder:"0.00",value:v,onChange:R=>j(R.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:B,children:"Max"})]})]}),(k||u)&&e.jsx(G.ErrorMessage,{error:k||u||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:Y,children:"Review Withdrawal"})]}),f==="confirm"&&m&&e.jsxs("div",{className:"cedros-withdrawal-confirm",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:J,disabled:d,children:"Back"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Confirm Withdrawal"})]}),e.jsxs("div",{className:"cedros-withdrawal-summary",children:[e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Token"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:m.symbol})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Amount"}),e.jsxs("span",{className:"cedros-withdrawal-summary-value",children:[Fe(T,m.decimals)," ",m.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Destination"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",title:A,children:Ls(A)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),u&&e.jsx(G.ErrorMessage,{error:u}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:J,disabled:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:le,disabled:d,children:d?"Sending...":"Confirm & Send"})]})]}),f==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(V.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",m?.symbol,"..."]})]}),f==="success"&&S&&e.jsxs("div",{className:"cedros-withdrawal-success",children:[e.jsx("div",{className:"cedros-withdrawal-success-icon",children:"✓"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdrawal Complete"}),e.jsxs("p",{className:"cedros-withdrawal-subtitle",children:[Fe(T,m?.decimals??9)," ",m?.symbol," ","sent"]}),e.jsxs("div",{className:"cedros-withdrawal-tx",children:[e.jsx("span",{className:"cedros-withdrawal-tx-label",children:"Transaction"}),e.jsx("a",{className:"cedros-withdrawal-tx-link",href:E,target:"_blank",rel:"noreferrer",children:Ls(S.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:q,children:"Done"})]})]}):null}function Qa(s,t){if(s==="sol")return"SOL";if(!t)return"SPL";const o=Rr.find(a=>a.mint===t);return o?o.symbol:`${t.slice(0,4)}...${t.slice(-4)}`}function Ka(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function $a(s){const t=new Date(s),o=new Date,a=o.getTime()-t.getTime(),r=Math.floor(a/(1e3*60*60*24));if(r===0){const n=Math.floor(a/36e5);if(n===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${n}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==o.getFullYear()?"numeric":void 0})}function Ga({pageSize:s=10,className:t="",onTransactionClick:o,explorerUrl:a="https://solscan.io"}){const{getHistory:r,error:n,clearError:c}=Ys(),[i,d]=l.useState([]),[u,p]=l.useState(0),[f,h]=l.useState(0),[w,g]=l.useState(!1),[m,y]=l.useState(null),A=l.useCallback(async()=>{g(!0);try{const S=await r(s,f);d(S.items),p(S.total),y(null)}catch(S){y(S instanceof Error?S.message:"Failed to load withdrawal history")}finally{g(!1)}},[s,f,r]);l.useEffect(()=>{A()},[A]);const b=Math.ceil(u/s),v=Math.floor(f/s)+1,j=S=>{const x=(S-1)*s;h(Math.max(0,Math.min(x,Math.max(0,u-1))))};return m||n?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${t}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:m||n}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{c(),y(null),A()},children:"Retry"})]}):w&&i.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${t}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${t}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:A,disabled:w,title:"Refresh",children:w?"...":"↻"})]}),i.length===0?e.jsx("div",{className:"cedros-tx-empty",children:e.jsx("p",{className:"cedros-tx-empty-message",children:"No withdrawal history yet."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:i.map(S=>{const x=Qa(S.tokenType,S.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>o?.(S),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(S))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsx("div",{className:"cedros-tx-icon cedros-tx-icon-negative",children:"↑"}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsxs("span",{className:"cedros-tx-type",children:[x," Withdrawal"]}),e.jsxs("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:[S.amount," ",x==="SOL"?"lamports":""]})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${a}/account/${S.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:k=>k.stopPropagation(),children:Ka(S.destination)})," · ",e.jsx("a",{href:`${a}/tx/${S.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:k=>k.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:$a(S.createdAt)})]})]})]},S.id)})}),b>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>j(v-1),disabled:v<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",v," of ",b]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>j(v+1),disabled:v>=b,children:"Next"})]})]})]})}function Ya({brandLogo:s,brandName:t,title:o="Welcome back",subtitle:a="Login with your Apple or Google account",termsText:r,onSuccess:n,defaultTab:c="login",children:i,className:d=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${d}`,children:[(s||t)&&e.jsxs("div",{className:"cedros-brand-header",children:[s,t&&e.jsx("span",{className:"cedros-brand-name",children:t})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:o}),a&&e.jsx("p",{className:"cedros-full-page-subtitle",children:a})]}),i??e.jsx(Ge,{defaultTab:c,onSuccess:n})]}),r&&e.jsx("p",{className:"cedros-terms-footer",children:r})]})}function Ja({brandName:s="Your Brand",brandLogo:t,tagline:o="Your tagline goes here. Make it compelling.",title:a="Sign in",subtitle:r="Enter your credentials to access your account",onSuccess:n,defaultTab:c="login",children:i,className:d=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${d}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[t??e.jsx("div",{className:"cedros-split-page-logo",children:s.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:s}),o&&e.jsx("p",{className:"cedros-split-page-tagline",children:o})]})}),e.jsx("div",{className:"cedros-split-page-form",children:e.jsxs("div",{className:"cedros-split-page-form-content",children:[e.jsx("h2",{className:"cedros-split-page-title",children:a}),r&&e.jsx("p",{className:"cedros-split-page-subtitle",children:r}),i??e.jsx(Ge,{defaultTab:c,onSuccess:n})]})})]})}class Xa{client;constructor(t,o,a,r){this.client=new _.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(t){throw _.handleApiError(t,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(t){throw _.handleApiError(t,"Failed to revoke sessions")}}}function Za(){const{config:s,authState:t,_internal:o}=_.useCedrosLogin(),[a,r]=l.useState([]),[n,c]=l.useState(!1),[i,d]=l.useState(null),u=l.useMemo(()=>new Xa(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),p=l.useCallback(async()=>{if(t!=="authenticated"){r([]);return}c(!0),d(null);try{const w=await u.listSessions();r(w)}catch(w){d(w)}finally{c(!1)}},[t,u]);l.useEffect(()=>{t==="authenticated"?p():r([])},[t,p]);const f=l.useCallback(async()=>{c(!0),d(null);try{const w=await u.revokeAllSessions();return await p(),w}catch(w){throw d(w),w}finally{c(!1)}},[u,p]),h=l.useMemo(()=>a.filter(w=>!w.isCurrent).length,[a]);return{sessions:a,isLoading:n,error:i,fetchSessions:p,revokeAllSessions:f,otherSessionCount:h}}function ei(){const{config:s,_internal:t}=_.useCedrosLogin(),[o,a]=l.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),r=l.useMemo(()=>new Is.OrgApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),n=l.useCallback(async d=>{a(u=>({...u,isLoading:!0,error:null}));try{const u=await r.authorize(d),p={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return a(p),p}catch(u){const p={allowed:!1,reason:void 0,isLoading:!1,error:u};return a(p),p}},[r]),c=l.useCallback(async d=>(await n(d)).allowed,[n]),i=l.useCallback(()=>{a({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:c,lastCheck:o,clearCheck:i,checkAuthorization:n}}function si(){const s=_.useCedrosLoginOptional(),[t,o]=l.useState(!1),[a,r]=l.useState(null),[n,c]=l.useState(null),i=l.useMemo(()=>s?new _.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=l.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");o(!0),r(null);try{const f=await i.get("/wallet/pending-recovery");c(f)}catch(f){const h=_.handleApiError(f,"Failed to fetch pending recovery");throw r(h.message),h}finally{o(!1)}},[i]),u=l.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");o(!0),r(null);try{const f={confirmed:!0};await i.post("/wallet/acknowledge-recovery",f),c(null)}catch(f){const h=_.handleApiError(f,"Failed to acknowledge recovery");throw r(h.message),h}finally{o(!1)}},[i]),p=l.useCallback(()=>r(null),[]);return l.useEffect(()=>{i&&s?.authState==="authenticated"&&d().catch(()=>{})},[i,s?.authState,d]),{hasPendingRecovery:n?.hasPendingRecovery??!1,recoveryType:n?.recoveryType??null,recoveryPhrase:n?.recoveryPhrase??null,expiresAt:n?.expiresAt?new Date(n.expiresAt):null,fetchPendingRecovery:d,acknowledgeRecovery:u,isLoading:t,error:a,clearError:p}}function ti(s={}){const{onExternalSign:t}=s,{solanaPubkey:o,hasExternalWallet:a,status:r,isUnlocked:n}=D.useWallet(),{signTransaction:c,isSigning:i,error:d,clearError:u}=cr(),p=l.useMemo(()=>a&&t?"external":r==="enrolled_locked"||r==="enrolled_unlocked"?"sss":"none",[a,t,r]),f=p!=="none",h=r==="enrolled_locked"||r==="enrolled_unlocked";return{signTransaction:l.useCallback(async(g,m)=>{if(p==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(g)}if(p==="sss"){if(!m&&!n)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return m?c(g,m):c(g)}throw new Error("No signing method available. Enroll a wallet first.")},[p,t,n,c]),signingMethod:p,canSign:f,isSigning:i,publicKey:o,hasExternalWallet:a,hasSssWallet:h,isSssUnlocked:n,error:d,clearError:u}}const Js=l.createContext(null),$e={auth:{email:"Email",password:"Password",confirmPassword:"Confirm Password",name:"Name",optional:"(optional)",createPassword:"Create a password",confirmYourPassword:"Confirm your password",emailPlaceholder:"you@example.com",namePlaceholder:"Your name"},buttons:{signIn:"Sign in",signUp:"Sign up",signOut:"Sign out",createAccount:"Create account",continueWithGoogle:"Continue with Google",continueWithSolana:"Connect Wallet",forgotPassword:"Forgot password?",resetPassword:"Reset password",sendVerification:"Send verification email"},messages:{signingIn:"Signing in...",signingUp:"Signing up...",creatingAccount:"Creating account...",connectingWallet:"Connecting wallet...",verifyingSignature:"Verifying signature...",passwordsDoNotMatch:"Passwords do not match",alreadyHaveAccount:"Already have an account?",dontHaveAccount:"Don't have an account?",orContinueWith:"Or continue with"},errors:{invalidCredentials:"Invalid email or password",emailExists:"An account with this email already exists",invalidEmail:"Please enter a valid email address",weakPassword:"Password does not meet requirements",networkError:"Network error. Please try again.",unknownError:"An error occurred. Please try again.",walletNotFound:"No wallet found. Please install a Solana wallet.",signatureRejected:"Signature request was rejected",challengeExpired:"Challenge expired. Please try again."},passwordValidation:{minLength:"At least 10 characters",uppercase:"At least 1 uppercase letter",lowercase:"At least 1 lowercase letter",number:"At least 1 number",special:"At least 1 special character",weak:"Weak",fair:"Fair",good:"Good",strong:"Strong"}};function Br(s,t){return Dr(s,t)}function Dr(s,t){const o={...s};for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const r=s[a],n=t[a];typeof r=="object"&&r!==null&&typeof n=="object"&&n!==null?o[a]=Dr(r,n):n!==void 0&&(o[a]=n)}return o}function ri({children:s,locale:t="en",translations:o}){const a=l.useMemo(()=>({t:o?Br($e,o):$e,locale:t}),[o,t]);return e.jsx(Js.Provider,{value:a,children:s})}function oi(){return l.useContext(Js)?.t??$e}function ni(){return l.useContext(Js)?.locale??"en"}exports.CedrosLoginProvider=D.CedrosLoginProvider;exports.getEmbeddedWalletInfo=D.getEmbeddedWalletInfo;exports.isEmbeddedWalletAvailable=D.isEmbeddedWalletAvailable;exports.useAuth=D.useAuth;exports.useWallet=D.useWallet;exports.useWalletMaterial=D.useWalletMaterial;exports.useAuthState=_.useAuthState;exports.useAuthUI=_.useAuthUI;exports.useCedrosLogin=_.useCedrosLogin;exports.LoadingSpinner=V.LoadingSpinner;exports.EmailLoginForm=K.EmailLoginForm;exports.EmailRegisterForm=K.EmailRegisterForm;exports.OtpInput=K.OtpInput;exports.PasswordInput=K.PasswordInput;exports.TotpVerify=K.TotpVerify;exports.useEmailAuth=K.useEmailAuth;exports.useInstantLink=K.useInstantLink;exports.useTotpVerify=K.useTotpVerify;exports.validatePassword=Pe.validatePassword;exports.ErrorMessage=G.ErrorMessage;exports.GoogleLoginButton=Bs.GoogleLoginButton;exports.useGoogleAuth=Bs.useGoogleAuth;exports.SolanaLoginButton=Se.SolanaLoginButton;exports.useSolanaAuth=Se.useSolanaAuth;exports.InviteForm=te.InviteForm;exports.InviteList=te.InviteList;exports.MemberList=te.MemberList;exports.useInvites=te.useInvites;exports.useMembers=te.useMembers;exports.useServerFeatures=te.useServerFeatures;exports.useSystemSettings=Ds.useSystemSettings;exports.useOrgs=Is.useOrgs;exports.AdminUserList=Ee.AdminUserList;exports.useAdminUsers=Ee.useAdminUsers;exports.AdminDepositList=We.AdminDepositList;exports.AdminDepositStats=We.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=fe.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=fe.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=fe.AdminWithdrawalQueue;exports.AdminWithdrawalStats=fe.AdminWithdrawalStats;exports.AdminIcons=ge.Icons;exports.AdminShell=ge.AdminShell;exports.ProfileDropdown=ge.ProfileDropdown;exports.cedrosLoginPlugin=ge.cedrosLoginPlugin;exports.loginPlugin=ge.cedrosLoginPlugin;exports.useAdminShell=ge.useAdminShell;exports.AuthenticationSettings=Ut.AuthenticationSettings;exports.EmbeddedWalletSettings=Wt.EmbeddedWalletSettings;exports.CreditSystemSettings=Fs.CreditSystemSettings;exports.PrivacyCashSettings=Fs.CreditSystemSettings;exports.ServerSettings=Ot.ServerSettings;exports.useAdminDeposits=Hr.useAdminDeposits;exports.SettingsPageLayout=qt.SettingsPageLayout;exports.EmailSettings=Qr.EmailSettings;exports.WebhookSettings=Kr.WebhookSettings;exports.AppleLoginButton=Zt;exports.CapabilityWarning=Oo;exports.CedrosAdminDashboard=Tn;exports.CreditBalance=Ia;exports.DepositFlow=ya;exports.ErrorBoundary=rr;exports.ForgotPasswordForm=Yt;exports.FullPageLayout=Ya;exports.History=qa;exports.I18nProvider=ri;exports.LoginButton=mo;exports.LoginForm=Ge;exports.LoginModal=Ao;exports.OrgSelector=jo;exports.OrgSwitcher=_o;exports.PasskeyLoginButton=tr;exports.PasskeyPrompt=ur;exports.RecoveryPhraseDisplay=or;exports.RecoveryPhraseInput=nr;exports.ResetPasswordForm=vo;exports.SUPPORTED_TOKENS=Rr;exports.SecuritySettings=Nn;exports.SessionList=Ro;exports.SetupWizard=br;exports.SplitPageLayout=Ja;exports.SystemSettings=dn;exports.TieredAmountSlider=$s;exports.TokenSelector=Hs;exports.TotpSettings=aa;exports.TotpSetup=jr;exports.UserProfileSettings=la;exports.WalletAddressRow=fr;exports.WalletEnrollment=lr;exports.WalletManager=on;exports.WalletRecovery=mr;exports.WalletStatus=gr;exports.WalletUnlock=hr;exports.WithdrawalFlow=Ha;exports.WithdrawalHistory=Ga;exports.defaultTranslations=$e;exports.getTierForAmount=Ye;exports.mergeTranslations=Br;exports.useAppleAuth=Jt;exports.useAuthorize=ei;exports.useCredits=Gs;exports.useDeposit=Nr;exports.useLocale=ni;exports.usePasskeySigning=dr;exports.usePasswordReset=Os;exports.usePendingRecovery=si;exports.useProfile=kr;exports.useSessions=Za;exports.useSetup=qs;exports.useTotp=Vs;exports.useTransactionSigning=ti;exports.useTranslations=oi;exports.useWalletEnrollment=ir;exports.useWalletRecovery=pr;exports.useWalletSigning=cr;exports.useWebAuthn=sr;exports.useWithdrawal=Ys;
2055
+ `);const E=v(k,C,L),T=s.getSymbolSize(k),_=new a(T);return w(_,k),g(_),m(_,k),A(_,C,0),k>=7&&y(_,k),b(_,E),isNaN(N)&&(N=c.getBestMask(_,A.bind(null,_,C))),c.applyMask(N,_),A(_,C,N),{modules:_,version:k,errorCorrectionLevel:C,maskPattern:N,segments:L}}return as.create=function(k,C){if(typeof k>"u"||k==="")throw new Error("No input text");let N=t.M,L,P;return typeof C<"u"&&(N=t.from(C.errorCorrectionLevel,t.M),L=u.from(C.version),P=c.from(C.maskPattern),C.toSJISFunc&&s.setToSJISFunction(C.toSJISFunc)),S(k,L,N,P)},as}var Ns={},Cs={},Tt;function vr(){return Tt||(Tt=1,(function(s){function t(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let a=o.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+o);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(n){return[n,n]}))),a.length===6&&a.push("F","F");const r=parseInt(a.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+a.slice(0,6).join("")}}s.getOptions=function(a){a||(a={}),a.color||(a.color={});const r=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,n=a.width&&a.width>=21?a.width:void 0,c=a.scale||4;return{width:n,scale:n?4:c,margin:r,color:{dark:t(a.color.dark||"#000000ff"),light:t(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},s.getScale=function(a,r){return r.width&&r.width>=a+r.margin*2?r.width/(a+r.margin*2):r.scale},s.getImageWidth=function(a,r){const n=s.getScale(a,r);return Math.floor((a+r.margin*2)*n)},s.qrToImageData=function(a,r,n){const c=r.modules.size,i=r.modules.data,d=s.getScale(c,n),u=Math.floor((c+n.margin*2)*d),p=n.margin*d,f=[n.color.light,n.color.dark];for(let h=0;h<u;h++)for(let w=0;w<u;w++){let g=(h*u+w)*4,m=n.color.light;if(h>=p&&w>=p&&h<u-p&&w<u-p){const y=Math.floor((h-p)/d),A=Math.floor((w-p)/d);m=f[i[y*c+A]?1:0]}a[g++]=m.r,a[g++]=m.g,a[g++]=m.b,a[g]=m.a}}})(Cs)),Cs}var Mt;function ea(){return Mt||(Mt=1,(function(s){const t=vr();function o(r,n,c){r.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=c,n.width=c,n.style.height=c+"px",n.style.width=c+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}s.render=function(n,c,i){let d=i,u=c;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),c||(u=a()),d=t.getOptions(d);const p=t.getImageWidth(n.modules.size,d),f=u.getContext("2d"),h=f.createImageData(p,p);return t.qrToImageData(h.data,n,d),o(f,u,p),f.putImageData(h,0,0),u},s.renderToDataURL=function(n,c,i){let d=i;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),d||(d={});const u=s.render(n,c,d),p=d.type||"image/png",f=d.rendererOpts||{};return u.toDataURL(p,f.quality)}})(Ns)),Ns}var Ss={},_t;function sa(){if(_t)return Ss;_t=1;const s=vr();function t(r,n){const c=r.a/255,i=n+'="'+r.hex+'"';return c<1?i+" "+n+'-opacity="'+c.toFixed(2).slice(1)+'"':i}function o(r,n,c){let i=r+n;return typeof c<"u"&&(i+=" "+c),i}function a(r,n,c){let i="",d=0,u=!1,p=0;for(let f=0;f<r.length;f++){const h=Math.floor(f%n),w=Math.floor(f/n);!h&&!u&&(u=!0),r[f]?(p++,f>0&&h>0&&r[f-1]||(i+=u?o("M",h+c,.5+w+c):o("m",d,0),d=0,u=!1),h+1<n&&r[f+1]||(i+=o("h",p),p=0)):d++}return i}return Ss.render=function(n,c,i){const d=s.getOptions(c),u=n.modules.size,p=n.modules.data,f=u+d.margin*2,h=d.color.light.a?"<path "+t(d.color.light,"fill")+' d="M0 0h'+f+"v"+f+'H0z"/>':"",w="<path "+t(d.color.dark,"stroke")+' d="'+a(p,u,d.margin)+'"/>',g='viewBox="0 0 '+f+" "+f+'"',y='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+g+' shape-rendering="crispEdges">'+h+w+`</svg>
2056
+ `;return typeof i=="function"&&i(null,y),y},Ss}var Rt;function ta(){if(Rt)return xe;Rt=1;const s=Dn(),t=Zn(),o=ea(),a=sa();function r(n,c,i,d,u){const p=[].slice.call(arguments,1),f=p.length,h=typeof p[f-1]=="function";if(!h&&!s())throw new Error("Callback required as last argument");if(h){if(f<2)throw new Error("Too few arguments provided");f===2?(u=i,i=c,c=d=void 0):f===3&&(c.getContext&&typeof u>"u"?(u=d,d=void 0):(u=d,d=i,i=c,c=void 0))}else{if(f<1)throw new Error("Too few arguments provided");return f===1?(i=c,c=d=void 0):f===2&&!c.getContext&&(d=i,i=c,c=void 0),new Promise(function(w,g){try{const m=t.create(i,d);w(n(m,c,d))}catch(m){g(m)}})}try{const w=t.create(i,d);u(null,n(w,c,d))}catch(w){u(w)}}return xe.create=t.create,xe.toCanvas=r.bind(null,o.render),xe.toDataURL=r.bind(null,o.renderToDataURL),xe.toString=r.bind(null,function(n,c,i){return a.render(n,i)}),xe}var ra=ta();const oa=ie.getDefaultExportFromCjs(ra);function na({value:s,size:t=200,alt:o="QR code",className:a=""}){const r=l.useRef(null),[n,c]=l.useState(null);return l.useEffect(()=>{!r.current||!s||oa.toCanvas(r.current,s,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{c(null)}).catch(i=>{c(i instanceof Error?i.message:"Failed to generate QR code")})},[s,t]),n?e.jsx("div",{className:`cedros-qr-error ${a}`,style:{width:t,height:t},role:"img","aria-label":o,children:e.jsx("p",{children:"Failed to generate QR code"})}):e.jsx("canvas",{ref:r,className:`cedros-totp-qr-image ${a}`,role:"img","aria-label":o,style:{borderRadius:"0.5rem"}})}function zs(){const{config:s,_internal:t}=M.useCedrosLogin(),[o,a]=l.useState(null),[r,n]=l.useState("idle"),[c,i]=l.useState(null),[d,u]=l.useState(!1),[p,f]=l.useState(null),h=l.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),w=l.useCallback(async()=>{u(!0),f(null);try{const j=await h.get("/mfa/status");return a(j),j}catch(j){const S=M.handleApiError(j,"Failed to get TOTP status");throw f(S),S}finally{u(!1)}},[h]),g=l.useCallback(async()=>{u(!0),f(null),n("loading");try{const j=await h.post("/mfa/setup",{});return i(j),n("setup"),j}catch(j){const S=M.handleApiError(j,"Failed to start TOTP setup");throw f(S),n("error"),S}finally{u(!1)}},[h]),m=l.useCallback(async j=>{if(!/^\d{6}$/.test(j)){const S={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw f(S),S}u(!0),f(null),n("verifying");try{await h.post("/mfa/enable",{code:j}),n("success");try{const S=await h.get("/mfa/status");a(S)}catch{a({enabled:!0,recoveryCodesRemaining:0})}}catch(S){const x=M.handleApiError(S,"Invalid verification code");throw f(x),n("error"),x}finally{u(!1)}},[h]),y=l.useCallback(async j=>{if(!j){const S={code:"VALIDATION_ERROR",message:"Please enter your password"};throw f(S),S}u(!0),f(null);try{await h.post("/mfa/disable",{password:j}),a({enabled:!1,recoveryCodesRemaining:0}),i(null),n("idle")}catch(S){const x=M.handleApiError(S,"Failed to disable TOTP");throw f(x),x}finally{u(!1)}},[h]),A=l.useCallback(async j=>{if(!/^\d{6}$/.test(j)){const S={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw f(S),S}u(!0),f(null);try{return await h.post("/mfa/recovery-codes/regenerate",{code:j})}catch(S){const x=M.handleApiError(S,"Failed to regenerate recovery codes");throw f(x),x}finally{u(!1)}},[h]),b=l.useCallback(()=>f(null),[]),v=l.useCallback(()=>{f(null),i(null),n("idle"),u(!1)},[]);return{status:o,setupState:r,setupData:c,isLoading:d,error:p,getStatus:w,beginSetup:g,enableTotp:m,disableTotp:y,regenerateBackupCodes:A,clearError:b,reset:v}}function jr({onSuccess:s,onCancel:t,className:o=""}){const{setupState:a,setupData:r,isLoading:n,error:c,beginSetup:i,enableTotp:d,clearError:u,reset:p}=zs(),[f,h]=l.useState("qr"),[w,g]=l.useState(""),[m,y]=l.useState(!1),[A,b]=l.useState(!1),v=l.useRef(null);l.useEffect(()=>{a==="idle"&&i().catch(()=>{})},[a,i]),l.useEffect(()=>{a==="success"&&s?.()},[a,s]);const j=async()=>{r?.secret&&(await navigator.clipboard.writeText(r.secret),y(!0),v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>y(!1),2e3))},S=async()=>{if(r?.recoveryCodes){const C=r.recoveryCodes.join(`
2057
+ `);await navigator.clipboard.writeText(C)}},x=async()=>{try{await d(w)}catch{g("")}},k=()=>{p(),t?.()};return l.useEffect(()=>()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]),a==="loading"||a==="idle"&&n?e.jsx("div",{className:`cedros-totp-setup ${o}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(V.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):a==="error"&&!r?e.jsxs("div",{className:`cedros-totp-setup ${o}`,children:[e.jsx(Y.ErrorMessage,{error:c,onDismiss:u}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:k,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>i(),children:"Try again"})]})]}):a==="success"?e.jsx("div",{className:`cedros-totp-setup ${o}`,children:e.jsxs("div",{className:"cedros-totp-success",children:[e.jsxs("svg",{className:"cedros-totp-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"var(--cedros-success)",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"var(--cedros-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication enabled"}),e.jsx("p",{className:"cedros-totp-description",children:"Your account is now protected with an additional layer of security."})]})}):r?e.jsxs("div",{className:`cedros-totp-setup ${o}`,children:[f==="qr"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Scan QR code"}),e.jsx("p",{className:"cedros-totp-description",children:"Use your authenticator app to scan this QR code."}),e.jsx("div",{className:"cedros-totp-qr",children:e.jsx(na,{value:r.otpauthUri,size:200,alt:"QR code for authenticator app"})}),e.jsxs("div",{className:"cedros-totp-manual",children:[e.jsx("p",{className:"cedros-totp-manual-label",children:"Or enter this code manually:"}),e.jsxs("div",{className:"cedros-totp-secret",children:[e.jsx("code",{className:"cedros-totp-secret-code",children:r.secret}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:j,"aria-label":"Copy secret",children:m?"Copied!":"Copy"})]})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:k,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>h("backup"),children:"Continue"})]})]}),f==="backup"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Save recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. You can use them to access your account if you lose your authenticator device."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:r.recoveryCodes.map((C,N)=>e.jsx("code",{className:"cedros-totp-backup-code",children:C},N))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:S,children:"Copy all codes"}),e.jsxs("label",{className:"cedros-checkbox-label cedros-totp-confirm",children:[e.jsx("input",{type:"checkbox",className:"cedros-checkbox",checked:A,onChange:C=>b(C.target.checked)}),e.jsx("span",{className:"cedros-checkbox-text",children:"I have saved these recovery codes"})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>h("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>h("verify"),disabled:!A,children:"Continue"})]})]}),f==="verify"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Verify setup"}),e.jsx("p",{className:"cedros-totp-description",children:"Enter the 6-digit code from your authenticator app to complete setup."}),e.jsx(K.OtpInput,{value:w,onChange:g,onComplete:x,disabled:n,error:c?.message,autoFocus:!0}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>h("backup"),disabled:n,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:x,disabled:n||w.length!==6,children:n?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function aa({onStatusChange:s,className:t=""}){const{status:o,isLoading:a,error:r,getStatus:n,disableTotp:c,regenerateBackupCodes:i,clearError:d}=zs(),[u,p]=l.useState("status"),[f,h]=l.useState(""),[w,g]=l.useState(""),[m,y]=l.useState(null),[A,b]=l.useState(!1),[v,j]=l.useState(null);l.useEffect(()=>{n().catch(()=>{})},[n]);const S=l.useCallback(()=>{p("status"),s?.(!0)},[s]),x=async()=>{b(!0),j(null);try{await c(f),p("status"),h(""),s?.(!1)}catch(N){j(N instanceof Error?N.message:"Failed to disable 2FA"),h("")}finally{b(!1)}},k=async()=>{b(!0),j(null);try{const N=await i(w);y(N.recoveryCodes),g("")}catch(N){j(N instanceof Error?N.message:"Failed to regenerate codes"),g("")}finally{b(!1)}},C=async()=>{m&&await navigator.clipboard.writeText(m.join(`
2058
+ `))};return a&&!o?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(V.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):r&&!o?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(Y.ErrorMessage,{error:r,onDismiss:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>n(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(jr,{onSuccess:S,onCancel:()=>p("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),v&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v},onDismiss:()=>j(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(K.PasswordInput,{label:"Password",placeholder:"Enter your password",value:f,onChange:N=>h(N.target.value),disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{p("status"),h(""),j(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:x,disabled:A||f.length===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?m?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:m.map((N,L)=>e.jsx("code",{className:"cedros-totp-backup-code",children:N},L))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:C,children:"Copy all codes"}),e.jsx("div",{className:"cedros-totp-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>{p("status"),y(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),v&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v},onDismiss:()=>j(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(K.OtpInput,{value:w,onChange:g,onComplete:k,disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{p("status"),g(""),j(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:k,disabled:A||w.length!==6,children:A?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in."})]}),e.jsx("div",{className:`cedros-totp-badge ${o?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:o?.enabled?"Enabled":"Disabled"})]}),o?.enabled?e.jsxs("div",{className:"cedros-totp-enabled-actions",children:[e.jsxs("div",{className:"cedros-totp-description",style:{marginTop:"0.25rem"},children:["Recovery codes remaining: ",e.jsx("strong",{children:o.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>p("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>p("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>p("setup"),children:"Enable two-factor authentication"})]})})}class ia{client;constructor(t,o,a,r){this.client=new M.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(o){throw M.handleApiError(o,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(o){throw M.handleApiError(o,"Failed to update profile")}}}function kr(){const{config:s,authState:t,_internal:o}=M.useCedrosLogin(),[a,r]=l.useState(!1),[n,c]=l.useState(null),i=l.useMemo(()=>new ia(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),d=l.useCallback(()=>{c(null)},[]),u=l.useCallback(async f=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");r(!0),c(null);try{return await i.updateProfile(f)}catch(h){const w=h instanceof Error?h:new Error("Failed to update profile");throw c(w),w}finally{r(!1)}},[t,i]),p=l.useCallback(async f=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");r(!0),c(null);try{await i.changePassword(f)}catch(h){const w=h instanceof Error?h:new Error("Failed to change password");throw c(w),w}finally{r(!1)}},[t,i]);return{isLoading:a,error:n,updateProfile:u,changePassword:p,clearError:d}}function la({onPasswordChange:s,onClose:t,className:o=""}){const{user:a}=D.useAuth(),{isLoading:r,error:n,changePassword:c,clearError:i}=kr(),[d,u]=l.useState("main"),[p,f]=l.useState(""),[h,w]=l.useState(""),[g,m]=l.useState(""),[y,A]=l.useState(null),[b,v]=l.useState(null),j=Pe.validatePassword(h),S=h===g,x=p.length>0&&h.length>0&&g.length>0&&j.isValid&&S,k=l.useCallback(async()=>{if(x){A(null),v(null);try{await c({currentPassword:p,newPassword:h}),f(""),w(""),m(""),v("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{u("main"),v(null)},2e3)}catch(L){A(L instanceof Error?L.message:"Failed to change password")}}},[x,p,h,c,s]),C=l.useCallback(()=>{u("main"),f(""),w(""),m(""),A(null),i()},[i]),N=()=>a?.name?a.name.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2):a?.email?a.email[0].toUpperCase():"?";return d==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(y||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:y||n?.message||""},onDismiss:()=>{A(null),i()}})}),b&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),b]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:p,onChange:L=>f(L.target.value),disabled:r,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"New password",placeholder:"Enter new password",value:h,onChange:L=>w(L.target.value),disabled:r,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:g,onChange:L=>m(L.target.value),disabled:r,error:g.length>0&&!S?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:C,disabled:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:k,disabled:r||!x,children:r?e.jsxs(e.Fragment,{children:[e.jsx(V.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:a?.picture?e.jsx("img",{src:a.picture,alt:a.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:N()})}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:a?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:a?.email})]})]}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:a?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:"••••••••"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u("change-password"),children:"Change"})]})]}),t&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})})}function Nr(){const s=M.useCedrosLoginOptional(),[t,o]=l.useState(!1),[a,r]=l.useState(null),n=l.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=l.useCallback(()=>{r(null)},[]),i=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(g)||g<=0){const m=new Error(`Invalid deposit amount: ${g}. Must be a positive integer (lamports).`);throw r(m.message),m}o(!0),r(null);try{return await n.post("/deposit",{amount_lamports:g})}catch(m){const y=M.handleApiError(m,"Failed to execute deposit");throw r(y.message),y}finally{o(!1)}},[n]),d=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get(`/deposit/status/${encodeURIComponent(g)}`)}catch(m){const y=M.handleApiError(m,"Failed to get deposit status");throw r(y.message),y}finally{o(!1)}},[n]),u=l.useCallback(async()=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get("/deposit/config")}catch(g){const m=M.handleApiError(g,"Failed to get deposit config");throw r(m.message),m}finally{o(!1)}},[n]),p=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{const m=new URLSearchParams;g?.limit!==void 0&&m.set("limit",String(g.limit)),g?.offset!==void 0&&m.set("offset",String(g.offset));const y=m.toString(),A=y?`/deposits?${y}`:"/deposits";return await n.get(A)}catch(m){const y=M.handleApiError(m,"Failed to list deposits");throw r(y.message),y}finally{o(!1)}},[n]),f=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{const m=new URLSearchParams({input_mint:g.inputMint,amount:String(g.amount),taker:g.taker});return await n.get(`/deposit/quote?${m}`)}catch(m){const y=M.handleApiError(m,"Failed to get deposit quote");throw r(y.message),y}finally{o(!1)}},[n]),h=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.post("/deposit/public",g)}catch(m){const y=M.handleApiError(m,"Failed to execute public deposit");throw r(y.message),y}finally{o(!1)}},[n]),w=l.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.post("/deposit/micro",g)}catch(m){const y=M.handleApiError(m,"Failed to execute micro deposit");throw r(y.message),y}finally{o(!1)}},[n]);return{deposit:i,getQuote:f,publicDeposit:h,microDeposit:w,getStatus:d,getConfig:u,listDeposits:p,isLoading:t,error:a,clearError:c}}function Vs({tokens:s,selectedToken:t,onSelect:o,openSignal:a,placeholder:r="Select token",disabled:n=!1,className:c="",searchable:i=!0}){const[d,u]=l.useState(!1),[p,f]=l.useState(""),h=l.useRef(null),w=l.useRef(null),g=l.useMemo(()=>{if(!p.trim())return s;const b=p.toLowerCase();return s.filter(v=>v.symbol.toLowerCase().includes(b)||v.name.toLowerCase().includes(b)||v.mint.toLowerCase().includes(b))},[s,p]);l.useEffect(()=>{const b=v=>{h.current&&!h.current.contains(v.target)&&(u(!1),f(""))};if(d)return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[d]),l.useEffect(()=>{d&&i&&w.current&&w.current.focus()},[d,i]),l.useEffect(()=>{a===void 0||n||(u(!0),f(""))},[a,n]);const m=l.useCallback(()=>{n||(u(b=>!b),d&&f(""))},[n,d]),y=l.useCallback(b=>{o(b),u(!1),f("")},[o]),A=l.useCallback(b=>{b.key==="Escape"?(u(!1),f("")):b.key==="Enter"&&g.length===1&&y(g[0])},[g,y]);return e.jsxs("div",{ref:h,className:`cedros-token-selector ${d?"cedros-token-selector-open":""} ${n?"cedros-token-selector-disabled":""} ${c}`,onKeyDown:A,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:m,disabled:n,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs("span",{className:"cedros-token-selector-selected",children:[t.logoUrl&&e.jsx("img",{src:t.logoUrl,alt:t.symbol,className:"cedros-token-icon",onError:b=>{b.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:r}),e.jsx("span",{className:"cedros-token-selector-arrow",children:d?"▲":"▼"})]}),d&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[i&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:w,type:"text",value:p,onChange:b=>f(b.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:g.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:g.map(b=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===b.mint?"cedros-token-option-selected":""}`,onClick:()=>y(b),role:"option","aria-selected":t?.mint===b.mint,children:[b.logoUrl&&e.jsx("img",{src:b.logoUrl,alt:b.symbol,className:"cedros-token-icon",onError:v=>{v.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:b.symbol}),e.jsx("span",{className:"cedros-token-name",children:b.name})]}),t?.mint===b.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},b.mint))})})]})]})}function $e(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const Hs="data:image/webp;base64,UklGRkACAABXRUJQVlA4IDQCAACQDQCdASo8ADwAPjEWiUMiISEUBFQgAwSgB4Z/TeLt3XMAoQH23eph0gPMB+sn+M9tvngOsA9ADwgPg3/cH9sfZciikEBuA1AB+nf+84CUkAVvA2x4xvyobR+mBaYhjUv/ewHb4hTqOnP38rzsxZX2inOSciAA/v7uqvqGdpWcjjrfMDFaNHumTog38t3yor0kbjn631VsX61cAC749wWuAX74u/f/hpeDFqS/ci8E1g94wk9UVs7BHqtv7f/M9iT1u5ITJV0Gv6tE/CW5j/nVR6yExJ6JoDRDOWQ8zVpWH92r3Lnbnc4WJpOchbRT3H5rv//6PP+F//4ehLUlR/4tkRUKZu/yOa26+sywmY+Xc1X2lXMcUv7+eQ7+FBE7bhKc7htieBfH4eR134AVaILL7PWA2FjzAjfaP1Lgirqoq/ZooE8jVD/b4g3J3O3/TG/4ajHe6clnAI/4NdwrnHX0P/quBU03HqSsQ0qsEMAuhrH/jn+YtDzmjm8q/cGJ44qvi24Hn+G1kxz2XP2S/Gp7ri5cMlo+muuwBjyNJnnEcTt/5cRdYS2cbEBZtpINWj3PuC1EOsd/8cTepSpxODcJHLzktfC1PHW3Pgoh3J5PHjW3TCQ1Wlu/wP8e8OPfNm48BODGChioj3ezblqrOBV+cI+hLi7ReJdvBF/4jY+/Un0asuWnrA6kRNpgOeO8wyl4Ryhkrff+9R1SpyPYP+5T3EuWWLZaCn0bGzyk97S3VAAAAAA=",ca=1e4,Ke=1e3,Cr=3;function da(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function ua(s,t){switch(s){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${da(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function Qs(s,t,o){return Math.min(Math.max(s,t),o)}function ha(s,t){if(t<=0)return 0;const o=Qs(s/t,0,1);return Math.round(Math.pow(o,1/Cr)*Ke)}function pa(s,t){const o=Qs(s/Ke,0,1);return t*Math.pow(o,Cr)}function Sr(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function ma(s){return s<1?2:0}function Bt(s){const t=Sr(s),o=Math.round(s/t)*t,a=ma(t);return Number(o.toFixed(a))}function Ks({config:s,valueUsd:t,onChange:o,maxUsd:a=ca,disabled:r=!1,className:n=""}){const c=Qs(Number.isFinite(t)?t:0,0,a),i=l.useMemo(()=>$e(c,s),[c,s]),d=ua(i,s),u=ha(c,a),p=u/Ke*100;return e.jsxs("div",{className:`cedros-tiered-slider ${n}`,children:[e.jsxs("div",{className:"cedros-tiered-slider-input-row",children:[e.jsxs("div",{className:"cedros-tiered-slider-input",children:[e.jsx("span",{className:"cedros-tiered-slider-currency",children:"$"}),e.jsx("input",{type:"number",value:c||"",onChange:f=>o(Bt(parseFloat(f.target.value)||0)),placeholder:"Enter amount",disabled:r,min:0,step:Sr(c),className:"cedros-deposit-flow-input cedros-tiered-slider-input-field","aria-label":"Deposit amount"})]}),e.jsxs("div",{className:"cedros-tiered-slider-tier",children:[e.jsxs("span",{className:`cedros-tiered-slider-badge cedros-tiered-slider-badge-${i}`,children:[i==="sol_micro"&&e.jsx("img",{src:Hs,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),d.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:d.detail})]})]}),e.jsx("input",{type:"range",min:0,max:Ke,step:1,value:u,onChange:f=>o(Bt(pa(parseFloat(f.target.value),a))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${p}%, var(--cedros-border) ${p}%, var(--cedros-border) 100%)`},disabled:r,"aria-label":"Deposit amount slider"}),d.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:d.note})]})}function fa(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function ga(s,t,o){const{feePolicy:a,privacyFeePercent:r,swapFeePercent:n,companyFeePercent:c}=s;let i=c;return o||(a==="user_pays_all"?(i+=n,t&&(i+=r)):a==="user_pays_privacy"&&t?i+=r:a==="user_pays_swap"&&(i+=n)),i}const Ue=1e9,Ae={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Hs},ve={mint:"other",symbol:"OTHER",name:"Other",decimals:6},Er=1e4;function wa(s,t){const o=t<s.publicMinUsd,a=t>=s.privateMinUsd,r=[],n=!o&&a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),c=!o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),i=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(n){const d=s.privacyFeeFixedLamports/Ue,u=s.privacyFeePercent,p=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Privacy",solAmount:d,percent:u,usdAmount:p+f})}if(c){const d=s.swapFeeFixedLamports/Ue,u=s.swapFeePercent,p=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Swap",solAmount:d,percent:u,usdAmount:p+f})}if(i){const d=s.companyFeeFixedLamports/Ue,u=s.companyFeePercent,p=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Service",solAmount:d,percent:u,usdAmount:p+f})}return r}function Pr(s,t,o){const a=wa(s,t),r=o<.01?.01:o;if(a.length===0)return`Total: $${r.toFixed(2)}`;const n=a.reduce((g,m)=>g+m.solAmount,0),c=a.reduce((g,m)=>g+m.percent,0),i={fee:7,sol:8,rate:7,usd:8},d=g=>{const m=g.label.padEnd(i.fee),y=g.solAmount.toFixed(4).padStart(6).padEnd(i.sol),A=(g.percent.toFixed(2)+"%").padStart(5).padEnd(i.rate),b=("$"+Math.max(g.usdAmount,.01).toFixed(2)).padEnd(i.usd);return`${m} │ ${y} │ ${A} │ ${b}`},u=`${"Fee".padEnd(i.fee)} │ ${"SOL".padEnd(i.sol)} │ ${"+ Rate".padEnd(i.rate)} │ ${"= Total".padEnd(i.usd)}`,p=`${"─".repeat(i.fee)}─┼─${"─".repeat(i.sol)}─┼─${"─".repeat(i.rate)}─┼─${"─".repeat(i.usd)}`,f=("$"+r.toFixed(2)).padEnd(i.usd),h=`${"TOTAL".padEnd(i.fee)} │ ${n.toFixed(4).padStart(6).padEnd(i.sol)} │ ${(c.toFixed(2)+"%").padStart(5).padEnd(i.rate)} │ ${f}`;return[u,p,...a.map(d),p,h].join(`
2059
+ `)}function ba(s){const t=[],o=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,a=s.swapFeeFixedLamports>0||s.swapFeePercent>0,r=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return o&&t.push("Privacy Cash fee"),a&&t.push("swap fee"),r&&t.push("company service fee"),t.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function Je(s,t){if(t<=0)return 0;const o=t<s.publicMinUsd,a=t>=s.privateMinUsd,r=ga(s,a,o);let n=s.companyFeeFixedLamports;o||(a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(n+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(n+=s.swapFeeFixedLamports));const c=n/Ue*s.solPriceUsd,i=t*(r/100);return c+i}function Lr(s,t,o){return s==="sol"?"SOL":s==="single-token"?t.symbol:o.some(r=>r.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function Dt(s){return s.map(t=>t.trim()).filter(Boolean)}const Tr=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function Mr(s,t,o){if(Tr.has(s.symbol))return 1;const a=t.tokenPrices?.[s.symbol];if(a&&a>0)return a;if(s.symbol==="SOL")return t.solPriceUsd||null;const r=o?.[s.symbol];return r&&r>0?r:null}function _r(s,t){const o=Tr.has(t)?2:4;return s.toFixed(o)}function ya({config:s,currencyMode:t,depositMethod:o,tokens:a=[],defaultToken:r,minAmount:n,maxAmount:c=1e4,onSuccess:i,onError:d,onCancel:u,onUnlockRequired:p,onAuthorize:f,className:h="",showStepIndicator:w=!0,pollInterval:g=5e3,demoMode:m=!1,demoAutoConfirmMs:y,tokenPriceUsd:A,showExplainer:b=!1,siteName:v,explainerConfig:j}){const{deposit:S,getStatus:x,error:k,clearError:C}=Nr(),N=D.useWallet(),L=Dt(s.quickActionTokens),P=Dt(s.customTokenSymbols),E=l.useMemo(()=>{const F=s.customTokens??[];if(F.length===0)return a;const O=new Set(a.map(G=>G.symbol)),H=[...a];for(const G of F)O.has(G.symbol)||(H.push({mint:G.mint,symbol:G.symbol,name:G.symbol,decimals:G.decimals,logoUrl:G.logoUrl}),O.add(G.symbol));return H},[a,s.customTokens]),T=l.useMemo(()=>{if(P.length===0)return E;const F=E.filter(O=>P.includes(O.symbol));return F.length>0?F:E},[E,P]),_=s.privateDepositsEnabled,B=o?o==="sign"&&!_?"receive":o:_&&N.hasExternalWallet?"sign":"receive",$=L[0]?E.find(F=>F.symbol===L[0]):void 0,le=t==="sol"?Ae:t==="single-token"?$??E.find(F=>F.symbol==="USDC")??E[0]??Ae:r??$??E.find(F=>F.symbol==="USDC")??E.find(F=>F.symbol!=="SOL")??E[0]??Ae,J=l.useCallback(()=>b?"explainer":"unlock",[b]),[q,R]=l.useState(J),[I,z]=l.useState(le),[X,ee]=l.useState(""),[ue,ce]=l.useState(null),[W,U]=l.useState(null),[Q,ne]=l.useState(null),[pe,Js]=l.useState(null),[Xe,ke]=l.useState(!1),[Ir,Ze]=l.useState(!1),[Le,Xs]=l.useState(null);l.useEffect(()=>{R(J()),z(le),ee(""),ce(null),U(null),ne(null),Js(null),ke(!1),Ze(!1),Xs(null),C()},[t,B,le,C,J]);const Fr=n??s.privateMinSol,Ur=c,Te=parseFloat(X),Zs=N.status==="enrolled_locked"||N.status==="enrolled_unlocked"||N.status==="unlocked",es=Zs&&N.isUnlocked,ss=Zs&&!N.isUnlocked,et=l.useCallback(()=>{let H=B==="sign"?[{key:"unlock",label:"Authorize"},{key:"confirm",label:"Send"},{key:"signing",label:"Signing"},{key:"success",label:"Complete"}]:[{key:"unlock",label:"Authorize"},{key:"show-address",label:"Send"},{key:"waiting",label:"Confirming"},{key:"success",label:"Complete"}];return b&&(H=[{key:"explainer",label:"Info"},...H]),H},[B,b])(),Wr=et.findIndex(F=>F.key===q),st=l.useCallback(F=>{z(F)},[]),Or=l.useCallback(async F=>{if(!f){R(B==="sign"?"confirm":"show-address");return}Ze(!0),U(null);try{const H=await f(F,B==="sign"?Te:null,I);ne(H.sessionId),Js(H.depositAddress),R(B==="sign"?"confirm":"show-address")}catch(O){const H=O instanceof Error?O:new Error("Authorization failed");U(H.message)}finally{Ze(!1)}},[f,B,Te,I]),qr=l.useCallback(async(F,O)=>{C(),U(null),R("signing");const H=F??Te,G=O??I;if(!m){if(ss&&p){p(),R("confirm");return}if(!es){U("Wallet not ready"),R("error");return}}try{const re=Math.floor(H*Math.pow(10,G.decimals));if(m){await new Promise(Re=>setTimeout(Re,1500));const _e={token:t==="sol"?null:G,amount:H,amountSmallestUnit:re,txSignature:`demo-tx-${Date.now()}`,sessionId:Q||`demo-session-${Date.now()}`,response:{sessionId:Q||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:re,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};ce(_e),R("success"),i?.(_e);return}const se=await S(re),Me={token:t==="sol"?null:G,amount:H,amountSmallestUnit:re,txSignature:se.txSignature,sessionId:se.sessionId,response:se,method:"sign"};ce(Me),R("success"),i?.(Me)}catch(re){const se=re instanceof Error?re:new Error("Deposit failed");U(se.message),R("error"),d?.(se)}},[S,Te,I,t,m,Q,es,ss,p,i,d,C]),zr=l.useCallback(()=>{R("waiting")},[]),ts=l.useCallback(async()=>{const F=pe||N.solanaPubkey;if(F)try{await navigator.clipboard.writeText(F),ke(!0),setTimeout(()=>ke(!1),2e3)}catch{const O=document.createElement("textarea");O.value=F,document.body.appendChild(O),O.select(),document.execCommand("copy"),document.body.removeChild(O),ke(!0),setTimeout(()=>ke(!1),2e3)}},[pe,N.solanaPubkey]);l.useEffect(()=>{if(!(q==="confirm"||q==="show-address"||q==="waiting")||!Q||m)return;let O=!1,H=0;const G=360,re=async()=>{if(!(O||H>=G)){H++;try{const se=await x(Q);if(se.status==="completed"||se.status==="detected"){const Me=se.amountLamports?se.amountLamports/Math.pow(10,I.decimals):0,_e=se.amountLamports||0,Re={token:t==="sol"?null:I,amount:Me,amountSmallestUnit:_e,txSignature:se.txSignature||"",sessionId:Q,response:se,method:"receive",depositAddress:N.solanaPubkey??void 0};ce(Re),R("success"),i?.(Re);return}}catch{}O||setTimeout(re,g)}};return re(),()=>{O=!0}},[q,Q,m,x,I,t,N.solanaPubkey,i,g]),l.useEffect(()=>{if(!m||!y||q!=="waiting"||B!=="receive"||!pe)return;const F=window.setTimeout(()=>{const O=Le??s.privateMinUsd,H=I.symbol==="SOL"&&s.solPriceUsd>0?O/s.solPriceUsd:O,G=Math.floor(H*Math.pow(10,I.decimals)),re={token:t==="sol"?null:I,amount:H,amountSmallestUnit:G,txSignature:`demo-tx-${Date.now()}`,sessionId:Q||`demo-session-${Date.now()}`,response:{sessionId:Q||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:G,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:pe??void 0};ce(re),R("success"),i?.(re)},y);return()=>window.clearTimeout(F)},[m,y,q,B,pe,Le,s,I,t,Q,i]);const Vr=l.useCallback(()=>{R(J()),ee(""),ce(null),U(null),C()},[J,C]);return s.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${h}`,children:[w&&q!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:et.map((F,O)=>{const H=Wr>=O,G=F.key===q;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${H?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${H?"active":""} ${G?"current":""}`,children:O+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${H?"active":""}`,children:F.label})]},F.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[q==="explainer"&&e.jsx(xa,{siteName:v,config:j,depositConfig:s,currencyMode:t,token:I,tokens:T,onContinue:()=>R("unlock"),onCancel:u}),q==="unlock"&&e.jsx(Aa,{token:I,tokens:T,currencyMode:t,depositMethod:B,isAuthorizing:Ir,error:W,onAuthorize:Or,onBack:b?()=>R("explainer"):void 0,onCancel:u}),q==="confirm"&&B==="sign"&&e.jsx(va,{token:I,tokens:E,quickActionSymbols:L,customTokenSymbols:P,currencyMode:t,minAmount:Fr,maxAmount:Ur,depositAddress:pe||N.solanaPubkey,walletReady:es||m,needsUnlock:ss&&!m,copied:Xe,isListening:!!Q&&!m,config:s,onCopy:ts,onTokenSelect:st,onUnlockRequired:p,onConfirm:(F,O)=>qr(F,O),onBack:()=>R("unlock"),onCancel:u}),q==="signing"&&e.jsx(ja,{depositAddress:N.solanaPubkey}),q==="show-address"&&e.jsx(ka,{token:I,tokens:E,quickActionSymbols:L,customTokenSymbols:P,tokenPriceUsd:A,currencyMode:t,depositAddress:pe||N.solanaPubkey,copied:Xe,isListening:!!Q&&!m,config:s,onCopy:ts,onTokenSelect:st,onAmountChange:Xs,onSent:zr,onBack:()=>R("unlock"),onCancel:u}),q==="waiting"&&e.jsx(Na,{token:I,depositAddress:pe||N.solanaPubkey,copied:Xe,feeLine:Le?`Fees: $${Math.max(Je(s,Le),.01).toFixed(2)} total`:"Fees: calculated after deposit",onCopy:ts}),q==="success"&&ue&&e.jsx(Ca,{result:ue,config:s,onNewDeposit:Vr}),q==="error"&&e.jsx(Sa,{error:W||k||"An error occurred",onRetry:()=>R("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${h}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function xa({siteName:s,config:t,depositConfig:o,currencyMode:a,token:r,tokens:n,onContinue:c,onCancel:i}){const d=t?.title??"How Deposits Work",u=t?.exchangeName??"Coinbase",p=Rs.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",f=t?.showExchangeSuggestion!==!1,h=Lr(a,r,n),w=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",g=t?.body??w,m=fa(o),y=ba(o);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:d}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:g}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:m?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:y})]})]})]}),f&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",h," using your credit card at"," ",e.jsx("a",{href:p,target:"_blank",rel:"noopener noreferrer",children:u}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[i&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:i,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:c,children:"Continue"})]})]})}function Aa({token:s,tokens:t,currencyMode:o,depositMethod:a,isAuthorizing:r,error:n,onAuthorize:c,onBack:i}){const[d,u]=l.useState(""),p=Lr(o,s,t),f=h=>{h.preventDefault(),d.trim()&&c(d)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Authorize Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:a==="sign"?o==="multi-token"?"Enter your password to authorize a deposit. This allows us to process your withdrawal when the privacy period ends.":`Enter your password to authorize a ${p} deposit. This allows us to process your withdrawal when the privacy period ends.`:o==="multi-token"?"Enter your password to get your deposit address. Any supported token sent to this address will be credited to your account.":`Enter your password to get your deposit address. Any ${p} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",htmlFor:"deposit-password",children:"Password"}),e.jsx("input",{id:"deposit-password",type:"password",value:d,onChange:h=>u(h.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:r,autoComplete:"current-password"})]}),n&&e.jsx("p",{className:"cedros-deposit-flow-error",children:n}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:i,disabled:r,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!d.trim()||r,children:r?"Authorizing...":"Continue"})]})]})]})}function va({token:s,tokens:t,quickActionSymbols:o,customTokenSymbols:a,currencyMode:r,minAmount:n,maxAmount:c,depositAddress:i,walletReady:d,needsUnlock:u,copied:p,isListening:f,config:h,onCopy:w,onTokenSelect:g,onUnlockRequired:m,onConfirm:y,onBack:A}){const[b,v]=l.useState(h.privateMinUsd),[j,S]=l.useState(!1),[x,k]=l.useState(!1),[C,N]=l.useState(0),[L,P]=l.useState(null),T=$e(b,h)==="sol_micro",_=s.symbol===ve.symbol,B=l.useMemo(()=>{const W=a.length===0?t:t.filter(ne=>a.includes(ne.symbol)),U=W.length>0?W:t;return U.some(ne=>ne.symbol===ve.symbol)?U:[...U,ve]},[t,a]),$=Je(h,b),le=$<.01?.01:$,J=_?"Fees: calculated after deposit":`Fees: $${le.toFixed(2)} total`,q=_?"":Pr(h,b,$),R=Mr(T?Ae:s,h),I=R?b/R:s.symbol==="SOL"&&h.solPriceUsd>0?b/h.solPriceUsd:b,z=I?_r(I,T?"SOL":s.symbol):null,ee=b-$<=0&&b>0,ue=!_&&b>0&&!ee&&I>=n&&I<=c;l.useEffect(()=>{if(r==="multi-token")if(T&&s.symbol!=="SOL"){P(s);const W=t.find(U=>U.symbol==="SOL");W&&g(W)}else!T&&L&&s.symbol==="SOL"&&(g(L),P(null))},[T,s.symbol,r,t,g,L,s]);const ce=()=>{ue&&y(I,s)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),r==="multi-token"&&!T&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[o.map(W=>{const U=t.find(ne=>ne.symbol===W),Q=s.symbol===W;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${Q?"is-active":""}`,onClick:()=>{U&&(S(!1),g(U))},disabled:!U,children:[U?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:U.logoUrl,alt:`${W} logo`}),W]},W)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${j?"is-active":""}`,onClick:()=>{S(!0),N(W=>W+1)},children:"Custom"})]}),j&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Vs,{tokens:B,selectedToken:s,onSelect:g,openSignal:C})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(Ks,{config:h,valueUsd:b,onChange:v,maxUsd:Er})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:_?"Sign to send tokens to this address":`Sign to send ${z??"--"} ${T?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:i||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:w,title:"Copy address",disabled:!i,children:p?"✓":"⧉"}),i&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${i}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),p&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),ee&&e.jsx("div",{className:"cedros-deposit-flow-warning",children:e.jsx("p",{children:"Deposit amount is less than the fees. Increase the amount to proceed."})}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[J,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${x?"is-open":""}`,"data-tooltip":q,"aria-label":`Fee breakdown: ${q.replaceAll(`
2060
+ `,", ")}`,"aria-expanded":x,onClick:W=>{W.stopPropagation(),k(U=>!U)},onBlur:()=>k(!1),onKeyDown:W=>{W.key==="Escape"&&k(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after network confirmation."})]})]}),f&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for incoming transfers. We will confirm automatically."}),u&&e.jsxs("div",{className:"cedros-deposit-flow-warning",children:[e.jsx("p",{children:"Your wallet is locked. Unlock it to continue."}),m&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:m,children:"Unlock Wallet"})]}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:A,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:ce,disabled:!ue||!d||!i,children:"Deposit"})]})]})}function ja({depositAddress:s}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Signing Transfer"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Approve the transfer in your wallet extension..."}),s&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[s.slice(0,6),"...",s.slice(-4)]})]})]})}function ka({token:s,tokens:t,quickActionSymbols:o,customTokenSymbols:a,tokenPriceUsd:r,currencyMode:n,depositAddress:c,copied:i,isListening:d,config:u,onCopy:p,onTokenSelect:f,onAmountChange:h,onSent:w,onBack:g}){const[m,y]=l.useState(u.privateMinUsd),[A,b]=l.useState(!1),[v,j]=l.useState(!1),[S,x]=l.useState(0),[k,C]=l.useState(null),L=$e(m,u)==="sol_micro",P=s.symbol===ve.symbol,E=l.useMemo(()=>{const I=a.length===0?t:t.filter(ee=>a.includes(ee.symbol)),z=I.length>0?I:t;return z.some(ee=>ee.symbol===ve.symbol)?z:[...z,ve]},[t,a]),T=Je(u,m),_=T<.01?.01:T,B=P?"Fees: calculated after deposit":`Fees: $${_.toFixed(2)} total`,$=P?"":Pr(u,m,T),le=P||m>0,J=Mr(L?Ae:s,u,r),q=J?m/J:null,R=q?_r(q,s.symbol):null;return l.useEffect(()=>{if(n==="multi-token")if(L&&s.symbol!=="SOL"){C(s);const I=t.find(z=>z.symbol==="SOL");I&&f(I)}else!L&&k&&s.symbol==="SOL"&&(f(k),C(null))},[L,s.symbol,n,t,f,k,s]),l.useEffect(()=>{h(m)},[m,h]),c?e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Send Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Send funds to your deposit address. We'll confirm automatically."}),n==="multi-token"&&!L&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[o.map(I=>{const z=t.find(ee=>ee.symbol===I),X=s.symbol===I;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${X?"is-active":""}`,onClick:()=>{z&&(b(!1),f(z))},disabled:!z,children:[z?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:z.logoUrl,alt:`${I} logo`}),I]},I)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${A?"is-active":""}`,onClick:()=>{b(!0),x(I=>I+1)},children:"Custom"})]}),A&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Vs,{tokens:E,selectedToken:s,onSelect:f,openSignal:S})})]}),!P&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(Ks,{config:u,valueUsd:m,onChange:y,maxUsd:Er})]}),P&&e.jsx("div",{className:"cedros-deposit-flow-note",children:"Send any token you want. We'll detect the deposit, swap it, and credit your balance automatically."}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:P?"Send any token to this address":`Send ${R??"--"} ${L?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:c}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:p,title:"Copy address",children:i?"✓":"📋"})]}),i&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[B,!P&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${v?"is-open":""}`,"data-tooltip":$,"aria-label":`Fee breakdown: ${$.replaceAll(`
2061
+ `,", ")}`,"aria-expanded":v,onClick:I=>{I.stopPropagation(),j(z=>!z)},onBlur:()=>j(!1),onKeyDown:I=>{I.key==="Escape"&&j(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after confirmation (typically ~30s)."})]})]}),d&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for your deposit. We'll notify you when it arrives."}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:g,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:w,disabled:!le,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function Na({token:s,depositAddress:t,copied:o,feeLine:a,onCopy:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:s.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),t&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[t.slice(0,6),"...",t.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:r,title:"Copy address",children:o?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${t}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:a})]})]})]})]})}function Ca({result:s,config:t,onNewDeposit:o}){const a=s.token??Ae,r=a.symbol==="SOL"&&t.solPriceUsd>0?s.amount*t.solPriceUsd:s.amount,n=Je(t,r),c=Math.max(r-n,0),i=n<.01?.01:n;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",s.amount.toLocaleString()," ",a.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[s.txSignature.slice(0,8),"...",s.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",r.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",i.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Credits Added"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-credit",children:["+$",c.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:o,children:"Make Another Deposit"})})]})}function Sa({error:s,onRetry:t,onCancel:o}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:s}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[o&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:t,children:"Try Again"})]})]})}const Ea="data:image/webp;base64,UklGRmIEAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IIIDAADwDwCdASo8ADwAPm0qkUWkIqGWDVeYQAbEtgBOmZMBu+H816ov3b8R8R2g2FXtxdyh5s3+A60v0APLi9ktgGB/LZjWNAXqgpE6jfW0NF+P4xEhH2L7M+26iGwrTjjcQegyCZqxs+ifvZANjWd279diqZNKUrgOTVtjJGtW4IVtRhMECd5aWVgAAP7nDv3UY/8f1l//xTP/FM/8NU8c9g//sC3+bX/1HZXsNsM57VKG2LVf1a0KdncWO8uPo/Oh79m9ZqjJZwXfPXuvwkK+WDOl6+N8C2Ux6no/V/zkoucKK/JZek7MR5sS8TknXB+6BuVDXou9Rx4aUea2q2IzvLvFIujjKsVYLMab7j9zo48fhgm9YOtjmWuS0WZ4c+6ta0mr3xF4fcdAIFf6oXRSlqovOX0HUiMV//hXwSX1cfP5cLj8c7OTyT/4ce4olJARV95GoY8oF+2uU0blGul3ItlG7c2Hl2/uC6s2WZc7Zukwojx6ed8t97bZ68N1uzCLzPlG7BuYS17F19e0wXnc6vEl3q7ft0K7OEl7r8mY6Kh+Nt/5V/Lp68mFBjLem1JjvC371+lKwez4KCdXwNo2Z04FqyzGpFutY6YQ/r5Tfu7Oi+oNfN0R/W+D4aj1nqHhlqYJzpx2NK4mj0gJIXmX8EArelSQI8mV4Ux9MRPwC2PuZhLTjQZv+Vl4p0D8bSB+Z0rek3hS6G1r80fW3cn767Pz/bXanjVmm34wt1nQPqdJObrZ7vv2NWcEuQKj9d+V6DzeDrq0CtGNcanEB5MY9agi1E6BprEScTdfPXjBeMnPbpD+QO6P7IW4UZ9etCCHtX++S/fl5Iz5RzUr10ojRMw//35C0yTjSEhbe884dPwor64n//KByjUFEGsCPAAXPJp1+O+SiKfUaODq6ncjKayTHXjoXgM7XP1z4sBhIKJZJRiM7vGC/+v/Sk8/jbgZLZDAVz1vLou93y7Yd8hxcWM/BesxgWgeKvl8fjE/Ud8tQKp4425hWh66lzzwxa4J3ctA4/E50wX/eoBOgq0B7+7S6FK4wvPHSNgfh+vwSWIJsJLt/3yjBeb41RRyMDMZqFQTZPEdFpXp48ExEyDayZ6objbjTHoS5WQDnDQpRyqMNKfvd41nhEPdb/hxpzXeTIjWmfHHCT+CQYWXDqLehCh1cRyeYOBwsSlSw5PiquAbsgAARVhJRroAAABFeGlmAABJSSoACAAAAAYAEgEDAAEAAAABAAAAGgEFAAEAAABWAAAAGwEFAAEAAABeAAAAKAEDAAEAAAACAAAAEwIDAAEAAAABAAAAaYcEAAEAAABmAAAAAAAAAEgAAAABAAAASAAAAAEAAAAGAACQBwAEAAAAMDIxMAGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgAwABAAAA//8AAAKgBAABAAAAPAAAAAOgBAABAAAAPAAAAAAAAAA=",Pa="data:image/webp;base64,UklGRtgCAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IPgBAABQCwCdASo8ADwAPm0wk0ekIqGhKBQMqIANiWkADPF3uV2D8VcQGk1mg+P36i9SLnZvYAQxszEWYzEwX1RVkqG/4BGbJgMSHqhKDFsjWsGfPPrvfef11goNmCDDlBJHVVD+8gAA/vu4q03kl+E7FpjtZ2gc8pQ619Hjv9NywoRZ6az43C1wcrRr/lWzJlJhLWMHN0MkVl1ueAf6Hn8StVzeUfMBXOKkgfe2msx7QWR5PnHW/5c6/35yrtWnrURc2q6UYlGin+v8C2dQqexkW6rX2EEijTI9eEQ46PWH3/59fM2AlMvvR2abaRk5XX7V1triQncRxvMfz5YmYDN+PY/ikcZUNaiFucKoUq5riv0eKCezuFNHecE11ojwJqWRSTWpalkz5autXp6vFS+FT1tWUsB/fs1CCOZxaA1vR1grOEaiuKe1RYm7e05psWtqbXLVmm1bA8Ly9PFkVdCbc6hR3UuBBsFGnVeGOUeMn2onnfvYhBMcM9YPxGdQkwZLXOk1VuQSTk01Shf3fZrFyRlFauftFdPYhKXwqrr+meav1P+KLKBVosqmHnFFfgExsQ/rOf3TSd+mOqQfJA+cF+HojNU7nmM3uDkoCBi+//Gqp+gPNNW8M4LFrol8rxE+7WsjqMgfwv1f+Nr25RtG1Wa/KkniRCAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",La="data:image/webp;base64,UklGRhYJAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSGICAAABkJz9nzon3/nNJGnBXRvBI0sDkR7slpRBaMDl5LByx7cEyBWHtWd+8/uiK/95uEfEBKBnFwRwk6Wjm89PW2Tj9OWNo7VxASQ4DDoIML9fbdLYpbFR21tykDAY8ZCLT9okqZrsD0uqJNl5sj6CIAPwDmdqRlNlz6o0vroE5/vlPObv0kyN/dVE3pmHd31xgt0P1MgBauTHLYjrg2DoClM0DtRi4kmA6ylgrMq2cuDaZm0CoQePyTqVhVTWJ+G7EozXqSyosj4K6cIhVBhZ2MjyMNy/BFcZWeDIE8g/PLaoLLRyF/4vgrlPTMVK/DQH+cPjGpUFV17/i6BEZeGVF+Dh4F/kUYGDR4nKDBPX4AX381Deh2C1Q8vB2F4CDqnMUrkPlPMpY+obLQ/j9+k1GjNNLB0z5hJ5fD0f5Y2XTLkkPn9Hy8X4vsGMW/xvt3JqvKflYnz3nCmXxJc3qLlEXj9mzOe4xJSLcW36Oy0P47cplKl5KMvAfj6HwFKbloOxswrBfWoOyvsQjzWmPErwcKhQi6d84eHgcSGPEgSA4Dq1aMpr8PjL3CemYiV+moP8AY9darGUW/D4u+CEsUiRVyH4p8NwmbE4kZUA9y8IRuvUoijr4xB06zFZpxZDWZ+ER/cBEzW2dXDaZnUMAb06hBOmaIOxmHhlCILenWDrI6MOIio/7kIc+uk85u+SSftkasZ78/AOffYOl17RqNqbqtFqZ+A8+i8BI+tPOiRNNdkfllSNZPvJRYEXDDQI3NJerUFjl8ZmbX8ekIBBuyCAjK8d3Xh52iBbp89vHl2ecIAEh54BVlA4IMwFAADQGwCdASo8ADwAPm0qkkYkIiGhLhtqqIANiWwAqSdaNo+beZFT37f+J9yXOd2J6HfQh5gH6edIDzAfst6vXoO9AD/Lf4DrAP2V9gDzY/+57F39p/3/7k+0RmjvYp/meic9ieyvJnZVfquF/a23ZOCHGT/sfDDjQ89zOL9Gewd+s3Vh/b32Gf28Ejb5ttLg9hoDiFb2tMW81eZU9Z1LHfdRSCsRMzHz0WT4BNgUakGf9oJtrGtVJFxHJfxAatIxnW1qjDi9i3DQtJp9pVNKlMoJEWdPKv3KaaFSlhd/aMGiir9CPcex5QAA+fpjxA6zfUamE3wS2zWwLVrt/fXA5+Wvx9j5SID0zuEHU2LisPUxvtRuIUwNrsUis8zy+IMpzft+ZSg+9gdx9e6+ZvPmtj4OByz5qo26J3rXhPy8LBXSpuPb+f+mP4CoTvYDhzQXh/SIGj8Ez1+W5MJ/Tkdw09wPCs3JuR3yoqO63FH/j81xW5Abr7tCdwfXwv3CXDtOcHwUqPCd1aiU2uT6XwgdnYqYygEXGKFx8nmaUvqSn9p8HmIA9dVTOoEnqYFjrNfWY034N2vjohd16cxnkP4PYvHkIOWa/FEUug7/qbJ/GFLPxNh6y9eQ//MzzXbcPwsT2chWXPBXNVF1S9dxv5NUuEueiw2kdebblQuvUSRLN+zx3VyT2lOzWBUqrzsTmeOlxjVcTA83H99r35O4X7WXNq7HExiWXxrdM/Ih4CvPJaEHPxUE/i6WIz6+VGq4RB3sBKl3P4M7/DLWAwCnwcpX228XezqQ4cS2tttWxLTc9cPd1ofek9qF9lpB8RvakdPnj2PruFA9W3iKbNdmgnb+mIpohHuUR73KdDDOHbyfAiOjPzzqomnIU3jcSt7LKOB/Op97sCk0yd18mVG3prs351B+xmCE2Zd3RFKL+mpMz5qcuAFAfRyodbggdgmFGkEGQ33VryYFl/upr31FGdI52sqzuxd7jZIsqCcznUH/gu+xaBw7wla49EmFNf+Ss+91i9Hsys0FS//Ktru1xWgkeEweX77y6Oot5tHQsDxgy0sAI85V7FmlpiiWXQdM12MGfCBfyRM+N23SjOdReeSILYCgsM3r33/54X+lfDVNj427MvbDFtKccqazlQ+iKqC//MvYwqyiJPL1ZbVoCEP774fKZA3D3qvsVPGlp9LPchpTs4mTJugt8qXl82RwXQCDNZXnbEois53E35hkRr+IJhndoRo1o2sZDoTgykbeOKiynPH03+BcUQ8zmxTmiVlHQym/LL3kRREnUlxs2zPPGb2E+Rpdib+LxOvFSmj9RfTZoYIJnrqNnBIXV2lt7xeZ0srf98JymJxrtr8lx69oSNZIReDddL+3iiUjh6lm7EcYuclqBaKp8q68geo7H1EvKy4nSRx5Q+uz4l/ypo2hVdwi9l+BHjZZmJ7lXkpNTRJ0gZpzquzN2vh/MZQALV6FZ6q4aofA9AJy1DVLdNjV8n6s9eFA5pazxwhLW4tgWMciGf5x6G7HqFPTL1ZL3l447zLGUkqAXjkeVaNmxZ2oNKIuTy6JDc0Z61Z2dgbsg6HwCX1/ux5sk82WsnNIO4CTnWKI1aCtQZaEsBf6hIl9n7VBsgZGIcPpqn7P4mbyf3EbfdfQ32qlawLuAxmDlwRsVsPkw7j4aKbvIBykNcsVXv0/X6UXXaAtw3feJnTwDak2qY6QpMLE9e7PJeuQQ8FXpqI5HoR82kd+DOwGH5F3OpuWsmEt8v7WQG8q1LMkg6vrl3I8047zMl1Yq0VwotbrsKJocsHgsbs/PGOO9v2s8U0Sju/71XRtG5skcy2msae3wixjlGR4i6ZfldMehQD1zf/FbWN9hnHfpq1Fh8+PSA9AzUi33qli8ixISbH+tw7CcumxvegMk88HMNZlVdnIEzIfyHrSdZ2S98yX2OYZw0+JyaBbQxI0fOr6KpuMD6FVGLrdN9dgOTgOPQgAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",Ta="data:image/webp;base64,UklGRo4EAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSA4CAAABkGXb2to2V9/v6D1Jmd5CQ5GXPYXAJMrtPOJMoMzMzDgIPYY5+vVds6T/m0BEOGzAtm1IBlR2d8kXUMyaADjeuHr9V7qj3E5/XrvaOA5AHCqzFgHTFz9tUTmEyq1PF6cBqVWDOLjkwS6VPsu8KqnaewRU7j5KIjipgFiQfCf1IGch8wMlv9QhcWk4nLlL9Z4l6b3y7hmUvGQkmF1nnrMC85zrc5CozDUQtwamisNSDCmxjL5jpqxMzfhutFCCY3+5110CaI9/jhVIcPg/DxiIB/x/eKgijLxkRobTyxFEw7zVm0NqcYg5LNAzKD3n4QbmyRVqWCiXJyD9uN7z0Ha9Dw4N5gzOnHU4IMJ7egt8HuYWasIJnlg46fkYgul9qgWU+9PA2Z7b2FngnR3e49Qm1QbKzVPNnltZ8wozK2S8et0SN34wt0LOnynVCsp02xI7tKSqqXYsV7ZtD/lpeaEfNyw/k9evWuKK7XfQ9ruP9/RW/s74t872N1bw2MY8n0Acmlb/KQ04AJ8t5PkeEbpDnbmR2/5392FiOfRFlCuTkIGsMh/aPBeGZFLBYuiM1IIUZLOD0NnMNBMWZdE/4bLo32MQ0wxcJnsvhcnerRhSLvPPhcj8s5DIsmtU6Tj1L1U6zvcEElfrVlHyqGy3epC4om5Vsg3OlO50UQ2V6Qa65LWf6TZ1J/11faBLlpgAVlA4IJgBAADwCQCdASo8ADwAPm0ylEckIyIhKAoAgA2JaQATzh4OcBkEByVmbl5z9gD9U/+J2APQgLaX4twLu19/UVxAWN1IKXE4cIqJBhoyQ0yDYn61m3zk6T7FMg0AAP78+EMvGgC8jLXmcbbmqvufKjG8Tv1M9Krl47vOW74O/Rapv2DgXbg9iK6PrRQG/9d9+rF/ESxzbszVFn3GThrMBmsklj/LPWDQ0pKzG7EyjQL6p6gfUwMze+wPhzJpn8tMqlUVgq6/QSUVcgG+ztsi73rA3vl3n4baeF1INsbuosTXtnsotVYuTii6rscx9OUTvevYcPNvcL9MPhyWeCQw0qynnGtzCIw+oFRN0+TN1mqXkFyk/rFBcH+FHiI6s9XX5EWCKn5vTRt/0RbS687PiXPFC5Zk/Gk4+538IYi+HZDjvlQQWOH/vddfYTerQ5QqWJt1YuaZNThQ2u+/DtXfZPRy1iWWLR9SKFFtlGrqBKWF5nPRPWWMNA3OssvUtvCNBLBA4cn1whzy+SpbgLvnaepxiykjKsU/MhzgAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Ma="data:image/webp;base64,UklGRqwEAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSL8BAAABkGvbtmlLc5997yvbmW19gBnbDm2kjF5UmW3bthXZVZFdZ+81r+87Z1XlEaHIbSNlMstwos4XUBSTLAFQo/u01Zdf/yLDDze3zB/YwADJEoOoJAKg7oTdH4SF+XxiZlMgSESzwAJdVn2iUJzzOUMiLhQKf+/va2FtBLMBuu1zpHcsincUXhtoTKLsCTVX/KF3wrLhPLm/OWzZtjQWfZ7RhYyAC/lxMowpSzJYJAyFkZDQc21FBMUT7BqGjpHxf3m+XlEPUHE/f3vGgPzmw4awRUaTexkyJhwfNShctVgZXyJDXq4CUyjNy6Y4fVOBIkAPR2GcOE7Jm2NQ/RE9YzXht3a5VYvlOX0xF0fy+tp/ozBuQg6DzZYb6Bi7ed4rB5Mp/1Co4cNhLUo1StLxDIDqrynUoRswiF6nFnIxsDpnZ5WBW0GFZ1qZ8HfLDk5txHHsGDpSa6B0cXZEa+DsTr1M+P4qPdXwjynU4+1/a7oN3Sm6G+meSd27oHsHde++7puj+tYpv7G6b7vun6L7l6n+oZp/t7JmUNUqqhpJV5upakJVLaqqgVW1t6rmV401NGMc1djqH4rpIseSfyPFkgAAVlA4IAQCAABQDACdASo8ADwAPm0yk0akIyGhJgzogA2JaQAThroHvLxu+aPf5G2BYxv+B6XHzx6GPon/o+qz/tOAA/TM82gR0vnExWoiQRM36jlg2UIvwCSqySErzuguz9EP2x/7hsNazr91aIworWI7AAD+/TZ+6Ipl444OdT+2wU0Ov+T8oJuVP/vUbT/w1Jsv6Awnl6rvF/xetfOPt3gTQZZi0Y/AOx563J7CJkqTR/fc/n34zyeKzR80fhfv4ef+Hjhz/CX5aQo+58zg/FdE+7bLoophGfG0szI513EH+q+Gc73H1PFdJYf7CF8v5dhr3tMwEVX5Ji2ZxejK8xrf/E6nVXqlA4DrYNRP09InHc+fEqO/fH8xr+rMf4y1F9TOnwVffZblLoTP6lot0m/sh7sTiDQr0mIA8TiHoOffGDG6KzV+B3239udfhzD740gkRi/m53abX0Ku3vAgadgFFqL0vk8M/4aI+cI+0fbLW17mWGeMu21wSRRQiv5iNgGKR3vEGXAItcLDft1uUzWAfbe1X3zK/ymT7bA/76PB6UUknm+Y5MM4osurUXU/k7P38pN/3slnGfpFzjl4c3USY4mH9ZCJYUuC/kGEnq/yRPalPdODNFvW6s8MiQeQejYNRY0LsJ0WXkK8vXiDmihCivYAOPoSovesL7on+WAArDNM/BcQSQvCYABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",_a="data:image/webp;base64,UklGRnIIAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSK4BAAABkHPbtrE9+z73/RTbqWw7Lf+BbbNKbTudbZe2qy+VbVv3PmeHj05G6ohg4LaRounNMtN1voB42ABA5R7TNlx5+O7du9e3Tiwb0b4EgFyAOCQM1Z16+DWFUZC7m3uVB2zKQGBhe+77RGHonJffCL1zQuHDxQ1hrEmTatDjHIXOC2MgzpNf1tVJkWgsGhyihI7JIE74aUYp2ITFAoz9QO+ZAs7zanvkEilKbIkMJS5ANwoJmrCodYVOmBqh5zIEJjZc9xods4A4rrPGxGitrJSU71yNyH4Myl7JTEl+5zzYSH9nlkrxHBzxWUzLVEnhh+YI/gq3+UphpvA8m/s7/wg9M4bjFNg/0vplrxQ+rQEDg/xihmT23jxYJZ8UPq8OA5z77Wt405FDR4poSMjiAJhPRxUIu8D+UVonOhfNPEVHPM9juFacwo+1V6kJQ3Y9Sa8ljhPuUvRk4UdNWU9ST3b9n0W3iG5DumdS9y7o3kHVu6/75ii/dbpvrO7brvtPUf2X6f5DVf/dmpxBmauociRVbqbKCXW5qCoHVuXempxf1dZQtXFUbat/yKZTtSUBVlA4INwFAABwGgCdASo8ADwAPm0qj0WkIqEZ+zYAQAbEtgBOmZoZF+E8zGoP3X8VbcdLvma8t+jH0E+YB+ofSA8wH7VdQv0AP75/iOsG9ADy3/Y5/b/91fgI/Y7MOesb0e/q+TUR1vt7VO6mwG0imO70GM5/0P7BX6qelv7EP209lz9oDRea09ZR+SjhX7sBu/ZS7tG917rPgI3Q7XsB7luy2hAg/95C2Z1L362OH1oFziDY/K5gWoSytSAtiKvA/jW1MehBzdLzJfszPPBvGa15IYwIVRTjO2Hz5ZS9HjLMehwAAP64SgjD3qeg6NRe/Ok+iFhrG3pgglCfbam3yBaDUH36sUiQx0PB1ZZyOHq0ky+f97h6tJMvo0p9LkfXecWOFJ8J5G7yRPuL4tzGLT09QulTJw42xp2hd+lMgIa51XoHx/iftn8B2D3k92H5jOQr+uIXFHHK5FpcTG+qGEF+np0LiQa+vdW7/+ZzOLVRf7jR5X3ANPt93Ng92DW7NflVr6kMr88O/v2ZNb0vtgao2Am/R3CDKiNq89f86CT6r2L2g1oTui7H3E1yhSPQpEOz01I3fhfiMMv4weqKuoedxn/xLg5uzHa6Gte4C/dQYkG3ZFSy4CXQtRjftBrjX/Oj+HpSUPDsv0wPW+ml5NbBKDCj2f3SD8TVMf2ZfHrOkR602RVk2UmKC+H0Y9iK6k98vsgPINtz0II8X7Mj2nJkTC6IMLuQ8dNTUq9VXOnhXrdhNZoaH94ePo6baBl3hTGFAnD3/b+gR/vtbqV7wktuX6fpnjeTBe/Drp6z3neeANj/aX4CsU9w67nwYOjZhueCjxaDKUnNjLPjI1e0BoTbcOzOQ0wHJHZJ+Pt608StBu4HiJ8NjH46fnvXL3yiMoSvkAuwCE1AakA+eU1u3unyjl1/MnZQmbp8fzfsfrFesehLPcIkYdCiZ+52QbmINNTjEsvjuBuZRubBE+Laihppsxoo4efGIo0xkw0etu1+yzvkqp88w3pBq0mRl13gnnc+2zl6SmhwgmNFbz+F8qAqmdfJL8iaNSGEWlPlpczDDe62GBZMlBhQmq/XCn/1b+VazHvJXkoIFDF+wktMg+rKfLyfTlXdK0cs+Kn8h+rjMakkf3WLo1TftMLn+O+x/Gat+BGstJrM1xvCSSnHQY+NV4B4gRqyZ55gRNnqN/0lWrATOcHUaGXpkTIM/yxFjxcePcSFo+t2aJ5lShtVukETzRxaIXgRkpROeWQHWpTHOaexmXOzF0b833qJSoXMk2zB/uMrgDzKd7d3ohUz8Ra08WYKlAuMQD08bF4+jUepEspqPLoYLQ73TfmL+1LwKxyTV3gEu6WnxBPWPLnYIGYN9U47ZNlB+NgHgYtKTyii6060RAG+wN32WUVFxCZw0HMHnHFgwxD34L/anlpS7mOrjKgyuGYhFC7iHqTQHuoAO1ekBHV+rndnbETKfa1F7LxNLYq+dmJyytmQrJUCGjelorI1m/TMQNiFVrY4FCI1Gl2W1JsZsw9zA+Bh3JmjkC0H5/0JV6JotNMatJIZ4v5PqwJe3r8xd+FNS3ynccdu+xtVdc27qwVdoomciZD5oXYey9KAFSAKO594sBKZNWUJTLXnt0BJbdF8FkQYvg3DQajYY2p+ixd5Ag7o92gw0pVVDDOP+WQxiEmKqgWJyTBsnsBk2Bxi2Unsv8S/4PmE8Hy/vy+Mij+aTAKZvg716IHfHX0/JMeFfmAnsZ39Q0qkfdPtq6+CxbGZ7wKDsK/8l/MVGuyd6faJFt5wyoOXuNrr3JC9EoBmjcOzkVw/6RNP49poZ1xzsX3q7B4HGfI/XSfRQq3HeZ2j12d0E3gCAube4oExaT1sx/v8F+f61QOsGdSaqM2im6qOGkSRkrRQ7L8hvS8vEYJeVkAbFvX5ov7e/egYYNToMHj651c5/rCVYtB9Ned6GvGN8R0x3t7+lsf8+ofhHRzpyvwxd6c5pREZVOKnXzplhJ61mki4JmAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Ra="data:image/svg+xml,%3csvg%20width='88'%20height='88'%20viewBox='0%200%2088%2088'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='88'%20height='88'%20fill='url(%23paint0_linear_170_79)'/%3e%3crect%20x='25.6665'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='51.3335'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='29.3335'%20y='40.3333'%20width='29.3333'%20height='7.33333'%20fill='white'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_170_79'%20x1='-75.3077'%20y1='-55'%20x2='146.302'%20y2='148.167'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF00FF'/%3e%3cstop%20offset='0.531673'%20stop-color='%237A84FF'/%3e%3cstop%20offset='1'%20stop-color='%2305FAFF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",Ba="data:image/webp;base64,UklGRh4HAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSNwBAAABkFxbexpJnyR3z8y+ajXMkAnjnnOgbUUxEAHjkpldWQwzFUn6v3PGVNI/AUQEA7dt49gN3PXavTlfQDeNAeyqg4PL5buRyOhteXlwcJWtHU8qzUIBs+30g7/s4N8Hp7cZFAtpDc7Bbr8xplB8iFJBYvBC4fjGdgvnElqdwc6XFPGRnQxehC93wjgzbxRYf1UYA+dkiJSrG1DMV6zDoW+MkQmMkd8Owdl5AsvOM3gm0geeXwY7R/Tu0EcmM3re6cF2Rr/kTJiBMmPZh+2q/wtm4ozD9qrB0tucMhunvL0Upg1n6JmRnmda4HCckVkZeRyuMWjjF0peCD9vhK3jAgMzM/BCDQ576225m/bCwcA+qzS/PLUwDrsr1ZDdcAa3KtWQWzDYPKZoQDjeDJyoVEdOAPf0cA/Lf1F0IPy1fG8VWmXvgF4LnoOLDFoIvPiaUQuRr99pNr8dUZEj0YToQnfjreaQd7oL6T6Tuu+C7juo++6rfnOUv3W631jNb7v+P8U+1ZDAZxZG9R+q/e+GxcbPuRcRftkIq+pVVD2Srjdr94TDnJ6w7MGqedFhH1bVA6t67zk9/3ctzw+YAhvSc431KExyjjNHQ2zLcTRzq/8op0vKJd+OREbvUnJJAFZQOCBaBAAA8BUAnQEqPAA8AD5tMJRHJCMiISgb+1CADYlsAJ0zIUCfxfmY2f+0b2AbztDnPeKX0qPMp+wHrDehz0AP7J/o+tP9ADy3f23+C79yPYA/aqK9mONrQbuszbsEyALJNTfg+Z6NjG2v+ETCuvlr1q6QUqEiAMUndG/WwfnjJIOTfOBS4W1w0HjOJa1XQ2K33n2b07EOjOBapwKzyoA2erTBTnEKlFjllBy68GBjZ+UKnlzN/f5ibbb4gAD+i9OsnW0xUnmTpyhVasIKzTu0BsXnfBm4rHJqGMFJBUgTESDXEPcNjAeaHP8ck9qdNBH4L/h53tXgHeZttc7c4lwTa6U4Lziz8qUoy8ce0IMc5TFElawGj16tME0GzSSbUqgH7/tYA6huPsWM2z3GjP8b9y7paRbINxwYRtuE90I6QVsNrEkbhL1YfwxRXnuobOfSe3KFVamrvsOqwTCMqlNfjsR3pyoiZ+lYt3+AH6x4ZVNltbYI5KiVhgCu1isooK324ldloH3zhlefYKEwTCYfNjbeH5UiL7JSev+t/C+ftc3TkAHcsvrLCU6n5pYYY2Yr1kRq+r6XVzI6iXuA/TqwMk6xq1PmdzHOwKavncLjWJrk0uU/5E5WKqXM0tgl5s3pduHjb5aiAt0ikEisMyYwnIhDiSemPRdGON4RlwSb3OEpZjhuZqoyen4Sw/fULewt3hAZizeiPZx1o9LS3M/4r3v/M6/o5925VJcmxAf/yjsyjCz0mV+6NuIeWp8shrFaIGgeduVJoZ0Kys1WjSLuFg9QvF5LlkOZ2k7WrzSu4ucsUOS/X4wnQvB0RCnR1PCsU4NDdLfxvQITUgGIuVTJ7LR73PHzZam/Z21oy3euiU55ffITekwjR4SgVoPvhxbdBSyVePf/twm62pSK9IfgPGN+ttubhQub1ooVZymdQCrS3goEs6dlnl/6TVfkgxFyBfAORkZafeu/Va2vIgUBNUQd48W8oPiMFjx+SAKx1qm2IwCLnuhJGf9M4nCzu7oo43f+nBeT07IjB+FpFKRGFNvlpLEXhPclSgFkqeU1W2eNqW2zShCWkQkgfE1HAoNX3z+CQcRQJq+HkC2nSjFdFYT8UNYNS6lYcyVWzEnOos1qpsNRxnLqY2Dl5CCT3Yeg/qT8chfF9ZadFvzNTEIDlARoN//7IU23MtuLdpsAjsiGfBHuR7y4lemYPdD/9Cuff9Qn/r/xlhmB5x2Y9Z1yME3aANAb5+u3lYz01zUlWwakKVmv9fhaeu/YzQ7BXLlcb+cbaIF5t/COmObnt20zaTfjad542f7p7f2Xea134nvyPYS+EAgjM+GufHvl9tXCrrRbH0pn7kH2XEGx9VbO4mY54+QZa5kPr0j3AOEtKd7SJWjlg5TQfgIuB6KoLGainSwF+pPdiCmzEzAOa1eFwn//2VdDMeq42/bKH8U4orewhLh60ci/S0BRBuItNMc+v1+vxl0YyS5it4AAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",Da="data:image/svg+xml,%3csvg%20width='868'%20height='868'%20viewBox='0%200%20868%20868'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='434'%20cy='434'%20r='434'%20fill='%231B262D'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M234.563%20184H640.697C650.387%20184%20659.339%20189.164%20664.172%20197.542L782.495%20402.657C788.631%20413.294%20786.808%20426.72%20778.056%20435.346L452.368%20756.327C441.818%20766.724%20424.846%20766.724%20414.296%20756.327L89.0484%20435.78C80.0927%20426.954%2078.4157%20413.136%2085.0013%20402.433L211.48%20196.884C216.405%20188.879%20225.146%20184%20234.563%20184ZM588.257%20275.577V333.129H472.567V373.032C553.82%20377.296%20614.782%20394.81%20615.234%20415.802L615.231%20459.563C614.779%20480.556%20553.82%20498.069%20472.567%20502.333V600.259H395.746V502.333C314.492%20498.069%20253.531%20480.555%20253.078%20459.563L253.081%20415.802C253.533%20394.81%20314.492%20377.296%20395.746%20373.032V333.129H280.055V275.577H588.257ZM434.156%20472.268C520.868%20472.268%20593.345%20457.459%20611.082%20437.683C596.041%20420.912%20541.636%20407.713%20472.567%20404.089V445.867C460.187%20446.516%20447.336%20446.858%20434.156%20446.858C420.976%20446.858%20408.125%20446.516%20395.746%20445.867V404.089C326.676%20407.713%20272.271%20420.912%20257.23%20437.683C274.968%20457.459%20347.444%20472.268%20434.156%20472.268Z'%20fill='%23009393'/%3e%3c/svg%3e",Rr=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Hs},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:_a},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Da},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:La},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:Ba},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Ma},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Ra},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Pa},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Ea},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Ta}];function Gs(){const s=M.useCedrosLoginOptional(),[t,o]=l.useState(!1),[a,r]=l.useState(null),n=l.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=l.useCallback(()=>{r(null)},[]),i=l.useCallback(async()=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get("/credits/balance/sol")}catch(p){const f=M.handleApiError(p,"Failed to fetch credit balance");throw r(f.message),f}finally{o(!1)}},[n]),d=l.useCallback(async()=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{return(await n.get("/credits/balance")).balances}catch(p){const f=M.handleApiError(p,"Failed to fetch credit balances");throw r(f.message),f}finally{o(!1)}},[n]),u=l.useCallback(async p=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{const f=new URLSearchParams;p?.currency&&f.set("currency",p.currency),p?.limit&&f.set("limit",p.limit.toString()),p?.offset&&f.set("offset",p.offset.toString());const h=f.toString(),w=h?`/credits/history?${h}`:"/credits/history";return await n.get(w)}catch(f){const h=M.handleApiError(f,"Failed to fetch transaction history");throw r(h.message),h}finally{o(!1)}},[n]);return{getBalance:i,getAllBalances:d,getHistory:u,isLoading:t,error:a,clearError:c}}function Ia({showAllCurrencies:s=!1,refreshInterval:t=0,compact:o=!1,className:a="",onLoad:r}){const{getBalance:n,getAllBalances:c,isLoading:i,error:d,clearError:u}=Gs(),[p,f]=l.useState([]),[h,w]=l.useState(null),g=l.useCallback(async()=>{try{if(s){const m=await c();f(m),r?.(m)}else{const m=await n();f([m]),r?.([m])}w(null)}catch(m){w(m instanceof Error?m.message:"Failed to load balance")}},[s,n,c,r]);if(l.useEffect(()=>{g()},[g]),l.useEffect(()=>{if(t<=0)return;const m=setInterval(g,t);return()=>clearInterval(m)},[t,g]),h||d)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${a}`,children:[e.jsx("p",{className:"cedros-credit-error",children:h||d}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),w(null),g()},children:"Retry"})]});if(i&&p.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${a}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(o){const m=p[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${a}`,children:[m?e.jsx("span",{className:"cedros-credit-value",title:`${m.balanceLamports} lamports`,children:m.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),i&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${a}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:g,disabled:i,title:"Refresh balance",children:i?"...":"↻"})]}),p.length===0?e.jsxs("div",{className:"cedros-credit-empty",children:[e.jsx("p",{className:"cedros-credit-empty-message",children:"No credit balance yet."}),e.jsx("p",{className:"cedros-credit-empty-hint",children:"Make a deposit to get started."})]}):e.jsx("div",{className:"cedros-credit-list",children:p.map(m=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:m.currency}),e.jsx("span",{className:"cedros-credit-amount",children:m.display})]},m.currency))})]})}const Es=[{key:"all",label:"All",txTypes:null},{key:"deposits",label:"Deposits",txTypes:["deposit"]},{key:"usage",label:"Usage",txTypes:["spend","usage","charge"]},{key:"adjustments",label:"Adjustments",txTypes:["refund","adjustment","bonus","credit"]}];function Fa(s,t){const o=s<0,a=Math.abs(s),r=t.toUpperCase()==="SOL",c=a/Math.pow(10,r?9:6),i=o?"-":"+";return r?`${i}${c.toFixed(4)} SOL`:`${i}$${c.toFixed(2)}`}function Ua(s){const t=new Date(s),o=new Date,a=o.getTime()-t.getTime(),r=Math.floor(a/(1e3*60*60*24));if(r===0){const n=Math.floor(a/36e5);if(n===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${n}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==o.getFullYear()?"numeric":void 0})}function Wa(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function Oa(s,t){const o=(s||"").toLowerCase();return o==="deposit"?"↓":o==="spend"||o==="usage"||o==="charge"?"↑":o==="refund"?"←":o==="bonus"||o==="credit"?"★":t?"+":"−"}function qa({defaultTab:s="all",pageSize:t=10,refreshInterval:o=0,className:a="",onLoad:r,onTransactionClick:n}){const{getHistory:c,isLoading:i,error:d,clearError:u}=Gs(),[p,f]=l.useState(s),[h,w]=l.useState([]),[g,m]=l.useState(0),[y,A]=l.useState(0),[b,v]=l.useState(null),j=Es.find(E=>E.key===p)||Es[0],S=l.useMemo(()=>j.txTypes===null?h:h.filter(E=>{const T=E.txType||"";return j.txTypes.some(_=>T.toLowerCase().includes(_.toLowerCase()))}),[h,j.txTypes]),x=l.useCallback(async()=>{try{const E=await c({limit:t*3,offset:y});w(E.transactions),m(E.total),r?.(E),v(null)}catch(E){v(E instanceof Error?E.message:"Failed to load history")}},[t,y,c,r]);l.useEffect(()=>{A(0)},[p]),l.useEffect(()=>{x()},[x]),l.useEffect(()=>{if(o<=0)return;const E=setInterval(x,o);return()=>clearInterval(E)},[o,x]);const k=Math.ceil(g/t),C=Math.floor(y/t)+1,N=E=>{const T=(E-1)*t;A(Math.max(0,Math.min(T,Math.max(0,g-1))))},L=E=>{f(E)};if(b||d)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${a}`,children:[e.jsx("p",{className:"cedros-tx-error",children:b||d}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),v(null),x()},children:"Retry"})]});if(i&&h.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${a}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=E=>E.txTypes===null?h.length:h.filter(T=>{const _=T.txType||"";return E.txTypes.some(B=>_.toLowerCase().includes(B.toLowerCase()))}).length;return e.jsxs("div",{className:`cedros-tx-history ${a}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Transaction History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:x,disabled:i,title:"Refresh",children:i?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:Es.map(E=>{const T=P(E),_=p===E.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${_?"cedros-tx-tab-active":""}`,onClick:()=>L(E.key),children:[E.label,T>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:T})]},E.key)})}),S.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:p==="all"?"No transactions yet.":`No ${j.label.toLowerCase()} found.`}),p==="all"&&e.jsx("p",{className:"cedros-tx-empty-hint",children:"Make a deposit to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:S.slice(0,t).map(E=>{const T=E.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${T?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>n?.(E),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.preventDefault(),n?.(E))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${T?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:Oa(E.txType,T)}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsx("span",{className:"cedros-tx-type",children:Wa(E.txType)}),e.jsx("span",{className:`cedros-tx-amount ${T?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:Fa(E.amountLamports,E.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:E.description}),e.jsx("span",{className:"cedros-tx-date",children:Ua(E.createdAt)})]})]})]},E.id)})}),k>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>N(C-1),disabled:C<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",C," of ",k]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>N(C+1),disabled:C>=k,children:"Next"})]})]})]})}function Ys(){const s=M.useCedrosLoginOptional(),[t,o]=l.useState(!1),[a,r]=l.useState(null),[n,c]=l.useState(null),i=l.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=l.useCallback(()=>{r(null)},[]),u=l.useCallback(async()=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await i.get("/wallet/withdraw/balances")}catch(w){const g=M.handleApiError(w,"Failed to fetch wallet balances");throw r(g.message),g}},[i]),p=l.useCallback(async(w,g)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");o(!0),r(null);try{const m=await i.post("/wallet/withdraw/sol",{destination:w,amount_lamports:g});return c(m),m}catch(m){const y=M.handleApiError(m,"Failed to withdraw SOL");throw r(y.message),y}finally{o(!1)}},[i]),f=l.useCallback(async(w,g,m)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");o(!0),r(null);try{const y=await i.post("/wallet/withdraw/spl",{destination:w,token_mint:g,amount:m});return c(y),y}catch(y){const A=M.handleApiError(y,"Failed to withdraw token");throw r(A.message),A}finally{o(!1)}},[i]),h=l.useCallback(async(w=10,g=0)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const m=Math.max(1,Math.min(100,Math.trunc(w))),y=Math.max(0,Math.trunc(g)),A=new URLSearchParams({limit:String(m),offset:String(y)});return await i.get(`/wallet/withdraw/history?${A}`)}catch(m){const y=M.handleApiError(m,"Failed to fetch withdrawal history");throw r(y.message),y}},[i]);return{withdrawSol:p,withdrawSpl:f,getBalances:u,getHistory:h,isSubmitting:t,error:a,clearError:d,lastResult:n}}const Ps="So11111111111111111111111111111111111111112",za={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Va(s){return s.length<32||s.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(s)}function Ls(s){return s.length<=16?s:`${s.slice(0,6)}...${s.slice(-6)}`}function Fe(s,t){return(Number(s)/Math.pow(10,t)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(t,6)})}function Ha({onSuccess:s,onError:t,onCancel:o,className:a=""}){const r=M.useCedrosLoginOptional(),{withdrawSol:n,withdrawSpl:c,getBalances:i,isSubmitting:d,error:u,clearError:p}=Ys(),[f,h]=l.useState("loading"),[w,g]=l.useState([]),[m,y]=l.useState(null),[A,b]=l.useState(""),[v,j]=l.useState(""),[S,x]=l.useState(null),[k,C]=l.useState(null),[N,L]=l.useState(null),P=r?.config.solana?.network??"mainnet-beta",E=l.useMemo(()=>{if(!S?.txSignature)return"";const R=`https://explorer.solana.com/tx/${S.txSignature}`;return P==="mainnet-beta"?R:`${R}?cluster=${encodeURIComponent(P)}`},[S,P]),T=l.useMemo(()=>{if(!m||!v)return"0";const R=parseFloat(v);return isNaN(R)||R<=0?"0":Math.floor(R*Math.pow(10,m.decimals)).toString()},[v,m]);l.useEffect(()=>{if(!r)return;let R=!1;return(async()=>{try{const I=await i();if(R)return;const z=[];I.solLamports>0&&z.push({symbol:"SOL",mint:Ps,decimals:9,rawBalance:String(I.solLamports),displayBalance:Fe(String(I.solLamports),9)});for(const X of I.tokens){const ee=za[X.mint]??Ls(X.mint);z.push({symbol:ee,mint:X.mint,decimals:X.decimals,rawBalance:X.amount,displayBalance:Fe(X.amount,X.decimals)})}g(z),h((z.length>0,"select"))}catch{R||(L("Failed to load wallet balances"),h("select"))}})(),()=>{R=!0}},[r,i]);const _=l.useCallback(R=>{y(R),h("form"),p(),C(null),j("")},[p]),B=l.useCallback(()=>{if(!m)return;const R=Number(m.rawBalance)/Math.pow(10,m.decimals);m.mint===Ps?j(String(Math.max(0,R-.01))):j(String(R))},[m]),$=l.useCallback(()=>{if(C(null),!A.trim()){C("Destination address is required");return}if(!Va(A.trim())){C("Invalid Solana address");return}if(!v||parseFloat(v)<=0||isNaN(parseFloat(v))){C("Please enter a valid amount");return}if(T==="0"){C("Amount is too small");return}h("confirm")},[A,v,T]),le=l.useCallback(async()=>{if(m){h("processing"),p();try{let R;m.mint===Ps?R=await n(A.trim(),Number(T)):R=await c(A.trim(),m.mint,T),x(R),h("success"),s?.(R)}catch(R){h("confirm"),t?.(R instanceof Error?R:new Error(String(R)))}}},[m,A,T,n,c,p,s,t]),J=l.useCallback(()=>{p(),C(null),f==="form"?(h("select"),y(null),j(""),b("")):f==="confirm"&&h("form")},[f,p]),q=l.useCallback(()=>{h("select"),y(null),b(""),j(""),x(null),p(),C(null)},[p]);return r?e.jsxs("div",{className:`cedros-withdrawal ${a}`,children:[f==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(V.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),f==="select"&&e.jsxs("div",{className:"cedros-withdrawal-select",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdraw"}),e.jsx("p",{className:"cedros-withdrawal-subtitle",children:"Select a token to withdraw"})]}),N&&e.jsx(Y.ErrorMessage,{error:N}),w.length===0&&!N&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:w.map(R=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>_(R),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:R.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:R.displayBalance})]},R.mint))}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:o,children:"Cancel"})]}),f==="form"&&m&&e.jsxs("div",{className:"cedros-withdrawal-form",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:J,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",m.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",m.displayBalance," ",m.symbol]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsx("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-destination",children:"Destination Address"}),e.jsx("input",{id:"cedros-withdrawal-destination",type:"text",className:"cedros-input",placeholder:"Solana address (base58)",value:A,onChange:R=>b(R.target.value),autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsxs("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-amount",children:["Amount (",m.symbol,")"]}),e.jsxs("div",{className:"cedros-withdrawal-amount-row",children:[e.jsx("input",{id:"cedros-withdrawal-amount",type:"number",className:"cedros-input",placeholder:"0.00",value:v,onChange:R=>j(R.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:B,children:"Max"})]})]}),(k||u)&&e.jsx(Y.ErrorMessage,{error:k||u||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:$,children:"Review Withdrawal"})]}),f==="confirm"&&m&&e.jsxs("div",{className:"cedros-withdrawal-confirm",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:J,disabled:d,children:"Back"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Confirm Withdrawal"})]}),e.jsxs("div",{className:"cedros-withdrawal-summary",children:[e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Token"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:m.symbol})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Amount"}),e.jsxs("span",{className:"cedros-withdrawal-summary-value",children:[Fe(T,m.decimals)," ",m.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Destination"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",title:A,children:Ls(A)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),u&&e.jsx(Y.ErrorMessage,{error:u}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:J,disabled:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:le,disabled:d,children:d?"Sending...":"Confirm & Send"})]})]}),f==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(V.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",m?.symbol,"..."]})]}),f==="success"&&S&&e.jsxs("div",{className:"cedros-withdrawal-success",children:[e.jsx("div",{className:"cedros-withdrawal-success-icon",children:"✓"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdrawal Complete"}),e.jsxs("p",{className:"cedros-withdrawal-subtitle",children:[Fe(T,m?.decimals??9)," ",m?.symbol," ","sent"]}),e.jsxs("div",{className:"cedros-withdrawal-tx",children:[e.jsx("span",{className:"cedros-withdrawal-tx-label",children:"Transaction"}),e.jsx("a",{className:"cedros-withdrawal-tx-link",href:E,target:"_blank",rel:"noreferrer",children:Ls(S.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:q,children:"Done"})]})]}):null}function Qa(s,t){if(s==="sol")return"SOL";if(!t)return"SPL";const o=Rr.find(a=>a.mint===t);return o?o.symbol:`${t.slice(0,4)}...${t.slice(-4)}`}function Ka(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function Ga(s){const t=new Date(s),o=new Date,a=o.getTime()-t.getTime(),r=Math.floor(a/(1e3*60*60*24));if(r===0){const n=Math.floor(a/36e5);if(n===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${n}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==o.getFullYear()?"numeric":void 0})}function Ya({pageSize:s=10,className:t="",onTransactionClick:o,explorerUrl:a="https://solscan.io"}){const{getHistory:r,error:n,clearError:c}=Ys(),[i,d]=l.useState([]),[u,p]=l.useState(0),[f,h]=l.useState(0),[w,g]=l.useState(!1),[m,y]=l.useState(null),A=l.useCallback(async()=>{g(!0);try{const S=await r(s,f);d(S.items),p(S.total),y(null)}catch(S){y(S instanceof Error?S.message:"Failed to load withdrawal history")}finally{g(!1)}},[s,f,r]);l.useEffect(()=>{A()},[A]);const b=Math.ceil(u/s),v=Math.floor(f/s)+1,j=S=>{const x=(S-1)*s;h(Math.max(0,Math.min(x,Math.max(0,u-1))))};return m||n?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${t}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:m||n}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{c(),y(null),A()},children:"Retry"})]}):w&&i.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${t}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${t}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:A,disabled:w,title:"Refresh",children:w?"...":"↻"})]}),i.length===0?e.jsx("div",{className:"cedros-tx-empty",children:e.jsx("p",{className:"cedros-tx-empty-message",children:"No withdrawal history yet."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:i.map(S=>{const x=Qa(S.tokenType,S.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>o?.(S),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(S))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsx("div",{className:"cedros-tx-icon cedros-tx-icon-negative",children:"↑"}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsxs("span",{className:"cedros-tx-type",children:[x," Withdrawal"]}),e.jsxs("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:[S.amount," ",x==="SOL"?"lamports":""]})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${a}/account/${S.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:k=>k.stopPropagation(),children:Ka(S.destination)})," · ",e.jsx("a",{href:`${a}/tx/${S.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:k=>k.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:Ga(S.createdAt)})]})]})]},S.id)})}),b>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>j(v-1),disabled:v<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",v," of ",b]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>j(v+1),disabled:v>=b,children:"Next"})]})]})]})}function $a({brandLogo:s,brandName:t,title:o="Welcome back",subtitle:a="Login with your Apple or Google account",termsText:r,onSuccess:n,defaultTab:c="login",children:i,className:d=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${d}`,children:[(s||t)&&e.jsxs("div",{className:"cedros-brand-header",children:[s,t&&e.jsx("span",{className:"cedros-brand-name",children:t})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:o}),a&&e.jsx("p",{className:"cedros-full-page-subtitle",children:a})]}),i??e.jsx(Ye,{defaultTab:c,onSuccess:n})]}),r&&e.jsx("p",{className:"cedros-terms-footer",children:r})]})}function Ja({brandName:s="Your Brand",brandLogo:t,tagline:o="Your tagline goes here. Make it compelling.",title:a="Sign in",subtitle:r="Enter your credentials to access your account",onSuccess:n,defaultTab:c="login",children:i,className:d=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${d}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[t??e.jsx("div",{className:"cedros-split-page-logo",children:s.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:s}),o&&e.jsx("p",{className:"cedros-split-page-tagline",children:o})]})}),e.jsx("div",{className:"cedros-split-page-form",children:e.jsxs("div",{className:"cedros-split-page-form-content",children:[e.jsx("h2",{className:"cedros-split-page-title",children:a}),r&&e.jsx("p",{className:"cedros-split-page-subtitle",children:r}),i??e.jsx(Ye,{defaultTab:c,onSuccess:n})]})})]})}class Xa{client;constructor(t,o,a,r){this.client=new M.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(t){throw M.handleApiError(t,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(t){throw M.handleApiError(t,"Failed to revoke sessions")}}}function Za(){const{config:s,authState:t,_internal:o}=M.useCedrosLogin(),[a,r]=l.useState([]),[n,c]=l.useState(!1),[i,d]=l.useState(null),u=l.useMemo(()=>new Xa(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),p=l.useCallback(async()=>{if(t!=="authenticated"){r([]);return}c(!0),d(null);try{const w=await u.listSessions();r(w)}catch(w){d(w)}finally{c(!1)}},[t,u]);l.useEffect(()=>{t==="authenticated"?p():r([])},[t,p]);const f=l.useCallback(async()=>{c(!0),d(null);try{const w=await u.revokeAllSessions();return await p(),w}catch(w){throw d(w),w}finally{c(!1)}},[u,p]),h=l.useMemo(()=>a.filter(w=>!w.isCurrent).length,[a]);return{sessions:a,isLoading:n,error:i,fetchSessions:p,revokeAllSessions:f,otherSessionCount:h}}function ei(){const{config:s,_internal:t}=M.useCedrosLogin(),[o,a]=l.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),r=l.useMemo(()=>new Ds.OrgApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),n=l.useCallback(async d=>{a(u=>({...u,isLoading:!0,error:null}));try{const u=await r.authorize(d),p={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return a(p),p}catch(u){const p={allowed:!1,reason:void 0,isLoading:!1,error:u};return a(p),p}},[r]),c=l.useCallback(async d=>(await n(d)).allowed,[n]),i=l.useCallback(()=>{a({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:c,lastCheck:o,clearCheck:i,checkAuthorization:n}}function si(){const s=M.useCedrosLoginOptional(),[t,o]=l.useState(!1),[a,r]=l.useState(null),[n,c]=l.useState(null),i=l.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=l.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");o(!0),r(null);try{const f=await i.get("/wallet/pending-recovery");c(f)}catch(f){const h=M.handleApiError(f,"Failed to fetch pending recovery");throw r(h.message),h}finally{o(!1)}},[i]),u=l.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");o(!0),r(null);try{const f={confirmed:!0};await i.post("/wallet/acknowledge-recovery",f),c(null)}catch(f){const h=M.handleApiError(f,"Failed to acknowledge recovery");throw r(h.message),h}finally{o(!1)}},[i]),p=l.useCallback(()=>r(null),[]);return l.useEffect(()=>{i&&s?.authState==="authenticated"&&d().catch(()=>{})},[i,s?.authState,d]),{hasPendingRecovery:n?.hasPendingRecovery??!1,recoveryType:n?.recoveryType??null,recoveryPhrase:n?.recoveryPhrase??null,expiresAt:n?.expiresAt?new Date(n.expiresAt):null,fetchPendingRecovery:d,acknowledgeRecovery:u,isLoading:t,error:a,clearError:p}}function ti(s={}){const{onExternalSign:t}=s,{solanaPubkey:o,hasExternalWallet:a,status:r,isUnlocked:n}=D.useWallet(),{signTransaction:c,isSigning:i,error:d,clearError:u}=cr(),p=l.useMemo(()=>a&&t?"external":r==="enrolled_locked"||r==="enrolled_unlocked"?"sss":"none",[a,t,r]),f=p!=="none",h=r==="enrolled_locked"||r==="enrolled_unlocked";return{signTransaction:l.useCallback(async(g,m)=>{if(p==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(g)}if(p==="sss"){if(!m&&!n)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return m?c(g,m):c(g)}throw new Error("No signing method available. Enroll a wallet first.")},[p,t,n,c]),signingMethod:p,canSign:f,isSigning:i,publicKey:o,hasExternalWallet:a,hasSssWallet:h,isSssUnlocked:n,error:d,clearError:u}}const $s=l.createContext(null),Ge={auth:{email:"Email",password:"Password",confirmPassword:"Confirm Password",name:"Name",optional:"(optional)",createPassword:"Create a password",confirmYourPassword:"Confirm your password",emailPlaceholder:"you@example.com",namePlaceholder:"Your name"},buttons:{signIn:"Sign in",signUp:"Sign up",signOut:"Sign out",createAccount:"Create account",continueWithGoogle:"Continue with Google",continueWithSolana:"Connect Wallet",forgotPassword:"Forgot password?",resetPassword:"Reset password",sendVerification:"Send verification email"},messages:{signingIn:"Signing in...",signingUp:"Signing up...",creatingAccount:"Creating account...",connectingWallet:"Connecting wallet...",verifyingSignature:"Verifying signature...",passwordsDoNotMatch:"Passwords do not match",alreadyHaveAccount:"Already have an account?",dontHaveAccount:"Don't have an account?",orContinueWith:"Or continue with"},errors:{invalidCredentials:"Invalid email or password",emailExists:"An account with this email already exists",invalidEmail:"Please enter a valid email address",weakPassword:"Password does not meet requirements",networkError:"Network error. Please try again.",unknownError:"An error occurred. Please try again.",walletNotFound:"No wallet found. Please install a Solana wallet.",signatureRejected:"Signature request was rejected",challengeExpired:"Challenge expired. Please try again."},passwordValidation:{minLength:"At least 10 characters",uppercase:"At least 1 uppercase letter",lowercase:"At least 1 lowercase letter",number:"At least 1 number",special:"At least 1 special character",weak:"Weak",fair:"Fair",good:"Good",strong:"Strong"}};function Br(s,t){return Dr(s,t)}function Dr(s,t){const o={...s};for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const r=s[a],n=t[a];typeof r=="object"&&r!==null&&typeof n=="object"&&n!==null?o[a]=Dr(r,n):n!==void 0&&(o[a]=n)}return o}function ri({children:s,locale:t="en",translations:o}){const a=l.useMemo(()=>({t:o?Br(Ge,o):Ge,locale:t}),[o,t]);return e.jsx($s.Provider,{value:a,children:s})}function oi(){return l.useContext($s)?.t??Ge}function ni(){return l.useContext($s)?.locale??"en"}exports.CedrosLoginProvider=D.CedrosLoginProvider;exports.getEmbeddedWalletInfo=D.getEmbeddedWalletInfo;exports.isEmbeddedWalletAvailable=D.isEmbeddedWalletAvailable;exports.useAuth=D.useAuth;exports.useWallet=D.useWallet;exports.useWalletMaterial=D.useWalletMaterial;exports.useAuthState=M.useAuthState;exports.useAuthUI=M.useAuthUI;exports.useCedrosLogin=M.useCedrosLogin;exports.LoadingSpinner=V.LoadingSpinner;exports.EmailLoginForm=K.EmailLoginForm;exports.EmailRegisterForm=K.EmailRegisterForm;exports.OtpInput=K.OtpInput;exports.PasswordInput=K.PasswordInput;exports.TotpVerify=K.TotpVerify;exports.useEmailAuth=K.useEmailAuth;exports.useInstantLink=K.useInstantLink;exports.useTotpVerify=K.useTotpVerify;exports.validatePassword=Pe.validatePassword;exports.ErrorMessage=Y.ErrorMessage;exports.GoogleLoginButton=Bs.GoogleLoginButton;exports.useGoogleAuth=Bs.useGoogleAuth;exports.SolanaLoginButton=Se.SolanaLoginButton;exports.useSolanaAuth=Se.useSolanaAuth;exports.InviteForm=te.InviteForm;exports.InviteList=te.InviteList;exports.MemberList=te.MemberList;exports.useInvites=te.useInvites;exports.useMembers=te.useMembers;exports.useServerFeatures=te.useServerFeatures;exports.useSystemSettings=It.useSystemSettings;exports.useOrgs=Ds.useOrgs;exports.AdminDepositList=We.AdminDepositList;exports.AdminDepositStats=We.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=fe.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=fe.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=fe.AdminWithdrawalQueue;exports.AdminWithdrawalStats=fe.AdminWithdrawalStats;exports.AdminUserList=Ee.AdminUserList;exports.useAdminUsers=Ee.useAdminUsers;exports.AdminIcons=ge.Icons;exports.AdminShell=ge.AdminShell;exports.ProfileDropdown=ge.ProfileDropdown;exports.cedrosLoginPlugin=ge.cedrosLoginPlugin;exports.loginPlugin=ge.cedrosLoginPlugin;exports.useAdminShell=ge.useAdminShell;exports.AuthenticationSettings=Ut.AuthenticationSettings;exports.EmbeddedWalletSettings=Wt.EmbeddedWalletSettings;exports.CreditSystemSettings=Is.CreditSystemSettings;exports.PrivacyCashSettings=Is.CreditSystemSettings;exports.ServerSettings=Ot.ServerSettings;exports.useAdminDeposits=Hr.useAdminDeposits;exports.SettingsPageLayout=qt.SettingsPageLayout;exports.EmailSettings=Qr.EmailSettings;exports.WebhookSettings=Kr.WebhookSettings;exports.AppleLoginButton=Zt;exports.CapabilityWarning=Oo;exports.CedrosAdminDashboard=Tn;exports.CreditBalance=Ia;exports.DepositFlow=ya;exports.ErrorBoundary=rr;exports.ForgotPasswordForm=$t;exports.FullPageLayout=$a;exports.History=qa;exports.I18nProvider=ri;exports.LoginButton=mo;exports.LoginForm=Ye;exports.LoginModal=Ao;exports.OrgSelector=jo;exports.OrgSwitcher=Mo;exports.PasskeyLoginButton=tr;exports.PasskeyPrompt=ur;exports.RecoveryPhraseDisplay=or;exports.RecoveryPhraseInput=nr;exports.ResetPasswordForm=vo;exports.SUPPORTED_TOKENS=Rr;exports.SecuritySettings=Nn;exports.SessionList=Ro;exports.SetupWizard=br;exports.SplitPageLayout=Ja;exports.SystemSettings=dn;exports.TieredAmountSlider=Ks;exports.TokenSelector=Vs;exports.TotpSettings=aa;exports.TotpSetup=jr;exports.UserProfileSettings=la;exports.WalletAddressRow=fr;exports.WalletEnrollment=lr;exports.WalletManager=on;exports.WalletRecovery=mr;exports.WalletStatus=gr;exports.WalletUnlock=hr;exports.WithdrawalFlow=Ha;exports.WithdrawalHistory=Ya;exports.defaultTranslations=Ge;exports.getTierForAmount=$e;exports.mergeTranslations=Br;exports.useAppleAuth=Jt;exports.useAuthorize=ei;exports.useCredits=Gs;exports.useDeposit=Nr;exports.useLocale=ni;exports.usePasskeySigning=dr;exports.usePasswordReset=Ws;exports.usePendingRecovery=si;exports.useProfile=kr;exports.useSessions=Za;exports.useSetup=Os;exports.useTotp=zs;exports.useTransactionSigning=ti;exports.useTranslations=oi;exports.useWalletEnrollment=ir;exports.useWalletRecovery=pr;exports.useWalletSigning=cr;exports.useWebAuthn=sr;exports.useWithdrawal=Ys;