@cedros/login-react 0.0.46 → 0.0.47
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.
- package/README.md +32 -2
- package/dist/EmailRegisterForm-ByYQ43yL.cjs +1 -0
- package/dist/EmailRegisterForm-ByYQ43yL.cjs.map +1 -0
- package/dist/EmailRegisterForm-DMUcNQT-.js +781 -0
- package/dist/EmailRegisterForm-DMUcNQT-.js.map +1 -0
- package/dist/GoogleLoginButton-DEwtBp56.cjs +1 -0
- package/dist/GoogleLoginButton-DEwtBp56.cjs.map +1 -0
- package/dist/{GoogleLoginButton-C1WNu7W3.js → GoogleLoginButton-DwyxvhnL.js} +82 -80
- package/dist/GoogleLoginButton-DwyxvhnL.js.map +1 -0
- package/dist/{PermissionsSection-mm9hfp-u.js → PermissionsSection-0oNHPZzL.js} +383 -415
- package/dist/PermissionsSection-0oNHPZzL.js.map +1 -0
- package/dist/PermissionsSection-CZsJuxo4.cjs +1 -0
- package/dist/PermissionsSection-CZsJuxo4.cjs.map +1 -0
- package/dist/SolanaLoginButton-2504p6cr.cjs +1 -0
- package/dist/SolanaLoginButton-2504p6cr.cjs.map +1 -0
- package/dist/SolanaLoginButton-C7Kc_m6n.js +234 -0
- package/dist/SolanaLoginButton-C7Kc_m6n.js.map +1 -0
- package/dist/{TeamSection-Km7EwLWD.cjs → TeamSection-DN8PEHH3.cjs} +1 -1
- package/dist/{TeamSection-Km7EwLWD.cjs.map → TeamSection-DN8PEHH3.cjs.map} +1 -1
- package/dist/{TeamSection-C_eODdLU.js → TeamSection-gUyP4YDM.js} +1 -1
- package/dist/{TeamSection-C_eODdLU.js.map → TeamSection-gUyP4YDM.js.map} +1 -1
- package/dist/{UsersSection-C1Tt0ePx.cjs → UsersSection-8wLuD0fr.cjs} +1 -1
- package/dist/{UsersSection-C1Tt0ePx.cjs.map → UsersSection-8wLuD0fr.cjs.map} +1 -1
- package/dist/{UsersSection-Ct_E-MBF.js → UsersSection-CnsFrG-6.js} +1 -1
- package/dist/{UsersSection-Ct_E-MBF.js.map → UsersSection-CnsFrG-6.js.map} +1 -1
- package/dist/admin-only.cjs +1 -1
- package/dist/admin-only.js +1 -1
- package/dist/email-only.cjs +1 -1
- package/dist/email-only.d.ts +10 -2
- package/dist/email-only.js +2 -2
- package/dist/google-only.cjs +1 -1
- package/dist/google-only.d.ts +7 -2
- package/dist/google-only.js +2 -2
- package/dist/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +182 -11
- package/dist/index.js +5221 -4657
- package/dist/index.js.map +1 -1
- package/dist/login-react.css +1 -1
- package/dist/{plugin-Ci67QMGG.cjs → plugin-DNFjEfYp.cjs} +1 -1
- package/dist/{plugin-Ci67QMGG.cjs.map → plugin-DNFjEfYp.cjs.map} +1 -1
- package/dist/{plugin-Cm8Q6O4-.js → plugin-WYMrRNbz.js} +1 -1
- package/dist/{plugin-Cm8Q6O4-.js.map → plugin-WYMrRNbz.js.map} +1 -1
- package/dist/solana-only.cjs +1 -1
- package/dist/solana-only.d.ts +6 -1
- package/dist/solana-only.js +2 -2
- package/dist/useAuth-2vgrAH-M.cjs +1 -0
- package/dist/useAuth-2vgrAH-M.cjs.map +1 -0
- package/dist/{useAuth-l-itM5am.js → useAuth-CNflw856.js} +465 -469
- package/dist/useAuth-CNflw856.js.map +1 -0
- package/dist/useServerFeatures-9_aNPaa6.cjs +1 -0
- package/dist/useServerFeatures-9_aNPaa6.cjs.map +1 -0
- package/dist/useServerFeatures-DSkYdan-.js +82 -0
- package/dist/useServerFeatures-DSkYdan-.js.map +1 -0
- package/dist/{useUsersStatsSummary-BGeh3RnI.js → useUsersStatsSummary-B4_RBEYy.js} +504 -442
- package/dist/useUsersStatsSummary-B4_RBEYy.js.map +1 -0
- package/dist/useUsersStatsSummary-CHRMrlk4.cjs +1 -0
- package/dist/useUsersStatsSummary-CHRMrlk4.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/EmailRegisterForm-p2X5QP58.js +0 -750
- package/dist/EmailRegisterForm-p2X5QP58.js.map +0 -1
- package/dist/EmailRegisterForm-xFb6MaVA.cjs +0 -1
- package/dist/EmailRegisterForm-xFb6MaVA.cjs.map +0 -1
- package/dist/GoogleLoginButton-2zNTIKMm.cjs +0 -1
- package/dist/GoogleLoginButton-2zNTIKMm.cjs.map +0 -1
- package/dist/GoogleLoginButton-C1WNu7W3.js.map +0 -1
- package/dist/PermissionsSection-4zcE9Zs9.cjs +0 -1
- package/dist/PermissionsSection-4zcE9Zs9.cjs.map +0 -1
- package/dist/PermissionsSection-mm9hfp-u.js.map +0 -1
- package/dist/SolanaLoginButton-CqdzSSeJ.cjs +0 -1
- package/dist/SolanaLoginButton-CqdzSSeJ.cjs.map +0 -1
- package/dist/SolanaLoginButton-CyeX35eU.js +0 -232
- package/dist/SolanaLoginButton-CyeX35eU.js.map +0 -1
- package/dist/sanitization-Bo_tn-L2.cjs +0 -1
- package/dist/sanitization-Bo_tn-L2.cjs.map +0 -1
- package/dist/sanitization-CQ-H1MSg.js +0 -39
- package/dist/sanitization-CQ-H1MSg.js.map +0 -1
- package/dist/useAuth-B1yS_YiD.cjs +0 -1
- package/dist/useAuth-B1yS_YiD.cjs.map +0 -1
- package/dist/useAuth-l-itM5am.js.map +0 -1
- package/dist/useUsersStatsSummary-BGeh3RnI.js.map +0 -1
- package/dist/useUsersStatsSummary-DnsYtFGX.cjs +0 -1
- package/dist/useUsersStatsSummary-DnsYtFGX.cjs.map +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-B1yS_YiD.cjs"),M=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),d=require("react"),Q=require("./LoadingSpinner-d6sSxgQN.cjs"),zs=require("./sanitization-Bo_tn-L2.cjs"),X=require("./EmailRegisterForm-xFb6MaVA.cjs"),Oe=require("./validation-BuGQrA-K.cjs"),te=require("./ErrorMessage-CHbYbVi2.cjs"),$s=require("./GoogleLoginButton-2zNTIKMm.cjs"),Ze=require("./SolanaLoginButton-CqdzSSeJ.cjs"),he=require("./PermissionsSection-4zcE9Zs9.cjs"),Vs=require("./useSystemSettings-B2jY51ob.cjs"),ke=require("./AutosaveStatus-DfMPudTQ.cjs"),Ct=require("./AdminDepositList-B_z6x3j5.cjs"),Me=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),We=require("./useUsersStatsSummary-DnsYtFGX.cjs"),Cn=require("./StatsBar-DTUZCwDD.cjs"),Hs=require("./useOrgs-CNqfn-fk.cjs"),Be=require("./plugin-Ci67QMGG.cjs"),En=require("./AuthenticationSettings-BBOjHR6j.cjs"),_n=require("./EmbeddedWalletSettings-Db9a0D5l.cjs"),jt=require("./EmailSettings-DIjo3aJo.cjs"),Qs=require("./CreditSystemSettings-Badz4iAc.cjs"),Ln=require("./ServerSettings-j5Lu5D-R.cjs"),lt=require("./WebhookSettings-DOaydSWQ.cjs"),ya=require("./useAdminDeposits-CpLd68oP.cjs");async function Pn(t,s,r=D.DEFAULT_KDF_PARAMS){return D.validateKdfParams(r),D.argon2Derive(t,s,r)}function Rn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function xa(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var s=t.default;if(typeof s=="function"){var r=function o(){var n=!1;try{n=this instanceof o}catch{}return n?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};r.prototype=s.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(r,o,n.get?n:{enumerable:!0,get:function(){return t[o]}})}),r}var Nt={exports:{}};const va=globalThis.crypto,Aa=globalThis.crypto,ja=globalThis.crypto.subtle,Na=globalThis.crypto.getRandomValues.bind(globalThis.crypto),ka=globalThis.crypto.randomUUID.bind(globalThis.crypto),Sa=Object.freeze(Object.defineProperty({__proto__:null,default:va,getRandomValues:Na,randomUUID:ka,subtle:ja,webcrypto:Aa},Symbol.toStringTag,{value:"Module"})),Ca=xa(Sa);var Ea=Nt.exports,yr;function _a(){return yr||(yr=1,(function(t,s){(function(r,o){t.exports=o(Ca)})(Ea,function(r){var o,n,a,i,l;function c(){o={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},n={},a=new Array(1024).join("0"),i=!0,l=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function h(){return!!(n&&n.rng&&typeof n.rng=="function")}function m(f,y){var x;if(y===0||y===1)return f;if(y&&y>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return y=y||n.bits,f&&(x=f.length%y),x?(a+f).slice(-(y-x+f.length)):f}function u(f){var y="",x,A;for(A=f.length-1;A>=0;A--){if(x=parseInt(f[A],16),isNaN(x))throw new Error("Invalid hex character.");y=m(x.toString(2),4)+y}return y}function p(f){var y="",x,A;for(f=m(f,4),A=f.length;A>=4;A-=4){if(x=parseInt(f.slice(A-4,A),2),isNaN(x))throw new Error("Invalid binary character.");y=x.toString(16)+y}return y}function b(){return!!(r&&typeof r=="object"&&(typeof r.getRandomValues=="function"||typeof r.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function w(){return typeof r=="object"&&typeof r.randomBytes=="function"}function g(f){function y(C,P,L,R){var T=0,B,F="",W;for(P&&(B=P.length-1);T<B||F.length<C;)W=Math.abs(parseInt(P[T],L)),F=F+m(W.toString(2),R),T++;return F=F.substr(-C),(F.match(/0/g)||[]).length===F.length?null:F}function x(C){var P,L,R,T,B=null;for(R=16,T=4,L=Math.ceil(C/8);B===null;)P=r.randomBytes(L),B=y(C,P.toString("hex"),R,T);return B}function A(C){var P,L,R,T=null;for(L=10,R=32,P=Math.ceil(C/32);T===null;)T=y(C,r.getRandomValues(new Uint32Array(P)),L,R);return T}function _(C){var P,L,R,T,B,F=null;T=10,B=32,L=Math.ceil(C/32),R=123456789,P=new Uint32Array(L);for(var W=0;W<P.length;W++)P[W]=R;for(;F===null;)F=y(C,P,T,B);return F}if(f&&f==="testRandom")return n.typeCSPRNG=f,_;if(f&&f==="nodeCryptoRandomBytes")return n.typeCSPRNG=f,x;if(f&&f==="browserCryptoGetRandomValues")return n.typeCSPRNG=f,A;if(w())return n.typeCSPRNG="nodeCryptoRandomBytes",x;if(b())return n.typeCSPRNG="browserCryptoGetRandomValues",A}function j(f,y){var x=[],A;for(y&&(f=m(f,y)),A=f.length;A>n.bits;A-=n.bits)x.push(parseInt(f.slice(A-n.bits,A),2));return x.push(parseInt(f.slice(0,A),2)),x}function v(f,y){var x=n.logs[f],A=0,_;for(_=y.length-1;_>=0;_--)A!==0?A=n.exps[(x+n.logs[A])%n.maxShares]^y[_]:A=y[_];return A}function N(f,y,x){var A=0,_,C,P,L;for(P=0,_=y.length;P<_;P++)if(x[P]){for(C=n.logs[x[P]],L=0;L<_;L++)if(P!==L){if(f===y[L]){C=-1;break}C=(C+n.logs[f^y[L]]-n.logs[y[P]^y[L]]+n.maxShares)%n.maxShares}A=C===-1?A:A^n.exps[C]}return A}function k(f,y,x){var A=[],_=[f],C,P;for(C=1;C<x;C++)_[C]=parseInt(n.rng(n.bits),2);for(C=1,P=y+1;C<P;C++)A[C-1]={x:C,y:v(C,_)};return A}function S(f,y,x){var A,_,C,P,L;if(y=parseInt(y,n.radix),f=parseInt(f,10)||n.bits,A=f.toString(36).toUpperCase(),C=Math.pow(2,f)-1,P=C.toString(n.radix).length,_=m(y.toString(n.radix),P),typeof y!="number"||y%1!==0||y<1||y>C)throw new Error("Share id must be an integer between 1 and "+C+", inclusive.");return L=A+_+x,L}var E={init:function(f,y){var x=[],A=[],_=1,C,P;if(c(),f&&(typeof f!="number"||f%1!==0||f<o.minBits||f>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(y&&l.indexOf(y)===-1)throw new Error("Invalid RNG type argument : '"+y+"'");for(n.radix=o.radix,n.bits=f||o.bits,n.size=Math.pow(2,n.bits),n.maxShares=n.size-1,C=o.primitivePolynomials[n.bits],P=0;P<n.size;P++)A[P]=_,x[_]=P,_=_<<1,_>=n.size&&(_=_^C,_=_&n.maxShares);if(n.logs=x,n.exps=A,y&&this.setRNG(y),h()||this.setRNG(),!h()||!n.bits||!n.size||!n.maxShares||!n.logs||!n.exps||n.logs.length!==n.size||n.exps.length!==n.size)throw new Error("Initialization failed.")},combine:function(f,y){var x,A,_,C,P="",L,R,T,B=[],F=[];for(y=y||0,x=0,_=f.length;x<_;x++){if(R=this.extractShareComponents(f[x]),L===void 0)L=R.bits;else if(R.bits!==L)throw new Error("Mismatched shares: Different bit settings.");if(n.bits!==L&&this.init(L),B.indexOf(R.id)===-1)for(B.push(R.id),T=j(u(R.data)),A=0,C=T.length;A<C;A++)F[A]=F[A]||[],F[A][B.length-1]=T[A]}for(x=0,_=F.length;x<_;x++)P=m(N(y,B,F[x]).toString(2))+P;return p(y>=1?P:P.slice(P.indexOf("1")+1))},getConfig:function(){var f={};return f.radix=n.radix,f.bits=n.bits,f.maxShares=n.maxShares,f.hasCSPRNG=h(),f.typeCSPRNG=n.typeCSPRNG,f},extractShareComponents:function(f){var y,x,A,_,C={},P,L;if(y=parseInt(f.substr(0,1),36),y&&(typeof y!="number"||y%1!==0||y<o.minBits||y>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(_=Math.pow(2,y)-1,A=(Math.pow(2,y)-1).toString(n.radix).length,P="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+A+"})([a-fA-F0-9]+)$",L=new RegExp(P).exec(f),L&&(x=parseInt(L[2],n.radix)),typeof x!="number"||x%1!==0||x<1||x>_)throw new Error("Invalid share : Share id must be an integer between 1 and "+n.maxShares+", inclusive.");if(L&&L[3])return C.bits=y,C.id=x,C.data=L[3],C;throw new Error("The share data provided is invalid : "+f)},setRNG:function(f){var y="Random number generator is invalid ",x=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(f&&typeof f=="string"&&l.indexOf(f)===-1)throw new Error("Invalid RNG type argument : '"+f+"'");if(f||(f=g()),f&&typeof f=="string"&&(f=g(f)),i){if(f&&typeof f!="function")throw new Error(y+"(Not a function)."+x);if(f&&typeof f(n.bits)!="string")throw new Error(y+"(Output is not a string)."+x);if(f&&!parseInt(f(n.bits),2))throw new Error(y+"(Binary string output not parseable to an Integer)."+x);if(f&&f(n.bits).length>n.bits)throw new Error(y+"(Output length is greater than config.bits)."+x);if(f&&f(n.bits).length<n.bits)throw new Error(y+"(Output length is less than config.bits)."+x)}return n.rng=f,!0},str2hex:function(f,y){var x,A,_="",C,P,L,R;if(typeof f!="string")throw new Error("Input must be a character string.");if(y||(y=o.bytesPerChar),typeof y!="number"||y<1||y>o.maxBytesPerChar||y%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,A=Math.pow(16,x)-1,L=0,R=f.length;L<R;L++){if(P=f[L].charCodeAt(),isNaN(P))throw new Error("Invalid character: "+f[L]);if(P>A)throw C=Math.ceil(Math.log(P+1)/Math.log(256)),new Error("Invalid character code ("+P+"). Maximum allowable is 256^bytes-1 ("+A+"). To convert this character, use at least "+C+" bytes.");_=m(P.toString(16),x)+_}return _},hex2str:function(f,y){var x,A="",_,C;if(typeof f!="string")throw new Error("Input must be a hexadecimal string.");if(y=y||o.bytesPerChar,typeof y!="number"||y%1!==0||y<1||y>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,f=m(f,x),_=0,C=f.length;_<C;_+=x)A=String.fromCharCode(parseInt(f.slice(_,_+x),16))+A;return A},random:function(f){if(typeof f!="number"||f%1!==0||f<2||f>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return p(n.rng(f))},share:function(f,y,x,A){var _,C,P=new Array(y),L=new Array(y),R,T,B;if(A=A||128,typeof f!="string")throw new Error("Secret must be a string.");if(typeof y!="number"||y%1!==0||y<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(y>n.maxShares)throw _=Math.ceil(Math.log(y+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To create "+y+" shares, use at least "+_+" bits.");if(typeof x!="number"||x%1!==0||x<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(x>n.maxShares)throw _=Math.ceil(Math.log(x+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To use a threshold of "+x+", use at least "+_+" bits.");if(x>y)throw new Error("Threshold number of shares was "+x+" but must be less than or equal to the "+y+" shares specified as the total to generate.");if(typeof A!="number"||A%1!==0||A<0||A>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(f="1"+u(f),f=j(f,A),R=0,B=f.length;R<B;R++)for(C=k(f[R],y,x),T=0;T<y;T++)P[T]=P[T]||C[T].x.toString(n.radix),L[T]=m(C[T].y.toString(2))+(L[T]||"");for(R=0;R<y;R++)P[R]=S(n.bits,P[R],p(L[R]));return P},newShare:function(f,y){var x,A;if(f&&typeof f=="string"&&(f=parseInt(f,n.radix)),A=f.toString(n.radix),f&&A&&y&&y[0])return x=this.extractShareComponents(y[0]),S(x.bits,A,this.combine(y,f));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:c,_padLeft:m,_hex2bin:u,_bin2hex:p,_hasCryptoGetRandomValues:b,_hasCryptoRandomBytes:w,_getRNG:g,_isSetRNG:h,_splitNumStringToIntArray:j,_horner:v,_lagrange:N,_getShares:k,_constructPublicShareString:S};return E.init(),E})})(Nt)),Nt.exports}var La=_a();const Tn=Rn(La);function Mn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Gs(t,s=""){if(!Number.isSafeInteger(t)||t<0){const r=s&&`"${s}" `;throw new Error(`${r}expected integer >= 0, got ${t}`)}}function ie(t,s,r=""){const o=Mn(t),n=t?.length,a=s!==void 0;if(!o||a&&n!==s){const i=r&&`"${r}" `,l=a?` of length ${s}`:"",c=o?`length=${n}`:`type=${typeof t}`;throw new Error(i+"expected Uint8Array"+l+", got "+c)}return t}function xr(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function Pa(t,s){ie(t,void 0,"digestInto() output");const r=s.outputLen;if(t.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Ts(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function Gt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const Bn=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ra=Array.from({length:256},(t,s)=>s.toString(16).padStart(2,"0"));function Ks(t){if(ie(t),Bn)return t.toHex();let s="";for(let r=0;r<t.length;r++)s+=Ra[t[r]];return s}const je={_0:48,_9:57,A:65,F:70,a:97,f:102};function vr(t){if(t>=je._0&&t<=je._9)return t-je._0;if(t>=je.A&&t<=je.F)return t-(je.A-10);if(t>=je.a&&t<=je.f)return t-(je.a-10)}function In(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Bn)return Uint8Array.fromHex(t);const s=t.length,r=s/2;if(s%2)throw new Error("hex string expected, got unpadded hex of length "+s);const o=new Uint8Array(r);for(let n=0,a=0;n<r;n++,a+=2){const i=vr(t.charCodeAt(a)),l=vr(t.charCodeAt(a+1));if(i===void 0||l===void 0){const c=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+a)}o[n]=i*16+l}return o}function Ar(...t){let s=0;for(let o=0;o<t.length;o++){const n=t[o];ie(n),s+=n.length}const r=new Uint8Array(s);for(let o=0,n=0;o<t.length;o++){const a=t[o];r.set(a,n),n+=a.length}return r}function Ta(t,s={}){const r=(n,a)=>t(a).update(n).digest(),o=t(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=n=>t(n),Object.assign(r,s),Object.freeze(r)}function Ma(t=32){const s=typeof globalThis=="object"?globalThis.crypto:null;if(typeof s?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return s.getRandomValues(new Uint8Array(t))}const Ba=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});let Ia=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(s,r,o,n){this.blockLen=s,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(s),this.view=Gt(this.buffer)}update(s){xr(this),ie(s);const{view:r,buffer:o,blockLen:n}=this,a=s.length;for(let i=0;i<a;){const l=Math.min(n-this.pos,a-i);if(l===n){const c=Gt(s);for(;n<=a-i;i+=n)this.process(c,i);continue}o.set(s.subarray(i,i+l),this.pos),this.pos+=l,i+=l,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){xr(this),Pa(s,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Ts(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;o.setBigUint64(n-8,BigInt(this.length*8),a),this.process(o,0);const l=Gt(s),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const h=c/4,m=this.get();if(h>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)l.setUint32(4*u,m[u],a)}digest(){const{buffer:s,outputLen:r}=this;this.digestInto(s);const o=s.slice(0,r);return this.destroy(),o}_cloneInto(s){s||=new this.constructor,s.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:l}=this;return s.destroyed=i,s.finished=a,s.length=n,s.pos=l,n%r&&s.buffer.set(o),s}clone(){return this._cloneInto()}};const ce=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ht=BigInt(2**32-1),jr=BigInt(32);function Da(t,s=!1){return s?{h:Number(t&ht),l:Number(t>>jr&ht)}:{h:Number(t>>jr&ht)|0,l:Number(t&ht)|0}}function Ua(t,s=!1){const r=t.length;let o=new Uint32Array(r),n=new Uint32Array(r);for(let a=0;a<r;a++){const{h:i,l}=Da(t[a],s);[o[a],n[a]]=[i,l]}return[o,n]}const Nr=(t,s,r)=>t>>>r,kr=(t,s,r)=>t<<32-r|s>>>r,Qe=(t,s,r)=>t>>>r|s<<32-r,Ge=(t,s,r)=>t<<32-r|s>>>r,mt=(t,s,r)=>t<<64-r|s>>>r-32,ft=(t,s,r)=>t>>>r-32|s<<64-r;function Ne(t,s,r,o){const n=(s>>>0)+(o>>>0);return{h:t+r+(n/2**32|0)|0,l:n|0}}const Fa=(t,s,r)=>(t>>>0)+(s>>>0)+(r>>>0),Wa=(t,s,r,o)=>s+r+o+(t/2**32|0)|0,Oa=(t,s,r,o)=>(t>>>0)+(s>>>0)+(r>>>0)+(o>>>0),qa=(t,s,r,o,n)=>s+r+o+n+(t/2**32|0)|0,za=(t,s,r,o,n)=>(t>>>0)+(s>>>0)+(r>>>0)+(o>>>0)+(n>>>0),$a=(t,s,r,o,n,a)=>s+r+o+n+a+(t/2**32|0)|0,Dn=Ua(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Va=Dn[0],Ha=Dn[1],Ee=new Uint32Array(80),_e=new Uint32Array(80);class Qa extends Ia{constructor(s){super(128,s,16,!1)}get(){const{Ah:s,Al:r,Bh:o,Bl:n,Ch:a,Cl:i,Dh:l,Dl:c,Eh:h,El:m,Fh:u,Fl:p,Gh:b,Gl:w,Hh:g,Hl:j}=this;return[s,r,o,n,a,i,l,c,h,m,u,p,b,w,g,j]}set(s,r,o,n,a,i,l,c,h,m,u,p,b,w,g,j){this.Ah=s|0,this.Al=r|0,this.Bh=o|0,this.Bl=n|0,this.Ch=a|0,this.Cl=i|0,this.Dh=l|0,this.Dl=c|0,this.Eh=h|0,this.El=m|0,this.Fh=u|0,this.Fl=p|0,this.Gh=b|0,this.Gl=w|0,this.Hh=g|0,this.Hl=j|0}process(s,r){for(let k=0;k<16;k++,r+=4)Ee[k]=s.getUint32(r),_e[k]=s.getUint32(r+=4);for(let k=16;k<80;k++){const S=Ee[k-15]|0,E=_e[k-15]|0,f=Qe(S,E,1)^Qe(S,E,8)^Nr(S,E,7),y=Ge(S,E,1)^Ge(S,E,8)^kr(S,E,7),x=Ee[k-2]|0,A=_e[k-2]|0,_=Qe(x,A,19)^mt(x,A,61)^Nr(x,A,6),C=Ge(x,A,19)^ft(x,A,61)^kr(x,A,6),P=Oa(y,C,_e[k-7],_e[k-16]),L=qa(P,f,_,Ee[k-7],Ee[k-16]);Ee[k]=L|0,_e[k]=P|0}let{Ah:o,Al:n,Bh:a,Bl:i,Ch:l,Cl:c,Dh:h,Dl:m,Eh:u,El:p,Fh:b,Fl:w,Gh:g,Gl:j,Hh:v,Hl:N}=this;for(let k=0;k<80;k++){const S=Qe(u,p,14)^Qe(u,p,18)^mt(u,p,41),E=Ge(u,p,14)^Ge(u,p,18)^ft(u,p,41),f=u&b^~u&g,y=p&w^~p&j,x=za(N,E,y,Ha[k],_e[k]),A=$a(x,v,S,f,Va[k],Ee[k]),_=x|0,C=Qe(o,n,28)^mt(o,n,34)^mt(o,n,39),P=Ge(o,n,28)^ft(o,n,34)^ft(o,n,39),L=o&a^o&l^a&l,R=n&i^n&c^i&c;v=g|0,N=j|0,g=b|0,j=w|0,b=u|0,w=p|0,{h:u,l:p}=Ne(h|0,m|0,A|0,_|0),h=l|0,m=c|0,l=a|0,c=i|0,a=o|0,i=n|0;const T=Fa(_,P,R);o=Wa(T,A,C,L),n=T|0}({h:o,l:n}=Ne(this.Ah|0,this.Al|0,o|0,n|0)),{h:a,l:i}=Ne(this.Bh|0,this.Bl|0,a|0,i|0),{h:l,l:c}=Ne(this.Ch|0,this.Cl|0,l|0,c|0),{h,l:m}=Ne(this.Dh|0,this.Dl|0,h|0,m|0),{h:u,l:p}=Ne(this.Eh|0,this.El|0,u|0,p|0),{h:b,l:w}=Ne(this.Fh|0,this.Fl|0,b|0,w|0),{h:g,l:j}=Ne(this.Gh|0,this.Gl|0,g|0,j|0),{h:v,l:N}=Ne(this.Hh|0,this.Hl|0,v|0,N|0),this.set(o,n,a,i,l,c,h,m,u,p,b,w,g,j,v,N)}roundClean(){Ts(Ee,_e)}destroy(){Ts(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ga extends Qa{Ah=ce[0]|0;Al=ce[1]|0;Bh=ce[2]|0;Bl=ce[3]|0;Ch=ce[4]|0;Cl=ce[5]|0;Dh=ce[6]|0;Dl=ce[7]|0;Eh=ce[8]|0;El=ce[9]|0;Fh=ce[10]|0;Fl=ce[11]|0;Gh=ce[12]|0;Gl=ce[13]|0;Hh=ce[14]|0;Hl=ce[15]|0;constructor(){super(64)}}const Ka=Ta(()=>new Ga,Ba(3));const Un=BigInt(0),Sr=BigInt(1);function Ms(t,s=""){if(typeof t!="boolean"){const r=s&&`"${s}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function Ya(t){if(typeof t=="bigint"){if(!kt(t))throw new Error("positive bigint expected, got "+t)}else Gs(t);return t}function Fn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Un:BigInt("0x"+t)}function Za(t){return Fn(Ks(t))}function Et(t){return Fn(Ks(Bs(ie(t)).reverse()))}function Wn(t,s){Gs(s),t=Ya(t);const r=In(t.toString(16).padStart(s*2,"0"));if(r.length!==s)throw new Error("number too large");return r}function Xa(t,s){return Wn(t,s).reverse()}function Bs(t){return Uint8Array.from(t)}const kt=t=>typeof t=="bigint"&&Un<=t;function Ja(t,s,r){return kt(t)&&kt(s)&&kt(r)&&s<=t&&t<r}function Cr(t,s,r,o){if(!Ja(s,r,o))throw new Error("expected valid "+t+": "+r+" <= n < "+o+", got "+s)}const ei=t=>(Sr<<BigInt(t))-Sr;function Ys(t,s={},r={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function o(a,i,l){const c=t[a];if(l&&c===void 0)return;const h=typeof c;if(h!==i||c===null)throw new Error(`param "${a}" is invalid: expected ${i}, got ${h}`)}const n=(a,i)=>Object.entries(a).forEach(([l,c])=>o(l,c,i));n(s,!1),n(r,!0)}function Er(t){const s=new WeakMap;return(r,...o)=>{const n=s.get(r);if(n!==void 0)return n;const a=t(r,...o);return s.set(r,a),a}}const me=BigInt(0),de=BigInt(1),Fe=BigInt(2),On=BigInt(3),qn=BigInt(4),zn=BigInt(5),ti=BigInt(7),$n=BigInt(8),si=BigInt(9),Vn=BigInt(16);function oe(t,s){const r=t%s;return r>=me?r:s+r}function xe(t,s,r){let o=t;for(;s-- >me;)o*=o,o%=r;return o}function _r(t,s){if(t===me)throw new Error("invert: expected non-zero number");if(s<=me)throw new Error("invert: expected positive modulus, got "+s);let r=oe(t,s),o=s,n=me,a=de;for(;r!==me;){const l=o/r,c=o%r,h=n-a*l;o=r,r=c,n=a,a=h}if(o!==de)throw new Error("invert: does not exist");return oe(n,s)}function Zs(t,s,r){if(!t.eql(t.sqr(s),r))throw new Error("Cannot find square root")}function Hn(t,s){const r=(t.ORDER+de)/qn,o=t.pow(s,r);return Zs(t,o,s),o}function ri(t,s){const r=(t.ORDER-zn)/$n,o=t.mul(s,Fe),n=t.pow(o,r),a=t.mul(s,n),i=t.mul(t.mul(a,Fe),n),l=t.mul(a,t.sub(i,t.ONE));return Zs(t,l,s),l}function ni(t){const s=Xs(t),r=Qn(t),o=r(s,s.neg(s.ONE)),n=r(s,o),a=r(s,s.neg(o)),i=(t+ti)/Vn;return(l,c)=>{let h=l.pow(c,i),m=l.mul(h,o);const u=l.mul(h,n),p=l.mul(h,a),b=l.eql(l.sqr(m),c),w=l.eql(l.sqr(u),c);h=l.cmov(h,m,b),m=l.cmov(p,u,w);const g=l.eql(l.sqr(m),c),j=l.cmov(h,m,g);return Zs(l,j,c),j}}function Qn(t){if(t<On)throw new Error("sqrt is not defined for small field");let s=t-de,r=0;for(;s%Fe===me;)s/=Fe,r++;let o=Fe;const n=Xs(t);for(;Lr(n,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Hn;let a=n.pow(o,s);const i=(s+de)/Fe;return function(c,h){if(c.is0(h))return h;if(Lr(c,h)!==1)throw new Error("Cannot find square root");let m=r,u=c.mul(c.ONE,a),p=c.pow(h,s),b=c.pow(h,i);for(;!c.eql(p,c.ONE);){if(c.is0(p))return c.ZERO;let w=1,g=c.sqr(p);for(;!c.eql(g,c.ONE);)if(w++,g=c.sqr(g),w===m)throw new Error("Cannot find square root");const j=de<<BigInt(m-w-1),v=c.pow(u,j);m=w,u=c.sqr(v),p=c.mul(p,u),b=c.mul(b,v)}return b}}function oi(t){return t%qn===On?Hn:t%$n===zn?ri:t%Vn===si?ni(t):Qn(t)}const ai=(t,s)=>(oe(t,s)&de)===de,ii=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ci(t){const s={ORDER:"bigint",BYTES:"number",BITS:"number"},r=ii.reduce((o,n)=>(o[n]="function",o),s);return Ys(t,r),t}function li(t,s,r){if(r<me)throw new Error("invalid exponent, negatives unsupported");if(r===me)return t.ONE;if(r===de)return s;let o=t.ONE,n=s;for(;r>me;)r&de&&(o=t.mul(o,n)),n=t.sqr(n),r>>=de;return o}function Gn(t,s,r=!1){const o=new Array(s.length).fill(r?t.ZERO:void 0),n=s.reduce((i,l,c)=>t.is0(l)?i:(o[c]=i,t.mul(i,l)),t.ONE),a=t.inv(n);return s.reduceRight((i,l,c)=>t.is0(l)?i:(o[c]=t.mul(i,o[c]),t.mul(i,l)),a),o}function Lr(t,s){const r=(t.ORDER-de)/Fe,o=t.pow(s,r),n=t.eql(o,t.ONE),a=t.eql(o,t.ZERO),i=t.eql(o,t.neg(t.ONE));if(!n&&!a&&!i)throw new Error("invalid Legendre symbol result");return n?1:a?0:-1}function di(t,s){s!==void 0&&Gs(s);const r=s!==void 0?s:t.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class ui{ORDER;BITS;BYTES;isLE;ZERO=me;ONE=de;_lengths;_sqrt;_mod;constructor(s,r={}){if(s<=me)throw new Error("invalid field: expected ORDER > 0, got "+s);let o;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(o=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));const{nBitLength:n,nByteLength:a}=di(s,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=s,this.BITS=n,this.BYTES=a,this._sqrt=void 0,Object.preventExtensions(this)}create(s){return oe(s,this.ORDER)}isValid(s){if(typeof s!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof s);return me<=s&&s<this.ORDER}is0(s){return s===me}isValidNot0(s){return!this.is0(s)&&this.isValid(s)}isOdd(s){return(s&de)===de}neg(s){return oe(-s,this.ORDER)}eql(s,r){return s===r}sqr(s){return oe(s*s,this.ORDER)}add(s,r){return oe(s+r,this.ORDER)}sub(s,r){return oe(s-r,this.ORDER)}mul(s,r){return oe(s*r,this.ORDER)}pow(s,r){return li(this,s,r)}div(s,r){return oe(s*_r(r,this.ORDER),this.ORDER)}sqrN(s){return s*s}addN(s,r){return s+r}subN(s,r){return s-r}mulN(s,r){return s*r}inv(s){return _r(s,this.ORDER)}sqrt(s){return this._sqrt||(this._sqrt=oi(this.ORDER)),this._sqrt(this,s)}toBytes(s){return this.isLE?Xa(s,this.BYTES):Wn(s,this.BYTES)}fromBytes(s,r=!1){ie(s);const{_lengths:o,BYTES:n,isLE:a,ORDER:i,_mod:l}=this;if(o){if(!o.includes(s.length)||s.length>n)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+s.length);const h=new Uint8Array(n);h.set(s,a?0:h.length-s.length),s=h}if(s.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+s.length);let c=a?Et(s):Za(s);if(l&&(c=oe(c,i)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(s){return Gn(this,s)}cmov(s,r,o){return o?r:s}}function Xs(t,s={}){return new ui(t,s)}const _t=BigInt(0),Is=BigInt(1);function Pr(t,s){const r=s.negate();return t?r:s}function Kt(t,s){const r=Gn(t.Fp,s.map(o=>o.Z));return s.map((o,n)=>t.fromAffine(o.toAffine(r[n])))}function Kn(t,s){if(!Number.isSafeInteger(t)||t<=0||t>s)throw new Error("invalid window size, expected [1.."+s+"], got W="+t)}function Yt(t,s){Kn(t,s);const r=Math.ceil(s/t)+1,o=2**(t-1),n=2**t,a=ei(t),i=BigInt(t);return{windows:r,windowSize:o,mask:a,maxNumber:n,shiftBy:i}}function Rr(t,s,r){const{windowSize:o,mask:n,maxNumber:a,shiftBy:i}=r;let l=Number(t&n),c=t>>i;l>o&&(l-=a,c+=Is);const h=s*o,m=h+Math.abs(l)-1,u=l===0,p=l<0,b=s%2!==0;return{nextN:c,offset:m,isZero:u,isNeg:p,isNegF:b,offsetF:h}}const Zt=new WeakMap,Yn=new WeakMap;function Xt(t){return Yn.get(t)||1}function Tr(t){if(t!==_t)throw new Error("invalid wNAF")}class hi{BASE;ZERO;Fn;bits;constructor(s,r){this.BASE=s.BASE,this.ZERO=s.ZERO,this.Fn=s.Fn,this.bits=r}_unsafeLadder(s,r,o=this.ZERO){let n=s;for(;r>_t;)r&Is&&(o=o.add(n)),n=n.double(),r>>=Is;return o}precomputeWindow(s,r){const{windows:o,windowSize:n}=Yt(r,this.bits),a=[];let i=s,l=i;for(let c=0;c<o;c++){l=i,a.push(l);for(let h=1;h<n;h++)l=l.add(i),a.push(l);i=l.double()}return a}wNAF(s,r,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let n=this.ZERO,a=this.BASE;const i=Yt(s,this.bits);for(let l=0;l<i.windows;l++){const{nextN:c,offset:h,isZero:m,isNeg:u,isNegF:p,offsetF:b}=Rr(o,l,i);o=c,m?a=a.add(Pr(p,r[b])):n=n.add(Pr(u,r[h]))}return Tr(o),{p:n,f:a}}wNAFUnsafe(s,r,o,n=this.ZERO){const a=Yt(s,this.bits);for(let i=0;i<a.windows&&o!==_t;i++){const{nextN:l,offset:c,isZero:h,isNeg:m}=Rr(o,i,a);if(o=l,!h){const u=r[c];n=n.add(m?u.negate():u)}}return Tr(o),n}getPrecomputes(s,r,o){let n=Zt.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&(typeof o=="function"&&(n=o(n)),Zt.set(r,n))),n}cached(s,r,o){const n=Xt(s);return this.wNAF(n,this.getPrecomputes(n,s,o),r)}unsafe(s,r,o,n){const a=Xt(s);return a===1?this._unsafeLadder(s,r,n):this.wNAFUnsafe(a,this.getPrecomputes(a,s,o),r,n)}createCache(s,r){Kn(r,this.bits),Yn.set(s,r),Zt.delete(s)}hasCache(s){return Xt(s)!==1}}function Mr(t,s,r){if(s){if(s.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ci(s),s}else return Xs(t,{isLE:r})}function mi(t,s,r={},o){if(o===void 0&&(o=t==="edwards"),!s||typeof s!="object")throw new Error(`expected valid ${t} CURVE object`);for(const c of["p","n","h"]){const h=s[c];if(!(typeof h=="bigint"&&h>_t))throw new Error(`CURVE.${c} must be positive bigint`)}const n=Mr(s.p,r.Fp,o),a=Mr(s.n,r.Fn,o),l=["Gx","Gy","a","d"];for(const c of l)if(!n.isValid(s[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return s=Object.freeze(Object.assign({},s)),{CURVE:s,Fp:n,Fn:a}}function fi(t,s){return function(o){const n=t(o);return{secretKey:n,publicKey:s(n)}}}const Le=BigInt(0),ae=BigInt(1),Jt=BigInt(2),pi=BigInt(8);function gi(t,s,r,o){const n=t.sqr(r),a=t.sqr(o),i=t.add(t.mul(s.a,n),a),l=t.add(t.ONE,t.mul(s.d,t.mul(n,a)));return t.eql(i,l)}function wi(t,s={}){const r=mi("edwards",t,s,s.FpFnLE),{Fp:o,Fn:n}=r;let a=r.CURVE;const{h:i}=a;Ys(s,{},{uvRatio:"function"});const l=Jt<<BigInt(n.BYTES*8)-ae,c=j=>o.create(j),h=s.uvRatio||((j,v)=>{try{return{isValid:!0,value:o.sqrt(o.div(j,v))}}catch{return{isValid:!1,value:Le}}});if(!gi(o,a,a.Gx,a.Gy))throw new Error("bad curve params: generator point");function m(j,v,N=!1){const k=N?ae:Le;return Cr("coordinate "+j,v,k,l),v}function u(j){if(!(j instanceof w))throw new Error("EdwardsPoint expected")}const p=Er((j,v)=>{const{X:N,Y:k,Z:S}=j,E=j.is0();v==null&&(v=E?pi:o.inv(S));const f=c(N*v),y=c(k*v),x=o.mul(S,v);if(E)return{x:Le,y:ae};if(x!==ae)throw new Error("invZ was invalid");return{x:f,y}}),b=Er(j=>{const{a:v,d:N}=a;if(j.is0())throw new Error("bad point: ZERO");const{X:k,Y:S,Z:E,T:f}=j,y=c(k*k),x=c(S*S),A=c(E*E),_=c(A*A),C=c(y*v),P=c(A*c(C+x)),L=c(_+c(N*c(y*x)));if(P!==L)throw new Error("bad point: equation left != right (1)");const R=c(k*S),T=c(E*f);if(R!==T)throw new Error("bad point: equation left != right (2)");return!0});class w{static BASE=new w(a.Gx,a.Gy,ae,c(a.Gx*a.Gy));static ZERO=new w(Le,ae,ae,Le);static Fp=o;static Fn=n;X;Y;Z;T;constructor(v,N,k,S){this.X=m("x",v),this.Y=m("y",N),this.Z=m("z",k,!0),this.T=m("t",S),Object.freeze(this)}static CURVE(){return a}static fromAffine(v){if(v instanceof w)throw new Error("extended point not allowed");const{x:N,y:k}=v||{};return m("x",N),m("y",k),new w(N,k,ae,c(N*k))}static fromBytes(v,N=!1){const k=o.BYTES,{a:S,d:E}=a;v=Bs(ie(v,k,"point")),Ms(N,"zip215");const f=Bs(v),y=v[k-1];f[k-1]=y&-129;const x=Et(f),A=N?l:o.ORDER;Cr("point.y",x,Le,A);const _=c(x*x),C=c(_-ae),P=c(E*_-S);let{isValid:L,value:R}=h(C,P);if(!L)throw new Error("bad point: invalid y coordinate");const T=(R&ae)===ae,B=(y&128)!==0;if(!N&&R===Le&&B)throw new Error("bad point: x=0 and x_0=1");return B!==T&&(R=c(-R)),w.fromAffine({x:R,y:x})}static fromHex(v,N=!1){return w.fromBytes(In(v),N)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(v=8,N=!0){return g.createCache(this,v),N||this.multiply(Jt),this}assertValidity(){b(this)}equals(v){u(v);const{X:N,Y:k,Z:S}=this,{X:E,Y:f,Z:y}=v,x=c(N*y),A=c(E*S),_=c(k*y),C=c(f*S);return x===A&&_===C}is0(){return this.equals(w.ZERO)}negate(){return new w(c(-this.X),this.Y,this.Z,c(-this.T))}double(){const{a:v}=a,{X:N,Y:k,Z:S}=this,E=c(N*N),f=c(k*k),y=c(Jt*c(S*S)),x=c(v*E),A=N+k,_=c(c(A*A)-E-f),C=x+f,P=C-y,L=x-f,R=c(_*P),T=c(C*L),B=c(_*L),F=c(P*C);return new w(R,T,F,B)}add(v){u(v);const{a:N,d:k}=a,{X:S,Y:E,Z:f,T:y}=this,{X:x,Y:A,Z:_,T:C}=v,P=c(S*x),L=c(E*A),R=c(y*k*C),T=c(f*_),B=c((S+E)*(x+A)-P-L),F=T-R,W=T+R,O=c(L-N*P),I=c(B*F),U=c(W*O),z=c(B*O),K=c(F*W);return new w(I,U,K,z)}subtract(v){return this.add(v.negate())}multiply(v){if(!n.isValidNot0(v))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:N,f:k}=g.cached(this,v,S=>Kt(w,S));return Kt(w,[N,k])[0]}multiplyUnsafe(v,N=w.ZERO){if(!n.isValid(v))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return v===Le?w.ZERO:this.is0()||v===ae?this:g.unsafe(this,v,k=>Kt(w,k),N)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return g.unsafe(this,a.n).is0()}toAffine(v){return p(this,v)}clearCofactor(){return i===ae?this:this.multiplyUnsafe(i)}toBytes(){const{x:v,y:N}=this.toAffine(),k=o.toBytes(N);return k[k.length-1]|=v&ae?128:0,k}toHex(){return Ks(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const g=new hi(w,n.BITS);return w.BASE.precompute(8),w}function bi(t,s,r={}){if(typeof s!="function")throw new Error('"hash" function param is required');Ys(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=r,{BASE:n,Fp:a,Fn:i}=t,l=r.randomBytes||Ma,c=r.adjustScalarBytes||(x=>x),h=r.domain||((x,A,_)=>{if(Ms(_,"phflag"),A.length||_)throw new Error("Contexts/pre-hash are not supported");return x});function m(x){return i.create(Et(x))}function u(x){const A=k.secretKey;ie(x,k.secretKey,"secretKey");const _=ie(s(x),2*A,"hashedSecretKey"),C=c(_.slice(0,A)),P=_.slice(A,2*A),L=m(C);return{head:C,prefix:P,scalar:L}}function p(x){const{head:A,prefix:_,scalar:C}=u(x),P=n.multiply(C),L=P.toBytes();return{head:A,prefix:_,scalar:C,point:P,pointBytes:L}}function b(x){return p(x).pointBytes}function w(x=Uint8Array.of(),...A){const _=Ar(...A);return m(s(h(_,ie(x,void 0,"context"),!!o)))}function g(x,A,_={}){x=ie(x,void 0,"message"),o&&(x=o(x));const{prefix:C,scalar:P,pointBytes:L}=p(A),R=w(_.context,C,x),T=n.multiply(R).toBytes(),B=w(_.context,T,L,x),F=i.create(R+B*P);if(!i.isValid(F))throw new Error("sign failed: invalid s");const W=Ar(T,i.toBytes(F));return ie(W,k.signature,"result")}const j={zip215:!0};function v(x,A,_,C=j){const{context:P,zip215:L}=C,R=k.signature;x=ie(x,R,"signature"),A=ie(A,void 0,"message"),_=ie(_,k.publicKey,"publicKey"),L!==void 0&&Ms(L,"zip215"),o&&(A=o(A));const T=R/2,B=x.subarray(0,T),F=Et(x.subarray(T,R));let W,O,I;try{W=t.fromBytes(_,L),O=t.fromBytes(B,L),I=n.multiplyUnsafe(F)}catch{return!1}if(!L&&W.isSmallOrder())return!1;const U=w(P,O.toBytes(),W.toBytes(),A);return O.add(W.multiplyUnsafe(U)).subtract(I).clearCofactor().is0()}const N=a.BYTES,k={secretKey:N,publicKey:N,signature:2*N,seed:N};function S(x=l(k.seed)){return ie(x,k.seed,"seed")}function E(x){return Mn(x)&&x.length===i.BYTES}function f(x,A){try{return!!t.fromBytes(x,A)}catch{return!1}}const y={getExtendedPublicKey:p,randomSecretKey:S,isValidSecretKey:E,isValidPublicKey:f,toMontgomery(x){const{y:A}=t.fromBytes(x),_=k.publicKey,C=_===32;if(!C&&_!==57)throw new Error("only defined for 25519 and 448");const P=C?a.div(ae+A,ae-A):a.div(A-ae,A+ae);return a.toBytes(P)},toMontgomerySecret(x){const A=k.secretKey;ie(x,A);const _=s(x.subarray(0,A));return c(_).subarray(0,A)}};return Object.freeze({keygen:fi(S,b),getPublicKey:b,sign:g,verify:v,utils:y,Point:t,lengths:k})}const yi=BigInt(1),Br=BigInt(2),xi=BigInt(5),vi=BigInt(8),Js=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Ai={p:Js,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:vi,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ji(t){const s=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),a=Js,l=t*t%a*t%a,c=xe(l,Br,a)*l%a,h=xe(c,yi,a)*t%a,m=xe(h,xi,a)*h%a,u=xe(m,s,a)*m%a,p=xe(u,r,a)*u%a,b=xe(p,o,a)*p%a,w=xe(b,n,a)*b%a,g=xe(w,n,a)*b%a,j=xe(g,s,a)*m%a;return{pow_p_5_8:xe(j,Br,a)*t%a,b2:l}}function Ni(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Ir=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ki(t,s){const r=Js,o=oe(s*s*s,r),n=oe(o*o*s,r),a=ji(t*n).pow_p_5_8;let i=oe(t*o*a,r);const l=oe(s*i*i,r),c=i,h=oe(i*Ir,r),m=l===t,u=l===oe(-t,r),p=l===oe(-t*Ir,r);return m&&(i=c),(u||p)&&(i=h),ai(i,r)&&(i=oe(-i,r)),{isValid:m||u,value:i}}const Si=wi(Ai,{uvRatio:ki});function Ci(t){return bi(Si,Ka,Object.assign({adjustScalarBytes:Ni},t))}const Ei=Ci({});function _i(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ut(t,...s){if(!_i(t))throw new Error("Uint8Array expected");if(s.length>0&&!s.includes(t.length))throw new Error("Uint8Array expected of length "+s+", got length="+t.length)}function Dr(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function Li(t,s){Ut(t);const r=s.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ds(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function es(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ve(t,s){return t<<32-s|t>>>s}function Pi(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Zn(t){return typeof t=="string"&&(t=Pi(t)),Ut(t),t}class Ri{}function Ti(t){const s=o=>t().update(Zn(o)).digest(),r=t();return s.outputLen=r.outputLen,s.blockLen=r.blockLen,s.create=()=>t(),s}function Mi(t,s,r,o){if(typeof t.setBigUint64=="function")return t.setBigUint64(s,r,o);const n=BigInt(32),a=BigInt(4294967295),i=Number(r>>n&a),l=Number(r&a),c=o?4:0,h=o?0:4;t.setUint32(s+c,i,o),t.setUint32(s+h,l,o)}function Bi(t,s,r){return t&s^~t&r}function Ii(t,s,r){return t&s^t&r^s&r}class Di extends Ri{constructor(s,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=s,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(s),this.view=es(this.buffer)}update(s){Dr(this),s=Zn(s),Ut(s);const{view:r,buffer:o,blockLen:n}=this,a=s.length;for(let i=0;i<a;){const l=Math.min(n-this.pos,a-i);if(l===n){const c=es(s);for(;n<=a-i;i+=n)this.process(c,i);continue}o.set(s.subarray(i,i+l),this.pos),this.pos+=l,i+=l,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){Dr(this),Li(s,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Ds(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;Mi(o,n-8,BigInt(this.length*8),a),this.process(o,0);const l=es(s),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=c/4,m=this.get();if(h>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)l.setUint32(4*u,m[u],a)}digest(){const{buffer:s,outputLen:r}=this;this.digestInto(s);const o=s.slice(0,r);return this.destroy(),o}_cloneInto(s){s||(s=new this.constructor),s.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:l}=this;return s.destroyed=i,s.finished=a,s.length=n,s.pos=l,n%r&&s.buffer.set(o),s}clone(){return this._cloneInto()}}const Pe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ui=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Re=new Uint32Array(64);class Fi extends Di{constructor(s=32){super(64,s,8,!1),this.A=Pe[0]|0,this.B=Pe[1]|0,this.C=Pe[2]|0,this.D=Pe[3]|0,this.E=Pe[4]|0,this.F=Pe[5]|0,this.G=Pe[6]|0,this.H=Pe[7]|0}get(){const{A:s,B:r,C:o,D:n,E:a,F:i,G:l,H:c}=this;return[s,r,o,n,a,i,l,c]}set(s,r,o,n,a,i,l,c){this.A=s|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=a|0,this.F=i|0,this.G=l|0,this.H=c|0}process(s,r){for(let u=0;u<16;u++,r+=4)Re[u]=s.getUint32(r,!1);for(let u=16;u<64;u++){const p=Re[u-15],b=Re[u-2],w=ve(p,7)^ve(p,18)^p>>>3,g=ve(b,17)^ve(b,19)^b>>>10;Re[u]=g+Re[u-7]+w+Re[u-16]|0}let{A:o,B:n,C:a,D:i,E:l,F:c,G:h,H:m}=this;for(let u=0;u<64;u++){const p=ve(l,6)^ve(l,11)^ve(l,25),b=m+p+Bi(l,c,h)+Ui[u]+Re[u]|0,g=(ve(o,2)^ve(o,13)^ve(o,22))+Ii(o,n,a)|0;m=h,h=c,c=l,l=i+b|0,i=a,a=n,n=o,o=b+g|0}o=o+this.A|0,n=n+this.B|0,a=a+this.C|0,i=i+this.D|0,l=l+this.E|0,c=c+this.F|0,h=h+this.G|0,m=m+this.H|0,this.set(o,n,a,i,l,c,h,m)}roundClean(){Ds(Re)}destroy(){this.set(0,0,0,0,0,0,0,0),Ds(this.buffer)}}const Xn=Ti(()=>new Fi),Wi=Xn,Oi="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function qi(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Wi(t),r=Ei.getPublicKey(s),o=new Uint8Array(64);return o.set(s,0),o.set(r,32),D.wipeBytes(s),{publicKey:r,secretKey:o}}function Jn(t){const s=qi(t),r=s.publicKey;return D.wipeBytes(s.secretKey),r}function eo(t){if(t.length!==32)throw new Error(`Invalid public key length: expected 32, got ${t.length}`);return zi(t)}function zi(t){let s=0;for(let n=0;n<t.length&&t[n]===0;n++)s++;let r=0n;for(let n=0;n<t.length;n++)r=r*256n+BigInt(t[n]);let o="";for(;r>0n;){const n=Number(r%58n);o=Oi[n]+o,r=r/58n}return"1".repeat(s)+o}const $i=2,Vi=3;function to(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Us(t),r=Tn.share(s,Vi,$i);if(r.length!==3)throw new Error(`Unexpected share count: ${r.length}`);const o=ts(r[0]),n=ts(r[1]),a=ts(r[2]);return{shareA:D.toShamirShare(o),shareB:D.toShamirShare(n),shareC:D.toShamirShare(a)}}function Hi(t,s,r){const o=Ur(t),n=Ur(s);try{const a=Tn.combine([o,n]),i=so(a);if(i.length!==16)throw new Error(`Reconstructed seed has wrong length: ${i.length}`);return D.toSeed(i)}catch(a){throw a instanceof Error&&a.message.startsWith("Reconstructed seed")||a instanceof Error&&a.message.startsWith("Invalid expectedPublicKey")||a instanceof Error&&a.message.startsWith("Reconstructed seed does not match")?a:new Error("Failed to reconstruct seed from shares")}}function Us(t){return Array.from(t).map(s=>s.toString(16).padStart(2,"0")).join("")}function so(t){if(!/^[0-9a-fA-F]*$/.test(t))throw new Error("Invalid hex string: contains non-hex characters");if(t.length%2!==0)throw new Error(`Invalid hex string: length ${t.length} is odd (must be even)`);const s=new Uint8Array(t.length/2);for(let r=0;r<s.length;r++)s[r]=parseInt(t.substr(r*2,2),16);return s}function ts(t){const s=t.length%2!==0,r=s?"0"+t:t,o=so(r),n=new Uint8Array(1+o.length);return n[0]=s?1:0,n.set(o,1),n}function Ur(t){const s=t[0];if(s===0||s===1){const o=s===1,n=t.subarray(1),a=Us(n),i=o?a.substring(1):a;if(/^[0-9a-f]/.test(i))return i}const r=Us(t);return r.startsWith("0")&&!r.startsWith("00")?r.substring(1):r}function Lt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ro(t,s){return Array.isArray(s)?s.length===0?!0:t?s.every(r=>typeof r=="string"):s.every(r=>Number.isSafeInteger(r)):!1}function Qi(t){if(typeof t!="function")throw new Error("function expected");return!0}function Pt(t,s){if(typeof s!="string")throw new Error(`${t}: string expected`);return!0}function et(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Rt(t){if(!Array.isArray(t))throw new Error("array expected")}function Tt(t,s){if(!ro(!0,s))throw new Error(`${t}: array of strings expected`)}function no(t,s){if(!ro(!1,s))throw new Error(`${t}: array of numbers expected`)}function Gi(...t){const s=a=>a,r=(a,i)=>l=>a(i(l)),o=t.map(a=>a.encode).reduceRight(r,s),n=t.map(a=>a.decode).reduce(r,s);return{encode:o,decode:n}}function Ki(t){const s=typeof t=="string"?t.split(""):t,r=s.length;Tt("alphabet",s);const o=new Map(s.map((n,a)=>[n,a]));return{encode:n=>(Rt(n),n.map(a=>{if(!Number.isSafeInteger(a)||a<0||a>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${t}`);return s[a]})),decode:n=>(Rt(n),n.map(a=>{Pt("alphabet.decode",a);const i=o.get(a);if(i===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${t}`);return i}))}}function Yi(t=""){return Pt("join",t),{encode:s=>(Tt("join.decode",s),s.join(t)),decode:s=>(Pt("join.decode",s),s.split(t))}}function Zi(t,s="="){return et(t),Pt("padding",s),{encode(r){for(Tt("padding.encode",r);r.length*t%8;)r.push(s);return r},decode(r){Tt("padding.decode",r);let o=r.length;if(o*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===s;o--)if((o-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function Fs(t,s,r){if(s<2)throw new Error(`convertRadix: invalid from=${s}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Rt(t),!t.length)return[];let o=0;const n=[],a=Array.from(t,l=>{if(et(l),l<0||l>=s)throw new Error(`invalid integer: ${l}`);return l}),i=a.length;for(;;){let l=0,c=!0;for(let h=o;h<i;h++){const m=a[h],u=s*l,p=u+m;if(!Number.isSafeInteger(p)||u/s!==l||p-m!==u)throw new Error("convertRadix: carry overflow");const b=p/r;l=p%r;const w=Math.floor(b);if(a[h]=w,!Number.isSafeInteger(w)||w*r+l!==p)throw new Error("convertRadix: carry overflow");if(c)w?c=!1:o=h;else continue}if(n.push(l),c)break}for(let l=0;l<t.length-1&&t[l]===0;l++)n.push(0);return n.reverse()}const oo=(t,s)=>s===0?t:oo(s,t%s),Mt=(t,s)=>t+(s-oo(t,s)),ss=(()=>{let t=[];for(let s=0;s<40;s++)t.push(2**s);return t})();function Ws(t,s,r,o){if(Rt(t),s<=0||s>32)throw new Error(`convertRadix2: wrong from=${s}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Mt(s,r)>32)throw new Error(`convertRadix2: carry overflow from=${s} to=${r} carryBits=${Mt(s,r)}`);let n=0,a=0;const i=ss[s],l=ss[r]-1,c=[];for(const h of t){if(et(h),h>=i)throw new Error(`convertRadix2: invalid data word=${h} from=${s}`);if(n=n<<s|h,a+s>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${s}`);for(a+=s;a>=r;a-=r)c.push((n>>a-r&l)>>>0);const m=ss[a];if(m===void 0)throw new Error("invalid carry");n&=m-1}if(n=n<<r-a&l,!o&&a>=s)throw new Error("Excess padding");if(!o&&n>0)throw new Error(`Non-zero padding: ${n}`);return o&&a>0&&c.push(n>>>0),c}function Xi(t){et(t);const s=2**8;return{encode:r=>{if(!Lt(r))throw new Error("radix.encode input should be Uint8Array");return Fs(Array.from(r),s,t)},decode:r=>(no("radix.decode",r),Uint8Array.from(Fs(r,t,s)))}}function Ji(t,s=!1){if(et(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(Mt(8,t)>32||Mt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Lt(r))throw new Error("radix2.encode input should be Uint8Array");return Ws(Array.from(r),8,t,!s)},decode:r=>(no("radix2.decode",r),Uint8Array.from(Ws(r,t,8,s)))}}function ec(t,s){return et(t),Qi(s),{encode(r){if(!Lt(r))throw new Error("checksum.encode: input should be Uint8Array");const o=s(r).slice(0,t),n=new Uint8Array(r.length+t);return n.set(r),n.set(o,r.length),n},decode(r){if(!Lt(r))throw new Error("checksum.decode: input should be Uint8Array");const o=r.slice(0,-t),n=r.slice(-t),a=s(o).slice(0,t);for(let i=0;i<t;i++)if(a[i]!==n[i])throw new Error("Invalid checksum");return o}}}const pt={alphabet:Ki,chain:Gi,checksum:ec,convertRadix:Fs,convertRadix2:Ws,radix:Xi,radix2:Ji,join:Yi,padding:Zi};const tc=t=>t[0]==="あいこくしん";function sc(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function rc(t){const s=sc(t),r=s.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:s,words:r}}function ao(t){Ut(t,16,20,24,28,32)}const nc=t=>{const s=8-t.length/4;return new Uint8Array([Xn(t)[0]>>s<<s])};function io(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return t.forEach(s=>{if(typeof s!="string")throw new Error("wordlist: non-string element: "+s)}),pt.chain(pt.checksum(1,nc),pt.radix2(11,!0),pt.alphabet(t))}function er(t,s){const{words:r}=rc(t),o=io(s).decode(r);return ao(o),o}function co(t,s){return ao(t),io(s).encode(t).join(tc(s)?" ":" ")}function tr(t,s){try{er(t,s)}catch{return!1}return!0}const Se=`abandon
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./useAuth-2vgrAH-M.cjs"),M=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),c=require("react"),Q=require("./LoadingSpinner-d6sSxgQN.cjs"),es=require("./useServerFeatures-9_aNPaa6.cjs"),J=require("./EmailRegisterForm-ByYQ43yL.cjs"),We=require("./validation-BuGQrA-K.cjs"),te=require("./ErrorMessage-CHbYbVi2.cjs"),Ht=require("./GoogleLoginButton-DEwtBp56.cjs"),Ze=require("./SolanaLoginButton-2504p6cr.cjs"),fe=require("./PermissionsSection-CZsJuxo4.cjs"),Gt=require("./useSystemSettings-B2jY51ob.cjs"),ke=require("./AutosaveStatus-DfMPudTQ.cjs"),_s=require("./AdminDepositList-B_z6x3j5.cjs"),Me=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),Ie=require("./useUsersStatsSummary-CHRMrlk4.cjs"),Pn=require("./StatsBar-DTUZCwDD.cjs"),Qt=require("./useOrgs-CNqfn-fk.cjs"),Be=require("./plugin-DNFjEfYp.cjs"),Rn=require("./AuthenticationSettings-BBOjHR6j.cjs"),Tn=require("./EmbeddedWalletSettings-Db9a0D5l.cjs"),ks=require("./EmailSettings-DIjo3aJo.cjs"),Kt=require("./CreditSystemSettings-Badz4iAc.cjs"),Mn=require("./ServerSettings-j5Lu5D-R.cjs"),ss=require("./WebhookSettings-DOaydSWQ.cjs"),Sa=require("./useAdminDeposits-CpLd68oP.cjs");async function In(s,t,r=D.DEFAULT_KDF_PARAMS){return D.validateKdfParams(r),D.argon2Derive(s,t,r)}function Bn(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ca(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var r=function o(){var n=!1;try{n=this instanceof o}catch{}return n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(s).forEach(function(o){var n=Object.getOwnPropertyDescriptor(s,o);Object.defineProperty(r,o,n.get?n:{enumerable:!0,get:function(){return s[o]}})}),r}var Ss={exports:{}};const Ea=globalThis.crypto,_a=globalThis.crypto,La=globalThis.crypto.subtle,Pa=globalThis.crypto.getRandomValues.bind(globalThis.crypto),Ra=globalThis.crypto.randomUUID.bind(globalThis.crypto),Ta=Object.freeze(Object.defineProperty({__proto__:null,default:Ea,getRandomValues:Pa,randomUUID:Ra,subtle:La,webcrypto:_a},Symbol.toStringTag,{value:"Module"})),Ma=Ca(Ta);var Ia=Ss.exports,vr;function Ba(){return vr||(vr=1,(function(s,t){(function(r,o){s.exports=o(Ma)})(Ia,function(r){var o,n,a,i,d;function l(){o={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},n={},a=new Array(1024).join("0"),i=!0,d=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function h(){return!!(n&&n.rng&&typeof n.rng=="function")}function m(p,y){var x;if(y===0||y===1)return p;if(y&&y>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return y=y||n.bits,p&&(x=p.length%y),x?(a+p).slice(-(y-x+p.length)):p}function u(p){var y="",x,j;for(j=p.length-1;j>=0;j--){if(x=parseInt(p[j],16),isNaN(x))throw new Error("Invalid hex character.");y=m(x.toString(2),4)+y}return y}function f(p){var y="",x,j;for(p=m(p,4),j=p.length;j>=4;j-=4){if(x=parseInt(p.slice(j-4,j),2),isNaN(x))throw new Error("Invalid binary character.");y=x.toString(16)+y}return y}function w(){return!!(r&&typeof r=="object"&&(typeof r.getRandomValues=="function"||typeof r.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function b(){return typeof r=="object"&&typeof r.randomBytes=="function"}function g(p){function y(C,P,_,R){var T=0,I,O="",W;for(P&&(I=P.length-1);T<I||O.length<C;)W=Math.abs(parseInt(P[T],_)),O=O+m(W.toString(2),R),T++;return O=O.substr(-C),(O.match(/0/g)||[]).length===O.length?null:O}function x(C){var P,_,R,T,I=null;for(R=16,T=4,_=Math.ceil(C/8);I===null;)P=r.randomBytes(_),I=y(C,P.toString("hex"),R,T);return I}function j(C){var P,_,R,T=null;for(_=10,R=32,P=Math.ceil(C/32);T===null;)T=y(C,r.getRandomValues(new Uint32Array(P)),_,R);return T}function L(C){var P,_,R,T,I,O=null;T=10,I=32,_=Math.ceil(C/32),R=123456789,P=new Uint32Array(_);for(var W=0;W<P.length;W++)P[W]=R;for(;O===null;)O=y(C,P,T,I);return O}if(p&&p==="testRandom")return n.typeCSPRNG=p,L;if(p&&p==="nodeCryptoRandomBytes")return n.typeCSPRNG=p,x;if(p&&p==="browserCryptoGetRandomValues")return n.typeCSPRNG=p,j;if(b())return n.typeCSPRNG="nodeCryptoRandomBytes",x;if(w())return n.typeCSPRNG="browserCryptoGetRandomValues",j}function N(p,y){var x=[],j;for(y&&(p=m(p,y)),j=p.length;j>n.bits;j-=n.bits)x.push(parseInt(p.slice(j-n.bits,j),2));return x.push(parseInt(p.slice(0,j),2)),x}function A(p,y){var x=n.logs[p],j=0,L;for(L=y.length-1;L>=0;L--)j!==0?j=n.exps[(x+n.logs[j])%n.maxShares]^y[L]:j=y[L];return j}function v(p,y,x){var j=0,L,C,P,_;for(P=0,L=y.length;P<L;P++)if(x[P]){for(C=n.logs[x[P]],_=0;_<L;_++)if(P!==_){if(p===y[_]){C=-1;break}C=(C+n.logs[p^y[_]]-n.logs[y[P]^y[_]]+n.maxShares)%n.maxShares}j=C===-1?j:j^n.exps[C]}return j}function k(p,y,x){var j=[],L=[p],C,P;for(C=1;C<x;C++)L[C]=parseInt(n.rng(n.bits),2);for(C=1,P=y+1;C<P;C++)j[C-1]={x:C,y:A(C,L)};return j}function S(p,y,x){var j,L,C,P,_;if(y=parseInt(y,n.radix),p=parseInt(p,10)||n.bits,j=p.toString(36).toUpperCase(),C=Math.pow(2,p)-1,P=C.toString(n.radix).length,L=m(y.toString(n.radix),P),typeof y!="number"||y%1!==0||y<1||y>C)throw new Error("Share id must be an integer between 1 and "+C+", inclusive.");return _=j+L+x,_}var E={init:function(p,y){var x=[],j=[],L=1,C,P;if(l(),p&&(typeof p!="number"||p%1!==0||p<o.minBits||p>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(y&&d.indexOf(y)===-1)throw new Error("Invalid RNG type argument : '"+y+"'");for(n.radix=o.radix,n.bits=p||o.bits,n.size=Math.pow(2,n.bits),n.maxShares=n.size-1,C=o.primitivePolynomials[n.bits],P=0;P<n.size;P++)j[P]=L,x[L]=P,L=L<<1,L>=n.size&&(L=L^C,L=L&n.maxShares);if(n.logs=x,n.exps=j,y&&this.setRNG(y),h()||this.setRNG(),!h()||!n.bits||!n.size||!n.maxShares||!n.logs||!n.exps||n.logs.length!==n.size||n.exps.length!==n.size)throw new Error("Initialization failed.")},combine:function(p,y){var x,j,L,C,P="",_,R,T,I=[],O=[];for(y=y||0,x=0,L=p.length;x<L;x++){if(R=this.extractShareComponents(p[x]),_===void 0)_=R.bits;else if(R.bits!==_)throw new Error("Mismatched shares: Different bit settings.");if(n.bits!==_&&this.init(_),I.indexOf(R.id)===-1)for(I.push(R.id),T=N(u(R.data)),j=0,C=T.length;j<C;j++)O[j]=O[j]||[],O[j][I.length-1]=T[j]}for(x=0,L=O.length;x<L;x++)P=m(v(y,I,O[x]).toString(2))+P;return f(y>=1?P:P.slice(P.indexOf("1")+1))},getConfig:function(){var p={};return p.radix=n.radix,p.bits=n.bits,p.maxShares=n.maxShares,p.hasCSPRNG=h(),p.typeCSPRNG=n.typeCSPRNG,p},extractShareComponents:function(p){var y,x,j,L,C={},P,_;if(y=parseInt(p.substr(0,1),36),y&&(typeof y!="number"||y%1!==0||y<o.minBits||y>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(L=Math.pow(2,y)-1,j=(Math.pow(2,y)-1).toString(n.radix).length,P="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+j+"})([a-fA-F0-9]+)$",_=new RegExp(P).exec(p),_&&(x=parseInt(_[2],n.radix)),typeof x!="number"||x%1!==0||x<1||x>L)throw new Error("Invalid share : Share id must be an integer between 1 and "+n.maxShares+", inclusive.");if(_&&_[3])return C.bits=y,C.id=x,C.data=_[3],C;throw new Error("The share data provided is invalid : "+p)},setRNG:function(p){var y="Random number generator is invalid ",x=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(p&&typeof p=="string"&&d.indexOf(p)===-1)throw new Error("Invalid RNG type argument : '"+p+"'");if(p||(p=g()),p&&typeof p=="string"&&(p=g(p)),i){if(p&&typeof p!="function")throw new Error(y+"(Not a function)."+x);if(p&&typeof p(n.bits)!="string")throw new Error(y+"(Output is not a string)."+x);if(p&&!parseInt(p(n.bits),2))throw new Error(y+"(Binary string output not parseable to an Integer)."+x);if(p&&p(n.bits).length>n.bits)throw new Error(y+"(Output length is greater than config.bits)."+x);if(p&&p(n.bits).length<n.bits)throw new Error(y+"(Output length is less than config.bits)."+x)}return n.rng=p,!0},str2hex:function(p,y){var x,j,L="",C,P,_,R;if(typeof p!="string")throw new Error("Input must be a character string.");if(y||(y=o.bytesPerChar),typeof y!="number"||y<1||y>o.maxBytesPerChar||y%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,j=Math.pow(16,x)-1,_=0,R=p.length;_<R;_++){if(P=p[_].charCodeAt(),isNaN(P))throw new Error("Invalid character: "+p[_]);if(P>j)throw C=Math.ceil(Math.log(P+1)/Math.log(256)),new Error("Invalid character code ("+P+"). Maximum allowable is 256^bytes-1 ("+j+"). To convert this character, use at least "+C+" bytes.");L=m(P.toString(16),x)+L}return L},hex2str:function(p,y){var x,j="",L,C;if(typeof p!="string")throw new Error("Input must be a hexadecimal string.");if(y=y||o.bytesPerChar,typeof y!="number"||y%1!==0||y<1||y>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,p=m(p,x),L=0,C=p.length;L<C;L+=x)j=String.fromCharCode(parseInt(p.slice(L,L+x),16))+j;return j},random:function(p){if(typeof p!="number"||p%1!==0||p<2||p>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return f(n.rng(p))},share:function(p,y,x,j){var L,C,P=new Array(y),_=new Array(y),R,T,I;if(j=j||128,typeof p!="string")throw new Error("Secret must be a string.");if(typeof y!="number"||y%1!==0||y<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(y>n.maxShares)throw L=Math.ceil(Math.log(y+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To create "+y+" shares, use at least "+L+" bits.");if(typeof x!="number"||x%1!==0||x<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(x>n.maxShares)throw L=Math.ceil(Math.log(x+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To use a threshold of "+x+", use at least "+L+" bits.");if(x>y)throw new Error("Threshold number of shares was "+x+" but must be less than or equal to the "+y+" shares specified as the total to generate.");if(typeof j!="number"||j%1!==0||j<0||j>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(p="1"+u(p),p=N(p,j),R=0,I=p.length;R<I;R++)for(C=k(p[R],y,x),T=0;T<y;T++)P[T]=P[T]||C[T].x.toString(n.radix),_[T]=m(C[T].y.toString(2))+(_[T]||"");for(R=0;R<y;R++)P[R]=S(n.bits,P[R],f(_[R]));return P},newShare:function(p,y){var x,j;if(p&&typeof p=="string"&&(p=parseInt(p,n.radix)),j=p.toString(n.radix),p&&j&&y&&y[0])return x=this.extractShareComponents(y[0]),S(x.bits,j,this.combine(y,p));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:l,_padLeft:m,_hex2bin:u,_bin2hex:f,_hasCryptoGetRandomValues:w,_hasCryptoRandomBytes:b,_getRNG:g,_isSetRNG:h,_splitNumStringToIntArray:N,_horner:A,_lagrange:v,_getShares:k,_constructPublicShareString:S};return E.init(),E})})(Ss)),Ss.exports}var Ua=Ba();const Un=Bn(Ua);function Dn(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Yt(s,t=""){if(!Number.isSafeInteger(s)||s<0){const r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${s}`)}}function ie(s,t,r=""){const o=Dn(s),n=s?.length,a=t!==void 0;if(!o||a&&n!==t){const i=r&&`"${r}" `,d=a?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof s}`;throw new Error(i+"expected Uint8Array"+d+", got "+l)}return s}function Ar(s,t=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(t&&s.finished)throw new Error("Hash#digest() has already been called")}function Da(s,t){ie(s,void 0,"digestInto() output");const r=t.outputLen;if(s.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Bt(...s){for(let t=0;t<s.length;t++)s[t].fill(0)}function Ys(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}const Fn=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Fa=Array.from({length:256},(s,t)=>t.toString(16).padStart(2,"0"));function Zt(s){if(ie(s),Fn)return s.toHex();let t="";for(let r=0;r<s.length;r++)t+=Fa[s[r]];return t}const je={_0:48,_9:57,A:65,F:70,a:97,f:102};function jr(s){if(s>=je._0&&s<=je._9)return s-je._0;if(s>=je.A&&s<=je.F)return s-(je.A-10);if(s>=je.a&&s<=je.f)return s-(je.a-10)}function On(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(Fn)return Uint8Array.fromHex(s);const t=s.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const o=new Uint8Array(r);for(let n=0,a=0;n<r;n++,a+=2){const i=jr(s.charCodeAt(a)),d=jr(s.charCodeAt(a+1));if(i===void 0||d===void 0){const l=s[a]+s[a+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+a)}o[n]=i*16+d}return o}function Nr(...s){let t=0;for(let o=0;o<s.length;o++){const n=s[o];ie(n),t+=n.length}const r=new Uint8Array(t);for(let o=0,n=0;o<s.length;o++){const a=s[o];r.set(a,n),n+=a.length}return r}function Oa(s,t={}){const r=(n,a)=>s(a).update(n).digest(),o=s(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=n=>s(n),Object.assign(r,t),Object.freeze(r)}function Wa(s=32){const t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(s))}const qa=s=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,s])});let za=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,o,n){this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=Ys(this.buffer)}update(t){Ar(this),ie(t);const{view:r,buffer:o,blockLen:n}=this,a=t.length;for(let i=0;i<a;){const d=Math.min(n-this.pos,a-i);if(d===n){const l=Ys(t);for(;n<=a-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+d),this.pos),this.pos+=d,i+=d,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ar(this),Da(t,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Bt(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;o.setBigUint64(n-8,BigInt(this.length*8),a),this.process(o,0);const d=Ys(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const h=l/4,m=this.get();if(h>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)d.setUint32(4*u,m[u],a)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:d}=this;return t.destroyed=i,t.finished=a,t.length=n,t.pos=d,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}};const ce=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ps=BigInt(2**32-1),kr=BigInt(32);function $a(s,t=!1){return t?{h:Number(s&ps),l:Number(s>>kr&ps)}:{h:Number(s>>kr&ps)|0,l:Number(s&ps)|0}}function Va(s,t=!1){const r=s.length;let o=new Uint32Array(r),n=new Uint32Array(r);for(let a=0;a<r;a++){const{h:i,l:d}=$a(s[a],t);[o[a],n[a]]=[i,d]}return[o,n]}const Sr=(s,t,r)=>s>>>r,Cr=(s,t,r)=>s<<32-r|t>>>r,Ge=(s,t,r)=>s>>>r|t<<32-r,Qe=(s,t,r)=>s<<32-r|t>>>r,fs=(s,t,r)=>s<<64-r|t>>>r-32,gs=(s,t,r)=>s>>>r-32|t<<64-r;function Ne(s,t,r,o){const n=(t>>>0)+(o>>>0);return{h:s+r+(n/2**32|0)|0,l:n|0}}const Ha=(s,t,r)=>(s>>>0)+(t>>>0)+(r>>>0),Ga=(s,t,r,o)=>t+r+o+(s/2**32|0)|0,Qa=(s,t,r,o)=>(s>>>0)+(t>>>0)+(r>>>0)+(o>>>0),Ka=(s,t,r,o,n)=>t+r+o+n+(s/2**32|0)|0,Ya=(s,t,r,o,n)=>(s>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),Za=(s,t,r,o,n,a)=>t+r+o+n+a+(s/2**32|0)|0,Wn=Va(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(s=>BigInt(s))),Xa=Wn[0],Ja=Wn[1],Ee=new Uint32Array(80),_e=new Uint32Array(80);class ei extends za{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:r,Bh:o,Bl:n,Ch:a,Cl:i,Dh:d,Dl:l,Eh:h,El:m,Fh:u,Fl:f,Gh:w,Gl:b,Hh:g,Hl:N}=this;return[t,r,o,n,a,i,d,l,h,m,u,f,w,b,g,N]}set(t,r,o,n,a,i,d,l,h,m,u,f,w,b,g,N){this.Ah=t|0,this.Al=r|0,this.Bh=o|0,this.Bl=n|0,this.Ch=a|0,this.Cl=i|0,this.Dh=d|0,this.Dl=l|0,this.Eh=h|0,this.El=m|0,this.Fh=u|0,this.Fl=f|0,this.Gh=w|0,this.Gl=b|0,this.Hh=g|0,this.Hl=N|0}process(t,r){for(let k=0;k<16;k++,r+=4)Ee[k]=t.getUint32(r),_e[k]=t.getUint32(r+=4);for(let k=16;k<80;k++){const S=Ee[k-15]|0,E=_e[k-15]|0,p=Ge(S,E,1)^Ge(S,E,8)^Sr(S,E,7),y=Qe(S,E,1)^Qe(S,E,8)^Cr(S,E,7),x=Ee[k-2]|0,j=_e[k-2]|0,L=Ge(x,j,19)^fs(x,j,61)^Sr(x,j,6),C=Qe(x,j,19)^gs(x,j,61)^Cr(x,j,6),P=Qa(y,C,_e[k-7],_e[k-16]),_=Ka(P,p,L,Ee[k-7],Ee[k-16]);Ee[k]=_|0,_e[k]=P|0}let{Ah:o,Al:n,Bh:a,Bl:i,Ch:d,Cl:l,Dh:h,Dl:m,Eh:u,El:f,Fh:w,Fl:b,Gh:g,Gl:N,Hh:A,Hl:v}=this;for(let k=0;k<80;k++){const S=Ge(u,f,14)^Ge(u,f,18)^fs(u,f,41),E=Qe(u,f,14)^Qe(u,f,18)^gs(u,f,41),p=u&w^~u&g,y=f&b^~f&N,x=Ya(v,E,y,Ja[k],_e[k]),j=Za(x,A,S,p,Xa[k],Ee[k]),L=x|0,C=Ge(o,n,28)^fs(o,n,34)^fs(o,n,39),P=Qe(o,n,28)^gs(o,n,34)^gs(o,n,39),_=o&a^o&d^a&d,R=n&i^n&l^i&l;A=g|0,v=N|0,g=w|0,N=b|0,w=u|0,b=f|0,{h:u,l:f}=Ne(h|0,m|0,j|0,L|0),h=d|0,m=l|0,d=a|0,l=i|0,a=o|0,i=n|0;const T=Ha(L,P,R);o=Ga(T,j,C,_),n=T|0}({h:o,l:n}=Ne(this.Ah|0,this.Al|0,o|0,n|0)),{h:a,l:i}=Ne(this.Bh|0,this.Bl|0,a|0,i|0),{h:d,l}=Ne(this.Ch|0,this.Cl|0,d|0,l|0),{h,l:m}=Ne(this.Dh|0,this.Dl|0,h|0,m|0),{h:u,l:f}=Ne(this.Eh|0,this.El|0,u|0,f|0),{h:w,l:b}=Ne(this.Fh|0,this.Fl|0,w|0,b|0),{h:g,l:N}=Ne(this.Gh|0,this.Gl|0,g|0,N|0),{h:A,l:v}=Ne(this.Hh|0,this.Hl|0,A|0,v|0),this.set(o,n,a,i,d,l,h,m,u,f,w,b,g,N,A,v)}roundClean(){Bt(Ee,_e)}destroy(){Bt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class si extends ei{Ah=ce[0]|0;Al=ce[1]|0;Bh=ce[2]|0;Bl=ce[3]|0;Ch=ce[4]|0;Cl=ce[5]|0;Dh=ce[6]|0;Dl=ce[7]|0;Eh=ce[8]|0;El=ce[9]|0;Fh=ce[10]|0;Fl=ce[11]|0;Gh=ce[12]|0;Gl=ce[13]|0;Hh=ce[14]|0;Hl=ce[15]|0;constructor(){super(64)}}const ti=Oa(()=>new si,qa(3));const qn=BigInt(0),Er=BigInt(1);function Ut(s,t=""){if(typeof s!="boolean"){const r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof s)}return s}function ri(s){if(typeof s=="bigint"){if(!Cs(s))throw new Error("positive bigint expected, got "+s)}else Yt(s);return s}function zn(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?qn:BigInt("0x"+s)}function ni(s){return zn(Zt(s))}function Ls(s){return zn(Zt(Dt(ie(s)).reverse()))}function $n(s,t){Yt(t),s=ri(s);const r=On(s.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function oi(s,t){return $n(s,t).reverse()}function Dt(s){return Uint8Array.from(s)}const Cs=s=>typeof s=="bigint"&&qn<=s;function ai(s,t,r){return Cs(s)&&Cs(t)&&Cs(r)&&t<=s&&s<r}function _r(s,t,r,o){if(!ai(t,r,o))throw new Error("expected valid "+s+": "+r+" <= n < "+o+", got "+t)}const ii=s=>(Er<<BigInt(s))-Er;function Xt(s,t={},r={}){if(!s||typeof s!="object")throw new Error("expected valid options object");function o(a,i,d){const l=s[a];if(d&&l===void 0)return;const h=typeof l;if(h!==i||l===null)throw new Error(`param "${a}" is invalid: expected ${i}, got ${h}`)}const n=(a,i)=>Object.entries(a).forEach(([d,l])=>o(d,l,i));n(t,!1),n(r,!0)}function Lr(s){const t=new WeakMap;return(r,...o)=>{const n=t.get(r);if(n!==void 0)return n;const a=s(r,...o);return t.set(r,a),a}}const he=BigInt(0),de=BigInt(1),Oe=BigInt(2),Vn=BigInt(3),Hn=BigInt(4),Gn=BigInt(5),ci=BigInt(7),Qn=BigInt(8),li=BigInt(9),Kn=BigInt(16);function oe(s,t){const r=s%t;return r>=he?r:t+r}function ye(s,t,r){let o=s;for(;t-- >he;)o*=o,o%=r;return o}function Pr(s,t){if(s===he)throw new Error("invert: expected non-zero number");if(t<=he)throw new Error("invert: expected positive modulus, got "+t);let r=oe(s,t),o=t,n=he,a=de;for(;r!==he;){const d=o/r,l=o%r,h=n-a*d;o=r,r=l,n=a,a=h}if(o!==de)throw new Error("invert: does not exist");return oe(n,t)}function Jt(s,t,r){if(!s.eql(s.sqr(t),r))throw new Error("Cannot find square root")}function Yn(s,t){const r=(s.ORDER+de)/Hn,o=s.pow(t,r);return Jt(s,o,t),o}function di(s,t){const r=(s.ORDER-Gn)/Qn,o=s.mul(t,Oe),n=s.pow(o,r),a=s.mul(t,n),i=s.mul(s.mul(a,Oe),n),d=s.mul(a,s.sub(i,s.ONE));return Jt(s,d,t),d}function ui(s){const t=er(s),r=Zn(s),o=r(t,t.neg(t.ONE)),n=r(t,o),a=r(t,t.neg(o)),i=(s+ci)/Kn;return(d,l)=>{let h=d.pow(l,i),m=d.mul(h,o);const u=d.mul(h,n),f=d.mul(h,a),w=d.eql(d.sqr(m),l),b=d.eql(d.sqr(u),l);h=d.cmov(h,m,w),m=d.cmov(f,u,b);const g=d.eql(d.sqr(m),l),N=d.cmov(h,m,g);return Jt(d,N,l),N}}function Zn(s){if(s<Vn)throw new Error("sqrt is not defined for small field");let t=s-de,r=0;for(;t%Oe===he;)t/=Oe,r++;let o=Oe;const n=er(s);for(;Rr(n,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Yn;let a=n.pow(o,t);const i=(t+de)/Oe;return function(l,h){if(l.is0(h))return h;if(Rr(l,h)!==1)throw new Error("Cannot find square root");let m=r,u=l.mul(l.ONE,a),f=l.pow(h,t),w=l.pow(h,i);for(;!l.eql(f,l.ONE);){if(l.is0(f))return l.ZERO;let b=1,g=l.sqr(f);for(;!l.eql(g,l.ONE);)if(b++,g=l.sqr(g),b===m)throw new Error("Cannot find square root");const N=de<<BigInt(m-b-1),A=l.pow(u,N);m=b,u=l.sqr(A),f=l.mul(f,u),w=l.mul(w,A)}return w}}function hi(s){return s%Hn===Vn?Yn:s%Qn===Gn?di:s%Kn===li?ui(s):Zn(s)}const mi=(s,t)=>(oe(s,t)&de)===de,pi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fi(s){const t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=pi.reduce((o,n)=>(o[n]="function",o),t);return Xt(s,r),s}function gi(s,t,r){if(r<he)throw new Error("invalid exponent, negatives unsupported");if(r===he)return s.ONE;if(r===de)return t;let o=s.ONE,n=t;for(;r>he;)r&de&&(o=s.mul(o,n)),n=s.sqr(n),r>>=de;return o}function Xn(s,t,r=!1){const o=new Array(t.length).fill(r?s.ZERO:void 0),n=t.reduce((i,d,l)=>s.is0(d)?i:(o[l]=i,s.mul(i,d)),s.ONE),a=s.inv(n);return t.reduceRight((i,d,l)=>s.is0(d)?i:(o[l]=s.mul(i,o[l]),s.mul(i,d)),a),o}function Rr(s,t){const r=(s.ORDER-de)/Oe,o=s.pow(t,r),n=s.eql(o,s.ONE),a=s.eql(o,s.ZERO),i=s.eql(o,s.neg(s.ONE));if(!n&&!a&&!i)throw new Error("invalid Legendre symbol result");return n?1:a?0:-1}function wi(s,t){t!==void 0&&Yt(t);const r=t!==void 0?t:s.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class bi{ORDER;BITS;BYTES;isLE;ZERO=he;ONE=de;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=he)throw new Error("invalid field: expected ORDER > 0, got "+t);let o;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(o=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));const{nBitLength:n,nByteLength:a}=wi(t,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=n,this.BYTES=a,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return oe(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return he<=t&&t<this.ORDER}is0(t){return t===he}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&de)===de}neg(t){return oe(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return oe(t*t,this.ORDER)}add(t,r){return oe(t+r,this.ORDER)}sub(t,r){return oe(t-r,this.ORDER)}mul(t,r){return oe(t*r,this.ORDER)}pow(t,r){return gi(this,t,r)}div(t,r){return oe(t*Pr(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Pr(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=hi(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?oi(t,this.BYTES):$n(t,this.BYTES)}fromBytes(t,r=!1){ie(t);const{_lengths:o,BYTES:n,isLE:a,ORDER:i,_mod:d}=this;if(o){if(!o.includes(t.length)||t.length>n)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);const h=new Uint8Array(n);h.set(t,a?0:h.length-t.length),t=h}if(t.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=a?Ls(t):ni(t);if(d&&(l=oe(l,i)),!r&&!this.isValid(l))throw new Error("invalid field element: outside of range 0..ORDER");return l}invertBatch(t){return Xn(this,t)}cmov(t,r,o){return o?r:t}}function er(s,t={}){return new bi(s,t)}const Ps=BigInt(0),Ft=BigInt(1);function Tr(s,t){const r=t.negate();return s?r:t}function Zs(s,t){const r=Xn(s.Fp,t.map(o=>o.Z));return t.map((o,n)=>s.fromAffine(o.toAffine(r[n])))}function Jn(s,t){if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+s)}function Xs(s,t){Jn(s,t);const r=Math.ceil(t/s)+1,o=2**(s-1),n=2**s,a=ii(s),i=BigInt(s);return{windows:r,windowSize:o,mask:a,maxNumber:n,shiftBy:i}}function Mr(s,t,r){const{windowSize:o,mask:n,maxNumber:a,shiftBy:i}=r;let d=Number(s&n),l=s>>i;d>o&&(d-=a,l+=Ft);const h=t*o,m=h+Math.abs(d)-1,u=d===0,f=d<0,w=t%2!==0;return{nextN:l,offset:m,isZero:u,isNeg:f,isNegF:w,offsetF:h}}const Js=new WeakMap,eo=new WeakMap;function et(s){return eo.get(s)||1}function Ir(s){if(s!==Ps)throw new Error("invalid wNAF")}class xi{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,o=this.ZERO){let n=t;for(;r>Ps;)r&Ft&&(o=o.add(n)),n=n.double(),r>>=Ft;return o}precomputeWindow(t,r){const{windows:o,windowSize:n}=Xs(r,this.bits),a=[];let i=t,d=i;for(let l=0;l<o;l++){d=i,a.push(d);for(let h=1;h<n;h++)d=d.add(i),a.push(d);i=d.double()}return a}wNAF(t,r,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let n=this.ZERO,a=this.BASE;const i=Xs(t,this.bits);for(let d=0;d<i.windows;d++){const{nextN:l,offset:h,isZero:m,isNeg:u,isNegF:f,offsetF:w}=Mr(o,d,i);o=l,m?a=a.add(Tr(f,r[w])):n=n.add(Tr(u,r[h]))}return Ir(o),{p:n,f:a}}wNAFUnsafe(t,r,o,n=this.ZERO){const a=Xs(t,this.bits);for(let i=0;i<a.windows&&o!==Ps;i++){const{nextN:d,offset:l,isZero:h,isNeg:m}=Mr(o,i,a);if(o=d,!h){const u=r[l];n=n.add(m?u.negate():u)}}return Ir(o),n}getPrecomputes(t,r,o){let n=Js.get(r);return n||(n=this.precomputeWindow(r,t),t!==1&&(typeof o=="function"&&(n=o(n)),Js.set(r,n))),n}cached(t,r,o){const n=et(t);return this.wNAF(n,this.getPrecomputes(n,t,o),r)}unsafe(t,r,o,n){const a=et(t);return a===1?this._unsafeLadder(t,r,n):this.wNAFUnsafe(a,this.getPrecomputes(a,t,o),r,n)}createCache(t,r){Jn(r,this.bits),eo.set(t,r),Js.delete(t)}hasCache(t){return et(t)!==1}}function Br(s,t,r){if(t){if(t.ORDER!==s)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return fi(t),t}else return er(s,{isLE:r})}function yi(s,t,r={},o){if(o===void 0&&(o=s==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${s} CURVE object`);for(const l of["p","n","h"]){const h=t[l];if(!(typeof h=="bigint"&&h>Ps))throw new Error(`CURVE.${l} must be positive bigint`)}const n=Br(t.p,r.Fp,o),a=Br(t.n,r.Fn,o),d=["Gx","Gy","a","d"];for(const l of d)if(!n.isValid(t[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:a}}function vi(s,t){return function(o){const n=s(o);return{secretKey:n,publicKey:t(n)}}}const Le=BigInt(0),ae=BigInt(1),st=BigInt(2),Ai=BigInt(8);function ji(s,t,r,o){const n=s.sqr(r),a=s.sqr(o),i=s.add(s.mul(t.a,n),a),d=s.add(s.ONE,s.mul(t.d,s.mul(n,a)));return s.eql(i,d)}function Ni(s,t={}){const r=yi("edwards",s,t,t.FpFnLE),{Fp:o,Fn:n}=r;let a=r.CURVE;const{h:i}=a;Xt(t,{},{uvRatio:"function"});const d=st<<BigInt(n.BYTES*8)-ae,l=N=>o.create(N),h=t.uvRatio||((N,A)=>{try{return{isValid:!0,value:o.sqrt(o.div(N,A))}}catch{return{isValid:!1,value:Le}}});if(!ji(o,a,a.Gx,a.Gy))throw new Error("bad curve params: generator point");function m(N,A,v=!1){const k=v?ae:Le;return _r("coordinate "+N,A,k,d),A}function u(N){if(!(N instanceof b))throw new Error("EdwardsPoint expected")}const f=Lr((N,A)=>{const{X:v,Y:k,Z:S}=N,E=N.is0();A==null&&(A=E?Ai:o.inv(S));const p=l(v*A),y=l(k*A),x=o.mul(S,A);if(E)return{x:Le,y:ae};if(x!==ae)throw new Error("invZ was invalid");return{x:p,y}}),w=Lr(N=>{const{a:A,d:v}=a;if(N.is0())throw new Error("bad point: ZERO");const{X:k,Y:S,Z:E,T:p}=N,y=l(k*k),x=l(S*S),j=l(E*E),L=l(j*j),C=l(y*A),P=l(j*l(C+x)),_=l(L+l(v*l(y*x)));if(P!==_)throw new Error("bad point: equation left != right (1)");const R=l(k*S),T=l(E*p);if(R!==T)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(a.Gx,a.Gy,ae,l(a.Gx*a.Gy));static ZERO=new b(Le,ae,ae,Le);static Fp=o;static Fn=n;X;Y;Z;T;constructor(A,v,k,S){this.X=m("x",A),this.Y=m("y",v),this.Z=m("z",k,!0),this.T=m("t",S),Object.freeze(this)}static CURVE(){return a}static fromAffine(A){if(A instanceof b)throw new Error("extended point not allowed");const{x:v,y:k}=A||{};return m("x",v),m("y",k),new b(v,k,ae,l(v*k))}static fromBytes(A,v=!1){const k=o.BYTES,{a:S,d:E}=a;A=Dt(ie(A,k,"point")),Ut(v,"zip215");const p=Dt(A),y=A[k-1];p[k-1]=y&-129;const x=Ls(p),j=v?d:o.ORDER;_r("point.y",x,Le,j);const L=l(x*x),C=l(L-ae),P=l(E*L-S);let{isValid:_,value:R}=h(C,P);if(!_)throw new Error("bad point: invalid y coordinate");const T=(R&ae)===ae,I=(y&128)!==0;if(!v&&R===Le&&I)throw new Error("bad point: x=0 and x_0=1");return I!==T&&(R=l(-R)),b.fromAffine({x:R,y:x})}static fromHex(A,v=!1){return b.fromBytes(On(A),v)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(A=8,v=!0){return g.createCache(this,A),v||this.multiply(st),this}assertValidity(){w(this)}equals(A){u(A);const{X:v,Y:k,Z:S}=this,{X:E,Y:p,Z:y}=A,x=l(v*y),j=l(E*S),L=l(k*y),C=l(p*S);return x===j&&L===C}is0(){return this.equals(b.ZERO)}negate(){return new b(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:A}=a,{X:v,Y:k,Z:S}=this,E=l(v*v),p=l(k*k),y=l(st*l(S*S)),x=l(A*E),j=v+k,L=l(l(j*j)-E-p),C=x+p,P=C-y,_=x-p,R=l(L*P),T=l(C*_),I=l(L*_),O=l(P*C);return new b(R,T,O,I)}add(A){u(A);const{a:v,d:k}=a,{X:S,Y:E,Z:p,T:y}=this,{X:x,Y:j,Z:L,T:C}=A,P=l(S*x),_=l(E*j),R=l(y*k*C),T=l(p*L),I=l((S+E)*(x+j)-P-_),O=T-R,W=T+R,q=l(_-v*P),U=l(I*O),F=l(W*q),V=l(I*q),Y=l(O*W);return new b(U,F,Y,V)}subtract(A){return this.add(A.negate())}multiply(A){if(!n.isValidNot0(A))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:v,f:k}=g.cached(this,A,S=>Zs(b,S));return Zs(b,[v,k])[0]}multiplyUnsafe(A,v=b.ZERO){if(!n.isValid(A))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return A===Le?b.ZERO:this.is0()||A===ae?this:g.unsafe(this,A,k=>Zs(b,k),v)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return g.unsafe(this,a.n).is0()}toAffine(A){return f(this,A)}clearCofactor(){return i===ae?this:this.multiplyUnsafe(i)}toBytes(){const{x:A,y:v}=this.toAffine(),k=o.toBytes(v);return k[k.length-1]|=A&ae?128:0,k}toHex(){return Zt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const g=new xi(b,n.BITS);return b.BASE.precompute(8),b}function ki(s,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');Xt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=r,{BASE:n,Fp:a,Fn:i}=s,d=r.randomBytes||Wa,l=r.adjustScalarBytes||(x=>x),h=r.domain||((x,j,L)=>{if(Ut(L,"phflag"),j.length||L)throw new Error("Contexts/pre-hash are not supported");return x});function m(x){return i.create(Ls(x))}function u(x){const j=k.secretKey;ie(x,k.secretKey,"secretKey");const L=ie(t(x),2*j,"hashedSecretKey"),C=l(L.slice(0,j)),P=L.slice(j,2*j),_=m(C);return{head:C,prefix:P,scalar:_}}function f(x){const{head:j,prefix:L,scalar:C}=u(x),P=n.multiply(C),_=P.toBytes();return{head:j,prefix:L,scalar:C,point:P,pointBytes:_}}function w(x){return f(x).pointBytes}function b(x=Uint8Array.of(),...j){const L=Nr(...j);return m(t(h(L,ie(x,void 0,"context"),!!o)))}function g(x,j,L={}){x=ie(x,void 0,"message"),o&&(x=o(x));const{prefix:C,scalar:P,pointBytes:_}=f(j),R=b(L.context,C,x),T=n.multiply(R).toBytes(),I=b(L.context,T,_,x),O=i.create(R+I*P);if(!i.isValid(O))throw new Error("sign failed: invalid s");const W=Nr(T,i.toBytes(O));return ie(W,k.signature,"result")}const N={zip215:!0};function A(x,j,L,C=N){const{context:P,zip215:_}=C,R=k.signature;x=ie(x,R,"signature"),j=ie(j,void 0,"message"),L=ie(L,k.publicKey,"publicKey"),_!==void 0&&Ut(_,"zip215"),o&&(j=o(j));const T=R/2,I=x.subarray(0,T),O=Ls(x.subarray(T,R));let W,q,U;try{W=s.fromBytes(L,_),q=s.fromBytes(I,_),U=n.multiplyUnsafe(O)}catch{return!1}if(!_&&W.isSmallOrder())return!1;const F=b(P,q.toBytes(),W.toBytes(),j);return q.add(W.multiplyUnsafe(F)).subtract(U).clearCofactor().is0()}const v=a.BYTES,k={secretKey:v,publicKey:v,signature:2*v,seed:v};function S(x=d(k.seed)){return ie(x,k.seed,"seed")}function E(x){return Dn(x)&&x.length===i.BYTES}function p(x,j){try{return!!s.fromBytes(x,j)}catch{return!1}}const y={getExtendedPublicKey:f,randomSecretKey:S,isValidSecretKey:E,isValidPublicKey:p,toMontgomery(x){const{y:j}=s.fromBytes(x),L=k.publicKey,C=L===32;if(!C&&L!==57)throw new Error("only defined for 25519 and 448");const P=C?a.div(ae+j,ae-j):a.div(j-ae,j+ae);return a.toBytes(P)},toMontgomerySecret(x){const j=k.secretKey;ie(x,j);const L=t(x.subarray(0,j));return l(L).subarray(0,j)}};return Object.freeze({keygen:vi(S,w),getPublicKey:w,sign:g,verify:A,utils:y,Point:s,lengths:k})}const Si=BigInt(1),Ur=BigInt(2),Ci=BigInt(5),Ei=BigInt(8),sr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),_i={p:sr,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Ei,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Li(s){const t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),a=sr,d=s*s%a*s%a,l=ye(d,Ur,a)*d%a,h=ye(l,Si,a)*s%a,m=ye(h,Ci,a)*h%a,u=ye(m,t,a)*m%a,f=ye(u,r,a)*u%a,w=ye(f,o,a)*f%a,b=ye(w,n,a)*w%a,g=ye(b,n,a)*w%a,N=ye(g,t,a)*m%a;return{pow_p_5_8:ye(N,Ur,a)*s%a,b2:d}}function Pi(s){return s[0]&=248,s[31]&=127,s[31]|=64,s}const Dr=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ri(s,t){const r=sr,o=oe(t*t*t,r),n=oe(o*o*t,r),a=Li(s*n).pow_p_5_8;let i=oe(s*o*a,r);const d=oe(t*i*i,r),l=i,h=oe(i*Dr,r),m=d===s,u=d===oe(-s,r),f=d===oe(-s*Dr,r);return m&&(i=l),(u||f)&&(i=h),mi(i,r)&&(i=oe(-i,r)),{isValid:m||u,value:i}}const Ti=Ni(_i,{uvRatio:Ri});function Mi(s){return ki(Ti,ti,Object.assign({adjustScalarBytes:Pi},s))}const Ii=Mi({});function Bi(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Os(s,...t){if(!Bi(s))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(s.length))throw new Error("Uint8Array expected of length "+t+", got length="+s.length)}function Fr(s,t=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(t&&s.finished)throw new Error("Hash#digest() has already been called")}function Ui(s,t){Os(s);const r=t.outputLen;if(s.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ot(...s){for(let t=0;t<s.length;t++)s[t].fill(0)}function tt(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function ve(s,t){return s<<32-t|s>>>t}function Di(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function so(s){return typeof s=="string"&&(s=Di(s)),Os(s),s}class Fi{}function Oi(s){const t=o=>s().update(so(o)).digest(),r=s();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>s(),t}function Wi(s,t,r,o){if(typeof s.setBigUint64=="function")return s.setBigUint64(t,r,o);const n=BigInt(32),a=BigInt(4294967295),i=Number(r>>n&a),d=Number(r&a),l=o?4:0,h=o?0:4;s.setUint32(t+l,i,o),s.setUint32(t+h,d,o)}function qi(s,t,r){return s&t^~s&r}function zi(s,t,r){return s&t^s&r^t&r}class $i extends Fi{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=tt(this.buffer)}update(t){Fr(this),t=so(t),Os(t);const{view:r,buffer:o,blockLen:n}=this,a=t.length;for(let i=0;i<a;){const d=Math.min(n-this.pos,a-i);if(d===n){const l=tt(t);for(;n<=a-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+d),this.pos),this.pos+=d,i+=d,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fr(this),Ui(t,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Ot(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;Wi(o,n-8,BigInt(this.length*8),a),this.process(o,0);const d=tt(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=l/4,m=this.get();if(h>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)d.setUint32(4*u,m[u],a)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:d}=this;return t.destroyed=i,t.finished=a,t.length=n,t.pos=d,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}}const Pe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Vi=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Re=new Uint32Array(64);class Hi extends $i{constructor(t=32){super(64,t,8,!1),this.A=Pe[0]|0,this.B=Pe[1]|0,this.C=Pe[2]|0,this.D=Pe[3]|0,this.E=Pe[4]|0,this.F=Pe[5]|0,this.G=Pe[6]|0,this.H=Pe[7]|0}get(){const{A:t,B:r,C:o,D:n,E:a,F:i,G:d,H:l}=this;return[t,r,o,n,a,i,d,l]}set(t,r,o,n,a,i,d,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=a|0,this.F=i|0,this.G=d|0,this.H=l|0}process(t,r){for(let u=0;u<16;u++,r+=4)Re[u]=t.getUint32(r,!1);for(let u=16;u<64;u++){const f=Re[u-15],w=Re[u-2],b=ve(f,7)^ve(f,18)^f>>>3,g=ve(w,17)^ve(w,19)^w>>>10;Re[u]=g+Re[u-7]+b+Re[u-16]|0}let{A:o,B:n,C:a,D:i,E:d,F:l,G:h,H:m}=this;for(let u=0;u<64;u++){const f=ve(d,6)^ve(d,11)^ve(d,25),w=m+f+qi(d,l,h)+Vi[u]+Re[u]|0,g=(ve(o,2)^ve(o,13)^ve(o,22))+zi(o,n,a)|0;m=h,h=l,l=d,d=i+w|0,i=a,a=n,n=o,o=w+g|0}o=o+this.A|0,n=n+this.B|0,a=a+this.C|0,i=i+this.D|0,d=d+this.E|0,l=l+this.F|0,h=h+this.G|0,m=m+this.H|0,this.set(o,n,a,i,d,l,h,m)}roundClean(){Ot(Re)}destroy(){this.set(0,0,0,0,0,0,0,0),Ot(this.buffer)}}const to=Oi(()=>new Hi),Gi=to,Qi="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ki(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const t=Gi(s),r=Ii.getPublicKey(t),o=new Uint8Array(64);return o.set(t,0),o.set(r,32),D.wipeBytes(t),{publicKey:r,secretKey:o}}function ro(s){const t=Ki(s),r=t.publicKey;return D.wipeBytes(t.secretKey),r}function no(s){if(s.length!==32)throw new Error(`Invalid public key length: expected 32, got ${s.length}`);return Yi(s)}function Yi(s){let t=0;for(let n=0;n<s.length&&s[n]===0;n++)t++;let r=0n;for(let n=0;n<s.length;n++)r=r*256n+BigInt(s[n]);let o="";for(;r>0n;){const n=Number(r%58n);o=Qi[n]+o,r=r/58n}return"1".repeat(t)+o}const Zi=2,Xi=3;function oo(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const t=Wt(s),r=Un.share(t,Xi,Zi);if(r.length!==3)throw new Error(`Unexpected share count: ${r.length}`);const o=rt(r[0]),n=rt(r[1]),a=rt(r[2]);return{shareA:D.toShamirShare(o),shareB:D.toShamirShare(n),shareC:D.toShamirShare(a)}}function Ji(s,t,r){const o=Or(s),n=Or(t);try{const a=Un.combine([o,n]),i=ao(a);if(i.length!==16)throw new Error(`Reconstructed seed has wrong length: ${i.length}`);return D.toSeed(i)}catch(a){throw a instanceof Error&&a.message.startsWith("Reconstructed seed")||a instanceof Error&&a.message.startsWith("Invalid expectedPublicKey")||a instanceof Error&&a.message.startsWith("Reconstructed seed does not match")?a:new Error("Failed to reconstruct seed from shares")}}function Wt(s){return Array.from(s).map(t=>t.toString(16).padStart(2,"0")).join("")}function ao(s){if(!/^[0-9a-fA-F]*$/.test(s))throw new Error("Invalid hex string: contains non-hex characters");if(s.length%2!==0)throw new Error(`Invalid hex string: length ${s.length} is odd (must be even)`);const t=new Uint8Array(s.length/2);for(let r=0;r<t.length;r++)t[r]=parseInt(s.substr(r*2,2),16);return t}function rt(s){const t=s.length%2!==0,r=t?"0"+s:s,o=ao(r),n=new Uint8Array(1+o.length);return n[0]=t?1:0,n.set(o,1),n}function Or(s){const t=s[0];if(t===0||t===1){const o=t===1,n=s.subarray(1),a=Wt(n),i=o?a.substring(1):a;if(/^[0-9a-f]/.test(i))return i}const r=Wt(s);return r.startsWith("0")&&!r.startsWith("00")?r.substring(1):r}function Rs(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function io(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function ec(s){if(typeof s!="function")throw new Error("function expected");return!0}function Ts(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function ts(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function Ms(s){if(!Array.isArray(s))throw new Error("array expected")}function Is(s,t){if(!io(!0,t))throw new Error(`${s}: array of strings expected`)}function co(s,t){if(!io(!1,t))throw new Error(`${s}: array of numbers expected`)}function sc(...s){const t=a=>a,r=(a,i)=>d=>a(i(d)),o=s.map(a=>a.encode).reduceRight(r,t),n=s.map(a=>a.decode).reduce(r,t);return{encode:o,decode:n}}function tc(s){const t=typeof s=="string"?s.split(""):s,r=t.length;Is("alphabet",t);const o=new Map(t.map((n,a)=>[n,a]));return{encode:n=>(Ms(n),n.map(a=>{if(!Number.isSafeInteger(a)||a<0||a>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${s}`);return t[a]})),decode:n=>(Ms(n),n.map(a=>{Ts("alphabet.decode",a);const i=o.get(a);if(i===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${s}`);return i}))}}function rc(s=""){return Ts("join",s),{encode:t=>(Is("join.decode",t),t.join(s)),decode:t=>(Ts("join.decode",t),t.split(s))}}function nc(s,t="="){return ts(s),Ts("padding",t),{encode(r){for(Is("padding.encode",r);r.length*s%8;)r.push(t);return r},decode(r){Is("padding.decode",r);let o=r.length;if(o*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function qt(s,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Ms(s),!s.length)return[];let o=0;const n=[],a=Array.from(s,d=>{if(ts(d),d<0||d>=t)throw new Error(`invalid integer: ${d}`);return d}),i=a.length;for(;;){let d=0,l=!0;for(let h=o;h<i;h++){const m=a[h],u=t*d,f=u+m;if(!Number.isSafeInteger(f)||u/t!==d||f-m!==u)throw new Error("convertRadix: carry overflow");const w=f/r;d=f%r;const b=Math.floor(w);if(a[h]=b,!Number.isSafeInteger(b)||b*r+d!==f)throw new Error("convertRadix: carry overflow");if(l)b?l=!1:o=h;else continue}if(n.push(d),l)break}for(let d=0;d<s.length-1&&s[d]===0;d++)n.push(0);return n.reverse()}const lo=(s,t)=>t===0?s:lo(t,s%t),Bs=(s,t)=>s+(t-lo(s,t)),nt=(()=>{let s=[];for(let t=0;t<40;t++)s.push(2**t);return s})();function zt(s,t,r,o){if(Ms(s),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Bs(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Bs(t,r)}`);let n=0,a=0;const i=nt[t],d=nt[r]-1,l=[];for(const h of s){if(ts(h),h>=i)throw new Error(`convertRadix2: invalid data word=${h} from=${t}`);if(n=n<<t|h,a+t>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${t}`);for(a+=t;a>=r;a-=r)l.push((n>>a-r&d)>>>0);const m=nt[a];if(m===void 0)throw new Error("invalid carry");n&=m-1}if(n=n<<r-a&d,!o&&a>=t)throw new Error("Excess padding");if(!o&&n>0)throw new Error(`Non-zero padding: ${n}`);return o&&a>0&&l.push(n>>>0),l}function oc(s){ts(s);const t=2**8;return{encode:r=>{if(!Rs(r))throw new Error("radix.encode input should be Uint8Array");return qt(Array.from(r),t,s)},decode:r=>(co("radix.decode",r),Uint8Array.from(qt(r,s,t)))}}function ac(s,t=!1){if(ts(s),s<=0||s>32)throw new Error("radix2: bits should be in (0..32]");if(Bs(8,s)>32||Bs(s,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Rs(r))throw new Error("radix2.encode input should be Uint8Array");return zt(Array.from(r),8,s,!t)},decode:r=>(co("radix2.decode",r),Uint8Array.from(zt(r,s,8,t)))}}function ic(s,t){return ts(s),ec(t),{encode(r){if(!Rs(r))throw new Error("checksum.encode: input should be Uint8Array");const o=t(r).slice(0,s),n=new Uint8Array(r.length+s);return n.set(r),n.set(o,r.length),n},decode(r){if(!Rs(r))throw new Error("checksum.decode: input should be Uint8Array");const o=r.slice(0,-s),n=r.slice(-s),a=t(o).slice(0,s);for(let i=0;i<s;i++)if(a[i]!==n[i])throw new Error("Invalid checksum");return o}}}const ws={alphabet:tc,chain:sc,checksum:ic,convertRadix:qt,convertRadix2:zt,radix:oc,radix2:ac,join:rc,padding:nc};const cc=s=>s[0]==="あいこくしん";function lc(s){if(typeof s!="string")throw new TypeError("invalid mnemonic type: "+typeof s);return s.normalize("NFKD")}function dc(s){const t=lc(s),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}function uo(s){Os(s,16,20,24,28,32)}const uc=s=>{const t=8-s.length/4;return new Uint8Array([to(s)[0]>>t<<t])};function ho(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)}),ws.chain(ws.checksum(1,uc),ws.radix2(11,!0),ws.alphabet(s))}function tr(s,t){const{words:r}=dc(s),o=ho(t).decode(r);return uo(o),o}function mo(s,t){return uo(s),ho(t).encode(s).join(cc(t)?" ":" ")}function rr(s,t){try{tr(s,t)}catch{return!1}return!0}const Se=`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
|
-
`),fe=12;function oc(t){if(t.length!==16)throw new Error(`Invalid share length: expected 16, got ${t.length}`);const r=co(t,Se).split(" ");if(r.length!==fe)throw new Error(`Unexpected word count: expected ${fe}, got ${r.length}`);return r}function ac(t){if(t.length!==fe)throw new Error(`Invalid word count: expected ${fe}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!tr(s,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=er(s,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return D.toShamirShare(r)}function ic(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const r=co(t,Se).split(" ");if(r.length!==fe)throw new Error(`Unexpected word count: expected ${fe}, got ${r.length}`);return r}function cc(t){if(t.length!==fe)throw new Error(`Invalid word count: expected ${fe}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!tr(s,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=er(s,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return D.toSeed(r)}function lo(t){if(t.length!==fe)return!1;const s=t.join(" ").toLowerCase().trim();return tr(s,Se)}function gt(t){return Se.includes(t.toLowerCase().trim())}function lc(t,s=5){const r=t.toLowerCase().trim();return r.length===0?[]:Se.filter(o=>o.startsWith(r)).slice(0,s)}function dc(t){const s=[];for(let r=0;r<t.length;r+=4)s.push(t.slice(r,r+4));return s}function uc(t){return t.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(s=>s.trim()).filter(s=>s.length>0)}function hc({className:t="",variant:s="default",size:r="md",children:o,menuItems:n=[],hideSignOut:a=!1}){const{user:i,isAuthenticated:l,isLoading:c,openLoginModal:h,logout:m}=D.useAuth(),[u,p]=d.useState(!1),[b,w]=d.useState(-1),g=d.useRef(null),j=d.useRef(null),v=d.useMemo(()=>[...n,...a?[]:[{label:"Sign out",onClick:m}]],[n,a,m]);d.useEffect(()=>{if(!u)return;const f=x=>{g.current&&!g.current.contains(x.target)&&(p(!1),w(-1))},y=x=>{x.key==="Escape"&&(p(!1),w(-1),j.current?.focus())};return document.addEventListener("mousedown",f),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",f),document.removeEventListener("keydown",y)}},[u]);const N=d.useCallback(f=>{if(!(!u||v.length===0))switch(f.key){case"ArrowDown":f.preventDefault(),w(y=>(y+1)%v.length);break;case"ArrowUp":f.preventDefault(),w(y=>(y-1+v.length)%v.length);break;case"Home":f.preventDefault(),w(0);break;case"End":f.preventDefault(),w(v.length-1);break;case"Enter":case" ":b>=0&&(f.preventDefault(),v[b].onClick(),p(!1),w(-1));break}},[u,b,v]),k=d.useCallback(()=>{v.length!==0&&(p(f=>!f),w(-1))},[v.length]),S={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},E={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(c)return e.jsx("button",{type:"button",className:`cedros-button ${E[s]} ${S[r]} ${t}`,disabled:!0,children:e.jsx(Q.LoadingSpinner,{size:"sm"})});if(l&&i){const f=i.name||i.email||"User",y=zs.sanitizeImageUrl(i.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:g,onKeyDown:N,children:[e.jsxs("button",{ref:j,type:"button",className:`cedros-button cedros-user-button ${S[r]} ${t}`,"aria-haspopup":"menu","aria-expanded":u,"aria-label":`User menu for ${f}`,onClick:k,children:[y?e.jsx("img",{src:y,alt:f,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(f[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:f})]}),u&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[n.map((x,A)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${b===A?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===A?0:-1,onClick:()=>{x.onClick(),p(!1)},children:[x.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:x.icon}),x.label]},A)),n.length>0&&!a&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!a&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${b===n.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===n.length?0:-1,onClick:()=>{m(),p(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${E[s]} ${S[r]} ${t}`,onClick:h,children:o||"Sign in"})}function Ft(){const{config:t}=M.useCedrosLogin(),[s,r]=d.useState(!1),[o,n]=d.useState(!1),[a,i]=d.useState(null),l=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:c,getRemainingAttempts:h}=X.useRateLimiter({maxAttempts:3,windowMs:3e5}),m=d.useCallback(async w=>{if(!Oe.validateEmail(w)){const g={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw i(g),g}try{c()}catch(g){const j={code:"RATE_LIMITED",message:g instanceof Error?g.message:"Too many attempts"};throw i(j),j}r(!0),i(null),n(!1);try{await l.post("/forgot-password",{email:w}),n(!0)}catch(g){const j=M.handleApiError(g,"Unable to send the reset email. Please try again.");throw i(j),j}finally{r(!1)}},[l,c]),u=d.useCallback(async(w,g)=>{r(!0),i(null),n(!1);try{await l.post("/reset-password",{token:w,newPassword:g}),n(!0)}catch(j){const v=M.handleApiError(j,"Unable to reset your password. Please try again.");throw i(v),v}finally{r(!1)}},[l]),p=d.useCallback(()=>i(null),[]),b=d.useCallback(()=>{i(null),n(!1),r(!1)},[]);return{forgotPassword:m,resetPassword:u,isLoading:s,isSuccess:o,error:a,clearError:p,reset:b,remainingAttempts:h()}}function mc(t){return typeof t=="object"&&t!==null&&"mfaRequired"in t&&t.mfaRequired===!0}function uo(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(!1),[i,l]=d.useState(null),c=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:h,getRemainingAttempts:m}=X.useRateLimiter({maxAttempts:3,windowMs:3e5}),u=d.useCallback(async g=>{if(!Oe.validateEmail(g)){const j={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw l(j),j}try{h()}catch(j){const v={code:"RATE_LIMITED",message:j instanceof Error?j.message:"Too many attempts"};throw l(v),v}o(!0),l(null),a(!1);try{await c.post("/instant-link",{email:g,referral:s?.getReferralCode?.()??void 0}),a(!0)}catch(j){const v=M.handleApiError(j,"Unable to send the sign-in link. Please try again.");throw l(v),v}finally{o(!1)}},[c,h]),p=d.useCallback(async g=>{if(!g||g.trim().length===0){const j={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw l(j),j}o(!0),l(null),a(!1);try{const j=await c.post("/instant-link/verify",{token:g});return mc(j)||(t.callbacks?.onLoginSuccess?.(j.user,"email"),s?.handleLoginSuccess(j.user,j.tokens)),j}catch(j){const v=M.handleApiError(j,"Unable to verify the sign-in link. Please try again.");throw l(v),v}finally{o(!1)}},[c,t.callbacks,s]),b=d.useCallback(()=>l(null),[]),w=d.useCallback(()=>{l(null),a(!1),o(!1)},[]);return{sendInstantLink:u,verifyInstantLink:p,isLoading:r,isSuccess:n,error:i,clearError:b,reset:w,remainingAttempts:m()}}const fc={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:t=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:t}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:t=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:t}),". Click the link to sign in."]})}};function ho({mode:t="reset",onSuccess:s,onCancel:r,className:o=""}){const[n,a]=d.useState(""),i=Ft(),l=uo(),c=d.useId(),h=t==="instantLink"?{submit:l.sendInstantLink,isLoading:l.isLoading,isSuccess:l.isSuccess,error:l.error,clearError:l.clearError}:{submit:i.forgotPassword,isLoading:i.isLoading,isSuccess:i.isSuccess,error:i.error,clearError:i.clearError},m=fc[t],u=async p=>{p.preventDefault();try{await h.submit(n),s?.()}catch{}};return h.isSuccess?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.jsx("p",{className:"cedros-success-message",children:m.successMessage(n)}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:r,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:u,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:m.subtitle})]}),e.jsx(te.ErrorMessage,{error:h.error,onDismiss:h.clearError}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:c,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:c,type:"email",className:"cedros-input",value:n,onChange:p=>a(p.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:h.isLoading})]}),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:h.isLoading||!n,children:h.isLoading?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),"Sending..."]}):m.button}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:h.isLoading,children:"Back to login"})]})]})}const pc={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((t,s)=>{this.callbacks.push({resolve:t,reject:s})}):(this.loading=!0,new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s});const r=document.getElementById("apple-signin-script");if(r){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]):r.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]});return}const o=document.createElement("script");o.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",o.async=!0,o.defer=!0,o.id="apple-signin-script",o.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]},o.onerror=()=>{this.loading=!1,o.remove();const n=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(a=>a.reject(n)),this.callbacks=[]},document.head.appendChild(o)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function mo(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(!1),[i,l]=d.useState(null),[c,h]=d.useState(null),m=d.useRef(t),u=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]);d.useEffect(()=>{m.current=t},[t]),d.useEffect(()=>{if(!t.appleClientId)return;let g=!0;const j=()=>{if(g)try{window.AppleID?.auth?.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),g&&a(!0)}catch{g&&l({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return pc.load().then(()=>{g&&j()}).catch(()=>{g&&l({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{g=!1}},[t.appleClientId]);const p=d.useCallback(async()=>{if(!t.appleClientId){const j={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw l(j),j}if(!n){const j={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw l(j),j}o(!0),l(null);let g;try{const j=crypto.getRandomValues(new Uint8Array(32)),v=Array.from(j,y=>y.toString(16).padStart(2,"0")).join(""),N=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(v)),k=Array.from(new Uint8Array(N),y=>y.toString(16).padStart(2,"0")).join("");window.AppleID.auth.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0,nonce:k});const S=await window.AppleID.auth.signIn();if(g=S.authorization?.id_token,!g)throw new Error("No ID token received from Apple");const E=S.user?.name?`${S.user.name.firstName||""} ${S.user.name.lastName||""}`.trim():void 0,f=await u.post("/apple",{idToken:g,name:E||void 0,nonce:v,referral:s?.getReferralCode?.()??void 0});return m.current.callbacks?.onLoginSuccess?.(f.user,"apple"),s?.handleLoginSuccess(f.user,f.tokens),o(!1),f}catch(j){if(j.error==="popup_closed_by_user"){const k={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw l(k),o(!1),k}const N=M.handleApiError(j,"Unable to sign in with Apple. Please try again.");throw N.code==="ACCOUNT_LINK_REQUIRED"&&g&&h(g),l(N),o(!1),N}},[t.appleClientId,n,u,s]),b=d.useCallback(()=>l(null),[]),w=d.useCallback(()=>h(null),[]);return{signIn:p,isLoading:r,isInitialized:n,error:i,clearError:b,pendingLinkIdToken:c,clearPendingLink:w}}function fo(){if(typeof window>"u"||typeof navigator>"u")return!1;const t=navigator.userAgent.toLowerCase(),s=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(t)||s.includes("mac")||/macintosh/.test(t)||s==="macintel"&&navigator.maxTouchPoints>1)}function po({onSuccess:t,onError:s,className:r="",variant:o="default",size:n="md",disabled:a=!1,hideOnNonApple:i=!0}){const{signIn:l,isLoading:c,isInitialized:h}=mo(),[m]=d.useState(()=>fo());if(i&&!m)return null;const u=async()=>{try{await l(),t?.()}catch(w){const g=w instanceof Error?w:new Error(String(w));s?.(g)}},p={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},b={default:"cedros-button-social",outline:"cedros-button-social-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${b[o]} ${p[n]} ${r}`,onClick:u,disabled:a||!h||c,"aria-label":"Sign in with Apple",children:[c?e.jsx(Q.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 le(t,s){if(!t)throw new Error(s)}function gc(t){return t.replace(/-/g,"+").replace(/_/g,"/")}function Bt(t){le(typeof t=="string"&&t.length>0,"Expected base64url string");const s=gc(t),r=s+"=".repeat((4-s.length%4)%4),o=atob(r),n=new Uint8Array(o.length);for(let a=0;a<o.length;a++)n[a]=o.charCodeAt(a);return n.buffer}function Ke(t){const s=new Uint8Array(t);let r="";for(let n=0;n<s.length;n++)r+=String.fromCharCode(s[n]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function go(t){le(typeof t=="object"&&t!==null,"Invalid credential descriptor");const s=t;return le(typeof s.type=="string","Invalid credential descriptor type"),le(typeof s.id=="string","Invalid credential descriptor id"),{type:s.type,id:Bt(s.id),transports:Array.isArray(s.transports)?s.transports:void 0}}function rs(t){le(t&&typeof t=="object","Missing creation options");const s=t.publicKey;le(s&&typeof s=="object","Missing creation options.publicKey"),le(typeof s.challenge=="string","Missing creation challenge"),le(typeof s.rp=="object"&&s.rp!==null,"Missing rp"),le(typeof s.user=="object"&&s.user!==null,"Missing user");const r=s.rp,o=s.user;le(typeof r.name=="string","Missing rp.name"),le(typeof o.id=="string","Missing user.id"),le(typeof o.name=="string","Missing user.name"),le(typeof o.displayName=="string","Missing user.displayName");const n=Array.isArray(s.excludeCredentials)?s.excludeCredentials.map(go):void 0,a=Array.isArray(s.pubKeyCredParams)?s.pubKeyCredParams.map(l=>({type:l.type,alg:l.alg})):[],i={challenge:Bt(s.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:Bt(o.id),name:o.name,displayName:o.displayName},pubKeyCredParams:a,timeout:typeof s.timeout=="number"?s.timeout:void 0,attestation:typeof s.attestation=="string"?s.attestation:void 0,authenticatorSelection:typeof s.authenticatorSelection=="object"&&s.authenticatorSelection!==null?s.authenticatorSelection:void 0,excludeCredentials:n,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return i.hints=["client-device"],i}function Fr(t){le(t&&typeof t=="object","Missing request options");const s=t.publicKey;le(s&&typeof s=="object","Missing request options.publicKey"),le(typeof s.challenge=="string","Missing request challenge");const r=Array.isArray(s.allowCredentials)?s.allowCredentials.map(go):void 0,o={challenge:Bt(s.challenge),rpId:typeof s.rpId=="string"?s.rpId:void 0,timeout:typeof s.timeout=="number"?s.timeout:void 0,userVerification:typeof s.userVerification=="string"?s.userVerification:void 0,allowCredentials:r,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return o.hints=["client-device"],o}function nt(t){const s=Ke(t.rawId),r=t.response,n={...{clientDataJSON:Ke(r.clientDataJSON)}};if("attestationObject"in r){const a=r;if(n.attestationObject=Ke(a.attestationObject),typeof a.getTransports=="function")try{n.transports=a.getTransports()}catch{}}if("authenticatorData"in r){const a=r;n.authenticatorData=Ke(a.authenticatorData),n.signature=Ke(a.signature),a.userHandle&&(n.userHandle=Ke(a.userHandle))}return{id:t.id,rawId:s,type:t.type,authenticatorAttachment:t.authenticatorAttachment??void 0,clientExtensionResults:t.getClientExtensionResults?.()??{},response:n}}function wc(){if(typeof window<"u"){const t=window.location?.hostname,s=t==="localhost"||t==="127.0.0.1"||t?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!s)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function bc(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&typeof t.code=="string"&&typeof t.message=="string"}function ot(t){if(!(t instanceof Error))return null;const s=t.name;return s==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:s==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:s==="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:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[s?.getAccessToken,t.serverUrl,t.requestTimeout,t.retryAttempts]),l=d.useCallback(()=>a(null),[]),c=wc(),h=d.useCallback(async j=>{if(!c){const v={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(v),v}o(!0),a(null);try{const v=await i.post("/webauthn/auth/options",{email:j?.email}),N=Fr(v.options),k=await navigator.credentials.get({publicKey:N});if(!k)throw new Error("Passkey authentication returned no credential");const S=await i.post("/webauthn/auth/verify",{challengeId:v.challengeId,credential:nt(k)});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),S}catch(v){const k=ot(v)??M.handleApiError(v,"Unable to sign in with passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,t.callbacks,s,c]),m=d.useCallback(async j=>{if(!c){const v={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(v),v}o(!0),a(null);try{const v=await i.post("/webauthn/register/options",{}),N=rs(v.options),k=await navigator.credentials.create({publicKey:N});if(!k)throw new Error("Passkey registration returned no credential");const S=await i.post("/webauthn/register/verify",{challengeId:v.challengeId,credential:nt(k),label:j?.label});if(!S.success)throw new Error("Passkey registration failed");return{credentialId:S.credentialId,label:S.label}}catch(v){const k=ot(v)??M.handleApiError(v,"Unable to register passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,c]),u=d.useCallback(async j=>{if(!c){const v={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(v),v}o(!0),a(null);try{const v=await i.post("/webauthn/signup/options",{}),N=rs(v.options),k=await navigator.credentials.create({publicKey:N});if(!k)throw new Error("Passkey signup returned no credential");const S=await i.post("/webauthn/signup/verify",{challengeId:v.challengeId,credential:nt(k),email:j?.email,name:j?.name,label:j?.label,referral:s?.getReferralCode?.()??void 0});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),S}catch(v){const k=ot(v)??M.handleApiError(v,"Unable to sign up with passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,t.callbacks,s,c]),p=d.useCallback(async()=>{if(!c){const N={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(N),N}o(!0),a(null);const j=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",v=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return j?b(v):w(v)},[i,t.callbacks,s,c]),b=d.useCallback(async j=>{try{const v=await i.post("/webauthn/auth/options",{}),N=Fr(v.options),k=await navigator.credentials.get({publicKey:N});if(!k)throw new Error("Passkey authentication returned no credential");const S=await i.post("/webauthn/auth/verify",{challengeId:v.challengeId,credential:nt(k)});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),j(),S}catch(v){if(v instanceof Error&&(v.name==="NotAllowedError"||v.name==="InvalidStateError"))return g(j);if(typeof v=="object"&&v!==null&&"isApiError"in v&&v.data?.code==="INVALID_CREDENTIALS"){const f={code:"INVALID_CREDENTIALS",message:"This passkey is not recognized. Please remove old passkeys for this site and try again, or sign in another way."};throw a(f),f}const E=ot(v)??M.handleApiError(v,"Unable to sign in with passkey. Please try again.");throw a(E),E}finally{o(!1)}},[i,t.callbacks,s]),w=d.useCallback(async j=>{try{return await g(j)}catch(v){if(v instanceof Error&&(v.name==="InvalidStateError"||v.name==="NotAllowedError"))return b(j);if(!bc(v)){const S=ot(v)??M.handleApiError(v,"Unable to create passkey. Please try again.");throw a(S),S}throw v}finally{o(!1)}},[i,t.callbacks,s]),g=d.useCallback(async j=>{const v=await i.post("/webauthn/signup/options",{}),N=rs(v.options),k=await navigator.credentials.create({publicKey:N});if(!k)throw new Error("Passkey signup returned no credential");const S=await i.post("/webauthn/signup/verify",{challengeId:v.challengeId,credential:nt(k),referral:s?.getReferralCode?.()??void 0});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),j(),S},[i,t.callbacks,s]);return{isSupported:c,isLoading:r,error:n,clearError:l,continueWithPasskey:p,authenticatePasskey:h,registerPasskey:m,signupWithPasskey:u}}function wo({onSuccess:t,className:s="",children:r,disabled:o}){const{continueWithPasskey:n,isLoading:a,isSupported:i}=sr(),l=o||!i||a;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${s}`,onClick:async()=>{try{await n(),t?.()}catch{}},disabled:l,"aria-disabled":l,children:[a?e.jsx(Q.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(yc,{})}),e.jsx("span",{children:r??"Continue with Passkey"})]})}function yc(){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 at=["login","register"];function Wt({onSuccess:t,className:s="",defaultTab:r="login"}){const{config:o,socialButtonOrder:n}=M.useCedrosLogin(),[a,i]=d.useState(r),[l,c]=d.useState("form"),[h,m]=d.useState(()=>Ze.detectSolanaWallets()),[u]=d.useState(()=>fo());d.useEffect(()=>{const E=()=>m(Ze.detectSolanaWallets());return E(),window.addEventListener("load",E),window.addEventListener("focus",E),()=>{window.removeEventListener("load",E),window.removeEventListener("focus",E)}},[]);const p=o.forms?.forgotPassword?.mode??(o.features?.instantLink?"instantLink":"reset"),b=d.useCallback(E=>{const f=at.indexOf(a);let y=f;switch(E.key){case"ArrowLeft":case"ArrowUp":y=f===0?at.length-1:f-1;break;case"ArrowRight":case"ArrowDown":y=f===at.length-1?0:f+1;break;case"Home":y=0;break;case"End":y=at.length-1;break;default:return}E.preventDefault();const x=at[y];i(x),document.getElementById(`cedros-tab-${x}`)?.focus()},[a]),w=o.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},g=w.email!==!1,j=w.google!==!1&&o.googleClientId,v=w.apple!==!1&&o.appleClientId&&u,N=w.solana!==!1&&h,k=w.webauthn!==!1,S=g&&(j||v||N||k);return l==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${s}`,children:e.jsx(ho,{mode:p,onCancel:()=>c("form")})}):e.jsxs("div",{className:`cedros-login-form ${s}`,children:[(k||j||v||N)&&(()=>{const E={webauthn:k?e.jsx(wo,{onSuccess:t}):null,google:j?e.jsx($s.GoogleLoginButton,{onSuccess:t}):null,apple:v?e.jsx(po,{onSuccess:t}):null,solana:N?e.jsx(Ze.SolanaLoginButton,{onSuccess:t}):null},f=n??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:f.map(y=>{const x=E[y];return x?e.jsx(d.Fragment,{children:x},y):null})})})(),S&&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 ${a==="login"?"cedros-tab-active":""}`,onClick:()=>i("login"),onKeyDown:b,"aria-selected":a==="login","aria-controls":"cedros-tabpanel-login",tabIndex:a==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${a==="register"?"cedros-tab-active":""}`,onClick:()=>i("register"),onKeyDown:b,"aria-selected":a==="register","aria-controls":"cedros-tabpanel-register",tabIndex:a==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${a}`,"aria-labelledby":`cedros-tab-${a}`,children:a==="login"?e.jsx(X.EmailLoginForm,{onSuccess:t,onSwitchToRegister:()=>i("register"),onForgotPassword:()=>c("forgotPassword")}):e.jsx(X.EmailRegisterForm,{onSuccess:t,onSwitchToLogin:()=>i("login")})})]})]})}class bo extends d.Component{constructor(s){super(s),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,r){this.setState({errorInfo:r}),console.error("[Cedros Login] Error caught by ErrorBoundary:",s),console.error("[Cedros Login] Component stack:",r.componentStack),this.props.onError?.(s,r)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:s,error:r,errorInfo:o}=this.state,{children:n,fallback:a,showDetails:i=!1}=this.props;return s?a||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."}),i&&r&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[r.toString(),o?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):n}}function xc({className:t="",title:s="Sign in to your account"}){const{isModalOpen:r,closeModal:o}=M.useCedrosLogin(),n=d.useRef(null),a=d.useRef(null),i=d.useRef(o);if(d.useEffect(()=>{i.current=o},[o]),d.useEffect(()=>{if(!r)return;a.current=document.activeElement,n.current?.focus();const c=m=>{if(m.key==="Escape"&&i.current(),m.key==="Tab"&&n.current){const u=n.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),p=u[0],b=u[u.length-1];m.shiftKey&&document.activeElement===p?(m.preventDefault(),b?.focus()):!m.shiftKey&&document.activeElement===b&&(m.preventDefault(),p?.focus())}};document.addEventListener("keydown",c);const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",c),document.body.style.overflow=h,a.current instanceof HTMLElement&&a.current.focus()}},[r]),!r)return null;const l=c=>{c.target===c.currentTarget&&o()};return e.jsx("div",{className:`cedros-modal-backdrop ${t}`,onClick:l,role:"presentation",children:e.jsxs("div",{ref:n,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:s}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:o,"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(bo,{children:e.jsx(Wt,{onSuccess:o})})})]})})}function vc({token:t,onSuccess:s,onLoginClick:r,className:o=""}){const[n,a]=d.useState(""),[i,l]=d.useState(""),[c,h]=d.useState(null),{resetPassword:m,isLoading:u,isSuccess:p,error:b,clearError:w}=Ft(),g=n===i,j=c?.isValid&&g&&n.length>0,v=async N=>{if(N.preventDefault(),!!j)try{await m(t,n),s?.()}catch{}};return p?e.jsxs("div",{className:`cedros-reset-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:"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."}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:r,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${o}`,onSubmit:v,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(te.ErrorMessage,{error:b,onDismiss:w}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(X.PasswordInput,{label:"New password",value:n,onChange:N=>{a(N.target.value),h(Oe.validatePassword(N.target.value))},showStrengthMeter:!0,onValidationChange:h,disabled:u,autoComplete:"new-password",error:c&&!c.isValid?Object.values(c.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(X.PasswordInput,{label:"Confirm password",value:i,onChange:N=>l(N.target.value),disabled:u,autoComplete:"new-password",error:i&&!g?"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:u||!j,children:u?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:u,children:"Back to login"})]})]})}function Os({org:t,size:s="lg",className:r=""}){const o=zs.sanitizeImageUrl(t.logoUrl),n=s==="lg"?"cedros-org-avatar-lg":"",a=["cedros-org-avatar",n,r].filter(Boolean).join(" "),i=["cedros-org-avatar-placeholder",n,r].filter(Boolean).join(" ");return o?e.jsx("img",{src:o,alt:t.name,className:a,referrerPolicy:"no-referrer"}):e.jsx("div",{className:i,children:t.name[0]?.toUpperCase()||"?"})}function Ac({orgs:t,activeOrg:s,isLoading:r=!1,onSelect:o,onCreateClick:n,className:a="",placeholder:i="Select organization"}){const[l,c]=d.useState(!1),h=d.useRef(null);d.useEffect(()=>{const b=w=>{h.current&&!h.current.contains(w.target)&&c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]),d.useEffect(()=>{const b=w=>{w.key==="Escape"&&c(!1)};if(l)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[l]);const m=d.useCallback(b=>{o(b),c(!1)},[o]),u=d.useCallback(()=>{c(!1),n?.()},[n]),p=d.useCallback(()=>{c(b=>!b)},[]);return r?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${a}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:h,className:`cedros-org-selector ${a}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:p,"aria-haspopup":"listbox","aria-expanded":l,children:[s?e.jsxs(e.Fragment,{children:[e.jsx(Os,{org:s,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:s.name}),e.jsx(Wr,{role:s.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:i}),e.jsx(jc,{isOpen:l})]}),l&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[t.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:t.map(b=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${b.id===s?.id?"cedros-org-selector-item-active":""}`,onClick:()=>m(b.id),role:"option","aria-selected":b.id===s?.id,children:[e.jsx(Os,{org:b,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:b.name}),e.jsx(Wr,{role:b.membership.role}),b.id===s?.id&&e.jsx(Nc,{})]})},b.id))}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:u,children:[e.jsx(kc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function Wr({role:t}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${t}`,children:t})}function jc({isOpen:t}){return e.jsx("svg",{className:`cedros-org-chevron ${t?"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 Nc(){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 kc(){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 Sc(){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 Cc(){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 Ec(){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 _c({orgs:t,activeOrg:s,isLoading:r,onSelect:o,onCreateClick:n}){return r?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[t.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:t.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${a.id===s?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>o(a.id),children:[e.jsx(Os,{org:a}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:a.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",a.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${a.membership.role}`,children:a.membership.role}),a.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),a.id===s?.id&&e.jsx(Cc,{})]})},a.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(Ec,{}),e.jsx("span",{children:"Create new organization"})]})]})}function Lc({isLoading:t,onSubmit:s,onCancel:r}){const[o,n]=d.useState(""),[a,i]=d.useState(""),[l,c]=d.useState(null),h=d.useCallback(u=>{n(u);const p=u.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);i(p)},[]),m=d.useCallback(async u=>{if(u.preventDefault(),c(null),!o.trim()){c("Organization name is required");return}if(!a.trim()){c("Organization slug is required");return}try{await s({name:o.trim(),slug:a.trim()})}catch(p){c(p.message||"Failed to create organization")}},[o,a,s]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:m,children:[l&&e.jsx(te.ErrorMessage,{error:l}),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:o,onChange:u=>h(u.target.value),placeholder:"My Organization",maxLength:255,disabled:t,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:a,onChange:u=>i(u.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:t})]}),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:r,disabled:t,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:t||!o.trim()||!a.trim(),children:t?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function Pc({isOpen:t,onClose:s,orgs:r,activeOrg:o,isLoading:n=!1,error:a,onSelect:i,onCreate:l,className:c=""}){return t?e.jsx(Rc,{onClose:s,orgs:r,activeOrg:o,isLoading:n,error:a,onSelect:i,onCreate:l,className:c}):null}function Rc({onClose:t,orgs:s,activeOrg:r,isLoading:o=!1,error:n,onSelect:a,onCreate:i,className:l}){const[c,h]=d.useState("list"),m=d.useRef(null),u=d.useRef(null);d.useEffect(()=>(u.current=document.activeElement,m.current?.querySelector(".cedros-modal-close")?.focus(),()=>{u.current?.focus()}),[]),d.useEffect(()=>{const g=j=>{if(j.key==="Escape"){t();return}if(j.key==="Tab"&&m.current){const v=m.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),N=v[0],k=v[v.length-1];j.shiftKey?document.activeElement===N&&(j.preventDefault(),k?.focus()):document.activeElement===k&&(j.preventDefault(),N?.focus())}};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const p=d.useCallback(g=>{g.target===g.currentTarget&&t()},[t]),b=d.useCallback(g=>{a(g),t()},[a,t]),w=d.useCallback(async g=>{await i?.(g),t()},[i,t]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:p,children:e.jsxs("div",{ref:m,className:`cedros-modal cedros-org-switcher ${l}`,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:c==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:t,"aria-label":"Close",children:e.jsx(Sc,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(te.ErrorMessage,{error:n}),c==="list"?e.jsx(_c,{orgs:s,activeOrg:r,isLoading:o,onSelect:b,onCreateClick:i?()=>h("create"):void 0}):e.jsx(Lc,{isLoading:o,onSubmit:w,onCancel:()=>h("list")})]})]})})}function yo({sessions:t,isLoading:s=!1,error:r,onRevokeAll:o,className:n=""}){const[a,i]=d.useState(!1),[l,c]=d.useState(!1),h=d.useRef(null),m=d.useMemo(()=>t.filter(p=>!p.isCurrent).length,[t]),u=d.useCallback(async()=>{if(!o)return;const p=t.filter(w=>!w.isCurrent).length;if(!(p===0||!window.confirm(`Are you sure you want to sign out of ${p} other device(s)? This will log you out everywhere except this browser.`))){i(!0),c(!1);try{await o(),c(!0),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{c(!1),h.current=null},3e3)}finally{i(!1)}}},[o,t]);return d.useEffect(()=>()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]),s&&t.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${n}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):r?e.jsx("div",{className:`cedros-session-list ${n}`,children:e.jsx(te.ErrorMessage,{error:r})}):t.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${n}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${n}`,children:[l&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Uc,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:t.map(p=>e.jsx(Tc,{session:p},p.id))}),o&&m>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:u,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${m} other device${m>1?"s":""}`})})]})}function Tc({session:t}){const s=Mc(t.userAgent),r=Ic(t.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${t.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(Dc,{userAgent:t.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:[s.browser," on ",s.os]}),t.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[t.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",t.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",Bc(t.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Mc(t){if(!t)return{browser:"Unknown browser",os:"Unknown device"};let s="Unknown browser";t.includes("Chrome")&&!t.includes("Edg")?s="Chrome":t.includes("Safari")&&!t.includes("Chrome")?s="Safari":t.includes("Firefox")?s="Firefox":t.includes("Edg")&&(s="Edge");let r="Unknown device";return t.includes("Windows")?r="Windows":t.includes("Mac")?r="macOS":t.includes("Linux")?r="Linux":t.includes("iPhone")||t.includes("iPad")?r="iOS":t.includes("Android")&&(r="Android"),{browser:s,os:r}}function Bc(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n} minute${n>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:i<7?`${i} day${i>1?"s":""} ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Ic(t){const s=new Date(t),r=new Date,o=3600*1e3;return s.getTime()-r.getTime()<o}function Dc({userAgent:t}){return t?.includes("iPhone")||t?.includes("iPad")||t?.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 Uc(){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 xo({words:t,onConfirm:s,className:r=""}){const[o,n]=d.useState(!1),[a,i]=d.useState(!1),l=d.useRef(null),c=dc(t),h=d.useCallback(async()=>{try{await navigator.clipboard.writeText(t.join(" ")),n(!0),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>n(!1),2e3)}catch{}},[t]);d.useEffect(()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]);const m=d.useCallback(()=>{a&&s()},[a,s]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${r}`,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:c.map((u,p)=>e.jsx("div",{className:"cedros-word-group",children:u.map((b,w)=>{const g=p*4+w+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[g,"."]}),e.jsx("span",{className:"cedros-word-text",children:b})]},g)})},p))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:h,children:o?"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:a,onChange:u=>i(u.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:m,disabled:!a,children:"Continue"})]})]})}function vo({onSubmit:t,onCancel:s,isSubmitting:r=!1,error:o,className:n=""}){const[a,i]=d.useState(Array(fe).fill("")),[l,c]=d.useState(null),[h,m]=d.useState([]),[u,p]=d.useState(null),b=d.useId(),w=d.useRef(null),g=d.useCallback((f,y)=>{const x=[...a];if(x[f]=y.toLowerCase().trim(),i(x),y.length>0){const A=lc(y,5);m(A)}else m([]);p(null)},[a]),j=d.useCallback(f=>{c(f),m([])},[]),v=d.useCallback(f=>{const y=a[f];y&&!gt(y)&&p(`Word ${f+1} is not in the wordlist`),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{l===f&&m([])},200)},[a,l]);d.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]);const N=d.useCallback(f=>{if(l!==null){const y=[...a];y[l]=f,i(y),m([]),document.querySelector(`[data-word-index="${l+1}"]`)?.focus()}},[l,a]),k=d.useCallback(f=>{const y=f.clipboardData.getData("text"),x=uc(y);x.length===fe&&(f.preventDefault(),i(x),p(null))},[]),S=d.useCallback(f=>{if(f.preventDefault(),a.filter(A=>!A).length>0){p(`Please enter all ${fe} words`);return}const x=a.map((A,_)=>({word:A,index:_+1})).filter(({word:A})=>!gt(A));if(x.length>0){p(`Invalid words: ${x.map(A=>`#${A.index}`).join(", ")}`);return}if(!lo(a)){p("Invalid recovery phrase - please check your words");return}t(a)},[a,t]),E=o||u;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${n}`,onSubmit:S,onPaste:k,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:fe},(f,y)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[y+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${a[y]&&!gt(a[y])?"cedros-word-invalid":a[y]&>(a[y])?"cedros-word-valid":""}`,value:a[y],onChange:x=>g(y,x.target.value),onFocus:()=>j(y),onBlur:()=>v(y),"data-word-index":y,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:r,"aria-label":`Word ${y+1}`})]},y))}),l!==null&&h.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${b}-suggestions`,children:h.map(f=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>N(f),role:"option",children:f},f))}),E&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:E}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:s,disabled:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:r,children:r?"Recovering...":"Recover Wallet"})]})]})}function Fc({capabilities:t,className:s=""}){if(t.allSupported)return null;const r=D.getMissingCapabilitiesMessage(t),o=D.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${s}`,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:r}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",o.browser," ",o.version,o.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:t.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",t.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:t.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",t.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:t.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",t.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",t.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",t.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:t.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",t.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 Wc=["share_c_only","full_seed","none"];function Oc(t){return t&&Wc.includes(t)?t:"share_c_only"}const qc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function Ao(){const t=M.useCedrosLoginOptional(),[s,r]=d.useState(null),[o,n]=d.useState(!!t),[a,i]=d.useState(null),l=d.useMemo(()=>t?new M.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts}):null,[t]),c=d.useCallback(async()=>{if(l){n(!0),i(null);try{const h=await l.get("/discovery");h.wallet?r({enabled:h.wallet.enabled,recoveryMode:Oc(h.wallet.recoveryMode),unlockTtlSeconds:h.wallet.unlockTtlSeconds}):r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(h){const m=h instanceof Error?h.message:"Failed to fetch wallet config";i(m),r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{n(!1)}}},[l]);return d.useEffect(()=>{l&&c()},[l,c]),t?{walletEnabled:s?.enabled??!1,recoveryMode:s?.recoveryMode??"share_c_only",unlockTtlSeconds:s?.unlockTtlSeconds??900,isLoading:o,error:a,refetch:c}:qc}function jo(){const{user:t}=M.useCedrosLogin(),{enroll:s}=D.useWalletMaterial(),{recoveryMode:r}=Ao(),[o,n]=d.useState({step:"idle"}),[a,i]=d.useState(!1),l=d.useRef([]),c=d.useCallback(()=>{D.wipeAll(...l.current),l.current=[]},[]);d.useEffect(()=>()=>{c()},[c]);const h=d.useCallback(async(w,g,j,v)=>{n({step:"generating_seed"});const N=D.generateSeed();l.current.push(N),n({step:"splitting_shares"});const{shareA:k,shareB:S,shareC:E}=to(N);l.current.push(k,S,E),n({step:"encrypting_shares"});const f=await D.aesGcmEncryptToBase64(k,D.toEncryptionKey(g)),y=Jn(N),x=eo(y);n({step:"uploading"});const A={solanaPubkey:x,shareAAuthMethod:w,shareACiphertext:f.ciphertext,shareANonce:f.nonce,shareB:D.uint8ArrayToBase64(S)};if(w==="password"){if(!j)throw new Error("KDF salt required for password method");A.shareAKdfSalt=D.uint8ArrayToBase64(j),A.shareAKdfParams=D.DEFAULT_KDF_PARAMS}if(w==="passkey"&&v&&(A.prfSalt=v),await s(A),r==="none")c(),n({step:"complete",solanaPubkey:x});else{const _=r==="full_seed"?ic(N):oc(D.toShamirShare(E));n({step:"showing_recovery",recoveryPhrase:_,solanaPubkey:x})}},[s,r,c]),m=d.useCallback(async w=>{if(!t){n({step:"error",error:"User not authenticated"});return}i(!0),c();try{const g=D.generateArgon2Salt(),j=await Pn(w,g,D.DEFAULT_KDF_PARAMS);l.current.push(j),await h("password",j,g)}catch(g){n({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{i(!1)}},[t,c,h]),u=d.useCallback(async()=>{if(!t){n({step:"error",error:"User not authenticated"});return}i(!0),c();try{const w=D.generatePrfSalt(),g=D.uint8ArrayToBase64(w);n({step:"encrypting_shares"});const v=(await D.authenticateWithDiscoverablePrf(g)).prfOutput;l.current.push(v);const N=await D.deriveKeyFromPrf(v,w);l.current.push(N),await h("passkey",N,void 0,g)}catch(w){n({step:"error",error:w instanceof Error?w.message:"Enrollment failed"})}finally{i(!1)}},[t,c,h]),p=d.useCallback(()=>{const w=o.solanaPubkey;c(),n({step:"complete",solanaPubkey:w})},[o.solanaPubkey,c]),b=d.useCallback(()=>{c(),n({step:"idle"}),i(!1)},[c]);return{state:o,startEnrollmentWithPassword:m,startEnrollmentWithPasskey:u,confirmRecoveryPhrase:p,cancel:b,isEnrolling:a}}function No(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken]);return{setPassword:d.useCallback(async c=>{o(!0),a(null);try{await i.post("/set-password",{password:c})}catch(h){const m=M.handleApiError(h,"Failed to set password");throw a(m),m}finally{o(!1)}},[i]),isLoading:r,error:n}}function zc(t){return t.includes("email")?"password":t.includes("webauthn")?"passkey":"set-password"}function ko({onComplete:t,onCancel:s,className:r=""}){const{user:o}=M.useCedrosLogin(),{state:n,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:i,confirmRecoveryPhrase:l,cancel:c,isEnrolling:h}=jo(),{setPassword:m,isLoading:u}=No(),p=o?zc(o.authMethods):"password",[b,w]=d.useState(""),[g,j]=d.useState(""),[v,N]=d.useState(null);d.useEffect(()=>{w(""),j(""),N(null)},[o?.id]);const k=d.useCallback(async A=>{A.preventDefault(),N(null),await a(b)},[b,a]),S=d.useCallback(async A=>{if(A.preventDefault(),b!==g){N("Passwords do not match");return}const _=Oe.validatePassword(b);if(!_.isValid){const C=Object.values(_.errors)[0];N(C??"Password does not meet requirements");return}N(null);try{await m(b),await a(b)}catch{}},[b,g,m,a]),E=d.useCallback(async()=>{await i()},[i]),f=d.useCallback(()=>{l(),n.solanaPubkey&&t?.(n.solanaPubkey)},[l,n.solanaPubkey,t]),y=d.useCallback(()=>{c(),s?.()},[c,s]),x=h||u;return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"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 ${r}`,"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==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"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 ${r}`,children:e.jsx(xo,{words:n.recoveryPhrase,onConfirm:f})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,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 ${r}`,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:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>c(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${r}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),p==="password"&&e.jsx("p",{children:"Enter your account password to secure your wallet."}),p==="passkey"&&e.jsx("p",{children:"Authenticate with your passkey to secure your wallet."}),p==="set-password"&&e.jsx("p",{children:"Set a password for your account to secure your wallet."})]}),p==="password"&&e.jsxs("form",{onSubmit:k,className:"cedros-enrollment-form",children:[e.jsx(X.PasswordInput,{label:"Account Password",value:b,onChange:A=>w(A.target.value),disabled:x,required:!0,placeholder:"Enter your account password"}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!b,children:x?"Creating...":"Continue"})]})]}),p==="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.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:E,disabled:x,children:x?"Creating...":"Use Passkey"})]})]}),p==="set-password"&&e.jsxs("form",{onSubmit:S,className:"cedros-enrollment-form",children:[e.jsx(X.PasswordInput,{label:"New Password",value:b,onChange:A=>w(A.target.value),showStrengthMeter:!0,disabled:x,required:!0,minLength:8,placeholder:"Choose a strong password"}),e.jsx(X.PasswordInput,{label:"Confirm Password",value:g,onChange:A=>j(A.target.value),error:v??void 0,disabled:x,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will also be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!b||!g,children:x?"Creating...":"Continue"})]})]})]})}function So(){const{user:t}=M.useCedrosLogin(),{signTransaction:s}=D.useWalletMaterial(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useCallback(async(c,h)=>{if(!t){const m="User not authenticated";throw a(m),new Error(m)}o(!0),a(null);try{const m={transaction:D.uint8ArrayToBase64(c),...h?{credential:D.toCredentialRequest(h)}:{}},u=await s(m);return D.base64ToUint8Array(u.signature)}catch(m){const u=m instanceof Error?m.message:"Signing failed";throw a(u),m}finally{o(!1)}},[t,s]),l=d.useCallback(()=>a(null),[]);return{signTransaction:i,isSigning:r,error:n,clearError:l}}function Co(){const{getMaterial:t}=D.useWalletMaterial(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useCallback(async()=>{r(!0),n(null);try{const l=await t();if(!l)throw new Error("No wallet enrolled");if(l.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!l.prfSalt)throw new Error("No PRF salt configured for wallet");const c=await D.authenticateWithDiscoverablePrf(l.prfSalt);try{return{type:"prfOutput",prfOutput:D.uint8ArrayToBase64(c.prfOutput)}}finally{c.prfOutput.fill(0)}}catch(l){const c=l instanceof Error?l.message:"Passkey authentication failed";return n(c),null}finally{r(!1)}},[t]),i=d.useCallback(()=>n(null),[]);return{getPasskeyCredential:a,isAuthenticating:s,error:o,clearError:i}}function Eo({mode:t,isLoading:s=!1,error:r,onPrompt:o,onRetry:n,onCancel:a,title:i,description:l,className:c=""}){const h=d.useCallback(()=>{s||o?.()},[s,o]),m=d.useCallback(()=>{n?.()},[n]),u=t==="register"?"Set Up Passkey":"Verify with Passkey",p=t==="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 ${c}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:s?e.jsx(Vc,{}):r?e.jsx(Hc,{}):e.jsx($c,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:i??u}),e.jsx("p",{className:"cedros-passkey-description",children:l??p}),r&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:r})}),e.jsx("div",{className:"cedros-passkey-actions",children:r?e.jsxs(e.Fragment,{children:[n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,children:"Try Again"}),a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:h,disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):t==="register"?"Create Passkey":"Use Passkey"}),a&&!s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]})}),s&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",t==="register"?"create":"verify"," your passkey."]})]})}function $c(){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 Vc(){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 Hc(){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 _o({onUnlock:t,onCancel:s,showCancel:r=!0,authMethod:o,className:n=""}){M.useCedrosLogin();const{unlock:a,getMaterial:i,isLoading:l}=D.useWalletMaterial(),{getPasskeyCredential:c,isAuthenticating:h}=Co(),[m,u]=d.useState("idle"),[p,b]=d.useState(o??null),[w,g]=d.useState(""),[j,v]=d.useState(null);d.useEffect(()=>{o!==void 0&&b(o)},[o]);const N=p==="password",k=p==="passkey",S=d.useCallback(async()=>{if(u("credential"),v(null),!p)try{const C=await i();C?b(C.shareAAuthMethod):(v("No wallet enrolled"),u("error"))}catch(C){v(C instanceof Error?C.message:"Failed to get wallet info"),u("error")}},[p,i]),E=d.useCallback(async C=>{C.preventDefault(),v(null),u("unlocking");try{let P;if(N)P={type:"password",password:w};else throw new Error("Invalid auth method");await a(P),u("unlocked"),t?.()}catch(P){v(P instanceof Error?P.message:"Failed to unlock wallet"),u("error")}},[N,w,a,t]),f=d.useCallback(async()=>{v(null),u("unlocking");try{const C=await c();if(!C){u("credential");return}await a(C),u("unlocked"),t?.()}catch(C){v(C instanceof Error?C.message:"Failed to unlock wallet"),u("error")}},[c,a,t]),y=d.useCallback(()=>{g(""),u("idle"),v(null),s?.()},[s]),x=d.useCallback(()=>{g(""),u("credential"),v(null)},[]),A=l||h,_=()=>{switch(m){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Qc,{})}),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:S,children:"Unlock Wallet"})]});case"credential":return N?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:E,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(X.PasswordInput,{label:"Password",value:w,onChange:C=>g(C.target.value),disabled:A,autoComplete:"current-password",error:j??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:A||w.length===0,children:A?"Unlocking...":"Unlock"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:A,children:"Cancel"})]})]}):k?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(Eo,{mode:"authenticate",isLoading:A,error:j??void 0,onPrompt:f,onRetry:f,onCancel:r?y:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(Q.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(Q.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(Gc,{})}),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(Kc,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:j??"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:x,children:"Try Again"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${n}`,children:_()})}function Qc(){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 Gc(){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 Kc(){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 Lo(){const{recover:t,getShareBForRecovery:s}=D.useWalletMaterial(),{recoveryMode:r}=Ao(),[o,n]=d.useState({step:"idle"}),[a,i]=d.useState(!1),l=d.useRef([]),c=d.useCallback(()=>{D.wipeAll(...l.current),l.current=[]},[]);d.useEffect(()=>()=>{c()},[c]);const h=d.useCallback(async(u,p,b)=>{i(!0),c();try{if(n({step:"validating"}),!lo(u))throw new Error("Invalid recovery phrase. Please check your words.");let w;if(r==="share_c_only"){const x=ac(u);l.current.push(x);const A=D.uint8ArrayToBase64(x),_=await s({shareC:A}),C=D.base64ToUint8Array(_.shareB);l.current.push(C),w=Hi(D.toShamirShare(C),D.toShamirShare(x)),l.current.push(w)}else w=cc(u),l.current.push(w);const g=Jn(w),j=eo(g),{shareA:v,shareB:N}=to(w);l.current.push(v,N),n({step:"encrypting"});let k,S,E;if(p==="passkey"){const x=D.generatePrfSalt();E=D.uint8ArrayToBase64(x);const A=await D.authenticateWithDiscoverablePrf(E);l.current.push(A.prfOutput),k=await D.deriveKeyFromPrf(A.prfOutput,x),l.current.push(k)}else S=D.generateArgon2Salt(),k=await Pn(b,S,D.DEFAULT_KDF_PARAMS),l.current.push(k);const f=await D.aesGcmEncryptToBase64(v,D.toEncryptionKey(k));n({step:"uploading"});const y={solanaPubkey:j,shareAAuthMethod:p,shareACiphertext:f.ciphertext,shareANonce:f.nonce,shareB:D.uint8ArrayToBase64(N)};p==="password"&&(y.shareAKdfSalt=D.uint8ArrayToBase64(S),y.shareAKdfParams=D.DEFAULT_KDF_PARAMS),p==="passkey"&&(y.prfSalt=E),await t(y),c(),n({step:"complete"})}catch(w){c(),n({step:"error",error:w instanceof Error?w.message:"Recovery failed"})}finally{i(!1)}},[t,s,r,c]),m=d.useCallback(()=>{c(),n({step:"idle"}),i(!1)},[c]);return{state:o,startRecovery:h,cancel:m,isRecovering:a}}function Po({onComplete:t,onCancel:s,className:r="",defaultAuthMethod:o="password"}){const{state:n,startRecovery:a,cancel:i,isRecovering:l}=Lo(),[c,h]=d.useState([]),[m,u]=d.useState(!1),[p,b]=d.useState(o),[w,g]=d.useState(""),[j,v]=d.useState(""),[N,k]=d.useState(null),S=d.useCallback(A=>{h(A),u(!0)},[]),E=d.useCallback(async A=>{if(A.preventDefault(),k(null),p!=="passkey"){if(w!==j){k("Passwords do not match");return}if(p==="password"&&w.length<8){k("Password must be at least 8 characters");return}}await a(c,p,w)},[c,p,w,j,a]),f=d.useCallback(()=>{i(),h([]),u(!1),g(""),v(""),s?.()},[i,s]),y=d.useCallback(()=>{u(!1),g(""),v("")},[]),x=d.useCallback(()=>{t?.()},[t]);return n.step==="validating"||n.step==="encrypting"||n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Yc,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[n.step==="validating"&&"Validating Recovery Phrase",n.step==="encrypting"&&"Encrypting Wallet",n.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[n.step==="validating"&&"Checking your recovery phrase...",n.step==="encrypting"&&"Securing your wallet with new encryption...",n.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Zc,{})}),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"," ",p==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Done"})})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Xc,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:n.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:f,children:"Start Over"})})]})}):m?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:E,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:p==="password",onChange:()=>b("password"),disabled:l}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:p==="passkey",onChange:()=>b("passkey"),disabled:l}),e.jsx("span",{children:"Passkey"})]})]}),p==="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:w,onChange:A=>g(A.target.value),disabled:l,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:j,onChange:A=>v(A.target.value),disabled:l,"aria-invalid":N?"true":void 0,placeholder:"Confirm your password"}),N&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:N})]})]}),p==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(Jc,{}),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:y,disabled:l,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:l||p!=="passkey"&&(w.length===0||j.length===0),children:l?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${r}`,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(vo,{onSubmit:S,onCancel:f,isSubmitting:!1})]})})}function Yc(){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 Zc(){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 Xc(){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 Jc(){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 Ro({address:t,label:s="Wallet Address",showCopy:r=!0,showExplorerLink:o=!0,allowReveal:n=!0,className:a=""}){const i=M.useCedrosLoginOptional(),[l,c]=d.useState(!1),[h,m]=d.useState(null),[u,p]=d.useState(!1),b=d.useRef(null),w=i?.config.solana?.network??"mainnet-beta",g=d.useMemo(()=>{const k=`https://explorer.solana.com/address/${t}`;return w==="mainnet-beta"?k:`${k}?cluster=${encodeURIComponent(w)}`},[t,w]),j=n&&t.length>18,v=d.useMemo(()=>!j||u?t:`${t.slice(0,8)}...${t.slice(-8)}`,[t,j,u]),N=d.useCallback(async()=>{try{m(null),await navigator.clipboard.writeText(t),c(!0),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{c(!1),b.current=null},2e3)}catch(k){c(!1),m(k instanceof Error?k.message:"Copy failed")}},[t]);return d.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${a}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:s}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[j&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>p(k=>!k),"aria-label":u?"Hide full wallet address":"Show full wallet address",children:u?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"})]})}),o&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:g,target:"_blank",rel:"noreferrer",children:"Explorer"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:N,"aria-label":"Copy wallet address",children:l?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:t,children:v}),h&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:h})]})}function To({status:t,publicKey:s,onLock:r,onEnroll:o,onUnlock:n,onRecover:a,showActions:i=!0,compact:l=!1,className:c=""}){const h=t!==void 0,m=D.useWallet(),u=h?t:m.status,p=h?s??null:m.solanaPubkey,b=h?null:m.error,w=h?()=>{}:m.refresh,g=h?()=>{}:m.clearError,j=el(u,b);return l?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${c}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${j.color}`,title:j.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:j.label}),p&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:p,children:tl(p)})]}):e.jsxs("div",{className:`cedros-wallet-status ${c}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${j.color}`,children:e.jsx(sl,{status:u})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:j.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:j.description})]})]}),p&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(Ro,{address:p})}),b&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:g,children:"Dismiss"})]}),i&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[u==="not_enrolled"&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:o,children:"Create Wallet"}),u==="enrolled_locked"&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:n,children:"Unlock Wallet"}),(u==="not_enrolled"||u==="error")&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:"Recover Wallet"}),u==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:w,children:"Retry"})]})]})}function el(t,s){switch(t){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:s??"An error occurred with your wallet.",color:"error"}}}function tl(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function sl({status:t}){switch(t){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 rl({className:t="",showActions:s=!0}){const r=D.useWallet(),[o,n]=d.useState("status"),a=d.useMemo(()=>{switch(o){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}},[o]),i=d.useCallback(()=>n("status"),[]),l=d.useCallback(async()=>{n("status"),await r.refresh()},[r]),c=d.useCallback(async()=>{n("status"),await r.refresh()},[r]),h=d.useCallback(async()=>{n("status"),await r.refresh()},[r]);return e.jsxs("div",{className:`cedros-wallet-manager ${t}`,children:[o!=="status"&&a&&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:a.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:a.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:i,children:"Back"})]}),o==="status"&&e.jsx(To,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:s}),o==="enroll"&&e.jsx(ko,{onComplete:()=>{l()},onCancel:i}),o==="unlock"&&e.jsx(_o,{onUnlock:()=>{c()},onCancel:i}),o==="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:()=>n("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:i,children:"Cancel"})]})]})}),o==="recover"&&e.jsx(Po,{onComplete:()=>{h()},onCancel:i})]})}function nl({showDescriptions:t=!0,className:s="",onSave:r}){const{settings:o,isLoading:n,isUpdating:a,error:i,fetchSettings:l,updateSettings:c}=Vs.useSystemSettings(),[h,m]=d.useState({}),[u,p]=d.useState(null),[b,w]=d.useState(!1);d.useEffect(()=>{l()},[l]),d.useEffect(()=>{if(b){const E=setTimeout(()=>w(!1),3e3);return()=>clearTimeout(E)}},[b]);const g=d.useCallback((E,f)=>{m(y=>({...y,[E]:f})),p(null),w(!1)},[]),j=d.useCallback(async()=>{const E=Object.entries(h).map(([f,y])=>({key:f,value:y}));if(E.length!==0)try{await c(E),m({}),p(null),w(!0),r?.()}catch(f){p(f instanceof Error?f.message:"Failed to save settings")}},[h,c,r]),v=d.useCallback(()=>{m({}),p(null),w(!1)},[]),N=Object.keys(h).length>0,k=Object.keys(h).length;if(n&&Object.keys(o).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(i)return e.jsx("div",{className:`cedros-system-settings ${s}`,children:e.jsx(te.ErrorMessage,{error:i.message})});const S=Object.keys(o).sort();return S.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${s}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${s}`,children:[u&&e.jsx(te.ErrorMessage,{error:u}),b&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),S.map(E=>e.jsx(ol,{category:E,settings:o[E],edits:h,showDescription:t,onChange:g},E)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[N&&e.jsxs("span",{className:"cedros-settings-change-count",children:[k," unsaved change",k!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:!N||a,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:j,disabled:!N||a,children:a?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const Or=Object.keys(ke.SETTING_METADATA);function ol({category:t,settings:s,edits:r,showDescription:o,onChange:n}){const a=ke.CATEGORY_METADATA[t]||{label:t,description:"",icon:""},i=d.useMemo(()=>[...s].sort((l,c)=>{const h=Or.indexOf(l.key),m=Or.indexOf(c.key);return(h===-1?1/0:h)-(m===-1?1/0:m)}),[s]);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:a.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:a.label}),o&&a.description&&e.jsx("p",{className:"cedros-settings-section-description",children:a.description})]})]}),e.jsx(ke.SettingsSection,{settings:i,edits:r,onChange:n})]})}const ne={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"})}),shield: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:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),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"})]}),image: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:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),referrals: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:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})},al=[{id:"users",label:"Users",icon:ne.users},{id:"team",label:"Team",icon:ne.members},{id:"referrals",label:"Referrals",icon:ne.referrals},{id:"deposits",label:"Deposits",icon:ne.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ne.withdrawals,requiredFeature:"credits"},{id:"compliance",label:"Compliance",icon:ne.shield,group:"Compliance"},{id:"accreditation-queue",label:"Accreditation Queue",icon:ne.shield,group:"Compliance"},{id:"sanctions",label:"Sanctions",icon:ne.shield,group:"Compliance"},{id:"settings-auth",label:"Authentication",icon:ne.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ne.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ne.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ne.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-compliance",label:"Compliance & Gating",icon:ne.shield,group:"Configuration"},{id:"settings-referrals",label:"Referrals & Rewards",icon:ne.referrals,group:"Configuration"},{id:"settings-server",label:"Auth Server",icon:ne.server,group:"Configuration"},{id:"settings-images",label:"Image Storage",icon:ne.image,group:"Configuration"}];function il(t,s){return s.toUpperCase()==="SOL"?`${(t/1e9).toFixed(4)} SOL`:`${t} ${s}`}function qr(t){return t.length<=16?t:`${t.slice(0,8)}...${t.slice(-6)}`}function cl(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const ll=["all","pending","completed","failed","cancelled"];function dl(){const{config:t,_internal:s}=M.useCedrosLogin(),r=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),[o,n]=d.useState("all"),[a,i]=d.useState(0),l=20,[c,h]=d.useState(null),[m,u]=d.useState(!1),[p,b]=d.useState(null),[w,g]=d.useState(null),[j,v]=d.useState(null),N=d.useCallback(async()=>{u(!0),b(null);try{const f=new URLSearchParams;o!=="all"&&f.set("status",o),f.set("limit",String(l)),f.set("offset",String(a*l));const y=await r.get(`/admin/referral-payouts/list?${f.toString()}`);h(y)}catch(f){const y=M.handleApiError(f,"Failed to load payouts");b(y.message)}finally{u(!1)}},[r,o,a]);d.useEffect(()=>{N()},[N]);const k=d.useCallback(async f=>{v(f),g(null);try{const y=await r.post(`/admin/referral-payouts/${f}/process`,{});g(`Processed: ${y.txSignature}`),N()}catch(y){const x=M.handleApiError(y,"Failed to process payout");g(x.message)}finally{v(null)}},[r,N]),S=d.useCallback(async f=>{v(f),g(null);try{await r.post(`/admin/referral-payouts/${f}/cancel`,{}),g("Payout cancelled."),N()}catch(y){const x=M.handleApiError(y,"Failed to cancel payout");g(x.message)}finally{v(null)}},[r,N]),E=c?Math.ceil(c.total/l):0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__filter-bar",children:[e.jsxs("label",{className:"cedros-admin-referral-payouts__filter-label",children:["Status:",e.jsx("select",{value:o,onChange:f=>{n(f.target.value),i(0)},className:"cedros-admin-referral-payouts__filter-select",children:ll.map(f=>e.jsx("option",{value:f,children:f.charAt(0).toUpperCase()+f.slice(1)},f))})]}),c&&e.jsxs("span",{className:"cedros-admin-referral-payouts__filter-count",children:[c.total," total"]})]}),w&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--info",children:w}),m&&!c&&e.jsxs("div",{className:"cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading payouts..."})]}),p&&e.jsxs("div",{className:"cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:p}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:N,children:"Retry"})]}),c&&c.payouts.length===0&&e.jsx("div",{className:"cedros-admin-empty-message",children:"No payouts found."}),c&&c.payouts.length>0&&e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"All referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Trigger"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"TX / Error"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),c.payouts.map(f=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:cl(f.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:f.referrerEmail||f.referrerName||qr(f.referrerId)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:f.triggerType}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:il(f.amount,f.currency)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-referral-payouts__status cedros-admin-referral-payouts__status--${f.status}`,children:f.status})}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:[f.txSignature&&qr(f.txSignature),f.errorMessage&&e.jsx("span",{className:"cedros-admin-list-td-muted",title:f.errorMessage,children:f.errorMessage.slice(0,40)})]}),e.jsxs("div",{className:"cedros-admin-list-td",role:"cell",children:[(f.status==="pending"||f.status==="failed")&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-xs",onClick:()=>k(f.id),disabled:j!==null,children:j===f.id?"...":"Process"}),f.status==="pending"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",onClick:()=>S(f.id),disabled:j!==null,style:{marginLeft:4},children:"Cancel"})]})]},f.id))]}),E>1&&e.jsxs("div",{className:"cedros-admin-referral-payouts__pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a===0,onClick:()=>i(f=>f-1),children:"Previous"}),e.jsxs("span",{className:"cedros-admin-referral-payouts__page-info",children:["Page ",a+1," of ",E]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a>=E-1,onClick:()=>i(f=>f+1),children:"Next"})]})]})}function ns(t,s){return s.toUpperCase()==="SOL"?`${(t/1e9).toFixed(4)} SOL`:`${t} ${s}`}function zr(t){return t.length<=16?t:`${t.slice(0,8)}...${t.slice(-6)}`}function Mo({className:t=""}){const[s,r]=d.useState("summary");return e.jsxs("div",{className:`cedros-admin-referral-payouts ${t}`,children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__tabs",children:[e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${s==="summary"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("summary"),children:"Summary"}),e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${s==="all"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("all"),children:"All Payouts"})]}),s==="summary"?e.jsx(ul,{}):e.jsx(dl,{})]})}function ul(){const{config:t,_internal:s}=M.useCedrosLogin(),r=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),[o,n]=d.useState(null),[a,i]=d.useState(!1),[l,c]=d.useState(null),[h,m]=d.useState(!1),[u,p]=d.useState(null),[b,w]=d.useState(null),[g,j]=d.useState(!1),[v,N]=d.useState(null),[k,S]=d.useState(null),[E,f]=d.useState(null),y=d.useCallback(async()=>{i(!0),c(null);try{const B=await r.get("/admin/referral-payouts");n(B)}catch(B){const F=M.handleApiError(B,"Failed to load referral payouts");c(F.message)}finally{i(!1)}},[r]),x=d.useCallback(async()=>{try{const F=(await r.get("/admin/settings"))?.payout_auto_enabled?.value;f(F==="true")}catch{}},[r]);d.useEffect(()=>{y(),x()},[y,x]);const A=d.useCallback(async()=>{m(!0),p(null),w(null);try{const B=await r.post("/admin/referral-payouts/process",{});p(B),y()}catch(B){const F=M.handleApiError(B,"Failed to process payouts");w(F.message)}finally{m(!1)}},[r,y]),_=d.useCallback(async()=>{j(!0),N(null),S(null);try{const B=await r.post("/admin/referral-payouts/retry-failed",{});N(B),y()}catch(B){const F=M.handleApiError(B,"Failed to retry failed payouts");S(F.message)}finally{j(!1)}},[r,y]),C=h||g;if(a&&!o)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading referral payouts..."})]});if(l)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,children:"Retry"})]});const P=o?.referrers??[],L=o?.total??0,R=P[0]?.currency??"SOL",T=P.reduce((B,F)=>B+F.totalPendingAmount,0);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__header",children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__summary",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Pending Referrers"}),e.jsx("span",{className:"cedros-admin-stat-value",children:L})]}),L>0&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Total Pending Amount"}),e.jsx("span",{className:"cedros-admin-stat-value",children:ns(T,R)})]}),E!==null&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Auto-Processing"}),e.jsx("span",{className:"cedros-admin-stat-value",children:E?"ON":"OFF"})]})]}),e.jsxs("div",{className:"cedros-admin-referral-payouts__actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:A,disabled:C||L===0,"aria-busy":h,children:h?"Processing...":"Process All Payouts"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:_,disabled:C,"aria-busy":g,children:g?"Retrying...":"Retry Failed"})]})]}),u&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Processed ",u.processed," payout(s) totalling"," ",ns(u.totalAmount,R),".",u.failed>0&&` ${u.failed} failed.`,u.skippedNoWallet>0&&` ${u.skippedNoWallet} skipped (no wallet).`]}),b&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:b}),v&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Reset ",v.resetCount," failed payout(s) for retry."]}),k&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:k}),P.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No pending referral payouts."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Pending referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer ID"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Wallet Address"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Pending Referrals"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Total Amount"})]}),P.map(B=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:e.jsx("button",{type:"button",className:"cedros-admin-user-uuid-link",onClick:()=>navigator.clipboard?.writeText(B.referrerId),title:`Click to copy: ${B.referrerId}`,children:zr(B.referrerId)})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:B.payoutWalletAddress?e.jsx("button",{type:"button",className:"cedros-admin-user-uuid-link cedros-admin-list-td-mono",onClick:()=>navigator.clipboard?.writeText(B.payoutWalletAddress),title:`Click to copy: ${B.payoutWalletAddress}`,children:zr(B.payoutWalletAddress)}):e.jsx("span",{className:"cedros-admin-list-td-muted",children:"No wallet"})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:B.pendingCount}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:ns(B.totalPendingAmount,B.currency)})]},B.referrerId))]})]})}function hl({pageSize:t,currentUserId:s}){const[r,o]=d.useState(null),{statsItems:n,isLoading:a,error:i,refresh:l}=We.useUsersStatsSummary();return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(We.AdminUserDetail,{userId:r.id,currentUserId:s,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Cn.StatsBar,{stats:n,isLoading:a,onRefresh:l}),i&&e.jsx("p",{className:"cedros-admin-error-inline",children:i}),e.jsx(We.AdminUserList,{pageSize:t,currentUserId:s,onUserClick:c=>o(c)})]})}function ml({orgId:t,currentUserId:s,hasPermission:r,role:o}){const[n,a]=d.useState("members"),{members:i,isLoading:l,error:c,fetchMembers:h,updateMemberRole:m,removeMember:u}=he.useMembers(t),{invites:p,isLoading:b,error:w,fetchInvites:g,createInvite:j,cancelInvite:v,resendInvite:N}=he.useInvites(t);d.useEffect(()=>{h(),g()},[h,g]);const k=r("invite:create"),S=r("invite:cancel"),E=p.length,f=i.reduce((_,C)=>(_[C.role]=(_[C.role]??0)+1,_),{}),y=f.owner??0,x=f.admin??0,A=f.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Cn.StatsBar,{stats:[{label:"Owners",value:y},{label:"Admins",value:x},{label:"Members",value:A},{label:"Pending Invites",value:E}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="members"?"cedros-admin-tab-active":""}`,onClick:()=>a("members"),"aria-selected":n==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${n==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>a("invites"),"aria-selected":n==="invites",role:"tab",children:["Pending Invites",E>0&&` (${E})`]}),o==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>a("permissions"),"aria-selected":n==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[n==="members"&&e.jsx(he.MemberList,{members:i,currentUserId:s,isLoading:l,error:c?.message,canManage:r("member:remove"),canChangeRoles:r("member:role_change"),onUpdateRole:m,onRemove:u}),n==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[k&&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(he.InviteForm,{onSubmit:j,isLoading:b,error:w?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(he.InviteList,{invites:p,isLoading:b,error:w?.message,canManage:S||k,onCancel:S?v:void 0,onResend:k?N:void 0})})]}),n==="permissions"&&o==="owner"&&e.jsx(he.PermissionsSection,{userRole:o})]})]})}function fl({pageSize:t,refreshInterval:s}){const[r,o]=d.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(Ct.AdminDepositStats,{refreshInterval:s}),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:r,onChange:n=>o(n.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(Ct.AdminDepositList,{statusFilter:r||void 0,pageSize:t,refreshInterval:s})]})]})}function pl({pageSize:t,refreshInterval:s}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Me.AdminWithdrawalStats,{refreshInterval:s}),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(Me.AdminPrivacyPeriodDeposits,{pageSize:t,refreshInterval:s}),e.jsx(Me.AdminWithdrawalQueue,{pageSize:t,refreshInterval:s}),e.jsx(Me.AdminWithdrawalHistory,{pageSize:t,refreshInterval:s})]})]})}function gl(){return e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Mo,{})})}const wl=["security","rate_limit"];function bl({className:t}){return e.jsx(lt.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:wl,className:t})}const $r=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function yl({className:t}){const{settings:s,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:l,handleChange:c,getEffectiveValue:h}=ke.useSettingsAutosave(),[m,u]=d.useState("email");d.useEffect(()=>{l()},[l]);const p=$r.find(S=>S.id===m),b=p?.category??"",g=(h("email_provider")||"custom")==="custom",j=h("email_smtp_host"),v=!g||j!=null&&j!=="",N=d.useMemo(()=>{const S=s[b]??[];if(m!=="email")return S;const E=g?jt.ALL_EMAIL_FIELDS:jt.SIMPLIFIED_EMAIL_FIELDS;return S.filter(f=>E.includes(f.key)).sort((f,y)=>E.indexOf(f.key)-E.indexOf(y.key))},[s,b,m,g]),k=(S,E)=>{if(c(S,E),S==="email_provider"&&E!=="custom"){const f=jt.PROVIDER_SMTP_HOSTS[E];f&&(c("email_smtp_host",f),c("email_smtp_port","587"),c("email_smtp_tls","true"))}};return o&&Object.keys(s).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t??""}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${t??""}`,children:e.jsx(te.ErrorMessage,{error:i.message})}):e.jsxs("div",{className:`cedros-system-settings ${t??""}`,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 for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(ke.AutosaveStatus,{status:n,error:a})]}),m==="email"&&!v&&e.jsx("div",{className:"cedros-settings-warning-banner",children:"Email features (verification, password reset, instant link) are disabled until SMTP is configured. Select a provider or enter custom SMTP settings below."}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:$r.map(S=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${m===S.id?"cedros-admin-tab-active":""}`,onClick:()=>u(S.id),"aria-selected":m===S.id,role:"tab",children:S.label},S.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:N.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",p?.label??"this section","."]})}):e.jsx(ke.SettingsSection,{settings:N,edits:r,onChange:m==="email"?k:c})})]})}const os=["image_storage_enabled","image_storage_provider","image_storage_bucket","image_storage_region","image_storage_endpoint","image_storage_access_key","image_storage_secret_key","image_storage_cdn_url"],Vr={nyc3:"https://nyc3.digitaloceanspaces.com",ams3:"https://ams3.digitaloceanspaces.com",sgp1:"https://sgp1.digitaloceanspaces.com",sfo3:"https://sfo3.digitaloceanspaces.com",fra1:"https://fra1.digitaloceanspaces.com",syd1:"https://syd1.digitaloceanspaces.com"};function xl({className:t}){const{settings:s,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:l,handleChange:c,getEffectiveValue:h}=ke.useSettingsAutosave();d.useEffect(()=>{l()},[l]);const m=d.useMemo(()=>(s.image_storage??[]).filter(b=>os.includes(b.key)).sort((b,w)=>os.indexOf(b.key)-os.indexOf(w.key)),[s]),u=(p,b)=>{if(c(p,b),p==="image_storage_provider")if(b==="digitalocean"){const w=h("image_storage_region")||"nyc3";c("image_storage_region",w),c("image_storage_endpoint",Vr[w]??`https://${w}.digitaloceanspaces.com`)}else b==="s3"&&c("image_storage_endpoint","");p==="image_storage_region"&&h("image_storage_provider")==="digitalocean"&&c("image_storage_endpoint",Vr[b]??`https://${b}.digitaloceanspaces.com`)};return o&&Object.keys(s).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t??""}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${t??""}`,children:e.jsx(te.ErrorMessage,{error:i.message})}):e.jsxs("div",{className:`cedros-system-settings ${t??""}`,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:"Image Storage"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure S3-compatible object storage for user avatars and images. Supports AWS S3, DigitalOcean Spaces, and other S3-compatible providers."})]}),e.jsx(ke.AutosaveStatus,{status:n,error:a})]}),m.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No image storage settings found."})}):e.jsx(ke.SettingsSection,{settings:m,edits:r,onChange:u})]})}const vl=["kyc","accreditation","sanctions","token_gating"];function Bo({className:t}){return e.jsx(lt.SettingsPageLayout,{title:"Compliance & Gating",description:"Configure KYC identity verification, accredited investor verification, sanctions screening, and Solana token gating.",categories:vl,className:t})}const Al=["referral"];function Io({className:t}){return e.jsx(lt.SettingsPageLayout,{title:"Referrals & Rewards",description:"Configure referral reward types, amounts, triggers, per-referrer caps, and automated payout processing.",categories:Al,className:t})}function jl(){return`rule_${Date.now()}_${Math.random().toString(36).slice(2,7)}`}function Nl(t){if(!t)return[];try{const s=JSON.parse(t);return Array.isArray(s)?s:[]}catch{return[]}}function kl(t){switch(t){case"nft_collection":return"NFT Collection";case"fungible_token":return"Fungible Token";case"any_nft":return"Any NFT"}}function Sl(t){switch(t){case"all":return"All";case"deposits":return"Deposits";case"withdrawals":return"Withdrawals"}}const Hr={name:"",ruleType:"nft_collection",collectionAddress:"",mintAddress:"",minQuantity:"",minAmount:"",enforcement:"all"};function Cl(t){return{name:t.name,ruleType:t.ruleType,collectionAddress:t.collectionAddress??"",mintAddress:t.mintAddress??"",minQuantity:t.minQuantity!==void 0?String(t.minQuantity):"",minAmount:t.minAmount??"",enforcement:t.enforcement}}function El(t,s){return{id:s,name:t.name.trim(),ruleType:t.ruleType,collectionAddress:t.ruleType==="nft_collection"&&t.collectionAddress.trim()||void 0,mintAddress:t.ruleType==="fungible_token"&&t.mintAddress.trim()||void 0,minQuantity:t.ruleType!=="fungible_token"&&t.minQuantity?parseInt(t.minQuantity,10):void 0,minAmount:t.ruleType==="fungible_token"&&t.minAmount.trim()||void 0,enforcement:t.enforcement}}function Do({className:t=""}){const{fetchSettings:s,updateSettings:r,getValue:o,isLoading:n,error:a}=Vs.useSystemSettings(),[i,l]=d.useState([]),[c,h]=d.useState(null),[m,u]=d.useState(!1),[p,b]=d.useState(Hr),[w,g]=d.useState(null),[j,v]=d.useState(!1);d.useEffect(()=>{s()},[s]);const N=o("token_gating_rules"),k=d.useMemo(()=>Nl(N),[N]);d.useEffect(()=>{l(k)},[k]);const S=d.useCallback(async C=>{v(!0),g(null);try{await r([{key:"token_gating_rules",value:JSON.stringify(C)}]),l(C)}catch(P){g(P instanceof Error?P.message:"Failed to save rules")}finally{v(!1)}},[r]),E=d.useCallback(()=>{h(null),b(Hr),g(null),u(!0)},[]),f=d.useCallback(C=>{h(C.id),b(Cl(C)),g(null),u(!0)},[]),y=d.useCallback(C=>{const P=i.filter(L=>L.id!==C);S(P)},[i,S]),x=d.useCallback(()=>{u(!1),g(null)},[]),A=d.useCallback(async()=>{if(!p.name.trim()){g("Rule name is required.");return}const C=c??jl(),P=El(p,C),L=c?i.map(R=>R.id===c?P:R):[...i,P];await S(L),w||u(!1)},[p,c,i,S,w]),_=d.useCallback((C,P)=>{b(L=>({...L,[C]:P}))},[]);return n&&i.length===0?e.jsxs("div",{className:`cedros-admin-token-gate ${t} cedros-admin-token-gate--loading`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading token gate rules..."})]}):a&&i.length===0?e.jsxs("div",{className:`cedros-admin-token-gate ${t} cedros-admin-token-gate--error`,children:[e.jsx("p",{className:"cedros-admin-error",children:a.message}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:"Retry"})]}):e.jsxs("div",{className:`cedros-admin-token-gate ${t}`,children:[e.jsxs("div",{className:"cedros-admin-token-gate__header",children:[e.jsx("h2",{className:"cedros-admin-token-gate__title",children:"Token Gate Rules"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:E,disabled:m,children:"Add Rule"})]}),m&&e.jsx(_l,{form:p,isNew:c===null,isSaving:j,saveError:w,onFieldChange:_,onSave:A,onCancel:x}),i.length===0&&!m?e.jsx("div",{className:"cedros-admin-empty-message",children:"No token gate rules configured."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Token gate rules",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Name"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Address / Mint"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Min Qty / Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Enforcement"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),i.map(C=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:C.name}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:kl(C.ruleType)}),e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:C.collectionAddress||C.mintAddress||"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:C.minQuantity!==void 0?C.minQuantity:C.minAmount??"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Sl(C.enforcement)}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-actions",role:"cell",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>f(C),disabled:m,children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>y(C.id),disabled:j||m,children:"Delete"})]})]},C.id))]})]})}function _l({form:t,isNew:s,isSaving:r,saveError:o,onFieldChange:n,onSave:a,onCancel:i}){const l=t.ruleType==="nft_collection",c=t.ruleType==="fungible_token",h=t.ruleType!=="fungible_token",m=t.ruleType==="fungible_token";return e.jsxs("div",{className:"cedros-admin-token-gate__form",role:"region","aria-label":s?"Add rule":"Edit rule",children:[e.jsx("h3",{className:"cedros-admin-token-gate__form-title",children:s?"Add Rule":"Edit Rule"}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-name",children:"Name"}),e.jsx("input",{id:"tg-name",type:"text",className:"cedros-admin-form-input",value:t.name,onChange:u=>n("name",u.target.value),placeholder:"e.g. Whale Gate"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-type",children:"Type"}),e.jsxs("select",{id:"tg-type",className:"cedros-admin-form-select",value:t.ruleType,onChange:u=>n("ruleType",u.target.value),children:[e.jsx("option",{value:"nft_collection",children:"NFT Collection"}),e.jsx("option",{value:"fungible_token",children:"Fungible Token"}),e.jsx("option",{value:"any_nft",children:"Any NFT"})]})]}),l&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-collection",children:"Collection Address"}),e.jsx("input",{id:"tg-collection",type:"text",className:"cedros-admin-form-input cedros-admin-form-input--mono",value:t.collectionAddress,onChange:u=>n("collectionAddress",u.target.value),placeholder:"Solana collection mint address"})]}),c&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-mint",children:"Mint Address"}),e.jsx("input",{id:"tg-mint",type:"text",className:"cedros-admin-form-input cedros-admin-form-input--mono",value:t.mintAddress,onChange:u=>n("mintAddress",u.target.value),placeholder:"SPL token mint address"})]}),h&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-minqty",children:"Min Quantity"}),e.jsx("input",{id:"tg-minqty",type:"number",min:"1",className:"cedros-admin-form-input",value:t.minQuantity,onChange:u=>n("minQuantity",u.target.value),placeholder:"1"})]}),m&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-minamount",children:"Min Amount"}),e.jsx("input",{id:"tg-minamount",type:"text",className:"cedros-admin-form-input",value:t.minAmount,onChange:u=>n("minAmount",u.target.value),placeholder:"e.g. 1000000 (raw units)"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-enforcement",children:"Enforcement"}),e.jsxs("select",{id:"tg-enforcement",className:"cedros-admin-form-select",value:t.enforcement,onChange:u=>n("enforcement",u.target.value),children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"deposits",children:"Deposits"}),e.jsx("option",{value:"withdrawals",children:"Withdrawals"})]})]}),o&&e.jsx("p",{className:"cedros-admin-error",children:o}),e.jsxs("div",{className:"cedros-admin-token-gate__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,disabled:r,"aria-busy":r,children:r?"Saving...":"Save Rule"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:i,disabled:r,children:"Cancel"})]})]})}function Ll(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Pl(t){return{income:"Income",net_worth:"Net Worth",credential:"Credential",third_party_letter:"Third-Party Letter",insider:"Insider / Executive",investment_threshold:"Investment Threshold"}[t]??t}function Rl(t){switch(t){case"pending":return"cedros-admin-badge--pending";case"approved":return"cedros-admin-badge--approved";case"rejected":return"cedros-admin-badge--rejected";case"expired":return"cedros-admin-badge--expired";default:return""}}function Tl({item:t,isExpanded:s,detail:r,detailLoading:o,detailError:n,reviewNotes:a,rejectionReason:i,isReviewing:l,reviewError:c,onRowClick:h,onDocumentDownload:m,onReviewNotesChange:u,onRejectionReasonChange:p,onReview:b}){const w=t.statedAmountUsd!==void 0?`$${t.statedAmountUsd.toLocaleString()}`:t.investmentCommitmentUsd!==void 0?`$${t.investmentCommitmentUsd.toLocaleString()}`:"—";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`cedros-admin-list-row cedros-admin-list-row--clickable ${s?"cedros-admin-list-row--expanded":""}`,role:"row",onClick:()=>h(t.id),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),h(t.id))},tabIndex:0,"aria-expanded":s,children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:t.userEmail??e.jsxs("span",{className:"cedros-admin-list-td-mono",children:[t.userId.slice(0,12),"..."]})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Pl(t.method)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:w}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Ll(t.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-badge ${Rl(t.status)}`,children:t.status})})]}),s&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail",role:"region","aria-label":"Submission detail",children:[o&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading detail..."})]}),n&&e.jsx("p",{className:"cedros-admin-error",children:n}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Ml,{detail:r,onDocumentDownload:m}),t.status==="pending"&&e.jsx(Bl,{submissionId:t.id,notes:a,rejectionReason:i,isReviewing:l,error:c,onNotesChange:u,onRejectionReasonChange:p,onReview:b})]})]})]})}function Ml({detail:t,onDocumentDownload:s}){return e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail-fields",children:[t.incomeType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Income Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:t.incomeType})]}),t.statedAmountUsd!==void 0&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Stated Amount"}),e.jsxs("span",{className:"cedros-admin-detail-value",children:["$",t.statedAmountUsd.toLocaleString()]})]}),t.crdNumber&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"CRD Number"}),e.jsx("span",{className:"cedros-admin-detail-value cedros-admin-list-td-mono",children:t.crdNumber})]}),t.licenseType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"License Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:t.licenseType})]}),t.investmentCommitmentUsd!==void 0&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Investment Commitment"}),e.jsxs("span",{className:"cedros-admin-detail-value",children:["$",t.investmentCommitmentUsd.toLocaleString()]})]}),t.entityType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Entity Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:t.entityType})]}),t.userStatement&&e.jsxs("div",{className:"cedros-admin-detail-row cedros-admin-detail-row--block",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"User Statement"}),e.jsx("p",{className:"cedros-admin-detail-statement",children:t.userStatement})]}),t.documents.length>0&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__documents",children:[e.jsx("h4",{className:"cedros-admin-accreditation-queue__documents-title",children:"Documents"}),t.documents.map(r=>e.jsxs("div",{className:"cedros-admin-accreditation-queue__document-row",children:[e.jsx("span",{className:"cedros-admin-accreditation-queue__document-name",children:r.originalFilename??r.documentType}),r.fileSizeBytes&&e.jsxs("span",{className:"cedros-admin-list-td-muted",children:[(r.fileSizeBytes/1024).toFixed(1)," KB"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>s(r.id),children:"Download"})]},r.id))]})]})}function Bl({submissionId:t,notes:s,rejectionReason:r,isReviewing:o,error:n,onNotesChange:a,onRejectionReasonChange:i,onReview:l}){return e.jsxs("div",{className:"cedros-admin-accreditation-queue__review-form",children:[e.jsx("h4",{className:"cedros-admin-accreditation-queue__review-title",children:"Review Decision"}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"review-notes",children:"Reviewer Notes (internal)"}),e.jsx("textarea",{id:"review-notes",className:"cedros-admin-form-textarea",value:s,onChange:c=>a(c.target.value),rows:2,placeholder:"Optional internal notes"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"rejection-reason",children:"Rejection Reason (required if rejecting)"}),e.jsx("textarea",{id:"rejection-reason",className:"cedros-admin-form-textarea",value:r,onChange:c=>i(c.target.value),rows:2,placeholder:"Reason shown to user"})]}),n&&e.jsx("p",{className:"cedros-admin-error",children:n}),e.jsxs("div",{className:"cedros-admin-accreditation-queue__review-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:()=>l(t,!0),disabled:o,"aria-busy":o,children:o?"Saving...":"Approve"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>l(t,!1),disabled:o,"aria-busy":o,children:o?"Saving...":"Reject"})]})]})}const it=20;function Uo({className:t=""}){const{config:s,_internal:r}=M.useCedrosLogin(),o=d.useMemo(()=>new We.AdminUserApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),[n,a]=d.useState("pending"),[i,l]=d.useState([]),[c,h]=d.useState(0),[m,u]=d.useState(0),[p,b]=d.useState(!1),[w,g]=d.useState(null),[j,v]=d.useState(null),[N,k]=d.useState(null),[S,E]=d.useState(!1),[f,y]=d.useState(null),[x,A]=d.useState(""),[_,C]=d.useState(""),[P,L]=d.useState(!1),[R,T]=d.useState(null),[B,F]=d.useState(null),W=d.useCallback(async()=>{b(!0),g(null);try{const $=await o.listPendingAccreditations(it,m);l($.items),h($.total)}catch($){g($ instanceof Error?$.message:"Failed to load submissions")}finally{b(!1)}},[o,n,m]);d.useEffect(()=>{W()},[W]),d.useEffect(()=>{u(0),v(null),k(null)},[n]);const O=d.useCallback(async $=>{if(j===$){v(null),k(null);return}v($),k(null),y(null),A(""),C(""),T(null),F(null),E(!0);try{const Y=await o.getAccreditationSubmission($);k(Y)}catch(Y){y(Y instanceof Error?Y.message:"Failed to load submission detail")}finally{E(!1)}},[j,o]),I=d.useCallback(async $=>{try{const Y=await o.getAccreditationDocumentUrl($);window.open(Y,"_blank","noopener,noreferrer")}catch(Y){T(Y instanceof Error?Y.message:"Failed to get document URL")}},[o]),U=d.useCallback(async($,Y)=>{if(!Y&&!_.trim()){T("Rejection reason is required.");return}L(!0),T(null),F(null);try{await o.reviewAccreditation($,Y,x.trim()||void 0,Y?void 0:_.trim()),F(Y?"Submission approved.":"Submission rejected."),v(null),k(null),W()}catch(V){T(V instanceof Error?V.message:"Failed to submit review")}finally{L(!1)}},[o,x,_,W]),z=Math.ceil(c/it),K=Math.floor(m/it)+1,se=n==="pending"?c:i.filter($=>$.status==="pending").length;return e.jsxs("div",{className:`cedros-admin-accreditation-queue ${t}`,children:[e.jsxs("div",{className:"cedros-admin-accreditation-queue__header",children:[e.jsxs("h2",{className:"cedros-admin-accreditation-queue__title",children:["Accreditation Review Queue",se>0&&e.jsx("span",{className:"cedros-admin-queue-count","aria-label":`${se} pending`,children:se})]}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:W,disabled:p,title:"Refresh","aria-label":"Refresh list",children:p?"...":"↻"})]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",role:"tablist",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="pending"?"cedros-admin-tab-active":""}`,onClick:()=>a("pending"),"aria-selected":n==="pending",role:"tab",children:"Pending"}),e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="all"?"cedros-admin-tab-active":""}`,onClick:()=>a("all"),"aria-selected":n==="all",role:"tab",children:"All"})]}),B&&e.jsx("div",{className:"cedros-admin-accreditation-queue__result cedros-admin-accreditation-queue__result--success",children:B}),w&&e.jsxs("div",{className:"cedros-admin-accreditation-queue cedros-admin-accreditation-queue--error",children:[e.jsx("p",{className:"cedros-admin-error",children:w}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:W,children:"Retry"})]}),!w&&p&&i.length===0?e.jsxs("div",{className:"cedros-admin-accreditation-queue--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading submissions..."})]}):e.jsx("div",{role:"tabpanel",children:i.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No submissions found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Accreditation submissions",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"User"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Method"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Submitted"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"})]}),i.map($=>e.jsx(Tl,{item:$,isExpanded:j===$.id,detail:j===$.id?N:null,detailLoading:j===$.id&&S,detailError:j===$.id?f:null,reviewNotes:x,rejectionReason:_,isReviewing:P,reviewError:j===$.id?R:null,onRowClick:O,onDocumentDownload:I,onReviewNotesChange:A,onRejectionReasonChange:C,onReview:U},$.id))]}),z>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(Math.max(0,m-it)),disabled:K<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",K," of ",z," (",c," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(m+it),disabled:K>=z,children:"Next"})]})]})})]})}function Il(t){return t===void 0?"—":t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m ${t%60}s`:`${Math.floor(t/3600)}h ${Math.floor(t%3600/60)}m`}function Dl(t){return t?new Date(t).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function Fo({className:t=""}){const{config:s,_internal:r}=M.useCedrosLogin(),o=d.useMemo(()=>new We.AdminUserApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),[n,a]=d.useState(null),[i,l]=d.useState(!1),[c,h]=d.useState(null),[m,u]=d.useState(!1),[p,b]=d.useState(null),[w,g]=d.useState(!1),j=d.useCallback(async()=>{l(!0),h(null);try{const N=await o.getSanctionsStats();a(N)}catch(N){h(N instanceof Error?N.message:"Failed to load sanctions stats")}finally{l(!1)}},[o]);d.useEffect(()=>{j()},[j]);const v=d.useCallback(async()=>{u(!0),b(null),g(!1);try{await o.refreshSanctions(),g(!0),await j()}catch(N){b(N instanceof Error?N.message:"Failed to refresh sanctions cache")}finally{u(!1)}},[o,j]);return i&&!n?e.jsxs("div",{className:`cedros-admin-sanctions-panel ${t} cedros-admin-sanctions-panel--loading`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading sanctions stats..."})]}):c&&!n?e.jsxs("div",{className:`cedros-admin-sanctions-panel ${t} cedros-admin-sanctions-panel--error`,children:[e.jsx("p",{className:"cedros-admin-error",children:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:j,children:"Retry"})]}):e.jsxs("div",{className:`cedros-admin-sanctions-panel ${t}`,children:[e.jsxs("div",{className:"cedros-admin-sanctions-panel__header",children:[e.jsx("h2",{className:"cedros-admin-sanctions-panel__title",children:"Sanctions Screening"}),e.jsxs("div",{className:"cedros-admin-sanctions-panel__header-actions",children:[n!==null&&e.jsx("span",{className:`cedros-admin-badge ${n.configured?"cedros-admin-badge--approved":"cedros-admin-badge--pending"}`,title:n.configured?"Sanctions API configured":"Sanctions API not configured",children:n.configured?"Configured":"Not Configured"}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:j,disabled:i,title:"Refresh stats","aria-label":"Refresh stats",children:i?"...":"↻"})]})]}),n!==null&&e.jsxs("div",{className:"cedros-admin-sanctions-panel__stats",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Sanctioned Addresses"}),e.jsx("span",{className:"cedros-admin-stat-value",children:n.sanctionedAddresses.toLocaleString()})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Sanctioned Countries"}),e.jsx("span",{className:"cedros-admin-stat-value",children:n.sanctionedCountries.toLocaleString()})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Cache Age"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Il(n.cacheAgeSeconds)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Last Refresh"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Dl(n.lastRefreshedAt)})]})]}),e.jsx("div",{className:"cedros-admin-sanctions-panel__actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:v,disabled:m||i,"aria-busy":m,children:m?"Refreshing...":"Force Refresh"})}),w&&e.jsx("div",{className:"cedros-admin-sanctions-panel__result cedros-admin-sanctions-panel__result--success",children:"Sanctions cache refreshed successfully."}),p&&e.jsx("div",{className:"cedros-admin-sanctions-panel__result cedros-admin-sanctions-panel__result--error",children:p}),c&&n&&e.jsx("p",{className:"cedros-admin-error cedros-admin-error--inline",children:c})]})}class Ul{client;constructor(s,r,o){this.client=new M.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o})}async getStatus(){try{return await this.client.get("/setup/status")}catch(s){throw M.handleApiError(s,"Failed to check setup status")}}async createFirstAdmin(s){try{return await this.client.post("/setup/admin",s)}catch(r){throw M.handleApiError(r,"Failed to create admin account")}}}function rr(){const{config:t}=M.useCedrosLogin(),[s,r]=d.useState(null),[o,n]=d.useState(!1),[a,i]=d.useState(!1),[l,c]=d.useState(null),h=d.useRef(0),m=d.useMemo(()=>new Ul(t.serverUrl,t.requestTimeout,t.retryAttempts),[t.serverUrl,t.requestTimeout,t.retryAttempts]),u=d.useRef(m);u.current=m;const p=d.useCallback(async()=>{n(!0),c(null);const w=++h.current;try{const g=await u.current.getStatus();if(w!==h.current)return;r(g)}catch(g){if(w!==h.current)return;c(g instanceof Error?g:new Error("Failed to check setup status"))}finally{w===h.current&&n(!1)}},[]),b=d.useCallback(async w=>{i(!0),c(null);try{const g=await u.current.createFirstAdmin(w);return await p(),g}catch(g){const j=g instanceof Error?g:new Error("Failed to create admin");throw c(j),j}finally{i(!1)}},[p]);return{status:s,isLoading:o,isCreating:a,error:l,checkStatus:p,createAdmin:b}}const Fl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Qr=8;function Wl(t){const s={};return t.email?Fl.test(t.email)||(s.email="Invalid email format"):s.email="Email is required",t.password?t.password.length<Qr&&(s.password=`Password must be at least ${Qr} characters`):s.password="Password is required",t.confirmPassword?t.password!==t.confirmPassword&&(s.confirmPassword="Passwords do not match"):s.confirmPassword="Please confirm your password",s}function Wo({onComplete:t,className:s=""}){const{status:r,isLoading:o,isCreating:n,error:a,checkStatus:i,createAdmin:l}=rr(),[c,h]=d.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[m,u]=d.useState({}),[p,b]=d.useState(!1);d.useEffect(()=>{i()},[i]);const w=d.useCallback(j=>v=>{h(N=>({...N,[j]:v.target.value})),u(N=>({...N,[j]:void 0}))},[]),g=d.useCallback(async j=>{j.preventDefault();const v=Wl(c);if(Object.keys(v).length>0){u(v);return}try{await l({email:c.email,password:c.password,name:c.name||void 0,orgName:c.orgName||void 0}),b(!0),t?.()}catch{}},[c,l,t]);return o?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):r&&!r.needsSetup?e.jsx("div",{className:`cedros-setup ${s}`,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."})]})}):p?e.jsx("div",{className:`cedros-setup ${s}`,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 ${s}`,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:g,children:[a&&e.jsx(te.ErrorMessage,{error:a.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 ${m.email?"cedros-setup__input--error":""}`,value:c.email,onChange:w("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:n}),m.email&&e.jsx("span",{className:"cedros-setup__error",children:m.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:c.name,onChange:w("name"),placeholder:"Admin",autoComplete:"name",disabled:n})]}),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:c.orgName,onChange:w("orgName"),placeholder:"My Organization",disabled:n})]}),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 ${m.password?"cedros-setup__input--error":""}`,value:c.password,onChange:w("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:n}),m.password&&e.jsx("span",{className:"cedros-setup__error",children:m.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 ${m.confirmPassword?"cedros-setup__input--error":""}`,value:c.confirmPassword,onChange:w("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:n}),m.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:m.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Q.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."}),r?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",r.serverVersion]})]})]})})}function Ol({title:t="Dashboard",sections:s=["users","team","referrals","deposits","withdrawals","compliance","accreditation-queue","sanctions","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-compliance","settings-referrals","settings-server","settings-images"],defaultSection:r="users",refreshInterval:o=0,pageSize:n=20,onSectionChange:a,onSettingsClick:i,onLogoutClick:l,className:c=""}){const[h,m]=d.useState(r),[u,p]=d.useState(!0),{user:b,logout:w}=M.useCedrosLogin(),{activeOrg:g,role:j,isLoading:v,fetchOrgs:N,hasPermission:k}=Hs.useOrgs(),{status:S,isLoading:E,checkStatus:f}=rr(),{features:y,isLoading:x}=he.useServerFeatures(),{canAccess:A}=he.useDashboardPermissions(),_=d.useCallback(T=>{m(T),a?.(T)},[a]),C=al.filter(T=>!(!s.includes(T.id)||T.requiredFeature&&!y[T.requiredFeature]||!A(T.id))),P=C.find(T=>T.id===h),L=!P&&!x;return d.useEffect(()=>{N(),f()},[N,f]),d.useEffect(()=>{L&&C.length>0&&m("users")},[L,C.length]),!E&&S?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${c}`,children:e.jsx(Wo,{onComplete:()=>f()})}):(v||E||x)&&!g?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${c}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):h==="team"&&!g?e.jsx("div",{className:`cedros-admin cedros-dashboard ${c}`,children:e.jsx(te.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${c}`,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:[ne.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:t})]})}),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"}),C.filter(T=>!T.group).map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${h===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>_(T.id),"aria-current":h===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]}),C.some(T=>T.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:()=>p(!u),"aria-expanded":u,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${u?"cedros-dashboard__nav-chevron--expanded":""}`,children:ne.chevronRight})]}),u&&C.filter(T=>T.group==="Configuration").map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${h===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>_(T.id),"aria-current":h===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]})]}),b&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(Be.ProfileDropdown,{name:b.name,email:b.email,picture:b.picture,onSettings:i,onLogout:l??w})})]}),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:t}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:ne.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:P?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[h==="users"&&e.jsx(hl,{pageSize:n,currentUserId:b?.id}),h==="team"&&g&&e.jsx(ml,{orgId:g.id,currentUserId:b?.id,hasPermission:k,role:j}),h==="referrals"&&e.jsx(gl,{}),h==="deposits"&&e.jsx(fl,{pageSize:n,refreshInterval:o}),h==="withdrawals"&&e.jsx(pl,{pageSize:n,refreshInterval:o}),h==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(En.AuthenticationSettings,{})}),h==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(_n.EmbeddedWalletSettings,{})}),h==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(yl,{})}),h==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Qs.CreditSystemSettings,{})}),h==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ln.ServerSettings,{})}),h==="settings-images"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(xl,{})}),h==="compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Do,{})}),h==="accreditation-queue"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Uo,{})}),h==="sanctions"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Fo,{})}),h==="settings-compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Bo,{})}),h==="settings-referrals"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Io,{})})]})]})]})}var Ye={},as,Gr;function ql(){return Gr||(Gr=1,as=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),as}var is={},Te={},Kr;function qe(){if(Kr)return Te;Kr=1;let t;const s=[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 Te.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Te.getSymbolTotalCodewords=function(o){return s[o]},Te.getBCHDigit=function(r){let o=0;for(;r!==0;)o++,r>>>=1;return o},Te.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');t=o},Te.isKanjiModeEnabled=function(){return typeof t<"u"},Te.toSJIS=function(o){return t(o)},Te}var cs={},Yr;function nr(){return Yr||(Yr=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+r)}}t.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},t.from=function(o,n){if(t.isValid(o))return o;try{return s(o)}catch{return n}}})(cs)),cs}var ls,Zr;function zl(){if(Zr)return ls;Zr=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const r=Math.floor(s/8);return(this.buffer[r]>>>7-s%8&1)===1},put:function(s,r){for(let o=0;o<r;o++)this.putBit((s>>>r-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),s&&(this.buffer[r]|=128>>>this.length%8),this.length++}},ls=t,ls}var ds,Xr;function $l(){if(Xr)return ds;Xr=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,r,o,n){const a=s*this.size+r;this.data[a]=o,n&&(this.reservedBit[a]=!0)},t.prototype.get=function(s,r){return this.data[s*this.size+r]},t.prototype.xor=function(s,r,o){this.data[s*this.size+r]^=o},t.prototype.isReserved=function(s,r){return this.reservedBit[s*this.size+r]},ds=t,ds}var us={},Jr;function Vl(){return Jr||(Jr=1,(function(t){const s=qe().getSymbolSize;t.getRowColCoords=function(o){if(o===1)return[];const n=Math.floor(o/7)+2,a=s(o),i=a===145?26:Math.ceil((a-13)/(2*n-2))*2,l=[a-7];for(let c=1;c<n-1;c++)l[c]=l[c-1]-i;return l.push(6),l.reverse()},t.getPositions=function(o){const n=[],a=t.getRowColCoords(o),i=a.length;for(let l=0;l<i;l++)for(let c=0;c<i;c++)l===0&&c===0||l===0&&c===i-1||l===i-1&&c===0||n.push([a[l],a[c]]);return n}})(us)),us}var hs={},en;function Hl(){if(en)return hs;en=1;const t=qe().getSymbolSize,s=7;return hs.getPositions=function(o){const n=t(o);return[[0,0],[n-s,0],[0,n-s]]},hs}var ms={},tn;function Ql(){return tn||(tn=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},t.from=function(n){return t.isValid(n)?parseInt(n,10):void 0},t.getPenaltyN1=function(n){const a=n.size;let i=0,l=0,c=0,h=null,m=null;for(let u=0;u<a;u++){l=c=0,h=m=null;for(let p=0;p<a;p++){let b=n.get(u,p);b===h?l++:(l>=5&&(i+=s.N1+(l-5)),h=b,l=1),b=n.get(p,u),b===m?c++:(c>=5&&(i+=s.N1+(c-5)),m=b,c=1)}l>=5&&(i+=s.N1+(l-5)),c>=5&&(i+=s.N1+(c-5))}return i},t.getPenaltyN2=function(n){const a=n.size;let i=0;for(let l=0;l<a-1;l++)for(let c=0;c<a-1;c++){const h=n.get(l,c)+n.get(l,c+1)+n.get(l+1,c)+n.get(l+1,c+1);(h===4||h===0)&&i++}return i*s.N2},t.getPenaltyN3=function(n){const a=n.size;let i=0,l=0,c=0;for(let h=0;h<a;h++){l=c=0;for(let m=0;m<a;m++)l=l<<1&2047|n.get(h,m),m>=10&&(l===1488||l===93)&&i++,c=c<<1&2047|n.get(m,h),m>=10&&(c===1488||c===93)&&i++}return i*s.N3},t.getPenaltyN4=function(n){let a=0;const i=n.data.length;for(let c=0;c<i;c++)a+=n.data[c];return Math.abs(Math.ceil(a*100/i/5)-10)*s.N4};function r(o,n,a){switch(o){case t.Patterns.PATTERN000:return(n+a)%2===0;case t.Patterns.PATTERN001:return n%2===0;case t.Patterns.PATTERN010:return a%3===0;case t.Patterns.PATTERN011:return(n+a)%3===0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(a/3))%2===0;case t.Patterns.PATTERN101:return n*a%2+n*a%3===0;case t.Patterns.PATTERN110:return(n*a%2+n*a%3)%2===0;case t.Patterns.PATTERN111:return(n*a%3+(n+a)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}t.applyMask=function(n,a){const i=a.size;for(let l=0;l<i;l++)for(let c=0;c<i;c++)a.isReserved(c,l)||a.xor(c,l,r(n,c,l))},t.getBestMask=function(n,a){const i=Object.keys(t.Patterns).length;let l=0,c=1/0;for(let h=0;h<i;h++){a(h),t.applyMask(h,n);const m=t.getPenaltyN1(n)+t.getPenaltyN2(n)+t.getPenaltyN3(n)+t.getPenaltyN4(n);t.applyMask(h,n),m<c&&(c=m,l=h)}return l}})(ms)),ms}var wt={},sn;function Oo(){if(sn)return wt;sn=1;const t=nr(),s=[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],r=[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 wt.getBlocksCount=function(n,a){switch(a){case t.L:return s[(n-1)*4+0];case t.M:return s[(n-1)*4+1];case t.Q:return s[(n-1)*4+2];case t.H:return s[(n-1)*4+3];default:return}},wt.getTotalCodewordsCount=function(n,a){switch(a){case t.L:return r[(n-1)*4+0];case t.M:return r[(n-1)*4+1];case t.Q:return r[(n-1)*4+2];case t.H:return r[(n-1)*4+3];default:return}},wt}var fs={},ct={},rn;function Gl(){if(rn)return ct;rn=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let o=1;for(let n=0;n<255;n++)t[n]=o,s[o]=n,o<<=1,o&256&&(o^=285);for(let n=255;n<512;n++)t[n]=t[n-255]})(),ct.log=function(o){if(o<1)throw new Error("log("+o+")");return s[o]},ct.exp=function(o){return t[o]},ct.mul=function(o,n){return o===0||n===0?0:t[s[o]+s[n]]},ct}var nn;function Kl(){return nn||(nn=1,(function(t){const s=Gl();t.mul=function(o,n){const a=new Uint8Array(o.length+n.length-1);for(let i=0;i<o.length;i++)for(let l=0;l<n.length;l++)a[i+l]^=s.mul(o[i],n[l]);return a},t.mod=function(o,n){let a=new Uint8Array(o);for(;a.length-n.length>=0;){const i=a[0];for(let c=0;c<n.length;c++)a[c]^=s.mul(n[c],i);let l=0;for(;l<a.length&&a[l]===0;)l++;a=a.slice(l)}return a},t.generateECPolynomial=function(o){let n=new Uint8Array([1]);for(let a=0;a<o;a++)n=t.mul(n,new Uint8Array([1,s.exp(a)]));return n}})(fs)),fs}var ps,on;function Yl(){if(on)return ps;on=1;const t=Kl();function s(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(o){this.degree=o,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(o.length+this.degree);n.set(o);const a=t.mod(n,this.genPoly),i=this.degree-a.length;if(i>0){const l=new Uint8Array(this.degree);return l.set(a,i),l}return a},ps=s,ps}var gs={},ws={},bs={},an;function qo(){return an||(an=1,bs.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),bs}var Ae={},cn;function zo(){if(cn)return Ae;cn=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
|
|
2050
|
-
]))+`;Ae.KANJI=new RegExp(r,"g"),Ae.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Ae.BYTE=new RegExp(o,"g"),Ae.NUMERIC=new RegExp(
|
|
2051
|
-
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},
|
|
2052
|
-
Suggested mode is: `+
|
|
2049
|
+
`),me=12;function hc(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const r=mo(s,Se).split(" ");if(r.length!==me)throw new Error(`Unexpected word count: expected ${me}, got ${r.length}`);return r}function mc(s){if(s.length!==me)throw new Error(`Invalid word count: expected ${me}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!rr(t,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=tr(t,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return D.toShamirShare(r)}function pc(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const r=mo(s,Se).split(" ");if(r.length!==me)throw new Error(`Unexpected word count: expected ${me}, got ${r.length}`);return r}function fc(s){if(s.length!==me)throw new Error(`Invalid word count: expected ${me}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!rr(t,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=tr(t,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return D.toSeed(r)}function po(s){if(s.length!==me)return!1;const t=s.join(" ").toLowerCase().trim();return rr(t,Se)}function bs(s){return Se.includes(s.toLowerCase().trim())}function gc(s,t=5){const r=s.toLowerCase().trim();return r.length===0?[]:Se.filter(o=>o.startsWith(r)).slice(0,t)}function wc(s){const t=[];for(let r=0;r<s.length;r+=4)t.push(s.slice(r,r+4));return t}function bc(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function xc({className:s="",variant:t="default",size:r="md",children:o,menuItems:n=[],hideSignOut:a=!1}){const{user:i,isAuthenticated:d,isLoading:l,openLoginModal:h,logout:m}=D.useAuth(),[u,f]=c.useState(!1),[w,b]=c.useState(-1),g=c.useRef(null),N=c.useRef(null),A=c.useMemo(()=>[...n,...a?[]:[{label:"Sign out",onClick:m}]],[n,a,m]);c.useEffect(()=>{if(!u)return;const p=x=>{g.current&&!g.current.contains(x.target)&&(f(!1),b(-1))},y=x=>{x.key==="Escape"&&(f(!1),b(-1),N.current?.focus())};return document.addEventListener("mousedown",p),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",y)}},[u]);const v=c.useCallback(p=>{if(!(!u||A.length===0))switch(p.key){case"ArrowDown":p.preventDefault(),b(y=>(y+1)%A.length);break;case"ArrowUp":p.preventDefault(),b(y=>(y-1+A.length)%A.length);break;case"Home":p.preventDefault(),b(0);break;case"End":p.preventDefault(),b(A.length-1);break;case"Enter":case" ":w>=0&&(p.preventDefault(),A[w].onClick(),f(!1),b(-1));break}},[u,w,A]),k=c.useCallback(()=>{A.length!==0&&(f(p=>!p),b(-1))},[A.length]),S={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},E={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(l)return e.jsx("button",{type:"button",className:`cedros-button ${E[t]} ${S[r]} ${s}`,disabled:!0,children:e.jsx(Q.LoadingSpinner,{size:"sm"})});if(d&&i){const p=i.name||i.email||"User",y=es.sanitizeImageUrl(i.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:g,onKeyDown:v,children:[e.jsxs("button",{ref:N,type:"button",className:`cedros-button cedros-user-button ${S[r]} ${s}`,"aria-haspopup":"menu","aria-expanded":u,"aria-label":`User menu for ${p}`,onClick:k,children:[y?e.jsx("img",{src:y,alt:p,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(p[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:p})]}),u&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[n.map((x,j)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${w===j?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===j?0:-1,onClick:()=>{x.onClick(),f(!1)},children:[x.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:x.icon}),x.label]},j)),n.length>0&&!a&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!a&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${w===n.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===n.length?0:-1,onClick:()=>{m(),f(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${E[t]} ${S[r]} ${s}`,onClick:h,children:o||"Sign in"})}function Ws(){const{config:s}=M.useCedrosLogin(),[t,r]=c.useState(!1),[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:l,getRemainingAttempts:h}=J.useRateLimiter({maxAttempts:3,windowMs:3e5}),m=c.useCallback(async b=>{if(!We.validateEmail(b)){const g={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw i(g),g}try{l()}catch(g){const N={code:"RATE_LIMITED",message:g instanceof Error?g.message:"Too many attempts"};throw i(N),N}r(!0),i(null),n(!1);try{await d.post("/forgot-password",{email:b}),n(!0)}catch(g){const N=M.handleApiError(g,"Unable to send the reset email. Please try again.");throw i(N),N}finally{r(!1)}},[d,l]),u=c.useCallback(async(b,g)=>{r(!0),i(null),n(!1);try{await d.post("/reset-password",{token:b,newPassword:g}),n(!0)}catch(N){const A=M.handleApiError(N,"Unable to reset your password. Please try again.");throw i(A),A}finally{r(!1)}},[d]),f=c.useCallback(()=>i(null),[]),w=c.useCallback(()=>{i(null),n(!1),r(!1)},[]);return{forgotPassword:m,resetPassword:u,isLoading:t,isSuccess:o,error:a,clearError:f,reset:w,remainingAttempts:h()}}function yc(s){return typeof s=="object"&&s!==null&&"mfaRequired"in s&&s.mfaRequired===!0}function fo(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(!1),[i,d]=c.useState(null),l=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:h,getRemainingAttempts:m}=J.useRateLimiter({maxAttempts:3,windowMs:3e5}),u=c.useCallback(async g=>{if(!We.validateEmail(g)){const N={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw d(N),N}try{h()}catch(N){const A={code:"RATE_LIMITED",message:N instanceof Error?N.message:"Too many attempts"};throw d(A),A}o(!0),d(null),a(!1);try{await l.post("/instant-link",{email:g,referral:t?.getReferralCode?.()??void 0}),a(!0)}catch(N){const A=M.handleApiError(N,"Unable to send the sign-in link. Please try again.");throw d(A),A}finally{o(!1)}},[l,h]),f=c.useCallback(async g=>{if(!g||g.trim().length===0){const N={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw d(N),N}o(!0),d(null),a(!1);try{const N=await l.post("/instant-link/verify",{token:g});return yc(N)||(s.callbacks?.onLoginSuccess?.(N.user,"email"),t?.handleLoginSuccess(N.user,N.tokens)),N}catch(N){const A=M.handleApiError(N,"Unable to verify the sign-in link. Please try again.");throw d(A),A}finally{o(!1)}},[l,s.callbacks,t]),w=c.useCallback(()=>d(null),[]),b=c.useCallback(()=>{d(null),a(!1),o(!1)},[]);return{sendInstantLink:u,verifyInstantLink:f,isLoading:r,isSuccess:n,error:i,clearError:w,reset:b,remainingAttempts:m()}}const vc={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:s=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:s}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:s=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:s}),". Click the link to sign in."]})}};function go({mode:s="reset",onSuccess:t,onCancel:r,className:o=""}){const[n,a]=c.useState(""),i=Ws(),d=fo(),l=c.useId(),h=s==="instantLink"?{submit:d.sendInstantLink,isLoading:d.isLoading,isSuccess:d.isSuccess,error:d.error,clearError:d.clearError}:{submit:i.forgotPassword,isLoading:i.isLoading,isSuccess:i.isSuccess,error:i.error,clearError:i.clearError},m=vc[s],u=async f=>{f.preventDefault();try{await h.submit(n),t?.()}catch{}};return h.isSuccess?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.jsx("p",{className:"cedros-success-message",children:m.successMessage(n)}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:r,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:u,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:m.subtitle})]}),e.jsx(te.ErrorMessage,{error:h.error,onDismiss:h.clearError}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:l,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:l,type:"email",className:"cedros-input",value:n,onChange:f=>a(f.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:h.isLoading})]}),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:h.isLoading||!n,children:h.isLoading?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),"Sending..."]}):m.button}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:h.isLoading,children:"Back to login"})]})]})}const Ac={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 r=document.getElementById("apple-signin-script");if(r){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]):r.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]});return}const o=document.createElement("script");o.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",o.async=!0,o.defer=!0,o.id="apple-signin-script",o.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]},o.onerror=()=>{this.loading=!1,o.remove();const n=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(a=>a.reject(n)),this.callbacks=[]},document.head.appendChild(o)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function wo(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(!1),[i,d]=c.useState(null),[l,h]=c.useState(null),m=c.useRef(s),u=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);c.useEffect(()=>{m.current=s},[s]),c.useEffect(()=>{if(!s.appleClientId)return;let g=!0;const N=()=>{if(g)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),g&&a(!0)}catch{g&&d({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return Ac.load().then(()=>{g&&N()}).catch(()=>{g&&d({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{g=!1}},[s.appleClientId]);const f=c.useCallback(async g=>{if(!s.appleClientId){const A={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw d(A),A}if(!n){const A={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw d(A),A}o(!0),d(null);let N;try{const A=crypto.getRandomValues(new Uint8Array(32)),v=Array.from(A,x=>x.toString(16).padStart(2,"0")).join(""),k=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(v)),S=Array.from(new Uint8Array(k),x=>x.toString(16).padStart(2,"0")).join("");window.AppleID.auth.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0,nonce:S});const E=await window.AppleID.auth.signIn();if(N=E.authorization?.id_token,!N)throw new Error("No ID token received from Apple");const p=E.user?.name?`${E.user.name.firstName||""} ${E.user.name.lastName||""}`.trim():void 0,y=await u.post("/apple",{idToken:N,name:p||void 0,nonce:v,referral:t?.getReferralCode?.()??void 0,access_code:g||void 0});return m.current.callbacks?.onLoginSuccess?.(y.user,"apple"),t?.handleLoginSuccess(y.user,y.tokens),o(!1),y}catch(A){if(A.error==="popup_closed_by_user"){const S={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw d(S),o(!1),S}const k=M.handleApiError(A,"Unable to sign in with Apple. Please try again.");throw k.code==="ACCOUNT_LINK_REQUIRED"&&N&&h(N),d(k),o(!1),k}},[s.appleClientId,n,u,t]),w=c.useCallback(()=>d(null),[]),b=c.useCallback(()=>h(null),[]);return{signIn:f,isLoading:r,isInitialized:n,error:i,clearError:w,pendingLinkIdToken:l,clearPendingLink:b}}function bo(){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 xo({onSuccess:s,onError:t,className:r="",variant:o="default",size:n="md",disabled:a=!1,hideOnNonApple:i=!0,accessCode:d}){const{signIn:l,isLoading:h,isInitialized:m}=wo(),[u]=c.useState(()=>bo());if(i&&!u)return null;const f=async()=>{try{await l(d),s?.()}catch(g){const N=g instanceof Error?g:new Error(String(g));t?.(N)}},w={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},b={default:"cedros-button-social",outline:"cedros-button-social-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${b[o]} ${w[n]} ${r}`,onClick:f,disabled:a||!m||h,"aria-label":"Sign in with Apple",children:[h?e.jsx(Q.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 le(s,t){if(!s)throw new Error(t)}function jc(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function Us(s){le(typeof s=="string"&&s.length>0,"Expected base64url string");const t=jc(s),r=t+"=".repeat((4-t.length%4)%4),o=atob(r),n=new Uint8Array(o.length);for(let a=0;a<o.length;a++)n[a]=o.charCodeAt(a);return n.buffer}function Ke(s){const t=new Uint8Array(s);let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function yo(s){le(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return le(typeof t.type=="string","Invalid credential descriptor type"),le(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:Us(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function ot(s){le(s&&typeof s=="object","Missing creation options");const t=s.publicKey;le(t&&typeof t=="object","Missing creation options.publicKey"),le(typeof t.challenge=="string","Missing creation challenge"),le(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),le(typeof t.user=="object"&&t.user!==null,"Missing user");const r=t.rp,o=t.user;le(typeof r.name=="string","Missing rp.name"),le(typeof o.id=="string","Missing user.id"),le(typeof o.name=="string","Missing user.name"),le(typeof o.displayName=="string","Missing user.displayName");const n=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(yo):void 0,a=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(d=>({type:d.type,alg:d.alg})):[],i={challenge:Us(t.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:Us(o.id),name:o.name,displayName:o.displayName},pubKeyCredParams:a,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:n,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return i.hints=["client-device"],i}function Wr(s){le(s&&typeof s=="object","Missing request options");const t=s.publicKey;le(t&&typeof t=="object","Missing request options.publicKey"),le(typeof t.challenge=="string","Missing request challenge");const r=Array.isArray(t.allowCredentials)?t.allowCredentials.map(yo):void 0,o={challenge:Us(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:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return o.hints=["client-device"],o}function as(s){const t=Ke(s.rawId),r=s.response,n={...{clientDataJSON:Ke(r.clientDataJSON)}};if("attestationObject"in r){const a=r;if(n.attestationObject=Ke(a.attestationObject),typeof a.getTransports=="function")try{n.transports=a.getTransports()}catch{}}if("authenticatorData"in r){const a=r;n.authenticatorData=Ke(a.authenticatorData),n.signature=Ke(a.signature),a.userHandle&&(n.userHandle=Ke(a.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:n}}function Nc(){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 kc(s){return typeof s=="object"&&s!==null&&"code"in s&&"message"in s&&typeof s.code=="string"&&typeof s.message=="string"}function is(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 nr(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),d=c.useCallback(()=>a(null),[]),l=Nc(),h=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/auth/options",{email:N?.email}),v=Wr(A.options),k=await navigator.credentials.get({publicKey:v});if(!k)throw new Error("Passkey authentication returned no credential");const S=await i.post("/webauthn/auth/verify",{challengeId:A.challengeId,credential:as(k)});return s.callbacks?.onLoginSuccess?.(S.user,"webauthn"),t?.handleLoginSuccess(S.user,S.tokens),S}catch(A){const k=is(A)??M.handleApiError(A,"Unable to sign in with passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,s.callbacks,t,l]),m=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/register/options",{}),v=ot(A.options),k=await navigator.credentials.create({publicKey:v});if(!k)throw new Error("Passkey registration returned no credential");const S=await i.post("/webauthn/register/verify",{challengeId:A.challengeId,credential:as(k),label:N?.label});if(!S.success)throw new Error("Passkey registration failed");return{credentialId:S.credentialId,label:S.label}}catch(A){const k=is(A)??M.handleApiError(A,"Unable to register passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,l]),u=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/signup/options",{}),v=ot(A.options),k=await navigator.credentials.create({publicKey:v});if(!k)throw new Error("Passkey signup returned no credential");const S=await i.post("/webauthn/signup/verify",{challengeId:A.challengeId,credential:as(k),email:N?.email,name:N?.name,label:N?.label,referral:t?.getReferralCode?.()??void 0,access_code:N?.accessCode||void 0});return s.callbacks?.onLoginSuccess?.(S.user,"webauthn"),t?.handleLoginSuccess(S.user,S.tokens),S}catch(A){const k=is(A)??M.handleApiError(A,"Unable to sign up with passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,s.callbacks,t,l]),f=c.useCallback(async N=>{if(!l){const k={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(k),k}o(!0),a(null);const A=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",v=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return A?w(v,N):b(v,N)},[i,s.callbacks,t,l]),w=c.useCallback(async(N,A)=>{try{const v=await i.post("/webauthn/auth/options",{}),k=Wr(v.options),S=await navigator.credentials.get({publicKey:k});if(!S)throw new Error("Passkey authentication returned no credential");const E=await i.post("/webauthn/auth/verify",{challengeId:v.challengeId,credential:as(S)});return s.callbacks?.onLoginSuccess?.(E.user,"webauthn"),t?.handleLoginSuccess(E.user,E.tokens),N(),E}catch(v){if(v instanceof Error&&(v.name==="NotAllowedError"||v.name==="InvalidStateError"))return g(N,A);if(typeof v=="object"&&v!==null&&"isApiError"in v&&v.data?.code==="INVALID_CREDENTIALS"){const y={code:"INVALID_CREDENTIALS",message:"This passkey is not recognized. Please remove old passkeys for this site and try again, or sign in another way."};throw a(y),y}const p=is(v)??M.handleApiError(v,"Unable to sign in with passkey. Please try again.");throw a(p),p}finally{o(!1)}},[i,s.callbacks,t]),b=c.useCallback(async(N,A)=>{try{return await g(N,A)}catch(v){if(v instanceof Error&&(v.name==="InvalidStateError"||v.name==="NotAllowedError"))return w(N,A);if(!kc(v)){const E=is(v)??M.handleApiError(v,"Unable to create passkey. Please try again.");throw a(E),E}throw v}finally{o(!1)}},[i,s.callbacks,t]),g=c.useCallback(async(N,A)=>{const v=await i.post("/webauthn/signup/options",{}),k=ot(v.options),S=await navigator.credentials.create({publicKey:k});if(!S)throw new Error("Passkey signup returned no credential");const E=await i.post("/webauthn/signup/verify",{challengeId:v.challengeId,credential:as(S),referral:t?.getReferralCode?.()??void 0,access_code:A||void 0});return s.callbacks?.onLoginSuccess?.(E.user,"webauthn"),t?.handleLoginSuccess(E.user,E.tokens),N(),E},[i,s.callbacks,t]);return{isSupported:l,isLoading:r,error:n,clearError:d,continueWithPasskey:f,authenticatePasskey:h,registerPasskey:m,signupWithPasskey:u}}function vo({onSuccess:s,onError:t,className:r="",children:o,disabled:n,accessCode:a}){const{continueWithPasskey:i,isLoading:d,isSupported:l}=nr(),h=n||!l||d;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${r}`,onClick:async()=>{try{await i(a),s?.()}catch(u){t?.(u instanceof Error?u:new Error(String(u)))}},disabled:h,"aria-disabled":h,children:[d?e.jsx(Q.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(Sc,{})}),e.jsx("span",{children:o??"Continue with Passkey"})]})}function Sc(){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 cs=["login","register"];function qs({onSuccess:s,className:t="",defaultTab:r="login"}){const{config:o,socialButtonOrder:n}=M.useCedrosLogin(),{features:a}=es.useServerFeatures(),[i,d]=c.useState(r),[l,h]=c.useState("form"),[m,u]=c.useState(()=>Ze.detectSolanaWallets()),[f]=c.useState(()=>bo()),[w,b]=c.useState(""),[g,N]=c.useState(null),A=a?.signupAccessCodeRequired??!1,v=c.useCallback(P=>{N(P.message)},[]);c.useEffect(()=>{const P=()=>u(Ze.detectSolanaWallets());return P(),window.addEventListener("load",P),window.addEventListener("focus",P),()=>{window.removeEventListener("load",P),window.removeEventListener("focus",P)}},[]);const k=o.forms?.forgotPassword?.mode??(o.features?.instantLink?"instantLink":"reset"),S=c.useCallback(P=>{const _=cs.indexOf(i);let R=_;switch(P.key){case"ArrowLeft":case"ArrowUp":R=_===0?cs.length-1:_-1;break;case"ArrowRight":case"ArrowDown":R=_===cs.length-1?0:_+1;break;case"Home":R=0;break;case"End":R=cs.length-1;break;default:return}P.preventDefault();const T=cs[R];d(T),document.getElementById(`cedros-tab-${T}`)?.focus()},[i]),E=o.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},p=E.email!==!1,y=E.google!==!1&&o.googleClientId,x=E.apple!==!1&&o.appleClientId&&f,j=E.solana!==!1&&m,L=E.webauthn!==!1,C=p&&(y||x||j||L);return l==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx(go,{mode:k,onCancel:()=>h("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[A&&e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:"login-form-access-code",className:"cedros-label",children:"Access Code"}),e.jsx("input",{id:"login-form-access-code",type:"text",className:"cedros-input",value:w,onChange:P=>b(P.target.value),placeholder:"Enter access code","aria-required":"true",autoComplete:"off"})]}),g&&e.jsx(te.ErrorMessage,{error:g,onDismiss:()=>N(null)}),(L||y||x||j)&&(()=>{const P={webauthn:L?e.jsx(vo,{onSuccess:s,onError:v,accessCode:w||void 0}):null,google:y?e.jsx(Ht.GoogleLoginButton,{onSuccess:s,onError:v,accessCode:w||void 0}):null,apple:x?e.jsx(xo,{onSuccess:s,onError:v,accessCode:w||void 0}):null,solana:j?e.jsx(Ze.SolanaLoginButton,{onSuccess:s,onError:v,accessCode:w||void 0}):null},_=n??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:_.map(R=>{const T=P[R];return T?e.jsx(c.Fragment,{children:T},R):null})})})(),C&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),p&&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 ${i==="login"?"cedros-tab-active":""}`,onClick:()=>d("login"),onKeyDown:S,"aria-selected":i==="login","aria-controls":"cedros-tabpanel-login",tabIndex:i==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${i==="register"?"cedros-tab-active":""}`,onClick:()=>d("register"),onKeyDown:S,"aria-selected":i==="register","aria-controls":"cedros-tabpanel-register",tabIndex:i==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${i}`,"aria-labelledby":`cedros-tab-${i}`,children:i==="login"?e.jsx(J.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>d("register"),onForgotPassword:()=>h("forgotPassword")}):e.jsx(J.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>d("login"),accessCode:A?w:void 0})})]})]})}class Ao extends c.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){this.setState({errorInfo:r}),console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",r.componentStack),this.props.onError?.(t,r)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:r,errorInfo:o}=this.state,{children:n,fallback:a,showDetails:i=!1}=this.props;return t?a||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."}),i&&r&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[r.toString(),o?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):n}}function Cc({className:s="",title:t="Sign in to your account"}){const{isModalOpen:r,closeModal:o}=M.useCedrosLogin(),n=c.useRef(null),a=c.useRef(null),i=c.useRef(o);if(c.useEffect(()=>{i.current=o},[o]),c.useEffect(()=>{if(!r)return;a.current=document.activeElement,n.current?.focus();const l=m=>{if(m.key==="Escape"&&i.current(),m.key==="Tab"&&n.current){const u=n.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),f=u[0],w=u[u.length-1];m.shiftKey&&document.activeElement===f?(m.preventDefault(),w?.focus()):!m.shiftKey&&document.activeElement===w&&(m.preventDefault(),f?.focus())}};document.addEventListener("keydown",l);const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",l),document.body.style.overflow=h,a.current instanceof HTMLElement&&a.current.focus()}},[r]),!r)return null;const d=l=>{l.target===l.currentTarget&&o()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,onClick:d,role:"presentation",children:e.jsxs("div",{ref:n,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:o,"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(Ao,{children:e.jsx(qs,{onSuccess:o})})})]})})}function Ec({token:s,onSuccess:t,onLoginClick:r,className:o=""}){const[n,a]=c.useState(""),[i,d]=c.useState(""),[l,h]=c.useState(null),{resetPassword:m,isLoading:u,isSuccess:f,error:w,clearError:b}=Ws(),g=n===i,N=l?.isValid&&g&&n.length>0,A=async v=>{if(v.preventDefault(),!!N)try{await m(s,n),t?.()}catch{}};return f?e.jsxs("div",{className:`cedros-reset-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:"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."}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:r,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${o}`,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(te.ErrorMessage,{error:w,onDismiss:b}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(J.PasswordInput,{label:"New password",value:n,onChange:v=>{a(v.target.value),h(We.validatePassword(v.target.value))},showStrengthMeter:!0,onValidationChange:h,disabled:u,autoComplete:"new-password",error:l&&!l.isValid?Object.values(l.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(J.PasswordInput,{label:"Confirm password",value:i,onChange:v=>d(v.target.value),disabled:u,autoComplete:"new-password",error:i&&!g?"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:u||!N,children:u?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:u,children:"Back to login"})]})]})}function $t({org:s,size:t="lg",className:r=""}){const o=es.sanitizeImageUrl(s.logoUrl),n=t==="lg"?"cedros-org-avatar-lg":"",a=["cedros-org-avatar",n,r].filter(Boolean).join(" "),i=["cedros-org-avatar-placeholder",n,r].filter(Boolean).join(" ");return o?e.jsx("img",{src:o,alt:s.name,className:a,referrerPolicy:"no-referrer"}):e.jsx("div",{className:i,children:s.name[0]?.toUpperCase()||"?"})}function _c({orgs:s,activeOrg:t,isLoading:r=!1,onSelect:o,onCreateClick:n,className:a="",placeholder:i="Select organization"}){const[d,l]=c.useState(!1),h=c.useRef(null);c.useEffect(()=>{const w=b=>{h.current&&!h.current.contains(b.target)&&l(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),c.useEffect(()=>{const w=b=>{b.key==="Escape"&&l(!1)};if(d)return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[d]);const m=c.useCallback(w=>{o(w),l(!1)},[o]),u=c.useCallback(()=>{l(!1),n?.()},[n]),f=c.useCallback(()=>{l(w=>!w)},[]);return r?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${a}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:h,className:`cedros-org-selector ${a}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:f,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs(e.Fragment,{children:[e.jsx($t,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(qr,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:i}),e.jsx(Lc,{isOpen:d})]}),d&&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:()=>m(w.id),role:"option","aria-selected":w.id===t?.id,children:[e.jsx($t,{org:w,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:w.name}),e.jsx(qr,{role:w.membership.role}),w.id===t?.id&&e.jsx(Pc,{})]})},w.id))}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:u,children:[e.jsx(Rc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function qr({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function Lc({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 Pc(){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 Rc(){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 Tc(){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 Mc(){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 Ic(){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 Bc({orgs:s,activeOrg:t,isLoading:r,onSelect:o,onCreateClick:n}){return r?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(Q.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(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${a.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>o(a.id),children:[e.jsx($t,{org:a}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:a.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",a.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${a.membership.role}`,children:a.membership.role}),a.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),a.id===t?.id&&e.jsx(Mc,{})]})},a.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(Ic,{}),e.jsx("span",{children:"Create new organization"})]})]})}function Uc({isLoading:s,onSubmit:t,onCancel:r}){const[o,n]=c.useState(""),[a,i]=c.useState(""),[d,l]=c.useState(null),h=c.useCallback(u=>{n(u);const f=u.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);i(f)},[]),m=c.useCallback(async u=>{if(u.preventDefault(),l(null),!o.trim()){l("Organization name is required");return}if(!a.trim()){l("Organization slug is required");return}try{await t({name:o.trim(),slug:a.trim()})}catch(f){l(f.message||"Failed to create organization")}},[o,a,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:m,children:[d&&e.jsx(te.ErrorMessage,{error:d}),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:o,onChange:u=>h(u.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:a,onChange:u=>i(u.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:r,disabled:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!o.trim()||!a.trim(),children:s?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function Dc({isOpen:s,onClose:t,orgs:r,activeOrg:o,isLoading:n=!1,error:a,onSelect:i,onCreate:d,className:l=""}){return s?e.jsx(Fc,{onClose:t,orgs:r,activeOrg:o,isLoading:n,error:a,onSelect:i,onCreate:d,className:l}):null}function Fc({onClose:s,orgs:t,activeOrg:r,isLoading:o=!1,error:n,onSelect:a,onCreate:i,className:d}){const[l,h]=c.useState("list"),m=c.useRef(null),u=c.useRef(null);c.useEffect(()=>(u.current=document.activeElement,m.current?.querySelector(".cedros-modal-close")?.focus(),()=>{u.current?.focus()}),[]),c.useEffect(()=>{const g=N=>{if(N.key==="Escape"){s();return}if(N.key==="Tab"&&m.current){const A=m.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),v=A[0],k=A[A.length-1];N.shiftKey?document.activeElement===v&&(N.preventDefault(),k?.focus()):document.activeElement===k&&(N.preventDefault(),v?.focus())}};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s]);const f=c.useCallback(g=>{g.target===g.currentTarget&&s()},[s]),w=c.useCallback(g=>{a(g),s()},[a,s]),b=c.useCallback(async g=>{await i?.(g),s()},[i,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:f,children:e.jsxs("div",{ref:m,className:`cedros-modal cedros-org-switcher ${d}`,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:l==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(Tc,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(te.ErrorMessage,{error:n}),l==="list"?e.jsx(Bc,{orgs:t,activeOrg:r,isLoading:o,onSelect:w,onCreateClick:i?()=>h("create"):void 0}):e.jsx(Uc,{isLoading:o,onSubmit:b,onCancel:()=>h("list")})]})]})})}function jo({sessions:s,isLoading:t=!1,error:r,onRevokeAll:o,className:n=""}){const[a,i]=c.useState(!1),[d,l]=c.useState(!1),h=c.useRef(null),m=c.useMemo(()=>s.filter(f=>!f.isCurrent).length,[s]),u=c.useCallback(async()=>{if(!o)return;const f=s.filter(b=>!b.isCurrent).length;if(!(f===0||!window.confirm(`Are you sure you want to sign out of ${f} other device(s)? This will log you out everywhere except this browser.`))){i(!0),l(!1);try{await o(),l(!0),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{l(!1),h.current=null},3e3)}finally{i(!1)}}},[o,s]);return c.useEffect(()=>()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${n}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):r?e.jsx("div",{className:`cedros-session-list ${n}`,children:e.jsx(te.ErrorMessage,{error:r})}):s.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${n}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${n}`,children:[d&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Vc,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(f=>e.jsx(Oc,{session:f},f.id))}),o&&m>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:u,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${m} other device${m>1?"s":""}`})})]})}function Oc({session:s}){const t=Wc(s.userAgent),r=zc(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($c,{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 ",qc(s.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Wc(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 r="Unknown device";return s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("iPhone")||s.includes("iPad")?r="iOS":s.includes("Android")&&(r="Android"),{browser:t,os:r}}function qc(s){const t=new Date(s),o=new Date().getTime()-t.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n} minute${n>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:i<7?`${i} day${i>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function zc(s){const t=new Date(s),r=new Date,o=3600*1e3;return t.getTime()-r.getTime()<o}function $c({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 Vc(){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 No({words:s,onConfirm:t,className:r=""}){const[o,n]=c.useState(!1),[a,i]=c.useState(!1),d=c.useRef(null),l=wc(s),h=c.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),n(!0),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>n(!1),2e3)}catch{}},[s]);c.useEffect(()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]);const m=c.useCallback(()=>{a&&t()},[a,t]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${r}`,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:l.map((u,f)=>e.jsx("div",{className:"cedros-word-group",children:u.map((w,b)=>{const g=f*4+b+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[g,"."]}),e.jsx("span",{className:"cedros-word-text",children:w})]},g)})},f))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:h,children:o?"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:a,onChange:u=>i(u.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:m,disabled:!a,children:"Continue"})]})]})}function ko({onSubmit:s,onCancel:t,isSubmitting:r=!1,error:o,className:n=""}){const[a,i]=c.useState(Array(me).fill("")),[d,l]=c.useState(null),[h,m]=c.useState([]),[u,f]=c.useState(null),w=c.useId(),b=c.useRef(null),g=c.useCallback((p,y)=>{const x=[...a];if(x[p]=y.toLowerCase().trim(),i(x),y.length>0){const j=gc(y,5);m(j)}else m([]);f(null)},[a]),N=c.useCallback(p=>{l(p),m([])},[]),A=c.useCallback(p=>{const y=a[p];y&&!bs(y)&&f(`Word ${p+1} is not in the wordlist`),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{d===p&&m([])},200)},[a,d]);c.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]);const v=c.useCallback(p=>{if(d!==null){const y=[...a];y[d]=p,i(y),m([]),document.querySelector(`[data-word-index="${d+1}"]`)?.focus()}},[d,a]),k=c.useCallback(p=>{const y=p.clipboardData.getData("text"),x=bc(y);x.length===me&&(p.preventDefault(),i(x),f(null))},[]),S=c.useCallback(p=>{if(p.preventDefault(),a.filter(j=>!j).length>0){f(`Please enter all ${me} words`);return}const x=a.map((j,L)=>({word:j,index:L+1})).filter(({word:j})=>!bs(j));if(x.length>0){f(`Invalid words: ${x.map(j=>`#${j.index}`).join(", ")}`);return}if(!po(a)){f("Invalid recovery phrase - please check your words");return}s(a)},[a,s]),E=o||u;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${n}`,onSubmit:S,onPaste:k,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:me},(p,y)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[y+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${a[y]&&!bs(a[y])?"cedros-word-invalid":a[y]&&bs(a[y])?"cedros-word-valid":""}`,value:a[y],onChange:x=>g(y,x.target.value),onFocus:()=>N(y),onBlur:()=>A(y),"data-word-index":y,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:r,"aria-label":`Word ${y+1}`})]},y))}),d!==null&&h.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${w}-suggestions`,children:h.map(p=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>v(p),role:"option",children:p},p))}),E&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:E}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:r,children:r?"Recovering...":"Recover Wallet"})]})]})}function Hc({capabilities:s,className:t=""}){if(s.allSupported)return null;const r=D.getMissingCapabilitiesMessage(s),o=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:r}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",o.browser," ",o.version,o.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 Gc=["share_c_only","full_seed","none"];function Qc(s){return s&&Gc.includes(s)?s:"share_c_only"}const Kc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function So(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(null),[o,n]=c.useState(!!s),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),l=c.useCallback(async()=>{if(d){n(!0),i(null);try{const h=await d.get("/discovery");h.wallet?r({enabled:h.wallet.enabled,recoveryMode:Qc(h.wallet.recoveryMode),unlockTtlSeconds:h.wallet.unlockTtlSeconds}):r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(h){const m=h instanceof Error?h.message:"Failed to fetch wallet config";i(m),r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{n(!1)}}},[d]);return c.useEffect(()=>{d&&l()},[d,l]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:o,error:a,refetch:l}:Kc}function Co(){const{user:s}=M.useCedrosLogin(),{enroll:t}=D.useWalletMaterial(),{recoveryMode:r}=So(),[o,n]=c.useState({step:"idle"}),[a,i]=c.useState(!1),d=c.useRef([]),l=c.useCallback(()=>{D.wipeAll(...d.current),d.current=[]},[]);c.useEffect(()=>()=>{l()},[l]);const h=c.useCallback(async(b,g,N,A)=>{n({step:"generating_seed"});const v=D.generateSeed();d.current.push(v),n({step:"splitting_shares"});const{shareA:k,shareB:S,shareC:E}=oo(v);d.current.push(k,S,E),n({step:"encrypting_shares"});const p=await D.aesGcmEncryptToBase64(k,D.toEncryptionKey(g)),y=ro(v),x=no(y);n({step:"uploading"});const j={solanaPubkey:x,shareAAuthMethod:b,shareACiphertext:p.ciphertext,shareANonce:p.nonce,shareB:D.uint8ArrayToBase64(S)};if(b==="password"){if(!N)throw new Error("KDF salt required for password method");j.shareAKdfSalt=D.uint8ArrayToBase64(N),j.shareAKdfParams=D.DEFAULT_KDF_PARAMS}if(b==="passkey"&&A&&(j.prfSalt=A),await t(j),r==="none")l(),n({step:"complete",solanaPubkey:x});else{const L=r==="full_seed"?pc(v):hc(D.toShamirShare(E));n({step:"showing_recovery",recoveryPhrase:L,solanaPubkey:x})}},[t,r,l]),m=c.useCallback(async b=>{if(!s){n({step:"error",error:"User not authenticated"});return}i(!0),l();try{const g=D.generateArgon2Salt(),N=await In(b,g,D.DEFAULT_KDF_PARAMS);d.current.push(N),await h("password",N,g)}catch(g){n({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{i(!1)}},[s,l,h]),u=c.useCallback(async()=>{if(!s){n({step:"error",error:"User not authenticated"});return}i(!0),l();try{const b=D.generatePrfSalt(),g=D.uint8ArrayToBase64(b);n({step:"encrypting_shares"});const A=(await D.authenticateWithDiscoverablePrf(g)).prfOutput;d.current.push(A);const v=await D.deriveKeyFromPrf(A,b);d.current.push(v),await h("passkey",v,void 0,g)}catch(b){n({step:"error",error:b instanceof Error?b.message:"Enrollment failed"})}finally{i(!1)}},[s,l,h]),f=c.useCallback(()=>{const b=o.solanaPubkey;l(),n({step:"complete",solanaPubkey:b})},[o.solanaPubkey,l]),w=c.useCallback(()=>{l(),n({step:"idle"}),i(!1)},[l]);return{state:o,startEnrollmentWithPassword:m,startEnrollmentWithPasskey:u,confirmRecoveryPhrase:f,cancel:w,isEnrolling:a}}function Eo(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken]);return{setPassword:c.useCallback(async l=>{o(!0),a(null);try{await i.post("/set-password",{password:l})}catch(h){const m=M.handleApiError(h,"Failed to set password");throw a(m),m}finally{o(!1)}},[i]),isLoading:r,error:n}}function Yc(s){return s.includes("email")?"password":s.includes("webauthn")?"passkey":"set-password"}function _o({onComplete:s,onCancel:t,className:r=""}){const{user:o}=M.useCedrosLogin(),{state:n,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:i,confirmRecoveryPhrase:d,cancel:l,isEnrolling:h}=Co(),{setPassword:m,isLoading:u}=Eo(),f=o?Yc(o.authMethods):"password",[w,b]=c.useState(""),[g,N]=c.useState(""),[A,v]=c.useState(null);c.useEffect(()=>{b(""),N(""),v(null)},[o?.id]);const k=c.useCallback(async j=>{j.preventDefault(),v(null),await a(w)},[w,a]),S=c.useCallback(async j=>{if(j.preventDefault(),w!==g){v("Passwords do not match");return}const L=We.validatePassword(w);if(!L.isValid){const C=Object.values(L.errors)[0];v(C??"Password does not meet requirements");return}v(null);try{await m(w),await a(w)}catch{}},[w,g,m,a]),E=c.useCallback(async()=>{await i()},[i]),p=c.useCallback(()=>{d(),n.solanaPubkey&&s?.(n.solanaPubkey)},[d,n.solanaPubkey,s]),y=c.useCallback(()=>{l(),t?.()},[l,t]),x=h||u;return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"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 ${r}`,"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==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"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 ${r}`,children:e.jsx(No,{words:n.recoveryPhrase,onConfirm:p})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,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 ${r}`,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:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>l(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${r}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),f==="password"&&e.jsx("p",{children:"Enter your account password to secure your wallet."}),f==="passkey"&&e.jsx("p",{children:"Authenticate with your passkey to secure your wallet."}),f==="set-password"&&e.jsx("p",{children:"Set a password for your account to secure your wallet."})]}),f==="password"&&e.jsxs("form",{onSubmit:k,className:"cedros-enrollment-form",children:[e.jsx(J.PasswordInput,{label:"Account Password",value:w,onChange:j=>b(j.target.value),disabled:x,required:!0,placeholder:"Enter your account password"}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!w,children:x?"Creating...":"Continue"})]})]}),f==="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.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:E,disabled:x,children:x?"Creating...":"Use Passkey"})]})]}),f==="set-password"&&e.jsxs("form",{onSubmit:S,className:"cedros-enrollment-form",children:[e.jsx(J.PasswordInput,{label:"New Password",value:w,onChange:j=>b(j.target.value),showStrengthMeter:!0,disabled:x,required:!0,minLength:8,placeholder:"Choose a strong password"}),e.jsx(J.PasswordInput,{label:"Confirm Password",value:g,onChange:j=>N(j.target.value),error:A??void 0,disabled:x,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will also 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:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!w||!g,children:x?"Creating...":"Continue"})]})]})]})}function Lo(){const{user:s}=M.useCedrosLogin(),{signTransaction:t}=D.useWalletMaterial(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useCallback(async(l,h)=>{if(!s){const m="User not authenticated";throw a(m),new Error(m)}o(!0),a(null);try{const m={transaction:D.uint8ArrayToBase64(l),...h?{credential:D.toCredentialRequest(h)}:{}},u=await t(m);return D.base64ToUint8Array(u.signature)}catch(m){const u=m instanceof Error?m.message:"Signing failed";throw a(u),m}finally{o(!1)}},[s,t]),d=c.useCallback(()=>a(null),[]);return{signTransaction:i,isSigning:r,error:n,clearError:d}}function Po(){const{getMaterial:s}=D.useWalletMaterial(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useCallback(async()=>{r(!0),n(null);try{const d=await s();if(!d)throw new Error("No wallet enrolled");if(d.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!d.prfSalt)throw new Error("No PRF salt configured for wallet");const l=await D.authenticateWithDiscoverablePrf(d.prfSalt);try{return{type:"prfOutput",prfOutput:D.uint8ArrayToBase64(l.prfOutput)}}finally{l.prfOutput.fill(0)}}catch(d){const l=d instanceof Error?d.message:"Passkey authentication failed";return n(l),null}finally{r(!1)}},[s]),i=c.useCallback(()=>n(null),[]);return{getPasskeyCredential:a,isAuthenticating:t,error:o,clearError:i}}function Ro({mode:s,isLoading:t=!1,error:r,onPrompt:o,onRetry:n,onCancel:a,title:i,description:d,className:l=""}){const h=c.useCallback(()=>{t||o?.()},[t,o]),m=c.useCallback(()=>{n?.()},[n]),u=s==="register"?"Set Up Passkey":"Verify with Passkey",f=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 ${l}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(Xc,{}):r?e.jsx(Jc,{}):e.jsx(Zc,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:i??u}),e.jsx("p",{className:"cedros-passkey-description",children:d??f}),r&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:r})}),e.jsx("div",{className:"cedros-passkey-actions",children:r?e.jsxs(e.Fragment,{children:[n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,children:"Try Again"}),a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:h,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"}),a&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,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 Zc(){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 Xc(){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 Jc(){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 To({onUnlock:s,onCancel:t,showCancel:r=!0,authMethod:o,className:n=""}){M.useCedrosLogin();const{unlock:a,getMaterial:i,isLoading:d}=D.useWalletMaterial(),{getPasskeyCredential:l,isAuthenticating:h}=Po(),[m,u]=c.useState("idle"),[f,w]=c.useState(o??null),[b,g]=c.useState(""),[N,A]=c.useState(null);c.useEffect(()=>{o!==void 0&&w(o)},[o]);const v=f==="password",k=f==="passkey",S=c.useCallback(async()=>{if(u("credential"),A(null),!f)try{const C=await i();C?w(C.shareAAuthMethod):(A("No wallet enrolled"),u("error"))}catch(C){A(C instanceof Error?C.message:"Failed to get wallet info"),u("error")}},[f,i]),E=c.useCallback(async C=>{C.preventDefault(),A(null),u("unlocking");try{let P;if(v)P={type:"password",password:b};else throw new Error("Invalid auth method");await a(P),u("unlocked"),s?.()}catch(P){A(P instanceof Error?P.message:"Failed to unlock wallet"),u("error")}},[v,b,a,s]),p=c.useCallback(async()=>{A(null),u("unlocking");try{const C=await l();if(!C){u("credential");return}await a(C),u("unlocked"),s?.()}catch(C){A(C instanceof Error?C.message:"Failed to unlock wallet"),u("error")}},[l,a,s]),y=c.useCallback(()=>{g(""),u("idle"),A(null),t?.()},[t]),x=c.useCallback(()=>{g(""),u("credential"),A(null)},[]),j=d||h,L=()=>{switch(m){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(el,{})}),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:S,children:"Unlock Wallet"})]});case"credential":return v?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:E,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(J.PasswordInput,{label:"Password",value:b,onChange:C=>g(C.target.value),disabled:j,autoComplete:"current-password",error:N??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:j||b.length===0,children:j?"Unlocking...":"Unlock"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:j,children:"Cancel"})]})]}):k?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(Ro,{mode:"authenticate",isLoading:j,error:N??void 0,onPrompt:p,onRetry:p,onCancel:r?y:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(Q.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(Q.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(sl,{})}),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(tl,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:N??"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:x,children:"Try Again"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${n}`,children:L()})}function el(){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 sl(){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 tl(){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 Mo(){const{recover:s,getShareBForRecovery:t}=D.useWalletMaterial(),{recoveryMode:r}=So(),[o,n]=c.useState({step:"idle"}),[a,i]=c.useState(!1),d=c.useRef([]),l=c.useCallback(()=>{D.wipeAll(...d.current),d.current=[]},[]);c.useEffect(()=>()=>{l()},[l]);const h=c.useCallback(async(u,f,w)=>{i(!0),l();try{if(n({step:"validating"}),!po(u))throw new Error("Invalid recovery phrase. Please check your words.");let b;if(r==="share_c_only"){const x=mc(u);d.current.push(x);const j=D.uint8ArrayToBase64(x),L=await t({shareC:j}),C=D.base64ToUint8Array(L.shareB);d.current.push(C),b=Ji(D.toShamirShare(C),D.toShamirShare(x)),d.current.push(b)}else b=fc(u),d.current.push(b);const g=ro(b),N=no(g),{shareA:A,shareB:v}=oo(b);d.current.push(A,v),n({step:"encrypting"});let k,S,E;if(f==="passkey"){const x=D.generatePrfSalt();E=D.uint8ArrayToBase64(x);const j=await D.authenticateWithDiscoverablePrf(E);d.current.push(j.prfOutput),k=await D.deriveKeyFromPrf(j.prfOutput,x),d.current.push(k)}else S=D.generateArgon2Salt(),k=await In(w,S,D.DEFAULT_KDF_PARAMS),d.current.push(k);const p=await D.aesGcmEncryptToBase64(A,D.toEncryptionKey(k));n({step:"uploading"});const y={solanaPubkey:N,shareAAuthMethod:f,shareACiphertext:p.ciphertext,shareANonce:p.nonce,shareB:D.uint8ArrayToBase64(v)};f==="password"&&(y.shareAKdfSalt=D.uint8ArrayToBase64(S),y.shareAKdfParams=D.DEFAULT_KDF_PARAMS),f==="passkey"&&(y.prfSalt=E),await s(y),l(),n({step:"complete"})}catch(b){l(),n({step:"error",error:b instanceof Error?b.message:"Recovery failed"})}finally{i(!1)}},[s,t,r,l]),m=c.useCallback(()=>{l(),n({step:"idle"}),i(!1)},[l]);return{state:o,startRecovery:h,cancel:m,isRecovering:a}}function Io({onComplete:s,onCancel:t,className:r="",defaultAuthMethod:o="password"}){const{state:n,startRecovery:a,cancel:i,isRecovering:d}=Mo(),[l,h]=c.useState([]),[m,u]=c.useState(!1),[f,w]=c.useState(o),[b,g]=c.useState(""),[N,A]=c.useState(""),[v,k]=c.useState(null),S=c.useCallback(j=>{h(j),u(!0)},[]),E=c.useCallback(async j=>{if(j.preventDefault(),k(null),f!=="passkey"){if(b!==N){k("Passwords do not match");return}if(f==="password"&&b.length<8){k("Password must be at least 8 characters");return}}await a(l,f,b)},[l,f,b,N,a]),p=c.useCallback(()=>{i(),h([]),u(!1),g(""),A(""),t?.()},[i,t]),y=c.useCallback(()=>{u(!1),g(""),A("")},[]),x=c.useCallback(()=>{s?.()},[s]);return n.step==="validating"||n.step==="encrypting"||n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(rl,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[n.step==="validating"&&"Validating Recovery Phrase",n.step==="encrypting"&&"Encrypting Wallet",n.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[n.step==="validating"&&"Checking your recovery phrase...",n.step==="encrypting"&&"Securing your wallet with new encryption...",n.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(nl,{})}),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"," ",f==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Done"})})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(ol,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:n.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:p,children:"Start Over"})})]})}):m?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:E,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:f==="password",onChange:()=>w("password"),disabled:d}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:f==="passkey",onChange:()=>w("passkey"),disabled:d}),e.jsx("span",{children:"Passkey"})]})]}),f==="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:b,onChange:j=>g(j.target.value),disabled:d,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:N,onChange:j=>A(j.target.value),disabled:d,"aria-invalid":v?"true":void 0,placeholder:"Confirm your password"}),v&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:v})]})]}),f==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(al,{}),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:y,disabled:d,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:d||f!=="passkey"&&(b.length===0||N.length===0),children:d?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${r}`,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(ko,{onSubmit:S,onCancel:p,isSubmitting:!1})]})})}function rl(){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 nl(){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 ol(){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 al(){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 Bo({address:s,label:t="Wallet Address",showCopy:r=!0,showExplorerLink:o=!0,allowReveal:n=!0,className:a=""}){const i=M.useCedrosLoginOptional(),[d,l]=c.useState(!1),[h,m]=c.useState(null),[u,f]=c.useState(!1),w=c.useRef(null),b=i?.config.solana?.network??"mainnet-beta",g=c.useMemo(()=>{const k=`https://explorer.solana.com/address/${s}`;return b==="mainnet-beta"?k:`${k}?cluster=${encodeURIComponent(b)}`},[s,b]),N=n&&s.length>18,A=c.useMemo(()=>!N||u?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,N,u]),v=c.useCallback(async()=>{try{m(null),await navigator.clipboard.writeText(s),l(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{l(!1),w.current=null},2e3)}catch(k){l(!1),m(k instanceof Error?k.message:"Copy failed")}},[s]);return c.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${a}`,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:[N&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>f(k=>!k),"aria-label":u?"Hide full wallet address":"Show full wallet address",children:u?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"})]})}),o&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:g,target:"_blank",rel:"noreferrer",children:"Explorer"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:v,"aria-label":"Copy wallet address",children:d?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:A}),h&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:h})]})}function Uo({status:s,publicKey:t,onLock:r,onEnroll:o,onUnlock:n,onRecover:a,showActions:i=!0,compact:d=!1,className:l=""}){const h=s!==void 0,m=D.useWallet(),u=h?s:m.status,f=h?t??null:m.solanaPubkey,w=h?null:m.error,b=h?()=>{}:m.refresh,g=h?()=>{}:m.clearError,N=il(u,w);return d?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${l}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${N.color}`,title:N.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:N.label}),f&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:f,children:cl(f)})]}):e.jsxs("div",{className:`cedros-wallet-status ${l}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${N.color}`,children:e.jsx(ll,{status:u})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:N.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:N.description})]})]}),f&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(Bo,{address:f})}),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:g,children:"Dismiss"})]}),i&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[u==="not_enrolled"&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:o,children:"Create Wallet"}),u==="enrolled_locked"&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:n,children:"Unlock Wallet"}),(u==="not_enrolled"||u==="error")&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:"Recover Wallet"}),u==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:b,children:"Retry"})]})]})}function il(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 cl(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function ll({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 dl({className:s="",showActions:t=!0}){const r=D.useWallet(),[o,n]=c.useState("status"),a=c.useMemo(()=>{switch(o){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}},[o]),i=c.useCallback(()=>n("status"),[]),d=c.useCallback(async()=>{n("status"),await r.refresh()},[r]),l=c.useCallback(async()=>{n("status"),await r.refresh()},[r]),h=c.useCallback(async()=>{n("status"),await r.refresh()},[r]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[o!=="status"&&a&&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:a.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:a.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:i,children:"Back"})]}),o==="status"&&e.jsx(Uo,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:t}),o==="enroll"&&e.jsx(_o,{onComplete:()=>{d()},onCancel:i}),o==="unlock"&&e.jsx(To,{onUnlock:()=>{l()},onCancel:i}),o==="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:()=>n("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:i,children:"Cancel"})]})]})}),o==="recover"&&e.jsx(Io,{onComplete:()=>{h()},onCancel:i})]})}function ul({showDescriptions:s=!0,className:t="",onSave:r}){const{settings:o,isLoading:n,isUpdating:a,error:i,fetchSettings:d,updateSettings:l}=Gt.useSystemSettings(),[h,m]=c.useState({}),[u,f]=c.useState(null),[w,b]=c.useState(!1);c.useEffect(()=>{d()},[d]),c.useEffect(()=>{if(w){const E=setTimeout(()=>b(!1),3e3);return()=>clearTimeout(E)}},[w]);const g=c.useCallback((E,p)=>{m(y=>({...y,[E]:p})),f(null),b(!1)},[]),N=c.useCallback(async()=>{const E=Object.entries(h).map(([p,y])=>({key:p,value:y}));if(E.length!==0)try{await l(E),m({}),f(null),b(!0),r?.()}catch(p){f(p instanceof Error?p.message:"Failed to save settings")}},[h,l,r]),A=c.useCallback(()=>{m({}),f(null),b(!1)},[]),v=Object.keys(h).length>0,k=Object.keys(h).length;if(n&&Object.keys(o).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(i)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(te.ErrorMessage,{error:i.message})});const S=Object.keys(o).sort();return S.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:[u&&e.jsx(te.ErrorMessage,{error:u}),w&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),S.map(E=>e.jsx(hl,{category:E,settings:o[E],edits:h,showDescription:s,onChange:g},E)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[v&&e.jsxs("span",{className:"cedros-settings-change-count",children:[k," unsaved change",k!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:A,disabled:!v||a,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:N,disabled:!v||a,children:a?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const zr=Object.keys(ke.SETTING_METADATA);function hl({category:s,settings:t,edits:r,showDescription:o,onChange:n}){const a=ke.CATEGORY_METADATA[s]||{label:s,description:"",icon:""},i=c.useMemo(()=>[...t].sort((d,l)=>{const h=zr.indexOf(d.key),m=zr.indexOf(l.key);return(h===-1?1/0:h)-(m===-1?1/0:m)}),[t]);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:a.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:a.label}),o&&a.description&&e.jsx("p",{className:"cedros-settings-section-description",children:a.description})]})]}),e.jsx(ke.SettingsSection,{settings:i,edits:r,onChange:n})]})}const ne={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"})}),shield: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:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),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"})]}),image: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:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),referrals: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:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),ticket: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:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),e.jsx("path",{d:"M13 5v2"}),e.jsx("path",{d:"M13 17v2"}),e.jsx("path",{d:"M13 11v2"})]})},ml=[{id:"users",label:"Users",icon:ne.users},{id:"team",label:"Team",icon:ne.members},{id:"referrals",label:"Referrals",icon:ne.referrals},{id:"deposits",label:"Deposits",icon:ne.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ne.withdrawals,requiredFeature:"credits"},{id:"compliance",label:"Compliance",icon:ne.shield,group:"Compliance"},{id:"accreditation-queue",label:"Accreditation Queue",icon:ne.shield,group:"Compliance"},{id:"sanctions",label:"Sanctions",icon:ne.shield,group:"Compliance"},{id:"signup-gating",label:"Signup Gating",icon:ne.ticket,group:"Compliance"},{id:"settings-auth",label:"Authentication",icon:ne.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ne.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ne.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ne.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-compliance",label:"Compliance & Gating",icon:ne.shield,group:"Configuration"},{id:"settings-referrals",label:"Referrals & Rewards",icon:ne.referrals,group:"Configuration"},{id:"settings-signup",label:"Signup Gating",icon:ne.ticket,group:"Configuration"},{id:"settings-server",label:"Auth Server",icon:ne.server,group:"Configuration"},{id:"settings-images",label:"Image Storage",icon:ne.image,group:"Configuration"}];function pl(s,t){return t.toUpperCase()==="SOL"?`${(s/1e9).toFixed(4)} SOL`:`${s} ${t}`}function $r(s){return s.length<=16?s:`${s.slice(0,8)}...${s.slice(-6)}`}function fl(s){return new Date(s).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const gl=["all","pending","completed","failed","cancelled"];function wl(){const{config:s,_internal:t}=M.useCedrosLogin(),r=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),[o,n]=c.useState("all"),[a,i]=c.useState(0),d=20,[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,w]=c.useState(null),[b,g]=c.useState(null),[N,A]=c.useState(null),v=c.useCallback(async()=>{u(!0),w(null);try{const p=new URLSearchParams;o!=="all"&&p.set("status",o),p.set("limit",String(d)),p.set("offset",String(a*d));const y=await r.get(`/admin/referral-payouts/list?${p.toString()}`);h(y)}catch(p){const y=M.handleApiError(p,"Failed to load payouts");w(y.message)}finally{u(!1)}},[r,o,a]);c.useEffect(()=>{v()},[v]);const k=c.useCallback(async p=>{A(p),g(null);try{const y=await r.post(`/admin/referral-payouts/${p}/process`,{});g(`Processed: ${y.txSignature}`),v()}catch(y){const x=M.handleApiError(y,"Failed to process payout");g(x.message)}finally{A(null)}},[r,v]),S=c.useCallback(async p=>{A(p),g(null);try{await r.post(`/admin/referral-payouts/${p}/cancel`,{}),g("Payout cancelled."),v()}catch(y){const x=M.handleApiError(y,"Failed to cancel payout");g(x.message)}finally{A(null)}},[r,v]),E=l?Math.ceil(l.total/d):0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__filter-bar",children:[e.jsxs("label",{className:"cedros-admin-referral-payouts__filter-label",children:["Status:",e.jsx("select",{value:o,onChange:p=>{n(p.target.value),i(0)},className:"cedros-admin-referral-payouts__filter-select",children:gl.map(p=>e.jsx("option",{value:p,children:p.charAt(0).toUpperCase()+p.slice(1)},p))})]}),l&&e.jsxs("span",{className:"cedros-admin-referral-payouts__filter-count",children:[l.total," total"]})]}),b&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--info",children:b}),m&&!l&&e.jsxs("div",{className:"cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading payouts..."})]}),f&&e.jsxs("div",{className:"cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:f}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:v,children:"Retry"})]}),l&&l.payouts.length===0&&e.jsx("div",{className:"cedros-admin-empty-message",children:"No payouts found."}),l&&l.payouts.length>0&&e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"All referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Trigger"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"TX / Error"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),l.payouts.map(p=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:fl(p.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:p.referrerEmail||p.referrerName||$r(p.referrerId)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:p.triggerType}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:pl(p.amount,p.currency)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-referral-payouts__status cedros-admin-referral-payouts__status--${p.status}`,children:p.status})}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:[p.txSignature&&$r(p.txSignature),p.errorMessage&&e.jsx("span",{className:"cedros-admin-list-td-muted",title:p.errorMessage,children:p.errorMessage.slice(0,40)})]}),e.jsxs("div",{className:"cedros-admin-list-td",role:"cell",children:[(p.status==="pending"||p.status==="failed")&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-xs",onClick:()=>k(p.id),disabled:N!==null,children:N===p.id?"...":"Process"}),p.status==="pending"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",onClick:()=>S(p.id),disabled:N!==null,style:{marginLeft:4},children:"Cancel"})]})]},p.id))]}),E>1&&e.jsxs("div",{className:"cedros-admin-referral-payouts__pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a===0,onClick:()=>i(p=>p-1),children:"Previous"}),e.jsxs("span",{className:"cedros-admin-referral-payouts__page-info",children:["Page ",a+1," of ",E]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a>=E-1,onClick:()=>i(p=>p+1),children:"Next"})]})]})}function at(s,t){return t.toUpperCase()==="SOL"?`${(s/1e9).toFixed(4)} SOL`:`${s} ${t}`}function Vr(s){return s.length<=16?s:`${s.slice(0,8)}...${s.slice(-6)}`}function Do({className:s=""}){const[t,r]=c.useState("summary");return e.jsxs("div",{className:`cedros-admin-referral-payouts ${s}`,children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__tabs",children:[e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${t==="summary"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("summary"),children:"Summary"}),e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${t==="all"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("all"),children:"All Payouts"})]}),t==="summary"?e.jsx(bl,{}):e.jsx(wl,{})]})}function bl(){const{config:s,_internal:t}=M.useCedrosLogin(),r=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),[o,n]=c.useState(null),[a,i]=c.useState(!1),[d,l]=c.useState(null),[h,m]=c.useState(!1),[u,f]=c.useState(null),[w,b]=c.useState(null),[g,N]=c.useState(!1),[A,v]=c.useState(null),[k,S]=c.useState(null),[E,p]=c.useState(null),y=c.useCallback(async()=>{i(!0),l(null);try{const I=await r.get("/admin/referral-payouts");n(I)}catch(I){const O=M.handleApiError(I,"Failed to load referral payouts");l(O.message)}finally{i(!1)}},[r]),x=c.useCallback(async()=>{try{const O=(await r.get("/admin/settings"))?.payout_auto_enabled?.value;p(O==="true")}catch{}},[r]);c.useEffect(()=>{y(),x()},[y,x]);const j=c.useCallback(async()=>{m(!0),f(null),b(null);try{const I=await r.post("/admin/referral-payouts/process",{});f(I),y()}catch(I){const O=M.handleApiError(I,"Failed to process payouts");b(O.message)}finally{m(!1)}},[r,y]),L=c.useCallback(async()=>{N(!0),v(null),S(null);try{const I=await r.post("/admin/referral-payouts/retry-failed",{});v(I),y()}catch(I){const O=M.handleApiError(I,"Failed to retry failed payouts");S(O.message)}finally{N(!1)}},[r,y]),C=h||g;if(a&&!o)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading referral payouts..."})]});if(d)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,children:"Retry"})]});const P=o?.referrers??[],_=o?.total??0,R=P[0]?.currency??"SOL",T=P.reduce((I,O)=>I+O.totalPendingAmount,0);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__header",children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__summary",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Pending Referrers"}),e.jsx("span",{className:"cedros-admin-stat-value",children:_})]}),_>0&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Total Pending Amount"}),e.jsx("span",{className:"cedros-admin-stat-value",children:at(T,R)})]}),E!==null&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Auto-Processing"}),e.jsx("span",{className:"cedros-admin-stat-value",children:E?"ON":"OFF"})]})]}),e.jsxs("div",{className:"cedros-admin-referral-payouts__actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:j,disabled:C||_===0,"aria-busy":h,children:h?"Processing...":"Process All Payouts"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:L,disabled:C,"aria-busy":g,children:g?"Retrying...":"Retry Failed"})]})]}),u&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Processed ",u.processed," payout(s) totalling"," ",at(u.totalAmount,R),".",u.failed>0&&` ${u.failed} failed.`,u.skippedNoWallet>0&&` ${u.skippedNoWallet} skipped (no wallet).`]}),w&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:w}),A&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Reset ",A.resetCount," failed payout(s) for retry."]}),k&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:k}),P.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No pending referral payouts."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Pending referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer ID"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Wallet Address"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Pending Referrals"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Total Amount"})]}),P.map(I=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:e.jsx("button",{type:"button",className:"cedros-admin-user-uuid-link",onClick:()=>navigator.clipboard?.writeText(I.referrerId),title:`Click to copy: ${I.referrerId}`,children:Vr(I.referrerId)})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:I.payoutWalletAddress?e.jsx("button",{type:"button",className:"cedros-admin-user-uuid-link cedros-admin-list-td-mono",onClick:()=>navigator.clipboard?.writeText(I.payoutWalletAddress),title:`Click to copy: ${I.payoutWalletAddress}`,children:Vr(I.payoutWalletAddress)}):e.jsx("span",{className:"cedros-admin-list-td-muted",children:"No wallet"})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:I.pendingCount}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:at(I.totalPendingAmount,I.currency)})]},I.referrerId))]})]})}function xl({pageSize:s,currentUserId:t}){const[r,o]=c.useState(null),{statsItems:n,isLoading:a,error:i,refresh:d}=Ie.useUsersStatsSummary();return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ie.AdminUserDetail,{userId:r.id,currentUserId:t,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Pn.StatsBar,{stats:n,isLoading:a,onRefresh:d}),i&&e.jsx("p",{className:"cedros-admin-error-inline",children:i}),e.jsx(Ie.AdminUserList,{pageSize:s,currentUserId:t,onUserClick:l=>o(l)})]})}function yl({orgId:s,currentUserId:t,hasPermission:r,role:o}){const[n,a]=c.useState("members"),{members:i,isLoading:d,error:l,fetchMembers:h,updateMemberRole:m,removeMember:u}=fe.useMembers(s),{invites:f,isLoading:w,error:b,fetchInvites:g,createInvite:N,cancelInvite:A,resendInvite:v}=fe.useInvites(s);c.useEffect(()=>{h(),g()},[h,g]);const k=r("invite:create"),S=r("invite:cancel"),E=f.length,p=i.reduce((L,C)=>(L[C.role]=(L[C.role]??0)+1,L),{}),y=p.owner??0,x=p.admin??0,j=p.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Pn.StatsBar,{stats:[{label:"Owners",value:y},{label:"Admins",value:x},{label:"Members",value:j},{label:"Pending Invites",value:E}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="members"?"cedros-admin-tab-active":""}`,onClick:()=>a("members"),"aria-selected":n==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${n==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>a("invites"),"aria-selected":n==="invites",role:"tab",children:["Pending Invites",E>0&&` (${E})`]}),o==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>a("permissions"),"aria-selected":n==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[n==="members"&&e.jsx(fe.MemberList,{members:i,currentUserId:t,isLoading:d,error:l?.message,canManage:r("member:remove"),canChangeRoles:r("member:role_change"),onUpdateRole:m,onRemove:u}),n==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[k&&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(fe.InviteForm,{onSubmit:N,isLoading:w,error:b?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(fe.InviteList,{invites:f,isLoading:w,error:b?.message,canManage:S||k,onCancel:S?A:void 0,onResend:k?v:void 0})})]}),n==="permissions"&&o==="owner"&&e.jsx(fe.PermissionsSection,{userRole:o})]})]})}function vl({pageSize:s,refreshInterval:t}){const[r,o]=c.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(_s.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:r,onChange:n=>o(n.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(_s.AdminDepositList,{statusFilter:r||void 0,pageSize:s,refreshInterval:t})]})]})}function Al({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Me.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(Me.AdminPrivacyPeriodDeposits,{pageSize:s,refreshInterval:t}),e.jsx(Me.AdminWithdrawalQueue,{pageSize:s,refreshInterval:t}),e.jsx(Me.AdminWithdrawalHistory,{pageSize:s,refreshInterval:t})]})]})}function jl(){return e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Do,{})})}const Nl=["security","rate_limit"];function kl({className:s}){return e.jsx(ss.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:Nl,className:s})}const Hr=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Sl({className:s}){const{settings:t,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:d,handleChange:l,getEffectiveValue:h}=ke.useSettingsAutosave(),[m,u]=c.useState("email");c.useEffect(()=>{d()},[d]);const f=Hr.find(S=>S.id===m),w=f?.category??"",g=(h("email_provider")||"custom")==="custom",N=h("email_smtp_host"),A=!g||N!=null&&N!=="",v=c.useMemo(()=>{const S=t[w]??[];if(m!=="email")return S;const E=g?ks.ALL_EMAIL_FIELDS:ks.SIMPLIFIED_EMAIL_FIELDS;return S.filter(p=>E.includes(p.key)).sort((p,y)=>E.indexOf(p.key)-E.indexOf(y.key))},[t,w,m,g]),k=(S,E)=>{if(l(S,E),S==="email_provider"&&E!=="custom"){const p=ks.PROVIDER_SMTP_HOSTS[E];p&&(l("email_smtp_host",p),l("email_smtp_port","587"),l("email_smtp_tls","true"))}};return o&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(te.ErrorMessage,{error:i.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 for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(ke.AutosaveStatus,{status:n,error:a})]}),m==="email"&&!A&&e.jsx("div",{className:"cedros-settings-warning-banner",children:"Email features (verification, password reset, instant link) are disabled until SMTP is configured. Select a provider or enter custom SMTP settings below."}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:Hr.map(S=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${m===S.id?"cedros-admin-tab-active":""}`,onClick:()=>u(S.id),"aria-selected":m===S.id,role:"tab",children:S.label},S.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:v.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",f?.label??"this section","."]})}):e.jsx(ke.SettingsSection,{settings:v,edits:r,onChange:m==="email"?k:l})})]})}const it=["image_storage_enabled","image_storage_provider","image_storage_bucket","image_storage_region","image_storage_endpoint","image_storage_access_key","image_storage_secret_key","image_storage_cdn_url"],Gr={nyc3:"https://nyc3.digitaloceanspaces.com",ams3:"https://ams3.digitaloceanspaces.com",sgp1:"https://sgp1.digitaloceanspaces.com",sfo3:"https://sfo3.digitaloceanspaces.com",fra1:"https://fra1.digitaloceanspaces.com",syd1:"https://syd1.digitaloceanspaces.com"};function Cl({className:s}){const{settings:t,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:d,handleChange:l,getEffectiveValue:h}=ke.useSettingsAutosave();c.useEffect(()=>{d()},[d]);const m=c.useMemo(()=>(t.image_storage??[]).filter(w=>it.includes(w.key)).sort((w,b)=>it.indexOf(w.key)-it.indexOf(b.key)),[t]),u=(f,w)=>{if(l(f,w),f==="image_storage_provider")if(w==="digitalocean"){const b=h("image_storage_region")||"nyc3";l("image_storage_region",b),l("image_storage_endpoint",Gr[b]??`https://${b}.digitaloceanspaces.com`)}else w==="s3"&&l("image_storage_endpoint","");f==="image_storage_region"&&h("image_storage_provider")==="digitalocean"&&l("image_storage_endpoint",Gr[w]??`https://${w}.digitaloceanspaces.com`)};return o&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(te.ErrorMessage,{error:i.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:"Image Storage"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure S3-compatible object storage for user avatars and images. Supports AWS S3, DigitalOcean Spaces, and other S3-compatible providers."})]}),e.jsx(ke.AutosaveStatus,{status:n,error:a})]}),m.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No image storage settings found."})}):e.jsx(ke.SettingsSection,{settings:m,edits:r,onChange:u})]})}const El=["kyc","accreditation","sanctions","token_gating"];function Fo({className:s}){return e.jsx(ss.SettingsPageLayout,{title:"Compliance & Gating",description:"Configure KYC identity verification, accredited investor verification, sanctions screening, and Solana token gating.",categories:El,className:s})}const _l=["referral"];function Oo({className:s}){return e.jsx(ss.SettingsPageLayout,{title:"Referrals & Rewards",description:"Configure referral reward types, amounts, triggers, per-referrer caps, and automated payout processing.",categories:_l,className:s})}const Ll=["signup"];function Wo({className:s}){return e.jsx(ss.SettingsPageLayout,{title:"Signup Gating",description:"Configure access codes required to register and optional signup rate limits.",categories:Ll,className:s})}const ls=20;function ct(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}function Pl(s){return!!s.expiresAt&&new Date(s.expiresAt)<new Date}function Rl(s){return s.maxUses!==null&&s.currentUses>=s.maxUses}function Tl(s){return Pl(s)?"expired":Rl(s)?"exhausted":"active"}function qo({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Ie.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState("all"),[i,d]=c.useState([]),[l,h]=c.useState(0),[m,u]=c.useState(0),[f,w]=c.useState(!1),[b,g]=c.useState(null),[N,A]=c.useState(null),[v,k]=c.useState(""),[S,E]=c.useState(""),[p,y]=c.useState(""),[x,j]=c.useState(!1),[L,C]=c.useState(null),[P,_]=c.useState(!1),[R,T]=c.useState(null),[I,O]=c.useState(null),W={all:void 0,limited:"limited",user_invite:"user_invite"},q=c.useCallback(async()=>{w(!0),g(null);try{const B=await o.listAccessCodes(ls,m,W[n]);d(B.items),h(B.total)}catch(B){g(B instanceof Error?B.message:"Failed to load access codes")}finally{w(!1)}},[o,n,m]),U=c.useCallback(async()=>{try{const B=await o.getSignupStats();A(B)}catch{}},[o]);c.useEffect(()=>{q(),U()},[q,U]),c.useEffect(()=>{u(0)},[n]);const F=c.useCallback(async B=>{if(B.preventDefault(),!v.trim()){C("Code is required.");return}const z=S.trim()?parseInt(S,10):null;if(S.trim()&&(isNaN(z)||z<1)){C("Max uses must be a positive integer.");return}const $=p.trim()?new Date(p).toISOString():void 0;j(!0),C(null),_(!1);try{await o.createAccessCode(v.trim(),z,$),k(""),E(""),y(""),_(!0),q(),U()}catch(H){C(H instanceof Error?H.message:"Failed to create code")}finally{j(!1)}},[o,v,S,p,q,U]),V=c.useCallback(async B=>{T(B),O(null);try{await o.deleteAccessCode(B),d(z=>z.filter($=>$.id!==B)),h(z=>z-1)}catch(z){O(z instanceof Error?z.message:"Failed to delete code")}finally{T(null)}},[o]),Y=Math.ceil(l/ls),X=Math.floor(m/ls)+1;return e.jsxs("div",{className:`cedros-admin-access-codes ${s}`,children:[e.jsxs("div",{className:"cedros-admin-access-codes__header",children:[e.jsx("h2",{className:"cedros-admin-access-codes__title",children:"Access Codes"}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:()=>{q(),U()},disabled:f,title:"Refresh","aria-label":"Refresh list",children:f?"...":"↻"})]}),N&&e.jsxs("div",{className:"cedros-admin-access-codes__stats-bar","aria-label":"Signup statistics",children:[e.jsxs("span",{className:"cedros-admin-access-codes__stat",children:[e.jsxs("strong",{children:["Signups this ",N.period,":"]})," ",N.count,N.limit!==null?` / ${N.limit}`:""]}),e.jsxs("span",{className:"cedros-admin-access-codes__stat",children:[e.jsx("strong",{children:"Period start:"})," ",ct(N.periodStart)]})]}),e.jsxs("section",{className:"cedros-admin-access-codes__create-section","aria-label":"Create access code",children:[e.jsx("h3",{className:"cedros-admin-access-codes__section-title",children:"Create Code"}),e.jsxs("form",{className:"cedros-admin-access-codes__create-form",onSubmit:F,"aria-label":"Create access code form",children:[e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsx("label",{htmlFor:"ac-code",className:"cedros-label",children:"Code"}),e.jsx("input",{id:"ac-code",type:"text",className:"cedros-input",value:v,onChange:B=>{k(B.target.value),C(null),_(!1)},placeholder:"e.g. BETA2025",disabled:x,required:!0})]}),e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsxs("label",{htmlFor:"ac-max-uses",className:"cedros-label",children:["Max Uses ",e.jsx("span",{className:"cedros-optional",children:"(blank = unlimited)"})]}),e.jsx("input",{id:"ac-max-uses",type:"number",className:"cedros-input",value:S,onChange:B=>E(B.target.value),placeholder:"e.g. 100",min:"1",disabled:x})]}),e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsxs("label",{htmlFor:"ac-expiry",className:"cedros-label",children:["Expiry ",e.jsx("span",{className:"cedros-optional",children:"(optional)"})]}),e.jsx("input",{id:"ac-expiry",type:"date",className:"cedros-input",value:p,onChange:B=>y(B.target.value),disabled:x})]}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary cedros-button-md",disabled:x,"aria-busy":x,children:x?"Creating...":"Create"})]}),L&&e.jsx("div",{className:"cedros-admin-error",role:"alert",children:L}),P&&!L&&e.jsx("div",{className:"cedros-admin-success",role:"status",children:"Code created."})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",role:"tablist",children:["all","limited","user_invite"].map(B=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${n===B?"cedros-admin-tab-active":""}`,onClick:()=>a(B),"aria-selected":n===B,role:"tab",children:B==="all"?"All":B==="limited"?"Limited":"User Invite"},B))}),I&&e.jsx("div",{className:"cedros-admin-error",role:"alert",children:I}),b&&e.jsxs("div",{className:"cedros-admin-access-codes--error",children:[e.jsx("p",{className:"cedros-admin-error",children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:q,children:"Retry"})]}),!b&&e.jsx("div",{role:"tabpanel",children:f&&i.length===0?e.jsxs("div",{className:"cedros-admin-access-codes--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading..."})]}):i.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No access codes found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table cedros-admin-access-codes__table",role:"table","aria-label":"Access codes",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Code"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Uses"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Created By"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Created"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Expires"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:e.jsx("span",{className:"cedros-sr-only",children:"Actions"})})]}),i.map(B=>{const z=Tl(B),$=B.maxUses!==null?`${B.currentUses} / ${B.maxUses}`:`${B.currentUses}`;return e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("code",{className:"cedros-admin-access-codes__code",children:B.code})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:B.codeType}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:$}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:B.createdByEmail??"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:ct(B.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:B.expiresAt?ct(B.expiresAt):"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-access-codes__status cedros-admin-access-codes__status--${z}`,children:z.charAt(0).toUpperCase()+z.slice(1)})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>V(B.id),disabled:R===B.id,"aria-label":`Delete code ${B.code}`,children:R===B.id?"...":"Delete"})})]},B.id)})]}),Y>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(Math.max(0,m-ls)),disabled:X<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",X," of ",Y," (",l," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(m+ls),disabled:X>=Y,children:"Next"})]})]})})]})}function Ml(){return`rule_${Date.now()}_${Math.random().toString(36).slice(2,7)}`}function Il(s){if(!s)return[];try{const t=JSON.parse(s);return Array.isArray(t)?t:[]}catch{return[]}}function Bl(s){switch(s){case"nft_collection":return"NFT Collection";case"fungible_token":return"Fungible Token";case"any_nft":return"Any NFT"}}function Ul(s){switch(s){case"all":return"All";case"deposits":return"Deposits";case"withdrawals":return"Withdrawals"}}const Qr={name:"",ruleType:"nft_collection",collectionAddress:"",mintAddress:"",minQuantity:"",minAmount:"",enforcement:"all"};function Dl(s){return{name:s.name,ruleType:s.ruleType,collectionAddress:s.collectionAddress??"",mintAddress:s.mintAddress??"",minQuantity:s.minQuantity!==void 0?String(s.minQuantity):"",minAmount:s.minAmount??"",enforcement:s.enforcement}}function Fl(s,t){return{id:t,name:s.name.trim(),ruleType:s.ruleType,collectionAddress:s.ruleType==="nft_collection"&&s.collectionAddress.trim()||void 0,mintAddress:s.ruleType==="fungible_token"&&s.mintAddress.trim()||void 0,minQuantity:s.ruleType!=="fungible_token"&&s.minQuantity?parseInt(s.minQuantity,10):void 0,minAmount:s.ruleType==="fungible_token"&&s.minAmount.trim()||void 0,enforcement:s.enforcement}}function zo({className:s=""}){const{fetchSettings:t,updateSettings:r,getValue:o,isLoading:n,error:a}=Gt.useSystemSettings(),[i,d]=c.useState([]),[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,w]=c.useState(Qr),[b,g]=c.useState(null),[N,A]=c.useState(!1);c.useEffect(()=>{t()},[t]);const v=o("token_gating_rules"),k=c.useMemo(()=>Il(v),[v]);c.useEffect(()=>{d(k)},[k]);const S=c.useCallback(async C=>{A(!0),g(null);try{await r([{key:"token_gating_rules",value:JSON.stringify(C)}]),d(C)}catch(P){g(P instanceof Error?P.message:"Failed to save rules")}finally{A(!1)}},[r]),E=c.useCallback(()=>{h(null),w(Qr),g(null),u(!0)},[]),p=c.useCallback(C=>{h(C.id),w(Dl(C)),g(null),u(!0)},[]),y=c.useCallback(C=>{const P=i.filter(_=>_.id!==C);S(P)},[i,S]),x=c.useCallback(()=>{u(!1),g(null)},[]),j=c.useCallback(async()=>{if(!f.name.trim()){g("Rule name is required.");return}const C=l??Ml(),P=Fl(f,C),_=l?i.map(R=>R.id===l?P:R):[...i,P];await S(_),b||u(!1)},[f,l,i,S,b]),L=c.useCallback((C,P)=>{w(_=>({..._,[C]:P}))},[]);return n&&i.length===0?e.jsxs("div",{className:`cedros-admin-token-gate ${s} cedros-admin-token-gate--loading`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading token gate rules..."})]}):a&&i.length===0?e.jsxs("div",{className:`cedros-admin-token-gate ${s} cedros-admin-token-gate--error`,children:[e.jsx("p",{className:"cedros-admin-error",children:a.message}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:"Retry"})]}):e.jsxs("div",{className:`cedros-admin-token-gate ${s}`,children:[e.jsxs("div",{className:"cedros-admin-token-gate__header",children:[e.jsx("h2",{className:"cedros-admin-token-gate__title",children:"Token Gate Rules"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:E,disabled:m,children:"Add Rule"})]}),m&&e.jsx(Ol,{form:f,isNew:l===null,isSaving:N,saveError:b,onFieldChange:L,onSave:j,onCancel:x}),i.length===0&&!m?e.jsx("div",{className:"cedros-admin-empty-message",children:"No token gate rules configured."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Token gate rules",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Name"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Address / Mint"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Min Qty / Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Enforcement"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),i.map(C=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:C.name}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Bl(C.ruleType)}),e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:C.collectionAddress||C.mintAddress||"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:C.minQuantity!==void 0?C.minQuantity:C.minAmount??"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Ul(C.enforcement)}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-actions",role:"cell",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>p(C),disabled:m,children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>y(C.id),disabled:N||m,children:"Delete"})]})]},C.id))]})]})}function Ol({form:s,isNew:t,isSaving:r,saveError:o,onFieldChange:n,onSave:a,onCancel:i}){const d=s.ruleType==="nft_collection",l=s.ruleType==="fungible_token",h=s.ruleType!=="fungible_token",m=s.ruleType==="fungible_token";return e.jsxs("div",{className:"cedros-admin-token-gate__form",role:"region","aria-label":t?"Add rule":"Edit rule",children:[e.jsx("h3",{className:"cedros-admin-token-gate__form-title",children:t?"Add Rule":"Edit Rule"}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-name",children:"Name"}),e.jsx("input",{id:"tg-name",type:"text",className:"cedros-admin-form-input",value:s.name,onChange:u=>n("name",u.target.value),placeholder:"e.g. Whale Gate"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-type",children:"Type"}),e.jsxs("select",{id:"tg-type",className:"cedros-admin-form-select",value:s.ruleType,onChange:u=>n("ruleType",u.target.value),children:[e.jsx("option",{value:"nft_collection",children:"NFT Collection"}),e.jsx("option",{value:"fungible_token",children:"Fungible Token"}),e.jsx("option",{value:"any_nft",children:"Any NFT"})]})]}),d&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-collection",children:"Collection Address"}),e.jsx("input",{id:"tg-collection",type:"text",className:"cedros-admin-form-input cedros-admin-form-input--mono",value:s.collectionAddress,onChange:u=>n("collectionAddress",u.target.value),placeholder:"Solana collection mint address"})]}),l&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-mint",children:"Mint Address"}),e.jsx("input",{id:"tg-mint",type:"text",className:"cedros-admin-form-input cedros-admin-form-input--mono",value:s.mintAddress,onChange:u=>n("mintAddress",u.target.value),placeholder:"SPL token mint address"})]}),h&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-minqty",children:"Min Quantity"}),e.jsx("input",{id:"tg-minqty",type:"number",min:"1",className:"cedros-admin-form-input",value:s.minQuantity,onChange:u=>n("minQuantity",u.target.value),placeholder:"1"})]}),m&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-minamount",children:"Min Amount"}),e.jsx("input",{id:"tg-minamount",type:"text",className:"cedros-admin-form-input",value:s.minAmount,onChange:u=>n("minAmount",u.target.value),placeholder:"e.g. 1000000 (raw units)"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-enforcement",children:"Enforcement"}),e.jsxs("select",{id:"tg-enforcement",className:"cedros-admin-form-select",value:s.enforcement,onChange:u=>n("enforcement",u.target.value),children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"deposits",children:"Deposits"}),e.jsx("option",{value:"withdrawals",children:"Withdrawals"})]})]}),o&&e.jsx("p",{className:"cedros-admin-error",children:o}),e.jsxs("div",{className:"cedros-admin-token-gate__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,disabled:r,"aria-busy":r,children:r?"Saving...":"Save Rule"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:i,disabled:r,children:"Cancel"})]})]})}function Wl(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function ql(s){return{income:"Income",net_worth:"Net Worth",credential:"Credential",third_party_letter:"Third-Party Letter",insider:"Insider / Executive",investment_threshold:"Investment Threshold"}[s]??s}function zl(s){switch(s){case"pending":return"cedros-admin-badge--pending";case"approved":return"cedros-admin-badge--approved";case"rejected":return"cedros-admin-badge--rejected";case"expired":return"cedros-admin-badge--expired";default:return""}}function $l({item:s,isExpanded:t,detail:r,detailLoading:o,detailError:n,reviewNotes:a,rejectionReason:i,isReviewing:d,reviewError:l,onRowClick:h,onDocumentDownload:m,onReviewNotesChange:u,onRejectionReasonChange:f,onReview:w}){const b=s.statedAmountUsd!==void 0?`$${s.statedAmountUsd.toLocaleString()}`:s.investmentCommitmentUsd!==void 0?`$${s.investmentCommitmentUsd.toLocaleString()}`:"—";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`cedros-admin-list-row cedros-admin-list-row--clickable ${t?"cedros-admin-list-row--expanded":""}`,role:"row",onClick:()=>h(s.id),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),h(s.id))},tabIndex:0,"aria-expanded":t,children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:s.userEmail??e.jsxs("span",{className:"cedros-admin-list-td-mono",children:[s.userId.slice(0,12),"..."]})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:ql(s.method)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:b}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Wl(s.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-badge ${zl(s.status)}`,children:s.status})})]}),t&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail",role:"region","aria-label":"Submission detail",children:[o&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading detail..."})]}),n&&e.jsx("p",{className:"cedros-admin-error",children:n}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Vl,{detail:r,onDocumentDownload:m}),s.status==="pending"&&e.jsx(Hl,{submissionId:s.id,notes:a,rejectionReason:i,isReviewing:d,error:l,onNotesChange:u,onRejectionReasonChange:f,onReview:w})]})]})]})}function Vl({detail:s,onDocumentDownload:t}){return e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail-fields",children:[s.incomeType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Income Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.incomeType})]}),s.statedAmountUsd!==void 0&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Stated Amount"}),e.jsxs("span",{className:"cedros-admin-detail-value",children:["$",s.statedAmountUsd.toLocaleString()]})]}),s.crdNumber&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"CRD Number"}),e.jsx("span",{className:"cedros-admin-detail-value cedros-admin-list-td-mono",children:s.crdNumber})]}),s.licenseType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"License Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.licenseType})]}),s.investmentCommitmentUsd!==void 0&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Investment Commitment"}),e.jsxs("span",{className:"cedros-admin-detail-value",children:["$",s.investmentCommitmentUsd.toLocaleString()]})]}),s.entityType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Entity Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.entityType})]}),s.userStatement&&e.jsxs("div",{className:"cedros-admin-detail-row cedros-admin-detail-row--block",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"User Statement"}),e.jsx("p",{className:"cedros-admin-detail-statement",children:s.userStatement})]}),s.documents.length>0&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__documents",children:[e.jsx("h4",{className:"cedros-admin-accreditation-queue__documents-title",children:"Documents"}),s.documents.map(r=>e.jsxs("div",{className:"cedros-admin-accreditation-queue__document-row",children:[e.jsx("span",{className:"cedros-admin-accreditation-queue__document-name",children:r.originalFilename??r.documentType}),r.fileSizeBytes&&e.jsxs("span",{className:"cedros-admin-list-td-muted",children:[(r.fileSizeBytes/1024).toFixed(1)," KB"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>t(r.id),children:"Download"})]},r.id))]})]})}function Hl({submissionId:s,notes:t,rejectionReason:r,isReviewing:o,error:n,onNotesChange:a,onRejectionReasonChange:i,onReview:d}){return e.jsxs("div",{className:"cedros-admin-accreditation-queue__review-form",children:[e.jsx("h4",{className:"cedros-admin-accreditation-queue__review-title",children:"Review Decision"}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"review-notes",children:"Reviewer Notes (internal)"}),e.jsx("textarea",{id:"review-notes",className:"cedros-admin-form-textarea",value:t,onChange:l=>a(l.target.value),rows:2,placeholder:"Optional internal notes"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"rejection-reason",children:"Rejection Reason (required if rejecting)"}),e.jsx("textarea",{id:"rejection-reason",className:"cedros-admin-form-textarea",value:r,onChange:l=>i(l.target.value),rows:2,placeholder:"Reason shown to user"})]}),n&&e.jsx("p",{className:"cedros-admin-error",children:n}),e.jsxs("div",{className:"cedros-admin-accreditation-queue__review-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:()=>d(s,!0),disabled:o,"aria-busy":o,children:o?"Saving...":"Approve"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>d(s,!1),disabled:o,"aria-busy":o,children:o?"Saving...":"Reject"})]})]})}const ds=20;function $o({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Ie.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState("pending"),[i,d]=c.useState([]),[l,h]=c.useState(0),[m,u]=c.useState(0),[f,w]=c.useState(!1),[b,g]=c.useState(null),[N,A]=c.useState(null),[v,k]=c.useState(null),[S,E]=c.useState(!1),[p,y]=c.useState(null),[x,j]=c.useState(""),[L,C]=c.useState(""),[P,_]=c.useState(!1),[R,T]=c.useState(null),[I,O]=c.useState(null),W=c.useCallback(async()=>{w(!0),g(null);try{const B=await o.listPendingAccreditations(ds,m);d(B.items),h(B.total)}catch(B){g(B instanceof Error?B.message:"Failed to load submissions")}finally{w(!1)}},[o,n,m]);c.useEffect(()=>{W()},[W]),c.useEffect(()=>{u(0),A(null),k(null)},[n]);const q=c.useCallback(async B=>{if(N===B){A(null),k(null);return}A(B),k(null),y(null),j(""),C(""),T(null),O(null),E(!0);try{const z=await o.getAccreditationSubmission(B);k(z)}catch(z){y(z instanceof Error?z.message:"Failed to load submission detail")}finally{E(!1)}},[N,o]),U=c.useCallback(async B=>{try{const z=await o.getAccreditationDocumentUrl(B);window.open(z,"_blank","noopener,noreferrer")}catch(z){T(z instanceof Error?z.message:"Failed to get document URL")}},[o]),F=c.useCallback(async(B,z)=>{if(!z&&!L.trim()){T("Rejection reason is required.");return}_(!0),T(null),O(null);try{await o.reviewAccreditation(B,z,x.trim()||void 0,z?void 0:L.trim()),O(z?"Submission approved.":"Submission rejected."),A(null),k(null),W()}catch($){T($ instanceof Error?$.message:"Failed to submit review")}finally{_(!1)}},[o,x,L,W]),V=Math.ceil(l/ds),Y=Math.floor(m/ds)+1,X=n==="pending"?l:i.filter(B=>B.status==="pending").length;return e.jsxs("div",{className:`cedros-admin-accreditation-queue ${s}`,children:[e.jsxs("div",{className:"cedros-admin-accreditation-queue__header",children:[e.jsxs("h2",{className:"cedros-admin-accreditation-queue__title",children:["Accreditation Review Queue",X>0&&e.jsx("span",{className:"cedros-admin-queue-count","aria-label":`${X} pending`,children:X})]}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:W,disabled:f,title:"Refresh","aria-label":"Refresh list",children:f?"...":"↻"})]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",role:"tablist",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="pending"?"cedros-admin-tab-active":""}`,onClick:()=>a("pending"),"aria-selected":n==="pending",role:"tab",children:"Pending"}),e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="all"?"cedros-admin-tab-active":""}`,onClick:()=>a("all"),"aria-selected":n==="all",role:"tab",children:"All"})]}),I&&e.jsx("div",{className:"cedros-admin-accreditation-queue__result cedros-admin-accreditation-queue__result--success",children:I}),b&&e.jsxs("div",{className:"cedros-admin-accreditation-queue cedros-admin-accreditation-queue--error",children:[e.jsx("p",{className:"cedros-admin-error",children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:W,children:"Retry"})]}),!b&&f&&i.length===0?e.jsxs("div",{className:"cedros-admin-accreditation-queue--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading submissions..."})]}):e.jsx("div",{role:"tabpanel",children:i.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No submissions found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Accreditation submissions",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"User"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Method"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Submitted"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"})]}),i.map(B=>e.jsx($l,{item:B,isExpanded:N===B.id,detail:N===B.id?v:null,detailLoading:N===B.id&&S,detailError:N===B.id?p:null,reviewNotes:x,rejectionReason:L,isReviewing:P,reviewError:N===B.id?R:null,onRowClick:q,onDocumentDownload:U,onReviewNotesChange:j,onRejectionReasonChange:C,onReview:F},B.id))]}),V>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(Math.max(0,m-ds)),disabled:Y<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",Y," of ",V," (",l," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(m+ds),disabled:Y>=V,children:"Next"})]})]})})]})}function Gl(s){return s===void 0?"—":s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m ${s%60}s`:`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`}function Ql(s){return s?new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function Vo({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Ie.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState(null),[i,d]=c.useState(!1),[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,w]=c.useState(null),[b,g]=c.useState(!1),N=c.useCallback(async()=>{d(!0),h(null);try{const v=await o.getSanctionsStats();a(v)}catch(v){h(v instanceof Error?v.message:"Failed to load sanctions stats")}finally{d(!1)}},[o]);c.useEffect(()=>{N()},[N]);const A=c.useCallback(async()=>{u(!0),w(null),g(!1);try{await o.refreshSanctions(),g(!0),await N()}catch(v){w(v instanceof Error?v.message:"Failed to refresh sanctions cache")}finally{u(!1)}},[o,N]);return i&&!n?e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s} cedros-admin-sanctions-panel--loading`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading sanctions stats..."})]}):l&&!n?e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s} cedros-admin-sanctions-panel--error`,children:[e.jsx("p",{className:"cedros-admin-error",children:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:N,children:"Retry"})]}):e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s}`,children:[e.jsxs("div",{className:"cedros-admin-sanctions-panel__header",children:[e.jsx("h2",{className:"cedros-admin-sanctions-panel__title",children:"Sanctions Screening"}),e.jsxs("div",{className:"cedros-admin-sanctions-panel__header-actions",children:[n!==null&&e.jsx("span",{className:`cedros-admin-badge ${n.configured?"cedros-admin-badge--approved":"cedros-admin-badge--pending"}`,title:n.configured?"Sanctions API configured":"Sanctions API not configured",children:n.configured?"Configured":"Not Configured"}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:N,disabled:i,title:"Refresh stats","aria-label":"Refresh stats",children:i?"...":"↻"})]})]}),n!==null&&e.jsxs("div",{className:"cedros-admin-sanctions-panel__stats",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Sanctioned Addresses"}),e.jsx("span",{className:"cedros-admin-stat-value",children:n.sanctionedAddresses.toLocaleString()})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Sanctioned Countries"}),e.jsx("span",{className:"cedros-admin-stat-value",children:n.sanctionedCountries.toLocaleString()})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Cache Age"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Gl(n.cacheAgeSeconds)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Last Refresh"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ql(n.lastRefreshedAt)})]})]}),e.jsx("div",{className:"cedros-admin-sanctions-panel__actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:A,disabled:m||i,"aria-busy":m,children:m?"Refreshing...":"Force Refresh"})}),b&&e.jsx("div",{className:"cedros-admin-sanctions-panel__result cedros-admin-sanctions-panel__result--success",children:"Sanctions cache refreshed successfully."}),f&&e.jsx("div",{className:"cedros-admin-sanctions-panel__result cedros-admin-sanctions-panel__result--error",children:f}),l&&n&&e.jsx("p",{className:"cedros-admin-error cedros-admin-error--inline",children:l})]})}class Kl{client;constructor(t,r,o){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o})}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(r){throw M.handleApiError(r,"Failed to create admin account")}}}function or(){const{config:s}=M.useCedrosLogin(),[t,r]=c.useState(null),[o,n]=c.useState(!1),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useRef(0),m=c.useMemo(()=>new Kl(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),u=c.useRef(m);u.current=m;const f=c.useCallback(async()=>{n(!0),l(null);const b=++h.current;try{const g=await u.current.getStatus();if(b!==h.current)return;r(g)}catch(g){if(b!==h.current)return;l(g instanceof Error?g:new Error("Failed to check setup status"))}finally{b===h.current&&n(!1)}},[]),w=c.useCallback(async b=>{i(!0),l(null);try{const g=await u.current.createFirstAdmin(b);return await f(),g}catch(g){const N=g instanceof Error?g:new Error("Failed to create admin");throw l(N),N}finally{i(!1)}},[f]);return{status:t,isLoading:o,isCreating:a,error:d,checkStatus:f,createAdmin:w}}const Yl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Kr=8;function Zl(s){const t={};return s.email?Yl.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<Kr&&(t.password=`Password must be at least ${Kr} 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 Ho({onComplete:s,className:t=""}){const{status:r,isLoading:o,isCreating:n,error:a,checkStatus:i,createAdmin:d}=or(),[l,h]=c.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[m,u]=c.useState({}),[f,w]=c.useState(!1);c.useEffect(()=>{i()},[i]);const b=c.useCallback(N=>A=>{h(v=>({...v,[N]:A.target.value})),u(v=>({...v,[N]:void 0}))},[]),g=c.useCallback(async N=>{N.preventDefault();const A=Zl(l);if(Object.keys(A).length>0){u(A);return}try{await d({email:l.email,password:l.password,name:l.name||void 0,orgName:l.orgName||void 0}),w(!0),s?.()}catch{}},[l,d,s]);return o?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):r&&!r.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."})]})}):f?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:g,children:[a&&e.jsx(te.ErrorMessage,{error:a.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 ${m.email?"cedros-setup__input--error":""}`,value:l.email,onChange:b("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:n}),m.email&&e.jsx("span",{className:"cedros-setup__error",children:m.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:l.name,onChange:b("name"),placeholder:"Admin",autoComplete:"name",disabled:n})]}),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:l.orgName,onChange:b("orgName"),placeholder:"My Organization",disabled:n})]}),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 ${m.password?"cedros-setup__input--error":""}`,value:l.password,onChange:b("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:n}),m.password&&e.jsx("span",{className:"cedros-setup__error",children:m.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 ${m.confirmPassword?"cedros-setup__input--error":""}`,value:l.confirmPassword,onChange:b("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:n}),m.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:m.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Q.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."}),r?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",r.serverVersion]})]})]})})}function Xl({title:s="Dashboard",sections:t=["users","team","referrals","deposits","withdrawals","compliance","accreditation-queue","sanctions","signup-gating","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-compliance","settings-referrals","settings-signup","settings-server","settings-images"],defaultSection:r="users",refreshInterval:o=0,pageSize:n=20,onSectionChange:a,onSettingsClick:i,onLogoutClick:d,className:l=""}){const[h,m]=c.useState(r),[u,f]=c.useState(!0),{user:w,logout:b}=M.useCedrosLogin(),{activeOrg:g,role:N,isLoading:A,fetchOrgs:v,hasPermission:k}=Qt.useOrgs(),{status:S,isLoading:E,checkStatus:p}=or(),{features:y,isLoading:x}=es.useServerFeatures(),{canAccess:j}=fe.useDashboardPermissions(),L=c.useCallback(T=>{m(T),a?.(T)},[a]),C=ml.filter(T=>!(!t.includes(T.id)||T.requiredFeature&&!y[T.requiredFeature]||!j(T.id))),P=C.find(T=>T.id===h),_=!P&&!x;return c.useEffect(()=>{v(),p()},[v,p]),c.useEffect(()=>{_&&C.length>0&&m("users")},[_,C.length]),!E&&S?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${l}`,children:e.jsx(Ho,{onComplete:()=>p()})}):(A||E||x)&&!g?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${l}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):h==="team"&&!g?e.jsx("div",{className:`cedros-admin cedros-dashboard ${l}`,children:e.jsx(te.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${l}`,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:[ne.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"}),C.filter(T=>!T.group).map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${h===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(T.id),"aria-current":h===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]}),C.some(T=>T.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:()=>f(!u),"aria-expanded":u,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${u?"cedros-dashboard__nav-chevron--expanded":""}`,children:ne.chevronRight})]}),u&&C.filter(T=>T.group==="Configuration").map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${h===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(T.id),"aria-current":h===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]})]}),w&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(Be.ProfileDropdown,{name:w.name,email:w.email,picture:w.picture,onSettings:i,onLogout:d??b})})]}),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:ne.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:P?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[h==="users"&&e.jsx(xl,{pageSize:n,currentUserId:w?.id}),h==="team"&&g&&e.jsx(yl,{orgId:g.id,currentUserId:w?.id,hasPermission:k,role:N}),h==="referrals"&&e.jsx(jl,{}),h==="deposits"&&e.jsx(vl,{pageSize:n,refreshInterval:o}),h==="withdrawals"&&e.jsx(Al,{pageSize:n,refreshInterval:o}),h==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Rn.AuthenticationSettings,{})}),h==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Tn.EmbeddedWalletSettings,{})}),h==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Sl,{})}),h==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Kt.CreditSystemSettings,{})}),h==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Mn.ServerSettings,{})}),h==="settings-images"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Cl,{})}),h==="compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(zo,{})}),h==="accreditation-queue"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx($o,{})}),h==="sanctions"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Vo,{})}),h==="settings-compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Fo,{})}),h==="settings-referrals"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Oo,{})}),h==="signup-gating"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(qo,{})}),h==="settings-signup"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Wo,{})})]})]})]})}var Ye={},lt,Yr;function Jl(){return Yr||(Yr=1,lt=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),lt}var dt={},Te={},Zr;function qe(){if(Zr)return Te;Zr=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 Te.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Te.getSymbolTotalCodewords=function(o){return t[o]},Te.getBCHDigit=function(r){let o=0;for(;r!==0;)o++,r>>>=1;return o},Te.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');s=o},Te.isKanjiModeEnabled=function(){return typeof s<"u"},Te.toSJIS=function(o){return s(o)},Te}var ut={},Xr;function ar(){return Xr||(Xr=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.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: "+r)}}s.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},s.from=function(o,n){if(s.isValid(o))return o;try{return t(o)}catch{return n}}})(ut)),ut}var ht,Jr;function ed(){if(Jr)return ht;Jr=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const r=Math.floor(t/8);return(this.buffer[r]>>>7-t%8&1)===1},put:function(t,r){for(let o=0;o<r;o++)this.putBit((t>>>r-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},ht=s,ht}var mt,en;function sd(){if(en)return mt;en=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,r,o,n){const a=t*this.size+r;this.data[a]=o,n&&(this.reservedBit[a]=!0)},s.prototype.get=function(t,r){return this.data[t*this.size+r]},s.prototype.xor=function(t,r,o){this.data[t*this.size+r]^=o},s.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},mt=s,mt}var pt={},sn;function td(){return sn||(sn=1,(function(s){const t=qe().getSymbolSize;s.getRowColCoords=function(o){if(o===1)return[];const n=Math.floor(o/7)+2,a=t(o),i=a===145?26:Math.ceil((a-13)/(2*n-2))*2,d=[a-7];for(let l=1;l<n-1;l++)d[l]=d[l-1]-i;return d.push(6),d.reverse()},s.getPositions=function(o){const n=[],a=s.getRowColCoords(o),i=a.length;for(let d=0;d<i;d++)for(let l=0;l<i;l++)d===0&&l===0||d===0&&l===i-1||d===i-1&&l===0||n.push([a[d],a[l]]);return n}})(pt)),pt}var ft={},tn;function rd(){if(tn)return ft;tn=1;const s=qe().getSymbolSize,t=7;return ft.getPositions=function(o){const n=s(o);return[[0,0],[n-t,0],[0,n-t]]},ft}var gt={},rn;function nd(){return rn||(rn=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(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},s.from=function(n){return s.isValid(n)?parseInt(n,10):void 0},s.getPenaltyN1=function(n){const a=n.size;let i=0,d=0,l=0,h=null,m=null;for(let u=0;u<a;u++){d=l=0,h=m=null;for(let f=0;f<a;f++){let w=n.get(u,f);w===h?d++:(d>=5&&(i+=t.N1+(d-5)),h=w,d=1),w=n.get(f,u),w===m?l++:(l>=5&&(i+=t.N1+(l-5)),m=w,l=1)}d>=5&&(i+=t.N1+(d-5)),l>=5&&(i+=t.N1+(l-5))}return i},s.getPenaltyN2=function(n){const a=n.size;let i=0;for(let d=0;d<a-1;d++)for(let l=0;l<a-1;l++){const h=n.get(d,l)+n.get(d,l+1)+n.get(d+1,l)+n.get(d+1,l+1);(h===4||h===0)&&i++}return i*t.N2},s.getPenaltyN3=function(n){const a=n.size;let i=0,d=0,l=0;for(let h=0;h<a;h++){d=l=0;for(let m=0;m<a;m++)d=d<<1&2047|n.get(h,m),m>=10&&(d===1488||d===93)&&i++,l=l<<1&2047|n.get(m,h),m>=10&&(l===1488||l===93)&&i++}return i*t.N3},s.getPenaltyN4=function(n){let a=0;const i=n.data.length;for(let l=0;l<i;l++)a+=n.data[l];return Math.abs(Math.ceil(a*100/i/5)-10)*t.N4};function r(o,n,a){switch(o){case s.Patterns.PATTERN000:return(n+a)%2===0;case s.Patterns.PATTERN001:return n%2===0;case s.Patterns.PATTERN010:return a%3===0;case s.Patterns.PATTERN011:return(n+a)%3===0;case s.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(a/3))%2===0;case s.Patterns.PATTERN101:return n*a%2+n*a%3===0;case s.Patterns.PATTERN110:return(n*a%2+n*a%3)%2===0;case s.Patterns.PATTERN111:return(n*a%3+(n+a)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}s.applyMask=function(n,a){const i=a.size;for(let d=0;d<i;d++)for(let l=0;l<i;l++)a.isReserved(l,d)||a.xor(l,d,r(n,l,d))},s.getBestMask=function(n,a){const i=Object.keys(s.Patterns).length;let d=0,l=1/0;for(let h=0;h<i;h++){a(h),s.applyMask(h,n);const m=s.getPenaltyN1(n)+s.getPenaltyN2(n)+s.getPenaltyN3(n)+s.getPenaltyN4(n);s.applyMask(h,n),m<l&&(l=m,d=h)}return d}})(gt)),gt}var xs={},nn;function Go(){if(nn)return xs;nn=1;const s=ar(),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],r=[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 xs.getBlocksCount=function(n,a){switch(a){case s.L:return t[(n-1)*4+0];case s.M:return t[(n-1)*4+1];case s.Q:return t[(n-1)*4+2];case s.H:return t[(n-1)*4+3];default:return}},xs.getTotalCodewordsCount=function(n,a){switch(a){case s.L:return r[(n-1)*4+0];case s.M:return r[(n-1)*4+1];case s.Q:return r[(n-1)*4+2];case s.H:return r[(n-1)*4+3];default:return}},xs}var wt={},us={},on;function od(){if(on)return us;on=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let o=1;for(let n=0;n<255;n++)s[n]=o,t[o]=n,o<<=1,o&256&&(o^=285);for(let n=255;n<512;n++)s[n]=s[n-255]})(),us.log=function(o){if(o<1)throw new Error("log("+o+")");return t[o]},us.exp=function(o){return s[o]},us.mul=function(o,n){return o===0||n===0?0:s[t[o]+t[n]]},us}var an;function ad(){return an||(an=1,(function(s){const t=od();s.mul=function(o,n){const a=new Uint8Array(o.length+n.length-1);for(let i=0;i<o.length;i++)for(let d=0;d<n.length;d++)a[i+d]^=t.mul(o[i],n[d]);return a},s.mod=function(o,n){let a=new Uint8Array(o);for(;a.length-n.length>=0;){const i=a[0];for(let l=0;l<n.length;l++)a[l]^=t.mul(n[l],i);let d=0;for(;d<a.length&&a[d]===0;)d++;a=a.slice(d)}return a},s.generateECPolynomial=function(o){let n=new Uint8Array([1]);for(let a=0;a<o;a++)n=s.mul(n,new Uint8Array([1,t.exp(a)]));return n}})(wt)),wt}var bt,cn;function id(){if(cn)return bt;cn=1;const s=ad();function t(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(o){this.degree=o,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(o.length+this.degree);n.set(o);const a=s.mod(n,this.genPoly),i=this.degree-a.length;if(i>0){const d=new Uint8Array(this.degree);return d.set(a,i),d}return a},bt=t,bt}var xt={},yt={},vt={},ln;function Qo(){return ln||(ln=1,vt.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),vt}var Ae={},dn;function Ko(){if(dn)return Ae;dn=1;const s="[0-9]+",t="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
|
|
2050
|
+
]))+`;Ae.KANJI=new RegExp(r,"g"),Ae.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Ae.BYTE=new RegExp(o,"g"),Ae.NUMERIC=new RegExp(s,"g"),Ae.ALPHANUMERIC=new RegExp(t,"g");const n=new RegExp("^"+r+"$"),a=new RegExp("^"+s+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Ae.testKanji=function(l){return n.test(l)},Ae.testNumeric=function(l){return a.test(l)},Ae.testAlphanumeric=function(l){return i.test(l)},Ae}var un;function ze(){return un||(un=1,(function(s){const t=Qo(),r=Ko();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(a,i){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?a.ccBits[0]:i<27?a.ccBits[1]:a.ccBits[2]},s.getBestModeForData=function(a){return r.testNumeric(a)?s.NUMERIC:r.testAlphanumeric(a)?s.ALPHANUMERIC:r.testKanji(a)?s.KANJI:s.BYTE},s.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},s.isValid=function(a){return a&&a.bit&&a.ccBits};function o(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.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: "+n)}}s.from=function(a,i){if(s.isValid(a))return a;try{return o(a)}catch{return i}}})(yt)),yt}var hn;function cd(){return hn||(hn=1,(function(s){const t=qe(),r=Go(),o=ar(),n=ze(),a=Qo(),i=7973,d=t.getBCHDigit(i);function l(f,w,b){for(let g=1;g<=40;g++)if(w<=s.getCapacity(g,b,f))return g}function h(f,w){return n.getCharCountIndicator(f,w)+4}function m(f,w){let b=0;return f.forEach(function(g){const N=h(g.mode,w);b+=N+g.getBitsLength()}),b}function u(f,w){for(let b=1;b<=40;b++)if(m(f,b)<=s.getCapacity(b,w,n.MIXED))return b}s.from=function(w,b){return a.isValid(w)?parseInt(w,10):b},s.getCapacity=function(w,b,g){if(!a.isValid(w))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=n.BYTE);const N=t.getSymbolTotalCodewords(w),A=r.getTotalCodewordsCount(w,b),v=(N-A)*8;if(g===n.MIXED)return v;const k=v-h(g,w);switch(g){case n.NUMERIC:return Math.floor(k/10*3);case n.ALPHANUMERIC:return Math.floor(k/11*2);case n.KANJI:return Math.floor(k/13);case n.BYTE:default:return Math.floor(k/8)}},s.getBestVersionForData=function(w,b){let g;const N=o.from(b,o.M);if(Array.isArray(w)){if(w.length>1)return u(w,N);if(w.length===0)return 1;g=w[0]}else g=w;return l(g.mode,g.getLength(),N)},s.getEncodedBits=function(w){if(!a.isValid(w)||w<7)throw new Error("Invalid QR Code version");let b=w<<12;for(;t.getBCHDigit(b)-d>=0;)b^=i<<t.getBCHDigit(b)-d;return w<<12|b}})(xt)),xt}var At={},mn;function ld(){if(mn)return At;mn=1;const s=qe(),t=1335,r=21522,o=s.getBCHDigit(t);return At.getEncodedBits=function(a,i){const d=a.bit<<3|i;let l=d<<10;for(;s.getBCHDigit(l)-o>=0;)l^=t<<s.getBCHDigit(l)-o;return(d<<10|l)^r},At}var jt={},Nt,pn;function dd(){if(pn)return Nt;pn=1;const s=ze();function t(r){this.mode=s.NUMERIC,this.data=r.toString()}return t.getBitsLength=function(o){return 10*Math.floor(o/3)+(o%3?o%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(o){let n,a,i;for(n=0;n+3<=this.data.length;n+=3)a=this.data.substr(n,3),i=parseInt(a,10),o.put(i,10);const d=this.data.length-n;d>0&&(a=this.data.substr(n),i=parseInt(a,10),o.put(i,d*3+1))},Nt=t,Nt}var kt,fn;function ud(){if(fn)return kt;fn=1;const s=ze(),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 r(o){this.mode=s.ALPHANUMERIC,this.data=o}return r.getBitsLength=function(n){return 11*Math.floor(n/2)+6*(n%2)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){let a;for(a=0;a+2<=this.data.length;a+=2){let i=t.indexOf(this.data[a])*45;i+=t.indexOf(this.data[a+1]),n.put(i,11)}this.data.length%2&&n.put(t.indexOf(this.data[a]),6)},kt=r,kt}var St,gn;function hd(){if(gn)return St;gn=1;const s=ze();function t(r){this.mode=s.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return t.getBitsLength=function(o){return o*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){for(let o=0,n=this.data.length;o<n;o++)r.put(this.data[o],8)},St=t,St}var Ct,wn;function md(){if(wn)return Ct;wn=1;const s=ze(),t=qe();function r(o){this.mode=s.KANJI,this.data=o}return r.getBitsLength=function(n){return n*13},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(o){let n;for(n=0;n<this.data.length;n++){let a=t.toSJIS(this.data[n]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
|
|
2051
|
+
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},Ct=r,Ct}var Et={exports:{}},bn;function pd(){return bn||(bn=1,(function(s){var t={single_source_shortest_paths:function(r,o,n){var a={},i={};i[o]=0;var d=t.PriorityQueue.make();d.push(o,0);for(var l,h,m,u,f,w,b,g,N;!d.empty();){l=d.pop(),h=l.value,u=l.cost,f=r[h]||{};for(m in f)f.hasOwnProperty(m)&&(w=f[m],b=u+w,g=i[m],N=typeof i[m]>"u",(N||g>b)&&(i[m]=b,d.push(m,b),a[m]=h))}if(typeof n<"u"&&typeof i[n]>"u"){var A=["Could not find a path from ",o," to ",n,"."].join("");throw new Error(A)}return a},extract_shortest_path_from_predecessor_list:function(r,o){for(var n=[],a=o;a;)n.push(a),r[a],a=r[a];return n.reverse(),n},find_path:function(r,o,n){var a=t.single_source_shortest_paths(r,o,n);return t.extract_shortest_path_from_predecessor_list(a,n)},PriorityQueue:{make:function(r){var o=t.PriorityQueue,n={},a;r=r||{};for(a in o)o.hasOwnProperty(a)&&(n[a]=o[a]);return n.queue=[],n.sorter=r.sorter||o.default_sorter,n},default_sorter:function(r,o){return r.cost-o.cost},push:function(r,o){var n={value:r,cost:o};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=t})(Et)),Et.exports}var xn;function fd(){return xn||(xn=1,(function(s){const t=ze(),r=dd(),o=ud(),n=hd(),a=md(),i=Ko(),d=qe(),l=pd();function h(A){return unescape(encodeURIComponent(A)).length}function m(A,v,k){const S=[];let E;for(;(E=A.exec(k))!==null;)S.push({data:E[0],index:E.index,mode:v,length:E[0].length});return S}function u(A){const v=m(i.NUMERIC,t.NUMERIC,A),k=m(i.ALPHANUMERIC,t.ALPHANUMERIC,A);let S,E;return d.isKanjiModeEnabled()?(S=m(i.BYTE,t.BYTE,A),E=m(i.KANJI,t.KANJI,A)):(S=m(i.BYTE_KANJI,t.BYTE,A),E=[]),v.concat(k,S,E).sort(function(y,x){return y.index-x.index}).map(function(y){return{data:y.data,mode:y.mode,length:y.length}})}function f(A,v){switch(v){case t.NUMERIC:return r.getBitsLength(A);case t.ALPHANUMERIC:return o.getBitsLength(A);case t.KANJI:return a.getBitsLength(A);case t.BYTE:return n.getBitsLength(A)}}function w(A){return A.reduce(function(v,k){const S=v.length-1>=0?v[v.length-1]:null;return S&&S.mode===k.mode?(v[v.length-1].data+=k.data,v):(v.push(k),v)},[])}function b(A){const v=[];for(let k=0;k<A.length;k++){const S=A[k];switch(S.mode){case t.NUMERIC:v.push([S,{data:S.data,mode:t.ALPHANUMERIC,length:S.length},{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.ALPHANUMERIC:v.push([S,{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.KANJI:v.push([S,{data:S.data,mode:t.BYTE,length:h(S.data)}]);break;case t.BYTE:v.push([{data:S.data,mode:t.BYTE,length:h(S.data)}])}}return v}function g(A,v){const k={},S={start:{}};let E=["start"];for(let p=0;p<A.length;p++){const y=A[p],x=[];for(let j=0;j<y.length;j++){const L=y[j],C=""+p+j;x.push(C),k[C]={node:L,lastCount:0},S[C]={};for(let P=0;P<E.length;P++){const _=E[P];k[_]&&k[_].node.mode===L.mode?(S[_][C]=f(k[_].lastCount+L.length,L.mode)-f(k[_].lastCount,L.mode),k[_].lastCount+=L.length):(k[_]&&(k[_].lastCount=L.length),S[_][C]=f(L.length,L.mode)+4+t.getCharCountIndicator(L.mode,v))}}E=x}for(let p=0;p<E.length;p++)S[E[p]].end=0;return{map:S,table:k}}function N(A,v){let k;const S=t.getBestModeForData(A);if(k=t.from(v,S),k!==t.BYTE&&k.bit<S.bit)throw new Error('"'+A+'" cannot be encoded with mode '+t.toString(k)+`.
|
|
2052
|
+
Suggested mode is: `+t.toString(S));switch(k===t.KANJI&&!d.isKanjiModeEnabled()&&(k=t.BYTE),k){case t.NUMERIC:return new r(A);case t.ALPHANUMERIC:return new o(A);case t.KANJI:return new a(A);case t.BYTE:return new n(A)}}s.fromArray=function(v){return v.reduce(function(k,S){return typeof S=="string"?k.push(N(S,null)):S.data&&k.push(N(S.data,S.mode)),k},[])},s.fromString=function(v,k){const S=u(v,d.isKanjiModeEnabled()),E=b(S),p=g(E,k),y=l.find_path(p.map,"start","end"),x=[];for(let j=1;j<y.length-1;j++)x.push(p.table[y[j]].node);return s.fromArray(w(x))},s.rawSplit=function(v){return s.fromArray(u(v,d.isKanjiModeEnabled()))}})(jt)),jt}var yn;function gd(){if(yn)return dt;yn=1;const s=qe(),t=ar(),r=ed(),o=sd(),n=td(),a=rd(),i=nd(),d=Go(),l=id(),h=cd(),m=ld(),u=ze(),f=fd();function w(p,y){const x=p.size,j=a.getPositions(y);for(let L=0;L<j.length;L++){const C=j[L][0],P=j[L][1];for(let _=-1;_<=7;_++)if(!(C+_<=-1||x<=C+_))for(let R=-1;R<=7;R++)P+R<=-1||x<=P+R||(_>=0&&_<=6&&(R===0||R===6)||R>=0&&R<=6&&(_===0||_===6)||_>=2&&_<=4&&R>=2&&R<=4?p.set(C+_,P+R,!0,!0):p.set(C+_,P+R,!1,!0))}}function b(p){const y=p.size;for(let x=8;x<y-8;x++){const j=x%2===0;p.set(x,6,j,!0),p.set(6,x,j,!0)}}function g(p,y){const x=n.getPositions(y);for(let j=0;j<x.length;j++){const L=x[j][0],C=x[j][1];for(let P=-2;P<=2;P++)for(let _=-2;_<=2;_++)P===-2||P===2||_===-2||_===2||P===0&&_===0?p.set(L+P,C+_,!0,!0):p.set(L+P,C+_,!1,!0)}}function N(p,y){const x=p.size,j=h.getEncodedBits(y);let L,C,P;for(let _=0;_<18;_++)L=Math.floor(_/3),C=_%3+x-8-3,P=(j>>_&1)===1,p.set(L,C,P,!0),p.set(C,L,P,!0)}function A(p,y,x){const j=p.size,L=m.getEncodedBits(y,x);let C,P;for(C=0;C<15;C++)P=(L>>C&1)===1,C<6?p.set(C,8,P,!0):C<8?p.set(C+1,8,P,!0):p.set(j-15+C,8,P,!0),C<8?p.set(8,j-C-1,P,!0):C<9?p.set(8,15-C-1+1,P,!0):p.set(8,15-C-1,P,!0);p.set(j-8,8,1,!0)}function v(p,y){const x=p.size;let j=-1,L=x-1,C=7,P=0;for(let _=x-1;_>0;_-=2)for(_===6&&_--;;){for(let R=0;R<2;R++)if(!p.isReserved(L,_-R)){let T=!1;P<y.length&&(T=(y[P]>>>C&1)===1),p.set(L,_-R,T),C--,C===-1&&(P++,C=7)}if(L+=j,L<0||x<=L){L-=j,j=-j;break}}}function k(p,y,x){const j=new r;x.forEach(function(R){j.put(R.mode.bit,4),j.put(R.getLength(),u.getCharCountIndicator(R.mode,p)),R.write(j)});const L=s.getSymbolTotalCodewords(p),C=d.getTotalCodewordsCount(p,y),P=(L-C)*8;for(j.getLengthInBits()+4<=P&&j.put(0,4);j.getLengthInBits()%8!==0;)j.putBit(0);const _=(P-j.getLengthInBits())/8;for(let R=0;R<_;R++)j.put(R%2?17:236,8);return S(j,p,y)}function S(p,y,x){const j=s.getSymbolTotalCodewords(y),L=d.getTotalCodewordsCount(y,x),C=j-L,P=d.getBlocksCount(y,x),_=j%P,R=P-_,T=Math.floor(j/P),I=Math.floor(C/P),O=I+1,W=T-I,q=new l(W);let U=0;const F=new Array(P),V=new Array(P);let Y=0;const X=new Uint8Array(p.buffer);for(let se=0;se<P;se++){const ue=se<R?I:O;F[se]=X.slice(U,U+ue),V[se]=q.encode(F[se]),U+=ue,Y=Math.max(Y,ue)}const B=new Uint8Array(j);let z=0,$,H;for($=0;$<Y;$++)for(H=0;H<P;H++)$<F[H].length&&(B[z++]=F[H][$]);for($=0;$<W;$++)for(H=0;H<P;H++)B[z++]=V[H][$];return B}function E(p,y,x,j){let L;if(Array.isArray(p))L=f.fromArray(p);else if(typeof p=="string"){let T=y;if(!T){const I=f.rawSplit(p);T=h.getBestVersionForData(I,x)}L=f.fromString(p,T||40)}else throw new Error("Invalid data");const C=h.getBestVersionForData(L,x);if(!C)throw new Error("The amount of data is too big to be stored in a QR Code");if(!y)y=C;else if(y<C)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: `+C+`.
|
|
2055
|
-
`);const P=k(y,x,
|
|
2056
|
-
`;return typeof
|
|
2057
|
-
`);await navigator.clipboard.writeText(x)}},
|
|
2058
|
-
`))};return o&&!r?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(Q.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):n&&!r?e.jsxs("div",{className:`cedros-totp-settings ${s}`,children:[e.jsx(te.ErrorMessage,{error:n,onDismiss:c}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>a(),children:"Retry"})]}):h==="setup"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx(ar,{onSuccess:E,onCancel:()=>m("status")})}):h==="disable"?e.jsx("div",{className:`cedros-totp-settings ${s}`,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."}),k&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(X.PasswordInput,{label:"Password",placeholder:"Enter your password",value:u,onChange:A=>p(A.target.value),disabled:v,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:()=>{m("status"),p(""),S(null)},disabled:v,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:f,disabled:v||u.length===0,children:v?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):h==="regenerate"?g?e.jsx("div",{className:`cedros-totp-settings ${s}`,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:g.map((A,_)=>e.jsx("code",{className:"cedros-totp-backup-code",children:A},_))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:x,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:()=>{m("status"),j(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${s}`,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."}),k&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(X.OtpInput,{value:b,onChange:w,onComplete:y,disabled:v,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:()=>{m("status"),w(""),S(null)},disabled:v,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:y,disabled:v||b.length!==6,children:v?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${s}`,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 with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${r?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:r?.enabled?"Enabled":"Disabled"})]}),r?.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:r.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>m("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>m("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>m("setup"),children:"Enable two-factor authentication"})]})})}class hd{client;constructor(s,r,o,n){this.client=new M.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async changePassword(s){try{return await this.client.post("/auth/change-password",s)}catch(r){throw M.handleApiError(r,"Failed to change password")}}async updateProfile(s){try{return await this.client.patch("/auth/me",s)}catch(r){throw M.handleApiError(r,"Failed to update profile")}}}function dt(){const{config:t,authState:s,_internal:r}=M.useCedrosLogin(),[o,n]=d.useState(!1),[a,i]=d.useState(null),l=d.useMemo(()=>new hd(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),c=d.useCallback(()=>{i(null)},[]),h=d.useCallback(async u=>{if(s!=="authenticated")throw new Error("Must be authenticated to update profile");n(!0),i(null);try{return await l.updateProfile(u)}catch(p){const b=p instanceof Error?p:new Error("Failed to update profile");throw i(b),b}finally{n(!1)}},[s,l]),m=d.useCallback(async u=>{if(s!=="authenticated")throw new Error("Must be authenticated to change password");n(!0),i(null);try{await l.changePassword(u)}catch(p){const b=p instanceof Error?p:new Error("Failed to change password");throw i(b),b}finally{n(!1)}},[s,l]);return{isLoading:o,error:a,updateProfile:h,changePassword:m,clearError:c}}function Ho(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),l=d.useCallback(async()=>{o(!0),a(null);try{return await i.get("/referral",{credentials:"include"})}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[i]),c=d.useCallback(async()=>{o(!0),a(null);try{return(await i.post("/referral/regenerate",void 0,{credentials:"include"})).referralCode}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[i]);return{getReferral:l,regenerateCode:c,isLoading:r,error:n}}function md({onPasswordChange:t,onClose:s,className:r=""}){const{user:o,refreshUser:n}=D.useAuth(),{config:a,_internal:i}=M.useCedrosLogin(),{isLoading:l,error:c,changePassword:h,updateProfile:m,clearError:u}=dt(),[p,b]=d.useState("main"),[w,g]=d.useState(""),[j,v]=d.useState(""),[N,k]=d.useState(""),[S,E]=d.useState(null),[f,y]=d.useState(null),[x,A]=d.useState(!1),_=d.useRef(null),[C,P]=d.useState(o?.payoutWalletAddress??""),[L,R]=d.useState(!1),[T,B]=d.useState(!1),[F,W]=d.useState(null),O=d.useCallback(async()=>{const G=C.trim();if(G.length>0&&(G.length<32||G.length>44)){W("Invalid Solana address — must be 32–44 characters.");return}const ge=/^[1-9A-HJ-NP-Za-km-z]+$/;if(G.length>0&&!ge.test(G)){W("Invalid Solana address — contains non-base58 characters.");return}W(null),R(!0);try{await m({payoutWalletAddress:G||void 0}),await n(),B(!0),setTimeout(()=>B(!1),2e3)}catch(be){W(be instanceof Error?be.message:"Failed to save payout wallet")}finally{R(!1)}},[C,m,n]),{getReferral:I,regenerateCode:U,isLoading:z}=Ho(),[K,se]=d.useState(null),[$,Y]=d.useState(0),[V,H]=d.useState(!1),[ee,ue]=d.useState(!1);d.useEffect(()=>{I().then(G=>{se(G.referralCode),Y(G.referralCount),ue(G.directPayoutEnabled)}).catch(()=>{})},[]);const we=Oe.validatePassword(j),tt=j===N,Ie=w.length>0&&j.length>0&&N.length>0&&we.isValid&&tt,De=d.useCallback(async G=>{const ge=G.target.files?.[0];if(ge){E(null),A(!0);try{const be=new FormData;be.append("file",ge);const ut=i?.getAccessToken?.(),Ue={};ut&&(Ue.Authorization=`Bearer ${ut}`);const Ve=await fetch(`${a.serverUrl}/auth/upload/avatar`,{method:"POST",headers:Ue,body:be,credentials:"include"});if(!Ve.ok){const He=await Ve.json().catch(()=>null);throw new Error(He?.message||He?.error||`Upload failed (${Ve.status})`)}await n()}catch(be){E(be instanceof Error?be.message:"Failed to upload avatar")}finally{A(!1),_.current&&(_.current.value="")}}},[a.serverUrl,i,n]),$t=d.useCallback(async()=>{if(Ie){E(null),y(null);try{await h({currentPassword:w,newPassword:j}),g(""),v(""),k(""),y("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>{b("main"),y(null)},2e3)}catch(G){E(G instanceof Error?G.message:"Failed to change password")}}},[Ie,w,j,h,t]),st=d.useCallback(()=>{b("main"),g(""),v(""),k(""),E(null),u()},[u]),$e=()=>o?.name?o.name.split(" ").map(G=>G[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?";return p==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${r}`,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."}),(S||c)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:S||c?.message||""},onDismiss:()=>{E(null),u()}})}),f&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),f]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:w,onChange:G=>g(G.target.value),disabled:l,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"New password",placeholder:"Enter new password",value:j,onChange:G=>v(G.target.value),disabled:l,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:N,onChange:G=>k(G.target.value),disabled:l,error:N.length>0&&!tt?"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:st,disabled:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:$t,disabled:l||!Ie,children:l?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsxs("div",{className:"cedros-profile-avatar-container cedros-profile-avatar-container--clickable",onClick:()=>_.current?.click(),role:"button",tabIndex:0,onKeyDown:G=>{(G.key==="Enter"||G.key===" ")&&(G.preventDefault(),_.current?.click())},"aria-label":"Change profile picture",children:[x?e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:e.jsx(Q.LoadingSpinner,{size:"sm"})}):o?.picture?e.jsx("img",{src:o.picture,alt:o.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:$e()}),e.jsx("div",{className:"cedros-profile-avatar-overlay",children: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:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),e.jsx("circle",{cx:"12",cy:"13",r:"4"})]})}),e.jsx("input",{ref:_,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",onChange:De,className:"cedros-profile-avatar-input","aria-hidden":"true",tabIndex:-1})]}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:o?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:o?.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:o?.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:()=>b("change-password"),children:"Change"})]})]}),K&&e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Referral"}),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:"Your code"}),e.jsx("span",{className:"cedros-profile-row-value cedros-profile-row-value--mono",children:K})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{navigator.clipboard.writeText(K),H(!0),setTimeout(()=>H(!1),2e3)},children:V?"Copied":"Copy"})]}),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:"Referrals"}),e.jsx("span",{className:"cedros-profile-row-value",children:$})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:async()=>{try{const G=await U();se(G)}catch{}},disabled:z,children:z?"Regenerating...":"Regenerate"})]})]}),ee&&e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Payout wallet"}),e.jsx("p",{className:"cedros-profile-description",children:"Solana wallet address to receive direct referral payouts when enabled by the platform."}),e.jsxs("div",{className:"cedros-profile-row cedros-profile-row--column",children:[e.jsx("input",{type:"text",className:"cedros-input",placeholder:"Solana wallet address (base58)",value:C,onChange:G=>{P(G.target.value),W(null)},disabled:L,maxLength:44}),F&&e.jsx("span",{className:"cedros-profile-error-text",children:F}),T&&e.jsx("span",{className:"cedros-profile-success-text",children:"Saved."})]}),e.jsx("div",{className:"cedros-profile-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:O,disabled:L,children:L?"Saving...":"Save wallet"})})]}),s&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})})}class fd{client;constructor(s,r,o,n){this.client=new M.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(s){throw M.handleApiError(s,"Failed to list credentials")}}async unlinkCredential(s){try{await this.client.delete(`/credentials/${encodeURIComponent(s)}`)}catch(r){throw M.handleApiError(r,"Failed to unlink credential")}}}function ir(){const{config:t,authState:s,_internal:r}=M.useCedrosLogin(),[o,n]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),h=d.useMemo(()=>new fd(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),m=d.useCallback(()=>{c(null)},[]),u=d.useCallback(async()=>{if(s!=="authenticated"){n([]);return}i(!0),c(null);try{const b=await h.listCredentials();n(b)}catch(b){c(b)}finally{i(!1)}},[s,h]);d.useEffect(()=>{s==="authenticated"?u():n([])},[s,u]);const p=d.useCallback(async b=>{i(!0),c(null);try{await h.unlinkCredential(b),await u()}catch(w){throw c(w),w}finally{i(!1)}},[h,u]);return{credentials:o,isLoading:a,error:l,fetchCredentials:u,unlinkCredential:p,clearError:m}}function pd({onPasswordChange:t,onCancel:s,className:r=""}){const{isLoading:o,error:n,changePassword:a,clearError:i}=dt(),[l,c]=d.useState(""),[h,m]=d.useState(""),[u,p]=d.useState(""),[b,w]=d.useState(null),[g,j]=d.useState(null),v=Oe.validatePassword(h),N=h===u,k=l.length>0&&h.length>0&&u.length>0&&v.isValid&&N,S=d.useCallback(async()=>{if(k){w(null),j(null);try{await a({currentPassword:l,newPassword:h}),c(""),m(""),p(""),j("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>s(),2e3)}catch(f){w(f instanceof Error?f.message:"Failed to change password")}}},[k,l,h,a,t,s]),E=d.useCallback(()=>{w(null),i(),s()},[i,s]);return e.jsx("div",{className:`cedros-profile-settings ${r}`,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."}),(b||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:b||n?.message||""},onDismiss:()=>{w(null),i()}})}),g&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),g]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:l,onChange:f=>c(f.target.value),disabled:o,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"New password",placeholder:"Enter new password",value:h,onChange:f=>m(f.target.value),disabled:o,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(X.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:u,onChange:f=>p(f.target.value),disabled:o,error:u.length>0&&!N?"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:E,disabled:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:S,disabled:o||!k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function Qo({onPasswordChange:t,className:s=""}){const{user:r,refreshUser:o}=D.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:l}=dt(),{credentials:c}=ir(),{forgotPassword:h,isLoading:m,isSuccess:u,reset:p}=Ft(),b=c.some(A=>A.credentialType==="password"),[w,g]=d.useState("view"),[j,v]=d.useState(""),[N,k]=d.useState(null),S=()=>r?.name?r.name.split(" ").map(A=>A[0]).join("").toUpperCase().slice(0,2):r?.email?r.email[0].toUpperCase():"?",E=d.useCallback(()=>{v(r?.name||""),g("edit"),k(null)},[r?.name]),f=d.useCallback(async()=>{const A=j.trim();if(A){k(null);try{await i({name:A}),await o(),g("view")}catch(_){k(_ instanceof Error?_.message:"Failed to update name")}}},[j,i,o]),y=d.useCallback(()=>{g("view"),v(""),k(null),l()},[l]),x=d.useCallback(async()=>{if(r?.email){k(null);try{await h(r.email)}catch(A){k(A instanceof Error?A.message:"Failed to send password setup email")}}},[r?.email,h]);return w==="change-password"?e.jsx(pd,{onPasswordChange:t,onCancel:()=>g("view"),className:s}):e.jsx("div",{className:`cedros-profile-settings ${s}`,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:r?.picture?e.jsx("img",{src:r.picture,alt:r.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:S()})}),e.jsxs("div",{className:"cedros-profile-info",children:[w==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:j,onChange:A=>v(A.target.value),disabled:n,autoFocus:!0,onKeyDown:A=>{A.key==="Enter"&&f(),A.key==="Escape"&&y()}}),e.jsxs("div",{className:"cedros-profile-name-edit-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:f,disabled:n||!j.trim(),children:n?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,disabled:n,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:r?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:E,title:"Edit name","aria-label":"Edit name",children:e.jsx(gd,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:r?.email})]})]}),(N||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:N||a?.message||""},onDismiss:()=>{k(null),l()}})}),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:r?.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:b?"••••••••":"Not set"})]}),b?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{g("change-password"),k(null)},children:"Change"}):u?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:p,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:x,disabled:m,children:m?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function gd(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M16.474 5.408l2.118 2.117m-.756-3.982L12.109 9.27a2.118 2.118 0 00-.58 1.082L11 13l2.648-.53c.41-.082.786-.283 1.082-.579l5.727-5.727a1.853 1.853 0 10-2.621-2.621z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M19 15v3a2 2 0 01-2 2H6a2 2 0 01-2-2V7a2 2 0 012-2h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const Go={password:"Email & Password",oauth_google:"Google",oauth_apple:"Apple",solana:"Solana Wallet",webauthn_passkey:"Passkey",webauthn_security_key:"Security Key",totp:"Authenticator App (2FA)",sso_oidc:"Single Sign-On"};function Ko({onLinkGoogle:t,onLinkApple:s,onAddPasskey:r,onLinkSolana:o,className:n=""}){const{credentials:a,isLoading:i,error:l,unlinkCredential:c,clearError:h,fetchCredentials:m}=ir(),{registerPasskey:u,isSupported:p}=sr(),[b,w]=d.useState(null),[g,j]=d.useState(!1),v=d.useCallback(async()=>{if(r){r();return}j(!0);try{await u(),await m()}catch{}finally{j(!1)}},[r,u,m]),N=d.useCallback(async A=>{const _=A.label||Go[A.credentialType];if(window.confirm(`Remove "${_}" as a sign-in method? You won't be able to sign in with it anymore.`)){w(A.id);try{await c(A.id)}catch{}finally{w(null)}}},[c]),k=new Set(a.map(A=>A.credentialType)),S=t&&!k.has("oauth_google"),E=s&&!k.has("oauth_apple"),f=(r||p)&&!k.has("webauthn_passkey"),y=o&&!k.has("solana"),x=S||E||f||y;return i&&a.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[l&&e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:l.message},onDismiss:h}),a.length===0&&!i&&e.jsx("p",{className:"cedros-linked-accounts-empty",children:"No linked sign-in methods found."}),a.length>0&&e.jsx("ul",{className:"cedros-linked-credential-list",children:a.map(A=>e.jsx(wd,{credential:A,isUnlinking:b===A.id,onUnlink:N},A.id))}),x&&e.jsxs("div",{className:"cedros-linked-add",children:[e.jsx("p",{className:"cedros-linked-add-label",children:"Link a new sign-in method"}),e.jsxs("div",{className:"cedros-linked-add-buttons",children:[S&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(Yo,{})," Google"]}),E&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(Zo,{})," Apple"]}),f&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:v,disabled:g,children:g?e.jsx(Q.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(qs,{})," Passkey"]})}),y&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(Xo,{})," Solana"]})]})]})]})}function wd({credential:t,isUnlinking:s,onUnlink:r}){const o=t.label||Go[t.credentialType],n=bd[t.credentialType]||yd;return e.jsxs("li",{className:"cedros-linked-credential",children:[e.jsx("div",{className:"cedros-linked-credential__icon",children:e.jsx(n,{})}),e.jsxs("div",{className:"cedros-linked-credential__info",children:[e.jsx("span",{className:"cedros-linked-credential__name",children:o}),e.jsxs("span",{className:"cedros-linked-credential__meta",children:["Added ",jn(t.createdAt),t.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",jn(t.lastUsedAt)]}),t.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>r(t),disabled:s,title:t.isPrimary?"Cannot remove primary sign-in method":"Remove",children:s?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function jn(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n}m ago`:a<24?`${a}h ago`:i<30?`${i}d ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const bd={password:xd,oauth_google:Yo,oauth_apple:Zo,solana:Xo,webauthn_passkey:qs,webauthn_security_key:qs,totp:vd,sso_oidc:Ad};function yd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M12 8v4m0 4h.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function xd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M7 11V7a5 5 0 0110 0v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"currentColor"})]})}function Yo(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21.8 12.2c0-.7-.1-1.4-.2-2H12v3.8h5.5a4.7 4.7 0 01-2 3.1v2.5h3.3c1.9-1.7 3-4.3 3-7.4z",fill:"#4285F4"}),e.jsx("path",{d:"M12 22c2.7 0 5-.9 6.6-2.4l-3.3-2.5c-.9.6-2 1-3.3 1-2.5 0-4.7-1.7-5.4-4H3.2v2.6A10 10 0 0012 22z",fill:"#34A853"}),e.jsx("path",{d:"M6.6 14.1a6 6 0 010-4.2V7.3H3.2a10 10 0 000 9.4l3.4-2.6z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.9c1.4 0 2.7.5 3.7 1.4l2.8-2.8A10 10 0 0012 2 10 10 0 003.2 7.3l3.4 2.6C7.3 7.6 9.5 5.9 12 5.9z",fill:"#EA4335"})]})}function Zo(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C3.79 16.16 4.36 9.53 8.72 9.28c1.3.07 2.2.74 2.96.8.93-.2 1.82-.92 3.03-.83 1.47.12 2.57.72 3.28 1.83-3.02 1.8-2.3 5.75.5 6.86-.6 1.53-1.37 3.04-2.44 4.34zM12.03 9.2C11.88 7.17 13.5 5.5 15.4 5.35c.29 2.28-2.08 3.98-3.37 3.85z",fill:"currentColor"})})}function Xo(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M2 10h20",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"17",cy:"14",r:"1.5",fill:"currentColor"})]})}function qs(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"10",cy:"7",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M3 21v-2a7 7 0 017-7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M17 14v4m0 0v2m0-2h-2m2 0h2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function vd(){return e.jsxs("svg",{width:"20",height:"20",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("path",{d:"M9 12h6M12 9v6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Ad(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"})]})}class jd{client;constructor(s,r,o,n){this.client=new M.ApiClient({baseUrl:s,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(s){throw M.handleApiError(s,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(s){throw M.handleApiError(s,"Failed to revoke sessions")}}}function Jo(){const{config:t,authState:s,_internal:r}=M.useCedrosLogin(),[o,n]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),h=d.useMemo(()=>new jd(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),m=d.useCallback(async()=>{if(s!=="authenticated"){n([]);return}i(!0),c(null);try{const b=await h.listSessions();n(b)}catch(b){c(b)}finally{i(!1)}},[s,h]);d.useEffect(()=>{s==="authenticated"?m():n([])},[s,m]);const u=d.useCallback(async()=>{i(!0),c(null);try{const b=await h.revokeAllSessions();return await m(),b}catch(b){throw c(b),b}finally{i(!1)}},[h,m]),p=d.useMemo(()=>o.filter(b=>!b.isCurrent).length,[o]);return{sessions:o,isLoading:a,error:l,fetchSessions:m,revokeAllSessions:u,otherSessionCount:p}}const Nd={profile:"Profile",security:"Security",linked:"Linked Accounts"},kd=["profile","security","linked"];function Sd({defaultTab:t="profile",onClose:s,onPasswordChange:r,onTotpChange:o,onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:l,className:c=""}){const[h,m]=d.useState(t),{sessions:u,isLoading:p,error:b,revokeAllSessions:w}=Jo();return e.jsxs("div",{className:`cedros-account-settings ${c}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:kd.map(g=>e.jsx("button",{type:"button",role:"tab","aria-selected":h===g,className:`cedros-account-tab ${h===g?"cedros-account-tab-active":""}`,onClick:()=>m(g),children:Nd[g]},g))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[h==="profile"&&e.jsx(Qo,{onPasswordChange:r}),h==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Vo,{onStatusChange:o}),e.jsx(yo,{sessions:u,isLoading:p,error:b??void 0,onRevokeAll:async()=>{await w()}})]}),h==="linked"&&e.jsx(Ko,{onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:l})]}),s&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})}function Cd({onComplete:t,className:s}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${s??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(ar,{onSuccess:t})})]})}function Ed({onComplete:t,onSkip:s,className:r}){const{user:o}=D.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:l}=dt(),[c,h]=d.useState(o?.name??""),m=d.useCallback(async p=>{p.preventDefault(),l();const b=c.trim();if(!b){t?.();return}try{await i({name:b}),t?.()}catch{}},[c,i,l,t]),u=c.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${r??""}`,children:[e.jsxs("div",{className:"cedros-complete-account__header",children:[e.jsx("h2",{className:"cedros-complete-account__title",children:"Complete Your Profile"}),e.jsx("p",{className:"cedros-complete-account__description",children:"Please fill in your name to get started."})]}),e.jsxs("form",{onSubmit:m,className:"cedros-complete-account__form",children:[e.jsxs("div",{className:"cedros-complete-account__field",children:[e.jsx("label",{htmlFor:"cedros-complete-name",className:"cedros-complete-account__label",children:"Name"}),e.jsx("input",{id:"cedros-complete-name",type:"text",value:c,onChange:p=>h(p.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),a&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:a.message}),e.jsxs("div",{className:"cedros-complete-account__actions",children:[e.jsx("button",{type:"submit",className:"cedros-complete-account__button cedros-complete-account__button--primary",disabled:n||!u,children:n?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:s,disabled:n,children:"Skip"})]})]})]})}function ea(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),i=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),l=d.useCallback(async m=>await i.get(`/username/available?username=${encodeURIComponent(m)}`,{credentials:"include"}),[i]),c=d.useCallback(async()=>{try{return(await i.get("/username/available?username=",{credentials:"include"})).suggestion??null}catch{return null}},[i]),h=d.useCallback(async m=>{o(!0),a(null);try{await i.patch("/me",{username:m})}catch(u){const p=u instanceof Error?u:new Error(String(u));throw a(p),p}finally{o(!1)}},[i]);return{checkAvailability:l,getSuggestion:c,setUsername:h,isLoading:r,error:n}}function _d({onComplete:t,onSkip:s,className:r}){const{checkAvailability:o,getSuggestion:n,setUsername:a,isLoading:i,error:l}=ea(),[c,h]=d.useState(""),[m,u]=d.useState("idle"),[p,b]=d.useState(""),w=d.useRef(null),g=d.useRef(!0);d.useEffect(()=>(g.current=!0,n().then(k=>{g.current&&k&&(h(k),u("available"),b("Available"))}),()=>{g.current=!1}),[n]);const j=d.useCallback(k=>{const S=k.toLowerCase().replace(/[^a-z0-9_]/g,"");if(h(S),u("idle"),b(""),w.current&&clearTimeout(w.current),S.length<3){S.length>0&&(u("error"),b("At least 3 characters"));return}u("checking"),w.current=setTimeout(async()=>{try{const E=await o(S);if(!g.current)return;E.error?(u("error"),b(E.error)):E.available?(u("available"),b("Available")):(u("taken"),b("Already taken"),E.suggestion)}catch{if(!g.current)return;u("error"),b("Could not check availability")}},400)},[o]),v=d.useCallback(async k=>{if(k.preventDefault(),!(m!=="available"||!c.trim()))try{await a(c.trim()),t?.()}catch{}},[c,m,a,t]),N=m==="available"&&!i;return e.jsxs("div",{className:`cedros-choose-username ${r??""}`,children:[e.jsxs("div",{className:"cedros-choose-username__header",children:[e.jsx("h2",{className:"cedros-choose-username__title",children:"Choose a Username"}),e.jsx("p",{className:"cedros-choose-username__description",children:"Pick a unique handle for your account."})]}),e.jsxs("form",{onSubmit:v,className:"cedros-choose-username__form",children:[e.jsxs("div",{className:"cedros-choose-username__field",children:[e.jsx("label",{htmlFor:"cedros-choose-username",className:"cedros-choose-username__label",children:"Username"}),e.jsxs("div",{className:"cedros-choose-username__input-wrapper",children:[e.jsx("span",{className:"cedros-choose-username__prefix",children:"@"}),e.jsx("input",{id:"cedros-choose-username",type:"text",value:c,onChange:k=>j(k.target.value),placeholder:"swift_falcon_42",className:"cedros-choose-username__input",maxLength:30,autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),p&&e.jsx("span",{className:`cedros-choose-username__status cedros-choose-username__status--${m}`,role:m==="error"||m==="taken"?"alert":void 0,children:m==="checking"?"Checking...":p})]}),l&&e.jsx("div",{className:"cedros-choose-username__error",role:"alert",children:l.message}),e.jsxs("div",{className:"cedros-choose-username__actions",children:[e.jsx("button",{type:"submit",className:"cedros-choose-username__button cedros-choose-username__button--primary",disabled:!N,children:i?"Saving...":"Continue"}),e.jsx("button",{type:"button",className:"cedros-choose-username__button cedros-choose-username__button--secondary",onClick:s,disabled:i,children:"Skip"})]})]})]})}function ta(){const t=M.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useMemo(()=>t?new M.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),i=d.useCallback(()=>{n(null)},[]),l=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(w)||w<=0){const g=new Error(`Invalid deposit amount: ${w}. Must be a positive integer (lamports).`);throw n(g.message),g}r(!0),n(null);try{return await a.post("/deposit",{amount_lamports:w})}catch(g){const j=M.handleApiError(g,"Failed to execute deposit");throw n(j.message),j}finally{r(!1)}},[a]),c=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");return await a.get(`/deposit/status/${encodeURIComponent(w)}`)},[a]),h=d.useCallback(async()=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/deposit/config")}catch(w){const g=M.handleApiError(w,"Failed to get deposit config");throw n(g.message),g}finally{r(!1)}},[a]),m=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=new URLSearchParams;w?.limit!==void 0&&g.set("limit",String(w.limit)),w?.offset!==void 0&&g.set("offset",String(w.offset));const j=g.toString(),v=j?`/deposits?${j}`:"/deposits";return await a.get(v)}catch(g){const j=M.handleApiError(g,"Failed to list deposits");throw n(j.message),j}finally{r(!1)}},[a]),u=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=new URLSearchParams({input_mint:w.inputMint,amount:String(w.amount),taker:w.taker});return await a.get(`/deposit/quote?${g}`)}catch(g){const j=M.handleApiError(g,"Failed to get deposit quote");throw n(j.message),j}finally{r(!1)}},[a]),p=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/public",w)}catch(g){const j=M.handleApiError(g,"Failed to execute public deposit");throw n(j.message),j}finally{r(!1)}},[a]),b=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/micro",w)}catch(g){const j=M.handleApiError(g,"Failed to execute micro deposit");throw n(j.message),j}finally{r(!1)}},[a]);return{deposit:l,getQuote:u,publicDeposit:p,microDeposit:b,getStatus:c,getConfig:h,listDeposits:m,isLoading:s,error:o,clearError:i}}function cr({tokens:t,selectedToken:s,onSelect:r,openSignal:o,placeholder:n="Select token",disabled:a=!1,className:i="",searchable:l=!0}){const[c,h]=d.useState(!1),[m,u]=d.useState(""),p=d.useRef(null),b=d.useRef(null),w=d.useMemo(()=>{if(!m.trim())return t;const N=m.toLowerCase();return t.filter(k=>k.symbol.toLowerCase().includes(N)||k.name.toLowerCase().includes(N)||k.mint.toLowerCase().includes(N))},[t,m]);d.useEffect(()=>{const N=k=>{p.current&&!p.current.contains(k.target)&&(h(!1),u(""))};if(c)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[c]),d.useEffect(()=>{c&&l&&b.current&&b.current.focus()},[c,l]),d.useEffect(()=>{o===void 0||a||(h(!0),u(""))},[o,a]);const g=d.useCallback(()=>{a||(h(N=>!N),c&&u(""))},[a,c]),j=d.useCallback(N=>{r(N),h(!1),u("")},[r]),v=d.useCallback(N=>{N.key==="Escape"?(h(!1),u("")):N.key==="Enter"&&w.length===1&&j(w[0])},[w,j]);return e.jsxs("div",{ref:p,className:`cedros-token-selector ${c?"cedros-token-selector-open":""} ${a?"cedros-token-selector-disabled":""} ${i}`,onKeyDown:v,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:g,disabled:a,"aria-haspopup":"listbox","aria-expanded":c,children:[s?e.jsxs("span",{className:"cedros-token-selector-selected",children:[s.logoUrl&&e.jsx("img",{src:s.logoUrl,alt:s.symbol,className:"cedros-token-icon",onError:N=>{N.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:s.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:n}),e.jsx("span",{className:"cedros-token-selector-arrow",children:c?"▲":"▼"})]}),c&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[l&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:b,type:"text",value:m,onChange:N=>u(N.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:w.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:w.map(N=>e.jsxs("button",{type:"button",className:`cedros-token-option ${s?.mint===N.mint?"cedros-token-option-selected":""}`,onClick:()=>j(N),role:"option","aria-selected":s?.mint===N.mint,children:[N.logoUrl&&e.jsx("img",{src:N.logoUrl,alt:N.symbol,className:"cedros-token-icon",onError:k=>{k.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:N.symbol}),e.jsx("span",{className:"cedros-token-name",children:N.name})]}),s?.mint===N.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},N.mint))})})]})]})}function Ot(t,s){return s.privateDepositsEnabled&&t>=s.privateMinUsd?"private":t>=s.publicMinUsd?"public":"sol_micro"}const lr="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=",Ld=1e4,It=1e3,sa=3;function Pd(t){return Number.isFinite(t)?`$${Math.round(t)}`:"$0"}function Rd(t,s){switch(t){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 ${Pd(s.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function dr(t,s,r){return Math.min(Math.max(t,s),r)}function Td(t,s){if(s<=0)return 0;const r=dr(t/s,0,1);return Math.round(Math.pow(r,1/sa)*It)}function Md(t,s){const r=dr(t/It,0,1);return s*Math.pow(r,sa)}function ra(t){return t<10?.01:t<100?1:t<500?5:t<1e3?10:t<5e3?25:50}function Bd(t){return t<1?2:0}function Nn(t){const s=ra(t),r=Math.round(t/s)*s,o=Bd(s);return Number(r.toFixed(o))}function ur({config:t,valueUsd:s,onChange:r,maxUsd:o=Ld,disabled:n=!1,className:a=""}){const i=dr(Number.isFinite(s)?s:0,0,o),l=d.useMemo(()=>Ot(i,t),[i,t]),c=Rd(l,t),h=Td(i,o),m=h/It*100;return e.jsxs("div",{className:`cedros-tiered-slider ${a}`,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:i||"",onChange:u=>r(Nn(Math.max(0,Math.min(parseFloat(u.target.value)||0,o)))),placeholder:"Enter amount",disabled:n,min:0,step:ra(i),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-${l}`,children:[l==="sol_micro"&&e.jsx("img",{src:lr,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),c.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:c.detail})]})]}),e.jsx("input",{type:"range",min:0,max:It,step:1,value:h,onChange:u=>r(Nn(Md(parseFloat(u.target.value),o))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${m}%, var(--cedros-border) ${m}%, var(--cedros-border) 100%)`},disabled:n,"aria-label":"Deposit amount slider"}),c.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:c.note})]})}const Id="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=",Dd="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==",Ud="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",Fd="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==",Wd="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==",Od="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==",qd="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",zd="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",$d="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";function na(t){const s=t.toUpperCase();return qt.find(o=>o.symbol===s)?.decimals??6}function Vd(t,s){const r=t.toUpperCase(),n=qt.find(a=>a.symbol===r)?.decimals??s;return n===void 0?2:r==="SOL"?4:n===6&&r!=="SOL"?2:n>6?6:n}const qt=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:lr},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Od},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:$d},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:Ud},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:zd},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Wd},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:qd},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Dd},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Id},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Fd}];function Hd(t){return t.companyFeePercent>0||t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap"||t.feePolicy==="user_pays_privacy"}function Qd(t,s,r){const{feePolicy:o,privacyFeePercent:n,swapFeePercent:a,companyFeePercent:i}=t;let l=i;return r||(o==="user_pays_all"?(l+=a,s&&(l+=n)):o==="user_pays_privacy"&&s?l+=n:o==="user_pays_swap"&&(l+=a)),l}const St=1e9,Xe={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:lr},Je={mint:"other",symbol:"OTHER",name:"Other",decimals:6},oa=1e4;function Gd(t,s){const r=s<t.publicMinUsd,o=s>=t.privateMinUsd,n=[],a=!r&&o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(t.privacyFeeFixedLamports>0||t.privacyFeePercent>0),i=!r&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(t.swapFeeFixedLamports>0||t.swapFeePercent>0),l=t.companyFeeFixedLamports>0||t.companyFeePercent>0;if(a){const c=t.privacyFeeFixedLamports/St,h=t.privacyFeePercent,m=c*t.solPriceUsd,u=s*(h/100);n.push({label:"Privacy",solAmount:c,percent:h,usdAmount:m+u})}if(i){const c=t.swapFeeFixedLamports/St,h=t.swapFeePercent,m=c*t.solPriceUsd,u=s*(h/100);n.push({label:"Swap",solAmount:c,percent:h,usdAmount:m+u})}if(l){const c=t.companyFeeFixedLamports/St,h=t.companyFeePercent,m=c*t.solPriceUsd,u=s*(h/100);n.push({label:"Service",solAmount:c,percent:h,usdAmount:m+u})}return n}function aa(t,s,r){const o=Gd(t,s),n=r===0?0:r<.01?.01:r;if(o.length===0)return r===0?"No fees":`Total: $${n.toFixed(2)}`;const a=o.reduce((w,g)=>w+g.solAmount,0),i=o.reduce((w,g)=>w+g.percent,0),l={fee:7,sol:8,rate:7,usd:8},c=w=>{const g=w.label.padEnd(l.fee),j=w.solAmount.toFixed(4).padStart(6).padEnd(l.sol),v=(w.percent.toFixed(2)+"%").padStart(5).padEnd(l.rate),k=("$"+(w.usdAmount===0?0:Math.max(w.usdAmount,.01)).toFixed(2)).padEnd(l.usd);return`${g} │ ${j} │ ${v} │ ${k}`},h=`${"Fee".padEnd(l.fee)} │ ${"SOL".padEnd(l.sol)} │ ${"+ Rate".padEnd(l.rate)} │ ${"= Total".padEnd(l.usd)}`,m=`${"─".repeat(l.fee)}─┼─${"─".repeat(l.sol)}─┼─${"─".repeat(l.rate)}─┼─${"─".repeat(l.usd)}`,u=("$"+n.toFixed(2)).padEnd(l.usd),p=`${"TOTAL".padEnd(l.fee)} │ ${a.toFixed(4).padStart(6).padEnd(l.sol)} │ ${(i.toFixed(2)+"%").padStart(5).padEnd(l.rate)} │ ${u}`;return[h,m,...o.map(c),m,p].join(`
|
|
2059
|
-
`)}function Kd(t){const s=[],r=t.privacyFeeFixedLamports>0||t.privacyFeePercent>0,o=t.swapFeeFixedLamports>0||t.swapFeePercent>0,n=t.companyFeeFixedLamports>0||t.companyFeePercent>0;return r&&s.push("Privacy Cash fee"),o&&s.push("swap fee"),n&&s.push("company service fee"),s.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function zt(t,s){if(s<=0)return 0;const r=s<t.publicMinUsd,o=s>=t.privateMinUsd,n=Qd(t,o,r);let a=t.companyFeeFixedLamports;r||(o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(a+=t.privacyFeeFixedLamports),(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(a+=t.swapFeeFixedLamports));const i=a/St*t.solPriceUsd,l=s*(n/100);return i+l}function ia(t,s,r){return t==="sol"?"SOL":t==="single-token"?s.symbol:r.some(n=>n.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function kn(t){return t.map(s=>s.trim()).filter(Boolean)}const Yd=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function hr(t,s,r){if(Yd.has(t.symbol))return 1;const o=s.tokenPrices?.[t.symbol];if(o&&o>0)return o;if(t.symbol==="SOL")return s.solPriceUsd||null;const n=r?.[t.symbol];return n&&n>0?n:null}function ca(t,s){return t.toFixed(Vd(s))}function Zd({config:t,currencyMode:s,depositMethod:r,tokens:o=[],defaultToken:n,minAmount:a,maxAmount:i=1e4,onSuccess:l,onError:c,onCancel:h,onUnlockRequired:m,onAuthorize:u,className:p="",showStepIndicator:b=!0,pollInterval:w=5e3,demoMode:g=!1,demoAutoConfirmMs:j,tokenPriceUsd:v,showExplainer:N=!1,siteName:k,explainerConfig:S}){const{deposit:E,getStatus:f,error:y,clearError:x}=ta(),A=D.useWallet(),_=kn(t.quickActionTokens),C=kn(t.customTokenSymbols),P=d.useMemo(()=>{const q=t.customTokens??[];if(q.length===0)return o;const Z=new Set(o.map(re=>re.symbol)),J=[...o];for(const re of q)Z.has(re.symbol)||(J.push({mint:re.mint,symbol:re.symbol,name:re.symbol,decimals:re.decimals,logoUrl:re.logoUrl}),Z.add(re.symbol));return J},[o,t.customTokens]),L=d.useMemo(()=>{if(C.length===0)return P;const q=P.filter(Z=>C.includes(Z.symbol));return q.length>0?q:P},[P,C]),R=t.privateDepositsEnabled,T=r?r==="sign"&&!R?"receive":r:R&&A.hasExternalWallet?"sign":"receive",B=_[0]?P.find(q=>q.symbol===_[0]):void 0,F=s==="sol"?Xe:s==="single-token"?B??P.find(q=>q.symbol==="USDC")??P[0]??Xe:n??B??P.find(q=>q.symbol==="USDC")??P.find(q=>q.symbol!=="SOL")??P[0]??Xe,W=d.useCallback(()=>N?"explainer":"unlock",[N]),[O,I]=d.useState(W),[U,z]=d.useState(F),[K,se]=d.useState(""),[$,Y]=d.useState(null),[V,H]=d.useState(null),[ee,ue]=d.useState(null),[we,tt]=d.useState(null),[Ie,De]=d.useState(!1),[$t,st]=d.useState(!1),[$e,G]=d.useState(null),ge=d.useRef(null);d.useEffect(()=>()=>{ge.current&&clearTimeout(ge.current)},[]),d.useEffect(()=>{I(W()),z(F),se(""),Y(null),H(null),ue(null),tt(null),De(!1),st(!1),G(null),x()},[s,T,F,x]);const be=a??t.privateMinSol,ut=i,Ue=parseFloat(K),Ve=A.status==="enrolled_locked"||A.status==="enrolled_unlocked"||A.status==="unlocked",He=Ve&&A.isUnlocked,Vt=Ve&&!A.isUnlocked,gr=d.useCallback(()=>{let J=T==="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 N&&(J=[{key:"explainer",label:"Info"},...J]),J},[T,N])(),ma=gr.findIndex(q=>q.key===O),wr=d.useCallback(q=>{z(q)},[]),fa=d.useCallback(async q=>{if(!u){I(T==="sign"?"confirm":"show-address");return}st(!0),H(null);try{const J=await u(q,T==="sign"?Ue:null,U);ue(J.sessionId),tt(J.depositAddress),I(T==="sign"?"confirm":"show-address")}catch(Z){const J=Z instanceof Error?Z:new Error("Authorization failed");H(J.message)}finally{st(!1)}},[u,T,Ue,U]),pa=d.useCallback(async(q,Z)=>{x(),H(null),I("signing");const J=q??Ue,re=Z??U;if(!g){if(Vt&&m){m(),I("confirm");return}if(!He){H("Wallet not ready"),I("error");return}}try{const pe=Math.round(J*Math.pow(10,re.decimals));if(g){await new Promise(Qt=>setTimeout(Qt,1500));const ye={token:s==="sol"?null:re,amount:J,amountSmallestUnit:pe,txSignature:`demo-tx-${Date.now()}`,sessionId:ee||`demo-session-${Date.now()}`,response:{sessionId:ee||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:pe,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};Y(ye),I("success"),l?.(ye);return}const Ce=await E(pe),rt={token:s==="sol"?null:re,amount:J,amountSmallestUnit:pe,txSignature:Ce.txSignature,sessionId:Ce.sessionId,response:Ce,method:"sign"};Y(rt),I("success"),l?.(rt)}catch(pe){const Ce=pe instanceof Error?pe:new Error("Deposit failed");H(Ce.message),I("error"),c?.(Ce)}},[E,Ue,U,s,g,ee,He,Vt,m,l,c,x]),ga=d.useCallback(()=>{I("waiting")},[]),Ht=d.useCallback(async()=>{const q=we||A.solanaPubkey;if(q){ge.current&&clearTimeout(ge.current);try{await navigator.clipboard.writeText(q),De(!0),ge.current=setTimeout(()=>De(!1),2e3)}catch{const Z=document.createElement("textarea");Z.value=q,document.body.appendChild(Z),Z.select(),document.execCommand("copy"),document.body.removeChild(Z),De(!0),ge.current=setTimeout(()=>De(!1),2e3)}}},[we,A.solanaPubkey]);d.useEffect(()=>{if(!(O==="confirm"||O==="show-address"||O==="waiting")||!ee||g)return;let Z=!1,J=0,re=0;const pe=360,Ce=5,rt=async()=>{if(!(Z||J>=pe)){J++;try{const ye=await f(ee);if(re=0,ye.status==="completed"||ye.status==="detected"){const Qt=ye.amountLamports?ye.amountLamports/Math.pow(10,U.decimals):0,ba=ye.amountLamports||0,br={token:s==="sol"?null:U,amount:Qt,amountSmallestUnit:ba,txSignature:ye.txSignature||"",sessionId:ee,response:ye,method:"receive",depositAddress:A.solanaPubkey??void 0};Y(br),I("success"),l?.(br);return}}catch{if(re++,re>=Ce){H("Unable to check deposit status. Please check your connection and try again.");return}}Z||setTimeout(rt,w)}};return rt(),()=>{Z=!0}},[O,ee,g,f,U,s,A.solanaPubkey,l,w]),d.useEffect(()=>{if(!g||!j||O!=="waiting"||T!=="receive"||!we)return;const q=window.setTimeout(()=>{const Z=$e??t.privateMinUsd,J=U.symbol==="SOL"&&t.solPriceUsd>0?Z/t.solPriceUsd:Z,re=Math.round(J*Math.pow(10,U.decimals)),pe={token:s==="sol"?null:U,amount:J,amountSmallestUnit:re,txSignature:`demo-tx-${Date.now()}`,sessionId:ee||`demo-session-${Date.now()}`,response:{sessionId:ee||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:re,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:we??void 0};Y(pe),I("success"),l?.(pe)},j);return()=>window.clearTimeout(q)},[g,j,O,T,we,$e,t,U,s,ee,l]);const wa=d.useCallback(()=>{I(W()),se(""),Y(null),H(null),x()},[W,x]);return t.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${p}`,children:[b&&O!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:gr.map((q,Z)=>{const J=ma>=Z,re=q.key===O;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${J?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${J?"active":""} ${re?"current":""}`,children:Z+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${J?"active":""}`,children:q.label})]},q.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[O==="explainer"&&e.jsx(Xd,{siteName:k,config:S,depositConfig:t,currencyMode:s,token:U,tokens:L,onContinue:()=>I("unlock"),onCancel:h}),O==="unlock"&&e.jsx(Jd,{token:U,tokens:L,currencyMode:s,depositMethod:T,isAuthorizing:$t,error:V,onAuthorize:fa,onBack:N?()=>I("explainer"):void 0,onCancel:h}),O==="confirm"&&T==="sign"&&e.jsx(eu,{token:U,tokens:P,quickActionSymbols:_,customTokenSymbols:C,currencyMode:s,minAmount:be,maxAmount:ut,depositAddress:we||A.solanaPubkey,walletReady:He||g,needsUnlock:Vt&&!g,copied:Ie,isListening:!!ee&&!g,config:t,onCopy:Ht,onTokenSelect:wr,onUnlockRequired:m,onConfirm:(q,Z)=>pa(q,Z),onBack:()=>I("unlock"),onCancel:h}),O==="signing"&&e.jsx(tu,{depositAddress:A.solanaPubkey}),O==="show-address"&&e.jsx(su,{token:U,tokens:P,quickActionSymbols:_,customTokenSymbols:C,tokenPriceUsd:v,currencyMode:s,depositAddress:we||A.solanaPubkey,copied:Ie,isListening:!!ee&&!g,config:t,onCopy:Ht,onTokenSelect:wr,onAmountChange:G,onSent:ga,onBack:()=>I("unlock"),onCancel:h}),O==="waiting"&&e.jsx(ru,{token:U,depositAddress:we||A.solanaPubkey,copied:Ie,feeLine:$e?(()=>{const q=zt(t,$e);return q===0?"No fees":`Fees: $${Math.max(q,.01).toFixed(2)} total`})():"Fees: calculated after deposit",onCopy:Ht}),O==="success"&&$&&e.jsx(nu,{result:$,config:t,onNewDeposit:wa}),O==="error"&&e.jsx(ou,{error:V||y||"An error occurred",onRetry:()=>I("confirm"),onCancel:h})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${p}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function Xd({siteName:t,config:s,depositConfig:r,currencyMode:o,token:n,tokens:a,onContinue:i,onCancel:l}){const c=s?.title??"How Deposits Work",h=s?.exchangeName??"Coinbase",m=zs.sanitizeExternalUrl(s?.exchangeUrl)??"https://www.coinbase.com",u=s?.showExchangeSuggestion!==!1,p=ia(o,n,a),b=t?`${t} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",w=s?.body??b,g=Hd(r),j=Kd(r);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:c}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:w}),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:g?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:j})]})]})]}),u&&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 ",p," using your credit card at"," ",e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:h}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[l&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:i,children:"Continue"})]})]})}function Jd({token:t,tokens:s,currencyMode:r,depositMethod:o,isAuthorizing:n,error:a,onAuthorize:i,onBack:l}){const[c,h]=d.useState(""),m=ia(r,t,s),u=p=>{p.preventDefault(),c.trim()&&(i(c),h(""))};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:o==="sign"?r==="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 ${m} deposit. This allows us to process your withdrawal when the privacy period ends.`:r==="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 ${m} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:u,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:c,onChange:p=>h(p.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:n,autoComplete:"current-password"})]}),a&&e.jsx("p",{className:"cedros-deposit-flow-error",children:a}),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:l,disabled:n,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!c.trim()||n,children:n?"Authorizing...":"Continue"})]})]})]})}function eu({token:t,tokens:s,quickActionSymbols:r,customTokenSymbols:o,currencyMode:n,minAmount:a,maxAmount:i,depositAddress:l,walletReady:c,needsUnlock:h,copied:m,isListening:u,config:p,onCopy:b,onTokenSelect:w,onUnlockRequired:g,onConfirm:j,onBack:v}){const[N,k]=d.useState(p.privateMinUsd),[S,E]=d.useState(!1),[f,y]=d.useState(!1),[x,A]=d.useState(0),[_,C]=d.useState(null),L=Ot(N,p)==="sol_micro",R=t.symbol===Je.symbol,T=d.useMemo(()=>{const V=o.length===0?s:s.filter(ue=>o.includes(ue.symbol)),H=V.length>0?V:s;return H.some(ue=>ue.symbol===Je.symbol)?H:[...H,Je]},[s,o]),B=zt(p,N),F=B===0?0:B<.01?.01:B,W=R?"Fees: calculated after deposit":B===0?"No fees":`Fees: $${F.toFixed(2)} total`,O=R?"":aa(p,N,B),I=hr(L?Xe:t,p),U=I?N/I:t.symbol==="SOL"&&p.solPriceUsd>0?N/p.solPriceUsd:null,z=U!=null?ca(U,L?"SOL":t.symbol):null,se=N-B<=0&&N>0,$=!R&&N>0&&!se&&U!=null&&U>=a&&U<=i;d.useEffect(()=>{if(n==="multi-token")if(L&&t.symbol!=="SOL"){C(t);const V=s.find(H=>H.symbol==="SOL");V&&w(V)}else!L&&_&&t.symbol==="SOL"&&(w(_),C(null))},[L,t.symbol,n,s,w,_,t]);const Y=()=>{$&&U!=null&&j(U,t)};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."}),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:[r.map(V=>{const H=s.find(ue=>ue.symbol===V),ee=t.symbol===V;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${ee?"is-active":""}`,onClick:()=>{H&&(E(!1),w(H))},disabled:!H,children:[H?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:H.logoUrl,alt:`${V} logo`}),V]},V)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${S?"is-active":""}`,onClick:()=>{E(!0),A(V=>V+1)},children:"Custom"})]}),S&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(cr,{tokens:T,selectedToken:t,onSelect:w,openSignal:x})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(ur,{config:p,valueUsd:N,onChange:k,maxUsd:oa})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:R?"Sign to send tokens to this address":`Sign to send ${z??"--"} ${L?"SOL":t.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:l||"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:b,title:"Copy address",disabled:!l,children:m?"✓":"⧉"}),l&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${l}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),m&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),se&&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:[W,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${f?"is-open":""}`,"data-tooltip":O,"aria-label":`Fee breakdown: ${O.replaceAll(`
|
|
2060
|
-
`,", ")}`,"aria-expanded":
|
|
2061
|
-
`,", ")}`,"aria-expanded":k,onClick:U=>{U.stopPropagation(),S(z=>!z)},onBlur:()=>S(!1),onKeyDown:U=>{U.key==="Escape"&&S(!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)."})]})]}),c&&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:w,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:b,disabled:!F,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 ru({token:t,depositAddress:s,copied:r,feeLine:o,onCopy:n}){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:t.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."}),s&&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:[s.slice(0,6),"...",s.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:n,title:"Copy address",children:r?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${s}`,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:o})]})]})]})]})}function nu({result:t,config:s,onNewDeposit:r}){const o=t.token??Xe,n=hr(o,s),a=n?t.amount*n:t.amount,i=zt(s,a),l=Math.max(a-i,0),c=i===0?0:i<.01?.01:i;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 ",t.amount.toLocaleString()," ",o.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[t.txSignature&&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/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[t.txSignature.slice(0,8),"...",t.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${t.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:["$",a.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:["-$",c.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:["+$",l.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:r,children:"Make Another Deposit"})})]})}function ou({error:t,onRetry:s,onCancel:r}){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:t}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[r&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:s,children:"Try Again"})]})]})}function mr(){const t=M.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),a=d.useMemo(()=>t?new M.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),i=d.useCallback(()=>{n(null)},[]),l=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/credits/balance/sol")}catch(m){const u=M.handleApiError(m,"Failed to fetch credit balance");throw n(u.message),u}finally{r(!1)}},[a]),c=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return(await a.get("/credits/balance")).balances}catch(m){const u=M.handleApiError(m,"Failed to fetch credit balances");throw n(u.message),u}finally{r(!1)}},[a]),h=d.useCallback(async m=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{const u=new URLSearchParams;m?.currency&&u.set("currency",m.currency),m?.limit!==void 0&&u.set("limit",m.limit.toString()),m?.offset!==void 0&&u.set("offset",m.offset.toString());const p=u.toString(),b=p?`/credits/history?${p}`:"/credits/history";return await a.get(b)}catch(u){const p=M.handleApiError(u,"Failed to fetch transaction history");throw n(p.message),p}finally{r(!1)}},[a]);return{getBalance:l,getAllBalances:c,getHistory:h,isLoading:s,error:o,clearError:i}}function au({showAllCurrencies:t=!1,refreshInterval:s=0,compact:r=!1,className:o="",onLoad:n}){const{getBalance:a,getAllBalances:i,isLoading:l,error:c,clearError:h}=mr(),[m,u]=d.useState([]),[p,b]=d.useState(null),w=d.useCallback(async()=>{try{if(t){const g=await i();u(g),n?.(g)}else{const g=await a();u([g]),n?.([g])}b(null)}catch(g){b(g instanceof Error?g.message:"Failed to load balance")}},[t,a,i,n]);if(d.useEffect(()=>{w()},[w]),d.useEffect(()=>{if(s<=0)return;const g=setInterval(w,s);return()=>clearInterval(g)},[s,w]),p||c)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${o}`,children:[e.jsx("p",{className:"cedros-credit-error",children:p||c}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{h(),b(null),w()},children:"Retry"})]});if(l&&m.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${o}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(r){const g=m[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${o}`,children:[g?e.jsx("span",{className:"cedros-credit-value",title:`${g.balanceLamports} lamports`,children:g.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),l&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${o}`,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:w,disabled:l,title:"Refresh balance",children:l?"...":"↻"})]}),m.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:m.map(g=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:g.currency}),e.jsx("span",{className:"cedros-credit-amount",children:g.display})]},g.currency))})]})}const _s=[{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 iu(t,s){const r=t<0,o=Math.abs(t),n=na(s),a=o/Math.pow(10,n),i=r?"-":"+";return s.toUpperCase()==="SOL"?`${i}${a.toFixed(4)} SOL`:`${i}$${a.toFixed(2)}`}function cu(t){const s=new Date(t),r=new Date,o=r.getTime()-s.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==r.getFullYear()?"numeric":void 0})}function lu(t){return t?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[t.toLowerCase()]||t:"Transaction"}function du(t,s){const r=(t||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":s?"+":"−"}function uu({defaultTab:t="all",pageSize:s=10,refreshInterval:r=0,className:o="",onLoad:n,onTransactionClick:a}){const{getHistory:i,isLoading:l,error:c,clearError:h}=mr(),[m,u]=d.useState(t),[p,b]=d.useState([]),[w,g]=d.useState(0),[j,v]=d.useState(0),[N,k]=d.useState(null),S=_s.find(L=>L.key===m)||_s[0],E=d.useMemo(()=>S.txTypes===null?p:p.filter(L=>{const R=L.txType||"";return S.txTypes.some(T=>R.toLowerCase()===T.toLowerCase())}),[p,S.txTypes]),f=d.useCallback(async()=>{try{const L=await i({limit:s*3,offset:j});b(L.transactions),g(L.total),n?.(L),k(null)}catch(L){k(L instanceof Error?L.message:"Failed to load history")}},[s,j,i,n]);d.useEffect(()=>{v(0)},[m]),d.useEffect(()=>{f()},[f]),d.useEffect(()=>{if(r<=0)return;const L=setInterval(f,r);return()=>clearInterval(L)},[r,f]);const y=S.txTypes===null?w:E.length,x=Math.ceil(y/s),A=Math.floor(j/s)+1,_=L=>{const R=(L-1)*s;v(Math.max(0,Math.min(R,Math.max(0,y-s))))},C=L=>{u(L)};if(N||c)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${o}`,children:[e.jsx("p",{className:"cedros-tx-error",children:N||c}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{h(),k(null),f()},children:"Retry"})]});if(l&&p.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${o}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=L=>L.txTypes===null?p.length:p.filter(R=>{const T=R.txType||"";return L.txTypes.some(B=>T.toLowerCase()===B.toLowerCase())}).length;return e.jsxs("div",{className:`cedros-tx-history ${o}`,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:f,disabled:l,title:"Refresh",children:l?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:_s.map(L=>{const R=P(L),T=m===L.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${T?"cedros-tx-tab-active":""}`,onClick:()=>C(L.key),children:[L.label,R>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:R})]},L.key)})}),E.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:m==="all"?"No transactions yet.":`No ${S.label.toLowerCase()} found.`}),m==="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:E.slice(0,s).map(L=>{const R=L.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${R?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>a?.(L),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),a?.(L))},role:a?"button":void 0,tabIndex:a?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${R?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:du(L.txType,R)}),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:lu(L.txType)}),e.jsx("span",{className:`cedros-tx-amount ${R?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:iu(L.amountLamports,L.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:L.description}),e.jsx("span",{className:"cedros-tx-date",children:cu(L.createdAt)})]})]})]},L.id)})}),x>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>_(A-1),disabled:A<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",A," of ",x]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>_(A+1),disabled:A>=x,children:"Next"})]})]})]})}function fr(){const t=M.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),[a,i]=d.useState(null),l=d.useMemo(()=>t?new M.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(()=>{n(null)},[]),h=d.useCallback(async()=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await l.get("/wallet/withdraw/balances")}catch(b){const w=M.handleApiError(b,"Failed to fetch wallet balances");throw n(w.message),w}},[l]),m=d.useCallback(async(b,w)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=await l.post("/wallet/withdraw/sol",{destination:b,amount_lamports:w});return i(g),g}catch(g){const j=M.handleApiError(g,"Failed to withdraw SOL");throw n(j.message),j}finally{r(!1)}},[l]),u=d.useCallback(async(b,w,g)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const j=await l.post("/wallet/withdraw/spl",{destination:b,token_mint:w,amount:g});return i(j),j}catch(j){const v=M.handleApiError(j,"Failed to withdraw token");throw n(v.message),v}finally{r(!1)}},[l]),p=d.useCallback(async(b=10,w=0)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const g=Math.max(1,Math.min(100,Math.trunc(b))),j=Math.max(0,Math.trunc(w)),v=new URLSearchParams({limit:String(g),offset:String(j)});return await l.get(`/wallet/withdraw/history?${v}`)}catch(g){const j=M.handleApiError(g,"Failed to fetch withdrawal history");throw n(j.message),j}},[l]);return{withdrawSol:m,withdrawSpl:u,getBalances:h,getHistory:p,isSubmitting:s,error:o,clearError:c,lastResult:a}}const Ls="So11111111111111111111111111111111111111112",hu={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function mu(t){return t.length<32||t.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(t)}function Ps(t){return t.length<=16?t:`${t.slice(0,6)}...${t.slice(-6)}`}function bt(t,s){return(Number(t)/Math.pow(10,s)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(s,6)})}function fu({onSuccess:t,onError:s,onCancel:r,className:o=""}){const n=M.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:i,getBalances:l,isSubmitting:c,error:h,clearError:m}=fr(),[u,p]=d.useState("loading"),[b,w]=d.useState([]),[g,j]=d.useState(null),[v,N]=d.useState(""),[k,S]=d.useState(""),[E,f]=d.useState(null),[y,x]=d.useState(null),[A,_]=d.useState(null),C=n?.config.solana?.network??"mainnet-beta",P=d.useMemo(()=>{if(!E?.txSignature)return"";const I=`https://explorer.solana.com/tx/${E.txSignature}`;return C==="mainnet-beta"?I:`${I}?cluster=${encodeURIComponent(C)}`},[E,C]),L=d.useMemo(()=>{if(!g||!k)return"0";const I=parseFloat(k);return isNaN(I)||I<=0?"0":Math.floor(I*Math.pow(10,g.decimals)).toString()},[k,g]);d.useEffect(()=>{if(!n)return;let I=!1;return(async()=>{try{const U=await l();if(I)return;const z=[];U.solLamports>0&&z.push({symbol:"SOL",mint:Ls,decimals:9,rawBalance:String(U.solLamports),displayBalance:bt(String(U.solLamports),9)});for(const K of U.tokens){const se=hu[K.mint]??Ps(K.mint);z.push({symbol:se,mint:K.mint,decimals:K.decimals,rawBalance:K.amount,displayBalance:bt(K.amount,K.decimals)})}w(z),p((z.length>0,"select"))}catch{I||(_("Failed to load wallet balances"),p("select"))}})(),()=>{I=!0}},[n,l]);const R=d.useCallback(I=>{j(I),p("form"),m(),x(null),S("")},[m]),T=d.useCallback(()=>{if(!g)return;const I=Number(g.rawBalance)/Math.pow(10,g.decimals);g.mint===Ls?S(String(Math.max(0,I-.01))):S(String(I))},[g]),B=d.useCallback(()=>{if(x(null),!v.trim()){x("Destination address is required");return}if(!mu(v.trim())){x("Invalid Solana address");return}if(!k||parseFloat(k)<=0||isNaN(parseFloat(k))){x("Please enter a valid amount");return}if(L==="0"){x("Amount is too small");return}p("confirm")},[v,k,L]),F=d.useCallback(async()=>{if(g){p("processing"),m();try{let I;g.mint===Ls?I=await a(v.trim(),Number(L)):I=await i(v.trim(),g.mint,L),f(I),p("success"),t?.(I)}catch(I){p("confirm"),s?.(I instanceof Error?I:new Error(String(I)))}}},[g,v,L,a,i,m,t,s]),W=d.useCallback(()=>{m(),x(null),u==="form"?(p("select"),j(null),S(""),N("")):u==="confirm"&&p("form")},[u,m]),O=d.useCallback(()=>{p("select"),j(null),N(""),S(""),f(null),m(),x(null)},[m]);return n?e.jsxs("div",{className:`cedros-withdrawal ${o}`,children:[u==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),u==="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"})]}),A&&e.jsx(te.ErrorMessage,{error:A}),b.length===0&&!A&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:b.map(I=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>R(I),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:I.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:I.displayBalance})]},I.mint))}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:r,children:"Cancel"})]}),u==="form"&&g&&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:W,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",g.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",g.displayBalance," ",g.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:v,onChange:I=>N(I.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 (",g.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:k,onChange:I=>S(I.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:T,children:"Max"})]})]}),(y||h)&&e.jsx(te.ErrorMessage,{error:y||h||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:B,children:"Review Withdrawal"})]}),u==="confirm"&&g&&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:W,disabled:c,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:g.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:[bt(L,g.decimals)," ",g.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:v,children:Ps(v)})]}),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"})]})]}),h&&e.jsx(te.ErrorMessage,{error:h}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:W,disabled:c,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:F,disabled:c,children:c?"Sending...":"Confirm & Send"})]})]}),u==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(Q.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",g?.symbol,"..."]})]}),u==="success"&&E&&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:[bt(L,g?.decimals??9)," ",g?.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:P,target:"_blank",rel:"noreferrer",children:Ps(E.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:O,children:"Done"})]})]}):null}function pu(t,s){if(t==="sol")return"SOL";if(!s)return"SPL";const r=qt.find(o=>o.mint===s);return r?r.symbol:`${s.slice(0,4)}...${s.slice(-4)}`}function gu(t,s){const r=Number(t);if(Number.isNaN(r))return t;const o=na(s),n=r/Math.pow(10,o);return s==="SOL"?`${n.toFixed(4)} SOL`:`${n.toFixed(2)} ${s}`}function wu(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function bu(t){const s=new Date(t),r=new Date,o=r.getTime()-s.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==r.getFullYear()?"numeric":void 0})}function yu({pageSize:t=10,className:s="",onTransactionClick:r,explorerUrl:o="https://solscan.io"}){const n=o.startsWith("https://")?o:"https://solscan.io",{getHistory:a,error:i,clearError:l}=fr(),[c,h]=d.useState([]),[m,u]=d.useState(0),[p,b]=d.useState(0),[w,g]=d.useState(!1),[j,v]=d.useState(null),N=d.useCallback(async()=>{g(!0);try{const f=await a(t,p);h(f.items),u(f.total),v(null)}catch(f){v(f instanceof Error?f.message:"Failed to load withdrawal history")}finally{g(!1)}},[t,p,a]);d.useEffect(()=>{N()},[N]);const k=Math.ceil(m/t),S=Math.floor(p/t)+1,E=f=>{const y=(f-1)*t;b(Math.max(0,Math.min(y,Math.max(0,m-t))))};return j||i?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${s}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:j||i}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{l(),v(null),N()},children:"Retry"})]}):w&&c.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${s}`,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 ${s}`,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:N,disabled:w,title:"Refresh",children:w?"...":"↻"})]}),c.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:c.map(f=>{const y=pu(f.tokenType,f.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>r?.(f),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),r?.(f))},role:r?"button":void 0,tabIndex:r?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:[y," Withdrawal"]}),e.jsx("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:gu(f.amount,y)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${n}/account/${f.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:wu(f.destination)})," · ",e.jsx("a",{href:`${n}/tx/${f.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:bu(f.createdAt)})]})]})]},f.id)})}),k>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>E(S-1),disabled:S<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",S," of ",k]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>E(S+1),disabled:S>=k,children:"Next"})]})]})]})}function xu({brandLogo:t,brandName:s,title:r="Welcome back",subtitle:o="Login with your Apple or Google account",termsText:n,onSuccess:a,defaultTab:i="login",children:l,className:c=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${c}`,children:[(t||s)&&e.jsxs("div",{className:"cedros-brand-header",children:[t,s&&e.jsx("span",{className:"cedros-brand-name",children:s})]}),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:r}),o&&e.jsx("p",{className:"cedros-full-page-subtitle",children:o})]}),l??e.jsx(Wt,{defaultTab:i,onSuccess:a})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function vu({brandName:t="Your Brand",brandLogo:s,tagline:r="Your tagline goes here. Make it compelling.",title:o="Sign in",subtitle:n="Enter your credentials to access your account",onSuccess:a,defaultTab:i="login",children:l,className:c=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${c}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[s??e.jsx("div",{className:"cedros-split-page-logo",children:t.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:t}),r&&e.jsx("p",{className:"cedros-split-page-tagline",children:r})]})}),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:o}),n&&e.jsx("p",{className:"cedros-split-page-subtitle",children:n}),l??e.jsx(Wt,{defaultTab:i,onSuccess:a})]})})]})}function Au(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=d.useMemo(()=>new Hs.OrgApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),a=d.useCallback(async c=>{o(h=>({...h,isLoading:!0,error:null}));try{const h=await n.authorize(c),m={allowed:h.allowed,reason:h.reason,isLoading:!1,error:null};return o(m),m}catch(h){const m={allowed:!1,reason:void 0,isLoading:!1,error:h};return o(m),m}},[n]),i=d.useCallback(async c=>(await a(c)).allowed,[a]),l=d.useCallback(()=>{o({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:i,lastCheck:r,clearCheck:l,checkAuthorization:a}}function ju(){const{listAllWallets:t,createDerivedWallet:s,deleteDerivedWallet:r}=D.useWalletMaterial(),[o,n]=d.useState([]),[a,i]=d.useState(!1),[l,c]=d.useState(null),h=d.useCallback(async()=>{i(!0),c(null);try{const b=await t();n(b.wallets)}catch(b){const w=b instanceof Error?b.message:"Failed to list wallets";c(w)}finally{i(!1)}},[t]),m=d.useCallback(async b=>{i(!0),c(null);try{const w=await s({label:b});return await h(),w}catch(w){const g=w instanceof Error?w.message:"Failed to create wallet";throw c(g),w}finally{i(!1)}},[s,h]),u=d.useCallback(async b=>{i(!0),c(null);try{await r(b),await h()}catch(w){const g=w instanceof Error?w.message:"Failed to delete wallet";throw c(g),w}finally{i(!1)}},[r,h]),p=d.useCallback(()=>c(null),[]);return{wallets:o,isLoading:a,createWallet:m,deleteWallet:u,refresh:h,error:l,clearError:p}}function Nu(){const t=M.useCedrosLoginOptional(),[s,r]=d.useState(!1),[o,n]=d.useState(null),[a,i]=d.useState(null),l=d.useMemo(()=>t?new M.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const u=await l.get("/wallet/pending-recovery");i(u)}catch(u){const p=M.handleApiError(u,"Failed to fetch pending recovery");throw n(p.message),p}finally{r(!1)}},[l]),h=d.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const u={confirmed:!0};await l.post("/wallet/acknowledge-recovery",u),i(null)}catch(u){const p=M.handleApiError(u,"Failed to acknowledge recovery");throw n(p.message),p}finally{r(!1)}},[l]),m=d.useCallback(()=>n(null),[]);return d.useEffect(()=>{l&&t?.authState==="authenticated"&&c().catch(()=>{})},[l,t?.authState,c]),{hasPendingRecovery:a?.hasPendingRecovery??!1,recoveryType:a?.recoveryType??null,recoveryPhrase:a?.recoveryPhrase??null,expiresAt:a?.expiresAt?new Date(a.expiresAt):null,fetchPendingRecovery:c,acknowledgeRecovery:h,isLoading:s,error:o,clearError:m}}function ku(t={}){const{onExternalSign:s}=t,{solanaPubkey:r,hasExternalWallet:o,status:n,isUnlocked:a}=D.useWallet(),{signTransaction:i,isSigning:l,error:c,clearError:h}=So(),m=d.useMemo(()=>o&&s?"external":n==="enrolled_locked"||n==="enrolled_unlocked"?"sss":"none",[o,s,n]),u=m!=="none",p=n==="enrolled_locked"||n==="enrolled_unlocked";return{signTransaction:d.useCallback(async(w,g)=>{if(m==="external"){if(!s)throw new Error("External wallet signing callback not provided");return s(w)}if(m==="sss"){if(!g&&!a)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return g?i(w,g):i(w)}throw new Error("No signing method available. Enroll a wallet first.")},[m,s,a,i]),signingMethod:m,canSign:u,isSigning:l,publicKey:r,hasExternalWallet:o,hasSssWallet:p,isSssUnlocked:a,error:c,clearError:h}}function Su(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(null),[n,a]=d.useState(!1),[i,l]=d.useState(null),c=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),h=d.useCallback(async()=>{a(!0),l(null);try{await c.post("/welcome-completed",{})}catch(u){const p=u instanceof Error?u:new Error(String(u));throw l(p),p}finally{a(!1)}},[c]),m=d.useCallback(()=>{o(null)},[]);return{postLoginAction:r,setPostLoginAction:o,markWelcomeCompleted:h,clearPostLogin:m,isLoading:n,error:i}}function Cu(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),[i,l]=d.useState(null),[c,h]=d.useState(null),[m,u]=d.useState(null),[p,b]=d.useState(null),w=p!==null&&p!=="none",g=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),j=d.useCallback(async()=>{o(!0),a(null);try{const N=await g.get("/kyc/status",{credentials:"include"});return l(N.status),h(N.verifiedAt??null),u(N.expiresAt??null),b(N.enforcementMode),N}catch(N){const k=N instanceof Error?N:new Error(String(N));throw a(k),k}finally{o(!1)}},[g]),v=d.useCallback(async()=>{o(!0),a(null);try{const N=await g.post("/kyc/start",void 0,{credentials:"include"});return l("pending"),N.redirectUrl}catch(N){const k=N instanceof Error?N:new Error(String(N));throw a(k),k}finally{o(!1)}},[g]);return{status:i,verifiedAt:c,expiresAt:m,isRequired:w,enforcementMode:p,fetchStatus:j,startVerification:v,isLoading:r,error:n}}function la(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),[i,l]=d.useState(null),[c,h]=d.useState([]),[m,u]=d.useState(0),p=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),b=d.useCallback(async()=>{o(!0),a(null);try{const j=await p.get("/referral/rewards",{credentials:"include"});return l(j),j}catch(j){const v=j instanceof Error?j:new Error(String(j));throw a(v),v}finally{o(!1)}},[p]),w=d.useCallback(async(j=10,v=0)=>{o(!0),a(null);try{const N=await p.get(`/referral/rewards/history?limit=${j}&offset=${v}`,{credentials:"include"});return h(N.items),u(N.total),N}catch(N){const k=N instanceof Error?N:new Error(String(N));throw a(k),k}finally{o(!1)}},[p]),g=d.useCallback(async j=>{o(!0),a(null);try{await p.post("/referral/payout-wallet",{walletAddress:j},{credentials:"include"}),l(v=>v&&{...v,payoutWalletAddress:j})}catch(v){const N=v instanceof Error?v:new Error(String(v));throw a(N),N}finally{o(!1)}},[p]);return{rewards:i,history:c,historyTotal:m,fetchRewards:b,fetchHistory:w,setPayoutWallet:g,isLoading:r,error:n}}function Rs(t,s){return s==="SOL"?(t/1e9).toFixed(4)+" SOL":"$"+(t/1e6).toFixed(2)}function Eu(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return t}}const _u=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function Lu(t){return _u.test(t)}function Pu(t){switch(t){case"signup":return"Sign-up";case"spend":return"Spend";case"first_spend":return"First Spend";default:return t}}function Ru({status:t}){const r={pending:"cedros-rewards-panel__badge--pending",completed:"cedros-rewards-panel__badge--completed",failed:"cedros-rewards-panel__badge--failed",credited:"cedros-rewards-panel__badge--credited"}[t]??"cedros-rewards-panel__badge--pending";return e.jsx("span",{className:`cedros-rewards-panel__badge ${r}`,children:t.charAt(0).toUpperCase()+t.slice(1)})}const yt=10;function Tu({explorerUrl:t="https://explorer.solana.com",className:s}){const{rewards:r,history:o,historyTotal:n,fetchRewards:a,fetchHistory:i,setPayoutWallet:l,isLoading:c,error:h}=la(),[m,u]=d.useState(0),[p,b]=d.useState(""),[w,g]=d.useState(null),[j,v]=d.useState(!1),[N,k]=d.useState(!1);d.useEffect(()=>{a().catch(()=>{}),i(yt,0).catch(()=>{})},[a,i]),d.useEffect(()=>{r?.payoutWalletAddress!=null&&b(r.payoutWalletAddress)},[r?.payoutWalletAddress]);const S=d.useCallback(x=>{u(x),i(yt,x*yt).catch(()=>{})},[i]),E=Math.ceil(n/yt),f=d.useCallback(async()=>{const x=p.trim();if(x!==""&&!Lu(x)){g("Invalid address. Must be a base58 string between 32 and 44 characters.");return}g(null),v(!0),k(!1);try{await l(x===""?null:x),k(!0)}catch(A){g(A instanceof Error?A.message:"Failed to save wallet address.")}finally{v(!1)}},[p,l]),y=r?.rewardType==="direct_payout"?"Direct Payout":"Credits";return e.jsxs("div",{className:`cedros-rewards-panel ${s??""}`.trim(),"aria-label":"Rewards dashboard",children:[h&&e.jsx("div",{className:"cedros-rewards-panel__error",role:"alert",children:h.message}),e.jsxs("section",{className:"cedros-rewards-panel__summary","aria-label":"Rewards summary",children:[e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Total Earned"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?Rs(r.totalEarned,r.currency):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Pending Payouts"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?`${Rs(r.pendingAmount,r.currency)} (${r.pendingCount})`:"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Referrals"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?String(r.referralCount):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Reward Type"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:e.jsx("span",{className:"cedros-rewards-panel__type-badge",children:y})})]})]}),r?.rewardType==="direct_payout"&&e.jsxs("section",{className:"cedros-rewards-panel__wallet-section","aria-label":"Payout wallet",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"Payout Wallet"}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-current",children:[e.jsx("span",{className:"cedros-rewards-panel__wallet-label",children:"Current address:"}),e.jsx("span",{className:"cedros-rewards-panel__wallet-address",children:r.payoutWalletAddress??"Not set"})]}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-form",children:[e.jsx("label",{htmlFor:"cedros-payout-wallet-input",className:"cedros-rewards-panel__wallet-input-label",children:"Wallet address"}),e.jsx("input",{id:"cedros-payout-wallet-input",type:"text",className:"cedros-rewards-panel__wallet-input",value:p,onChange:x=>{b(x.target.value),g(null),k(!1)},placeholder:"Base58 Solana address","aria-describedby":w?"cedros-wallet-error":void 0,disabled:j}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__wallet-save-btn",onClick:f,disabled:j||c,children:j?"Saving...":"Save"})]}),w&&e.jsx("div",{id:"cedros-wallet-error",className:"cedros-rewards-panel__wallet-error",role:"alert",children:w}),N&&!w&&e.jsx("div",{className:"cedros-rewards-panel__wallet-success",role:"status",children:"Wallet address saved."})]}),e.jsxs("section",{className:"cedros-rewards-panel__history-section","aria-label":"Reward history",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"History"}),c&&o.length===0?e.jsx("div",{className:"cedros-rewards-panel__loading","aria-busy":"true",children:"Loading..."}):o.length===0?e.jsx("div",{className:"cedros-rewards-panel__empty",children:"No rewards yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-rewards-panel__table-wrapper",role:"region","aria-label":"Reward history table",tabIndex:0,children:e.jsxs("table",{className:"cedros-rewards-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Date"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Type"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Amount"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Status"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Transaction"})]})}),e.jsx("tbody",{children:o.map(x=>e.jsxs("tr",{className:"cedros-rewards-panel__tr",children:[e.jsx("td",{className:"cedros-rewards-panel__td",children:Eu(x.createdAt)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:Pu(x.triggerType)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:Rs(x.amount,x.currency)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:e.jsx(Ru,{status:x.status})}),e.jsx("td",{className:"cedros-rewards-panel__td",children:x.txSignature?e.jsxs("a",{href:`${t}/tx/${x.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-rewards-panel__tx-link","aria-label":`View transaction ${x.txSignature.slice(0,8)}... on Solana explorer`,children:[x.txSignature.slice(0,8),"..."]}):e.jsx("span",{className:"cedros-rewards-panel__tx-none",children:"—"})})]},x.id))})]})}),E>1&&e.jsxs("div",{className:"cedros-rewards-panel__pagination",role:"navigation","aria-label":"History pagination",children:[e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m-1),disabled:m===0||c,"aria-label":"Previous page",children:"Previous"}),e.jsxs("span",{className:"cedros-rewards-panel__page-info",children:[m+1," / ",E]}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m+1),disabled:m>=E-1||c,"aria-label":"Next page",children:"Next"})]})]})]})]})}function Mu({status:t,startVerification:s,className:r}){const[o,n]=d.useState(!1),[a,i]=d.useState(null),l=d.useCallback(async()=>{n(!0),i(null);try{const m=await s();m&&(window.location.href=m)}catch(m){i(m instanceof Error?m.message:"Failed to start verification")}finally{n(!1)}},[s]);if(t==="verified")return null;let c;switch(t){case"pending":c="Your identity verification is being processed.";break;case"failed":c="Identity verification failed. Please try again.";break;case"expired":c="Your identity verification has expired. Please verify again.";break;case"canceled":c="Verification was canceled. Please try again.";break;default:c="Identity verification is required to continue.";break}const h=t!=="pending";return e.jsxs("div",{className:`cedros-kyc-banner ${r??""}`,role:"alert",children:[e.jsxs("div",{className:"cedros-kyc-banner-content",children:[e.jsx("span",{className:"cedros-kyc-banner-message",children:c}),h&&e.jsx("button",{type:"button",className:"cedros-kyc-banner-button",onClick:l,disabled:o,children:o?"Starting...":"Verify Identity"})]}),a&&e.jsx("div",{className:"cedros-kyc-banner-error",children:a})]})}const Bu=3e3,Iu=6e4;function Du(t){switch(t){case"verified":return"Identity verified successfully!";case"failed":return"Verification failed. You can try again.";case"expired":return"Your identity verification has expired.";case"canceled":return"Verification was canceled.";default:return"Verification was canceled."}}function Uu({fetchStatus:t,onComplete:s,className:r}){const[o,n]=d.useState(null),[a,i]=d.useState(!1),l=d.useRef(s);l.current=s;const c=d.useRef(t);c.current=t,d.useEffect(()=>{let m=!1,u=null;const p=setTimeout(()=>{i(!0),u!==null&&clearInterval(u)},Iu),b=async()=>{try{const w=await c.current();if(m)return;n(w.status),w.status!=="pending"&&(clearTimeout(p),u!==null&&clearInterval(u),l.current?.(w.status))}catch{}};return b(),u=setInterval(b,Bu),()=>{m=!0,clearTimeout(p),u!==null&&clearInterval(u)}},[]);const h=!o||o==="pending";return e.jsx("div",{className:`cedros-kyc-callback ${r??""}`,role:"status","aria-live":"polite",children:a&&h?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:"cedros-kyc-callback-message",children:"Verification is taking longer than expected. Please refresh or check back later."}),s&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>s("pending"),children:"Continue"})]}):h?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("span",{className:"cedros-kyc-callback-spinner","aria-hidden":"true"}),e.jsx("p",{className:"cedros-kyc-callback-message",children:"Processing your verification..."})]}):e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:`cedros-kyc-callback-message cedros-kyc-callback-message--${o}`,children:Du(o)}),s&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>s(o),children:"Continue"})]})})}function da(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(!1),[n,a]=d.useState(null),[i,l]=d.useState(null),[c,h]=d.useState(null),[m,u]=d.useState(null),[p,b]=d.useState(null),w=p!==null&&p!=="none",g=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),j=d.useCallback(async()=>{o(!0),a(null);try{const S=await g.get("/accreditation/status",{credentials:"include"});return l(S.status),h(S.verifiedAt??null),u(S.expiresAt??null),b(S.enforcementMode),S}catch(S){const E=S instanceof Error?S:new Error(String(S));throw a(E),E}finally{o(!1)}},[g]),v=d.useCallback(async(S,E)=>{o(!0),a(null);try{const f=await g.post("/accreditation/submit",{method:S,...E},{credentials:"include"});return l("pending"),f}catch(f){const y=f instanceof Error?f:new Error(String(f));throw a(y),y}finally{o(!1)}},[g]),N=d.useCallback(async(S,E,f)=>{o(!0),a(null);try{const y=new FormData;y.append("submissionId",S),y.append("documentType",f),y.append("file",E);const x=s?.getAccessToken?.(),A={};x&&(A.Authorization=`Bearer ${x}`);const _=await fetch(`${t.serverUrl}/accreditation/upload`,{method:"POST",headers:A,credentials:"include",body:y});if(!_.ok){const C=await _.text().catch(()=>_.statusText);throw new Error(`Upload failed (${_.status}): ${C}`)}return _.json()}catch(y){const x=y instanceof Error?y:new Error(String(y));throw a(x),x}finally{o(!1)}},[t.serverUrl,s]),k=d.useCallback(async()=>{o(!0),a(null);try{return(await g.get("/accreditation/submissions",{credentials:"include"})).submissions}catch(S){const E=S instanceof Error?S:new Error(String(S));throw a(E),E}finally{o(!1)}},[g]);return{status:i,verifiedAt:c,expiresAt:m,isRequired:w,enforcementMode:p,fetchStatus:j,submitVerification:v,uploadDocument:N,listSubmissions:k,isLoading:r,error:n}}const Sn=[{method:"income",label:"Income",description:"Verify via annual income ($200K+ individual / $300K+ joint)"},{method:"net_worth",label:"Net Worth",description:"Verify via net worth ($1M+ excluding primary residence)"},{method:"credential",label:"Professional Credential",description:"Verify via FINRA license (Series 7, 65, or 82)"},{method:"third_party_letter",label:"Third-Party Letter",description:"Upload a verification letter from a CPA, attorney, or RIA"},{method:"insider",label:"Insider / Officer",description:"Self-certify as a director, executive officer, or general partner"},{method:"investment_threshold",label:"Investment Threshold",description:"Qualify via investment commitment ($200K+ individual / $1M+ entity)"}];function xt({label:t,acceptedTypes:s=".pdf,.jpg,.jpeg,.png,.tiff",documentType:r,files:o,onFilesChange:n,maxFiles:a=5}){const i=d.useRef(null),[l,c]=d.useState(!1),h=d.useCallback(u=>{if(!u)return;const p=Array.from(u),b=[...o,...p].slice(0,a);n(b)},[o,a,n]),m=u=>{n(o.filter((p,b)=>b!==u))};return e.jsxs("div",{className:"cedros-accreditation-wizard__upload-zone",children:[e.jsx("p",{className:"cedros-accreditation-wizard__upload-label",children:t}),e.jsxs("div",{className:`cedros-accreditation-wizard__drop-area${l?" cedros-accreditation-wizard__drop-area--active":""}`,role:"button",tabIndex:0,"aria-label":`Upload files: ${t}`,onClick:()=>i.current?.click(),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&i.current?.click()},onDragOver:u=>{u.preventDefault(),c(!0)},onDragLeave:()=>c(!1),onDrop:u=>{u.preventDefault(),c(!1),h(u.dataTransfer.files)},children:[e.jsx("span",{children:"Click or drag files here"}),e.jsx("span",{className:"cedros-accreditation-wizard__upload-hint",children:s})]}),e.jsx("input",{ref:i,type:"file",accept:s,multiple:a>1,style:{display:"none"},onChange:u=>h(u.target.files),"aria-hidden":"true"}),o.length>0&&e.jsx("ul",{className:"cedros-accreditation-wizard__file-list","aria-label":"Uploaded files",children:o.map((u,p)=>e.jsxs("li",{className:"cedros-accreditation-wizard__file-item",children:[e.jsx("span",{children:u.name}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__file-remove",onClick:()=>m(p),"aria-label":`Remove ${u.name}`,children:"Remove"})]},`${u.name}-${p}`))})]})}function Fu(t,s,r,o){s({...t,[r]:o})}function vt(t,s){return t.filter(r=>r.documentType===s).map(r=>r.file)}function At(t,s,r,o){const n=t.filter(a=>a.documentType!==s);o([...n,...r.map(a=>({file:a,documentType:s}))])}function Wu({method:t,formData:s,onFormDataChange:r,fileEntries:o,onFileEntriesChange:n}){const a=(i,l)=>Fu(s,r,i,l);return t==="income"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Income Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Income type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"individual",checked:s.incomeType==="individual",onChange:()=>a("incomeType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"joint",checked:s.incomeType==="joint",onChange:()=>a("incomeType","joint")})," ","Joint with spouse ($300K+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"statedAmount",children:"Stated annual income (USD)"}),e.jsx("input",{id:"statedAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:s.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"userStatement",children:"Statement about current year income expectation"}),e.jsx("textarea",{id:"userStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:s.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx(xt,{label:"Upload tax documents (W-2, 1040, 1099, K-1) from the last 2 years",documentType:"tax_return",files:vt(o,"tax_return"),onFilesChange:i=>At(o,"tax_return",i,n)})]}):t==="net_worth"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Net Worth Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"netWorthAmount",children:"Stated net worth (USD, excluding primary residence)"}),e.jsx("input",{id:"netWorthAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:s.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Documents must be dated within the last 90 days."}),e.jsx(xt,{label:"Upload asset documents (bank/brokerage statements, property appraisals)",documentType:"asset_statement",files:vt(o,"asset_statement"),onFilesChange:i=>At(o,"asset_statement",i,n)}),e.jsx(xt,{label:"Upload liability documents (credit report)",documentType:"liability_statement",files:vt(o,"liability_statement"),onFilesChange:i=>At(o,"liability_statement",i,n)})]}):t==="credential"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Professional Credential"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"crdNumber",children:"FINRA CRD Number"}),e.jsx("input",{id:"crdNumber",type:"text",className:"cedros-accreditation-wizard__input",value:s.crdNumber??"",onChange:i=>a("crdNumber",i.target.value)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"licenseType",children:"License type"}),e.jsxs("select",{id:"licenseType",className:"cedros-accreditation-wizard__select",value:s.licenseType??"",onChange:i=>a("licenseType",i.target.value),children:[e.jsx("option",{value:"",children:"Select a license"}),e.jsx("option",{value:"series_7",children:"Series 7"}),e.jsx("option",{value:"series_65",children:"Series 65"}),e.jsx("option",{value:"series_82",children:"Series 82"})]})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Your license will be verified via FINRA BrokerCheck."})]}):t==="third_party_letter"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Third-Party Letter"}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Letter must be dated within the last 90 days."}),e.jsx(xt,{label:"Upload verification letter from a CPA, attorney, RIA, or broker-dealer",documentType:"letter",files:vt(o,"letter"),onFilesChange:i=>At(o,"letter",i,n),maxFiles:1})]}):t==="insider"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Insider / Officer"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"insiderStatement",children:"Describe your role as director, executive officer, or general partner"}),e.jsx("textarea",{id:"insiderStatement",className:"cedros-accreditation-wizard__textarea",rows:4,value:s.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"An administrator will verify your status."})]}):e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Investment Threshold"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Entity type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"individual",checked:s.entityType==="individual",onChange:()=>a("entityType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"entity",checked:s.entityType==="entity",onChange:()=>a("entityType","entity")})," ","Entity ($1M+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentAmount",children:"Investment commitment amount (USD)"}),e.jsx("input",{id:"commitmentAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:s.investmentCommitmentUsd??"",onChange:i=>a("investmentCommitmentUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentStatement",children:"Written representation of commitment"}),e.jsx("textarea",{id:"commitmentStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:s.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Per 2025 SEC guidance, a minimum investment commitment serves as evidence of accredited status."})]})}function Ou({onComplete:t,onCancel:s,className:r}){const{submitVerification:o,uploadDocument:n,isLoading:a,error:i}=da(),[l,c]=d.useState(1),[h,m]=d.useState(null),[u,p]=d.useState({}),[b,w]=d.useState([]),[g,j]=d.useState(!1),[v,N]=d.useState(null),k=y=>{m(y),c(2)},S=()=>{l===2?c(1):l===3?c(2):s?.()},E=d.useCallback(async()=>{if(h){N(null);try{const{submissionId:y}=await o(h,u);for(const x of b)await n(y,x.file,x.documentType);j(!0),t?.(y)}catch(y){N(y instanceof Error?y.message:"Submission failed. Please try again.")}}},[h,u,b,o,n,t]),f=Sn.find(y=>y.method===h);return g?e.jsx("div",{className:`cedros-accreditation-wizard cedros-accreditation-wizard--success ${r??""}`,role:"status",children:e.jsx("p",{className:"cedros-accreditation-wizard__success-message",children:"Submitted for review. You will be notified once your accreditation is verified."})}):e.jsxs("div",{className:`cedros-accreditation-wizard ${r??""}`,children:[e.jsx("div",{className:"cedros-accreditation-wizard__header",children:e.jsx("nav",{className:"cedros-accreditation-wizard__steps","aria-label":"Wizard steps",children:["Choose Method","Fill Details","Review & Submit"].map((y,x)=>e.jsxs("span",{className:`cedros-accreditation-wizard__step${l===x+1?" cedros-accreditation-wizard__step--active":""}`,"aria-current":l===x+1?"step":void 0,children:[x+1,". ",y]},y))})}),l===1&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step1-heading",children:[e.jsx("h2",{id:"step1-heading",className:"cedros-accreditation-wizard__section-title",children:"Choose Verification Method"}),e.jsx("div",{className:"cedros-accreditation-wizard__method-grid",role:"list",children:Sn.map(y=>e.jsxs("button",{type:"button",role:"listitem",className:"cedros-accreditation-wizard__method-card",onClick:()=>k(y.method),children:[e.jsx("span",{className:"cedros-accreditation-wizard__method-title",children:y.label}),e.jsx("span",{className:"cedros-accreditation-wizard__method-desc",children:y.description})]},y.method))}),s&&e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__cancel",onClick:s,children:"Cancel"})]}),l===2&&h&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step2-heading",children:[e.jsx("h2",{id:"step2-heading",className:"cedros-accreditation-wizard__section-title",children:f?.label}),e.jsx(Wu,{method:h,formData:u,onFormDataChange:p,fileEntries:b,onFileEntriesChange:w}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__next",onClick:()=>c(3),children:"Review"})]})]}),l===3&&h&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step3-heading",children:[e.jsx("h2",{id:"step3-heading",className:"cedros-accreditation-wizard__section-title",children:"Review & Submit"}),e.jsxs("dl",{className:"cedros-accreditation-wizard__review-list",children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:"Method"}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:f?.label}),Object.entries(u).filter(([,y])=>y!==void 0&&y!==""&&y!==null).map(([y,x])=>e.jsxs("div",{children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:y}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:String(x)})]},y))]}),b.length>0&&e.jsxs("div",{className:"cedros-accreditation-wizard__review-files",children:[e.jsx("p",{className:"cedros-accreditation-wizard__review-files-heading",children:"Documents to upload:"}),e.jsx("ul",{children:b.map((y,x)=>e.jsxs("li",{children:[y.file.name," ",e.jsxs("span",{className:"cedros-accreditation-wizard__doc-type",children:["(",y.documentType,")"]})]},`${y.file.name}-${x}`))})]}),(i||v)&&e.jsx("div",{className:"cedros-accreditation-wizard__error",role:"alert",children:v??i?.message}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__submit",onClick:E,disabled:a,children:a?"Submitting...":"Submit Verification"})]})]})]})}function qu({status:t,onStartVerification:s,className:r}){if(t==="approved")return null;let o,n=!0;switch(t){case"pending":o="Your accreditation is under review.",n=!1;break;case"rejected":o="Accreditation was not approved. You can resubmit.";break;case"expired":o="Your accreditation has expired. Please verify again.";break;default:o="Accredited investor verification is required.";break}return e.jsx("div",{className:`cedros-accreditation-banner ${r??""}`,role:"alert",children:e.jsxs("div",{className:"cedros-accreditation-banner__content",children:[e.jsx("span",{className:"cedros-accreditation-banner__message",children:o}),n&&s&&e.jsx("button",{type:"button",className:"cedros-accreditation-banner__button",onClick:s,children:t==="rejected"||t==="expired"?"Resubmit Verification":"Start Verification"})]})})}const pr=d.createContext(null),Dt={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 ua(t,s){return ha(t,s)}function ha(t,s){const r={...t};for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)){const n=t[o],a=s[o];typeof n=="object"&&n!==null&&typeof a=="object"&&a!==null?r[o]=ha(n,a):a!==void 0&&(r[o]=a)}return r}function zu({children:t,locale:s="en",translations:r}){const o=d.useMemo(()=>({t:r?ua(Dt,r):Dt,locale:s}),[r,s]);return e.jsx(pr.Provider,{value:o,children:t})}function $u(){return d.useContext(pr)?.t??Dt}function Vu(){return d.useContext(pr)?.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=Q.LoadingSpinner;exports.EmailLoginForm=X.EmailLoginForm;exports.EmailRegisterForm=X.EmailRegisterForm;exports.OtpInput=X.OtpInput;exports.PasswordInput=X.PasswordInput;exports.TotpVerify=X.TotpVerify;exports.useEmailAuth=X.useEmailAuth;exports.useTotpVerify=X.useTotpVerify;exports.validatePassword=Oe.validatePassword;exports.ErrorMessage=te.ErrorMessage;exports.GoogleLoginButton=$s.GoogleLoginButton;exports.useGoogleAuth=$s.useGoogleAuth;exports.SolanaLoginButton=Ze.SolanaLoginButton;exports.registerMobileWallet=Ze.registerMobileWallet;exports.useSolanaAuth=Ze.useSolanaAuth;exports.InviteForm=he.InviteForm;exports.InviteList=he.InviteList;exports.MemberList=he.MemberList;exports.useInvites=he.useInvites;exports.useMembers=he.useMembers;exports.useServerFeatures=he.useServerFeatures;exports.useSystemSettings=Vs.useSystemSettings;exports.AdminDepositList=Ct.AdminDepositList;exports.AdminDepositStats=Ct.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Me.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Me.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Me.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Me.AdminWithdrawalStats;exports.AdminUserList=We.AdminUserList;exports.useAdminUsers=We.useAdminUsers;exports.useOrgs=Hs.useOrgs;exports.AdminIcons=Be.Icons;exports.AdminShell=Be.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=Be.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=Be.ProfileDropdown;exports.cedrosLoginPlugin=Be.cedrosLoginPlugin;exports.loginPlugin=Be.cedrosLoginPlugin;exports.useAdminShell=Be.useAdminShell;exports.AuthenticationSettings=En.AuthenticationSettings;exports.EmbeddedWalletSettings=_n.EmbeddedWalletSettings;exports.EmailSettings=jt.EmailSettings;exports.CreditSystemSettings=Qs.CreditSystemSettings;exports.PrivacyCashSettings=Qs.CreditSystemSettings;exports.ServerSettings=Ln.ServerSettings;exports.SettingsPageLayout=lt.SettingsPageLayout;exports.WebhookSettings=lt.WebhookSettings;exports.useAdminDeposits=ya.useAdminDeposits;exports.AccountSettings=Sd;exports.AccreditationBanner=qu;exports.AccreditationWizard=Ou;exports.AdminAccreditationQueue=Uo;exports.AdminReferralPayouts=Mo;exports.AdminSanctionsPanel=Fo;exports.AppleLoginButton=po;exports.CapabilityWarning=Fc;exports.CedrosAdminDashboard=Ol;exports.ChooseUsernamePrompt=_d;exports.CompleteAccountPrompt=Ed;exports.ComplianceSettings=Bo;exports.CreditBalance=au;exports.DepositFlow=Zd;exports.ErrorBoundary=bo;exports.ForgotPasswordForm=ho;exports.FullPageLayout=xu;exports.History=uu;exports.I18nProvider=zu;exports.KycBanner=Mu;exports.KycCallback=Uu;exports.LinkedAccounts=Ko;exports.LoginButton=hc;exports.LoginForm=Wt;exports.LoginModal=xc;exports.MfaSetupPrompt=Cd;exports.OrgSelector=Ac;exports.OrgSwitcher=Pc;exports.PasskeyLoginButton=wo;exports.PasskeyPrompt=Eo;exports.ProfileTab=Qo;exports.RecoveryPhraseDisplay=xo;exports.RecoveryPhraseInput=vo;exports.ReferralSettings=Io;exports.ResetPasswordForm=vc;exports.RewardsPanel=Tu;exports.SUPPORTED_TOKENS=qt;exports.SecuritySettings=bl;exports.SessionList=yo;exports.SetupWizard=Wo;exports.SplitPageLayout=vu;exports.SystemSettings=nl;exports.TieredAmountSlider=ur;exports.TokenGateSettings=Do;exports.TokenSelector=cr;exports.TotpSettings=Vo;exports.TotpSetup=ar;exports.UserProfileSettings=md;exports.WalletAddressRow=Ro;exports.WalletEnrollment=ko;exports.WalletManager=rl;exports.WalletRecovery=Po;exports.WalletStatus=To;exports.WalletUnlock=_o;exports.WithdrawalFlow=fu;exports.WithdrawalHistory=yu;exports.defaultTranslations=Dt;exports.getTierForAmount=Ot;exports.mergeTranslations=ua;exports.useAccreditation=da;exports.useAppleAuth=mo;exports.useAuthorize=Au;exports.useCredentials=ir;exports.useCredits=mr;exports.useDeposit=ta;exports.useInstantLink=uo;exports.useKyc=Cu;exports.useLocale=Vu;exports.usePasskeySigning=Co;exports.usePasswordReset=Ft;exports.usePendingRecovery=Nu;exports.usePostLogin=Su;exports.useProfile=dt;exports.useReferral=Ho;exports.useRewards=la;exports.useSessions=Jo;exports.useSetPassword=No;exports.useSetup=rr;exports.useTotp=or;exports.useTransactionSigning=ku;exports.useTranslations=$u;exports.useUsername=ea;exports.useWalletEnrollment=jo;exports.useWalletRecovery=Lo;exports.useWalletSigning=So;exports.useWallets=ju;exports.useWebAuthn=sr;exports.useWithdrawal=fr;
|
|
2055
|
+
`);const P=k(y,x,L),_=s.getSymbolSize(y),R=new o(_);return w(R,y),b(R),g(R,y),A(R,x,0),y>=7&&N(R,y),v(R,P),isNaN(j)&&(j=i.getBestMask(R,A.bind(null,R,x))),i.applyMask(j,R),A(R,x,j),{modules:R,version:y,errorCorrectionLevel:x,maskPattern:j,segments:L}}return dt.create=function(y,x){if(typeof y>"u"||y==="")throw new Error("No input text");let j=t.M,L,C;return typeof x<"u"&&(j=t.from(x.errorCorrectionLevel,t.M),L=h.from(x.version),C=i.from(x.maskPattern),x.toSJISFunc&&s.setToSJISFunction(x.toSJISFunc)),E(y,L,j,C)},dt}var _t={},Lt={},vn;function Yo(){return vn||(vn=1,(function(s){function t(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let o=r.slice().replace("#","").split("");if(o.length<3||o.length===5||o.length>8)throw new Error("Invalid hex color: "+r);(o.length===3||o.length===4)&&(o=Array.prototype.concat.apply([],o.map(function(a){return[a,a]}))),o.length===6&&o.push("F","F");const n=parseInt(o.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+o.slice(0,6).join("")}}s.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=typeof o.margin>"u"||o.margin===null||o.margin<0?4:o.margin,a=o.width&&o.width>=21?o.width:void 0,i=o.scale||4;return{width:a,scale:a?4:i,margin:n,color:{dark:t(o.color.dark||"#000000ff"),light:t(o.color.light||"#ffffffff")},type:o.type,rendererOpts:o.rendererOpts||{}}},s.getScale=function(o,n){return n.width&&n.width>=o+n.margin*2?n.width/(o+n.margin*2):n.scale},s.getImageWidth=function(o,n){const a=s.getScale(o,n);return Math.floor((o+n.margin*2)*a)},s.qrToImageData=function(o,n,a){const i=n.modules.size,d=n.modules.data,l=s.getScale(i,a),h=Math.floor((i+a.margin*2)*l),m=a.margin*l,u=[a.color.light,a.color.dark];for(let f=0;f<h;f++)for(let w=0;w<h;w++){let b=(f*h+w)*4,g=a.color.light;if(f>=m&&w>=m&&f<h-m&&w<h-m){const N=Math.floor((f-m)/l),A=Math.floor((w-m)/l);g=u[d[N*i+A]?1:0]}o[b++]=g.r,o[b++]=g.g,o[b++]=g.b,o[b]=g.a}}})(Lt)),Lt}var An;function wd(){return An||(An=1,(function(s){const t=Yo();function r(n,a,i){n.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=i,a.width=i,a.style.height=i+"px",a.style.width=i+"px"}function o(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}s.render=function(a,i,d){let l=d,h=i;typeof l>"u"&&(!i||!i.getContext)&&(l=i,i=void 0),i||(h=o()),l=t.getOptions(l);const m=t.getImageWidth(a.modules.size,l),u=h.getContext("2d"),f=u.createImageData(m,m);return t.qrToImageData(f.data,a,l),r(u,h,m),u.putImageData(f,0,0),h},s.renderToDataURL=function(a,i,d){let l=d;typeof l>"u"&&(!i||!i.getContext)&&(l=i,i=void 0),l||(l={});const h=s.render(a,i,l),m=l.type||"image/png",u=l.rendererOpts||{};return h.toDataURL(m,u.quality)}})(_t)),_t}var Pt={},jn;function bd(){if(jn)return Pt;jn=1;const s=Yo();function t(n,a){const i=n.a/255,d=a+'="'+n.hex+'"';return i<1?d+" "+a+'-opacity="'+i.toFixed(2).slice(1)+'"':d}function r(n,a,i){let d=n+a;return typeof i<"u"&&(d+=" "+i),d}function o(n,a,i){let d="",l=0,h=!1,m=0;for(let u=0;u<n.length;u++){const f=Math.floor(u%a),w=Math.floor(u/a);!f&&!h&&(h=!0),n[u]?(m++,u>0&&f>0&&n[u-1]||(d+=h?r("M",f+i,.5+w+i):r("m",l,0),l=0,h=!1),f+1<a&&n[u+1]||(d+=r("h",m),m=0)):l++}return d}return Pt.render=function(a,i,d){const l=s.getOptions(i),h=a.modules.size,m=a.modules.data,u=h+l.margin*2,f=l.color.light.a?"<path "+t(l.color.light,"fill")+' d="M0 0h'+u+"v"+u+'H0z"/>':"",w="<path "+t(l.color.dark,"stroke")+' d="'+o(m,h,l.margin)+'"/>',b='viewBox="0 0 '+u+" "+u+'"',N='<svg xmlns="http://www.w3.org/2000/svg" '+(l.width?'width="'+l.width+'" height="'+l.width+'" ':"")+b+' shape-rendering="crispEdges">'+f+w+`</svg>
|
|
2056
|
+
`;return typeof d=="function"&&d(null,N),N},Pt}var Nn;function xd(){if(Nn)return Ye;Nn=1;const s=Jl(),t=gd(),r=wd(),o=bd();function n(a,i,d,l,h){const m=[].slice.call(arguments,1),u=m.length,f=typeof m[u-1]=="function";if(!f&&!s())throw new Error("Callback required as last argument");if(f){if(u<2)throw new Error("Too few arguments provided");u===2?(h=d,d=i,i=l=void 0):u===3&&(i.getContext&&typeof h>"u"?(h=l,l=void 0):(h=l,l=d,d=i,i=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(d=i,i=l=void 0):u===2&&!i.getContext&&(l=d,d=i,i=void 0),new Promise(function(w,b){try{const g=t.create(d,l);w(a(g,i,l))}catch(g){b(g)}})}try{const w=t.create(d,l);h(null,a(w,i,l))}catch(w){h(w)}}return Ye.create=t.create,Ye.toCanvas=n.bind(null,r.render),Ye.toDataURL=n.bind(null,r.renderToDataURL),Ye.toString=n.bind(null,function(a,i,d){return o.render(a,d)}),Ye}var yd=xd();const vd=Bn(yd);function Ad({value:s,size:t=200,alt:r="QR code",className:o=""}){const n=c.useRef(null),[a,i]=c.useState(null);return c.useEffect(()=>{!n.current||!s||vd.toCanvas(n.current,s,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{i(null)}).catch(d=>{i(d instanceof Error?d.message:"Failed to generate QR code")})},[s,t]),a?e.jsx("div",{className:`cedros-qr-error ${o}`,style:{width:t,height:t},role:"img","aria-label":r,children:e.jsx("p",{children:"Failed to generate QR code"})}):e.jsx("canvas",{ref:n,className:`cedros-totp-qr-image ${o}`,role:"img","aria-label":r,style:{borderRadius:"0.5rem"}})}function ir(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(null),[n,a]=c.useState("idle"),[i,d]=c.useState(null),[l,h]=c.useState(!1),[m,u]=c.useState(null),f=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),w=c.useCallback(async()=>{h(!0),u(null);try{const S=await f.get("/mfa/status");return o(S),S}catch(S){const E=M.handleApiError(S,"Unable to load two-factor authentication status. Please try again.");throw u(E),E}finally{h(!1)}},[f]),b=c.useCallback(async()=>{h(!0),u(null),a("loading");try{const S=await f.post("/mfa/setup",{});return d(S),a("setup"),S}catch(S){const E=M.handleApiError(S,"Unable to start two-factor setup. Please try again.");throw u(E),a("error"),E}finally{h(!1)}},[f]),g=c.useCallback(async S=>{if(!/^\d{6}$/.test(S)){const E={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw u(E),E}h(!0),u(null),a("verifying");try{await f.post("/mfa/enable",{code:S}),a("success");try{const E=await f.get("/mfa/status");o(E)}catch{o({enabled:!0,recoveryCodesRemaining:0})}}catch(E){const p=M.handleApiError(E,"Incorrect verification code. Please check and try again.");throw u(p),a("error"),p}finally{h(!1)}},[f]),N=c.useCallback(async S=>{if(!S){const E={code:"VALIDATION_ERROR",message:"Please enter your password"};throw u(E),E}h(!0),u(null);try{await f.post("/mfa/disable",{password:S}),o({enabled:!1,recoveryCodesRemaining:0}),d(null),a("idle")}catch(E){const p=M.handleApiError(E,"Unable to disable two-factor authentication. Please try again.");throw u(p),p}finally{h(!1)}},[f]),A=c.useCallback(async S=>{if(!/^\d{6}$/.test(S)){const E={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw u(E),E}h(!0),u(null);try{return await f.post("/mfa/recovery-codes/regenerate",{code:S})}catch(E){const p=M.handleApiError(E,"Unable to regenerate recovery codes. Please try again.");throw u(p),p}finally{h(!1)}},[f]),v=c.useCallback(()=>u(null),[]),k=c.useCallback(()=>{u(null),d(null),a("idle"),h(!1)},[]);return{status:r,setupState:n,setupData:i,isLoading:l,error:m,getStatus:w,beginSetup:b,enableTotp:g,disableTotp:N,regenerateBackupCodes:A,clearError:v,reset:k}}function cr({onSuccess:s,onCancel:t,className:r=""}){const{setupState:o,setupData:n,isLoading:a,error:i,beginSetup:d,enableTotp:l,clearError:h,reset:m}=ir(),[u,f]=c.useState("qr"),[w,b]=c.useState(""),[g,N]=c.useState(!1),[A,v]=c.useState(!1),k=c.useRef(null);c.useEffect(()=>{o==="idle"&&d().catch(()=>{})},[o,d]),c.useEffect(()=>{o==="success"&&s?.()},[o,s]);const S=async()=>{n?.secret&&(await navigator.clipboard.writeText(n.secret),N(!0),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>N(!1),2e3))},E=async()=>{if(n?.recoveryCodes){const x=n.recoveryCodes.join(`
|
|
2057
|
+
`);await navigator.clipboard.writeText(x)}},p=async()=>{try{await l(w)}catch{b("")}},y=()=>{m(),t?.()};return c.useEffect(()=>()=>{k.current!==null&&(window.clearTimeout(k.current),k.current=null)},[]),o==="loading"||o==="idle"&&a?e.jsx("div",{className:`cedros-totp-setup ${r}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(Q.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):o==="error"&&!n?e.jsxs("div",{className:`cedros-totp-setup ${r}`,children:[e.jsx(te.ErrorMessage,{error:i,onDismiss:h}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>d(),children:"Try again"})]})]}):o==="success"?e.jsx("div",{className:`cedros-totp-setup ${r}`,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."})]})}):n?e.jsxs("div",{className:`cedros-totp-setup ${r}`,children:[u==="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(Ad,{value:n.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:n.secret}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:S,"aria-label":"Copy secret",children:g?"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:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("backup"),children:"Continue"})]})]}),u==="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:n.recoveryCodes.map((x,j)=>e.jsx("code",{className:"cedros-totp-backup-code",children:x},j))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:E,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:x=>v(x.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:()=>f("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("verify"),disabled:!A,children:"Continue"})]})]}),u==="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(J.OtpInput,{value:w,onChange:b,onComplete:p,disabled:a,error:i?.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:()=>f("backup"),disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:p,disabled:a||w.length!==6,children:a?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function Zo({onStatusChange:s,className:t=""}){const{status:r,isLoading:o,error:n,getStatus:a,disableTotp:i,regenerateBackupCodes:d,clearError:l}=ir(),[h,m]=c.useState("status"),[u,f]=c.useState(""),[w,b]=c.useState(""),[g,N]=c.useState(null),[A,v]=c.useState(!1),[k,S]=c.useState(null);c.useEffect(()=>{a().catch(()=>{})},[a]);const E=c.useCallback(()=>{m("status"),s?.(!0)},[s]),p=async()=>{v(!0),S(null);try{await i(u),m("status"),f(""),s?.(!1)}catch(j){S(j instanceof Error?j.message:"Failed to disable 2FA"),f("")}finally{v(!1)}},y=async()=>{v(!0),S(null);try{const j=await d(w);N(j.recoveryCodes),b("")}catch(j){S(j instanceof Error?j.message:"Failed to regenerate codes"),b("")}finally{v(!1)}},x=async()=>{g&&await navigator.clipboard.writeText(g.join(`
|
|
2058
|
+
`))};return o&&!r?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(Q.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):n&&!r?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(te.ErrorMessage,{error:n,onDismiss:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>a(),children:"Retry"})]}):h==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(cr,{onSuccess:E,onCancel:()=>m("status")})}):h==="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."}),k&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(J.PasswordInput,{label:"Password",placeholder:"Enter your password",value:u,onChange:j=>f(j.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:()=>{m("status"),f(""),S(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:p,disabled:A||u.length===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):h==="regenerate"?g?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:g.map((j,L)=>e.jsx("code",{className:"cedros-totp-backup-code",children:j},L))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:x,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:()=>{m("status"),N(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."}),k&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(J.OtpInput,{value:w,onChange:b,onComplete:y,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:()=>{m("status"),b(""),S(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:y,disabled:A||w.length!==6,children:A?e.jsxs(e.Fragment,{children:[e.jsx(Q.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 with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${r?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:r?.enabled?"Enabled":"Disabled"})]}),r?.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:r.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>m("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>m("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>m("setup"),children:"Enable two-factor authentication"})]})})}class jd{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(r){throw M.handleApiError(r,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(r){throw M.handleApiError(r,"Failed to update profile")}}}function hs(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useMemo(()=>new jd(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),l=c.useCallback(()=>{i(null)},[]),h=c.useCallback(async u=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");n(!0),i(null);try{return await d.updateProfile(u)}catch(f){const w=f instanceof Error?f:new Error("Failed to update profile");throw i(w),w}finally{n(!1)}},[t,d]),m=c.useCallback(async u=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");n(!0),i(null);try{await d.changePassword(u)}catch(f){const w=f instanceof Error?f:new Error("Failed to change password");throw i(w),w}finally{n(!1)}},[t,d]);return{isLoading:o,error:a,updateProfile:h,changePassword:m,clearError:l}}function Xo(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),d=c.useCallback(async()=>{o(!0),a(null);try{return await i.get("/referral",{credentials:"include"})}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[i]),l=c.useCallback(async()=>{o(!0),a(null);try{return(await i.post("/referral/regenerate",void 0,{credentials:"include"})).referralCode}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[i]);return{getReferral:d,regenerateCode:l,isLoading:r,error:n}}function Nd({onPasswordChange:s,onClose:t,className:r=""}){const{user:o,refreshUser:n}=D.useAuth(),{config:a,_internal:i}=M.useCedrosLogin(),{isLoading:d,error:l,changePassword:h,updateProfile:m,clearError:u}=hs(),[f,w]=c.useState("main"),[b,g]=c.useState(""),[N,A]=c.useState(""),[v,k]=c.useState(""),[S,E]=c.useState(null),[p,y]=c.useState(null),[x,j]=c.useState(!1),L=c.useRef(null),[C,P]=c.useState(o?.payoutWalletAddress??""),[_,R]=c.useState(!1),[T,I]=c.useState(!1),[O,W]=c.useState(null),q=c.useCallback(async()=>{const K=C.trim();if(K.length>0&&(K.length<32||K.length>44)){W("Invalid Solana address — must be 32–44 characters.");return}const ge=/^[1-9A-HJ-NP-Za-km-z]+$/;if(K.length>0&&!ge.test(K)){W("Invalid Solana address — contains non-base58 characters.");return}W(null),R(!0);try{await m({payoutWalletAddress:K||void 0}),await n(),I(!0),setTimeout(()=>I(!1),2e3)}catch(be){W(be instanceof Error?be.message:"Failed to save payout wallet")}finally{R(!1)}},[C,m,n]),{getReferral:U,regenerateCode:F,isLoading:V}=Xo(),[Y,X]=c.useState(null),[B,z]=c.useState(0),[$,H]=c.useState(!1),[se,ue]=c.useState(!1);c.useEffect(()=>{U().then(K=>{X(K.referralCode),z(K.referralCount),ue(K.directPayoutEnabled)}).catch(()=>{})},[]);const we=We.validatePassword(N),rs=N===v,Ue=b.length>0&&N.length>0&&v.length>0&&we.isValid&&rs,De=c.useCallback(async K=>{const ge=K.target.files?.[0];if(ge){E(null),j(!0);try{const be=new FormData;be.append("file",ge);const ms=i?.getAccessToken?.(),Fe={};ms&&(Fe.Authorization=`Bearer ${ms}`);const Ve=await fetch(`${a.serverUrl}/auth/upload/avatar`,{method:"POST",headers:Fe,body:be,credentials:"include"});if(!Ve.ok){const He=await Ve.json().catch(()=>null);throw new Error(He?.message||He?.error||`Upload failed (${Ve.status})`)}await n()}catch(be){E(be instanceof Error?be.message:"Failed to upload avatar")}finally{j(!1),L.current&&(L.current.value="")}}},[a.serverUrl,i,n]),Hs=c.useCallback(async()=>{if(Ue){E(null),y(null);try{await h({currentPassword:b,newPassword:N}),g(""),A(""),k(""),y("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{w("main"),y(null)},2e3)}catch(K){E(K instanceof Error?K.message:"Failed to change password")}}},[Ue,b,N,h,s]),ns=c.useCallback(()=>{w("main"),g(""),A(""),k(""),E(null),u()},[u]),$e=()=>o?.name?o.name.split(" ").map(K=>K[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?";return f==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${r}`,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."}),(S||l)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:S||l?.message||""},onDismiss:()=>{E(null),u()}})}),p&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),p]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:b,onChange:K=>g(K.target.value),disabled:d,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"New password",placeholder:"Enter new password",value:N,onChange:K=>A(K.target.value),disabled:d,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:v,onChange:K=>k(K.target.value),disabled:d,error:v.length>0&&!rs?"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:ns,disabled:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:Hs,disabled:d||!Ue,children:d?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsxs("div",{className:"cedros-profile-avatar-container cedros-profile-avatar-container--clickable",onClick:()=>L.current?.click(),role:"button",tabIndex:0,onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),L.current?.click())},"aria-label":"Change profile picture",children:[x?e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:e.jsx(Q.LoadingSpinner,{size:"sm"})}):o?.picture?e.jsx("img",{src:o.picture,alt:o.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:$e()}),e.jsx("div",{className:"cedros-profile-avatar-overlay",children: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:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),e.jsx("circle",{cx:"12",cy:"13",r:"4"})]})}),e.jsx("input",{ref:L,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",onChange:De,className:"cedros-profile-avatar-input","aria-hidden":"true",tabIndex:-1})]}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:o?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:o?.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:o?.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:()=>w("change-password"),children:"Change"})]})]}),Y&&e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Referral"}),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:"Your code"}),e.jsx("span",{className:"cedros-profile-row-value cedros-profile-row-value--mono",children:Y})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{navigator.clipboard.writeText(Y),H(!0),setTimeout(()=>H(!1),2e3)},children:$?"Copied":"Copy"})]}),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:"Referrals"}),e.jsx("span",{className:"cedros-profile-row-value",children:B})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:async()=>{try{const K=await F();X(K)}catch{}},disabled:V,children:V?"Regenerating...":"Regenerate"})]})]}),se&&e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Payout wallet"}),e.jsx("p",{className:"cedros-profile-description",children:"Solana wallet address to receive direct referral payouts when enabled by the platform."}),e.jsxs("div",{className:"cedros-profile-row cedros-profile-row--column",children:[e.jsx("input",{type:"text",className:"cedros-input",placeholder:"Solana wallet address (base58)",value:C,onChange:K=>{P(K.target.value),W(null)},disabled:_,maxLength:44}),O&&e.jsx("span",{className:"cedros-profile-error-text",children:O}),T&&e.jsx("span",{className:"cedros-profile-success-text",children:"Saved."})]}),e.jsx("div",{className:"cedros-profile-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:q,disabled:_,children:_?"Saving...":"Save wallet"})})]}),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"})})]})})}class kd{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(t){throw M.handleApiError(t,"Failed to list credentials")}}async unlinkCredential(t){try{await this.client.delete(`/credentials/${encodeURIComponent(t)}`)}catch(r){throw M.handleApiError(r,"Failed to unlink credential")}}}function lr(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useMemo(()=>new kd(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),m=c.useCallback(()=>{l(null)},[]),u=c.useCallback(async()=>{if(t!=="authenticated"){n([]);return}i(!0),l(null);try{const w=await h.listCredentials();n(w)}catch(w){l(w)}finally{i(!1)}},[t,h]);c.useEffect(()=>{t==="authenticated"?u():n([])},[t,u]);const f=c.useCallback(async w=>{i(!0),l(null);try{await h.unlinkCredential(w),await u()}catch(b){throw l(b),b}finally{i(!1)}},[h,u]);return{credentials:o,isLoading:a,error:d,fetchCredentials:u,unlinkCredential:f,clearError:m}}function Sd({onPasswordChange:s,onCancel:t,className:r=""}){const{isLoading:o,error:n,changePassword:a,clearError:i}=hs(),[d,l]=c.useState(""),[h,m]=c.useState(""),[u,f]=c.useState(""),[w,b]=c.useState(null),[g,N]=c.useState(null),A=We.validatePassword(h),v=h===u,k=d.length>0&&h.length>0&&u.length>0&&A.isValid&&v,S=c.useCallback(async()=>{if(k){b(null),N(null);try{await a({currentPassword:d,newPassword:h}),l(""),m(""),f(""),N("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>t(),2e3)}catch(p){b(p instanceof Error?p.message:"Failed to change password")}}},[k,d,h,a,s,t]),E=c.useCallback(()=>{b(null),i(),t()},[i,t]);return e.jsx("div",{className:`cedros-profile-settings ${r}`,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."}),(w||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:w||n?.message||""},onDismiss:()=>{b(null),i()}})}),g&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),g]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:d,onChange:p=>l(p.target.value),disabled:o,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"New password",placeholder:"Enter new password",value:h,onChange:p=>m(p.target.value),disabled:o,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:u,onChange:p=>f(p.target.value),disabled:o,error:u.length>0&&!v?"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:E,disabled:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:S,disabled:o||!k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function Jo({onPasswordChange:s,className:t=""}){const{user:r,refreshUser:o}=D.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:d}=hs(),{credentials:l}=lr(),{forgotPassword:h,isLoading:m,isSuccess:u,reset:f}=Ws(),w=l.some(j=>j.credentialType==="password"),[b,g]=c.useState("view"),[N,A]=c.useState(""),[v,k]=c.useState(null),S=()=>r?.name?r.name.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2):r?.email?r.email[0].toUpperCase():"?",E=c.useCallback(()=>{A(r?.name||""),g("edit"),k(null)},[r?.name]),p=c.useCallback(async()=>{const j=N.trim();if(j){k(null);try{await i({name:j}),await o(),g("view")}catch(L){k(L instanceof Error?L.message:"Failed to update name")}}},[N,i,o]),y=c.useCallback(()=>{g("view"),A(""),k(null),d()},[d]),x=c.useCallback(async()=>{if(r?.email){k(null);try{await h(r.email)}catch(j){k(j instanceof Error?j.message:"Failed to send password setup email")}}},[r?.email,h]);return b==="change-password"?e.jsx(Sd,{onPasswordChange:s,onCancel:()=>g("view"),className:t}):e.jsx("div",{className:`cedros-profile-settings ${t}`,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:r?.picture?e.jsx("img",{src:r.picture,alt:r.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:S()})}),e.jsxs("div",{className:"cedros-profile-info",children:[b==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:N,onChange:j=>A(j.target.value),disabled:n,autoFocus:!0,onKeyDown:j=>{j.key==="Enter"&&p(),j.key==="Escape"&&y()}}),e.jsxs("div",{className:"cedros-profile-name-edit-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:p,disabled:n||!N.trim(),children:n?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,disabled:n,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:r?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:E,title:"Edit name","aria-label":"Edit name",children:e.jsx(Cd,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:r?.email})]})]}),(v||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v||a?.message||""},onDismiss:()=>{k(null),d()}})}),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:r?.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:w?"••••••••":"Not set"})]}),w?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{g("change-password"),k(null)},children:"Change"}):u?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:f,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:x,disabled:m,children:m?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function Cd(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M16.474 5.408l2.118 2.117m-.756-3.982L12.109 9.27a2.118 2.118 0 00-.58 1.082L11 13l2.648-.53c.41-.082.786-.283 1.082-.579l5.727-5.727a1.853 1.853 0 10-2.621-2.621z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M19 15v3a2 2 0 01-2 2H6a2 2 0 01-2-2V7a2 2 0 012-2h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const ea={password:"Email & Password",oauth_google:"Google",oauth_apple:"Apple",solana:"Solana Wallet",webauthn_passkey:"Passkey",webauthn_security_key:"Security Key",totp:"Authenticator App (2FA)",sso_oidc:"Single Sign-On"};function sa({onLinkGoogle:s,onLinkApple:t,onAddPasskey:r,onLinkSolana:o,className:n=""}){const{credentials:a,isLoading:i,error:d,unlinkCredential:l,clearError:h,fetchCredentials:m}=lr(),{registerPasskey:u,isSupported:f}=nr(),[w,b]=c.useState(null),[g,N]=c.useState(!1),A=c.useCallback(async()=>{if(r){r();return}N(!0);try{await u(),await m()}catch{}finally{N(!1)}},[r,u,m]),v=c.useCallback(async j=>{const L=j.label||ea[j.credentialType];if(window.confirm(`Remove "${L}" as a sign-in method? You won't be able to sign in with it anymore.`)){b(j.id);try{await l(j.id)}catch{}finally{b(null)}}},[l]),k=new Set(a.map(j=>j.credentialType)),S=s&&!k.has("oauth_google"),E=t&&!k.has("oauth_apple"),p=(r||f)&&!k.has("webauthn_passkey"),y=o&&!k.has("solana"),x=S||E||p||y;return i&&a.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[d&&e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:d.message},onDismiss:h}),a.length===0&&!i&&e.jsx("p",{className:"cedros-linked-accounts-empty",children:"No linked sign-in methods found."}),a.length>0&&e.jsx("ul",{className:"cedros-linked-credential-list",children:a.map(j=>e.jsx(Ed,{credential:j,isUnlinking:w===j.id,onUnlink:v},j.id))}),x&&e.jsxs("div",{className:"cedros-linked-add",children:[e.jsx("p",{className:"cedros-linked-add-label",children:"Link a new sign-in method"}),e.jsxs("div",{className:"cedros-linked-add-buttons",children:[S&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(ta,{})," Google"]}),E&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(ra,{})," Apple"]}),p&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:A,disabled:g,children:g?e.jsx(Q.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Vt,{})," Passkey"]})}),y&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(na,{})," Solana"]})]})]})]})}function Ed({credential:s,isUnlinking:t,onUnlink:r}){const o=s.label||ea[s.credentialType],n=_d[s.credentialType]||Ld;return e.jsxs("li",{className:"cedros-linked-credential",children:[e.jsx("div",{className:"cedros-linked-credential__icon",children:e.jsx(n,{})}),e.jsxs("div",{className:"cedros-linked-credential__info",children:[e.jsx("span",{className:"cedros-linked-credential__name",children:o}),e.jsxs("span",{className:"cedros-linked-credential__meta",children:["Added ",kn(s.createdAt),s.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",kn(s.lastUsedAt)]}),s.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>r(s),disabled:t,title:s.isPrimary?"Cannot remove primary sign-in method":"Remove",children:t?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function kn(s){const t=new Date(s),o=new Date().getTime()-t.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n}m ago`:a<24?`${a}h ago`:i<30?`${i}d ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const _d={password:Pd,oauth_google:ta,oauth_apple:ra,solana:na,webauthn_passkey:Vt,webauthn_security_key:Vt,totp:Rd,sso_oidc:Td};function Ld(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M12 8v4m0 4h.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Pd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M7 11V7a5 5 0 0110 0v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"currentColor"})]})}function ta(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21.8 12.2c0-.7-.1-1.4-.2-2H12v3.8h5.5a4.7 4.7 0 01-2 3.1v2.5h3.3c1.9-1.7 3-4.3 3-7.4z",fill:"#4285F4"}),e.jsx("path",{d:"M12 22c2.7 0 5-.9 6.6-2.4l-3.3-2.5c-.9.6-2 1-3.3 1-2.5 0-4.7-1.7-5.4-4H3.2v2.6A10 10 0 0012 22z",fill:"#34A853"}),e.jsx("path",{d:"M6.6 14.1a6 6 0 010-4.2V7.3H3.2a10 10 0 000 9.4l3.4-2.6z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.9c1.4 0 2.7.5 3.7 1.4l2.8-2.8A10 10 0 0012 2 10 10 0 003.2 7.3l3.4 2.6C7.3 7.6 9.5 5.9 12 5.9z",fill:"#EA4335"})]})}function ra(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C3.79 16.16 4.36 9.53 8.72 9.28c1.3.07 2.2.74 2.96.8.93-.2 1.82-.92 3.03-.83 1.47.12 2.57.72 3.28 1.83-3.02 1.8-2.3 5.75.5 6.86-.6 1.53-1.37 3.04-2.44 4.34zM12.03 9.2C11.88 7.17 13.5 5.5 15.4 5.35c.29 2.28-2.08 3.98-3.37 3.85z",fill:"currentColor"})})}function na(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M2 10h20",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"17",cy:"14",r:"1.5",fill:"currentColor"})]})}function Vt(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"10",cy:"7",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M3 21v-2a7 7 0 017-7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M17 14v4m0 0v2m0-2h-2m2 0h2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Rd(){return e.jsxs("svg",{width:"20",height:"20",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("path",{d:"M9 12h6M12 9v6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Td(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"})]})}class Md{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}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 oa(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useMemo(()=>new Md(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),m=c.useCallback(async()=>{if(t!=="authenticated"){n([]);return}i(!0),l(null);try{const w=await h.listSessions();n(w)}catch(w){l(w)}finally{i(!1)}},[t,h]);c.useEffect(()=>{t==="authenticated"?m():n([])},[t,m]);const u=c.useCallback(async()=>{i(!0),l(null);try{const w=await h.revokeAllSessions();return await m(),w}catch(w){throw l(w),w}finally{i(!1)}},[h,m]),f=c.useMemo(()=>o.filter(w=>!w.isCurrent).length,[o]);return{sessions:o,isLoading:a,error:d,fetchSessions:m,revokeAllSessions:u,otherSessionCount:f}}const Id={profile:"Profile",security:"Security",linked:"Linked Accounts"},Bd=["profile","security","linked"];function Ud({defaultTab:s="profile",onClose:t,onPasswordChange:r,onTotpChange:o,onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:d,className:l=""}){const[h,m]=c.useState(s),{sessions:u,isLoading:f,error:w,revokeAllSessions:b}=oa();return e.jsxs("div",{className:`cedros-account-settings ${l}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:Bd.map(g=>e.jsx("button",{type:"button",role:"tab","aria-selected":h===g,className:`cedros-account-tab ${h===g?"cedros-account-tab-active":""}`,onClick:()=>m(g),children:Id[g]},g))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[h==="profile"&&e.jsx(Jo,{onPasswordChange:r}),h==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Zo,{onStatusChange:o}),e.jsx(jo,{sessions:u,isLoading:f,error:w??void 0,onRevokeAll:async()=>{await b()}})]}),h==="linked"&&e.jsx(sa,{onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:d})]}),t&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})}function Dd({onComplete:s,className:t}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${t??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(cr,{onSuccess:s})})]})}function Fd({onComplete:s,onSkip:t,className:r}){const{user:o}=D.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:d}=hs(),[l,h]=c.useState(o?.name??""),m=c.useCallback(async f=>{f.preventDefault(),d();const w=l.trim();if(!w){s?.();return}try{await i({name:w}),s?.()}catch{}},[l,i,d,s]),u=l.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${r??""}`,children:[e.jsxs("div",{className:"cedros-complete-account__header",children:[e.jsx("h2",{className:"cedros-complete-account__title",children:"Complete Your Profile"}),e.jsx("p",{className:"cedros-complete-account__description",children:"Please fill in your name to get started."})]}),e.jsxs("form",{onSubmit:m,className:"cedros-complete-account__form",children:[e.jsxs("div",{className:"cedros-complete-account__field",children:[e.jsx("label",{htmlFor:"cedros-complete-name",className:"cedros-complete-account__label",children:"Name"}),e.jsx("input",{id:"cedros-complete-name",type:"text",value:l,onChange:f=>h(f.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),a&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:a.message}),e.jsxs("div",{className:"cedros-complete-account__actions",children:[e.jsx("button",{type:"submit",className:"cedros-complete-account__button cedros-complete-account__button--primary",disabled:n||!u,children:n?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:t,disabled:n,children:"Skip"})]})]})]})}function aa(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),d=c.useCallback(async m=>await i.get(`/username/available?username=${encodeURIComponent(m)}`,{credentials:"include"}),[i]),l=c.useCallback(async()=>{try{return(await i.get("/username/available?username=",{credentials:"include"})).suggestion??null}catch{return null}},[i]),h=c.useCallback(async m=>{o(!0),a(null);try{await i.patch("/me",{username:m})}catch(u){const f=u instanceof Error?u:new Error(String(u));throw a(f),f}finally{o(!1)}},[i]);return{checkAvailability:d,getSuggestion:l,setUsername:h,isLoading:r,error:n}}function Od({onComplete:s,onSkip:t,className:r}){const{checkAvailability:o,getSuggestion:n,setUsername:a,isLoading:i,error:d}=aa(),[l,h]=c.useState(""),[m,u]=c.useState("idle"),[f,w]=c.useState(""),b=c.useRef(null),g=c.useRef(!0);c.useEffect(()=>(g.current=!0,n().then(k=>{g.current&&k&&(h(k),u("available"),w("Available"))}),()=>{g.current=!1}),[n]);const N=c.useCallback(k=>{const S=k.toLowerCase().replace(/[^a-z0-9_]/g,"");if(h(S),u("idle"),w(""),b.current&&clearTimeout(b.current),S.length<3){S.length>0&&(u("error"),w("At least 3 characters"));return}u("checking"),b.current=setTimeout(async()=>{try{const E=await o(S);if(!g.current)return;E.error?(u("error"),w(E.error)):E.available?(u("available"),w("Available")):(u("taken"),w("Already taken"),E.suggestion)}catch{if(!g.current)return;u("error"),w("Could not check availability")}},400)},[o]),A=c.useCallback(async k=>{if(k.preventDefault(),!(m!=="available"||!l.trim()))try{await a(l.trim()),s?.()}catch{}},[l,m,a,s]),v=m==="available"&&!i;return e.jsxs("div",{className:`cedros-choose-username ${r??""}`,children:[e.jsxs("div",{className:"cedros-choose-username__header",children:[e.jsx("h2",{className:"cedros-choose-username__title",children:"Choose a Username"}),e.jsx("p",{className:"cedros-choose-username__description",children:"Pick a unique handle for your account."})]}),e.jsxs("form",{onSubmit:A,className:"cedros-choose-username__form",children:[e.jsxs("div",{className:"cedros-choose-username__field",children:[e.jsx("label",{htmlFor:"cedros-choose-username",className:"cedros-choose-username__label",children:"Username"}),e.jsxs("div",{className:"cedros-choose-username__input-wrapper",children:[e.jsx("span",{className:"cedros-choose-username__prefix",children:"@"}),e.jsx("input",{id:"cedros-choose-username",type:"text",value:l,onChange:k=>N(k.target.value),placeholder:"swift_falcon_42",className:"cedros-choose-username__input",maxLength:30,autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),f&&e.jsx("span",{className:`cedros-choose-username__status cedros-choose-username__status--${m}`,role:m==="error"||m==="taken"?"alert":void 0,children:m==="checking"?"Checking...":f})]}),d&&e.jsx("div",{className:"cedros-choose-username__error",role:"alert",children:d.message}),e.jsxs("div",{className:"cedros-choose-username__actions",children:[e.jsx("button",{type:"submit",className:"cedros-choose-username__button cedros-choose-username__button--primary",disabled:!v,children:i?"Saving...":"Continue"}),e.jsx("button",{type:"button",className:"cedros-choose-username__button cedros-choose-username__button--secondary",onClick:t,disabled:i,children:"Skip"})]})]})]})}function ia(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),i=c.useCallback(()=>{n(null)},[]),d=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(b)||b<=0){const g=new Error(`Invalid deposit amount: ${b}. Must be a positive integer (lamports).`);throw n(g.message),g}r(!0),n(null);try{return await a.post("/deposit",{amount_lamports:b})}catch(g){const N=M.handleApiError(g,"Failed to execute deposit");throw n(N.message),N}finally{r(!1)}},[a]),l=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");return await a.get(`/deposit/status/${encodeURIComponent(b)}`)},[a]),h=c.useCallback(async()=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/deposit/config")}catch(b){const g=M.handleApiError(b,"Failed to get deposit config");throw n(g.message),g}finally{r(!1)}},[a]),m=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=new URLSearchParams;b?.limit!==void 0&&g.set("limit",String(b.limit)),b?.offset!==void 0&&g.set("offset",String(b.offset));const N=g.toString(),A=N?`/deposits?${N}`:"/deposits";return await a.get(A)}catch(g){const N=M.handleApiError(g,"Failed to list deposits");throw n(N.message),N}finally{r(!1)}},[a]),u=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=new URLSearchParams({input_mint:b.inputMint,amount:String(b.amount),taker:b.taker});return await a.get(`/deposit/quote?${g}`)}catch(g){const N=M.handleApiError(g,"Failed to get deposit quote");throw n(N.message),N}finally{r(!1)}},[a]),f=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/public",b)}catch(g){const N=M.handleApiError(g,"Failed to execute public deposit");throw n(N.message),N}finally{r(!1)}},[a]),w=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/micro",b)}catch(g){const N=M.handleApiError(g,"Failed to execute micro deposit");throw n(N.message),N}finally{r(!1)}},[a]);return{deposit:d,getQuote:u,publicDeposit:f,microDeposit:w,getStatus:l,getConfig:h,listDeposits:m,isLoading:t,error:o,clearError:i}}function dr({tokens:s,selectedToken:t,onSelect:r,openSignal:o,placeholder:n="Select token",disabled:a=!1,className:i="",searchable:d=!0}){const[l,h]=c.useState(!1),[m,u]=c.useState(""),f=c.useRef(null),w=c.useRef(null),b=c.useMemo(()=>{if(!m.trim())return s;const v=m.toLowerCase();return s.filter(k=>k.symbol.toLowerCase().includes(v)||k.name.toLowerCase().includes(v)||k.mint.toLowerCase().includes(v))},[s,m]);c.useEffect(()=>{const v=k=>{f.current&&!f.current.contains(k.target)&&(h(!1),u(""))};if(l)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[l]),c.useEffect(()=>{l&&d&&w.current&&w.current.focus()},[l,d]),c.useEffect(()=>{o===void 0||a||(h(!0),u(""))},[o,a]);const g=c.useCallback(()=>{a||(h(v=>!v),l&&u(""))},[a,l]),N=c.useCallback(v=>{r(v),h(!1),u("")},[r]),A=c.useCallback(v=>{v.key==="Escape"?(h(!1),u("")):v.key==="Enter"&&b.length===1&&N(b[0])},[b,N]);return e.jsxs("div",{ref:f,className:`cedros-token-selector ${l?"cedros-token-selector-open":""} ${a?"cedros-token-selector-disabled":""} ${i}`,onKeyDown:A,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:g,disabled:a,"aria-haspopup":"listbox","aria-expanded":l,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:v=>{v.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:n}),e.jsx("span",{className:"cedros-token-selector-arrow",children:l?"▲":"▼"})]}),l&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[d&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:w,type:"text",value:m,onChange:v=>u(v.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:b.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:b.map(v=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===v.mint?"cedros-token-option-selected":""}`,onClick:()=>N(v),role:"option","aria-selected":t?.mint===v.mint,children:[v.logoUrl&&e.jsx("img",{src:v.logoUrl,alt:v.symbol,className:"cedros-token-icon",onError:k=>{k.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:v.symbol}),e.jsx("span",{className:"cedros-token-name",children:v.name})]}),t?.mint===v.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},v.mint))})})]})]})}function zs(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const ur="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=",Wd=1e4,Ds=1e3,ca=3;function qd(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function zd(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 ${qd(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function hr(s,t,r){return Math.min(Math.max(s,t),r)}function $d(s,t){if(t<=0)return 0;const r=hr(s/t,0,1);return Math.round(Math.pow(r,1/ca)*Ds)}function Vd(s,t){const r=hr(s/Ds,0,1);return t*Math.pow(r,ca)}function la(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function Hd(s){return s<1?2:0}function Sn(s){const t=la(s),r=Math.round(s/t)*t,o=Hd(t);return Number(r.toFixed(o))}function mr({config:s,valueUsd:t,onChange:r,maxUsd:o=Wd,disabled:n=!1,className:a=""}){const i=hr(Number.isFinite(t)?t:0,0,o),d=c.useMemo(()=>zs(i,s),[i,s]),l=zd(d,s),h=$d(i,o),m=h/Ds*100;return e.jsxs("div",{className:`cedros-tiered-slider ${a}`,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:i||"",onChange:u=>r(Sn(Math.max(0,Math.min(parseFloat(u.target.value)||0,o)))),placeholder:"Enter amount",disabled:n,min:0,step:la(i),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-${d}`,children:[d==="sol_micro"&&e.jsx("img",{src:ur,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),l.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:l.detail})]})]}),e.jsx("input",{type:"range",min:0,max:Ds,step:1,value:h,onChange:u=>r(Sn(Vd(parseFloat(u.target.value),o))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${m}%, var(--cedros-border) ${m}%, var(--cedros-border) 100%)`},disabled:n,"aria-label":"Deposit amount slider"}),l.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:l.note})]})}const Gd="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=",Qd="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==",Kd="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",Yd="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==",Zd="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==",Xd="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==",Jd="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",eu="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",su="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";function da(s){const t=s.toUpperCase();return $s.find(o=>o.symbol===t)?.decimals??6}function tu(s,t){const r=s.toUpperCase(),n=$s.find(a=>a.symbol===r)?.decimals??t;return n===void 0?2:r==="SOL"?4:n===6&&r!=="SOL"?2:n>6?6:n}const $s=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:ur},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Xd},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:su},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:Kd},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:eu},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Zd},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Jd},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Qd},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Gd},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Yd}];function ru(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function nu(s,t,r){const{feePolicy:o,privacyFeePercent:n,swapFeePercent:a,companyFeePercent:i}=s;let d=i;return r||(o==="user_pays_all"?(d+=a,t&&(d+=n)):o==="user_pays_privacy"&&t?d+=n:o==="user_pays_swap"&&(d+=a)),d}const Es=1e9,Xe={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:ur},Je={mint:"other",symbol:"OTHER",name:"Other",decimals:6},ua=1e4;function ou(s,t){const r=t<s.publicMinUsd,o=t>=s.privateMinUsd,n=[],a=!r&&o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),i=!r&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),d=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(a){const l=s.privacyFeeFixedLamports/Es,h=s.privacyFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Privacy",solAmount:l,percent:h,usdAmount:m+u})}if(i){const l=s.swapFeeFixedLamports/Es,h=s.swapFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Swap",solAmount:l,percent:h,usdAmount:m+u})}if(d){const l=s.companyFeeFixedLamports/Es,h=s.companyFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Service",solAmount:l,percent:h,usdAmount:m+u})}return n}function ha(s,t,r){const o=ou(s,t),n=r===0?0:r<.01?.01:r;if(o.length===0)return r===0?"No fees":`Total: $${n.toFixed(2)}`;const a=o.reduce((b,g)=>b+g.solAmount,0),i=o.reduce((b,g)=>b+g.percent,0),d={fee:7,sol:8,rate:7,usd:8},l=b=>{const g=b.label.padEnd(d.fee),N=b.solAmount.toFixed(4).padStart(6).padEnd(d.sol),A=(b.percent.toFixed(2)+"%").padStart(5).padEnd(d.rate),k=("$"+(b.usdAmount===0?0:Math.max(b.usdAmount,.01)).toFixed(2)).padEnd(d.usd);return`${g} │ ${N} │ ${A} │ ${k}`},h=`${"Fee".padEnd(d.fee)} │ ${"SOL".padEnd(d.sol)} │ ${"+ Rate".padEnd(d.rate)} │ ${"= Total".padEnd(d.usd)}`,m=`${"─".repeat(d.fee)}─┼─${"─".repeat(d.sol)}─┼─${"─".repeat(d.rate)}─┼─${"─".repeat(d.usd)}`,u=("$"+n.toFixed(2)).padEnd(d.usd),f=`${"TOTAL".padEnd(d.fee)} │ ${a.toFixed(4).padStart(6).padEnd(d.sol)} │ ${(i.toFixed(2)+"%").padStart(5).padEnd(d.rate)} │ ${u}`;return[h,m,...o.map(l),m,f].join(`
|
|
2059
|
+
`)}function au(s){const t=[],r=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,o=s.swapFeeFixedLamports>0||s.swapFeePercent>0,n=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return r&&t.push("Privacy Cash fee"),o&&t.push("swap fee"),n&&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 Vs(s,t){if(t<=0)return 0;const r=t<s.publicMinUsd,o=t>=s.privateMinUsd,n=nu(s,o,r);let a=s.companyFeeFixedLamports;r||(o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(a+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(a+=s.swapFeeFixedLamports));const i=a/Es*s.solPriceUsd,d=t*(n/100);return i+d}function ma(s,t,r){return s==="sol"?"SOL":s==="single-token"?t.symbol:r.some(n=>n.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function Cn(s){return s.map(t=>t.trim()).filter(Boolean)}const iu=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function pr(s,t,r){if(iu.has(s.symbol))return 1;const o=t.tokenPrices?.[s.symbol];if(o&&o>0)return o;if(s.symbol==="SOL")return t.solPriceUsd||null;const n=r?.[s.symbol];return n&&n>0?n:null}function pa(s,t){return s.toFixed(tu(t))}function cu({config:s,currencyMode:t,depositMethod:r,tokens:o=[],defaultToken:n,minAmount:a,maxAmount:i=1e4,onSuccess:d,onError:l,onCancel:h,onUnlockRequired:m,onAuthorize:u,className:f="",showStepIndicator:w=!0,pollInterval:b=5e3,demoMode:g=!1,demoAutoConfirmMs:N,tokenPriceUsd:A,showExplainer:v=!1,siteName:k,explainerConfig:S}){const{deposit:E,getStatus:p,error:y,clearError:x}=ia(),j=D.useWallet(),L=Cn(s.quickActionTokens),C=Cn(s.customTokenSymbols),P=c.useMemo(()=>{const G=s.customTokens??[];if(G.length===0)return o;const Z=new Set(o.map(re=>re.symbol)),ee=[...o];for(const re of G)Z.has(re.symbol)||(ee.push({mint:re.mint,symbol:re.symbol,name:re.symbol,decimals:re.decimals,logoUrl:re.logoUrl}),Z.add(re.symbol));return ee},[o,s.customTokens]),_=c.useMemo(()=>{if(C.length===0)return P;const G=P.filter(Z=>C.includes(Z.symbol));return G.length>0?G:P},[P,C]),R=s.privateDepositsEnabled,T=r?r==="sign"&&!R?"receive":r:R&&j.hasExternalWallet?"sign":"receive",I=L[0]?P.find(G=>G.symbol===L[0]):void 0,O=t==="sol"?Xe:t==="single-token"?I??P.find(G=>G.symbol==="USDC")??P[0]??Xe:n??I??P.find(G=>G.symbol==="USDC")??P.find(G=>G.symbol!=="SOL")??P[0]??Xe,W=c.useCallback(()=>v?"explainer":"unlock",[v]),[q,U]=c.useState(W),[F,V]=c.useState(O),[Y,X]=c.useState(""),[B,z]=c.useState(null),[$,H]=c.useState(null),[se,ue]=c.useState(null),[we,rs]=c.useState(null),[Ue,De]=c.useState(!1),[Hs,ns]=c.useState(!1),[$e,K]=c.useState(null),ge=c.useRef(null);c.useEffect(()=>()=>{ge.current&&clearTimeout(ge.current)},[]),c.useEffect(()=>{U(W()),V(O),X(""),z(null),H(null),ue(null),rs(null),De(!1),ns(!1),K(null),x()},[t,T,O,x]);const be=a??s.privateMinSol,ms=i,Fe=parseFloat(Y),Ve=j.status==="enrolled_locked"||j.status==="enrolled_unlocked"||j.status==="unlocked",He=Ve&&j.isUnlocked,Gs=Ve&&!j.isUnlocked,br=c.useCallback(()=>{let ee=T==="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 v&&(ee=[{key:"explainer",label:"Info"},...ee]),ee},[T,v])(),ya=br.findIndex(G=>G.key===q),xr=c.useCallback(G=>{V(G)},[]),va=c.useCallback(async G=>{if(!u){U(T==="sign"?"confirm":"show-address");return}ns(!0),H(null);try{const ee=await u(G,T==="sign"?Fe:null,F);ue(ee.sessionId),rs(ee.depositAddress),U(T==="sign"?"confirm":"show-address")}catch(Z){const ee=Z instanceof Error?Z:new Error("Authorization failed");H(ee.message)}finally{ns(!1)}},[u,T,Fe,F]),Aa=c.useCallback(async(G,Z)=>{x(),H(null),U("signing");const ee=G??Fe,re=Z??F;if(!g){if(Gs&&m){m(),U("confirm");return}if(!He){H("Wallet not ready"),U("error");return}}try{const pe=Math.round(ee*Math.pow(10,re.decimals));if(g){await new Promise(Ks=>setTimeout(Ks,1500));const xe={token:t==="sol"?null:re,amount:ee,amountSmallestUnit:pe,txSignature:`demo-tx-${Date.now()}`,sessionId:se||`demo-session-${Date.now()}`,response:{sessionId:se||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:pe,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};z(xe),U("success"),d?.(xe);return}const Ce=await E(pe),os={token:t==="sol"?null:re,amount:ee,amountSmallestUnit:pe,txSignature:Ce.txSignature,sessionId:Ce.sessionId,response:Ce,method:"sign"};z(os),U("success"),d?.(os)}catch(pe){const Ce=pe instanceof Error?pe:new Error("Deposit failed");H(Ce.message),U("error"),l?.(Ce)}},[E,Fe,F,t,g,se,He,Gs,m,d,l,x]),ja=c.useCallback(()=>{U("waiting")},[]),Qs=c.useCallback(async()=>{const G=we||j.solanaPubkey;if(G){ge.current&&clearTimeout(ge.current);try{await navigator.clipboard.writeText(G),De(!0),ge.current=setTimeout(()=>De(!1),2e3)}catch{const Z=document.createElement("textarea");Z.value=G,document.body.appendChild(Z),Z.select(),document.execCommand("copy"),document.body.removeChild(Z),De(!0),ge.current=setTimeout(()=>De(!1),2e3)}}},[we,j.solanaPubkey]);c.useEffect(()=>{if(!(q==="confirm"||q==="show-address"||q==="waiting")||!se||g)return;let Z=!1,ee=0,re=0;const pe=360,Ce=5,os=async()=>{if(!(Z||ee>=pe)){ee++;try{const xe=await p(se);if(re=0,xe.status==="completed"||xe.status==="detected"){const Ks=xe.amountLamports?xe.amountLamports/Math.pow(10,F.decimals):0,ka=xe.amountLamports||0,yr={token:t==="sol"?null:F,amount:Ks,amountSmallestUnit:ka,txSignature:xe.txSignature||"",sessionId:se,response:xe,method:"receive",depositAddress:j.solanaPubkey??void 0};z(yr),U("success"),d?.(yr);return}}catch{if(re++,re>=Ce){H("Unable to check deposit status. Please check your connection and try again.");return}}Z||setTimeout(os,b)}};return os(),()=>{Z=!0}},[q,se,g,p,F,t,j.solanaPubkey,d,b]),c.useEffect(()=>{if(!g||!N||q!=="waiting"||T!=="receive"||!we)return;const G=window.setTimeout(()=>{const Z=$e??s.privateMinUsd,ee=F.symbol==="SOL"&&s.solPriceUsd>0?Z/s.solPriceUsd:Z,re=Math.round(ee*Math.pow(10,F.decimals)),pe={token:t==="sol"?null:F,amount:ee,amountSmallestUnit:re,txSignature:`demo-tx-${Date.now()}`,sessionId:se||`demo-session-${Date.now()}`,response:{sessionId:se||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:re,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:we??void 0};z(pe),U("success"),d?.(pe)},N);return()=>window.clearTimeout(G)},[g,N,q,T,we,$e,s,F,t,se,d]);const Na=c.useCallback(()=>{U(W()),X(""),z(null),H(null),x()},[W,x]);return s.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${f}`,children:[w&&q!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:br.map((G,Z)=>{const ee=ya>=Z,re=G.key===q;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${ee?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${ee?"active":""} ${re?"current":""}`,children:Z+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${ee?"active":""}`,children:G.label})]},G.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[q==="explainer"&&e.jsx(lu,{siteName:k,config:S,depositConfig:s,currencyMode:t,token:F,tokens:_,onContinue:()=>U("unlock"),onCancel:h}),q==="unlock"&&e.jsx(du,{token:F,tokens:_,currencyMode:t,depositMethod:T,isAuthorizing:Hs,error:$,onAuthorize:va,onBack:v?()=>U("explainer"):void 0,onCancel:h}),q==="confirm"&&T==="sign"&&e.jsx(uu,{token:F,tokens:P,quickActionSymbols:L,customTokenSymbols:C,currencyMode:t,minAmount:be,maxAmount:ms,depositAddress:we||j.solanaPubkey,walletReady:He||g,needsUnlock:Gs&&!g,copied:Ue,isListening:!!se&&!g,config:s,onCopy:Qs,onTokenSelect:xr,onUnlockRequired:m,onConfirm:(G,Z)=>Aa(G,Z),onBack:()=>U("unlock"),onCancel:h}),q==="signing"&&e.jsx(hu,{depositAddress:j.solanaPubkey}),q==="show-address"&&e.jsx(mu,{token:F,tokens:P,quickActionSymbols:L,customTokenSymbols:C,tokenPriceUsd:A,currencyMode:t,depositAddress:we||j.solanaPubkey,copied:Ue,isListening:!!se&&!g,config:s,onCopy:Qs,onTokenSelect:xr,onAmountChange:K,onSent:ja,onBack:()=>U("unlock"),onCancel:h}),q==="waiting"&&e.jsx(pu,{token:F,depositAddress:we||j.solanaPubkey,copied:Ue,feeLine:$e?(()=>{const G=Vs(s,$e);return G===0?"No fees":`Fees: $${Math.max(G,.01).toFixed(2)} total`})():"Fees: calculated after deposit",onCopy:Qs}),q==="success"&&B&&e.jsx(fu,{result:B,config:s,onNewDeposit:Na}),q==="error"&&e.jsx(gu,{error:$||y||"An error occurred",onRetry:()=>U("confirm"),onCancel:h})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${f}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function lu({siteName:s,config:t,depositConfig:r,currencyMode:o,token:n,tokens:a,onContinue:i,onCancel:d}){const l=t?.title??"How Deposits Work",h=t?.exchangeName??"Coinbase",m=es.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",u=t?.showExchangeSuggestion!==!1,f=ma(o,n,a),w=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",b=t?.body??w,g=ru(r),N=au(r);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:l}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:b}),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:g?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:N})]})]})]}),u&&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 ",f," using your credit card at"," ",e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:h}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[d&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:i,children:"Continue"})]})]})}function du({token:s,tokens:t,currencyMode:r,depositMethod:o,isAuthorizing:n,error:a,onAuthorize:i,onBack:d}){const[l,h]=c.useState(""),m=ma(r,s,t),u=f=>{f.preventDefault(),l.trim()&&(i(l),h(""))};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:o==="sign"?r==="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 ${m} deposit. This allows us to process your withdrawal when the privacy period ends.`:r==="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 ${m} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:u,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:l,onChange:f=>h(f.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:n,autoComplete:"current-password"})]}),a&&e.jsx("p",{className:"cedros-deposit-flow-error",children:a}),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:d,disabled:n,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!l.trim()||n,children:n?"Authorizing...":"Continue"})]})]})]})}function uu({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:o,currencyMode:n,minAmount:a,maxAmount:i,depositAddress:d,walletReady:l,needsUnlock:h,copied:m,isListening:u,config:f,onCopy:w,onTokenSelect:b,onUnlockRequired:g,onConfirm:N,onBack:A}){const[v,k]=c.useState(f.privateMinUsd),[S,E]=c.useState(!1),[p,y]=c.useState(!1),[x,j]=c.useState(0),[L,C]=c.useState(null),_=zs(v,f)==="sol_micro",R=s.symbol===Je.symbol,T=c.useMemo(()=>{const $=o.length===0?t:t.filter(ue=>o.includes(ue.symbol)),H=$.length>0?$:t;return H.some(ue=>ue.symbol===Je.symbol)?H:[...H,Je]},[t,o]),I=Vs(f,v),O=I===0?0:I<.01?.01:I,W=R?"Fees: calculated after deposit":I===0?"No fees":`Fees: $${O.toFixed(2)} total`,q=R?"":ha(f,v,I),U=pr(_?Xe:s,f),F=U?v/U:s.symbol==="SOL"&&f.solPriceUsd>0?v/f.solPriceUsd:null,V=F!=null?pa(F,_?"SOL":s.symbol):null,X=v-I<=0&&v>0,B=!R&&v>0&&!X&&F!=null&&F>=a&&F<=i;c.useEffect(()=>{if(n==="multi-token")if(_&&s.symbol!=="SOL"){C(s);const $=t.find(H=>H.symbol==="SOL");$&&b($)}else!_&&L&&s.symbol==="SOL"&&(b(L),C(null))},[_,s.symbol,n,t,b,L,s]);const z=()=>{B&&F!=null&&N(F,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."}),n==="multi-token"&&!_&&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:[r.map($=>{const H=t.find(ue=>ue.symbol===$),se=s.symbol===$;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${se?"is-active":""}`,onClick:()=>{H&&(E(!1),b(H))},disabled:!H,children:[H?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:H.logoUrl,alt:`${$} logo`}),$]},$)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${S?"is-active":""}`,onClick:()=>{E(!0),j($=>$+1)},children:"Custom"})]}),S&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(dr,{tokens:T,selectedToken:s,onSelect:b,openSignal:x})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(mr,{config:f,valueUsd:v,onChange:k,maxUsd:ua})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:R?"Sign to send tokens to this address":`Sign to send ${V??"--"} ${_?"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:d||"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:!d,children:m?"✓":"⧉"}),d&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${d}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),m&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),X&&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:[W,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${p?"is-open":""}`,"data-tooltip":q,"aria-label":`Fee breakdown: ${q.replaceAll(`
|
|
2060
|
+
`,", ")}`,"aria-expanded":p,onClick:$=>{$.stopPropagation(),y(H=>!H)},onBlur:()=>y(!1),onKeyDown:$=>{$.key==="Escape"&&y(!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."})]})]}),u&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for incoming transfers. We will confirm automatically."}),h&&e.jsxs("div",{className:"cedros-deposit-flow-warning",children:[e.jsx("p",{children:"Your wallet is locked. Unlock it to continue."}),g&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:g,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:z,disabled:!B||!l||!d,children:"Deposit"})]})]})}function hu({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 mu({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:o,tokenPriceUsd:n,currencyMode:a,depositAddress:i,copied:d,isListening:l,config:h,onCopy:m,onTokenSelect:u,onAmountChange:f,onSent:w,onBack:b}){const[g,N]=c.useState(h.privateMinUsd),[A,v]=c.useState(!1),[k,S]=c.useState(!1),[E,p]=c.useState(0),[y,x]=c.useState(null),L=zs(g,h)==="sol_micro",C=s.symbol===Je.symbol,P=c.useMemo(()=>{const F=o.length===0?t:t.filter(X=>o.includes(X.symbol)),V=F.length>0?F:t;return V.some(X=>X.symbol===Je.symbol)?V:[...V,Je]},[t,o]),_=Vs(h,g),R=_===0?0:_<.01?.01:_,T=C?"Fees: calculated after deposit":_===0?"No fees":`Fees: $${R.toFixed(2)} total`,I=C?"":ha(h,g,_),O=C||g>0,W=pr(L?Xe:s,h,n),q=W?g/W:null,U=q?pa(q,s.symbol):null;return c.useEffect(()=>{if(a==="multi-token")if(L&&s.symbol!=="SOL"){x(s);const F=t.find(V=>V.symbol==="SOL");F&&u(F)}else!L&&y&&s.symbol==="SOL"&&(u(y),x(null))},[L,s.symbol,a,t,u,y,s]),c.useEffect(()=>{f(g)},[g,f]),i?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."}),a==="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:[r.map(F=>{const V=t.find(X=>X.symbol===F),Y=s.symbol===F;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${Y?"is-active":""}`,onClick:()=>{V&&(v(!1),u(V))},disabled:!V,children:[V?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:V.logoUrl,alt:`${F} logo`}),F]},F)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${A?"is-active":""}`,onClick:()=>{v(!0),p(F=>F+1)},children:"Custom"})]}),A&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(dr,{tokens:P,selectedToken:s,onSelect:u,openSignal:E})})]}),!C&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(mr,{config:h,valueUsd:g,onChange:N,maxUsd:ua})]}),C&&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:C?"Send any token to this address":`Send ${U??"--"} ${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:i}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:m,title:"Copy address",children:d?"✓":"📋"})]}),d&&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:[T,!C&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${k?"is-open":""}`,"data-tooltip":I,"aria-label":`Fee breakdown: ${I.replaceAll(`
|
|
2061
|
+
`,", ")}`,"aria-expanded":k,onClick:F=>{F.stopPropagation(),S(V=>!V)},onBlur:()=>S(!1),onKeyDown:F=>{F.key==="Escape"&&S(!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)."})]})]}),l&&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:b,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:w,disabled:!O,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 pu({token:s,depositAddress:t,copied:r,feeLine:o,onCopy:n}){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:n,title:"Copy address",children:r?"✓":"⧉"}),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:o})]})]})]})]})}function fu({result:s,config:t,onNewDeposit:r}){const o=s.token??Xe,n=pr(o,t),a=n?s.amount*n:s.amount,i=Vs(t,a),d=Math.max(a-i,0),l=i===0?0:i<.01?.01:i;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()," ",o.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[s.txSignature&&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:["$",a.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:["-$",l.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:["+$",d.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:r,children:"Make Another Deposit"})})]})}function gu({error:s,onRetry:t,onCancel:r}){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:[r&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:t,children:"Try Again"})]})]})}function fr(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),i=c.useCallback(()=>{n(null)},[]),d=c.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/credits/balance/sol")}catch(m){const u=M.handleApiError(m,"Failed to fetch credit balance");throw n(u.message),u}finally{r(!1)}},[a]),l=c.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return(await a.get("/credits/balance")).balances}catch(m){const u=M.handleApiError(m,"Failed to fetch credit balances");throw n(u.message),u}finally{r(!1)}},[a]),h=c.useCallback(async m=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{const u=new URLSearchParams;m?.currency&&u.set("currency",m.currency),m?.limit!==void 0&&u.set("limit",m.limit.toString()),m?.offset!==void 0&&u.set("offset",m.offset.toString());const f=u.toString(),w=f?`/credits/history?${f}`:"/credits/history";return await a.get(w)}catch(u){const f=M.handleApiError(u,"Failed to fetch transaction history");throw n(f.message),f}finally{r(!1)}},[a]);return{getBalance:d,getAllBalances:l,getHistory:h,isLoading:t,error:o,clearError:i}}function wu({showAllCurrencies:s=!1,refreshInterval:t=0,compact:r=!1,className:o="",onLoad:n}){const{getBalance:a,getAllBalances:i,isLoading:d,error:l,clearError:h}=fr(),[m,u]=c.useState([]),[f,w]=c.useState(null),b=c.useCallback(async()=>{try{if(s){const g=await i();u(g),n?.(g)}else{const g=await a();u([g]),n?.([g])}w(null)}catch(g){w(g instanceof Error?g.message:"Failed to load balance")}},[s,a,i,n]);if(c.useEffect(()=>{b()},[b]),c.useEffect(()=>{if(t<=0)return;const g=setInterval(b,t);return()=>clearInterval(g)},[t,b]),f||l)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${o}`,children:[e.jsx("p",{className:"cedros-credit-error",children:f||l}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{h(),w(null),b()},children:"Retry"})]});if(d&&m.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${o}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(r){const g=m[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${o}`,children:[g?e.jsx("span",{className:"cedros-credit-value",title:`${g.balanceLamports} lamports`,children:g.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),d&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${o}`,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:b,disabled:d,title:"Refresh balance",children:d?"...":"↻"})]}),m.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:m.map(g=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:g.currency}),e.jsx("span",{className:"cedros-credit-amount",children:g.display})]},g.currency))})]})}const Rt=[{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 bu(s,t){const r=s<0,o=Math.abs(s),n=da(t),a=o/Math.pow(10,n),i=r?"-":"+";return t.toUpperCase()==="SOL"?`${i}${a.toFixed(4)} SOL`:`${i}$${a.toFixed(2)}`}function xu(s){const t=new Date(s),r=new Date,o=r.getTime()-t.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0})}function yu(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function vu(s,t){const r=(s||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":t?"+":"−"}function Au({defaultTab:s="all",pageSize:t=10,refreshInterval:r=0,className:o="",onLoad:n,onTransactionClick:a}){const{getHistory:i,isLoading:d,error:l,clearError:h}=fr(),[m,u]=c.useState(s),[f,w]=c.useState([]),[b,g]=c.useState(0),[N,A]=c.useState(0),[v,k]=c.useState(null),S=Rt.find(_=>_.key===m)||Rt[0],E=c.useMemo(()=>S.txTypes===null?f:f.filter(_=>{const R=_.txType||"";return S.txTypes.some(T=>R.toLowerCase()===T.toLowerCase())}),[f,S.txTypes]),p=c.useCallback(async()=>{try{const _=await i({limit:t*3,offset:N});w(_.transactions),g(_.total),n?.(_),k(null)}catch(_){k(_ instanceof Error?_.message:"Failed to load history")}},[t,N,i,n]);c.useEffect(()=>{A(0)},[m]),c.useEffect(()=>{p()},[p]),c.useEffect(()=>{if(r<=0)return;const _=setInterval(p,r);return()=>clearInterval(_)},[r,p]);const y=S.txTypes===null?b:E.length,x=Math.ceil(y/t),j=Math.floor(N/t)+1,L=_=>{const R=(_-1)*t;A(Math.max(0,Math.min(R,Math.max(0,y-t))))},C=_=>{u(_)};if(v||l)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${o}`,children:[e.jsx("p",{className:"cedros-tx-error",children:v||l}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{h(),k(null),p()},children:"Retry"})]});if(d&&f.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${o}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=_=>_.txTypes===null?f.length:f.filter(R=>{const T=R.txType||"";return _.txTypes.some(I=>T.toLowerCase()===I.toLowerCase())}).length;return e.jsxs("div",{className:`cedros-tx-history ${o}`,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:p,disabled:d,title:"Refresh",children:d?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:Rt.map(_=>{const R=P(_),T=m===_.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${T?"cedros-tx-tab-active":""}`,onClick:()=>C(_.key),children:[_.label,R>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:R})]},_.key)})}),E.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:m==="all"?"No transactions yet.":`No ${S.label.toLowerCase()} found.`}),m==="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:E.slice(0,t).map(_=>{const R=_.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${R?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>a?.(_),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),a?.(_))},role:a?"button":void 0,tabIndex:a?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${R?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:vu(_.txType,R)}),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:yu(_.txType)}),e.jsx("span",{className:`cedros-tx-amount ${R?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:bu(_.amountLamports,_.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:_.description}),e.jsx("span",{className:"cedros-tx-date",children:xu(_.createdAt)})]})]})]},_.id)})}),x>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(j-1),disabled:j<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",j," of ",x]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(j+1),disabled:j>=x,children:"Next"})]})]})]})}function gr(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),l=c.useCallback(()=>{n(null)},[]),h=c.useCallback(async()=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await d.get("/wallet/withdraw/balances")}catch(w){const b=M.handleApiError(w,"Failed to fetch wallet balances");throw n(b.message),b}},[d]),m=c.useCallback(async(w,b)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=await d.post("/wallet/withdraw/sol",{destination:w,amount_lamports:b});return i(g),g}catch(g){const N=M.handleApiError(g,"Failed to withdraw SOL");throw n(N.message),N}finally{r(!1)}},[d]),u=c.useCallback(async(w,b,g)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const N=await d.post("/wallet/withdraw/spl",{destination:w,token_mint:b,amount:g});return i(N),N}catch(N){const A=M.handleApiError(N,"Failed to withdraw token");throw n(A.message),A}finally{r(!1)}},[d]),f=c.useCallback(async(w=10,b=0)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const g=Math.max(1,Math.min(100,Math.trunc(w))),N=Math.max(0,Math.trunc(b)),A=new URLSearchParams({limit:String(g),offset:String(N)});return await d.get(`/wallet/withdraw/history?${A}`)}catch(g){const N=M.handleApiError(g,"Failed to fetch withdrawal history");throw n(N.message),N}},[d]);return{withdrawSol:m,withdrawSpl:u,getBalances:h,getHistory:f,isSubmitting:t,error:o,clearError:l,lastResult:a}}const Tt="So11111111111111111111111111111111111111112",ju={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Nu(s){return s.length<32||s.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(s)}function Mt(s){return s.length<=16?s:`${s.slice(0,6)}...${s.slice(-6)}`}function ys(s,t){return(Number(s)/Math.pow(10,t)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(t,6)})}function ku({onSuccess:s,onError:t,onCancel:r,className:o=""}){const n=M.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:i,getBalances:d,isSubmitting:l,error:h,clearError:m}=gr(),[u,f]=c.useState("loading"),[w,b]=c.useState([]),[g,N]=c.useState(null),[A,v]=c.useState(""),[k,S]=c.useState(""),[E,p]=c.useState(null),[y,x]=c.useState(null),[j,L]=c.useState(null),C=n?.config.solana?.network??"mainnet-beta",P=c.useMemo(()=>{if(!E?.txSignature)return"";const U=`https://explorer.solana.com/tx/${E.txSignature}`;return C==="mainnet-beta"?U:`${U}?cluster=${encodeURIComponent(C)}`},[E,C]),_=c.useMemo(()=>{if(!g||!k)return"0";const U=parseFloat(k);return isNaN(U)||U<=0?"0":Math.floor(U*Math.pow(10,g.decimals)).toString()},[k,g]);c.useEffect(()=>{if(!n)return;let U=!1;return(async()=>{try{const F=await d();if(U)return;const V=[];F.solLamports>0&&V.push({symbol:"SOL",mint:Tt,decimals:9,rawBalance:String(F.solLamports),displayBalance:ys(String(F.solLamports),9)});for(const Y of F.tokens){const X=ju[Y.mint]??Mt(Y.mint);V.push({symbol:X,mint:Y.mint,decimals:Y.decimals,rawBalance:Y.amount,displayBalance:ys(Y.amount,Y.decimals)})}b(V),f((V.length>0,"select"))}catch{U||(L("Failed to load wallet balances"),f("select"))}})(),()=>{U=!0}},[n,d]);const R=c.useCallback(U=>{N(U),f("form"),m(),x(null),S("")},[m]),T=c.useCallback(()=>{if(!g)return;const U=Number(g.rawBalance)/Math.pow(10,g.decimals);g.mint===Tt?S(String(Math.max(0,U-.01))):S(String(U))},[g]),I=c.useCallback(()=>{if(x(null),!A.trim()){x("Destination address is required");return}if(!Nu(A.trim())){x("Invalid Solana address");return}if(!k||parseFloat(k)<=0||isNaN(parseFloat(k))){x("Please enter a valid amount");return}if(_==="0"){x("Amount is too small");return}f("confirm")},[A,k,_]),O=c.useCallback(async()=>{if(g){f("processing"),m();try{let U;g.mint===Tt?U=await a(A.trim(),Number(_)):U=await i(A.trim(),g.mint,_),p(U),f("success"),s?.(U)}catch(U){f("confirm"),t?.(U instanceof Error?U:new Error(String(U)))}}},[g,A,_,a,i,m,s,t]),W=c.useCallback(()=>{m(),x(null),u==="form"?(f("select"),N(null),S(""),v("")):u==="confirm"&&f("form")},[u,m]),q=c.useCallback(()=>{f("select"),N(null),v(""),S(""),p(null),m(),x(null)},[m]);return n?e.jsxs("div",{className:`cedros-withdrawal ${o}`,children:[u==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),u==="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"})]}),j&&e.jsx(te.ErrorMessage,{error:j}),w.length===0&&!j&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:w.map(U=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>R(U),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:U.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:U.displayBalance})]},U.mint))}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:r,children:"Cancel"})]}),u==="form"&&g&&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:W,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",g.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",g.displayBalance," ",g.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:U=>v(U.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 (",g.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:k,onChange:U=>S(U.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:T,children:"Max"})]})]}),(y||h)&&e.jsx(te.ErrorMessage,{error:y||h||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:I,children:"Review Withdrawal"})]}),u==="confirm"&&g&&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:W,disabled:l,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:g.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:[ys(_,g.decimals)," ",g.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:Mt(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"})]})]}),h&&e.jsx(te.ErrorMessage,{error:h}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:W,disabled:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:O,disabled:l,children:l?"Sending...":"Confirm & Send"})]})]}),u==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(Q.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",g?.symbol,"..."]})]}),u==="success"&&E&&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:[ys(_,g?.decimals??9)," ",g?.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:P,target:"_blank",rel:"noreferrer",children:Mt(E.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:q,children:"Done"})]})]}):null}function Su(s,t){if(s==="sol")return"SOL";if(!t)return"SPL";const r=$s.find(o=>o.mint===t);return r?r.symbol:`${t.slice(0,4)}...${t.slice(-4)}`}function Cu(s,t){const r=Number(s);if(Number.isNaN(r))return s;const o=da(t),n=r/Math.pow(10,o);return t==="SOL"?`${n.toFixed(4)} SOL`:`${n.toFixed(2)} ${t}`}function Eu(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function _u(s){const t=new Date(s),r=new Date,o=r.getTime()-t.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0})}function Lu({pageSize:s=10,className:t="",onTransactionClick:r,explorerUrl:o="https://solscan.io"}){const n=o.startsWith("https://")?o:"https://solscan.io",{getHistory:a,error:i,clearError:d}=gr(),[l,h]=c.useState([]),[m,u]=c.useState(0),[f,w]=c.useState(0),[b,g]=c.useState(!1),[N,A]=c.useState(null),v=c.useCallback(async()=>{g(!0);try{const p=await a(s,f);h(p.items),u(p.total),A(null)}catch(p){A(p instanceof Error?p.message:"Failed to load withdrawal history")}finally{g(!1)}},[s,f,a]);c.useEffect(()=>{v()},[v]);const k=Math.ceil(m/s),S=Math.floor(f/s)+1,E=p=>{const y=(p-1)*s;w(Math.max(0,Math.min(y,Math.max(0,m-s))))};return N||i?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${t}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:N||i}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{d(),A(null),v()},children:"Retry"})]}):b&&l.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:v,disabled:b,title:"Refresh",children:b?"...":"↻"})]}),l.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:l.map(p=>{const y=Su(p.tokenType,p.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>r?.(p),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),r?.(p))},role:r?"button":void 0,tabIndex:r?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:[y," Withdrawal"]}),e.jsx("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:Cu(p.amount,y)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${n}/account/${p.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:Eu(p.destination)})," · ",e.jsx("a",{href:`${n}/tx/${p.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:_u(p.createdAt)})]})]})]},p.id)})}),k>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>E(S-1),disabled:S<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",S," of ",k]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>E(S+1),disabled:S>=k,children:"Next"})]})]})]})}function Pu({brandLogo:s,brandName:t,title:r="Welcome back",subtitle:o="Login with your Apple or Google account",termsText:n,onSuccess:a,defaultTab:i="login",children:d,className:l=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${l}`,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:r}),o&&e.jsx("p",{className:"cedros-full-page-subtitle",children:o})]}),d??e.jsx(qs,{defaultTab:i,onSuccess:a})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function Ru({brandName:s="Your Brand",brandLogo:t,tagline:r="Your tagline goes here. Make it compelling.",title:o="Sign in",subtitle:n="Enter your credentials to access your account",onSuccess:a,defaultTab:i="login",children:d,className:l=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${l}`,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}),r&&e.jsx("p",{className:"cedros-split-page-tagline",children:r})]})}),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:o}),n&&e.jsx("p",{className:"cedros-split-page-subtitle",children:n}),d??e.jsx(qs,{defaultTab:i,onSuccess:a})]})})]})}function Tu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=c.useMemo(()=>new Qt.OrgApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),a=c.useCallback(async l=>{o(h=>({...h,isLoading:!0,error:null}));try{const h=await n.authorize(l),m={allowed:h.allowed,reason:h.reason,isLoading:!1,error:null};return o(m),m}catch(h){const m={allowed:!1,reason:void 0,isLoading:!1,error:h};return o(m),m}},[n]),i=c.useCallback(async l=>(await a(l)).allowed,[a]),d=c.useCallback(()=>{o({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:i,lastCheck:r,clearCheck:d,checkAuthorization:a}}function Mu(){const{listAllWallets:s,createDerivedWallet:t,deleteDerivedWallet:r}=D.useWalletMaterial(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useCallback(async()=>{i(!0),l(null);try{const w=await s();n(w.wallets)}catch(w){const b=w instanceof Error?w.message:"Failed to list wallets";l(b)}finally{i(!1)}},[s]),m=c.useCallback(async w=>{i(!0),l(null);try{const b=await t({label:w});return await h(),b}catch(b){const g=b instanceof Error?b.message:"Failed to create wallet";throw l(g),b}finally{i(!1)}},[t,h]),u=c.useCallback(async w=>{i(!0),l(null);try{await r(w),await h()}catch(b){const g=b instanceof Error?b.message:"Failed to delete wallet";throw l(g),b}finally{i(!1)}},[r,h]),f=c.useCallback(()=>l(null),[]);return{wallets:o,isLoading:a,createWallet:m,deleteWallet:u,refresh:h,error:d,clearError:f}}function Iu(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),l=c.useCallback(async()=>{if(!d)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const u=await d.get("/wallet/pending-recovery");i(u)}catch(u){const f=M.handleApiError(u,"Failed to fetch pending recovery");throw n(f.message),f}finally{r(!1)}},[d]),h=c.useCallback(async()=>{if(!d)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const u={confirmed:!0};await d.post("/wallet/acknowledge-recovery",u),i(null)}catch(u){const f=M.handleApiError(u,"Failed to acknowledge recovery");throw n(f.message),f}finally{r(!1)}},[d]),m=c.useCallback(()=>n(null),[]);return c.useEffect(()=>{d&&s?.authState==="authenticated"&&l().catch(()=>{})},[d,s?.authState,l]),{hasPendingRecovery:a?.hasPendingRecovery??!1,recoveryType:a?.recoveryType??null,recoveryPhrase:a?.recoveryPhrase??null,expiresAt:a?.expiresAt?new Date(a.expiresAt):null,fetchPendingRecovery:l,acknowledgeRecovery:h,isLoading:t,error:o,clearError:m}}function Bu(s={}){const{onExternalSign:t}=s,{solanaPubkey:r,hasExternalWallet:o,status:n,isUnlocked:a}=D.useWallet(),{signTransaction:i,isSigning:d,error:l,clearError:h}=Lo(),m=c.useMemo(()=>o&&t?"external":n==="enrolled_locked"||n==="enrolled_unlocked"?"sss":"none",[o,t,n]),u=m!=="none",f=n==="enrolled_locked"||n==="enrolled_unlocked";return{signTransaction:c.useCallback(async(b,g)=>{if(m==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(b)}if(m==="sss"){if(!g&&!a)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return g?i(b,g):i(b)}throw new Error("No signing method available. Enroll a wallet first.")},[m,t,a,i]),signingMethod:m,canSign:u,isSigning:d,publicKey:r,hasExternalWallet:o,hasSssWallet:f,isSssUnlocked:a,error:l,clearError:h}}function Uu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(null),[n,a]=c.useState(!1),[i,d]=c.useState(null),l=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),h=c.useCallback(async()=>{a(!0),d(null);try{await l.post("/welcome-completed",{})}catch(u){const f=u instanceof Error?u:new Error(String(u));throw d(f),f}finally{a(!1)}},[l]),m=c.useCallback(()=>{o(null)},[]);return{postLoginAction:r,setPostLoginAction:o,markWelcomeCompleted:h,clearPostLogin:m,isLoading:n,error:i}}function Du(){const{config:s}=M.useCedrosLogin(),t=s.theme??"auto",r=D.useThemeManager({theme:t,themeOverrides:s.themeOverrides});return{mode:t,isDark:r.className==="cedros-dark",className:r.className,style:r.style,unstyled:s.unstyled??!1,overrides:s.themeOverrides}}function fa(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState([]),[l,h]=c.useState(0),m=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),u=c.useCallback(async()=>{o(!0),a(null);try{const w=await m.post("/access-codes/generate",{},{credentials:"include"});return d(b=>[w,...b]),h(b=>b+1),w}catch(w){const b=w instanceof Error?w:new Error(String(w));throw a(b),b}finally{o(!1)}},[m]),f=c.useCallback(async()=>{o(!0),a(null);try{const w=await m.get("/access-codes/mine",{credentials:"include"});d(w.items),h(w.total)}catch(w){const b=w instanceof Error?w:new Error(String(w));throw a(b),b}finally{o(!1)}},[m]);return{codes:i,total:l,generateCode:u,fetchCodes:f,isLoading:r,error:n}}function Fu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState(null),[m,u]=c.useState(null),[f,w]=c.useState(null),b=f!==null&&f!=="none",g=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),N=c.useCallback(async()=>{o(!0),a(null);try{const v=await g.get("/kyc/status",{credentials:"include"});return d(v.status),h(v.verifiedAt??null),u(v.expiresAt??null),w(v.enforcementMode),v}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[g]),A=c.useCallback(async()=>{o(!0),a(null);try{const v=await g.post("/kyc/start",void 0,{credentials:"include"});return d("pending"),v.redirectUrl}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[g]);return{status:i,verifiedAt:l,expiresAt:m,isRequired:b,enforcementMode:f,fetchStatus:N,startVerification:A,isLoading:r,error:n}}function ga(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState([]),[m,u]=c.useState(0),f=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),w=c.useCallback(async()=>{o(!0),a(null);try{const N=await f.get("/referral/rewards",{credentials:"include"});return d(N),N}catch(N){const A=N instanceof Error?N:new Error(String(N));throw a(A),A}finally{o(!1)}},[f]),b=c.useCallback(async(N=10,A=0)=>{o(!0),a(null);try{const v=await f.get(`/referral/rewards/history?limit=${N}&offset=${A}`,{credentials:"include"});return h(v.items),u(v.total),v}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[f]),g=c.useCallback(async N=>{o(!0),a(null);try{await f.post("/referral/payout-wallet",{walletAddress:N},{credentials:"include"}),d(A=>A&&{...A,payoutWalletAddress:N})}catch(A){const v=A instanceof Error?A:new Error(String(A));throw a(v),v}finally{o(!1)}},[f]);return{rewards:i,history:l,historyTotal:m,fetchRewards:w,fetchHistory:b,setPayoutWallet:g,isLoading:r,error:n}}function It(s,t){return t==="SOL"?(s/1e9).toFixed(4)+" SOL":"$"+(s/1e6).toFixed(2)}function Ou(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}const Wu=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function qu(s){return Wu.test(s)}function zu(s){switch(s){case"signup":return"Sign-up";case"spend":return"Spend";case"first_spend":return"First Spend";default:return s}}function $u({status:s}){const r={pending:"cedros-rewards-panel__badge--pending",completed:"cedros-rewards-panel__badge--completed",failed:"cedros-rewards-panel__badge--failed",credited:"cedros-rewards-panel__badge--credited"}[s]??"cedros-rewards-panel__badge--pending";return e.jsx("span",{className:`cedros-rewards-panel__badge ${r}`,children:s.charAt(0).toUpperCase()+s.slice(1)})}const vs=10;function Vu({explorerUrl:s="https://explorer.solana.com",className:t}){const{rewards:r,history:o,historyTotal:n,fetchRewards:a,fetchHistory:i,setPayoutWallet:d,isLoading:l,error:h}=ga(),[m,u]=c.useState(0),[f,w]=c.useState(""),[b,g]=c.useState(null),[N,A]=c.useState(!1),[v,k]=c.useState(!1);c.useEffect(()=>{a().catch(()=>{}),i(vs,0).catch(()=>{})},[a,i]),c.useEffect(()=>{r?.payoutWalletAddress!=null&&w(r.payoutWalletAddress)},[r?.payoutWalletAddress]);const S=c.useCallback(x=>{u(x),i(vs,x*vs).catch(()=>{})},[i]),E=Math.ceil(n/vs),p=c.useCallback(async()=>{const x=f.trim();if(x!==""&&!qu(x)){g("Invalid address. Must be a base58 string between 32 and 44 characters.");return}g(null),A(!0),k(!1);try{await d(x===""?null:x),k(!0)}catch(j){g(j instanceof Error?j.message:"Failed to save wallet address.")}finally{A(!1)}},[f,d]),y=r?.rewardType==="direct_payout"?"Direct Payout":"Credits";return e.jsxs("div",{className:`cedros-rewards-panel ${t??""}`.trim(),"aria-label":"Rewards dashboard",children:[h&&e.jsx("div",{className:"cedros-rewards-panel__error",role:"alert",children:h.message}),e.jsxs("section",{className:"cedros-rewards-panel__summary","aria-label":"Rewards summary",children:[e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Total Earned"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?It(r.totalEarned,r.currency):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Pending Payouts"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?`${It(r.pendingAmount,r.currency)} (${r.pendingCount})`:"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Referrals"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?String(r.referralCount):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Reward Type"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:e.jsx("span",{className:"cedros-rewards-panel__type-badge",children:y})})]})]}),r?.rewardType==="direct_payout"&&e.jsxs("section",{className:"cedros-rewards-panel__wallet-section","aria-label":"Payout wallet",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"Payout Wallet"}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-current",children:[e.jsx("span",{className:"cedros-rewards-panel__wallet-label",children:"Current address:"}),e.jsx("span",{className:"cedros-rewards-panel__wallet-address",children:r.payoutWalletAddress??"Not set"})]}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-form",children:[e.jsx("label",{htmlFor:"cedros-payout-wallet-input",className:"cedros-rewards-panel__wallet-input-label",children:"Wallet address"}),e.jsx("input",{id:"cedros-payout-wallet-input",type:"text",className:"cedros-rewards-panel__wallet-input",value:f,onChange:x=>{w(x.target.value),g(null),k(!1)},placeholder:"Base58 Solana address","aria-describedby":b?"cedros-wallet-error":void 0,disabled:N}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__wallet-save-btn",onClick:p,disabled:N||l,children:N?"Saving...":"Save"})]}),b&&e.jsx("div",{id:"cedros-wallet-error",className:"cedros-rewards-panel__wallet-error",role:"alert",children:b}),v&&!b&&e.jsx("div",{className:"cedros-rewards-panel__wallet-success",role:"status",children:"Wallet address saved."})]}),e.jsxs("section",{className:"cedros-rewards-panel__history-section","aria-label":"Reward history",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"History"}),l&&o.length===0?e.jsx("div",{className:"cedros-rewards-panel__loading","aria-busy":"true",children:"Loading..."}):o.length===0?e.jsx("div",{className:"cedros-rewards-panel__empty",children:"No rewards yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-rewards-panel__table-wrapper",role:"region","aria-label":"Reward history table",tabIndex:0,children:e.jsxs("table",{className:"cedros-rewards-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Date"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Type"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Amount"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Status"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Transaction"})]})}),e.jsx("tbody",{children:o.map(x=>e.jsxs("tr",{className:"cedros-rewards-panel__tr",children:[e.jsx("td",{className:"cedros-rewards-panel__td",children:Ou(x.createdAt)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:zu(x.triggerType)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:It(x.amount,x.currency)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:e.jsx($u,{status:x.status})}),e.jsx("td",{className:"cedros-rewards-panel__td",children:x.txSignature?e.jsxs("a",{href:`${s}/tx/${x.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-rewards-panel__tx-link","aria-label":`View transaction ${x.txSignature.slice(0,8)}... on Solana explorer`,children:[x.txSignature.slice(0,8),"..."]}):e.jsx("span",{className:"cedros-rewards-panel__tx-none",children:"—"})})]},x.id))})]})}),E>1&&e.jsxs("div",{className:"cedros-rewards-panel__pagination",role:"navigation","aria-label":"History pagination",children:[e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m-1),disabled:m===0||l,"aria-label":"Previous page",children:"Previous"}),e.jsxs("span",{className:"cedros-rewards-panel__page-info",children:[m+1," / ",E]}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m+1),disabled:m>=E-1||l,"aria-label":"Next page",children:"Next"})]})]})]})]})}function En(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}function _n(s){return s.expiresAt&&new Date(s.expiresAt)<new Date?"expired":s.maxUses!==null&&s.currentUses>=s.maxUses?"used":"active"}function Hu({status:s}){const t={active:"cedros-invite-panel__badge--active",used:"cedros-invite-panel__badge--used",expired:"cedros-invite-panel__badge--expired"};return e.jsx("span",{className:`cedros-invite-panel__badge ${t[s]??""}`,children:s.charAt(0).toUpperCase()+s.slice(1)})}function Gu({text:s}){const[t,r]=c.useState(!1),o=c.useCallback(async()=>{try{await navigator.clipboard.writeText(s),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},[s]);return e.jsx("button",{type:"button",className:"cedros-invite-panel__copy-btn",onClick:o,"aria-label":t?"Copied":`Copy code ${s}`,title:t?"Copied!":"Copy to clipboard",children:t?"✓":"Copy"})}function Qu({className:s}){const{codes:t,total:r,generateCode:o,fetchCodes:n,isLoading:a,error:i}=fa(),[d,l]=c.useState(!1),[h,m]=c.useState(null);c.useEffect(()=>{n().catch(()=>{})},[n]);const u=c.useCallback(async()=>{l(!0),m(null);try{await o()}catch(w){m(w instanceof Error?w.message:"Failed to generate invite code.")}finally{l(!1)}},[o]),f=t.filter(w=>_n(w)==="active").length;return e.jsxs("div",{className:`cedros-invite-panel ${s??""}`.trim(),"aria-label":"Invite code panel",children:[e.jsxs("div",{className:"cedros-invite-panel__header",children:[e.jsx("h2",{className:"cedros-invite-panel__title",children:"Invite Codes"}),e.jsxs("span",{className:"cedros-invite-panel__budget","aria-live":"polite",children:[f," active · ",r," total"]})]}),i&&e.jsx("div",{className:"cedros-invite-panel__error",role:"alert",children:i.message}),h&&e.jsx("div",{className:"cedros-invite-panel__error",role:"alert",children:h}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:u,disabled:d||a,"aria-busy":d,children:d?"Generating...":"Generate Invite Code"}),e.jsx("section",{className:"cedros-invite-panel__list-section","aria-label":"Your invite codes",children:a&&t.length===0?e.jsx("div",{className:"cedros-invite-panel__loading","aria-busy":"true",children:"Loading..."}):t.length===0?e.jsx("div",{className:"cedros-invite-panel__empty",children:"No invite codes yet. Generate one above."}):e.jsx("div",{className:"cedros-invite-panel__table-wrapper",role:"region","aria-label":"Invite codes table",tabIndex:0,children:e.jsxs("table",{className:"cedros-invite-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Code"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Uses"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Created"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Expires"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Status"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:e.jsx("span",{className:"cedros-sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:t.map(w=>{const b=_n(w),g=w.maxUses!==null?`${w.currentUses} / ${w.maxUses}`:`${w.currentUses}`;return e.jsxs("tr",{className:"cedros-invite-panel__tr",children:[e.jsx("td",{className:"cedros-invite-panel__td cedros-invite-panel__td--code",children:e.jsx("code",{className:"cedros-invite-panel__code",children:w.code})}),e.jsx("td",{className:"cedros-invite-panel__td",children:g}),e.jsx("td",{className:"cedros-invite-panel__td",children:En(w.createdAt)}),e.jsx("td",{className:"cedros-invite-panel__td",children:w.expiresAt?En(w.expiresAt):"—"}),e.jsx("td",{className:"cedros-invite-panel__td",children:e.jsx(Hu,{status:b})}),e.jsx("td",{className:"cedros-invite-panel__td",children:e.jsx(Gu,{text:w.code})})]},w.id)})})]})})})]})}function Ku({status:s,startVerification:t,className:r}){const[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useCallback(async()=>{n(!0),i(null);try{const m=await t();m&&(window.location.href=m)}catch(m){i(m instanceof Error?m.message:"Failed to start verification")}finally{n(!1)}},[t]);if(s==="verified")return null;let l;switch(s){case"pending":l="Your identity verification is being processed.";break;case"failed":l="Identity verification failed. Please try again.";break;case"expired":l="Your identity verification has expired. Please verify again.";break;case"canceled":l="Verification was canceled. Please try again.";break;default:l="Identity verification is required to continue.";break}const h=s!=="pending";return e.jsxs("div",{className:`cedros-kyc-banner ${r??""}`,role:"alert",children:[e.jsxs("div",{className:"cedros-kyc-banner-content",children:[e.jsx("span",{className:"cedros-kyc-banner-message",children:l}),h&&e.jsx("button",{type:"button",className:"cedros-kyc-banner-button",onClick:d,disabled:o,children:o?"Starting...":"Verify Identity"})]}),a&&e.jsx("div",{className:"cedros-kyc-banner-error",children:a})]})}const Yu=3e3,Zu=6e4;function Xu(s){switch(s){case"verified":return"Identity verified successfully!";case"failed":return"Verification failed. You can try again.";case"expired":return"Your identity verification has expired.";case"canceled":return"Verification was canceled.";default:return"Verification was canceled."}}function Ju({fetchStatus:s,onComplete:t,className:r}){const[o,n]=c.useState(null),[a,i]=c.useState(!1),d=c.useRef(t);d.current=t;const l=c.useRef(s);l.current=s,c.useEffect(()=>{let m=!1,u=null;const f=setTimeout(()=>{i(!0),u!==null&&clearInterval(u)},Zu),w=async()=>{try{const b=await l.current();if(m)return;n(b.status),b.status!=="pending"&&(clearTimeout(f),u!==null&&clearInterval(u),d.current?.(b.status))}catch{}};return w(),u=setInterval(w,Yu),()=>{m=!0,clearTimeout(f),u!==null&&clearInterval(u)}},[]);const h=!o||o==="pending";return e.jsx("div",{className:`cedros-kyc-callback ${r??""}`,role:"status","aria-live":"polite",children:a&&h?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:"cedros-kyc-callback-message",children:"Verification is taking longer than expected. Please refresh or check back later."}),t&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>t("pending"),children:"Continue"})]}):h?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("span",{className:"cedros-kyc-callback-spinner","aria-hidden":"true"}),e.jsx("p",{className:"cedros-kyc-callback-message",children:"Processing your verification..."})]}):e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:`cedros-kyc-callback-message cedros-kyc-callback-message--${o}`,children:Xu(o)}),t&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>t(o),children:"Continue"})]})})}function wa(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState(null),[m,u]=c.useState(null),[f,w]=c.useState(null),b=f!==null&&f!=="none",g=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),N=c.useCallback(async()=>{o(!0),a(null);try{const S=await g.get("/accreditation/status",{credentials:"include"});return d(S.status),h(S.verifiedAt??null),u(S.expiresAt??null),w(S.enforcementMode),S}catch(S){const E=S instanceof Error?S:new Error(String(S));throw a(E),E}finally{o(!1)}},[g]),A=c.useCallback(async(S,E)=>{o(!0),a(null);try{const p=await g.post("/accreditation/submit",{method:S,...E},{credentials:"include"});return d("pending"),p}catch(p){const y=p instanceof Error?p:new Error(String(p));throw a(y),y}finally{o(!1)}},[g]),v=c.useCallback(async(S,E,p)=>{o(!0),a(null);try{const y=new FormData;y.append("submissionId",S),y.append("documentType",p),y.append("file",E);const x=t?.getAccessToken?.(),j={};x&&(j.Authorization=`Bearer ${x}`);const L=await fetch(`${s.serverUrl}/accreditation/upload`,{method:"POST",headers:j,credentials:"include",body:y});if(!L.ok){const C=await L.text().catch(()=>L.statusText);throw new Error(`Upload failed (${L.status}): ${C}`)}return L.json()}catch(y){const x=y instanceof Error?y:new Error(String(y));throw a(x),x}finally{o(!1)}},[s.serverUrl,t]),k=c.useCallback(async()=>{o(!0),a(null);try{return(await g.get("/accreditation/submissions",{credentials:"include"})).submissions}catch(S){const E=S instanceof Error?S:new Error(String(S));throw a(E),E}finally{o(!1)}},[g]);return{status:i,verifiedAt:l,expiresAt:m,isRequired:b,enforcementMode:f,fetchStatus:N,submitVerification:A,uploadDocument:v,listSubmissions:k,isLoading:r,error:n}}const Ln=[{method:"income",label:"Income",description:"Verify via annual income ($200K+ individual / $300K+ joint)"},{method:"net_worth",label:"Net Worth",description:"Verify via net worth ($1M+ excluding primary residence)"},{method:"credential",label:"Professional Credential",description:"Verify via FINRA license (Series 7, 65, or 82)"},{method:"third_party_letter",label:"Third-Party Letter",description:"Upload a verification letter from a CPA, attorney, or RIA"},{method:"insider",label:"Insider / Officer",description:"Self-certify as a director, executive officer, or general partner"},{method:"investment_threshold",label:"Investment Threshold",description:"Qualify via investment commitment ($200K+ individual / $1M+ entity)"}];function As({label:s,acceptedTypes:t=".pdf,.jpg,.jpeg,.png,.tiff",documentType:r,files:o,onFilesChange:n,maxFiles:a=5}){const i=c.useRef(null),[d,l]=c.useState(!1),h=c.useCallback(u=>{if(!u)return;const f=Array.from(u),w=[...o,...f].slice(0,a);n(w)},[o,a,n]),m=u=>{n(o.filter((f,w)=>w!==u))};return e.jsxs("div",{className:"cedros-accreditation-wizard__upload-zone",children:[e.jsx("p",{className:"cedros-accreditation-wizard__upload-label",children:s}),e.jsxs("div",{className:`cedros-accreditation-wizard__drop-area${d?" cedros-accreditation-wizard__drop-area--active":""}`,role:"button",tabIndex:0,"aria-label":`Upload files: ${s}`,onClick:()=>i.current?.click(),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&i.current?.click()},onDragOver:u=>{u.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:u=>{u.preventDefault(),l(!1),h(u.dataTransfer.files)},children:[e.jsx("span",{children:"Click or drag files here"}),e.jsx("span",{className:"cedros-accreditation-wizard__upload-hint",children:t})]}),e.jsx("input",{ref:i,type:"file",accept:t,multiple:a>1,style:{display:"none"},onChange:u=>h(u.target.files),"aria-hidden":"true"}),o.length>0&&e.jsx("ul",{className:"cedros-accreditation-wizard__file-list","aria-label":"Uploaded files",children:o.map((u,f)=>e.jsxs("li",{className:"cedros-accreditation-wizard__file-item",children:[e.jsx("span",{children:u.name}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__file-remove",onClick:()=>m(f),"aria-label":`Remove ${u.name}`,children:"Remove"})]},`${u.name}-${f}`))})]})}function eh(s,t,r,o){t({...s,[r]:o})}function js(s,t){return s.filter(r=>r.documentType===t).map(r=>r.file)}function Ns(s,t,r,o){const n=s.filter(a=>a.documentType!==t);o([...n,...r.map(a=>({file:a,documentType:t}))])}function sh({method:s,formData:t,onFormDataChange:r,fileEntries:o,onFileEntriesChange:n}){const a=(i,d)=>eh(t,r,i,d);return s==="income"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Income Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Income type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"individual",checked:t.incomeType==="individual",onChange:()=>a("incomeType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"joint",checked:t.incomeType==="joint",onChange:()=>a("incomeType","joint")})," ","Joint with spouse ($300K+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"statedAmount",children:"Stated annual income (USD)"}),e.jsx("input",{id:"statedAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"userStatement",children:"Statement about current year income expectation"}),e.jsx("textarea",{id:"userStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx(As,{label:"Upload tax documents (W-2, 1040, 1099, K-1) from the last 2 years",documentType:"tax_return",files:js(o,"tax_return"),onFilesChange:i=>Ns(o,"tax_return",i,n)})]}):s==="net_worth"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Net Worth Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"netWorthAmount",children:"Stated net worth (USD, excluding primary residence)"}),e.jsx("input",{id:"netWorthAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Documents must be dated within the last 90 days."}),e.jsx(As,{label:"Upload asset documents (bank/brokerage statements, property appraisals)",documentType:"asset_statement",files:js(o,"asset_statement"),onFilesChange:i=>Ns(o,"asset_statement",i,n)}),e.jsx(As,{label:"Upload liability documents (credit report)",documentType:"liability_statement",files:js(o,"liability_statement"),onFilesChange:i=>Ns(o,"liability_statement",i,n)})]}):s==="credential"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Professional Credential"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"crdNumber",children:"FINRA CRD Number"}),e.jsx("input",{id:"crdNumber",type:"text",className:"cedros-accreditation-wizard__input",value:t.crdNumber??"",onChange:i=>a("crdNumber",i.target.value)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"licenseType",children:"License type"}),e.jsxs("select",{id:"licenseType",className:"cedros-accreditation-wizard__select",value:t.licenseType??"",onChange:i=>a("licenseType",i.target.value),children:[e.jsx("option",{value:"",children:"Select a license"}),e.jsx("option",{value:"series_7",children:"Series 7"}),e.jsx("option",{value:"series_65",children:"Series 65"}),e.jsx("option",{value:"series_82",children:"Series 82"})]})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Your license will be verified via FINRA BrokerCheck."})]}):s==="third_party_letter"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Third-Party Letter"}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Letter must be dated within the last 90 days."}),e.jsx(As,{label:"Upload verification letter from a CPA, attorney, RIA, or broker-dealer",documentType:"letter",files:js(o,"letter"),onFilesChange:i=>Ns(o,"letter",i,n),maxFiles:1})]}):s==="insider"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Insider / Officer"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"insiderStatement",children:"Describe your role as director, executive officer, or general partner"}),e.jsx("textarea",{id:"insiderStatement",className:"cedros-accreditation-wizard__textarea",rows:4,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"An administrator will verify your status."})]}):e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Investment Threshold"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Entity type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"individual",checked:t.entityType==="individual",onChange:()=>a("entityType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"entity",checked:t.entityType==="entity",onChange:()=>a("entityType","entity")})," ","Entity ($1M+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentAmount",children:"Investment commitment amount (USD)"}),e.jsx("input",{id:"commitmentAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.investmentCommitmentUsd??"",onChange:i=>a("investmentCommitmentUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentStatement",children:"Written representation of commitment"}),e.jsx("textarea",{id:"commitmentStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Per 2025 SEC guidance, a minimum investment commitment serves as evidence of accredited status."})]})}function th({onComplete:s,onCancel:t,className:r}){const{submitVerification:o,uploadDocument:n,isLoading:a,error:i}=wa(),[d,l]=c.useState(1),[h,m]=c.useState(null),[u,f]=c.useState({}),[w,b]=c.useState([]),[g,N]=c.useState(!1),[A,v]=c.useState(null),k=y=>{m(y),l(2)},S=()=>{d===2?l(1):d===3?l(2):t?.()},E=c.useCallback(async()=>{if(h){v(null);try{const{submissionId:y}=await o(h,u);for(const x of w)await n(y,x.file,x.documentType);N(!0),s?.(y)}catch(y){v(y instanceof Error?y.message:"Submission failed. Please try again.")}}},[h,u,w,o,n,s]),p=Ln.find(y=>y.method===h);return g?e.jsx("div",{className:`cedros-accreditation-wizard cedros-accreditation-wizard--success ${r??""}`,role:"status",children:e.jsx("p",{className:"cedros-accreditation-wizard__success-message",children:"Submitted for review. You will be notified once your accreditation is verified."})}):e.jsxs("div",{className:`cedros-accreditation-wizard ${r??""}`,children:[e.jsx("div",{className:"cedros-accreditation-wizard__header",children:e.jsx("nav",{className:"cedros-accreditation-wizard__steps","aria-label":"Wizard steps",children:["Choose Method","Fill Details","Review & Submit"].map((y,x)=>e.jsxs("span",{className:`cedros-accreditation-wizard__step${d===x+1?" cedros-accreditation-wizard__step--active":""}`,"aria-current":d===x+1?"step":void 0,children:[x+1,". ",y]},y))})}),d===1&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step1-heading",children:[e.jsx("h2",{id:"step1-heading",className:"cedros-accreditation-wizard__section-title",children:"Choose Verification Method"}),e.jsx("div",{className:"cedros-accreditation-wizard__method-grid",role:"list",children:Ln.map(y=>e.jsxs("button",{type:"button",role:"listitem",className:"cedros-accreditation-wizard__method-card",onClick:()=>k(y.method),children:[e.jsx("span",{className:"cedros-accreditation-wizard__method-title",children:y.label}),e.jsx("span",{className:"cedros-accreditation-wizard__method-desc",children:y.description})]},y.method))}),t&&e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__cancel",onClick:t,children:"Cancel"})]}),d===2&&h&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step2-heading",children:[e.jsx("h2",{id:"step2-heading",className:"cedros-accreditation-wizard__section-title",children:p?.label}),e.jsx(sh,{method:h,formData:u,onFormDataChange:f,fileEntries:w,onFileEntriesChange:b}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__next",onClick:()=>l(3),children:"Review"})]})]}),d===3&&h&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step3-heading",children:[e.jsx("h2",{id:"step3-heading",className:"cedros-accreditation-wizard__section-title",children:"Review & Submit"}),e.jsxs("dl",{className:"cedros-accreditation-wizard__review-list",children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:"Method"}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:p?.label}),Object.entries(u).filter(([,y])=>y!==void 0&&y!==""&&y!==null).map(([y,x])=>e.jsxs("div",{children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:y}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:String(x)})]},y))]}),w.length>0&&e.jsxs("div",{className:"cedros-accreditation-wizard__review-files",children:[e.jsx("p",{className:"cedros-accreditation-wizard__review-files-heading",children:"Documents to upload:"}),e.jsx("ul",{children:w.map((y,x)=>e.jsxs("li",{children:[y.file.name," ",e.jsxs("span",{className:"cedros-accreditation-wizard__doc-type",children:["(",y.documentType,")"]})]},`${y.file.name}-${x}`))})]}),(i||A)&&e.jsx("div",{className:"cedros-accreditation-wizard__error",role:"alert",children:A??i?.message}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__submit",onClick:E,disabled:a,children:a?"Submitting...":"Submit Verification"})]})]})]})}function rh({status:s,onStartVerification:t,className:r}){if(s==="approved")return null;let o,n=!0;switch(s){case"pending":o="Your accreditation is under review.",n=!1;break;case"rejected":o="Accreditation was not approved. You can resubmit.";break;case"expired":o="Your accreditation has expired. Please verify again.";break;default:o="Accredited investor verification is required.";break}return e.jsx("div",{className:`cedros-accreditation-banner ${r??""}`,role:"alert",children:e.jsxs("div",{className:"cedros-accreditation-banner__content",children:[e.jsx("span",{className:"cedros-accreditation-banner__message",children:o}),n&&t&&e.jsx("button",{type:"button",className:"cedros-accreditation-banner__button",onClick:t,children:s==="rejected"||s==="expired"?"Resubmit Verification":"Start Verification"})]})})}const wr=c.createContext(null),Fs={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 ba(s,t){return xa(s,t)}function xa(s,t){const r={...s};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=s[o],a=t[o];typeof n=="object"&&n!==null&&typeof a=="object"&&a!==null?r[o]=xa(n,a):a!==void 0&&(r[o]=a)}return r}function nh({children:s,locale:t="en",translations:r}){const o=c.useMemo(()=>({t:r?ba(Fs,r):Fs,locale:t}),[r,t]);return e.jsx(wr.Provider,{value:o,children:s})}function oh(){return c.useContext(wr)?.t??Fs}function ah(){return c.useContext(wr)?.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=Q.LoadingSpinner;exports.useServerFeatures=es.useServerFeatures;exports.EmailLoginForm=J.EmailLoginForm;exports.EmailRegisterForm=J.EmailRegisterForm;exports.OtpInput=J.OtpInput;exports.PasswordInput=J.PasswordInput;exports.TotpVerify=J.TotpVerify;exports.useEmailAuth=J.useEmailAuth;exports.useTotpVerify=J.useTotpVerify;exports.validatePassword=We.validatePassword;exports.ErrorMessage=te.ErrorMessage;exports.GoogleLoginButton=Ht.GoogleLoginButton;exports.useGoogleAuth=Ht.useGoogleAuth;exports.SolanaLoginButton=Ze.SolanaLoginButton;exports.registerMobileWallet=Ze.registerMobileWallet;exports.useSolanaAuth=Ze.useSolanaAuth;exports.InviteForm=fe.InviteForm;exports.InviteList=fe.InviteList;exports.MemberList=fe.MemberList;exports.useInvites=fe.useInvites;exports.useMembers=fe.useMembers;exports.useSystemSettings=Gt.useSystemSettings;exports.AdminDepositList=_s.AdminDepositList;exports.AdminDepositStats=_s.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Me.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Me.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Me.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Me.AdminWithdrawalStats;exports.AdminUserList=Ie.AdminUserList;exports.useAdminUsers=Ie.useAdminUsers;exports.useOrgs=Qt.useOrgs;exports.AdminIcons=Be.Icons;exports.AdminShell=Be.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=Be.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=Be.ProfileDropdown;exports.cedrosLoginPlugin=Be.cedrosLoginPlugin;exports.loginPlugin=Be.cedrosLoginPlugin;exports.useAdminShell=Be.useAdminShell;exports.AuthenticationSettings=Rn.AuthenticationSettings;exports.EmbeddedWalletSettings=Tn.EmbeddedWalletSettings;exports.EmailSettings=ks.EmailSettings;exports.CreditSystemSettings=Kt.CreditSystemSettings;exports.PrivacyCashSettings=Kt.CreditSystemSettings;exports.ServerSettings=Mn.ServerSettings;exports.SettingsPageLayout=ss.SettingsPageLayout;exports.WebhookSettings=ss.WebhookSettings;exports.useAdminDeposits=Sa.useAdminDeposits;exports.AccountSettings=Ud;exports.AccreditationBanner=rh;exports.AccreditationWizard=th;exports.AdminAccessCodes=qo;exports.AdminAccreditationQueue=$o;exports.AdminReferralPayouts=Do;exports.AdminSanctionsPanel=Vo;exports.AppleLoginButton=xo;exports.CapabilityWarning=Hc;exports.CedrosAdminDashboard=Xl;exports.ChooseUsernamePrompt=Od;exports.CompleteAccountPrompt=Fd;exports.ComplianceSettings=Fo;exports.CreditBalance=wu;exports.DepositFlow=cu;exports.ErrorBoundary=Ao;exports.ForgotPasswordForm=go;exports.FullPageLayout=Pu;exports.History=Au;exports.I18nProvider=nh;exports.InviteCodePanel=Qu;exports.KycBanner=Ku;exports.KycCallback=Ju;exports.LinkedAccounts=sa;exports.LoginButton=xc;exports.LoginForm=qs;exports.LoginModal=Cc;exports.MfaSetupPrompt=Dd;exports.OrgSelector=_c;exports.OrgSwitcher=Dc;exports.PasskeyLoginButton=vo;exports.PasskeyPrompt=Ro;exports.ProfileTab=Jo;exports.RecoveryPhraseDisplay=No;exports.RecoveryPhraseInput=ko;exports.ReferralSettings=Oo;exports.ResetPasswordForm=Ec;exports.RewardsPanel=Vu;exports.SUPPORTED_TOKENS=$s;exports.SecuritySettings=kl;exports.SessionList=jo;exports.SetupWizard=Ho;exports.SignupSettings=Wo;exports.SplitPageLayout=Ru;exports.SystemSettings=ul;exports.TieredAmountSlider=mr;exports.TokenGateSettings=zo;exports.TokenSelector=dr;exports.TotpSettings=Zo;exports.TotpSetup=cr;exports.UserProfileSettings=Nd;exports.WalletAddressRow=Bo;exports.WalletEnrollment=_o;exports.WalletManager=dl;exports.WalletRecovery=Io;exports.WalletStatus=Uo;exports.WalletUnlock=To;exports.WithdrawalFlow=ku;exports.WithdrawalHistory=Lu;exports.defaultTranslations=Fs;exports.getTierForAmount=zs;exports.mergeTranslations=ba;exports.useAccessCodes=fa;exports.useAccreditation=wa;exports.useAppleAuth=wo;exports.useAuthorize=Tu;exports.useCedrosTheme=Du;exports.useCredentials=lr;exports.useCredits=fr;exports.useDeposit=ia;exports.useInstantLink=fo;exports.useKyc=Fu;exports.useLocale=ah;exports.usePasskeySigning=Po;exports.usePasswordReset=Ws;exports.usePendingRecovery=Iu;exports.usePostLogin=Uu;exports.useProfile=hs;exports.useReferral=Xo;exports.useRewards=ga;exports.useSessions=oa;exports.useSetPassword=Eo;exports.useSetup=or;exports.useTotp=ir;exports.useTransactionSigning=Bu;exports.useTranslations=oh;exports.useUsername=aa;exports.useWalletEnrollment=Co;exports.useWalletRecovery=Mo;exports.useWalletSigning=Lo;exports.useWallets=Mu;exports.useWebAuthn=nr;exports.useWithdrawal=gr;
|