@cedros/login-react 0.0.47 → 0.0.48
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/AdminWithdrawalHistory-CgYehfMH.js +948 -0
- package/dist/AdminWithdrawalHistory-CgYehfMH.js.map +1 -0
- package/dist/AdminWithdrawalHistory-zDUhPDNi.cjs +1 -0
- package/dist/AdminWithdrawalHistory-zDUhPDNi.cjs.map +1 -0
- package/dist/{WithdrawalsSection-BN-FjTEV.js → WithdrawalsSection-BCG_-DAP.js} +1 -1
- package/dist/{WithdrawalsSection-BN-FjTEV.js.map → WithdrawalsSection-BCG_-DAP.js.map} +1 -1
- package/dist/{WithdrawalsSection-BhuCwFat.cjs → WithdrawalsSection-DKpL2mt8.cjs} +1 -1
- package/dist/{WithdrawalsSection-BhuCwFat.cjs.map → WithdrawalsSection-DKpL2mt8.cjs.map} +1 -1
- package/dist/admin-only.cjs +1 -1
- package/dist/admin-only.js +1 -1
- package/dist/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4235 -4208
- package/dist/index.js.map +1 -1
- package/dist/{plugin-DNFjEfYp.cjs → plugin-C7dru1t-.cjs} +1 -1
- package/dist/{plugin-DNFjEfYp.cjs.map → plugin-C7dru1t-.cjs.map} +1 -1
- package/dist/{plugin-WYMrRNbz.js → plugin-DivbaxSZ.js} +1 -1
- package/dist/{plugin-WYMrRNbz.js.map → plugin-DivbaxSZ.js.map} +1 -1
- package/package.json +1 -1
- package/dist/AdminWithdrawalHistory-B2EY2ZmH.cjs +0 -1
- package/dist/AdminWithdrawalHistory-B2EY2ZmH.cjs.map +0 -1
- package/dist/AdminWithdrawalHistory-C76bkbjX.js +0 -916
- package/dist/AdminWithdrawalHistory-C76bkbjX.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./useAuth-2vgrAH-M.cjs"),M=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),c=require("react"),Q=require("./LoadingSpinner-d6sSxgQN.cjs"),es=require("./useServerFeatures-9_aNPaa6.cjs"),J=require("./EmailRegisterForm-ByYQ43yL.cjs"),We=require("./validation-BuGQrA-K.cjs"),te=require("./ErrorMessage-CHbYbVi2.cjs"),Ht=require("./GoogleLoginButton-DEwtBp56.cjs"),Ze=require("./SolanaLoginButton-2504p6cr.cjs"),fe=require("./PermissionsSection-CZsJuxo4.cjs"),Gt=require("./useSystemSettings-B2jY51ob.cjs"),ke=require("./AutosaveStatus-DfMPudTQ.cjs"),_s=require("./AdminDepositList-B_z6x3j5.cjs"),Me=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),Ie=require("./useUsersStatsSummary-CHRMrlk4.cjs"),Pn=require("./StatsBar-DTUZCwDD.cjs"),Qt=require("./useOrgs-CNqfn-fk.cjs"),Be=require("./plugin-DNFjEfYp.cjs"),Rn=require("./AuthenticationSettings-BBOjHR6j.cjs"),Tn=require("./EmbeddedWalletSettings-Db9a0D5l.cjs"),ks=require("./EmailSettings-DIjo3aJo.cjs"),Kt=require("./CreditSystemSettings-Badz4iAc.cjs"),Mn=require("./ServerSettings-j5Lu5D-R.cjs"),ss=require("./WebhookSettings-DOaydSWQ.cjs"),Sa=require("./useAdminDeposits-CpLd68oP.cjs");async function In(s,t,r=D.DEFAULT_KDF_PARAMS){return D.validateKdfParams(r),D.argon2Derive(s,t,r)}function Bn(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ca(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var r=function o(){var n=!1;try{n=this instanceof o}catch{}return n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(s).forEach(function(o){var n=Object.getOwnPropertyDescriptor(s,o);Object.defineProperty(r,o,n.get?n:{enumerable:!0,get:function(){return s[o]}})}),r}var Ss={exports:{}};const Ea=globalThis.crypto,_a=globalThis.crypto,La=globalThis.crypto.subtle,Pa=globalThis.crypto.getRandomValues.bind(globalThis.crypto),Ra=globalThis.crypto.randomUUID.bind(globalThis.crypto),Ta=Object.freeze(Object.defineProperty({__proto__:null,default:Ea,getRandomValues:Pa,randomUUID:Ra,subtle:La,webcrypto:_a},Symbol.toStringTag,{value:"Module"})),Ma=Ca(Ta);var Ia=Ss.exports,vr;function Ba(){return vr||(vr=1,(function(s,t){(function(r,o){s.exports=o(Ma)})(Ia,function(r){var o,n,a,i,d;function l(){o={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},n={},a=new Array(1024).join("0"),i=!0,d=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function h(){return!!(n&&n.rng&&typeof n.rng=="function")}function m(p,y){var x;if(y===0||y===1)return p;if(y&&y>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return y=y||n.bits,p&&(x=p.length%y),x?(a+p).slice(-(y-x+p.length)):p}function u(p){var y="",x,j;for(j=p.length-1;j>=0;j--){if(x=parseInt(p[j],16),isNaN(x))throw new Error("Invalid hex character.");y=m(x.toString(2),4)+y}return y}function f(p){var y="",x,j;for(p=m(p,4),j=p.length;j>=4;j-=4){if(x=parseInt(p.slice(j-4,j),2),isNaN(x))throw new Error("Invalid binary character.");y=x.toString(16)+y}return y}function w(){return!!(r&&typeof r=="object"&&(typeof r.getRandomValues=="function"||typeof r.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function b(){return typeof r=="object"&&typeof r.randomBytes=="function"}function g(p){function y(C,P,_,R){var T=0,I,O="",W;for(P&&(I=P.length-1);T<I||O.length<C;)W=Math.abs(parseInt(P[T],_)),O=O+m(W.toString(2),R),T++;return O=O.substr(-C),(O.match(/0/g)||[]).length===O.length?null:O}function x(C){var P,_,R,T,I=null;for(R=16,T=4,_=Math.ceil(C/8);I===null;)P=r.randomBytes(_),I=y(C,P.toString("hex"),R,T);return I}function j(C){var P,_,R,T=null;for(_=10,R=32,P=Math.ceil(C/32);T===null;)T=y(C,r.getRandomValues(new Uint32Array(P)),_,R);return T}function L(C){var P,_,R,T,I,O=null;T=10,I=32,_=Math.ceil(C/32),R=123456789,P=new Uint32Array(_);for(var W=0;W<P.length;W++)P[W]=R;for(;O===null;)O=y(C,P,T,I);return O}if(p&&p==="testRandom")return n.typeCSPRNG=p,L;if(p&&p==="nodeCryptoRandomBytes")return n.typeCSPRNG=p,x;if(p&&p==="browserCryptoGetRandomValues")return n.typeCSPRNG=p,j;if(b())return n.typeCSPRNG="nodeCryptoRandomBytes",x;if(w())return n.typeCSPRNG="browserCryptoGetRandomValues",j}function N(p,y){var x=[],j;for(y&&(p=m(p,y)),j=p.length;j>n.bits;j-=n.bits)x.push(parseInt(p.slice(j-n.bits,j),2));return x.push(parseInt(p.slice(0,j),2)),x}function A(p,y){var x=n.logs[p],j=0,L;for(L=y.length-1;L>=0;L--)j!==0?j=n.exps[(x+n.logs[j])%n.maxShares]^y[L]:j=y[L];return j}function v(p,y,x){var j=0,L,C,P,_;for(P=0,L=y.length;P<L;P++)if(x[P]){for(C=n.logs[x[P]],_=0;_<L;_++)if(P!==_){if(p===y[_]){C=-1;break}C=(C+n.logs[p^y[_]]-n.logs[y[P]^y[_]]+n.maxShares)%n.maxShares}j=C===-1?j:j^n.exps[C]}return j}function k(p,y,x){var j=[],L=[p],C,P;for(C=1;C<x;C++)L[C]=parseInt(n.rng(n.bits),2);for(C=1,P=y+1;C<P;C++)j[C-1]={x:C,y:A(C,L)};return j}function S(p,y,x){var j,L,C,P,_;if(y=parseInt(y,n.radix),p=parseInt(p,10)||n.bits,j=p.toString(36).toUpperCase(),C=Math.pow(2,p)-1,P=C.toString(n.radix).length,L=m(y.toString(n.radix),P),typeof y!="number"||y%1!==0||y<1||y>C)throw new Error("Share id must be an integer between 1 and "+C+", inclusive.");return _=j+L+x,_}var E={init:function(p,y){var x=[],j=[],L=1,C,P;if(l(),p&&(typeof p!="number"||p%1!==0||p<o.minBits||p>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(y&&d.indexOf(y)===-1)throw new Error("Invalid RNG type argument : '"+y+"'");for(n.radix=o.radix,n.bits=p||o.bits,n.size=Math.pow(2,n.bits),n.maxShares=n.size-1,C=o.primitivePolynomials[n.bits],P=0;P<n.size;P++)j[P]=L,x[L]=P,L=L<<1,L>=n.size&&(L=L^C,L=L&n.maxShares);if(n.logs=x,n.exps=j,y&&this.setRNG(y),h()||this.setRNG(),!h()||!n.bits||!n.size||!n.maxShares||!n.logs||!n.exps||n.logs.length!==n.size||n.exps.length!==n.size)throw new Error("Initialization failed.")},combine:function(p,y){var x,j,L,C,P="",_,R,T,I=[],O=[];for(y=y||0,x=0,L=p.length;x<L;x++){if(R=this.extractShareComponents(p[x]),_===void 0)_=R.bits;else if(R.bits!==_)throw new Error("Mismatched shares: Different bit settings.");if(n.bits!==_&&this.init(_),I.indexOf(R.id)===-1)for(I.push(R.id),T=N(u(R.data)),j=0,C=T.length;j<C;j++)O[j]=O[j]||[],O[j][I.length-1]=T[j]}for(x=0,L=O.length;x<L;x++)P=m(v(y,I,O[x]).toString(2))+P;return f(y>=1?P:P.slice(P.indexOf("1")+1))},getConfig:function(){var p={};return p.radix=n.radix,p.bits=n.bits,p.maxShares=n.maxShares,p.hasCSPRNG=h(),p.typeCSPRNG=n.typeCSPRNG,p},extractShareComponents:function(p){var y,x,j,L,C={},P,_;if(y=parseInt(p.substr(0,1),36),y&&(typeof y!="number"||y%1!==0||y<o.minBits||y>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(L=Math.pow(2,y)-1,j=(Math.pow(2,y)-1).toString(n.radix).length,P="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+j+"})([a-fA-F0-9]+)$",_=new RegExp(P).exec(p),_&&(x=parseInt(_[2],n.radix)),typeof x!="number"||x%1!==0||x<1||x>L)throw new Error("Invalid share : Share id must be an integer between 1 and "+n.maxShares+", inclusive.");if(_&&_[3])return C.bits=y,C.id=x,C.data=_[3],C;throw new Error("The share data provided is invalid : "+p)},setRNG:function(p){var y="Random number generator is invalid ",x=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(p&&typeof p=="string"&&d.indexOf(p)===-1)throw new Error("Invalid RNG type argument : '"+p+"'");if(p||(p=g()),p&&typeof p=="string"&&(p=g(p)),i){if(p&&typeof p!="function")throw new Error(y+"(Not a function)."+x);if(p&&typeof p(n.bits)!="string")throw new Error(y+"(Output is not a string)."+x);if(p&&!parseInt(p(n.bits),2))throw new Error(y+"(Binary string output not parseable to an Integer)."+x);if(p&&p(n.bits).length>n.bits)throw new Error(y+"(Output length is greater than config.bits)."+x);if(p&&p(n.bits).length<n.bits)throw new Error(y+"(Output length is less than config.bits)."+x)}return n.rng=p,!0},str2hex:function(p,y){var x,j,L="",C,P,_,R;if(typeof p!="string")throw new Error("Input must be a character string.");if(y||(y=o.bytesPerChar),typeof y!="number"||y<1||y>o.maxBytesPerChar||y%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,j=Math.pow(16,x)-1,_=0,R=p.length;_<R;_++){if(P=p[_].charCodeAt(),isNaN(P))throw new Error("Invalid character: "+p[_]);if(P>j)throw C=Math.ceil(Math.log(P+1)/Math.log(256)),new Error("Invalid character code ("+P+"). Maximum allowable is 256^bytes-1 ("+j+"). To convert this character, use at least "+C+" bytes.");L=m(P.toString(16),x)+L}return L},hex2str:function(p,y){var x,j="",L,C;if(typeof p!="string")throw new Error("Input must be a hexadecimal string.");if(y=y||o.bytesPerChar,typeof y!="number"||y%1!==0||y<1||y>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,p=m(p,x),L=0,C=p.length;L<C;L+=x)j=String.fromCharCode(parseInt(p.slice(L,L+x),16))+j;return j},random:function(p){if(typeof p!="number"||p%1!==0||p<2||p>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return f(n.rng(p))},share:function(p,y,x,j){var L,C,P=new Array(y),_=new Array(y),R,T,I;if(j=j||128,typeof p!="string")throw new Error("Secret must be a string.");if(typeof y!="number"||y%1!==0||y<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(y>n.maxShares)throw L=Math.ceil(Math.log(y+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To create "+y+" shares, use at least "+L+" bits.");if(typeof x!="number"||x%1!==0||x<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(x>n.maxShares)throw L=Math.ceil(Math.log(x+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive. To use a threshold of "+x+", use at least "+L+" bits.");if(x>y)throw new Error("Threshold number of shares was "+x+" but must be less than or equal to the "+y+" shares specified as the total to generate.");if(typeof j!="number"||j%1!==0||j<0||j>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(p="1"+u(p),p=N(p,j),R=0,I=p.length;R<I;R++)for(C=k(p[R],y,x),T=0;T<y;T++)P[T]=P[T]||C[T].x.toString(n.radix),_[T]=m(C[T].y.toString(2))+(_[T]||"");for(R=0;R<y;R++)P[R]=S(n.bits,P[R],f(_[R]));return P},newShare:function(p,y){var x,j;if(p&&typeof p=="string"&&(p=parseInt(p,n.radix)),j=p.toString(n.radix),p&&j&&y&&y[0])return x=this.extractShareComponents(y[0]),S(x.bits,j,this.combine(y,p));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:l,_padLeft:m,_hex2bin:u,_bin2hex:f,_hasCryptoGetRandomValues:w,_hasCryptoRandomBytes:b,_getRNG:g,_isSetRNG:h,_splitNumStringToIntArray:N,_horner:A,_lagrange:v,_getShares:k,_constructPublicShareString:S};return E.init(),E})})(Ss)),Ss.exports}var Ua=Ba();const Un=Bn(Ua);function Dn(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Yt(s,t=""){if(!Number.isSafeInteger(s)||s<0){const r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${s}`)}}function ie(s,t,r=""){const o=Dn(s),n=s?.length,a=t!==void 0;if(!o||a&&n!==t){const i=r&&`"${r}" `,d=a?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof s}`;throw new Error(i+"expected Uint8Array"+d+", got "+l)}return s}function Ar(s,t=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(t&&s.finished)throw new Error("Hash#digest() has already been called")}function Da(s,t){ie(s,void 0,"digestInto() output");const r=t.outputLen;if(s.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Bt(...s){for(let t=0;t<s.length;t++)s[t].fill(0)}function Ys(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}const Fn=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Fa=Array.from({length:256},(s,t)=>t.toString(16).padStart(2,"0"));function Zt(s){if(ie(s),Fn)return s.toHex();let t="";for(let r=0;r<s.length;r++)t+=Fa[s[r]];return t}const je={_0:48,_9:57,A:65,F:70,a:97,f:102};function jr(s){if(s>=je._0&&s<=je._9)return s-je._0;if(s>=je.A&&s<=je.F)return s-(je.A-10);if(s>=je.a&&s<=je.f)return s-(je.a-10)}function On(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(Fn)return Uint8Array.fromHex(s);const t=s.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const o=new Uint8Array(r);for(let n=0,a=0;n<r;n++,a+=2){const i=jr(s.charCodeAt(a)),d=jr(s.charCodeAt(a+1));if(i===void 0||d===void 0){const l=s[a]+s[a+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+a)}o[n]=i*16+d}return o}function Nr(...s){let t=0;for(let o=0;o<s.length;o++){const n=s[o];ie(n),t+=n.length}const r=new Uint8Array(t);for(let o=0,n=0;o<s.length;o++){const a=s[o];r.set(a,n),n+=a.length}return r}function Oa(s,t={}){const r=(n,a)=>s(a).update(n).digest(),o=s(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=n=>s(n),Object.assign(r,t),Object.freeze(r)}function Wa(s=32){const t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(s))}const qa=s=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,s])});let za=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,o,n){this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=Ys(this.buffer)}update(t){Ar(this),ie(t);const{view:r,buffer:o,blockLen:n}=this,a=t.length;for(let i=0;i<a;){const d=Math.min(n-this.pos,a-i);if(d===n){const l=Ys(t);for(;n<=a-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+d),this.pos),this.pos+=d,i+=d,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ar(this),Da(t,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Bt(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;o.setBigUint64(n-8,BigInt(this.length*8),a),this.process(o,0);const d=Ys(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const h=l/4,m=this.get();if(h>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)d.setUint32(4*u,m[u],a)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:d}=this;return t.destroyed=i,t.finished=a,t.length=n,t.pos=d,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}};const ce=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ps=BigInt(2**32-1),kr=BigInt(32);function $a(s,t=!1){return t?{h:Number(s&ps),l:Number(s>>kr&ps)}:{h:Number(s>>kr&ps)|0,l:Number(s&ps)|0}}function Va(s,t=!1){const r=s.length;let o=new Uint32Array(r),n=new Uint32Array(r);for(let a=0;a<r;a++){const{h:i,l:d}=$a(s[a],t);[o[a],n[a]]=[i,d]}return[o,n]}const Sr=(s,t,r)=>s>>>r,Cr=(s,t,r)=>s<<32-r|t>>>r,Ge=(s,t,r)=>s>>>r|t<<32-r,Qe=(s,t,r)=>s<<32-r|t>>>r,fs=(s,t,r)=>s<<64-r|t>>>r-32,gs=(s,t,r)=>s>>>r-32|t<<64-r;function Ne(s,t,r,o){const n=(t>>>0)+(o>>>0);return{h:s+r+(n/2**32|0)|0,l:n|0}}const Ha=(s,t,r)=>(s>>>0)+(t>>>0)+(r>>>0),Ga=(s,t,r,o)=>t+r+o+(s/2**32|0)|0,Qa=(s,t,r,o)=>(s>>>0)+(t>>>0)+(r>>>0)+(o>>>0),Ka=(s,t,r,o,n)=>t+r+o+n+(s/2**32|0)|0,Ya=(s,t,r,o,n)=>(s>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),Za=(s,t,r,o,n,a)=>t+r+o+n+a+(s/2**32|0)|0,Wn=Va(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(s=>BigInt(s))),Xa=Wn[0],Ja=Wn[1],Ee=new Uint32Array(80),_e=new Uint32Array(80);class ei extends za{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:r,Bh:o,Bl:n,Ch:a,Cl:i,Dh:d,Dl:l,Eh:h,El:m,Fh:u,Fl:f,Gh:w,Gl:b,Hh:g,Hl:N}=this;return[t,r,o,n,a,i,d,l,h,m,u,f,w,b,g,N]}set(t,r,o,n,a,i,d,l,h,m,u,f,w,b,g,N){this.Ah=t|0,this.Al=r|0,this.Bh=o|0,this.Bl=n|0,this.Ch=a|0,this.Cl=i|0,this.Dh=d|0,this.Dl=l|0,this.Eh=h|0,this.El=m|0,this.Fh=u|0,this.Fl=f|0,this.Gh=w|0,this.Gl=b|0,this.Hh=g|0,this.Hl=N|0}process(t,r){for(let k=0;k<16;k++,r+=4)Ee[k]=t.getUint32(r),_e[k]=t.getUint32(r+=4);for(let k=16;k<80;k++){const S=Ee[k-15]|0,E=_e[k-15]|0,p=Ge(S,E,1)^Ge(S,E,8)^Sr(S,E,7),y=Qe(S,E,1)^Qe(S,E,8)^Cr(S,E,7),x=Ee[k-2]|0,j=_e[k-2]|0,L=Ge(x,j,19)^fs(x,j,61)^Sr(x,j,6),C=Qe(x,j,19)^gs(x,j,61)^Cr(x,j,6),P=Qa(y,C,_e[k-7],_e[k-16]),_=Ka(P,p,L,Ee[k-7],Ee[k-16]);Ee[k]=_|0,_e[k]=P|0}let{Ah:o,Al:n,Bh:a,Bl:i,Ch:d,Cl:l,Dh:h,Dl:m,Eh:u,El:f,Fh:w,Fl:b,Gh:g,Gl:N,Hh:A,Hl:v}=this;for(let k=0;k<80;k++){const S=Ge(u,f,14)^Ge(u,f,18)^fs(u,f,41),E=Qe(u,f,14)^Qe(u,f,18)^gs(u,f,41),p=u&w^~u&g,y=f&b^~f&N,x=Ya(v,E,y,Ja[k],_e[k]),j=Za(x,A,S,p,Xa[k],Ee[k]),L=x|0,C=Ge(o,n,28)^fs(o,n,34)^fs(o,n,39),P=Qe(o,n,28)^gs(o,n,34)^gs(o,n,39),_=o&a^o&d^a&d,R=n&i^n&l^i&l;A=g|0,v=N|0,g=w|0,N=b|0,w=u|0,b=f|0,{h:u,l:f}=Ne(h|0,m|0,j|0,L|0),h=d|0,m=l|0,d=a|0,l=i|0,a=o|0,i=n|0;const T=Ha(L,P,R);o=Ga(T,j,C,_),n=T|0}({h:o,l:n}=Ne(this.Ah|0,this.Al|0,o|0,n|0)),{h:a,l:i}=Ne(this.Bh|0,this.Bl|0,a|0,i|0),{h:d,l}=Ne(this.Ch|0,this.Cl|0,d|0,l|0),{h,l:m}=Ne(this.Dh|0,this.Dl|0,h|0,m|0),{h:u,l:f}=Ne(this.Eh|0,this.El|0,u|0,f|0),{h:w,l:b}=Ne(this.Fh|0,this.Fl|0,w|0,b|0),{h:g,l:N}=Ne(this.Gh|0,this.Gl|0,g|0,N|0),{h:A,l:v}=Ne(this.Hh|0,this.Hl|0,A|0,v|0),this.set(o,n,a,i,d,l,h,m,u,f,w,b,g,N,A,v)}roundClean(){Bt(Ee,_e)}destroy(){Bt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class si extends ei{Ah=ce[0]|0;Al=ce[1]|0;Bh=ce[2]|0;Bl=ce[3]|0;Ch=ce[4]|0;Cl=ce[5]|0;Dh=ce[6]|0;Dl=ce[7]|0;Eh=ce[8]|0;El=ce[9]|0;Fh=ce[10]|0;Fl=ce[11]|0;Gh=ce[12]|0;Gl=ce[13]|0;Hh=ce[14]|0;Hl=ce[15]|0;constructor(){super(64)}}const ti=Oa(()=>new si,qa(3));const qn=BigInt(0),Er=BigInt(1);function Ut(s,t=""){if(typeof s!="boolean"){const r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof s)}return s}function ri(s){if(typeof s=="bigint"){if(!Cs(s))throw new Error("positive bigint expected, got "+s)}else Yt(s);return s}function zn(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?qn:BigInt("0x"+s)}function ni(s){return zn(Zt(s))}function Ls(s){return zn(Zt(Dt(ie(s)).reverse()))}function $n(s,t){Yt(t),s=ri(s);const r=On(s.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function oi(s,t){return $n(s,t).reverse()}function Dt(s){return Uint8Array.from(s)}const Cs=s=>typeof s=="bigint"&&qn<=s;function ai(s,t,r){return Cs(s)&&Cs(t)&&Cs(r)&&t<=s&&s<r}function _r(s,t,r,o){if(!ai(t,r,o))throw new Error("expected valid "+s+": "+r+" <= n < "+o+", got "+t)}const ii=s=>(Er<<BigInt(s))-Er;function Xt(s,t={},r={}){if(!s||typeof s!="object")throw new Error("expected valid options object");function o(a,i,d){const l=s[a];if(d&&l===void 0)return;const h=typeof l;if(h!==i||l===null)throw new Error(`param "${a}" is invalid: expected ${i}, got ${h}`)}const n=(a,i)=>Object.entries(a).forEach(([d,l])=>o(d,l,i));n(t,!1),n(r,!0)}function Lr(s){const t=new WeakMap;return(r,...o)=>{const n=t.get(r);if(n!==void 0)return n;const a=s(r,...o);return t.set(r,a),a}}const he=BigInt(0),de=BigInt(1),Oe=BigInt(2),Vn=BigInt(3),Hn=BigInt(4),Gn=BigInt(5),ci=BigInt(7),Qn=BigInt(8),li=BigInt(9),Kn=BigInt(16);function oe(s,t){const r=s%t;return r>=he?r:t+r}function ye(s,t,r){let o=s;for(;t-- >he;)o*=o,o%=r;return o}function Pr(s,t){if(s===he)throw new Error("invert: expected non-zero number");if(t<=he)throw new Error("invert: expected positive modulus, got "+t);let r=oe(s,t),o=t,n=he,a=de;for(;r!==he;){const d=o/r,l=o%r,h=n-a*d;o=r,r=l,n=a,a=h}if(o!==de)throw new Error("invert: does not exist");return oe(n,t)}function Jt(s,t,r){if(!s.eql(s.sqr(t),r))throw new Error("Cannot find square root")}function Yn(s,t){const r=(s.ORDER+de)/Hn,o=s.pow(t,r);return Jt(s,o,t),o}function di(s,t){const r=(s.ORDER-Gn)/Qn,o=s.mul(t,Oe),n=s.pow(o,r),a=s.mul(t,n),i=s.mul(s.mul(a,Oe),n),d=s.mul(a,s.sub(i,s.ONE));return Jt(s,d,t),d}function ui(s){const t=er(s),r=Zn(s),o=r(t,t.neg(t.ONE)),n=r(t,o),a=r(t,t.neg(o)),i=(s+ci)/Kn;return(d,l)=>{let h=d.pow(l,i),m=d.mul(h,o);const u=d.mul(h,n),f=d.mul(h,a),w=d.eql(d.sqr(m),l),b=d.eql(d.sqr(u),l);h=d.cmov(h,m,w),m=d.cmov(f,u,b);const g=d.eql(d.sqr(m),l),N=d.cmov(h,m,g);return Jt(d,N,l),N}}function Zn(s){if(s<Vn)throw new Error("sqrt is not defined for small field");let t=s-de,r=0;for(;t%Oe===he;)t/=Oe,r++;let o=Oe;const n=er(s);for(;Rr(n,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Yn;let a=n.pow(o,t);const i=(t+de)/Oe;return function(l,h){if(l.is0(h))return h;if(Rr(l,h)!==1)throw new Error("Cannot find square root");let m=r,u=l.mul(l.ONE,a),f=l.pow(h,t),w=l.pow(h,i);for(;!l.eql(f,l.ONE);){if(l.is0(f))return l.ZERO;let b=1,g=l.sqr(f);for(;!l.eql(g,l.ONE);)if(b++,g=l.sqr(g),b===m)throw new Error("Cannot find square root");const N=de<<BigInt(m-b-1),A=l.pow(u,N);m=b,u=l.sqr(A),f=l.mul(f,u),w=l.mul(w,A)}return w}}function hi(s){return s%Hn===Vn?Yn:s%Qn===Gn?di:s%Kn===li?ui(s):Zn(s)}const mi=(s,t)=>(oe(s,t)&de)===de,pi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fi(s){const t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=pi.reduce((o,n)=>(o[n]="function",o),t);return Xt(s,r),s}function gi(s,t,r){if(r<he)throw new Error("invalid exponent, negatives unsupported");if(r===he)return s.ONE;if(r===de)return t;let o=s.ONE,n=t;for(;r>he;)r&de&&(o=s.mul(o,n)),n=s.sqr(n),r>>=de;return o}function Xn(s,t,r=!1){const o=new Array(t.length).fill(r?s.ZERO:void 0),n=t.reduce((i,d,l)=>s.is0(d)?i:(o[l]=i,s.mul(i,d)),s.ONE),a=s.inv(n);return t.reduceRight((i,d,l)=>s.is0(d)?i:(o[l]=s.mul(i,o[l]),s.mul(i,d)),a),o}function Rr(s,t){const r=(s.ORDER-de)/Oe,o=s.pow(t,r),n=s.eql(o,s.ONE),a=s.eql(o,s.ZERO),i=s.eql(o,s.neg(s.ONE));if(!n&&!a&&!i)throw new Error("invalid Legendre symbol result");return n?1:a?0:-1}function wi(s,t){t!==void 0&&Yt(t);const r=t!==void 0?t:s.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class bi{ORDER;BITS;BYTES;isLE;ZERO=he;ONE=de;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=he)throw new Error("invalid field: expected ORDER > 0, got "+t);let o;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(o=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));const{nBitLength:n,nByteLength:a}=wi(t,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=n,this.BYTES=a,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return oe(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return he<=t&&t<this.ORDER}is0(t){return t===he}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&de)===de}neg(t){return oe(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return oe(t*t,this.ORDER)}add(t,r){return oe(t+r,this.ORDER)}sub(t,r){return oe(t-r,this.ORDER)}mul(t,r){return oe(t*r,this.ORDER)}pow(t,r){return gi(this,t,r)}div(t,r){return oe(t*Pr(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Pr(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=hi(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?oi(t,this.BYTES):$n(t,this.BYTES)}fromBytes(t,r=!1){ie(t);const{_lengths:o,BYTES:n,isLE:a,ORDER:i,_mod:d}=this;if(o){if(!o.includes(t.length)||t.length>n)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);const h=new Uint8Array(n);h.set(t,a?0:h.length-t.length),t=h}if(t.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=a?Ls(t):ni(t);if(d&&(l=oe(l,i)),!r&&!this.isValid(l))throw new Error("invalid field element: outside of range 0..ORDER");return l}invertBatch(t){return Xn(this,t)}cmov(t,r,o){return o?r:t}}function er(s,t={}){return new bi(s,t)}const Ps=BigInt(0),Ft=BigInt(1);function Tr(s,t){const r=t.negate();return s?r:t}function Zs(s,t){const r=Xn(s.Fp,t.map(o=>o.Z));return t.map((o,n)=>s.fromAffine(o.toAffine(r[n])))}function Jn(s,t){if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+s)}function Xs(s,t){Jn(s,t);const r=Math.ceil(t/s)+1,o=2**(s-1),n=2**s,a=ii(s),i=BigInt(s);return{windows:r,windowSize:o,mask:a,maxNumber:n,shiftBy:i}}function Mr(s,t,r){const{windowSize:o,mask:n,maxNumber:a,shiftBy:i}=r;let d=Number(s&n),l=s>>i;d>o&&(d-=a,l+=Ft);const h=t*o,m=h+Math.abs(d)-1,u=d===0,f=d<0,w=t%2!==0;return{nextN:l,offset:m,isZero:u,isNeg:f,isNegF:w,offsetF:h}}const Js=new WeakMap,eo=new WeakMap;function et(s){return eo.get(s)||1}function Ir(s){if(s!==Ps)throw new Error("invalid wNAF")}class xi{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,o=this.ZERO){let n=t;for(;r>Ps;)r&Ft&&(o=o.add(n)),n=n.double(),r>>=Ft;return o}precomputeWindow(t,r){const{windows:o,windowSize:n}=Xs(r,this.bits),a=[];let i=t,d=i;for(let l=0;l<o;l++){d=i,a.push(d);for(let h=1;h<n;h++)d=d.add(i),a.push(d);i=d.double()}return a}wNAF(t,r,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let n=this.ZERO,a=this.BASE;const i=Xs(t,this.bits);for(let d=0;d<i.windows;d++){const{nextN:l,offset:h,isZero:m,isNeg:u,isNegF:f,offsetF:w}=Mr(o,d,i);o=l,m?a=a.add(Tr(f,r[w])):n=n.add(Tr(u,r[h]))}return Ir(o),{p:n,f:a}}wNAFUnsafe(t,r,o,n=this.ZERO){const a=Xs(t,this.bits);for(let i=0;i<a.windows&&o!==Ps;i++){const{nextN:d,offset:l,isZero:h,isNeg:m}=Mr(o,i,a);if(o=d,!h){const u=r[l];n=n.add(m?u.negate():u)}}return Ir(o),n}getPrecomputes(t,r,o){let n=Js.get(r);return n||(n=this.precomputeWindow(r,t),t!==1&&(typeof o=="function"&&(n=o(n)),Js.set(r,n))),n}cached(t,r,o){const n=et(t);return this.wNAF(n,this.getPrecomputes(n,t,o),r)}unsafe(t,r,o,n){const a=et(t);return a===1?this._unsafeLadder(t,r,n):this.wNAFUnsafe(a,this.getPrecomputes(a,t,o),r,n)}createCache(t,r){Jn(r,this.bits),eo.set(t,r),Js.delete(t)}hasCache(t){return et(t)!==1}}function Br(s,t,r){if(t){if(t.ORDER!==s)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return fi(t),t}else return er(s,{isLE:r})}function yi(s,t,r={},o){if(o===void 0&&(o=s==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${s} CURVE object`);for(const l of["p","n","h"]){const h=t[l];if(!(typeof h=="bigint"&&h>Ps))throw new Error(`CURVE.${l} must be positive bigint`)}const n=Br(t.p,r.Fp,o),a=Br(t.n,r.Fn,o),d=["Gx","Gy","a","d"];for(const l of d)if(!n.isValid(t[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:a}}function vi(s,t){return function(o){const n=s(o);return{secretKey:n,publicKey:t(n)}}}const Le=BigInt(0),ae=BigInt(1),st=BigInt(2),Ai=BigInt(8);function ji(s,t,r,o){const n=s.sqr(r),a=s.sqr(o),i=s.add(s.mul(t.a,n),a),d=s.add(s.ONE,s.mul(t.d,s.mul(n,a)));return s.eql(i,d)}function Ni(s,t={}){const r=yi("edwards",s,t,t.FpFnLE),{Fp:o,Fn:n}=r;let a=r.CURVE;const{h:i}=a;Xt(t,{},{uvRatio:"function"});const d=st<<BigInt(n.BYTES*8)-ae,l=N=>o.create(N),h=t.uvRatio||((N,A)=>{try{return{isValid:!0,value:o.sqrt(o.div(N,A))}}catch{return{isValid:!1,value:Le}}});if(!ji(o,a,a.Gx,a.Gy))throw new Error("bad curve params: generator point");function m(N,A,v=!1){const k=v?ae:Le;return _r("coordinate "+N,A,k,d),A}function u(N){if(!(N instanceof b))throw new Error("EdwardsPoint expected")}const f=Lr((N,A)=>{const{X:v,Y:k,Z:S}=N,E=N.is0();A==null&&(A=E?Ai:o.inv(S));const p=l(v*A),y=l(k*A),x=o.mul(S,A);if(E)return{x:Le,y:ae};if(x!==ae)throw new Error("invZ was invalid");return{x:p,y}}),w=Lr(N=>{const{a:A,d:v}=a;if(N.is0())throw new Error("bad point: ZERO");const{X:k,Y:S,Z:E,T:p}=N,y=l(k*k),x=l(S*S),j=l(E*E),L=l(j*j),C=l(y*A),P=l(j*l(C+x)),_=l(L+l(v*l(y*x)));if(P!==_)throw new Error("bad point: equation left != right (1)");const R=l(k*S),T=l(E*p);if(R!==T)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(a.Gx,a.Gy,ae,l(a.Gx*a.Gy));static ZERO=new b(Le,ae,ae,Le);static Fp=o;static Fn=n;X;Y;Z;T;constructor(A,v,k,S){this.X=m("x",A),this.Y=m("y",v),this.Z=m("z",k,!0),this.T=m("t",S),Object.freeze(this)}static CURVE(){return a}static fromAffine(A){if(A instanceof b)throw new Error("extended point not allowed");const{x:v,y:k}=A||{};return m("x",v),m("y",k),new b(v,k,ae,l(v*k))}static fromBytes(A,v=!1){const k=o.BYTES,{a:S,d:E}=a;A=Dt(ie(A,k,"point")),Ut(v,"zip215");const p=Dt(A),y=A[k-1];p[k-1]=y&-129;const x=Ls(p),j=v?d:o.ORDER;_r("point.y",x,Le,j);const L=l(x*x),C=l(L-ae),P=l(E*L-S);let{isValid:_,value:R}=h(C,P);if(!_)throw new Error("bad point: invalid y coordinate");const T=(R&ae)===ae,I=(y&128)!==0;if(!v&&R===Le&&I)throw new Error("bad point: x=0 and x_0=1");return I!==T&&(R=l(-R)),b.fromAffine({x:R,y:x})}static fromHex(A,v=!1){return b.fromBytes(On(A),v)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(A=8,v=!0){return g.createCache(this,A),v||this.multiply(st),this}assertValidity(){w(this)}equals(A){u(A);const{X:v,Y:k,Z:S}=this,{X:E,Y:p,Z:y}=A,x=l(v*y),j=l(E*S),L=l(k*y),C=l(p*S);return x===j&&L===C}is0(){return this.equals(b.ZERO)}negate(){return new b(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:A}=a,{X:v,Y:k,Z:S}=this,E=l(v*v),p=l(k*k),y=l(st*l(S*S)),x=l(A*E),j=v+k,L=l(l(j*j)-E-p),C=x+p,P=C-y,_=x-p,R=l(L*P),T=l(C*_),I=l(L*_),O=l(P*C);return new b(R,T,O,I)}add(A){u(A);const{a:v,d:k}=a,{X:S,Y:E,Z:p,T:y}=this,{X:x,Y:j,Z:L,T:C}=A,P=l(S*x),_=l(E*j),R=l(y*k*C),T=l(p*L),I=l((S+E)*(x+j)-P-_),O=T-R,W=T+R,q=l(_-v*P),U=l(I*O),F=l(W*q),V=l(I*q),Y=l(O*W);return new b(U,F,Y,V)}subtract(A){return this.add(A.negate())}multiply(A){if(!n.isValidNot0(A))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:v,f:k}=g.cached(this,A,S=>Zs(b,S));return Zs(b,[v,k])[0]}multiplyUnsafe(A,v=b.ZERO){if(!n.isValid(A))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return A===Le?b.ZERO:this.is0()||A===ae?this:g.unsafe(this,A,k=>Zs(b,k),v)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return g.unsafe(this,a.n).is0()}toAffine(A){return f(this,A)}clearCofactor(){return i===ae?this:this.multiplyUnsafe(i)}toBytes(){const{x:A,y:v}=this.toAffine(),k=o.toBytes(v);return k[k.length-1]|=A&ae?128:0,k}toHex(){return Zt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const g=new xi(b,n.BITS);return b.BASE.precompute(8),b}function ki(s,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');Xt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=r,{BASE:n,Fp:a,Fn:i}=s,d=r.randomBytes||Wa,l=r.adjustScalarBytes||(x=>x),h=r.domain||((x,j,L)=>{if(Ut(L,"phflag"),j.length||L)throw new Error("Contexts/pre-hash are not supported");return x});function m(x){return i.create(Ls(x))}function u(x){const j=k.secretKey;ie(x,k.secretKey,"secretKey");const L=ie(t(x),2*j,"hashedSecretKey"),C=l(L.slice(0,j)),P=L.slice(j,2*j),_=m(C);return{head:C,prefix:P,scalar:_}}function f(x){const{head:j,prefix:L,scalar:C}=u(x),P=n.multiply(C),_=P.toBytes();return{head:j,prefix:L,scalar:C,point:P,pointBytes:_}}function w(x){return f(x).pointBytes}function b(x=Uint8Array.of(),...j){const L=Nr(...j);return m(t(h(L,ie(x,void 0,"context"),!!o)))}function g(x,j,L={}){x=ie(x,void 0,"message"),o&&(x=o(x));const{prefix:C,scalar:P,pointBytes:_}=f(j),R=b(L.context,C,x),T=n.multiply(R).toBytes(),I=b(L.context,T,_,x),O=i.create(R+I*P);if(!i.isValid(O))throw new Error("sign failed: invalid s");const W=Nr(T,i.toBytes(O));return ie(W,k.signature,"result")}const N={zip215:!0};function A(x,j,L,C=N){const{context:P,zip215:_}=C,R=k.signature;x=ie(x,R,"signature"),j=ie(j,void 0,"message"),L=ie(L,k.publicKey,"publicKey"),_!==void 0&&Ut(_,"zip215"),o&&(j=o(j));const T=R/2,I=x.subarray(0,T),O=Ls(x.subarray(T,R));let W,q,U;try{W=s.fromBytes(L,_),q=s.fromBytes(I,_),U=n.multiplyUnsafe(O)}catch{return!1}if(!_&&W.isSmallOrder())return!1;const F=b(P,q.toBytes(),W.toBytes(),j);return q.add(W.multiplyUnsafe(F)).subtract(U).clearCofactor().is0()}const v=a.BYTES,k={secretKey:v,publicKey:v,signature:2*v,seed:v};function S(x=d(k.seed)){return ie(x,k.seed,"seed")}function E(x){return Dn(x)&&x.length===i.BYTES}function p(x,j){try{return!!s.fromBytes(x,j)}catch{return!1}}const y={getExtendedPublicKey:f,randomSecretKey:S,isValidSecretKey:E,isValidPublicKey:p,toMontgomery(x){const{y:j}=s.fromBytes(x),L=k.publicKey,C=L===32;if(!C&&L!==57)throw new Error("only defined for 25519 and 448");const P=C?a.div(ae+j,ae-j):a.div(j-ae,j+ae);return a.toBytes(P)},toMontgomerySecret(x){const j=k.secretKey;ie(x,j);const L=t(x.subarray(0,j));return l(L).subarray(0,j)}};return Object.freeze({keygen:vi(S,w),getPublicKey:w,sign:g,verify:A,utils:y,Point:s,lengths:k})}const Si=BigInt(1),Ur=BigInt(2),Ci=BigInt(5),Ei=BigInt(8),sr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),_i={p:sr,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Ei,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Li(s){const t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),a=sr,d=s*s%a*s%a,l=ye(d,Ur,a)*d%a,h=ye(l,Si,a)*s%a,m=ye(h,Ci,a)*h%a,u=ye(m,t,a)*m%a,f=ye(u,r,a)*u%a,w=ye(f,o,a)*f%a,b=ye(w,n,a)*w%a,g=ye(b,n,a)*w%a,N=ye(g,t,a)*m%a;return{pow_p_5_8:ye(N,Ur,a)*s%a,b2:d}}function Pi(s){return s[0]&=248,s[31]&=127,s[31]|=64,s}const Dr=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ri(s,t){const r=sr,o=oe(t*t*t,r),n=oe(o*o*t,r),a=Li(s*n).pow_p_5_8;let i=oe(s*o*a,r);const d=oe(t*i*i,r),l=i,h=oe(i*Dr,r),m=d===s,u=d===oe(-s,r),f=d===oe(-s*Dr,r);return m&&(i=l),(u||f)&&(i=h),mi(i,r)&&(i=oe(-i,r)),{isValid:m||u,value:i}}const Ti=Ni(_i,{uvRatio:Ri});function Mi(s){return ki(Ti,ti,Object.assign({adjustScalarBytes:Pi},s))}const Ii=Mi({});function Bi(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Os(s,...t){if(!Bi(s))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(s.length))throw new Error("Uint8Array expected of length "+t+", got length="+s.length)}function Fr(s,t=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(t&&s.finished)throw new Error("Hash#digest() has already been called")}function Ui(s,t){Os(s);const r=t.outputLen;if(s.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Ot(...s){for(let t=0;t<s.length;t++)s[t].fill(0)}function tt(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function ve(s,t){return s<<32-t|s>>>t}function Di(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function so(s){return typeof s=="string"&&(s=Di(s)),Os(s),s}class Fi{}function Oi(s){const t=o=>s().update(so(o)).digest(),r=s();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>s(),t}function Wi(s,t,r,o){if(typeof s.setBigUint64=="function")return s.setBigUint64(t,r,o);const n=BigInt(32),a=BigInt(4294967295),i=Number(r>>n&a),d=Number(r&a),l=o?4:0,h=o?0:4;s.setUint32(t+l,i,o),s.setUint32(t+h,d,o)}function qi(s,t,r){return s&t^~s&r}function zi(s,t,r){return s&t^s&r^t&r}class $i extends Fi{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=tt(this.buffer)}update(t){Fr(this),t=so(t),Os(t);const{view:r,buffer:o,blockLen:n}=this,a=t.length;for(let i=0;i<a;){const d=Math.min(n-this.pos,a-i);if(d===n){const l=tt(t);for(;n<=a-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+d),this.pos),this.pos+=d,i+=d,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Fr(this),Ui(t,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Ot(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;Wi(o,n-8,BigInt(this.length*8),a),this.process(o,0);const d=tt(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=l/4,m=this.get();if(h>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)d.setUint32(4*u,m[u],a)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:d}=this;return t.destroyed=i,t.finished=a,t.length=n,t.pos=d,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}}const Pe=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Vi=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Re=new Uint32Array(64);class Hi extends $i{constructor(t=32){super(64,t,8,!1),this.A=Pe[0]|0,this.B=Pe[1]|0,this.C=Pe[2]|0,this.D=Pe[3]|0,this.E=Pe[4]|0,this.F=Pe[5]|0,this.G=Pe[6]|0,this.H=Pe[7]|0}get(){const{A:t,B:r,C:o,D:n,E:a,F:i,G:d,H:l}=this;return[t,r,o,n,a,i,d,l]}set(t,r,o,n,a,i,d,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=a|0,this.F=i|0,this.G=d|0,this.H=l|0}process(t,r){for(let u=0;u<16;u++,r+=4)Re[u]=t.getUint32(r,!1);for(let u=16;u<64;u++){const f=Re[u-15],w=Re[u-2],b=ve(f,7)^ve(f,18)^f>>>3,g=ve(w,17)^ve(w,19)^w>>>10;Re[u]=g+Re[u-7]+b+Re[u-16]|0}let{A:o,B:n,C:a,D:i,E:d,F:l,G:h,H:m}=this;for(let u=0;u<64;u++){const f=ve(d,6)^ve(d,11)^ve(d,25),w=m+f+qi(d,l,h)+Vi[u]+Re[u]|0,g=(ve(o,2)^ve(o,13)^ve(o,22))+zi(o,n,a)|0;m=h,h=l,l=d,d=i+w|0,i=a,a=n,n=o,o=w+g|0}o=o+this.A|0,n=n+this.B|0,a=a+this.C|0,i=i+this.D|0,d=d+this.E|0,l=l+this.F|0,h=h+this.G|0,m=m+this.H|0,this.set(o,n,a,i,d,l,h,m)}roundClean(){Ot(Re)}destroy(){this.set(0,0,0,0,0,0,0,0),Ot(this.buffer)}}const to=Oi(()=>new Hi),Gi=to,Qi="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ki(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const t=Gi(s),r=Ii.getPublicKey(t),o=new Uint8Array(64);return o.set(t,0),o.set(r,32),D.wipeBytes(t),{publicKey:r,secretKey:o}}function ro(s){const t=Ki(s),r=t.publicKey;return D.wipeBytes(t.secretKey),r}function no(s){if(s.length!==32)throw new Error(`Invalid public key length: expected 32, got ${s.length}`);return Yi(s)}function Yi(s){let t=0;for(let n=0;n<s.length&&s[n]===0;n++)t++;let r=0n;for(let n=0;n<s.length;n++)r=r*256n+BigInt(s[n]);let o="";for(;r>0n;){const n=Number(r%58n);o=Qi[n]+o,r=r/58n}return"1".repeat(t)+o}const Zi=2,Xi=3;function oo(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const t=Wt(s),r=Un.share(t,Xi,Zi);if(r.length!==3)throw new Error(`Unexpected share count: ${r.length}`);const o=rt(r[0]),n=rt(r[1]),a=rt(r[2]);return{shareA:D.toShamirShare(o),shareB:D.toShamirShare(n),shareC:D.toShamirShare(a)}}function Ji(s,t,r){const o=Or(s),n=Or(t);try{const a=Un.combine([o,n]),i=ao(a);if(i.length!==16)throw new Error(`Reconstructed seed has wrong length: ${i.length}`);return D.toSeed(i)}catch(a){throw a instanceof Error&&a.message.startsWith("Reconstructed seed")||a instanceof Error&&a.message.startsWith("Invalid expectedPublicKey")||a instanceof Error&&a.message.startsWith("Reconstructed seed does not match")?a:new Error("Failed to reconstruct seed from shares")}}function Wt(s){return Array.from(s).map(t=>t.toString(16).padStart(2,"0")).join("")}function ao(s){if(!/^[0-9a-fA-F]*$/.test(s))throw new Error("Invalid hex string: contains non-hex characters");if(s.length%2!==0)throw new Error(`Invalid hex string: length ${s.length} is odd (must be even)`);const t=new Uint8Array(s.length/2);for(let r=0;r<t.length;r++)t[r]=parseInt(s.substr(r*2,2),16);return t}function rt(s){const t=s.length%2!==0,r=t?"0"+s:s,o=ao(r),n=new Uint8Array(1+o.length);return n[0]=t?1:0,n.set(o,1),n}function Or(s){const t=s[0];if(t===0||t===1){const o=t===1,n=s.subarray(1),a=Wt(n),i=o?a.substring(1):a;if(/^[0-9a-f]/.test(i))return i}const r=Wt(s);return r.startsWith("0")&&!r.startsWith("00")?r.substring(1):r}function Rs(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function io(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function ec(s){if(typeof s!="function")throw new Error("function expected");return!0}function Ts(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function ts(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function Ms(s){if(!Array.isArray(s))throw new Error("array expected")}function Is(s,t){if(!io(!0,t))throw new Error(`${s}: array of strings expected`)}function co(s,t){if(!io(!1,t))throw new Error(`${s}: array of numbers expected`)}function sc(...s){const t=a=>a,r=(a,i)=>d=>a(i(d)),o=s.map(a=>a.encode).reduceRight(r,t),n=s.map(a=>a.decode).reduce(r,t);return{encode:o,decode:n}}function tc(s){const t=typeof s=="string"?s.split(""):s,r=t.length;Is("alphabet",t);const o=new Map(t.map((n,a)=>[n,a]));return{encode:n=>(Ms(n),n.map(a=>{if(!Number.isSafeInteger(a)||a<0||a>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${s}`);return t[a]})),decode:n=>(Ms(n),n.map(a=>{Ts("alphabet.decode",a);const i=o.get(a);if(i===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${s}`);return i}))}}function rc(s=""){return Ts("join",s),{encode:t=>(Is("join.decode",t),t.join(s)),decode:t=>(Ts("join.decode",t),t.split(s))}}function nc(s,t="="){return ts(s),Ts("padding",t),{encode(r){for(Is("padding.encode",r);r.length*s%8;)r.push(t);return r},decode(r){Is("padding.decode",r);let o=r.length;if(o*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function qt(s,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Ms(s),!s.length)return[];let o=0;const n=[],a=Array.from(s,d=>{if(ts(d),d<0||d>=t)throw new Error(`invalid integer: ${d}`);return d}),i=a.length;for(;;){let d=0,l=!0;for(let h=o;h<i;h++){const m=a[h],u=t*d,f=u+m;if(!Number.isSafeInteger(f)||u/t!==d||f-m!==u)throw new Error("convertRadix: carry overflow");const w=f/r;d=f%r;const b=Math.floor(w);if(a[h]=b,!Number.isSafeInteger(b)||b*r+d!==f)throw new Error("convertRadix: carry overflow");if(l)b?l=!1:o=h;else continue}if(n.push(d),l)break}for(let d=0;d<s.length-1&&s[d]===0;d++)n.push(0);return n.reverse()}const lo=(s,t)=>t===0?s:lo(t,s%t),Bs=(s,t)=>s+(t-lo(s,t)),nt=(()=>{let s=[];for(let t=0;t<40;t++)s.push(2**t);return s})();function zt(s,t,r,o){if(Ms(s),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Bs(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Bs(t,r)}`);let n=0,a=0;const i=nt[t],d=nt[r]-1,l=[];for(const h of s){if(ts(h),h>=i)throw new Error(`convertRadix2: invalid data word=${h} from=${t}`);if(n=n<<t|h,a+t>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${t}`);for(a+=t;a>=r;a-=r)l.push((n>>a-r&d)>>>0);const m=nt[a];if(m===void 0)throw new Error("invalid carry");n&=m-1}if(n=n<<r-a&d,!o&&a>=t)throw new Error("Excess padding");if(!o&&n>0)throw new Error(`Non-zero padding: ${n}`);return o&&a>0&&l.push(n>>>0),l}function oc(s){ts(s);const t=2**8;return{encode:r=>{if(!Rs(r))throw new Error("radix.encode input should be Uint8Array");return qt(Array.from(r),t,s)},decode:r=>(co("radix.decode",r),Uint8Array.from(qt(r,s,t)))}}function ac(s,t=!1){if(ts(s),s<=0||s>32)throw new Error("radix2: bits should be in (0..32]");if(Bs(8,s)>32||Bs(s,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Rs(r))throw new Error("radix2.encode input should be Uint8Array");return zt(Array.from(r),8,s,!t)},decode:r=>(co("radix2.decode",r),Uint8Array.from(zt(r,s,8,t)))}}function ic(s,t){return ts(s),ec(t),{encode(r){if(!Rs(r))throw new Error("checksum.encode: input should be Uint8Array");const o=t(r).slice(0,s),n=new Uint8Array(r.length+s);return n.set(r),n.set(o,r.length),n},decode(r){if(!Rs(r))throw new Error("checksum.decode: input should be Uint8Array");const o=r.slice(0,-s),n=r.slice(-s),a=t(o).slice(0,s);for(let i=0;i<s;i++)if(a[i]!==n[i])throw new Error("Invalid checksum");return o}}}const ws={alphabet:tc,chain:sc,checksum:ic,convertRadix:qt,convertRadix2:zt,radix:oc,radix2:ac,join:rc,padding:nc};const cc=s=>s[0]==="あいこくしん";function lc(s){if(typeof s!="string")throw new TypeError("invalid mnemonic type: "+typeof s);return s.normalize("NFKD")}function dc(s){const t=lc(s),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}function uo(s){Os(s,16,20,24,28,32)}const uc=s=>{const t=8-s.length/4;return new Uint8Array([to(s)[0]>>t<<t])};function ho(s){if(!Array.isArray(s)||s.length!==2048||typeof s[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return s.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),ws.chain(ws.checksum(1,uc),ws.radix2(11,!0),ws.alphabet(s))}function tr(s,t){const{words:r}=dc(s),o=ho(t).decode(r);return uo(o),o}function mo(s,t){return uo(s),ho(t).encode(s).join(cc(t)?" ":" ")}function rr(s,t){try{tr(s,t)}catch{return!1}return!0}const Se=`abandon
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("./useAuth-2vgrAH-M.cjs"),M=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),c=require("react"),z=require("./LoadingSpinner-d6sSxgQN.cjs"),Ke=require("./useServerFeatures-9_aNPaa6.cjs"),K=require("./EmailRegisterForm-ByYQ43yL.cjs"),Fe=require("./validation-BuGQrA-K.cjs"),Z=require("./ErrorMessage-CHbYbVi2.cjs"),zt=require("./GoogleLoginButton-DEwtBp56.cjs"),Ge=require("./SolanaLoginButton-2504p6cr.cjs"),pe=require("./PermissionsSection-CZsJuxo4.cjs"),$t=require("./useSystemSettings-B2jY51ob.cjs"),ye=require("./AutosaveStatus-DfMPudTQ.cjs"),ks=require("./AdminDepositList-B_z6x3j5.cjs"),Pe=require("./AdminWithdrawalHistory-zDUhPDNi.cjs"),Re=require("./useUsersStatsSummary-CHRMrlk4.cjs"),En=require("./StatsBar-DTUZCwDD.cjs"),Vt=require("./useOrgs-CNqfn-fk.cjs"),Te=require("./plugin-C7dru1t-.cjs"),_n=require("./AuthenticationSettings-BBOjHR6j.cjs"),Ln=require("./EmbeddedWalletSettings-Db9a0D5l.cjs"),vs=require("./EmailSettings-DIjo3aJo.cjs"),Ht=require("./CreditSystemSettings-Badz4iAc.cjs"),Pn=require("./ServerSettings-j5Lu5D-R.cjs"),Ye=require("./WebhookSettings-DOaydSWQ.cjs"),Sa=require("./useAdminDeposits-CpLd68oP.cjs");async function Rn(s,t,r=U.DEFAULT_KDF_PARAMS){return U.validateKdfParams(r),U.argon2Derive(s,t,r)}function Tn(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function Ca(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var t=s.default;if(typeof t=="function"){var r=function o(){var n=!1;try{n=this instanceof o}catch{}return n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(s).forEach(function(o){var n=Object.getOwnPropertyDescriptor(s,o);Object.defineProperty(r,o,n.get?n:{enumerable:!0,get:function(){return s[o]}})}),r}var As={exports:{}};const Ea=globalThis.crypto,_a=globalThis.crypto,La=globalThis.crypto.subtle,Pa=globalThis.crypto.getRandomValues.bind(globalThis.crypto),Ra=globalThis.crypto.randomUUID.bind(globalThis.crypto),Ta=Object.freeze(Object.defineProperty({__proto__:null,default:Ea,getRandomValues:Pa,randomUUID:Ra,subtle:La,webcrypto:_a},Symbol.toStringTag,{value:"Module"})),Ma=Ca(Ta);var Ba=As.exports,br;function Ia(){return br||(br=1,(function(s,t){(function(r,o){s.exports=o(Ma)})(Ba,function(r){var o,n,a,i,d;function l(){o={bits:8,radix:16,minBits:3,maxBits:20,bytesPerChar:2,maxBytesPerChar:6,primitivePolynomials:[null,null,1,3,3,5,3,3,29,17,9,5,83,27,43,3,45,9,39,39,9,5,3,33,27,9,71,39,9,5,83]},n={},a=new Array(1024).join("0"),i=!0,d=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function h(){return!!(n&&n.rng&&typeof n.rng=="function")}function m(p,y){var x;if(y===0||y===1)return p;if(y&&y>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return y=y||n.bits,p&&(x=p.length%y),x?(a+p).slice(-(y-x+p.length)):p}function u(p){var y="",x,j;for(j=p.length-1;j>=0;j--){if(x=parseInt(p[j],16),isNaN(x))throw new Error("Invalid hex character.");y=m(x.toString(2),4)+y}return y}function f(p){var y="",x,j;for(p=m(p,4),j=p.length;j>=4;j-=4){if(x=parseInt(p.slice(j-4,j),2),isNaN(x))throw new Error("Invalid binary character.");y=x.toString(16)+y}return y}function g(){return!!(r&&typeof r=="object"&&(typeof r.getRandomValues=="function"||typeof r.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function b(){return typeof r=="object"&&typeof r.randomBytes=="function"}function w(p){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 j(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(p&&p==="testRandom")return n.typeCSPRNG=p,_;if(p&&p==="nodeCryptoRandomBytes")return n.typeCSPRNG=p,x;if(p&&p==="browserCryptoGetRandomValues")return n.typeCSPRNG=p,j;if(b())return n.typeCSPRNG="nodeCryptoRandomBytes",x;if(g())return n.typeCSPRNG="browserCryptoGetRandomValues",j}function N(p,y){var x=[],j;for(y&&(p=m(p,y)),j=p.length;j>n.bits;j-=n.bits)x.push(parseInt(p.slice(j-n.bits,j),2));return x.push(parseInt(p.slice(0,j),2)),x}function A(p,y){var x=n.logs[p],j=0,_;for(_=y.length-1;_>=0;_--)j!==0?j=n.exps[(x+n.logs[j])%n.maxShares]^y[_]:j=y[_];return j}function v(p,y,x){var j=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(p===y[L]){C=-1;break}C=(C+n.logs[p^y[L]]-n.logs[y[P]^y[L]]+n.maxShares)%n.maxShares}j=C===-1?j:j^n.exps[C]}return j}function k(p,y,x){var j=[],_=[p],C,P;for(C=1;C<x;C++)_[C]=parseInt(n.rng(n.bits),2);for(C=1,P=y+1;C<P;C++)j[C-1]={x:C,y:A(C,_)};return j}function S(p,y,x){var j,_,C,P,L;if(y=parseInt(y,n.radix),p=parseInt(p,10)||n.bits,j=p.toString(36).toUpperCase(),C=Math.pow(2,p)-1,P=C.toString(n.radix).length,_=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=j+_+x,L}var E={init:function(p,y){var x=[],j=[],_=1,C,P;if(l(),p&&(typeof p!="number"||p%1!==0||p<o.minBits||p>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(y&&d.indexOf(y)===-1)throw new Error("Invalid RNG type argument : '"+y+"'");for(n.radix=o.radix,n.bits=p||o.bits,n.size=Math.pow(2,n.bits),n.maxShares=n.size-1,C=o.primitivePolynomials[n.bits],P=0;P<n.size;P++)j[P]=_,x[_]=P,_=_<<1,_>=n.size&&(_=_^C,_=_&n.maxShares);if(n.logs=x,n.exps=j,y&&this.setRNG(y),h()||this.setRNG(),!h()||!n.bits||!n.size||!n.maxShares||!n.logs||!n.exps||n.logs.length!==n.size||n.exps.length!==n.size)throw new Error("Initialization failed.")},combine:function(p,y){var x,j,_,C,P="",L,R,T,B=[],F=[];for(y=y||0,x=0,_=p.length;x<_;x++){if(R=this.extractShareComponents(p[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=N(u(R.data)),j=0,C=T.length;j<C;j++)F[j]=F[j]||[],F[j][B.length-1]=T[j]}for(x=0,_=F.length;x<_;x++)P=m(v(y,B,F[x]).toString(2))+P;return f(y>=1?P:P.slice(P.indexOf("1")+1))},getConfig:function(){var p={};return p.radix=n.radix,p.bits=n.bits,p.maxShares=n.maxShares,p.hasCSPRNG=h(),p.typeCSPRNG=n.typeCSPRNG,p},extractShareComponents:function(p){var y,x,j,_,C={},P,L;if(y=parseInt(p.substr(0,1),36),y&&(typeof y!="number"||y%1!==0||y<o.minBits||y>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(_=Math.pow(2,y)-1,j=(Math.pow(2,y)-1).toString(n.radix).length,P="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+j+"})([a-fA-F0-9]+)$",L=new RegExp(P).exec(p),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 : "+p)},setRNG:function(p){var y="Random number generator is invalid ",x=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(p&&typeof p=="string"&&d.indexOf(p)===-1)throw new Error("Invalid RNG type argument : '"+p+"'");if(p||(p=w()),p&&typeof p=="string"&&(p=w(p)),i){if(p&&typeof p!="function")throw new Error(y+"(Not a function)."+x);if(p&&typeof p(n.bits)!="string")throw new Error(y+"(Output is not a string)."+x);if(p&&!parseInt(p(n.bits),2))throw new Error(y+"(Binary string output not parseable to an Integer)."+x);if(p&&p(n.bits).length>n.bits)throw new Error(y+"(Output length is greater than config.bits)."+x);if(p&&p(n.bits).length<n.bits)throw new Error(y+"(Output length is less than config.bits)."+x)}return n.rng=p,!0},str2hex:function(p,y){var x,j,_="",C,P,L,R;if(typeof p!="string")throw new Error("Input must be a character string.");if(y||(y=o.bytesPerChar),typeof y!="number"||y<1||y>o.maxBytesPerChar||y%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,j=Math.pow(16,x)-1,L=0,R=p.length;L<R;L++){if(P=p[L].charCodeAt(),isNaN(P))throw new Error("Invalid character: "+p[L]);if(P>j)throw C=Math.ceil(Math.log(P+1)/Math.log(256)),new Error("Invalid character code ("+P+"). Maximum allowable is 256^bytes-1 ("+j+"). To convert this character, use at least "+C+" bytes.");_=m(P.toString(16),x)+_}return _},hex2str:function(p,y){var x,j="",_,C;if(typeof p!="string")throw new Error("Input must be a hexadecimal string.");if(y=y||o.bytesPerChar,typeof y!="number"||y%1!==0||y<1||y>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(x=2*y,p=m(p,x),_=0,C=p.length;_<C;_+=x)j=String.fromCharCode(parseInt(p.slice(_,_+x),16))+j;return j},random:function(p){if(typeof p!="number"||p%1!==0||p<2||p>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return f(n.rng(p))},share:function(p,y,x,j){var _,C,P=new Array(y),L=new Array(y),R,T,B;if(j=j||128,typeof p!="string")throw new Error("Secret must be a string.");if(typeof y!="number"||y%1!==0||y<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+n.maxShares+"), inclusive.");if(y>n.maxShares)throw _=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 j!="number"||j%1!==0||j<0||j>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(p="1"+u(p),p=N(p,j),R=0,B=p.length;R<B;R++)for(C=k(p[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],f(L[R]));return P},newShare:function(p,y){var x,j;if(p&&typeof p=="string"&&(p=parseInt(p,n.radix)),j=p.toString(n.radix),p&&j&&y&&y[0])return x=this.extractShareComponents(y[0]),S(x.bits,j,this.combine(y,p));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:l,_padLeft:m,_hex2bin:u,_bin2hex:f,_hasCryptoGetRandomValues:g,_hasCryptoRandomBytes:b,_getRNG:w,_isSetRNG:h,_splitNumStringToIntArray:N,_horner:A,_lagrange:v,_getShares:k,_constructPublicShareString:S};return E.init(),E})})(As)),As.exports}var Da=Ia();const Mn=Tn(Da);function Bn(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Gt(s,t=""){if(!Number.isSafeInteger(s)||s<0){const r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${s}`)}}function ne(s,t,r=""){const o=Bn(s),n=s?.length,a=t!==void 0;if(!o||a&&n!==t){const i=r&&`"${r}" `,d=a?` of length ${t}`:"",l=o?`length=${n}`:`type=${typeof s}`;throw new Error(i+"expected Uint8Array"+d+", got "+l)}return s}function xr(s,t=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(t&&s.finished)throw new Error("Hash#digest() has already been called")}function Ua(s,t){ne(s,void 0,"digestInto() output");const r=t.outputLen;if(s.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function Tt(...s){for(let t=0;t<s.length;t++)s[t].fill(0)}function Gs(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}const In=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Fa=Array.from({length:256},(s,t)=>t.toString(16).padStart(2,"0"));function Qt(s){if(ne(s),In)return s.toHex();let t="";for(let r=0;r<s.length;r++)t+=Fa[s[r]];return t}const be={_0:48,_9:57,A:65,F:70,a:97,f:102};function yr(s){if(s>=be._0&&s<=be._9)return s-be._0;if(s>=be.A&&s<=be.F)return s-(be.A-10);if(s>=be.a&&s<=be.f)return s-(be.a-10)}function Dn(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);if(In)return Uint8Array.fromHex(s);const t=s.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const o=new Uint8Array(r);for(let n=0,a=0;n<r;n++,a+=2){const i=yr(s.charCodeAt(a)),d=yr(s.charCodeAt(a+1));if(i===void 0||d===void 0){const l=s[a]+s[a+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+a)}o[n]=i*16+d}return o}function vr(...s){let t=0;for(let o=0;o<s.length;o++){const n=s[o];ne(n),t+=n.length}const r=new Uint8Array(t);for(let o=0,n=0;o<s.length;o++){const a=s[o];r.set(a,n),n+=a.length}return r}function Wa(s,t={}){const r=(n,a)=>s(a).update(n).digest(),o=s(void 0);return r.outputLen=o.outputLen,r.blockLen=o.blockLen,r.create=n=>s(n),Object.assign(r,t),Object.freeze(r)}function Oa(s=32){const t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(s))}const qa=s=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,s])});let za=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,o,n){this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=Gs(this.buffer)}update(t){xr(this),ne(t);const{view:r,buffer:o,blockLen:n}=this,a=t.length;for(let i=0;i<a;){const d=Math.min(n-this.pos,a-i);if(d===n){const l=Gs(t);for(;n<=a-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+d),this.pos),this.pos+=d,i+=d,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){xr(this),Ua(t,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Tt(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;o.setBigUint64(n-8,BigInt(this.length*8),a),this.process(o,0);const d=Gs(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const h=l/4,m=this.get();if(h>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)d.setUint32(4*u,m[u],a)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||=new this.constructor,t.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:d}=this;return t.destroyed=i,t.finished=a,t.length=n,t.pos=d,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}};const oe=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),ds=BigInt(2**32-1),Ar=BigInt(32);function $a(s,t=!1){return t?{h:Number(s&ds),l:Number(s>>Ar&ds)}:{h:Number(s>>Ar&ds)|0,l:Number(s&ds)|0}}function Va(s,t=!1){const r=s.length;let o=new Uint32Array(r),n=new Uint32Array(r);for(let a=0;a<r;a++){const{h:i,l:d}=$a(s[a],t);[o[a],n[a]]=[i,d]}return[o,n]}const jr=(s,t,r)=>s>>>r,Nr=(s,t,r)=>s<<32-r|t>>>r,ze=(s,t,r)=>s>>>r|t<<32-r,$e=(s,t,r)=>s<<32-r|t>>>r,us=(s,t,r)=>s<<64-r|t>>>r-32,hs=(s,t,r)=>s>>>r-32|t<<64-r;function xe(s,t,r,o){const n=(t>>>0)+(o>>>0);return{h:s+r+(n/2**32|0)|0,l:n|0}}const Ha=(s,t,r)=>(s>>>0)+(t>>>0)+(r>>>0),Ga=(s,t,r,o)=>t+r+o+(s/2**32|0)|0,Qa=(s,t,r,o)=>(s>>>0)+(t>>>0)+(r>>>0)+(o>>>0),Ka=(s,t,r,o,n)=>t+r+o+n+(s/2**32|0)|0,Ya=(s,t,r,o,n)=>(s>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(n>>>0),Za=(s,t,r,o,n,a)=>t+r+o+n+a+(s/2**32|0)|0,Un=Va(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(s=>BigInt(s))),Xa=Un[0],Ja=Un[1],ke=new Uint32Array(80),Se=new Uint32Array(80);class ei extends za{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:r,Bh:o,Bl:n,Ch:a,Cl:i,Dh:d,Dl:l,Eh:h,El:m,Fh:u,Fl:f,Gh:g,Gl:b,Hh:w,Hl:N}=this;return[t,r,o,n,a,i,d,l,h,m,u,f,g,b,w,N]}set(t,r,o,n,a,i,d,l,h,m,u,f,g,b,w,N){this.Ah=t|0,this.Al=r|0,this.Bh=o|0,this.Bl=n|0,this.Ch=a|0,this.Cl=i|0,this.Dh=d|0,this.Dl=l|0,this.Eh=h|0,this.El=m|0,this.Fh=u|0,this.Fl=f|0,this.Gh=g|0,this.Gl=b|0,this.Hh=w|0,this.Hl=N|0}process(t,r){for(let k=0;k<16;k++,r+=4)ke[k]=t.getUint32(r),Se[k]=t.getUint32(r+=4);for(let k=16;k<80;k++){const S=ke[k-15]|0,E=Se[k-15]|0,p=ze(S,E,1)^ze(S,E,8)^jr(S,E,7),y=$e(S,E,1)^$e(S,E,8)^Nr(S,E,7),x=ke[k-2]|0,j=Se[k-2]|0,_=ze(x,j,19)^us(x,j,61)^jr(x,j,6),C=$e(x,j,19)^hs(x,j,61)^Nr(x,j,6),P=Qa(y,C,Se[k-7],Se[k-16]),L=Ka(P,p,_,ke[k-7],ke[k-16]);ke[k]=L|0,Se[k]=P|0}let{Ah:o,Al:n,Bh:a,Bl:i,Ch:d,Cl:l,Dh:h,Dl:m,Eh:u,El:f,Fh:g,Fl:b,Gh:w,Gl:N,Hh:A,Hl:v}=this;for(let k=0;k<80;k++){const S=ze(u,f,14)^ze(u,f,18)^us(u,f,41),E=$e(u,f,14)^$e(u,f,18)^hs(u,f,41),p=u&g^~u&w,y=f&b^~f&N,x=Ya(v,E,y,Ja[k],Se[k]),j=Za(x,A,S,p,Xa[k],ke[k]),_=x|0,C=ze(o,n,28)^us(o,n,34)^us(o,n,39),P=$e(o,n,28)^hs(o,n,34)^hs(o,n,39),L=o&a^o&d^a&d,R=n&i^n&l^i&l;A=w|0,v=N|0,w=g|0,N=b|0,g=u|0,b=f|0,{h:u,l:f}=xe(h|0,m|0,j|0,_|0),h=d|0,m=l|0,d=a|0,l=i|0,a=o|0,i=n|0;const T=Ha(_,P,R);o=Ga(T,j,C,L),n=T|0}({h:o,l:n}=xe(this.Ah|0,this.Al|0,o|0,n|0)),{h:a,l:i}=xe(this.Bh|0,this.Bl|0,a|0,i|0),{h:d,l}=xe(this.Ch|0,this.Cl|0,d|0,l|0),{h,l:m}=xe(this.Dh|0,this.Dl|0,h|0,m|0),{h:u,l:f}=xe(this.Eh|0,this.El|0,u|0,f|0),{h:g,l:b}=xe(this.Fh|0,this.Fl|0,g|0,b|0),{h:w,l:N}=xe(this.Gh|0,this.Gl|0,w|0,N|0),{h:A,l:v}=xe(this.Hh|0,this.Hl|0,A|0,v|0),this.set(o,n,a,i,d,l,h,m,u,f,g,b,w,N,A,v)}roundClean(){Tt(ke,Se)}destroy(){Tt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class si extends ei{Ah=oe[0]|0;Al=oe[1]|0;Bh=oe[2]|0;Bl=oe[3]|0;Ch=oe[4]|0;Cl=oe[5]|0;Dh=oe[6]|0;Dl=oe[7]|0;Eh=oe[8]|0;El=oe[9]|0;Fh=oe[10]|0;Fl=oe[11]|0;Gh=oe[12]|0;Gl=oe[13]|0;Hh=oe[14]|0;Hl=oe[15]|0;constructor(){super(64)}}const ti=Wa(()=>new si,qa(3));const Fn=BigInt(0),kr=BigInt(1);function Mt(s,t=""){if(typeof s!="boolean"){const r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof s)}return s}function ri(s){if(typeof s=="bigint"){if(!js(s))throw new Error("positive bigint expected, got "+s)}else Gt(s);return s}function Wn(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?Fn:BigInt("0x"+s)}function ni(s){return Wn(Qt(s))}function Ss(s){return Wn(Qt(Bt(ne(s)).reverse()))}function On(s,t){Gt(t),s=ri(s);const r=Dn(s.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function oi(s,t){return On(s,t).reverse()}function Bt(s){return Uint8Array.from(s)}const js=s=>typeof s=="bigint"&&Fn<=s;function ai(s,t,r){return js(s)&&js(t)&&js(r)&&t<=s&&s<r}function Sr(s,t,r,o){if(!ai(t,r,o))throw new Error("expected valid "+s+": "+r+" <= n < "+o+", got "+t)}const ii=s=>(kr<<BigInt(s))-kr;function Kt(s,t={},r={}){if(!s||typeof s!="object")throw new Error("expected valid options object");function o(a,i,d){const l=s[a];if(d&&l===void 0)return;const h=typeof l;if(h!==i||l===null)throw new Error(`param "${a}" is invalid: expected ${i}, got ${h}`)}const n=(a,i)=>Object.entries(a).forEach(([d,l])=>o(d,l,i));n(t,!1),n(r,!0)}function Cr(s){const t=new WeakMap;return(r,...o)=>{const n=t.get(r);if(n!==void 0)return n;const a=s(r,...o);return t.set(r,a),a}}const ue=BigInt(0),de=BigInt(1),Ue=BigInt(2),qn=BigInt(3),zn=BigInt(4),$n=BigInt(5),ci=BigInt(7),Vn=BigInt(8),li=BigInt(9),Hn=BigInt(16);function ee(s,t){const r=s%t;return r>=ue?r:t+r}function fe(s,t,r){let o=s;for(;t-- >ue;)o*=o,o%=r;return o}function Er(s,t){if(s===ue)throw new Error("invert: expected non-zero number");if(t<=ue)throw new Error("invert: expected positive modulus, got "+t);let r=ee(s,t),o=t,n=ue,a=de;for(;r!==ue;){const d=o/r,l=o%r,h=n-a*d;o=r,r=l,n=a,a=h}if(o!==de)throw new Error("invert: does not exist");return ee(n,t)}function Yt(s,t,r){if(!s.eql(s.sqr(t),r))throw new Error("Cannot find square root")}function Gn(s,t){const r=(s.ORDER+de)/zn,o=s.pow(t,r);return Yt(s,o,t),o}function di(s,t){const r=(s.ORDER-$n)/Vn,o=s.mul(t,Ue),n=s.pow(o,r),a=s.mul(t,n),i=s.mul(s.mul(a,Ue),n),d=s.mul(a,s.sub(i,s.ONE));return Yt(s,d,t),d}function ui(s){const t=Zt(s),r=Qn(s),o=r(t,t.neg(t.ONE)),n=r(t,o),a=r(t,t.neg(o)),i=(s+ci)/Hn;return(d,l)=>{let h=d.pow(l,i),m=d.mul(h,o);const u=d.mul(h,n),f=d.mul(h,a),g=d.eql(d.sqr(m),l),b=d.eql(d.sqr(u),l);h=d.cmov(h,m,g),m=d.cmov(f,u,b);const w=d.eql(d.sqr(m),l),N=d.cmov(h,m,w);return Yt(d,N,l),N}}function Qn(s){if(s<qn)throw new Error("sqrt is not defined for small field");let t=s-de,r=0;for(;t%Ue===ue;)t/=Ue,r++;let o=Ue;const n=Zt(s);for(;_r(n,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Gn;let a=n.pow(o,t);const i=(t+de)/Ue;return function(l,h){if(l.is0(h))return h;if(_r(l,h)!==1)throw new Error("Cannot find square root");let m=r,u=l.mul(l.ONE,a),f=l.pow(h,t),g=l.pow(h,i);for(;!l.eql(f,l.ONE);){if(l.is0(f))return l.ZERO;let b=1,w=l.sqr(f);for(;!l.eql(w,l.ONE);)if(b++,w=l.sqr(w),b===m)throw new Error("Cannot find square root");const N=de<<BigInt(m-b-1),A=l.pow(u,N);m=b,u=l.sqr(A),f=l.mul(f,u),g=l.mul(g,A)}return g}}function hi(s){return s%zn===qn?Gn:s%Vn===$n?di:s%Hn===li?ui(s):Qn(s)}const mi=(s,t)=>(ee(s,t)&de)===de,pi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function fi(s){const t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=pi.reduce((o,n)=>(o[n]="function",o),t);return Kt(s,r),s}function gi(s,t,r){if(r<ue)throw new Error("invalid exponent, negatives unsupported");if(r===ue)return s.ONE;if(r===de)return t;let o=s.ONE,n=t;for(;r>ue;)r&de&&(o=s.mul(o,n)),n=s.sqr(n),r>>=de;return o}function Kn(s,t,r=!1){const o=new Array(t.length).fill(r?s.ZERO:void 0),n=t.reduce((i,d,l)=>s.is0(d)?i:(o[l]=i,s.mul(i,d)),s.ONE),a=s.inv(n);return t.reduceRight((i,d,l)=>s.is0(d)?i:(o[l]=s.mul(i,o[l]),s.mul(i,d)),a),o}function _r(s,t){const r=(s.ORDER-de)/Ue,o=s.pow(t,r),n=s.eql(o,s.ONE),a=s.eql(o,s.ZERO),i=s.eql(o,s.neg(s.ONE));if(!n&&!a&&!i)throw new Error("invalid Legendre symbol result");return n?1:a?0:-1}function wi(s,t){t!==void 0&&Gt(t);const r=t!==void 0?t:s.toString(2).length,o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}class bi{ORDER;BITS;BYTES;isLE;ZERO=ue;ONE=de;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=ue)throw new Error("invalid field: expected ORDER > 0, got "+t);let o;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(o=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));const{nBitLength:n,nByteLength:a}=wi(t,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=n,this.BYTES=a,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return ee(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return ue<=t&&t<this.ORDER}is0(t){return t===ue}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&de)===de}neg(t){return ee(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return ee(t*t,this.ORDER)}add(t,r){return ee(t+r,this.ORDER)}sub(t,r){return ee(t-r,this.ORDER)}mul(t,r){return ee(t*r,this.ORDER)}pow(t,r){return gi(this,t,r)}div(t,r){return ee(t*Er(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Er(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=hi(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?oi(t,this.BYTES):On(t,this.BYTES)}fromBytes(t,r=!1){ne(t);const{_lengths:o,BYTES:n,isLE:a,ORDER:i,_mod:d}=this;if(o){if(!o.includes(t.length)||t.length>n)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);const h=new Uint8Array(n);h.set(t,a?0:h.length-t.length),t=h}if(t.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=a?Ss(t):ni(t);if(d&&(l=ee(l,i)),!r&&!this.isValid(l))throw new Error("invalid field element: outside of range 0..ORDER");return l}invertBatch(t){return Kn(this,t)}cmov(t,r,o){return o?r:t}}function Zt(s,t={}){return new bi(s,t)}const Cs=BigInt(0),It=BigInt(1);function Lr(s,t){const r=t.negate();return s?r:t}function Qs(s,t){const r=Kn(s.Fp,t.map(o=>o.Z));return t.map((o,n)=>s.fromAffine(o.toAffine(r[n])))}function Yn(s,t){if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+s)}function Ks(s,t){Yn(s,t);const r=Math.ceil(t/s)+1,o=2**(s-1),n=2**s,a=ii(s),i=BigInt(s);return{windows:r,windowSize:o,mask:a,maxNumber:n,shiftBy:i}}function Pr(s,t,r){const{windowSize:o,mask:n,maxNumber:a,shiftBy:i}=r;let d=Number(s&n),l=s>>i;d>o&&(d-=a,l+=It);const h=t*o,m=h+Math.abs(d)-1,u=d===0,f=d<0,g=t%2!==0;return{nextN:l,offset:m,isZero:u,isNeg:f,isNegF:g,offsetF:h}}const Ys=new WeakMap,Zn=new WeakMap;function Zs(s){return Zn.get(s)||1}function Rr(s){if(s!==Cs)throw new Error("invalid wNAF")}class xi{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,o=this.ZERO){let n=t;for(;r>Cs;)r&It&&(o=o.add(n)),n=n.double(),r>>=It;return o}precomputeWindow(t,r){const{windows:o,windowSize:n}=Ks(r,this.bits),a=[];let i=t,d=i;for(let l=0;l<o;l++){d=i,a.push(d);for(let h=1;h<n;h++)d=d.add(i),a.push(d);i=d.double()}return a}wNAF(t,r,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let n=this.ZERO,a=this.BASE;const i=Ks(t,this.bits);for(let d=0;d<i.windows;d++){const{nextN:l,offset:h,isZero:m,isNeg:u,isNegF:f,offsetF:g}=Pr(o,d,i);o=l,m?a=a.add(Lr(f,r[g])):n=n.add(Lr(u,r[h]))}return Rr(o),{p:n,f:a}}wNAFUnsafe(t,r,o,n=this.ZERO){const a=Ks(t,this.bits);for(let i=0;i<a.windows&&o!==Cs;i++){const{nextN:d,offset:l,isZero:h,isNeg:m}=Pr(o,i,a);if(o=d,!h){const u=r[l];n=n.add(m?u.negate():u)}}return Rr(o),n}getPrecomputes(t,r,o){let n=Ys.get(r);return n||(n=this.precomputeWindow(r,t),t!==1&&(typeof o=="function"&&(n=o(n)),Ys.set(r,n))),n}cached(t,r,o){const n=Zs(t);return this.wNAF(n,this.getPrecomputes(n,t,o),r)}unsafe(t,r,o,n){const a=Zs(t);return a===1?this._unsafeLadder(t,r,n):this.wNAFUnsafe(a,this.getPrecomputes(a,t,o),r,n)}createCache(t,r){Yn(r,this.bits),Zn.set(t,r),Ys.delete(t)}hasCache(t){return Zs(t)!==1}}function Tr(s,t,r){if(t){if(t.ORDER!==s)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return fi(t),t}else return Zt(s,{isLE:r})}function yi(s,t,r={},o){if(o===void 0&&(o=s==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${s} CURVE object`);for(const l of["p","n","h"]){const h=t[l];if(!(typeof h=="bigint"&&h>Cs))throw new Error(`CURVE.${l} must be positive bigint`)}const n=Tr(t.p,r.Fp,o),a=Tr(t.n,r.Fn,o),d=["Gx","Gy","a","d"];for(const l of d)if(!n.isValid(t[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:n,Fn:a}}function vi(s,t){return function(o){const n=s(o);return{secretKey:n,publicKey:t(n)}}}const Ce=BigInt(0),te=BigInt(1),Xs=BigInt(2),Ai=BigInt(8);function ji(s,t,r,o){const n=s.sqr(r),a=s.sqr(o),i=s.add(s.mul(t.a,n),a),d=s.add(s.ONE,s.mul(t.d,s.mul(n,a)));return s.eql(i,d)}function Ni(s,t={}){const r=yi("edwards",s,t,t.FpFnLE),{Fp:o,Fn:n}=r;let a=r.CURVE;const{h:i}=a;Kt(t,{},{uvRatio:"function"});const d=Xs<<BigInt(n.BYTES*8)-te,l=N=>o.create(N),h=t.uvRatio||((N,A)=>{try{return{isValid:!0,value:o.sqrt(o.div(N,A))}}catch{return{isValid:!1,value:Ce}}});if(!ji(o,a,a.Gx,a.Gy))throw new Error("bad curve params: generator point");function m(N,A,v=!1){const k=v?te:Ce;return Sr("coordinate "+N,A,k,d),A}function u(N){if(!(N instanceof b))throw new Error("EdwardsPoint expected")}const f=Cr((N,A)=>{const{X:v,Y:k,Z:S}=N,E=N.is0();A==null&&(A=E?Ai:o.inv(S));const p=l(v*A),y=l(k*A),x=o.mul(S,A);if(E)return{x:Ce,y:te};if(x!==te)throw new Error("invZ was invalid");return{x:p,y}}),g=Cr(N=>{const{a:A,d:v}=a;if(N.is0())throw new Error("bad point: ZERO");const{X:k,Y:S,Z:E,T:p}=N,y=l(k*k),x=l(S*S),j=l(E*E),_=l(j*j),C=l(y*A),P=l(j*l(C+x)),L=l(_+l(v*l(y*x)));if(P!==L)throw new Error("bad point: equation left != right (1)");const R=l(k*S),T=l(E*p);if(R!==T)throw new Error("bad point: equation left != right (2)");return!0});class b{static BASE=new b(a.Gx,a.Gy,te,l(a.Gx*a.Gy));static ZERO=new b(Ce,te,te,Ce);static Fp=o;static Fn=n;X;Y;Z;T;constructor(A,v,k,S){this.X=m("x",A),this.Y=m("y",v),this.Z=m("z",k,!0),this.T=m("t",S),Object.freeze(this)}static CURVE(){return a}static fromAffine(A){if(A instanceof b)throw new Error("extended point not allowed");const{x:v,y:k}=A||{};return m("x",v),m("y",k),new b(v,k,te,l(v*k))}static fromBytes(A,v=!1){const k=o.BYTES,{a:S,d:E}=a;A=Bt(ne(A,k,"point")),Mt(v,"zip215");const p=Bt(A),y=A[k-1];p[k-1]=y&-129;const x=Ss(p),j=v?d:o.ORDER;Sr("point.y",x,Ce,j);const _=l(x*x),C=l(_-te),P=l(E*_-S);let{isValid:L,value:R}=h(C,P);if(!L)throw new Error("bad point: invalid y coordinate");const T=(R&te)===te,B=(y&128)!==0;if(!v&&R===Ce&&B)throw new Error("bad point: x=0 and x_0=1");return B!==T&&(R=l(-R)),b.fromAffine({x:R,y:x})}static fromHex(A,v=!1){return b.fromBytes(Dn(A),v)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(A=8,v=!0){return w.createCache(this,A),v||this.multiply(Xs),this}assertValidity(){g(this)}equals(A){u(A);const{X:v,Y:k,Z:S}=this,{X:E,Y:p,Z:y}=A,x=l(v*y),j=l(E*S),_=l(k*y),C=l(p*S);return x===j&&_===C}is0(){return this.equals(b.ZERO)}negate(){return new b(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:A}=a,{X:v,Y:k,Z:S}=this,E=l(v*v),p=l(k*k),y=l(Xs*l(S*S)),x=l(A*E),j=v+k,_=l(l(j*j)-E-p),C=x+p,P=C-y,L=x-p,R=l(_*P),T=l(C*L),B=l(_*L),F=l(P*C);return new b(R,T,F,B)}add(A){u(A);const{a:v,d:k}=a,{X:S,Y:E,Z:p,T:y}=this,{X:x,Y:j,Z:_,T:C}=A,P=l(S*x),L=l(E*j),R=l(y*k*C),T=l(p*_),B=l((S+E)*(x+j)-P-L),F=T-R,W=T+R,q=l(L-v*P),D=l(B*F),$=l(W*q),Q=l(B*q),H=l(F*W);return new b(D,$,H,Q)}subtract(A){return this.add(A.negate())}multiply(A){if(!n.isValidNot0(A))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:v,f:k}=w.cached(this,A,S=>Qs(b,S));return Qs(b,[v,k])[0]}multiplyUnsafe(A,v=b.ZERO){if(!n.isValid(A))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return A===Ce?b.ZERO:this.is0()||A===te?this:w.unsafe(this,A,k=>Qs(b,k),v)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return w.unsafe(this,a.n).is0()}toAffine(A){return f(this,A)}clearCofactor(){return i===te?this:this.multiplyUnsafe(i)}toBytes(){const{x:A,y:v}=this.toAffine(),k=o.toBytes(v);return k[k.length-1]|=A&te?128:0,k}toHex(){return Qt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const w=new xi(b,n.BITS);return b.BASE.precompute(8),b}function ki(s,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');Kt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=r,{BASE:n,Fp:a,Fn:i}=s,d=r.randomBytes||Oa,l=r.adjustScalarBytes||(x=>x),h=r.domain||((x,j,_)=>{if(Mt(_,"phflag"),j.length||_)throw new Error("Contexts/pre-hash are not supported");return x});function m(x){return i.create(Ss(x))}function u(x){const j=k.secretKey;ne(x,k.secretKey,"secretKey");const _=ne(t(x),2*j,"hashedSecretKey"),C=l(_.slice(0,j)),P=_.slice(j,2*j),L=m(C);return{head:C,prefix:P,scalar:L}}function f(x){const{head:j,prefix:_,scalar:C}=u(x),P=n.multiply(C),L=P.toBytes();return{head:j,prefix:_,scalar:C,point:P,pointBytes:L}}function g(x){return f(x).pointBytes}function b(x=Uint8Array.of(),...j){const _=vr(...j);return m(t(h(_,ne(x,void 0,"context"),!!o)))}function w(x,j,_={}){x=ne(x,void 0,"message"),o&&(x=o(x));const{prefix:C,scalar:P,pointBytes:L}=f(j),R=b(_.context,C,x),T=n.multiply(R).toBytes(),B=b(_.context,T,L,x),F=i.create(R+B*P);if(!i.isValid(F))throw new Error("sign failed: invalid s");const W=vr(T,i.toBytes(F));return ne(W,k.signature,"result")}const N={zip215:!0};function A(x,j,_,C=N){const{context:P,zip215:L}=C,R=k.signature;x=ne(x,R,"signature"),j=ne(j,void 0,"message"),_=ne(_,k.publicKey,"publicKey"),L!==void 0&&Mt(L,"zip215"),o&&(j=o(j));const T=R/2,B=x.subarray(0,T),F=Ss(x.subarray(T,R));let W,q,D;try{W=s.fromBytes(_,L),q=s.fromBytes(B,L),D=n.multiplyUnsafe(F)}catch{return!1}if(!L&&W.isSmallOrder())return!1;const $=b(P,q.toBytes(),W.toBytes(),j);return q.add(W.multiplyUnsafe($)).subtract(D).clearCofactor().is0()}const v=a.BYTES,k={secretKey:v,publicKey:v,signature:2*v,seed:v};function S(x=d(k.seed)){return ne(x,k.seed,"seed")}function E(x){return Bn(x)&&x.length===i.BYTES}function p(x,j){try{return!!s.fromBytes(x,j)}catch{return!1}}const y={getExtendedPublicKey:f,randomSecretKey:S,isValidSecretKey:E,isValidPublicKey:p,toMontgomery(x){const{y:j}=s.fromBytes(x),_=k.publicKey,C=_===32;if(!C&&_!==57)throw new Error("only defined for 25519 and 448");const P=C?a.div(te+j,te-j):a.div(j-te,j+te);return a.toBytes(P)},toMontgomerySecret(x){const j=k.secretKey;ne(x,j);const _=t(x.subarray(0,j));return l(_).subarray(0,j)}};return Object.freeze({keygen:vi(S,g),getPublicKey:g,sign:w,verify:A,utils:y,Point:s,lengths:k})}const Si=BigInt(1),Mr=BigInt(2),Ci=BigInt(5),Ei=BigInt(8),Xt=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),_i={p:Xt,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Ei,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Li(s){const t=BigInt(10),r=BigInt(20),o=BigInt(40),n=BigInt(80),a=Xt,d=s*s%a*s%a,l=fe(d,Mr,a)*d%a,h=fe(l,Si,a)*s%a,m=fe(h,Ci,a)*h%a,u=fe(m,t,a)*m%a,f=fe(u,r,a)*u%a,g=fe(f,o,a)*f%a,b=fe(g,n,a)*g%a,w=fe(b,n,a)*g%a,N=fe(w,t,a)*m%a;return{pow_p_5_8:fe(N,Mr,a)*s%a,b2:d}}function Pi(s){return s[0]&=248,s[31]&=127,s[31]|=64,s}const Br=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ri(s,t){const r=Xt,o=ee(t*t*t,r),n=ee(o*o*t,r),a=Li(s*n).pow_p_5_8;let i=ee(s*o*a,r);const d=ee(t*i*i,r),l=i,h=ee(i*Br,r),m=d===s,u=d===ee(-s,r),f=d===ee(-s*Br,r);return m&&(i=l),(u||f)&&(i=h),mi(i,r)&&(i=ee(-i,r)),{isValid:m||u,value:i}}const Ti=Ni(_i,{uvRatio:Ri});function Mi(s){return ki(Ti,ti,Object.assign({adjustScalarBytes:Pi},s))}const Bi=Mi({});function Ii(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Ds(s,...t){if(!Ii(s))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(s.length))throw new Error("Uint8Array expected of length "+t+", got length="+s.length)}function Ir(s,t=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(t&&s.finished)throw new Error("Hash#digest() has already been called")}function Di(s,t){Ds(s);const r=t.outputLen;if(s.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function Dt(...s){for(let t=0;t<s.length;t++)s[t].fill(0)}function Js(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function ge(s,t){return s<<32-t|s>>>t}function Ui(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function Xn(s){return typeof s=="string"&&(s=Ui(s)),Ds(s),s}class Fi{}function Wi(s){const t=o=>s().update(Xn(o)).digest(),r=s();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>s(),t}function Oi(s,t,r,o){if(typeof s.setBigUint64=="function")return s.setBigUint64(t,r,o);const n=BigInt(32),a=BigInt(4294967295),i=Number(r>>n&a),d=Number(r&a),l=o?4:0,h=o?0:4;s.setUint32(t+l,i,o),s.setUint32(t+h,d,o)}function qi(s,t,r){return s&t^~s&r}function zi(s,t,r){return s&t^s&r^t&r}class $i extends Fi{constructor(t,r,o,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=n,this.buffer=new Uint8Array(t),this.view=Js(this.buffer)}update(t){Ir(this),t=Xn(t),Ds(t);const{view:r,buffer:o,blockLen:n}=this,a=t.length;for(let i=0;i<a;){const d=Math.min(n-this.pos,a-i);if(d===n){const l=Js(t);for(;n<=a-i;i+=n)this.process(l,i);continue}o.set(t.subarray(i,i+d),this.pos),this.pos+=d,i+=d,this.pos===n&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ir(this),Di(t,this),this.finished=!0;const{buffer:r,view:o,blockLen:n,isLE:a}=this;let{pos:i}=this;r[i++]=128,Dt(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(o,0),i=0);for(let u=i;u<n;u++)r[u]=0;Oi(o,n-8,BigInt(this.length*8),a),this.process(o,0);const d=Js(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const h=l/4,m=this.get();if(h>m.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<h;u++)d.setUint32(4*u,m[u],a)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const o=t.slice(0,r);return this.destroy(),o}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:o,length:n,finished:a,destroyed:i,pos:d}=this;return t.destroyed=i,t.finished=a,t.length=n,t.pos=d,n%r&&t.buffer.set(o),t}clone(){return this._cloneInto()}}const Ee=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Vi=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),_e=new Uint32Array(64);class Hi extends $i{constructor(t=32){super(64,t,8,!1),this.A=Ee[0]|0,this.B=Ee[1]|0,this.C=Ee[2]|0,this.D=Ee[3]|0,this.E=Ee[4]|0,this.F=Ee[5]|0,this.G=Ee[6]|0,this.H=Ee[7]|0}get(){const{A:t,B:r,C:o,D:n,E:a,F:i,G:d,H:l}=this;return[t,r,o,n,a,i,d,l]}set(t,r,o,n,a,i,d,l){this.A=t|0,this.B=r|0,this.C=o|0,this.D=n|0,this.E=a|0,this.F=i|0,this.G=d|0,this.H=l|0}process(t,r){for(let u=0;u<16;u++,r+=4)_e[u]=t.getUint32(r,!1);for(let u=16;u<64;u++){const f=_e[u-15],g=_e[u-2],b=ge(f,7)^ge(f,18)^f>>>3,w=ge(g,17)^ge(g,19)^g>>>10;_e[u]=w+_e[u-7]+b+_e[u-16]|0}let{A:o,B:n,C:a,D:i,E:d,F:l,G:h,H:m}=this;for(let u=0;u<64;u++){const f=ge(d,6)^ge(d,11)^ge(d,25),g=m+f+qi(d,l,h)+Vi[u]+_e[u]|0,w=(ge(o,2)^ge(o,13)^ge(o,22))+zi(o,n,a)|0;m=h,h=l,l=d,d=i+g|0,i=a,a=n,n=o,o=g+w|0}o=o+this.A|0,n=n+this.B|0,a=a+this.C|0,i=i+this.D|0,d=d+this.E|0,l=l+this.F|0,h=h+this.G|0,m=m+this.H|0,this.set(o,n,a,i,d,l,h,m)}roundClean(){Dt(_e)}destroy(){this.set(0,0,0,0,0,0,0,0),Dt(this.buffer)}}const Jn=Wi(()=>new Hi),Gi=Jn,Qi="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ki(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const t=Gi(s),r=Bi.getPublicKey(t),o=new Uint8Array(64);return o.set(t,0),o.set(r,32),U.wipeBytes(t),{publicKey:r,secretKey:o}}function eo(s){const t=Ki(s),r=t.publicKey;return U.wipeBytes(t.secretKey),r}function so(s){if(s.length!==32)throw new Error(`Invalid public key length: expected 32, got ${s.length}`);return Yi(s)}function Yi(s){let t=0;for(let n=0;n<s.length&&s[n]===0;n++)t++;let r=0n;for(let n=0;n<s.length;n++)r=r*256n+BigInt(s[n]);let o="";for(;r>0n;){const n=Number(r%58n);o=Qi[n]+o,r=r/58n}return"1".repeat(t)+o}const Zi=2,Xi=3;function to(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const t=Ut(s),r=Mn.share(t,Xi,Zi);if(r.length!==3)throw new Error(`Unexpected share count: ${r.length}`);const o=et(r[0]),n=et(r[1]),a=et(r[2]);return{shareA:U.toShamirShare(o),shareB:U.toShamirShare(n),shareC:U.toShamirShare(a)}}function Ji(s,t,r){const o=Dr(s),n=Dr(t);try{const a=Mn.combine([o,n]),i=ro(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 Ut(s){return Array.from(s).map(t=>t.toString(16).padStart(2,"0")).join("")}function ro(s){if(!/^[0-9a-fA-F]*$/.test(s))throw new Error("Invalid hex string: contains non-hex characters");if(s.length%2!==0)throw new Error(`Invalid hex string: length ${s.length} is odd (must be even)`);const t=new Uint8Array(s.length/2);for(let r=0;r<t.length;r++)t[r]=parseInt(s.substr(r*2,2),16);return t}function et(s){const t=s.length%2!==0,r=t?"0"+s:s,o=ro(r),n=new Uint8Array(1+o.length);return n[0]=t?1:0,n.set(o,1),n}function Dr(s){const t=s[0];if(t===0||t===1){const o=t===1,n=s.subarray(1),a=Ut(n),i=o?a.substring(1):a;if(/^[0-9a-f]/.test(i))return i}const r=Ut(s);return r.startsWith("0")&&!r.startsWith("00")?r.substring(1):r}function Es(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function no(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function ec(s){if(typeof s!="function")throw new Error("function expected");return!0}function _s(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function Ze(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function Ls(s){if(!Array.isArray(s))throw new Error("array expected")}function Ps(s,t){if(!no(!0,t))throw new Error(`${s}: array of strings expected`)}function oo(s,t){if(!no(!1,t))throw new Error(`${s}: array of numbers expected`)}function sc(...s){const t=a=>a,r=(a,i)=>d=>a(i(d)),o=s.map(a=>a.encode).reduceRight(r,t),n=s.map(a=>a.decode).reduce(r,t);return{encode:o,decode:n}}function tc(s){const t=typeof s=="string"?s.split(""):s,r=t.length;Ps("alphabet",t);const o=new Map(t.map((n,a)=>[n,a]));return{encode:n=>(Ls(n),n.map(a=>{if(!Number.isSafeInteger(a)||a<0||a>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${s}`);return t[a]})),decode:n=>(Ls(n),n.map(a=>{_s("alphabet.decode",a);const i=o.get(a);if(i===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${s}`);return i}))}}function rc(s=""){return _s("join",s),{encode:t=>(Ps("join.decode",t),t.join(s)),decode:t=>(_s("join.decode",t),t.split(s))}}function nc(s,t="="){return Ze(s),_s("padding",t),{encode(r){for(Ps("padding.encode",r);r.length*s%8;)r.push(t);return r},decode(r){Ps("padding.decode",r);let o=r.length;if(o*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&r[o-1]===t;o--)if((o-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return r.slice(0,o)}}}function Ft(s,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Ls(s),!s.length)return[];let o=0;const n=[],a=Array.from(s,d=>{if(Ze(d),d<0||d>=t)throw new Error(`invalid integer: ${d}`);return d}),i=a.length;for(;;){let d=0,l=!0;for(let h=o;h<i;h++){const m=a[h],u=t*d,f=u+m;if(!Number.isSafeInteger(f)||u/t!==d||f-m!==u)throw new Error("convertRadix: carry overflow");const g=f/r;d=f%r;const b=Math.floor(g);if(a[h]=b,!Number.isSafeInteger(b)||b*r+d!==f)throw new Error("convertRadix: carry overflow");if(l)b?l=!1:o=h;else continue}if(n.push(d),l)break}for(let d=0;d<s.length-1&&s[d]===0;d++)n.push(0);return n.reverse()}const ao=(s,t)=>t===0?s:ao(t,s%t),Rs=(s,t)=>s+(t-ao(s,t)),st=(()=>{let s=[];for(let t=0;t<40;t++)s.push(2**t);return s})();function Wt(s,t,r,o){if(Ls(s),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(r<=0||r>32)throw new Error(`convertRadix2: wrong to=${r}`);if(Rs(t,r)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${r} carryBits=${Rs(t,r)}`);let n=0,a=0;const i=st[t],d=st[r]-1,l=[];for(const h of s){if(Ze(h),h>=i)throw new Error(`convertRadix2: invalid data word=${h} from=${t}`);if(n=n<<t|h,a+t>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${t}`);for(a+=t;a>=r;a-=r)l.push((n>>a-r&d)>>>0);const m=st[a];if(m===void 0)throw new Error("invalid carry");n&=m-1}if(n=n<<r-a&d,!o&&a>=t)throw new Error("Excess padding");if(!o&&n>0)throw new Error(`Non-zero padding: ${n}`);return o&&a>0&&l.push(n>>>0),l}function oc(s){Ze(s);const t=2**8;return{encode:r=>{if(!Es(r))throw new Error("radix.encode input should be Uint8Array");return Ft(Array.from(r),t,s)},decode:r=>(oo("radix.decode",r),Uint8Array.from(Ft(r,s,t)))}}function ac(s,t=!1){if(Ze(s),s<=0||s>32)throw new Error("radix2: bits should be in (0..32]");if(Rs(8,s)>32||Rs(s,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!Es(r))throw new Error("radix2.encode input should be Uint8Array");return Wt(Array.from(r),8,s,!t)},decode:r=>(oo("radix2.decode",r),Uint8Array.from(Wt(r,s,8,t)))}}function ic(s,t){return Ze(s),ec(t),{encode(r){if(!Es(r))throw new Error("checksum.encode: input should be Uint8Array");const o=t(r).slice(0,s),n=new Uint8Array(r.length+s);return n.set(r),n.set(o,r.length),n},decode(r){if(!Es(r))throw new Error("checksum.decode: input should be Uint8Array");const o=r.slice(0,-s),n=r.slice(-s),a=t(o).slice(0,s);for(let i=0;i<s;i++)if(a[i]!==n[i])throw new Error("Invalid checksum");return o}}}const ms={alphabet:tc,chain:sc,checksum:ic,convertRadix:Ft,convertRadix2:Wt,radix:oc,radix2:ac,join:rc,padding:nc};const cc=s=>s[0]==="あいこくしん";function lc(s){if(typeof s!="string")throw new TypeError("invalid mnemonic type: "+typeof s);return s.normalize("NFKD")}function dc(s){const t=lc(s),r=t.split(" ");if(![12,15,18,21,24].includes(r.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:r}}function io(s){Ds(s,16,20,24,28,32)}const uc=s=>{const t=8-s.length/4;return new Uint8Array([Jn(s)[0]>>t<<t])};function co(s){if(!Array.isArray(s)||s.length!==2048||typeof s[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return s.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),ms.chain(ms.checksum(1,uc),ms.radix2(11,!0),ms.alphabet(s))}function Jt(s,t){const{words:r}=dc(s),o=co(t).decode(r);return io(o),o}function lo(s,t){return io(s),co(t).encode(s).join(cc(t)?" ":" ")}function er(s,t){try{Jt(s,t)}catch{return!1}return!0}const ve=`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
|
-
`),me=12;function hc(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const r=mo(s,Se).split(" ");if(r.length!==me)throw new Error(`Unexpected word count: expected ${me}, got ${r.length}`);return r}function mc(s){if(s.length!==me)throw new Error(`Invalid word count: expected ${me}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!rr(t,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=tr(t,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return D.toShamirShare(r)}function pc(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const r=mo(s,Se).split(" ");if(r.length!==me)throw new Error(`Unexpected word count: expected ${me}, got ${r.length}`);return r}function fc(s){if(s.length!==me)throw new Error(`Invalid word count: expected ${me}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!rr(t,Se))throw new Error("Invalid recovery phrase: checksum mismatch");const r=tr(t,Se);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return D.toSeed(r)}function po(s){if(s.length!==me)return!1;const t=s.join(" ").toLowerCase().trim();return rr(t,Se)}function bs(s){return Se.includes(s.toLowerCase().trim())}function gc(s,t=5){const r=s.toLowerCase().trim();return r.length===0?[]:Se.filter(o=>o.startsWith(r)).slice(0,t)}function wc(s){const t=[];for(let r=0;r<s.length;r+=4)t.push(s.slice(r,r+4));return t}function bc(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function xc({className:s="",variant:t="default",size:r="md",children:o,menuItems:n=[],hideSignOut:a=!1}){const{user:i,isAuthenticated:d,isLoading:l,openLoginModal:h,logout:m}=D.useAuth(),[u,f]=c.useState(!1),[w,b]=c.useState(-1),g=c.useRef(null),N=c.useRef(null),A=c.useMemo(()=>[...n,...a?[]:[{label:"Sign out",onClick:m}]],[n,a,m]);c.useEffect(()=>{if(!u)return;const p=x=>{g.current&&!g.current.contains(x.target)&&(f(!1),b(-1))},y=x=>{x.key==="Escape"&&(f(!1),b(-1),N.current?.focus())};return document.addEventListener("mousedown",p),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",y)}},[u]);const v=c.useCallback(p=>{if(!(!u||A.length===0))switch(p.key){case"ArrowDown":p.preventDefault(),b(y=>(y+1)%A.length);break;case"ArrowUp":p.preventDefault(),b(y=>(y-1+A.length)%A.length);break;case"Home":p.preventDefault(),b(0);break;case"End":p.preventDefault(),b(A.length-1);break;case"Enter":case" ":w>=0&&(p.preventDefault(),A[w].onClick(),f(!1),b(-1));break}},[u,w,A]),k=c.useCallback(()=>{A.length!==0&&(f(p=>!p),b(-1))},[A.length]),S={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},E={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(l)return e.jsx("button",{type:"button",className:`cedros-button ${E[t]} ${S[r]} ${s}`,disabled:!0,children:e.jsx(Q.LoadingSpinner,{size:"sm"})});if(d&&i){const p=i.name||i.email||"User",y=es.sanitizeImageUrl(i.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:g,onKeyDown:v,children:[e.jsxs("button",{ref:N,type:"button",className:`cedros-button cedros-user-button ${S[r]} ${s}`,"aria-haspopup":"menu","aria-expanded":u,"aria-label":`User menu for ${p}`,onClick:k,children:[y?e.jsx("img",{src:y,alt:p,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(p[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:p})]}),u&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[n.map((x,j)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${w===j?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===j?0:-1,onClick:()=>{x.onClick(),f(!1)},children:[x.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:x.icon}),x.label]},j)),n.length>0&&!a&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!a&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${w===n.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===n.length?0:-1,onClick:()=>{m(),f(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${E[t]} ${S[r]} ${s}`,onClick:h,children:o||"Sign in"})}function Ws(){const{config:s}=M.useCedrosLogin(),[t,r]=c.useState(!1),[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:l,getRemainingAttempts:h}=J.useRateLimiter({maxAttempts:3,windowMs:3e5}),m=c.useCallback(async b=>{if(!We.validateEmail(b)){const g={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw i(g),g}try{l()}catch(g){const N={code:"RATE_LIMITED",message:g instanceof Error?g.message:"Too many attempts"};throw i(N),N}r(!0),i(null),n(!1);try{await d.post("/forgot-password",{email:b}),n(!0)}catch(g){const N=M.handleApiError(g,"Unable to send the reset email. Please try again.");throw i(N),N}finally{r(!1)}},[d,l]),u=c.useCallback(async(b,g)=>{r(!0),i(null),n(!1);try{await d.post("/reset-password",{token:b,newPassword:g}),n(!0)}catch(N){const A=M.handleApiError(N,"Unable to reset your password. Please try again.");throw i(A),A}finally{r(!1)}},[d]),f=c.useCallback(()=>i(null),[]),w=c.useCallback(()=>{i(null),n(!1),r(!1)},[]);return{forgotPassword:m,resetPassword:u,isLoading:t,isSuccess:o,error:a,clearError:f,reset:w,remainingAttempts:h()}}function yc(s){return typeof s=="object"&&s!==null&&"mfaRequired"in s&&s.mfaRequired===!0}function fo(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(!1),[i,d]=c.useState(null),l=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:h,getRemainingAttempts:m}=J.useRateLimiter({maxAttempts:3,windowMs:3e5}),u=c.useCallback(async g=>{if(!We.validateEmail(g)){const N={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw d(N),N}try{h()}catch(N){const A={code:"RATE_LIMITED",message:N instanceof Error?N.message:"Too many attempts"};throw d(A),A}o(!0),d(null),a(!1);try{await l.post("/instant-link",{email:g,referral:t?.getReferralCode?.()??void 0}),a(!0)}catch(N){const A=M.handleApiError(N,"Unable to send the sign-in link. Please try again.");throw d(A),A}finally{o(!1)}},[l,h]),f=c.useCallback(async g=>{if(!g||g.trim().length===0){const N={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw d(N),N}o(!0),d(null),a(!1);try{const N=await l.post("/instant-link/verify",{token:g});return yc(N)||(s.callbacks?.onLoginSuccess?.(N.user,"email"),t?.handleLoginSuccess(N.user,N.tokens)),N}catch(N){const A=M.handleApiError(N,"Unable to verify the sign-in link. Please try again.");throw d(A),A}finally{o(!1)}},[l,s.callbacks,t]),w=c.useCallback(()=>d(null),[]),b=c.useCallback(()=>{d(null),a(!1),o(!1)},[]);return{sendInstantLink:u,verifyInstantLink:f,isLoading:r,isSuccess:n,error:i,clearError:w,reset:b,remainingAttempts:m()}}const vc={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:s=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:s}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:s=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:s}),". Click the link to sign in."]})}};function go({mode:s="reset",onSuccess:t,onCancel:r,className:o=""}){const[n,a]=c.useState(""),i=Ws(),d=fo(),l=c.useId(),h=s==="instantLink"?{submit:d.sendInstantLink,isLoading:d.isLoading,isSuccess:d.isSuccess,error:d.error,clearError:d.clearError}:{submit:i.forgotPassword,isLoading:i.isLoading,isSuccess:i.isSuccess,error:i.error,clearError:i.clearError},m=vc[s],u=async f=>{f.preventDefault();try{await h.submit(n),t?.()}catch{}};return h.isSuccess?e.jsxs("div",{className:`cedros-forgot-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Check your email"}),e.jsx("p",{className:"cedros-success-message",children:m.successMessage(n)}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:r,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:u,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Forgot password?"}),e.jsx("p",{className:"cedros-form-subtitle",children:m.subtitle})]}),e.jsx(te.ErrorMessage,{error:h.error,onDismiss:h.clearError}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:l,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:l,type:"email",className:"cedros-input",value:n,onChange:f=>a(f.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:h.isLoading})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:h.isLoading||!n,children:h.isLoading?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),"Sending..."]}):m.button}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:h.isLoading,children:"Back to login"})]})]})}const Ac={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t})}):(this.loading=!0,new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t});const r=document.getElementById("apple-signin-script");if(r){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]):r.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]});return}const o=document.createElement("script");o.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",o.async=!0,o.defer=!0,o.id="apple-signin-script",o.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]},o.onerror=()=>{this.loading=!1,o.remove();const n=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(a=>a.reject(n)),this.callbacks=[]},document.head.appendChild(o)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function wo(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(!1),[i,d]=c.useState(null),[l,h]=c.useState(null),m=c.useRef(s),u=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);c.useEffect(()=>{m.current=s},[s]),c.useEffect(()=>{if(!s.appleClientId)return;let g=!0;const N=()=>{if(g)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),g&&a(!0)}catch{g&&d({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return Ac.load().then(()=>{g&&N()}).catch(()=>{g&&d({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{g=!1}},[s.appleClientId]);const f=c.useCallback(async g=>{if(!s.appleClientId){const A={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw d(A),A}if(!n){const A={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw d(A),A}o(!0),d(null);let N;try{const A=crypto.getRandomValues(new Uint8Array(32)),v=Array.from(A,x=>x.toString(16).padStart(2,"0")).join(""),k=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(v)),S=Array.from(new Uint8Array(k),x=>x.toString(16).padStart(2,"0")).join("");window.AppleID.auth.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0,nonce:S});const E=await window.AppleID.auth.signIn();if(N=E.authorization?.id_token,!N)throw new Error("No ID token received from Apple");const p=E.user?.name?`${E.user.name.firstName||""} ${E.user.name.lastName||""}`.trim():void 0,y=await u.post("/apple",{idToken:N,name:p||void 0,nonce:v,referral:t?.getReferralCode?.()??void 0,access_code:g||void 0});return m.current.callbacks?.onLoginSuccess?.(y.user,"apple"),t?.handleLoginSuccess(y.user,y.tokens),o(!1),y}catch(A){if(A.error==="popup_closed_by_user"){const S={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw d(S),o(!1),S}const k=M.handleApiError(A,"Unable to sign in with Apple. Please try again.");throw k.code==="ACCOUNT_LINK_REQUIRED"&&N&&h(N),d(k),o(!1),k}},[s.appleClientId,n,u,t]),w=c.useCallback(()=>d(null),[]),b=c.useCallback(()=>h(null),[]);return{signIn:f,isLoading:r,isInitialized:n,error:i,clearError:w,pendingLinkIdToken:l,clearPendingLink:b}}function bo(){if(typeof window>"u"||typeof navigator>"u")return!1;const s=navigator.userAgent.toLowerCase(),t=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(s)||t.includes("mac")||/macintosh/.test(s)||t==="macintel"&&navigator.maxTouchPoints>1)}function xo({onSuccess:s,onError:t,className:r="",variant:o="default",size:n="md",disabled:a=!1,hideOnNonApple:i=!0,accessCode:d}){const{signIn:l,isLoading:h,isInitialized:m}=wo(),[u]=c.useState(()=>bo());if(i&&!u)return null;const f=async()=>{try{await l(d),s?.()}catch(g){const N=g instanceof Error?g:new Error(String(g));t?.(N)}},w={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},b={default:"cedros-button-social",outline:"cedros-button-social-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${b[o]} ${w[n]} ${r}`,onClick:f,disabled:a||!m||h,"aria-label":"Sign in with Apple",children:[h?e.jsx(Q.LoadingSpinner,{size:"sm"}):e.jsx("svg",{className:"cedros-button-icon",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),e.jsx("span",{children:"Continue with Apple"})]})}function le(s,t){if(!s)throw new Error(t)}function jc(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function Us(s){le(typeof s=="string"&&s.length>0,"Expected base64url string");const t=jc(s),r=t+"=".repeat((4-t.length%4)%4),o=atob(r),n=new Uint8Array(o.length);for(let a=0;a<o.length;a++)n[a]=o.charCodeAt(a);return n.buffer}function Ke(s){const t=new Uint8Array(s);let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function yo(s){le(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return le(typeof t.type=="string","Invalid credential descriptor type"),le(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:Us(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function ot(s){le(s&&typeof s=="object","Missing creation options");const t=s.publicKey;le(t&&typeof t=="object","Missing creation options.publicKey"),le(typeof t.challenge=="string","Missing creation challenge"),le(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),le(typeof t.user=="object"&&t.user!==null,"Missing user");const r=t.rp,o=t.user;le(typeof r.name=="string","Missing rp.name"),le(typeof o.id=="string","Missing user.id"),le(typeof o.name=="string","Missing user.name"),le(typeof o.displayName=="string","Missing user.displayName");const n=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(yo):void 0,a=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(d=>({type:d.type,alg:d.alg})):[],i={challenge:Us(t.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:Us(o.id),name:o.name,displayName:o.displayName},pubKeyCredParams:a,timeout:typeof t.timeout=="number"?t.timeout:void 0,attestation:typeof t.attestation=="string"?t.attestation:void 0,authenticatorSelection:typeof t.authenticatorSelection=="object"&&t.authenticatorSelection!==null?t.authenticatorSelection:void 0,excludeCredentials:n,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return i.hints=["client-device"],i}function Wr(s){le(s&&typeof s=="object","Missing request options");const t=s.publicKey;le(t&&typeof t=="object","Missing request options.publicKey"),le(typeof t.challenge=="string","Missing request challenge");const r=Array.isArray(t.allowCredentials)?t.allowCredentials.map(yo):void 0,o={challenge:Us(t.challenge),rpId:typeof t.rpId=="string"?t.rpId:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,userVerification:typeof t.userVerification=="string"?t.userVerification:void 0,allowCredentials:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return o.hints=["client-device"],o}function as(s){const t=Ke(s.rawId),r=s.response,n={...{clientDataJSON:Ke(r.clientDataJSON)}};if("attestationObject"in r){const a=r;if(n.attestationObject=Ke(a.attestationObject),typeof a.getTransports=="function")try{n.transports=a.getTransports()}catch{}}if("authenticatorData"in r){const a=r;n.authenticatorData=Ke(a.authenticatorData),n.signature=Ke(a.signature),a.userHandle&&(n.userHandle=Ke(a.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:n}}function Nc(){if(typeof window<"u"){const s=window.location?.hostname,t=s==="localhost"||s==="127.0.0.1"||s?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!t)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function kc(s){return typeof s=="object"&&s!==null&&"code"in s&&"message"in s&&typeof s.code=="string"&&typeof s.message=="string"}function is(s){if(!(s instanceof Error))return null;const t=s.name;return t==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:t==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:t==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function nr(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),d=c.useCallback(()=>a(null),[]),l=Nc(),h=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/auth/options",{email:N?.email}),v=Wr(A.options),k=await navigator.credentials.get({publicKey:v});if(!k)throw new Error("Passkey authentication returned no credential");const S=await i.post("/webauthn/auth/verify",{challengeId:A.challengeId,credential:as(k)});return s.callbacks?.onLoginSuccess?.(S.user,"webauthn"),t?.handleLoginSuccess(S.user,S.tokens),S}catch(A){const k=is(A)??M.handleApiError(A,"Unable to sign in with passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,s.callbacks,t,l]),m=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/register/options",{}),v=ot(A.options),k=await navigator.credentials.create({publicKey:v});if(!k)throw new Error("Passkey registration returned no credential");const S=await i.post("/webauthn/register/verify",{challengeId:A.challengeId,credential:as(k),label:N?.label});if(!S.success)throw new Error("Passkey registration failed");return{credentialId:S.credentialId,label:S.label}}catch(A){const k=is(A)??M.handleApiError(A,"Unable to register passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,l]),u=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/signup/options",{}),v=ot(A.options),k=await navigator.credentials.create({publicKey:v});if(!k)throw new Error("Passkey signup returned no credential");const S=await i.post("/webauthn/signup/verify",{challengeId:A.challengeId,credential:as(k),email:N?.email,name:N?.name,label:N?.label,referral:t?.getReferralCode?.()??void 0,access_code:N?.accessCode||void 0});return s.callbacks?.onLoginSuccess?.(S.user,"webauthn"),t?.handleLoginSuccess(S.user,S.tokens),S}catch(A){const k=is(A)??M.handleApiError(A,"Unable to sign up with passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,s.callbacks,t,l]),f=c.useCallback(async N=>{if(!l){const k={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(k),k}o(!0),a(null);const A=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",v=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return A?w(v,N):b(v,N)},[i,s.callbacks,t,l]),w=c.useCallback(async(N,A)=>{try{const v=await i.post("/webauthn/auth/options",{}),k=Wr(v.options),S=await navigator.credentials.get({publicKey:k});if(!S)throw new Error("Passkey authentication returned no credential");const E=await i.post("/webauthn/auth/verify",{challengeId:v.challengeId,credential:as(S)});return s.callbacks?.onLoginSuccess?.(E.user,"webauthn"),t?.handleLoginSuccess(E.user,E.tokens),N(),E}catch(v){if(v instanceof Error&&(v.name==="NotAllowedError"||v.name==="InvalidStateError"))return g(N,A);if(typeof v=="object"&&v!==null&&"isApiError"in v&&v.data?.code==="INVALID_CREDENTIALS"){const y={code:"INVALID_CREDENTIALS",message:"This passkey is not recognized. Please remove old passkeys for this site and try again, or sign in another way."};throw a(y),y}const p=is(v)??M.handleApiError(v,"Unable to sign in with passkey. Please try again.");throw a(p),p}finally{o(!1)}},[i,s.callbacks,t]),b=c.useCallback(async(N,A)=>{try{return await g(N,A)}catch(v){if(v instanceof Error&&(v.name==="InvalidStateError"||v.name==="NotAllowedError"))return w(N,A);if(!kc(v)){const E=is(v)??M.handleApiError(v,"Unable to create passkey. Please try again.");throw a(E),E}throw v}finally{o(!1)}},[i,s.callbacks,t]),g=c.useCallback(async(N,A)=>{const v=await i.post("/webauthn/signup/options",{}),k=ot(v.options),S=await navigator.credentials.create({publicKey:k});if(!S)throw new Error("Passkey signup returned no credential");const E=await i.post("/webauthn/signup/verify",{challengeId:v.challengeId,credential:as(S),referral:t?.getReferralCode?.()??void 0,access_code:A||void 0});return s.callbacks?.onLoginSuccess?.(E.user,"webauthn"),t?.handleLoginSuccess(E.user,E.tokens),N(),E},[i,s.callbacks,t]);return{isSupported:l,isLoading:r,error:n,clearError:d,continueWithPasskey:f,authenticatePasskey:h,registerPasskey:m,signupWithPasskey:u}}function vo({onSuccess:s,onError:t,className:r="",children:o,disabled:n,accessCode:a}){const{continueWithPasskey:i,isLoading:d,isSupported:l}=nr(),h=n||!l||d;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${r}`,onClick:async()=>{try{await i(a),s?.()}catch(u){t?.(u instanceof Error?u:new Error(String(u)))}},disabled:h,"aria-disabled":h,children:[d?e.jsx(Q.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(Sc,{})}),e.jsx("span",{children:o??"Continue with Passkey"})]})}function Sc(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}const cs=["login","register"];function qs({onSuccess:s,className:t="",defaultTab:r="login"}){const{config:o,socialButtonOrder:n}=M.useCedrosLogin(),{features:a}=es.useServerFeatures(),[i,d]=c.useState(r),[l,h]=c.useState("form"),[m,u]=c.useState(()=>Ze.detectSolanaWallets()),[f]=c.useState(()=>bo()),[w,b]=c.useState(""),[g,N]=c.useState(null),A=a?.signupAccessCodeRequired??!1,v=c.useCallback(P=>{N(P.message)},[]);c.useEffect(()=>{const P=()=>u(Ze.detectSolanaWallets());return P(),window.addEventListener("load",P),window.addEventListener("focus",P),()=>{window.removeEventListener("load",P),window.removeEventListener("focus",P)}},[]);const k=o.forms?.forgotPassword?.mode??(o.features?.instantLink?"instantLink":"reset"),S=c.useCallback(P=>{const _=cs.indexOf(i);let R=_;switch(P.key){case"ArrowLeft":case"ArrowUp":R=_===0?cs.length-1:_-1;break;case"ArrowRight":case"ArrowDown":R=_===cs.length-1?0:_+1;break;case"Home":R=0;break;case"End":R=cs.length-1;break;default:return}P.preventDefault();const T=cs[R];d(T),document.getElementById(`cedros-tab-${T}`)?.focus()},[i]),E=o.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},p=E.email!==!1,y=E.google!==!1&&o.googleClientId,x=E.apple!==!1&&o.appleClientId&&f,j=E.solana!==!1&&m,L=E.webauthn!==!1,C=p&&(y||x||j||L);return l==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx(go,{mode:k,onCancel:()=>h("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[A&&e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:"login-form-access-code",className:"cedros-label",children:"Access Code"}),e.jsx("input",{id:"login-form-access-code",type:"text",className:"cedros-input",value:w,onChange:P=>b(P.target.value),placeholder:"Enter access code","aria-required":"true",autoComplete:"off"})]}),g&&e.jsx(te.ErrorMessage,{error:g,onDismiss:()=>N(null)}),(L||y||x||j)&&(()=>{const P={webauthn:L?e.jsx(vo,{onSuccess:s,onError:v,accessCode:w||void 0}):null,google:y?e.jsx(Ht.GoogleLoginButton,{onSuccess:s,onError:v,accessCode:w||void 0}):null,apple:x?e.jsx(xo,{onSuccess:s,onError:v,accessCode:w||void 0}):null,solana:j?e.jsx(Ze.SolanaLoginButton,{onSuccess:s,onError:v,accessCode:w||void 0}):null},_=n??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:_.map(R=>{const T=P[R];return T?e.jsx(c.Fragment,{children:T},R):null})})})(),C&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-tabs",role:"tablist","aria-label":"Authentication method",children:[e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-login",className:`cedros-tab ${i==="login"?"cedros-tab-active":""}`,onClick:()=>d("login"),onKeyDown:S,"aria-selected":i==="login","aria-controls":"cedros-tabpanel-login",tabIndex:i==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${i==="register"?"cedros-tab-active":""}`,onClick:()=>d("register"),onKeyDown:S,"aria-selected":i==="register","aria-controls":"cedros-tabpanel-register",tabIndex:i==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${i}`,"aria-labelledby":`cedros-tab-${i}`,children:i==="login"?e.jsx(J.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>d("register"),onForgotPassword:()=>h("forgotPassword")}):e.jsx(J.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>d("login"),accessCode:A?w:void 0})})]})]})}class Ao extends c.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){this.setState({errorInfo:r}),console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",r.componentStack),this.props.onError?.(t,r)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:r,errorInfo:o}=this.state,{children:n,fallback:a,showDetails:i=!1}=this.props;return t?a||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),i&&r&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[r.toString(),o?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):n}}function Cc({className:s="",title:t="Sign in to your account"}){const{isModalOpen:r,closeModal:o}=M.useCedrosLogin(),n=c.useRef(null),a=c.useRef(null),i=c.useRef(o);if(c.useEffect(()=>{i.current=o},[o]),c.useEffect(()=>{if(!r)return;a.current=document.activeElement,n.current?.focus();const l=m=>{if(m.key==="Escape"&&i.current(),m.key==="Tab"&&n.current){const u=n.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),f=u[0],w=u[u.length-1];m.shiftKey&&document.activeElement===f?(m.preventDefault(),w?.focus()):!m.shiftKey&&document.activeElement===w&&(m.preventDefault(),f?.focus())}};document.addEventListener("keydown",l);const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",l),document.body.style.overflow=h,a.current instanceof HTMLElement&&a.current.focus()}},[r]),!r)return null;const d=l=>{l.target===l.currentTarget&&o()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,onClick:d,role:"presentation",children:e.jsxs("div",{ref:n,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:t}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:o,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(Ao,{children:e.jsx(qs,{onSuccess:o})})})]})})}function Ec({token:s,onSuccess:t,onLoginClick:r,className:o=""}){const[n,a]=c.useState(""),[i,d]=c.useState(""),[l,h]=c.useState(null),{resetPassword:m,isLoading:u,isSuccess:f,error:w,clearError:b}=Ws(),g=n===i,N=l?.isValid&&g&&n.length>0,A=async v=>{if(v.preventDefault(),!!N)try{await m(s,n),t?.()}catch{}};return f?e.jsxs("div",{className:`cedros-reset-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:r,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${o}`,onSubmit:A,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Reset your password"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your new password below."})]}),e.jsx(te.ErrorMessage,{error:w,onDismiss:b}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(J.PasswordInput,{label:"New password",value:n,onChange:v=>{a(v.target.value),h(We.validatePassword(v.target.value))},showStrengthMeter:!0,onValidationChange:h,disabled:u,autoComplete:"new-password",error:l&&!l.isValid?Object.values(l.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(J.PasswordInput,{label:"Confirm password",value:i,onChange:v=>d(v.target.value),disabled:u,autoComplete:"new-password",error:i&&!g?"Passwords do not match":void 0})}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:u||!N,children:u?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:u,children:"Back to login"})]})]})}function $t({org:s,size:t="lg",className:r=""}){const o=es.sanitizeImageUrl(s.logoUrl),n=t==="lg"?"cedros-org-avatar-lg":"",a=["cedros-org-avatar",n,r].filter(Boolean).join(" "),i=["cedros-org-avatar-placeholder",n,r].filter(Boolean).join(" ");return o?e.jsx("img",{src:o,alt:s.name,className:a,referrerPolicy:"no-referrer"}):e.jsx("div",{className:i,children:s.name[0]?.toUpperCase()||"?"})}function _c({orgs:s,activeOrg:t,isLoading:r=!1,onSelect:o,onCreateClick:n,className:a="",placeholder:i="Select organization"}){const[d,l]=c.useState(!1),h=c.useRef(null);c.useEffect(()=>{const w=b=>{h.current&&!h.current.contains(b.target)&&l(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),c.useEffect(()=>{const w=b=>{b.key==="Escape"&&l(!1)};if(d)return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[d]);const m=c.useCallback(w=>{o(w),l(!1)},[o]),u=c.useCallback(()=>{l(!1),n?.()},[n]),f=c.useCallback(()=>{l(w=>!w)},[]);return r?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${a}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:h,className:`cedros-org-selector ${a}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:f,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs(e.Fragment,{children:[e.jsx($t,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(qr,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:i}),e.jsx(Lc,{isOpen:d})]}),d&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[s.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:s.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${w.id===t?.id?"cedros-org-selector-item-active":""}`,onClick:()=>m(w.id),role:"option","aria-selected":w.id===t?.id,children:[e.jsx($t,{org:w,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:w.name}),e.jsx(qr,{role:w.membership.role}),w.id===t?.id&&e.jsx(Pc,{})]})},w.id))}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:u,children:[e.jsx(Rc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function qr({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function Lc({isOpen:s}){return e.jsx("svg",{className:`cedros-org-chevron ${s?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Pc(){return e.jsx("svg",{className:"cedros-org-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Rc(){return e.jsx("svg",{className:"cedros-org-plus",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 3V13M3 8H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Tc(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Mc(){return e.jsx("svg",{className:"cedros-org-check",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 10L8 14L16 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ic(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M10 4V16M4 10H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Bc({orgs:s,activeOrg:t,isLoading:r,onSelect:o,onCreateClick:n}){return r?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[s.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:s.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${a.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>o(a.id),children:[e.jsx($t,{org:a}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:a.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",a.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${a.membership.role}`,children:a.membership.role}),a.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),a.id===t?.id&&e.jsx(Mc,{})]})},a.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(Ic,{}),e.jsx("span",{children:"Create new organization"})]})]})}function Uc({isLoading:s,onSubmit:t,onCancel:r}){const[o,n]=c.useState(""),[a,i]=c.useState(""),[d,l]=c.useState(null),h=c.useCallback(u=>{n(u);const f=u.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);i(f)},[]),m=c.useCallback(async u=>{if(u.preventDefault(),l(null),!o.trim()){l("Organization name is required");return}if(!a.trim()){l("Organization slug is required");return}try{await t({name:o.trim(),slug:a.trim()})}catch(f){l(f.message||"Failed to create organization")}},[o,a,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:m,children:[d&&e.jsx(te.ErrorMessage,{error:d}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:o,onChange:u=>h(u.target.value),placeholder:"My Organization",maxLength:255,disabled:s,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:a,onChange:u=>i(u.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:s})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:r,disabled:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!o.trim()||!a.trim(),children:s?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function Dc({isOpen:s,onClose:t,orgs:r,activeOrg:o,isLoading:n=!1,error:a,onSelect:i,onCreate:d,className:l=""}){return s?e.jsx(Fc,{onClose:t,orgs:r,activeOrg:o,isLoading:n,error:a,onSelect:i,onCreate:d,className:l}):null}function Fc({onClose:s,orgs:t,activeOrg:r,isLoading:o=!1,error:n,onSelect:a,onCreate:i,className:d}){const[l,h]=c.useState("list"),m=c.useRef(null),u=c.useRef(null);c.useEffect(()=>(u.current=document.activeElement,m.current?.querySelector(".cedros-modal-close")?.focus(),()=>{u.current?.focus()}),[]),c.useEffect(()=>{const g=N=>{if(N.key==="Escape"){s();return}if(N.key==="Tab"&&m.current){const A=m.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),v=A[0],k=A[A.length-1];N.shiftKey?document.activeElement===v&&(N.preventDefault(),k?.focus()):document.activeElement===k&&(N.preventDefault(),v?.focus())}};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s]);const f=c.useCallback(g=>{g.target===g.currentTarget&&s()},[s]),w=c.useCallback(g=>{a(g),s()},[a,s]),b=c.useCallback(async g=>{await i?.(g),s()},[i,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:f,children:e.jsxs("div",{ref:m,className:`cedros-modal cedros-org-switcher ${d}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:l==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(Tc,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(te.ErrorMessage,{error:n}),l==="list"?e.jsx(Bc,{orgs:t,activeOrg:r,isLoading:o,onSelect:w,onCreateClick:i?()=>h("create"):void 0}):e.jsx(Uc,{isLoading:o,onSubmit:b,onCancel:()=>h("list")})]})]})})}function jo({sessions:s,isLoading:t=!1,error:r,onRevokeAll:o,className:n=""}){const[a,i]=c.useState(!1),[d,l]=c.useState(!1),h=c.useRef(null),m=c.useMemo(()=>s.filter(f=>!f.isCurrent).length,[s]),u=c.useCallback(async()=>{if(!o)return;const f=s.filter(b=>!b.isCurrent).length;if(!(f===0||!window.confirm(`Are you sure you want to sign out of ${f} other device(s)? This will log you out everywhere except this browser.`))){i(!0),l(!1);try{await o(),l(!0),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{l(!1),h.current=null},3e3)}finally{i(!1)}}},[o,s]);return c.useEffect(()=>()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${n}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):r?e.jsx("div",{className:`cedros-session-list ${n}`,children:e.jsx(te.ErrorMessage,{error:r})}):s.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${n}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${n}`,children:[d&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Vc,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(f=>e.jsx(Oc,{session:f},f.id))}),o&&m>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:u,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${m} other device${m>1?"s":""}`})})]})}function Oc({session:s}){const t=Wc(s.userAgent),r=zc(s.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${s.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx($c,{userAgent:s.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[t.browser," on ",t.os]}),s.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[s.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",s.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",qc(s.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Wc(s){if(!s)return{browser:"Unknown browser",os:"Unknown device"};let t="Unknown browser";s.includes("Chrome")&&!s.includes("Edg")?t="Chrome":s.includes("Safari")&&!s.includes("Chrome")?t="Safari":s.includes("Firefox")?t="Firefox":s.includes("Edg")&&(t="Edge");let r="Unknown device";return s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("iPhone")||s.includes("iPad")?r="iOS":s.includes("Android")&&(r="Android"),{browser:t,os:r}}function qc(s){const t=new Date(s),o=new Date().getTime()-t.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n} minute${n>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:i<7?`${i} day${i>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function zc(s){const t=new Date(s),r=new Date,o=3600*1e3;return t.getTime()-r.getTime()<o}function $c({userAgent:s}){return s?.includes("iPhone")||s?.includes("iPad")||s?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function Vc(){return e.jsx("svg",{className:"cedros-session-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function No({words:s,onConfirm:t,className:r=""}){const[o,n]=c.useState(!1),[a,i]=c.useState(!1),d=c.useRef(null),l=wc(s),h=c.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),n(!0),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>n(!1),2e3)}catch{}},[s]);c.useEffect(()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]);const m=c.useCallback(()=>{a&&t()},[a,t]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${r}`,children:[e.jsxs("div",{className:"cedros-recovery-header",children:[e.jsx("h3",{className:"cedros-recovery-title",children:"Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-warning",children:"Write down these 12 words in order and store them securely. This is the only way to recover your wallet if you lose access."})]}),e.jsx("div",{className:"cedros-recovery-grid",children:l.map((u,f)=>e.jsx("div",{className:"cedros-word-group",children:u.map((w,b)=>{const g=f*4+b+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[g,"."]}),e.jsx("span",{className:"cedros-word-text",children:w})]},g)})},f))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:h,children:o?"Copied!":"Copy to Clipboard"}),e.jsx("div",{className:"cedros-recovery-security",children:e.jsxs("div",{className:"cedros-warning-box",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M10 6v4m0 4h.01M19 10a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsxs("div",{className:"cedros-warning-content",children:[e.jsx("strong",{children:"Security Warning"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Never share this phrase with anyone"}),e.jsx("li",{children:"Store it offline in a secure location"}),e.jsx("li",{children:"Anyone with this phrase can access your wallet"}),e.jsx("li",{children:"Cedros cannot recover this phrase for you"})]})]})]})}),e.jsxs("div",{className:"cedros-recovery-confirm",children:[e.jsxs("label",{className:"cedros-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:u=>i(u.target.checked),className:"cedros-checkbox"}),e.jsx("span",{children:"I have written down and securely stored my recovery phrase"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,disabled:!a,children:"Continue"})]})]})}function ko({onSubmit:s,onCancel:t,isSubmitting:r=!1,error:o,className:n=""}){const[a,i]=c.useState(Array(me).fill("")),[d,l]=c.useState(null),[h,m]=c.useState([]),[u,f]=c.useState(null),w=c.useId(),b=c.useRef(null),g=c.useCallback((p,y)=>{const x=[...a];if(x[p]=y.toLowerCase().trim(),i(x),y.length>0){const j=gc(y,5);m(j)}else m([]);f(null)},[a]),N=c.useCallback(p=>{l(p),m([])},[]),A=c.useCallback(p=>{const y=a[p];y&&!bs(y)&&f(`Word ${p+1} is not in the wordlist`),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{d===p&&m([])},200)},[a,d]);c.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]);const v=c.useCallback(p=>{if(d!==null){const y=[...a];y[d]=p,i(y),m([]),document.querySelector(`[data-word-index="${d+1}"]`)?.focus()}},[d,a]),k=c.useCallback(p=>{const y=p.clipboardData.getData("text"),x=bc(y);x.length===me&&(p.preventDefault(),i(x),f(null))},[]),S=c.useCallback(p=>{if(p.preventDefault(),a.filter(j=>!j).length>0){f(`Please enter all ${me} words`);return}const x=a.map((j,L)=>({word:j,index:L+1})).filter(({word:j})=>!bs(j));if(x.length>0){f(`Invalid words: ${x.map(j=>`#${j.index}`).join(", ")}`);return}if(!po(a)){f("Invalid recovery phrase - please check your words");return}s(a)},[a,s]),E=o||u;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${n}`,onSubmit:S,onPaste:k,children:[e.jsxs("div",{className:"cedros-recovery-input-header",children:[e.jsx("h3",{className:"cedros-recovery-input-title",children:"Enter Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-input-description",children:"Enter your 12-word recovery phrase. You can paste the entire phrase at once."})]}),e.jsx("div",{className:"cedros-word-inputs",children:Array.from({length:me},(p,y)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[y+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${a[y]&&!bs(a[y])?"cedros-word-invalid":a[y]&&bs(a[y])?"cedros-word-valid":""}`,value:a[y],onChange:x=>g(y,x.target.value),onFocus:()=>N(y),onBlur:()=>A(y),"data-word-index":y,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:r,"aria-label":`Word ${y+1}`})]},y))}),d!==null&&h.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${w}-suggestions`,children:h.map(p=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>v(p),role:"option",children:p},p))}),E&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:E}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:r,children:r?"Recovering...":"Recover Wallet"})]})]})}function Hc({capabilities:s,className:t=""}){if(s.allSupported)return null;const r=D.getMissingCapabilitiesMessage(s),o=D.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${t}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:r}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",o.browser," ",o.version,o.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:s.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",s.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:s.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",s.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:s.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",s.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",s.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",s.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:s.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",s.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const Gc=["share_c_only","full_seed","none"];function Qc(s){return s&&Gc.includes(s)?s:"share_c_only"}const Kc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function So(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(null),[o,n]=c.useState(!!s),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),l=c.useCallback(async()=>{if(d){n(!0),i(null);try{const h=await d.get("/discovery");h.wallet?r({enabled:h.wallet.enabled,recoveryMode:Qc(h.wallet.recoveryMode),unlockTtlSeconds:h.wallet.unlockTtlSeconds}):r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(h){const m=h instanceof Error?h.message:"Failed to fetch wallet config";i(m),r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{n(!1)}}},[d]);return c.useEffect(()=>{d&&l()},[d,l]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:o,error:a,refetch:l}:Kc}function Co(){const{user:s}=M.useCedrosLogin(),{enroll:t}=D.useWalletMaterial(),{recoveryMode:r}=So(),[o,n]=c.useState({step:"idle"}),[a,i]=c.useState(!1),d=c.useRef([]),l=c.useCallback(()=>{D.wipeAll(...d.current),d.current=[]},[]);c.useEffect(()=>()=>{l()},[l]);const h=c.useCallback(async(b,g,N,A)=>{n({step:"generating_seed"});const v=D.generateSeed();d.current.push(v),n({step:"splitting_shares"});const{shareA:k,shareB:S,shareC:E}=oo(v);d.current.push(k,S,E),n({step:"encrypting_shares"});const p=await D.aesGcmEncryptToBase64(k,D.toEncryptionKey(g)),y=ro(v),x=no(y);n({step:"uploading"});const j={solanaPubkey:x,shareAAuthMethod:b,shareACiphertext:p.ciphertext,shareANonce:p.nonce,shareB:D.uint8ArrayToBase64(S)};if(b==="password"){if(!N)throw new Error("KDF salt required for password method");j.shareAKdfSalt=D.uint8ArrayToBase64(N),j.shareAKdfParams=D.DEFAULT_KDF_PARAMS}if(b==="passkey"&&A&&(j.prfSalt=A),await t(j),r==="none")l(),n({step:"complete",solanaPubkey:x});else{const L=r==="full_seed"?pc(v):hc(D.toShamirShare(E));n({step:"showing_recovery",recoveryPhrase:L,solanaPubkey:x})}},[t,r,l]),m=c.useCallback(async b=>{if(!s){n({step:"error",error:"User not authenticated"});return}i(!0),l();try{const g=D.generateArgon2Salt(),N=await In(b,g,D.DEFAULT_KDF_PARAMS);d.current.push(N),await h("password",N,g)}catch(g){n({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{i(!1)}},[s,l,h]),u=c.useCallback(async()=>{if(!s){n({step:"error",error:"User not authenticated"});return}i(!0),l();try{const b=D.generatePrfSalt(),g=D.uint8ArrayToBase64(b);n({step:"encrypting_shares"});const A=(await D.authenticateWithDiscoverablePrf(g)).prfOutput;d.current.push(A);const v=await D.deriveKeyFromPrf(A,b);d.current.push(v),await h("passkey",v,void 0,g)}catch(b){n({step:"error",error:b instanceof Error?b.message:"Enrollment failed"})}finally{i(!1)}},[s,l,h]),f=c.useCallback(()=>{const b=o.solanaPubkey;l(),n({step:"complete",solanaPubkey:b})},[o.solanaPubkey,l]),w=c.useCallback(()=>{l(),n({step:"idle"}),i(!1)},[l]);return{state:o,startEnrollmentWithPassword:m,startEnrollmentWithPasskey:u,confirmRecoveryPhrase:f,cancel:w,isEnrolling:a}}function Eo(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken]);return{setPassword:c.useCallback(async l=>{o(!0),a(null);try{await i.post("/set-password",{password:l})}catch(h){const m=M.handleApiError(h,"Failed to set password");throw a(m),m}finally{o(!1)}},[i]),isLoading:r,error:n}}function Yc(s){return s.includes("email")?"password":s.includes("webauthn")?"passkey":"set-password"}function _o({onComplete:s,onCancel:t,className:r=""}){const{user:o}=M.useCedrosLogin(),{state:n,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:i,confirmRecoveryPhrase:d,cancel:l,isEnrolling:h}=Co(),{setPassword:m,isLoading:u}=Eo(),f=o?Yc(o.authMethods):"password",[w,b]=c.useState(""),[g,N]=c.useState(""),[A,v]=c.useState(null);c.useEffect(()=>{b(""),N(""),v(null)},[o?.id]);const k=c.useCallback(async j=>{j.preventDefault(),v(null),await a(w)},[w,a]),S=c.useCallback(async j=>{if(j.preventDefault(),w!==g){v("Passwords do not match");return}const L=We.validatePassword(w);if(!L.isValid){const C=Object.values(L.errors)[0];v(C??"Password does not meet requirements");return}v(null);try{await m(w),await a(w)}catch{}},[w,g,m,a]),E=c.useCallback(async()=>{await i()},[i]),p=c.useCallback(()=>{d(),n.solanaPubkey&&s?.(n.solanaPubkey)},[d,n.solanaPubkey,s]),y=c.useCallback(()=>{l(),t?.()},[l,t]),x=h||u;return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Generating secure wallet..."})]})}):n.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Encrypting wallet shares..."})]})}):n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Saving wallet..."})]})}):n.step==="showing_recovery"&&n.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsx(No,{words:n.recoveryPhrase,onConfirm:p})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsxs("div",{className:"cedros-enrollment-complete",children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M16 24l6 6 12-12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{children:"Wallet Created!"}),e.jsxs("p",{className:"cedros-pubkey",children:[e.jsx("strong",{children:"Address:"})," ",n.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsxs("div",{className:"cedros-enrollment-error",children:[e.jsxs("svg",{className:"cedros-error-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 16v12m0 6h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Enrollment Failed"}),e.jsx("p",{className:"cedros-error-message",children:n.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>l(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${r}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),f==="password"&&e.jsx("p",{children:"Enter your account password to secure your wallet."}),f==="passkey"&&e.jsx("p",{children:"Authenticate with your passkey to secure your wallet."}),f==="set-password"&&e.jsx("p",{children:"Set a password for your account to secure your wallet."})]}),f==="password"&&e.jsxs("form",{onSubmit:k,className:"cedros-enrollment-form",children:[e.jsx(J.PasswordInput,{label:"Account Password",value:w,onChange:j=>b(j.target.value),disabled:x,required:!0,placeholder:"Enter your account password"}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!w,children:x?"Creating...":"Continue"})]})]}),f==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:E,disabled:x,children:x?"Creating...":"Use Passkey"})]})]}),f==="set-password"&&e.jsxs("form",{onSubmit:S,className:"cedros-enrollment-form",children:[e.jsx(J.PasswordInput,{label:"New Password",value:w,onChange:j=>b(j.target.value),showStrengthMeter:!0,disabled:x,required:!0,minLength:8,placeholder:"Choose a strong password"}),e.jsx(J.PasswordInput,{label:"Confirm Password",value:g,onChange:j=>N(j.target.value),error:A??void 0,disabled:x,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will also be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!w||!g,children:x?"Creating...":"Continue"})]})]})]})}function Lo(){const{user:s}=M.useCedrosLogin(),{signTransaction:t}=D.useWalletMaterial(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useCallback(async(l,h)=>{if(!s){const m="User not authenticated";throw a(m),new Error(m)}o(!0),a(null);try{const m={transaction:D.uint8ArrayToBase64(l),...h?{credential:D.toCredentialRequest(h)}:{}},u=await t(m);return D.base64ToUint8Array(u.signature)}catch(m){const u=m instanceof Error?m.message:"Signing failed";throw a(u),m}finally{o(!1)}},[s,t]),d=c.useCallback(()=>a(null),[]);return{signTransaction:i,isSigning:r,error:n,clearError:d}}function Po(){const{getMaterial:s}=D.useWalletMaterial(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useCallback(async()=>{r(!0),n(null);try{const d=await s();if(!d)throw new Error("No wallet enrolled");if(d.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!d.prfSalt)throw new Error("No PRF salt configured for wallet");const l=await D.authenticateWithDiscoverablePrf(d.prfSalt);try{return{type:"prfOutput",prfOutput:D.uint8ArrayToBase64(l.prfOutput)}}finally{l.prfOutput.fill(0)}}catch(d){const l=d instanceof Error?d.message:"Passkey authentication failed";return n(l),null}finally{r(!1)}},[s]),i=c.useCallback(()=>n(null),[]);return{getPasskeyCredential:a,isAuthenticating:t,error:o,clearError:i}}function Ro({mode:s,isLoading:t=!1,error:r,onPrompt:o,onRetry:n,onCancel:a,title:i,description:d,className:l=""}){const h=c.useCallback(()=>{t||o?.()},[t,o]),m=c.useCallback(()=>{n?.()},[n]),u=s==="register"?"Set Up Passkey":"Verify with Passkey",f=s==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${l}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(Xc,{}):r?e.jsx(Jc,{}):e.jsx(Zc,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:i??u}),e.jsx("p",{className:"cedros-passkey-description",children:d??f}),r&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:r})}),e.jsx("div",{className:"cedros-passkey-actions",children:r?e.jsxs(e.Fragment,{children:[n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,children:"Try Again"}),a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:h,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):s==="register"?"Create Passkey":"Use Passkey"}),a&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]})}),t&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",s==="register"?"create":"verify"," your passkey."]})]})}function Zc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}function Xc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Jc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01"})]})}function To({onUnlock:s,onCancel:t,showCancel:r=!0,authMethod:o,className:n=""}){M.useCedrosLogin();const{unlock:a,getMaterial:i,isLoading:d}=D.useWalletMaterial(),{getPasskeyCredential:l,isAuthenticating:h}=Po(),[m,u]=c.useState("idle"),[f,w]=c.useState(o??null),[b,g]=c.useState(""),[N,A]=c.useState(null);c.useEffect(()=>{o!==void 0&&w(o)},[o]);const v=f==="password",k=f==="passkey",S=c.useCallback(async()=>{if(u("credential"),A(null),!f)try{const C=await i();C?w(C.shareAAuthMethod):(A("No wallet enrolled"),u("error"))}catch(C){A(C instanceof Error?C.message:"Failed to get wallet info"),u("error")}},[f,i]),E=c.useCallback(async C=>{C.preventDefault(),A(null),u("unlocking");try{let P;if(v)P={type:"password",password:b};else throw new Error("Invalid auth method");await a(P),u("unlocked"),s?.()}catch(P){A(P instanceof Error?P.message:"Failed to unlock wallet"),u("error")}},[v,b,a,s]),p=c.useCallback(async()=>{A(null),u("unlocking");try{const C=await l();if(!C){u("credential");return}await a(C),u("unlocked"),s?.()}catch(C){A(C instanceof Error?C.message:"Failed to unlock wallet"),u("error")}},[l,a,s]),y=c.useCallback(()=>{g(""),u("idle"),A(null),t?.()},[t]),x=c.useCallback(()=>{g(""),u("credential"),A(null)},[]),j=d||h,L=()=>{switch(m){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(el,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Locked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Unlock your wallet to sign transactions."}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,children:"Unlock Wallet"})]});case"credential":return v?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:E,children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Enter Password"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Enter your wallet password to unlock."}),e.jsx(J.PasswordInput,{label:"Password",value:b,onChange:C=>g(C.target.value),disabled:j,autoComplete:"current-password",error:N??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:j||b.length===0,children:j?"Unlocking...":"Unlock"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:j,children:"Cancel"})]})]}):k?e.jsxs("div",{className:"cedros-wallet-unlock-passkey",children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Verify with Passkey"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Use your passkey to unlock your wallet."}),e.jsx(Ro,{mode:"authenticate",isLoading:j,error:N??void 0,onPrompt:p,onRetry:p,onCancel:r?y:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(Q.LoadingSpinner,{size:"xl"}),e.jsx("p",{children:"Loading wallet info..."})]});case"unlocking":return e.jsxs("div",{className:"cedros-wallet-unlock-progress",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Q.LoadingSpinner,{size:"xl"})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlocking Wallet"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Verifying your credentials..."})]});case"unlocked":return e.jsxs("div",{className:"cedros-wallet-unlock-success",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(sl,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Unlocked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Your wallet is ready to sign transactions."})]});case"error":return e.jsxs("div",{className:"cedros-wallet-unlock-error",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(tl,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:N??"Failed to unlock wallet. Please try again."}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Try Again"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${n}`,children:L()})}function el(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"10",y:"22",width:"28",height:"20",rx:"4",stroke:"currentColor",strokeWidth:"2",fill:"var(--cedros-muted, #f3f4f6)"}),e.jsx("path",{d:"M16 22V16a8 8 0 1 1 16 0v6",stroke:"currentColor",strokeWidth:"2",fill:"none"}),e.jsx("circle",{cx:"24",cy:"32",r:"3",fill:"currentColor"})]})}function sl(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function tl(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function Mo(){const{recover:s,getShareBForRecovery:t}=D.useWalletMaterial(),{recoveryMode:r}=So(),[o,n]=c.useState({step:"idle"}),[a,i]=c.useState(!1),d=c.useRef([]),l=c.useCallback(()=>{D.wipeAll(...d.current),d.current=[]},[]);c.useEffect(()=>()=>{l()},[l]);const h=c.useCallback(async(u,f,w)=>{i(!0),l();try{if(n({step:"validating"}),!po(u))throw new Error("Invalid recovery phrase. Please check your words.");let b;if(r==="share_c_only"){const x=mc(u);d.current.push(x);const j=D.uint8ArrayToBase64(x),L=await t({shareC:j}),C=D.base64ToUint8Array(L.shareB);d.current.push(C),b=Ji(D.toShamirShare(C),D.toShamirShare(x)),d.current.push(b)}else b=fc(u),d.current.push(b);const g=ro(b),N=no(g),{shareA:A,shareB:v}=oo(b);d.current.push(A,v),n({step:"encrypting"});let k,S,E;if(f==="passkey"){const x=D.generatePrfSalt();E=D.uint8ArrayToBase64(x);const j=await D.authenticateWithDiscoverablePrf(E);d.current.push(j.prfOutput),k=await D.deriveKeyFromPrf(j.prfOutput,x),d.current.push(k)}else S=D.generateArgon2Salt(),k=await In(w,S,D.DEFAULT_KDF_PARAMS),d.current.push(k);const p=await D.aesGcmEncryptToBase64(A,D.toEncryptionKey(k));n({step:"uploading"});const y={solanaPubkey:N,shareAAuthMethod:f,shareACiphertext:p.ciphertext,shareANonce:p.nonce,shareB:D.uint8ArrayToBase64(v)};f==="password"&&(y.shareAKdfSalt=D.uint8ArrayToBase64(S),y.shareAKdfParams=D.DEFAULT_KDF_PARAMS),f==="passkey"&&(y.prfSalt=E),await s(y),l(),n({step:"complete"})}catch(b){l(),n({step:"error",error:b instanceof Error?b.message:"Recovery failed"})}finally{i(!1)}},[s,t,r,l]),m=c.useCallback(()=>{l(),n({step:"idle"}),i(!1)},[l]);return{state:o,startRecovery:h,cancel:m,isRecovering:a}}function Io({onComplete:s,onCancel:t,className:r="",defaultAuthMethod:o="password"}){const{state:n,startRecovery:a,cancel:i,isRecovering:d}=Mo(),[l,h]=c.useState([]),[m,u]=c.useState(!1),[f,w]=c.useState(o),[b,g]=c.useState(""),[N,A]=c.useState(""),[v,k]=c.useState(null),S=c.useCallback(j=>{h(j),u(!0)},[]),E=c.useCallback(async j=>{if(j.preventDefault(),k(null),f!=="passkey"){if(b!==N){k("Passwords do not match");return}if(f==="password"&&b.length<8){k("Password must be at least 8 characters");return}}await a(l,f,b)},[l,f,b,N,a]),p=c.useCallback(()=>{i(),h([]),u(!1),g(""),A(""),t?.()},[i,t]),y=c.useCallback(()=>{u(!1),g(""),A("")},[]),x=c.useCallback(()=>{s?.()},[s]);return n.step==="validating"||n.step==="encrypting"||n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(rl,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[n.step==="validating"&&"Validating Recovery Phrase",n.step==="encrypting"&&"Encrypting Wallet",n.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[n.step==="validating"&&"Checking your recovery phrase...",n.step==="encrypting"&&"Securing your wallet with new encryption...",n.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(nl,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Wallet Recovered"}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:["Your wallet has been successfully recovered and secured with your new"," ",f==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Done"})})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(ol,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:n.error??"An error occurred during recovery. Please try again."}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:p,children:"Start Over"})})]})}):m?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:E,children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Set New Security"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Choose how to secure your recovered wallet."})]}),e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:f==="password",onChange:()=>w("password"),disabled:d}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:f==="passkey",onChange:()=>w("passkey"),disabled:d}),e.jsx("span",{children:"Passkey"})]})]}),f==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:b,onChange:j=>g(j.target.value),disabled:d,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:N,onChange:j=>A(j.target.value),disabled:d,"aria-invalid":v?"true":void 0,placeholder:"Confirm your password"}),v&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:v})]})]}),f==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(al,{}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-wallet-recovery-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:d,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:d||f!=="passkey"&&(b.length===0||N.length===0),children:d?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-phrase",children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recover Your Wallet"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Enter your 12-word recovery phrase to restore your wallet."})]}),e.jsx(ko,{onSubmit:S,onCancel:p,isSubmitting:!1})]})})}function rl(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-muted, #e5e7eb)",strokeWidth:"3",fill:"none"}),e.jsx("path",{d:"M24 4a20 20 0 0 1 20 20",stroke:"var(--cedros-primary, #6366f1)",strokeWidth:"3",strokeLinecap:"round",fill:"none"})]})}function nl(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function ol(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function al(){return e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Bo({address:s,label:t="Wallet Address",showCopy:r=!0,showExplorerLink:o=!0,allowReveal:n=!0,className:a=""}){const i=M.useCedrosLoginOptional(),[d,l]=c.useState(!1),[h,m]=c.useState(null),[u,f]=c.useState(!1),w=c.useRef(null),b=i?.config.solana?.network??"mainnet-beta",g=c.useMemo(()=>{const k=`https://explorer.solana.com/address/${s}`;return b==="mainnet-beta"?k:`${k}?cluster=${encodeURIComponent(b)}`},[s,b]),N=n&&s.length>18,A=c.useMemo(()=>!N||u?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,N,u]),v=c.useCallback(async()=>{try{m(null),await navigator.clipboard.writeText(s),l(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{l(!1),w.current=null},2e3)}catch(k){l(!1),m(k instanceof Error?k.message:"Copy failed")}},[s]);return c.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${a}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:t}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[N&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>f(k=>!k),"aria-label":u?"Hide full wallet address":"Show full wallet address",children:u?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.7 10.7a3 3 0 0 0 4.24 4.24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.88 5.09A10.94 10.94 0 0 1 12 5c5 0 9.27 3.11 11 7-0.55 1.23-1.32 2.33-2.27 3.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.61 6.61C4.4 7.9 2.74 9.8 1 12c1.73 3.89 6 7 11 7 1.14 0 2.25-0.16 3.3-0.46",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),o&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:g,target:"_blank",rel:"noreferrer",children:"Explorer"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:v,"aria-label":"Copy wallet address",children:d?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:A}),h&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:h})]})}function Uo({status:s,publicKey:t,onLock:r,onEnroll:o,onUnlock:n,onRecover:a,showActions:i=!0,compact:d=!1,className:l=""}){const h=s!==void 0,m=D.useWallet(),u=h?s:m.status,f=h?t??null:m.solanaPubkey,w=h?null:m.error,b=h?()=>{}:m.refresh,g=h?()=>{}:m.clearError,N=il(u,w);return d?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${l}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${N.color}`,title:N.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:N.label}),f&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:f,children:cl(f)})]}):e.jsxs("div",{className:`cedros-wallet-status ${l}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${N.color}`,children:e.jsx(ll,{status:u})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:N.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:N.description})]})]}),f&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(Bo,{address:f})}),w&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:w}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:g,children:"Dismiss"})]}),i&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[u==="not_enrolled"&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:o,children:"Create Wallet"}),u==="enrolled_locked"&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:n,children:"Unlock Wallet"}),(u==="not_enrolled"||u==="error")&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:"Recover Wallet"}),u==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:b,children:"Retry"})]})]})}function il(s,t){switch(s){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:t??"An error occurred with your wallet.",color:"error"}}}function cl(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function ll({status:s}){switch(s){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function dl({className:s="",showActions:t=!0}){const r=D.useWallet(),[o,n]=c.useState("status"),a=c.useMemo(()=>{switch(o){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[o]),i=c.useCallback(()=>n("status"),[]),d=c.useCallback(async()=>{n("status"),await r.refresh()},[r]),l=c.useCallback(async()=>{n("status"),await r.refresh()},[r]),h=c.useCallback(async()=>{n("status"),await r.refresh()},[r]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[o!=="status"&&a&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:a.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:a.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:i,children:"Back"})]}),o==="status"&&e.jsx(Uo,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:t}),o==="enroll"&&e.jsx(_o,{onComplete:()=>{d()},onCancel:i}),o==="unlock"&&e.jsx(To,{onUnlock:()=>{l()},onCancel:i}),o==="recover_intro"&&e.jsx("div",{className:"cedros-wallet-manager-intro",children:e.jsxs("div",{className:"cedros-wallet-manager-intro-card",children:[e.jsx("h4",{className:"cedros-wallet-manager-intro-title",children:"Before you start"}),e.jsxs("ul",{className:"cedros-wallet-manager-intro-list",children:[e.jsx("li",{children:"You’ll need your 12-word recovery phrase."}),e.jsx("li",{children:"You’ll set a new password or passkey for this wallet."}),e.jsx("li",{children:"If you’re on a shared device, avoid copying the phrase into other apps."})]}),e.jsxs("div",{className:"cedros-wallet-manager-intro-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>n("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:i,children:"Cancel"})]})]})}),o==="recover"&&e.jsx(Io,{onComplete:()=>{h()},onCancel:i})]})}function ul({showDescriptions:s=!0,className:t="",onSave:r}){const{settings:o,isLoading:n,isUpdating:a,error:i,fetchSettings:d,updateSettings:l}=Gt.useSystemSettings(),[h,m]=c.useState({}),[u,f]=c.useState(null),[w,b]=c.useState(!1);c.useEffect(()=>{d()},[d]),c.useEffect(()=>{if(w){const E=setTimeout(()=>b(!1),3e3);return()=>clearTimeout(E)}},[w]);const g=c.useCallback((E,p)=>{m(y=>({...y,[E]:p})),f(null),b(!1)},[]),N=c.useCallback(async()=>{const E=Object.entries(h).map(([p,y])=>({key:p,value:y}));if(E.length!==0)try{await l(E),m({}),f(null),b(!0),r?.()}catch(p){f(p instanceof Error?p.message:"Failed to save settings")}},[h,l,r]),A=c.useCallback(()=>{m({}),f(null),b(!1)},[]),v=Object.keys(h).length>0,k=Object.keys(h).length;if(n&&Object.keys(o).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(i)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(te.ErrorMessage,{error:i.message})});const S=Object.keys(o).sort();return S.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${t}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${t}`,children:[u&&e.jsx(te.ErrorMessage,{error:u}),w&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),S.map(E=>e.jsx(hl,{category:E,settings:o[E],edits:h,showDescription:s,onChange:g},E)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[v&&e.jsxs("span",{className:"cedros-settings-change-count",children:[k," unsaved change",k!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:A,disabled:!v||a,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:N,disabled:!v||a,children:a?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const zr=Object.keys(ke.SETTING_METADATA);function hl({category:s,settings:t,edits:r,showDescription:o,onChange:n}){const a=ke.CATEGORY_METADATA[s]||{label:s,description:"",icon:""},i=c.useMemo(()=>[...t].sort((d,l)=>{const h=zr.indexOf(d.key),m=zr.indexOf(l.key);return(h===-1?1/0:h)-(m===-1?1/0:m)}),[t]);return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:a.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:a.label}),o&&a.description&&e.jsx("p",{className:"cedros-settings-section-description",children:a.description})]})]}),e.jsx(ke.SettingsSection,{settings:i,edits:r,onChange:n})]})}const ne={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),shield:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),image:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),referrals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),ticket:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),e.jsx("path",{d:"M13 5v2"}),e.jsx("path",{d:"M13 17v2"}),e.jsx("path",{d:"M13 11v2"})]})},ml=[{id:"users",label:"Users",icon:ne.users},{id:"team",label:"Team",icon:ne.members},{id:"referrals",label:"Referrals",icon:ne.referrals},{id:"deposits",label:"Deposits",icon:ne.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ne.withdrawals,requiredFeature:"credits"},{id:"compliance",label:"Compliance",icon:ne.shield,group:"Compliance"},{id:"accreditation-queue",label:"Accreditation Queue",icon:ne.shield,group:"Compliance"},{id:"sanctions",label:"Sanctions",icon:ne.shield,group:"Compliance"},{id:"signup-gating",label:"Signup Gating",icon:ne.ticket,group:"Compliance"},{id:"settings-auth",label:"Authentication",icon:ne.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ne.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ne.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ne.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-compliance",label:"Compliance & Gating",icon:ne.shield,group:"Configuration"},{id:"settings-referrals",label:"Referrals & Rewards",icon:ne.referrals,group:"Configuration"},{id:"settings-signup",label:"Signup Gating",icon:ne.ticket,group:"Configuration"},{id:"settings-server",label:"Auth Server",icon:ne.server,group:"Configuration"},{id:"settings-images",label:"Image Storage",icon:ne.image,group:"Configuration"}];function pl(s,t){return t.toUpperCase()==="SOL"?`${(s/1e9).toFixed(4)} SOL`:`${s} ${t}`}function $r(s){return s.length<=16?s:`${s.slice(0,8)}...${s.slice(-6)}`}function fl(s){return new Date(s).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const gl=["all","pending","completed","failed","cancelled"];function wl(){const{config:s,_internal:t}=M.useCedrosLogin(),r=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),[o,n]=c.useState("all"),[a,i]=c.useState(0),d=20,[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,w]=c.useState(null),[b,g]=c.useState(null),[N,A]=c.useState(null),v=c.useCallback(async()=>{u(!0),w(null);try{const p=new URLSearchParams;o!=="all"&&p.set("status",o),p.set("limit",String(d)),p.set("offset",String(a*d));const y=await r.get(`/admin/referral-payouts/list?${p.toString()}`);h(y)}catch(p){const y=M.handleApiError(p,"Failed to load payouts");w(y.message)}finally{u(!1)}},[r,o,a]);c.useEffect(()=>{v()},[v]);const k=c.useCallback(async p=>{A(p),g(null);try{const y=await r.post(`/admin/referral-payouts/${p}/process`,{});g(`Processed: ${y.txSignature}`),v()}catch(y){const x=M.handleApiError(y,"Failed to process payout");g(x.message)}finally{A(null)}},[r,v]),S=c.useCallback(async p=>{A(p),g(null);try{await r.post(`/admin/referral-payouts/${p}/cancel`,{}),g("Payout cancelled."),v()}catch(y){const x=M.handleApiError(y,"Failed to cancel payout");g(x.message)}finally{A(null)}},[r,v]),E=l?Math.ceil(l.total/d):0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__filter-bar",children:[e.jsxs("label",{className:"cedros-admin-referral-payouts__filter-label",children:["Status:",e.jsx("select",{value:o,onChange:p=>{n(p.target.value),i(0)},className:"cedros-admin-referral-payouts__filter-select",children:gl.map(p=>e.jsx("option",{value:p,children:p.charAt(0).toUpperCase()+p.slice(1)},p))})]}),l&&e.jsxs("span",{className:"cedros-admin-referral-payouts__filter-count",children:[l.total," total"]})]}),b&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--info",children:b}),m&&!l&&e.jsxs("div",{className:"cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading payouts..."})]}),f&&e.jsxs("div",{className:"cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:f}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:v,children:"Retry"})]}),l&&l.payouts.length===0&&e.jsx("div",{className:"cedros-admin-empty-message",children:"No payouts found."}),l&&l.payouts.length>0&&e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"All referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Trigger"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"TX / Error"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),l.payouts.map(p=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:fl(p.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:p.referrerEmail||p.referrerName||$r(p.referrerId)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:p.triggerType}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:pl(p.amount,p.currency)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-referral-payouts__status cedros-admin-referral-payouts__status--${p.status}`,children:p.status})}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:[p.txSignature&&$r(p.txSignature),p.errorMessage&&e.jsx("span",{className:"cedros-admin-list-td-muted",title:p.errorMessage,children:p.errorMessage.slice(0,40)})]}),e.jsxs("div",{className:"cedros-admin-list-td",role:"cell",children:[(p.status==="pending"||p.status==="failed")&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-xs",onClick:()=>k(p.id),disabled:N!==null,children:N===p.id?"...":"Process"}),p.status==="pending"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",onClick:()=>S(p.id),disabled:N!==null,style:{marginLeft:4},children:"Cancel"})]})]},p.id))]}),E>1&&e.jsxs("div",{className:"cedros-admin-referral-payouts__pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a===0,onClick:()=>i(p=>p-1),children:"Previous"}),e.jsxs("span",{className:"cedros-admin-referral-payouts__page-info",children:["Page ",a+1," of ",E]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a>=E-1,onClick:()=>i(p=>p+1),children:"Next"})]})]})}function at(s,t){return t.toUpperCase()==="SOL"?`${(s/1e9).toFixed(4)} SOL`:`${s} ${t}`}function Vr(s){return s.length<=16?s:`${s.slice(0,8)}...${s.slice(-6)}`}function Do({className:s=""}){const[t,r]=c.useState("summary");return e.jsxs("div",{className:`cedros-admin-referral-payouts ${s}`,children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__tabs",children:[e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${t==="summary"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("summary"),children:"Summary"}),e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${t==="all"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("all"),children:"All Payouts"})]}),t==="summary"?e.jsx(bl,{}):e.jsx(wl,{})]})}function bl(){const{config:s,_internal:t}=M.useCedrosLogin(),r=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),[o,n]=c.useState(null),[a,i]=c.useState(!1),[d,l]=c.useState(null),[h,m]=c.useState(!1),[u,f]=c.useState(null),[w,b]=c.useState(null),[g,N]=c.useState(!1),[A,v]=c.useState(null),[k,S]=c.useState(null),[E,p]=c.useState(null),y=c.useCallback(async()=>{i(!0),l(null);try{const I=await r.get("/admin/referral-payouts");n(I)}catch(I){const O=M.handleApiError(I,"Failed to load referral payouts");l(O.message)}finally{i(!1)}},[r]),x=c.useCallback(async()=>{try{const O=(await r.get("/admin/settings"))?.payout_auto_enabled?.value;p(O==="true")}catch{}},[r]);c.useEffect(()=>{y(),x()},[y,x]);const j=c.useCallback(async()=>{m(!0),f(null),b(null);try{const I=await r.post("/admin/referral-payouts/process",{});f(I),y()}catch(I){const O=M.handleApiError(I,"Failed to process payouts");b(O.message)}finally{m(!1)}},[r,y]),L=c.useCallback(async()=>{N(!0),v(null),S(null);try{const I=await r.post("/admin/referral-payouts/retry-failed",{});v(I),y()}catch(I){const O=M.handleApiError(I,"Failed to retry failed payouts");S(O.message)}finally{N(!1)}},[r,y]),C=h||g;if(a&&!o)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading referral payouts..."})]});if(d)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,children:"Retry"})]});const P=o?.referrers??[],_=o?.total??0,R=P[0]?.currency??"SOL",T=P.reduce((I,O)=>I+O.totalPendingAmount,0);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__header",children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__summary",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Pending Referrers"}),e.jsx("span",{className:"cedros-admin-stat-value",children:_})]}),_>0&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Total Pending Amount"}),e.jsx("span",{className:"cedros-admin-stat-value",children:at(T,R)})]}),E!==null&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Auto-Processing"}),e.jsx("span",{className:"cedros-admin-stat-value",children:E?"ON":"OFF"})]})]}),e.jsxs("div",{className:"cedros-admin-referral-payouts__actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:j,disabled:C||_===0,"aria-busy":h,children:h?"Processing...":"Process All Payouts"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:L,disabled:C,"aria-busy":g,children:g?"Retrying...":"Retry Failed"})]})]}),u&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Processed ",u.processed," payout(s) totalling"," ",at(u.totalAmount,R),".",u.failed>0&&` ${u.failed} failed.`,u.skippedNoWallet>0&&` ${u.skippedNoWallet} skipped (no wallet).`]}),w&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:w}),A&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Reset ",A.resetCount," failed payout(s) for retry."]}),k&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:k}),P.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No pending referral payouts."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Pending referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer ID"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Wallet Address"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Pending Referrals"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Total Amount"})]}),P.map(I=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:e.jsx("button",{type:"button",className:"cedros-admin-user-uuid-link",onClick:()=>navigator.clipboard?.writeText(I.referrerId),title:`Click to copy: ${I.referrerId}`,children:Vr(I.referrerId)})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:I.payoutWalletAddress?e.jsx("button",{type:"button",className:"cedros-admin-user-uuid-link cedros-admin-list-td-mono",onClick:()=>navigator.clipboard?.writeText(I.payoutWalletAddress),title:`Click to copy: ${I.payoutWalletAddress}`,children:Vr(I.payoutWalletAddress)}):e.jsx("span",{className:"cedros-admin-list-td-muted",children:"No wallet"})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:I.pendingCount}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:at(I.totalPendingAmount,I.currency)})]},I.referrerId))]})]})}function xl({pageSize:s,currentUserId:t}){const[r,o]=c.useState(null),{statsItems:n,isLoading:a,error:i,refresh:d}=Ie.useUsersStatsSummary();return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ie.AdminUserDetail,{userId:r.id,currentUserId:t,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Pn.StatsBar,{stats:n,isLoading:a,onRefresh:d}),i&&e.jsx("p",{className:"cedros-admin-error-inline",children:i}),e.jsx(Ie.AdminUserList,{pageSize:s,currentUserId:t,onUserClick:l=>o(l)})]})}function yl({orgId:s,currentUserId:t,hasPermission:r,role:o}){const[n,a]=c.useState("members"),{members:i,isLoading:d,error:l,fetchMembers:h,updateMemberRole:m,removeMember:u}=fe.useMembers(s),{invites:f,isLoading:w,error:b,fetchInvites:g,createInvite:N,cancelInvite:A,resendInvite:v}=fe.useInvites(s);c.useEffect(()=>{h(),g()},[h,g]);const k=r("invite:create"),S=r("invite:cancel"),E=f.length,p=i.reduce((L,C)=>(L[C.role]=(L[C.role]??0)+1,L),{}),y=p.owner??0,x=p.admin??0,j=p.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Pn.StatsBar,{stats:[{label:"Owners",value:y},{label:"Admins",value:x},{label:"Members",value:j},{label:"Pending Invites",value:E}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="members"?"cedros-admin-tab-active":""}`,onClick:()=>a("members"),"aria-selected":n==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${n==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>a("invites"),"aria-selected":n==="invites",role:"tab",children:["Pending Invites",E>0&&` (${E})`]}),o==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>a("permissions"),"aria-selected":n==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[n==="members"&&e.jsx(fe.MemberList,{members:i,currentUserId:t,isLoading:d,error:l?.message,canManage:r("member:remove"),canChangeRoles:r("member:role_change"),onUpdateRole:m,onRemove:u}),n==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[k&&e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx("div",{className:"cedros-dashboard__section-header",children:e.jsx("h3",{className:"cedros-dashboard__section-title",children:"Send Invitation"})}),e.jsx(fe.InviteForm,{onSubmit:N,isLoading:w,error:b?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(fe.InviteList,{invites:f,isLoading:w,error:b?.message,canManage:S||k,onCancel:S?A:void 0,onResend:k?v:void 0})})]}),n==="permissions"&&o==="owner"&&e.jsx(fe.PermissionsSection,{userRole:o})]})]})}function vl({pageSize:s,refreshInterval:t}){const[r,o]=c.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(_s.AdminDepositStats,{refreshInterval:t}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:r,onChange:n=>o(n.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(_s.AdminDepositList,{statusFilter:r||void 0,pageSize:s,refreshInterval:t})]})]})}function Al({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Me.AdminWithdrawalStats,{refreshInterval:t}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(Me.AdminPrivacyPeriodDeposits,{pageSize:s,refreshInterval:t}),e.jsx(Me.AdminWithdrawalQueue,{pageSize:s,refreshInterval:t}),e.jsx(Me.AdminWithdrawalHistory,{pageSize:s,refreshInterval:t})]})]})}function jl(){return e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Do,{})})}const Nl=["security","rate_limit"];function kl({className:s}){return e.jsx(ss.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:Nl,className:s})}const Hr=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Sl({className:s}){const{settings:t,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:d,handleChange:l,getEffectiveValue:h}=ke.useSettingsAutosave(),[m,u]=c.useState("email");c.useEffect(()=>{d()},[d]);const f=Hr.find(S=>S.id===m),w=f?.category??"",g=(h("email_provider")||"custom")==="custom",N=h("email_smtp_host"),A=!g||N!=null&&N!=="",v=c.useMemo(()=>{const S=t[w]??[];if(m!=="email")return S;const E=g?ks.ALL_EMAIL_FIELDS:ks.SIMPLIFIED_EMAIL_FIELDS;return S.filter(p=>E.includes(p.key)).sort((p,y)=>E.indexOf(p.key)-E.indexOf(y.key))},[t,w,m,g]),k=(S,E)=>{if(l(S,E),S==="email_provider"&&E!=="custom"){const p=ks.PROVIDER_SMTP_HOSTS[E];p&&(l("email_smtp_host",p),l("email_smtp_port","587"),l("email_smtp_tls","true"))}};return o&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(te.ErrorMessage,{error:i.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(ke.AutosaveStatus,{status:n,error:a})]}),m==="email"&&!A&&e.jsx("div",{className:"cedros-settings-warning-banner",children:"Email features (verification, password reset, instant link) are disabled until SMTP is configured. Select a provider or enter custom SMTP settings below."}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:Hr.map(S=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${m===S.id?"cedros-admin-tab-active":""}`,onClick:()=>u(S.id),"aria-selected":m===S.id,role:"tab",children:S.label},S.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:v.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",f?.label??"this section","."]})}):e.jsx(ke.SettingsSection,{settings:v,edits:r,onChange:m==="email"?k:l})})]})}const it=["image_storage_enabled","image_storage_provider","image_storage_bucket","image_storage_region","image_storage_endpoint","image_storage_access_key","image_storage_secret_key","image_storage_cdn_url"],Gr={nyc3:"https://nyc3.digitaloceanspaces.com",ams3:"https://ams3.digitaloceanspaces.com",sgp1:"https://sgp1.digitaloceanspaces.com",sfo3:"https://sfo3.digitaloceanspaces.com",fra1:"https://fra1.digitaloceanspaces.com",syd1:"https://syd1.digitaloceanspaces.com"};function Cl({className:s}){const{settings:t,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:d,handleChange:l,getEffectiveValue:h}=ke.useSettingsAutosave();c.useEffect(()=>{d()},[d]);const m=c.useMemo(()=>(t.image_storage??[]).filter(w=>it.includes(w.key)).sort((w,b)=>it.indexOf(w.key)-it.indexOf(b.key)),[t]),u=(f,w)=>{if(l(f,w),f==="image_storage_provider")if(w==="digitalocean"){const b=h("image_storage_region")||"nyc3";l("image_storage_region",b),l("image_storage_endpoint",Gr[b]??`https://${b}.digitaloceanspaces.com`)}else w==="s3"&&l("image_storage_endpoint","");f==="image_storage_region"&&h("image_storage_provider")==="digitalocean"&&l("image_storage_endpoint",Gr[w]??`https://${w}.digitaloceanspaces.com`)};return o&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(te.ErrorMessage,{error:i.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Image Storage"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure S3-compatible object storage for user avatars and images. Supports AWS S3, DigitalOcean Spaces, and other S3-compatible providers."})]}),e.jsx(ke.AutosaveStatus,{status:n,error:a})]}),m.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsx("p",{children:"No image storage settings found."})}):e.jsx(ke.SettingsSection,{settings:m,edits:r,onChange:u})]})}const El=["kyc","accreditation","sanctions","token_gating"];function Fo({className:s}){return e.jsx(ss.SettingsPageLayout,{title:"Compliance & Gating",description:"Configure KYC identity verification, accredited investor verification, sanctions screening, and Solana token gating.",categories:El,className:s})}const _l=["referral"];function Oo({className:s}){return e.jsx(ss.SettingsPageLayout,{title:"Referrals & Rewards",description:"Configure referral reward types, amounts, triggers, per-referrer caps, and automated payout processing.",categories:_l,className:s})}const Ll=["signup"];function Wo({className:s}){return e.jsx(ss.SettingsPageLayout,{title:"Signup Gating",description:"Configure access codes required to register and optional signup rate limits.",categories:Ll,className:s})}const ls=20;function ct(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}function Pl(s){return!!s.expiresAt&&new Date(s.expiresAt)<new Date}function Rl(s){return s.maxUses!==null&&s.currentUses>=s.maxUses}function Tl(s){return Pl(s)?"expired":Rl(s)?"exhausted":"active"}function qo({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Ie.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState("all"),[i,d]=c.useState([]),[l,h]=c.useState(0),[m,u]=c.useState(0),[f,w]=c.useState(!1),[b,g]=c.useState(null),[N,A]=c.useState(null),[v,k]=c.useState(""),[S,E]=c.useState(""),[p,y]=c.useState(""),[x,j]=c.useState(!1),[L,C]=c.useState(null),[P,_]=c.useState(!1),[R,T]=c.useState(null),[I,O]=c.useState(null),W={all:void 0,limited:"limited",user_invite:"user_invite"},q=c.useCallback(async()=>{w(!0),g(null);try{const B=await o.listAccessCodes(ls,m,W[n]);d(B.items),h(B.total)}catch(B){g(B instanceof Error?B.message:"Failed to load access codes")}finally{w(!1)}},[o,n,m]),U=c.useCallback(async()=>{try{const B=await o.getSignupStats();A(B)}catch{}},[o]);c.useEffect(()=>{q(),U()},[q,U]),c.useEffect(()=>{u(0)},[n]);const F=c.useCallback(async B=>{if(B.preventDefault(),!v.trim()){C("Code is required.");return}const z=S.trim()?parseInt(S,10):null;if(S.trim()&&(isNaN(z)||z<1)){C("Max uses must be a positive integer.");return}const $=p.trim()?new Date(p).toISOString():void 0;j(!0),C(null),_(!1);try{await o.createAccessCode(v.trim(),z,$),k(""),E(""),y(""),_(!0),q(),U()}catch(H){C(H instanceof Error?H.message:"Failed to create code")}finally{j(!1)}},[o,v,S,p,q,U]),V=c.useCallback(async B=>{T(B),O(null);try{await o.deleteAccessCode(B),d(z=>z.filter($=>$.id!==B)),h(z=>z-1)}catch(z){O(z instanceof Error?z.message:"Failed to delete code")}finally{T(null)}},[o]),Y=Math.ceil(l/ls),X=Math.floor(m/ls)+1;return e.jsxs("div",{className:`cedros-admin-access-codes ${s}`,children:[e.jsxs("div",{className:"cedros-admin-access-codes__header",children:[e.jsx("h2",{className:"cedros-admin-access-codes__title",children:"Access Codes"}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:()=>{q(),U()},disabled:f,title:"Refresh","aria-label":"Refresh list",children:f?"...":"↻"})]}),N&&e.jsxs("div",{className:"cedros-admin-access-codes__stats-bar","aria-label":"Signup statistics",children:[e.jsxs("span",{className:"cedros-admin-access-codes__stat",children:[e.jsxs("strong",{children:["Signups this ",N.period,":"]})," ",N.count,N.limit!==null?` / ${N.limit}`:""]}),e.jsxs("span",{className:"cedros-admin-access-codes__stat",children:[e.jsx("strong",{children:"Period start:"})," ",ct(N.periodStart)]})]}),e.jsxs("section",{className:"cedros-admin-access-codes__create-section","aria-label":"Create access code",children:[e.jsx("h3",{className:"cedros-admin-access-codes__section-title",children:"Create Code"}),e.jsxs("form",{className:"cedros-admin-access-codes__create-form",onSubmit:F,"aria-label":"Create access code form",children:[e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsx("label",{htmlFor:"ac-code",className:"cedros-label",children:"Code"}),e.jsx("input",{id:"ac-code",type:"text",className:"cedros-input",value:v,onChange:B=>{k(B.target.value),C(null),_(!1)},placeholder:"e.g. BETA2025",disabled:x,required:!0})]}),e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsxs("label",{htmlFor:"ac-max-uses",className:"cedros-label",children:["Max Uses ",e.jsx("span",{className:"cedros-optional",children:"(blank = unlimited)"})]}),e.jsx("input",{id:"ac-max-uses",type:"number",className:"cedros-input",value:S,onChange:B=>E(B.target.value),placeholder:"e.g. 100",min:"1",disabled:x})]}),e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsxs("label",{htmlFor:"ac-expiry",className:"cedros-label",children:["Expiry ",e.jsx("span",{className:"cedros-optional",children:"(optional)"})]}),e.jsx("input",{id:"ac-expiry",type:"date",className:"cedros-input",value:p,onChange:B=>y(B.target.value),disabled:x})]}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary cedros-button-md",disabled:x,"aria-busy":x,children:x?"Creating...":"Create"})]}),L&&e.jsx("div",{className:"cedros-admin-error",role:"alert",children:L}),P&&!L&&e.jsx("div",{className:"cedros-admin-success",role:"status",children:"Code created."})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",role:"tablist",children:["all","limited","user_invite"].map(B=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${n===B?"cedros-admin-tab-active":""}`,onClick:()=>a(B),"aria-selected":n===B,role:"tab",children:B==="all"?"All":B==="limited"?"Limited":"User Invite"},B))}),I&&e.jsx("div",{className:"cedros-admin-error",role:"alert",children:I}),b&&e.jsxs("div",{className:"cedros-admin-access-codes--error",children:[e.jsx("p",{className:"cedros-admin-error",children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:q,children:"Retry"})]}),!b&&e.jsx("div",{role:"tabpanel",children:f&&i.length===0?e.jsxs("div",{className:"cedros-admin-access-codes--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading..."})]}):i.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No access codes found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table cedros-admin-access-codes__table",role:"table","aria-label":"Access codes",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Code"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Uses"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Created By"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Created"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Expires"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:e.jsx("span",{className:"cedros-sr-only",children:"Actions"})})]}),i.map(B=>{const z=Tl(B),$=B.maxUses!==null?`${B.currentUses} / ${B.maxUses}`:`${B.currentUses}`;return e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("code",{className:"cedros-admin-access-codes__code",children:B.code})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:B.codeType}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:$}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:B.createdByEmail??"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:ct(B.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:B.expiresAt?ct(B.expiresAt):"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-access-codes__status cedros-admin-access-codes__status--${z}`,children:z.charAt(0).toUpperCase()+z.slice(1)})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>V(B.id),disabled:R===B.id,"aria-label":`Delete code ${B.code}`,children:R===B.id?"...":"Delete"})})]},B.id)})]}),Y>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(Math.max(0,m-ls)),disabled:X<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",X," of ",Y," (",l," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(m+ls),disabled:X>=Y,children:"Next"})]})]})})]})}function Ml(){return`rule_${Date.now()}_${Math.random().toString(36).slice(2,7)}`}function Il(s){if(!s)return[];try{const t=JSON.parse(s);return Array.isArray(t)?t:[]}catch{return[]}}function Bl(s){switch(s){case"nft_collection":return"NFT Collection";case"fungible_token":return"Fungible Token";case"any_nft":return"Any NFT"}}function Ul(s){switch(s){case"all":return"All";case"deposits":return"Deposits";case"withdrawals":return"Withdrawals"}}const Qr={name:"",ruleType:"nft_collection",collectionAddress:"",mintAddress:"",minQuantity:"",minAmount:"",enforcement:"all"};function Dl(s){return{name:s.name,ruleType:s.ruleType,collectionAddress:s.collectionAddress??"",mintAddress:s.mintAddress??"",minQuantity:s.minQuantity!==void 0?String(s.minQuantity):"",minAmount:s.minAmount??"",enforcement:s.enforcement}}function Fl(s,t){return{id:t,name:s.name.trim(),ruleType:s.ruleType,collectionAddress:s.ruleType==="nft_collection"&&s.collectionAddress.trim()||void 0,mintAddress:s.ruleType==="fungible_token"&&s.mintAddress.trim()||void 0,minQuantity:s.ruleType!=="fungible_token"&&s.minQuantity?parseInt(s.minQuantity,10):void 0,minAmount:s.ruleType==="fungible_token"&&s.minAmount.trim()||void 0,enforcement:s.enforcement}}function zo({className:s=""}){const{fetchSettings:t,updateSettings:r,getValue:o,isLoading:n,error:a}=Gt.useSystemSettings(),[i,d]=c.useState([]),[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,w]=c.useState(Qr),[b,g]=c.useState(null),[N,A]=c.useState(!1);c.useEffect(()=>{t()},[t]);const v=o("token_gating_rules"),k=c.useMemo(()=>Il(v),[v]);c.useEffect(()=>{d(k)},[k]);const S=c.useCallback(async C=>{A(!0),g(null);try{await r([{key:"token_gating_rules",value:JSON.stringify(C)}]),d(C)}catch(P){g(P instanceof Error?P.message:"Failed to save rules")}finally{A(!1)}},[r]),E=c.useCallback(()=>{h(null),w(Qr),g(null),u(!0)},[]),p=c.useCallback(C=>{h(C.id),w(Dl(C)),g(null),u(!0)},[]),y=c.useCallback(C=>{const P=i.filter(_=>_.id!==C);S(P)},[i,S]),x=c.useCallback(()=>{u(!1),g(null)},[]),j=c.useCallback(async()=>{if(!f.name.trim()){g("Rule name is required.");return}const C=l??Ml(),P=Fl(f,C),_=l?i.map(R=>R.id===l?P:R):[...i,P];await S(_),b||u(!1)},[f,l,i,S,b]),L=c.useCallback((C,P)=>{w(_=>({..._,[C]:P}))},[]);return n&&i.length===0?e.jsxs("div",{className:`cedros-admin-token-gate ${s} cedros-admin-token-gate--loading`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading token gate rules..."})]}):a&&i.length===0?e.jsxs("div",{className:`cedros-admin-token-gate ${s} cedros-admin-token-gate--error`,children:[e.jsx("p",{className:"cedros-admin-error",children:a.message}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:"Retry"})]}):e.jsxs("div",{className:`cedros-admin-token-gate ${s}`,children:[e.jsxs("div",{className:"cedros-admin-token-gate__header",children:[e.jsx("h2",{className:"cedros-admin-token-gate__title",children:"Token Gate Rules"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:E,disabled:m,children:"Add Rule"})]}),m&&e.jsx(Ol,{form:f,isNew:l===null,isSaving:N,saveError:b,onFieldChange:L,onSave:j,onCancel:x}),i.length===0&&!m?e.jsx("div",{className:"cedros-admin-empty-message",children:"No token gate rules configured."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Token gate rules",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Name"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Address / Mint"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Min Qty / Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Enforcement"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),i.map(C=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:C.name}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Bl(C.ruleType)}),e.jsx("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:C.collectionAddress||C.mintAddress||"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:C.minQuantity!==void 0?C.minQuantity:C.minAmount??"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Ul(C.enforcement)}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-actions",role:"cell",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>p(C),disabled:m,children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>y(C.id),disabled:N||m,children:"Delete"})]})]},C.id))]})]})}function Ol({form:s,isNew:t,isSaving:r,saveError:o,onFieldChange:n,onSave:a,onCancel:i}){const d=s.ruleType==="nft_collection",l=s.ruleType==="fungible_token",h=s.ruleType!=="fungible_token",m=s.ruleType==="fungible_token";return e.jsxs("div",{className:"cedros-admin-token-gate__form",role:"region","aria-label":t?"Add rule":"Edit rule",children:[e.jsx("h3",{className:"cedros-admin-token-gate__form-title",children:t?"Add Rule":"Edit Rule"}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-name",children:"Name"}),e.jsx("input",{id:"tg-name",type:"text",className:"cedros-admin-form-input",value:s.name,onChange:u=>n("name",u.target.value),placeholder:"e.g. Whale Gate"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-type",children:"Type"}),e.jsxs("select",{id:"tg-type",className:"cedros-admin-form-select",value:s.ruleType,onChange:u=>n("ruleType",u.target.value),children:[e.jsx("option",{value:"nft_collection",children:"NFT Collection"}),e.jsx("option",{value:"fungible_token",children:"Fungible Token"}),e.jsx("option",{value:"any_nft",children:"Any NFT"})]})]}),d&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-collection",children:"Collection Address"}),e.jsx("input",{id:"tg-collection",type:"text",className:"cedros-admin-form-input cedros-admin-form-input--mono",value:s.collectionAddress,onChange:u=>n("collectionAddress",u.target.value),placeholder:"Solana collection mint address"})]}),l&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-mint",children:"Mint Address"}),e.jsx("input",{id:"tg-mint",type:"text",className:"cedros-admin-form-input cedros-admin-form-input--mono",value:s.mintAddress,onChange:u=>n("mintAddress",u.target.value),placeholder:"SPL token mint address"})]}),h&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-minqty",children:"Min Quantity"}),e.jsx("input",{id:"tg-minqty",type:"number",min:"1",className:"cedros-admin-form-input",value:s.minQuantity,onChange:u=>n("minQuantity",u.target.value),placeholder:"1"})]}),m&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-minamount",children:"Min Amount"}),e.jsx("input",{id:"tg-minamount",type:"text",className:"cedros-admin-form-input",value:s.minAmount,onChange:u=>n("minAmount",u.target.value),placeholder:"e.g. 1000000 (raw units)"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-enforcement",children:"Enforcement"}),e.jsxs("select",{id:"tg-enforcement",className:"cedros-admin-form-select",value:s.enforcement,onChange:u=>n("enforcement",u.target.value),children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"deposits",children:"Deposits"}),e.jsx("option",{value:"withdrawals",children:"Withdrawals"})]})]}),o&&e.jsx("p",{className:"cedros-admin-error",children:o}),e.jsxs("div",{className:"cedros-admin-token-gate__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,disabled:r,"aria-busy":r,children:r?"Saving...":"Save Rule"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:i,disabled:r,children:"Cancel"})]})]})}function Wl(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function ql(s){return{income:"Income",net_worth:"Net Worth",credential:"Credential",third_party_letter:"Third-Party Letter",insider:"Insider / Executive",investment_threshold:"Investment Threshold"}[s]??s}function zl(s){switch(s){case"pending":return"cedros-admin-badge--pending";case"approved":return"cedros-admin-badge--approved";case"rejected":return"cedros-admin-badge--rejected";case"expired":return"cedros-admin-badge--expired";default:return""}}function $l({item:s,isExpanded:t,detail:r,detailLoading:o,detailError:n,reviewNotes:a,rejectionReason:i,isReviewing:d,reviewError:l,onRowClick:h,onDocumentDownload:m,onReviewNotesChange:u,onRejectionReasonChange:f,onReview:w}){const b=s.statedAmountUsd!==void 0?`$${s.statedAmountUsd.toLocaleString()}`:s.investmentCommitmentUsd!==void 0?`$${s.investmentCommitmentUsd.toLocaleString()}`:"—";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`cedros-admin-list-row cedros-admin-list-row--clickable ${t?"cedros-admin-list-row--expanded":""}`,role:"row",onClick:()=>h(s.id),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),h(s.id))},tabIndex:0,"aria-expanded":t,children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:s.userEmail??e.jsxs("span",{className:"cedros-admin-list-td-mono",children:[s.userId.slice(0,12),"..."]})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:ql(s.method)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:b}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Wl(s.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-badge ${zl(s.status)}`,children:s.status})})]}),t&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail",role:"region","aria-label":"Submission detail",children:[o&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading detail..."})]}),n&&e.jsx("p",{className:"cedros-admin-error",children:n}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Vl,{detail:r,onDocumentDownload:m}),s.status==="pending"&&e.jsx(Hl,{submissionId:s.id,notes:a,rejectionReason:i,isReviewing:d,error:l,onNotesChange:u,onRejectionReasonChange:f,onReview:w})]})]})]})}function Vl({detail:s,onDocumentDownload:t}){return e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail-fields",children:[s.incomeType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Income Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.incomeType})]}),s.statedAmountUsd!==void 0&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Stated Amount"}),e.jsxs("span",{className:"cedros-admin-detail-value",children:["$",s.statedAmountUsd.toLocaleString()]})]}),s.crdNumber&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"CRD Number"}),e.jsx("span",{className:"cedros-admin-detail-value cedros-admin-list-td-mono",children:s.crdNumber})]}),s.licenseType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"License Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.licenseType})]}),s.investmentCommitmentUsd!==void 0&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Investment Commitment"}),e.jsxs("span",{className:"cedros-admin-detail-value",children:["$",s.investmentCommitmentUsd.toLocaleString()]})]}),s.entityType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Entity Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.entityType})]}),s.userStatement&&e.jsxs("div",{className:"cedros-admin-detail-row cedros-admin-detail-row--block",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"User Statement"}),e.jsx("p",{className:"cedros-admin-detail-statement",children:s.userStatement})]}),s.documents.length>0&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__documents",children:[e.jsx("h4",{className:"cedros-admin-accreditation-queue__documents-title",children:"Documents"}),s.documents.map(r=>e.jsxs("div",{className:"cedros-admin-accreditation-queue__document-row",children:[e.jsx("span",{className:"cedros-admin-accreditation-queue__document-name",children:r.originalFilename??r.documentType}),r.fileSizeBytes&&e.jsxs("span",{className:"cedros-admin-list-td-muted",children:[(r.fileSizeBytes/1024).toFixed(1)," KB"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>t(r.id),children:"Download"})]},r.id))]})]})}function Hl({submissionId:s,notes:t,rejectionReason:r,isReviewing:o,error:n,onNotesChange:a,onRejectionReasonChange:i,onReview:d}){return e.jsxs("div",{className:"cedros-admin-accreditation-queue__review-form",children:[e.jsx("h4",{className:"cedros-admin-accreditation-queue__review-title",children:"Review Decision"}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"review-notes",children:"Reviewer Notes (internal)"}),e.jsx("textarea",{id:"review-notes",className:"cedros-admin-form-textarea",value:t,onChange:l=>a(l.target.value),rows:2,placeholder:"Optional internal notes"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"rejection-reason",children:"Rejection Reason (required if rejecting)"}),e.jsx("textarea",{id:"rejection-reason",className:"cedros-admin-form-textarea",value:r,onChange:l=>i(l.target.value),rows:2,placeholder:"Reason shown to user"})]}),n&&e.jsx("p",{className:"cedros-admin-error",children:n}),e.jsxs("div",{className:"cedros-admin-accreditation-queue__review-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:()=>d(s,!0),disabled:o,"aria-busy":o,children:o?"Saving...":"Approve"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>d(s,!1),disabled:o,"aria-busy":o,children:o?"Saving...":"Reject"})]})]})}const ds=20;function $o({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Ie.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState("pending"),[i,d]=c.useState([]),[l,h]=c.useState(0),[m,u]=c.useState(0),[f,w]=c.useState(!1),[b,g]=c.useState(null),[N,A]=c.useState(null),[v,k]=c.useState(null),[S,E]=c.useState(!1),[p,y]=c.useState(null),[x,j]=c.useState(""),[L,C]=c.useState(""),[P,_]=c.useState(!1),[R,T]=c.useState(null),[I,O]=c.useState(null),W=c.useCallback(async()=>{w(!0),g(null);try{const B=await o.listPendingAccreditations(ds,m);d(B.items),h(B.total)}catch(B){g(B instanceof Error?B.message:"Failed to load submissions")}finally{w(!1)}},[o,n,m]);c.useEffect(()=>{W()},[W]),c.useEffect(()=>{u(0),A(null),k(null)},[n]);const q=c.useCallback(async B=>{if(N===B){A(null),k(null);return}A(B),k(null),y(null),j(""),C(""),T(null),O(null),E(!0);try{const z=await o.getAccreditationSubmission(B);k(z)}catch(z){y(z instanceof Error?z.message:"Failed to load submission detail")}finally{E(!1)}},[N,o]),U=c.useCallback(async B=>{try{const z=await o.getAccreditationDocumentUrl(B);window.open(z,"_blank","noopener,noreferrer")}catch(z){T(z instanceof Error?z.message:"Failed to get document URL")}},[o]),F=c.useCallback(async(B,z)=>{if(!z&&!L.trim()){T("Rejection reason is required.");return}_(!0),T(null),O(null);try{await o.reviewAccreditation(B,z,x.trim()||void 0,z?void 0:L.trim()),O(z?"Submission approved.":"Submission rejected."),A(null),k(null),W()}catch($){T($ instanceof Error?$.message:"Failed to submit review")}finally{_(!1)}},[o,x,L,W]),V=Math.ceil(l/ds),Y=Math.floor(m/ds)+1,X=n==="pending"?l:i.filter(B=>B.status==="pending").length;return e.jsxs("div",{className:`cedros-admin-accreditation-queue ${s}`,children:[e.jsxs("div",{className:"cedros-admin-accreditation-queue__header",children:[e.jsxs("h2",{className:"cedros-admin-accreditation-queue__title",children:["Accreditation Review Queue",X>0&&e.jsx("span",{className:"cedros-admin-queue-count","aria-label":`${X} pending`,children:X})]}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:W,disabled:f,title:"Refresh","aria-label":"Refresh list",children:f?"...":"↻"})]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",role:"tablist",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="pending"?"cedros-admin-tab-active":""}`,onClick:()=>a("pending"),"aria-selected":n==="pending",role:"tab",children:"Pending"}),e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="all"?"cedros-admin-tab-active":""}`,onClick:()=>a("all"),"aria-selected":n==="all",role:"tab",children:"All"})]}),I&&e.jsx("div",{className:"cedros-admin-accreditation-queue__result cedros-admin-accreditation-queue__result--success",children:I}),b&&e.jsxs("div",{className:"cedros-admin-accreditation-queue cedros-admin-accreditation-queue--error",children:[e.jsx("p",{className:"cedros-admin-error",children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:W,children:"Retry"})]}),!b&&f&&i.length===0?e.jsxs("div",{className:"cedros-admin-accreditation-queue--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading submissions..."})]}):e.jsx("div",{role:"tabpanel",children:i.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No submissions found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Accreditation submissions",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"User"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Method"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Submitted"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"})]}),i.map(B=>e.jsx($l,{item:B,isExpanded:N===B.id,detail:N===B.id?v:null,detailLoading:N===B.id&&S,detailError:N===B.id?p:null,reviewNotes:x,rejectionReason:L,isReviewing:P,reviewError:N===B.id?R:null,onRowClick:q,onDocumentDownload:U,onReviewNotesChange:j,onRejectionReasonChange:C,onReview:F},B.id))]}),V>1&&e.jsxs("div",{className:"cedros-admin-pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(Math.max(0,m-ds)),disabled:Y<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",Y," of ",V," (",l," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(m+ds),disabled:Y>=V,children:"Next"})]})]})})]})}function Gl(s){return s===void 0?"—":s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m ${s%60}s`:`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`}function Ql(s){return s?new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function Vo({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Ie.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState(null),[i,d]=c.useState(!1),[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,w]=c.useState(null),[b,g]=c.useState(!1),N=c.useCallback(async()=>{d(!0),h(null);try{const v=await o.getSanctionsStats();a(v)}catch(v){h(v instanceof Error?v.message:"Failed to load sanctions stats")}finally{d(!1)}},[o]);c.useEffect(()=>{N()},[N]);const A=c.useCallback(async()=>{u(!0),w(null),g(!1);try{await o.refreshSanctions(),g(!0),await N()}catch(v){w(v instanceof Error?v.message:"Failed to refresh sanctions cache")}finally{u(!1)}},[o,N]);return i&&!n?e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s} cedros-admin-sanctions-panel--loading`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading sanctions stats..."})]}):l&&!n?e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s} cedros-admin-sanctions-panel--error`,children:[e.jsx("p",{className:"cedros-admin-error",children:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:N,children:"Retry"})]}):e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s}`,children:[e.jsxs("div",{className:"cedros-admin-sanctions-panel__header",children:[e.jsx("h2",{className:"cedros-admin-sanctions-panel__title",children:"Sanctions Screening"}),e.jsxs("div",{className:"cedros-admin-sanctions-panel__header-actions",children:[n!==null&&e.jsx("span",{className:`cedros-admin-badge ${n.configured?"cedros-admin-badge--approved":"cedros-admin-badge--pending"}`,title:n.configured?"Sanctions API configured":"Sanctions API not configured",children:n.configured?"Configured":"Not Configured"}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:N,disabled:i,title:"Refresh stats","aria-label":"Refresh stats",children:i?"...":"↻"})]})]}),n!==null&&e.jsxs("div",{className:"cedros-admin-sanctions-panel__stats",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Sanctioned Addresses"}),e.jsx("span",{className:"cedros-admin-stat-value",children:n.sanctionedAddresses.toLocaleString()})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Sanctioned Countries"}),e.jsx("span",{className:"cedros-admin-stat-value",children:n.sanctionedCountries.toLocaleString()})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Cache Age"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Gl(n.cacheAgeSeconds)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Last Refresh"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ql(n.lastRefreshedAt)})]})]}),e.jsx("div",{className:"cedros-admin-sanctions-panel__actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:A,disabled:m||i,"aria-busy":m,children:m?"Refreshing...":"Force Refresh"})}),b&&e.jsx("div",{className:"cedros-admin-sanctions-panel__result cedros-admin-sanctions-panel__result--success",children:"Sanctions cache refreshed successfully."}),f&&e.jsx("div",{className:"cedros-admin-sanctions-panel__result cedros-admin-sanctions-panel__result--error",children:f}),l&&n&&e.jsx("p",{className:"cedros-admin-error cedros-admin-error--inline",children:l})]})}class Kl{client;constructor(t,r,o){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o})}async getStatus(){try{return await this.client.get("/setup/status")}catch(t){throw M.handleApiError(t,"Failed to check setup status")}}async createFirstAdmin(t){try{return await this.client.post("/setup/admin",t)}catch(r){throw M.handleApiError(r,"Failed to create admin account")}}}function or(){const{config:s}=M.useCedrosLogin(),[t,r]=c.useState(null),[o,n]=c.useState(!1),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useRef(0),m=c.useMemo(()=>new Kl(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),u=c.useRef(m);u.current=m;const f=c.useCallback(async()=>{n(!0),l(null);const b=++h.current;try{const g=await u.current.getStatus();if(b!==h.current)return;r(g)}catch(g){if(b!==h.current)return;l(g instanceof Error?g:new Error("Failed to check setup status"))}finally{b===h.current&&n(!1)}},[]),w=c.useCallback(async b=>{i(!0),l(null);try{const g=await u.current.createFirstAdmin(b);return await f(),g}catch(g){const N=g instanceof Error?g:new Error("Failed to create admin");throw l(N),N}finally{i(!1)}},[f]);return{status:t,isLoading:o,isCreating:a,error:d,checkStatus:f,createAdmin:w}}const Yl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Kr=8;function Zl(s){const t={};return s.email?Yl.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<Kr&&(t.password=`Password must be at least ${Kr} characters`):t.password="Password is required",s.confirmPassword?s.password!==s.confirmPassword&&(t.confirmPassword="Passwords do not match"):t.confirmPassword="Please confirm your password",t}function Ho({onComplete:s,className:t=""}){const{status:r,isLoading:o,isCreating:n,error:a,checkStatus:i,createAdmin:d}=or(),[l,h]=c.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[m,u]=c.useState({}),[f,w]=c.useState(!1);c.useEffect(()=>{i()},[i]);const b=c.useCallback(N=>A=>{h(v=>({...v,[N]:A.target.value})),u(v=>({...v,[N]:void 0}))},[]),g=c.useCallback(async N=>{N.preventDefault();const A=Zl(l);if(Object.keys(A).length>0){u(A);return}try{await d({email:l.email,password:l.password,name:l.name||void 0,orgName:l.orgName||void 0}),w(!0),s?.()}catch{}},[l,d,s]);return o?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):r&&!r.needsSetup?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):f?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:g,children:[a&&e.jsx(te.ErrorMessage,{error:a.message}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-email",className:"cedros-setup__label",children:["Email Address ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-email",type:"email",className:`cedros-setup__input ${m.email?"cedros-setup__input--error":""}`,value:l.email,onChange:b("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:n}),m.email&&e.jsx("span",{className:"cedros-setup__error",children:m.email})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-name",className:"cedros-setup__label",children:"Display Name"}),e.jsx("input",{id:"setup-name",type:"text",className:"cedros-setup__input",value:l.name,onChange:b("name"),placeholder:"Admin",autoComplete:"name",disabled:n})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:l.orgName,onChange:b("orgName"),placeholder:"My Organization",disabled:n})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${m.password?"cedros-setup__input--error":""}`,value:l.password,onChange:b("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:n}),m.password&&e.jsx("span",{className:"cedros-setup__error",children:m.password})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-confirm-password",className:"cedros-setup__label",children:["Confirm Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-confirm-password",type:"password",className:`cedros-setup__input ${m.confirmPassword?"cedros-setup__input--error":""}`,value:l.confirmPassword,onChange:b("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:n}),m.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:m.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Creating Account..."})]}):"Create Admin Account"})]}),e.jsxs("div",{className:"cedros-setup__footer",children:[e.jsx("p",{className:"cedros-setup__note",children:"This will be the first administrator account for your installation."}),r?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",r.serverVersion]})]})]})})}function Xl({title:s="Dashboard",sections:t=["users","team","referrals","deposits","withdrawals","compliance","accreditation-queue","sanctions","signup-gating","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-compliance","settings-referrals","settings-signup","settings-server","settings-images"],defaultSection:r="users",refreshInterval:o=0,pageSize:n=20,onSectionChange:a,onSettingsClick:i,onLogoutClick:d,className:l=""}){const[h,m]=c.useState(r),[u,f]=c.useState(!0),{user:w,logout:b}=M.useCedrosLogin(),{activeOrg:g,role:N,isLoading:A,fetchOrgs:v,hasPermission:k}=Qt.useOrgs(),{status:S,isLoading:E,checkStatus:p}=or(),{features:y,isLoading:x}=es.useServerFeatures(),{canAccess:j}=fe.useDashboardPermissions(),L=c.useCallback(T=>{m(T),a?.(T)},[a]),C=ml.filter(T=>!(!t.includes(T.id)||T.requiredFeature&&!y[T.requiredFeature]||!j(T.id))),P=C.find(T=>T.id===h),_=!P&&!x;return c.useEffect(()=>{v(),p()},[v,p]),c.useEffect(()=>{_&&C.length>0&&m("users")},[_,C.length]),!E&&S?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${l}`,children:e.jsx(Ho,{onComplete:()=>p()})}):(A||E||x)&&!g?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${l}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):h==="team"&&!g?e.jsx("div",{className:`cedros-admin cedros-dashboard ${l}`,children:e.jsx(te.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${l}`,children:[e.jsxs("aside",{className:"cedros-dashboard__sidebar",children:[e.jsx("div",{className:"cedros-dashboard__sidebar-header",children:e.jsxs("div",{className:"cedros-dashboard__logo",children:[ne.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:s})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),C.filter(T=>!T.group).map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${h===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(T.id),"aria-current":h===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]}),C.some(T=>T.group==="Configuration")&&e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsxs("button",{type:"button",className:"cedros-dashboard__nav-label cedros-dashboard__nav-label--collapsible",onClick:()=>f(!u),"aria-expanded":u,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${u?"cedros-dashboard__nav-chevron--expanded":""}`,children:ne.chevronRight})]}),u&&C.filter(T=>T.group==="Configuration").map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${h===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>L(T.id),"aria-current":h===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]})]}),w&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(Be.ProfileDropdown,{name:w.name,email:w.email,picture:w.picture,onSettings:i,onLogout:d??b})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:s}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:ne.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:P?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[h==="users"&&e.jsx(xl,{pageSize:n,currentUserId:w?.id}),h==="team"&&g&&e.jsx(yl,{orgId:g.id,currentUserId:w?.id,hasPermission:k,role:N}),h==="referrals"&&e.jsx(jl,{}),h==="deposits"&&e.jsx(vl,{pageSize:n,refreshInterval:o}),h==="withdrawals"&&e.jsx(Al,{pageSize:n,refreshInterval:o}),h==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Rn.AuthenticationSettings,{})}),h==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Tn.EmbeddedWalletSettings,{})}),h==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Sl,{})}),h==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Kt.CreditSystemSettings,{})}),h==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Mn.ServerSettings,{})}),h==="settings-images"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Cl,{})}),h==="compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(zo,{})}),h==="accreditation-queue"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx($o,{})}),h==="sanctions"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Vo,{})}),h==="settings-compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Fo,{})}),h==="settings-referrals"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Oo,{})}),h==="signup-gating"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(qo,{})}),h==="settings-signup"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Wo,{})})]})]})]})}var Ye={},lt,Yr;function Jl(){return Yr||(Yr=1,lt=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),lt}var dt={},Te={},Zr;function qe(){if(Zr)return Te;Zr=1;let s;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Te.getSymbolSize=function(o){if(!o)throw new Error('"version" cannot be null or undefined');if(o<1||o>40)throw new Error('"version" should be in range from 1 to 40');return o*4+17},Te.getSymbolTotalCodewords=function(o){return t[o]},Te.getBCHDigit=function(r){let o=0;for(;r!==0;)o++,r>>>=1;return o},Te.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');s=o},Te.isKanjiModeEnabled=function(){return typeof s<"u"},Te.toSJIS=function(o){return s(o)},Te}var ut={},Xr;function ar(){return Xr||(Xr=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+r)}}s.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},s.from=function(o,n){if(s.isValid(o))return o;try{return t(o)}catch{return n}}})(ut)),ut}var ht,Jr;function ed(){if(Jr)return ht;Jr=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const r=Math.floor(t/8);return(this.buffer[r]>>>7-t%8&1)===1},put:function(t,r){for(let o=0;o<r;o++)this.putBit((t>>>r-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},ht=s,ht}var mt,en;function sd(){if(en)return mt;en=1;function s(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return s.prototype.set=function(t,r,o,n){const a=t*this.size+r;this.data[a]=o,n&&(this.reservedBit[a]=!0)},s.prototype.get=function(t,r){return this.data[t*this.size+r]},s.prototype.xor=function(t,r,o){this.data[t*this.size+r]^=o},s.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},mt=s,mt}var pt={},sn;function td(){return sn||(sn=1,(function(s){const t=qe().getSymbolSize;s.getRowColCoords=function(o){if(o===1)return[];const n=Math.floor(o/7)+2,a=t(o),i=a===145?26:Math.ceil((a-13)/(2*n-2))*2,d=[a-7];for(let l=1;l<n-1;l++)d[l]=d[l-1]-i;return d.push(6),d.reverse()},s.getPositions=function(o){const n=[],a=s.getRowColCoords(o),i=a.length;for(let d=0;d<i;d++)for(let l=0;l<i;l++)d===0&&l===0||d===0&&l===i-1||d===i-1&&l===0||n.push([a[d],a[l]]);return n}})(pt)),pt}var ft={},tn;function rd(){if(tn)return ft;tn=1;const s=qe().getSymbolSize,t=7;return ft.getPositions=function(o){const n=s(o);return[[0,0],[n-t,0],[0,n-t]]},ft}var gt={},rn;function nd(){return rn||(rn=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};s.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},s.from=function(n){return s.isValid(n)?parseInt(n,10):void 0},s.getPenaltyN1=function(n){const a=n.size;let i=0,d=0,l=0,h=null,m=null;for(let u=0;u<a;u++){d=l=0,h=m=null;for(let f=0;f<a;f++){let w=n.get(u,f);w===h?d++:(d>=5&&(i+=t.N1+(d-5)),h=w,d=1),w=n.get(f,u),w===m?l++:(l>=5&&(i+=t.N1+(l-5)),m=w,l=1)}d>=5&&(i+=t.N1+(d-5)),l>=5&&(i+=t.N1+(l-5))}return i},s.getPenaltyN2=function(n){const a=n.size;let i=0;for(let d=0;d<a-1;d++)for(let l=0;l<a-1;l++){const h=n.get(d,l)+n.get(d,l+1)+n.get(d+1,l)+n.get(d+1,l+1);(h===4||h===0)&&i++}return i*t.N2},s.getPenaltyN3=function(n){const a=n.size;let i=0,d=0,l=0;for(let h=0;h<a;h++){d=l=0;for(let m=0;m<a;m++)d=d<<1&2047|n.get(h,m),m>=10&&(d===1488||d===93)&&i++,l=l<<1&2047|n.get(m,h),m>=10&&(l===1488||l===93)&&i++}return i*t.N3},s.getPenaltyN4=function(n){let a=0;const i=n.data.length;for(let l=0;l<i;l++)a+=n.data[l];return Math.abs(Math.ceil(a*100/i/5)-10)*t.N4};function r(o,n,a){switch(o){case s.Patterns.PATTERN000:return(n+a)%2===0;case s.Patterns.PATTERN001:return n%2===0;case s.Patterns.PATTERN010:return a%3===0;case s.Patterns.PATTERN011:return(n+a)%3===0;case s.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(a/3))%2===0;case s.Patterns.PATTERN101:return n*a%2+n*a%3===0;case s.Patterns.PATTERN110:return(n*a%2+n*a%3)%2===0;case s.Patterns.PATTERN111:return(n*a%3+(n+a)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}s.applyMask=function(n,a){const i=a.size;for(let d=0;d<i;d++)for(let l=0;l<i;l++)a.isReserved(l,d)||a.xor(l,d,r(n,l,d))},s.getBestMask=function(n,a){const i=Object.keys(s.Patterns).length;let d=0,l=1/0;for(let h=0;h<i;h++){a(h),s.applyMask(h,n);const m=s.getPenaltyN1(n)+s.getPenaltyN2(n)+s.getPenaltyN3(n)+s.getPenaltyN4(n);s.applyMask(h,n),m<l&&(l=m,d=h)}return d}})(gt)),gt}var xs={},nn;function Go(){if(nn)return xs;nn=1;const s=ar(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return xs.getBlocksCount=function(n,a){switch(a){case s.L:return t[(n-1)*4+0];case s.M:return t[(n-1)*4+1];case s.Q:return t[(n-1)*4+2];case s.H:return t[(n-1)*4+3];default:return}},xs.getTotalCodewordsCount=function(n,a){switch(a){case s.L:return r[(n-1)*4+0];case s.M:return r[(n-1)*4+1];case s.Q:return r[(n-1)*4+2];case s.H:return r[(n-1)*4+3];default:return}},xs}var wt={},us={},on;function od(){if(on)return us;on=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let o=1;for(let n=0;n<255;n++)s[n]=o,t[o]=n,o<<=1,o&256&&(o^=285);for(let n=255;n<512;n++)s[n]=s[n-255]})(),us.log=function(o){if(o<1)throw new Error("log("+o+")");return t[o]},us.exp=function(o){return s[o]},us.mul=function(o,n){return o===0||n===0?0:s[t[o]+t[n]]},us}var an;function ad(){return an||(an=1,(function(s){const t=od();s.mul=function(o,n){const a=new Uint8Array(o.length+n.length-1);for(let i=0;i<o.length;i++)for(let d=0;d<n.length;d++)a[i+d]^=t.mul(o[i],n[d]);return a},s.mod=function(o,n){let a=new Uint8Array(o);for(;a.length-n.length>=0;){const i=a[0];for(let l=0;l<n.length;l++)a[l]^=t.mul(n[l],i);let d=0;for(;d<a.length&&a[d]===0;)d++;a=a.slice(d)}return a},s.generateECPolynomial=function(o){let n=new Uint8Array([1]);for(let a=0;a<o;a++)n=s.mul(n,new Uint8Array([1,t.exp(a)]));return n}})(wt)),wt}var bt,cn;function id(){if(cn)return bt;cn=1;const s=ad();function t(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(o){this.degree=o,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(o.length+this.degree);n.set(o);const a=s.mod(n,this.genPoly),i=this.degree-a.length;if(i>0){const d=new Uint8Array(this.degree);return d.set(a,i),d}return a},bt=t,bt}var xt={},yt={},vt={},ln;function Qo(){return ln||(ln=1,vt.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),vt}var Ae={},dn;function Ko(){if(dn)return Ae;dn=1;const s="[0-9]+",t="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
|
|
2050
|
-
]))+`;
|
|
2051
|
-
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},
|
|
2052
|
-
Suggested mode is: `+t.toString(S));switch(k===t.KANJI&&!d.isKanjiModeEnabled()&&(k=t.BYTE),k){case t.NUMERIC:return new r(A);case t.ALPHANUMERIC:return new o(A);case t.KANJI:return new a(A);case t.BYTE:return new n(A)}}s.fromArray=function(v){return v.reduce(function(k,S){return typeof S=="string"?k.push(N(S,null)):S.data&&k.push(N(S.data,S.mode)),k},[])},s.fromString=function(v,k){const S=u(v,d.isKanjiModeEnabled()),E=b(S),p=
|
|
2049
|
+
`),me=12;function hc(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const r=lo(s,ve).split(" ");if(r.length!==me)throw new Error(`Unexpected word count: expected ${me}, got ${r.length}`);return r}function mc(s){if(s.length!==me)throw new Error(`Invalid word count: expected ${me}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!er(t,ve))throw new Error("Invalid recovery phrase: checksum mismatch");const r=Jt(t,ve);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return U.toShamirShare(r)}function pc(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const r=lo(s,ve).split(" ");if(r.length!==me)throw new Error(`Unexpected word count: expected ${me}, got ${r.length}`);return r}function fc(s){if(s.length!==me)throw new Error(`Invalid word count: expected ${me}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!er(t,ve))throw new Error("Invalid recovery phrase: checksum mismatch");const r=Jt(t,ve);if(r.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${r.length}`);return U.toSeed(r)}function uo(s){if(s.length!==me)return!1;const t=s.join(" ").toLowerCase().trim();return er(t,ve)}function ps(s){return ve.includes(s.toLowerCase().trim())}function gc(s,t=5){const r=s.toLowerCase().trim();return r.length===0?[]:ve.filter(o=>o.startsWith(r)).slice(0,t)}function wc(s){const t=[];for(let r=0;r<s.length;r+=4)t.push(s.slice(r,r+4));return t}function bc(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function xc({className:s="",variant:t="default",size:r="md",children:o,menuItems:n=[],hideSignOut:a=!1}){const{user:i,isAuthenticated:d,isLoading:l,openLoginModal:h,logout:m}=U.useAuth(),[u,f]=c.useState(!1),[g,b]=c.useState(-1),w=c.useRef(null),N=c.useRef(null),A=c.useMemo(()=>[...n,...a?[]:[{label:"Sign out",onClick:m}]],[n,a,m]);c.useEffect(()=>{if(!u)return;const p=x=>{w.current&&!w.current.contains(x.target)&&(f(!1),b(-1))},y=x=>{x.key==="Escape"&&(f(!1),b(-1),N.current?.focus())};return document.addEventListener("mousedown",p),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",y)}},[u]);const v=c.useCallback(p=>{if(!(!u||A.length===0))switch(p.key){case"ArrowDown":p.preventDefault(),b(y=>(y+1)%A.length);break;case"ArrowUp":p.preventDefault(),b(y=>(y-1+A.length)%A.length);break;case"Home":p.preventDefault(),b(0);break;case"End":p.preventDefault(),b(A.length-1);break;case"Enter":case" ":g>=0&&(p.preventDefault(),A[g].onClick(),f(!1),b(-1));break}},[u,g,A]),k=c.useCallback(()=>{A.length!==0&&(f(p=>!p),b(-1))},[A.length]),S={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},E={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(l)return e.jsx("button",{type:"button",className:`cedros-button ${E[t]} ${S[r]} ${s}`,disabled:!0,children:e.jsx(z.LoadingSpinner,{size:"sm"})});if(d&&i){const p=i.name||i.email||"User",y=Ke.sanitizeImageUrl(i.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:w,onKeyDown:v,children:[e.jsxs("button",{ref:N,type:"button",className:`cedros-button cedros-user-button ${S[r]} ${s}`,"aria-haspopup":"menu","aria-expanded":u,"aria-label":`User menu for ${p}`,onClick:k,children:[y?e.jsx("img",{src:y,alt:p,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(p[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:p})]}),u&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[n.map((x,j)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${g===j?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:g===j?0:-1,onClick:()=>{x.onClick(),f(!1)},children:[x.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:x.icon}),x.label]},j)),n.length>0&&!a&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!a&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${g===n.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:g===n.length?0:-1,onClick:()=>{m(),f(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${E[t]} ${S[r]} ${s}`,onClick:h,children:o||"Sign in"})}function Us(){const{config:s}=M.useCedrosLogin(),[t,r]=c.useState(!1),[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:l,getRemainingAttempts:h}=K.useRateLimiter({maxAttempts:3,windowMs:3e5}),m=c.useCallback(async b=>{if(!Fe.validateEmail(b)){const w={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw i(w),w}try{l()}catch(w){const N={code:"RATE_LIMITED",message:w instanceof Error?w.message:"Too many attempts"};throw i(N),N}r(!0),i(null),n(!1);try{await d.post("/forgot-password",{email:b}),n(!0)}catch(w){const N=M.handleApiError(w,"Unable to send the reset email. Please try again.");throw i(N),N}finally{r(!1)}},[d,l]),u=c.useCallback(async(b,w)=>{r(!0),i(null),n(!1);try{await d.post("/reset-password",{token:b,newPassword:w}),n(!0)}catch(N){const A=M.handleApiError(N,"Unable to reset your password. Please try again.");throw i(A),A}finally{r(!1)}},[d]),f=c.useCallback(()=>i(null),[]),g=c.useCallback(()=>{i(null),n(!1),r(!1)},[]);return{forgotPassword:m,resetPassword:u,isLoading:t,isSuccess:o,error:a,clearError:f,reset:g,remainingAttempts:h()}}function yc(s){return typeof s=="object"&&s!==null&&"mfaRequired"in s&&s.mfaRequired===!0}function ho(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(!1),[i,d]=c.useState(null),l=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:h,getRemainingAttempts:m}=K.useRateLimiter({maxAttempts:3,windowMs:3e5}),u=c.useCallback(async w=>{if(!Fe.validateEmail(w)){const N={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw d(N),N}try{h()}catch(N){const A={code:"RATE_LIMITED",message:N instanceof Error?N.message:"Too many attempts"};throw d(A),A}o(!0),d(null),a(!1);try{await l.post("/instant-link",{email:w,referral:t?.getReferralCode?.()??void 0}),a(!0)}catch(N){const A=M.handleApiError(N,"Unable to send the sign-in link. Please try again.");throw d(A),A}finally{o(!1)}},[l,h]),f=c.useCallback(async w=>{if(!w||w.trim().length===0){const N={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw d(N),N}o(!0),d(null),a(!1);try{const N=await l.post("/instant-link/verify",{token:w});return yc(N)||(s.callbacks?.onLoginSuccess?.(N.user,"email"),t?.handleLoginSuccess(N.user,N.tokens)),N}catch(N){const A=M.handleApiError(N,"Unable to verify the sign-in link. Please try again.");throw d(A),A}finally{o(!1)}},[l,s.callbacks,t]),g=c.useCallback(()=>d(null),[]),b=c.useCallback(()=>{d(null),a(!1),o(!1)},[]);return{sendInstantLink:u,verifyInstantLink:f,isLoading:r,isSuccess:n,error:i,clearError:g,reset:b,remainingAttempts:m()}}const vc={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:s=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:s}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:s=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:s}),". Click the link to sign in."]})}};function mo({mode:s="reset",onSuccess:t,onCancel:r,className:o=""}){const[n,a]=c.useState(""),i=Us(),d=ho(),l=c.useId(),h=s==="instantLink"?{submit:d.sendInstantLink,isLoading:d.isLoading,isSuccess:d.isSuccess,error:d.error,clearError:d.clearError}:{submit:i.forgotPassword,isLoading:i.isLoading,isSuccess:i.isSuccess,error:i.error,clearError:i.clearError},m=vc[s],u=async f=>{f.preventDefault();try{await h.submit(n),t?.()}catch{}};return h.isSuccess?e.jsxs("div",{className:`cedros-forgot-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Check your email"}),e.jsx("p",{className:"cedros-success-message",children:m.successMessage(n)}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:r,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:u,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Forgot password?"}),e.jsx("p",{className:"cedros-form-subtitle",children:m.subtitle})]}),e.jsx(Z.ErrorMessage,{error:h.error,onDismiss:h.clearError}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:l,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:l,type:"email",className:"cedros-input",value:n,onChange:f=>a(f.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:h.isLoading})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:h.isLoading||!n,children:h.isLoading?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),"Sending..."]}):m.button}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:r,disabled:h.isLoading,children:"Back to login"})]})]})}const Ac={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t})}):(this.loading=!0,new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t});const r=document.getElementById("apple-signin-script");if(r){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]):r.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]});return}const o=document.createElement("script");o.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",o.async=!0,o.defer=!0,o.id="apple-signin-script",o.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(n=>n.resolve()),this.callbacks=[]},o.onerror=()=>{this.loading=!1,o.remove();const n=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(a=>a.reject(n)),this.callbacks=[]},document.head.appendChild(o)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function po(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(!1),[i,d]=c.useState(null),[l,h]=c.useState(null),m=c.useRef(s),u=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);c.useEffect(()=>{m.current=s},[s]),c.useEffect(()=>{if(!s.appleClientId)return;let w=!0;const N=()=>{if(w)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),w&&a(!0)}catch{w&&d({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return Ac.load().then(()=>{w&&N()}).catch(()=>{w&&d({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{w=!1}},[s.appleClientId]);const f=c.useCallback(async w=>{if(!s.appleClientId){const A={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw d(A),A}if(!n){const A={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw d(A),A}o(!0),d(null);let N;try{const A=crypto.getRandomValues(new Uint8Array(32)),v=Array.from(A,x=>x.toString(16).padStart(2,"0")).join(""),k=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(v)),S=Array.from(new Uint8Array(k),x=>x.toString(16).padStart(2,"0")).join("");window.AppleID.auth.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0,nonce:S});const E=await window.AppleID.auth.signIn();if(N=E.authorization?.id_token,!N)throw new Error("No ID token received from Apple");const p=E.user?.name?`${E.user.name.firstName||""} ${E.user.name.lastName||""}`.trim():void 0,y=await u.post("/apple",{idToken:N,name:p||void 0,nonce:v,referral:t?.getReferralCode?.()??void 0,access_code:w||void 0});return m.current.callbacks?.onLoginSuccess?.(y.user,"apple"),t?.handleLoginSuccess(y.user,y.tokens),o(!1),y}catch(A){if(A.error==="popup_closed_by_user"){const S={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw d(S),o(!1),S}const k=M.handleApiError(A,"Unable to sign in with Apple. Please try again.");throw k.code==="ACCOUNT_LINK_REQUIRED"&&N&&h(N),d(k),o(!1),k}},[s.appleClientId,n,u,t]),g=c.useCallback(()=>d(null),[]),b=c.useCallback(()=>h(null),[]);return{signIn:f,isLoading:r,isInitialized:n,error:i,clearError:g,pendingLinkIdToken:l,clearPendingLink:b}}function fo(){if(typeof window>"u"||typeof navigator>"u")return!1;const s=navigator.userAgent.toLowerCase(),t=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(s)||t.includes("mac")||/macintosh/.test(s)||t==="macintel"&&navigator.maxTouchPoints>1)}function go({onSuccess:s,onError:t,className:r="",variant:o="default",size:n="md",disabled:a=!1,hideOnNonApple:i=!0,accessCode:d}){const{signIn:l,isLoading:h,isInitialized:m}=po(),[u]=c.useState(()=>fo());if(i&&!u)return null;const f=async()=>{try{await l(d),s?.()}catch(w){const N=w instanceof Error?w:new Error(String(w));t?.(N)}},g={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]} ${g[n]} ${r}`,onClick:f,disabled:a||!m||h,"aria-label":"Sign in with Apple",children:[h?e.jsx(z.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 ae(s,t){if(!s)throw new Error(t)}function jc(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function Ts(s){ae(typeof s=="string"&&s.length>0,"Expected base64url string");const t=jc(s),r=t+"=".repeat((4-t.length%4)%4),o=atob(r),n=new Uint8Array(o.length);for(let a=0;a<o.length;a++)n[a]=o.charCodeAt(a);return n.buffer}function Ve(s){const t=new Uint8Array(s);let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function wo(s){ae(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return ae(typeof t.type=="string","Invalid credential descriptor type"),ae(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:Ts(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function tt(s){ae(s&&typeof s=="object","Missing creation options");const t=s.publicKey;ae(t&&typeof t=="object","Missing creation options.publicKey"),ae(typeof t.challenge=="string","Missing creation challenge"),ae(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),ae(typeof t.user=="object"&&t.user!==null,"Missing user");const r=t.rp,o=t.user;ae(typeof r.name=="string","Missing rp.name"),ae(typeof o.id=="string","Missing user.id"),ae(typeof o.name=="string","Missing user.name"),ae(typeof o.displayName=="string","Missing user.displayName");const n=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(wo):void 0,a=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(d=>({type:d.type,alg:d.alg})):[],i={challenge:Ts(t.challenge),rp:{name:r.name,id:typeof r.id=="string"?r.id:void 0},user:{id:Ts(o.id),name:o.name,displayName:o.displayName},pubKeyCredParams:a,timeout:typeof t.timeout=="number"?t.timeout:void 0,attestation:typeof t.attestation=="string"?t.attestation:void 0,authenticatorSelection:typeof t.authenticatorSelection=="object"&&t.authenticatorSelection!==null?t.authenticatorSelection:void 0,excludeCredentials:n,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return i.hints=["client-device"],i}function Ur(s){ae(s&&typeof s=="object","Missing request options");const t=s.publicKey;ae(t&&typeof t=="object","Missing request options.publicKey"),ae(typeof t.challenge=="string","Missing request challenge");const r=Array.isArray(t.allowCredentials)?t.allowCredentials.map(wo):void 0,o={challenge:Ts(t.challenge),rpId:typeof t.rpId=="string"?t.rpId:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,userVerification:typeof t.userVerification=="string"?t.userVerification:void 0,allowCredentials:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return o.hints=["client-device"],o}function ss(s){const t=Ve(s.rawId),r=s.response,n={...{clientDataJSON:Ve(r.clientDataJSON)}};if("attestationObject"in r){const a=r;if(n.attestationObject=Ve(a.attestationObject),typeof a.getTransports=="function")try{n.transports=a.getTransports()}catch{}}if("authenticatorData"in r){const a=r;n.authenticatorData=Ve(a.authenticatorData),n.signature=Ve(a.signature),a.userHandle&&(n.userHandle=Ve(a.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:n}}function Nc(){if(typeof window<"u"){const s=window.location?.hostname,t=s==="localhost"||s==="127.0.0.1"||s?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!t)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function kc(s){return typeof s=="object"&&s!==null&&"code"in s&&"message"in s&&typeof s.code=="string"&&typeof s.message=="string"}function ts(s){if(!(s instanceof Error))return null;const t=s.name;return t==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:t==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:t==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function sr(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),d=c.useCallback(()=>a(null),[]),l=Nc(),h=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/auth/options",{email:N?.email}),v=Ur(A.options),k=await navigator.credentials.get({publicKey:v});if(!k)throw new Error("Passkey authentication returned no credential");const S=await i.post("/webauthn/auth/verify",{challengeId:A.challengeId,credential:ss(k)});return s.callbacks?.onLoginSuccess?.(S.user,"webauthn"),t?.handleLoginSuccess(S.user,S.tokens),S}catch(A){const k=ts(A)??M.handleApiError(A,"Unable to sign in with passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,s.callbacks,t,l]),m=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/register/options",{}),v=tt(A.options),k=await navigator.credentials.create({publicKey:v});if(!k)throw new Error("Passkey registration returned no credential");const S=await i.post("/webauthn/register/verify",{challengeId:A.challengeId,credential:ss(k),label:N?.label});if(!S.success)throw new Error("Passkey registration failed");return{credentialId:S.credentialId,label:S.label}}catch(A){const k=ts(A)??M.handleApiError(A,"Unable to register passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,l]),u=c.useCallback(async N=>{if(!l){const A={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(A),A}o(!0),a(null);try{const A=await i.post("/webauthn/signup/options",{}),v=tt(A.options),k=await navigator.credentials.create({publicKey:v});if(!k)throw new Error("Passkey signup returned no credential");const S=await i.post("/webauthn/signup/verify",{challengeId:A.challengeId,credential:ss(k),email:N?.email,name:N?.name,label:N?.label,referral:t?.getReferralCode?.()??void 0,access_code:N?.accessCode||void 0});return s.callbacks?.onLoginSuccess?.(S.user,"webauthn"),t?.handleLoginSuccess(S.user,S.tokens),S}catch(A){const k=ts(A)??M.handleApiError(A,"Unable to sign up with passkey. Please try again.");throw a(k),k}finally{o(!1)}},[i,s.callbacks,t,l]),f=c.useCallback(async N=>{if(!l){const k={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(k),k}o(!0),a(null);const A=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",v=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return A?g(v,N):b(v,N)},[i,s.callbacks,t,l]),g=c.useCallback(async(N,A)=>{try{const v=await i.post("/webauthn/auth/options",{}),k=Ur(v.options),S=await navigator.credentials.get({publicKey:k});if(!S)throw new Error("Passkey authentication returned no credential");const E=await i.post("/webauthn/auth/verify",{challengeId:v.challengeId,credential:ss(S)});return s.callbacks?.onLoginSuccess?.(E.user,"webauthn"),t?.handleLoginSuccess(E.user,E.tokens),N(),E}catch(v){if(v instanceof Error&&(v.name==="NotAllowedError"||v.name==="InvalidStateError"))return w(N,A);if(typeof v=="object"&&v!==null&&"isApiError"in v&&v.data?.code==="INVALID_CREDENTIALS"){const y={code:"INVALID_CREDENTIALS",message:"This passkey is not recognized. Please remove old passkeys for this site and try again, or sign in another way."};throw a(y),y}const p=ts(v)??M.handleApiError(v,"Unable to sign in with passkey. Please try again.");throw a(p),p}finally{o(!1)}},[i,s.callbacks,t]),b=c.useCallback(async(N,A)=>{try{return await w(N,A)}catch(v){if(v instanceof Error&&(v.name==="InvalidStateError"||v.name==="NotAllowedError"))return g(N,A);if(!kc(v)){const E=ts(v)??M.handleApiError(v,"Unable to create passkey. Please try again.");throw a(E),E}throw v}finally{o(!1)}},[i,s.callbacks,t]),w=c.useCallback(async(N,A)=>{const v=await i.post("/webauthn/signup/options",{}),k=tt(v.options),S=await navigator.credentials.create({publicKey:k});if(!S)throw new Error("Passkey signup returned no credential");const E=await i.post("/webauthn/signup/verify",{challengeId:v.challengeId,credential:ss(S),referral:t?.getReferralCode?.()??void 0,access_code:A||void 0});return s.callbacks?.onLoginSuccess?.(E.user,"webauthn"),t?.handleLoginSuccess(E.user,E.tokens),N(),E},[i,s.callbacks,t]);return{isSupported:l,isLoading:r,error:n,clearError:d,continueWithPasskey:f,authenticatePasskey:h,registerPasskey:m,signupWithPasskey:u}}function bo({onSuccess:s,onError:t,className:r="",children:o,disabled:n,accessCode:a}){const{continueWithPasskey:i,isLoading:d,isSupported:l}=sr(),h=n||!l||d;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${r}`,onClick:async()=>{try{await i(a),s?.()}catch(u){t?.(u instanceof Error?u:new Error(String(u)))}},disabled:h,"aria-disabled":h,children:[d?e.jsx(z.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(Sc,{})}),e.jsx("span",{children:o??"Continue with Passkey"})]})}function Sc(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}const rs=["login","register"];function Fs({onSuccess:s,className:t="",defaultTab:r="login"}){const{config:o,socialButtonOrder:n}=M.useCedrosLogin(),{features:a}=Ke.useServerFeatures(),[i,d]=c.useState(r),[l,h]=c.useState("form"),[m,u]=c.useState(()=>Ge.detectSolanaWallets()),[f]=c.useState(()=>fo()),[g,b]=c.useState(""),[w,N]=c.useState(null),A=a?.signupAccessCodeRequired??!1,v=c.useCallback(P=>{N(P.message)},[]);c.useEffect(()=>{const P=()=>u(Ge.detectSolanaWallets());return P(),window.addEventListener("load",P),window.addEventListener("focus",P),()=>{window.removeEventListener("load",P),window.removeEventListener("focus",P)}},[]);const k=o.forms?.forgotPassword?.mode??(o.features?.instantLink?"instantLink":"reset"),S=c.useCallback(P=>{const L=rs.indexOf(i);let R=L;switch(P.key){case"ArrowLeft":case"ArrowUp":R=L===0?rs.length-1:L-1;break;case"ArrowRight":case"ArrowDown":R=L===rs.length-1?0:L+1;break;case"Home":R=0;break;case"End":R=rs.length-1;break;default:return}P.preventDefault();const T=rs[R];d(T),document.getElementById(`cedros-tab-${T}`)?.focus()},[i]),E=o.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},p=E.email!==!1,y=E.google!==!1&&o.googleClientId,x=E.apple!==!1&&o.appleClientId&&f,j=E.solana!==!1&&m,_=E.webauthn!==!1,C=p&&(y||x||j||_);return l==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx(mo,{mode:k,onCancel:()=>h("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[A&&e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:"login-form-access-code",className:"cedros-label",children:"Access Code"}),e.jsx("input",{id:"login-form-access-code",type:"text",className:"cedros-input",value:g,onChange:P=>b(P.target.value),placeholder:"Enter access code","aria-required":"true",autoComplete:"off"})]}),w&&e.jsx(Z.ErrorMessage,{error:w,onDismiss:()=>N(null)}),(_||y||x||j)&&(()=>{const P={webauthn:_?e.jsx(bo,{onSuccess:s,onError:v,accessCode:g||void 0}):null,google:y?e.jsx(zt.GoogleLoginButton,{onSuccess:s,onError:v,accessCode:g||void 0}):null,apple:x?e.jsx(go,{onSuccess:s,onError:v,accessCode:g||void 0}):null,solana:j?e.jsx(Ge.SolanaLoginButton,{onSuccess:s,onError:v,accessCode:g||void 0}):null},L=n??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:L.map(R=>{const T=P[R];return T?e.jsx(c.Fragment,{children:T},R):null})})})(),C&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),p&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-tabs",role:"tablist","aria-label":"Authentication method",children:[e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-login",className:`cedros-tab ${i==="login"?"cedros-tab-active":""}`,onClick:()=>d("login"),onKeyDown:S,"aria-selected":i==="login","aria-controls":"cedros-tabpanel-login",tabIndex:i==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${i==="register"?"cedros-tab-active":""}`,onClick:()=>d("register"),onKeyDown:S,"aria-selected":i==="register","aria-controls":"cedros-tabpanel-register",tabIndex:i==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${i}`,"aria-labelledby":`cedros-tab-${i}`,children:i==="login"?e.jsx(K.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>d("register"),onForgotPassword:()=>h("forgotPassword")}):e.jsx(K.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>d("login"),accessCode:A?g:void 0})})]})]})}class xo extends c.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,r){this.setState({errorInfo:r}),console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",r.componentStack),this.props.onError?.(t,r)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:r,errorInfo:o}=this.state,{children:n,fallback:a,showDetails:i=!1}=this.props;return t?a||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),i&&r&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[r.toString(),o?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):n}}function Cc({className:s="",title:t="Sign in to your account"}){const{isModalOpen:r,closeModal:o}=M.useCedrosLogin(),n=c.useRef(null),a=c.useRef(null),i=c.useRef(o);if(c.useEffect(()=>{i.current=o},[o]),c.useEffect(()=>{if(!r)return;a.current=document.activeElement,n.current?.focus();const l=m=>{if(m.key==="Escape"&&i.current(),m.key==="Tab"&&n.current){const u=n.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),f=u[0],g=u[u.length-1];m.shiftKey&&document.activeElement===f?(m.preventDefault(),g?.focus()):!m.shiftKey&&document.activeElement===g&&(m.preventDefault(),f?.focus())}};document.addEventListener("keydown",l);const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",l),document.body.style.overflow=h,a.current instanceof HTMLElement&&a.current.focus()}},[r]),!r)return null;const d=l=>{l.target===l.currentTarget&&o()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,onClick:d,role:"presentation",children:e.jsxs("div",{ref:n,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:t}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:o,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(xo,{children:e.jsx(Fs,{onSuccess:o})})})]})})}function Ec({token:s,onSuccess:t,onLoginClick:r,className:o=""}){const[n,a]=c.useState(""),[i,d]=c.useState(""),[l,h]=c.useState(null),{resetPassword:m,isLoading:u,isSuccess:f,error:g,clearError:b}=Us(),w=n===i,N=l?.isValid&&w&&n.length>0,A=async v=>{if(v.preventDefault(),!!N)try{await m(s,n),t?.()}catch{}};return f?e.jsxs("div",{className:`cedros-reset-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:r,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${o}`,onSubmit:A,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Reset your password"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your new password below."})]}),e.jsx(Z.ErrorMessage,{error:g,onDismiss:b}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(K.PasswordInput,{label:"New password",value:n,onChange:v=>{a(v.target.value),h(Fe.validatePassword(v.target.value))},showStrengthMeter:!0,onValidationChange:h,disabled:u,autoComplete:"new-password",error:l&&!l.isValid?Object.values(l.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(K.PasswordInput,{label:"Confirm password",value:i,onChange:v=>d(v.target.value),disabled:u,autoComplete:"new-password",error:i&&!w?"Passwords do not match":void 0})}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:u||!N,children:u?e.jsxs(e.Fragment,{children:[e.jsx(z.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 Ot({org:s,size:t="lg",className:r=""}){const o=Ke.sanitizeImageUrl(s.logoUrl),n=t==="lg"?"cedros-org-avatar-lg":"",a=["cedros-org-avatar",n,r].filter(Boolean).join(" "),i=["cedros-org-avatar-placeholder",n,r].filter(Boolean).join(" ");return o?e.jsx("img",{src:o,alt:s.name,className:a,referrerPolicy:"no-referrer"}):e.jsx("div",{className:i,children:s.name[0]?.toUpperCase()||"?"})}function _c({orgs:s,activeOrg:t,isLoading:r=!1,onSelect:o,onCreateClick:n,className:a="",placeholder:i="Select organization"}){const[d,l]=c.useState(!1),h=c.useRef(null);c.useEffect(()=>{const g=b=>{h.current&&!h.current.contains(b.target)&&l(!1)};return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[]),c.useEffect(()=>{const g=b=>{b.key==="Escape"&&l(!1)};if(d)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[d]);const m=c.useCallback(g=>{o(g),l(!1)},[o]),u=c.useCallback(()=>{l(!1),n?.()},[n]),f=c.useCallback(()=>{l(g=>!g)},[]);return r?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${a}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:h,className:`cedros-org-selector ${a}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:f,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs(e.Fragment,{children:[e.jsx(Ot,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(Fr,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:i}),e.jsx(Lc,{isOpen:d})]}),d&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[s.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:s.map(g=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${g.id===t?.id?"cedros-org-selector-item-active":""}`,onClick:()=>m(g.id),role:"option","aria-selected":g.id===t?.id,children:[e.jsx(Ot,{org:g,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:g.name}),e.jsx(Fr,{role:g.membership.role}),g.id===t?.id&&e.jsx(Pc,{})]})},g.id))}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:u,children:[e.jsx(Rc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function Fr({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function Lc({isOpen:s}){return e.jsx("svg",{className:`cedros-org-chevron ${s?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Pc(){return e.jsx("svg",{className:"cedros-org-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Rc(){return e.jsx("svg",{className:"cedros-org-plus",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 3V13M3 8H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Tc(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Mc(){return e.jsx("svg",{className:"cedros-org-check",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 10L8 14L16 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Bc(){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 Ic({orgs:s,activeOrg:t,isLoading:r,onSelect:o,onCreateClick:n}){return r?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[s.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:s.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${a.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>o(a.id),children:[e.jsx(Ot,{org:a}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:a.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",a.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${a.membership.role}`,children:a.membership.role}),a.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),a.id===t?.id&&e.jsx(Mc,{})]})},a.id))}),n&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:n,children:[e.jsx(Bc,{}),e.jsx("span",{children:"Create new organization"})]})]})}function Dc({isLoading:s,onSubmit:t,onCancel:r}){const[o,n]=c.useState(""),[a,i]=c.useState(""),[d,l]=c.useState(null),h=c.useCallback(u=>{n(u);const f=u.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);i(f)},[]),m=c.useCallback(async u=>{if(u.preventDefault(),l(null),!o.trim()){l("Organization name is required");return}if(!a.trim()){l("Organization slug is required");return}try{await t({name:o.trim(),slug:a.trim()})}catch(f){l(f.message||"Failed to create organization")}},[o,a,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:m,children:[d&&e.jsx(Z.ErrorMessage,{error:d}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:o,onChange:u=>h(u.target.value),placeholder:"My Organization",maxLength:255,disabled:s,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:a,onChange:u=>i(u.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:s})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:r,disabled:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!o.trim()||!a.trim(),children:s?e.jsx(z.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function Uc({isOpen:s,onClose:t,orgs:r,activeOrg:o,isLoading:n=!1,error:a,onSelect:i,onCreate:d,className:l=""}){return s?e.jsx(Fc,{onClose:t,orgs:r,activeOrg:o,isLoading:n,error:a,onSelect:i,onCreate:d,className:l}):null}function Fc({onClose:s,orgs:t,activeOrg:r,isLoading:o=!1,error:n,onSelect:a,onCreate:i,className:d}){const[l,h]=c.useState("list"),m=c.useRef(null),u=c.useRef(null);c.useEffect(()=>(u.current=document.activeElement,m.current?.querySelector(".cedros-modal-close")?.focus(),()=>{u.current?.focus()}),[]),c.useEffect(()=>{const w=N=>{if(N.key==="Escape"){s();return}if(N.key==="Tab"&&m.current){const A=m.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),v=A[0],k=A[A.length-1];N.shiftKey?document.activeElement===v&&(N.preventDefault(),k?.focus()):document.activeElement===k&&(N.preventDefault(),v?.focus())}};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[s]);const f=c.useCallback(w=>{w.target===w.currentTarget&&s()},[s]),g=c.useCallback(w=>{a(w),s()},[a,s]),b=c.useCallback(async w=>{await i?.(w),s()},[i,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:f,children:e.jsxs("div",{ref:m,className:`cedros-modal cedros-org-switcher ${d}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:l==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(Tc,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[n&&e.jsx(Z.ErrorMessage,{error:n}),l==="list"?e.jsx(Ic,{orgs:t,activeOrg:r,isLoading:o,onSelect:g,onCreateClick:i?()=>h("create"):void 0}):e.jsx(Dc,{isLoading:o,onSubmit:b,onCancel:()=>h("list")})]})]})})}function yo({sessions:s,isLoading:t=!1,error:r,onRevokeAll:o,className:n=""}){const[a,i]=c.useState(!1),[d,l]=c.useState(!1),h=c.useRef(null),m=c.useMemo(()=>s.filter(f=>!f.isCurrent).length,[s]),u=c.useCallback(async()=>{if(!o)return;const f=s.filter(b=>!b.isCurrent).length;if(!(f===0||!window.confirm(`Are you sure you want to sign out of ${f} other device(s)? This will log you out everywhere except this browser.`))){i(!0),l(!1);try{await o(),l(!0),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{l(!1),h.current=null},3e3)}finally{i(!1)}}},[o,s]);return c.useEffect(()=>()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${n}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):r?e.jsx("div",{className:`cedros-session-list ${n}`,children:e.jsx(Z.ErrorMessage,{error:r})}):s.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${n}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${n}`,children:[d&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Vc,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(f=>e.jsx(Wc,{session:f},f.id))}),o&&m>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:u,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${m} other device${m>1?"s":""}`})})]})}function Wc({session:s}){const t=Oc(s.userAgent),r=zc(s.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${s.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx($c,{userAgent:s.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[t.browser," on ",t.os]}),s.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[s.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",s.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",qc(s.createdAt)]}),r&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Oc(s){if(!s)return{browser:"Unknown browser",os:"Unknown device"};let t="Unknown browser";s.includes("Chrome")&&!s.includes("Edg")?t="Chrome":s.includes("Safari")&&!s.includes("Chrome")?t="Safari":s.includes("Firefox")?t="Firefox":s.includes("Edg")&&(t="Edge");let r="Unknown device";return s.includes("Windows")?r="Windows":s.includes("Mac")?r="macOS":s.includes("Linux")?r="Linux":s.includes("iPhone")||s.includes("iPad")?r="iOS":s.includes("Android")&&(r="Android"),{browser:t,os:r}}function qc(s){const t=new Date(s),o=new Date().getTime()-t.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n} minute${n>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:i<7?`${i} day${i>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function zc(s){const t=new Date(s),r=new Date,o=3600*1e3;return t.getTime()-r.getTime()<o}function $c({userAgent:s}){return s?.includes("iPhone")||s?.includes("iPad")||s?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function Vc(){return e.jsx("svg",{className:"cedros-session-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function vo({words:s,onConfirm:t,className:r=""}){const[o,n]=c.useState(!1),[a,i]=c.useState(!1),d=c.useRef(null),l=wc(s),h=c.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),n(!0),d.current!==null&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>n(!1),2e3)}catch{}},[s]);c.useEffect(()=>()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]);const m=c.useCallback(()=>{a&&t()},[a,t]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${r}`,children:[e.jsxs("div",{className:"cedros-recovery-header",children:[e.jsx("h3",{className:"cedros-recovery-title",children:"Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-warning",children:"Write down these 12 words in order and store them securely. This is the only way to recover your wallet if you lose access."})]}),e.jsx("div",{className:"cedros-recovery-grid",children:l.map((u,f)=>e.jsx("div",{className:"cedros-word-group",children:u.map((g,b)=>{const w=f*4+b+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[w,"."]}),e.jsx("span",{className:"cedros-word-text",children:g})]},w)})},f))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:h,children:o?"Copied!":"Copy to Clipboard"}),e.jsx("div",{className:"cedros-recovery-security",children:e.jsxs("div",{className:"cedros-warning-box",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M10 6v4m0 4h.01M19 10a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsxs("div",{className:"cedros-warning-content",children:[e.jsx("strong",{children:"Security Warning"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Never share this phrase with anyone"}),e.jsx("li",{children:"Store it offline in a secure location"}),e.jsx("li",{children:"Anyone with this phrase can access your wallet"}),e.jsx("li",{children:"Cedros cannot recover this phrase for you"})]})]})]})}),e.jsxs("div",{className:"cedros-recovery-confirm",children:[e.jsxs("label",{className:"cedros-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:u=>i(u.target.checked),className:"cedros-checkbox"}),e.jsx("span",{children:"I have written down and securely stored my recovery phrase"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,disabled:!a,children:"Continue"})]})]})}function Ao({onSubmit:s,onCancel:t,isSubmitting:r=!1,error:o,className:n=""}){const[a,i]=c.useState(Array(me).fill("")),[d,l]=c.useState(null),[h,m]=c.useState([]),[u,f]=c.useState(null),g=c.useId(),b=c.useRef(null),w=c.useCallback((p,y)=>{const x=[...a];if(x[p]=y.toLowerCase().trim(),i(x),y.length>0){const j=gc(y,5);m(j)}else m([]);f(null)},[a]),N=c.useCallback(p=>{l(p),m([])},[]),A=c.useCallback(p=>{const y=a[p];y&&!ps(y)&&f(`Word ${p+1} is not in the wordlist`),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{d===p&&m([])},200)},[a,d]);c.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]);const v=c.useCallback(p=>{if(d!==null){const y=[...a];y[d]=p,i(y),m([]),document.querySelector(`[data-word-index="${d+1}"]`)?.focus()}},[d,a]),k=c.useCallback(p=>{const y=p.clipboardData.getData("text"),x=bc(y);x.length===me&&(p.preventDefault(),i(x),f(null))},[]),S=c.useCallback(p=>{if(p.preventDefault(),a.filter(j=>!j).length>0){f(`Please enter all ${me} words`);return}const x=a.map((j,_)=>({word:j,index:_+1})).filter(({word:j})=>!ps(j));if(x.length>0){f(`Invalid words: ${x.map(j=>`#${j.index}`).join(", ")}`);return}if(!uo(a)){f("Invalid recovery phrase - please check your words");return}s(a)},[a,s]),E=o||u;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${n}`,onSubmit:S,onPaste:k,children:[e.jsxs("div",{className:"cedros-recovery-input-header",children:[e.jsx("h3",{className:"cedros-recovery-input-title",children:"Enter Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-input-description",children:"Enter your 12-word recovery phrase. You can paste the entire phrase at once."})]}),e.jsx("div",{className:"cedros-word-inputs",children:Array.from({length:me},(p,y)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[y+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${a[y]&&!ps(a[y])?"cedros-word-invalid":a[y]&&ps(a[y])?"cedros-word-valid":""}`,value:a[y],onChange:x=>w(y,x.target.value),onFocus:()=>N(y),onBlur:()=>A(y),"data-word-index":y,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:r,"aria-label":`Word ${y+1}`})]},y))}),d!==null&&h.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${g}-suggestions`,children:h.map(p=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>v(p),role:"option",children:p},p))}),E&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:E}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:r,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:r,children:r?"Recovering...":"Recover Wallet"})]})]})}function Hc({capabilities:s,className:t=""}){if(s.allSupported)return null;const r=U.getMissingCapabilitiesMessage(s),o=U.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${t}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:r}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",o.browser," ",o.version,o.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:s.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",s.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:s.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",s.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:s.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",s.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",s.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",s.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:s.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",s.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const Gc=["share_c_only","full_seed","none"];function Qc(s){return s&&Gc.includes(s)?s:"share_c_only"}const Kc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function jo(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(null),[o,n]=c.useState(!!s),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),l=c.useCallback(async()=>{if(d){n(!0),i(null);try{const h=await d.get("/discovery");h.wallet?r({enabled:h.wallet.enabled,recoveryMode:Qc(h.wallet.recoveryMode),unlockTtlSeconds:h.wallet.unlockTtlSeconds}):r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(h){const m=h instanceof Error?h.message:"Failed to fetch wallet config";i(m),r({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{n(!1)}}},[d]);return c.useEffect(()=>{d&&l()},[d,l]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:o,error:a,refetch:l}:Kc}function No(){const{user:s}=M.useCedrosLogin(),{enroll:t}=U.useWalletMaterial(),{recoveryMode:r}=jo(),[o,n]=c.useState({step:"idle"}),[a,i]=c.useState(!1),d=c.useRef([]),l=c.useCallback(()=>{U.wipeAll(...d.current),d.current=[]},[]);c.useEffect(()=>()=>{l()},[l]);const h=c.useCallback(async(b,w,N,A)=>{n({step:"generating_seed"});const v=U.generateSeed();d.current.push(v),n({step:"splitting_shares"});const{shareA:k,shareB:S,shareC:E}=to(v);d.current.push(k,S,E),n({step:"encrypting_shares"});const p=await U.aesGcmEncryptToBase64(k,U.toEncryptionKey(w)),y=eo(v),x=so(y);n({step:"uploading"});const j={solanaPubkey:x,shareAAuthMethod:b,shareACiphertext:p.ciphertext,shareANonce:p.nonce,shareB:U.uint8ArrayToBase64(S)};if(b==="password"){if(!N)throw new Error("KDF salt required for password method");j.shareAKdfSalt=U.uint8ArrayToBase64(N),j.shareAKdfParams=U.DEFAULT_KDF_PARAMS}if(b==="passkey"&&A&&(j.prfSalt=A),await t(j),r==="none")l(),n({step:"complete",solanaPubkey:x});else{const _=r==="full_seed"?pc(v):hc(U.toShamirShare(E));n({step:"showing_recovery",recoveryPhrase:_,solanaPubkey:x})}},[t,r,l]),m=c.useCallback(async b=>{if(!s){n({step:"error",error:"User not authenticated"});return}i(!0),l();try{const w=U.generateArgon2Salt(),N=await Rn(b,w,U.DEFAULT_KDF_PARAMS);d.current.push(N),await h("password",N,w)}catch(w){n({step:"error",error:w instanceof Error?w.message:"Enrollment failed"})}finally{i(!1)}},[s,l,h]),u=c.useCallback(async()=>{if(!s){n({step:"error",error:"User not authenticated"});return}i(!0),l();try{const b=U.generatePrfSalt(),w=U.uint8ArrayToBase64(b);n({step:"encrypting_shares"});const A=(await U.authenticateWithDiscoverablePrf(w)).prfOutput;d.current.push(A);const v=await U.deriveKeyFromPrf(A,b);d.current.push(v),await h("passkey",v,void 0,w)}catch(b){n({step:"error",error:b instanceof Error?b.message:"Enrollment failed"})}finally{i(!1)}},[s,l,h]),f=c.useCallback(()=>{const b=o.solanaPubkey;l(),n({step:"complete",solanaPubkey:b})},[o.solanaPubkey,l]),g=c.useCallback(()=>{l(),n({step:"idle"}),i(!1)},[l]);return{state:o,startEnrollmentWithPassword:m,startEnrollmentWithPasskey:u,confirmRecoveryPhrase:f,cancel:g,isEnrolling:a}}function ko(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken]);return{setPassword:c.useCallback(async l=>{o(!0),a(null);try{await i.post("/set-password",{password:l})}catch(h){const m=M.handleApiError(h,"Failed to set password");throw a(m),m}finally{o(!1)}},[i]),isLoading:r,error:n}}function Yc(s){return s.includes("email")?"password":s.includes("webauthn")?"passkey":"set-password"}function So({onComplete:s,onCancel:t,className:r=""}){const{user:o}=M.useCedrosLogin(),{state:n,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:i,confirmRecoveryPhrase:d,cancel:l,isEnrolling:h}=No(),{setPassword:m,isLoading:u}=ko(),f=o?Yc(o.authMethods):"password",[g,b]=c.useState(""),[w,N]=c.useState(""),[A,v]=c.useState(null);c.useEffect(()=>{b(""),N(""),v(null)},[o?.id]);const k=c.useCallback(async j=>{j.preventDefault(),v(null),await a(g)},[g,a]),S=c.useCallback(async j=>{if(j.preventDefault(),g!==w){v("Passwords do not match");return}const _=Fe.validatePassword(g);if(!_.isValid){const C=Object.values(_.errors)[0];v(C??"Password does not meet requirements");return}v(null);try{await m(g),await a(g)}catch{}},[g,w,m,a]),E=c.useCallback(async()=>{await i()},[i]),p=c.useCallback(()=>{d(),n.solanaPubkey&&s?.(n.solanaPubkey)},[d,n.solanaPubkey,s]),y=c.useCallback(()=>{l(),t?.()},[l,t]),x=h||u;return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Generating secure wallet..."})]})}):n.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Encrypting wallet shares..."})]})}):n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Saving wallet..."})]})}):n.step==="showing_recovery"&&n.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsx(vo,{words:n.recoveryPhrase,onConfirm:p})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsxs("div",{className:"cedros-enrollment-complete",children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M16 24l6 6 12-12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{children:"Wallet Created!"}),e.jsxs("p",{className:"cedros-pubkey",children:[e.jsx("strong",{children:"Address:"})," ",n.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${r}`,children:e.jsxs("div",{className:"cedros-enrollment-error",children:[e.jsxs("svg",{className:"cedros-error-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 16v12m0 6h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Enrollment Failed"}),e.jsx("p",{className:"cedros-error-message",children:n.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>l(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${r}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),f==="password"&&e.jsx("p",{children:"Enter your account password to secure your wallet."}),f==="passkey"&&e.jsx("p",{children:"Authenticate with your passkey to secure your wallet."}),f==="set-password"&&e.jsx("p",{children:"Set a password for your account to secure your wallet."})]}),f==="password"&&e.jsxs("form",{onSubmit:k,className:"cedros-enrollment-form",children:[e.jsx(K.PasswordInput,{label:"Account Password",value:g,onChange:j=>b(j.target.value),disabled:x,required:!0,placeholder:"Enter your account password"}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!g,children:x?"Creating...":"Continue"})]})]}),f==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:E,disabled:x,children:x?"Creating...":"Use Passkey"})]})]}),f==="set-password"&&e.jsxs("form",{onSubmit:S,className:"cedros-enrollment-form",children:[e.jsx(K.PasswordInput,{label:"New Password",value:g,onChange:j=>b(j.target.value),showStrengthMeter:!0,disabled:x,required:!0,minLength:8,placeholder:"Choose a strong password"}),e.jsx(K.PasswordInput,{label:"Confirm Password",value:w,onChange:j=>N(j.target.value),error:A??void 0,disabled:x,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will also be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:x,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||!g||!w,children:x?"Creating...":"Continue"})]})]})]})}function Co(){const{user:s}=M.useCedrosLogin(),{signTransaction:t}=U.useWalletMaterial(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useCallback(async(l,h)=>{if(!s){const m="User not authenticated";throw a(m),new Error(m)}o(!0),a(null);try{const m={transaction:U.uint8ArrayToBase64(l),...h?{credential:U.toCredentialRequest(h)}:{}},u=await t(m);return U.base64ToUint8Array(u.signature)}catch(m){const u=m instanceof Error?m.message:"Signing failed";throw a(u),m}finally{o(!1)}},[s,t]),d=c.useCallback(()=>a(null),[]);return{signTransaction:i,isSigning:r,error:n,clearError:d}}function Eo(){const{getMaterial:s}=U.useWalletMaterial(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useCallback(async()=>{r(!0),n(null);try{const d=await s();if(!d)throw new Error("No wallet enrolled");if(d.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!d.prfSalt)throw new Error("No PRF salt configured for wallet");const l=await U.authenticateWithDiscoverablePrf(d.prfSalt);try{return{type:"prfOutput",prfOutput:U.uint8ArrayToBase64(l.prfOutput)}}finally{l.prfOutput.fill(0)}}catch(d){const l=d instanceof Error?d.message:"Passkey authentication failed";return n(l),null}finally{r(!1)}},[s]),i=c.useCallback(()=>n(null),[]);return{getPasskeyCredential:a,isAuthenticating:t,error:o,clearError:i}}function _o({mode:s,isLoading:t=!1,error:r,onPrompt:o,onRetry:n,onCancel:a,title:i,description:d,className:l=""}){const h=c.useCallback(()=>{t||o?.()},[t,o]),m=c.useCallback(()=>{n?.()},[n]),u=s==="register"?"Set Up Passkey":"Verify with Passkey",f=s==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${l}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(Xc,{}):r?e.jsx(Jc,{}):e.jsx(Zc,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:i??u}),e.jsx("p",{className:"cedros-passkey-description",children:d??f}),r&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:r})}),e.jsx("div",{className:"cedros-passkey-actions",children:r?e.jsxs(e.Fragment,{children:[n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,children:"Try Again"}),a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:h,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):s==="register"?"Create Passkey":"Use Passkey"}),a&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]})}),t&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",s==="register"?"create":"verify"," your passkey."]})]})}function Zc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}function Xc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Jc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 8v4M12 16h.01"})]})}function Lo({onUnlock:s,onCancel:t,showCancel:r=!0,authMethod:o,className:n=""}){M.useCedrosLogin();const{unlock:a,getMaterial:i,isLoading:d}=U.useWalletMaterial(),{getPasskeyCredential:l,isAuthenticating:h}=Eo(),[m,u]=c.useState("idle"),[f,g]=c.useState(o??null),[b,w]=c.useState(""),[N,A]=c.useState(null);c.useEffect(()=>{o!==void 0&&g(o)},[o]);const v=f==="password",k=f==="passkey",S=c.useCallback(async()=>{if(u("credential"),A(null),!f)try{const C=await i();C?g(C.shareAAuthMethod):(A("No wallet enrolled"),u("error"))}catch(C){A(C instanceof Error?C.message:"Failed to get wallet info"),u("error")}},[f,i]),E=c.useCallback(async C=>{C.preventDefault(),A(null),u("unlocking");try{let P;if(v)P={type:"password",password:b};else throw new Error("Invalid auth method");await a(P),u("unlocked"),s?.()}catch(P){A(P instanceof Error?P.message:"Failed to unlock wallet"),u("error")}},[v,b,a,s]),p=c.useCallback(async()=>{A(null),u("unlocking");try{const C=await l();if(!C){u("credential");return}await a(C),u("unlocked"),s?.()}catch(C){A(C instanceof Error?C.message:"Failed to unlock wallet"),u("error")}},[l,a,s]),y=c.useCallback(()=>{w(""),u("idle"),A(null),t?.()},[t]),x=c.useCallback(()=>{w(""),u("credential"),A(null)},[]),j=d||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(el,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Locked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Unlock your wallet to sign transactions."}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,children:"Unlock Wallet"})]});case"credential":return v?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:E,children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Enter Password"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Enter your wallet password to unlock."}),e.jsx(K.PasswordInput,{label:"Password",value:b,onChange:C=>w(C.target.value),disabled:j,autoComplete:"current-password",error:N??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:j||b.length===0,children:j?"Unlocking...":"Unlock"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:j,children:"Cancel"})]})]}):k?e.jsxs("div",{className:"cedros-wallet-unlock-passkey",children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Verify with Passkey"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Use your passkey to unlock your wallet."}),e.jsx(_o,{mode:"authenticate",isLoading:j,error:N??void 0,onPrompt:p,onRetry:p,onCancel:r?y:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(z.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(z.LoadingSpinner,{size:"xl"})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlocking Wallet"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Verifying your credentials..."})]});case"unlocked":return e.jsxs("div",{className:"cedros-wallet-unlock-success",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(sl,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Unlocked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Your wallet is ready to sign transactions."})]});case"error":return e.jsxs("div",{className:"cedros-wallet-unlock-error",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(tl,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:N??"Failed to unlock wallet. Please try again."}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Try Again"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${n}`,children:_()})}function el(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"10",y:"22",width:"28",height:"20",rx:"4",stroke:"currentColor",strokeWidth:"2",fill:"var(--cedros-muted, #f3f4f6)"}),e.jsx("path",{d:"M16 22V16a8 8 0 1 1 16 0v6",stroke:"currentColor",strokeWidth:"2",fill:"none"}),e.jsx("circle",{cx:"24",cy:"32",r:"3",fill:"currentColor"})]})}function sl(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function tl(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function Po(){const{recover:s,getShareBForRecovery:t}=U.useWalletMaterial(),{recoveryMode:r}=jo(),[o,n]=c.useState({step:"idle"}),[a,i]=c.useState(!1),d=c.useRef([]),l=c.useCallback(()=>{U.wipeAll(...d.current),d.current=[]},[]);c.useEffect(()=>()=>{l()},[l]);const h=c.useCallback(async(u,f,g)=>{i(!0),l();try{if(n({step:"validating"}),!uo(u))throw new Error("Invalid recovery phrase. Please check your words.");let b;if(r==="share_c_only"){const x=mc(u);d.current.push(x);const j=U.uint8ArrayToBase64(x),_=await t({shareC:j}),C=U.base64ToUint8Array(_.shareB);d.current.push(C),b=Ji(U.toShamirShare(C),U.toShamirShare(x)),d.current.push(b)}else b=fc(u),d.current.push(b);const w=eo(b),N=so(w),{shareA:A,shareB:v}=to(b);d.current.push(A,v),n({step:"encrypting"});let k,S,E;if(f==="passkey"){const x=U.generatePrfSalt();E=U.uint8ArrayToBase64(x);const j=await U.authenticateWithDiscoverablePrf(E);d.current.push(j.prfOutput),k=await U.deriveKeyFromPrf(j.prfOutput,x),d.current.push(k)}else S=U.generateArgon2Salt(),k=await Rn(g,S,U.DEFAULT_KDF_PARAMS),d.current.push(k);const p=await U.aesGcmEncryptToBase64(A,U.toEncryptionKey(k));n({step:"uploading"});const y={solanaPubkey:N,shareAAuthMethod:f,shareACiphertext:p.ciphertext,shareANonce:p.nonce,shareB:U.uint8ArrayToBase64(v)};f==="password"&&(y.shareAKdfSalt=U.uint8ArrayToBase64(S),y.shareAKdfParams=U.DEFAULT_KDF_PARAMS),f==="passkey"&&(y.prfSalt=E),await s(y),l(),n({step:"complete"})}catch(b){l(),n({step:"error",error:b instanceof Error?b.message:"Recovery failed"})}finally{i(!1)}},[s,t,r,l]),m=c.useCallback(()=>{l(),n({step:"idle"}),i(!1)},[l]);return{state:o,startRecovery:h,cancel:m,isRecovering:a}}function Ro({onComplete:s,onCancel:t,className:r="",defaultAuthMethod:o="password"}){const{state:n,startRecovery:a,cancel:i,isRecovering:d}=Po(),[l,h]=c.useState([]),[m,u]=c.useState(!1),[f,g]=c.useState(o),[b,w]=c.useState(""),[N,A]=c.useState(""),[v,k]=c.useState(null),S=c.useCallback(j=>{h(j),u(!0)},[]),E=c.useCallback(async j=>{if(j.preventDefault(),k(null),f!=="passkey"){if(b!==N){k("Passwords do not match");return}if(f==="password"&&b.length<8){k("Password must be at least 8 characters");return}}await a(l,f,b)},[l,f,b,N,a]),p=c.useCallback(()=>{i(),h([]),u(!1),w(""),A(""),t?.()},[i,t]),y=c.useCallback(()=>{u(!1),w(""),A("")},[]),x=c.useCallback(()=>{s?.()},[s]);return n.step==="validating"||n.step==="encrypting"||n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(rl,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[n.step==="validating"&&"Validating Recovery Phrase",n.step==="encrypting"&&"Encrypting Wallet",n.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[n.step==="validating"&&"Checking your recovery phrase...",n.step==="encrypting"&&"Securing your wallet with new encryption...",n.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(nl,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Wallet Recovered"}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:["Your wallet has been successfully recovered and secured with your new"," ",f==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:x,children:"Done"})})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(ol,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:n.error??"An error occurred during recovery. Please try again."}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:p,children:"Start Over"})})]})}):m?e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:E,children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Set New Security"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Choose how to secure your recovered wallet."})]}),e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:f==="password",onChange:()=>g("password"),disabled:d}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:f==="passkey",onChange:()=>g("passkey"),disabled:d}),e.jsx("span",{children:"Passkey"})]})]}),f==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:b,onChange:j=>w(j.target.value),disabled:d,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:N,onChange:j=>A(j.target.value),disabled:d,"aria-invalid":v?"true":void 0,placeholder:"Confirm your password"}),v&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:v})]})]}),f==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(al,{}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-wallet-recovery-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:d,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:d||f!=="passkey"&&(b.length===0||N.length===0),children:d?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${r}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-phrase",children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recover Your Wallet"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Enter your 12-word recovery phrase to restore your wallet."})]}),e.jsx(Ao,{onSubmit:S,onCancel:p,isSubmitting:!1})]})})}function rl(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-muted, #e5e7eb)",strokeWidth:"3",fill:"none"}),e.jsx("path",{d:"M24 4a20 20 0 0 1 20 20",stroke:"var(--cedros-primary, #6366f1)",strokeWidth:"3",strokeLinecap:"round",fill:"none"})]})}function nl(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"2",fill:"var(--cedros-success-light, #dcfce7)"}),e.jsx("path",{d:"M16 24l6 6 10-10",stroke:"var(--cedros-success, #22c55e)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function ol(){return e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"2",fill:"var(--cedros-destructive-light, #fee2e2)"}),e.jsx("path",{d:"M24 16v10M24 30v2",stroke:"var(--cedros-destructive, #ef4444)",strokeWidth:"3",strokeLinecap:"round"})]})}function al(){return e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function To({address:s,label:t="Wallet Address",showCopy:r=!0,showExplorerLink:o=!0,allowReveal:n=!0,className:a=""}){const i=M.useCedrosLoginOptional(),[d,l]=c.useState(!1),[h,m]=c.useState(null),[u,f]=c.useState(!1),g=c.useRef(null),b=i?.config.solana?.network??"mainnet-beta",w=c.useMemo(()=>{const k=`https://explorer.solana.com/address/${s}`;return b==="mainnet-beta"?k:`${k}?cluster=${encodeURIComponent(b)}`},[s,b]),N=n&&s.length>18,A=c.useMemo(()=>!N||u?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,N,u]),v=c.useCallback(async()=>{try{m(null),await navigator.clipboard.writeText(s),l(!0),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{l(!1),g.current=null},2e3)}catch(k){l(!1),m(k instanceof Error?k.message:"Copy failed")}},[s]);return c.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${a}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:t}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[N&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>f(k=>!k),"aria-label":u?"Hide full wallet address":"Show full wallet address",children:u?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.7 10.7a3 3 0 0 0 4.24 4.24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.88 5.09A10.94 10.94 0 0 1 12 5c5 0 9.27 3.11 11 7-0.55 1.23-1.32 2.33-2.27 3.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.61 6.61C4.4 7.9 2.74 9.8 1 12c1.73 3.89 6 7 11 7 1.14 0 2.25-0.16 3.3-0.46",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),o&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:w,target:"_blank",rel:"noreferrer",children:"Explorer"}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:v,"aria-label":"Copy wallet address",children:d?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:A}),h&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:h})]})}function Mo({status:s,publicKey:t,onLock:r,onEnroll:o,onUnlock:n,onRecover:a,showActions:i=!0,compact:d=!1,className:l=""}){const h=s!==void 0,m=U.useWallet(),u=h?s:m.status,f=h?t??null:m.solanaPubkey,g=h?null:m.error,b=h?()=>{}:m.refresh,w=h?()=>{}:m.clearError,N=il(u,g);return d?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${l}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${N.color}`,title:N.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:N.label}),f&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:f,children:cl(f)})]}):e.jsxs("div",{className:`cedros-wallet-status ${l}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${N.color}`,children:e.jsx(ll,{status:u})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:N.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:N.description})]})]}),f&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(To,{address:f})}),g&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:g}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:w,children:"Dismiss"})]}),i&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[u==="not_enrolled"&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:o,children:"Create Wallet"}),u==="enrolled_locked"&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:n,children:"Unlock Wallet"}),(u==="not_enrolled"||u==="error")&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:"Recover Wallet"}),u==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:b,children:"Retry"})]})]})}function il(s,t){switch(s){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:t??"An error occurred with your wallet.",color:"error"}}}function cl(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function ll({status:s}){switch(s){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function dl({className:s="",showActions:t=!0}){const r=U.useWallet(),[o,n]=c.useState("status"),a=c.useMemo(()=>{switch(o){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[o]),i=c.useCallback(()=>n("status"),[]),d=c.useCallback(async()=>{n("status"),await r.refresh()},[r]),l=c.useCallback(async()=>{n("status"),await r.refresh()},[r]),h=c.useCallback(async()=>{n("status"),await r.refresh()},[r]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[o!=="status"&&a&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:a.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:a.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:i,children:"Back"})]}),o==="status"&&e.jsx(Mo,{onEnroll:()=>n("enroll"),onUnlock:()=>n("unlock"),onRecover:()=>n("recover_intro"),showActions:t}),o==="enroll"&&e.jsx(So,{onComplete:()=>{d()},onCancel:i}),o==="unlock"&&e.jsx(Lo,{onUnlock:()=>{l()},onCancel:i}),o==="recover_intro"&&e.jsx("div",{className:"cedros-wallet-manager-intro",children:e.jsxs("div",{className:"cedros-wallet-manager-intro-card",children:[e.jsx("h4",{className:"cedros-wallet-manager-intro-title",children:"Before you start"}),e.jsxs("ul",{className:"cedros-wallet-manager-intro-list",children:[e.jsx("li",{children:"You’ll need your 12-word recovery phrase."}),e.jsx("li",{children:"You’ll set a new password or passkey for this wallet."}),e.jsx("li",{children:"If you’re on a shared device, avoid copying the phrase into other apps."})]}),e.jsxs("div",{className:"cedros-wallet-manager-intro-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>n("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:i,children:"Cancel"})]})]})}),o==="recover"&&e.jsx(Ro,{onComplete:()=>{h()},onCancel:i})]})}function ul({showDescriptions:s=!0,className:t="",onSave:r}){const{settings:o,isLoading:n,isUpdating:a,error:i,fetchSettings:d,updateSettings:l}=$t.useSystemSettings(),[h,m]=c.useState({}),[u,f]=c.useState(null),[g,b]=c.useState(!1);c.useEffect(()=>{d()},[d]),c.useEffect(()=>{if(g){const E=setTimeout(()=>b(!1),3e3);return()=>clearTimeout(E)}},[g]);const w=c.useCallback((E,p)=>{m(y=>({...y,[E]:p})),f(null),b(!1)},[]),N=c.useCallback(async()=>{const E=Object.entries(h).map(([p,y])=>({key:p,value:y}));if(E.length!==0)try{await l(E),m({}),f(null),b(!0),r?.()}catch(p){f(p instanceof Error?p.message:"Failed to save settings")}},[h,l,r]),A=c.useCallback(()=>{m({}),f(null),b(!1)},[]),v=Object.keys(h).length>0,k=Object.keys(h).length;if(n&&Object.keys(o).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(i)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(Z.ErrorMessage,{error:i.message})});const S=Object.keys(o).sort();return S.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${t}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${t}`,children:[u&&e.jsx(Z.ErrorMessage,{error:u}),g&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),S.map(E=>e.jsx(hl,{category:E,settings:o[E],edits:h,showDescription:s,onChange:w},E)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[v&&e.jsxs("span",{className:"cedros-settings-change-count",children:[k," unsaved change",k!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:A,disabled:!v||a,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:N,disabled:!v||a,children:a?e.jsx(z.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const Wr=Object.keys(ye.SETTING_METADATA);function hl({category:s,settings:t,edits:r,showDescription:o,onChange:n}){const a=ye.CATEGORY_METADATA[s]||{label:s,description:"",icon:""},i=c.useMemo(()=>[...t].sort((d,l)=>{const h=Wr.indexOf(d.key),m=Wr.indexOf(l.key);return(h===-1?1/0:h)-(m===-1?1/0:m)}),[t]);return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:a.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:a.label}),o&&a.description&&e.jsx("p",{className:"cedros-settings-section-description",children:a.description})]})]}),e.jsx(ye.SettingsSection,{settings:i,edits:r,onChange:n})]})}const J={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),shield:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),image:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),e.jsx("circle",{cx:"9",cy:"9",r:"2"}),e.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]}),referrals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),ticket:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),e.jsx("path",{d:"M13 5v2"}),e.jsx("path",{d:"M13 17v2"}),e.jsx("path",{d:"M13 11v2"})]})},ml=[{id:"users",label:"Users",icon:J.users},{id:"team",label:"Team",icon:J.members},{id:"referrals",label:"Referrals",icon:J.referrals},{id:"deposits",label:"Deposits",icon:J.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:J.withdrawals,requiredFeature:"credits"},{id:"compliance",label:"Compliance",icon:J.shield,group:"Compliance"},{id:"accreditation-queue",label:"Accreditation Queue",icon:J.shield,group:"Compliance"},{id:"sanctions",label:"Sanctions",icon:J.shield,group:"Compliance"},{id:"signup-gating",label:"Signup Gating",icon:J.ticket,group:"Compliance"},{id:"settings-auth",label:"Authentication",icon:J.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:J.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:J.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:J.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-compliance",label:"Compliance & Gating",icon:J.shield,group:"Configuration"},{id:"settings-referrals",label:"Referrals & Rewards",icon:J.referrals,group:"Configuration"},{id:"settings-signup",label:"Signup Gating",icon:J.ticket,group:"Configuration"},{id:"settings-server",label:"Auth Server",icon:J.server,group:"Configuration"},{id:"settings-images",label:"Image Storage",icon:J.image,group:"Configuration"}];function pl(s,t){return t.toUpperCase()==="SOL"?`${(s/1e9).toFixed(4)} SOL`:`${s} ${t}`}function Or(s){return s.length<=16?s:`${s.slice(0,8)}...${s.slice(-6)}`}function fl(s){return new Date(s).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}const gl=["all","pending","completed","failed","cancelled"];function wl(){const{config:s,_internal:t}=M.useCedrosLogin(),r=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),[o,n]=c.useState("all"),[a,i]=c.useState(0),d=20,[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,g]=c.useState(null),[b,w]=c.useState(null),[N,A]=c.useState(null),v=c.useCallback(async()=>{u(!0),g(null);try{const p=new URLSearchParams;o!=="all"&&p.set("status",o),p.set("limit",String(d)),p.set("offset",String(a*d));const y=await r.get(`/admin/referral-payouts/list?${p.toString()}`);h(y)}catch(p){const y=M.handleApiError(p,"Failed to load payouts");g(y.message)}finally{u(!1)}},[r,o,a]);c.useEffect(()=>{v()},[v]);const k=c.useCallback(async p=>{A(p),w(null);try{const y=await r.post(`/admin/referral-payouts/${p}/process`,{});w(`Processed: ${y.txSignature}`),v()}catch(y){const x=M.handleApiError(y,"Failed to process payout");w(x.message)}finally{A(null)}},[r,v]),S=c.useCallback(async p=>{A(p),w(null);try{await r.post(`/admin/referral-payouts/${p}/cancel`,{}),w("Payout cancelled."),v()}catch(y){const x=M.handleApiError(y,"Failed to cancel payout");w(x.message)}finally{A(null)}},[r,v]),E=l?Math.ceil(l.total/d):0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__filter-bar",children:[e.jsxs("label",{className:"cedros-admin-referral-payouts__filter-label",children:["Status:",e.jsx("select",{value:o,onChange:p=>{n(p.target.value),i(0)},className:"cedros-admin-referral-payouts__filter-select",children:gl.map(p=>e.jsx("option",{value:p,children:p.charAt(0).toUpperCase()+p.slice(1)},p))})]}),l&&e.jsxs("span",{className:"cedros-admin-referral-payouts__filter-count",children:[l.total," total"]})]}),b&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--info",children:b}),m&&!l&&e.jsxs("div",{className:"cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading payouts..."})]}),f&&e.jsxs("div",{className:"cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:f}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:v,children:"Retry"})]}),l&&l.payouts.length===0&&e.jsx("div",{className:"cedros-admin-empty-message",children:"No payouts found."}),l&&l.payouts.length>0&&e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"All referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Date"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Trigger"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"TX / Error"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),l.payouts.map(p=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:fl(p.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:p.referrerEmail||p.referrerName||Or(p.referrerId)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:p.triggerType}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:pl(p.amount,p.currency)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-referral-payouts__status cedros-admin-referral-payouts__status--${p.status}`,children:p.status})}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-mono",role:"cell",children:[p.txSignature&&Or(p.txSignature),p.errorMessage&&e.jsx("span",{className:"cedros-admin-list-td-muted",title:p.errorMessage,children:p.errorMessage.slice(0,40)})]}),e.jsxs("div",{className:"cedros-admin-list-td",role:"cell",children:[(p.status==="pending"||p.status==="failed")&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-xs",onClick:()=>k(p.id),disabled:N!==null,children:N===p.id?"...":"Process"}),p.status==="pending"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",onClick:()=>S(p.id),disabled:N!==null,style:{marginLeft:4},children:"Cancel"})]})]},p.id))]}),E>1&&e.jsxs("div",{className:"cedros-admin-referral-payouts__pagination",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a===0,onClick:()=>i(p=>p-1),children:"Previous"}),e.jsxs("span",{className:"cedros-admin-referral-payouts__page-info",children:["Page ",a+1," of ",E]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-xs",disabled:a>=E-1,onClick:()=>i(p=>p+1),children:"Next"})]})]})}function rt(s,t){return t.toUpperCase()==="SOL"?`${(s/1e9).toFixed(4)} SOL`:`${s} ${t}`}function qr(s){return s.length<=16?s:`${s.slice(0,8)}...${s.slice(-6)}`}function Bo({className:s=""}){const[t,r]=c.useState("summary");return e.jsxs("div",{className:`cedros-admin-referral-payouts ${s}`,children:[e.jsxs("div",{className:"cedros-admin-referral-payouts__tabs",children:[e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${t==="summary"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("summary"),children:"Summary"}),e.jsx("button",{type:"button",className:`cedros-admin-referral-payouts__tab ${t==="all"?"cedros-admin-referral-payouts__tab--active":""}`,onClick:()=>r("all"),children:"All Payouts"})]}),t==="summary"?e.jsx(bl,{}):e.jsx(wl,{})]})}function bl(){const{config:s,_internal:t}=M.useCedrosLogin(),r=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),[o,n]=c.useState(null),[a,i]=c.useState(!1),[d,l]=c.useState(null),[h,m]=c.useState(!1),[u,f]=c.useState(null),[g,b]=c.useState(null),[w,N]=c.useState(!1),[A,v]=c.useState(null),[k,S]=c.useState(null),[E,p]=c.useState(null),y=c.useCallback(async()=>{i(!0),l(null);try{const B=await r.get("/admin/referral-payouts");n(B)}catch(B){const F=M.handleApiError(B,"Failed to load referral payouts");l(F.message)}finally{i(!1)}},[r]),x=c.useCallback(async()=>{try{const F=(await r.get("/admin/settings"))?.payout_auto_enabled?.value;p(F==="true")}catch{}},[r]);c.useEffect(()=>{y(),x()},[y,x]);const j=c.useCallback(async()=>{m(!0),f(null),b(null);try{const B=await r.post("/admin/referral-payouts/process",{});f(B),y()}catch(B){const F=M.handleApiError(B,"Failed to process payouts");b(F.message)}finally{m(!1)}},[r,y]),_=c.useCallback(async()=>{N(!0),v(null),S(null);try{const B=await r.post("/admin/referral-payouts/retry-failed",{});v(B),y()}catch(B){const F=M.handleApiError(B,"Failed to retry failed payouts");S(F.message)}finally{N(!1)}},[r,y]),C=h||w;if(a&&!o)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading referral payouts..."})]});if(d)return e.jsxs("div",{className:"cedros-admin-referral-payouts cedros-admin-referral-payouts--error",children:[e.jsx("p",{className:"cedros-admin-error",children:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,children:"Retry"})]});const P=o?.referrers??[],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:rt(T,R)})]}),E!==null&&e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Auto-Processing"}),e.jsx("span",{className:"cedros-admin-stat-value",children:E?"ON":"OFF"})]})]}),e.jsxs("div",{className:"cedros-admin-referral-payouts__actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:j,disabled:C||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":w,children:w?"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"," ",rt(u.totalAmount,R),".",u.failed>0&&` ${u.failed} failed.`,u.skippedNoWallet>0&&` ${u.skippedNoWallet} skipped (no wallet).`]}),g&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:g}),A&&e.jsxs("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--success",children:["Reset ",A.resetCount," failed payout(s) for retry."]}),k&&e.jsx("div",{className:"cedros-admin-referral-payouts__result cedros-admin-referral-payouts__result--error",children:k}),P.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No pending referral payouts."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Pending referral payouts",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Referrer ID"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Wallet Address"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Pending Referrals"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Total Amount"})]}),P.map(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:qr(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:qr(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:rt(B.totalPendingAmount,B.currency)})]},B.referrerId))]})]})}function xl({pageSize:s,currentUserId:t}){const[r,o]=c.useState(null),{statsItems:n,isLoading:a,error:i,refresh:d}=Re.useUsersStatsSummary();return r?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Re.AdminUserDetail,{userId:r.id,currentUserId:t,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(En.StatsBar,{stats:n,isLoading:a,onRefresh:d}),i&&e.jsx("p",{className:"cedros-admin-error-inline",children:i}),e.jsx(Re.AdminUserList,{pageSize:s,currentUserId:t,onUserClick:l=>o(l)})]})}function yl({orgId:s,currentUserId:t,hasPermission:r,role:o}){const[n,a]=c.useState("members"),{members:i,isLoading:d,error:l,fetchMembers:h,updateMemberRole:m,removeMember:u}=pe.useMembers(s),{invites:f,isLoading:g,error:b,fetchInvites:w,createInvite:N,cancelInvite:A,resendInvite:v}=pe.useInvites(s);c.useEffect(()=>{h(),w()},[h,w]);const k=r("invite:create"),S=r("invite:cancel"),E=f.length,p=i.reduce((_,C)=>(_[C.role]=(_[C.role]??0)+1,_),{}),y=p.owner??0,x=p.admin??0,j=p.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(En.StatsBar,{stats:[{label:"Owners",value:y},{label:"Admins",value:x},{label:"Members",value:j},{label:"Pending Invites",value:E}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="members"?"cedros-admin-tab-active":""}`,onClick:()=>a("members"),"aria-selected":n==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${n==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>a("invites"),"aria-selected":n==="invites",role:"tab",children:["Pending Invites",E>0&&` (${E})`]}),o==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>a("permissions"),"aria-selected":n==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[n==="members"&&e.jsx(pe.MemberList,{members:i,currentUserId:t,isLoading:d,error:l?.message,canManage:r("member:remove"),canChangeRoles:r("member:role_change"),onUpdateRole:m,onRemove:u}),n==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[k&&e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx("div",{className:"cedros-dashboard__section-header",children:e.jsx("h3",{className:"cedros-dashboard__section-title",children:"Send Invitation"})}),e.jsx(pe.InviteForm,{onSubmit:N,isLoading:g,error:b?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(pe.InviteList,{invites:f,isLoading:g,error:b?.message,canManage:S||k,onCancel:S?A:void 0,onResend:k?v:void 0})})]}),n==="permissions"&&o==="owner"&&e.jsx(pe.PermissionsSection,{userRole:o})]})]})}function vl({pageSize:s,refreshInterval:t}){const[r,o]=c.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(ks.AdminDepositStats,{refreshInterval:t}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:r,onChange:n=>o(n.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(ks.AdminDepositList,{statusFilter:r||void 0,pageSize:s,refreshInterval:t})]})]})}function Al({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Pe.AdminWithdrawalStats,{refreshInterval:t}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(Pe.AdminPrivacyPeriodDeposits,{pageSize:s,refreshInterval:t}),e.jsx(Pe.AdminWithdrawalQueue,{pageSize:s,refreshInterval:t}),e.jsx(Pe.AdminWithdrawalHistory,{pageSize:s,refreshInterval:t})]})]})}function jl(){return e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Bo,{})})}const Nl=["security","rate_limit"];function kl({className:s}){return e.jsx(Ye.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:Nl,className:s})}const zr=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Sl({className:s}){const{settings:t,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:d,handleChange:l,getEffectiveValue:h}=ye.useSettingsAutosave(),[m,u]=c.useState("email");c.useEffect(()=>{d()},[d]);const f=zr.find(S=>S.id===m),g=f?.category??"",w=(h("email_provider")||"custom")==="custom",N=h("email_smtp_host"),A=!w||N!=null&&N!=="",v=c.useMemo(()=>{const S=t[g]??[];if(m!=="email")return S;const E=w?vs.ALL_EMAIL_FIELDS:vs.SIMPLIFIED_EMAIL_FIELDS;return S.filter(p=>E.includes(p.key)).sort((p,y)=>E.indexOf(p.key)-E.indexOf(y.key))},[t,g,m,w]),k=(S,E)=>{if(l(S,E),S==="email_provider"&&E!=="custom"){const p=vs.PROVIDER_SMTP_HOSTS[E];p&&(l("email_smtp_host",p),l("email_smtp_port","587"),l("email_smtp_tls","true"))}};return o&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(Z.ErrorMessage,{error:i.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(ye.AutosaveStatus,{status:n,error:a})]}),m==="email"&&!A&&e.jsx("div",{className:"cedros-settings-warning-banner",children:"Email features (verification, password reset, instant link) are disabled until SMTP is configured. Select a provider or enter custom SMTP settings below."}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:zr.map(S=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${m===S.id?"cedros-admin-tab-active":""}`,onClick:()=>u(S.id),"aria-selected":m===S.id,role:"tab",children:S.label},S.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:v.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",f?.label??"this section","."]})}):e.jsx(ye.SettingsSection,{settings:v,edits:r,onChange:m==="email"?k:l})})]})}const nt=["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"],$r={nyc3:"https://nyc3.digitaloceanspaces.com",ams3:"https://ams3.digitaloceanspaces.com",sgp1:"https://sgp1.digitaloceanspaces.com",sfo3:"https://sfo3.digitaloceanspaces.com",fra1:"https://fra1.digitaloceanspaces.com",syd1:"https://syd1.digitaloceanspaces.com"};function Cl({className:s}){const{settings:t,edits:r,isLoading:o,autosaveStatus:n,autosaveError:a,error:i,fetchSettings:d,handleChange:l,getEffectiveValue:h}=ye.useSettingsAutosave();c.useEffect(()=>{d()},[d]);const m=c.useMemo(()=>(t.image_storage??[]).filter(g=>nt.includes(g.key)).sort((g,b)=>nt.indexOf(g.key)-nt.indexOf(b.key)),[t]),u=(f,g)=>{if(l(f,g),f==="image_storage_provider")if(g==="digitalocean"){const b=h("image_storage_region")||"nyc3";l("image_storage_region",b),l("image_storage_endpoint",$r[b]??`https://${b}.digitaloceanspaces.com`)}else g==="s3"&&l("image_storage_endpoint","");f==="image_storage_region"&&h("image_storage_provider")==="digitalocean"&&l("image_storage_endpoint",$r[g]??`https://${g}.digitaloceanspaces.com`)};return o&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):i?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(Z.ErrorMessage,{error:i.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Image Storage"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure S3-compatible object storage for user avatars and images. Supports AWS S3, DigitalOcean Spaces, and other S3-compatible providers."})]}),e.jsx(ye.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(ye.SettingsSection,{settings:m,edits:r,onChange:u})]})}const El=["kyc","accreditation","sanctions","token_gating"];function Io({className:s}){return e.jsx(Ye.SettingsPageLayout,{title:"Compliance & Gating",description:"Configure KYC identity verification, accredited investor verification, sanctions screening, and Solana token gating.",categories:El,className:s})}const _l=["referral"];function Do({className:s}){return e.jsx(Ye.SettingsPageLayout,{title:"Referrals & Rewards",description:"Configure referral reward types, amounts, triggers, per-referrer caps, and automated payout processing.",categories:_l,className:s})}const Ll=["signup"];function Uo({className:s}){return e.jsx(Ye.SettingsPageLayout,{title:"Signup Gating",description:"Configure access codes required to register and optional signup rate limits.",categories:Ll,className:s})}const ns=20;function ot(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}function Pl(s){return!!s.expiresAt&&new Date(s.expiresAt)<new Date}function Rl(s){return s.maxUses!==null&&s.currentUses>=s.maxUses}function Tl(s){return Pl(s)?"expired":Rl(s)?"exhausted":"active"}function Fo({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Re.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState("all"),[i,d]=c.useState([]),[l,h]=c.useState(0),[m,u]=c.useState(0),[f,g]=c.useState(!1),[b,w]=c.useState(null),[N,A]=c.useState(null),[v,k]=c.useState(""),[S,E]=c.useState(""),[p,y]=c.useState(""),[x,j]=c.useState(!1),[_,C]=c.useState(null),[P,L]=c.useState(!1),[R,T]=c.useState(null),[B,F]=c.useState(null),W={all:void 0,limited:"limited",user_invite:"user_invite"},q=c.useCallback(async()=>{g(!0),w(null);try{const I=await o.listAccessCodes(ns,m,W[n]);d(I.items),h(I.total)}catch(I){w(I instanceof Error?I.message:"Failed to load access codes")}finally{g(!1)}},[o,n,m]),D=c.useCallback(async()=>{try{const I=await o.getSignupStats();A(I)}catch{}},[o]);c.useEffect(()=>{q(),D()},[q,D]),c.useEffect(()=>{u(0)},[n]);const $=c.useCallback(async I=>{if(I.preventDefault(),!v.trim()){C("Code is required.");return}const O=S.trim()?parseInt(S,10):null;if(S.trim()&&(isNaN(O)||O<1)){C("Max uses must be a positive integer.");return}const X=p.trim()?new Date(p).toISOString():void 0;j(!0),C(null),L(!1);try{await o.createAccessCode(v.trim(),O,X),k(""),E(""),y(""),L(!0),q(),D()}catch(Y){C(Y instanceof Error?Y.message:"Failed to create code")}finally{j(!1)}},[o,v,S,p,q,D]),Q=c.useCallback(async I=>{T(I),F(null);try{await o.deleteAccessCode(I),d(O=>O.filter(X=>X.id!==I)),h(O=>O-1)}catch(O){F(O instanceof Error?O.message:"Failed to delete code")}finally{T(null)}},[o]),H=Math.ceil(l/ns),re=Math.floor(m/ns)+1;return e.jsxs("div",{className:`cedros-admin-access-codes ${s}`,children:[e.jsxs("div",{className:"cedros-admin-access-codes__header",children:[e.jsx("h2",{className:"cedros-admin-access-codes__title",children:"Access Codes"}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:()=>{q(),D()},disabled:f,title:"Refresh","aria-label":"Refresh list",children:f?"...":"↻"})]}),N&&e.jsxs("div",{className:"cedros-admin-access-codes__stats-bar","aria-label":"Signup statistics",children:[e.jsxs("span",{className:"cedros-admin-access-codes__stat",children:[e.jsxs("strong",{children:["Signups this ",N.period,":"]})," ",N.count,N.limit!==null?` / ${N.limit}`:""]}),e.jsxs("span",{className:"cedros-admin-access-codes__stat",children:[e.jsx("strong",{children:"Period start:"})," ",ot(N.periodStart)]})]}),e.jsxs("section",{className:"cedros-admin-access-codes__create-section","aria-label":"Create access code",children:[e.jsx("h3",{className:"cedros-admin-access-codes__section-title",children:"Create Code"}),e.jsxs("form",{className:"cedros-admin-access-codes__create-form",onSubmit:$,"aria-label":"Create access code form",children:[e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsx("label",{htmlFor:"ac-code",className:"cedros-label",children:"Code"}),e.jsx("input",{id:"ac-code",type:"text",className:"cedros-input",value:v,onChange:I=>{k(I.target.value),C(null),L(!1)},placeholder:"e.g. BETA2025",disabled:x,required:!0})]}),e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsxs("label",{htmlFor:"ac-max-uses",className:"cedros-label",children:["Max Uses ",e.jsx("span",{className:"cedros-optional",children:"(blank = unlimited)"})]}),e.jsx("input",{id:"ac-max-uses",type:"number",className:"cedros-input",value:S,onChange:I=>E(I.target.value),placeholder:"e.g. 100",min:"1",disabled:x})]}),e.jsxs("div",{className:"cedros-form-field cedros-form-field--inline",children:[e.jsxs("label",{htmlFor:"ac-expiry",className:"cedros-label",children:["Expiry ",e.jsx("span",{className:"cedros-optional",children:"(optional)"})]}),e.jsx("input",{id:"ac-expiry",type:"date",className:"cedros-input",value:p,onChange:I=>y(I.target.value),disabled:x})]}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary cedros-button-md",disabled:x,"aria-busy":x,children:x?"Creating...":"Create"})]}),_&&e.jsx("div",{className:"cedros-admin-error",role:"alert",children:_}),P&&!_&&e.jsx("div",{className:"cedros-admin-success",role:"status",children:"Code created."})]}),e.jsx("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",role:"tablist",children:["all","limited","user_invite"].map(I=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${n===I?"cedros-admin-tab-active":""}`,onClick:()=>a(I),"aria-selected":n===I,role:"tab",children:I==="all"?"All":I==="limited"?"Limited":"User Invite"},I))}),B&&e.jsx("div",{className:"cedros-admin-error",role:"alert",children:B}),b&&e.jsxs("div",{className:"cedros-admin-access-codes--error",children:[e.jsx("p",{className:"cedros-admin-error",children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:q,children:"Retry"})]}),!b&&e.jsx("div",{role:"tabpanel",children:f&&i.length===0?e.jsxs("div",{className:"cedros-admin-access-codes--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading..."})]}):i.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No access codes found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table cedros-admin-access-codes__table",role:"table","aria-label":"Access codes",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Code"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Uses"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Created By"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Created"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Expires"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:e.jsx("span",{className:"cedros-sr-only",children:"Actions"})})]}),i.map(I=>{const O=Tl(I),X=I.maxUses!==null?`${I.currentUses} / ${I.maxUses}`:`${I.currentUses}`;return e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("code",{className:"cedros-admin-access-codes__code",children:I.code})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:I.codeType}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:X}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:I.createdByEmail??"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:ot(I.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:I.expiresAt?ot(I.expiresAt):"—"}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-access-codes__status cedros-admin-access-codes__status--${O}`,children:O.charAt(0).toUpperCase()+O.slice(1)})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>Q(I.id),disabled:R===I.id,"aria-label":`Delete code ${I.code}`,children:R===I.id?"...":"Delete"})})]},I.id)})]}),H>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-ns)),disabled:re<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",re," of ",H," (",l," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(m+ns),disabled:re>=H,children:"Next"})]})]})})]})}function Ml(){return`rule_${Date.now()}_${Math.random().toString(36).slice(2,7)}`}function Bl(s){if(!s)return[];try{const t=JSON.parse(s);return Array.isArray(t)?t:[]}catch{return[]}}function Il(s){switch(s){case"nft_collection":return"NFT Collection";case"fungible_token":return"Fungible Token";case"any_nft":return"Any NFT"}}function Dl(s){switch(s){case"all":return"All";case"deposits":return"Deposits";case"withdrawals":return"Withdrawals"}}const Vr={name:"",ruleType:"nft_collection",collectionAddress:"",mintAddress:"",minQuantity:"",minAmount:"",enforcement:"all"};function Ul(s){return{name:s.name,ruleType:s.ruleType,collectionAddress:s.collectionAddress??"",mintAddress:s.mintAddress??"",minQuantity:s.minQuantity!==void 0?String(s.minQuantity):"",minAmount:s.minAmount??"",enforcement:s.enforcement}}function Fl(s,t){return{id:t,name:s.name.trim(),ruleType:s.ruleType,collectionAddress:s.ruleType==="nft_collection"&&s.collectionAddress.trim()||void 0,mintAddress:s.ruleType==="fungible_token"&&s.mintAddress.trim()||void 0,minQuantity:s.ruleType!=="fungible_token"&&s.minQuantity?parseInt(s.minQuantity,10):void 0,minAmount:s.ruleType==="fungible_token"&&s.minAmount.trim()||void 0,enforcement:s.enforcement}}function Wo({className:s=""}){const{fetchSettings:t,updateSettings:r,getValue:o,isLoading:n,error:a}=$t.useSystemSettings(),[i,d]=c.useState([]),[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,g]=c.useState(Vr),[b,w]=c.useState(null),[N,A]=c.useState(!1);c.useEffect(()=>{t()},[t]);const v=o("token_gating_rules"),k=c.useMemo(()=>Bl(v),[v]);c.useEffect(()=>{d(k)},[k]);const S=c.useCallback(async C=>{A(!0),w(null);try{await r([{key:"token_gating_rules",value:JSON.stringify(C)}]),d(C)}catch(P){w(P instanceof Error?P.message:"Failed to save rules")}finally{A(!1)}},[r]),E=c.useCallback(()=>{h(null),g(Vr),w(null),u(!0)},[]),p=c.useCallback(C=>{h(C.id),g(Ul(C)),w(null),u(!0)},[]),y=c.useCallback(C=>{const P=i.filter(L=>L.id!==C);S(P)},[i,S]),x=c.useCallback(()=>{u(!1),w(null)},[]),j=c.useCallback(async()=>{if(!f.name.trim()){w("Rule name is required.");return}const C=l??Ml(),P=Fl(f,C),L=l?i.map(R=>R.id===l?P:R):[...i,P];await S(L),b||u(!1)},[f,l,i,S,b]),_=c.useCallback((C,P)=>{g(L=>({...L,[C]:P}))},[]);return n&&i.length===0?e.jsxs("div",{className:`cedros-admin-token-gate ${s} cedros-admin-token-gate--loading`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading token gate rules..."})]}):a&&i.length===0?e.jsxs("div",{className:`cedros-admin-token-gate ${s} cedros-admin-token-gate--error`,children:[e.jsx("p",{className:"cedros-admin-error",children:a.message}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:"Retry"})]}):e.jsxs("div",{className:`cedros-admin-token-gate ${s}`,children:[e.jsxs("div",{className:"cedros-admin-token-gate__header",children:[e.jsx("h2",{className:"cedros-admin-token-gate__title",children:"Token Gate Rules"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:E,disabled:m,children:"Add Rule"})]}),m&&e.jsx(Wl,{form:f,isNew:l===null,isSaving:N,saveError:b,onFieldChange:_,onSave:j,onCancel:x}),i.length===0&&!m?e.jsx("div",{className:"cedros-admin-empty-message",children:"No token gate rules configured."}):e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Token gate rules",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Name"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Type"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Address / Mint"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Min Qty / Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Enforcement"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Actions"})]}),i.map(C=>e.jsxs("div",{className:"cedros-admin-list-row",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:C.name}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Il(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:Dl(C.enforcement)}),e.jsxs("div",{className:"cedros-admin-list-td cedros-admin-list-td-actions",role:"cell",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>p(C),disabled:m,children:"Edit"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>y(C.id),disabled:N||m,children:"Delete"})]})]},C.id))]})]})}function Wl({form:s,isNew:t,isSaving:r,saveError:o,onFieldChange:n,onSave:a,onCancel:i}){const d=s.ruleType==="nft_collection",l=s.ruleType==="fungible_token",h=s.ruleType!=="fungible_token",m=s.ruleType==="fungible_token";return e.jsxs("div",{className:"cedros-admin-token-gate__form",role:"region","aria-label":t?"Add rule":"Edit rule",children:[e.jsx("h3",{className:"cedros-admin-token-gate__form-title",children:t?"Add Rule":"Edit Rule"}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-name",children:"Name"}),e.jsx("input",{id:"tg-name",type:"text",className:"cedros-admin-form-input",value:s.name,onChange:u=>n("name",u.target.value),placeholder:"e.g. Whale Gate"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-type",children:"Type"}),e.jsxs("select",{id:"tg-type",className:"cedros-admin-form-select",value:s.ruleType,onChange:u=>n("ruleType",u.target.value),children:[e.jsx("option",{value:"nft_collection",children:"NFT Collection"}),e.jsx("option",{value:"fungible_token",children:"Fungible Token"}),e.jsx("option",{value:"any_nft",children:"Any NFT"})]})]}),d&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-collection",children:"Collection Address"}),e.jsx("input",{id:"tg-collection",type:"text",className:"cedros-admin-form-input cedros-admin-form-input--mono",value:s.collectionAddress,onChange:u=>n("collectionAddress",u.target.value),placeholder:"Solana collection mint address"})]}),l&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-mint",children:"Mint Address"}),e.jsx("input",{id:"tg-mint",type:"text",className:"cedros-admin-form-input cedros-admin-form-input--mono",value:s.mintAddress,onChange:u=>n("mintAddress",u.target.value),placeholder:"SPL token mint address"})]}),h&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-minqty",children:"Min Quantity"}),e.jsx("input",{id:"tg-minqty",type:"number",min:"1",className:"cedros-admin-form-input",value:s.minQuantity,onChange:u=>n("minQuantity",u.target.value),placeholder:"1"})]}),m&&e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-minamount",children:"Min Amount"}),e.jsx("input",{id:"tg-minamount",type:"text",className:"cedros-admin-form-input",value:s.minAmount,onChange:u=>n("minAmount",u.target.value),placeholder:"e.g. 1000000 (raw units)"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"tg-enforcement",children:"Enforcement"}),e.jsxs("select",{id:"tg-enforcement",className:"cedros-admin-form-select",value:s.enforcement,onChange:u=>n("enforcement",u.target.value),children:[e.jsx("option",{value:"all",children:"All"}),e.jsx("option",{value:"deposits",children:"Deposits"}),e.jsx("option",{value:"withdrawals",children:"Withdrawals"})]})]}),o&&e.jsx("p",{className:"cedros-admin-error",children:o}),e.jsxs("div",{className:"cedros-admin-token-gate__form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,disabled:r,"aria-busy":r,children:r?"Saving...":"Save Rule"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:i,disabled:r,children:"Cancel"})]})]})}function Ol(s){return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function ql(s){return{income:"Income",net_worth:"Net Worth",credential:"Credential",third_party_letter:"Third-Party Letter",insider:"Insider / Executive",investment_threshold:"Investment Threshold"}[s]??s}function zl(s){switch(s){case"pending":return"cedros-admin-badge--pending";case"approved":return"cedros-admin-badge--approved";case"rejected":return"cedros-admin-badge--rejected";case"expired":return"cedros-admin-badge--expired";default:return""}}function $l({item:s,isExpanded:t,detail:r,detailLoading:o,detailError:n,reviewNotes:a,rejectionReason:i,isReviewing:d,reviewError:l,onRowClick:h,onDocumentDownload:m,onReviewNotesChange:u,onRejectionReasonChange:f,onReview:g}){const b=s.statedAmountUsd!==void 0?`$${s.statedAmountUsd.toLocaleString()}`:s.investmentCommitmentUsd!==void 0?`$${s.investmentCommitmentUsd.toLocaleString()}`:"—";return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`cedros-admin-list-row cedros-admin-list-row--clickable ${t?"cedros-admin-list-row--expanded":""}`,role:"row",onClick:()=>h(s.id),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),h(s.id))},tabIndex:0,"aria-expanded":t,children:[e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:s.userEmail??e.jsxs("span",{className:"cedros-admin-list-td-mono",children:[s.userId.slice(0,12),"..."]})}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:ql(s.method)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:b}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:Ol(s.createdAt)}),e.jsx("div",{className:"cedros-admin-list-td",role:"cell",children:e.jsx("span",{className:`cedros-admin-badge ${zl(s.status)}`,children:s.status})})]}),t&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail",role:"region","aria-label":"Submission detail",children:[o&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail-loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading detail..."})]}),n&&e.jsx("p",{className:"cedros-admin-error",children:n}),r&&e.jsxs(e.Fragment,{children:[e.jsx(Vl,{detail:r,onDocumentDownload:m}),s.status==="pending"&&e.jsx(Hl,{submissionId:s.id,notes:a,rejectionReason:i,isReviewing:d,error:l,onNotesChange:u,onRejectionReasonChange:f,onReview:g})]})]})]})}function Vl({detail:s,onDocumentDownload:t}){return e.jsxs("div",{className:"cedros-admin-accreditation-queue__detail-fields",children:[s.incomeType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Income Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.incomeType})]}),s.statedAmountUsd!==void 0&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Stated Amount"}),e.jsxs("span",{className:"cedros-admin-detail-value",children:["$",s.statedAmountUsd.toLocaleString()]})]}),s.crdNumber&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"CRD Number"}),e.jsx("span",{className:"cedros-admin-detail-value cedros-admin-list-td-mono",children:s.crdNumber})]}),s.licenseType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"License Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.licenseType})]}),s.investmentCommitmentUsd!==void 0&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Investment Commitment"}),e.jsxs("span",{className:"cedros-admin-detail-value",children:["$",s.investmentCommitmentUsd.toLocaleString()]})]}),s.entityType&&e.jsxs("div",{className:"cedros-admin-detail-row",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"Entity Type"}),e.jsx("span",{className:"cedros-admin-detail-value",children:s.entityType})]}),s.userStatement&&e.jsxs("div",{className:"cedros-admin-detail-row cedros-admin-detail-row--block",children:[e.jsx("span",{className:"cedros-admin-detail-label",children:"User Statement"}),e.jsx("p",{className:"cedros-admin-detail-statement",children:s.userStatement})]}),s.documents.length>0&&e.jsxs("div",{className:"cedros-admin-accreditation-queue__documents",children:[e.jsx("h4",{className:"cedros-admin-accreditation-queue__documents-title",children:"Documents"}),s.documents.map(r=>e.jsxs("div",{className:"cedros-admin-accreditation-queue__document-row",children:[e.jsx("span",{className:"cedros-admin-accreditation-queue__document-name",children:r.originalFilename??r.documentType}),r.fileSizeBytes&&e.jsxs("span",{className:"cedros-admin-list-td-muted",children:[(r.fileSizeBytes/1024).toFixed(1)," KB"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>t(r.id),children:"Download"})]},r.id))]})]})}function Hl({submissionId:s,notes:t,rejectionReason:r,isReviewing:o,error:n,onNotesChange:a,onRejectionReasonChange:i,onReview:d}){return e.jsxs("div",{className:"cedros-admin-accreditation-queue__review-form",children:[e.jsx("h4",{className:"cedros-admin-accreditation-queue__review-title",children:"Review Decision"}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"review-notes",children:"Reviewer Notes (internal)"}),e.jsx("textarea",{id:"review-notes",className:"cedros-admin-form-textarea",value:t,onChange:l=>a(l.target.value),rows:2,placeholder:"Optional internal notes"})]}),e.jsxs("div",{className:"cedros-admin-form-row",children:[e.jsx("label",{className:"cedros-admin-form-label",htmlFor:"rejection-reason",children:"Rejection Reason (required if rejecting)"}),e.jsx("textarea",{id:"rejection-reason",className:"cedros-admin-form-textarea",value:r,onChange:l=>i(l.target.value),rows:2,placeholder:"Reason shown to user"})]}),n&&e.jsx("p",{className:"cedros-admin-error",children:n}),e.jsxs("div",{className:"cedros-admin-accreditation-queue__review-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:()=>d(s,!0),disabled:o,"aria-busy":o,children:o?"Saving...":"Approve"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger cedros-button-sm",onClick:()=>d(s,!1),disabled:o,"aria-busy":o,children:o?"Saving...":"Reject"})]})]})}const os=20;function Oo({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Re.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState("pending"),[i,d]=c.useState([]),[l,h]=c.useState(0),[m,u]=c.useState(0),[f,g]=c.useState(!1),[b,w]=c.useState(null),[N,A]=c.useState(null),[v,k]=c.useState(null),[S,E]=c.useState(!1),[p,y]=c.useState(null),[x,j]=c.useState(""),[_,C]=c.useState(""),[P,L]=c.useState(!1),[R,T]=c.useState(null),[B,F]=c.useState(null),W=c.useCallback(async()=>{g(!0),w(null);try{const I=await o.listPendingAccreditations(os,m);d(I.items),h(I.total)}catch(I){w(I instanceof Error?I.message:"Failed to load submissions")}finally{g(!1)}},[o,n,m]);c.useEffect(()=>{W()},[W]),c.useEffect(()=>{u(0),A(null),k(null)},[n]);const q=c.useCallback(async I=>{if(N===I){A(null),k(null);return}A(I),k(null),y(null),j(""),C(""),T(null),F(null),E(!0);try{const O=await o.getAccreditationSubmission(I);k(O)}catch(O){y(O instanceof Error?O.message:"Failed to load submission detail")}finally{E(!1)}},[N,o]),D=c.useCallback(async I=>{try{const O=await o.getAccreditationDocumentUrl(I);window.open(O,"_blank","noopener,noreferrer")}catch(O){T(O instanceof Error?O.message:"Failed to get document URL")}},[o]),$=c.useCallback(async(I,O)=>{if(!O&&!_.trim()){T("Rejection reason is required.");return}L(!0),T(null),F(null);try{await o.reviewAccreditation(I,O,x.trim()||void 0,O?void 0:_.trim()),F(O?"Submission approved.":"Submission rejected."),A(null),k(null),W()}catch(X){T(X instanceof Error?X.message:"Failed to submit review")}finally{L(!1)}},[o,x,_,W]),Q=Math.ceil(l/os),H=Math.floor(m/os)+1,re=n==="pending"?l:i.filter(I=>I.status==="pending").length;return e.jsxs("div",{className:`cedros-admin-accreditation-queue ${s}`,children:[e.jsxs("div",{className:"cedros-admin-accreditation-queue__header",children:[e.jsxs("h2",{className:"cedros-admin-accreditation-queue__title",children:["Accreditation Review Queue",re>0&&e.jsx("span",{className:"cedros-admin-queue-count","aria-label":`${re} pending`,children:re})]}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:W,disabled:f,title:"Refresh","aria-label":"Refresh list",children:f?"...":"↻"})]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",role:"tablist",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="pending"?"cedros-admin-tab-active":""}`,onClick:()=>a("pending"),"aria-selected":n==="pending",role:"tab",children:"Pending"}),e.jsx("button",{type:"button",className:`cedros-admin-tab ${n==="all"?"cedros-admin-tab-active":""}`,onClick:()=>a("all"),"aria-selected":n==="all",role:"tab",children:"All"})]}),B&&e.jsx("div",{className:"cedros-admin-accreditation-queue__result cedros-admin-accreditation-queue__result--success",children:B}),b&&e.jsxs("div",{className:"cedros-admin-accreditation-queue cedros-admin-accreditation-queue--error",children:[e.jsx("p",{className:"cedros-admin-error",children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:W,children:"Retry"})]}),!b&&f&&i.length===0?e.jsxs("div",{className:"cedros-admin-accreditation-queue--loading",children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading submissions..."})]}):e.jsx("div",{role:"tabpanel",children:i.length===0?e.jsx("div",{className:"cedros-admin-empty-message",children:"No submissions found."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-admin-list-table",role:"table","aria-label":"Accreditation submissions",children:[e.jsxs("div",{className:"cedros-admin-list-thead",role:"row",children:[e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"User"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Method"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Amount"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Submitted"}),e.jsx("div",{className:"cedros-admin-list-th",role:"columnheader",children:"Status"})]}),i.map(I=>e.jsx($l,{item:I,isExpanded:N===I.id,detail:N===I.id?v:null,detailLoading:N===I.id&&S,detailError:N===I.id?p:null,reviewNotes:x,rejectionReason:_,isReviewing:P,reviewError:N===I.id?R:null,onRowClick:q,onDocumentDownload:D,onReviewNotesChange:j,onRejectionReasonChange:C,onReview:$},I.id))]}),Q>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-os)),disabled:H<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-admin-page-info",children:["Page ",H," of ",Q," (",l," total)"]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u(m+os),disabled:H>=Q,children:"Next"})]})]})})]})}function Gl(s){return s===void 0?"—":s<60?`${s}s`:s<3600?`${Math.floor(s/60)}m ${s%60}s`:`${Math.floor(s/3600)}h ${Math.floor(s%3600/60)}m`}function Ql(s){return s?new Date(s).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function qo({className:s=""}){const{config:t,_internal:r}=M.useCedrosLogin(),o=c.useMemo(()=>new Re.AdminUserApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,r?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,r]),[n,a]=c.useState(null),[i,d]=c.useState(!1),[l,h]=c.useState(null),[m,u]=c.useState(!1),[f,g]=c.useState(null),[b,w]=c.useState(!1),N=c.useCallback(async()=>{d(!0),h(null);try{const v=await o.getSanctionsStats();a(v)}catch(v){h(v instanceof Error?v.message:"Failed to load sanctions stats")}finally{d(!1)}},[o]);c.useEffect(()=>{N()},[N]);const A=c.useCallback(async()=>{u(!0),g(null),w(!1);try{await o.refreshSanctions(),w(!0),await N()}catch(v){g(v instanceof Error?v.message:"Failed to refresh sanctions cache")}finally{u(!1)}},[o,N]);return i&&!n?e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s} cedros-admin-sanctions-panel--loading`,children:[e.jsx("span",{className:"cedros-admin-loading-indicator"}),e.jsx("span",{className:"cedros-admin-loading-text",children:"Loading sanctions stats..."})]}):l&&!n?e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s} cedros-admin-sanctions-panel--error`,children:[e.jsx("p",{className:"cedros-admin-error",children:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:N,children:"Retry"})]}):e.jsxs("div",{className:`cedros-admin-sanctions-panel ${s}`,children:[e.jsxs("div",{className:"cedros-admin-sanctions-panel__header",children:[e.jsx("h2",{className:"cedros-admin-sanctions-panel__title",children:"Sanctions Screening"}),e.jsxs("div",{className:"cedros-admin-sanctions-panel__header-actions",children:[n!==null&&e.jsx("span",{className:`cedros-admin-badge ${n.configured?"cedros-admin-badge--approved":"cedros-admin-badge--pending"}`,title:n.configured?"Sanctions API configured":"Sanctions API not configured",children:n.configured?"Configured":"Not Configured"}),e.jsx("button",{type:"button",className:"cedros-admin__stats-bar-refresh",onClick:N,disabled:i,title:"Refresh stats","aria-label":"Refresh stats",children:i?"...":"↻"})]})]}),n!==null&&e.jsxs("div",{className:"cedros-admin-sanctions-panel__stats",children:[e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Sanctioned Addresses"}),e.jsx("span",{className:"cedros-admin-stat-value",children:n.sanctionedAddresses.toLocaleString()})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Sanctioned Countries"}),e.jsx("span",{className:"cedros-admin-stat-value",children:n.sanctionedCountries.toLocaleString()})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Cache Age"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Gl(n.cacheAgeSeconds)})]}),e.jsxs("div",{className:"cedros-admin-stat-card",children:[e.jsx("span",{className:"cedros-admin-stat-label",children:"Last Refresh"}),e.jsx("span",{className:"cedros-admin-stat-value",children:Ql(n.lastRefreshedAt)})]})]}),e.jsx("div",{className:"cedros-admin-sanctions-panel__actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:A,disabled:m||i,"aria-busy":m,children:m?"Refreshing...":"Force Refresh"})}),b&&e.jsx("div",{className:"cedros-admin-sanctions-panel__result cedros-admin-sanctions-panel__result--success",children:"Sanctions cache refreshed successfully."}),f&&e.jsx("div",{className:"cedros-admin-sanctions-panel__result cedros-admin-sanctions-panel__result--error",children:f}),l&&n&&e.jsx("p",{className:"cedros-admin-error cedros-admin-error--inline",children:l})]})}class Kl{client;constructor(t,r,o){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o})}async getStatus(){try{return await this.client.get("/setup/status")}catch(t){throw M.handleApiError(t,"Failed to check setup status")}}async createFirstAdmin(t){try{return await this.client.post("/setup/admin",t)}catch(r){throw M.handleApiError(r,"Failed to create admin account")}}}function tr(){const{config:s}=M.useCedrosLogin(),[t,r]=c.useState(null),[o,n]=c.useState(!1),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useRef(0),m=c.useMemo(()=>new Kl(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),u=c.useRef(m);u.current=m;const f=c.useCallback(async()=>{n(!0),l(null);const b=++h.current;try{const w=await u.current.getStatus();if(b!==h.current)return;r(w)}catch(w){if(b!==h.current)return;l(w instanceof Error?w:new Error("Failed to check setup status"))}finally{b===h.current&&n(!1)}},[]),g=c.useCallback(async b=>{i(!0),l(null);try{const w=await u.current.createFirstAdmin(b);return await f(),w}catch(w){const N=w instanceof Error?w:new Error("Failed to create admin");throw l(N),N}finally{i(!1)}},[f]);return{status:t,isLoading:o,isCreating:a,error:d,checkStatus:f,createAdmin:g}}const Yl=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Hr=8;function Zl(s){const t={};return s.email?Yl.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<Hr&&(t.password=`Password must be at least ${Hr} characters`):t.password="Password is required",s.confirmPassword?s.password!==s.confirmPassword&&(t.confirmPassword="Passwords do not match"):t.confirmPassword="Please confirm your password",t}function zo({onComplete:s,className:t=""}){const{status:r,isLoading:o,isCreating:n,error:a,checkStatus:i,createAdmin:d}=tr(),[l,h]=c.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[m,u]=c.useState({}),[f,g]=c.useState(!1);c.useEffect(()=>{i()},[i]);const b=c.useCallback(N=>A=>{h(v=>({...v,[N]:A.target.value})),u(v=>({...v,[N]:void 0}))},[]),w=c.useCallback(async N=>{N.preventDefault();const A=Zl(l);if(Object.keys(A).length>0){u(A);return}try{await d({email:l.email,password:l.password,name:l.name||void 0,orgName:l.orgName||void 0}),g(!0),s?.()}catch{}},[l,d,s]);return o?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):r&&!r.needsSetup?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):f?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:w,children:[a&&e.jsx(Z.ErrorMessage,{error:a.message}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-email",className:"cedros-setup__label",children:["Email Address ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-email",type:"email",className:`cedros-setup__input ${m.email?"cedros-setup__input--error":""}`,value:l.email,onChange:b("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:n}),m.email&&e.jsx("span",{className:"cedros-setup__error",children:m.email})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-name",className:"cedros-setup__label",children:"Display Name"}),e.jsx("input",{id:"setup-name",type:"text",className:"cedros-setup__input",value:l.name,onChange:b("name"),placeholder:"Admin",autoComplete:"name",disabled:n})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:l.orgName,onChange:b("orgName"),placeholder:"My Organization",disabled:n})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${m.password?"cedros-setup__input--error":""}`,value:l.password,onChange:b("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:n}),m.password&&e.jsx("span",{className:"cedros-setup__error",children:m.password})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-confirm-password",className:"cedros-setup__label",children:["Confirm Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-confirm-password",type:"password",className:`cedros-setup__input ${m.confirmPassword?"cedros-setup__input--error":""}`,value:l.confirmPassword,onChange:b("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:n}),m.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:m.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Creating Account..."})]}):"Create Admin Account"})]}),e.jsxs("div",{className:"cedros-setup__footer",children:[e.jsx("p",{className:"cedros-setup__note",children:"This will be the first administrator account for your installation."}),r?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",r.serverVersion]})]})]})})}function Xl({title:s="Dashboard",sections:t=["users","team","referrals","deposits","withdrawals","compliance","accreditation-queue","sanctions","signup-gating","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-compliance","settings-referrals","settings-signup","settings-server","settings-images"],defaultSection:r="users",refreshInterval:o=0,pageSize:n=20,onSectionChange:a,onSettingsClick:i,onLogoutClick:d,className:l=""}){const[h,m]=c.useState(r),[u,f]=c.useState(!0),{user:g,logout:b}=M.useCedrosLogin(),{activeOrg:w,role:N,isLoading:A,fetchOrgs:v,hasPermission:k}=Vt.useOrgs(),{status:S,isLoading:E,checkStatus:p}=tr(),{features:y,isLoading:x}=Ke.useServerFeatures(),{canAccess:j}=pe.useDashboardPermissions(),_=c.useCallback(T=>{m(T),a?.(T)},[a]),C=ml.filter(T=>!(!t.includes(T.id)||T.requiredFeature&&!y[T.requiredFeature]||!j(T.id))),P=C.find(T=>T.id===h),L=!P&&!x;return c.useEffect(()=>{v(),p()},[v,p]),c.useEffect(()=>{L&&C.length>0&&m("users")},[L,C.length]),!E&&S?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${l}`,children:e.jsx(zo,{onComplete:()=>p()})}):(A||E||x)&&!w?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${l}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):h==="team"&&!w?e.jsx("div",{className:`cedros-admin cedros-dashboard ${l}`,children:e.jsx(Z.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${l}`,children:[e.jsxs("aside",{className:"cedros-dashboard__sidebar",children:[e.jsx("div",{className:"cedros-dashboard__sidebar-header",children:e.jsxs("div",{className:"cedros-dashboard__logo",children:[J.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:s})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),C.filter(T=>!T.group).map(T=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${h===T.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>_(T.id),"aria-current":h===T.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:T.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:T.label})]},T.id))]}),C.some(T=>T.group==="Configuration")&&e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsxs("button",{type:"button",className:"cedros-dashboard__nav-label cedros-dashboard__nav-label--collapsible",onClick:()=>f(!u),"aria-expanded":u,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${u?"cedros-dashboard__nav-chevron--expanded":""}`,children:J.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))]})]}),g&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(Te.ProfileDropdown,{name:g.name,email:g.email,picture:g.picture,onSettings:i,onLogout:d??b})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:s}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:J.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:P?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[h==="users"&&e.jsx(xl,{pageSize:n,currentUserId:g?.id}),h==="team"&&w&&e.jsx(yl,{orgId:w.id,currentUserId:g?.id,hasPermission:k,role:N}),h==="referrals"&&e.jsx(jl,{}),h==="deposits"&&e.jsx(vl,{pageSize:n,refreshInterval:o}),h==="withdrawals"&&e.jsx(Al,{pageSize:n,refreshInterval:o}),h==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(_n.AuthenticationSettings,{})}),h==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ln.EmbeddedWalletSettings,{})}),h==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Sl,{})}),h==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ht.CreditSystemSettings,{})}),h==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Pn.ServerSettings,{})}),h==="settings-images"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Cl,{})}),h==="compliance"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(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(Io,{})}),h==="settings-referrals"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Do,{})}),h==="signup-gating"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Fo,{})}),h==="settings-signup"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Uo,{})})]})]})]})}var He={},at,Gr;function Jl(){return Gr||(Gr=1,at=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),at}var it={},Le={},Qr;function We(){if(Qr)return Le;Qr=1;let s;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Le.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},Le.getSymbolTotalCodewords=function(o){return t[o]},Le.getBCHDigit=function(r){let o=0;for(;r!==0;)o++,r>>>=1;return o},Le.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');s=o},Le.isKanjiModeEnabled=function(){return typeof s<"u"},Le.toSJIS=function(o){return s(o)},Le}var ct={},Kr;function rr(){return Kr||(Kr=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+r)}}s.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},s.from=function(o,n){if(s.isValid(o))return o;try{return t(o)}catch{return n}}})(ct)),ct}var lt,Yr;function ed(){if(Yr)return lt;Yr=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const r=Math.floor(t/8);return(this.buffer[r]>>>7-t%8&1)===1},put:function(t,r){for(let o=0;o<r;o++)this.putBit((t>>>r-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},lt=s,lt}var dt,Zr;function sd(){if(Zr)return dt;Zr=1;function s(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return s.prototype.set=function(t,r,o,n){const a=t*this.size+r;this.data[a]=o,n&&(this.reservedBit[a]=!0)},s.prototype.get=function(t,r){return this.data[t*this.size+r]},s.prototype.xor=function(t,r,o){this.data[t*this.size+r]^=o},s.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]},dt=s,dt}var ut={},Xr;function td(){return Xr||(Xr=1,(function(s){const t=We().getSymbolSize;s.getRowColCoords=function(o){if(o===1)return[];const n=Math.floor(o/7)+2,a=t(o),i=a===145?26:Math.ceil((a-13)/(2*n-2))*2,d=[a-7];for(let l=1;l<n-1;l++)d[l]=d[l-1]-i;return d.push(6),d.reverse()},s.getPositions=function(o){const n=[],a=s.getRowColCoords(o),i=a.length;for(let d=0;d<i;d++)for(let l=0;l<i;l++)d===0&&l===0||d===0&&l===i-1||d===i-1&&l===0||n.push([a[d],a[l]]);return n}})(ut)),ut}var ht={},Jr;function rd(){if(Jr)return ht;Jr=1;const s=We().getSymbolSize,t=7;return ht.getPositions=function(o){const n=s(o);return[[0,0],[n-t,0],[0,n-t]]},ht}var mt={},en;function nd(){return en||(en=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};s.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},s.from=function(n){return s.isValid(n)?parseInt(n,10):void 0},s.getPenaltyN1=function(n){const a=n.size;let i=0,d=0,l=0,h=null,m=null;for(let u=0;u<a;u++){d=l=0,h=m=null;for(let f=0;f<a;f++){let g=n.get(u,f);g===h?d++:(d>=5&&(i+=t.N1+(d-5)),h=g,d=1),g=n.get(f,u),g===m?l++:(l>=5&&(i+=t.N1+(l-5)),m=g,l=1)}d>=5&&(i+=t.N1+(d-5)),l>=5&&(i+=t.N1+(l-5))}return i},s.getPenaltyN2=function(n){const a=n.size;let i=0;for(let d=0;d<a-1;d++)for(let l=0;l<a-1;l++){const h=n.get(d,l)+n.get(d,l+1)+n.get(d+1,l)+n.get(d+1,l+1);(h===4||h===0)&&i++}return i*t.N2},s.getPenaltyN3=function(n){const a=n.size;let i=0,d=0,l=0;for(let h=0;h<a;h++){d=l=0;for(let m=0;m<a;m++)d=d<<1&2047|n.get(h,m),m>=10&&(d===1488||d===93)&&i++,l=l<<1&2047|n.get(m,h),m>=10&&(l===1488||l===93)&&i++}return i*t.N3},s.getPenaltyN4=function(n){let a=0;const i=n.data.length;for(let l=0;l<i;l++)a+=n.data[l];return Math.abs(Math.ceil(a*100/i/5)-10)*t.N4};function r(o,n,a){switch(o){case s.Patterns.PATTERN000:return(n+a)%2===0;case s.Patterns.PATTERN001:return n%2===0;case s.Patterns.PATTERN010:return a%3===0;case s.Patterns.PATTERN011:return(n+a)%3===0;case s.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(a/3))%2===0;case s.Patterns.PATTERN101:return n*a%2+n*a%3===0;case s.Patterns.PATTERN110:return(n*a%2+n*a%3)%2===0;case s.Patterns.PATTERN111:return(n*a%3+(n+a)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}s.applyMask=function(n,a){const i=a.size;for(let d=0;d<i;d++)for(let l=0;l<i;l++)a.isReserved(l,d)||a.xor(l,d,r(n,l,d))},s.getBestMask=function(n,a){const i=Object.keys(s.Patterns).length;let d=0,l=1/0;for(let h=0;h<i;h++){a(h),s.applyMask(h,n);const m=s.getPenaltyN1(n)+s.getPenaltyN2(n)+s.getPenaltyN3(n)+s.getPenaltyN4(n);s.applyMask(h,n),m<l&&(l=m,d=h)}return d}})(mt)),mt}var fs={},sn;function $o(){if(sn)return fs;sn=1;const s=rr(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return fs.getBlocksCount=function(n,a){switch(a){case s.L:return t[(n-1)*4+0];case s.M:return t[(n-1)*4+1];case s.Q:return t[(n-1)*4+2];case s.H:return t[(n-1)*4+3];default:return}},fs.getTotalCodewordsCount=function(n,a){switch(a){case s.L:return r[(n-1)*4+0];case s.M:return r[(n-1)*4+1];case s.Q:return r[(n-1)*4+2];case s.H:return r[(n-1)*4+3];default:return}},fs}var pt={},as={},tn;function od(){if(tn)return as;tn=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let o=1;for(let n=0;n<255;n++)s[n]=o,t[o]=n,o<<=1,o&256&&(o^=285);for(let n=255;n<512;n++)s[n]=s[n-255]})(),as.log=function(o){if(o<1)throw new Error("log("+o+")");return t[o]},as.exp=function(o){return s[o]},as.mul=function(o,n){return o===0||n===0?0:s[t[o]+t[n]]},as}var rn;function ad(){return rn||(rn=1,(function(s){const t=od();s.mul=function(o,n){const a=new Uint8Array(o.length+n.length-1);for(let i=0;i<o.length;i++)for(let d=0;d<n.length;d++)a[i+d]^=t.mul(o[i],n[d]);return a},s.mod=function(o,n){let a=new Uint8Array(o);for(;a.length-n.length>=0;){const i=a[0];for(let l=0;l<n.length;l++)a[l]^=t.mul(n[l],i);let d=0;for(;d<a.length&&a[d]===0;)d++;a=a.slice(d)}return a},s.generateECPolynomial=function(o){let n=new Uint8Array([1]);for(let a=0;a<o;a++)n=s.mul(n,new Uint8Array([1,t.exp(a)]));return n}})(pt)),pt}var ft,nn;function id(){if(nn)return ft;nn=1;const s=ad();function t(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(o){this.degree=o,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(o.length+this.degree);n.set(o);const a=s.mod(n,this.genPoly),i=this.degree-a.length;if(i>0){const d=new Uint8Array(this.degree);return d.set(a,i),d}return a},ft=t,ft}var gt={},wt={},bt={},on;function Vo(){return on||(on=1,bt.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),bt}var we={},an;function Ho(){if(an)return we;an=1;const s="[0-9]+",t="[A-Z $%*+\\-./:]+";let r="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";r=r.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+r+`)(?:.|[\r
|
|
2050
|
+
]))+`;we.KANJI=new RegExp(r,"g"),we.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),we.BYTE=new RegExp(o,"g"),we.NUMERIC=new RegExp(s,"g"),we.ALPHANUMERIC=new RegExp(t,"g");const n=new RegExp("^"+r+"$"),a=new RegExp("^"+s+"$"),i=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return we.testKanji=function(l){return n.test(l)},we.testNumeric=function(l){return a.test(l)},we.testAlphanumeric=function(l){return i.test(l)},we}var cn;function Oe(){return cn||(cn=1,(function(s){const t=Vo(),r=Ho();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(a,i){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!t.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?a.ccBits[0]:i<27?a.ccBits[1]:a.ccBits[2]},s.getBestModeForData=function(a){return r.testNumeric(a)?s.NUMERIC:r.testAlphanumeric(a)?s.ALPHANUMERIC:r.testKanji(a)?s.KANJI:s.BYTE},s.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},s.isValid=function(a){return a&&a.bit&&a.ccBits};function o(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+n)}}s.from=function(a,i){if(s.isValid(a))return a;try{return o(a)}catch{return i}}})(wt)),wt}var ln;function cd(){return ln||(ln=1,(function(s){const t=We(),r=$o(),o=rr(),n=Oe(),a=Vo(),i=7973,d=t.getBCHDigit(i);function l(f,g,b){for(let w=1;w<=40;w++)if(g<=s.getCapacity(w,b,f))return w}function h(f,g){return n.getCharCountIndicator(f,g)+4}function m(f,g){let b=0;return f.forEach(function(w){const N=h(w.mode,g);b+=N+w.getBitsLength()}),b}function u(f,g){for(let b=1;b<=40;b++)if(m(f,b)<=s.getCapacity(b,g,n.MIXED))return b}s.from=function(g,b){return a.isValid(g)?parseInt(g,10):b},s.getCapacity=function(g,b,w){if(!a.isValid(g))throw new Error("Invalid QR Code version");typeof w>"u"&&(w=n.BYTE);const N=t.getSymbolTotalCodewords(g),A=r.getTotalCodewordsCount(g,b),v=(N-A)*8;if(w===n.MIXED)return v;const k=v-h(w,g);switch(w){case n.NUMERIC:return Math.floor(k/10*3);case n.ALPHANUMERIC:return Math.floor(k/11*2);case n.KANJI:return Math.floor(k/13);case n.BYTE:default:return Math.floor(k/8)}},s.getBestVersionForData=function(g,b){let w;const N=o.from(b,o.M);if(Array.isArray(g)){if(g.length>1)return u(g,N);if(g.length===0)return 1;w=g[0]}else w=g;return l(w.mode,w.getLength(),N)},s.getEncodedBits=function(g){if(!a.isValid(g)||g<7)throw new Error("Invalid QR Code version");let b=g<<12;for(;t.getBCHDigit(b)-d>=0;)b^=i<<t.getBCHDigit(b)-d;return g<<12|b}})(gt)),gt}var xt={},dn;function ld(){if(dn)return xt;dn=1;const s=We(),t=1335,r=21522,o=s.getBCHDigit(t);return xt.getEncodedBits=function(a,i){const d=a.bit<<3|i;let l=d<<10;for(;s.getBCHDigit(l)-o>=0;)l^=t<<s.getBCHDigit(l)-o;return(d<<10|l)^r},xt}var yt={},vt,un;function dd(){if(un)return vt;un=1;const s=Oe();function t(r){this.mode=s.NUMERIC,this.data=r.toString()}return t.getBitsLength=function(o){return 10*Math.floor(o/3)+(o%3?o%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(o){let n,a,i;for(n=0;n+3<=this.data.length;n+=3)a=this.data.substr(n,3),i=parseInt(a,10),o.put(i,10);const d=this.data.length-n;d>0&&(a=this.data.substr(n),i=parseInt(a,10),o.put(i,d*3+1))},vt=t,vt}var At,hn;function ud(){if(hn)return At;hn=1;const s=Oe(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function r(o){this.mode=s.ALPHANUMERIC,this.data=o}return r.getBitsLength=function(n){return 11*Math.floor(n/2)+6*(n%2)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(n){let a;for(a=0;a+2<=this.data.length;a+=2){let i=t.indexOf(this.data[a])*45;i+=t.indexOf(this.data[a+1]),n.put(i,11)}this.data.length%2&&n.put(t.indexOf(this.data[a]),6)},At=r,At}var jt,mn;function hd(){if(mn)return jt;mn=1;const s=Oe();function t(r){this.mode=s.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}return t.getBitsLength=function(o){return o*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(r){for(let o=0,n=this.data.length;o<n;o++)r.put(this.data[o],8)},jt=t,jt}var Nt,pn;function md(){if(pn)return Nt;pn=1;const s=Oe(),t=We();function r(o){this.mode=s.KANJI,this.data=o}return r.getBitsLength=function(n){return n*13},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(o){let n;for(n=0;n<this.data.length;n++){let a=t.toSJIS(this.data[n]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[n]+`
|
|
2051
|
+
Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},Nt=r,Nt}var kt={exports:{}},fn;function pd(){return fn||(fn=1,(function(s){var t={single_source_shortest_paths:function(r,o,n){var a={},i={};i[o]=0;var d=t.PriorityQueue.make();d.push(o,0);for(var l,h,m,u,f,g,b,w,N;!d.empty();){l=d.pop(),h=l.value,u=l.cost,f=r[h]||{};for(m in f)f.hasOwnProperty(m)&&(g=f[m],b=u+g,w=i[m],N=typeof i[m]>"u",(N||w>b)&&(i[m]=b,d.push(m,b),a[m]=h))}if(typeof n<"u"&&typeof i[n]>"u"){var A=["Could not find a path from ",o," to ",n,"."].join("");throw new Error(A)}return a},extract_shortest_path_from_predecessor_list:function(r,o){for(var n=[],a=o;a;)n.push(a),r[a],a=r[a];return n.reverse(),n},find_path:function(r,o,n){var a=t.single_source_shortest_paths(r,o,n);return t.extract_shortest_path_from_predecessor_list(a,n)},PriorityQueue:{make:function(r){var o=t.PriorityQueue,n={},a;r=r||{};for(a in o)o.hasOwnProperty(a)&&(n[a]=o[a]);return n.queue=[],n.sorter=r.sorter||o.default_sorter,n},default_sorter:function(r,o){return r.cost-o.cost},push:function(r,o){var n={value:r,cost:o};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=t})(kt)),kt.exports}var gn;function fd(){return gn||(gn=1,(function(s){const t=Oe(),r=dd(),o=ud(),n=hd(),a=md(),i=Ho(),d=We(),l=pd();function h(A){return unescape(encodeURIComponent(A)).length}function m(A,v,k){const S=[];let E;for(;(E=A.exec(k))!==null;)S.push({data:E[0],index:E.index,mode:v,length:E[0].length});return S}function u(A){const v=m(i.NUMERIC,t.NUMERIC,A),k=m(i.ALPHANUMERIC,t.ALPHANUMERIC,A);let S,E;return d.isKanjiModeEnabled()?(S=m(i.BYTE,t.BYTE,A),E=m(i.KANJI,t.KANJI,A)):(S=m(i.BYTE_KANJI,t.BYTE,A),E=[]),v.concat(k,S,E).sort(function(y,x){return y.index-x.index}).map(function(y){return{data:y.data,mode:y.mode,length:y.length}})}function f(A,v){switch(v){case t.NUMERIC:return r.getBitsLength(A);case t.ALPHANUMERIC:return o.getBitsLength(A);case t.KANJI:return a.getBitsLength(A);case t.BYTE:return n.getBitsLength(A)}}function g(A){return A.reduce(function(v,k){const S=v.length-1>=0?v[v.length-1]:null;return S&&S.mode===k.mode?(v[v.length-1].data+=k.data,v):(v.push(k),v)},[])}function b(A){const v=[];for(let k=0;k<A.length;k++){const S=A[k];switch(S.mode){case t.NUMERIC:v.push([S,{data:S.data,mode:t.ALPHANUMERIC,length:S.length},{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.ALPHANUMERIC:v.push([S,{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.KANJI:v.push([S,{data:S.data,mode:t.BYTE,length:h(S.data)}]);break;case t.BYTE:v.push([{data:S.data,mode:t.BYTE,length:h(S.data)}])}}return v}function w(A,v){const k={},S={start:{}};let E=["start"];for(let p=0;p<A.length;p++){const y=A[p],x=[];for(let j=0;j<y.length;j++){const _=y[j],C=""+p+j;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]=f(k[L].lastCount+_.length,_.mode)-f(k[L].lastCount,_.mode),k[L].lastCount+=_.length):(k[L]&&(k[L].lastCount=_.length),S[L][C]=f(_.length,_.mode)+4+t.getCharCountIndicator(_.mode,v))}}E=x}for(let p=0;p<E.length;p++)S[E[p]].end=0;return{map:S,table:k}}function N(A,v){let k;const S=t.getBestModeForData(A);if(k=t.from(v,S),k!==t.BYTE&&k.bit<S.bit)throw new Error('"'+A+'" cannot be encoded with mode '+t.toString(k)+`.
|
|
2052
|
+
Suggested mode is: `+t.toString(S));switch(k===t.KANJI&&!d.isKanjiModeEnabled()&&(k=t.BYTE),k){case t.NUMERIC:return new r(A);case t.ALPHANUMERIC:return new o(A);case t.KANJI:return new a(A);case t.BYTE:return new n(A)}}s.fromArray=function(v){return v.reduce(function(k,S){return typeof S=="string"?k.push(N(S,null)):S.data&&k.push(N(S.data,S.mode)),k},[])},s.fromString=function(v,k){const S=u(v,d.isKanjiModeEnabled()),E=b(S),p=w(E,k),y=l.find_path(p.map,"start","end"),x=[];for(let j=1;j<y.length-1;j++)x.push(p.table[y[j]].node);return s.fromArray(g(x))},s.rawSplit=function(v){return s.fromArray(u(v,d.isKanjiModeEnabled()))}})(yt)),yt}var wn;function gd(){if(wn)return it;wn=1;const s=We(),t=rr(),r=ed(),o=sd(),n=td(),a=rd(),i=nd(),d=$o(),l=id(),h=cd(),m=ld(),u=Oe(),f=fd();function g(p,y){const x=p.size,j=a.getPositions(y);for(let _=0;_<j.length;_++){const C=j[_][0],P=j[_][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?p.set(C+L,P+R,!0,!0):p.set(C+L,P+R,!1,!0))}}function b(p){const y=p.size;for(let x=8;x<y-8;x++){const j=x%2===0;p.set(x,6,j,!0),p.set(6,x,j,!0)}}function w(p,y){const x=n.getPositions(y);for(let j=0;j<x.length;j++){const _=x[j][0],C=x[j][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?p.set(_+P,C+L,!0,!0):p.set(_+P,C+L,!1,!0)}}function N(p,y){const x=p.size,j=h.getEncodedBits(y);let _,C,P;for(let L=0;L<18;L++)_=Math.floor(L/3),C=L%3+x-8-3,P=(j>>L&1)===1,p.set(_,C,P,!0),p.set(C,_,P,!0)}function A(p,y,x){const j=p.size,_=m.getEncodedBits(y,x);let C,P;for(C=0;C<15;C++)P=(_>>C&1)===1,C<6?p.set(C,8,P,!0):C<8?p.set(C+1,8,P,!0):p.set(j-15+C,8,P,!0),C<8?p.set(8,j-C-1,P,!0):C<9?p.set(8,15-C-1+1,P,!0):p.set(8,15-C-1,P,!0);p.set(j-8,8,1,!0)}function v(p,y){const x=p.size;let j=-1,_=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(!p.isReserved(_,L-R)){let T=!1;P<y.length&&(T=(y[P]>>>C&1)===1),p.set(_,L-R,T),C--,C===-1&&(P++,C=7)}if(_+=j,_<0||x<=_){_-=j,j=-j;break}}}function k(p,y,x){const j=new r;x.forEach(function(R){j.put(R.mode.bit,4),j.put(R.getLength(),u.getCharCountIndicator(R.mode,p)),R.write(j)});const _=s.getSymbolTotalCodewords(p),C=d.getTotalCodewordsCount(p,y),P=(_-C)*8;for(j.getLengthInBits()+4<=P&&j.put(0,4);j.getLengthInBits()%8!==0;)j.putBit(0);const L=(P-j.getLengthInBits())/8;for(let R=0;R<L;R++)j.put(R%2?17:236,8);return S(j,p,y)}function S(p,y,x){const j=s.getSymbolTotalCodewords(y),_=d.getTotalCodewordsCount(y,x),C=j-_,P=d.getBlocksCount(y,x),L=j%P,R=P-L,T=Math.floor(j/P),B=Math.floor(C/P),F=B+1,W=T-B,q=new l(W);let D=0;const $=new Array(P),Q=new Array(P);let H=0;const re=new Uint8Array(p.buffer);for(let ie=0;ie<P;ie++){const Ae=ie<R?B:F;$[ie]=re.slice(D,D+Ae),Q[ie]=q.encode($[ie]),D+=Ae,H=Math.max(H,Ae)}const I=new Uint8Array(j);let O=0,X,Y;for(X=0;X<H;X++)for(Y=0;Y<P;Y++)X<$[Y].length&&(I[O++]=$[Y][X]);for(X=0;X<W;X++)for(Y=0;Y<P;Y++)I[O++]=Q[Y][X];return I}function E(p,y,x,j){let _;if(Array.isArray(p))_=f.fromArray(p);else if(typeof p=="string"){let T=y;if(!T){const B=f.rawSplit(p);T=h.getBestVersionForData(B,x)}_=f.fromString(p,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,
|
|
2056
|
-
`;return typeof d=="function"&&d(null,N),N},
|
|
2057
|
-
`);await navigator.clipboard.writeText(x)}},p=async()=>{try{await l(
|
|
2058
|
-
`))};return o&&!r?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(Q.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):n&&!r?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(te.ErrorMessage,{error:n,onDismiss:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>a(),children:"Retry"})]}):h==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(cr,{onSuccess:E,onCancel:()=>m("status")})}):h==="disable"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),k&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(J.PasswordInput,{label:"Password",placeholder:"Enter your password",value:u,onChange:j=>f(j.target.value),disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{m("status"),f(""),S(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:p,disabled:A||u.length===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):h==="regenerate"?g?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:g.map((j,L)=>e.jsx("code",{className:"cedros-totp-backup-code",children:j},L))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:x,children:"Copy all codes"}),e.jsx("div",{className:"cedros-totp-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>{m("status"),N(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),k&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(J.OtpInput,{value:w,onChange:b,onComplete:y,disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{m("status"),b(""),S(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:y,disabled:A||w.length!==6,children:A?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${r?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:r?.enabled?"Enabled":"Disabled"})]}),r?.enabled?e.jsxs("div",{className:"cedros-totp-enabled-actions",children:[e.jsxs("div",{className:"cedros-totp-description",style:{marginTop:"0.25rem"},children:["Recovery codes remaining: ",e.jsx("strong",{children:r.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>m("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>m("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>m("setup"),children:"Enable two-factor authentication"})]})})}class jd{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(r){throw M.handleApiError(r,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(r){throw M.handleApiError(r,"Failed to update profile")}}}function hs(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useMemo(()=>new jd(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),l=c.useCallback(()=>{i(null)},[]),h=c.useCallback(async u=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");n(!0),i(null);try{return await d.updateProfile(u)}catch(f){const w=f instanceof Error?f:new Error("Failed to update profile");throw i(w),w}finally{n(!1)}},[t,d]),m=c.useCallback(async u=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");n(!0),i(null);try{await d.changePassword(u)}catch(f){const w=f instanceof Error?f:new Error("Failed to change password");throw i(w),w}finally{n(!1)}},[t,d]);return{isLoading:o,error:a,updateProfile:h,changePassword:m,clearError:l}}function Xo(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),d=c.useCallback(async()=>{o(!0),a(null);try{return await i.get("/referral",{credentials:"include"})}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[i]),l=c.useCallback(async()=>{o(!0),a(null);try{return(await i.post("/referral/regenerate",void 0,{credentials:"include"})).referralCode}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[i]);return{getReferral:d,regenerateCode:l,isLoading:r,error:n}}function Nd({onPasswordChange:s,onClose:t,className:r=""}){const{user:o,refreshUser:n}=D.useAuth(),{config:a,_internal:i}=M.useCedrosLogin(),{isLoading:d,error:l,changePassword:h,updateProfile:m,clearError:u}=hs(),[f,w]=c.useState("main"),[b,g]=c.useState(""),[N,A]=c.useState(""),[v,k]=c.useState(""),[S,E]=c.useState(null),[p,y]=c.useState(null),[x,j]=c.useState(!1),L=c.useRef(null),[C,P]=c.useState(o?.payoutWalletAddress??""),[_,R]=c.useState(!1),[T,I]=c.useState(!1),[O,W]=c.useState(null),q=c.useCallback(async()=>{const K=C.trim();if(K.length>0&&(K.length<32||K.length>44)){W("Invalid Solana address — must be 32–44 characters.");return}const ge=/^[1-9A-HJ-NP-Za-km-z]+$/;if(K.length>0&&!ge.test(K)){W("Invalid Solana address — contains non-base58 characters.");return}W(null),R(!0);try{await m({payoutWalletAddress:K||void 0}),await n(),I(!0),setTimeout(()=>I(!1),2e3)}catch(be){W(be instanceof Error?be.message:"Failed to save payout wallet")}finally{R(!1)}},[C,m,n]),{getReferral:U,regenerateCode:F,isLoading:V}=Xo(),[Y,X]=c.useState(null),[B,z]=c.useState(0),[$,H]=c.useState(!1),[se,ue]=c.useState(!1);c.useEffect(()=>{U().then(K=>{X(K.referralCode),z(K.referralCount),ue(K.directPayoutEnabled)}).catch(()=>{})},[]);const we=We.validatePassword(N),rs=N===v,Ue=b.length>0&&N.length>0&&v.length>0&&we.isValid&&rs,De=c.useCallback(async K=>{const ge=K.target.files?.[0];if(ge){E(null),j(!0);try{const be=new FormData;be.append("file",ge);const ms=i?.getAccessToken?.(),Fe={};ms&&(Fe.Authorization=`Bearer ${ms}`);const Ve=await fetch(`${a.serverUrl}/auth/upload/avatar`,{method:"POST",headers:Fe,body:be,credentials:"include"});if(!Ve.ok){const He=await Ve.json().catch(()=>null);throw new Error(He?.message||He?.error||`Upload failed (${Ve.status})`)}await n()}catch(be){E(be instanceof Error?be.message:"Failed to upload avatar")}finally{j(!1),L.current&&(L.current.value="")}}},[a.serverUrl,i,n]),Hs=c.useCallback(async()=>{if(Ue){E(null),y(null);try{await h({currentPassword:b,newPassword:N}),g(""),A(""),k(""),y("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{w("main"),y(null)},2e3)}catch(K){E(K instanceof Error?K.message:"Failed to change password")}}},[Ue,b,N,h,s]),ns=c.useCallback(()=>{w("main"),g(""),A(""),k(""),E(null),u()},[u]),$e=()=>o?.name?o.name.split(" ").map(K=>K[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?";return f==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(S||l)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:S||l?.message||""},onDismiss:()=>{E(null),u()}})}),p&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),p]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:b,onChange:K=>g(K.target.value),disabled:d,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"New password",placeholder:"Enter new password",value:N,onChange:K=>A(K.target.value),disabled:d,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:v,onChange:K=>k(K.target.value),disabled:d,error:v.length>0&&!rs?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:ns,disabled:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:Hs,disabled:d||!Ue,children:d?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsxs("div",{className:"cedros-profile-avatar-container cedros-profile-avatar-container--clickable",onClick:()=>L.current?.click(),role:"button",tabIndex:0,onKeyDown:K=>{(K.key==="Enter"||K.key===" ")&&(K.preventDefault(),L.current?.click())},"aria-label":"Change profile picture",children:[x?e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:e.jsx(Q.LoadingSpinner,{size:"sm"})}):o?.picture?e.jsx("img",{src:o.picture,alt:o.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:$e()}),e.jsx("div",{className:"cedros-profile-avatar-overlay",children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"}),e.jsx("circle",{cx:"12",cy:"13",r:"4"})]})}),e.jsx("input",{ref:L,type:"file",accept:"image/jpeg,image/png,image/gif,image/webp",onChange:De,className:"cedros-profile-avatar-input","aria-hidden":"true",tabIndex:-1})]}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:o?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:o?.email})]})]}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:o?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:"••••••••"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>w("change-password"),children:"Change"})]})]}),Y&&e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Referral"}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Your code"}),e.jsx("span",{className:"cedros-profile-row-value cedros-profile-row-value--mono",children:Y})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{navigator.clipboard.writeText(Y),H(!0),setTimeout(()=>H(!1),2e3)},children:$?"Copied":"Copy"})]}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Referrals"}),e.jsx("span",{className:"cedros-profile-row-value",children:B})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:async()=>{try{const K=await F();X(K)}catch{}},disabled:V,children:V?"Regenerating...":"Regenerate"})]})]}),se&&e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Payout wallet"}),e.jsx("p",{className:"cedros-profile-description",children:"Solana wallet address to receive direct referral payouts when enabled by the platform."}),e.jsxs("div",{className:"cedros-profile-row cedros-profile-row--column",children:[e.jsx("input",{type:"text",className:"cedros-input",placeholder:"Solana wallet address (base58)",value:C,onChange:K=>{P(K.target.value),W(null)},disabled:_,maxLength:44}),O&&e.jsx("span",{className:"cedros-profile-error-text",children:O}),T&&e.jsx("span",{className:"cedros-profile-success-text",children:"Saved."})]}),e.jsx("div",{className:"cedros-profile-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:q,disabled:_,children:_?"Saving...":"Save wallet"})})]}),t&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})})}class kd{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(t){throw M.handleApiError(t,"Failed to list credentials")}}async unlinkCredential(t){try{await this.client.delete(`/credentials/${encodeURIComponent(t)}`)}catch(r){throw M.handleApiError(r,"Failed to unlink credential")}}}function lr(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useMemo(()=>new kd(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),m=c.useCallback(()=>{l(null)},[]),u=c.useCallback(async()=>{if(t!=="authenticated"){n([]);return}i(!0),l(null);try{const w=await h.listCredentials();n(w)}catch(w){l(w)}finally{i(!1)}},[t,h]);c.useEffect(()=>{t==="authenticated"?u():n([])},[t,u]);const f=c.useCallback(async w=>{i(!0),l(null);try{await h.unlinkCredential(w),await u()}catch(b){throw l(b),b}finally{i(!1)}},[h,u]);return{credentials:o,isLoading:a,error:d,fetchCredentials:u,unlinkCredential:f,clearError:m}}function Sd({onPasswordChange:s,onCancel:t,className:r=""}){const{isLoading:o,error:n,changePassword:a,clearError:i}=hs(),[d,l]=c.useState(""),[h,m]=c.useState(""),[u,f]=c.useState(""),[w,b]=c.useState(null),[g,N]=c.useState(null),A=We.validatePassword(h),v=h===u,k=d.length>0&&h.length>0&&u.length>0&&A.isValid&&v,S=c.useCallback(async()=>{if(k){b(null),N(null);try{await a({currentPassword:d,newPassword:h}),l(""),m(""),f(""),N("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>t(),2e3)}catch(p){b(p instanceof Error?p.message:"Failed to change password")}}},[k,d,h,a,s,t]),E=c.useCallback(()=>{b(null),i(),t()},[i,t]);return e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(w||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:w||n?.message||""},onDismiss:()=>{b(null),i()}})}),g&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),g]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:d,onChange:p=>l(p.target.value),disabled:o,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"New password",placeholder:"Enter new password",value:h,onChange:p=>m(p.target.value),disabled:o,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(J.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:u,onChange:p=>f(p.target.value),disabled:o,error:u.length>0&&!v?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:E,disabled:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:S,disabled:o||!k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(Q.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function Jo({onPasswordChange:s,className:t=""}){const{user:r,refreshUser:o}=D.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:d}=hs(),{credentials:l}=lr(),{forgotPassword:h,isLoading:m,isSuccess:u,reset:f}=Ws(),w=l.some(j=>j.credentialType==="password"),[b,g]=c.useState("view"),[N,A]=c.useState(""),[v,k]=c.useState(null),S=()=>r?.name?r.name.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2):r?.email?r.email[0].toUpperCase():"?",E=c.useCallback(()=>{A(r?.name||""),g("edit"),k(null)},[r?.name]),p=c.useCallback(async()=>{const j=N.trim();if(j){k(null);try{await i({name:j}),await o(),g("view")}catch(L){k(L instanceof Error?L.message:"Failed to update name")}}},[N,i,o]),y=c.useCallback(()=>{g("view"),A(""),k(null),d()},[d]),x=c.useCallback(async()=>{if(r?.email){k(null);try{await h(r.email)}catch(j){k(j instanceof Error?j.message:"Failed to send password setup email")}}},[r?.email,h]);return b==="change-password"?e.jsx(Sd,{onPasswordChange:s,onCancel:()=>g("view"),className:t}):e.jsx("div",{className:`cedros-profile-settings ${t}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:r?.picture?e.jsx("img",{src:r.picture,alt:r.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:S()})}),e.jsxs("div",{className:"cedros-profile-info",children:[b==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:N,onChange:j=>A(j.target.value),disabled:n,autoFocus:!0,onKeyDown:j=>{j.key==="Enter"&&p(),j.key==="Escape"&&y()}}),e.jsxs("div",{className:"cedros-profile-name-edit-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:p,disabled:n||!N.trim(),children:n?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,disabled:n,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:r?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:E,title:"Edit name","aria-label":"Edit name",children:e.jsx(Cd,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:r?.email})]})]}),(v||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v||a?.message||""},onDismiss:()=>{k(null),d()}})}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:r?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:w?"••••••••":"Not set"})]}),w?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{g("change-password"),k(null)},children:"Change"}):u?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:f,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:x,disabled:m,children:m?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function Cd(){return e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M16.474 5.408l2.118 2.117m-.756-3.982L12.109 9.27a2.118 2.118 0 00-.58 1.082L11 13l2.648-.53c.41-.082.786-.283 1.082-.579l5.727-5.727a1.853 1.853 0 10-2.621-2.621z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M19 15v3a2 2 0 01-2 2H6a2 2 0 01-2-2V7a2 2 0 012-2h3",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}const ea={password:"Email & Password",oauth_google:"Google",oauth_apple:"Apple",solana:"Solana Wallet",webauthn_passkey:"Passkey",webauthn_security_key:"Security Key",totp:"Authenticator App (2FA)",sso_oidc:"Single Sign-On"};function sa({onLinkGoogle:s,onLinkApple:t,onAddPasskey:r,onLinkSolana:o,className:n=""}){const{credentials:a,isLoading:i,error:d,unlinkCredential:l,clearError:h,fetchCredentials:m}=lr(),{registerPasskey:u,isSupported:f}=nr(),[w,b]=c.useState(null),[g,N]=c.useState(!1),A=c.useCallback(async()=>{if(r){r();return}N(!0);try{await u(),await m()}catch{}finally{N(!1)}},[r,u,m]),v=c.useCallback(async j=>{const L=j.label||ea[j.credentialType];if(window.confirm(`Remove "${L}" as a sign-in method? You won't be able to sign in with it anymore.`)){b(j.id);try{await l(j.id)}catch{}finally{b(null)}}},[l]),k=new Set(a.map(j=>j.credentialType)),S=s&&!k.has("oauth_google"),E=t&&!k.has("oauth_apple"),p=(r||f)&&!k.has("webauthn_passkey"),y=o&&!k.has("solana"),x=S||E||p||y;return i&&a.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[d&&e.jsx(te.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:d.message},onDismiss:h}),a.length===0&&!i&&e.jsx("p",{className:"cedros-linked-accounts-empty",children:"No linked sign-in methods found."}),a.length>0&&e.jsx("ul",{className:"cedros-linked-credential-list",children:a.map(j=>e.jsx(Ed,{credential:j,isUnlinking:w===j.id,onUnlink:v},j.id))}),x&&e.jsxs("div",{className:"cedros-linked-add",children:[e.jsx("p",{className:"cedros-linked-add-label",children:"Link a new sign-in method"}),e.jsxs("div",{className:"cedros-linked-add-buttons",children:[S&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(ta,{})," Google"]}),E&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(ra,{})," Apple"]}),p&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:A,disabled:g,children:g?e.jsx(Q.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Vt,{})," Passkey"]})}),y&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(na,{})," Solana"]})]})]})]})}function Ed({credential:s,isUnlinking:t,onUnlink:r}){const o=s.label||ea[s.credentialType],n=_d[s.credentialType]||Ld;return e.jsxs("li",{className:"cedros-linked-credential",children:[e.jsx("div",{className:"cedros-linked-credential__icon",children:e.jsx(n,{})}),e.jsxs("div",{className:"cedros-linked-credential__info",children:[e.jsx("span",{className:"cedros-linked-credential__name",children:o}),e.jsxs("span",{className:"cedros-linked-credential__meta",children:["Added ",kn(s.createdAt),s.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",kn(s.lastUsedAt)]}),s.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>r(s),disabled:t,title:s.isPrimary?"Cannot remove primary sign-in method":"Remove",children:t?e.jsx(Q.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function kn(s){const t=new Date(s),o=new Date().getTime()-t.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n}m ago`:a<24?`${a}h ago`:i<30?`${i}d ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const _d={password:Pd,oauth_google:ta,oauth_apple:ra,solana:na,webauthn_passkey:Vt,webauthn_security_key:Vt,totp:Rd,sso_oidc:Td};function Ld(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M12 8v4m0 4h.01",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Pd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M7 11V7a5 5 0 0110 0v4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"16",r:"1.5",fill:"currentColor"})]})}function ta(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M21.8 12.2c0-.7-.1-1.4-.2-2H12v3.8h5.5a4.7 4.7 0 01-2 3.1v2.5h3.3c1.9-1.7 3-4.3 3-7.4z",fill:"#4285F4"}),e.jsx("path",{d:"M12 22c2.7 0 5-.9 6.6-2.4l-3.3-2.5c-.9.6-2 1-3.3 1-2.5 0-4.7-1.7-5.4-4H3.2v2.6A10 10 0 0012 22z",fill:"#34A853"}),e.jsx("path",{d:"M6.6 14.1a6 6 0 010-4.2V7.3H3.2a10 10 0 000 9.4l3.4-2.6z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.9c1.4 0 2.7.5 3.7 1.4l2.8-2.8A10 10 0 0012 2 10 10 0 003.2 7.3l3.4 2.6C7.3 7.6 9.5 5.9 12 5.9z",fill:"#EA4335"})]})}function ra(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M17.05 20.28c-.98.95-2.05.88-3.08.4-1.09-.5-2.08-.48-3.24 0-1.44.62-2.2.44-3.06-.4C3.79 16.16 4.36 9.53 8.72 9.28c1.3.07 2.2.74 2.96.8.93-.2 1.82-.92 3.03-.83 1.47.12 2.57.72 3.28 1.83-3.02 1.8-2.3 5.75.5 6.86-.6 1.53-1.37 3.04-2.44 4.34zM12.03 9.2C11.88 7.17 13.5 5.5 15.4 5.35c.29 2.28-2.08 3.98-3.37 3.85z",fill:"currentColor"})})}function na(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"6",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M2 10h20",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"17",cy:"14",r:"1.5",fill:"currentColor"})]})}function Vt(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"10",cy:"7",r:"4",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M3 21v-2a7 7 0 017-7",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M17 14v4m0 0v2m0-2h-2m2 0h2",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Rd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M9 12h6M12 9v6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Td(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.5"})]})}class Md{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(t){throw M.handleApiError(t,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(t){throw M.handleApiError(t,"Failed to revoke sessions")}}}function oa(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useMemo(()=>new Md(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),m=c.useCallback(async()=>{if(t!=="authenticated"){n([]);return}i(!0),l(null);try{const w=await h.listSessions();n(w)}catch(w){l(w)}finally{i(!1)}},[t,h]);c.useEffect(()=>{t==="authenticated"?m():n([])},[t,m]);const u=c.useCallback(async()=>{i(!0),l(null);try{const w=await h.revokeAllSessions();return await m(),w}catch(w){throw l(w),w}finally{i(!1)}},[h,m]),f=c.useMemo(()=>o.filter(w=>!w.isCurrent).length,[o]);return{sessions:o,isLoading:a,error:d,fetchSessions:m,revokeAllSessions:u,otherSessionCount:f}}const Id={profile:"Profile",security:"Security",linked:"Linked Accounts"},Bd=["profile","security","linked"];function Ud({defaultTab:s="profile",onClose:t,onPasswordChange:r,onTotpChange:o,onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:d,className:l=""}){const[h,m]=c.useState(s),{sessions:u,isLoading:f,error:w,revokeAllSessions:b}=oa();return e.jsxs("div",{className:`cedros-account-settings ${l}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:Bd.map(g=>e.jsx("button",{type:"button",role:"tab","aria-selected":h===g,className:`cedros-account-tab ${h===g?"cedros-account-tab-active":""}`,onClick:()=>m(g),children:Id[g]},g))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[h==="profile"&&e.jsx(Jo,{onPasswordChange:r}),h==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Zo,{onStatusChange:o}),e.jsx(jo,{sessions:u,isLoading:f,error:w??void 0,onRevokeAll:async()=>{await b()}})]}),h==="linked"&&e.jsx(sa,{onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:d})]}),t&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})}function Dd({onComplete:s,className:t}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${t??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(cr,{onSuccess:s})})]})}function Fd({onComplete:s,onSkip:t,className:r}){const{user:o}=D.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:d}=hs(),[l,h]=c.useState(o?.name??""),m=c.useCallback(async f=>{f.preventDefault(),d();const w=l.trim();if(!w){s?.();return}try{await i({name:w}),s?.()}catch{}},[l,i,d,s]),u=l.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${r??""}`,children:[e.jsxs("div",{className:"cedros-complete-account__header",children:[e.jsx("h2",{className:"cedros-complete-account__title",children:"Complete Your Profile"}),e.jsx("p",{className:"cedros-complete-account__description",children:"Please fill in your name to get started."})]}),e.jsxs("form",{onSubmit:m,className:"cedros-complete-account__form",children:[e.jsxs("div",{className:"cedros-complete-account__field",children:[e.jsx("label",{htmlFor:"cedros-complete-name",className:"cedros-complete-account__label",children:"Name"}),e.jsx("input",{id:"cedros-complete-name",type:"text",value:l,onChange:f=>h(f.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),a&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:a.message}),e.jsxs("div",{className:"cedros-complete-account__actions",children:[e.jsx("button",{type:"submit",className:"cedros-complete-account__button cedros-complete-account__button--primary",disabled:n||!u,children:n?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:t,disabled:n,children:"Skip"})]})]})]})}function aa(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),d=c.useCallback(async m=>await i.get(`/username/available?username=${encodeURIComponent(m)}`,{credentials:"include"}),[i]),l=c.useCallback(async()=>{try{return(await i.get("/username/available?username=",{credentials:"include"})).suggestion??null}catch{return null}},[i]),h=c.useCallback(async m=>{o(!0),a(null);try{await i.patch("/me",{username:m})}catch(u){const f=u instanceof Error?u:new Error(String(u));throw a(f),f}finally{o(!1)}},[i]);return{checkAvailability:d,getSuggestion:l,setUsername:h,isLoading:r,error:n}}function Od({onComplete:s,onSkip:t,className:r}){const{checkAvailability:o,getSuggestion:n,setUsername:a,isLoading:i,error:d}=aa(),[l,h]=c.useState(""),[m,u]=c.useState("idle"),[f,w]=c.useState(""),b=c.useRef(null),g=c.useRef(!0);c.useEffect(()=>(g.current=!0,n().then(k=>{g.current&&k&&(h(k),u("available"),w("Available"))}),()=>{g.current=!1}),[n]);const N=c.useCallback(k=>{const S=k.toLowerCase().replace(/[^a-z0-9_]/g,"");if(h(S),u("idle"),w(""),b.current&&clearTimeout(b.current),S.length<3){S.length>0&&(u("error"),w("At least 3 characters"));return}u("checking"),b.current=setTimeout(async()=>{try{const E=await o(S);if(!g.current)return;E.error?(u("error"),w(E.error)):E.available?(u("available"),w("Available")):(u("taken"),w("Already taken"),E.suggestion)}catch{if(!g.current)return;u("error"),w("Could not check availability")}},400)},[o]),A=c.useCallback(async k=>{if(k.preventDefault(),!(m!=="available"||!l.trim()))try{await a(l.trim()),s?.()}catch{}},[l,m,a,s]),v=m==="available"&&!i;return e.jsxs("div",{className:`cedros-choose-username ${r??""}`,children:[e.jsxs("div",{className:"cedros-choose-username__header",children:[e.jsx("h2",{className:"cedros-choose-username__title",children:"Choose a Username"}),e.jsx("p",{className:"cedros-choose-username__description",children:"Pick a unique handle for your account."})]}),e.jsxs("form",{onSubmit:A,className:"cedros-choose-username__form",children:[e.jsxs("div",{className:"cedros-choose-username__field",children:[e.jsx("label",{htmlFor:"cedros-choose-username",className:"cedros-choose-username__label",children:"Username"}),e.jsxs("div",{className:"cedros-choose-username__input-wrapper",children:[e.jsx("span",{className:"cedros-choose-username__prefix",children:"@"}),e.jsx("input",{id:"cedros-choose-username",type:"text",value:l,onChange:k=>N(k.target.value),placeholder:"swift_falcon_42",className:"cedros-choose-username__input",maxLength:30,autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),f&&e.jsx("span",{className:`cedros-choose-username__status cedros-choose-username__status--${m}`,role:m==="error"||m==="taken"?"alert":void 0,children:m==="checking"?"Checking...":f})]}),d&&e.jsx("div",{className:"cedros-choose-username__error",role:"alert",children:d.message}),e.jsxs("div",{className:"cedros-choose-username__actions",children:[e.jsx("button",{type:"submit",className:"cedros-choose-username__button cedros-choose-username__button--primary",disabled:!v,children:i?"Saving...":"Continue"}),e.jsx("button",{type:"button",className:"cedros-choose-username__button cedros-choose-username__button--secondary",onClick:t,disabled:i,children:"Skip"})]})]})]})}function ia(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),i=c.useCallback(()=>{n(null)},[]),d=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(b)||b<=0){const g=new Error(`Invalid deposit amount: ${b}. Must be a positive integer (lamports).`);throw n(g.message),g}r(!0),n(null);try{return await a.post("/deposit",{amount_lamports:b})}catch(g){const N=M.handleApiError(g,"Failed to execute deposit");throw n(N.message),N}finally{r(!1)}},[a]),l=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");return await a.get(`/deposit/status/${encodeURIComponent(b)}`)},[a]),h=c.useCallback(async()=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/deposit/config")}catch(b){const g=M.handleApiError(b,"Failed to get deposit config");throw n(g.message),g}finally{r(!1)}},[a]),m=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=new URLSearchParams;b?.limit!==void 0&&g.set("limit",String(b.limit)),b?.offset!==void 0&&g.set("offset",String(b.offset));const N=g.toString(),A=N?`/deposits?${N}`:"/deposits";return await a.get(A)}catch(g){const N=M.handleApiError(g,"Failed to list deposits");throw n(N.message),N}finally{r(!1)}},[a]),u=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=new URLSearchParams({input_mint:b.inputMint,amount:String(b.amount),taker:b.taker});return await a.get(`/deposit/quote?${g}`)}catch(g){const N=M.handleApiError(g,"Failed to get deposit quote");throw n(N.message),N}finally{r(!1)}},[a]),f=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/public",b)}catch(g){const N=M.handleApiError(g,"Failed to execute public deposit");throw n(N.message),N}finally{r(!1)}},[a]),w=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/micro",b)}catch(g){const N=M.handleApiError(g,"Failed to execute micro deposit");throw n(N.message),N}finally{r(!1)}},[a]);return{deposit:d,getQuote:u,publicDeposit:f,microDeposit:w,getStatus:l,getConfig:h,listDeposits:m,isLoading:t,error:o,clearError:i}}function dr({tokens:s,selectedToken:t,onSelect:r,openSignal:o,placeholder:n="Select token",disabled:a=!1,className:i="",searchable:d=!0}){const[l,h]=c.useState(!1),[m,u]=c.useState(""),f=c.useRef(null),w=c.useRef(null),b=c.useMemo(()=>{if(!m.trim())return s;const v=m.toLowerCase();return s.filter(k=>k.symbol.toLowerCase().includes(v)||k.name.toLowerCase().includes(v)||k.mint.toLowerCase().includes(v))},[s,m]);c.useEffect(()=>{const v=k=>{f.current&&!f.current.contains(k.target)&&(h(!1),u(""))};if(l)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[l]),c.useEffect(()=>{l&&d&&w.current&&w.current.focus()},[l,d]),c.useEffect(()=>{o===void 0||a||(h(!0),u(""))},[o,a]);const g=c.useCallback(()=>{a||(h(v=>!v),l&&u(""))},[a,l]),N=c.useCallback(v=>{r(v),h(!1),u("")},[r]),A=c.useCallback(v=>{v.key==="Escape"?(h(!1),u("")):v.key==="Enter"&&b.length===1&&N(b[0])},[b,N]);return e.jsxs("div",{ref:f,className:`cedros-token-selector ${l?"cedros-token-selector-open":""} ${a?"cedros-token-selector-disabled":""} ${i}`,onKeyDown:A,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:g,disabled:a,"aria-haspopup":"listbox","aria-expanded":l,children:[t?e.jsxs("span",{className:"cedros-token-selector-selected",children:[t.logoUrl&&e.jsx("img",{src:t.logoUrl,alt:t.symbol,className:"cedros-token-icon",onError:v=>{v.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:n}),e.jsx("span",{className:"cedros-token-selector-arrow",children:l?"▲":"▼"})]}),l&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[d&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:w,type:"text",value:m,onChange:v=>u(v.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:b.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:b.map(v=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===v.mint?"cedros-token-option-selected":""}`,onClick:()=>N(v),role:"option","aria-selected":t?.mint===v.mint,children:[v.logoUrl&&e.jsx("img",{src:v.logoUrl,alt:v.symbol,className:"cedros-token-icon",onError:k=>{k.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:v.symbol}),e.jsx("span",{className:"cedros-token-name",children:v.name})]}),t?.mint===v.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},v.mint))})})]})]})}function zs(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const ur="data:image/webp;base64,UklGRkACAABXRUJQVlA4IDQCAACQDQCdASo8ADwAPjEWiUMiISEUBFQgAwSgB4Z/TeLt3XMAoQH23eph0gPMB+sn+M9tvngOsA9ADwgPg3/cH9sfZciikEBuA1AB+nf+84CUkAVvA2x4xvyobR+mBaYhjUv/ewHb4hTqOnP38rzsxZX2inOSciAA/v7uqvqGdpWcjjrfMDFaNHumTog38t3yor0kbjn631VsX61cAC749wWuAX74u/f/hpeDFqS/ci8E1g94wk9UVs7BHqtv7f/M9iT1u5ITJV0Gv6tE/CW5j/nVR6yExJ6JoDRDOWQ8zVpWH92r3Lnbnc4WJpOchbRT3H5rv//6PP+F//4ehLUlR/4tkRUKZu/yOa26+sywmY+Xc1X2lXMcUv7+eQ7+FBE7bhKc7htieBfH4eR134AVaILL7PWA2FjzAjfaP1Lgirqoq/ZooE8jVD/b4g3J3O3/TG/4ajHe6clnAI/4NdwrnHX0P/quBU03HqSsQ0qsEMAuhrH/jn+YtDzmjm8q/cGJ44qvi24Hn+G1kxz2XP2S/Gp7ri5cMlo+muuwBjyNJnnEcTt/5cRdYS2cbEBZtpINWj3PuC1EOsd/8cTepSpxODcJHLzktfC1PHW3Pgoh3J5PHjW3TCQ1Wlu/wP8e8OPfNm48BODGChioj3ezblqrOBV+cI+hLi7ReJdvBF/4jY+/Un0asuWnrA6kRNpgOeO8wyl4Ryhkrff+9R1SpyPYP+5T3EuWWLZaCn0bGzyk97S3VAAAAAA=",Wd=1e4,Ds=1e3,ca=3;function qd(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function zd(s,t){switch(s){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${qd(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function hr(s,t,r){return Math.min(Math.max(s,t),r)}function $d(s,t){if(t<=0)return 0;const r=hr(s/t,0,1);return Math.round(Math.pow(r,1/ca)*Ds)}function Vd(s,t){const r=hr(s/Ds,0,1);return t*Math.pow(r,ca)}function la(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function Hd(s){return s<1?2:0}function Sn(s){const t=la(s),r=Math.round(s/t)*t,o=Hd(t);return Number(r.toFixed(o))}function mr({config:s,valueUsd:t,onChange:r,maxUsd:o=Wd,disabled:n=!1,className:a=""}){const i=hr(Number.isFinite(t)?t:0,0,o),d=c.useMemo(()=>zs(i,s),[i,s]),l=zd(d,s),h=$d(i,o),m=h/Ds*100;return e.jsxs("div",{className:`cedros-tiered-slider ${a}`,children:[e.jsxs("div",{className:"cedros-tiered-slider-input-row",children:[e.jsxs("div",{className:"cedros-tiered-slider-input",children:[e.jsx("span",{className:"cedros-tiered-slider-currency",children:"$"}),e.jsx("input",{type:"number",value:i||"",onChange:u=>r(Sn(Math.max(0,Math.min(parseFloat(u.target.value)||0,o)))),placeholder:"Enter amount",disabled:n,min:0,step:la(i),className:"cedros-deposit-flow-input cedros-tiered-slider-input-field","aria-label":"Deposit amount"})]}),e.jsxs("div",{className:"cedros-tiered-slider-tier",children:[e.jsxs("span",{className:`cedros-tiered-slider-badge cedros-tiered-slider-badge-${d}`,children:[d==="sol_micro"&&e.jsx("img",{src:ur,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),l.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:l.detail})]})]}),e.jsx("input",{type:"range",min:0,max:Ds,step:1,value:h,onChange:u=>r(Sn(Vd(parseFloat(u.target.value),o))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${m}%, var(--cedros-border) ${m}%, var(--cedros-border) 100%)`},disabled:n,"aria-label":"Deposit amount slider"}),l.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:l.note})]})}const Gd="data:image/webp;base64,UklGRmIEAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IIIDAADwDwCdASo8ADwAPm0qkUWkIqGWDVeYQAbEtgBOmZMBu+H816ov3b8R8R2g2FXtxdyh5s3+A60v0APLi9ktgGB/LZjWNAXqgpE6jfW0NF+P4xEhH2L7M+26iGwrTjjcQegyCZqxs+ifvZANjWd279diqZNKUrgOTVtjJGtW4IVtRhMECd5aWVgAAP7nDv3UY/8f1l//xTP/FM/8NU8c9g//sC3+bX/1HZXsNsM57VKG2LVf1a0KdncWO8uPo/Oh79m9ZqjJZwXfPXuvwkK+WDOl6+N8C2Ux6no/V/zkoucKK/JZek7MR5sS8TknXB+6BuVDXou9Rx4aUea2q2IzvLvFIujjKsVYLMab7j9zo48fhgm9YOtjmWuS0WZ4c+6ta0mr3xF4fcdAIFf6oXRSlqovOX0HUiMV//hXwSX1cfP5cLj8c7OTyT/4ce4olJARV95GoY8oF+2uU0blGul3ItlG7c2Hl2/uC6s2WZc7Zukwojx6ed8t97bZ68N1uzCLzPlG7BuYS17F19e0wXnc6vEl3q7ft0K7OEl7r8mY6Kh+Nt/5V/Lp68mFBjLem1JjvC371+lKwez4KCdXwNo2Z04FqyzGpFutY6YQ/r5Tfu7Oi+oNfN0R/W+D4aj1nqHhlqYJzpx2NK4mj0gJIXmX8EArelSQI8mV4Ux9MRPwC2PuZhLTjQZv+Vl4p0D8bSB+Z0rek3hS6G1r80fW3cn767Pz/bXanjVmm34wt1nQPqdJObrZ7vv2NWcEuQKj9d+V6DzeDrq0CtGNcanEB5MY9agi1E6BprEScTdfPXjBeMnPbpD+QO6P7IW4UZ9etCCHtX++S/fl5Iz5RzUr10ojRMw//35C0yTjSEhbe884dPwor64n//KByjUFEGsCPAAXPJp1+O+SiKfUaODq6ncjKayTHXjoXgM7XP1z4sBhIKJZJRiM7vGC/+v/Sk8/jbgZLZDAVz1vLou93y7Yd8hxcWM/BesxgWgeKvl8fjE/Ud8tQKp4425hWh66lzzwxa4J3ctA4/E50wX/eoBOgq0B7+7S6FK4wvPHSNgfh+vwSWIJsJLt/3yjBeb41RRyMDMZqFQTZPEdFpXp48ExEyDayZ6objbjTHoS5WQDnDQpRyqMNKfvd41nhEPdb/hxpzXeTIjWmfHHCT+CQYWXDqLehCh1cRyeYOBwsSlSw5PiquAbsgAARVhJRroAAABFeGlmAABJSSoACAAAAAYAEgEDAAEAAAABAAAAGgEFAAEAAABWAAAAGwEFAAEAAABeAAAAKAEDAAEAAAACAAAAEwIDAAEAAAABAAAAaYcEAAEAAABmAAAAAAAAAEgAAAABAAAASAAAAAEAAAAGAACQBwAEAAAAMDIxMAGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgAwABAAAA//8AAAKgBAABAAAAPAAAAAOgBAABAAAAPAAAAAAAAAA=",Qd="data:image/webp;base64,UklGRtgCAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IPgBAABQCwCdASo8ADwAPm0wk0ekIqGhKBQMqIANiWkADPF3uV2D8VcQGk1mg+P36i9SLnZvYAQxszEWYzEwX1RVkqG/4BGbJgMSHqhKDFsjWsGfPPrvfef11goNmCDDlBJHVVD+8gAA/vu4q03kl+E7FpjtZ2gc8pQ619Hjv9NywoRZ6az43C1wcrRr/lWzJlJhLWMHN0MkVl1ueAf6Hn8StVzeUfMBXOKkgfe2msx7QWR5PnHW/5c6/35yrtWnrURc2q6UYlGin+v8C2dQqexkW6rX2EEijTI9eEQ46PWH3/59fM2AlMvvR2abaRk5XX7V1triQncRxvMfz5YmYDN+PY/ikcZUNaiFucKoUq5riv0eKCezuFNHecE11ojwJqWRSTWpalkz5autXp6vFS+FT1tWUsB/fs1CCOZxaA1vR1grOEaiuKe1RYm7e05psWtqbXLVmm1bA8Ly9PFkVdCbc6hR3UuBBsFGnVeGOUeMn2onnfvYhBMcM9YPxGdQkwZLXOk1VuQSTk01Shf3fZrFyRlFauftFdPYhKXwqrr+meav1P+KLKBVosqmHnFFfgExsQ/rOf3TSd+mOqQfJA+cF+HojNU7nmM3uDkoCBi+//Gqp+gPNNW8M4LFrol8rxE+7WsjqMgfwv1f+Nr25RtG1Wa/KkniRCAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Kd="data:image/webp;base64,UklGRhYJAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSGICAAABkJz9nzon3/nNJGnBXRvBI0sDkR7slpRBaMDl5LByx7cEyBWHtWd+8/uiK/95uEfEBKBnFwRwk6Wjm89PW2Tj9OWNo7VxASQ4DDoIML9fbdLYpbFR21tykDAY8ZCLT9okqZrsD0uqJNl5sj6CIAPwDmdqRlNlz6o0vroE5/vlPObv0kyN/dVE3pmHd31xgt0P1MgBauTHLYjrg2DoClM0DtRi4kmA6ylgrMq2cuDaZm0CoQePyTqVhVTWJ+G7EozXqSyosj4K6cIhVBhZ2MjyMNy/BFcZWeDIE8g/PLaoLLRyF/4vgrlPTMVK/DQH+cPjGpUFV17/i6BEZeGVF+Dh4F/kUYGDR4nKDBPX4AX381Deh2C1Q8vB2F4CDqnMUrkPlPMpY+obLQ/j9+k1GjNNLB0z5hJ5fD0f5Y2XTLkkPn9Hy8X4vsGMW/xvt3JqvKflYnz3nCmXxJc3qLlEXj9mzOe4xJSLcW36Oy0P47cplKl5KMvAfj6HwFKbloOxswrBfWoOyvsQjzWmPErwcKhQi6d84eHgcSGPEgSA4Dq1aMpr8PjL3CemYiV+moP8AY9darGUW/D4u+CEsUiRVyH4p8NwmbE4kZUA9y8IRuvUoijr4xB06zFZpxZDWZ+ER/cBEzW2dXDaZnUMAb06hBOmaIOxmHhlCILenWDrI6MOIio/7kIc+uk85u+SSftkasZ78/AOffYOl17RqNqbqtFqZ+A8+i8BI+tPOiRNNdkfllSNZPvJRYEXDDQI3NJerUFjl8ZmbX8ekIBBuyCAjK8d3Xh52iBbp89vHl2ecIAEh54BVlA4IMwFAADQGwCdASo8ADwAPm0qkkYkIiGhLhtqqIANiWwAqSdaNo+beZFT37f+J9yXOd2J6HfQh5gH6edIDzAfst6vXoO9AD/Lf4DrAP2V9gDzY/+57F39p/3/7k+0RmjvYp/meic9ieyvJnZVfquF/a23ZOCHGT/sfDDjQ89zOL9Gewd+s3Vh/b32Gf28Ejb5ttLg9hoDiFb2tMW81eZU9Z1LHfdRSCsRMzHz0WT4BNgUakGf9oJtrGtVJFxHJfxAatIxnW1qjDi9i3DQtJp9pVNKlMoJEWdPKv3KaaFSlhd/aMGiir9CPcex5QAA+fpjxA6zfUamE3wS2zWwLVrt/fXA5+Wvx9j5SID0zuEHU2LisPUxvtRuIUwNrsUis8zy+IMpzft+ZSg+9gdx9e6+ZvPmtj4OByz5qo26J3rXhPy8LBXSpuPb+f+mP4CoTvYDhzQXh/SIGj8Ez1+W5MJ/Tkdw09wPCs3JuR3yoqO63FH/j81xW5Abr7tCdwfXwv3CXDtOcHwUqPCd1aiU2uT6XwgdnYqYygEXGKFx8nmaUvqSn9p8HmIA9dVTOoEnqYFjrNfWY034N2vjohd16cxnkP4PYvHkIOWa/FEUug7/qbJ/GFLPxNh6y9eQ//MzzXbcPwsT2chWXPBXNVF1S9dxv5NUuEueiw2kdebblQuvUSRLN+zx3VyT2lOzWBUqrzsTmeOlxjVcTA83H99r35O4X7WXNq7HExiWXxrdM/Ih4CvPJaEHPxUE/i6WIz6+VGq4RB3sBKl3P4M7/DLWAwCnwcpX228XezqQ4cS2tttWxLTc9cPd1ofek9qF9lpB8RvakdPnj2PruFA9W3iKbNdmgnb+mIpohHuUR73KdDDOHbyfAiOjPzzqomnIU3jcSt7LKOB/Op97sCk0yd18mVG3prs351B+xmCE2Zd3RFKL+mpMz5qcuAFAfRyodbggdgmFGkEGQ33VryYFl/upr31FGdI52sqzuxd7jZIsqCcznUH/gu+xaBw7wla49EmFNf+Ss+91i9Hsys0FS//Ktru1xWgkeEweX77y6Oot5tHQsDxgy0sAI85V7FmlpiiWXQdM12MGfCBfyRM+N23SjOdReeSILYCgsM3r33/54X+lfDVNj427MvbDFtKccqazlQ+iKqC//MvYwqyiJPL1ZbVoCEP774fKZA3D3qvsVPGlp9LPchpTs4mTJugt8qXl82RwXQCDNZXnbEois53E35hkRr+IJhndoRo1o2sZDoTgykbeOKiynPH03+BcUQ8zmxTmiVlHQym/LL3kRREnUlxs2zPPGb2E+Rpdib+LxOvFSmj9RfTZoYIJnrqNnBIXV2lt7xeZ0srf98JymJxrtr8lx69oSNZIReDddL+3iiUjh6lm7EcYuclqBaKp8q68geo7H1EvKy4nSRx5Q+uz4l/ypo2hVdwi9l+BHjZZmJ7lXkpNTRJ0gZpzquzN2vh/MZQALV6FZ6q4aofA9AJy1DVLdNjV8n6s9eFA5pazxwhLW4tgWMciGf5x6G7HqFPTL1ZL3l447zLGUkqAXjkeVaNmxZ2oNKIuTy6JDc0Z61Z2dgbsg6HwCX1/ux5sk82WsnNIO4CTnWKI1aCtQZaEsBf6hIl9n7VBsgZGIcPpqn7P4mbyf3EbfdfQ32qlawLuAxmDlwRsVsPkw7j4aKbvIBykNcsVXv0/X6UXXaAtw3feJnTwDak2qY6QpMLE9e7PJeuQQ8FXpqI5HoR82kd+DOwGH5F3OpuWsmEt8v7WQG8q1LMkg6vrl3I8047zMl1Yq0VwotbrsKJocsHgsbs/PGOO9v2s8U0Sju/71XRtG5skcy2msae3wixjlGR4i6ZfldMehQD1zf/FbWN9hnHfpq1Fh8+PSA9AzUi33qli8ixISbH+tw7CcumxvegMk88HMNZlVdnIEzIfyHrSdZ2S98yX2OYZw0+JyaBbQxI0fOr6KpuMD6FVGLrdN9dgOTgOPQgAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",Yd="data:image/webp;base64,UklGRo4EAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSA4CAAABkGXb2to2V9/v6D1Jmd5CQ5GXPYXAJMrtPOJMoMzMzDgIPYY5+vVds6T/m0BEOGzAtm1IBlR2d8kXUMyaADjeuHr9V7qj3E5/XrvaOA5AHCqzFgHTFz9tUTmEyq1PF6cBqVWDOLjkwS6VPsu8KqnaewRU7j5KIjipgFiQfCf1IGch8wMlv9QhcWk4nLlL9Z4l6b3y7hmUvGQkmF1nnrMC85zrc5CozDUQtwamisNSDCmxjL5jpqxMzfhutFCCY3+5110CaI9/jhVIcPg/DxiIB/x/eKgijLxkRobTyxFEw7zVm0NqcYg5LNAzKD3n4QbmyRVqWCiXJyD9uN7z0Ha9Dw4N5gzOnHU4IMJ7egt8HuYWasIJnlg46fkYgul9qgWU+9PA2Z7b2FngnR3e49Qm1QbKzVPNnltZ8wozK2S8et0SN34wt0LOnynVCsp02xI7tKSqqXYsV7ZtD/lpeaEfNyw/k9evWuKK7XfQ9ruP9/RW/s74t872N1bw2MY8n0Acmlb/KQ04AJ8t5PkeEbpDnbmR2/5392FiOfRFlCuTkIGsMh/aPBeGZFLBYuiM1IIUZLOD0NnMNBMWZdE/4bLo32MQ0wxcJnsvhcnerRhSLvPPhcj8s5DIsmtU6Tj1L1U6zvcEElfrVlHyqGy3epC4om5Vsg3OlO50UQ2V6Qa65LWf6TZ1J/11faBLlpgAVlA4IJgBAADwCQCdASo8ADwAPm0ylEckIyIhKAoAgA2JaQATzh4OcBkEByVmbl5z9gD9U/+J2APQgLaX4twLu19/UVxAWN1IKXE4cIqJBhoyQ0yDYn61m3zk6T7FMg0AAP78+EMvGgC8jLXmcbbmqvufKjG8Tv1M9Krl47vOW74O/Rapv2DgXbg9iK6PrRQG/9d9+rF/ESxzbszVFn3GThrMBmsklj/LPWDQ0pKzG7EyjQL6p6gfUwMze+wPhzJpn8tMqlUVgq6/QSUVcgG+ztsi73rA3vl3n4baeF1INsbuosTXtnsotVYuTii6rscx9OUTvevYcPNvcL9MPhyWeCQw0qynnGtzCIw+oFRN0+TN1mqXkFyk/rFBcH+FHiI6s9XX5EWCKn5vTRt/0RbS687PiXPFC5Zk/Gk4+538IYi+HZDjvlQQWOH/vddfYTerQ5QqWJt1YuaZNThQ2u+/DtXfZPRy1iWWLR9SKFFtlGrqBKWF5nPRPWWMNA3OssvUtvCNBLBA4cn1whzy+SpbgLvnaepxiykjKsU/MhzgAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Zd="data:image/webp;base64,UklGRqwEAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSL8BAAABkGvbtmlLc5997yvbmW19gBnbDm2kjF5UmW3bthXZVZFdZ+81r+87Z1XlEaHIbSNlMstwos4XUBSTLAFQo/u01Zdf/yLDDze3zB/YwADJEoOoJAKg7oTdH4SF+XxiZlMgSESzwAJdVn2iUJzzOUMiLhQKf+/va2FtBLMBuu1zpHcsincUXhtoTKLsCTVX/KF3wrLhPLm/OWzZtjQWfZ7RhYyAC/lxMowpSzJYJAyFkZDQc21FBMUT7BqGjpHxf3m+XlEPUHE/f3vGgPzmw4awRUaTexkyJhwfNShctVgZXyJDXq4CUyjNy6Y4fVOBIkAPR2GcOE7Jm2NQ/RE9YzXht3a5VYvlOX0xF0fy+tp/ozBuQg6DzZYb6Bi7ed4rB5Mp/1Co4cNhLUo1StLxDIDqrynUoRswiF6nFnIxsDpnZ5WBW0GFZ1qZ8HfLDk5txHHsGDpSa6B0cXZEa+DsTr1M+P4qPdXwjynU4+1/a7oN3Sm6G+meSd27oHsHde++7puj+tYpv7G6b7vun6L7l6n+oZp/t7JmUNUqqhpJV5upakJVLaqqgVW1t6rmV401NGMc1djqH4rpIseSfyPFkgAAVlA4IAQCAABQDACdASo8ADwAPm0yk0akIyGhJgzogA2JaQAThroHvLxu+aPf5G2BYxv+B6XHzx6GPon/o+qz/tOAA/TM82gR0vnExWoiQRM36jlg2UIvwCSqySErzuguz9EP2x/7hsNazr91aIworWI7AAD+/TZ+6Ipl444OdT+2wU0Ov+T8oJuVP/vUbT/w1Jsv6Awnl6rvF/xetfOPt3gTQZZi0Y/AOx563J7CJkqTR/fc/n34zyeKzR80fhfv4ef+Hjhz/CX5aQo+58zg/FdE+7bLoophGfG0szI513EH+q+Gc73H1PFdJYf7CF8v5dhr3tMwEVX5Ji2ZxejK8xrf/E6nVXqlA4DrYNRP09InHc+fEqO/fH8xr+rMf4y1F9TOnwVffZblLoTP6lot0m/sh7sTiDQr0mIA8TiHoOffGDG6KzV+B3239udfhzD740gkRi/m53abX0Ku3vAgadgFFqL0vk8M/4aI+cI+0fbLW17mWGeMu21wSRRQiv5iNgGKR3vEGXAItcLDft1uUzWAfbe1X3zK/ymT7bA/76PB6UUknm+Y5MM4osurUXU/k7P38pN/3slnGfpFzjl4c3USY4mH9ZCJYUuC/kGEnq/yRPalPdODNFvW6s8MiQeQejYNRY0LsJ0WXkK8vXiDmihCivYAOPoSovesL7on+WAArDNM/BcQSQvCYABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Xd="data:image/webp;base64,UklGRnIIAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSK4BAAABkHPbtrE9+z73/RTbqWw7Lf+BbbNKbTudbZe2qy+VbVv3PmeHj05G6ohg4LaRounNMtN1voB42ABA5R7TNlx5+O7du9e3Tiwb0b4EgFyAOCQM1Z16+DWFUZC7m3uVB2zKQGBhe+77RGHonJffCL1zQuHDxQ1hrEmTatDjHIXOC2MgzpNf1tVJkWgsGhyihI7JIE74aUYp2ITFAoz9QO+ZAs7zanvkEilKbIkMJS5ANwoJmrCodYVOmBqh5zIEJjZc9xods4A4rrPGxGitrJSU71yNyH4Myl7JTEl+5zzYSH9nlkrxHBzxWUzLVEnhh+YI/gq3+UphpvA8m/s7/wg9M4bjFNg/0vplrxQ+rQEDg/xihmT23jxYJZ8UPq8OA5z77Wt405FDR4poSMjiAJhPRxUIu8D+UVonOhfNPEVHPM9juFacwo+1V6kJQ3Y9Sa8ljhPuUvRk4UdNWU9ST3b9n0W3iG5DumdS9y7o3kHVu6/75ii/dbpvrO7brvtPUf2X6f5DVf/dmpxBmauociRVbqbKCXW5qCoHVuXempxf1dZQtXFUbat/yKZTtSUBVlA4INwFAABwGgCdASo8ADwAPm0qj0WkIqEZ+zYAQAbEtgBOmZoZF+E8zGoP3X8VbcdLvma8t+jH0E+YB+ofSA8wH7VdQv0AP75/iOsG9ADy3/Y5/b/91fgI/Y7MOesb0e/q+TUR1vt7VO6mwG0imO70GM5/0P7BX6qelv7EP209lz9oDRea09ZR+SjhX7sBu/ZS7tG917rPgI3Q7XsB7luy2hAg/95C2Z1L362OH1oFziDY/K5gWoSytSAtiKvA/jW1MehBzdLzJfszPPBvGa15IYwIVRTjO2Hz5ZS9HjLMehwAAP64SgjD3qeg6NRe/Ok+iFhrG3pgglCfbam3yBaDUH36sUiQx0PB1ZZyOHq0ky+f97h6tJMvo0p9LkfXecWOFJ8J5G7yRPuL4tzGLT09QulTJw42xp2hd+lMgIa51XoHx/iftn8B2D3k92H5jOQr+uIXFHHK5FpcTG+qGEF+np0LiQa+vdW7/+ZzOLVRf7jR5X3ANPt93Ng92DW7NflVr6kMr88O/v2ZNb0vtgao2Am/R3CDKiNq89f86CT6r2L2g1oTui7H3E1yhSPQpEOz01I3fhfiMMv4weqKuoedxn/xLg5uzHa6Gte4C/dQYkG3ZFSy4CXQtRjftBrjX/Oj+HpSUPDsv0wPW+ml5NbBKDCj2f3SD8TVMf2ZfHrOkR602RVk2UmKC+H0Y9iK6k98vsgPINtz0II8X7Mj2nJkTC6IMLuQ8dNTUq9VXOnhXrdhNZoaH94ePo6baBl3hTGFAnD3/b+gR/vtbqV7wktuX6fpnjeTBe/Drp6z3neeANj/aX4CsU9w67nwYOjZhueCjxaDKUnNjLPjI1e0BoTbcOzOQ0wHJHZJ+Pt608StBu4HiJ8NjH46fnvXL3yiMoSvkAuwCE1AakA+eU1u3unyjl1/MnZQmbp8fzfsfrFesehLPcIkYdCiZ+52QbmINNTjEsvjuBuZRubBE+Laihppsxoo4efGIo0xkw0etu1+yzvkqp88w3pBq0mRl13gnnc+2zl6SmhwgmNFbz+F8qAqmdfJL8iaNSGEWlPlpczDDe62GBZMlBhQmq/XCn/1b+VazHvJXkoIFDF+wktMg+rKfLyfTlXdK0cs+Kn8h+rjMakkf3WLo1TftMLn+O+x/Gat+BGstJrM1xvCSSnHQY+NV4B4gRqyZ55gRNnqN/0lWrATOcHUaGXpkTIM/yxFjxcePcSFo+t2aJ5lShtVukETzRxaIXgRkpROeWQHWpTHOaexmXOzF0b833qJSoXMk2zB/uMrgDzKd7d3ohUz8Ra08WYKlAuMQD08bF4+jUepEspqPLoYLQ73TfmL+1LwKxyTV3gEu6WnxBPWPLnYIGYN9U47ZNlB+NgHgYtKTyii6060RAG+wN32WUVFxCZw0HMHnHFgwxD34L/anlpS7mOrjKgyuGYhFC7iHqTQHuoAO1ekBHV+rndnbETKfa1F7LxNLYq+dmJyytmQrJUCGjelorI1m/TMQNiFVrY4FCI1Gl2W1JsZsw9zA+Bh3JmjkC0H5/0JV6JotNMatJIZ4v5PqwJe3r8xd+FNS3ynccdu+xtVdc27qwVdoomciZD5oXYey9KAFSAKO594sBKZNWUJTLXnt0BJbdF8FkQYvg3DQajYY2p+ixd5Ag7o92gw0pVVDDOP+WQxiEmKqgWJyTBsnsBk2Bxi2Unsv8S/4PmE8Hy/vy+Mij+aTAKZvg716IHfHX0/JMeFfmAnsZ39Q0qkfdPtq6+CxbGZ7wKDsK/8l/MVGuyd6faJFt5wyoOXuNrr3JC9EoBmjcOzkVw/6RNP49poZ1xzsX3q7B4HGfI/XSfRQq3HeZ2j12d0E3gCAube4oExaT1sx/v8F+f61QOsGdSaqM2im6qOGkSRkrRQ7L8hvS8vEYJeVkAbFvX5ov7e/egYYNToMHj651c5/rCVYtB9Ned6GvGN8R0x3t7+lsf8+ofhHRzpyvwxd6c5pREZVOKnXzplhJ61mki4JmAAAABFWElGugAAAEV4aWYAAElJKgAIAAAABgASAQMAAQAAAAEAAAAaAQUAAQAAAFYAAAAbAQUAAQAAAF4AAAAoAQMAAQAAAAIAAAATAgMAAQAAAAEAAABphwQAAQAAAGYAAAAAAAAASAAAAAEAAABIAAAAAQAAAAYAAJAHAAQAAAAwMjEwAZEHAAQAAAABAgMAAKAHAAQAAAAwMTAwAaADAAEAAAD//wAAAqAEAAEAAAA8AAAAA6AEAAEAAAA8AAAAAAAAAA==",Jd="data:image/svg+xml,%3csvg%20width='88'%20height='88'%20viewBox='0%200%2088%2088'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='88'%20height='88'%20fill='url(%23paint0_linear_170_79)'/%3e%3crect%20x='25.6665'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='51.3335'%20y='25.6667'%20width='11'%20height='36.6667'%20rx='1.83333'%20fill='white'/%3e%3crect%20x='29.3335'%20y='40.3333'%20width='29.3333'%20height='7.33333'%20fill='white'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_170_79'%20x1='-75.3077'%20y1='-55'%20x2='146.302'%20y2='148.167'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF00FF'/%3e%3cstop%20offset='0.531673'%20stop-color='%237A84FF'/%3e%3cstop%20offset='1'%20stop-color='%2305FAFF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",eu="data:image/webp;base64,UklGRh4HAABXRUJQVlA4WAoAAAAYAAAAOwAAOwAAQUxQSNwBAAABkFxbexpJnyR3z8y+ajXMkAnjnnOgbUUxEAHjkpldWQwzFUn6v3PGVNI/AUQEA7dt49gN3PXavTlfQDeNAeyqg4PL5buRyOhteXlwcJWtHU8qzUIBs+30g7/s4N8Hp7cZFAtpDc7Bbr8xplB8iFJBYvBC4fjGdgvnElqdwc6XFPGRnQxehC93wjgzbxRYf1UYA+dkiJSrG1DMV6zDoW+MkQmMkd8Owdl5AsvOM3gm0geeXwY7R/Tu0EcmM3re6cF2Rr/kTJiBMmPZh+2q/wtm4ozD9qrB0tucMhunvL0Upg1n6JmRnmda4HCckVkZeRyuMWjjF0peCD9vhK3jAgMzM/BCDQ576225m/bCwcA+qzS/PLUwDrsr1ZDdcAa3KtWQWzDYPKZoQDjeDJyoVEdOAPf0cA/Lf1F0IPy1fG8VWmXvgF4LnoOLDFoIvPiaUQuRr99pNr8dUZEj0YToQnfjreaQd7oL6T6Tuu+C7juo++6rfnOUv3W631jNb7v+P8U+1ZDAZxZG9R+q/e+GxcbPuRcRftkIq+pVVD2Srjdr94TDnJ6w7MGqedFhH1bVA6t67zk9/3ctzw+YAhvSc431KExyjjNHQ2zLcTRzq/8op0vKJd+OREbvUnJJAFZQOCBaBAAA8BUAnQEqPAA8AD5tMJRHJCMiISgb+1CADYlsAJ0zIUCfxfmY2f+0b2AbztDnPeKX0qPMp+wHrDehz0AP7J/o+tP9ADy3f23+C79yPYA/aqK9mONrQbuszbsEyALJNTfg+Z6NjG2v+ETCuvlr1q6QUqEiAMUndG/WwfnjJIOTfOBS4W1w0HjOJa1XQ2K33n2b07EOjOBapwKzyoA2erTBTnEKlFjllBy68GBjZ+UKnlzN/f5ibbb4gAD+i9OsnW0xUnmTpyhVasIKzTu0BsXnfBm4rHJqGMFJBUgTESDXEPcNjAeaHP8ck9qdNBH4L/h53tXgHeZttc7c4lwTa6U4Lziz8qUoy8ce0IMc5TFElawGj16tME0GzSSbUqgH7/tYA6huPsWM2z3GjP8b9y7paRbINxwYRtuE90I6QVsNrEkbhL1YfwxRXnuobOfSe3KFVamrvsOqwTCMqlNfjsR3pyoiZ+lYt3+AH6x4ZVNltbYI5KiVhgCu1isooK324ldloH3zhlefYKEwTCYfNjbeH5UiL7JSev+t/C+ftc3TkAHcsvrLCU6n5pYYY2Yr1kRq+r6XVzI6iXuA/TqwMk6xq1PmdzHOwKavncLjWJrk0uU/5E5WKqXM0tgl5s3pduHjb5aiAt0ikEisMyYwnIhDiSemPRdGON4RlwSb3OEpZjhuZqoyen4Sw/fULewt3hAZizeiPZx1o9LS3M/4r3v/M6/o5925VJcmxAf/yjsyjCz0mV+6NuIeWp8shrFaIGgeduVJoZ0Kys1WjSLuFg9QvF5LlkOZ2k7WrzSu4ucsUOS/X4wnQvB0RCnR1PCsU4NDdLfxvQITUgGIuVTJ7LR73PHzZam/Z21oy3euiU55ffITekwjR4SgVoPvhxbdBSyVePf/twm62pSK9IfgPGN+ttubhQub1ooVZymdQCrS3goEs6dlnl/6TVfkgxFyBfAORkZafeu/Va2vIgUBNUQd48W8oPiMFjx+SAKx1qm2IwCLnuhJGf9M4nCzu7oo43f+nBeT07IjB+FpFKRGFNvlpLEXhPclSgFkqeU1W2eNqW2zShCWkQkgfE1HAoNX3z+CQcRQJq+HkC2nSjFdFYT8UNYNS6lYcyVWzEnOos1qpsNRxnLqY2Dl5CCT3Yeg/qT8chfF9ZadFvzNTEIDlARoN//7IU23MtuLdpsAjsiGfBHuR7y4lemYPdD/9Cuff9Qn/r/xlhmB5x2Y9Z1yME3aANAb5+u3lYz01zUlWwakKVmv9fhaeu/YzQ7BXLlcb+cbaIF5t/COmObnt20zaTfjad542f7p7f2Xea134nvyPYS+EAgjM+GufHvl9tXCrrRbH0pn7kH2XEGx9VbO4mY54+QZa5kPr0j3AOEtKd7SJWjlg5TQfgIuB6KoLGainSwF+pPdiCmzEzAOa1eFwn//2VdDMeq42/bKH8U4orewhLh60ci/S0BRBuItNMc+v1+vxl0YyS5it4AAAEVYSUa6AAAARXhpZgAASUkqAAgAAAAGABIBAwABAAAAAQAAABoBBQABAAAAVgAAABsBBQABAAAAXgAAACgBAwABAAAAAgAAABMCAwABAAAAAQAAAGmHBAABAAAAZgAAAAAAAABIAAAAAQAAAEgAAAABAAAABgAAkAcABAAAADAyMTABkQcABAAAAAECAwAAoAcABAAAADAxMDABoAMAAQAAAP//AAACoAQAAQAAADwAAAADoAQAAQAAADwAAAAAAAAA",su="data:image/svg+xml,%3csvg%20width='868'%20height='868'%20viewBox='0%200%20868%20868'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='434'%20cy='434'%20r='434'%20fill='%231B262D'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M234.563%20184H640.697C650.387%20184%20659.339%20189.164%20664.172%20197.542L782.495%20402.657C788.631%20413.294%20786.808%20426.72%20778.056%20435.346L452.368%20756.327C441.818%20766.724%20424.846%20766.724%20414.296%20756.327L89.0484%20435.78C80.0927%20426.954%2078.4157%20413.136%2085.0013%20402.433L211.48%20196.884C216.405%20188.879%20225.146%20184%20234.563%20184ZM588.257%20275.577V333.129H472.567V373.032C553.82%20377.296%20614.782%20394.81%20615.234%20415.802L615.231%20459.563C614.779%20480.556%20553.82%20498.069%20472.567%20502.333V600.259H395.746V502.333C314.492%20498.069%20253.531%20480.555%20253.078%20459.563L253.081%20415.802C253.533%20394.81%20314.492%20377.296%20395.746%20373.032V333.129H280.055V275.577H588.257ZM434.156%20472.268C520.868%20472.268%20593.345%20457.459%20611.082%20437.683C596.041%20420.912%20541.636%20407.713%20472.567%20404.089V445.867C460.187%20446.516%20447.336%20446.858%20434.156%20446.858C420.976%20446.858%20408.125%20446.516%20395.746%20445.867V404.089C326.676%20407.713%20272.271%20420.912%20257.23%20437.683C274.968%20457.459%20347.444%20472.268%20434.156%20472.268Z'%20fill='%23009393'/%3e%3c/svg%3e";function da(s){const t=s.toUpperCase();return $s.find(o=>o.symbol===t)?.decimals??6}function tu(s,t){const r=s.toUpperCase(),n=$s.find(a=>a.symbol===r)?.decimals??t;return n===void 0?2:r==="SOL"?4:n===6&&r!=="SOL"?2:n>6?6:n}const $s=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:ur},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Xd},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:su},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:Kd},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:eu},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Zd},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Jd},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Qd},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Gd},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Yd}];function ru(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function nu(s,t,r){const{feePolicy:o,privacyFeePercent:n,swapFeePercent:a,companyFeePercent:i}=s;let d=i;return r||(o==="user_pays_all"?(d+=a,t&&(d+=n)):o==="user_pays_privacy"&&t?d+=n:o==="user_pays_swap"&&(d+=a)),d}const Es=1e9,Xe={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:ur},Je={mint:"other",symbol:"OTHER",name:"Other",decimals:6},ua=1e4;function ou(s,t){const r=t<s.publicMinUsd,o=t>=s.privateMinUsd,n=[],a=!r&&o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),i=!r&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),d=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(a){const l=s.privacyFeeFixedLamports/Es,h=s.privacyFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Privacy",solAmount:l,percent:h,usdAmount:m+u})}if(i){const l=s.swapFeeFixedLamports/Es,h=s.swapFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Swap",solAmount:l,percent:h,usdAmount:m+u})}if(d){const l=s.companyFeeFixedLamports/Es,h=s.companyFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Service",solAmount:l,percent:h,usdAmount:m+u})}return n}function ha(s,t,r){const o=ou(s,t),n=r===0?0:r<.01?.01:r;if(o.length===0)return r===0?"No fees":`Total: $${n.toFixed(2)}`;const a=o.reduce((b,g)=>b+g.solAmount,0),i=o.reduce((b,g)=>b+g.percent,0),d={fee:7,sol:8,rate:7,usd:8},l=b=>{const g=b.label.padEnd(d.fee),N=b.solAmount.toFixed(4).padStart(6).padEnd(d.sol),A=(b.percent.toFixed(2)+"%").padStart(5).padEnd(d.rate),k=("$"+(b.usdAmount===0?0:Math.max(b.usdAmount,.01)).toFixed(2)).padEnd(d.usd);return`${g} │ ${N} │ ${A} │ ${k}`},h=`${"Fee".padEnd(d.fee)} │ ${"SOL".padEnd(d.sol)} │ ${"+ Rate".padEnd(d.rate)} │ ${"= Total".padEnd(d.usd)}`,m=`${"─".repeat(d.fee)}─┼─${"─".repeat(d.sol)}─┼─${"─".repeat(d.rate)}─┼─${"─".repeat(d.usd)}`,u=("$"+n.toFixed(2)).padEnd(d.usd),f=`${"TOTAL".padEnd(d.fee)} │ ${a.toFixed(4).padStart(6).padEnd(d.sol)} │ ${(i.toFixed(2)+"%").padStart(5).padEnd(d.rate)} │ ${u}`;return[h,m,...o.map(l),m,f].join(`
|
|
2059
|
-
`)}function au(s){const t=[],r=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,o=s.swapFeeFixedLamports>0||s.swapFeePercent>0,n=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return r&&t.push("Privacy Cash fee"),o&&t.push("swap fee"),n&&t.push("company service fee"),t.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function Vs(s,t){if(t<=0)return 0;const r=t<s.publicMinUsd,o=t>=s.privateMinUsd,n=nu(s,o,r);let a=s.companyFeeFixedLamports;r||(o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(a+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(a+=s.swapFeeFixedLamports));const i=a/Es*s.solPriceUsd,d=t*(n/100);return i+d}function ma(s,t,r){return s==="sol"?"SOL":s==="single-token"?t.symbol:r.some(n=>n.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function Cn(s){return s.map(t=>t.trim()).filter(Boolean)}const iu=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function pr(s,t,r){if(iu.has(s.symbol))return 1;const o=t.tokenPrices?.[s.symbol];if(o&&o>0)return o;if(s.symbol==="SOL")return t.solPriceUsd||null;const n=r?.[s.symbol];return n&&n>0?n:null}function pa(s,t){return s.toFixed(tu(t))}function cu({config:s,currencyMode:t,depositMethod:r,tokens:o=[],defaultToken:n,minAmount:a,maxAmount:i=1e4,onSuccess:d,onError:l,onCancel:h,onUnlockRequired:m,onAuthorize:u,className:f="",showStepIndicator:w=!0,pollInterval:b=5e3,demoMode:g=!1,demoAutoConfirmMs:N,tokenPriceUsd:A,showExplainer:v=!1,siteName:k,explainerConfig:S}){const{deposit:E,getStatus:p,error:y,clearError:x}=ia(),j=D.useWallet(),L=Cn(s.quickActionTokens),C=Cn(s.customTokenSymbols),P=c.useMemo(()=>{const G=s.customTokens??[];if(G.length===0)return o;const Z=new Set(o.map(re=>re.symbol)),ee=[...o];for(const re of G)Z.has(re.symbol)||(ee.push({mint:re.mint,symbol:re.symbol,name:re.symbol,decimals:re.decimals,logoUrl:re.logoUrl}),Z.add(re.symbol));return ee},[o,s.customTokens]),_=c.useMemo(()=>{if(C.length===0)return P;const G=P.filter(Z=>C.includes(Z.symbol));return G.length>0?G:P},[P,C]),R=s.privateDepositsEnabled,T=r?r==="sign"&&!R?"receive":r:R&&j.hasExternalWallet?"sign":"receive",I=L[0]?P.find(G=>G.symbol===L[0]):void 0,O=t==="sol"?Xe:t==="single-token"?I??P.find(G=>G.symbol==="USDC")??P[0]??Xe:n??I??P.find(G=>G.symbol==="USDC")??P.find(G=>G.symbol!=="SOL")??P[0]??Xe,W=c.useCallback(()=>v?"explainer":"unlock",[v]),[q,U]=c.useState(W),[F,V]=c.useState(O),[Y,X]=c.useState(""),[B,z]=c.useState(null),[$,H]=c.useState(null),[se,ue]=c.useState(null),[we,rs]=c.useState(null),[Ue,De]=c.useState(!1),[Hs,ns]=c.useState(!1),[$e,K]=c.useState(null),ge=c.useRef(null);c.useEffect(()=>()=>{ge.current&&clearTimeout(ge.current)},[]),c.useEffect(()=>{U(W()),V(O),X(""),z(null),H(null),ue(null),rs(null),De(!1),ns(!1),K(null),x()},[t,T,O,x]);const be=a??s.privateMinSol,ms=i,Fe=parseFloat(Y),Ve=j.status==="enrolled_locked"||j.status==="enrolled_unlocked"||j.status==="unlocked",He=Ve&&j.isUnlocked,Gs=Ve&&!j.isUnlocked,br=c.useCallback(()=>{let ee=T==="sign"?[{key:"unlock",label:"Authorize"},{key:"confirm",label:"Send"},{key:"signing",label:"Signing"},{key:"success",label:"Complete"}]:[{key:"unlock",label:"Authorize"},{key:"show-address",label:"Send"},{key:"waiting",label:"Confirming"},{key:"success",label:"Complete"}];return v&&(ee=[{key:"explainer",label:"Info"},...ee]),ee},[T,v])(),ya=br.findIndex(G=>G.key===q),xr=c.useCallback(G=>{V(G)},[]),va=c.useCallback(async G=>{if(!u){U(T==="sign"?"confirm":"show-address");return}ns(!0),H(null);try{const ee=await u(G,T==="sign"?Fe:null,F);ue(ee.sessionId),rs(ee.depositAddress),U(T==="sign"?"confirm":"show-address")}catch(Z){const ee=Z instanceof Error?Z:new Error("Authorization failed");H(ee.message)}finally{ns(!1)}},[u,T,Fe,F]),Aa=c.useCallback(async(G,Z)=>{x(),H(null),U("signing");const ee=G??Fe,re=Z??F;if(!g){if(Gs&&m){m(),U("confirm");return}if(!He){H("Wallet not ready"),U("error");return}}try{const pe=Math.round(ee*Math.pow(10,re.decimals));if(g){await new Promise(Ks=>setTimeout(Ks,1500));const xe={token:t==="sol"?null:re,amount:ee,amountSmallestUnit:pe,txSignature:`demo-tx-${Date.now()}`,sessionId:se||`demo-session-${Date.now()}`,response:{sessionId:se||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:pe,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};z(xe),U("success"),d?.(xe);return}const Ce=await E(pe),os={token:t==="sol"?null:re,amount:ee,amountSmallestUnit:pe,txSignature:Ce.txSignature,sessionId:Ce.sessionId,response:Ce,method:"sign"};z(os),U("success"),d?.(os)}catch(pe){const Ce=pe instanceof Error?pe:new Error("Deposit failed");H(Ce.message),U("error"),l?.(Ce)}},[E,Fe,F,t,g,se,He,Gs,m,d,l,x]),ja=c.useCallback(()=>{U("waiting")},[]),Qs=c.useCallback(async()=>{const G=we||j.solanaPubkey;if(G){ge.current&&clearTimeout(ge.current);try{await navigator.clipboard.writeText(G),De(!0),ge.current=setTimeout(()=>De(!1),2e3)}catch{const Z=document.createElement("textarea");Z.value=G,document.body.appendChild(Z),Z.select(),document.execCommand("copy"),document.body.removeChild(Z),De(!0),ge.current=setTimeout(()=>De(!1),2e3)}}},[we,j.solanaPubkey]);c.useEffect(()=>{if(!(q==="confirm"||q==="show-address"||q==="waiting")||!se||g)return;let Z=!1,ee=0,re=0;const pe=360,Ce=5,os=async()=>{if(!(Z||ee>=pe)){ee++;try{const xe=await p(se);if(re=0,xe.status==="completed"||xe.status==="detected"){const Ks=xe.amountLamports?xe.amountLamports/Math.pow(10,F.decimals):0,ka=xe.amountLamports||0,yr={token:t==="sol"?null:F,amount:Ks,amountSmallestUnit:ka,txSignature:xe.txSignature||"",sessionId:se,response:xe,method:"receive",depositAddress:j.solanaPubkey??void 0};z(yr),U("success"),d?.(yr);return}}catch{if(re++,re>=Ce){H("Unable to check deposit status. Please check your connection and try again.");return}}Z||setTimeout(os,b)}};return os(),()=>{Z=!0}},[q,se,g,p,F,t,j.solanaPubkey,d,b]),c.useEffect(()=>{if(!g||!N||q!=="waiting"||T!=="receive"||!we)return;const G=window.setTimeout(()=>{const Z=$e??s.privateMinUsd,ee=F.symbol==="SOL"&&s.solPriceUsd>0?Z/s.solPriceUsd:Z,re=Math.round(ee*Math.pow(10,F.decimals)),pe={token:t==="sol"?null:F,amount:ee,amountSmallestUnit:re,txSignature:`demo-tx-${Date.now()}`,sessionId:se||`demo-session-${Date.now()}`,response:{sessionId:se||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:re,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:we??void 0};z(pe),U("success"),d?.(pe)},N);return()=>window.clearTimeout(G)},[g,N,q,T,we,$e,s,F,t,se,d]);const Na=c.useCallback(()=>{U(W()),X(""),z(null),H(null),x()},[W,x]);return s.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${f}`,children:[w&&q!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:br.map((G,Z)=>{const ee=ya>=Z,re=G.key===q;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${ee?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${ee?"active":""} ${re?"current":""}`,children:Z+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${ee?"active":""}`,children:G.label})]},G.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[q==="explainer"&&e.jsx(lu,{siteName:k,config:S,depositConfig:s,currencyMode:t,token:F,tokens:_,onContinue:()=>U("unlock"),onCancel:h}),q==="unlock"&&e.jsx(du,{token:F,tokens:_,currencyMode:t,depositMethod:T,isAuthorizing:Hs,error:$,onAuthorize:va,onBack:v?()=>U("explainer"):void 0,onCancel:h}),q==="confirm"&&T==="sign"&&e.jsx(uu,{token:F,tokens:P,quickActionSymbols:L,customTokenSymbols:C,currencyMode:t,minAmount:be,maxAmount:ms,depositAddress:we||j.solanaPubkey,walletReady:He||g,needsUnlock:Gs&&!g,copied:Ue,isListening:!!se&&!g,config:s,onCopy:Qs,onTokenSelect:xr,onUnlockRequired:m,onConfirm:(G,Z)=>Aa(G,Z),onBack:()=>U("unlock"),onCancel:h}),q==="signing"&&e.jsx(hu,{depositAddress:j.solanaPubkey}),q==="show-address"&&e.jsx(mu,{token:F,tokens:P,quickActionSymbols:L,customTokenSymbols:C,tokenPriceUsd:A,currencyMode:t,depositAddress:we||j.solanaPubkey,copied:Ue,isListening:!!se&&!g,config:s,onCopy:Qs,onTokenSelect:xr,onAmountChange:K,onSent:ja,onBack:()=>U("unlock"),onCancel:h}),q==="waiting"&&e.jsx(pu,{token:F,depositAddress:we||j.solanaPubkey,copied:Ue,feeLine:$e?(()=>{const G=Vs(s,$e);return G===0?"No fees":`Fees: $${Math.max(G,.01).toFixed(2)} total`})():"Fees: calculated after deposit",onCopy:Qs}),q==="success"&&B&&e.jsx(fu,{result:B,config:s,onNewDeposit:Na}),q==="error"&&e.jsx(gu,{error:$||y||"An error occurred",onRetry:()=>U("confirm"),onCancel:h})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${f}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function lu({siteName:s,config:t,depositConfig:r,currencyMode:o,token:n,tokens:a,onContinue:i,onCancel:d}){const l=t?.title??"How Deposits Work",h=t?.exchangeName??"Coinbase",m=es.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",u=t?.showExchangeSuggestion!==!1,f=ma(o,n,a),w=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",b=t?.body??w,g=ru(r),N=au(r);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:l}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:b}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:g?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:N})]})]})]}),u&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",f," using your credit card at"," ",e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:h}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[d&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:i,children:"Continue"})]})]})}function du({token:s,tokens:t,currencyMode:r,depositMethod:o,isAuthorizing:n,error:a,onAuthorize:i,onBack:d}){const[l,h]=c.useState(""),m=ma(r,s,t),u=f=>{f.preventDefault(),l.trim()&&(i(l),h(""))};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Authorize Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:o==="sign"?r==="multi-token"?"Enter your password to authorize a deposit. This allows us to process your withdrawal when the privacy period ends.":`Enter your password to authorize a ${m} deposit. This allows us to process your withdrawal when the privacy period ends.`:r==="multi-token"?"Enter your password to get your deposit address. Any supported token sent to this address will be credited to your account.":`Enter your password to get your deposit address. Any ${m} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",htmlFor:"deposit-password",children:"Password"}),e.jsx("input",{id:"deposit-password",type:"password",value:l,onChange:f=>h(f.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:n,autoComplete:"current-password"})]}),a&&e.jsx("p",{className:"cedros-deposit-flow-error",children:a}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:d,disabled:n,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!l.trim()||n,children:n?"Authorizing...":"Continue"})]})]})]})}function uu({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:o,currencyMode:n,minAmount:a,maxAmount:i,depositAddress:d,walletReady:l,needsUnlock:h,copied:m,isListening:u,config:f,onCopy:w,onTokenSelect:b,onUnlockRequired:g,onConfirm:N,onBack:A}){const[v,k]=c.useState(f.privateMinUsd),[S,E]=c.useState(!1),[p,y]=c.useState(!1),[x,j]=c.useState(0),[L,C]=c.useState(null),_=zs(v,f)==="sol_micro",R=s.symbol===Je.symbol,T=c.useMemo(()=>{const $=o.length===0?t:t.filter(ue=>o.includes(ue.symbol)),H=$.length>0?$:t;return H.some(ue=>ue.symbol===Je.symbol)?H:[...H,Je]},[t,o]),I=Vs(f,v),O=I===0?0:I<.01?.01:I,W=R?"Fees: calculated after deposit":I===0?"No fees":`Fees: $${O.toFixed(2)} total`,q=R?"":ha(f,v,I),U=pr(_?Xe:s,f),F=U?v/U:s.symbol==="SOL"&&f.solPriceUsd>0?v/f.solPriceUsd:null,V=F!=null?pa(F,_?"SOL":s.symbol):null,X=v-I<=0&&v>0,B=!R&&v>0&&!X&&F!=null&&F>=a&&F<=i;c.useEffect(()=>{if(n==="multi-token")if(_&&s.symbol!=="SOL"){C(s);const $=t.find(H=>H.symbol==="SOL");$&&b($)}else!_&&L&&s.symbol==="SOL"&&(b(L),C(null))},[_,s.symbol,n,t,b,L,s]);const z=()=>{B&&F!=null&&N(F,s)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),n==="multi-token"&&!_&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[r.map($=>{const H=t.find(ue=>ue.symbol===$),se=s.symbol===$;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${se?"is-active":""}`,onClick:()=>{H&&(E(!1),b(H))},disabled:!H,children:[H?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:H.logoUrl,alt:`${$} logo`}),$]},$)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${S?"is-active":""}`,onClick:()=>{E(!0),j($=>$+1)},children:"Custom"})]}),S&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(dr,{tokens:T,selectedToken:s,onSelect:b,openSignal:x})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(mr,{config:f,valueUsd:v,onChange:k,maxUsd:ua})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:R?"Sign to send tokens to this address":`Sign to send ${V??"--"} ${_?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:d||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:w,title:"Copy address",disabled:!d,children:m?"✓":"⧉"}),d&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${d}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),m&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),X&&e.jsx("div",{className:"cedros-deposit-flow-warning",children:e.jsx("p",{children:"Deposit amount is less than the fees. Increase the amount to proceed."})}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[W,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${p?"is-open":""}`,"data-tooltip":q,"aria-label":`Fee breakdown: ${q.replaceAll(`
|
|
2060
|
-
`,", ")}`,"aria-expanded":
|
|
2061
|
-
`,", ")}`,"aria-expanded":k,onClick:F=>{F.stopPropagation(),S(V=>!V)},onBlur:()=>S(!1),onKeyDown:F=>{F.key==="Escape"&&S(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after confirmation (typically ~30s)."})]})]}),l&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for your deposit. We'll notify you when it arrives."}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:b,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:w,disabled:!O,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function pu({token:s,depositAddress:t,copied:r,feeLine:o,onCopy:n}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:s.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),t&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[t.slice(0,6),"...",t.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:n,title:"Copy address",children:r?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${t}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:o})]})]})]})]})}function fu({result:s,config:t,onNewDeposit:r}){const o=s.token??Xe,n=pr(o,t),a=n?s.amount*n:s.amount,i=Vs(t,a),d=Math.max(a-i,0),l=i===0?0:i<.01?.01:i;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",s.amount.toLocaleString()," ",o.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[s.txSignature&&e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[s.txSignature.slice(0,8),"...",s.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",a.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",l.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Credits Added"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-credit",children:["+$",d.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:r,children:"Make Another Deposit"})})]})}function gu({error:s,onRetry:t,onCancel:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:s}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[r&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:t,children:"Try Again"})]})]})}function fr(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),i=c.useCallback(()=>{n(null)},[]),d=c.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/credits/balance/sol")}catch(m){const u=M.handleApiError(m,"Failed to fetch credit balance");throw n(u.message),u}finally{r(!1)}},[a]),l=c.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return(await a.get("/credits/balance")).balances}catch(m){const u=M.handleApiError(m,"Failed to fetch credit balances");throw n(u.message),u}finally{r(!1)}},[a]),h=c.useCallback(async m=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{const u=new URLSearchParams;m?.currency&&u.set("currency",m.currency),m?.limit!==void 0&&u.set("limit",m.limit.toString()),m?.offset!==void 0&&u.set("offset",m.offset.toString());const f=u.toString(),w=f?`/credits/history?${f}`:"/credits/history";return await a.get(w)}catch(u){const f=M.handleApiError(u,"Failed to fetch transaction history");throw n(f.message),f}finally{r(!1)}},[a]);return{getBalance:d,getAllBalances:l,getHistory:h,isLoading:t,error:o,clearError:i}}function wu({showAllCurrencies:s=!1,refreshInterval:t=0,compact:r=!1,className:o="",onLoad:n}){const{getBalance:a,getAllBalances:i,isLoading:d,error:l,clearError:h}=fr(),[m,u]=c.useState([]),[f,w]=c.useState(null),b=c.useCallback(async()=>{try{if(s){const g=await i();u(g),n?.(g)}else{const g=await a();u([g]),n?.([g])}w(null)}catch(g){w(g instanceof Error?g.message:"Failed to load balance")}},[s,a,i,n]);if(c.useEffect(()=>{b()},[b]),c.useEffect(()=>{if(t<=0)return;const g=setInterval(b,t);return()=>clearInterval(g)},[t,b]),f||l)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${o}`,children:[e.jsx("p",{className:"cedros-credit-error",children:f||l}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{h(),w(null),b()},children:"Retry"})]});if(d&&m.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${o}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(r){const g=m[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${o}`,children:[g?e.jsx("span",{className:"cedros-credit-value",title:`${g.balanceLamports} lamports`,children:g.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),d&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${o}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:b,disabled:d,title:"Refresh balance",children:d?"...":"↻"})]}),m.length===0?e.jsxs("div",{className:"cedros-credit-empty",children:[e.jsx("p",{className:"cedros-credit-empty-message",children:"No credit balance yet."}),e.jsx("p",{className:"cedros-credit-empty-hint",children:"Make a deposit to get started."})]}):e.jsx("div",{className:"cedros-credit-list",children:m.map(g=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:g.currency}),e.jsx("span",{className:"cedros-credit-amount",children:g.display})]},g.currency))})]})}const Rt=[{key:"all",label:"All",txTypes:null},{key:"deposits",label:"Deposits",txTypes:["deposit"]},{key:"usage",label:"Usage",txTypes:["spend","usage","charge"]},{key:"adjustments",label:"Adjustments",txTypes:["refund","adjustment","bonus","credit"]}];function bu(s,t){const r=s<0,o=Math.abs(s),n=da(t),a=o/Math.pow(10,n),i=r?"-":"+";return t.toUpperCase()==="SOL"?`${i}${a.toFixed(4)} SOL`:`${i}$${a.toFixed(2)}`}function xu(s){const t=new Date(s),r=new Date,o=r.getTime()-t.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0})}function yu(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function vu(s,t){const r=(s||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":t?"+":"−"}function Au({defaultTab:s="all",pageSize:t=10,refreshInterval:r=0,className:o="",onLoad:n,onTransactionClick:a}){const{getHistory:i,isLoading:d,error:l,clearError:h}=fr(),[m,u]=c.useState(s),[f,w]=c.useState([]),[b,g]=c.useState(0),[N,A]=c.useState(0),[v,k]=c.useState(null),S=Rt.find(_=>_.key===m)||Rt[0],E=c.useMemo(()=>S.txTypes===null?f:f.filter(_=>{const R=_.txType||"";return S.txTypes.some(T=>R.toLowerCase()===T.toLowerCase())}),[f,S.txTypes]),p=c.useCallback(async()=>{try{const _=await i({limit:t*3,offset:N});w(_.transactions),g(_.total),n?.(_),k(null)}catch(_){k(_ instanceof Error?_.message:"Failed to load history")}},[t,N,i,n]);c.useEffect(()=>{A(0)},[m]),c.useEffect(()=>{p()},[p]),c.useEffect(()=>{if(r<=0)return;const _=setInterval(p,r);return()=>clearInterval(_)},[r,p]);const y=S.txTypes===null?b:E.length,x=Math.ceil(y/t),j=Math.floor(N/t)+1,L=_=>{const R=(_-1)*t;A(Math.max(0,Math.min(R,Math.max(0,y-t))))},C=_=>{u(_)};if(v||l)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${o}`,children:[e.jsx("p",{className:"cedros-tx-error",children:v||l}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{h(),k(null),p()},children:"Retry"})]});if(d&&f.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${o}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=_=>_.txTypes===null?f.length:f.filter(R=>{const T=R.txType||"";return _.txTypes.some(I=>T.toLowerCase()===I.toLowerCase())}).length;return e.jsxs("div",{className:`cedros-tx-history ${o}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Transaction History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:p,disabled:d,title:"Refresh",children:d?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:Rt.map(_=>{const R=P(_),T=m===_.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${T?"cedros-tx-tab-active":""}`,onClick:()=>C(_.key),children:[_.label,R>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:R})]},_.key)})}),E.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:m==="all"?"No transactions yet.":`No ${S.label.toLowerCase()} found.`}),m==="all"&&e.jsx("p",{className:"cedros-tx-empty-hint",children:"Make a deposit to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:E.slice(0,t).map(_=>{const R=_.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${R?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>a?.(_),onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),a?.(_))},role:a?"button":void 0,tabIndex:a?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${R?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:vu(_.txType,R)}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsx("span",{className:"cedros-tx-type",children:yu(_.txType)}),e.jsx("span",{className:`cedros-tx-amount ${R?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:bu(_.amountLamports,_.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:_.description}),e.jsx("span",{className:"cedros-tx-date",children:xu(_.createdAt)})]})]})]},_.id)})}),x>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(j-1),disabled:j<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",j," of ",x]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>L(j+1),disabled:j>=x,children:"Next"})]})]})]})}function gr(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),l=c.useCallback(()=>{n(null)},[]),h=c.useCallback(async()=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await d.get("/wallet/withdraw/balances")}catch(w){const b=M.handleApiError(w,"Failed to fetch wallet balances");throw n(b.message),b}},[d]),m=c.useCallback(async(w,b)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const g=await d.post("/wallet/withdraw/sol",{destination:w,amount_lamports:b});return i(g),g}catch(g){const N=M.handleApiError(g,"Failed to withdraw SOL");throw n(N.message),N}finally{r(!1)}},[d]),u=c.useCallback(async(w,b,g)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const N=await d.post("/wallet/withdraw/spl",{destination:w,token_mint:b,amount:g});return i(N),N}catch(N){const A=M.handleApiError(N,"Failed to withdraw token");throw n(A.message),A}finally{r(!1)}},[d]),f=c.useCallback(async(w=10,b=0)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const g=Math.max(1,Math.min(100,Math.trunc(w))),N=Math.max(0,Math.trunc(b)),A=new URLSearchParams({limit:String(g),offset:String(N)});return await d.get(`/wallet/withdraw/history?${A}`)}catch(g){const N=M.handleApiError(g,"Failed to fetch withdrawal history");throw n(N.message),N}},[d]);return{withdrawSol:m,withdrawSpl:u,getBalances:h,getHistory:f,isSubmitting:t,error:o,clearError:l,lastResult:a}}const Tt="So11111111111111111111111111111111111111112",ju={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Nu(s){return s.length<32||s.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(s)}function Mt(s){return s.length<=16?s:`${s.slice(0,6)}...${s.slice(-6)}`}function ys(s,t){return(Number(s)/Math.pow(10,t)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(t,6)})}function ku({onSuccess:s,onError:t,onCancel:r,className:o=""}){const n=M.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:i,getBalances:d,isSubmitting:l,error:h,clearError:m}=gr(),[u,f]=c.useState("loading"),[w,b]=c.useState([]),[g,N]=c.useState(null),[A,v]=c.useState(""),[k,S]=c.useState(""),[E,p]=c.useState(null),[y,x]=c.useState(null),[j,L]=c.useState(null),C=n?.config.solana?.network??"mainnet-beta",P=c.useMemo(()=>{if(!E?.txSignature)return"";const U=`https://explorer.solana.com/tx/${E.txSignature}`;return C==="mainnet-beta"?U:`${U}?cluster=${encodeURIComponent(C)}`},[E,C]),_=c.useMemo(()=>{if(!g||!k)return"0";const U=parseFloat(k);return isNaN(U)||U<=0?"0":Math.floor(U*Math.pow(10,g.decimals)).toString()},[k,g]);c.useEffect(()=>{if(!n)return;let U=!1;return(async()=>{try{const F=await d();if(U)return;const V=[];F.solLamports>0&&V.push({symbol:"SOL",mint:Tt,decimals:9,rawBalance:String(F.solLamports),displayBalance:ys(String(F.solLamports),9)});for(const Y of F.tokens){const X=ju[Y.mint]??Mt(Y.mint);V.push({symbol:X,mint:Y.mint,decimals:Y.decimals,rawBalance:Y.amount,displayBalance:ys(Y.amount,Y.decimals)})}b(V),f((V.length>0,"select"))}catch{U||(L("Failed to load wallet balances"),f("select"))}})(),()=>{U=!0}},[n,d]);const R=c.useCallback(U=>{N(U),f("form"),m(),x(null),S("")},[m]),T=c.useCallback(()=>{if(!g)return;const U=Number(g.rawBalance)/Math.pow(10,g.decimals);g.mint===Tt?S(String(Math.max(0,U-.01))):S(String(U))},[g]),I=c.useCallback(()=>{if(x(null),!A.trim()){x("Destination address is required");return}if(!Nu(A.trim())){x("Invalid Solana address");return}if(!k||parseFloat(k)<=0||isNaN(parseFloat(k))){x("Please enter a valid amount");return}if(_==="0"){x("Amount is too small");return}f("confirm")},[A,k,_]),O=c.useCallback(async()=>{if(g){f("processing"),m();try{let U;g.mint===Tt?U=await a(A.trim(),Number(_)):U=await i(A.trim(),g.mint,_),p(U),f("success"),s?.(U)}catch(U){f("confirm"),t?.(U instanceof Error?U:new Error(String(U)))}}},[g,A,_,a,i,m,s,t]),W=c.useCallback(()=>{m(),x(null),u==="form"?(f("select"),N(null),S(""),v("")):u==="confirm"&&f("form")},[u,m]),q=c.useCallback(()=>{f("select"),N(null),v(""),S(""),p(null),m(),x(null)},[m]);return n?e.jsxs("div",{className:`cedros-withdrawal ${o}`,children:[u==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(Q.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),u==="select"&&e.jsxs("div",{className:"cedros-withdrawal-select",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdraw"}),e.jsx("p",{className:"cedros-withdrawal-subtitle",children:"Select a token to withdraw"})]}),j&&e.jsx(te.ErrorMessage,{error:j}),w.length===0&&!j&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:w.map(U=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>R(U),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:U.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:U.displayBalance})]},U.mint))}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:r,children:"Cancel"})]}),u==="form"&&g&&e.jsxs("div",{className:"cedros-withdrawal-form",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:W,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",g.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",g.displayBalance," ",g.symbol]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsx("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-destination",children:"Destination Address"}),e.jsx("input",{id:"cedros-withdrawal-destination",type:"text",className:"cedros-input",placeholder:"Solana address (base58)",value:A,onChange:U=>v(U.target.value),autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsxs("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-amount",children:["Amount (",g.symbol,")"]}),e.jsxs("div",{className:"cedros-withdrawal-amount-row",children:[e.jsx("input",{id:"cedros-withdrawal-amount",type:"number",className:"cedros-input",placeholder:"0.00",value:k,onChange:U=>S(U.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:T,children:"Max"})]})]}),(y||h)&&e.jsx(te.ErrorMessage,{error:y||h||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:I,children:"Review Withdrawal"})]}),u==="confirm"&&g&&e.jsxs("div",{className:"cedros-withdrawal-confirm",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:W,disabled:l,children:"Back"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Confirm Withdrawal"})]}),e.jsxs("div",{className:"cedros-withdrawal-summary",children:[e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Token"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:g.symbol})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Amount"}),e.jsxs("span",{className:"cedros-withdrawal-summary-value",children:[ys(_,g.decimals)," ",g.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Destination"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",title:A,children:Mt(A)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),h&&e.jsx(te.ErrorMessage,{error:h}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:W,disabled:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:O,disabled:l,children:l?"Sending...":"Confirm & Send"})]})]}),u==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(Q.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",g?.symbol,"..."]})]}),u==="success"&&E&&e.jsxs("div",{className:"cedros-withdrawal-success",children:[e.jsx("div",{className:"cedros-withdrawal-success-icon",children:"✓"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdrawal Complete"}),e.jsxs("p",{className:"cedros-withdrawal-subtitle",children:[ys(_,g?.decimals??9)," ",g?.symbol," ","sent"]}),e.jsxs("div",{className:"cedros-withdrawal-tx",children:[e.jsx("span",{className:"cedros-withdrawal-tx-label",children:"Transaction"}),e.jsx("a",{className:"cedros-withdrawal-tx-link",href:P,target:"_blank",rel:"noreferrer",children:Mt(E.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:q,children:"Done"})]})]}):null}function Su(s,t){if(s==="sol")return"SOL";if(!t)return"SPL";const r=$s.find(o=>o.mint===t);return r?r.symbol:`${t.slice(0,4)}...${t.slice(-4)}`}function Cu(s,t){const r=Number(s);if(Number.isNaN(r))return s;const o=da(t),n=r/Math.pow(10,o);return t==="SOL"?`${n.toFixed(4)} SOL`:`${n.toFixed(2)} ${t}`}function Eu(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function _u(s){const t=new Date(s),r=new Date,o=r.getTime()-t.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0})}function Lu({pageSize:s=10,className:t="",onTransactionClick:r,explorerUrl:o="https://solscan.io"}){const n=o.startsWith("https://")?o:"https://solscan.io",{getHistory:a,error:i,clearError:d}=gr(),[l,h]=c.useState([]),[m,u]=c.useState(0),[f,w]=c.useState(0),[b,g]=c.useState(!1),[N,A]=c.useState(null),v=c.useCallback(async()=>{g(!0);try{const p=await a(s,f);h(p.items),u(p.total),A(null)}catch(p){A(p instanceof Error?p.message:"Failed to load withdrawal history")}finally{g(!1)}},[s,f,a]);c.useEffect(()=>{v()},[v]);const k=Math.ceil(m/s),S=Math.floor(f/s)+1,E=p=>{const y=(p-1)*s;w(Math.max(0,Math.min(y,Math.max(0,m-s))))};return N||i?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${t}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:N||i}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{d(),A(null),v()},children:"Retry"})]}):b&&l.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${t}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${t}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:v,disabled:b,title:"Refresh",children:b?"...":"↻"})]}),l.length===0?e.jsx("div",{className:"cedros-tx-empty",children:e.jsx("p",{className:"cedros-tx-empty-message",children:"No withdrawal history yet."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:l.map(p=>{const y=Su(p.tokenType,p.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>r?.(p),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),r?.(p))},role:r?"button":void 0,tabIndex:r?0:void 0,children:[e.jsx("div",{className:"cedros-tx-icon cedros-tx-icon-negative",children:"↑"}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsxs("span",{className:"cedros-tx-type",children:[y," Withdrawal"]}),e.jsx("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:Cu(p.amount,y)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${n}/account/${p.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:Eu(p.destination)})," · ",e.jsx("a",{href:`${n}/tx/${p.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:_u(p.createdAt)})]})]})]},p.id)})}),k>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>E(S-1),disabled:S<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",S," of ",k]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>E(S+1),disabled:S>=k,children:"Next"})]})]})]})}function Pu({brandLogo:s,brandName:t,title:r="Welcome back",subtitle:o="Login with your Apple or Google account",termsText:n,onSuccess:a,defaultTab:i="login",children:d,className:l=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${l}`,children:[(s||t)&&e.jsxs("div",{className:"cedros-brand-header",children:[s,t&&e.jsx("span",{className:"cedros-brand-name",children:t})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:r}),o&&e.jsx("p",{className:"cedros-full-page-subtitle",children:o})]}),d??e.jsx(qs,{defaultTab:i,onSuccess:a})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function Ru({brandName:s="Your Brand",brandLogo:t,tagline:r="Your tagline goes here. Make it compelling.",title:o="Sign in",subtitle:n="Enter your credentials to access your account",onSuccess:a,defaultTab:i="login",children:d,className:l=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${l}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[t??e.jsx("div",{className:"cedros-split-page-logo",children:s.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:s}),r&&e.jsx("p",{className:"cedros-split-page-tagline",children:r})]})}),e.jsx("div",{className:"cedros-split-page-form",children:e.jsxs("div",{className:"cedros-split-page-form-content",children:[e.jsx("h2",{className:"cedros-split-page-title",children:o}),n&&e.jsx("p",{className:"cedros-split-page-subtitle",children:n}),d??e.jsx(qs,{defaultTab:i,onSuccess:a})]})})]})}function Tu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=c.useMemo(()=>new Qt.OrgApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),a=c.useCallback(async l=>{o(h=>({...h,isLoading:!0,error:null}));try{const h=await n.authorize(l),m={allowed:h.allowed,reason:h.reason,isLoading:!1,error:null};return o(m),m}catch(h){const m={allowed:!1,reason:void 0,isLoading:!1,error:h};return o(m),m}},[n]),i=c.useCallback(async l=>(await a(l)).allowed,[a]),d=c.useCallback(()=>{o({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:i,lastCheck:r,clearCheck:d,checkAuthorization:a}}function Mu(){const{listAllWallets:s,createDerivedWallet:t,deleteDerivedWallet:r}=D.useWalletMaterial(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useCallback(async()=>{i(!0),l(null);try{const w=await s();n(w.wallets)}catch(w){const b=w instanceof Error?w.message:"Failed to list wallets";l(b)}finally{i(!1)}},[s]),m=c.useCallback(async w=>{i(!0),l(null);try{const b=await t({label:w});return await h(),b}catch(b){const g=b instanceof Error?b.message:"Failed to create wallet";throw l(g),b}finally{i(!1)}},[t,h]),u=c.useCallback(async w=>{i(!0),l(null);try{await r(w),await h()}catch(b){const g=b instanceof Error?b.message:"Failed to delete wallet";throw l(g),b}finally{i(!1)}},[r,h]),f=c.useCallback(()=>l(null),[]);return{wallets:o,isLoading:a,createWallet:m,deleteWallet:u,refresh:h,error:d,clearError:f}}function Iu(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),l=c.useCallback(async()=>{if(!d)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const u=await d.get("/wallet/pending-recovery");i(u)}catch(u){const f=M.handleApiError(u,"Failed to fetch pending recovery");throw n(f.message),f}finally{r(!1)}},[d]),h=c.useCallback(async()=>{if(!d)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const u={confirmed:!0};await d.post("/wallet/acknowledge-recovery",u),i(null)}catch(u){const f=M.handleApiError(u,"Failed to acknowledge recovery");throw n(f.message),f}finally{r(!1)}},[d]),m=c.useCallback(()=>n(null),[]);return c.useEffect(()=>{d&&s?.authState==="authenticated"&&l().catch(()=>{})},[d,s?.authState,l]),{hasPendingRecovery:a?.hasPendingRecovery??!1,recoveryType:a?.recoveryType??null,recoveryPhrase:a?.recoveryPhrase??null,expiresAt:a?.expiresAt?new Date(a.expiresAt):null,fetchPendingRecovery:l,acknowledgeRecovery:h,isLoading:t,error:o,clearError:m}}function Bu(s={}){const{onExternalSign:t}=s,{solanaPubkey:r,hasExternalWallet:o,status:n,isUnlocked:a}=D.useWallet(),{signTransaction:i,isSigning:d,error:l,clearError:h}=Lo(),m=c.useMemo(()=>o&&t?"external":n==="enrolled_locked"||n==="enrolled_unlocked"?"sss":"none",[o,t,n]),u=m!=="none",f=n==="enrolled_locked"||n==="enrolled_unlocked";return{signTransaction:c.useCallback(async(b,g)=>{if(m==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(b)}if(m==="sss"){if(!g&&!a)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return g?i(b,g):i(b)}throw new Error("No signing method available. Enroll a wallet first.")},[m,t,a,i]),signingMethod:m,canSign:u,isSigning:d,publicKey:r,hasExternalWallet:o,hasSssWallet:f,isSssUnlocked:a,error:l,clearError:h}}function Uu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(null),[n,a]=c.useState(!1),[i,d]=c.useState(null),l=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),h=c.useCallback(async()=>{a(!0),d(null);try{await l.post("/welcome-completed",{})}catch(u){const f=u instanceof Error?u:new Error(String(u));throw d(f),f}finally{a(!1)}},[l]),m=c.useCallback(()=>{o(null)},[]);return{postLoginAction:r,setPostLoginAction:o,markWelcomeCompleted:h,clearPostLogin:m,isLoading:n,error:i}}function Du(){const{config:s}=M.useCedrosLogin(),t=s.theme??"auto",r=D.useThemeManager({theme:t,themeOverrides:s.themeOverrides});return{mode:t,isDark:r.className==="cedros-dark",className:r.className,style:r.style,unstyled:s.unstyled??!1,overrides:s.themeOverrides}}function fa(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState([]),[l,h]=c.useState(0),m=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),u=c.useCallback(async()=>{o(!0),a(null);try{const w=await m.post("/access-codes/generate",{},{credentials:"include"});return d(b=>[w,...b]),h(b=>b+1),w}catch(w){const b=w instanceof Error?w:new Error(String(w));throw a(b),b}finally{o(!1)}},[m]),f=c.useCallback(async()=>{o(!0),a(null);try{const w=await m.get("/access-codes/mine",{credentials:"include"});d(w.items),h(w.total)}catch(w){const b=w instanceof Error?w:new Error(String(w));throw a(b),b}finally{o(!1)}},[m]);return{codes:i,total:l,generateCode:u,fetchCodes:f,isLoading:r,error:n}}function Fu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState(null),[m,u]=c.useState(null),[f,w]=c.useState(null),b=f!==null&&f!=="none",g=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),N=c.useCallback(async()=>{o(!0),a(null);try{const v=await g.get("/kyc/status",{credentials:"include"});return d(v.status),h(v.verifiedAt??null),u(v.expiresAt??null),w(v.enforcementMode),v}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[g]),A=c.useCallback(async()=>{o(!0),a(null);try{const v=await g.post("/kyc/start",void 0,{credentials:"include"});return d("pending"),v.redirectUrl}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[g]);return{status:i,verifiedAt:l,expiresAt:m,isRequired:b,enforcementMode:f,fetchStatus:N,startVerification:A,isLoading:r,error:n}}function ga(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState([]),[m,u]=c.useState(0),f=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),w=c.useCallback(async()=>{o(!0),a(null);try{const N=await f.get("/referral/rewards",{credentials:"include"});return d(N),N}catch(N){const A=N instanceof Error?N:new Error(String(N));throw a(A),A}finally{o(!1)}},[f]),b=c.useCallback(async(N=10,A=0)=>{o(!0),a(null);try{const v=await f.get(`/referral/rewards/history?limit=${N}&offset=${A}`,{credentials:"include"});return h(v.items),u(v.total),v}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[f]),g=c.useCallback(async N=>{o(!0),a(null);try{await f.post("/referral/payout-wallet",{walletAddress:N},{credentials:"include"}),d(A=>A&&{...A,payoutWalletAddress:N})}catch(A){const v=A instanceof Error?A:new Error(String(A));throw a(v),v}finally{o(!1)}},[f]);return{rewards:i,history:l,historyTotal:m,fetchRewards:w,fetchHistory:b,setPayoutWallet:g,isLoading:r,error:n}}function It(s,t){return t==="SOL"?(s/1e9).toFixed(4)+" SOL":"$"+(s/1e6).toFixed(2)}function Ou(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}const Wu=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function qu(s){return Wu.test(s)}function zu(s){switch(s){case"signup":return"Sign-up";case"spend":return"Spend";case"first_spend":return"First Spend";default:return s}}function $u({status:s}){const r={pending:"cedros-rewards-panel__badge--pending",completed:"cedros-rewards-panel__badge--completed",failed:"cedros-rewards-panel__badge--failed",credited:"cedros-rewards-panel__badge--credited"}[s]??"cedros-rewards-panel__badge--pending";return e.jsx("span",{className:`cedros-rewards-panel__badge ${r}`,children:s.charAt(0).toUpperCase()+s.slice(1)})}const vs=10;function Vu({explorerUrl:s="https://explorer.solana.com",className:t}){const{rewards:r,history:o,historyTotal:n,fetchRewards:a,fetchHistory:i,setPayoutWallet:d,isLoading:l,error:h}=ga(),[m,u]=c.useState(0),[f,w]=c.useState(""),[b,g]=c.useState(null),[N,A]=c.useState(!1),[v,k]=c.useState(!1);c.useEffect(()=>{a().catch(()=>{}),i(vs,0).catch(()=>{})},[a,i]),c.useEffect(()=>{r?.payoutWalletAddress!=null&&w(r.payoutWalletAddress)},[r?.payoutWalletAddress]);const S=c.useCallback(x=>{u(x),i(vs,x*vs).catch(()=>{})},[i]),E=Math.ceil(n/vs),p=c.useCallback(async()=>{const x=f.trim();if(x!==""&&!qu(x)){g("Invalid address. Must be a base58 string between 32 and 44 characters.");return}g(null),A(!0),k(!1);try{await d(x===""?null:x),k(!0)}catch(j){g(j instanceof Error?j.message:"Failed to save wallet address.")}finally{A(!1)}},[f,d]),y=r?.rewardType==="direct_payout"?"Direct Payout":"Credits";return e.jsxs("div",{className:`cedros-rewards-panel ${t??""}`.trim(),"aria-label":"Rewards dashboard",children:[h&&e.jsx("div",{className:"cedros-rewards-panel__error",role:"alert",children:h.message}),e.jsxs("section",{className:"cedros-rewards-panel__summary","aria-label":"Rewards summary",children:[e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Total Earned"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?It(r.totalEarned,r.currency):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Pending Payouts"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?`${It(r.pendingAmount,r.currency)} (${r.pendingCount})`:"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Referrals"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?String(r.referralCount):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Reward Type"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:e.jsx("span",{className:"cedros-rewards-panel__type-badge",children:y})})]})]}),r?.rewardType==="direct_payout"&&e.jsxs("section",{className:"cedros-rewards-panel__wallet-section","aria-label":"Payout wallet",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"Payout Wallet"}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-current",children:[e.jsx("span",{className:"cedros-rewards-panel__wallet-label",children:"Current address:"}),e.jsx("span",{className:"cedros-rewards-panel__wallet-address",children:r.payoutWalletAddress??"Not set"})]}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-form",children:[e.jsx("label",{htmlFor:"cedros-payout-wallet-input",className:"cedros-rewards-panel__wallet-input-label",children:"Wallet address"}),e.jsx("input",{id:"cedros-payout-wallet-input",type:"text",className:"cedros-rewards-panel__wallet-input",value:f,onChange:x=>{w(x.target.value),g(null),k(!1)},placeholder:"Base58 Solana address","aria-describedby":b?"cedros-wallet-error":void 0,disabled:N}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__wallet-save-btn",onClick:p,disabled:N||l,children:N?"Saving...":"Save"})]}),b&&e.jsx("div",{id:"cedros-wallet-error",className:"cedros-rewards-panel__wallet-error",role:"alert",children:b}),v&&!b&&e.jsx("div",{className:"cedros-rewards-panel__wallet-success",role:"status",children:"Wallet address saved."})]}),e.jsxs("section",{className:"cedros-rewards-panel__history-section","aria-label":"Reward history",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"History"}),l&&o.length===0?e.jsx("div",{className:"cedros-rewards-panel__loading","aria-busy":"true",children:"Loading..."}):o.length===0?e.jsx("div",{className:"cedros-rewards-panel__empty",children:"No rewards yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-rewards-panel__table-wrapper",role:"region","aria-label":"Reward history table",tabIndex:0,children:e.jsxs("table",{className:"cedros-rewards-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Date"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Type"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Amount"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Status"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Transaction"})]})}),e.jsx("tbody",{children:o.map(x=>e.jsxs("tr",{className:"cedros-rewards-panel__tr",children:[e.jsx("td",{className:"cedros-rewards-panel__td",children:Ou(x.createdAt)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:zu(x.triggerType)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:It(x.amount,x.currency)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:e.jsx($u,{status:x.status})}),e.jsx("td",{className:"cedros-rewards-panel__td",children:x.txSignature?e.jsxs("a",{href:`${s}/tx/${x.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-rewards-panel__tx-link","aria-label":`View transaction ${x.txSignature.slice(0,8)}... on Solana explorer`,children:[x.txSignature.slice(0,8),"..."]}):e.jsx("span",{className:"cedros-rewards-panel__tx-none",children:"—"})})]},x.id))})]})}),E>1&&e.jsxs("div",{className:"cedros-rewards-panel__pagination",role:"navigation","aria-label":"History pagination",children:[e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m-1),disabled:m===0||l,"aria-label":"Previous page",children:"Previous"}),e.jsxs("span",{className:"cedros-rewards-panel__page-info",children:[m+1," / ",E]}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m+1),disabled:m>=E-1||l,"aria-label":"Next page",children:"Next"})]})]})]})]})}function En(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}function _n(s){return s.expiresAt&&new Date(s.expiresAt)<new Date?"expired":s.maxUses!==null&&s.currentUses>=s.maxUses?"used":"active"}function Hu({status:s}){const t={active:"cedros-invite-panel__badge--active",used:"cedros-invite-panel__badge--used",expired:"cedros-invite-panel__badge--expired"};return e.jsx("span",{className:`cedros-invite-panel__badge ${t[s]??""}`,children:s.charAt(0).toUpperCase()+s.slice(1)})}function Gu({text:s}){const[t,r]=c.useState(!1),o=c.useCallback(async()=>{try{await navigator.clipboard.writeText(s),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},[s]);return e.jsx("button",{type:"button",className:"cedros-invite-panel__copy-btn",onClick:o,"aria-label":t?"Copied":`Copy code ${s}`,title:t?"Copied!":"Copy to clipboard",children:t?"✓":"Copy"})}function Qu({className:s}){const{codes:t,total:r,generateCode:o,fetchCodes:n,isLoading:a,error:i}=fa(),[d,l]=c.useState(!1),[h,m]=c.useState(null);c.useEffect(()=>{n().catch(()=>{})},[n]);const u=c.useCallback(async()=>{l(!0),m(null);try{await o()}catch(w){m(w instanceof Error?w.message:"Failed to generate invite code.")}finally{l(!1)}},[o]),f=t.filter(w=>_n(w)==="active").length;return e.jsxs("div",{className:`cedros-invite-panel ${s??""}`.trim(),"aria-label":"Invite code panel",children:[e.jsxs("div",{className:"cedros-invite-panel__header",children:[e.jsx("h2",{className:"cedros-invite-panel__title",children:"Invite Codes"}),e.jsxs("span",{className:"cedros-invite-panel__budget","aria-live":"polite",children:[f," active · ",r," total"]})]}),i&&e.jsx("div",{className:"cedros-invite-panel__error",role:"alert",children:i.message}),h&&e.jsx("div",{className:"cedros-invite-panel__error",role:"alert",children:h}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:u,disabled:d||a,"aria-busy":d,children:d?"Generating...":"Generate Invite Code"}),e.jsx("section",{className:"cedros-invite-panel__list-section","aria-label":"Your invite codes",children:a&&t.length===0?e.jsx("div",{className:"cedros-invite-panel__loading","aria-busy":"true",children:"Loading..."}):t.length===0?e.jsx("div",{className:"cedros-invite-panel__empty",children:"No invite codes yet. Generate one above."}):e.jsx("div",{className:"cedros-invite-panel__table-wrapper",role:"region","aria-label":"Invite codes table",tabIndex:0,children:e.jsxs("table",{className:"cedros-invite-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Code"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Uses"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Created"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Expires"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Status"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:e.jsx("span",{className:"cedros-sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:t.map(w=>{const b=_n(w),g=w.maxUses!==null?`${w.currentUses} / ${w.maxUses}`:`${w.currentUses}`;return e.jsxs("tr",{className:"cedros-invite-panel__tr",children:[e.jsx("td",{className:"cedros-invite-panel__td cedros-invite-panel__td--code",children:e.jsx("code",{className:"cedros-invite-panel__code",children:w.code})}),e.jsx("td",{className:"cedros-invite-panel__td",children:g}),e.jsx("td",{className:"cedros-invite-panel__td",children:En(w.createdAt)}),e.jsx("td",{className:"cedros-invite-panel__td",children:w.expiresAt?En(w.expiresAt):"—"}),e.jsx("td",{className:"cedros-invite-panel__td",children:e.jsx(Hu,{status:b})}),e.jsx("td",{className:"cedros-invite-panel__td",children:e.jsx(Gu,{text:w.code})})]},w.id)})})]})})})]})}function Ku({status:s,startVerification:t,className:r}){const[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useCallback(async()=>{n(!0),i(null);try{const m=await t();m&&(window.location.href=m)}catch(m){i(m instanceof Error?m.message:"Failed to start verification")}finally{n(!1)}},[t]);if(s==="verified")return null;let l;switch(s){case"pending":l="Your identity verification is being processed.";break;case"failed":l="Identity verification failed. Please try again.";break;case"expired":l="Your identity verification has expired. Please verify again.";break;case"canceled":l="Verification was canceled. Please try again.";break;default:l="Identity verification is required to continue.";break}const h=s!=="pending";return e.jsxs("div",{className:`cedros-kyc-banner ${r??""}`,role:"alert",children:[e.jsxs("div",{className:"cedros-kyc-banner-content",children:[e.jsx("span",{className:"cedros-kyc-banner-message",children:l}),h&&e.jsx("button",{type:"button",className:"cedros-kyc-banner-button",onClick:d,disabled:o,children:o?"Starting...":"Verify Identity"})]}),a&&e.jsx("div",{className:"cedros-kyc-banner-error",children:a})]})}const Yu=3e3,Zu=6e4;function Xu(s){switch(s){case"verified":return"Identity verified successfully!";case"failed":return"Verification failed. You can try again.";case"expired":return"Your identity verification has expired.";case"canceled":return"Verification was canceled.";default:return"Verification was canceled."}}function Ju({fetchStatus:s,onComplete:t,className:r}){const[o,n]=c.useState(null),[a,i]=c.useState(!1),d=c.useRef(t);d.current=t;const l=c.useRef(s);l.current=s,c.useEffect(()=>{let m=!1,u=null;const f=setTimeout(()=>{i(!0),u!==null&&clearInterval(u)},Zu),w=async()=>{try{const b=await l.current();if(m)return;n(b.status),b.status!=="pending"&&(clearTimeout(f),u!==null&&clearInterval(u),d.current?.(b.status))}catch{}};return w(),u=setInterval(w,Yu),()=>{m=!0,clearTimeout(f),u!==null&&clearInterval(u)}},[]);const h=!o||o==="pending";return e.jsx("div",{className:`cedros-kyc-callback ${r??""}`,role:"status","aria-live":"polite",children:a&&h?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:"cedros-kyc-callback-message",children:"Verification is taking longer than expected. Please refresh or check back later."}),t&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>t("pending"),children:"Continue"})]}):h?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("span",{className:"cedros-kyc-callback-spinner","aria-hidden":"true"}),e.jsx("p",{className:"cedros-kyc-callback-message",children:"Processing your verification..."})]}):e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:`cedros-kyc-callback-message cedros-kyc-callback-message--${o}`,children:Xu(o)}),t&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>t(o),children:"Continue"})]})})}function wa(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState(null),[m,u]=c.useState(null),[f,w]=c.useState(null),b=f!==null&&f!=="none",g=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),N=c.useCallback(async()=>{o(!0),a(null);try{const S=await g.get("/accreditation/status",{credentials:"include"});return d(S.status),h(S.verifiedAt??null),u(S.expiresAt??null),w(S.enforcementMode),S}catch(S){const E=S instanceof Error?S:new Error(String(S));throw a(E),E}finally{o(!1)}},[g]),A=c.useCallback(async(S,E)=>{o(!0),a(null);try{const p=await g.post("/accreditation/submit",{method:S,...E},{credentials:"include"});return d("pending"),p}catch(p){const y=p instanceof Error?p:new Error(String(p));throw a(y),y}finally{o(!1)}},[g]),v=c.useCallback(async(S,E,p)=>{o(!0),a(null);try{const y=new FormData;y.append("submissionId",S),y.append("documentType",p),y.append("file",E);const x=t?.getAccessToken?.(),j={};x&&(j.Authorization=`Bearer ${x}`);const L=await fetch(`${s.serverUrl}/accreditation/upload`,{method:"POST",headers:j,credentials:"include",body:y});if(!L.ok){const C=await L.text().catch(()=>L.statusText);throw new Error(`Upload failed (${L.status}): ${C}`)}return L.json()}catch(y){const x=y instanceof Error?y:new Error(String(y));throw a(x),x}finally{o(!1)}},[s.serverUrl,t]),k=c.useCallback(async()=>{o(!0),a(null);try{return(await g.get("/accreditation/submissions",{credentials:"include"})).submissions}catch(S){const E=S instanceof Error?S:new Error(String(S));throw a(E),E}finally{o(!1)}},[g]);return{status:i,verifiedAt:l,expiresAt:m,isRequired:b,enforcementMode:f,fetchStatus:N,submitVerification:A,uploadDocument:v,listSubmissions:k,isLoading:r,error:n}}const Ln=[{method:"income",label:"Income",description:"Verify via annual income ($200K+ individual / $300K+ joint)"},{method:"net_worth",label:"Net Worth",description:"Verify via net worth ($1M+ excluding primary residence)"},{method:"credential",label:"Professional Credential",description:"Verify via FINRA license (Series 7, 65, or 82)"},{method:"third_party_letter",label:"Third-Party Letter",description:"Upload a verification letter from a CPA, attorney, or RIA"},{method:"insider",label:"Insider / Officer",description:"Self-certify as a director, executive officer, or general partner"},{method:"investment_threshold",label:"Investment Threshold",description:"Qualify via investment commitment ($200K+ individual / $1M+ entity)"}];function As({label:s,acceptedTypes:t=".pdf,.jpg,.jpeg,.png,.tiff",documentType:r,files:o,onFilesChange:n,maxFiles:a=5}){const i=c.useRef(null),[d,l]=c.useState(!1),h=c.useCallback(u=>{if(!u)return;const f=Array.from(u),w=[...o,...f].slice(0,a);n(w)},[o,a,n]),m=u=>{n(o.filter((f,w)=>w!==u))};return e.jsxs("div",{className:"cedros-accreditation-wizard__upload-zone",children:[e.jsx("p",{className:"cedros-accreditation-wizard__upload-label",children:s}),e.jsxs("div",{className:`cedros-accreditation-wizard__drop-area${d?" cedros-accreditation-wizard__drop-area--active":""}`,role:"button",tabIndex:0,"aria-label":`Upload files: ${s}`,onClick:()=>i.current?.click(),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&i.current?.click()},onDragOver:u=>{u.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:u=>{u.preventDefault(),l(!1),h(u.dataTransfer.files)},children:[e.jsx("span",{children:"Click or drag files here"}),e.jsx("span",{className:"cedros-accreditation-wizard__upload-hint",children:t})]}),e.jsx("input",{ref:i,type:"file",accept:t,multiple:a>1,style:{display:"none"},onChange:u=>h(u.target.files),"aria-hidden":"true"}),o.length>0&&e.jsx("ul",{className:"cedros-accreditation-wizard__file-list","aria-label":"Uploaded files",children:o.map((u,f)=>e.jsxs("li",{className:"cedros-accreditation-wizard__file-item",children:[e.jsx("span",{children:u.name}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__file-remove",onClick:()=>m(f),"aria-label":`Remove ${u.name}`,children:"Remove"})]},`${u.name}-${f}`))})]})}function eh(s,t,r,o){t({...s,[r]:o})}function js(s,t){return s.filter(r=>r.documentType===t).map(r=>r.file)}function Ns(s,t,r,o){const n=s.filter(a=>a.documentType!==t);o([...n,...r.map(a=>({file:a,documentType:t}))])}function sh({method:s,formData:t,onFormDataChange:r,fileEntries:o,onFileEntriesChange:n}){const a=(i,d)=>eh(t,r,i,d);return s==="income"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Income Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Income type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"individual",checked:t.incomeType==="individual",onChange:()=>a("incomeType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"joint",checked:t.incomeType==="joint",onChange:()=>a("incomeType","joint")})," ","Joint with spouse ($300K+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"statedAmount",children:"Stated annual income (USD)"}),e.jsx("input",{id:"statedAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"userStatement",children:"Statement about current year income expectation"}),e.jsx("textarea",{id:"userStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx(As,{label:"Upload tax documents (W-2, 1040, 1099, K-1) from the last 2 years",documentType:"tax_return",files:js(o,"tax_return"),onFilesChange:i=>Ns(o,"tax_return",i,n)})]}):s==="net_worth"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Net Worth Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"netWorthAmount",children:"Stated net worth (USD, excluding primary residence)"}),e.jsx("input",{id:"netWorthAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Documents must be dated within the last 90 days."}),e.jsx(As,{label:"Upload asset documents (bank/brokerage statements, property appraisals)",documentType:"asset_statement",files:js(o,"asset_statement"),onFilesChange:i=>Ns(o,"asset_statement",i,n)}),e.jsx(As,{label:"Upload liability documents (credit report)",documentType:"liability_statement",files:js(o,"liability_statement"),onFilesChange:i=>Ns(o,"liability_statement",i,n)})]}):s==="credential"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Professional Credential"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"crdNumber",children:"FINRA CRD Number"}),e.jsx("input",{id:"crdNumber",type:"text",className:"cedros-accreditation-wizard__input",value:t.crdNumber??"",onChange:i=>a("crdNumber",i.target.value)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"licenseType",children:"License type"}),e.jsxs("select",{id:"licenseType",className:"cedros-accreditation-wizard__select",value:t.licenseType??"",onChange:i=>a("licenseType",i.target.value),children:[e.jsx("option",{value:"",children:"Select a license"}),e.jsx("option",{value:"series_7",children:"Series 7"}),e.jsx("option",{value:"series_65",children:"Series 65"}),e.jsx("option",{value:"series_82",children:"Series 82"})]})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Your license will be verified via FINRA BrokerCheck."})]}):s==="third_party_letter"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Third-Party Letter"}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Letter must be dated within the last 90 days."}),e.jsx(As,{label:"Upload verification letter from a CPA, attorney, RIA, or broker-dealer",documentType:"letter",files:js(o,"letter"),onFilesChange:i=>Ns(o,"letter",i,n),maxFiles:1})]}):s==="insider"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Insider / Officer"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"insiderStatement",children:"Describe your role as director, executive officer, or general partner"}),e.jsx("textarea",{id:"insiderStatement",className:"cedros-accreditation-wizard__textarea",rows:4,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"An administrator will verify your status."})]}):e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Investment Threshold"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Entity type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"individual",checked:t.entityType==="individual",onChange:()=>a("entityType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"entity",checked:t.entityType==="entity",onChange:()=>a("entityType","entity")})," ","Entity ($1M+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentAmount",children:"Investment commitment amount (USD)"}),e.jsx("input",{id:"commitmentAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.investmentCommitmentUsd??"",onChange:i=>a("investmentCommitmentUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentStatement",children:"Written representation of commitment"}),e.jsx("textarea",{id:"commitmentStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Per 2025 SEC guidance, a minimum investment commitment serves as evidence of accredited status."})]})}function th({onComplete:s,onCancel:t,className:r}){const{submitVerification:o,uploadDocument:n,isLoading:a,error:i}=wa(),[d,l]=c.useState(1),[h,m]=c.useState(null),[u,f]=c.useState({}),[w,b]=c.useState([]),[g,N]=c.useState(!1),[A,v]=c.useState(null),k=y=>{m(y),l(2)},S=()=>{d===2?l(1):d===3?l(2):t?.()},E=c.useCallback(async()=>{if(h){v(null);try{const{submissionId:y}=await o(h,u);for(const x of w)await n(y,x.file,x.documentType);N(!0),s?.(y)}catch(y){v(y instanceof Error?y.message:"Submission failed. Please try again.")}}},[h,u,w,o,n,s]),p=Ln.find(y=>y.method===h);return g?e.jsx("div",{className:`cedros-accreditation-wizard cedros-accreditation-wizard--success ${r??""}`,role:"status",children:e.jsx("p",{className:"cedros-accreditation-wizard__success-message",children:"Submitted for review. You will be notified once your accreditation is verified."})}):e.jsxs("div",{className:`cedros-accreditation-wizard ${r??""}`,children:[e.jsx("div",{className:"cedros-accreditation-wizard__header",children:e.jsx("nav",{className:"cedros-accreditation-wizard__steps","aria-label":"Wizard steps",children:["Choose Method","Fill Details","Review & Submit"].map((y,x)=>e.jsxs("span",{className:`cedros-accreditation-wizard__step${d===x+1?" cedros-accreditation-wizard__step--active":""}`,"aria-current":d===x+1?"step":void 0,children:[x+1,". ",y]},y))})}),d===1&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step1-heading",children:[e.jsx("h2",{id:"step1-heading",className:"cedros-accreditation-wizard__section-title",children:"Choose Verification Method"}),e.jsx("div",{className:"cedros-accreditation-wizard__method-grid",role:"list",children:Ln.map(y=>e.jsxs("button",{type:"button",role:"listitem",className:"cedros-accreditation-wizard__method-card",onClick:()=>k(y.method),children:[e.jsx("span",{className:"cedros-accreditation-wizard__method-title",children:y.label}),e.jsx("span",{className:"cedros-accreditation-wizard__method-desc",children:y.description})]},y.method))}),t&&e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__cancel",onClick:t,children:"Cancel"})]}),d===2&&h&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step2-heading",children:[e.jsx("h2",{id:"step2-heading",className:"cedros-accreditation-wizard__section-title",children:p?.label}),e.jsx(sh,{method:h,formData:u,onFormDataChange:f,fileEntries:w,onFileEntriesChange:b}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__next",onClick:()=>l(3),children:"Review"})]})]}),d===3&&h&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step3-heading",children:[e.jsx("h2",{id:"step3-heading",className:"cedros-accreditation-wizard__section-title",children:"Review & Submit"}),e.jsxs("dl",{className:"cedros-accreditation-wizard__review-list",children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:"Method"}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:p?.label}),Object.entries(u).filter(([,y])=>y!==void 0&&y!==""&&y!==null).map(([y,x])=>e.jsxs("div",{children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:y}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:String(x)})]},y))]}),w.length>0&&e.jsxs("div",{className:"cedros-accreditation-wizard__review-files",children:[e.jsx("p",{className:"cedros-accreditation-wizard__review-files-heading",children:"Documents to upload:"}),e.jsx("ul",{children:w.map((y,x)=>e.jsxs("li",{children:[y.file.name," ",e.jsxs("span",{className:"cedros-accreditation-wizard__doc-type",children:["(",y.documentType,")"]})]},`${y.file.name}-${x}`))})]}),(i||A)&&e.jsx("div",{className:"cedros-accreditation-wizard__error",role:"alert",children:A??i?.message}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__submit",onClick:E,disabled:a,children:a?"Submitting...":"Submit Verification"})]})]})]})}function rh({status:s,onStartVerification:t,className:r}){if(s==="approved")return null;let o,n=!0;switch(s){case"pending":o="Your accreditation is under review.",n=!1;break;case"rejected":o="Accreditation was not approved. You can resubmit.";break;case"expired":o="Your accreditation has expired. Please verify again.";break;default:o="Accredited investor verification is required.";break}return e.jsx("div",{className:`cedros-accreditation-banner ${r??""}`,role:"alert",children:e.jsxs("div",{className:"cedros-accreditation-banner__content",children:[e.jsx("span",{className:"cedros-accreditation-banner__message",children:o}),n&&t&&e.jsx("button",{type:"button",className:"cedros-accreditation-banner__button",onClick:t,children:s==="rejected"||s==="expired"?"Resubmit Verification":"Start Verification"})]})})}const wr=c.createContext(null),Fs={auth:{email:"Email",password:"Password",confirmPassword:"Confirm Password",name:"Name",optional:"(optional)",createPassword:"Create a password",confirmYourPassword:"Confirm your password",emailPlaceholder:"you@example.com",namePlaceholder:"Your name"},buttons:{signIn:"Sign in",signUp:"Sign up",signOut:"Sign out",createAccount:"Create account",continueWithGoogle:"Continue with Google",continueWithSolana:"Connect Wallet",forgotPassword:"Forgot password?",resetPassword:"Reset password",sendVerification:"Send verification email"},messages:{signingIn:"Signing in...",signingUp:"Signing up...",creatingAccount:"Creating account...",connectingWallet:"Connecting wallet...",verifyingSignature:"Verifying signature...",passwordsDoNotMatch:"Passwords do not match",alreadyHaveAccount:"Already have an account?",dontHaveAccount:"Don't have an account?",orContinueWith:"Or continue with"},errors:{invalidCredentials:"Invalid email or password",emailExists:"An account with this email already exists",invalidEmail:"Please enter a valid email address",weakPassword:"Password does not meet requirements",networkError:"Network error. Please try again.",unknownError:"An error occurred. Please try again.",walletNotFound:"No wallet found. Please install a Solana wallet.",signatureRejected:"Signature request was rejected",challengeExpired:"Challenge expired. Please try again."},passwordValidation:{minLength:"At least 10 characters",uppercase:"At least 1 uppercase letter",lowercase:"At least 1 lowercase letter",number:"At least 1 number",special:"At least 1 special character",weak:"Weak",fair:"Fair",good:"Good",strong:"Strong"}};function ba(s,t){return xa(s,t)}function xa(s,t){const r={...s};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=s[o],a=t[o];typeof n=="object"&&n!==null&&typeof a=="object"&&a!==null?r[o]=xa(n,a):a!==void 0&&(r[o]=a)}return r}function nh({children:s,locale:t="en",translations:r}){const o=c.useMemo(()=>({t:r?ba(Fs,r):Fs,locale:t}),[r,t]);return e.jsx(wr.Provider,{value:o,children:s})}function oh(){return c.useContext(wr)?.t??Fs}function ah(){return c.useContext(wr)?.locale??"en"}exports.CedrosLoginProvider=D.CedrosLoginProvider;exports.getEmbeddedWalletInfo=D.getEmbeddedWalletInfo;exports.isEmbeddedWalletAvailable=D.isEmbeddedWalletAvailable;exports.useAuth=D.useAuth;exports.useWallet=D.useWallet;exports.useWalletMaterial=D.useWalletMaterial;exports.useAuthState=M.useAuthState;exports.useAuthUI=M.useAuthUI;exports.useCedrosLogin=M.useCedrosLogin;exports.LoadingSpinner=Q.LoadingSpinner;exports.useServerFeatures=es.useServerFeatures;exports.EmailLoginForm=J.EmailLoginForm;exports.EmailRegisterForm=J.EmailRegisterForm;exports.OtpInput=J.OtpInput;exports.PasswordInput=J.PasswordInput;exports.TotpVerify=J.TotpVerify;exports.useEmailAuth=J.useEmailAuth;exports.useTotpVerify=J.useTotpVerify;exports.validatePassword=We.validatePassword;exports.ErrorMessage=te.ErrorMessage;exports.GoogleLoginButton=Ht.GoogleLoginButton;exports.useGoogleAuth=Ht.useGoogleAuth;exports.SolanaLoginButton=Ze.SolanaLoginButton;exports.registerMobileWallet=Ze.registerMobileWallet;exports.useSolanaAuth=Ze.useSolanaAuth;exports.InviteForm=fe.InviteForm;exports.InviteList=fe.InviteList;exports.MemberList=fe.MemberList;exports.useInvites=fe.useInvites;exports.useMembers=fe.useMembers;exports.useSystemSettings=Gt.useSystemSettings;exports.AdminDepositList=_s.AdminDepositList;exports.AdminDepositStats=_s.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Me.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Me.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Me.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Me.AdminWithdrawalStats;exports.AdminUserList=Ie.AdminUserList;exports.useAdminUsers=Ie.useAdminUsers;exports.useOrgs=Qt.useOrgs;exports.AdminIcons=Be.Icons;exports.AdminShell=Be.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=Be.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=Be.ProfileDropdown;exports.cedrosLoginPlugin=Be.cedrosLoginPlugin;exports.loginPlugin=Be.cedrosLoginPlugin;exports.useAdminShell=Be.useAdminShell;exports.AuthenticationSettings=Rn.AuthenticationSettings;exports.EmbeddedWalletSettings=Tn.EmbeddedWalletSettings;exports.EmailSettings=ks.EmailSettings;exports.CreditSystemSettings=Kt.CreditSystemSettings;exports.PrivacyCashSettings=Kt.CreditSystemSettings;exports.ServerSettings=Mn.ServerSettings;exports.SettingsPageLayout=ss.SettingsPageLayout;exports.WebhookSettings=ss.WebhookSettings;exports.useAdminDeposits=Sa.useAdminDeposits;exports.AccountSettings=Ud;exports.AccreditationBanner=rh;exports.AccreditationWizard=th;exports.AdminAccessCodes=qo;exports.AdminAccreditationQueue=$o;exports.AdminReferralPayouts=Do;exports.AdminSanctionsPanel=Vo;exports.AppleLoginButton=xo;exports.CapabilityWarning=Hc;exports.CedrosAdminDashboard=Xl;exports.ChooseUsernamePrompt=Od;exports.CompleteAccountPrompt=Fd;exports.ComplianceSettings=Fo;exports.CreditBalance=wu;exports.DepositFlow=cu;exports.ErrorBoundary=Ao;exports.ForgotPasswordForm=go;exports.FullPageLayout=Pu;exports.History=Au;exports.I18nProvider=nh;exports.InviteCodePanel=Qu;exports.KycBanner=Ku;exports.KycCallback=Ju;exports.LinkedAccounts=sa;exports.LoginButton=xc;exports.LoginForm=qs;exports.LoginModal=Cc;exports.MfaSetupPrompt=Dd;exports.OrgSelector=_c;exports.OrgSwitcher=Dc;exports.PasskeyLoginButton=vo;exports.PasskeyPrompt=Ro;exports.ProfileTab=Jo;exports.RecoveryPhraseDisplay=No;exports.RecoveryPhraseInput=ko;exports.ReferralSettings=Oo;exports.ResetPasswordForm=Ec;exports.RewardsPanel=Vu;exports.SUPPORTED_TOKENS=$s;exports.SecuritySettings=kl;exports.SessionList=jo;exports.SetupWizard=Ho;exports.SignupSettings=Wo;exports.SplitPageLayout=Ru;exports.SystemSettings=ul;exports.TieredAmountSlider=mr;exports.TokenGateSettings=zo;exports.TokenSelector=dr;exports.TotpSettings=Zo;exports.TotpSetup=cr;exports.UserProfileSettings=Nd;exports.WalletAddressRow=Bo;exports.WalletEnrollment=_o;exports.WalletManager=dl;exports.WalletRecovery=Io;exports.WalletStatus=Uo;exports.WalletUnlock=To;exports.WithdrawalFlow=ku;exports.WithdrawalHistory=Lu;exports.defaultTranslations=Fs;exports.getTierForAmount=zs;exports.mergeTranslations=ba;exports.useAccessCodes=fa;exports.useAccreditation=wa;exports.useAppleAuth=wo;exports.useAuthorize=Tu;exports.useCedrosTheme=Du;exports.useCredentials=lr;exports.useCredits=fr;exports.useDeposit=ia;exports.useInstantLink=fo;exports.useKyc=Fu;exports.useLocale=ah;exports.usePasskeySigning=Po;exports.usePasswordReset=Ws;exports.usePendingRecovery=Iu;exports.usePostLogin=Uu;exports.useProfile=hs;exports.useReferral=Xo;exports.useRewards=ga;exports.useSessions=oa;exports.useSetPassword=Eo;exports.useSetup=or;exports.useTotp=ir;exports.useTransactionSigning=Bu;exports.useTranslations=oh;exports.useUsername=aa;exports.useWalletEnrollment=Co;exports.useWalletRecovery=Mo;exports.useWalletSigning=Lo;exports.useWallets=Mu;exports.useWebAuthn=nr;exports.useWithdrawal=gr;
|
|
2055
|
+
`);const P=k(y,x,_),L=s.getSymbolSize(y),R=new o(L);return g(R,y),b(R),w(R,y),A(R,x,0),y>=7&&N(R,y),v(R,P),isNaN(j)&&(j=i.getBestMask(R,A.bind(null,R,x))),i.applyMask(j,R),A(R,x,j),{modules:R,version:y,errorCorrectionLevel:x,maskPattern:j,segments:_}}return it.create=function(y,x){if(typeof y>"u"||y==="")throw new Error("No input text");let j=t.M,_,C;return typeof x<"u"&&(j=t.from(x.errorCorrectionLevel,t.M),_=h.from(x.version),C=i.from(x.maskPattern),x.toSJISFunc&&s.setToSJISFunction(x.toSJISFunc)),E(y,_,j,C)},it}var St={},Ct={},bn;function Go(){return bn||(bn=1,(function(s){function t(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let o=r.slice().replace("#","").split("");if(o.length<3||o.length===5||o.length>8)throw new Error("Invalid hex color: "+r);(o.length===3||o.length===4)&&(o=Array.prototype.concat.apply([],o.map(function(a){return[a,a]}))),o.length===6&&o.push("F","F");const n=parseInt(o.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+o.slice(0,6).join("")}}s.getOptions=function(o){o||(o={}),o.color||(o.color={});const n=typeof o.margin>"u"||o.margin===null||o.margin<0?4:o.margin,a=o.width&&o.width>=21?o.width:void 0,i=o.scale||4;return{width:a,scale:a?4:i,margin:n,color:{dark:t(o.color.dark||"#000000ff"),light:t(o.color.light||"#ffffffff")},type:o.type,rendererOpts:o.rendererOpts||{}}},s.getScale=function(o,n){return n.width&&n.width>=o+n.margin*2?n.width/(o+n.margin*2):n.scale},s.getImageWidth=function(o,n){const a=s.getScale(o,n);return Math.floor((o+n.margin*2)*a)},s.qrToImageData=function(o,n,a){const i=n.modules.size,d=n.modules.data,l=s.getScale(i,a),h=Math.floor((i+a.margin*2)*l),m=a.margin*l,u=[a.color.light,a.color.dark];for(let f=0;f<h;f++)for(let g=0;g<h;g++){let b=(f*h+g)*4,w=a.color.light;if(f>=m&&g>=m&&f<h-m&&g<h-m){const N=Math.floor((f-m)/l),A=Math.floor((g-m)/l);w=u[d[N*i+A]?1:0]}o[b++]=w.r,o[b++]=w.g,o[b++]=w.b,o[b]=w.a}}})(Ct)),Ct}var xn;function wd(){return xn||(xn=1,(function(s){const t=Go();function r(n,a,i){n.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=i,a.width=i,a.style.height=i+"px",a.style.width=i+"px"}function o(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}s.render=function(a,i,d){let l=d,h=i;typeof l>"u"&&(!i||!i.getContext)&&(l=i,i=void 0),i||(h=o()),l=t.getOptions(l);const m=t.getImageWidth(a.modules.size,l),u=h.getContext("2d"),f=u.createImageData(m,m);return t.qrToImageData(f.data,a,l),r(u,h,m),u.putImageData(f,0,0),h},s.renderToDataURL=function(a,i,d){let l=d;typeof l>"u"&&(!i||!i.getContext)&&(l=i,i=void 0),l||(l={});const h=s.render(a,i,l),m=l.type||"image/png",u=l.rendererOpts||{};return h.toDataURL(m,u.quality)}})(St)),St}var Et={},yn;function bd(){if(yn)return Et;yn=1;const s=Go();function t(n,a){const i=n.a/255,d=a+'="'+n.hex+'"';return i<1?d+" "+a+'-opacity="'+i.toFixed(2).slice(1)+'"':d}function r(n,a,i){let d=n+a;return typeof i<"u"&&(d+=" "+i),d}function o(n,a,i){let d="",l=0,h=!1,m=0;for(let u=0;u<n.length;u++){const f=Math.floor(u%a),g=Math.floor(u/a);!f&&!h&&(h=!0),n[u]?(m++,u>0&&f>0&&n[u-1]||(d+=h?r("M",f+i,.5+g+i):r("m",l,0),l=0,h=!1),f+1<a&&n[u+1]||(d+=r("h",m),m=0)):l++}return d}return Et.render=function(a,i,d){const l=s.getOptions(i),h=a.modules.size,m=a.modules.data,u=h+l.margin*2,f=l.color.light.a?"<path "+t(l.color.light,"fill")+' d="M0 0h'+u+"v"+u+'H0z"/>':"",g="<path "+t(l.color.dark,"stroke")+' d="'+o(m,h,l.margin)+'"/>',b='viewBox="0 0 '+u+" "+u+'"',N='<svg xmlns="http://www.w3.org/2000/svg" '+(l.width?'width="'+l.width+'" height="'+l.width+'" ':"")+b+' shape-rendering="crispEdges">'+f+g+`</svg>
|
|
2056
|
+
`;return typeof d=="function"&&d(null,N),N},Et}var vn;function xd(){if(vn)return He;vn=1;const s=Jl(),t=gd(),r=wd(),o=bd();function n(a,i,d,l,h){const m=[].slice.call(arguments,1),u=m.length,f=typeof m[u-1]=="function";if(!f&&!s())throw new Error("Callback required as last argument");if(f){if(u<2)throw new Error("Too few arguments provided");u===2?(h=d,d=i,i=l=void 0):u===3&&(i.getContext&&typeof h>"u"?(h=l,l=void 0):(h=l,l=d,d=i,i=void 0))}else{if(u<1)throw new Error("Too few arguments provided");return u===1?(d=i,i=l=void 0):u===2&&!i.getContext&&(l=d,d=i,i=void 0),new Promise(function(g,b){try{const w=t.create(d,l);g(a(w,i,l))}catch(w){b(w)}})}try{const g=t.create(d,l);h(null,a(g,i,l))}catch(g){h(g)}}return He.create=t.create,He.toCanvas=n.bind(null,r.render),He.toDataURL=n.bind(null,r.renderToDataURL),He.toString=n.bind(null,function(a,i,d){return o.render(a,d)}),He}var yd=xd();const vd=Tn(yd);function Ad({value:s,size:t=200,alt:r="QR code",className:o=""}){const n=c.useRef(null),[a,i]=c.useState(null);return c.useEffect(()=>{!n.current||!s||vd.toCanvas(n.current,s,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{i(null)}).catch(d=>{i(d instanceof Error?d.message:"Failed to generate QR code")})},[s,t]),a?e.jsx("div",{className:`cedros-qr-error ${o}`,style:{width:t,height:t},role:"img","aria-label":r,children:e.jsx("p",{children:"Failed to generate QR code"})}):e.jsx("canvas",{ref:n,className:`cedros-totp-qr-image ${o}`,role:"img","aria-label":r,style:{borderRadius:"0.5rem"}})}function nr(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(null),[n,a]=c.useState("idle"),[i,d]=c.useState(null),[l,h]=c.useState(!1),[m,u]=c.useState(null),f=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),g=c.useCallback(async()=>{h(!0),u(null);try{const S=await f.get("/mfa/status");return o(S),S}catch(S){const E=M.handleApiError(S,"Unable to load two-factor authentication status. Please try again.");throw u(E),E}finally{h(!1)}},[f]),b=c.useCallback(async()=>{h(!0),u(null),a("loading");try{const S=await f.post("/mfa/setup",{});return d(S),a("setup"),S}catch(S){const E=M.handleApiError(S,"Unable to start two-factor setup. Please try again.");throw u(E),a("error"),E}finally{h(!1)}},[f]),w=c.useCallback(async S=>{if(!/^\d{6}$/.test(S)){const E={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw u(E),E}h(!0),u(null),a("verifying");try{await f.post("/mfa/enable",{code:S}),a("success");try{const E=await f.get("/mfa/status");o(E)}catch{o({enabled:!0,recoveryCodesRemaining:0})}}catch(E){const p=M.handleApiError(E,"Incorrect verification code. Please check and try again.");throw u(p),a("error"),p}finally{h(!1)}},[f]),N=c.useCallback(async S=>{if(!S){const E={code:"VALIDATION_ERROR",message:"Please enter your password"};throw u(E),E}h(!0),u(null);try{await f.post("/mfa/disable",{password:S}),o({enabled:!1,recoveryCodesRemaining:0}),d(null),a("idle")}catch(E){const p=M.handleApiError(E,"Unable to disable two-factor authentication. Please try again.");throw u(p),p}finally{h(!1)}},[f]),A=c.useCallback(async S=>{if(!/^\d{6}$/.test(S)){const E={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw u(E),E}h(!0),u(null);try{return await f.post("/mfa/recovery-codes/regenerate",{code:S})}catch(E){const p=M.handleApiError(E,"Unable to regenerate recovery codes. Please try again.");throw u(p),p}finally{h(!1)}},[f]),v=c.useCallback(()=>u(null),[]),k=c.useCallback(()=>{u(null),d(null),a("idle"),h(!1)},[]);return{status:r,setupState:n,setupData:i,isLoading:l,error:m,getStatus:g,beginSetup:b,enableTotp:w,disableTotp:N,regenerateBackupCodes:A,clearError:v,reset:k}}function or({onSuccess:s,onCancel:t,className:r=""}){const{setupState:o,setupData:n,isLoading:a,error:i,beginSetup:d,enableTotp:l,clearError:h,reset:m}=nr(),[u,f]=c.useState("qr"),[g,b]=c.useState(""),[w,N]=c.useState(!1),[A,v]=c.useState(!1),k=c.useRef(null);c.useEffect(()=>{o==="idle"&&d().catch(()=>{})},[o,d]),c.useEffect(()=>{o==="success"&&s?.()},[o,s]);const S=async()=>{n?.secret&&(await navigator.clipboard.writeText(n.secret),N(!0),k.current!==null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>N(!1),2e3))},E=async()=>{if(n?.recoveryCodes){const x=n.recoveryCodes.join(`
|
|
2057
|
+
`);await navigator.clipboard.writeText(x)}},p=async()=>{try{await l(g)}catch{b("")}},y=()=>{m(),t?.()};return c.useEffect(()=>()=>{k.current!==null&&(window.clearTimeout(k.current),k.current=null)},[]),o==="loading"||o==="idle"&&a?e.jsx("div",{className:`cedros-totp-setup ${r}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(z.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):o==="error"&&!n?e.jsxs("div",{className:`cedros-totp-setup ${r}`,children:[e.jsx(Z.ErrorMessage,{error:i,onDismiss:h}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>d(),children:"Try again"})]})]}):o==="success"?e.jsx("div",{className:`cedros-totp-setup ${r}`,children:e.jsxs("div",{className:"cedros-totp-success",children:[e.jsxs("svg",{className:"cedros-totp-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"var(--cedros-success)",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"var(--cedros-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication enabled"}),e.jsx("p",{className:"cedros-totp-description",children:"Your account is now protected with an additional layer of security."})]})}):n?e.jsxs("div",{className:`cedros-totp-setup ${r}`,children:[u==="qr"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Scan QR code"}),e.jsx("p",{className:"cedros-totp-description",children:"Use your authenticator app to scan this QR code."}),e.jsx("div",{className:"cedros-totp-qr",children:e.jsx(Ad,{value:n.otpauthUri,size:200,alt:"QR code for authenticator app"})}),e.jsxs("div",{className:"cedros-totp-manual",children:[e.jsx("p",{className:"cedros-totp-manual-label",children:"Or enter this code manually:"}),e.jsxs("div",{className:"cedros-totp-secret",children:[e.jsx("code",{className:"cedros-totp-secret-code",children:n.secret}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:S,"aria-label":"Copy secret",children:w?"Copied!":"Copy"})]})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("backup"),children:"Continue"})]})]}),u==="backup"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Save recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. You can use them to access your account if you lose your authenticator device."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:n.recoveryCodes.map((x,j)=>e.jsx("code",{className:"cedros-totp-backup-code",children:x},j))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:E,children:"Copy all codes"}),e.jsxs("label",{className:"cedros-checkbox-label cedros-totp-confirm",children:[e.jsx("input",{type:"checkbox",className:"cedros-checkbox",checked:A,onChange:x=>v(x.target.checked)}),e.jsx("span",{className:"cedros-checkbox-text",children:"I have saved these recovery codes"})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>f("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("verify"),disabled:!A,children:"Continue"})]})]}),u==="verify"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Verify setup"}),e.jsx("p",{className:"cedros-totp-description",children:"Enter the 6-digit code from your authenticator app to complete setup."}),e.jsx(K.OtpInput,{value:g,onChange:b,onComplete:p,disabled:a,error:i?.message,autoFocus:!0}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>f("backup"),disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:p,disabled:a||g.length!==6,children:a?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function Qo({onStatusChange:s,className:t=""}){const{status:r,isLoading:o,error:n,getStatus:a,disableTotp:i,regenerateBackupCodes:d,clearError:l}=nr(),[h,m]=c.useState("status"),[u,f]=c.useState(""),[g,b]=c.useState(""),[w,N]=c.useState(null),[A,v]=c.useState(!1),[k,S]=c.useState(null);c.useEffect(()=>{a().catch(()=>{})},[a]);const E=c.useCallback(()=>{m("status"),s?.(!0)},[s]),p=async()=>{v(!0),S(null);try{await i(u),m("status"),f(""),s?.(!1)}catch(j){S(j instanceof Error?j.message:"Failed to disable 2FA"),f("")}finally{v(!1)}},y=async()=>{v(!0),S(null);try{const j=await d(g);N(j.recoveryCodes),b("")}catch(j){S(j instanceof Error?j.message:"Failed to regenerate codes"),b("")}finally{v(!1)}},x=async()=>{w&&await navigator.clipboard.writeText(w.join(`
|
|
2058
|
+
`))};return o&&!r?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(z.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):n&&!r?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(Z.ErrorMessage,{error:n,onDismiss:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>a(),children:"Retry"})]}):h==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(or,{onSuccess:E,onCancel:()=>m("status")})}):h==="disable"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),k&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(K.PasswordInput,{label:"Password",placeholder:"Enter your password",value:u,onChange:j=>f(j.target.value),disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{m("status"),f(""),S(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:p,disabled:A||u.length===0,children:A?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):h==="regenerate"?w?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:w.map((j,_)=>e.jsx("code",{className:"cedros-totp-backup-code",children:j},_))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:x,children:"Copy all codes"}),e.jsx("div",{className:"cedros-totp-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>{m("status"),N(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),k&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k},onDismiss:()=>S(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(K.OtpInput,{value:g,onChange:b,onComplete:y,disabled:A,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{m("status"),b(""),S(null)},disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:y,disabled:A||g.length!==6,children:A?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${r?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:r?.enabled?"Enabled":"Disabled"})]}),r?.enabled?e.jsxs("div",{className:"cedros-totp-enabled-actions",children:[e.jsxs("div",{className:"cedros-totp-description",style:{marginTop:"0.25rem"},children:["Recovery codes remaining: ",e.jsx("strong",{children:r.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>m("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>m("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>m("setup"),children:"Enable two-factor authentication"})]})})}class jd{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(r){throw M.handleApiError(r,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(r){throw M.handleApiError(r,"Failed to update profile")}}}function is(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useMemo(()=>new jd(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),l=c.useCallback(()=>{i(null)},[]),h=c.useCallback(async u=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");n(!0),i(null);try{return await d.updateProfile(u)}catch(f){const g=f instanceof Error?f:new Error("Failed to update profile");throw i(g),g}finally{n(!1)}},[t,d]),m=c.useCallback(async u=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");n(!0),i(null);try{await d.changePassword(u)}catch(f){const g=f instanceof Error?f:new Error("Failed to change password");throw i(g),g}finally{n(!1)}},[t,d]);return{isLoading:o,error:a,updateProfile:h,changePassword:m,clearError:l}}function Ko(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),d=c.useCallback(async()=>{o(!0),a(null);try{return await i.get("/referral",{credentials:"include"})}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[i]),l=c.useCallback(async()=>{o(!0),a(null);try{return(await i.post("/referral/regenerate",void 0,{credentials:"include"})).referralCode}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[i]);return{getReferral:d,regenerateCode:l,isLoading:r,error:n}}function Nd(s){return s?.name?s.name.split(" ").map(t=>t[0]).join("").toUpperCase().slice(0,2):s?.email?s.email[0].toUpperCase():"?"}function kd({onPasswordChange:s,onClose:t,className:r=""}){const{user:o,refreshUser:n}=U.useAuth(),{config:a,_internal:i}=M.useCedrosLogin(),{isLoading:d,error:l,changePassword:h,updateProfile:m,clearError:u}=is(),[f,g]=c.useState("main"),[b,w]=c.useState(""),[N,A]=c.useState(""),[v,k]=c.useState(""),[S,E]=c.useState(null),[p,y]=c.useState(null),[x,j]=c.useState(!1),_=c.useRef(null),[C,P]=c.useState(o?.payoutWalletAddress??""),[L,R]=c.useState(!1),[T,B]=c.useState(!1),[F,W]=c.useState(null),q=c.useCallback(async()=>{const V=C.trim();if(V.length>0&&(V.length<32||V.length>44)){W("Invalid Solana address — must be 32–44 characters.");return}const Ie=/^[1-9A-HJ-NP-Za-km-z]+$/;if(V.length>0&&!Ie.test(V)){W("Invalid Solana address — contains non-base58 characters.");return}W(null),R(!0);try{await m({payoutWalletAddress:V||void 0}),await n(),B(!0),setTimeout(()=>B(!1),2e3)}catch(ce){W(ce instanceof Error?ce.message:"Failed to save payout wallet")}finally{R(!1)}},[C,m,n]),{getReferral:D,regenerateCode:$,isLoading:Q}=Ko(),[H,re]=c.useState(null),[I,O]=c.useState(0),[X,Y]=c.useState(!1),[ie,Ae]=c.useState(!1);c.useEffect(()=>{D().then(V=>{re(V.referralCode),O(V.referralCount),Ae(V.directPayoutEnabled)}).catch(()=>{})},[]);const je=Fe.validatePassword(N),Xe=N===v,Me=b.length>0&&N.length>0&&v.length>0&&je.isValid&&Xe,Be=c.useCallback(async V=>{const Ie=V.target.files?.[0];if(Ie){E(null),j(!0);try{const ce=new FormData;ce.append("file",Ie);const cs=i?.getAccessToken?.(),ls={};cs&&(ls.Authorization=`Bearer ${cs}`);const Ne=await fetch(`${a.serverUrl}/auth/upload/avatar`,{method:"POST",headers:ls,body:ce,credentials:"include"});if(!Ne.ok){const es=await Ne.json().catch(()=>null);throw new Error(es?.message||es?.error||`Upload failed (${Ne.status})`)}await n()}catch(ce){E(ce instanceof Error?ce.message:"Failed to upload avatar")}finally{j(!1),_.current&&(_.current.value="")}}},[a.serverUrl,i,n]),zs=c.useCallback(async()=>{if(Me){E(null),y(null);try{await h({currentPassword:b,newPassword:N}),w(""),A(""),k(""),y("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{g("main"),y(null)},2e3)}catch(V){E(V instanceof Error?V.message:"Failed to change password")}}},[Me,b,N,h,s]),Je=c.useCallback(()=>{g("main"),w(""),A(""),k(""),E(null),u()},[u]);return f==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(S||l)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:S||l?.message||""},onDismiss:()=>{E(null),u()}})}),p&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),p]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:b,onChange:V=>w(V.target.value),disabled:d,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"New password",placeholder:"Enter new password",value:N,onChange:V=>A(V.target.value),disabled:d,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:v,onChange:V=>k(V.target.value),disabled:d,error:v.length>0&&!Xe?"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:Je,disabled:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:zs,disabled:d||!Me,children:d?e.jsxs(e.Fragment,{children:[e.jsx(z.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:V=>{(V.key==="Enter"||V.key===" ")&&(V.preventDefault(),_.current?.click())},"aria-label":"Change profile picture",children:[x?e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:e.jsx(z.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:Nd(o)}),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:Be,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:()=>g("change-password"),children:"Change"})]})]}),H&&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:H})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{navigator.clipboard.writeText(H),Y(!0),setTimeout(()=>Y(!1),2e3)},children:X?"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:I})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:async()=>{try{const V=await $();re(V)}catch{}},disabled:Q,children:Q?"Regenerating...":"Regenerate"})]})]}),ie&&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:V=>{P(V.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:q,disabled:L,children:L?"Saving...":"Save wallet"})})]}),t&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})})}class Sd{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(t){throw M.handleApiError(t,"Failed to list credentials")}}async unlinkCredential(t){try{await this.client.delete(`/credentials/${encodeURIComponent(t)}`)}catch(r){throw M.handleApiError(r,"Failed to unlink credential")}}}function ar(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useMemo(()=>new Sd(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),m=c.useCallback(()=>{l(null)},[]),u=c.useCallback(async()=>{if(t!=="authenticated"){n([]);return}i(!0),l(null);try{const g=await h.listCredentials();n(g)}catch(g){l(g)}finally{i(!1)}},[t,h]);c.useEffect(()=>{t==="authenticated"?u():n([])},[t,u]);const f=c.useCallback(async g=>{i(!0),l(null);try{await h.unlinkCredential(g),await u()}catch(b){throw l(b),b}finally{i(!1)}},[h,u]);return{credentials:o,isLoading:a,error:d,fetchCredentials:u,unlinkCredential:f,clearError:m}}function Cd({onPasswordChange:s,onCancel:t,className:r=""}){const{isLoading:o,error:n,changePassword:a,clearError:i}=is(),[d,l]=c.useState(""),[h,m]=c.useState(""),[u,f]=c.useState(""),[g,b]=c.useState(null),[w,N]=c.useState(null),A=Fe.validatePassword(h),v=h===u,k=d.length>0&&h.length>0&&u.length>0&&A.isValid&&v,S=c.useCallback(async()=>{if(k){b(null),N(null);try{await a({currentPassword:d,newPassword:h}),l(""),m(""),f(""),N("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>t(),2e3)}catch(p){b(p instanceof Error?p.message:"Failed to change password")}}},[k,d,h,a,s,t]),E=c.useCallback(()=>{b(null),i(),t()},[i,t]);return e.jsx("div",{className:`cedros-profile-settings ${r}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(g||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:g||n?.message||""},onDismiss:()=>{b(null),i()}})}),w&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),w]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:d,onChange:p=>l(p.target.value),disabled:o,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"New password",placeholder:"Enter new password",value:h,onChange:p=>m(p.target.value),disabled:o,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(K.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:u,onChange:p=>f(p.target.value),disabled:o,error:u.length>0&&!v?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:E,disabled:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:S,disabled:o||!k,children:o?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function Yo({onPasswordChange:s,className:t=""}){const{user:r,refreshUser:o}=U.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:d}=is(),{credentials:l}=ar(),{forgotPassword:h,isLoading:m,isSuccess:u,reset:f}=Us(),g=l.some(j=>j.credentialType==="password"),[b,w]=c.useState("view"),[N,A]=c.useState(""),[v,k]=c.useState(null),S=()=>r?.name?r.name.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2):r?.email?r.email[0].toUpperCase():"?",E=c.useCallback(()=>{A(r?.name||""),w("edit"),k(null)},[r?.name]),p=c.useCallback(async()=>{const j=N.trim();if(j){k(null);try{await i({name:j}),await o(),w("view")}catch(_){k(_ instanceof Error?_.message:"Failed to update name")}}},[N,i,o]),y=c.useCallback(()=>{w("view"),A(""),k(null),d()},[d]),x=c.useCallback(async()=>{if(r?.email){k(null);try{await h(r.email)}catch(j){k(j instanceof Error?j.message:"Failed to send password setup email")}}},[r?.email,h]);return b==="change-password"?e.jsx(Cd,{onPasswordChange:s,onCancel:()=>w("view"),className:t}):e.jsx("div",{className:`cedros-profile-settings ${t}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:r?.picture?e.jsx("img",{src:r.picture,alt:r.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:S()})}),e.jsxs("div",{className:"cedros-profile-info",children:[b==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:N,onChange:j=>A(j.target.value),disabled:n,autoFocus:!0,onKeyDown:j=>{j.key==="Enter"&&p(),j.key==="Escape"&&y()}}),e.jsxs("div",{className:"cedros-profile-name-edit-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:p,disabled:n||!N.trim(),children:n?e.jsx(z.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(Ed,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:r?.email})]})]}),(v||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v||a?.message||""},onDismiss:()=>{k(null),d()}})}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:r?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:g?"••••••••":"Not set"})]}),g?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{w("change-password"),k(null)},children:"Change"}):u?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:f,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:x,disabled:m,children:m?e.jsx(z.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function Ed(){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:s,onLinkApple:t,onAddPasskey:r,onLinkSolana:o,className:n=""}){const{credentials:a,isLoading:i,error:d,unlinkCredential:l,clearError:h,fetchCredentials:m}=ar(),{registerPasskey:u,isSupported:f}=sr(),[g,b]=c.useState(null),[w,N]=c.useState(!1),A=c.useCallback(async()=>{if(r){r();return}N(!0);try{await u(),await m()}catch{}finally{N(!1)}},[r,u,m]),v=c.useCallback(async j=>{const _=j.label||Zo[j.credentialType];if(window.confirm(`Remove "${_}" as a sign-in method? You won't be able to sign in with it anymore.`)){b(j.id);try{await l(j.id)}catch{}finally{b(null)}}},[l]),k=new Set(a.map(j=>j.credentialType)),S=s&&!k.has("oauth_google"),E=t&&!k.has("oauth_apple"),p=(r||f)&&!k.has("webauthn_passkey"),y=o&&!k.has("solana"),x=S||E||p||y;return i&&a.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${n}`,children:[d&&e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:d.message},onDismiss:h}),a.length===0&&!i&&e.jsx("p",{className:"cedros-linked-accounts-empty",children:"No linked sign-in methods found."}),a.length>0&&e.jsx("ul",{className:"cedros-linked-credential-list",children:a.map(j=>e.jsx(_d,{credential:j,isUnlinking:g===j.id,onUnlink:v},j.id))}),x&&e.jsxs("div",{className:"cedros-linked-add",children:[e.jsx("p",{className:"cedros-linked-add-label",children:"Link a new sign-in method"}),e.jsxs("div",{className:"cedros-linked-add-buttons",children:[S&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(Jo,{})," Google"]}),E&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(ea,{})," Apple"]}),p&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:A,disabled:w,children:w?e.jsx(z.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(qt,{})," Passkey"]})}),y&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(sa,{})," Solana"]})]})]})]})}function _d({credential:s,isUnlinking:t,onUnlink:r}){const o=s.label||Zo[s.credentialType],n=Ld[s.credentialType]||Pd;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 ",An(s.createdAt),s.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",An(s.lastUsedAt)]}),s.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>r(s),disabled:t,title:s.isPrimary?"Cannot remove primary sign-in method":"Remove",children:t?e.jsx(z.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function An(s){const t=new Date(s),o=new Date().getTime()-t.getTime(),n=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),i=Math.floor(o/(1e3*60*60*24));return n<1?"just now":n<60?`${n}m ago`:a<24?`${a}h ago`:i<30?`${i}d ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const Ld={password:Rd,oauth_google:Jo,oauth_apple:ea,solana:sa,webauthn_passkey:qt,webauthn_security_key:qt,totp:Td,sso_oidc:Md};function Pd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("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 Rd(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"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 sa(){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 qt(){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 Td(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"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 Md(){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 Bd{client;constructor(t,r,o,n){this.client=new M.ApiClient({baseUrl:t,timeoutMs:r,retryAttempts:o,getAccessToken:n})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(t){throw M.handleApiError(t,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(t){throw M.handleApiError(t,"Failed to revoke sessions")}}}function ta(){const{config:s,authState:t,_internal:r}=M.useCedrosLogin(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useMemo(()=>new Bd(s.serverUrl,s.requestTimeout,s.retryAttempts,r?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,r]),m=c.useCallback(async()=>{if(t!=="authenticated"){n([]);return}i(!0),l(null);try{const g=await h.listSessions();n(g)}catch(g){l(g)}finally{i(!1)}},[t,h]);c.useEffect(()=>{t==="authenticated"?m():n([])},[t,m]);const u=c.useCallback(async()=>{i(!0),l(null);try{const g=await h.revokeAllSessions();return await m(),g}catch(g){throw l(g),g}finally{i(!1)}},[h,m]),f=c.useMemo(()=>o.filter(g=>!g.isCurrent).length,[o]);return{sessions:o,isLoading:a,error:d,fetchSessions:m,revokeAllSessions:u,otherSessionCount:f}}const Id={profile:"Profile",security:"Security",linked:"Linked Accounts"},Dd=["profile","security","linked"];function Ud({defaultTab:s="profile",onClose:t,onPasswordChange:r,onTotpChange:o,onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:d,className:l=""}){const[h,m]=c.useState(s),{sessions:u,isLoading:f,error:g,revokeAllSessions:b}=ta();return e.jsxs("div",{className:`cedros-account-settings ${l}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:Dd.map(w=>e.jsx("button",{type:"button",role:"tab","aria-selected":h===w,className:`cedros-account-tab ${h===w?"cedros-account-tab-active":""}`,onClick:()=>m(w),children:Id[w]},w))}),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(Qo,{onStatusChange:o}),e.jsx(yo,{sessions:u,isLoading:f,error:g??void 0,onRevokeAll:async()=>{await b()}})]}),h==="linked"&&e.jsx(Xo,{onLinkGoogle:n,onLinkApple:a,onAddPasskey:i,onLinkSolana:d})]}),t&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})}function Fd({onComplete:s,className:t}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${t??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(or,{onSuccess:s})})]})}function Wd({onComplete:s,onSkip:t,className:r}){const{user:o}=U.useAuth(),{isLoading:n,error:a,updateProfile:i,clearError:d}=is(),[l,h]=c.useState(o?.name??""),m=c.useCallback(async f=>{f.preventDefault(),d();const g=l.trim();if(!g){s?.();return}try{await i({name:g}),s?.()}catch{}},[l,i,d,s]),u=l.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${r??""}`,children:[e.jsxs("div",{className:"cedros-complete-account__header",children:[e.jsx("h2",{className:"cedros-complete-account__title",children:"Complete Your Profile"}),e.jsx("p",{className:"cedros-complete-account__description",children:"Please fill in your name to get started."})]}),e.jsxs("form",{onSubmit:m,className:"cedros-complete-account__form",children:[e.jsxs("div",{className:"cedros-complete-account__field",children:[e.jsx("label",{htmlFor:"cedros-complete-name",className:"cedros-complete-account__label",children:"Name"}),e.jsx("input",{id:"cedros-complete-name",type:"text",value:l,onChange:f=>h(f.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),a&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:a.message}),e.jsxs("div",{className:"cedros-complete-account__actions",children:[e.jsx("button",{type:"submit",className:"cedros-complete-account__button cedros-complete-account__button--primary",disabled:n||!u,children:n?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:t,disabled:n,children:"Skip"})]})]})]})}function ra(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),i=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),d=c.useCallback(async m=>await i.get(`/username/available?username=${encodeURIComponent(m)}`,{credentials:"include"}),[i]),l=c.useCallback(async()=>{try{return(await i.get("/username/available?username=",{credentials:"include"})).suggestion??null}catch{return null}},[i]),h=c.useCallback(async m=>{o(!0),a(null);try{await i.patch("/me",{username:m})}catch(u){const f=u instanceof Error?u:new Error(String(u));throw a(f),f}finally{o(!1)}},[i]);return{checkAvailability:d,getSuggestion:l,setUsername:h,isLoading:r,error:n}}function Od({onComplete:s,onSkip:t,className:r}){const{checkAvailability:o,getSuggestion:n,setUsername:a,isLoading:i,error:d}=ra(),[l,h]=c.useState(""),[m,u]=c.useState("idle"),[f,g]=c.useState(""),b=c.useRef(null),w=c.useRef(!0);c.useEffect(()=>(w.current=!0,n().then(k=>{w.current&&k&&(h(k),u("available"),g("Available"))}),()=>{w.current=!1}),[n]);const N=c.useCallback(k=>{const S=k.toLowerCase().replace(/[^a-z0-9_]/g,"");if(h(S),u("idle"),g(""),b.current&&clearTimeout(b.current),S.length<3){S.length>0&&(u("error"),g("At least 3 characters"));return}u("checking"),b.current=setTimeout(async()=>{try{const E=await o(S);if(!w.current)return;E.error?(u("error"),g(E.error)):E.available?(u("available"),g("Available")):(u("taken"),g("Already taken"),E.suggestion)}catch{if(!w.current)return;u("error"),g("Could not check availability")}},400)},[o]),A=c.useCallback(async k=>{if(k.preventDefault(),!(m!=="available"||!l.trim()))try{await a(l.trim()),s?.()}catch{}},[l,m,a,s]),v=m==="available"&&!i;return e.jsxs("div",{className:`cedros-choose-username ${r??""}`,children:[e.jsxs("div",{className:"cedros-choose-username__header",children:[e.jsx("h2",{className:"cedros-choose-username__title",children:"Choose a Username"}),e.jsx("p",{className:"cedros-choose-username__description",children:"Pick a unique handle for your account."})]}),e.jsxs("form",{onSubmit:A,className:"cedros-choose-username__form",children:[e.jsxs("div",{className:"cedros-choose-username__field",children:[e.jsx("label",{htmlFor:"cedros-choose-username",className:"cedros-choose-username__label",children:"Username"}),e.jsxs("div",{className:"cedros-choose-username__input-wrapper",children:[e.jsx("span",{className:"cedros-choose-username__prefix",children:"@"}),e.jsx("input",{id:"cedros-choose-username",type:"text",value:l,onChange:k=>N(k.target.value),placeholder:"swift_falcon_42",className:"cedros-choose-username__input",maxLength:30,autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),f&&e.jsx("span",{className:`cedros-choose-username__status cedros-choose-username__status--${m}`,role:m==="error"||m==="taken"?"alert":void 0,children:m==="checking"?"Checking...":f})]}),d&&e.jsx("div",{className:"cedros-choose-username__error",role:"alert",children:d.message}),e.jsxs("div",{className:"cedros-choose-username__actions",children:[e.jsx("button",{type:"submit",className:"cedros-choose-username__button cedros-choose-username__button--primary",disabled:!v,children:i?"Saving...":"Continue"}),e.jsx("button",{type:"button",className:"cedros-choose-username__button cedros-choose-username__button--secondary",onClick:t,disabled:i,children:"Skip"})]})]})]})}function na(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),i=c.useCallback(()=>{n(null)},[]),d=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(b)||b<=0){const w=new Error(`Invalid deposit amount: ${b}. Must be a positive integer (lamports).`);throw n(w.message),w}r(!0),n(null);try{return await a.post("/deposit",{amount_lamports:b})}catch(w){const N=M.handleApiError(w,"Failed to execute deposit");throw n(N.message),N}finally{r(!1)}},[a]),l=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");return await a.get(`/deposit/status/${encodeURIComponent(b)}`)},[a]),h=c.useCallback(async()=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/deposit/config")}catch(b){const w=M.handleApiError(b,"Failed to get deposit config");throw n(w.message),w}finally{r(!1)}},[a]),m=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const w=new URLSearchParams;b?.limit!==void 0&&w.set("limit",String(b.limit)),b?.offset!==void 0&&w.set("offset",String(b.offset));const N=w.toString(),A=N?`/deposits?${N}`:"/deposits";return await a.get(A)}catch(w){const N=M.handleApiError(w,"Failed to list deposits");throw n(N.message),N}finally{r(!1)}},[a]),u=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{const w=new URLSearchParams({input_mint:b.inputMint,amount:String(b.amount),taker:b.taker});return await a.get(`/deposit/quote?${w}`)}catch(w){const N=M.handleApiError(w,"Failed to get deposit quote");throw n(N.message),N}finally{r(!1)}},[a]),f=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/public",b)}catch(w){const N=M.handleApiError(w,"Failed to execute public deposit");throw n(N.message),N}finally{r(!1)}},[a]),g=c.useCallback(async b=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.post("/deposit/micro",b)}catch(w){const N=M.handleApiError(w,"Failed to execute micro deposit");throw n(N.message),N}finally{r(!1)}},[a]);return{deposit:d,getQuote:u,publicDeposit:f,microDeposit:g,getStatus:l,getConfig:h,listDeposits:m,isLoading:t,error:o,clearError:i}}const ir="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=",qd="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=",zd="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==",$d="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",Vd="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==",Hd="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==",Gd="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",Kd="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",Yd="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 oa(s){const t=s.toUpperCase();return Ws.find(o=>o.symbol===t)?.decimals??6}function Zd(s,t){const r=s.toUpperCase(),n=Ws.find(a=>a.symbol===r)?.decimals??t;return n===void 0?2:r==="SOL"?4:n===6&&r!=="SOL"?2:n>6?6:n}const Ws=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:ir},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Gd},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Yd},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:$d},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:Kd},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Hd},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Qd},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:zd},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:qd},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Vd}],Ns=1e9,aa=1e4,Qe={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:ir},Ms={mint:"other",symbol:"OTHER",name:"Other",decimals:6},Xd=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function jn(s){return s.map(t=>t.trim()).filter(Boolean)}function ia(s,t,r){return s==="sol"?"SOL":s==="single-token"?t.symbol:r.some(n=>n.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function cr(s,t,r){if(Xd.has(s.symbol))return 1;const o=t.tokenPrices?.[s.symbol];if(o&&o>0)return o;if(s.symbol==="SOL")return t.solPriceUsd||null;const n=r?.[s.symbol];return n&&n>0?n:null}function ca(s,t){return s.toFixed(Zd(t))}function Jd(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function eu(s,t,r){const{feePolicy:o,privacyFeePercent:n,swapFeePercent:a,companyFeePercent:i}=s;let d=i;return r||(o==="user_pays_all"?(d+=a,t&&(d+=n)):o==="user_pays_privacy"&&t?d+=n:o==="user_pays_swap"&&(d+=a)),d}function su(s,t){const r=t<s.publicMinUsd,o=t>=s.privateMinUsd,n=[],a=!r&&o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),i=!r&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),d=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(a){const l=s.privacyFeeFixedLamports/Ns,h=s.privacyFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Privacy",solAmount:l,percent:h,usdAmount:m+u})}if(i){const l=s.swapFeeFixedLamports/Ns,h=s.swapFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Swap",solAmount:l,percent:h,usdAmount:m+u})}if(d){const l=s.companyFeeFixedLamports/Ns,h=s.companyFeePercent,m=l*s.solPriceUsd,u=t*(h/100);n.push({label:"Service",solAmount:l,percent:h,usdAmount:m+u})}return n}function la(s,t,r){const o=su(s,t),n=r===0?0:r<.01?.01:r;if(o.length===0)return r===0?"No fees":`Total: $${n.toFixed(2)}`;const a=o.reduce((b,w)=>b+w.solAmount,0),i=o.reduce((b,w)=>b+w.percent,0),d={fee:7,sol:8,rate:7,usd:8},l=b=>{const w=b.label.padEnd(d.fee),N=b.solAmount.toFixed(4).padStart(6).padEnd(d.sol),A=(b.percent.toFixed(2)+"%").padStart(5).padEnd(d.rate),k=("$"+(b.usdAmount===0?0:Math.max(b.usdAmount,.01)).toFixed(2)).padEnd(d.usd);return`${w} │ ${N} │ ${A} │ ${k}`},h=`${"Fee".padEnd(d.fee)} │ ${"SOL".padEnd(d.sol)} │ ${"+ Rate".padEnd(d.rate)} │ ${"= Total".padEnd(d.usd)}`,m=`${"─".repeat(d.fee)}─┼─${"─".repeat(d.sol)}─┼─${"─".repeat(d.rate)}─┼─${"─".repeat(d.usd)}`,u=("$"+n.toFixed(2)).padEnd(d.usd),f=`${"TOTAL".padEnd(d.fee)} │ ${a.toFixed(4).padStart(6).padEnd(d.sol)} │ ${(i.toFixed(2)+"%").padStart(5).padEnd(d.rate)} │ ${u}`;return[h,m,...o.map(l),m,f].join(`
|
|
2059
|
+
`)}function tu(s){const t=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,r=s.swapFeeFixedLamports>0||s.swapFeePercent>0,o=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return!t&&!r&&!o?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function Os(s,t){if(t<=0)return 0;const r=t<s.publicMinUsd,o=t>=s.privateMinUsd,n=eu(s,o,r);let a=s.companyFeeFixedLamports;r||(o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(a+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(a+=s.swapFeeFixedLamports));const i=a/Ns*s.solPriceUsd,d=t*(n/100);return i+d}function ru({step:s,sessionId:t,demoMode:r,demoAutoConfirmMs:o,depositMethod:n,depositAddress:a,receiveAmountUsd:i,selectedToken:d,currencyMode:l,config:h,solanaPubkey:m,pollInterval:u,getStatus:f,onSuccess:g,setResult:b,setStep:w,setFlowError:N}){c.useEffect(()=>{if(!(s==="confirm"||s==="show-address"||s==="waiting")||!t||r)return;let v=!1,k=0,S=0;const E=360,p=5,y=async()=>{if(!(v||k>=E)){k++;try{const x=await f(t);if(S=0,x.status==="completed"||x.status==="detected"){const j=x.amountLamports?x.amountLamports/Math.pow(10,d.decimals):0,_=x.amountLamports||0,C={token:l==="sol"?null:d,amount:j,amountSmallestUnit:_,txSignature:x.txSignature||"",sessionId:t,response:x,method:"receive",depositAddress:m??void 0};b(C),w("success"),g?.(C);return}}catch{if(S++,S>=p){N("Unable to check deposit status. Please check your connection and try again.");return}}v||setTimeout(y,u)}};return y(),()=>{v=!0}},[s,t,r,f,d,l,m,g,u,b,w,N]),c.useEffect(()=>{if(!r||!o||s!=="waiting"||n!=="receive"||!a)return;const A=window.setTimeout(()=>{const v=i??h.privateMinUsd,k=d.symbol==="SOL"&&h.solPriceUsd>0?v/h.solPriceUsd:v,S=Math.round(k*Math.pow(10,d.decimals)),E={token:l==="sol"?null:d,amount:k,amountSmallestUnit:S,txSignature:`demo-tx-${Date.now()}`,sessionId:t||`demo-session-${Date.now()}`,response:{sessionId:t||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:S,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:a??void 0};b(E),w("success"),g?.(E)},o);return()=>window.clearTimeout(A)},[r,o,s,n,a,i,h,d,l,t,g,b,w])}function nu({siteName:s,config:t,depositConfig:r,currencyMode:o,token:n,tokens:a,onContinue:i,onCancel:d}){const l=t?.title??"How Deposits Work",h=t?.exchangeName??"Coinbase",m=Ke.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",u=t?.showExchangeSuggestion!==!1,f=ia(o,n,a),g=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",b=t?.body??g,w=Jd(r),N=tu(r);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:l}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:b}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:w?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:N})]})]})]}),u&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",f," using your credit card at"," ",e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:h}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[d&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:i,children:"Continue"})]})]})}function ou({token:s,tokens:t,currencyMode:r,depositMethod:o,isAuthorizing:n,error:a,onAuthorize:i,onBack:d}){const[l,h]=c.useState(""),m=ia(r,s,t),u=f=>{f.preventDefault(),l.trim()&&(i(l),h(""))};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Authorize Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:o==="sign"?r==="multi-token"?"Enter your password to authorize a deposit. This allows us to process your withdrawal when the privacy period ends.":`Enter your password to authorize a ${m} deposit. This allows us to process your withdrawal when the privacy period ends.`:r==="multi-token"?"Enter your password to get your deposit address. Any supported token sent to this address will be credited to your account.":`Enter your password to get your deposit address. Any ${m} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",htmlFor:"deposit-password",children:"Password"}),e.jsx("input",{id:"deposit-password",type:"password",value:l,onChange:f=>h(f.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:n,autoComplete:"current-password"})]}),a&&e.jsx("p",{className:"cedros-deposit-flow-error",children:a}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:d,disabled:n,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!l.trim()||n,children:n?"Authorizing...":"Continue"})]})]})]})}function qs(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const au=1e4,Bs=1e3,da=3;function iu(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function cu(s,t){switch(s){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${iu(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function lr(s,t,r){return Math.min(Math.max(s,t),r)}function lu(s,t){if(t<=0)return 0;const r=lr(s/t,0,1);return Math.round(Math.pow(r,1/da)*Bs)}function du(s,t){const r=lr(s/Bs,0,1);return t*Math.pow(r,da)}function ua(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function uu(s){return s<1?2:0}function Nn(s){const t=ua(s),r=Math.round(s/t)*t,o=uu(t);return Number(r.toFixed(o))}function dr({config:s,valueUsd:t,onChange:r,maxUsd:o=au,disabled:n=!1,className:a=""}){const i=lr(Number.isFinite(t)?t:0,0,o),d=c.useMemo(()=>qs(i,s),[i,s]),l=cu(d,s),h=lu(i,o),m=h/Bs*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:ua(i),className:"cedros-deposit-flow-input cedros-tiered-slider-input-field","aria-label":"Deposit amount"})]}),e.jsxs("div",{className:"cedros-tiered-slider-tier",children:[e.jsxs("span",{className:`cedros-tiered-slider-badge cedros-tiered-slider-badge-${d}`,children:[d==="sol_micro"&&e.jsx("img",{src:ir,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),l.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:l.detail})]})]}),e.jsx("input",{type:"range",min:0,max:Bs,step:1,value:h,onChange:u=>r(Nn(du(parseFloat(u.target.value),o))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${m}%, var(--cedros-border) ${m}%, var(--cedros-border) 100%)`},disabled:n,"aria-label":"Deposit amount slider"}),l.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:l.note})]})}function ha({tokens:s,selectedToken:t,onSelect:r,openSignal:o,placeholder:n="Select token",disabled:a=!1,className:i="",searchable:d=!0}){const[l,h]=c.useState(!1),[m,u]=c.useState(""),f=c.useRef(null),g=c.useRef(null),b=c.useMemo(()=>{if(!m.trim())return s;const v=m.toLowerCase();return s.filter(k=>k.symbol.toLowerCase().includes(v)||k.name.toLowerCase().includes(v)||k.mint.toLowerCase().includes(v))},[s,m]);c.useEffect(()=>{const v=k=>{f.current&&!f.current.contains(k.target)&&(h(!1),u(""))};if(l)return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[l]),c.useEffect(()=>{l&&d&&g.current&&g.current.focus()},[l,d]),c.useEffect(()=>{o===void 0||a||(h(!0),u(""))},[o,a]);const w=c.useCallback(()=>{a||(h(v=>!v),l&&u(""))},[a,l]),N=c.useCallback(v=>{r(v),h(!1),u("")},[r]),A=c.useCallback(v=>{v.key==="Escape"?(h(!1),u("")):v.key==="Enter"&&b.length===1&&N(b[0])},[b,N]);return e.jsxs("div",{ref:f,className:`cedros-token-selector ${l?"cedros-token-selector-open":""} ${a?"cedros-token-selector-disabled":""} ${i}`,onKeyDown:A,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:w,disabled:a,"aria-haspopup":"listbox","aria-expanded":l,children:[t?e.jsxs("span",{className:"cedros-token-selector-selected",children:[t.logoUrl&&e.jsx("img",{src:t.logoUrl,alt:t.symbol,className:"cedros-token-icon",onError:v=>{v.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:n}),e.jsx("span",{className:"cedros-token-selector-arrow",children:l?"▲":"▼"})]}),l&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[d&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:g,type:"text",value:m,onChange:v=>u(v.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:b.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:b.map(v=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===v.mint?"cedros-token-option-selected":""}`,onClick:()=>N(v),role:"option","aria-selected":t?.mint===v.mint,children:[v.logoUrl&&e.jsx("img",{src:v.logoUrl,alt:v.symbol,className:"cedros-token-icon",onError:k=>{k.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:v.symbol}),e.jsx("span",{className:"cedros-token-name",children:v.name})]}),t?.mint===v.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},v.mint))})})]})]})}function ma({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:o,onTokenSelect:n}){const[a,i]=c.useState(!1),[d,l]=c.useState(0),h=c.useMemo(()=>{const m=o.length===0?t:t.filter(g=>o.includes(g.symbol)),u=m.length>0?m:t;return u.some(g=>g.symbol===Ms.symbol)?u:[...u,Ms]},[t,o]);return 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(m=>{const u=t.find(g=>g.symbol===m),f=s.symbol===m;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${f?"is-active":""}`,onClick:()=>{u&&(i(!1),n(u))},disabled:!u,children:[u?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:u.logoUrl,alt:`${m} logo`}),m]},m)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${a?"is-active":""}`,onClick:()=>{i(!0),l(m=>m+1)},children:"Custom"})]}),a&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(ha,{tokens:h,selectedToken:s,onSelect:n,openSignal:d})})]})}function hu({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:o,currencyMode:n,minAmount:a,maxAmount:i,depositAddress:d,walletReady:l,needsUnlock:h,copied:m,isListening:u,config:f,onCopy:g,onTokenSelect:b,onUnlockRequired:w,onConfirm:N,onBack:A}){const[v,k]=c.useState(f.privateMinUsd),[S,E]=c.useState(!1),[p,y]=c.useState(null),j=qs(v,f)==="sol_micro",_=s.symbol===Ms.symbol,C=Os(f,v),P=C===0?0:C<.01?.01:C,L=_?"Fees: calculated after deposit":C===0?"No fees":`Fees: $${P.toFixed(2)} total`,R=_?"":la(f,v,C),T=cr(j?Qe:s,f),B=T?v/T:s.symbol==="SOL"&&f.solPriceUsd>0?v/f.solPriceUsd:null,F=B!=null?ca(B,j?"SOL":s.symbol):null,q=v-C<=0&&v>0,D=!_&&v>0&&!q&&B!=null&&B>=a&&B<=i;c.useEffect(()=>{if(n==="multi-token")if(j&&s.symbol!=="SOL"){y(s);const Q=t.find(H=>H.symbol==="SOL");Q&&b(Q)}else!j&&p&&s.symbol==="SOL"&&(b(p),y(null))},[j,s.symbol,n,t,b,p,s]);const $=()=>{D&&B!=null&&N(B,s)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),n==="multi-token"&&!j&&e.jsx(ma,{token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:o,onTokenSelect:b}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(dr,{config:f,valueUsd:v,onChange:k,maxUsd:aa})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:_?"Sign to send tokens to this address":`Sign to send ${F??"--"} ${j?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:d||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:g,title:"Copy address",disabled:!d,children:m?"✓":"⧉"}),d&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${d}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),m&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),q&&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:[L,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${S?"is-open":""}`,"data-tooltip":R,"aria-label":`Fee breakdown: ${R.replaceAll(`
|
|
2060
|
+
`,", ")}`,"aria-expanded":S,onClick:Q=>{Q.stopPropagation(),E(H=>!H)},onBlur:()=>E(!1),onKeyDown:Q=>{Q.key==="Escape"&&E(!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."}),w&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:w,children:"Unlock Wallet"})]}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:A,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:$,disabled:!D||!l||!d,children:"Deposit"})]})]})}function mu({depositAddress:s}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Signing Transfer"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Approve the transfer in your wallet extension..."}),s&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[s.slice(0,6),"...",s.slice(-4)]})]})]})}function pu({token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:o,tokenPriceUsd:n,currencyMode:a,depositAddress:i,copied:d,isListening:l,config:h,onCopy:m,onTokenSelect:u,onAmountChange:f,onSent:g,onBack:b}){const[w,N]=c.useState(h.privateMinUsd),[A,v]=c.useState(!1),[k,S]=c.useState(null),p=qs(w,h)==="sol_micro",y=s.symbol===Ms.symbol,x=Os(h,w),j=x===0?0:x<.01?.01:x,_=y?"Fees: calculated after deposit":x===0?"No fees":`Fees: $${j.toFixed(2)} total`,C=y?"":la(h,w,x),P=y||w>0,L=cr(p?Qe:s,h,n),R=L?w/L:null,T=R?ca(R,s.symbol):null;return c.useEffect(()=>{if(a==="multi-token")if(p&&s.symbol!=="SOL"){S(s);const B=t.find(F=>F.symbol==="SOL");B&&u(B)}else!p&&k&&s.symbol==="SOL"&&(u(k),S(null))},[p,s.symbol,a,t,u,k,s]),c.useEffect(()=>{f(w)},[w,f]),i?e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Send Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Send funds to your deposit address. We'll confirm automatically."}),a==="multi-token"&&!p&&e.jsx(ma,{token:s,tokens:t,quickActionSymbols:r,customTokenSymbols:o,onTokenSelect:u}),!y&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(dr,{config:h,valueUsd:w,onChange:N,maxUsd:aa})]}),y&&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:y?"Send any token to this address":`Send ${T??"--"} ${p?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:i}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:m,title:"Copy address",children:d?"✓":"📋"})]}),d&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[_,!y&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${A?"is-open":""}`,"data-tooltip":C,"aria-label":`Fee breakdown: ${C.replaceAll(`
|
|
2061
|
+
`,", ")}`,"aria-expanded":A,onClick:B=>{B.stopPropagation(),v(F=>!F)},onBlur:()=>v(!1),onKeyDown:B=>{B.key==="Escape"&&v(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after confirmation (typically ~30s)."})]})]}),l&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for your deposit. We'll notify you when it arrives."}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:b,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:g,disabled:!P,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 fu({token:s,depositAddress:t,copied:r,feeLine:o,onCopy:n}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:s.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),t&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[t.slice(0,6),"...",t.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:n,title:"Copy address",children:r?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${t}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:o})]})]})]})]})}function gu({result:s,config:t,onNewDeposit:r}){const o=s.token??Qe,n=cr(o,t),a=n?s.amount*n:s.amount,i=Os(t,a),d=Math.max(a-i,0),l=i===0?0:i<.01?.01:i;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",s.amount.toLocaleString()," ",o.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[s.txSignature&&e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[s.txSignature.slice(0,8),"...",s.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",a.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",l.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Credits Added"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-credit",children:["+$",d.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:r,children:"Make Another Deposit"})})]})}function wu({error:s,onRetry:t,onCancel:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:s}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[r&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:t,children:"Try Again"})]})]})}function bu({steps:s,currentStepIndex:t,currentStep:r}){return e.jsx("div",{className:"cedros-deposit-flow-steps",children:s.map((o,n)=>{const a=t>=n,i=o.key===r;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${a?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${a?"active":""} ${i?"current":""}`,children:n+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${a?"active":""}`,children:o.label})]},o.key)})})}function xu({config:s,currencyMode:t,depositMethod:r,tokens:o=[],defaultToken:n,minAmount:a,maxAmount:i=1e4,onSuccess:d,onError:l,onCancel:h,onUnlockRequired:m,onAuthorize:u,className:f="",showStepIndicator:g=!0,pollInterval:b=5e3,demoMode:w=!1,demoAutoConfirmMs:N,tokenPriceUsd:A,showExplainer:v=!1,siteName:k,explainerConfig:S}){const{deposit:E,getStatus:p,error:y,clearError:x}=na(),j=U.useWallet(),_=jn(s.quickActionTokens),C=jn(s.customTokenSymbols),P=c.useMemo(()=>{const G=s.customTokens??[];if(G.length===0)return o;const se=new Set(o.map(he=>he.symbol)),le=[...o];for(const he of G)se.has(he.symbol)||(le.push({mint:he.mint,symbol:he.symbol,name:he.symbol,decimals:he.decimals,logoUrl:he.logoUrl}),se.add(he.symbol));return le},[o,s.customTokens]),L=c.useMemo(()=>{if(C.length===0)return P;const G=P.filter(se=>C.includes(se.symbol));return G.length>0?G:P},[P,C]),R=s.privateDepositsEnabled,T=r?r==="sign"&&!R?"receive":r:R&&j.hasExternalWallet?"sign":"receive",B=_[0]?P.find(G=>G.symbol===_[0]):void 0,F=t==="sol"?Qe:t==="single-token"?B??P.find(G=>G.symbol==="USDC")??P[0]??Qe:n??B??P.find(G=>G.symbol==="USDC")??P.find(G=>G.symbol!=="SOL")??P[0]??Qe,W=c.useCallback(()=>v?"explainer":"unlock",[v]),[q,D]=c.useState(W),[$,Q]=c.useState(F),[H,re]=c.useState(""),[I,O]=c.useState(null),[X,Y]=c.useState(null),[ie,Ae]=c.useState(null),[je,Xe]=c.useState(null),[Me,Be]=c.useState(!1),[zs,Je]=c.useState(!1),[V,Ie]=c.useState(null),ce=c.useRef(null);c.useEffect(()=>()=>{ce.current&&clearTimeout(ce.current)},[]),c.useEffect(()=>{D(W()),Q(F),re(""),O(null),Y(null),Ae(null),Xe(null),Be(!1),Je(!1),Ie(null),x()},[t,T,F,x]);const cs=a??s.privateMinSol,ls=i,Ne=parseFloat(H),es=j.status==="enrolled_locked"||j.status==="enrolled_unlocked"||j.status==="unlocked",$s=es&&j.isUnlocked,Vs=es&&!j.isUnlocked,pr=c.useCallback(()=>{let le=T==="sign"?[{key:"unlock",label:"Authorize"},{key:"confirm",label:"Send"},{key:"signing",label:"Signing"},{key:"success",label:"Complete"}]:[{key:"unlock",label:"Authorize"},{key:"show-address",label:"Send"},{key:"waiting",label:"Confirming"},{key:"success",label:"Complete"}];return v&&(le=[{key:"explainer",label:"Info"},...le]),le},[T,v])(),xa=pr.findIndex(G=>G.key===q),fr=c.useCallback(G=>{Q(G)},[]),ya=c.useCallback(async G=>{if(!u){D(T==="sign"?"confirm":"show-address");return}Je(!0),Y(null);try{const le=await u(G,T==="sign"?Ne:null,$);Ae(le.sessionId),Xe(le.depositAddress),D(T==="sign"?"confirm":"show-address")}catch(se){const le=se instanceof Error?se:new Error("Authorization failed");Y(le.message)}finally{Je(!1)}},[u,T,Ne,$]),va=c.useCallback(async(G,se)=>{x(),Y(null),D("signing");const le=G??Ne,he=se??$;if(!w){if(Vs&&m){m(),D("confirm");return}if(!$s){Y("Wallet not ready"),D("error");return}}try{const De=Math.round(le*Math.pow(10,he.decimals));if(w){await new Promise(ka=>setTimeout(ka,1500));const wr={token:t==="sol"?null:he,amount:le,amountSmallestUnit:De,txSignature:`demo-tx-${Date.now()}`,sessionId:ie||`demo-session-${Date.now()}`,response:{sessionId:ie||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:De,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};O(wr),D("success"),d?.(wr);return}const qe=await E(De),gr={token:t==="sol"?null:he,amount:le,amountSmallestUnit:De,txSignature:qe.txSignature,sessionId:qe.sessionId,response:qe,method:"sign"};O(gr),D("success"),d?.(gr)}catch(De){const qe=De instanceof Error?De:new Error("Deposit failed");Y(qe.message),D("error"),l?.(qe)}},[E,Ne,$,t,w,ie,$s,Vs,m,d,l,x]),Aa=c.useCallback(()=>{D("waiting")},[]),Hs=c.useCallback(async()=>{const G=je||j.solanaPubkey;if(G){ce.current&&clearTimeout(ce.current);try{await navigator.clipboard.writeText(G),Be(!0),ce.current=setTimeout(()=>Be(!1),2e3)}catch{const se=document.createElement("textarea");se.value=G,document.body.appendChild(se),se.select(),document.execCommand("copy"),document.body.removeChild(se),Be(!0),ce.current=setTimeout(()=>Be(!1),2e3)}}},[je,j.solanaPubkey]);ru({step:q,sessionId:ie,demoMode:w,demoAutoConfirmMs:N,depositMethod:T,depositAddress:je,receiveAmountUsd:V,selectedToken:$,currencyMode:t,config:s,solanaPubkey:j.solanaPubkey,pollInterval:b,getStatus:p,onSuccess:d,setResult:O,setStep:D,setFlowError:Y});const ja=c.useCallback(()=>{D(W()),re(""),O(null),Y(null),x()},[W,x]);if(!s.enabled)return e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${f}`,children:e.jsx("p",{children:"Deposits are not currently available."})});const Na=V?(()=>{const G=Os(s,V);return G===0?"No fees":`Fees: $${Math.max(G,.01).toFixed(2)} total`})():"Fees: calculated after deposit";return e.jsxs("div",{className:`cedros-deposit-flow ${f}`,children:[g&&q!=="error"&&e.jsx(bu,{steps:pr,currentStepIndex:xa,currentStep:q}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[q==="explainer"&&e.jsx(nu,{siteName:k,config:S,depositConfig:s,currencyMode:t,token:$,tokens:L,onContinue:()=>D("unlock"),onCancel:h}),q==="unlock"&&e.jsx(ou,{token:$,tokens:L,currencyMode:t,depositMethod:T,isAuthorizing:zs,error:X,onAuthorize:ya,onBack:v?()=>D("explainer"):void 0,onCancel:h}),q==="confirm"&&T==="sign"&&e.jsx(hu,{token:$,tokens:P,quickActionSymbols:_,customTokenSymbols:C,currencyMode:t,minAmount:cs,maxAmount:ls,depositAddress:je||j.solanaPubkey,walletReady:$s||w,needsUnlock:Vs&&!w,copied:Me,isListening:!!ie&&!w,config:s,onCopy:Hs,onTokenSelect:fr,onUnlockRequired:m,onConfirm:(G,se)=>va(G,se),onBack:()=>D("unlock"),onCancel:h}),q==="signing"&&e.jsx(mu,{depositAddress:j.solanaPubkey}),q==="show-address"&&e.jsx(pu,{token:$,tokens:P,quickActionSymbols:_,customTokenSymbols:C,tokenPriceUsd:A,currencyMode:t,depositAddress:je||j.solanaPubkey,copied:Me,isListening:!!ie&&!w,config:s,onCopy:Hs,onTokenSelect:fr,onAmountChange:Ie,onSent:Aa,onBack:()=>D("unlock"),onCancel:h}),q==="waiting"&&e.jsx(fu,{token:$,depositAddress:je||j.solanaPubkey,copied:Me,feeLine:Na,onCopy:Hs}),q==="success"&&I&&e.jsx(gu,{result:I,config:s,onNewDeposit:ja}),q==="error"&&e.jsx(wu,{error:X||y||"An error occurred",onRetry:()=>D("confirm"),onCancel:h})]})]})}function ur(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),a=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),i=c.useCallback(()=>{n(null)},[]),d=c.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return await a.get("/credits/balance/sol")}catch(m){const u=M.handleApiError(m,"Failed to fetch credit balance");throw n(u.message),u}finally{r(!1)}},[a]),l=c.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{return(await a.get("/credits/balance")).balances}catch(m){const u=M.handleApiError(m,"Failed to fetch credit balances");throw n(u.message),u}finally{r(!1)}},[a]),h=c.useCallback(async m=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");r(!0),n(null);try{const u=new URLSearchParams;m?.currency&&u.set("currency",m.currency),m?.limit!==void 0&&u.set("limit",m.limit.toString()),m?.offset!==void 0&&u.set("offset",m.offset.toString());const f=u.toString(),g=f?`/credits/history?${f}`:"/credits/history";return await a.get(g)}catch(u){const f=M.handleApiError(u,"Failed to fetch transaction history");throw n(f.message),f}finally{r(!1)}},[a]);return{getBalance:d,getAllBalances:l,getHistory:h,isLoading:t,error:o,clearError:i}}function yu({showAllCurrencies:s=!1,refreshInterval:t=0,compact:r=!1,className:o="",onLoad:n}){const{getBalance:a,getAllBalances:i,isLoading:d,error:l,clearError:h}=ur(),[m,u]=c.useState([]),[f,g]=c.useState(null),b=c.useCallback(async()=>{try{if(s){const w=await i();u(w),n?.(w)}else{const w=await a();u([w]),n?.([w])}g(null)}catch(w){g(w instanceof Error?w.message:"Failed to load balance")}},[s,a,i,n]);if(c.useEffect(()=>{b()},[b]),c.useEffect(()=>{if(t<=0)return;const w=setInterval(b,t);return()=>clearInterval(w)},[t,b]),f||l)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${o}`,children:[e.jsx("p",{className:"cedros-credit-error",children:f||l}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{h(),g(null),b()},children:"Retry"})]});if(d&&m.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${o}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(r){const w=m[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${o}`,children:[w?e.jsx("span",{className:"cedros-credit-value",title:`${w.balanceLamports} lamports`,children:w.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),d&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${o}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:b,disabled:d,title:"Refresh balance",children:d?"...":"↻"})]}),m.length===0?e.jsxs("div",{className:"cedros-credit-empty",children:[e.jsx("p",{className:"cedros-credit-empty-message",children:"No credit balance yet."}),e.jsx("p",{className:"cedros-credit-empty-hint",children:"Make a deposit to get started."})]}):e.jsx("div",{className:"cedros-credit-list",children:m.map(w=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:w.currency}),e.jsx("span",{className:"cedros-credit-amount",children:w.display})]},w.currency))})]})}const _t=[{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 vu(s,t){const r=s<0,o=Math.abs(s),n=oa(t),a=o/Math.pow(10,n),i=r?"-":"+";return t.toUpperCase()==="SOL"?`${i}${a.toFixed(4)} SOL`:`${i}$${a.toFixed(2)}`}function Au(s){const t=new Date(s),r=new Date,o=r.getTime()-t.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0})}function ju(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function Nu(s,t){const r=(s||"").toLowerCase();return r==="deposit"?"↓":r==="spend"||r==="usage"||r==="charge"?"↑":r==="refund"?"←":r==="bonus"||r==="credit"?"★":t?"+":"−"}function ku({defaultTab:s="all",pageSize:t=10,refreshInterval:r=0,className:o="",onLoad:n,onTransactionClick:a}){const{getHistory:i,isLoading:d,error:l,clearError:h}=ur(),[m,u]=c.useState(s),[f,g]=c.useState([]),[b,w]=c.useState(0),[N,A]=c.useState(0),[v,k]=c.useState(null),S=_t.find(L=>L.key===m)||_t[0],E=c.useMemo(()=>S.txTypes===null?f:f.filter(L=>{const R=L.txType||"";return S.txTypes.some(T=>R.toLowerCase()===T.toLowerCase())}),[f,S.txTypes]),p=c.useCallback(async()=>{try{const L=await i({limit:t*3,offset:N});g(L.transactions),w(L.total),n?.(L),k(null)}catch(L){k(L instanceof Error?L.message:"Failed to load history")}},[t,N,i,n]);c.useEffect(()=>{A(0)},[m]),c.useEffect(()=>{p()},[p]),c.useEffect(()=>{if(r<=0)return;const L=setInterval(p,r);return()=>clearInterval(L)},[r,p]);const y=S.txTypes===null?b:E.length,x=Math.ceil(y/t),j=Math.floor(N/t)+1,_=L=>{const R=(L-1)*t;A(Math.max(0,Math.min(R,Math.max(0,y-t))))},C=L=>{u(L)};if(v||l)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${o}`,children:[e.jsx("p",{className:"cedros-tx-error",children:v||l}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{h(),k(null),p()},children:"Retry"})]});if(d&&f.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${o}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const P=L=>L.txTypes===null?f.length:f.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:p,disabled:d,title:"Refresh",children:d?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:_t.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,t).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:Nu(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:ju(L.txType)}),e.jsx("span",{className:`cedros-tx-amount ${R?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:vu(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:Au(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:()=>_(j-1),disabled:j<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",j," of ",x]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>_(j+1),disabled:j>=x,children:"Next"})]})]})]})}function hr(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),l=c.useCallback(()=>{n(null)},[]),h=c.useCallback(async()=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await d.get("/wallet/withdraw/balances")}catch(g){const b=M.handleApiError(g,"Failed to fetch wallet balances");throw n(b.message),b}},[d]),m=c.useCallback(async(g,b)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const w=await d.post("/wallet/withdraw/sol",{destination:g,amount_lamports:b});return i(w),w}catch(w){const N=M.handleApiError(w,"Failed to withdraw SOL");throw n(N.message),N}finally{r(!1)}},[d]),u=c.useCallback(async(g,b,w)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");r(!0),n(null);try{const N=await d.post("/wallet/withdraw/spl",{destination:g,token_mint:b,amount:w});return i(N),N}catch(N){const A=M.handleApiError(N,"Failed to withdraw token");throw n(A.message),A}finally{r(!1)}},[d]),f=c.useCallback(async(g=10,b=0)=>{if(!d)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const w=Math.max(1,Math.min(100,Math.trunc(g))),N=Math.max(0,Math.trunc(b)),A=new URLSearchParams({limit:String(w),offset:String(N)});return await d.get(`/wallet/withdraw/history?${A}`)}catch(w){const N=M.handleApiError(w,"Failed to fetch withdrawal history");throw n(N.message),N}},[d]);return{withdrawSol:m,withdrawSpl:u,getBalances:h,getHistory:f,isSubmitting:t,error:o,clearError:l,lastResult:a}}const Lt="So11111111111111111111111111111111111111112",Su={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Cu(s){return s.length<32||s.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(s)}function Pt(s){return s.length<=16?s:`${s.slice(0,6)}...${s.slice(-6)}`}function gs(s,t){return(Number(s)/Math.pow(10,t)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(t,6)})}function Eu({onSuccess:s,onError:t,onCancel:r,className:o=""}){const n=M.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:i,getBalances:d,isSubmitting:l,error:h,clearError:m}=hr(),[u,f]=c.useState("loading"),[g,b]=c.useState([]),[w,N]=c.useState(null),[A,v]=c.useState(""),[k,S]=c.useState(""),[E,p]=c.useState(null),[y,x]=c.useState(null),[j,_]=c.useState(null),C=n?.config.solana?.network??"mainnet-beta",P=c.useMemo(()=>{if(!E?.txSignature)return"";const D=`https://explorer.solana.com/tx/${E.txSignature}`;return C==="mainnet-beta"?D:`${D}?cluster=${encodeURIComponent(C)}`},[E,C]),L=c.useMemo(()=>{if(!w||!k)return"0";const D=parseFloat(k);return isNaN(D)||D<=0?"0":Math.floor(D*Math.pow(10,w.decimals)).toString()},[k,w]);c.useEffect(()=>{if(!n)return;let D=!1;return(async()=>{try{const $=await d();if(D)return;const Q=[];$.solLamports>0&&Q.push({symbol:"SOL",mint:Lt,decimals:9,rawBalance:String($.solLamports),displayBalance:gs(String($.solLamports),9)});for(const H of $.tokens){const re=Su[H.mint]??Pt(H.mint);Q.push({symbol:re,mint:H.mint,decimals:H.decimals,rawBalance:H.amount,displayBalance:gs(H.amount,H.decimals)})}b(Q),f((Q.length>0,"select"))}catch{D||(_("Failed to load wallet balances"),f("select"))}})(),()=>{D=!0}},[n,d]);const R=c.useCallback(D=>{N(D),f("form"),m(),x(null),S("")},[m]),T=c.useCallback(()=>{if(!w)return;const D=Number(w.rawBalance)/Math.pow(10,w.decimals);w.mint===Lt?S(String(Math.max(0,D-.01))):S(String(D))},[w]),B=c.useCallback(()=>{if(x(null),!A.trim()){x("Destination address is required");return}if(!Cu(A.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}f("confirm")},[A,k,L]),F=c.useCallback(async()=>{if(w){f("processing"),m();try{let D;w.mint===Lt?D=await a(A.trim(),Number(L)):D=await i(A.trim(),w.mint,L),p(D),f("success"),s?.(D)}catch(D){f("confirm"),t?.(D instanceof Error?D:new Error(String(D)))}}},[w,A,L,a,i,m,s,t]),W=c.useCallback(()=>{m(),x(null),u==="form"?(f("select"),N(null),S(""),v("")):u==="confirm"&&f("form")},[u,m]),q=c.useCallback(()=>{f("select"),N(null),v(""),S(""),p(null),m(),x(null)},[m]);return n?e.jsxs("div",{className:`cedros-withdrawal ${o}`,children:[u==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(z.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),u==="select"&&e.jsxs("div",{className:"cedros-withdrawal-select",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdraw"}),e.jsx("p",{className:"cedros-withdrawal-subtitle",children:"Select a token to withdraw"})]}),j&&e.jsx(Z.ErrorMessage,{error:j}),g.length===0&&!j&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:g.map(D=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>R(D),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:D.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:D.displayBalance})]},D.mint))}),r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:r,children:"Cancel"})]}),u==="form"&&w&&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 ",w.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",w.displayBalance," ",w.symbol]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsx("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-destination",children:"Destination Address"}),e.jsx("input",{id:"cedros-withdrawal-destination",type:"text",className:"cedros-input",placeholder:"Solana address (base58)",value:A,onChange:D=>v(D.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 (",w.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:D=>S(D.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(Z.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"&&w&&e.jsxs("div",{className:"cedros-withdrawal-confirm",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:W,disabled:l,children:"Back"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Confirm Withdrawal"})]}),e.jsxs("div",{className:"cedros-withdrawal-summary",children:[e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Token"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:w.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:[gs(L,w.decimals)," ",w.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Destination"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",title:A,children:Pt(A)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),h&&e.jsx(Z.ErrorMessage,{error:h}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:W,disabled:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:F,disabled:l,children:l?"Sending...":"Confirm & Send"})]})]}),u==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(z.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",w?.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:[gs(L,w?.decimals??9)," ",w?.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:Pt(E.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:q,children:"Done"})]})]}):null}function _u(s,t){if(s==="sol")return"SOL";if(!t)return"SPL";const r=Ws.find(o=>o.mint===t);return r?r.symbol:`${t.slice(0,4)}...${t.slice(-4)}`}function Lu(s,t){const r=Number(s);if(Number.isNaN(r))return s;const o=oa(t),n=r/Math.pow(10,o);return t==="SOL"?`${n.toFixed(4)} SOL`:`${n.toFixed(2)} ${t}`}function Pu(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function Ru(s){const t=new Date(s),r=new Date,o=r.getTime()-t.getTime();if(o<0)return"Just now";const n=Math.floor(o/(1e3*60*60*24));if(n===0){const a=Math.floor(o/36e5);if(a===0){const i=Math.floor(o/6e4);return i<1?"Just now":`${i}m ago`}return`${a}h ago`}return n===1?"Yesterday":n<7?`${n}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==r.getFullYear()?"numeric":void 0})}function Tu({pageSize:s=10,className:t="",onTransactionClick:r,explorerUrl:o="https://solscan.io"}){const n=o.startsWith("https://")?o:"https://solscan.io",{getHistory:a,error:i,clearError:d}=hr(),[l,h]=c.useState([]),[m,u]=c.useState(0),[f,g]=c.useState(0),[b,w]=c.useState(!1),[N,A]=c.useState(null),v=c.useCallback(async()=>{w(!0);try{const p=await a(s,f);h(p.items),u(p.total),A(null)}catch(p){A(p instanceof Error?p.message:"Failed to load withdrawal history")}finally{w(!1)}},[s,f,a]);c.useEffect(()=>{v()},[v]);const k=Math.ceil(m/s),S=Math.floor(f/s)+1,E=p=>{const y=(p-1)*s;g(Math.max(0,Math.min(y,Math.max(0,m-s))))};return N||i?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${t}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:N||i}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{d(),A(null),v()},children:"Retry"})]}):b&&l.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${t}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${t}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:v,disabled:b,title:"Refresh",children:b?"...":"↻"})]}),l.length===0?e.jsx("div",{className:"cedros-tx-empty",children:e.jsx("p",{className:"cedros-tx-empty-message",children:"No withdrawal history yet."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:l.map(p=>{const y=_u(p.tokenType,p.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>r?.(p),onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),r?.(p))},role:r?"button":void 0,tabIndex:r?0:void 0,children:[e.jsx("div",{className:"cedros-tx-icon cedros-tx-icon-negative",children:"↑"}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsxs("span",{className:"cedros-tx-type",children:[y," Withdrawal"]}),e.jsx("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:Lu(p.amount,y)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${n}/account/${p.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:Pu(p.destination)})," · ",e.jsx("a",{href:`${n}/tx/${p.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:x=>x.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:Ru(p.createdAt)})]})]})]},p.id)})}),k>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>E(S-1),disabled:S<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",S," of ",k]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>E(S+1),disabled:S>=k,children:"Next"})]})]})]})}function Mu({brandLogo:s,brandName:t,title:r="Welcome back",subtitle:o="Login with your Apple or Google account",termsText:n,onSuccess:a,defaultTab:i="login",children:d,className:l=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${l}`,children:[(s||t)&&e.jsxs("div",{className:"cedros-brand-header",children:[s,t&&e.jsx("span",{className:"cedros-brand-name",children:t})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:r}),o&&e.jsx("p",{className:"cedros-full-page-subtitle",children:o})]}),d??e.jsx(Fs,{defaultTab:i,onSuccess:a})]}),n&&e.jsx("p",{className:"cedros-terms-footer",children:n})]})}function Bu({brandName:s="Your Brand",brandLogo:t,tagline:r="Your tagline goes here. Make it compelling.",title:o="Sign in",subtitle:n="Enter your credentials to access your account",onSuccess:a,defaultTab:i="login",children:d,className:l=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${l}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[t??e.jsx("div",{className:"cedros-split-page-logo",children:s.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:s}),r&&e.jsx("p",{className:"cedros-split-page-tagline",children:r})]})}),e.jsx("div",{className:"cedros-split-page-form",children:e.jsxs("div",{className:"cedros-split-page-form-content",children:[e.jsx("h2",{className:"cedros-split-page-title",children:o}),n&&e.jsx("p",{className:"cedros-split-page-subtitle",children:n}),d??e.jsx(Fs,{defaultTab:i,onSuccess:a})]})})]})}function Iu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),n=c.useMemo(()=>new Vt.OrgApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),a=c.useCallback(async l=>{o(h=>({...h,isLoading:!0,error:null}));try{const h=await n.authorize(l),m={allowed:h.allowed,reason:h.reason,isLoading:!1,error:null};return o(m),m}catch(h){const m={allowed:!1,reason:void 0,isLoading:!1,error:h};return o(m),m}},[n]),i=c.useCallback(async l=>(await a(l)).allowed,[a]),d=c.useCallback(()=>{o({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:i,lastCheck:r,clearCheck:d,checkAuthorization:a}}function Du(){const{listAllWallets:s,createDerivedWallet:t,deleteDerivedWallet:r}=U.useWalletMaterial(),[o,n]=c.useState([]),[a,i]=c.useState(!1),[d,l]=c.useState(null),h=c.useCallback(async()=>{i(!0),l(null);try{const g=await s();n(g.wallets)}catch(g){const b=g instanceof Error?g.message:"Failed to list wallets";l(b)}finally{i(!1)}},[s]),m=c.useCallback(async g=>{i(!0),l(null);try{const b=await t({label:g});return await h(),b}catch(b){const w=b instanceof Error?b.message:"Failed to create wallet";throw l(w),b}finally{i(!1)}},[t,h]),u=c.useCallback(async g=>{i(!0),l(null);try{await r(g),await h()}catch(b){const w=b instanceof Error?b.message:"Failed to delete wallet";throw l(w),b}finally{i(!1)}},[r,h]),f=c.useCallback(()=>l(null),[]);return{wallets:o,isLoading:a,createWallet:m,deleteWallet:u,refresh:h,error:d,clearError:f}}function Uu(){const s=M.useCedrosLoginOptional(),[t,r]=c.useState(!1),[o,n]=c.useState(null),[a,i]=c.useState(null),d=c.useMemo(()=>s?new M.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),l=c.useCallback(async()=>{if(!d)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const u=await d.get("/wallet/pending-recovery");i(u)}catch(u){const f=M.handleApiError(u,"Failed to fetch pending recovery");throw n(f.message),f}finally{r(!1)}},[d]),h=c.useCallback(async()=>{if(!d)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");r(!0),n(null);try{const u={confirmed:!0};await d.post("/wallet/acknowledge-recovery",u),i(null)}catch(u){const f=M.handleApiError(u,"Failed to acknowledge recovery");throw n(f.message),f}finally{r(!1)}},[d]),m=c.useCallback(()=>n(null),[]);return c.useEffect(()=>{d&&s?.authState==="authenticated"&&l().catch(()=>{})},[d,s?.authState,l]),{hasPendingRecovery:a?.hasPendingRecovery??!1,recoveryType:a?.recoveryType??null,recoveryPhrase:a?.recoveryPhrase??null,expiresAt:a?.expiresAt?new Date(a.expiresAt):null,fetchPendingRecovery:l,acknowledgeRecovery:h,isLoading:t,error:o,clearError:m}}function Fu(s={}){const{onExternalSign:t}=s,{solanaPubkey:r,hasExternalWallet:o,status:n,isUnlocked:a}=U.useWallet(),{signTransaction:i,isSigning:d,error:l,clearError:h}=Co(),m=c.useMemo(()=>o&&t?"external":n==="enrolled_locked"||n==="enrolled_unlocked"?"sss":"none",[o,t,n]),u=m!=="none",f=n==="enrolled_locked"||n==="enrolled_unlocked";return{signTransaction:c.useCallback(async(b,w)=>{if(m==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(b)}if(m==="sss"){if(!w&&!a)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return w?i(b,w):i(b)}throw new Error("No signing method available. Enroll a wallet first.")},[m,t,a,i]),signingMethod:m,canSign:u,isSigning:d,publicKey:r,hasExternalWallet:o,hasSssWallet:f,isSssUnlocked:a,error:l,clearError:h}}function Wu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(null),[n,a]=c.useState(!1),[i,d]=c.useState(null),l=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),h=c.useCallback(async()=>{a(!0),d(null);try{await l.post("/welcome-completed",{})}catch(u){const f=u instanceof Error?u:new Error(String(u));throw d(f),f}finally{a(!1)}},[l]),m=c.useCallback(()=>{o(null)},[]);return{postLoginAction:r,setPostLoginAction:o,markWelcomeCompleted:h,clearPostLogin:m,isLoading:n,error:i}}function Ou(){const{config:s}=M.useCedrosLogin(),t=s.theme??"auto",r=U.useThemeManager({theme:t,themeOverrides:s.themeOverrides});return{mode:t,isDark:r.className==="cedros-dark",className:r.className,style:r.style,unstyled:s.unstyled??!1,overrides:s.themeOverrides}}function pa(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState([]),[l,h]=c.useState(0),m=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),u=c.useCallback(async()=>{o(!0),a(null);try{const g=await m.post("/access-codes/generate",{},{credentials:"include"});return d(b=>[g,...b]),h(b=>b+1),g}catch(g){const b=g instanceof Error?g:new Error(String(g));throw a(b),b}finally{o(!1)}},[m]),f=c.useCallback(async()=>{o(!0),a(null);try{const g=await m.get("/access-codes/mine",{credentials:"include"});d(g.items),h(g.total)}catch(g){const b=g instanceof Error?g:new Error(String(g));throw a(b),b}finally{o(!1)}},[m]);return{codes:i,total:l,generateCode:u,fetchCodes:f,isLoading:r,error:n}}function qu(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState(null),[m,u]=c.useState(null),[f,g]=c.useState(null),b=f!==null&&f!=="none",w=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),N=c.useCallback(async()=>{o(!0),a(null);try{const v=await w.get("/kyc/status",{credentials:"include"});return d(v.status),h(v.verifiedAt??null),u(v.expiresAt??null),g(v.enforcementMode),v}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[w]),A=c.useCallback(async()=>{o(!0),a(null);try{const v=await w.post("/kyc/start",void 0,{credentials:"include"});return d("pending"),v.redirectUrl}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[w]);return{status:i,verifiedAt:l,expiresAt:m,isRequired:b,enforcementMode:f,fetchStatus:N,startVerification:A,isLoading:r,error:n}}function fa(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState([]),[m,u]=c.useState(0),f=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),g=c.useCallback(async()=>{o(!0),a(null);try{const N=await f.get("/referral/rewards",{credentials:"include"});return d(N),N}catch(N){const A=N instanceof Error?N:new Error(String(N));throw a(A),A}finally{o(!1)}},[f]),b=c.useCallback(async(N=10,A=0)=>{o(!0),a(null);try{const v=await f.get(`/referral/rewards/history?limit=${N}&offset=${A}`,{credentials:"include"});return h(v.items),u(v.total),v}catch(v){const k=v instanceof Error?v:new Error(String(v));throw a(k),k}finally{o(!1)}},[f]),w=c.useCallback(async N=>{o(!0),a(null);try{await f.post("/referral/payout-wallet",{walletAddress:N},{credentials:"include"}),d(A=>A&&{...A,payoutWalletAddress:N})}catch(A){const v=A instanceof Error?A:new Error(String(A));throw a(v),v}finally{o(!1)}},[f]);return{rewards:i,history:l,historyTotal:m,fetchRewards:g,fetchHistory:b,setPayoutWallet:w,isLoading:r,error:n}}function Rt(s,t){return t==="SOL"?(s/1e9).toFixed(4)+" SOL":"$"+(s/1e6).toFixed(2)}function zu(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}const $u=/^[1-9A-HJ-NP-Za-km-z]{32,44}$/;function Vu(s){return $u.test(s)}function Hu(s){switch(s){case"signup":return"Sign-up";case"spend":return"Spend";case"first_spend":return"First Spend";default:return s}}function Gu({status:s}){const r={pending:"cedros-rewards-panel__badge--pending",completed:"cedros-rewards-panel__badge--completed",failed:"cedros-rewards-panel__badge--failed",credited:"cedros-rewards-panel__badge--credited"}[s]??"cedros-rewards-panel__badge--pending";return e.jsx("span",{className:`cedros-rewards-panel__badge ${r}`,children:s.charAt(0).toUpperCase()+s.slice(1)})}const ws=10;function Qu({explorerUrl:s="https://explorer.solana.com",className:t}){const{rewards:r,history:o,historyTotal:n,fetchRewards:a,fetchHistory:i,setPayoutWallet:d,isLoading:l,error:h}=fa(),[m,u]=c.useState(0),[f,g]=c.useState(""),[b,w]=c.useState(null),[N,A]=c.useState(!1),[v,k]=c.useState(!1);c.useEffect(()=>{a().catch(()=>{}),i(ws,0).catch(()=>{})},[a,i]),c.useEffect(()=>{r?.payoutWalletAddress!=null&&g(r.payoutWalletAddress)},[r?.payoutWalletAddress]);const S=c.useCallback(x=>{u(x),i(ws,x*ws).catch(()=>{})},[i]),E=Math.ceil(n/ws),p=c.useCallback(async()=>{const x=f.trim();if(x!==""&&!Vu(x)){w("Invalid address. Must be a base58 string between 32 and 44 characters.");return}w(null),A(!0),k(!1);try{await d(x===""?null:x),k(!0)}catch(j){w(j instanceof Error?j.message:"Failed to save wallet address.")}finally{A(!1)}},[f,d]),y=r?.rewardType==="direct_payout"?"Direct Payout":"Credits";return e.jsxs("div",{className:`cedros-rewards-panel ${t??""}`.trim(),"aria-label":"Rewards dashboard",children:[h&&e.jsx("div",{className:"cedros-rewards-panel__error",role:"alert",children:h.message}),e.jsxs("section",{className:"cedros-rewards-panel__summary","aria-label":"Rewards summary",children:[e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Total Earned"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?Rt(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?`${Rt(r.pendingAmount,r.currency)} (${r.pendingCount})`:"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Referrals"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:r?String(r.referralCount):"—"})]}),e.jsxs("div",{className:"cedros-rewards-panel__card",children:[e.jsx("span",{className:"cedros-rewards-panel__card-label",children:"Reward Type"}),e.jsx("span",{className:"cedros-rewards-panel__card-value",children:e.jsx("span",{className:"cedros-rewards-panel__type-badge",children:y})})]})]}),r?.rewardType==="direct_payout"&&e.jsxs("section",{className:"cedros-rewards-panel__wallet-section","aria-label":"Payout wallet",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"Payout Wallet"}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-current",children:[e.jsx("span",{className:"cedros-rewards-panel__wallet-label",children:"Current address:"}),e.jsx("span",{className:"cedros-rewards-panel__wallet-address",children:r.payoutWalletAddress??"Not set"})]}),e.jsxs("div",{className:"cedros-rewards-panel__wallet-form",children:[e.jsx("label",{htmlFor:"cedros-payout-wallet-input",className:"cedros-rewards-panel__wallet-input-label",children:"Wallet address"}),e.jsx("input",{id:"cedros-payout-wallet-input",type:"text",className:"cedros-rewards-panel__wallet-input",value:f,onChange:x=>{g(x.target.value),w(null),k(!1)},placeholder:"Base58 Solana address","aria-describedby":b?"cedros-wallet-error":void 0,disabled:N}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__wallet-save-btn",onClick:p,disabled:N||l,children:N?"Saving...":"Save"})]}),b&&e.jsx("div",{id:"cedros-wallet-error",className:"cedros-rewards-panel__wallet-error",role:"alert",children:b}),v&&!b&&e.jsx("div",{className:"cedros-rewards-panel__wallet-success",role:"status",children:"Wallet address saved."})]}),e.jsxs("section",{className:"cedros-rewards-panel__history-section","aria-label":"Reward history",children:[e.jsx("h3",{className:"cedros-rewards-panel__section-title",children:"History"}),l&&o.length===0?e.jsx("div",{className:"cedros-rewards-panel__loading","aria-busy":"true",children:"Loading..."}):o.length===0?e.jsx("div",{className:"cedros-rewards-panel__empty",children:"No rewards yet."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-rewards-panel__table-wrapper",role:"region","aria-label":"Reward history table",tabIndex:0,children:e.jsxs("table",{className:"cedros-rewards-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Date"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Type"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Amount"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Status"}),e.jsx("th",{scope:"col",className:"cedros-rewards-panel__th",children:"Transaction"})]})}),e.jsx("tbody",{children:o.map(x=>e.jsxs("tr",{className:"cedros-rewards-panel__tr",children:[e.jsx("td",{className:"cedros-rewards-panel__td",children:zu(x.createdAt)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:Hu(x.triggerType)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:Rt(x.amount,x.currency)}),e.jsx("td",{className:"cedros-rewards-panel__td",children:e.jsx(Gu,{status:x.status})}),e.jsx("td",{className:"cedros-rewards-panel__td",children:x.txSignature?e.jsxs("a",{href:`${s}/tx/${x.txSignature}`,target:"_blank",rel:"noopener noreferrer",className:"cedros-rewards-panel__tx-link","aria-label":`View transaction ${x.txSignature.slice(0,8)}... on Solana explorer`,children:[x.txSignature.slice(0,8),"..."]}):e.jsx("span",{className:"cedros-rewards-panel__tx-none",children:"—"})})]},x.id))})]})}),E>1&&e.jsxs("div",{className:"cedros-rewards-panel__pagination",role:"navigation","aria-label":"History pagination",children:[e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m-1),disabled:m===0||l,"aria-label":"Previous page",children:"Previous"}),e.jsxs("span",{className:"cedros-rewards-panel__page-info",children:[m+1," / ",E]}),e.jsx("button",{type:"button",className:"cedros-rewards-panel__page-btn",onClick:()=>S(m+1),disabled:m>=E-1||l,"aria-label":"Next page",children:"Next"})]})]})]})]})}function kn(s){try{return new Date(s).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return s}}function Sn(s){return s.expiresAt&&new Date(s.expiresAt)<new Date?"expired":s.maxUses!==null&&s.currentUses>=s.maxUses?"used":"active"}function Ku({status:s}){const t={active:"cedros-invite-panel__badge--active",used:"cedros-invite-panel__badge--used",expired:"cedros-invite-panel__badge--expired"};return e.jsx("span",{className:`cedros-invite-panel__badge ${t[s]??""}`,children:s.charAt(0).toUpperCase()+s.slice(1)})}function Yu({text:s}){const[t,r]=c.useState(!1),o=c.useCallback(async()=>{try{await navigator.clipboard.writeText(s),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},[s]);return e.jsx("button",{type:"button",className:"cedros-invite-panel__copy-btn",onClick:o,"aria-label":t?"Copied":`Copy code ${s}`,title:t?"Copied!":"Copy to clipboard",children:t?"✓":"Copy"})}function Zu({className:s}){const{codes:t,total:r,generateCode:o,fetchCodes:n,isLoading:a,error:i}=pa(),[d,l]=c.useState(!1),[h,m]=c.useState(null);c.useEffect(()=>{n().catch(()=>{})},[n]);const u=c.useCallback(async()=>{l(!0),m(null);try{await o()}catch(g){m(g instanceof Error?g.message:"Failed to generate invite code.")}finally{l(!1)}},[o]),f=t.filter(g=>Sn(g)==="active").length;return e.jsxs("div",{className:`cedros-invite-panel ${s??""}`.trim(),"aria-label":"Invite code panel",children:[e.jsxs("div",{className:"cedros-invite-panel__header",children:[e.jsx("h2",{className:"cedros-invite-panel__title",children:"Invite Codes"}),e.jsxs("span",{className:"cedros-invite-panel__budget","aria-live":"polite",children:[f," active · ",r," total"]})]}),i&&e.jsx("div",{className:"cedros-invite-panel__error",role:"alert",children:i.message}),h&&e.jsx("div",{className:"cedros-invite-panel__error",role:"alert",children:h}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:u,disabled:d||a,"aria-busy":d,children:d?"Generating...":"Generate Invite Code"}),e.jsx("section",{className:"cedros-invite-panel__list-section","aria-label":"Your invite codes",children:a&&t.length===0?e.jsx("div",{className:"cedros-invite-panel__loading","aria-busy":"true",children:"Loading..."}):t.length===0?e.jsx("div",{className:"cedros-invite-panel__empty",children:"No invite codes yet. Generate one above."}):e.jsx("div",{className:"cedros-invite-panel__table-wrapper",role:"region","aria-label":"Invite codes table",tabIndex:0,children:e.jsxs("table",{className:"cedros-invite-panel__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Code"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Uses"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Created"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Expires"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:"Status"}),e.jsx("th",{scope:"col",className:"cedros-invite-panel__th",children:e.jsx("span",{className:"cedros-sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:t.map(g=>{const b=Sn(g),w=g.maxUses!==null?`${g.currentUses} / ${g.maxUses}`:`${g.currentUses}`;return e.jsxs("tr",{className:"cedros-invite-panel__tr",children:[e.jsx("td",{className:"cedros-invite-panel__td cedros-invite-panel__td--code",children:e.jsx("code",{className:"cedros-invite-panel__code",children:g.code})}),e.jsx("td",{className:"cedros-invite-panel__td",children:w}),e.jsx("td",{className:"cedros-invite-panel__td",children:kn(g.createdAt)}),e.jsx("td",{className:"cedros-invite-panel__td",children:g.expiresAt?kn(g.expiresAt):"—"}),e.jsx("td",{className:"cedros-invite-panel__td",children:e.jsx(Ku,{status:b})}),e.jsx("td",{className:"cedros-invite-panel__td",children:e.jsx(Yu,{text:g.code})})]},g.id)})})]})})})]})}function Xu({status:s,startVerification:t,className:r}){const[o,n]=c.useState(!1),[a,i]=c.useState(null),d=c.useCallback(async()=>{n(!0),i(null);try{const m=await t();m&&(window.location.href=m)}catch(m){i(m instanceof Error?m.message:"Failed to start verification")}finally{n(!1)}},[t]);if(s==="verified")return null;let l;switch(s){case"pending":l="Your identity verification is being processed.";break;case"failed":l="Identity verification failed. Please try again.";break;case"expired":l="Your identity verification has expired. Please verify again.";break;case"canceled":l="Verification was canceled. Please try again.";break;default:l="Identity verification is required to continue.";break}const h=s!=="pending";return e.jsxs("div",{className:`cedros-kyc-banner ${r??""}`,role:"alert",children:[e.jsxs("div",{className:"cedros-kyc-banner-content",children:[e.jsx("span",{className:"cedros-kyc-banner-message",children:l}),h&&e.jsx("button",{type:"button",className:"cedros-kyc-banner-button",onClick:d,disabled:o,children:o?"Starting...":"Verify Identity"})]}),a&&e.jsx("div",{className:"cedros-kyc-banner-error",children:a})]})}const Ju=3e3,eh=6e4;function sh(s){switch(s){case"verified":return"Identity verified successfully!";case"failed":return"Verification failed. You can try again.";case"expired":return"Your identity verification has expired.";case"canceled":return"Verification was canceled.";default:return"Verification was canceled."}}function th({fetchStatus:s,onComplete:t,className:r}){const[o,n]=c.useState(null),[a,i]=c.useState(!1),d=c.useRef(t);d.current=t;const l=c.useRef(s);l.current=s,c.useEffect(()=>{let m=!1,u=null;const f=setTimeout(()=>{i(!0),u!==null&&clearInterval(u)},eh),g=async()=>{try{const b=await l.current();if(m)return;n(b.status),b.status!=="pending"&&(clearTimeout(f),u!==null&&clearInterval(u),d.current?.(b.status))}catch{}};return g(),u=setInterval(g,Ju),()=>{m=!0,clearTimeout(f),u!==null&&clearInterval(u)}},[]);const h=!o||o==="pending";return e.jsx("div",{className:`cedros-kyc-callback ${r??""}`,role:"status","aria-live":"polite",children:a&&h?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:"cedros-kyc-callback-message",children:"Verification is taking longer than expected. Please refresh or check back later."}),t&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>t("pending"),children:"Continue"})]}):h?e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("span",{className:"cedros-kyc-callback-spinner","aria-hidden":"true"}),e.jsx("p",{className:"cedros-kyc-callback-message",children:"Processing your verification..."})]}):e.jsxs("div",{className:"cedros-kyc-callback-content",children:[e.jsx("p",{className:`cedros-kyc-callback-message cedros-kyc-callback-message--${o}`,children:sh(o)}),t&&e.jsx("button",{type:"button",className:"cedros-kyc-callback-continue",onClick:()=>t(o),children:"Continue"})]})})}function ga(){const{config:s,_internal:t}=M.useCedrosLogin(),[r,o]=c.useState(!1),[n,a]=c.useState(null),[i,d]=c.useState(null),[l,h]=c.useState(null),[m,u]=c.useState(null),[f,g]=c.useState(null),b=f!==null&&f!=="none",w=c.useMemo(()=>new M.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),N=c.useCallback(async()=>{o(!0),a(null);try{const S=await w.get("/accreditation/status",{credentials:"include"});return d(S.status),h(S.verifiedAt??null),u(S.expiresAt??null),g(S.enforcementMode),S}catch(S){const E=S instanceof Error?S:new Error(String(S));throw a(E),E}finally{o(!1)}},[w]),A=c.useCallback(async(S,E)=>{o(!0),a(null);try{const p=await w.post("/accreditation/submit",{method:S,...E},{credentials:"include"});return d("pending"),p}catch(p){const y=p instanceof Error?p:new Error(String(p));throw a(y),y}finally{o(!1)}},[w]),v=c.useCallback(async(S,E,p)=>{o(!0),a(null);try{const y=new FormData;y.append("submissionId",S),y.append("documentType",p),y.append("file",E);const x=t?.getAccessToken?.(),j={};x&&(j.Authorization=`Bearer ${x}`);const _=await fetch(`${s.serverUrl}/accreditation/upload`,{method:"POST",headers:j,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)}},[s.serverUrl,t]),k=c.useCallback(async()=>{o(!0),a(null);try{return(await w.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)}},[w]);return{status:i,verifiedAt:l,expiresAt:m,isRequired:b,enforcementMode:f,fetchStatus:N,submitVerification:A,uploadDocument:v,listSubmissions:k,isLoading:r,error:n}}const Cn=[{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 bs({label:s,acceptedTypes:t=".pdf,.jpg,.jpeg,.png,.tiff",documentType:r,files:o,onFilesChange:n,maxFiles:a=5}){const i=c.useRef(null),[d,l]=c.useState(!1),h=c.useCallback(u=>{if(!u)return;const f=Array.from(u),g=[...o,...f].slice(0,a);n(g)},[o,a,n]),m=u=>{n(o.filter((f,g)=>g!==u))};return e.jsxs("div",{className:"cedros-accreditation-wizard__upload-zone",children:[e.jsx("p",{className:"cedros-accreditation-wizard__upload-label",children:s}),e.jsxs("div",{className:`cedros-accreditation-wizard__drop-area${d?" cedros-accreditation-wizard__drop-area--active":""}`,role:"button",tabIndex:0,"aria-label":`Upload files: ${s}`,onClick:()=>i.current?.click(),onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&i.current?.click()},onDragOver:u=>{u.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:u=>{u.preventDefault(),l(!1),h(u.dataTransfer.files)},children:[e.jsx("span",{children:"Click or drag files here"}),e.jsx("span",{className:"cedros-accreditation-wizard__upload-hint",children:t})]}),e.jsx("input",{ref:i,type:"file",accept:t,multiple:a>1,style:{display:"none"},onChange:u=>h(u.target.files),"aria-hidden":"true"}),o.length>0&&e.jsx("ul",{className:"cedros-accreditation-wizard__file-list","aria-label":"Uploaded files",children:o.map((u,f)=>e.jsxs("li",{className:"cedros-accreditation-wizard__file-item",children:[e.jsx("span",{children:u.name}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__file-remove",onClick:()=>m(f),"aria-label":`Remove ${u.name}`,children:"Remove"})]},`${u.name}-${f}`))})]})}function rh(s,t,r,o){t({...s,[r]:o})}function xs(s,t){return s.filter(r=>r.documentType===t).map(r=>r.file)}function ys(s,t,r,o){const n=s.filter(a=>a.documentType!==t);o([...n,...r.map(a=>({file:a,documentType:t}))])}function nh({method:s,formData:t,onFormDataChange:r,fileEntries:o,onFileEntriesChange:n}){const a=(i,d)=>rh(t,r,i,d);return s==="income"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Income Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Income type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"individual",checked:t.incomeType==="individual",onChange:()=>a("incomeType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"incomeType",value:"joint",checked:t.incomeType==="joint",onChange:()=>a("incomeType","joint")})," ","Joint with spouse ($300K+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"statedAmount",children:"Stated annual income (USD)"}),e.jsx("input",{id:"statedAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"userStatement",children:"Statement about current year income expectation"}),e.jsx("textarea",{id:"userStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx(bs,{label:"Upload tax documents (W-2, 1040, 1099, K-1) from the last 2 years",documentType:"tax_return",files:xs(o,"tax_return"),onFilesChange:i=>ys(o,"tax_return",i,n)})]}):s==="net_worth"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Net Worth Details"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"netWorthAmount",children:"Stated net worth (USD, excluding primary residence)"}),e.jsx("input",{id:"netWorthAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.statedAmountUsd??"",onChange:i=>a("statedAmountUsd",i.target.valueAsNumber)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Documents must be dated within the last 90 days."}),e.jsx(bs,{label:"Upload asset documents (bank/brokerage statements, property appraisals)",documentType:"asset_statement",files:xs(o,"asset_statement"),onFilesChange:i=>ys(o,"asset_statement",i,n)}),e.jsx(bs,{label:"Upload liability documents (credit report)",documentType:"liability_statement",files:xs(o,"liability_statement"),onFilesChange:i=>ys(o,"liability_statement",i,n)})]}):s==="credential"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Professional Credential"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"crdNumber",children:"FINRA CRD Number"}),e.jsx("input",{id:"crdNumber",type:"text",className:"cedros-accreditation-wizard__input",value:t.crdNumber??"",onChange:i=>a("crdNumber",i.target.value)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"licenseType",children:"License type"}),e.jsxs("select",{id:"licenseType",className:"cedros-accreditation-wizard__select",value:t.licenseType??"",onChange:i=>a("licenseType",i.target.value),children:[e.jsx("option",{value:"",children:"Select a license"}),e.jsx("option",{value:"series_7",children:"Series 7"}),e.jsx("option",{value:"series_65",children:"Series 65"}),e.jsx("option",{value:"series_82",children:"Series 82"})]})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Your license will be verified via FINRA BrokerCheck."})]}):s==="third_party_letter"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Third-Party Letter"}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Letter must be dated within the last 90 days."}),e.jsx(bs,{label:"Upload verification letter from a CPA, attorney, RIA, or broker-dealer",documentType:"letter",files:xs(o,"letter"),onFilesChange:i=>ys(o,"letter",i,n),maxFiles:1})]}):s==="insider"?e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Insider / Officer"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"insiderStatement",children:"Describe your role as director, executive officer, or general partner"}),e.jsx("textarea",{id:"insiderStatement",className:"cedros-accreditation-wizard__textarea",rows:4,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"An administrator will verify your status."})]}):e.jsxs("fieldset",{className:"cedros-accreditation-wizard__fieldset",children:[e.jsx("legend",{className:"cedros-accreditation-wizard__fieldset-legend",children:"Investment Threshold"}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",children:"Entity type"}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"individual",checked:t.entityType==="individual",onChange:()=>a("entityType","individual")})," ","Individual ($200K+)"]}),e.jsxs("label",{className:"cedros-accreditation-wizard__radio-label",children:[e.jsx("input",{type:"radio",name:"entityType",value:"entity",checked:t.entityType==="entity",onChange:()=>a("entityType","entity")})," ","Entity ($1M+)"]})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentAmount",children:"Investment commitment amount (USD)"}),e.jsx("input",{id:"commitmentAmount",type:"number",min:0,className:"cedros-accreditation-wizard__input",value:t.investmentCommitmentUsd??"",onChange:i=>a("investmentCommitmentUsd",i.target.valueAsNumber)})]}),e.jsxs("div",{className:"cedros-accreditation-wizard__field",children:[e.jsx("label",{className:"cedros-accreditation-wizard__label",htmlFor:"commitmentStatement",children:"Written representation of commitment"}),e.jsx("textarea",{id:"commitmentStatement",className:"cedros-accreditation-wizard__textarea",rows:3,value:t.userStatement??"",onChange:i=>a("userStatement",i.target.value)})]}),e.jsx("p",{className:"cedros-accreditation-wizard__note",children:"Per 2025 SEC guidance, a minimum investment commitment serves as evidence of accredited status."})]})}function oh({onComplete:s,onCancel:t,className:r}){const{submitVerification:o,uploadDocument:n,isLoading:a,error:i}=ga(),[d,l]=c.useState(1),[h,m]=c.useState(null),[u,f]=c.useState({}),[g,b]=c.useState([]),[w,N]=c.useState(!1),[A,v]=c.useState(null),k=y=>{m(y),l(2)},S=()=>{d===2?l(1):d===3?l(2):t?.()},E=c.useCallback(async()=>{if(h){v(null);try{const{submissionId:y}=await o(h,u);for(const x of g)await n(y,x.file,x.documentType);N(!0),s?.(y)}catch(y){v(y instanceof Error?y.message:"Submission failed. Please try again.")}}},[h,u,g,o,n,s]),p=Cn.find(y=>y.method===h);return w?e.jsx("div",{className:`cedros-accreditation-wizard cedros-accreditation-wizard--success ${r??""}`,role:"status",children:e.jsx("p",{className:"cedros-accreditation-wizard__success-message",children:"Submitted for review. You will be notified once your accreditation is verified."})}):e.jsxs("div",{className:`cedros-accreditation-wizard ${r??""}`,children:[e.jsx("div",{className:"cedros-accreditation-wizard__header",children:e.jsx("nav",{className:"cedros-accreditation-wizard__steps","aria-label":"Wizard steps",children:["Choose Method","Fill Details","Review & Submit"].map((y,x)=>e.jsxs("span",{className:`cedros-accreditation-wizard__step${d===x+1?" cedros-accreditation-wizard__step--active":""}`,"aria-current":d===x+1?"step":void 0,children:[x+1,". ",y]},y))})}),d===1&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step1-heading",children:[e.jsx("h2",{id:"step1-heading",className:"cedros-accreditation-wizard__section-title",children:"Choose Verification Method"}),e.jsx("div",{className:"cedros-accreditation-wizard__method-grid",role:"list",children:Cn.map(y=>e.jsxs("button",{type:"button",role:"listitem",className:"cedros-accreditation-wizard__method-card",onClick:()=>k(y.method),children:[e.jsx("span",{className:"cedros-accreditation-wizard__method-title",children:y.label}),e.jsx("span",{className:"cedros-accreditation-wizard__method-desc",children:y.description})]},y.method))}),t&&e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__cancel",onClick:t,children:"Cancel"})]}),d===2&&h&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step2-heading",children:[e.jsx("h2",{id:"step2-heading",className:"cedros-accreditation-wizard__section-title",children:p?.label}),e.jsx(nh,{method:h,formData:u,onFormDataChange:f,fileEntries:g,onFileEntriesChange:b}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__next",onClick:()=>l(3),children:"Review"})]})]}),d===3&&h&&e.jsxs("section",{className:"cedros-accreditation-wizard__section","aria-labelledby":"step3-heading",children:[e.jsx("h2",{id:"step3-heading",className:"cedros-accreditation-wizard__section-title",children:"Review & Submit"}),e.jsxs("dl",{className:"cedros-accreditation-wizard__review-list",children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:"Method"}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:p?.label}),Object.entries(u).filter(([,y])=>y!==void 0&&y!==""&&y!==null).map(([y,x])=>e.jsxs("div",{children:[e.jsx("dt",{className:"cedros-accreditation-wizard__review-term",children:y}),e.jsx("dd",{className:"cedros-accreditation-wizard__review-detail",children:String(x)})]},y))]}),g.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:g.map((y,x)=>e.jsxs("li",{children:[y.file.name," ",e.jsxs("span",{className:"cedros-accreditation-wizard__doc-type",children:["(",y.documentType,")"]})]},`${y.file.name}-${x}`))})]}),(i||A)&&e.jsx("div",{className:"cedros-accreditation-wizard__error",role:"alert",children:A??i?.message}),e.jsxs("div",{className:"cedros-accreditation-wizard__actions",children:[e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__back",onClick:S,disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-accreditation-wizard__submit",onClick:E,disabled:a,children:a?"Submitting...":"Submit Verification"})]})]})]})}function ah({status:s,onStartVerification:t,className:r}){if(s==="approved")return null;let o,n=!0;switch(s){case"pending":o="Your accreditation is under review.",n=!1;break;case"rejected":o="Accreditation was not approved. You can resubmit.";break;case"expired":o="Your accreditation has expired. Please verify again.";break;default:o="Accredited investor verification is required.";break}return e.jsx("div",{className:`cedros-accreditation-banner ${r??""}`,role:"alert",children:e.jsxs("div",{className:"cedros-accreditation-banner__content",children:[e.jsx("span",{className:"cedros-accreditation-banner__message",children:o}),n&&t&&e.jsx("button",{type:"button",className:"cedros-accreditation-banner__button",onClick:t,children:s==="rejected"||s==="expired"?"Resubmit Verification":"Start Verification"})]})})}const mr=c.createContext(null),Is={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 wa(s,t){return ba(s,t)}function ba(s,t){const r={...s};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=s[o],a=t[o];typeof n=="object"&&n!==null&&typeof a=="object"&&a!==null?r[o]=ba(n,a):a!==void 0&&(r[o]=a)}return r}function ih({children:s,locale:t="en",translations:r}){const o=c.useMemo(()=>({t:r?wa(Is,r):Is,locale:t}),[r,t]);return e.jsx(mr.Provider,{value:o,children:s})}function ch(){return c.useContext(mr)?.t??Is}function lh(){return c.useContext(mr)?.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=z.LoadingSpinner;exports.useServerFeatures=Ke.useServerFeatures;exports.EmailLoginForm=K.EmailLoginForm;exports.EmailRegisterForm=K.EmailRegisterForm;exports.OtpInput=K.OtpInput;exports.PasswordInput=K.PasswordInput;exports.TotpVerify=K.TotpVerify;exports.useEmailAuth=K.useEmailAuth;exports.useTotpVerify=K.useTotpVerify;exports.validatePassword=Fe.validatePassword;exports.ErrorMessage=Z.ErrorMessage;exports.GoogleLoginButton=zt.GoogleLoginButton;exports.useGoogleAuth=zt.useGoogleAuth;exports.SolanaLoginButton=Ge.SolanaLoginButton;exports.registerMobileWallet=Ge.registerMobileWallet;exports.useSolanaAuth=Ge.useSolanaAuth;exports.InviteForm=pe.InviteForm;exports.InviteList=pe.InviteList;exports.MemberList=pe.MemberList;exports.useInvites=pe.useInvites;exports.useMembers=pe.useMembers;exports.useSystemSettings=$t.useSystemSettings;exports.AdminDepositList=ks.AdminDepositList;exports.AdminDepositStats=ks.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Pe.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Pe.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Pe.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Pe.AdminWithdrawalStats;exports.AdminUserList=Re.AdminUserList;exports.useAdminUsers=Re.useAdminUsers;exports.useOrgs=Vt.useOrgs;exports.AdminIcons=Te.Icons;exports.AdminShell=Te.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=Te.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=Te.ProfileDropdown;exports.cedrosLoginPlugin=Te.cedrosLoginPlugin;exports.loginPlugin=Te.cedrosLoginPlugin;exports.useAdminShell=Te.useAdminShell;exports.AuthenticationSettings=_n.AuthenticationSettings;exports.EmbeddedWalletSettings=Ln.EmbeddedWalletSettings;exports.EmailSettings=vs.EmailSettings;exports.CreditSystemSettings=Ht.CreditSystemSettings;exports.PrivacyCashSettings=Ht.CreditSystemSettings;exports.ServerSettings=Pn.ServerSettings;exports.SettingsPageLayout=Ye.SettingsPageLayout;exports.WebhookSettings=Ye.WebhookSettings;exports.useAdminDeposits=Sa.useAdminDeposits;exports.AccountSettings=Ud;exports.AccreditationBanner=ah;exports.AccreditationWizard=oh;exports.AdminAccessCodes=Fo;exports.AdminAccreditationQueue=Oo;exports.AdminReferralPayouts=Bo;exports.AdminSanctionsPanel=qo;exports.AppleLoginButton=go;exports.CapabilityWarning=Hc;exports.CedrosAdminDashboard=Xl;exports.ChooseUsernamePrompt=Od;exports.CompleteAccountPrompt=Wd;exports.ComplianceSettings=Io;exports.CreditBalance=yu;exports.DepositFlow=xu;exports.ErrorBoundary=xo;exports.ForgotPasswordForm=mo;exports.FullPageLayout=Mu;exports.History=ku;exports.I18nProvider=ih;exports.InviteCodePanel=Zu;exports.KycBanner=Xu;exports.KycCallback=th;exports.LinkedAccounts=Xo;exports.LoginButton=xc;exports.LoginForm=Fs;exports.LoginModal=Cc;exports.MfaSetupPrompt=Fd;exports.OrgSelector=_c;exports.OrgSwitcher=Uc;exports.PasskeyLoginButton=bo;exports.PasskeyPrompt=_o;exports.ProfileTab=Yo;exports.RecoveryPhraseDisplay=vo;exports.RecoveryPhraseInput=Ao;exports.ReferralSettings=Do;exports.ResetPasswordForm=Ec;exports.RewardsPanel=Qu;exports.SUPPORTED_TOKENS=Ws;exports.SecuritySettings=kl;exports.SessionList=yo;exports.SetupWizard=zo;exports.SignupSettings=Uo;exports.SplitPageLayout=Bu;exports.SystemSettings=ul;exports.TieredAmountSlider=dr;exports.TokenGateSettings=Wo;exports.TokenSelector=ha;exports.TotpSettings=Qo;exports.TotpSetup=or;exports.UserProfileSettings=kd;exports.WalletAddressRow=To;exports.WalletEnrollment=So;exports.WalletManager=dl;exports.WalletRecovery=Ro;exports.WalletStatus=Mo;exports.WalletUnlock=Lo;exports.WithdrawalFlow=Eu;exports.WithdrawalHistory=Tu;exports.defaultTranslations=Is;exports.getTierForAmount=qs;exports.mergeTranslations=wa;exports.useAccessCodes=pa;exports.useAccreditation=ga;exports.useAppleAuth=po;exports.useAuthorize=Iu;exports.useCedrosTheme=Ou;exports.useCredentials=ar;exports.useCredits=ur;exports.useDeposit=na;exports.useInstantLink=ho;exports.useKyc=qu;exports.useLocale=lh;exports.usePasskeySigning=Eo;exports.usePasswordReset=Us;exports.usePendingRecovery=Uu;exports.usePostLogin=Wu;exports.useProfile=is;exports.useReferral=Ko;exports.useRewards=fa;exports.useSessions=ta;exports.useSetPassword=ko;exports.useSetup=tr;exports.useTotp=nr;exports.useTransactionSigning=Fu;exports.useTranslations=ch;exports.useUsername=ra;exports.useWalletEnrollment=No;exports.useWalletRecovery=Po;exports.useWalletSigning=Co;exports.useWallets=Du;exports.useWebAuthn=sr;exports.useWithdrawal=hr;
|