@cedros/login-react 0.0.44 → 0.0.45
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/dist/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1448 -1489
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/assets/argon2Worker-Bi5TuQvD.js +0 -1
- package/dist/assets/argon2Worker-Bi5TuQvD.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("./useAuth-B1yS_YiD.cjs"),M=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),d=require("react"),Q=require("./LoadingSpinner-d6sSxgQN.cjs"),Hs=require("./sanitization-Bo_tn-L2.cjs"),X=require("./EmailRegisterForm-xFb6MaVA.cjs"),qe=require("./validation-BuGQrA-K.cjs"),te=require("./ErrorMessage-CHbYbVi2.cjs"),Qs=require("./GoogleLoginButton-2zNTIKMm.cjs"),Xe=require("./SolanaLoginButton-CqdzSSeJ.cjs"),he=require("./PermissionsSection-4zcE9Zs9.cjs"),Gs=require("./useSystemSettings-B2jY51ob.cjs"),ke=require("./AutosaveStatus-CZSwtgrL.cjs"),_t=require("./AdminDepositList-B_z6x3j5.cjs"),Me=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),Oe=require("./useUsersStatsSummary-DnsYtFGX.cjs"),Ln=require("./StatsBar-DTUZCwDD.cjs"),Ks=require("./useOrgs-CNqfn-fk.cjs"),Be=require("./plugin-BwwJh2cY.cjs"),Pn=require("./AuthenticationSettings-bNQiNQ9g.cjs"),Rn=require("./EmbeddedWalletSettings-MtwR81WH.cjs"),kt=require("./EmailSettings-CEC1rhrm.cjs"),Ys=require("./CreditSystemSettings-3R6crxvW.cjs"),Tn=require("./ServerSettings-BNc4LEs4.cjs"),ut=require("./WebhookSettings-H1x6IKOj.cjs"),Aa=require("./useAdminDeposits-CpLd68oP.cjs");var Yt=typeof document<"u"?document.currentScript:null;let Fe=null,ja=0;const dt=new Map;function Na(){return typeof Worker>"u"?null:(Fe||(Fe=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/argon2Worker-Bi5TuQvD.js").href:new URL("assets/argon2Worker-Bi5TuQvD.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:Yt&&Yt.tagName.toUpperCase()==="SCRIPT"&&Yt.src||new URL("index.cjs",document.baseURI).href),{type:"module"}),Fe.onmessage=t=>{const{id:s,key:r,error:o}=t.data,n=dt.get(s);if(n){if(dt.delete(s),o){n.reject(new Error(o));return}if(!r){n.reject(new Error("Argon2 worker returned no key"));return}n.resolve(r)}},Fe.onerror=t=>{const s=t instanceof ErrorEvent?t.error:new Error("Argon2 worker error");for(const r of dt.values())r.reject(s instanceof Error?s:new Error(String(s)));dt.clear(),Fe?.terminate(),Fe=null}),Fe)}async function Mn(t,s,r=U.DEFAULT_KDF_PARAMS){U.validateKdfParams(r);const o=Na();return o?new Promise((n,a)=>{const i=ja++;dt.set(i,{resolve:n,reject:a});const l={id:i,password:t,salt:s,params:r};o.postMessage(l)}):U.argon2Derive(t,s,r)}function Bn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ka(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 St={exports:{}};const Sa=globalThis.crypto,Ca=globalThis.crypto,Ea=globalThis.crypto.subtle,_a=globalThis.crypto.getRandomValues.bind(globalThis.crypto),La=globalThis.crypto.randomUUID.bind(globalThis.crypto),Pa=Object.freeze(Object.defineProperty({__proto__:null,default:Sa,getRandomValues:_a,randomUUID:La,subtle:Ea,webcrypto:Ca},Symbol.toStringTag,{value:"Module"})),Ra=ka(Pa);var Ta=St.exports,Ar;function Ma(){return Ar||(Ar=1,(function(t,s){(function(r,o){t.exports=o(Ra)})(Ta,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})})(St)),St.exports}var Ba=Ma();const In=Bn(Ba);function Un(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Zs(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=Un(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 jr(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 Ia(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 Is(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function Zt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const Dn=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Ua=Array.from({length:256},(t,s)=>s.toString(16).padStart(2,"0"));function Xs(t){if(ie(t),Dn)return t.toHex();let s="";for(let r=0;r<t.length;r++)s+=Ua[t[r]];return s}const je={_0:48,_9:57,A:65,F:70,a:97,f:102};function Nr(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 Fn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Dn)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=Nr(t.charCodeAt(a)),l=Nr(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 kr(...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 Da(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 Fa(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 Wa=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});let Oa=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=Zt(this.buffer)}update(s){jr(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=Zt(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){jr(this),Ia(s,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Is(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=Zt(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]),ft=BigInt(2**32-1),Sr=BigInt(32);function qa(t,s=!1){return s?{h:Number(t&ft),l:Number(t>>Sr&ft)}:{h:Number(t>>Sr&ft)|0,l:Number(t&ft)|0}}function za(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}=qa(t[a],s);[o[a],n[a]]=[i,l]}return[o,n]}const Cr=(t,s,r)=>t>>>r,Er=(t,s,r)=>t<<32-r|s>>>r,Ge=(t,s,r)=>t>>>r|s<<32-r,Ke=(t,s,r)=>t<<32-r|s>>>r,pt=(t,s,r)=>t<<64-r|s>>>r-32,gt=(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 $a=(t,s,r)=>(t>>>0)+(s>>>0)+(r>>>0),Va=(t,s,r,o)=>s+r+o+(t/2**32|0)|0,Ha=(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,Ga=(t,s,r,o,n)=>(t>>>0)+(s>>>0)+(r>>>0)+(o>>>0)+(n>>>0),Ka=(t,s,r,o,n,a)=>s+r+o+n+a+(t/2**32|0)|0,Wn=za(["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))),Ya=Wn[0],Za=Wn[1],Ee=new Uint32Array(80),_e=new Uint32Array(80);class Xa extends Oa{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=Ge(S,E,1)^Ge(S,E,8)^Cr(S,E,7),y=Ke(S,E,1)^Ke(S,E,8)^Er(S,E,7),x=Ee[k-2]|0,A=_e[k-2]|0,_=Ge(x,A,19)^pt(x,A,61)^Cr(x,A,6),C=Ke(x,A,19)^gt(x,A,61)^Er(x,A,6),P=Ha(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=Ge(u,p,14)^Ge(u,p,18)^pt(u,p,41),E=Ke(u,p,14)^Ke(u,p,18)^gt(u,p,41),f=u&b^~u&g,y=p&w^~p&j,x=Ga(N,E,y,Za[k],_e[k]),A=Ka(x,v,S,f,Ya[k],Ee[k]),_=x|0,C=Ge(o,n,28)^pt(o,n,34)^pt(o,n,39),P=Ke(o,n,28)^gt(o,n,34)^gt(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=$a(_,P,R);o=Va(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(){Is(Ee,_e)}destroy(){Is(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ja extends Xa{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 ei=Da(()=>new Ja,Wa(3));const On=BigInt(0),_r=BigInt(1);function Us(t,s=""){if(typeof t!="boolean"){const r=s&&`"${s}" `;throw new Error(r+"expected boolean, got type="+typeof t)}return t}function ti(t){if(typeof t=="bigint"){if(!Ct(t))throw new Error("positive bigint expected, got "+t)}else Zs(t);return t}function qn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?On:BigInt("0x"+t)}function si(t){return qn(Xs(t))}function Lt(t){return qn(Xs(Ds(ie(t)).reverse()))}function zn(t,s){Zs(s),t=ti(t);const r=Fn(t.toString(16).padStart(s*2,"0"));if(r.length!==s)throw new Error("number too large");return r}function ri(t,s){return zn(t,s).reverse()}function Ds(t){return Uint8Array.from(t)}const Ct=t=>typeof t=="bigint"&&On<=t;function ni(t,s,r){return Ct(t)&&Ct(s)&&Ct(r)&&s<=t&&t<r}function Lr(t,s,r,o){if(!ni(s,r,o))throw new Error("expected valid "+t+": "+r+" <= n < "+o+", got "+s)}const oi=t=>(_r<<BigInt(t))-_r;function Js(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 Pr(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),We=BigInt(2),$n=BigInt(3),Vn=BigInt(4),Hn=BigInt(5),ai=BigInt(7),Qn=BigInt(8),ii=BigInt(9),Gn=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 Rr(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 er(t,s,r){if(!t.eql(t.sqr(s),r))throw new Error("Cannot find square root")}function Kn(t,s){const r=(t.ORDER+de)/Vn,o=t.pow(s,r);return er(t,o,s),o}function ci(t,s){const r=(t.ORDER-Hn)/Qn,o=t.mul(s,We),n=t.pow(o,r),a=t.mul(s,n),i=t.mul(t.mul(a,We),n),l=t.mul(a,t.sub(i,t.ONE));return er(t,l,s),l}function li(t){const s=tr(t),r=Yn(t),o=r(s,s.neg(s.ONE)),n=r(s,o),a=r(s,s.neg(o)),i=(t+ai)/Gn;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 er(l,j,c),j}}function Yn(t){if(t<$n)throw new Error("sqrt is not defined for small field");let s=t-de,r=0;for(;s%We===me;)s/=We,r++;let o=We;const n=tr(t);for(;Tr(n,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Kn;let a=n.pow(o,s);const i=(s+de)/We;return function(c,h){if(c.is0(h))return h;if(Tr(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 di(t){return t%Vn===$n?Kn:t%Qn===Hn?ci:t%Gn===ii?li(t):Yn(t)}const ui=(t,s)=>(oe(t,s)&de)===de,hi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function mi(t){const s={ORDER:"bigint",BYTES:"number",BITS:"number"},r=hi.reduce((o,n)=>(o[n]="function",o),s);return Js(t,r),t}function fi(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 Zn(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 Tr(t,s){const r=(t.ORDER-de)/We,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 pi(t,s){s!==void 0&&Zs(s);const r=s!==void 0?s:t.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class gi{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}=pi(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 fi(this,s,r)}div(s,r){return oe(s*Rr(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 Rr(s,this.ORDER)}sqrt(s){return this._sqrt||(this._sqrt=di(this.ORDER)),this._sqrt(this,s)}toBytes(s){return this.isLE?ri(s,this.BYTES):zn(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?Lt(s):si(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 Zn(this,s)}cmov(s,r,o){return o?r:s}}function tr(t,s={}){return new gi(t,s)}const Pt=BigInt(0),Fs=BigInt(1);function Mr(t,s){const r=s.negate();return t?r:s}function Xt(t,s){const r=Zn(t.Fp,s.map(o=>o.Z));return s.map((o,n)=>t.fromAffine(o.toAffine(r[n])))}function Xn(t,s){if(!Number.isSafeInteger(t)||t<=0||t>s)throw new Error("invalid window size, expected [1.."+s+"], got W="+t)}function Jt(t,s){Xn(t,s);const r=Math.ceil(s/t)+1,o=2**(t-1),n=2**t,a=oi(t),i=BigInt(t);return{windows:r,windowSize:o,mask:a,maxNumber:n,shiftBy:i}}function Br(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+=Fs);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 es=new WeakMap,Jn=new WeakMap;function ts(t){return Jn.get(t)||1}function Ir(t){if(t!==Pt)throw new Error("invalid wNAF")}class wi{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>Pt;)r&Fs&&(o=o.add(n)),n=n.double(),r>>=Fs;return o}precomputeWindow(s,r){const{windows:o,windowSize:n}=Jt(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=Jt(s,this.bits);for(let l=0;l<i.windows;l++){const{nextN:c,offset:h,isZero:m,isNeg:u,isNegF:p,offsetF:b}=Br(o,l,i);o=c,m?a=a.add(Mr(p,r[b])):n=n.add(Mr(u,r[h]))}return Ir(o),{p:n,f:a}}wNAFUnsafe(s,r,o,n=this.ZERO){const a=Jt(s,this.bits);for(let i=0;i<a.windows&&o!==Pt;i++){const{nextN:l,offset:c,isZero:h,isNeg:m}=Br(o,i,a);if(o=l,!h){const u=r[c];n=n.add(m?u.negate():u)}}return Ir(o),n}getPrecomputes(s,r,o){let n=es.get(r);return n||(n=this.precomputeWindow(r,s),s!==1&&(typeof o=="function"&&(n=o(n)),es.set(r,n))),n}cached(s,r,o){const n=ts(s);return this.wNAF(n,this.getPrecomputes(n,s,o),r)}unsafe(s,r,o,n){const a=ts(s);return a===1?this._unsafeLadder(s,r,n):this.wNAFUnsafe(a,this.getPrecomputes(a,s,o),r,n)}createCache(s,r){Xn(r,this.bits),Jn.set(s,r),es.delete(s)}hasCache(s){return ts(s)!==1}}function Ur(t,s,r){if(s){if(s.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return mi(s),s}else return tr(t,{isLE:r})}function bi(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>Pt))throw new Error(`CURVE.${c} must be positive bigint`)}const n=Ur(s.p,r.Fp,o),a=Ur(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 yi(t,s){return function(o){const n=t(o);return{secretKey:n,publicKey:s(n)}}}const Le=BigInt(0),ae=BigInt(1),ss=BigInt(2),xi=BigInt(8);function vi(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 Ai(t,s={}){const r=bi("edwards",t,s,s.FpFnLE),{Fp:o,Fn:n}=r;let a=r.CURVE;const{h:i}=a;Js(s,{},{uvRatio:"function"});const l=ss<<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(!vi(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 Lr("coordinate "+j,v,k,l),v}function u(j){if(!(j instanceof w))throw new Error("EdwardsPoint expected")}const p=Pr((j,v)=>{const{X:N,Y:k,Z:S}=j,E=j.is0();v==null&&(v=E?xi: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=Pr(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=Ds(ie(v,k,"point")),Us(N,"zip215");const f=Ds(v),y=v[k-1];f[k-1]=y&-129;const x=Lt(f),A=N?l:o.ORDER;Lr("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(Fn(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(ss),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(ss*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),D=c(W*O),z=c(B*O),K=c(F*W);return new w(I,D,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=>Xt(w,S));return Xt(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=>Xt(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 Xs(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const g=new wi(w,n.BITS);return w.BASE.precompute(8),w}function ji(t,s,r={}){if(typeof s!="function")throw new Error('"hash" function param is required');Js(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||Fa,c=r.adjustScalarBytes||(x=>x),h=r.domain||((x,A,_)=>{if(Us(_,"phflag"),A.length||_)throw new Error("Contexts/pre-hash are not supported");return x});function m(x){return i.create(Lt(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 _=kr(...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=kr(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&&Us(L,"zip215"),o&&(A=o(A));const T=R/2,B=x.subarray(0,T),F=Lt(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 D=w(P,O.toBytes(),W.toBytes(),A);return O.add(W.multiplyUnsafe(D)).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 Un(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:yi(S,b),getPublicKey:b,sign:g,verify:v,utils:y,Point:t,lengths:k})}const Ni=BigInt(1),Dr=BigInt(2),ki=BigInt(5),Si=BigInt(8),sr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Ci={p:sr,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Si,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Ei(t){const s=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),a=sr,l=t*t%a*t%a,c=xe(l,Dr,a)*l%a,h=xe(c,Ni,a)*t%a,m=xe(h,ki,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,Dr,a)*t%a,b2:l}}function _i(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Fr=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Li(t,s){const r=sr,o=oe(s*s*s,r),n=oe(o*o*s,r),a=Ei(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*Fr,r),m=l===t,u=l===oe(-t,r),p=l===oe(-t*Fr,r);return m&&(i=c),(u||p)&&(i=h),ui(i,r)&&(i=oe(-i,r)),{isValid:m||u,value:i}}const Pi=Ai(Ci,{uvRatio:Li});function Ri(t){return ji(Pi,ei,Object.assign({adjustScalarBytes:_i},t))}const Ti=Ri({});function Mi(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Wt(t,...s){if(!Mi(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 Wr(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 Bi(t,s){Wt(t);const r=s.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ws(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function rs(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ve(t,s){return t<<32-s|t>>>s}function Ii(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function eo(t){return typeof t=="string"&&(t=Ii(t)),Wt(t),t}class Ui{}function Di(t){const s=o=>t().update(eo(o)).digest(),r=t();return s.outputLen=r.outputLen,s.blockLen=r.blockLen,s.create=()=>t(),s}function Fi(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 Wi(t,s,r){return t&s^~t&r}function Oi(t,s,r){return t&s^t&r^s&r}class qi extends Ui{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=rs(this.buffer)}update(s){Wr(this),s=eo(s),Wt(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=rs(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){Wr(this),Bi(s,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Ws(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;Fi(o,n-8,BigInt(this.length*8),a),this.process(o,0);const l=rs(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]),zi=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 $i extends qi{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+Wi(l,c,h)+zi[u]+Re[u]|0,g=(ve(o,2)^ve(o,13)^ve(o,22))+Oi(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(){Ws(Re)}destroy(){this.set(0,0,0,0,0,0,0,0),Ws(this.buffer)}}const to=Di(()=>new $i),Vi=to,Hi="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Qi(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Vi(t),r=Ti.getPublicKey(s),o=new Uint8Array(64);return o.set(s,0),o.set(r,32),U.wipeBytes(s),{publicKey:r,secretKey:o}}function so(t){const s=Qi(t),r=s.publicKey;return U.wipeBytes(s.secretKey),r}function ro(t){if(t.length!==32)throw new Error(`Invalid public key length: expected 32, got ${t.length}`);return Gi(t)}function Gi(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=Hi[n]+o,r=r/58n}return"1".repeat(s)+o}const Ki=2,Yi=3;function no(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Os(t),r=In.share(s,Yi,Ki);if(r.length!==3)throw new Error(`Unexpected share count: ${r.length}`);const o=ns(r[0]),n=ns(r[1]),a=ns(r[2]);return{shareA:U.toShamirShare(o),shareB:U.toShamirShare(n),shareC:U.toShamirShare(a)}}function Zi(t,s,r){const o=Or(t),n=Or(s);try{const a=In.combine([o,n]),i=oo(a);if(i.length!==16)throw new Error(`Reconstructed seed has wrong length: ${i.length}`);return U.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 Os(t){return Array.from(t).map(s=>s.toString(16).padStart(2,"0")).join("")}function oo(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 ns(t){const s=t.length%2!==0,r=s?"0"+t:t,o=oo(r),n=new Uint8Array(1+o.length);return n[0]=s?1:0,n.set(o,1),n}function Or(t){const s=t[0];if(s===0||s===1){const o=s===1,n=t.subarray(1),a=Os(n),i=o?a.substring(1):a;if(/^[0-9a-f]/.test(i))return i}const r=Os(t);return r.startsWith("0")&&!r.startsWith("00")?r.substring(1):r}function Rt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ao(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 Xi(t){if(typeof t!="function")throw new Error("function expected");return!0}function Tt(t,s){if(typeof s!="string")throw new Error(`${t}: string expected`);return!0}function tt(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function Mt(t){if(!Array.isArray(t))throw new Error("array expected")}function Bt(t,s){if(!ao(!0,s))throw new Error(`${t}: array of strings expected`)}function io(t,s){if(!ao(!1,s))throw new Error(`${t}: array of numbers expected`)}function Ji(...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 ec(t){const s=typeof t=="string"?t.split(""):t,r=s.length;Bt("alphabet",s);const o=new Map(s.map((n,a)=>[n,a]));return{encode:n=>(Mt(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=>(Mt(n),n.map(a=>{Tt("alphabet.decode",a);const i=o.get(a);if(i===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${t}`);return i}))}}function tc(t=""){return Tt("join",t),{encode:s=>(Bt("join.decode",s),s.join(t)),decode:s=>(Tt("join.decode",s),s.split(t))}}function sc(t,s="="){return tt(t),Tt("padding",s),{encode(r){for(Bt("padding.encode",r);r.length*t%8;)r.push(s);return r},decode(r){Bt("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 qs(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(Mt(t),!t.length)return[];let o=0;const n=[],a=Array.from(t,l=>{if(tt(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 co=(t,s)=>s===0?t:co(s,t%s),It=(t,s)=>t+(s-co(t,s)),os=(()=>{let t=[];for(let s=0;s<40;s++)t.push(2**s);return t})();function zs(t,s,r,o){if(Mt(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(It(s,r)>32)throw new Error(`convertRadix2: carry overflow from=${s} to=${r} carryBits=${It(s,r)}`);let n=0,a=0;const i=os[s],l=os[r]-1,c=[];for(const h of t){if(tt(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=os[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 rc(t){tt(t);const s=2**8;return{encode:r=>{if(!Rt(r))throw new Error("radix.encode input should be Uint8Array");return qs(Array.from(r),s,t)},decode:r=>(io("radix.decode",r),Uint8Array.from(qs(r,t,s)))}}function nc(t,s=!1){if(tt(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(It(8,t)>32||It(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Rt(r))throw new Error("radix2.encode input should be Uint8Array");return zs(Array.from(r),8,t,!s)},decode:r=>(io("radix2.decode",r),Uint8Array.from(zs(r,t,8,s)))}}function oc(t,s){return tt(t),Xi(s),{encode(r){if(!Rt(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(!Rt(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 wt={alphabet:ec,chain:Ji,checksum:oc,convertRadix:qs,convertRadix2:zs,radix:rc,radix2:nc,join:tc,padding:sc};const ac=t=>t[0]==="あいこくしん";function ic(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function cc(t){const s=ic(t),r=s.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:s,words:r}}function lo(t){Wt(t,16,20,24,28,32)}const lc=t=>{const s=8-t.length/4;return new Uint8Array([to(t)[0]>>s<<s])};function uo(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)}),wt.chain(wt.checksum(1,lc),wt.radix2(11,!0),wt.alphabet(t))}function rr(t,s){const{words:r}=cc(t),o=uo(s).decode(r);return lo(o),o}function ho(t,s){return lo(t),uo(s).encode(t).join(ac(s)?" ":" ")}function nr(t,s){try{rr(t,s)}catch{return!1}return!0}const Se=`abandon
|
|
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-CZSwtgrL.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-BwwJh2cY.cjs"),En=require("./AuthenticationSettings-bNQiNQ9g.cjs"),_n=require("./EmbeddedWalletSettings-MtwR81WH.cjs"),jt=require("./EmailSettings-CEC1rhrm.cjs"),Qs=require("./CreditSystemSettings-3R6crxvW.cjs"),Ln=require("./ServerSettings-BNc4LEs4.cjs"),lt=require("./WebhookSettings-H1x6IKOj.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
|
|
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 dc(t){if(t.length!==16)throw new Error(`Invalid share length: expected 16, got ${t.length}`);const r=ho(t,Se).split(" ");if(r.length!==fe)throw new Error(`Unexpected word count: expected ${fe}, got ${r.length}`);return r}function uc(t){if(t.length!==fe)throw new Error(`Invalid word count: expected ${fe}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!nr(s,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=rr(s,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return U.toShamirShare(r)}function hc(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const r=ho(t,Se).split(" ");if(r.length!==fe)throw new Error(`Unexpected word count: expected ${fe}, got ${r.length}`);return r}function mc(t){if(t.length!==fe)throw new Error(`Invalid word count: expected ${fe}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!nr(s,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=rr(s,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return U.toSeed(r)}function mo(t){if(t.length!==fe)return!1;const s=t.join(" ").toLowerCase().trim();return nr(s,Se)}function bt(t){return Se.includes(t.toLowerCase().trim())}function fc(t,s=5){const r=t.toLowerCase().trim();return r.length===0?[]:Se.filter(o=>o.startsWith(r)).slice(0,s)}function pc(t){const s=[];for(let r=0;r<t.length;r+=4)s.push(t.slice(r,r+4));return s}function gc(t){return t.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(s=>s.trim()).filter(s=>s.length>0)}function wc({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}=U.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=Hs.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 Ot(){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(!qe.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 bc(t){return typeof t=="object"&&t!==null&&"mfaRequired"in t&&t.mfaRequired===!0}function fo(){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(!qe.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 bc(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 yc={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 po({mode:t="reset",onSuccess:s,onCancel:r,className:o=""}){const[n,a]=d.useState(""),i=Ot(),l=fo(),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=yc[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 xc={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 go(){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 xc.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 wo(){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 bo({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}=go(),[m]=d.useState(()=>wo());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 vc(t){return t.replace(/-/g,"+").replace(/_/g,"/")}function Ut(t){le(typeof t=="string"&&t.length>0,"Expected base64url string");const s=vc(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 Ye(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 yo(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:Ut(s.id),transports:Array.isArray(s.transports)?s.transports:void 0}}function as(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(yo):void 0,a=Array.isArray(s.pubKeyCredParams)?s.pubKeyCredParams.map(l=>({type:l.type,alg:l.alg})):[],i={challenge:Ut(s.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:Ut(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 qr(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(yo):void 0,o={challenge:Ut(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 ot(t){const s=Ye(t.rawId),r=t.response,n={...{clientDataJSON:Ye(r.clientDataJSON)}};if("attestationObject"in r){const a=r;if(n.attestationObject=Ye(a.attestationObject),typeof a.getTransports=="function")try{n.transports=a.getTransports()}catch{}}if("authenticatorData"in r){const a=r;n.authenticatorData=Ye(a.authenticatorData),n.signature=Ye(a.signature),a.userHandle&&(n.userHandle=Ye(a.userHandle))}return{id:t.id,rawId:s,type:t.type,authenticatorAttachment:t.authenticatorAttachment??void 0,clientExtensionResults:t.getClientExtensionResults?.()??{},response:n}}function Ac(){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 jc(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&typeof t.code=="string"&&typeof t.message=="string"}function at(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 or(){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=Ac(),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=qr(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:ot(k)});return t.callbacks?.onLoginSuccess?.(S.user,"webauthn"),s?.handleLoginSuccess(S.user,S.tokens),S}catch(v){const k=at(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=as(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:ot(k),label:j?.label});if(!S.success)throw new Error("Passkey registration failed");return{credentialId:S.credentialId,label:S.label}}catch(v){const k=at(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=as(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:ot(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=at(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=qr(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:ot(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=at(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(!jc(v)){const S=at(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=as(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:ot(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 xo({onSuccess:t,className:s="",children:r,disabled:o}){const{continueWithPasskey:n,isLoading:a,isSupported:i}=or(),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(Nc,{})}),e.jsx("span",{children:r??"Continue with Passkey"})]})}function Nc(){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 it=["login","register"];function qt({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(()=>Xe.detectSolanaWallets()),[u]=d.useState(()=>wo());d.useEffect(()=>{const E=()=>m(Xe.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=it.indexOf(a);let y=f;switch(E.key){case"ArrowLeft":case"ArrowUp":y=f===0?it.length-1:f-1;break;case"ArrowRight":case"ArrowDown":y=f===it.length-1?0:f+1;break;case"Home":y=0;break;case"End":y=it.length-1;break;default:return}E.preventDefault();const x=it[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(po,{mode:p,onCancel:()=>c("form")})}):e.jsxs("div",{className:`cedros-login-form ${s}`,children:[(k||j||v||N)&&(()=>{const E={webauthn:k?e.jsx(xo,{onSuccess:t}):null,google:j?e.jsx(Qs.GoogleLoginButton,{onSuccess:t}):null,apple:v?e.jsx(bo,{onSuccess:t}):null,solana:N?e.jsx(Xe.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 vo 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 kc({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(vo,{children:e.jsx(qt,{onSuccess:o})})})]})})}function Sc({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}=Ot(),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(qe.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 $s({org:t,size:s="lg",className:r=""}){const o=Hs.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 Cc({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($s,{org:s,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:s.name}),e.jsx(zr,{role:s.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:i}),e.jsx(Ec,{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($s,{org:b,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:b.name}),e.jsx(zr,{role:b.membership.role}),b.id===s?.id&&e.jsx(_c,{})]})},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(Lc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function zr({role:t}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${t}`,children:t})}function Ec({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 _c(){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 Lc(){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 Pc(){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 Rc(){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 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:"M10 4V16M4 10H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Mc({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($s,{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(Rc,{})]})},a.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(Tc,{}),e.jsx("span",{children:"Create new organization"})]})]})}function Bc({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 Ic({isOpen:t,onClose:s,orgs:r,activeOrg:o,isLoading:n=!1,error:a,onSelect:i,onCreate:l,className:c=""}){return t?e.jsx(Uc,{onClose:s,orgs:r,activeOrg:o,isLoading:n,error:a,onSelect:i,onCreate:l,className:c}):null}function Uc({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(Pc,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(te.ErrorMessage,{error:n}),c==="list"?e.jsx(Mc,{orgs:s,activeOrg:r,isLoading:o,onSelect:b,onCreateClick:i?()=>h("create"):void 0}):e.jsx(Bc,{isLoading:o,onSubmit:w,onCancel:()=>h("list")})]})]})})}function Ao({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(zc,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:t.map(p=>e.jsx(Dc,{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 Dc({session:t}){const s=Fc(t.userAgent),r=Oc(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(qc,{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 ",Wc(t.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Fc(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 Wc(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 Oc(t){const s=new Date(t),r=new Date,o=3600*1e3;return s.getTime()-r.getTime()<o}function qc({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 zc(){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 jo({words:t,onConfirm:s,className:r=""}){const[o,n]=d.useState(!1),[a,i]=d.useState(!1),l=d.useRef(null),c=pc(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 No({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=fc(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&&!bt(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=gc(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})=>!bt(A));if(x.length>0){p(`Invalid words: ${x.map(A=>`#${A.index}`).join(", ")}`);return}if(!mo(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]&&!bt(a[y])?"cedros-word-invalid":a[y]&&bt(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 $c({capabilities:t,className:s=""}){if(t.allSupported)return null;const r=U.getMissingCapabilitiesMessage(t),o=U.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 Vc=["share_c_only","full_seed","none"];function Hc(t){return t&&Vc.includes(t)?t:"share_c_only"}const Qc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function ko(){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:Hc(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 So(){const{user:t}=M.useCedrosLogin(),{enroll:s}=U.useWalletMaterial(),{recoveryMode:r}=ko(),[o,n]=d.useState({step:"idle"}),[a,i]=d.useState(!1),l=d.useRef([]),c=d.useCallback(()=>{U.wipeAll(...l.current),l.current=[]},[]);d.useEffect(()=>()=>{c()},[c]);const h=d.useCallback(async(w,g,j,v)=>{n({step:"generating_seed"});const N=U.generateSeed();l.current.push(N),n({step:"splitting_shares"});const{shareA:k,shareB:S,shareC:E}=no(N);l.current.push(k,S,E),n({step:"encrypting_shares"});const f=await U.aesGcmEncryptToBase64(k,U.toEncryptionKey(g)),y=so(N),x=ro(y);n({step:"uploading"});const A={solanaPubkey:x,shareAAuthMethod:w,shareACiphertext:f.ciphertext,shareANonce:f.nonce,shareB:U.uint8ArrayToBase64(S)};if(w==="password"){if(!j)throw new Error("KDF salt required for password method");A.shareAKdfSalt=U.uint8ArrayToBase64(j),A.shareAKdfParams=U.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"?hc(N):dc(U.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=U.generateArgon2Salt(),j=await Mn(w,g,U.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=U.generatePrfSalt(),g=U.uint8ArrayToBase64(w);n({step:"encrypting_shares"});const v=(await U.authenticateWithDiscoverablePrf(g)).prfOutput;l.current.push(v);const N=await U.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 Co(){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 Gc(t){return t.includes("email")?"password":t.includes("webauthn")?"passkey":"set-password"}function Eo({onComplete:t,onCancel:s,className:r=""}){const{user:o}=M.useCedrosLogin(),{state:n,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:i,confirmRecoveryPhrase:l,cancel:c,isEnrolling:h}=So(),{setPassword:m,isLoading:u}=Co(),p=o?Gc(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 _=qe.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(jo,{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 _o(){const{user:t}=M.useCedrosLogin(),{signTransaction:s}=U.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:U.uint8ArrayToBase64(c),...h?{credential:U.toCredentialRequest(h)}:{}},u=await s(m);return U.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 Lo(){const{getMaterial:t}=U.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 U.authenticateWithDiscoverablePrf(l.prfSalt);try{return{type:"prfOutput",prfOutput:U.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 Po({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(Yc,{}):r?e.jsx(Zc,{}):e.jsx(Kc,{})}),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 Kc(){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 Yc(){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 Zc(){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 Ro({onUnlock:t,onCancel:s,showCancel:r=!0,authMethod:o,className:n=""}){M.useCedrosLogin();const{unlock:a,getMaterial:i,isLoading:l}=U.useWalletMaterial(),{getPasskeyCredential:c,isAuthenticating:h}=Lo(),[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(Xc,{})}),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(Po,{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(Jc,{})}),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(el,{})}),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 Xc(){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 Jc(){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 el(){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 To(){const{recover:t,getShareBForRecovery:s}=U.useWalletMaterial(),{recoveryMode:r}=ko(),[o,n]=d.useState({step:"idle"}),[a,i]=d.useState(!1),l=d.useRef([]),c=d.useCallback(()=>{U.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"}),!mo(u))throw new Error("Invalid recovery phrase. Please check your words.");let w;if(r==="share_c_only"){const x=uc(u);l.current.push(x);const A=U.uint8ArrayToBase64(x),_=await s({shareC:A}),C=U.base64ToUint8Array(_.shareB);l.current.push(C),w=Zi(U.toShamirShare(C),U.toShamirShare(x)),l.current.push(w)}else w=mc(u),l.current.push(w);const g=so(w),j=ro(g),{shareA:v,shareB:N}=no(w);l.current.push(v,N),n({step:"encrypting"});let k,S,E;if(p==="passkey"){const x=U.generatePrfSalt();E=U.uint8ArrayToBase64(x);const A=await U.authenticateWithDiscoverablePrf(E);l.current.push(A.prfOutput),k=await U.deriveKeyFromPrf(A.prfOutput,x),l.current.push(k)}else S=U.generateArgon2Salt(),k=await Mn(b,S,U.DEFAULT_KDF_PARAMS),l.current.push(k);const f=await U.aesGcmEncryptToBase64(v,U.toEncryptionKey(k));n({step:"uploading"});const y={solanaPubkey:j,shareAAuthMethod:p,shareACiphertext:f.ciphertext,shareANonce:f.nonce,shareB:U.uint8ArrayToBase64(N)};p==="password"&&(y.shareAKdfSalt=U.uint8ArrayToBase64(S),y.shareAKdfParams=U.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 Mo({onComplete:t,onCancel:s,className:r="",defaultAuthMethod:o="password"}){const{state:n,startRecovery:a,cancel:i,isRecovering:l}=To(),[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(tl,{})}),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(sl,{})}),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(rl,{})}),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(nl,{}),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(No,{onSubmit:S,onCancel:f,isSubmitting:!1})]})})}function tl(){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 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 rl(){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 nl(){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: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 Io({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=U.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=ol(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:al(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(il,{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(Bo,{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 ol(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 al(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function il({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 cl({className:t="",showActions:s=!0}){const r=U.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(Io,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:s}),o==="enroll"&&e.jsx(Eo,{onComplete:()=>{l()},onCancel:i}),o==="unlock"&&e.jsx(Ro,{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(Mo,{onComplete:()=>{h()},onCancel:i})]})}function ll({showDescriptions:t=!0,className:s="",onSave:r}){const{settings:o,isLoading:n,isUpdating:a,error:i,fetchSettings:l,updateSettings:c}=Gs.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(dl,{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 $r=Object.keys(ke.SETTING_METADATA);function dl({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=$r.indexOf(l.key),m=$r.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"})]})},ul=[{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 hl(t,s){return s.toUpperCase()==="SOL"?`${(t/1e9).toFixed(4)} SOL`:`${t} ${s}`}function Vr(t){return t.length<=16?t:`${t.slice(0,8)}...${t.slice(-6)}`}function ml(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const fl=["all","pending","completed","failed","cancelled"];function pl(){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:fl.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:ml(f.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:f.referrerEmail||f.referrerName||Vr(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:hl(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&&Vr(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 is(t,s){return s.toUpperCase()==="SOL"?`${(t/1e9).toFixed(4)} SOL`:`${t} ${s}`}function Hr(t){return t.length<=16?t:`${t.slice(0,8)}...${t.slice(-6)}`}function Uo({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(gl,{}):e.jsx(pl,{})]})}function gl(){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:is(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"," ",is(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:Hr(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:Hr(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:is(B.totalPendingAmount,B.currency)})]},B.referrerId))]})]})}function wl({pageSize:t,currentUserId:s}){const[r,o]=d.useState(null),{statsItems:n,isLoading:a,error:i,refresh:l}=Oe.useUsersStatsSummary();return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Oe.AdminUserDetail,{userId:r.id,currentUserId:s,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Ln.StatsBar,{stats:n,isLoading:a,onRefresh:l}),i&&e.jsx("p",{className:"cedros-admin-error-inline",children:i}),e.jsx(Oe.AdminUserList,{pageSize:t,currentUserId:s,onUserClick:c=>o(c)})]})}function bl({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(Ln.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 yl({pageSize:t,refreshInterval:s}){const[r,o]=d.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(_t.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(_t.AdminDepositList,{statusFilter:r||void 0,pageSize:t,refreshInterval:s})]})]})}function xl({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 vl(){return e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Uo,{})})}const Al=["security","rate_limit"];function jl({className:t}){return e.jsx(ut.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:Al,className:t})}const Qr=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Nl({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=Qr.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?kt.ALL_EMAIL_FIELDS:kt.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=kt.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:Qr.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 cs=["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 kl({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=>cs.includes(b.key)).sort((b,w)=>cs.indexOf(b.key)-cs.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",Gr[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",Gr[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 Sl=["kyc","accreditation","sanctions","token_gating"];function Do({className:t}){return e.jsx(ut.SettingsPageLayout,{title:"Compliance & Gating",description:"Configure KYC identity verification, accredited investor verification, sanctions screening, and Solana token gating.",categories:Sl,className:t})}const Cl=["referral"];function Fo({className:t}){return e.jsx(ut.SettingsPageLayout,{title:"Referrals & Rewards",description:"Configure referral reward types, amounts, triggers, per-referrer caps, and automated payout processing.",categories:Cl,className:t})}function El(){return`rule_${Date.now()}_${Math.random().toString(36).slice(2,7)}`}function _l(t){if(!t)return[];try{const s=JSON.parse(t);return Array.isArray(s)?s:[]}catch{return[]}}function Ll(t){switch(t){case"nft_collection":return"NFT Collection";case"fungible_token":return"Fungible Token";case"any_nft":return"Any NFT"}}function Pl(t){switch(t){case"all":return"All";case"deposits":return"Deposits";case"withdrawals":return"Withdrawals"}}const Kr={name:"",ruleType:"nft_collection",collectionAddress:"",mintAddress:"",minQuantity:"",minAmount:"",enforcement:"all"};function Rl(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 Tl(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 Wo({className:t=""}){const{fetchSettings:s,updateSettings:r,getValue:o,isLoading:n,error:a}=Gs.useSystemSettings(),[i,l]=d.useState([]),[c,h]=d.useState(null),[m,u]=d.useState(!1),[p,b]=d.useState(Kr),[w,g]=d.useState(null),[j,v]=d.useState(!1);d.useEffect(()=>{s()},[s]);const N=o("token_gating_rules"),k=d.useMemo(()=>_l(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(Kr),g(null),u(!0)},[]),f=d.useCallback(C=>{h(C.id),b(Rl(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??El(),P=Tl(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(Ml,{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:Ll(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:Pl(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 Ml({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 Bl(t){return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Il(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 Ul(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 Dl({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:Il(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:Bl(t.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-badge ${Ul(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(Fl,{detail:r,onDocumentDownload:m}),t.status==="pending"&&e.jsx(Wl,{submissionId:t.id,notes:a,rejectionReason:i,isReviewing:l,error:c,onNotesChange:u,onRejectionReasonChange:p,onReview:b})]})]})]})}function Fl({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 Wl({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 ct=20;function Oo({className:t=""}){const{config:s,_internal:r}=M.useCedrosLogin(),o=d.useMemo(()=>new Oe.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(ct,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]),D=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/ct),K=Math.floor(m/ct)+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(Dl,{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:D},$.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-ct)),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+ct),disabled:K>=z,children:"Next"})]})]})})]})}function Ol(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 ql(t){return t?new Date(t).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function qo({className:t=""}){const{config:s,_internal:r}=M.useCedrosLogin(),o=d.useMemo(()=>new Oe.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:Ol(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: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 zl{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 ar(){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 zl(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 $l=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Yr=8;function Vl(t){const s={};return t.email?$l.test(t.email)||(s.email="Invalid email format"):s.email="Email is required",t.password?t.password.length<Yr&&(s.password=`Password must be at least ${Yr} 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 zo({onComplete:t,className:s=""}){const{status:r,isLoading:o,isCreating:n,error:a,checkStatus:i,createAdmin:l}=ar(),[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=Vl(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 Hl({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}=Ks.useOrgs(),{status:S,isLoading:E,checkStatus:f}=ar(),{features:y,isLoading:x}=he.useServerFeatures(),{canAccess:A}=he.useDashboardPermissions(),_=d.useCallback(T=>{m(T),a?.(T)},[a]),C=ul.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(zo,{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(wl,{pageSize:n,currentUserId:b?.id}),h==="team"&&g&&e.jsx(bl,{orgId:g.id,currentUserId:b?.id,hasPermission:k,role:j}),h==="referrals"&&e.jsx(vl,{}),h==="deposits"&&e.jsx(yl,{pageSize:n,refreshInterval:o}),h==="withdrawals"&&e.jsx(xl,{pageSize:n,refreshInterval:o}),h==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Pn.AuthenticationSettings,{})}),h==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Rn.EmbeddedWalletSettings,{})}),h==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Nl,{})}),h==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ys.CreditSystemSettings,{})}),h==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Tn.ServerSettings,{})}),h==="settings-images"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(kl,{})}),h==="compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Wo,{})}),h==="accreditation-queue"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Oo,{})}),h==="sanctions"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(qo,{})}),h==="settings-compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Do,{})}),h==="settings-referrals"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Fo,{})})]})]})]})}var Ze={},ls,Zr;function Ql(){return Zr||(Zr=1,ls=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),ls}var ds={},Te={},Xr;function ze(){if(Xr)return Te;Xr=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 us={},Jr;function ir(){return Jr||(Jr=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}}})(us)),us}var hs,en;function Gl(){if(en)return hs;en=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++}},hs=t,hs}var ms,tn;function Kl(){if(tn)return ms;tn=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]},ms=t,ms}var fs={},sn;function Yl(){return sn||(sn=1,(function(t){const s=ze().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}})(fs)),fs}var ps={},rn;function Zl(){if(rn)return ps;rn=1;const t=ze().getSymbolSize,s=7;return ps.getPositions=function(o){const n=t(o);return[[0,0],[n-s,0],[0,n-s]]},ps}var gs={},nn;function Xl(){return nn||(nn=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}})(gs)),gs}var yt={},on;function $o(){if(on)return yt;on=1;const t=ir(),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 yt.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}},yt.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}},yt}var ws={},lt={},an;function Jl(){if(an)return lt;an=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]})(),lt.log=function(o){if(o<1)throw new Error("log("+o+")");return s[o]},lt.exp=function(o){return t[o]},lt.mul=function(o,n){return o===0||n===0?0:t[s[o]+s[n]]},lt}var cn;function ed(){return cn||(cn=1,(function(t){const s=Jl();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}})(ws)),ws}var bs,ln;function td(){if(ln)return bs;ln=1;const t=ed();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},bs=s,bs}var ys={},xs={},vs={},dn;function Vo(){return dn||(dn=1,vs.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),vs}var Ae={},un;function Ho(){if(un)return Ae;un=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(t,"g"),Ae.ALPHANUMERIC=new RegExp(s,"g");const n=new RegExp("^"+r+"$"),a=new RegExp("^"+t+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Ae.testKanji=function(c){return n.test(c)},Ae.testNumeric=function(c){return a.test(c)},Ae.testAlphanumeric=function(c){return i.test(c)},Ae}var
|
|
2051
|
-
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},
|
|
2052
|
-
Suggested mode is: `+s.toString(S));switch(k===s.KANJI&&!l.isKanjiModeEnabled()&&(k=s.BYTE),k){case s.NUMERIC:return new r(v);case s.ALPHANUMERIC:return new o(v);case s.KANJI:return new a(v);case s.BYTE:return new n(v)}}t.fromArray=function(N){return N.reduce(function(k,S){return typeof S=="string"?k.push(j(S,null)):S.data&&k.push(j(S.data,S.mode)),k},[])},t.fromString=function(N,k){const S=u(N,l.isKanjiModeEnabled()),E=w(S),f=g(E,k),y=c.find_path(f.map,"start","end"),x=[];for(let A=1;A<y.length-1;A++)x.push(f.table[y[A]].node);return t.fromArray(b(x))},t.rawSplit=function(N){return t.fromArray(u(N,l.isKanjiModeEnabled()))}})(
|
|
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(t,"g"),Ae.ALPHANUMERIC=new RegExp(s,"g");const n=new RegExp("^"+r+"$"),a=new RegExp("^"+t+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Ae.testKanji=function(c){return n.test(c)},Ae.testNumeric=function(c){return a.test(c)},Ae.testAlphanumeric=function(c){return i.test(c)},Ae}var ln;function ze(){return ln||(ln=1,(function(t){const s=qo(),r=zo();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(a,i){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!s.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?a.ccBits[0]:i<27?a.ccBits[1]:a.ccBits[2]},t.getBestModeForData=function(a){return r.testNumeric(a)?t.NUMERIC:r.testAlphanumeric(a)?t.ALPHANUMERIC:r.testKanji(a)?t.KANJI:t.BYTE},t.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},t.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 t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+n)}}t.from=function(a,i){if(t.isValid(a))return a;try{return o(a)}catch{return i}}})(ws)),ws}var dn;function Zl(){return dn||(dn=1,(function(t){const s=qe(),r=Oo(),o=nr(),n=ze(),a=qo(),i=7973,l=s.getBCHDigit(i);function c(p,b,w){for(let g=1;g<=40;g++)if(b<=t.getCapacity(g,w,p))return g}function h(p,b){return n.getCharCountIndicator(p,b)+4}function m(p,b){let w=0;return p.forEach(function(g){const j=h(g.mode,b);w+=j+g.getBitsLength()}),w}function u(p,b){for(let w=1;w<=40;w++)if(m(p,w)<=t.getCapacity(w,b,n.MIXED))return w}t.from=function(b,w){return a.isValid(b)?parseInt(b,10):w},t.getCapacity=function(b,w,g){if(!a.isValid(b))throw new Error("Invalid QR Code version");typeof g>"u"&&(g=n.BYTE);const j=s.getSymbolTotalCodewords(b),v=r.getTotalCodewordsCount(b,w),N=(j-v)*8;if(g===n.MIXED)return N;const k=N-h(g,b);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)}},t.getBestVersionForData=function(b,w){let g;const j=o.from(w,o.M);if(Array.isArray(b)){if(b.length>1)return u(b,j);if(b.length===0)return 1;g=b[0]}else g=b;return c(g.mode,g.getLength(),j)},t.getEncodedBits=function(b){if(!a.isValid(b)||b<7)throw new Error("Invalid QR Code version");let w=b<<12;for(;s.getBCHDigit(w)-l>=0;)w^=i<<s.getBCHDigit(w)-l;return b<<12|w}})(gs)),gs}var ys={},un;function Xl(){if(un)return ys;un=1;const t=qe(),s=1335,r=21522,o=t.getBCHDigit(s);return ys.getEncodedBits=function(a,i){const l=a.bit<<3|i;let c=l<<10;for(;t.getBCHDigit(c)-o>=0;)c^=s<<t.getBCHDigit(c)-o;return(l<<10|c)^r},ys}var xs={},vs,hn;function Jl(){if(hn)return vs;hn=1;const t=ze();function s(r){this.mode=t.NUMERIC,this.data=r.toString()}return s.getBitsLength=function(o){return 10*Math.floor(o/3)+(o%3?o%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.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 l=this.data.length-n;l>0&&(a=this.data.substr(n),i=parseInt(a,10),o.put(i,l*3+1))},vs=s,vs}var As,mn;function ed(){if(mn)return As;mn=1;const t=ze(),s=["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=t.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=s.indexOf(this.data[a])*45;i+=s.indexOf(this.data[a+1]),n.put(i,11)}this.data.length%2&&n.put(s.indexOf(this.data[a]),6)},As=r,As}var js,fn;function td(){if(fn)return js;fn=1;const t=ze();function s(r){this.mode=t.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return s.getBitsLength=function(o){return o*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(r){for(let o=0,n=this.data.length;o<n;o++)r.put(this.data[o],8)},js=s,js}var Ns,pn;function sd(){if(pn)return Ns;pn=1;const t=ze(),s=qe();function r(o){this.mode=t.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=s.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)}},Ns=r,Ns}var ks={exports:{}},gn;function rd(){return gn||(gn=1,(function(t){var s={single_source_shortest_paths:function(r,o,n){var a={},i={};i[o]=0;var l=s.PriorityQueue.make();l.push(o,0);for(var c,h,m,u,p,b,w,g,j;!l.empty();){c=l.pop(),h=c.value,u=c.cost,p=r[h]||{};for(m in p)p.hasOwnProperty(m)&&(b=p[m],w=u+b,g=i[m],j=typeof i[m]>"u",(j||g>w)&&(i[m]=w,l.push(m,w),a[m]=h))}if(typeof n<"u"&&typeof i[n]>"u"){var v=["Could not find a path from ",o," to ",n,"."].join("");throw new Error(v)}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=s.single_source_shortest_paths(r,o,n);return s.extract_shortest_path_from_predecessor_list(a,n)},PriorityQueue:{make:function(r){var o=s.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}}};t.exports=s})(ks)),ks.exports}var wn;function nd(){return wn||(wn=1,(function(t){const s=ze(),r=Jl(),o=ed(),n=td(),a=sd(),i=zo(),l=qe(),c=rd();function h(v){return unescape(encodeURIComponent(v)).length}function m(v,N,k){const S=[];let E;for(;(E=v.exec(k))!==null;)S.push({data:E[0],index:E.index,mode:N,length:E[0].length});return S}function u(v){const N=m(i.NUMERIC,s.NUMERIC,v),k=m(i.ALPHANUMERIC,s.ALPHANUMERIC,v);let S,E;return l.isKanjiModeEnabled()?(S=m(i.BYTE,s.BYTE,v),E=m(i.KANJI,s.KANJI,v)):(S=m(i.BYTE_KANJI,s.BYTE,v),E=[]),N.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 p(v,N){switch(N){case s.NUMERIC:return r.getBitsLength(v);case s.ALPHANUMERIC:return o.getBitsLength(v);case s.KANJI:return a.getBitsLength(v);case s.BYTE:return n.getBitsLength(v)}}function b(v){return v.reduce(function(N,k){const S=N.length-1>=0?N[N.length-1]:null;return S&&S.mode===k.mode?(N[N.length-1].data+=k.data,N):(N.push(k),N)},[])}function w(v){const N=[];for(let k=0;k<v.length;k++){const S=v[k];switch(S.mode){case s.NUMERIC:N.push([S,{data:S.data,mode:s.ALPHANUMERIC,length:S.length},{data:S.data,mode:s.BYTE,length:S.length}]);break;case s.ALPHANUMERIC:N.push([S,{data:S.data,mode:s.BYTE,length:S.length}]);break;case s.KANJI:N.push([S,{data:S.data,mode:s.BYTE,length:h(S.data)}]);break;case s.BYTE:N.push([{data:S.data,mode:s.BYTE,length:h(S.data)}])}}return N}function g(v,N){const k={},S={start:{}};let E=["start"];for(let f=0;f<v.length;f++){const y=v[f],x=[];for(let A=0;A<y.length;A++){const _=y[A],C=""+f+A;x.push(C),k[C]={node:_,lastCount:0},S[C]={};for(let P=0;P<E.length;P++){const L=E[P];k[L]&&k[L].node.mode===_.mode?(S[L][C]=p(k[L].lastCount+_.length,_.mode)-p(k[L].lastCount,_.mode),k[L].lastCount+=_.length):(k[L]&&(k[L].lastCount=_.length),S[L][C]=p(_.length,_.mode)+4+s.getCharCountIndicator(_.mode,N))}}E=x}for(let f=0;f<E.length;f++)S[E[f]].end=0;return{map:S,table:k}}function j(v,N){let k;const S=s.getBestModeForData(v);if(k=s.from(N,S),k!==s.BYTE&&k.bit<S.bit)throw new Error('"'+v+'" cannot be encoded with mode '+s.toString(k)+`.
|
|
2052
|
+
Suggested mode is: `+s.toString(S));switch(k===s.KANJI&&!l.isKanjiModeEnabled()&&(k=s.BYTE),k){case s.NUMERIC:return new r(v);case s.ALPHANUMERIC:return new o(v);case s.KANJI:return new a(v);case s.BYTE:return new n(v)}}t.fromArray=function(N){return N.reduce(function(k,S){return typeof S=="string"?k.push(j(S,null)):S.data&&k.push(j(S.data,S.mode)),k},[])},t.fromString=function(N,k){const S=u(N,l.isKanjiModeEnabled()),E=w(S),f=g(E,k),y=c.find_path(f.map,"start","end"),x=[];for(let A=1;A<y.length-1;A++)x.push(f.table[y[A]].node);return t.fromArray(b(x))},t.rawSplit=function(N){return t.fromArray(u(N,l.isKanjiModeEnabled()))}})(xs)),xs}var bn;function od(){if(bn)return is;bn=1;const t=qe(),s=nr(),r=zl(),o=$l(),n=Vl(),a=Hl(),i=Ql(),l=Oo(),c=Yl(),h=Zl(),m=Xl(),u=ze(),p=nd();function b(f,y){const x=f.size,A=a.getPositions(y);for(let _=0;_<A.length;_++){const C=A[_][0],P=A[_][1];for(let L=-1;L<=7;L++)if(!(C+L<=-1||x<=C+L))for(let R=-1;R<=7;R++)P+R<=-1||x<=P+R||(L>=0&&L<=6&&(R===0||R===6)||R>=0&&R<=6&&(L===0||L===6)||L>=2&&L<=4&&R>=2&&R<=4?f.set(C+L,P+R,!0,!0):f.set(C+L,P+R,!1,!0))}}function w(f){const y=f.size;for(let x=8;x<y-8;x++){const A=x%2===0;f.set(x,6,A,!0),f.set(6,x,A,!0)}}function g(f,y){const x=n.getPositions(y);for(let A=0;A<x.length;A++){const _=x[A][0],C=x[A][1];for(let P=-2;P<=2;P++)for(let L=-2;L<=2;L++)P===-2||P===2||L===-2||L===2||P===0&&L===0?f.set(_+P,C+L,!0,!0):f.set(_+P,C+L,!1,!0)}}function j(f,y){const x=f.size,A=h.getEncodedBits(y);let _,C,P;for(let L=0;L<18;L++)_=Math.floor(L/3),C=L%3+x-8-3,P=(A>>L&1)===1,f.set(_,C,P,!0),f.set(C,_,P,!0)}function v(f,y,x){const A=f.size,_=m.getEncodedBits(y,x);let C,P;for(C=0;C<15;C++)P=(_>>C&1)===1,C<6?f.set(C,8,P,!0):C<8?f.set(C+1,8,P,!0):f.set(A-15+C,8,P,!0),C<8?f.set(8,A-C-1,P,!0):C<9?f.set(8,15-C-1+1,P,!0):f.set(8,15-C-1,P,!0);f.set(A-8,8,1,!0)}function N(f,y){const x=f.size;let A=-1,_=x-1,C=7,P=0;for(let L=x-1;L>0;L-=2)for(L===6&&L--;;){for(let R=0;R<2;R++)if(!f.isReserved(_,L-R)){let T=!1;P<y.length&&(T=(y[P]>>>C&1)===1),f.set(_,L-R,T),C--,C===-1&&(P++,C=7)}if(_+=A,_<0||x<=_){_-=A,A=-A;break}}}function k(f,y,x){const A=new r;x.forEach(function(R){A.put(R.mode.bit,4),A.put(R.getLength(),u.getCharCountIndicator(R.mode,f)),R.write(A)});const _=t.getSymbolTotalCodewords(f),C=l.getTotalCodewordsCount(f,y),P=(_-C)*8;for(A.getLengthInBits()+4<=P&&A.put(0,4);A.getLengthInBits()%8!==0;)A.putBit(0);const L=(P-A.getLengthInBits())/8;for(let R=0;R<L;R++)A.put(R%2?17:236,8);return S(A,f,y)}function S(f,y,x){const A=t.getSymbolTotalCodewords(y),_=l.getTotalCodewordsCount(y,x),C=A-_,P=l.getBlocksCount(y,x),L=A%P,R=P-L,T=Math.floor(A/P),B=Math.floor(C/P),F=B+1,W=T-B,O=new c(W);let I=0;const U=new Array(P),z=new Array(P);let K=0;const se=new Uint8Array(f.buffer);for(let ee=0;ee<P;ee++){const ue=ee<R?B:F;U[ee]=se.slice(I,I+ue),z[ee]=O.encode(U[ee]),I+=ue,K=Math.max(K,ue)}const $=new Uint8Array(A);let Y=0,V,H;for(V=0;V<K;V++)for(H=0;H<P;H++)V<U[H].length&&($[Y++]=U[H][V]);for(V=0;V<W;V++)for(H=0;H<P;H++)$[Y++]=z[H][V];return $}function E(f,y,x,A){let _;if(Array.isArray(f))_=p.fromArray(f);else if(typeof f=="string"){let T=y;if(!T){const B=p.rawSplit(f);T=h.getBestVersionForData(B,x)}_=p.fromString(f,T||40)}else throw new Error("Invalid data");const C=h.getBestVersionForData(_,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,_),L=t.getSymbolSize(y),R=new o(L);return b(R,y),w(R),g(R,y),v(R,x,0),y>=7&&j(R,y),N(R,P),isNaN(A)&&(A=i.getBestMask(R,v.bind(null,R,x))),i.applyMask(A,R),v(R,x,A),{modules:R,version:y,errorCorrectionLevel:x,maskPattern:A,segments:_}}return
|
|
2056
|
-
`;return typeof l=="function"&&l(null,j),j},
|
|
2057
|
-
`);await navigator.clipboard.writeText(x)}},f=async()=>{try{await c(b)}catch{w("")}},y=()=>{m(),s?.()};return d.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:()=>l(),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(
|
|
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(lr,{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 wd{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 ht(){const{config:t,authState:s,_internal:r}=M.useCedrosLogin(),[o,n]=d.useState(!1),[a,i]=d.useState(null),l=d.useMemo(()=>new wd(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 Ko(){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 bd({onPasswordChange:t,onClose:s,className:r=""}){const{user:o,refreshUser:n}=U.useAuth(),{config:a,_internal:i}=M.useCedrosLogin(),{isLoading:l,error:c,changePassword:h,updateProfile:m,clearError:u}=ht(),[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:D,isLoading:z}=Ko(),[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=qe.validatePassword(j),st=j===N,Ie=w.length>0&&j.length>0&&N.length>0&&we.isValid&&st,Ue=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 mt=i?.getAccessToken?.(),De={};mt&&(De.Authorization=`Bearer ${mt}`);const He=await fetch(`${a.serverUrl}/auth/upload/avatar`,{method:"POST",headers:De,body:be,credentials:"include"});if(!He.ok){const Qe=await He.json().catch(()=>null);throw new Error(Qe?.message||Qe?.error||`Upload failed (${He.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]),Ht=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]),rt=d.useCallback(()=>{b("main"),g(""),v(""),k(""),E(null),u()},[u]),Ve=()=>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&&!st?"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:rt,disabled:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:Ht,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:Ve()}),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:Ue,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 D();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 yd{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 dr(){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 yd(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 xd({onPasswordChange:t,onCancel:s,className:r=""}){const{isLoading:o,error:n,changePassword:a,clearError:i}=ht(),[l,c]=d.useState(""),[h,m]=d.useState(""),[u,p]=d.useState(""),[b,w]=d.useState(null),[g,j]=d.useState(null),v=qe.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 Yo({onPasswordChange:t,className:s=""}){const{user:r,refreshUser:o}=U.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:l}=ht(),{credentials:c}=dr(),{forgotPassword:h,isLoading:m,isSuccess:u,reset:p}=Ot(),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(xd,{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(vd,{})})]}),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 vd(){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 Zo={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 Xo({onLinkGoogle:t,onLinkApple:s,onAddPasskey:r,onLinkSolana:o,className:n=""}){const{credentials:a,isLoading:i,error:l,unlinkCredential:c,clearError:h,fetchCredentials:m}=dr(),{registerPasskey:u,isSupported:p}=or(),[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||Zo[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(Ad,{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(Jo,{})," Google"]}),E&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(ea,{})," 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(Vs,{})," Passkey"]})}),y&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(ta,{})," Solana"]})]})]})]})}function Ad({credential:t,isUnlinking:s,onUnlink:r}){const o=t.label||Zo[t.credentialType],n=jd[t.credentialType]||Nd;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 ",Sn(t.createdAt),t.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",Sn(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 Sn(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 jd={password:kd,oauth_google:Jo,oauth_apple:ea,solana:ta,webauthn_passkey:Vs,webauthn_security_key:Vs,totp:Sd,sso_oidc:Cd};function Nd(){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 kd(){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 Jo(){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 ea(){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 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("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 Vs(){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 Sd(){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 Cd(){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 Ed{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 sa(){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 Ed(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 _d={profile:"Profile",security:"Security",linked:"Linked Accounts"},Ld=["profile","security","linked"];function Pd({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}=sa();return e.jsxs("div",{className:`cedros-account-settings ${c}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:Ld.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:_d[g]},g))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[h==="profile"&&e.jsx(Yo,{onPasswordChange:r}),h==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Go,{onStatusChange:o}),e.jsx(Ao,{sessions:u,isLoading:p,error:b??void 0,onRevokeAll:async()=>{await w()}})]}),h==="linked"&&e.jsx(Xo,{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 Rd({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(lr,{onSuccess:t})})]})}function Td({onComplete:t,onSkip:s,className:r}){const{user:o}=U.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:l}=ht(),[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 ra(){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 Md({onComplete:t,onSkip:s,className:r}){const{checkAvailability:o,getSuggestion:n,setUsername:a,isLoading:i,error:l}=ra(),[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 na(){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 ur({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 zt(t,s){return s.privateDepositsEnabled&&t>=s.privateMinUsd?"private":t>=s.publicMinUsd?"public":"sol_micro"}const hr="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=",Bd=1e4,Dt=1e3,oa=3;function Id(t){return Number.isFinite(t)?`$${Math.round(t)}`:"$0"}function Ud(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 ${Id(s.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function mr(t,s,r){return Math.min(Math.max(t,s),r)}function Dd(t,s){if(s<=0)return 0;const r=mr(t/s,0,1);return Math.round(Math.pow(r,1/oa)*Dt)}function Fd(t,s){const r=mr(t/Dt,0,1);return s*Math.pow(r,oa)}function aa(t){return t<10?.01:t<100?1:t<500?5:t<1e3?10:t<5e3?25:50}function Wd(t){return t<1?2:0}function Cn(t){const s=aa(t),r=Math.round(t/s)*s,o=Wd(s);return Number(r.toFixed(o))}function fr({config:t,valueUsd:s,onChange:r,maxUsd:o=Bd,disabled:n=!1,className:a=""}){const i=mr(Number.isFinite(s)?s:0,0,o),l=d.useMemo(()=>zt(i,t),[i,t]),c=Ud(l,t),h=Dd(i,o),m=h/Dt*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(Cn(Math.max(0,Math.min(parseFloat(u.target.value)||0,o)))),placeholder:"Enter amount",disabled:n,min:0,step:aa(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:hr,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:Dt,step:1,value:h,onChange:u=>r(Cn(Fd(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 Od="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==",zd="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",$d="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==",Vd="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==",Hd="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",Gd="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",Kd="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 ia(t){const s=t.toUpperCase();return $t.find(o=>o.symbol===s)?.decimals??6}function Yd(t,s){const r=t.toUpperCase(),n=$t.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 $t=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:hr},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Hd},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Kd},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:zd},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:Gd},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Vd},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Qd},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:qd},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Od},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:$d}];function Zd(t){return t.companyFeePercent>0||t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap"||t.feePolicy==="user_pays_privacy"}function Xd(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 Et=1e9,Je={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:hr},et={mint:"other",symbol:"OTHER",name:"Other",decimals:6},ca=1e4;function Jd(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/Et,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/Et,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/Et,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 la(t,s,r){const o=Jd(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 eu(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 Vt(t,s){if(s<=0)return 0;const r=s<t.publicMinUsd,o=s>=t.privateMinUsd,n=Xd(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/Et*t.solPriceUsd,l=s*(n/100);return i+l}function da(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 En(t){return t.map(s=>s.trim()).filter(Boolean)}const tu=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function pr(t,s,r){if(tu.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 ua(t,s){return t.toFixed(Yd(s))}function su({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}=na(),A=U.useWallet(),_=En(t.quickActionTokens),C=En(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"?Je:s==="single-token"?B??P.find(q=>q.symbol==="USDC")??P[0]??Je:n??B??P.find(q=>q.symbol==="USDC")??P.find(q=>q.symbol!=="SOL")??P[0]??Je,W=d.useCallback(()=>N?"explainer":"unlock",[N]),[O,I]=d.useState(W),[D,z]=d.useState(F),[K,se]=d.useState(""),[$,Y]=d.useState(null),[V,H]=d.useState(null),[ee,ue]=d.useState(null),[we,st]=d.useState(null),[Ie,Ue]=d.useState(!1),[Ht,rt]=d.useState(!1),[Ve,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),st(null),Ue(!1),rt(!1),G(null),x()},[s,T,F,x]);const be=a??t.privateMinSol,mt=i,De=parseFloat(K),He=A.status==="enrolled_locked"||A.status==="enrolled_unlocked"||A.status==="unlocked",Qe=He&&A.isUnlocked,Qt=He&&!A.isUnlocked,yr=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])(),ga=yr.findIndex(q=>q.key===O),xr=d.useCallback(q=>{z(q)},[]),wa=d.useCallback(async q=>{if(!u){I(T==="sign"?"confirm":"show-address");return}rt(!0),H(null);try{const J=await u(q,T==="sign"?De:null,D);ue(J.sessionId),st(J.depositAddress),I(T==="sign"?"confirm":"show-address")}catch(Z){const J=Z instanceof Error?Z:new Error("Authorization failed");H(J.message)}finally{rt(!1)}},[u,T,De,D]),ba=d.useCallback(async(q,Z)=>{x(),H(null),I("signing");const J=q??De,re=Z??D;if(!g){if(Qt&&m){m(),I("confirm");return}if(!Qe){H("Wallet not ready"),I("error");return}}try{const pe=Math.round(J*Math.pow(10,re.decimals));if(g){await new Promise(Kt=>setTimeout(Kt,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),nt={token:s==="sol"?null:re,amount:J,amountSmallestUnit:pe,txSignature:Ce.txSignature,sessionId:Ce.sessionId,response:Ce,method:"sign"};Y(nt),I("success"),l?.(nt)}catch(pe){const Ce=pe instanceof Error?pe:new Error("Deposit failed");H(Ce.message),I("error"),c?.(Ce)}},[E,De,D,s,g,ee,Qe,Qt,m,l,c,x]),ya=d.useCallback(()=>{I("waiting")},[]),Gt=d.useCallback(async()=>{const q=we||A.solanaPubkey;if(q){ge.current&&clearTimeout(ge.current);try{await navigator.clipboard.writeText(q),Ue(!0),ge.current=setTimeout(()=>Ue(!1),2e3)}catch{const Z=document.createElement("textarea");Z.value=q,document.body.appendChild(Z),Z.select(),document.execCommand("copy"),document.body.removeChild(Z),Ue(!0),ge.current=setTimeout(()=>Ue(!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,nt=async()=>{if(!(Z||J>=pe)){J++;try{const ye=await f(ee);if(re=0,ye.status==="completed"||ye.status==="detected"){const Kt=ye.amountLamports?ye.amountLamports/Math.pow(10,D.decimals):0,va=ye.amountLamports||0,vr={token:s==="sol"?null:D,amount:Kt,amountSmallestUnit:va,txSignature:ye.txSignature||"",sessionId:ee,response:ye,method:"receive",depositAddress:A.solanaPubkey??void 0};Y(vr),I("success"),l?.(vr);return}}catch{if(re++,re>=Ce){H("Unable to check deposit status. Please check your connection and try again.");return}}Z||setTimeout(nt,w)}};return nt(),()=>{Z=!0}},[O,ee,g,f,D,s,A.solanaPubkey,l,w]),d.useEffect(()=>{if(!g||!j||O!=="waiting"||T!=="receive"||!we)return;const q=window.setTimeout(()=>{const Z=Ve??t.privateMinUsd,J=D.symbol==="SOL"&&t.solPriceUsd>0?Z/t.solPriceUsd:Z,re=Math.round(J*Math.pow(10,D.decimals)),pe={token:s==="sol"?null:D,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,Ve,t,D,s,ee,l]);const xa=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:yr.map((q,Z)=>{const J=ga>=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(ru,{siteName:k,config:S,depositConfig:t,currencyMode:s,token:D,tokens:L,onContinue:()=>I("unlock"),onCancel:h}),O==="unlock"&&e.jsx(nu,{token:D,tokens:L,currencyMode:s,depositMethod:T,isAuthorizing:Ht,error:V,onAuthorize:wa,onBack:N?()=>I("explainer"):void 0,onCancel:h}),O==="confirm"&&T==="sign"&&e.jsx(ou,{token:D,tokens:P,quickActionSymbols:_,customTokenSymbols:C,currencyMode:s,minAmount:be,maxAmount:mt,depositAddress:we||A.solanaPubkey,walletReady:Qe||g,needsUnlock:Qt&&!g,copied:Ie,isListening:!!ee&&!g,config:t,onCopy:Gt,onTokenSelect:xr,onUnlockRequired:m,onConfirm:(q,Z)=>ba(q,Z),onBack:()=>I("unlock"),onCancel:h}),O==="signing"&&e.jsx(au,{depositAddress:A.solanaPubkey}),O==="show-address"&&e.jsx(iu,{token:D,tokens:P,quickActionSymbols:_,customTokenSymbols:C,tokenPriceUsd:v,currencyMode:s,depositAddress:we||A.solanaPubkey,copied:Ie,isListening:!!ee&&!g,config:t,onCopy:Gt,onTokenSelect:xr,onAmountChange:G,onSent:ya,onBack:()=>I("unlock"),onCancel:h}),O==="waiting"&&e.jsx(cu,{token:D,depositAddress:we||A.solanaPubkey,copied:Ie,feeLine:Ve?(()=>{const q=Vt(t,Ve);return q===0?"No fees":`Fees: $${Math.max(q,.01).toFixed(2)} total`})():"Fees: calculated after deposit",onCopy:Gt}),O==="success"&&$&&e.jsx(lu,{result:$,config:t,onNewDeposit:xa}),O==="error"&&e.jsx(du,{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 ru({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=Hs.sanitizeExternalUrl(s?.exchangeUrl)??"https://www.coinbase.com",u=s?.showExchangeSuggestion!==!1,p=da(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=Zd(r),j=eu(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 nu({token:t,tokens:s,currencyMode:r,depositMethod:o,isAuthorizing:n,error:a,onAuthorize:i,onBack:l}){const[c,h]=d.useState(""),m=da(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 ou({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=zt(N,p)==="sol_micro",R=t.symbol===et.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===et.symbol)?H:[...H,et]},[s,o]),B=Vt(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?"":la(p,N,B),I=pr(L?Je:t,p),D=I?N/I:t.symbol==="SOL"&&p.solPriceUsd>0?N/p.solPriceUsd:null,z=D!=null?ua(D,L?"SOL":t.symbol):null,se=N-B<=0&&N>0,$=!R&&N>0&&!se&&D!=null&&D>=a&&D<=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=()=>{$&&D!=null&&j(D,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(ur,{tokens:T,selectedToken:t,onSelect:w,openSignal:x})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(fr,{config:p,valueUsd:N,onChange:k,maxUsd:ca})}),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":f,onClick:V=>{V.stopPropagation(),y(H=>!H)},onBlur:()=>y(!1),onKeyDown:V=>{V.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:v,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:Y,disabled:!$||!c||!l,children:"Deposit"})]})]})}function
|
|
2061
|
-
`,", ")}`,"aria-expanded":k,onClick:D=>{D.stopPropagation(),S(z=>!z)},onBlur:()=>S(!1),onKeyDown:D=>{D.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 cu({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 lu({result:t,config:s,onNewDeposit:r}){const o=t.token??Je,n=pr(o,s),a=n?t.amount*n:t.amount,i=Vt(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 du({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 gr(){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 uu({showAllCurrencies:t=!1,refreshInterval:s=0,compact:r=!1,className:o="",onLoad:n}){const{getBalance:a,getAllBalances:i,isLoading:l,error:c,clearError:h}=gr(),[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 Rs=[{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 hu(t,s){const r=t<0,o=Math.abs(t),n=ia(s),a=o/Math.pow(10,n),i=r?"-":"+";return s.toUpperCase()==="SOL"?`${i}${a.toFixed(4)} SOL`:`${i}$${a.toFixed(2)}`}function mu(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 fu(t){return t?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[t.toLowerCase()]||t:"Transaction"}function pu(t,s){const r=(t||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":s?"+":"−"}function gu({defaultTab:t="all",pageSize:s=10,refreshInterval:r=0,className:o="",onLoad:n,onTransactionClick:a}){const{getHistory:i,isLoading:l,error:c,clearError:h}=gr(),[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=Rs.find(L=>L.key===m)||Rs[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:Rs.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:pu(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:fu(L.txType)}),e.jsx("span",{className:`cedros-tx-amount ${R?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:hu(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:mu(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 wr(){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 Ts="So11111111111111111111111111111111111111112",wu={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function bu(t){return t.length<32||t.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(t)}function Ms(t){return t.length<=16?t:`${t.slice(0,6)}...${t.slice(-6)}`}function xt(t,s){return(Number(t)/Math.pow(10,s)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(s,6)})}function yu({onSuccess:t,onError:s,onCancel:r,className:o=""}){const n=M.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:i,getBalances:l,isSubmitting:c,error:h,clearError:m}=wr(),[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 D=await l();if(I)return;const z=[];D.solLamports>0&&z.push({symbol:"SOL",mint:Ts,decimals:9,rawBalance:String(D.solLamports),displayBalance:xt(String(D.solLamports),9)});for(const K of D.tokens){const se=wu[K.mint]??Ms(K.mint);z.push({symbol:se,mint:K.mint,decimals:K.decimals,rawBalance:K.amount,displayBalance:xt(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===Ts?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(!bu(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===Ts?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:[xt(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:Ms(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:[xt(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:Ms(E.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:O,children:"Done"})]})]}):null}function xu(t,s){if(t==="sol")return"SOL";if(!s)return"SPL";const r=$t.find(o=>o.mint===s);return r?r.symbol:`${s.slice(0,4)}...${s.slice(-4)}`}function vu(t,s){const r=Number(t);if(Number.isNaN(r))return t;const o=ia(s),n=r/Math.pow(10,o);return s==="SOL"?`${n.toFixed(4)} SOL`:`${n.toFixed(2)} ${s}`}function Au(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function ju(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 Nu({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}=wr(),[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=xu(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:vu(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:Au(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:ju(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 ku({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(qt,{defaultTab:i,onSuccess:a})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function Su({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(qt,{defaultTab:i,onSuccess:a})]})})]})}function Cu(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=d.useMemo(()=>new Ks.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 Eu(){const{listAllWallets:t,createDerivedWallet:s,deleteDerivedWallet:r}=U.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 _u(){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 Lu(t={}){const{onExternalSign:s}=t,{solanaPubkey:r,hasExternalWallet:o,status:n,isUnlocked:a}=U.useWallet(),{signTransaction:i,isSigning:l,error:c,clearError:h}=_o(),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 Pu(){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 Ru(){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 ha(){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 Bs(t,s){return s==="SOL"?(t/1e9).toFixed(4)+" SOL":"$"+(t/1e6).toFixed(2)}function Tu(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return t}}const Mu=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function Bu(t){return Mu.test(t)}function Iu(t){switch(t){case"signup":return"Sign-up";case"spend":return"Spend";case"first_spend":return"First Spend";default:return t}}function Uu({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 vt=10;function Du({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}=ha(),[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(vt,0).catch(()=>{})},[a,i]),d.useEffect(()=>{r?.payoutWalletAddress!=null&&b(r.payoutWalletAddress)},[r?.payoutWalletAddress]);const S=d.useCallback(x=>{u(x),i(vt,x*vt).catch(()=>{})},[i]),E=Math.ceil(n/vt),f=d.useCallback(async()=>{const x=p.trim();if(x!==""&&!Bu(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?Bs(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?`${Bs(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:Tu(x.createdAt)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:Iu(x.triggerType)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:Bs(x.amount,x.currency)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:e.jsx(Uu,{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 Fu({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 Wu=3e3,Ou=6e4;function qu(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 zu({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)},Ou),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,Wu),()=>{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:qu(o)}),s&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>s(o),children:"Continue"})]})})}function ma(){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 _n=[{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 At({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 $u(t,s,r,o){s({...t,[r]:o})}function jt(t,s){return t.filter(r=>r.documentType===s).map(r=>r.file)}function Nt(t,s,r,o){const n=t.filter(a=>a.documentType!==s);o([...n,...r.map(a=>({file:a,documentType:s}))])}function Vu({method:t,formData:s,onFormDataChange:r,fileEntries:o,onFileEntriesChange:n}){const a=(i,l)=>$u(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(At,{label:"Upload tax documents (W-2, 1040, 1099, K-1) from the last 2 years",documentType:"tax_return",files:jt(o,"tax_return"),onFilesChange:i=>Nt(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(At,{label:"Upload asset documents (bank/brokerage statements, property appraisals)",documentType:"asset_statement",files:jt(o,"asset_statement"),onFilesChange:i=>Nt(o,"asset_statement",i,n)}),e.jsx(At,{label:"Upload liability documents (credit report)",documentType:"liability_statement",files:jt(o,"liability_statement"),onFilesChange:i=>Nt(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(At,{label:"Upload verification letter from a CPA, attorney, RIA, or broker-dealer",documentType:"letter",files:jt(o,"letter"),onFilesChange:i=>Nt(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 Hu({onComplete:t,onCancel:s,className:r}){const{submitVerification:o,uploadDocument:n,isLoading:a,error:i}=ma(),[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=_n.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:_n.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(Vu,{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 br=d.createContext(null),Ft={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 fa(t,s){return pa(t,s)}function pa(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]=pa(n,a):a!==void 0&&(r[o]=a)}return r}function Gu({children:t,locale:s="en",translations:r}){const o=d.useMemo(()=>({t:r?fa(Ft,r):Ft,locale:s}),[r,s]);return e.jsx(br.Provider,{value:o,children:t})}function Ku(){return d.useContext(br)?.t??Ft}function Yu(){return d.useContext(br)?.locale??"en"}exports.CedrosLoginProvider=U.CedrosLoginProvider;exports.getEmbeddedWalletInfo=U.getEmbeddedWalletInfo;exports.isEmbeddedWalletAvailable=U.isEmbeddedWalletAvailable;exports.useAuth=U.useAuth;exports.useWallet=U.useWallet;exports.useWalletMaterial=U.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=qe.validatePassword;exports.ErrorMessage=te.ErrorMessage;exports.GoogleLoginButton=Qs.GoogleLoginButton;exports.useGoogleAuth=Qs.useGoogleAuth;exports.SolanaLoginButton=Xe.SolanaLoginButton;exports.registerMobileWallet=Xe.registerMobileWallet;exports.useSolanaAuth=Xe.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=Gs.useSystemSettings;exports.AdminDepositList=_t.AdminDepositList;exports.AdminDepositStats=_t.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Me.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Me.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Me.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Me.AdminWithdrawalStats;exports.AdminUserList=Oe.AdminUserList;exports.useAdminUsers=Oe.useAdminUsers;exports.useOrgs=Ks.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=Pn.AuthenticationSettings;exports.EmbeddedWalletSettings=Rn.EmbeddedWalletSettings;exports.EmailSettings=kt.EmailSettings;exports.CreditSystemSettings=Ys.CreditSystemSettings;exports.PrivacyCashSettings=Ys.CreditSystemSettings;exports.ServerSettings=Tn.ServerSettings;exports.SettingsPageLayout=ut.SettingsPageLayout;exports.WebhookSettings=ut.WebhookSettings;exports.useAdminDeposits=Aa.useAdminDeposits;exports.AccountSettings=Pd;exports.AccreditationBanner=Qu;exports.AccreditationWizard=Hu;exports.AdminAccreditationQueue=Oo;exports.AdminReferralPayouts=Uo;exports.AdminSanctionsPanel=qo;exports.AppleLoginButton=bo;exports.CapabilityWarning=$c;exports.CedrosAdminDashboard=Hl;exports.ChooseUsernamePrompt=Md;exports.CompleteAccountPrompt=Td;exports.ComplianceSettings=Do;exports.CreditBalance=uu;exports.DepositFlow=su;exports.ErrorBoundary=vo;exports.ForgotPasswordForm=po;exports.FullPageLayout=ku;exports.History=gu;exports.I18nProvider=Gu;exports.KycBanner=Fu;exports.KycCallback=zu;exports.LinkedAccounts=Xo;exports.LoginButton=wc;exports.LoginForm=qt;exports.LoginModal=kc;exports.MfaSetupPrompt=Rd;exports.OrgSelector=Cc;exports.OrgSwitcher=Ic;exports.PasskeyLoginButton=xo;exports.PasskeyPrompt=Po;exports.ProfileTab=Yo;exports.RecoveryPhraseDisplay=jo;exports.RecoveryPhraseInput=No;exports.ReferralSettings=Fo;exports.ResetPasswordForm=Sc;exports.RewardsPanel=Du;exports.SUPPORTED_TOKENS=$t;exports.SecuritySettings=jl;exports.SessionList=Ao;exports.SetupWizard=zo;exports.SplitPageLayout=Su;exports.SystemSettings=ll;exports.TieredAmountSlider=fr;exports.TokenGateSettings=Wo;exports.TokenSelector=ur;exports.TotpSettings=Go;exports.TotpSetup=lr;exports.UserProfileSettings=bd;exports.WalletAddressRow=Bo;exports.WalletEnrollment=Eo;exports.WalletManager=cl;exports.WalletRecovery=Mo;exports.WalletStatus=Io;exports.WalletUnlock=Ro;exports.WithdrawalFlow=yu;exports.WithdrawalHistory=Nu;exports.defaultTranslations=Ft;exports.getTierForAmount=zt;exports.mergeTranslations=fa;exports.useAccreditation=ma;exports.useAppleAuth=go;exports.useAuthorize=Cu;exports.useCredentials=dr;exports.useCredits=gr;exports.useDeposit=na;exports.useInstantLink=fo;exports.useKyc=Ru;exports.useLocale=Yu;exports.usePasskeySigning=Lo;exports.usePasswordReset=Ot;exports.usePendingRecovery=_u;exports.usePostLogin=Pu;exports.useProfile=ht;exports.useReferral=Ko;exports.useRewards=ha;exports.useSessions=sa;exports.useSetPassword=Co;exports.useSetup=ar;exports.useTotp=cr;exports.useTransactionSigning=Lu;exports.useTranslations=Ku;exports.useUsername=ra;exports.useWalletEnrollment=So;exports.useWalletRecovery=To;exports.useWalletSigning=_o;exports.useWallets=Eu;exports.useWebAuthn=or;exports.useWithdrawal=wr;
|
|
2055
|
+
`);const P=k(y,x,_),L=t.getSymbolSize(y),R=new o(L);return b(R,y),w(R),g(R,y),v(R,x,0),y>=7&&j(R,y),N(R,P),isNaN(A)&&(A=i.getBestMask(R,v.bind(null,R,x))),i.applyMask(A,R),v(R,x,A),{modules:R,version:y,errorCorrectionLevel:x,maskPattern:A,segments:_}}return is.create=function(y,x){if(typeof y>"u"||y==="")throw new Error("No input text");let A=s.M,_,C;return typeof x<"u"&&(A=s.from(x.errorCorrectionLevel,s.M),_=h.from(x.version),C=i.from(x.maskPattern),x.toSJISFunc&&t.setToSJISFunction(x.toSJISFunc)),E(y,_,A,C)},is}var Ss={},Cs={},yn;function $o(){return yn||(yn=1,(function(t){function s(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("")}}t.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:s(o.color.dark||"#000000ff"),light:s(o.color.light||"#ffffffff")},type:o.type,rendererOpts:o.rendererOpts||{}}},t.getScale=function(o,n){return n.width&&n.width>=o+n.margin*2?n.width/(o+n.margin*2):n.scale},t.getImageWidth=function(o,n){const a=t.getScale(o,n);return Math.floor((o+n.margin*2)*a)},t.qrToImageData=function(o,n,a){const i=n.modules.size,l=n.modules.data,c=t.getScale(i,a),h=Math.floor((i+a.margin*2)*c),m=a.margin*c,u=[a.color.light,a.color.dark];for(let p=0;p<h;p++)for(let b=0;b<h;b++){let w=(p*h+b)*4,g=a.color.light;if(p>=m&&b>=m&&p<h-m&&b<h-m){const j=Math.floor((p-m)/c),v=Math.floor((b-m)/c);g=u[l[j*i+v]?1:0]}o[w++]=g.r,o[w++]=g.g,o[w++]=g.b,o[w]=g.a}}})(Cs)),Cs}var xn;function ad(){return xn||(xn=1,(function(t){const s=$o();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")}}t.render=function(a,i,l){let c=l,h=i;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),i||(h=o()),c=s.getOptions(c);const m=s.getImageWidth(a.modules.size,c),u=h.getContext("2d"),p=u.createImageData(m,m);return s.qrToImageData(p.data,a,c),r(u,h,m),u.putImageData(p,0,0),h},t.renderToDataURL=function(a,i,l){let c=l;typeof c>"u"&&(!i||!i.getContext)&&(c=i,i=void 0),c||(c={});const h=t.render(a,i,c),m=c.type||"image/png",u=c.rendererOpts||{};return h.toDataURL(m,u.quality)}})(Ss)),Ss}var Es={},vn;function id(){if(vn)return Es;vn=1;const t=$o();function s(n,a){const i=n.a/255,l=a+'="'+n.hex+'"';return i<1?l+" "+a+'-opacity="'+i.toFixed(2).slice(1)+'"':l}function r(n,a,i){let l=n+a;return typeof i<"u"&&(l+=" "+i),l}function o(n,a,i){let l="",c=0,h=!1,m=0;for(let u=0;u<n.length;u++){const p=Math.floor(u%a),b=Math.floor(u/a);!p&&!h&&(h=!0),n[u]?(m++,u>0&&p>0&&n[u-1]||(l+=h?r("M",p+i,.5+b+i):r("m",c,0),c=0,h=!1),p+1<a&&n[u+1]||(l+=r("h",m),m=0)):c++}return l}return Es.render=function(a,i,l){const c=t.getOptions(i),h=a.modules.size,m=a.modules.data,u=h+c.margin*2,p=c.color.light.a?"<path "+s(c.color.light,"fill")+' d="M0 0h'+u+"v"+u+'H0z"/>':"",b="<path "+s(c.color.dark,"stroke")+' d="'+o(m,h,c.margin)+'"/>',w='viewBox="0 0 '+u+" "+u+'"',j='<svg xmlns="http://www.w3.org/2000/svg" '+(c.width?'width="'+c.width+'" height="'+c.width+'" ':"")+w+' shape-rendering="crispEdges">'+p+b+`</svg>
|
|
2056
|
+
`;return typeof l=="function"&&l(null,j),j},Es}var An;function cd(){if(An)return Ye;An=1;const t=ql(),s=od(),r=ad(),o=id();function n(a,i,l,c,h){const m=[].slice.call(arguments,1),u=m.length,p=typeof m[u-1]=="function";if(!p&&!t())throw new Error("Callback required as last argument");if(p){if(u<2)throw new Error("Too few arguments provided");u===2?(h=l,l=i,i=c=void 0):u===3&&(i.getContext&&typeof h>"u"?(h=c,c=void 0):(h=c,c=l,l=i,i=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(l=i,i=c=void 0):u===2&&!i.getContext&&(c=l,l=i,i=void 0),new Promise(function(b,w){try{const g=s.create(l,c);b(a(g,i,c))}catch(g){w(g)}})}try{const b=s.create(l,c);h(null,a(b,i,c))}catch(b){h(b)}}return Ye.create=s.create,Ye.toCanvas=n.bind(null,r.render),Ye.toDataURL=n.bind(null,r.renderToDataURL),Ye.toString=n.bind(null,function(a,i,l){return o.render(a,l)}),Ye}var ld=cd();const dd=Rn(ld);function ud({value:t,size:s=200,alt:r="QR code",className:o=""}){const n=d.useRef(null),[a,i]=d.useState(null);return d.useEffect(()=>{!n.current||!t||dd.toCanvas(n.current,t,{width:s,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{i(null)}).catch(l=>{i(l instanceof Error?l.message:"Failed to generate QR code")})},[t,s]),a?e.jsx("div",{className:`cedros-qr-error ${o}`,style:{width:s,height:s},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 or(){const{config:t,_internal:s}=M.useCedrosLogin(),[r,o]=d.useState(null),[n,a]=d.useState("idle"),[i,l]=d.useState(null),[c,h]=d.useState(!1),[m,u]=d.useState(null),p=d.useMemo(()=>new M.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),b=d.useCallback(async()=>{h(!0),u(null);try{const S=await p.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)}},[p]),w=d.useCallback(async()=>{h(!0),u(null),a("loading");try{const S=await p.post("/mfa/setup",{});return l(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)}},[p]),g=d.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 p.post("/mfa/enable",{code:S}),a("success");try{const E=await p.get("/mfa/status");o(E)}catch{o({enabled:!0,recoveryCodesRemaining:0})}}catch(E){const f=M.handleApiError(E,"Incorrect verification code. Please check and try again.");throw u(f),a("error"),f}finally{h(!1)}},[p]),j=d.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 p.post("/mfa/disable",{password:S}),o({enabled:!1,recoveryCodesRemaining:0}),l(null),a("idle")}catch(E){const f=M.handleApiError(E,"Unable to disable two-factor authentication. Please try again.");throw u(f),f}finally{h(!1)}},[p]),v=d.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 p.post("/mfa/recovery-codes/regenerate",{code:S})}catch(E){const f=M.handleApiError(E,"Unable to regenerate recovery codes. Please try again.");throw u(f),f}finally{h(!1)}},[p]),N=d.useCallback(()=>u(null),[]),k=d.useCallback(()=>{u(null),l(null),a("idle"),h(!1)},[]);return{status:r,setupState:n,setupData:i,isLoading:c,error:m,getStatus:b,beginSetup:w,enableTotp:g,disableTotp:j,regenerateBackupCodes:v,clearError:N,reset:k}}function ar({onSuccess:t,onCancel:s,className:r=""}){const{setupState:o,setupData:n,isLoading:a,error:i,beginSetup:l,enableTotp:c,clearError:h,reset:m}=or(),[u,p]=d.useState("qr"),[b,w]=d.useState(""),[g,j]=d.useState(!1),[v,N]=d.useState(!1),k=d.useRef(null);d.useEffect(()=>{o==="idle"&&l().catch(()=>{})},[o,l]),d.useEffect(()=>{o==="success"&&t?.()},[o,t]);const S=async()=>{n?.secret&&(await navigator.clipboard.writeText(n.secret),j(!0),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>j(!1),2e3))},E=async()=>{if(n?.recoveryCodes){const x=n.recoveryCodes.join(`
|
|
2057
|
+
`);await navigator.clipboard.writeText(x)}},f=async()=>{try{await c(b)}catch{w("")}},y=()=>{m(),s?.()};return d.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:()=>l(),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(ud,{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:()=>p("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,A)=>e.jsx("code",{className:"cedros-totp-backup-code",children:x},A))}),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:v,onChange:x=>N(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:()=>p("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>p("verify"),disabled:!v,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(X.OtpInput,{value:b,onChange:w,onComplete:f,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:()=>p("backup"),disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:f,disabled:a||b.length!==6,children:a?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function Vo({onStatusChange:t,className:s=""}){const{status:r,isLoading:o,error:n,getStatus:a,disableTotp:i,regenerateBackupCodes:l,clearError:c}=or(),[h,m]=d.useState("status"),[u,p]=d.useState(""),[b,w]=d.useState(""),[g,j]=d.useState(null),[v,N]=d.useState(!1),[k,S]=d.useState(null);d.useEffect(()=>{a().catch(()=>{})},[a]);const E=d.useCallback(()=>{m("status"),t?.(!0)},[t]),f=async()=>{N(!0),S(null);try{await i(u),m("status"),p(""),t?.(!1)}catch(A){S(A instanceof Error?A.message:"Failed to disable 2FA"),p("")}finally{N(!1)}},y=async()=>{N(!0),S(null);try{const A=await l(b);j(A.recoveryCodes),w("")}catch(A){S(A instanceof Error?A.message:"Failed to regenerate codes"),w("")}finally{N(!1)}},x=async()=>{g&&await navigator.clipboard.writeText(g.join(`
|
|
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":f,onClick:V=>{V.stopPropagation(),y(H=>!H)},onBlur:()=>y(!1),onKeyDown:V=>{V.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:v,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:Y,disabled:!$||!c||!l,children:"Deposit"})]})]})}function tu({depositAddress:t}){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..."}),t&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[t.slice(0,6),"...",t.slice(-4)]})]})]})}function su({token:t,tokens:s,quickActionSymbols:r,customTokenSymbols:o,tokenPriceUsd:n,currencyMode:a,depositAddress:i,copied:l,isListening:c,config:h,onCopy:m,onTokenSelect:u,onAmountChange:p,onSent:b,onBack:w}){const[g,j]=d.useState(h.privateMinUsd),[v,N]=d.useState(!1),[k,S]=d.useState(!1),[E,f]=d.useState(0),[y,x]=d.useState(null),_=Ot(g,h)==="sol_micro",C=t.symbol===Je.symbol,P=d.useMemo(()=>{const U=o.length===0?s:s.filter(se=>o.includes(se.symbol)),z=U.length>0?U:s;return z.some(se=>se.symbol===Je.symbol)?z:[...z,Je]},[s,o]),L=zt(h,g),R=L===0?0:L<.01?.01:L,T=C?"Fees: calculated after deposit":L===0?"No fees":`Fees: $${R.toFixed(2)} total`,B=C?"":aa(h,g,L),F=C||g>0,W=hr(_?Xe:t,h,n),O=W?g/W:null,I=O?ca(O,t.symbol):null;return d.useEffect(()=>{if(a==="multi-token")if(_&&t.symbol!=="SOL"){x(t);const U=s.find(z=>z.symbol==="SOL");U&&u(U)}else!_&&y&&t.symbol==="SOL"&&(u(y),x(null))},[_,t.symbol,a,s,u,y,t]),d.useEffect(()=>{p(g)},[g,p]),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"&&!_&&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(U=>{const z=s.find(se=>se.symbol===U),K=t.symbol===U;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${K?"is-active":""}`,onClick:()=>{z&&(N(!1),u(z))},disabled:!z,children:[z?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:z.logoUrl,alt:`${U} logo`}),U]},U)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${v?"is-active":""}`,onClick:()=>{N(!0),f(U=>U+1)},children:"Custom"})]}),v&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(cr,{tokens:P,selectedToken:t,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(ur,{config:h,valueUsd:g,onChange:j,maxUsd:oa})]}),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 ${I??"--"} ${_?"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:i}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:m,title:"Copy address",children:l?"✓":"📋"})]}),l&&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":B,"aria-label":`Fee breakdown: ${B.replaceAll(`
|
|
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;
|