@cedros/login-react 0.0.39 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./useAuth-U5CYsHEU.cjs"),T=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),d=require("react"),z=require("./LoadingSpinner-d6sSxgQN.cjs"),Ls=require("./sanitization-Bo_tn-L2.cjs"),Q=require("./EmailRegisterForm-CNjYrqU6.cjs"),Re=require("./validation-BuGQrA-K.cjs"),Z=require("./ErrorMessage-CHbYbVi2.cjs"),Ps=require("./GoogleLoginButton-JtRViYWS.cjs"),Oe=require("./SolanaLoginButton-nSJHVFpZ.cjs"),ce=require("./PermissionsSection-DEMVp7X3.cjs"),ln=require("./useSystemSettings-B2jY51ob.cjs"),We=require("./AutosaveStatus-BKsCIvPj.cjs"),Bs=require("./useOrgs-CNqfn-fk.cjs"),mt=require("./AdminDepositList-B_z6x3j5.cjs"),Le=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),Ze=require("./useUsersStatsSummary-DgKaUIfs.cjs"),dn=require("./StatsBar-DTUZCwDD.cjs"),Pe=require("./plugin-CUxpAjL-.cjs"),un=require("./AuthenticationSettings-Dk1LX0CK.cjs"),hn=require("./EmbeddedWalletSettings-DGq-kXbw.cjs"),ut=require("./EmailSettings-eLlzzI5D.cjs"),Ms=require("./CreditSystemSettings-C2HkyMXy.cjs"),fn=require("./ServerSettings-CMmH5pZv.cjs"),Zo=require("./useAdminDeposits-CpLd68oP.cjs"),Rs=require("./WebhookSettings-0sgWRI3U.cjs");var Dt=typeof document<"u"?document.currentScript:null;let Be=null,Xo=0;const Ye=new Map;function Jo(){return typeof Worker>"u"?null:(Be||(Be=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/argon2Worker-Bi5TuQvD.js").href:new URL("assets/argon2Worker-Bi5TuQvD.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:Dt&&Dt.tagName.toUpperCase()==="SCRIPT"&&Dt.src||new URL("index.cjs",document.baseURI).href),{type:"module"}),Be.onmessage=t=>{const{id:s,key:n,error:o}=t.data,r=Ye.get(s);if(r){if(Ye.delete(s),o){r.reject(new Error(o));return}if(!n){r.reject(new Error("Argon2 worker returned no key"));return}r.resolve(n)}},Be.onerror=t=>{const s=t instanceof ErrorEvent?t.error:new Error("Argon2 worker error");for(const n of Ye.values())n.reject(s instanceof Error?s:new Error(String(s)));Ye.clear(),Be?.terminate(),Be=null}),Be)}async function pn(t,s,n=I.DEFAULT_KDF_PARAMS){I.validateKdfParams(n);const o=Jo();return o?new Promise((r,a)=>{const c=Xo++;Ye.set(c,{resolve:r,reject:a});const i={id:c,password:t,salt:s,params:n};o.postMessage(i)}):I.argon2Derive(t,s,n)}function mn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ea(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var s=t.default;if(typeof s=="function"){var n=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};n.prototype=s.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var r=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return t[o]}})}),n}var ht={exports:{}};const ta=globalThis.crypto,sa=globalThis.crypto,ra=globalThis.crypto.subtle,na=globalThis.crypto.getRandomValues.bind(globalThis.crypto),oa=globalThis.crypto.randomUUID.bind(globalThis.crypto),aa=Object.freeze(Object.defineProperty({__proto__:null,default:ta,getRandomValues:na,randomUUID:oa,subtle:ra,webcrypto:sa},Symbol.toStringTag,{value:"Module"})),ia=ea(aa);var ca=ht.exports,ar;function la(){return ar||(ar=1,(function(t,s){(function(n,o){t.exports=o(ia)})(ca,function(n){var o,r,a,c,i;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]},r={},a=new Array(1024).join("0"),c=!0,i=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function u(){return!!(r&&r.rng&&typeof r.rng=="function")}function f(w,v){var A;if(v===0||v===1)return w;if(v&&v>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return v=v||r.bits,w&&(A=w.length%v),A?(a+w).slice(-(v-A+w.length)):w}function h(w){var v="",A,x;for(x=w.length-1;x>=0;x--){if(A=parseInt(w[x],16),isNaN(A))throw new Error("Invalid hex character.");v=f(A.toString(2),4)+v}return v}function m(w){var v="",A,x;for(w=f(w,4),x=w.length;x>=4;x-=4){if(A=parseInt(w.slice(x-4,x),2),isNaN(A))throw new Error("Invalid binary character.");v=A.toString(16)+v}return v}function b(){return!!(n&&typeof n=="object"&&(typeof n.getRandomValues=="function"||typeof n.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function g(){return typeof n=="object"&&typeof n.randomBytes=="function"}function p(w){function v(P,S,B,M){var R=0,U,F="",W;for(S&&(U=S.length-1);R<U||F.length<P;)W=Math.abs(parseInt(S[R],B)),F=F+f(W.toString(2),M),R++;return F=F.substr(-P),(F.match(/0/g)||[]).length===F.length?null:F}function A(P){var S,B,M,R,U=null;for(M=16,R=4,B=Math.ceil(P/8);U===null;)S=n.randomBytes(B),U=v(P,S.toString("hex"),M,R);return U}function x(P){var S,B,M,R=null;for(B=10,M=32,S=Math.ceil(P/32);R===null;)R=v(P,n.getRandomValues(new Uint32Array(S)),B,M);return R}function E(P){var S,B,M,R,U,F=null;R=10,U=32,B=Math.ceil(P/32),M=123456789,S=new Uint32Array(B);for(var W=0;W<S.length;W++)S[W]=M;for(;F===null;)F=v(P,S,R,U);return F}if(w&&w==="testRandom")return r.typeCSPRNG=w,E;if(w&&w==="nodeCryptoRandomBytes")return r.typeCSPRNG=w,A;if(w&&w==="browserCryptoGetRandomValues")return r.typeCSPRNG=w,x;if(g())return r.typeCSPRNG="nodeCryptoRandomBytes",A;if(b())return r.typeCSPRNG="browserCryptoGetRandomValues",x}function k(w,v){var A=[],x;for(v&&(w=f(w,v)),x=w.length;x>r.bits;x-=r.bits)A.push(parseInt(w.slice(x-r.bits,x),2));return A.push(parseInt(w.slice(0,x),2)),A}function y(w,v){var A=r.logs[w],x=0,E;for(E=v.length-1;E>=0;E--)x!==0?x=r.exps[(A+r.logs[x])%r.maxShares]^v[E]:x=v[E];return x}function N(w,v,A){var x=0,E,P,S,B;for(S=0,E=v.length;S<E;S++)if(A[S]){for(P=r.logs[A[S]],B=0;B<E;B++)if(S!==B){if(w===v[B]){P=-1;break}P=(P+r.logs[w^v[B]]-r.logs[v[S]^v[B]]+r.maxShares)%r.maxShares}x=P===-1?x:x^r.exps[P]}return x}function j(w,v,A){var x=[],E=[w],P,S;for(P=1;P<A;P++)E[P]=parseInt(r.rng(r.bits),2);for(P=1,S=v+1;P<S;P++)x[P-1]={x:P,y:y(P,E)};return x}function C(w,v,A){var x,E,P,S,B;if(v=parseInt(v,r.radix),w=parseInt(w,10)||r.bits,x=w.toString(36).toUpperCase(),P=Math.pow(2,w)-1,S=P.toString(r.radix).length,E=f(v.toString(r.radix),S),typeof v!="number"||v%1!==0||v<1||v>P)throw new Error("Share id must be an integer between 1 and "+P+", inclusive.");return B=x+E+A,B}var L={init:function(w,v){var A=[],x=[],E=1,P,S;if(l(),w&&(typeof w!="number"||w%1!==0||w<o.minBits||w>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(v&&i.indexOf(v)===-1)throw new Error("Invalid RNG type argument : '"+v+"'");for(r.radix=o.radix,r.bits=w||o.bits,r.size=Math.pow(2,r.bits),r.maxShares=r.size-1,P=o.primitivePolynomials[r.bits],S=0;S<r.size;S++)x[S]=E,A[E]=S,E=E<<1,E>=r.size&&(E=E^P,E=E&r.maxShares);if(r.logs=A,r.exps=x,v&&this.setRNG(v),u()||this.setRNG(),!u()||!r.bits||!r.size||!r.maxShares||!r.logs||!r.exps||r.logs.length!==r.size||r.exps.length!==r.size)throw new Error("Initialization failed.")},combine:function(w,v){var A,x,E,P,S="",B,M,R,U=[],F=[];for(v=v||0,A=0,E=w.length;A<E;A++){if(M=this.extractShareComponents(w[A]),B===void 0)B=M.bits;else if(M.bits!==B)throw new Error("Mismatched shares: Different bit settings.");if(r.bits!==B&&this.init(B),U.indexOf(M.id)===-1)for(U.push(M.id),R=k(h(M.data)),x=0,P=R.length;x<P;x++)F[x]=F[x]||[],F[x][U.length-1]=R[x]}for(A=0,E=F.length;A<E;A++)S=f(N(v,U,F[A]).toString(2))+S;return m(v>=1?S:S.slice(S.indexOf("1")+1))},getConfig:function(){var w={};return w.radix=r.radix,w.bits=r.bits,w.maxShares=r.maxShares,w.hasCSPRNG=u(),w.typeCSPRNG=r.typeCSPRNG,w},extractShareComponents:function(w){var v,A,x,E,P={},S,B;if(v=parseInt(w.substr(0,1),36),v&&(typeof v!="number"||v%1!==0||v<o.minBits||v>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(E=Math.pow(2,v)-1,x=(Math.pow(2,v)-1).toString(r.radix).length,S="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+x+"})([a-fA-F0-9]+)$",B=new RegExp(S).exec(w),B&&(A=parseInt(B[2],r.radix)),typeof A!="number"||A%1!==0||A<1||A>E)throw new Error("Invalid share : Share id must be an integer between 1 and "+r.maxShares+", inclusive.");if(B&&B[3])return P.bits=v,P.id=A,P.data=B[3],P;throw new Error("The share data provided is invalid : "+w)},setRNG:function(w){var v="Random number generator is invalid ",A=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(w&&typeof w=="string"&&i.indexOf(w)===-1)throw new Error("Invalid RNG type argument : '"+w+"'");if(w||(w=p()),w&&typeof w=="string"&&(w=p(w)),c){if(w&&typeof w!="function")throw new Error(v+"(Not a function)."+A);if(w&&typeof w(r.bits)!="string")throw new Error(v+"(Output is not a string)."+A);if(w&&!parseInt(w(r.bits),2))throw new Error(v+"(Binary string output not parseable to an Integer)."+A);if(w&&w(r.bits).length>r.bits)throw new Error(v+"(Output length is greater than config.bits)."+A);if(w&&w(r.bits).length<r.bits)throw new Error(v+"(Output length is less than config.bits)."+A)}return r.rng=w,!0},str2hex:function(w,v){var A,x,E="",P,S,B,M;if(typeof w!="string")throw new Error("Input must be a character string.");if(v||(v=o.bytesPerChar),typeof v!="number"||v<1||v>o.maxBytesPerChar||v%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(A=2*v,x=Math.pow(16,A)-1,B=0,M=w.length;B<M;B++){if(S=w[B].charCodeAt(),isNaN(S))throw new Error("Invalid character: "+w[B]);if(S>x)throw P=Math.ceil(Math.log(S+1)/Math.log(256)),new Error("Invalid character code ("+S+"). Maximum allowable is 256^bytes-1 ("+x+"). To convert this character, use at least "+P+" bytes.");E=f(S.toString(16),A)+E}return E},hex2str:function(w,v){var A,x="",E,P;if(typeof w!="string")throw new Error("Input must be a hexadecimal string.");if(v=v||o.bytesPerChar,typeof v!="number"||v%1!==0||v<1||v>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(A=2*v,w=f(w,A),E=0,P=w.length;E<P;E+=A)x=String.fromCharCode(parseInt(w.slice(E,E+A),16))+x;return x},random:function(w){if(typeof w!="number"||w%1!==0||w<2||w>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return m(r.rng(w))},share:function(w,v,A,x){var E,P,S=new Array(v),B=new Array(v),M,R,U;if(x=x||128,typeof w!="string")throw new Error("Secret must be a string.");if(typeof v!="number"||v%1!==0||v<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(v>r.maxShares)throw E=Math.ceil(Math.log(v+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To create "+v+" shares, use at least "+E+" bits.");if(typeof A!="number"||A%1!==0||A<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(A>r.maxShares)throw E=Math.ceil(Math.log(A+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To use a threshold of "+A+", use at least "+E+" bits.");if(A>v)throw new Error("Threshold number of shares was "+A+" but must be less than or equal to the "+v+" shares specified as the total to generate.");if(typeof x!="number"||x%1!==0||x<0||x>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(w="1"+h(w),w=k(w,x),M=0,U=w.length;M<U;M++)for(P=j(w[M],v,A),R=0;R<v;R++)S[R]=S[R]||P[R].x.toString(r.radix),B[R]=f(P[R].y.toString(2))+(B[R]||"");for(M=0;M<v;M++)S[M]=C(r.bits,S[M],m(B[M]));return S},newShare:function(w,v){var A,x;if(w&&typeof w=="string"&&(w=parseInt(w,r.radix)),x=w.toString(r.radix),w&&x&&v&&v[0])return A=this.extractShareComponents(v[0]),C(A.bits,x,this.combine(v,w));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:l,_padLeft:f,_hex2bin:h,_bin2hex:m,_hasCryptoGetRandomValues:b,_hasCryptoRandomBytes:g,_getRNG:p,_isSetRNG:u,_splitNumStringToIntArray:k,_horner:y,_lagrange:N,_getShares:j,_constructPublicShareString:C};return L.init(),L})})(ht)),ht.exports}var da=la();const gn=mn(da);function wn(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ts(t,s=""){if(!Number.isSafeInteger(t)||t<0){const n=s&&`"${s}" `;throw new Error(`${n}expected integer >= 0, got ${t}`)}}function se(t,s,n=""){const o=wn(t),r=t?.length,a=s!==void 0;if(!o||a&&r!==s){const c=n&&`"${n}" `,i=a?` of length ${s}`:"",l=o?`length=${r}`:`type=${typeof t}`;throw new Error(c+"expected Uint8Array"+i+", got "+l)}return t}function ir(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function ua(t,s){se(t,void 0,"digestInto() output");const n=s.outputLen;if(t.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function ys(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function _t(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const bn=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ha=Array.from({length:256},(t,s)=>s.toString(16).padStart(2,"0"));function Is(t){if(se(t),bn)return t.toHex();let s="";for(let n=0;n<t.length;n++)s+=ha[t[n]];return s}const ye={_0:48,_9:57,A:65,F:70,a:97,f:102};function cr(t){if(t>=ye._0&&t<=ye._9)return t-ye._0;if(t>=ye.A&&t<=ye.F)return t-(ye.A-10);if(t>=ye.a&&t<=ye.f)return t-(ye.a-10)}function yn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(bn)return Uint8Array.fromHex(t);const s=t.length,n=s/2;if(s%2)throw new Error("hex string expected, got unpadded hex of length "+s);const o=new Uint8Array(n);for(let r=0,a=0;r<n;r++,a+=2){const c=cr(t.charCodeAt(a)),i=cr(t.charCodeAt(a+1));if(c===void 0||i===void 0){const l=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+a)}o[r]=c*16+i}return o}function lr(...t){let s=0;for(let o=0;o<t.length;o++){const r=t[o];se(r),s+=r.length}const n=new Uint8Array(s);for(let o=0,r=0;o<t.length;o++){const a=t[o];n.set(a,r),r+=a.length}return n}function fa(t,s={}){const n=(r,a)=>t(a).update(r).digest(),o=t(void 0);return n.outputLen=o.outputLen,n.blockLen=o.blockLen,n.create=r=>t(r),Object.assign(n,s),Object.freeze(n)}function pa(t=32){const s=typeof globalThis=="object"?globalThis.crypto:null;if(typeof s?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return s.getRandomValues(new Uint8Array(t))}const ma=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});let ga=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(s,n,o,r){this.blockLen=s,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(s),this.view=_t(this.buffer)}update(s){ir(this),se(s);const{view:n,buffer:o,blockLen:r}=this,a=s.length;for(let c=0;c<a;){const i=Math.min(r-this.pos,a-c);if(i===r){const l=_t(s);for(;r<=a-c;c+=r)this.process(l,c);continue}o.set(s.subarray(c,c+i),this.pos),this.pos+=i,c+=i,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){ir(this),ua(s,this),this.finished=!0;const{buffer:n,view:o,blockLen:r,isLE:a}=this;let{pos:c}=this;n[c++]=128,ys(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(o,0),c=0);for(let h=c;h<r;h++)n[h]=0;o.setBigUint64(r-8,BigInt(this.length*8),a),this.process(o,0);const i=_t(s),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)i.setUint32(4*h,f[h],a)}digest(){const{buffer:s,outputLen:n}=this;this.digestInto(s);const o=s.slice(0,n);return this.destroy(),o}_cloneInto(s){s||=new this.constructor,s.set(...this.get());const{blockLen:n,buffer:o,length:r,finished:a,destroyed:c,pos:i}=this;return s.destroyed=c,s.finished=a,s.length=r,s.pos=i,r%n&&s.buffer.set(o),s}clone(){return this._cloneInto()}};const re=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),nt=BigInt(2**32-1),dr=BigInt(32);function wa(t,s=!1){return s?{h:Number(t&nt),l:Number(t>>dr&nt)}:{h:Number(t>>dr&nt)|0,l:Number(t&nt)|0}}function ba(t,s=!1){const n=t.length;let o=new Uint32Array(n),r=new Uint32Array(n);for(let a=0;a<n;a++){const{h:c,l:i}=wa(t[a],s);[o[a],r[a]]=[c,i]}return[o,r]}const ur=(t,s,n)=>t>>>n,hr=(t,s,n)=>t<<32-n|s>>>n,De=(t,s,n)=>t>>>n|s<<32-n,_e=(t,s,n)=>t<<32-n|s>>>n,ot=(t,s,n)=>t<<64-n|s>>>n-32,at=(t,s,n)=>t>>>n-32|s<<64-n;function xe(t,s,n,o){const r=(s>>>0)+(o>>>0);return{h:t+n+(r/2**32|0)|0,l:r|0}}const ya=(t,s,n)=>(t>>>0)+(s>>>0)+(n>>>0),xa=(t,s,n,o)=>s+n+o+(t/2**32|0)|0,Aa=(t,s,n,o)=>(t>>>0)+(s>>>0)+(n>>>0)+(o>>>0),va=(t,s,n,o,r)=>s+n+o+r+(t/2**32|0)|0,ja=(t,s,n,o,r)=>(t>>>0)+(s>>>0)+(n>>>0)+(o>>>0)+(r>>>0),ka=(t,s,n,o,r,a)=>s+n+o+r+a+(t/2**32|0)|0,xn=ba(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Na=xn[0],Ca=xn[1],je=new Uint32Array(80),ke=new Uint32Array(80);class Sa extends ga{constructor(s){super(128,s,16,!1)}get(){const{Ah:s,Al:n,Bh:o,Bl:r,Ch:a,Cl:c,Dh:i,Dl:l,Eh:u,El:f,Fh:h,Fl:m,Gh:b,Gl:g,Hh:p,Hl:k}=this;return[s,n,o,r,a,c,i,l,u,f,h,m,b,g,p,k]}set(s,n,o,r,a,c,i,l,u,f,h,m,b,g,p,k){this.Ah=s|0,this.Al=n|0,this.Bh=o|0,this.Bl=r|0,this.Ch=a|0,this.Cl=c|0,this.Dh=i|0,this.Dl=l|0,this.Eh=u|0,this.El=f|0,this.Fh=h|0,this.Fl=m|0,this.Gh=b|0,this.Gl=g|0,this.Hh=p|0,this.Hl=k|0}process(s,n){for(let j=0;j<16;j++,n+=4)je[j]=s.getUint32(n),ke[j]=s.getUint32(n+=4);for(let j=16;j<80;j++){const C=je[j-15]|0,L=ke[j-15]|0,w=De(C,L,1)^De(C,L,8)^ur(C,L,7),v=_e(C,L,1)^_e(C,L,8)^hr(C,L,7),A=je[j-2]|0,x=ke[j-2]|0,E=De(A,x,19)^ot(A,x,61)^ur(A,x,6),P=_e(A,x,19)^at(A,x,61)^hr(A,x,6),S=Aa(v,P,ke[j-7],ke[j-16]),B=va(S,w,E,je[j-7],je[j-16]);je[j]=B|0,ke[j]=S|0}let{Ah:o,Al:r,Bh:a,Bl:c,Ch:i,Cl:l,Dh:u,Dl:f,Eh:h,El:m,Fh:b,Fl:g,Gh:p,Gl:k,Hh:y,Hl:N}=this;for(let j=0;j<80;j++){const C=De(h,m,14)^De(h,m,18)^ot(h,m,41),L=_e(h,m,14)^_e(h,m,18)^at(h,m,41),w=h&b^~h&p,v=m&g^~m&k,A=ja(N,L,v,Ca[j],ke[j]),x=ka(A,y,C,w,Na[j],je[j]),E=A|0,P=De(o,r,28)^ot(o,r,34)^ot(o,r,39),S=_e(o,r,28)^at(o,r,34)^at(o,r,39),B=o&a^o&i^a&i,M=r&c^r&l^c&l;y=p|0,N=k|0,p=b|0,k=g|0,b=h|0,g=m|0,{h,l:m}=xe(u|0,f|0,x|0,E|0),u=i|0,f=l|0,i=a|0,l=c|0,a=o|0,c=r|0;const R=ya(E,S,M);o=xa(R,x,P,B),r=R|0}({h:o,l:r}=xe(this.Ah|0,this.Al|0,o|0,r|0)),{h:a,l:c}=xe(this.Bh|0,this.Bl|0,a|0,c|0),{h:i,l}=xe(this.Ch|0,this.Cl|0,i|0,l|0),{h:u,l:f}=xe(this.Dh|0,this.Dl|0,u|0,f|0),{h,l:m}=xe(this.Eh|0,this.El|0,h|0,m|0),{h:b,l:g}=xe(this.Fh|0,this.Fl|0,b|0,g|0),{h:p,l:k}=xe(this.Gh|0,this.Gl|0,p|0,k|0),{h:y,l:N}=xe(this.Hh|0,this.Hl|0,y|0,N|0),this.set(o,r,a,c,i,l,u,f,h,m,b,g,p,k,y,N)}roundClean(){ys(je,ke)}destroy(){ys(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ea extends Sa{Ah=re[0]|0;Al=re[1]|0;Bh=re[2]|0;Bl=re[3]|0;Ch=re[4]|0;Cl=re[5]|0;Dh=re[6]|0;Dl=re[7]|0;Eh=re[8]|0;El=re[9]|0;Fh=re[10]|0;Fl=re[11]|0;Gh=re[12]|0;Gl=re[13]|0;Hh=re[14]|0;Hl=re[15]|0;constructor(){super(64)}}const La=fa(()=>new Ea,ma(3));const An=BigInt(0),fr=BigInt(1);function xs(t,s=""){if(typeof t!="boolean"){const n=s&&`"${s}" `;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function Pa(t){if(typeof t=="bigint"){if(!ft(t))throw new Error("positive bigint expected, got "+t)}else Ts(t);return t}function vn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?An:BigInt("0x"+t)}function Ba(t){return vn(Is(t))}function gt(t){return vn(Is(As(se(t)).reverse()))}function jn(t,s){Ts(s),t=Pa(t);const n=yn(t.toString(16).padStart(s*2,"0"));if(n.length!==s)throw new Error("number too large");return n}function Ma(t,s){return jn(t,s).reverse()}function As(t){return Uint8Array.from(t)}const ft=t=>typeof t=="bigint"&&An<=t;function Ra(t,s,n){return ft(t)&&ft(s)&&ft(n)&&s<=t&&t<n}function pr(t,s,n,o){if(!Ra(s,n,o))throw new Error("expected valid "+t+": "+n+" <= n < "+o+", got "+s)}const Ta=t=>(fr<<BigInt(t))-fr;function Ds(t,s={},n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function o(a,c,i){const l=t[a];if(i&&l===void 0)return;const u=typeof l;if(u!==c||l===null)throw new Error(`param "${a}" is invalid: expected ${c}, got ${u}`)}const r=(a,c)=>Object.entries(a).forEach(([i,l])=>o(i,l,c));r(s,!1),r(n,!0)}function mr(t){const s=new WeakMap;return(n,...o)=>{const r=s.get(n);if(r!==void 0)return r;const a=t(n,...o);return s.set(n,a),a}}const le=BigInt(0),ae=BigInt(1),Me=BigInt(2),kn=BigInt(3),Nn=BigInt(4),Cn=BigInt(5),Ia=BigInt(7),Sn=BigInt(8),Da=BigInt(9),En=BigInt(16);function ee(t,s){const n=t%s;return n>=le?n:s+n}function me(t,s,n){let o=t;for(;s-- >le;)o*=o,o%=n;return o}function gr(t,s){if(t===le)throw new Error("invert: expected non-zero number");if(s<=le)throw new Error("invert: expected positive modulus, got "+s);let n=ee(t,s),o=s,r=le,a=ae;for(;n!==le;){const i=o/n,l=o%n,u=r-a*i;o=n,n=l,r=a,a=u}if(o!==ae)throw new Error("invert: does not exist");return ee(r,s)}function _s(t,s,n){if(!t.eql(t.sqr(s),n))throw new Error("Cannot find square root")}function Ln(t,s){const n=(t.ORDER+ae)/Nn,o=t.pow(s,n);return _s(t,o,s),o}function _a(t,s){const n=(t.ORDER-Cn)/Sn,o=t.mul(s,Me),r=t.pow(o,n),a=t.mul(s,r),c=t.mul(t.mul(a,Me),r),i=t.mul(a,t.sub(c,t.ONE));return _s(t,i,s),i}function Ua(t){const s=Us(t),n=Pn(t),o=n(s,s.neg(s.ONE)),r=n(s,o),a=n(s,s.neg(o)),c=(t+Ia)/En;return(i,l)=>{let u=i.pow(l,c),f=i.mul(u,o);const h=i.mul(u,r),m=i.mul(u,a),b=i.eql(i.sqr(f),l),g=i.eql(i.sqr(h),l);u=i.cmov(u,f,b),f=i.cmov(m,h,g);const p=i.eql(i.sqr(f),l),k=i.cmov(u,f,p);return _s(i,k,l),k}}function Pn(t){if(t<kn)throw new Error("sqrt is not defined for small field");let s=t-ae,n=0;for(;s%Me===le;)s/=Me,n++;let o=Me;const r=Us(t);for(;wr(r,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Ln;let a=r.pow(o,s);const c=(s+ae)/Me;return function(l,u){if(l.is0(u))return u;if(wr(l,u)!==1)throw new Error("Cannot find square root");let f=n,h=l.mul(l.ONE,a),m=l.pow(u,s),b=l.pow(u,c);for(;!l.eql(m,l.ONE);){if(l.is0(m))return l.ZERO;let g=1,p=l.sqr(m);for(;!l.eql(p,l.ONE);)if(g++,p=l.sqr(p),g===f)throw new Error("Cannot find square root");const k=ae<<BigInt(f-g-1),y=l.pow(h,k);f=g,h=l.sqr(y),m=l.mul(m,h),b=l.mul(b,y)}return b}}function Fa(t){return t%Nn===kn?Ln:t%Sn===Cn?_a:t%En===Da?Ua(t):Pn(t)}const Oa=(t,s)=>(ee(t,s)&ae)===ae,Wa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qa(t){const s={ORDER:"bigint",BYTES:"number",BITS:"number"},n=Wa.reduce((o,r)=>(o[r]="function",o),s);return Ds(t,n),t}function za(t,s,n){if(n<le)throw new Error("invalid exponent, negatives unsupported");if(n===le)return t.ONE;if(n===ae)return s;let o=t.ONE,r=s;for(;n>le;)n&ae&&(o=t.mul(o,r)),r=t.sqr(r),n>>=ae;return o}function Bn(t,s,n=!1){const o=new Array(s.length).fill(n?t.ZERO:void 0),r=s.reduce((c,i,l)=>t.is0(i)?c:(o[l]=c,t.mul(c,i)),t.ONE),a=t.inv(r);return s.reduceRight((c,i,l)=>t.is0(i)?c:(o[l]=t.mul(c,o[l]),t.mul(c,i)),a),o}function wr(t,s){const n=(t.ORDER-ae)/Me,o=t.pow(s,n),r=t.eql(o,t.ONE),a=t.eql(o,t.ZERO),c=t.eql(o,t.neg(t.ONE));if(!r&&!a&&!c)throw new Error("invalid Legendre symbol result");return r?1:a?0:-1}function Ha(t,s){s!==void 0&&Ts(s);const n=s!==void 0?s:t.toString(2).length,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}class Va{ORDER;BITS;BYTES;isLE;ZERO=le;ONE=ae;_lengths;_sqrt;_mod;constructor(s,n={}){if(s<=le)throw new Error("invalid field: expected ORDER > 0, got "+s);let o;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(o=n.BITS),typeof n.sqrt=="function"&&(this.sqrt=n.sqrt),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=n.allowedLengths?.slice()),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));const{nBitLength:r,nByteLength:a}=Ha(s,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=s,this.BITS=r,this.BYTES=a,this._sqrt=void 0,Object.preventExtensions(this)}create(s){return ee(s,this.ORDER)}isValid(s){if(typeof s!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof s);return le<=s&&s<this.ORDER}is0(s){return s===le}isValidNot0(s){return!this.is0(s)&&this.isValid(s)}isOdd(s){return(s&ae)===ae}neg(s){return ee(-s,this.ORDER)}eql(s,n){return s===n}sqr(s){return ee(s*s,this.ORDER)}add(s,n){return ee(s+n,this.ORDER)}sub(s,n){return ee(s-n,this.ORDER)}mul(s,n){return ee(s*n,this.ORDER)}pow(s,n){return za(this,s,n)}div(s,n){return ee(s*gr(n,this.ORDER),this.ORDER)}sqrN(s){return s*s}addN(s,n){return s+n}subN(s,n){return s-n}mulN(s,n){return s*n}inv(s){return gr(s,this.ORDER)}sqrt(s){return this._sqrt||(this._sqrt=Fa(this.ORDER)),this._sqrt(this,s)}toBytes(s){return this.isLE?Ma(s,this.BYTES):jn(s,this.BYTES)}fromBytes(s,n=!1){se(s);const{_lengths:o,BYTES:r,isLE:a,ORDER:c,_mod:i}=this;if(o){if(!o.includes(s.length)||s.length>r)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+s.length);const u=new Uint8Array(r);u.set(s,a?0:u.length-s.length),s=u}if(s.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+s.length);let l=a?gt(s):Ba(s);if(i&&(l=ee(l,c)),!n&&!this.isValid(l))throw new Error("invalid field element: outside of range 0..ORDER");return l}invertBatch(s){return Bn(this,s)}cmov(s,n,o){return o?n:s}}function Us(t,s={}){return new Va(t,s)}const wt=BigInt(0),vs=BigInt(1);function br(t,s){const n=s.negate();return t?n:s}function Ut(t,s){const n=Bn(t.Fp,s.map(o=>o.Z));return s.map((o,r)=>t.fromAffine(o.toAffine(n[r])))}function Mn(t,s){if(!Number.isSafeInteger(t)||t<=0||t>s)throw new Error("invalid window size, expected [1.."+s+"], got W="+t)}function Ft(t,s){Mn(t,s);const n=Math.ceil(s/t)+1,o=2**(t-1),r=2**t,a=Ta(t),c=BigInt(t);return{windows:n,windowSize:o,mask:a,maxNumber:r,shiftBy:c}}function yr(t,s,n){const{windowSize:o,mask:r,maxNumber:a,shiftBy:c}=n;let i=Number(t&r),l=t>>c;i>o&&(i-=a,l+=vs);const u=s*o,f=u+Math.abs(i)-1,h=i===0,m=i<0,b=s%2!==0;return{nextN:l,offset:f,isZero:h,isNeg:m,isNegF:b,offsetF:u}}const Ot=new WeakMap,Rn=new WeakMap;function Wt(t){return Rn.get(t)||1}function xr(t){if(t!==wt)throw new Error("invalid wNAF")}class $a{BASE;ZERO;Fn;bits;constructor(s,n){this.BASE=s.BASE,this.ZERO=s.ZERO,this.Fn=s.Fn,this.bits=n}_unsafeLadder(s,n,o=this.ZERO){let r=s;for(;n>wt;)n&vs&&(o=o.add(r)),r=r.double(),n>>=vs;return o}precomputeWindow(s,n){const{windows:o,windowSize:r}=Ft(n,this.bits),a=[];let c=s,i=c;for(let l=0;l<o;l++){i=c,a.push(i);for(let u=1;u<r;u++)i=i.add(c),a.push(i);c=i.double()}return a}wNAF(s,n,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let r=this.ZERO,a=this.BASE;const c=Ft(s,this.bits);for(let i=0;i<c.windows;i++){const{nextN:l,offset:u,isZero:f,isNeg:h,isNegF:m,offsetF:b}=yr(o,i,c);o=l,f?a=a.add(br(m,n[b])):r=r.add(br(h,n[u]))}return xr(o),{p:r,f:a}}wNAFUnsafe(s,n,o,r=this.ZERO){const a=Ft(s,this.bits);for(let c=0;c<a.windows&&o!==wt;c++){const{nextN:i,offset:l,isZero:u,isNeg:f}=yr(o,c,a);if(o=i,!u){const h=n[l];r=r.add(f?h.negate():h)}}return xr(o),r}getPrecomputes(s,n,o){let r=Ot.get(n);return r||(r=this.precomputeWindow(n,s),s!==1&&(typeof o=="function"&&(r=o(r)),Ot.set(n,r))),r}cached(s,n,o){const r=Wt(s);return this.wNAF(r,this.getPrecomputes(r,s,o),n)}unsafe(s,n,o,r){const a=Wt(s);return a===1?this._unsafeLadder(s,n,r):this.wNAFUnsafe(a,this.getPrecomputes(a,s,o),n,r)}createCache(s,n){Mn(n,this.bits),Rn.set(s,n),Ot.delete(s)}hasCache(s){return Wt(s)!==1}}function Ar(t,s,n){if(s){if(s.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return qa(s),s}else return Us(t,{isLE:n})}function Ga(t,s,n={},o){if(o===void 0&&(o=t==="edwards"),!s||typeof s!="object")throw new Error(`expected valid ${t} CURVE object`);for(const l of["p","n","h"]){const u=s[l];if(!(typeof u=="bigint"&&u>wt))throw new Error(`CURVE.${l} must be positive bigint`)}const r=Ar(s.p,n.Fp,o),a=Ar(s.n,n.Fn,o),i=["Gx","Gy","a","d"];for(const l of i)if(!r.isValid(s[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return s=Object.freeze(Object.assign({},s)),{CURVE:s,Fp:r,Fn:a}}function Qa(t,s){return function(o){const r=t(o);return{secretKey:r,publicKey:s(r)}}}const Ne=BigInt(0),te=BigInt(1),qt=BigInt(2),Ka=BigInt(8);function Ya(t,s,n,o){const r=t.sqr(n),a=t.sqr(o),c=t.add(t.mul(s.a,r),a),i=t.add(t.ONE,t.mul(s.d,t.mul(r,a)));return t.eql(c,i)}function Za(t,s={}){const n=Ga("edwards",t,s,s.FpFnLE),{Fp:o,Fn:r}=n;let a=n.CURVE;const{h:c}=a;Ds(s,{},{uvRatio:"function"});const i=qt<<BigInt(r.BYTES*8)-te,l=k=>o.create(k),u=s.uvRatio||((k,y)=>{try{return{isValid:!0,value:o.sqrt(o.div(k,y))}}catch{return{isValid:!1,value:Ne}}});if(!Ya(o,a,a.Gx,a.Gy))throw new Error("bad curve params: generator point");function f(k,y,N=!1){const j=N?te:Ne;return pr("coordinate "+k,y,j,i),y}function h(k){if(!(k instanceof g))throw new Error("EdwardsPoint expected")}const m=mr((k,y)=>{const{X:N,Y:j,Z:C}=k,L=k.is0();y==null&&(y=L?Ka:o.inv(C));const w=l(N*y),v=l(j*y),A=o.mul(C,y);if(L)return{x:Ne,y:te};if(A!==te)throw new Error("invZ was invalid");return{x:w,y:v}}),b=mr(k=>{const{a:y,d:N}=a;if(k.is0())throw new Error("bad point: ZERO");const{X:j,Y:C,Z:L,T:w}=k,v=l(j*j),A=l(C*C),x=l(L*L),E=l(x*x),P=l(v*y),S=l(x*l(P+A)),B=l(E+l(N*l(v*A)));if(S!==B)throw new Error("bad point: equation left != right (1)");const M=l(j*C),R=l(L*w);if(M!==R)throw new Error("bad point: equation left != right (2)");return!0});class g{static BASE=new g(a.Gx,a.Gy,te,l(a.Gx*a.Gy));static ZERO=new g(Ne,te,te,Ne);static Fp=o;static Fn=r;X;Y;Z;T;constructor(y,N,j,C){this.X=f("x",y),this.Y=f("y",N),this.Z=f("z",j,!0),this.T=f("t",C),Object.freeze(this)}static CURVE(){return a}static fromAffine(y){if(y instanceof g)throw new Error("extended point not allowed");const{x:N,y:j}=y||{};return f("x",N),f("y",j),new g(N,j,te,l(N*j))}static fromBytes(y,N=!1){const j=o.BYTES,{a:C,d:L}=a;y=As(se(y,j,"point")),xs(N,"zip215");const w=As(y),v=y[j-1];w[j-1]=v&-129;const A=gt(w),x=N?i:o.ORDER;pr("point.y",A,Ne,x);const E=l(A*A),P=l(E-te),S=l(L*E-C);let{isValid:B,value:M}=u(P,S);if(!B)throw new Error("bad point: invalid y coordinate");const R=(M&te)===te,U=(v&128)!==0;if(!N&&M===Ne&&U)throw new Error("bad point: x=0 and x_0=1");return U!==R&&(M=l(-M)),g.fromAffine({x:M,y:A})}static fromHex(y,N=!1){return g.fromBytes(yn(y),N)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,N=!0){return p.createCache(this,y),N||this.multiply(qt),this}assertValidity(){b(this)}equals(y){h(y);const{X:N,Y:j,Z:C}=this,{X:L,Y:w,Z:v}=y,A=l(N*v),x=l(L*C),E=l(j*v),P=l(w*C);return A===x&&E===P}is0(){return this.equals(g.ZERO)}negate(){return new g(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:y}=a,{X:N,Y:j,Z:C}=this,L=l(N*N),w=l(j*j),v=l(qt*l(C*C)),A=l(y*L),x=N+j,E=l(l(x*x)-L-w),P=A+w,S=P-v,B=A-w,M=l(E*S),R=l(P*B),U=l(E*B),F=l(S*P);return new g(M,R,F,U)}add(y){h(y);const{a:N,d:j}=a,{X:C,Y:L,Z:w,T:v}=this,{X:A,Y:x,Z:E,T:P}=y,S=l(C*A),B=l(L*x),M=l(v*j*P),R=l(w*E),U=l((C+L)*(A+x)-S-B),F=R-M,W=R+M,q=l(B-N*S),D=l(U*F),_=l(W*q),$=l(U*q),X=l(F*W);return new g(D,_,X,$)}subtract(y){return this.add(y.negate())}multiply(y){if(!r.isValidNot0(y))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:N,f:j}=p.cached(this,y,C=>Ut(g,C));return Ut(g,[N,j])[0]}multiplyUnsafe(y,N=g.ZERO){if(!r.isValid(y))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return y===Ne?g.ZERO:this.is0()||y===te?this:p.unsafe(this,y,j=>Ut(g,j),N)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return p.unsafe(this,a.n).is0()}toAffine(y){return m(this,y)}clearCofactor(){return c===te?this:this.multiplyUnsafe(c)}toBytes(){const{x:y,y:N}=this.toAffine(),j=o.toBytes(N);return j[j.length-1]|=y&te?128:0,j}toHex(){return Is(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const p=new $a(g,r.BITS);return g.BASE.precompute(8),g}function Xa(t,s,n={}){if(typeof s!="function")throw new Error('"hash" function param is required');Ds(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=n,{BASE:r,Fp:a,Fn:c}=t,i=n.randomBytes||pa,l=n.adjustScalarBytes||(A=>A),u=n.domain||((A,x,E)=>{if(xs(E,"phflag"),x.length||E)throw new Error("Contexts/pre-hash are not supported");return A});function f(A){return c.create(gt(A))}function h(A){const x=j.secretKey;se(A,j.secretKey,"secretKey");const E=se(s(A),2*x,"hashedSecretKey"),P=l(E.slice(0,x)),S=E.slice(x,2*x),B=f(P);return{head:P,prefix:S,scalar:B}}function m(A){const{head:x,prefix:E,scalar:P}=h(A),S=r.multiply(P),B=S.toBytes();return{head:x,prefix:E,scalar:P,point:S,pointBytes:B}}function b(A){return m(A).pointBytes}function g(A=Uint8Array.of(),...x){const E=lr(...x);return f(s(u(E,se(A,void 0,"context"),!!o)))}function p(A,x,E={}){A=se(A,void 0,"message"),o&&(A=o(A));const{prefix:P,scalar:S,pointBytes:B}=m(x),M=g(E.context,P,A),R=r.multiply(M).toBytes(),U=g(E.context,R,B,A),F=c.create(M+U*S);if(!c.isValid(F))throw new Error("sign failed: invalid s");const W=lr(R,c.toBytes(F));return se(W,j.signature,"result")}const k={zip215:!0};function y(A,x,E,P=k){const{context:S,zip215:B}=P,M=j.signature;A=se(A,M,"signature"),x=se(x,void 0,"message"),E=se(E,j.publicKey,"publicKey"),B!==void 0&&xs(B,"zip215"),o&&(x=o(x));const R=M/2,U=A.subarray(0,R),F=gt(A.subarray(R,M));let W,q,D;try{W=t.fromBytes(E,B),q=t.fromBytes(U,B),D=r.multiplyUnsafe(F)}catch{return!1}if(!B&&W.isSmallOrder())return!1;const _=g(S,q.toBytes(),W.toBytes(),x);return q.add(W.multiplyUnsafe(_)).subtract(D).clearCofactor().is0()}const N=a.BYTES,j={secretKey:N,publicKey:N,signature:2*N,seed:N};function C(A=i(j.seed)){return se(A,j.seed,"seed")}function L(A){return wn(A)&&A.length===c.BYTES}function w(A,x){try{return!!t.fromBytes(A,x)}catch{return!1}}const v={getExtendedPublicKey:m,randomSecretKey:C,isValidSecretKey:L,isValidPublicKey:w,toMontgomery(A){const{y:x}=t.fromBytes(A),E=j.publicKey,P=E===32;if(!P&&E!==57)throw new Error("only defined for 25519 and 448");const S=P?a.div(te+x,te-x):a.div(x-te,x+te);return a.toBytes(S)},toMontgomerySecret(A){const x=j.secretKey;se(A,x);const E=s(A.subarray(0,x));return l(E).subarray(0,x)}};return Object.freeze({keygen:Qa(C,b),getPublicKey:b,sign:p,verify:y,utils:v,Point:t,lengths:j})}const Ja=BigInt(1),vr=BigInt(2),ei=BigInt(5),ti=BigInt(8),Fs=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),si={p:Fs,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:ti,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ri(t){const s=BigInt(10),n=BigInt(20),o=BigInt(40),r=BigInt(80),a=Fs,i=t*t%a*t%a,l=me(i,vr,a)*i%a,u=me(l,Ja,a)*t%a,f=me(u,ei,a)*u%a,h=me(f,s,a)*f%a,m=me(h,n,a)*h%a,b=me(m,o,a)*m%a,g=me(b,r,a)*b%a,p=me(g,r,a)*b%a,k=me(p,s,a)*f%a;return{pow_p_5_8:me(k,vr,a)*t%a,b2:i}}function ni(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const jr=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function oi(t,s){const n=Fs,o=ee(s*s*s,n),r=ee(o*o*s,n),a=ri(t*r).pow_p_5_8;let c=ee(t*o*a,n);const i=ee(s*c*c,n),l=c,u=ee(c*jr,n),f=i===t,h=i===ee(-t,n),m=i===ee(-t*jr,n);return f&&(c=l),(h||m)&&(c=u),Oa(c,n)&&(c=ee(-c,n)),{isValid:f||h,value:c}}const ai=Za(si,{uvRatio:oi});function ii(t){return Xa(ai,La,Object.assign({adjustScalarBytes:ni},t))}const ci=ii({});function li(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ct(t,...s){if(!li(t))throw new Error("Uint8Array expected");if(s.length>0&&!s.includes(t.length))throw new Error("Uint8Array expected of length "+s+", got length="+t.length)}function kr(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function di(t,s){Ct(t);const n=s.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function js(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function zt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ge(t,s){return t<<32-s|t>>>s}function ui(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Tn(t){return typeof t=="string"&&(t=ui(t)),Ct(t),t}class hi{}function fi(t){const s=o=>t().update(Tn(o)).digest(),n=t();return s.outputLen=n.outputLen,s.blockLen=n.blockLen,s.create=()=>t(),s}function pi(t,s,n,o){if(typeof t.setBigUint64=="function")return t.setBigUint64(s,n,o);const r=BigInt(32),a=BigInt(4294967295),c=Number(n>>r&a),i=Number(n&a),l=o?4:0,u=o?0:4;t.setUint32(s+l,c,o),t.setUint32(s+u,i,o)}function mi(t,s,n){return t&s^~t&n}function gi(t,s,n){return t&s^t&n^s&n}class wi extends hi{constructor(s,n,o,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=s,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(s),this.view=zt(this.buffer)}update(s){kr(this),s=Tn(s),Ct(s);const{view:n,buffer:o,blockLen:r}=this,a=s.length;for(let c=0;c<a;){const i=Math.min(r-this.pos,a-c);if(i===r){const l=zt(s);for(;r<=a-c;c+=r)this.process(l,c);continue}o.set(s.subarray(c,c+i),this.pos),this.pos+=i,c+=i,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){kr(this),di(s,this),this.finished=!0;const{buffer:n,view:o,blockLen:r,isLE:a}=this;let{pos:c}=this;n[c++]=128,js(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(o,0),c=0);for(let h=c;h<r;h++)n[h]=0;pi(o,r-8,BigInt(this.length*8),a),this.process(o,0);const i=zt(s),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)i.setUint32(4*h,f[h],a)}digest(){const{buffer:s,outputLen:n}=this;this.digestInto(s);const o=s.slice(0,n);return this.destroy(),o}_cloneInto(s){s||(s=new this.constructor),s.set(...this.get());const{blockLen:n,buffer:o,length:r,finished:a,destroyed:c,pos:i}=this;return s.destroyed=c,s.finished=a,s.length=r,s.pos=i,r%n&&s.buffer.set(o),s}clone(){return this._cloneInto()}}const Ce=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),bi=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]),Se=new Uint32Array(64);class yi extends wi{constructor(s=32){super(64,s,8,!1),this.A=Ce[0]|0,this.B=Ce[1]|0,this.C=Ce[2]|0,this.D=Ce[3]|0,this.E=Ce[4]|0,this.F=Ce[5]|0,this.G=Ce[6]|0,this.H=Ce[7]|0}get(){const{A:s,B:n,C:o,D:r,E:a,F:c,G:i,H:l}=this;return[s,n,o,r,a,c,i,l]}set(s,n,o,r,a,c,i,l){this.A=s|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=a|0,this.F=c|0,this.G=i|0,this.H=l|0}process(s,n){for(let h=0;h<16;h++,n+=4)Se[h]=s.getUint32(n,!1);for(let h=16;h<64;h++){const m=Se[h-15],b=Se[h-2],g=ge(m,7)^ge(m,18)^m>>>3,p=ge(b,17)^ge(b,19)^b>>>10;Se[h]=p+Se[h-7]+g+Se[h-16]|0}let{A:o,B:r,C:a,D:c,E:i,F:l,G:u,H:f}=this;for(let h=0;h<64;h++){const m=ge(i,6)^ge(i,11)^ge(i,25),b=f+m+mi(i,l,u)+bi[h]+Se[h]|0,p=(ge(o,2)^ge(o,13)^ge(o,22))+gi(o,r,a)|0;f=u,u=l,l=i,i=c+b|0,c=a,a=r,r=o,o=b+p|0}o=o+this.A|0,r=r+this.B|0,a=a+this.C|0,c=c+this.D|0,i=i+this.E|0,l=l+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(o,r,a,c,i,l,u,f)}roundClean(){js(Se)}destroy(){this.set(0,0,0,0,0,0,0,0),js(this.buffer)}}const In=fi(()=>new yi),xi=In,Ai="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function vi(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=xi(t),n=ci.getPublicKey(s),o=new Uint8Array(64);return o.set(s,0),o.set(n,32),I.wipeBytes(s),{publicKey:n,secretKey:o}}function Dn(t){const s=vi(t),n=s.publicKey;return I.wipeBytes(s.secretKey),n}function _n(t){if(t.length!==32)throw new Error(`Invalid public key length: expected 32, got ${t.length}`);return ji(t)}function ji(t){let s=0;for(let r=0;r<t.length&&t[r]===0;r++)s++;let n=0n;for(let r=0;r<t.length;r++)n=n*256n+BigInt(t[r]);let o="";for(;n>0n;){const r=Number(n%58n);o=Ai[r]+o,n=n/58n}return"1".repeat(s)+o}const ki=2,Ni=3;function Un(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=ks(t),n=gn.share(s,Ni,ki);if(n.length!==3)throw new Error(`Unexpected share count: ${n.length}`);const o=Ht(n[0]),r=Ht(n[1]),a=Ht(n[2]);return{shareA:I.toShamirShare(o),shareB:I.toShamirShare(r),shareC:I.toShamirShare(a)}}function Ci(t,s,n){const o=Nr(t),r=Nr(s);try{const a=gn.combine([o,r]),c=Fn(a);if(c.length!==16)throw new Error(`Reconstructed seed has wrong length: ${c.length}`);return I.toSeed(c)}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 ks(t){return Array.from(t).map(s=>s.toString(16).padStart(2,"0")).join("")}function Fn(t){if(!/^[0-9a-fA-F]*$/.test(t))throw new Error("Invalid hex string: contains non-hex characters");if(t.length%2!==0)throw new Error(`Invalid hex string: length ${t.length} is odd (must be even)`);const s=new Uint8Array(t.length/2);for(let n=0;n<s.length;n++)s[n]=parseInt(t.substr(n*2,2),16);return s}function Ht(t){const s=t.length%2!==0,n=s?"0"+t:t,o=Fn(n),r=new Uint8Array(1+o.length);return r[0]=s?1:0,r.set(o,1),r}function Nr(t){const s=t[0];if(s===0||s===1){const o=s===1,r=t.subarray(1),a=ks(r),c=o?a.substring(1):a;if(/^[0-9a-f]/.test(c))return c}const n=ks(t);return n.startsWith("0")&&!n.startsWith("00")?n.substring(1):n}function bt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function On(t,s){return Array.isArray(s)?s.length===0?!0:t?s.every(n=>typeof n=="string"):s.every(n=>Number.isSafeInteger(n)):!1}function Si(t){if(typeof t!="function")throw new Error("function expected");return!0}function yt(t,s){if(typeof s!="string")throw new Error(`${t}: string expected`);return!0}function He(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function xt(t){if(!Array.isArray(t))throw new Error("array expected")}function At(t,s){if(!On(!0,s))throw new Error(`${t}: array of strings expected`)}function Wn(t,s){if(!On(!1,s))throw new Error(`${t}: array of numbers expected`)}function Ei(...t){const s=a=>a,n=(a,c)=>i=>a(c(i)),o=t.map(a=>a.encode).reduceRight(n,s),r=t.map(a=>a.decode).reduce(n,s);return{encode:o,decode:r}}function Li(t){const s=typeof t=="string"?t.split(""):t,n=s.length;At("alphabet",s);const o=new Map(s.map((r,a)=>[r,a]));return{encode:r=>(xt(r),r.map(a=>{if(!Number.isSafeInteger(a)||a<0||a>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${t}`);return s[a]})),decode:r=>(xt(r),r.map(a=>{yt("alphabet.decode",a);const c=o.get(a);if(c===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${t}`);return c}))}}function Pi(t=""){return yt("join",t),{encode:s=>(At("join.decode",s),s.join(t)),decode:s=>(yt("join.decode",s),s.split(t))}}function Bi(t,s="="){return He(t),yt("padding",s),{encode(n){for(At("padding.encode",n);n.length*t%8;)n.push(s);return n},decode(n){At("padding.decode",n);let o=n.length;if(o*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&n[o-1]===s;o--)if((o-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,o)}}}function Ns(t,s,n){if(s<2)throw new Error(`convertRadix: invalid from=${s}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(xt(t),!t.length)return[];let o=0;const r=[],a=Array.from(t,i=>{if(He(i),i<0||i>=s)throw new Error(`invalid integer: ${i}`);return i}),c=a.length;for(;;){let i=0,l=!0;for(let u=o;u<c;u++){const f=a[u],h=s*i,m=h+f;if(!Number.isSafeInteger(m)||h/s!==i||m-f!==h)throw new Error("convertRadix: carry overflow");const b=m/n;i=m%n;const g=Math.floor(b);if(a[u]=g,!Number.isSafeInteger(g)||g*n+i!==m)throw new Error("convertRadix: carry overflow");if(l)g?l=!1:o=u;else continue}if(r.push(i),l)break}for(let i=0;i<t.length-1&&t[i]===0;i++)r.push(0);return r.reverse()}const qn=(t,s)=>s===0?t:qn(s,t%s),vt=(t,s)=>t+(s-qn(t,s)),Vt=(()=>{let t=[];for(let s=0;s<40;s++)t.push(2**s);return t})();function Cs(t,s,n,o){if(xt(t),s<=0||s>32)throw new Error(`convertRadix2: wrong from=${s}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(vt(s,n)>32)throw new Error(`convertRadix2: carry overflow from=${s} to=${n} carryBits=${vt(s,n)}`);let r=0,a=0;const c=Vt[s],i=Vt[n]-1,l=[];for(const u of t){if(He(u),u>=c)throw new Error(`convertRadix2: invalid data word=${u} from=${s}`);if(r=r<<s|u,a+s>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${s}`);for(a+=s;a>=n;a-=n)l.push((r>>a-n&i)>>>0);const f=Vt[a];if(f===void 0)throw new Error("invalid carry");r&=f-1}if(r=r<<n-a&i,!o&&a>=s)throw new Error("Excess padding");if(!o&&r>0)throw new Error(`Non-zero padding: ${r}`);return o&&a>0&&l.push(r>>>0),l}function Mi(t){He(t);const s=2**8;return{encode:n=>{if(!bt(n))throw new Error("radix.encode input should be Uint8Array");return Ns(Array.from(n),s,t)},decode:n=>(Wn("radix.decode",n),Uint8Array.from(Ns(n,t,s)))}}function Ri(t,s=!1){if(He(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(vt(8,t)>32||vt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!bt(n))throw new Error("radix2.encode input should be Uint8Array");return Cs(Array.from(n),8,t,!s)},decode:n=>(Wn("radix2.decode",n),Uint8Array.from(Cs(n,t,8,s)))}}function Ti(t,s){return He(t),Si(s),{encode(n){if(!bt(n))throw new Error("checksum.encode: input should be Uint8Array");const o=s(n).slice(0,t),r=new Uint8Array(n.length+t);return r.set(n),r.set(o,n.length),r},decode(n){if(!bt(n))throw new Error("checksum.decode: input should be Uint8Array");const o=n.slice(0,-t),r=n.slice(-t),a=s(o).slice(0,t);for(let c=0;c<t;c++)if(a[c]!==r[c])throw new Error("Invalid checksum");return o}}}const it={alphabet:Li,chain:Ei,checksum:Ti,convertRadix:Ns,convertRadix2:Cs,radix:Mi,radix2:Ri,join:Pi,padding:Bi};const Ii=t=>t[0]==="あいこくしん";function Di(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function _i(t){const s=Di(t),n=s.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:s,words:n}}function zn(t){Ct(t,16,20,24,28,32)}const Ui=t=>{const s=8-t.length/4;return new Uint8Array([In(t)[0]>>s<<s])};function Hn(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return t.forEach(s=>{if(typeof s!="string")throw new Error("wordlist: non-string element: "+s)}),it.chain(it.checksum(1,Ui),it.radix2(11,!0),it.alphabet(t))}function Os(t,s){const{words:n}=_i(t),o=Hn(s).decode(n);return zn(o),o}function Vn(t,s){return zn(t),Hn(s).encode(t).join(Ii(s)?" ":" ")}function Ws(t,s){try{Os(t,s)}catch{return!1}return!0}const Ae=`abandon
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./useAuth-U5CYsHEU.cjs"),T=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),d=require("react"),z=require("./LoadingSpinner-d6sSxgQN.cjs"),Bs=require("./sanitization-Bo_tn-L2.cjs"),Q=require("./EmailRegisterForm-CNjYrqU6.cjs"),Te=require("./validation-BuGQrA-K.cjs"),X=require("./ErrorMessage-CHbYbVi2.cjs"),Ms=require("./GoogleLoginButton-JtRViYWS.cjs"),qe=require("./SolanaLoginButton-nSJHVFpZ.cjs"),ie=require("./PermissionsSection-DEMVp7X3.cjs"),fn=require("./useSystemSettings-B2jY51ob.cjs"),ze=require("./AutosaveStatus-BKsCIvPj.cjs"),Rs=require("./useOrgs-CNqfn-fk.cjs"),mt=require("./AdminDepositList-B_z6x3j5.cjs"),Pe=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),et=require("./useUsersStatsSummary-DgKaUIfs.cjs"),pn=require("./StatsBar-DTUZCwDD.cjs"),Be=require("./plugin-CUxpAjL-.cjs"),mn=require("./AuthenticationSettings-Dk1LX0CK.cjs"),gn=require("./EmbeddedWalletSettings-DGq-kXbw.cjs"),ut=require("./EmailSettings-eLlzzI5D.cjs"),Ts=require("./CreditSystemSettings-C2HkyMXy.cjs"),wn=require("./ServerSettings-CMmH5pZv.cjs"),ea=require("./useAdminDeposits-CpLd68oP.cjs"),Is=require("./WebhookSettings-0sgWRI3U.cjs");var Ut=typeof document<"u"?document.currentScript:null;let Me=null,ta=0;const Je=new Map;function sa(){return typeof Worker>"u"?null:(Me||(Me=new Worker(new URL(""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/assets/argon2Worker-Bi5TuQvD.js").href:new URL("assets/argon2Worker-Bi5TuQvD.js",document.currentScript&&document.currentScript.tagName.toUpperCase()==="SCRIPT"&&document.currentScript.src||document.baseURI).href),typeof document>"u"?require("url").pathToFileURL(__filename).href:Ut&&Ut.tagName.toUpperCase()==="SCRIPT"&&Ut.src||new URL("index.cjs",document.baseURI).href),{type:"module"}),Me.onmessage=t=>{const{id:s,key:n,error:o}=t.data,r=Je.get(s);if(r){if(Je.delete(s),o){r.reject(new Error(o));return}if(!n){r.reject(new Error("Argon2 worker returned no key"));return}r.resolve(n)}},Me.onerror=t=>{const s=t instanceof ErrorEvent?t.error:new Error("Argon2 worker error");for(const n of Je.values())n.reject(s instanceof Error?s:new Error(String(s)));Je.clear(),Me?.terminate(),Me=null}),Me)}async function bn(t,s,n=I.DEFAULT_KDF_PARAMS){I.validateKdfParams(n);const o=sa();return o?new Promise((r,a)=>{const c=ta++;Je.set(c,{resolve:r,reject:a});const i={id:c,password:t,salt:s,params:n};o.postMessage(i)}):I.argon2Derive(t,s,n)}function yn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ra(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var s=t.default;if(typeof s=="function"){var n=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(s,arguments,this.constructor):s.apply(this,arguments)};n.prototype=s.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach(function(o){var r=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return t[o]}})}),n}var ht={exports:{}};const na=globalThis.crypto,oa=globalThis.crypto,aa=globalThis.crypto.subtle,ia=globalThis.crypto.getRandomValues.bind(globalThis.crypto),ca=globalThis.crypto.randomUUID.bind(globalThis.crypto),la=Object.freeze(Object.defineProperty({__proto__:null,default:na,getRandomValues:ia,randomUUID:ca,subtle:aa,webcrypto:oa},Symbol.toStringTag,{value:"Module"})),da=ra(la);var ua=ht.exports,dr;function ha(){return dr||(dr=1,(function(t,s){(function(n,o){t.exports=o(da)})(ua,function(n){var o,r,a,c,i;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]},r={},a=new Array(1024).join("0"),c=!0,i=["nodeCryptoRandomBytes","browserCryptoGetRandomValues","testRandom"]}function u(){return!!(r&&r.rng&&typeof r.rng=="function")}function f(g,v){var A;if(v===0||v===1)return g;if(v&&v>1024)throw new Error("Padding must be multiples of no larger than 1024 bits.");return v=v||r.bits,g&&(A=g.length%v),A?(a+g).slice(-(v-A+g.length)):g}function h(g){var v="",A,y;for(y=g.length-1;y>=0;y--){if(A=parseInt(g[y],16),isNaN(A))throw new Error("Invalid hex character.");v=f(A.toString(2),4)+v}return v}function p(g){var v="",A,y;for(g=f(g,4),y=g.length;y>=4;y-=4){if(A=parseInt(g.slice(y-4,y),2),isNaN(A))throw new Error("Invalid binary character.");v=A.toString(16)+v}return v}function b(){return!!(n&&typeof n=="object"&&(typeof n.getRandomValues=="function"||typeof n.getRandomValues=="object")&&(typeof Uint32Array=="function"||typeof Uint32Array=="object"))}function w(){return typeof n=="object"&&typeof n.randomBytes=="function"}function m(g){function v(E,B,L,M){var R=0,U,F="",q;for(B&&(U=B.length-1);R<U||F.length<E;)q=Math.abs(parseInt(B[R],L)),F=F+f(q.toString(2),M),R++;return F=F.substr(-E),(F.match(/0/g)||[]).length===F.length?null:F}function A(E){var B,L,M,R,U=null;for(M=16,R=4,L=Math.ceil(E/8);U===null;)B=n.randomBytes(L),U=v(E,B.toString("hex"),M,R);return U}function y(E){var B,L,M,R=null;for(L=10,M=32,B=Math.ceil(E/32);R===null;)R=v(E,n.getRandomValues(new Uint32Array(B)),L,M);return R}function S(E){var B,L,M,R,U,F=null;R=10,U=32,L=Math.ceil(E/32),M=123456789,B=new Uint32Array(L);for(var q=0;q<B.length;q++)B[q]=M;for(;F===null;)F=v(E,B,R,U);return F}if(g&&g==="testRandom")return r.typeCSPRNG=g,S;if(g&&g==="nodeCryptoRandomBytes")return r.typeCSPRNG=g,A;if(g&&g==="browserCryptoGetRandomValues")return r.typeCSPRNG=g,y;if(w())return r.typeCSPRNG="nodeCryptoRandomBytes",A;if(b())return r.typeCSPRNG="browserCryptoGetRandomValues",y}function k(g,v){var A=[],y;for(v&&(g=f(g,v)),y=g.length;y>r.bits;y-=r.bits)A.push(parseInt(g.slice(y-r.bits,y),2));return A.push(parseInt(g.slice(0,y),2)),A}function x(g,v){var A=r.logs[g],y=0,S;for(S=v.length-1;S>=0;S--)y!==0?y=r.exps[(A+r.logs[y])%r.maxShares]^v[S]:y=v[S];return y}function N(g,v,A){var y=0,S,E,B,L;for(B=0,S=v.length;B<S;B++)if(A[B]){for(E=r.logs[A[B]],L=0;L<S;L++)if(B!==L){if(g===v[L]){E=-1;break}E=(E+r.logs[g^v[L]]-r.logs[v[B]^v[L]]+r.maxShares)%r.maxShares}y=E===-1?y:y^r.exps[E]}return y}function j(g,v,A){var y=[],S=[g],E,B;for(E=1;E<A;E++)S[E]=parseInt(r.rng(r.bits),2);for(E=1,B=v+1;E<B;E++)y[E-1]={x:E,y:x(E,S)};return y}function C(g,v,A){var y,S,E,B,L;if(v=parseInt(v,r.radix),g=parseInt(g,10)||r.bits,y=g.toString(36).toUpperCase(),E=Math.pow(2,g)-1,B=E.toString(r.radix).length,S=f(v.toString(r.radix),B),typeof v!="number"||v%1!==0||v<1||v>E)throw new Error("Share id must be an integer between 1 and "+E+", inclusive.");return L=y+S+A,L}var P={init:function(g,v){var A=[],y=[],S=1,E,B;if(l(),g&&(typeof g!="number"||g%1!==0||g<o.minBits||g>o.maxBits))throw new Error("Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(v&&i.indexOf(v)===-1)throw new Error("Invalid RNG type argument : '"+v+"'");for(r.radix=o.radix,r.bits=g||o.bits,r.size=Math.pow(2,r.bits),r.maxShares=r.size-1,E=o.primitivePolynomials[r.bits],B=0;B<r.size;B++)y[B]=S,A[S]=B,S=S<<1,S>=r.size&&(S=S^E,S=S&r.maxShares);if(r.logs=A,r.exps=y,v&&this.setRNG(v),u()||this.setRNG(),!u()||!r.bits||!r.size||!r.maxShares||!r.logs||!r.exps||r.logs.length!==r.size||r.exps.length!==r.size)throw new Error("Initialization failed.")},combine:function(g,v){var A,y,S,E,B="",L,M,R,U=[],F=[];for(v=v||0,A=0,S=g.length;A<S;A++){if(M=this.extractShareComponents(g[A]),L===void 0)L=M.bits;else if(M.bits!==L)throw new Error("Mismatched shares: Different bit settings.");if(r.bits!==L&&this.init(L),U.indexOf(M.id)===-1)for(U.push(M.id),R=k(h(M.data)),y=0,E=R.length;y<E;y++)F[y]=F[y]||[],F[y][U.length-1]=R[y]}for(A=0,S=F.length;A<S;A++)B=f(N(v,U,F[A]).toString(2))+B;return p(v>=1?B:B.slice(B.indexOf("1")+1))},getConfig:function(){var g={};return g.radix=r.radix,g.bits=r.bits,g.maxShares=r.maxShares,g.hasCSPRNG=u(),g.typeCSPRNG=r.typeCSPRNG,g},extractShareComponents:function(g){var v,A,y,S,E={},B,L;if(v=parseInt(g.substr(0,1),36),v&&(typeof v!="number"||v%1!==0||v<o.minBits||v>o.maxBits))throw new Error("Invalid share : Number of bits must be an integer between "+o.minBits+" and "+o.maxBits+", inclusive.");if(S=Math.pow(2,v)-1,y=(Math.pow(2,v)-1).toString(r.radix).length,B="^([a-kA-K3-9]{1})([a-fA-F0-9]{"+y+"})([a-fA-F0-9]+)$",L=new RegExp(B).exec(g),L&&(A=parseInt(L[2],r.radix)),typeof A!="number"||A%1!==0||A<1||A>S)throw new Error("Invalid share : Share id must be an integer between 1 and "+r.maxShares+", inclusive.");if(L&&L[3])return E.bits=v,E.id=A,E.data=L[3],E;throw new Error("The share data provided is invalid : "+g)},setRNG:function(g){var v="Random number generator is invalid ",A=" Supply an CSPRNG of the form function(bits){} that returns a string containing 'bits' number of random 1's and 0's.";if(g&&typeof g=="string"&&i.indexOf(g)===-1)throw new Error("Invalid RNG type argument : '"+g+"'");if(g||(g=m()),g&&typeof g=="string"&&(g=m(g)),c){if(g&&typeof g!="function")throw new Error(v+"(Not a function)."+A);if(g&&typeof g(r.bits)!="string")throw new Error(v+"(Output is not a string)."+A);if(g&&!parseInt(g(r.bits),2))throw new Error(v+"(Binary string output not parseable to an Integer)."+A);if(g&&g(r.bits).length>r.bits)throw new Error(v+"(Output length is greater than config.bits)."+A);if(g&&g(r.bits).length<r.bits)throw new Error(v+"(Output length is less than config.bits)."+A)}return r.rng=g,!0},str2hex:function(g,v){var A,y,S="",E,B,L,M;if(typeof g!="string")throw new Error("Input must be a character string.");if(v||(v=o.bytesPerChar),typeof v!="number"||v<1||v>o.maxBytesPerChar||v%1!==0)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(A=2*v,y=Math.pow(16,A)-1,L=0,M=g.length;L<M;L++){if(B=g[L].charCodeAt(),isNaN(B))throw new Error("Invalid character: "+g[L]);if(B>y)throw E=Math.ceil(Math.log(B+1)/Math.log(256)),new Error("Invalid character code ("+B+"). Maximum allowable is 256^bytes-1 ("+y+"). To convert this character, use at least "+E+" bytes.");S=f(B.toString(16),A)+S}return S},hex2str:function(g,v){var A,y="",S,E;if(typeof g!="string")throw new Error("Input must be a hexadecimal string.");if(v=v||o.bytesPerChar,typeof v!="number"||v%1!==0||v<1||v>o.maxBytesPerChar)throw new Error("Bytes per character must be an integer between 1 and "+o.maxBytesPerChar+", inclusive.");for(A=2*v,g=f(g,A),S=0,E=g.length;S<E;S+=A)y=String.fromCharCode(parseInt(g.slice(S,S+A),16))+y;return y},random:function(g){if(typeof g!="number"||g%1!==0||g<2||g>65536)throw new Error("Number of bits must be an Integer between 1 and 65536.");return p(r.rng(g))},share:function(g,v,A,y){var S,E,B=new Array(v),L=new Array(v),M,R,U;if(y=y||128,typeof g!="string")throw new Error("Secret must be a string.");if(typeof v!="number"||v%1!==0||v<2)throw new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(v>r.maxShares)throw S=Math.ceil(Math.log(v+1)/Math.LN2),new Error("Number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To create "+v+" shares, use at least "+S+" bits.");if(typeof A!="number"||A%1!==0||A<2)throw new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive.");if(A>r.maxShares)throw S=Math.ceil(Math.log(A+1)/Math.LN2),new Error("Threshold number of shares must be an integer between 2 and 2^bits-1 ("+r.maxShares+"), inclusive. To use a threshold of "+A+", use at least "+S+" bits.");if(A>v)throw new Error("Threshold number of shares was "+A+" but must be less than or equal to the "+v+" shares specified as the total to generate.");if(typeof y!="number"||y%1!==0||y<0||y>1024)throw new Error("Zero-pad length must be an integer between 0 and 1024 inclusive.");for(g="1"+h(g),g=k(g,y),M=0,U=g.length;M<U;M++)for(E=j(g[M],v,A),R=0;R<v;R++)B[R]=B[R]||E[R].x.toString(r.radix),L[R]=f(E[R].y.toString(2))+(L[R]||"");for(M=0;M<v;M++)B[M]=C(r.bits,B[M],p(L[M]));return B},newShare:function(g,v){var A,y;if(g&&typeof g=="string"&&(g=parseInt(g,r.radix)),y=g.toString(r.radix),g&&y&&v&&v[0])return A=this.extractShareComponents(v[0]),C(A.bits,y,this.combine(v,g));throw new Error("Invalid 'id' or 'shares' Array argument to newShare().")},_reset:l,_padLeft:f,_hex2bin:h,_bin2hex:p,_hasCryptoGetRandomValues:b,_hasCryptoRandomBytes:w,_getRNG:m,_isSetRNG:u,_splitNumStringToIntArray:k,_horner:x,_lagrange:N,_getShares:j,_constructPublicShareString:C};return P.init(),P})})(ht)),ht.exports}var fa=ha();const xn=yn(fa);function An(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ds(t,s=""){if(!Number.isSafeInteger(t)||t<0){const n=s&&`"${s}" `;throw new Error(`${n}expected integer >= 0, got ${t}`)}}function se(t,s,n=""){const o=An(t),r=t?.length,a=s!==void 0;if(!o||a&&r!==s){const c=n&&`"${n}" `,i=a?` of length ${s}`:"",l=o?`length=${r}`:`type=${typeof t}`;throw new Error(c+"expected Uint8Array"+i+", got "+l)}return t}function ur(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function pa(t,s){se(t,void 0,"digestInto() output");const n=s.outputLen;if(t.length<n)throw new Error('"digestInto() output" expected to be of length >='+n)}function As(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function Ft(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const vn=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ma=Array.from({length:256},(t,s)=>s.toString(16).padStart(2,"0"));function _s(t){if(se(t),vn)return t.toHex();let s="";for(let n=0;n<t.length;n++)s+=ma[t[n]];return s}const ye={_0:48,_9:57,A:65,F:70,a:97,f:102};function hr(t){if(t>=ye._0&&t<=ye._9)return t-ye._0;if(t>=ye.A&&t<=ye.F)return t-(ye.A-10);if(t>=ye.a&&t<=ye.f)return t-(ye.a-10)}function jn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(vn)return Uint8Array.fromHex(t);const s=t.length,n=s/2;if(s%2)throw new Error("hex string expected, got unpadded hex of length "+s);const o=new Uint8Array(n);for(let r=0,a=0;r<n;r++,a+=2){const c=hr(t.charCodeAt(a)),i=hr(t.charCodeAt(a+1));if(c===void 0||i===void 0){const l=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+a)}o[r]=c*16+i}return o}function fr(...t){let s=0;for(let o=0;o<t.length;o++){const r=t[o];se(r),s+=r.length}const n=new Uint8Array(s);for(let o=0,r=0;o<t.length;o++){const a=t[o];n.set(a,r),r+=a.length}return n}function ga(t,s={}){const n=(r,a)=>t(a).update(r).digest(),o=t(void 0);return n.outputLen=o.outputLen,n.blockLen=o.blockLen,n.create=r=>t(r),Object.assign(n,s),Object.freeze(n)}function wa(t=32){const s=typeof globalThis=="object"?globalThis.crypto:null;if(typeof s?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return s.getRandomValues(new Uint8Array(t))}const ba=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});let ya=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(s,n,o,r){this.blockLen=s,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(s),this.view=Ft(this.buffer)}update(s){ur(this),se(s);const{view:n,buffer:o,blockLen:r}=this,a=s.length;for(let c=0;c<a;){const i=Math.min(r-this.pos,a-c);if(i===r){const l=Ft(s);for(;r<=a-c;c+=r)this.process(l,c);continue}o.set(s.subarray(c,c+i),this.pos),this.pos+=i,c+=i,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){ur(this),pa(s,this),this.finished=!0;const{buffer:n,view:o,blockLen:r,isLE:a}=this;let{pos:c}=this;n[c++]=128,As(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(o,0),c=0);for(let h=c;h<r;h++)n[h]=0;o.setBigUint64(r-8,BigInt(this.length*8),a),this.process(o,0);const i=Ft(s),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)i.setUint32(4*h,f[h],a)}digest(){const{buffer:s,outputLen:n}=this;this.digestInto(s);const o=s.slice(0,n);return this.destroy(),o}_cloneInto(s){s||=new this.constructor,s.set(...this.get());const{blockLen:n,buffer:o,length:r,finished:a,destroyed:c,pos:i}=this;return s.destroyed=c,s.finished=a,s.length=r,s.pos=i,r%n&&s.buffer.set(o),s}clone(){return this._cloneInto()}};const re=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),nt=BigInt(2**32-1),pr=BigInt(32);function xa(t,s=!1){return s?{h:Number(t&nt),l:Number(t>>pr&nt)}:{h:Number(t>>pr&nt)|0,l:Number(t&nt)|0}}function Aa(t,s=!1){const n=t.length;let o=new Uint32Array(n),r=new Uint32Array(n);for(let a=0;a<n;a++){const{h:c,l:i}=xa(t[a],s);[o[a],r[a]]=[c,i]}return[o,r]}const mr=(t,s,n)=>t>>>n,gr=(t,s,n)=>t<<32-n|s>>>n,Ue=(t,s,n)=>t>>>n|s<<32-n,Fe=(t,s,n)=>t<<32-n|s>>>n,ot=(t,s,n)=>t<<64-n|s>>>n-32,at=(t,s,n)=>t>>>n-32|s<<64-n;function xe(t,s,n,o){const r=(s>>>0)+(o>>>0);return{h:t+n+(r/2**32|0)|0,l:r|0}}const va=(t,s,n)=>(t>>>0)+(s>>>0)+(n>>>0),ja=(t,s,n,o)=>s+n+o+(t/2**32|0)|0,ka=(t,s,n,o)=>(t>>>0)+(s>>>0)+(n>>>0)+(o>>>0),Na=(t,s,n,o,r)=>s+n+o+r+(t/2**32|0)|0,Ca=(t,s,n,o,r)=>(t>>>0)+(s>>>0)+(n>>>0)+(o>>>0)+(r>>>0),Sa=(t,s,n,o,r,a)=>s+n+o+r+a+(t/2**32|0)|0,kn=Aa(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),Ea=kn[0],La=kn[1],ke=new Uint32Array(80),Ne=new Uint32Array(80);class Pa extends ya{constructor(s){super(128,s,16,!1)}get(){const{Ah:s,Al:n,Bh:o,Bl:r,Ch:a,Cl:c,Dh:i,Dl:l,Eh:u,El:f,Fh:h,Fl:p,Gh:b,Gl:w,Hh:m,Hl:k}=this;return[s,n,o,r,a,c,i,l,u,f,h,p,b,w,m,k]}set(s,n,o,r,a,c,i,l,u,f,h,p,b,w,m,k){this.Ah=s|0,this.Al=n|0,this.Bh=o|0,this.Bl=r|0,this.Ch=a|0,this.Cl=c|0,this.Dh=i|0,this.Dl=l|0,this.Eh=u|0,this.El=f|0,this.Fh=h|0,this.Fl=p|0,this.Gh=b|0,this.Gl=w|0,this.Hh=m|0,this.Hl=k|0}process(s,n){for(let j=0;j<16;j++,n+=4)ke[j]=s.getUint32(n),Ne[j]=s.getUint32(n+=4);for(let j=16;j<80;j++){const C=ke[j-15]|0,P=Ne[j-15]|0,g=Ue(C,P,1)^Ue(C,P,8)^mr(C,P,7),v=Fe(C,P,1)^Fe(C,P,8)^gr(C,P,7),A=ke[j-2]|0,y=Ne[j-2]|0,S=Ue(A,y,19)^ot(A,y,61)^mr(A,y,6),E=Fe(A,y,19)^at(A,y,61)^gr(A,y,6),B=ka(v,E,Ne[j-7],Ne[j-16]),L=Na(B,g,S,ke[j-7],ke[j-16]);ke[j]=L|0,Ne[j]=B|0}let{Ah:o,Al:r,Bh:a,Bl:c,Ch:i,Cl:l,Dh:u,Dl:f,Eh:h,El:p,Fh:b,Fl:w,Gh:m,Gl:k,Hh:x,Hl:N}=this;for(let j=0;j<80;j++){const C=Ue(h,p,14)^Ue(h,p,18)^ot(h,p,41),P=Fe(h,p,14)^Fe(h,p,18)^at(h,p,41),g=h&b^~h&m,v=p&w^~p&k,A=Ca(N,P,v,La[j],Ne[j]),y=Sa(A,x,C,g,Ea[j],ke[j]),S=A|0,E=Ue(o,r,28)^ot(o,r,34)^ot(o,r,39),B=Fe(o,r,28)^at(o,r,34)^at(o,r,39),L=o&a^o&i^a&i,M=r&c^r&l^c&l;x=m|0,N=k|0,m=b|0,k=w|0,b=h|0,w=p|0,{h,l:p}=xe(u|0,f|0,y|0,S|0),u=i|0,f=l|0,i=a|0,l=c|0,a=o|0,c=r|0;const R=va(S,B,M);o=ja(R,y,E,L),r=R|0}({h:o,l:r}=xe(this.Ah|0,this.Al|0,o|0,r|0)),{h:a,l:c}=xe(this.Bh|0,this.Bl|0,a|0,c|0),{h:i,l}=xe(this.Ch|0,this.Cl|0,i|0,l|0),{h:u,l:f}=xe(this.Dh|0,this.Dl|0,u|0,f|0),{h,l:p}=xe(this.Eh|0,this.El|0,h|0,p|0),{h:b,l:w}=xe(this.Fh|0,this.Fl|0,b|0,w|0),{h:m,l:k}=xe(this.Gh|0,this.Gl|0,m|0,k|0),{h:x,l:N}=xe(this.Hh|0,this.Hl|0,x|0,N|0),this.set(o,r,a,c,i,l,u,f,h,p,b,w,m,k,x,N)}roundClean(){As(ke,Ne)}destroy(){As(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ba extends Pa{Ah=re[0]|0;Al=re[1]|0;Bh=re[2]|0;Bl=re[3]|0;Ch=re[4]|0;Cl=re[5]|0;Dh=re[6]|0;Dl=re[7]|0;Eh=re[8]|0;El=re[9]|0;Fh=re[10]|0;Fl=re[11]|0;Gh=re[12]|0;Gl=re[13]|0;Hh=re[14]|0;Hl=re[15]|0;constructor(){super(64)}}const Ma=ga(()=>new Ba,ba(3));const Nn=BigInt(0),wr=BigInt(1);function vs(t,s=""){if(typeof t!="boolean"){const n=s&&`"${s}" `;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function Ra(t){if(typeof t=="bigint"){if(!ft(t))throw new Error("positive bigint expected, got "+t)}else Ds(t);return t}function Cn(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Nn:BigInt("0x"+t)}function Ta(t){return Cn(_s(t))}function gt(t){return Cn(_s(js(se(t)).reverse()))}function Sn(t,s){Ds(s),t=Ra(t);const n=jn(t.toString(16).padStart(s*2,"0"));if(n.length!==s)throw new Error("number too large");return n}function Ia(t,s){return Sn(t,s).reverse()}function js(t){return Uint8Array.from(t)}const ft=t=>typeof t=="bigint"&&Nn<=t;function Da(t,s,n){return ft(t)&&ft(s)&&ft(n)&&s<=t&&t<n}function br(t,s,n,o){if(!Da(s,n,o))throw new Error("expected valid "+t+": "+n+" <= n < "+o+", got "+s)}const _a=t=>(wr<<BigInt(t))-wr;function Us(t,s={},n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function o(a,c,i){const l=t[a];if(i&&l===void 0)return;const u=typeof l;if(u!==c||l===null)throw new Error(`param "${a}" is invalid: expected ${c}, got ${u}`)}const r=(a,c)=>Object.entries(a).forEach(([i,l])=>o(i,l,c));r(s,!1),r(n,!0)}function yr(t){const s=new WeakMap;return(n,...o)=>{const r=s.get(n);if(r!==void 0)return r;const a=t(n,...o);return s.set(n,a),a}}const ce=BigInt(0),ae=BigInt(1),Re=BigInt(2),En=BigInt(3),Ln=BigInt(4),Pn=BigInt(5),Ua=BigInt(7),Bn=BigInt(8),Fa=BigInt(9),Mn=BigInt(16);function ee(t,s){const n=t%s;return n>=ce?n:s+n}function me(t,s,n){let o=t;for(;s-- >ce;)o*=o,o%=n;return o}function xr(t,s){if(t===ce)throw new Error("invert: expected non-zero number");if(s<=ce)throw new Error("invert: expected positive modulus, got "+s);let n=ee(t,s),o=s,r=ce,a=ae;for(;n!==ce;){const i=o/n,l=o%n,u=r-a*i;o=n,n=l,r=a,a=u}if(o!==ae)throw new Error("invert: does not exist");return ee(r,s)}function Fs(t,s,n){if(!t.eql(t.sqr(s),n))throw new Error("Cannot find square root")}function Rn(t,s){const n=(t.ORDER+ae)/Ln,o=t.pow(s,n);return Fs(t,o,s),o}function Oa(t,s){const n=(t.ORDER-Pn)/Bn,o=t.mul(s,Re),r=t.pow(o,n),a=t.mul(s,r),c=t.mul(t.mul(a,Re),r),i=t.mul(a,t.sub(c,t.ONE));return Fs(t,i,s),i}function Wa(t){const s=Os(t),n=Tn(t),o=n(s,s.neg(s.ONE)),r=n(s,o),a=n(s,s.neg(o)),c=(t+Ua)/Mn;return(i,l)=>{let u=i.pow(l,c),f=i.mul(u,o);const h=i.mul(u,r),p=i.mul(u,a),b=i.eql(i.sqr(f),l),w=i.eql(i.sqr(h),l);u=i.cmov(u,f,b),f=i.cmov(p,h,w);const m=i.eql(i.sqr(f),l),k=i.cmov(u,f,m);return Fs(i,k,l),k}}function Tn(t){if(t<En)throw new Error("sqrt is not defined for small field");let s=t-ae,n=0;for(;s%Re===ce;)s/=Re,n++;let o=Re;const r=Os(t);for(;Ar(r,o)===1;)if(o++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Rn;let a=r.pow(o,s);const c=(s+ae)/Re;return function(l,u){if(l.is0(u))return u;if(Ar(l,u)!==1)throw new Error("Cannot find square root");let f=n,h=l.mul(l.ONE,a),p=l.pow(u,s),b=l.pow(u,c);for(;!l.eql(p,l.ONE);){if(l.is0(p))return l.ZERO;let w=1,m=l.sqr(p);for(;!l.eql(m,l.ONE);)if(w++,m=l.sqr(m),w===f)throw new Error("Cannot find square root");const k=ae<<BigInt(f-w-1),x=l.pow(h,k);f=w,h=l.sqr(x),p=l.mul(p,h),b=l.mul(b,x)}return b}}function qa(t){return t%Ln===En?Rn:t%Bn===Pn?Oa:t%Mn===Fa?Wa(t):Tn(t)}const za=(t,s)=>(ee(t,s)&ae)===ae,Ha=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Va(t){const s={ORDER:"bigint",BYTES:"number",BITS:"number"},n=Ha.reduce((o,r)=>(o[r]="function",o),s);return Us(t,n),t}function $a(t,s,n){if(n<ce)throw new Error("invalid exponent, negatives unsupported");if(n===ce)return t.ONE;if(n===ae)return s;let o=t.ONE,r=s;for(;n>ce;)n&ae&&(o=t.mul(o,r)),r=t.sqr(r),n>>=ae;return o}function In(t,s,n=!1){const o=new Array(s.length).fill(n?t.ZERO:void 0),r=s.reduce((c,i,l)=>t.is0(i)?c:(o[l]=c,t.mul(c,i)),t.ONE),a=t.inv(r);return s.reduceRight((c,i,l)=>t.is0(i)?c:(o[l]=t.mul(c,o[l]),t.mul(c,i)),a),o}function Ar(t,s){const n=(t.ORDER-ae)/Re,o=t.pow(s,n),r=t.eql(o,t.ONE),a=t.eql(o,t.ZERO),c=t.eql(o,t.neg(t.ONE));if(!r&&!a&&!c)throw new Error("invalid Legendre symbol result");return r?1:a?0:-1}function Ga(t,s){s!==void 0&&Ds(s);const n=s!==void 0?s:t.toString(2).length,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}class Qa{ORDER;BITS;BYTES;isLE;ZERO=ce;ONE=ae;_lengths;_sqrt;_mod;constructor(s,n={}){if(s<=ce)throw new Error("invalid field: expected ORDER > 0, got "+s);let o;this.isLE=!1,n!=null&&typeof n=="object"&&(typeof n.BITS=="number"&&(o=n.BITS),typeof n.sqrt=="function"&&(this.sqrt=n.sqrt),typeof n.isLE=="boolean"&&(this.isLE=n.isLE),n.allowedLengths&&(this._lengths=n.allowedLengths?.slice()),typeof n.modFromBytes=="boolean"&&(this._mod=n.modFromBytes));const{nBitLength:r,nByteLength:a}=Ga(s,o);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=s,this.BITS=r,this.BYTES=a,this._sqrt=void 0,Object.preventExtensions(this)}create(s){return ee(s,this.ORDER)}isValid(s){if(typeof s!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof s);return ce<=s&&s<this.ORDER}is0(s){return s===ce}isValidNot0(s){return!this.is0(s)&&this.isValid(s)}isOdd(s){return(s&ae)===ae}neg(s){return ee(-s,this.ORDER)}eql(s,n){return s===n}sqr(s){return ee(s*s,this.ORDER)}add(s,n){return ee(s+n,this.ORDER)}sub(s,n){return ee(s-n,this.ORDER)}mul(s,n){return ee(s*n,this.ORDER)}pow(s,n){return $a(this,s,n)}div(s,n){return ee(s*xr(n,this.ORDER),this.ORDER)}sqrN(s){return s*s}addN(s,n){return s+n}subN(s,n){return s-n}mulN(s,n){return s*n}inv(s){return xr(s,this.ORDER)}sqrt(s){return this._sqrt||(this._sqrt=qa(this.ORDER)),this._sqrt(this,s)}toBytes(s){return this.isLE?Ia(s,this.BYTES):Sn(s,this.BYTES)}fromBytes(s,n=!1){se(s);const{_lengths:o,BYTES:r,isLE:a,ORDER:c,_mod:i}=this;if(o){if(!o.includes(s.length)||s.length>r)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+s.length);const u=new Uint8Array(r);u.set(s,a?0:u.length-s.length),s=u}if(s.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+s.length);let l=a?gt(s):Ta(s);if(i&&(l=ee(l,c)),!n&&!this.isValid(l))throw new Error("invalid field element: outside of range 0..ORDER");return l}invertBatch(s){return In(this,s)}cmov(s,n,o){return o?n:s}}function Os(t,s={}){return new Qa(t,s)}const wt=BigInt(0),ks=BigInt(1);function vr(t,s){const n=s.negate();return t?n:s}function Ot(t,s){const n=In(t.Fp,s.map(o=>o.Z));return s.map((o,r)=>t.fromAffine(o.toAffine(n[r])))}function Dn(t,s){if(!Number.isSafeInteger(t)||t<=0||t>s)throw new Error("invalid window size, expected [1.."+s+"], got W="+t)}function Wt(t,s){Dn(t,s);const n=Math.ceil(s/t)+1,o=2**(t-1),r=2**t,a=_a(t),c=BigInt(t);return{windows:n,windowSize:o,mask:a,maxNumber:r,shiftBy:c}}function jr(t,s,n){const{windowSize:o,mask:r,maxNumber:a,shiftBy:c}=n;let i=Number(t&r),l=t>>c;i>o&&(i-=a,l+=ks);const u=s*o,f=u+Math.abs(i)-1,h=i===0,p=i<0,b=s%2!==0;return{nextN:l,offset:f,isZero:h,isNeg:p,isNegF:b,offsetF:u}}const qt=new WeakMap,_n=new WeakMap;function zt(t){return _n.get(t)||1}function kr(t){if(t!==wt)throw new Error("invalid wNAF")}class Ka{BASE;ZERO;Fn;bits;constructor(s,n){this.BASE=s.BASE,this.ZERO=s.ZERO,this.Fn=s.Fn,this.bits=n}_unsafeLadder(s,n,o=this.ZERO){let r=s;for(;n>wt;)n&ks&&(o=o.add(r)),r=r.double(),n>>=ks;return o}precomputeWindow(s,n){const{windows:o,windowSize:r}=Wt(n,this.bits),a=[];let c=s,i=c;for(let l=0;l<o;l++){i=c,a.push(i);for(let u=1;u<r;u++)i=i.add(c),a.push(i);c=i.double()}return a}wNAF(s,n,o){if(!this.Fn.isValid(o))throw new Error("invalid scalar");let r=this.ZERO,a=this.BASE;const c=Wt(s,this.bits);for(let i=0;i<c.windows;i++){const{nextN:l,offset:u,isZero:f,isNeg:h,isNegF:p,offsetF:b}=jr(o,i,c);o=l,f?a=a.add(vr(p,n[b])):r=r.add(vr(h,n[u]))}return kr(o),{p:r,f:a}}wNAFUnsafe(s,n,o,r=this.ZERO){const a=Wt(s,this.bits);for(let c=0;c<a.windows&&o!==wt;c++){const{nextN:i,offset:l,isZero:u,isNeg:f}=jr(o,c,a);if(o=i,!u){const h=n[l];r=r.add(f?h.negate():h)}}return kr(o),r}getPrecomputes(s,n,o){let r=qt.get(n);return r||(r=this.precomputeWindow(n,s),s!==1&&(typeof o=="function"&&(r=o(r)),qt.set(n,r))),r}cached(s,n,o){const r=zt(s);return this.wNAF(r,this.getPrecomputes(r,s,o),n)}unsafe(s,n,o,r){const a=zt(s);return a===1?this._unsafeLadder(s,n,r):this.wNAFUnsafe(a,this.getPrecomputes(a,s,o),n,r)}createCache(s,n){Dn(n,this.bits),_n.set(s,n),qt.delete(s)}hasCache(s){return zt(s)!==1}}function Nr(t,s,n){if(s){if(s.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Va(s),s}else return Os(t,{isLE:n})}function Ya(t,s,n={},o){if(o===void 0&&(o=t==="edwards"),!s||typeof s!="object")throw new Error(`expected valid ${t} CURVE object`);for(const l of["p","n","h"]){const u=s[l];if(!(typeof u=="bigint"&&u>wt))throw new Error(`CURVE.${l} must be positive bigint`)}const r=Nr(s.p,n.Fp,o),a=Nr(s.n,n.Fn,o),i=["Gx","Gy","a","d"];for(const l of i)if(!r.isValid(s[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return s=Object.freeze(Object.assign({},s)),{CURVE:s,Fp:r,Fn:a}}function Za(t,s){return function(o){const r=t(o);return{secretKey:r,publicKey:s(r)}}}const Ce=BigInt(0),te=BigInt(1),Ht=BigInt(2),Xa=BigInt(8);function Ja(t,s,n,o){const r=t.sqr(n),a=t.sqr(o),c=t.add(t.mul(s.a,r),a),i=t.add(t.ONE,t.mul(s.d,t.mul(r,a)));return t.eql(c,i)}function ei(t,s={}){const n=Ya("edwards",t,s,s.FpFnLE),{Fp:o,Fn:r}=n;let a=n.CURVE;const{h:c}=a;Us(s,{},{uvRatio:"function"});const i=Ht<<BigInt(r.BYTES*8)-te,l=k=>o.create(k),u=s.uvRatio||((k,x)=>{try{return{isValid:!0,value:o.sqrt(o.div(k,x))}}catch{return{isValid:!1,value:Ce}}});if(!Ja(o,a,a.Gx,a.Gy))throw new Error("bad curve params: generator point");function f(k,x,N=!1){const j=N?te:Ce;return br("coordinate "+k,x,j,i),x}function h(k){if(!(k instanceof w))throw new Error("EdwardsPoint expected")}const p=yr((k,x)=>{const{X:N,Y:j,Z:C}=k,P=k.is0();x==null&&(x=P?Xa:o.inv(C));const g=l(N*x),v=l(j*x),A=o.mul(C,x);if(P)return{x:Ce,y:te};if(A!==te)throw new Error("invZ was invalid");return{x:g,y:v}}),b=yr(k=>{const{a:x,d:N}=a;if(k.is0())throw new Error("bad point: ZERO");const{X:j,Y:C,Z:P,T:g}=k,v=l(j*j),A=l(C*C),y=l(P*P),S=l(y*y),E=l(v*x),B=l(y*l(E+A)),L=l(S+l(N*l(v*A)));if(B!==L)throw new Error("bad point: equation left != right (1)");const M=l(j*C),R=l(P*g);if(M!==R)throw new Error("bad point: equation left != right (2)");return!0});class w{static BASE=new w(a.Gx,a.Gy,te,l(a.Gx*a.Gy));static ZERO=new w(Ce,te,te,Ce);static Fp=o;static Fn=r;X;Y;Z;T;constructor(x,N,j,C){this.X=f("x",x),this.Y=f("y",N),this.Z=f("z",j,!0),this.T=f("t",C),Object.freeze(this)}static CURVE(){return a}static fromAffine(x){if(x instanceof w)throw new Error("extended point not allowed");const{x:N,y:j}=x||{};return f("x",N),f("y",j),new w(N,j,te,l(N*j))}static fromBytes(x,N=!1){const j=o.BYTES,{a:C,d:P}=a;x=js(se(x,j,"point")),vs(N,"zip215");const g=js(x),v=x[j-1];g[j-1]=v&-129;const A=gt(g),y=N?i:o.ORDER;br("point.y",A,Ce,y);const S=l(A*A),E=l(S-te),B=l(P*S-C);let{isValid:L,value:M}=u(E,B);if(!L)throw new Error("bad point: invalid y coordinate");const R=(M&te)===te,U=(v&128)!==0;if(!N&&M===Ce&&U)throw new Error("bad point: x=0 and x_0=1");return U!==R&&(M=l(-M)),w.fromAffine({x:M,y:A})}static fromHex(x,N=!1){return w.fromBytes(jn(x),N)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,N=!0){return m.createCache(this,x),N||this.multiply(Ht),this}assertValidity(){b(this)}equals(x){h(x);const{X:N,Y:j,Z:C}=this,{X:P,Y:g,Z:v}=x,A=l(N*v),y=l(P*C),S=l(j*v),E=l(g*C);return A===y&&S===E}is0(){return this.equals(w.ZERO)}negate(){return new w(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:x}=a,{X:N,Y:j,Z:C}=this,P=l(N*N),g=l(j*j),v=l(Ht*l(C*C)),A=l(x*P),y=N+j,S=l(l(y*y)-P-g),E=A+g,B=E-v,L=A-g,M=l(S*B),R=l(E*L),U=l(S*L),F=l(B*E);return new w(M,R,F,U)}add(x){h(x);const{a:N,d:j}=a,{X:C,Y:P,Z:g,T:v}=this,{X:A,Y:y,Z:S,T:E}=x,B=l(C*A),L=l(P*y),M=l(v*j*E),R=l(g*S),U=l((C+P)*(A+y)-B-L),F=R-M,q=R+M,W=l(L-N*B),D=l(U*F),_=l(q*W),$=l(U*W),J=l(F*q);return new w(D,_,J,$)}subtract(x){return this.add(x.negate())}multiply(x){if(!r.isValidNot0(x))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:N,f:j}=m.cached(this,x,C=>Ot(w,C));return Ot(w,[N,j])[0]}multiplyUnsafe(x,N=w.ZERO){if(!r.isValid(x))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return x===Ce?w.ZERO:this.is0()||x===te?this:m.unsafe(this,x,j=>Ot(w,j),N)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return m.unsafe(this,a.n).is0()}toAffine(x){return p(this,x)}clearCofactor(){return c===te?this:this.multiplyUnsafe(c)}toBytes(){const{x,y:N}=this.toAffine(),j=o.toBytes(N);return j[j.length-1]|=x&te?128:0,j}toHex(){return _s(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}const m=new Ka(w,r.BITS);return w.BASE.precompute(8),w}function ti(t,s,n={}){if(typeof s!="function")throw new Error('"hash" function param is required');Us(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:o}=n,{BASE:r,Fp:a,Fn:c}=t,i=n.randomBytes||wa,l=n.adjustScalarBytes||(A=>A),u=n.domain||((A,y,S)=>{if(vs(S,"phflag"),y.length||S)throw new Error("Contexts/pre-hash are not supported");return A});function f(A){return c.create(gt(A))}function h(A){const y=j.secretKey;se(A,j.secretKey,"secretKey");const S=se(s(A),2*y,"hashedSecretKey"),E=l(S.slice(0,y)),B=S.slice(y,2*y),L=f(E);return{head:E,prefix:B,scalar:L}}function p(A){const{head:y,prefix:S,scalar:E}=h(A),B=r.multiply(E),L=B.toBytes();return{head:y,prefix:S,scalar:E,point:B,pointBytes:L}}function b(A){return p(A).pointBytes}function w(A=Uint8Array.of(),...y){const S=fr(...y);return f(s(u(S,se(A,void 0,"context"),!!o)))}function m(A,y,S={}){A=se(A,void 0,"message"),o&&(A=o(A));const{prefix:E,scalar:B,pointBytes:L}=p(y),M=w(S.context,E,A),R=r.multiply(M).toBytes(),U=w(S.context,R,L,A),F=c.create(M+U*B);if(!c.isValid(F))throw new Error("sign failed: invalid s");const q=fr(R,c.toBytes(F));return se(q,j.signature,"result")}const k={zip215:!0};function x(A,y,S,E=k){const{context:B,zip215:L}=E,M=j.signature;A=se(A,M,"signature"),y=se(y,void 0,"message"),S=se(S,j.publicKey,"publicKey"),L!==void 0&&vs(L,"zip215"),o&&(y=o(y));const R=M/2,U=A.subarray(0,R),F=gt(A.subarray(R,M));let q,W,D;try{q=t.fromBytes(S,L),W=t.fromBytes(U,L),D=r.multiplyUnsafe(F)}catch{return!1}if(!L&&q.isSmallOrder())return!1;const _=w(B,W.toBytes(),q.toBytes(),y);return W.add(q.multiplyUnsafe(_)).subtract(D).clearCofactor().is0()}const N=a.BYTES,j={secretKey:N,publicKey:N,signature:2*N,seed:N};function C(A=i(j.seed)){return se(A,j.seed,"seed")}function P(A){return An(A)&&A.length===c.BYTES}function g(A,y){try{return!!t.fromBytes(A,y)}catch{return!1}}const v={getExtendedPublicKey:p,randomSecretKey:C,isValidSecretKey:P,isValidPublicKey:g,toMontgomery(A){const{y}=t.fromBytes(A),S=j.publicKey,E=S===32;if(!E&&S!==57)throw new Error("only defined for 25519 and 448");const B=E?a.div(te+y,te-y):a.div(y-te,y+te);return a.toBytes(B)},toMontgomerySecret(A){const y=j.secretKey;se(A,y);const S=s(A.subarray(0,y));return l(S).subarray(0,y)}};return Object.freeze({keygen:Za(C,b),getPublicKey:b,sign:m,verify:x,utils:v,Point:t,lengths:j})}const si=BigInt(1),Cr=BigInt(2),ri=BigInt(5),ni=BigInt(8),Ws=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),oi={p:Ws,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:ni,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function ai(t){const s=BigInt(10),n=BigInt(20),o=BigInt(40),r=BigInt(80),a=Ws,i=t*t%a*t%a,l=me(i,Cr,a)*i%a,u=me(l,si,a)*t%a,f=me(u,ri,a)*u%a,h=me(f,s,a)*f%a,p=me(h,n,a)*h%a,b=me(p,o,a)*p%a,w=me(b,r,a)*b%a,m=me(w,r,a)*b%a,k=me(m,s,a)*f%a;return{pow_p_5_8:me(k,Cr,a)*t%a,b2:i}}function ii(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Sr=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ci(t,s){const n=Ws,o=ee(s*s*s,n),r=ee(o*o*s,n),a=ai(t*r).pow_p_5_8;let c=ee(t*o*a,n);const i=ee(s*c*c,n),l=c,u=ee(c*Sr,n),f=i===t,h=i===ee(-t,n),p=i===ee(-t*Sr,n);return f&&(c=l),(h||p)&&(c=u),za(c,n)&&(c=ee(-c,n)),{isValid:f||h,value:c}}const li=ei(oi,{uvRatio:ci});function di(t){return ti(li,Ma,Object.assign({adjustScalarBytes:ii},t))}const ui=di({});function hi(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ct(t,...s){if(!hi(t))throw new Error("Uint8Array expected");if(s.length>0&&!s.includes(t.length))throw new Error("Uint8Array expected of length "+s+", got length="+t.length)}function Er(t,s=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(s&&t.finished)throw new Error("Hash#digest() has already been called")}function fi(t,s){Ct(t);const n=s.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Ns(...t){for(let s=0;s<t.length;s++)t[s].fill(0)}function Vt(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function ge(t,s){return t<<32-s|t>>>s}function pi(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Un(t){return typeof t=="string"&&(t=pi(t)),Ct(t),t}class mi{}function gi(t){const s=o=>t().update(Un(o)).digest(),n=t();return s.outputLen=n.outputLen,s.blockLen=n.blockLen,s.create=()=>t(),s}function wi(t,s,n,o){if(typeof t.setBigUint64=="function")return t.setBigUint64(s,n,o);const r=BigInt(32),a=BigInt(4294967295),c=Number(n>>r&a),i=Number(n&a),l=o?4:0,u=o?0:4;t.setUint32(s+l,c,o),t.setUint32(s+u,i,o)}function bi(t,s,n){return t&s^~t&n}function yi(t,s,n){return t&s^t&n^s&n}class xi extends mi{constructor(s,n,o,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=s,this.outputLen=n,this.padOffset=o,this.isLE=r,this.buffer=new Uint8Array(s),this.view=Vt(this.buffer)}update(s){Er(this),s=Un(s),Ct(s);const{view:n,buffer:o,blockLen:r}=this,a=s.length;for(let c=0;c<a;){const i=Math.min(r-this.pos,a-c);if(i===r){const l=Vt(s);for(;r<=a-c;c+=r)this.process(l,c);continue}o.set(s.subarray(c,c+i),this.pos),this.pos+=i,c+=i,this.pos===r&&(this.process(n,0),this.pos=0)}return this.length+=s.length,this.roundClean(),this}digestInto(s){Er(this),fi(s,this),this.finished=!0;const{buffer:n,view:o,blockLen:r,isLE:a}=this;let{pos:c}=this;n[c++]=128,Ns(this.buffer.subarray(c)),this.padOffset>r-c&&(this.process(o,0),c=0);for(let h=c;h<r;h++)n[h]=0;wi(o,r-8,BigInt(this.length*8),a),this.process(o,0);const i=Vt(s),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=l/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<u;h++)i.setUint32(4*h,f[h],a)}digest(){const{buffer:s,outputLen:n}=this;this.digestInto(s);const o=s.slice(0,n);return this.destroy(),o}_cloneInto(s){s||(s=new this.constructor),s.set(...this.get());const{blockLen:n,buffer:o,length:r,finished:a,destroyed:c,pos:i}=this;return s.destroyed=c,s.finished=a,s.length=r,s.pos=i,r%n&&s.buffer.set(o),s}clone(){return this._cloneInto()}}const Se=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ai=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]),Ee=new Uint32Array(64);class vi extends xi{constructor(s=32){super(64,s,8,!1),this.A=Se[0]|0,this.B=Se[1]|0,this.C=Se[2]|0,this.D=Se[3]|0,this.E=Se[4]|0,this.F=Se[5]|0,this.G=Se[6]|0,this.H=Se[7]|0}get(){const{A:s,B:n,C:o,D:r,E:a,F:c,G:i,H:l}=this;return[s,n,o,r,a,c,i,l]}set(s,n,o,r,a,c,i,l){this.A=s|0,this.B=n|0,this.C=o|0,this.D=r|0,this.E=a|0,this.F=c|0,this.G=i|0,this.H=l|0}process(s,n){for(let h=0;h<16;h++,n+=4)Ee[h]=s.getUint32(n,!1);for(let h=16;h<64;h++){const p=Ee[h-15],b=Ee[h-2],w=ge(p,7)^ge(p,18)^p>>>3,m=ge(b,17)^ge(b,19)^b>>>10;Ee[h]=m+Ee[h-7]+w+Ee[h-16]|0}let{A:o,B:r,C:a,D:c,E:i,F:l,G:u,H:f}=this;for(let h=0;h<64;h++){const p=ge(i,6)^ge(i,11)^ge(i,25),b=f+p+bi(i,l,u)+Ai[h]+Ee[h]|0,m=(ge(o,2)^ge(o,13)^ge(o,22))+yi(o,r,a)|0;f=u,u=l,l=i,i=c+b|0,c=a,a=r,r=o,o=b+m|0}o=o+this.A|0,r=r+this.B|0,a=a+this.C|0,c=c+this.D|0,i=i+this.E|0,l=l+this.F|0,u=u+this.G|0,f=f+this.H|0,this.set(o,r,a,c,i,l,u,f)}roundClean(){Ns(Ee)}destroy(){this.set(0,0,0,0,0,0,0,0),Ns(this.buffer)}}const Fn=gi(()=>new vi),ji=Fn,ki="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Ni(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=ji(t),n=ui.getPublicKey(s),o=new Uint8Array(64);return o.set(s,0),o.set(n,32),I.wipeBytes(s),{publicKey:n,secretKey:o}}function On(t){const s=Ni(t),n=s.publicKey;return I.wipeBytes(s.secretKey),n}function Wn(t){if(t.length!==32)throw new Error(`Invalid public key length: expected 32, got ${t.length}`);return Ci(t)}function Ci(t){let s=0;for(let r=0;r<t.length&&t[r]===0;r++)s++;let n=0n;for(let r=0;r<t.length;r++)n=n*256n+BigInt(t[r]);let o="";for(;n>0n;){const r=Number(n%58n);o=ki[r]+o,n=n/58n}return"1".repeat(s)+o}const Si=2,Ei=3;function qn(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const s=Cs(t),n=xn.share(s,Ei,Si);if(n.length!==3)throw new Error(`Unexpected share count: ${n.length}`);const o=$t(n[0]),r=$t(n[1]),a=$t(n[2]);return{shareA:I.toShamirShare(o),shareB:I.toShamirShare(r),shareC:I.toShamirShare(a)}}function Li(t,s,n){const o=Lr(t),r=Lr(s);try{const a=xn.combine([o,r]),c=zn(a);if(c.length!==16)throw new Error(`Reconstructed seed has wrong length: ${c.length}`);return I.toSeed(c)}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 Cs(t){return Array.from(t).map(s=>s.toString(16).padStart(2,"0")).join("")}function zn(t){if(!/^[0-9a-fA-F]*$/.test(t))throw new Error("Invalid hex string: contains non-hex characters");if(t.length%2!==0)throw new Error(`Invalid hex string: length ${t.length} is odd (must be even)`);const s=new Uint8Array(t.length/2);for(let n=0;n<s.length;n++)s[n]=parseInt(t.substr(n*2,2),16);return s}function $t(t){const s=t.length%2!==0,n=s?"0"+t:t,o=zn(n),r=new Uint8Array(1+o.length);return r[0]=s?1:0,r.set(o,1),r}function Lr(t){const s=t[0];if(s===0||s===1){const o=s===1,r=t.subarray(1),a=Cs(r),c=o?a.substring(1):a;if(/^[0-9a-f]/.test(c))return c}const n=Cs(t);return n.startsWith("0")&&!n.startsWith("00")?n.substring(1):n}function bt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Hn(t,s){return Array.isArray(s)?s.length===0?!0:t?s.every(n=>typeof n=="string"):s.every(n=>Number.isSafeInteger(n)):!1}function Pi(t){if(typeof t!="function")throw new Error("function expected");return!0}function yt(t,s){if(typeof s!="string")throw new Error(`${t}: string expected`);return!0}function $e(t){if(!Number.isSafeInteger(t))throw new Error(`invalid integer: ${t}`)}function xt(t){if(!Array.isArray(t))throw new Error("array expected")}function At(t,s){if(!Hn(!0,s))throw new Error(`${t}: array of strings expected`)}function Vn(t,s){if(!Hn(!1,s))throw new Error(`${t}: array of numbers expected`)}function Bi(...t){const s=a=>a,n=(a,c)=>i=>a(c(i)),o=t.map(a=>a.encode).reduceRight(n,s),r=t.map(a=>a.decode).reduce(n,s);return{encode:o,decode:r}}function Mi(t){const s=typeof t=="string"?t.split(""):t,n=s.length;At("alphabet",s);const o=new Map(s.map((r,a)=>[r,a]));return{encode:r=>(xt(r),r.map(a=>{if(!Number.isSafeInteger(a)||a<0||a>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${a}". Allowed: ${t}`);return s[a]})),decode:r=>(xt(r),r.map(a=>{yt("alphabet.decode",a);const c=o.get(a);if(c===void 0)throw new Error(`Unknown letter: "${a}". Allowed: ${t}`);return c}))}}function Ri(t=""){return yt("join",t),{encode:s=>(At("join.decode",s),s.join(t)),decode:s=>(yt("join.decode",s),s.split(t))}}function Ti(t,s="="){return $e(t),yt("padding",s),{encode(n){for(At("padding.encode",n);n.length*t%8;)n.push(s);return n},decode(n){At("padding.decode",n);let o=n.length;if(o*t%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;o>0&&n[o-1]===s;o--)if((o-1)*t%8===0)throw new Error("padding: invalid, string has too much padding");return n.slice(0,o)}}}function Ss(t,s,n){if(s<2)throw new Error(`convertRadix: invalid from=${s}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: invalid to=${n}, base cannot be less than 2`);if(xt(t),!t.length)return[];let o=0;const r=[],a=Array.from(t,i=>{if($e(i),i<0||i>=s)throw new Error(`invalid integer: ${i}`);return i}),c=a.length;for(;;){let i=0,l=!0;for(let u=o;u<c;u++){const f=a[u],h=s*i,p=h+f;if(!Number.isSafeInteger(p)||h/s!==i||p-f!==h)throw new Error("convertRadix: carry overflow");const b=p/n;i=p%n;const w=Math.floor(b);if(a[u]=w,!Number.isSafeInteger(w)||w*n+i!==p)throw new Error("convertRadix: carry overflow");if(l)w?l=!1:o=u;else continue}if(r.push(i),l)break}for(let i=0;i<t.length-1&&t[i]===0;i++)r.push(0);return r.reverse()}const $n=(t,s)=>s===0?t:$n(s,t%s),vt=(t,s)=>t+(s-$n(t,s)),Gt=(()=>{let t=[];for(let s=0;s<40;s++)t.push(2**s);return t})();function Es(t,s,n,o){if(xt(t),s<=0||s>32)throw new Error(`convertRadix2: wrong from=${s}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(vt(s,n)>32)throw new Error(`convertRadix2: carry overflow from=${s} to=${n} carryBits=${vt(s,n)}`);let r=0,a=0;const c=Gt[s],i=Gt[n]-1,l=[];for(const u of t){if($e(u),u>=c)throw new Error(`convertRadix2: invalid data word=${u} from=${s}`);if(r=r<<s|u,a+s>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${s}`);for(a+=s;a>=n;a-=n)l.push((r>>a-n&i)>>>0);const f=Gt[a];if(f===void 0)throw new Error("invalid carry");r&=f-1}if(r=r<<n-a&i,!o&&a>=s)throw new Error("Excess padding");if(!o&&r>0)throw new Error(`Non-zero padding: ${r}`);return o&&a>0&&l.push(r>>>0),l}function Ii(t){$e(t);const s=2**8;return{encode:n=>{if(!bt(n))throw new Error("radix.encode input should be Uint8Array");return Ss(Array.from(n),s,t)},decode:n=>(Vn("radix.decode",n),Uint8Array.from(Ss(n,t,s)))}}function Di(t,s=!1){if($e(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(vt(8,t)>32||vt(t,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!bt(n))throw new Error("radix2.encode input should be Uint8Array");return Es(Array.from(n),8,t,!s)},decode:n=>(Vn("radix2.decode",n),Uint8Array.from(Es(n,t,8,s)))}}function _i(t,s){return $e(t),Pi(s),{encode(n){if(!bt(n))throw new Error("checksum.encode: input should be Uint8Array");const o=s(n).slice(0,t),r=new Uint8Array(n.length+t);return r.set(n),r.set(o,n.length),r},decode(n){if(!bt(n))throw new Error("checksum.decode: input should be Uint8Array");const o=n.slice(0,-t),r=n.slice(-t),a=s(o).slice(0,t);for(let c=0;c<t;c++)if(a[c]!==r[c])throw new Error("Invalid checksum");return o}}}const it={alphabet:Mi,chain:Bi,checksum:_i,convertRadix:Ss,convertRadix2:Es,radix:Ii,radix2:Di,join:Ri,padding:Ti};const Ui=t=>t[0]==="あいこくしん";function Fi(t){if(typeof t!="string")throw new TypeError("invalid mnemonic type: "+typeof t);return t.normalize("NFKD")}function Oi(t){const s=Fi(t),n=s.split(" ");if(![12,15,18,21,24].includes(n.length))throw new Error("Invalid mnemonic");return{nfkd:s,words:n}}function Gn(t){Ct(t,16,20,24,28,32)}const Wi=t=>{const s=8-t.length/4;return new Uint8Array([Fn(t)[0]>>s<<s])};function Qn(t){if(!Array.isArray(t)||t.length!==2048||typeof t[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return t.forEach(s=>{if(typeof s!="string")throw new Error("wordlist: non-string element: "+s)}),it.chain(it.checksum(1,Wi),it.radix2(11,!0),it.alphabet(t))}function qs(t,s){const{words:n}=Oi(t),o=Qn(s).decode(n);return Gn(o),o}function Kn(t,s){return Gn(t),Qn(s).encode(t).join(Ui(s)?" ":" ")}function zs(t,s){try{qs(t,s)}catch{return!1}return!0}const Ae=`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
- `),ue=12;function Fi(t){if(t.length!==16)throw new Error(`Invalid share length: expected 16, got ${t.length}`);const n=Vn(t,Ae).split(" ");if(n.length!==ue)throw new Error(`Unexpected word count: expected ${ue}, got ${n.length}`);return n}function Oi(t){if(t.length!==ue)throw new Error(`Invalid word count: expected ${ue}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!Ws(s,Ae))throw new Error("Invalid recovery phrase: checksum mismatch");const n=Os(s,Ae);if(n.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${n.length}`);return I.toShamirShare(n)}function Wi(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const n=Vn(t,Ae).split(" ");if(n.length!==ue)throw new Error(`Unexpected word count: expected ${ue}, got ${n.length}`);return n}function qi(t){if(t.length!==ue)throw new Error(`Invalid word count: expected ${ue}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!Ws(s,Ae))throw new Error("Invalid recovery phrase: checksum mismatch");const n=Os(s,Ae);if(n.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${n.length}`);return I.toSeed(n)}function $n(t){if(t.length!==ue)return!1;const s=t.join(" ").toLowerCase().trim();return Ws(s,Ae)}function ct(t){return Ae.includes(t.toLowerCase().trim())}function zi(t,s=5){const n=t.toLowerCase().trim();return n.length===0?[]:Ae.filter(o=>o.startsWith(n)).slice(0,s)}function Hi(t){const s=[];for(let n=0;n<t.length;n+=4)s.push(t.slice(n,n+4));return s}function Vi(t){return t.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(s=>s.trim()).filter(s=>s.length>0)}function $i({className:t="",variant:s="default",size:n="md",children:o,menuItems:r=[],hideSignOut:a=!1}){const{user:c,isAuthenticated:i,isLoading:l,openLoginModal:u,logout:f}=I.useAuth(),[h,m]=d.useState(!1),[b,g]=d.useState(-1),p=d.useRef(null),k=d.useRef(null),y=d.useMemo(()=>[...r,...a?[]:[{label:"Sign out",onClick:f}]],[r,a,f]);d.useEffect(()=>{if(!h)return;const w=A=>{p.current&&!p.current.contains(A.target)&&(m(!1),g(-1))},v=A=>{A.key==="Escape"&&(m(!1),g(-1),k.current?.focus())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",v)}},[h]);const N=d.useCallback(w=>{if(!(!h||y.length===0))switch(w.key){case"ArrowDown":w.preventDefault(),g(v=>(v+1)%y.length);break;case"ArrowUp":w.preventDefault(),g(v=>(v-1+y.length)%y.length);break;case"Home":w.preventDefault(),g(0);break;case"End":w.preventDefault(),g(y.length-1);break;case"Enter":case" ":b>=0&&(w.preventDefault(),y[b].onClick(),m(!1),g(-1));break}},[h,b,y]),j=d.useCallback(()=>{y.length!==0&&(m(w=>!w),g(-1))},[y.length]),C={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},L={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(l)return e.jsx("button",{type:"button",className:`cedros-button ${L[s]} ${C[n]} ${t}`,disabled:!0,children:e.jsx(z.LoadingSpinner,{size:"sm"})});if(i&&c){const w=c.name||c.email||"User",v=Ls.sanitizeImageUrl(c.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:p,onKeyDown:N,children:[e.jsxs("button",{ref:k,type:"button",className:`cedros-button cedros-user-button ${C[n]} ${t}`,"aria-haspopup":"menu","aria-expanded":h,"aria-label":`User menu for ${w}`,onClick:j,children:[v?e.jsx("img",{src:v,alt:w,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(w[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:w})]}),h&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[r.map((A,x)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${b===x?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===x?0:-1,onClick:()=>{A.onClick(),m(!1)},children:[A.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:A.icon}),A.label]},x)),r.length>0&&!a&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!a&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${b===r.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===r.length?0:-1,onClick:()=>{f(),m(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${L[s]} ${C[n]} ${t}`,onClick:u,children:o||"Sign in"})}function St(){const{config:t}=T.useCedrosLogin(),[s,n]=d.useState(!1),[o,r]=d.useState(!1),[a,c]=d.useState(null),i=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:l,getRemainingAttempts:u}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),f=d.useCallback(async g=>{if(!Re.validateEmail(g)){const p={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw c(p),p}try{l()}catch(p){const k={code:"RATE_LIMITED",message:p instanceof Error?p.message:"Too many attempts"};throw c(k),k}n(!0),c(null),r(!1);try{await i.post("/forgot-password",{email:g}),r(!0)}catch(p){const k=T.handleApiError(p,"Unable to send the reset email. Please try again.");throw c(k),k}finally{n(!1)}},[i,l]),h=d.useCallback(async(g,p)=>{n(!0),c(null),r(!1);try{await i.post("/reset-password",{token:g,newPassword:p}),r(!0)}catch(k){const y=T.handleApiError(k,"Unable to reset your password. Please try again.");throw c(y),y}finally{n(!1)}},[i]),m=d.useCallback(()=>c(null),[]),b=d.useCallback(()=>{c(null),r(!1),n(!1)},[]);return{forgotPassword:f,resetPassword:h,isLoading:s,isSuccess:o,error:a,clearError:m,reset:b,remainingAttempts:u()}}function Gi(t){return typeof t=="object"&&t!==null&&"mfaRequired"in t&&t.mfaRequired===!0}function Gn(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(!1),[c,i]=d.useState(null),l=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:u,getRemainingAttempts:f}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),h=d.useCallback(async p=>{if(!Re.validateEmail(p)){const k={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw i(k),k}try{u()}catch(k){const y={code:"RATE_LIMITED",message:k instanceof Error?k.message:"Too many attempts"};throw i(y),y}o(!0),i(null),a(!1);try{await l.post("/instant-link",{email:p}),a(!0)}catch(k){const y=T.handleApiError(k,"Unable to send the sign-in link. Please try again.");throw i(y),y}finally{o(!1)}},[l,u]),m=d.useCallback(async p=>{if(!p||p.trim().length===0){const k={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw i(k),k}o(!0),i(null),a(!1);try{const k=await l.post("/instant-link/verify",{token:p});return Gi(k)||(t.callbacks?.onLoginSuccess?.(k.user,"email"),s?.handleLoginSuccess(k.user,k.tokens)),k}catch(k){const y=T.handleApiError(k,"Unable to verify the sign-in link. Please try again.");throw i(y),y}finally{o(!1)}},[l,t.callbacks,s]),b=d.useCallback(()=>i(null),[]),g=d.useCallback(()=>{i(null),a(!1),o(!1)},[]);return{sendInstantLink:h,verifyInstantLink:m,isLoading:n,isSuccess:r,error:c,clearError:b,reset:g,remainingAttempts:f()}}const Qi={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:t=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:t}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:t=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:t}),". Click the link to sign in."]})}};function Qn({mode:t="reset",onSuccess:s,onCancel:n,className:o=""}){const[r,a]=d.useState(""),c=St(),i=Gn(),l=d.useId(),u=t==="instantLink"?{submit:i.sendInstantLink,isLoading:i.isLoading,isSuccess:i.isSuccess,error:i.error,clearError:i.clearError}:{submit:c.forgotPassword,isLoading:c.isLoading,isSuccess:c.isSuccess,error:c.error,clearError:c.clearError},f=Qi[t],h=async m=>{m.preventDefault();try{await u.submit(r),s?.()}catch{}};return u.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:f.successMessage(r)}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:n,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:h,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:f.subtitle})]}),e.jsx(Z.ErrorMessage,{error:u.error,onDismiss:u.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:r,onChange:m=>a(m.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:u.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:u.isLoading||!r,children:u.isLoading?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),"Sending..."]}):f.button}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:n,disabled:u.isLoading,children:"Back to login"})]})]})}const Ki={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s})}):(this.loading=!0,new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s});const n=document.getElementById("apple-signin-script");if(n){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]):n.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.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(r=>r.resolve()),this.callbacks=[]},o.onerror=()=>{this.loading=!1,o.remove();const r=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(a=>a.reject(r)),this.callbacks=[]},document.head.appendChild(o)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function Kn(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(!1),[c,i]=d.useState(null),[l,u]=d.useState(null),f=d.useRef(t),h=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]);d.useEffect(()=>{f.current=t},[t]),d.useEffect(()=>{if(!t.appleClientId)return;let p=!0;const k=()=>{if(p)try{window.AppleID?.auth?.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),p&&a(!0)}catch{p&&i({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return Ki.load().then(()=>{p&&k()}).catch(()=>{p&&i({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{p=!1}},[t.appleClientId]);const m=d.useCallback(async()=>{if(!t.appleClientId){const k={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw i(k),k}if(!r){const k={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw i(k),k}o(!0),i(null);let p;try{const k=crypto.getRandomValues(new Uint8Array(32)),y=Array.from(k,v=>v.toString(16).padStart(2,"0")).join(""),N=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(y)),j=Array.from(new Uint8Array(N),v=>v.toString(16).padStart(2,"0")).join("");window.AppleID.auth.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0,nonce:j});const C=await window.AppleID.auth.signIn();if(p=C.authorization?.id_token,!p)throw new Error("No ID token received from Apple");const L=C.user?.name?`${C.user.name.firstName||""} ${C.user.name.lastName||""}`.trim():void 0,w=await h.post("/apple",{idToken:p,name:L||void 0,nonce:y});return f.current.callbacks?.onLoginSuccess?.(w.user,"apple"),s?.handleLoginSuccess(w.user,w.tokens),o(!1),w}catch(k){if(k.error==="popup_closed_by_user"){const j={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw i(j),o(!1),j}const N=T.handleApiError(k,"Unable to sign in with Apple. Please try again.");throw N.code==="ACCOUNT_LINK_REQUIRED"&&p&&u(p),i(N),o(!1),N}},[t.appleClientId,r,h,s]),b=d.useCallback(()=>i(null),[]),g=d.useCallback(()=>u(null),[]);return{signIn:m,isLoading:n,isInitialized:r,error:c,clearError:b,pendingLinkIdToken:l,clearPendingLink:g}}function Yn(){if(typeof window>"u"||typeof navigator>"u")return!1;const t=navigator.userAgent.toLowerCase(),s=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(t)||s.includes("mac")||/macintosh/.test(t)||s==="macintel"&&navigator.maxTouchPoints>1)}function Zn({onSuccess:t,onError:s,className:n="",variant:o="default",size:r="md",disabled:a=!1,hideOnNonApple:c=!0}){const{signIn:i,isLoading:l,isInitialized:u}=Kn(),[f]=d.useState(()=>Yn());if(c&&!f)return null;const h=async()=>{try{await i(),t?.()}catch(g){const p=g instanceof Error?g:new Error(String(g));s?.(p)}},m={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]} ${m[r]} ${n}`,onClick:h,disabled:a||!u||l,"aria-label":"Sign in with Apple",children:[l?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 ne(t,s){if(!t)throw new Error(s)}function Yi(t){return t.replace(/-/g,"+").replace(/_/g,"/")}function jt(t){ne(typeof t=="string"&&t.length>0,"Expected base64url string");const s=Yi(t),n=s+"=".repeat((4-s.length%4)%4),o=atob(n),r=new Uint8Array(o.length);for(let a=0;a<o.length;a++)r[a]=o.charCodeAt(a);return r.buffer}function Ue(t){const s=new Uint8Array(t);let n="";for(let r=0;r<s.length;r++)n+=String.fromCharCode(s[r]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Xn(t){ne(typeof t=="object"&&t!==null,"Invalid credential descriptor");const s=t;return ne(typeof s.type=="string","Invalid credential descriptor type"),ne(typeof s.id=="string","Invalid credential descriptor id"),{type:s.type,id:jt(s.id),transports:Array.isArray(s.transports)?s.transports:void 0}}function $t(t){ne(t&&typeof t=="object","Missing creation options");const s=t.publicKey;ne(s&&typeof s=="object","Missing creation options.publicKey"),ne(typeof s.challenge=="string","Missing creation challenge"),ne(typeof s.rp=="object"&&s.rp!==null,"Missing rp"),ne(typeof s.user=="object"&&s.user!==null,"Missing user");const n=s.rp,o=s.user;ne(typeof n.name=="string","Missing rp.name"),ne(typeof o.id=="string","Missing user.id"),ne(typeof o.name=="string","Missing user.name"),ne(typeof o.displayName=="string","Missing user.displayName");const r=Array.isArray(s.excludeCredentials)?s.excludeCredentials.map(Xn):void 0,a=Array.isArray(s.pubKeyCredParams)?s.pubKeyCredParams.map(i=>({type:i.type,alg:i.alg})):[],c={challenge:jt(s.challenge),rp:{name:n.name,id:typeof n.id=="string"?n.id:void 0},user:{id:jt(o.id),name:o.name,displayName:o.displayName},pubKeyCredParams:a,timeout:typeof s.timeout=="number"?s.timeout:void 0,attestation:typeof s.attestation=="string"?s.attestation:void 0,authenticatorSelection:typeof s.authenticatorSelection=="object"&&s.authenticatorSelection!==null?s.authenticatorSelection:void 0,excludeCredentials:r,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return c.hints=["client-device"],c}function Cr(t){ne(t&&typeof t=="object","Missing request options");const s=t.publicKey;ne(s&&typeof s=="object","Missing request options.publicKey"),ne(typeof s.challenge=="string","Missing request challenge");const n=Array.isArray(s.allowCredentials)?s.allowCredentials.map(Xn):void 0,o={challenge:jt(s.challenge),rpId:typeof s.rpId=="string"?s.rpId:void 0,timeout:typeof s.timeout=="number"?s.timeout:void 0,userVerification:typeof s.userVerification=="string"?s.userVerification:void 0,allowCredentials:n,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return o.hints=["client-device"],o}function $e(t){const s=Ue(t.rawId),n=t.response,r={...{clientDataJSON:Ue(n.clientDataJSON)}};if("attestationObject"in n){const a=n;if(r.attestationObject=Ue(a.attestationObject),typeof a.getTransports=="function")try{r.transports=a.getTransports()}catch{}}if("authenticatorData"in n){const a=n;r.authenticatorData=Ue(a.authenticatorData),r.signature=Ue(a.signature),a.userHandle&&(r.userHandle=Ue(a.userHandle))}return{id:t.id,rawId:s,type:t.type,authenticatorAttachment:t.authenticatorAttachment??void 0,clientExtensionResults:t.getClientExtensionResults?.()??{},response:r}}function Zi(){if(typeof window<"u"){const t=window.location?.hostname,s=t==="localhost"||t==="127.0.0.1"||t?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!s)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function Xi(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&typeof t.code=="string"&&typeof t.message=="string"}function Ge(t){if(!(t instanceof Error))return null;const s=t.name;return s==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:s==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:s==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function qs(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(null),c=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[s?.getAccessToken,t.serverUrl,t.requestTimeout,t.retryAttempts]),i=d.useCallback(()=>a(null),[]),l=Zi(),u=d.useCallback(async k=>{if(!l){const y={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(y),y}o(!0),a(null);try{const y=await c.post("/webauthn/auth/options",{email:k?.email}),N=Cr(y.options),j=await navigator.credentials.get({publicKey:N});if(!j)throw new Error("Passkey authentication returned no credential");const C=await c.post("/webauthn/auth/verify",{challengeId:y.challengeId,credential:$e(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),C}catch(y){const j=Ge(y)??T.handleApiError(y,"Unable to sign in with passkey. Please try again.");throw a(j),j}finally{o(!1)}},[c,t.callbacks,s,l]),f=d.useCallback(async k=>{if(!l){const y={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(y),y}o(!0),a(null);try{const y=await c.post("/webauthn/register/options",{}),N=$t(y.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey registration returned no credential");const C=await c.post("/webauthn/register/verify",{challengeId:y.challengeId,credential:$e(j),label:k?.label});if(!C.success)throw new Error("Passkey registration failed");return{credentialId:C.credentialId,label:C.label}}catch(y){const j=Ge(y)??T.handleApiError(y,"Unable to register passkey. Please try again.");throw a(j),j}finally{o(!1)}},[c,l]),h=d.useCallback(async k=>{if(!l){const y={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(y),y}o(!0),a(null);try{const y=await c.post("/webauthn/signup/options",{}),N=$t(y.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey signup returned no credential");const C=await c.post("/webauthn/signup/verify",{challengeId:y.challengeId,credential:$e(j),email:k?.email,name:k?.name,label:k?.label});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),C}catch(y){const j=Ge(y)??T.handleApiError(y,"Unable to sign up with passkey. Please try again.");throw a(j),j}finally{o(!1)}},[c,t.callbacks,s,l]),m=d.useCallback(async()=>{if(!l){const N={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(N),N}o(!0),a(null);const k=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",y=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return k?b(y):g(y)},[c,t.callbacks,s,l]),b=d.useCallback(async k=>{try{const y=await c.post("/webauthn/auth/options",{}),N=Cr(y.options),j=await navigator.credentials.get({publicKey:N});if(!j)throw new Error("Passkey authentication returned no credential");const C=await c.post("/webauthn/auth/verify",{challengeId:y.challengeId,credential:$e(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),k(),C}catch(y){if(y instanceof Error&&(y.name==="NotAllowedError"||y.name==="InvalidStateError"))return p(k);if(typeof y=="object"&&y!==null&&"isApiError"in y&&y.data?.code==="INVALID_CREDENTIALS"){const w={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(w),w}const L=Ge(y)??T.handleApiError(y,"Unable to sign in with passkey. Please try again.");throw a(L),L}finally{o(!1)}},[c,t.callbacks,s]),g=d.useCallback(async k=>{try{return await p(k)}catch(y){if(y instanceof Error&&(y.name==="InvalidStateError"||y.name==="NotAllowedError"))return b(k);if(!Xi(y)){const C=Ge(y)??T.handleApiError(y,"Unable to create passkey. Please try again.");throw a(C),C}throw y}finally{o(!1)}},[c,t.callbacks,s]),p=d.useCallback(async k=>{const y=await c.post("/webauthn/signup/options",{}),N=$t(y.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey signup returned no credential");const C=await c.post("/webauthn/signup/verify",{challengeId:y.challengeId,credential:$e(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),k(),C},[c,t.callbacks,s]);return{isSupported:l,isLoading:n,error:r,clearError:i,continueWithPasskey:m,authenticatePasskey:u,registerPasskey:f,signupWithPasskey:h}}function Jn({onSuccess:t,className:s="",children:n,disabled:o}){const{continueWithPasskey:r,isLoading:a,isSupported:c}=qs(),i=o||!c||a;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${s}`,onClick:async()=>{try{await r(),t?.()}catch{}},disabled:i,"aria-disabled":i,children:[a?e.jsx(z.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(Ji,{})}),e.jsx("span",{children:n??"Continue with Passkey"})]})}function Ji(){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 Qe=["login","register"];function Et({onSuccess:t,className:s="",defaultTab:n="login"}){const{config:o,socialButtonOrder:r}=T.useCedrosLogin(),[a,c]=d.useState(n),[i,l]=d.useState("form"),[u,f]=d.useState(()=>Oe.detectSolanaWallets()),[h]=d.useState(()=>Yn());d.useEffect(()=>{const L=()=>f(Oe.detectSolanaWallets());return L(),window.addEventListener("load",L),window.addEventListener("focus",L),()=>{window.removeEventListener("load",L),window.removeEventListener("focus",L)}},[]);const m=o.forms?.forgotPassword?.mode??(o.features?.instantLink?"instantLink":"reset"),b=d.useCallback(L=>{const w=Qe.indexOf(a);let v=w;switch(L.key){case"ArrowLeft":case"ArrowUp":v=w===0?Qe.length-1:w-1;break;case"ArrowRight":case"ArrowDown":v=w===Qe.length-1?0:w+1;break;case"Home":v=0;break;case"End":v=Qe.length-1;break;default:return}L.preventDefault();const A=Qe[v];c(A),document.getElementById(`cedros-tab-${A}`)?.focus()},[a]),g=o.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},p=g.email!==!1,k=g.google!==!1&&o.googleClientId,y=g.apple!==!1&&o.appleClientId&&h,N=g.solana!==!1&&u,j=g.webauthn!==!1,C=p&&(k||y||N||j);return i==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${s}`,children:e.jsx(Qn,{mode:m,onCancel:()=>l("form")})}):e.jsxs("div",{className:`cedros-login-form ${s}`,children:[(j||k||y||N)&&(()=>{const L={webauthn:j?e.jsx(Jn,{onSuccess:t}):null,google:k?e.jsx(Ps.GoogleLoginButton,{onSuccess:t}):null,apple:y?e.jsx(Zn,{onSuccess:t}):null,solana:N?e.jsx(Oe.SolanaLoginButton,{onSuccess:t}):null},w=r??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:w.map(v=>{const A=L[v];return A?e.jsx(d.Fragment,{children:A},v):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 ${a==="login"?"cedros-tab-active":""}`,onClick:()=>c("login"),onKeyDown:b,"aria-selected":a==="login","aria-controls":"cedros-tabpanel-login",tabIndex:a==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${a==="register"?"cedros-tab-active":""}`,onClick:()=>c("register"),onKeyDown:b,"aria-selected":a==="register","aria-controls":"cedros-tabpanel-register",tabIndex:a==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${a}`,"aria-labelledby":`cedros-tab-${a}`,children:a==="login"?e.jsx(Q.EmailLoginForm,{onSuccess:t,onSwitchToRegister:()=>c("register"),onForgotPassword:()=>l("forgotPassword")}):e.jsx(Q.EmailRegisterForm,{onSuccess:t,onSwitchToLogin:()=>c("login")})})]})]})}class eo extends d.Component{constructor(s){super(s),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,n){this.setState({errorInfo:n}),console.error("[Cedros Login] Error caught by ErrorBoundary:",s),console.error("[Cedros Login] Component stack:",n.componentStack),this.props.onError?.(s,n)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:s,error:n,errorInfo:o}=this.state,{children:r,fallback:a,showDetails:c=!1}=this.props;return s?a||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),c&&n&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[n.toString(),o?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):r}}function ec({className:t="",title:s="Sign in to your account"}){const{isModalOpen:n,closeModal:o}=T.useCedrosLogin(),r=d.useRef(null),a=d.useRef(null),c=d.useRef(o);if(d.useEffect(()=>{c.current=o},[o]),d.useEffect(()=>{if(!n)return;a.current=document.activeElement,r.current?.focus();const l=f=>{if(f.key==="Escape"&&c.current(),f.key==="Tab"&&r.current){const h=r.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),m=h[0],b=h[h.length-1];f.shiftKey&&document.activeElement===m?(f.preventDefault(),b?.focus()):!f.shiftKey&&document.activeElement===b&&(f.preventDefault(),m?.focus())}};document.addEventListener("keydown",l);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",l),document.body.style.overflow=u,a.current instanceof HTMLElement&&a.current.focus()}},[n]),!n)return null;const i=l=>{l.target===l.currentTarget&&o()};return e.jsx("div",{className:`cedros-modal-backdrop ${t}`,onClick:i,role:"presentation",children:e.jsxs("div",{ref:r,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:s}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:o,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(eo,{children:e.jsx(Et,{onSuccess:o})})})]})})}function tc({token:t,onSuccess:s,onLoginClick:n,className:o=""}){const[r,a]=d.useState(""),[c,i]=d.useState(""),[l,u]=d.useState(null),{resetPassword:f,isLoading:h,isSuccess:m,error:b,clearError:g}=St(),p=r===c,k=l?.isValid&&p&&r.length>0,y=async N=>{if(N.preventDefault(),!!k)try{await f(t,r),s?.()}catch{}};return m?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."}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:n,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${o}`,onSubmit:y,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:b,onDismiss:g}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"New password",value:r,onChange:N=>{a(N.target.value),u(Re.validatePassword(N.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:h,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(Q.PasswordInput,{label:"Confirm password",value:c,onChange:N=>i(N.target.value),disabled:h,autoComplete:"new-password",error:c&&!p?"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:h||!k,children:h?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:n,disabled:h,children:"Back to login"})]})]})}function Ss({org:t,size:s="lg",className:n=""}){const o=Ls.sanitizeImageUrl(t.logoUrl),r=s==="lg"?"cedros-org-avatar-lg":"",a=["cedros-org-avatar",r,n].filter(Boolean).join(" "),c=["cedros-org-avatar-placeholder",r,n].filter(Boolean).join(" ");return o?e.jsx("img",{src:o,alt:t.name,className:a,referrerPolicy:"no-referrer"}):e.jsx("div",{className:c,children:t.name[0]?.toUpperCase()||"?"})}function sc({orgs:t,activeOrg:s,isLoading:n=!1,onSelect:o,onCreateClick:r,className:a="",placeholder:c="Select organization"}){const[i,l]=d.useState(!1),u=d.useRef(null);d.useEffect(()=>{const b=g=>{u.current&&!u.current.contains(g.target)&&l(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]),d.useEffect(()=>{const b=g=>{g.key==="Escape"&&l(!1)};if(i)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[i]);const f=d.useCallback(b=>{o(b),l(!1)},[o]),h=d.useCallback(()=>{l(!1),r?.()},[r]),m=d.useCallback(()=>{l(b=>!b)},[]);return n?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:u,className:`cedros-org-selector ${a}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:m,"aria-haspopup":"listbox","aria-expanded":i,children:[s?e.jsxs(e.Fragment,{children:[e.jsx(Ss,{org:s,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:s.name}),e.jsx(Sr,{role:s.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:c}),e.jsx(rc,{isOpen:i})]}),i&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[t.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:t.map(b=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${b.id===s?.id?"cedros-org-selector-item-active":""}`,onClick:()=>f(b.id),role:"option","aria-selected":b.id===s?.id,children:[e.jsx(Ss,{org:b,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:b.name}),e.jsx(Sr,{role:b.membership.role}),b.id===s?.id&&e.jsx(nc,{})]})},b.id))}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:h,children:[e.jsx(oc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function Sr({role:t}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${t}`,children:t})}function rc({isOpen:t}){return e.jsx("svg",{className:`cedros-org-chevron ${t?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function nc(){return e.jsx("svg",{className:"cedros-org-check",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 8L6 11L13 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function oc(){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 ac(){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 ic(){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 cc(){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 lc({orgs:t,activeOrg:s,isLoading:n,onSelect:o,onCreateClick:r}){return n?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[t.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:t.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${a.id===s?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>o(a.id),children:[e.jsx(Ss,{org:a}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:a.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",a.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${a.membership.role}`,children:a.membership.role}),a.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),a.id===s?.id&&e.jsx(ic,{})]})},a.id))}),r&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:r,children:[e.jsx(cc,{}),e.jsx("span",{children:"Create new organization"})]})]})}function dc({isLoading:t,onSubmit:s,onCancel:n}){const[o,r]=d.useState(""),[a,c]=d.useState(""),[i,l]=d.useState(null),u=d.useCallback(h=>{r(h);const m=h.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);c(m)},[]),f=d.useCallback(async h=>{if(h.preventDefault(),l(null),!o.trim()){l("Organization name is required");return}if(!a.trim()){l("Organization slug is required");return}try{await s({name:o.trim(),slug:a.trim()})}catch(m){l(m.message||"Failed to create organization")}},[o,a,s]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:f,children:[i&&e.jsx(Z.ErrorMessage,{error:i}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:o,onChange:h=>u(h.target.value),placeholder:"My Organization",maxLength:255,disabled:t,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:a,onChange:h=>c(h.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:t})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:n,disabled:t,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:t||!o.trim()||!a.trim(),children:t?e.jsx(z.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function uc({isOpen:t,onClose:s,orgs:n,activeOrg:o,isLoading:r=!1,error:a,onSelect:c,onCreate:i,className:l=""}){return t?e.jsx(hc,{onClose:s,orgs:n,activeOrg:o,isLoading:r,error:a,onSelect:c,onCreate:i,className:l}):null}function hc({onClose:t,orgs:s,activeOrg:n,isLoading:o=!1,error:r,onSelect:a,onCreate:c,className:i}){const[l,u]=d.useState("list"),f=d.useRef(null),h=d.useRef(null);d.useEffect(()=>(h.current=document.activeElement,f.current?.querySelector(".cedros-modal-close")?.focus(),()=>{h.current?.focus()}),[]),d.useEffect(()=>{const p=k=>{if(k.key==="Escape"){t();return}if(k.key==="Tab"&&f.current){const y=f.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),N=y[0],j=y[y.length-1];k.shiftKey?document.activeElement===N&&(k.preventDefault(),j?.focus()):document.activeElement===j&&(k.preventDefault(),N?.focus())}};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t]);const m=d.useCallback(p=>{p.target===p.currentTarget&&t()},[t]),b=d.useCallback(p=>{a(p),t()},[a,t]),g=d.useCallback(async p=>{await c?.(p),t()},[c,t]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:m,children:e.jsxs("div",{ref:f,className:`cedros-modal cedros-org-switcher ${i}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:l==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:t,"aria-label":"Close",children:e.jsx(ac,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[r&&e.jsx(Z.ErrorMessage,{error:r}),l==="list"?e.jsx(lc,{orgs:s,activeOrg:n,isLoading:o,onSelect:b,onCreateClick:c?()=>u("create"):void 0}):e.jsx(dc,{isLoading:o,onSubmit:g,onCancel:()=>u("list")})]})]})})}function to({sessions:t,isLoading:s=!1,error:n,onRevokeAll:o,className:r=""}){const[a,c]=d.useState(!1),[i,l]=d.useState(!1),u=d.useRef(null),f=d.useMemo(()=>t.filter(m=>!m.isCurrent).length,[t]),h=d.useCallback(async()=>{if(!o)return;const m=t.filter(g=>!g.isCurrent).length;if(!(m===0||!window.confirm(`Are you sure you want to sign out of ${m} other device(s)? This will log you out everywhere except this browser.`))){c(!0),l(!1);try{await o(),l(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{l(!1),u.current=null},3e3)}finally{c(!1)}}},[o,t]);return d.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),s&&t.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${r}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):n?e.jsx("div",{className:`cedros-session-list ${r}`,children:e.jsx(Z.ErrorMessage,{error:n})}):t.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${r}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${r}`,children:[i&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(bc,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:t.map(m=>e.jsx(fc,{session:m},m.id))}),o&&f>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:h,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${f} other device${f>1?"s":""}`})})]})}function fc({session:t}){const s=pc(t.userAgent),n=gc(t.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${t.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(wc,{userAgent:t.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[s.browser," on ",s.os]}),t.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[t.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",t.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",mc(t.createdAt)]}),n&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function pc(t){if(!t)return{browser:"Unknown browser",os:"Unknown device"};let s="Unknown browser";t.includes("Chrome")&&!t.includes("Edg")?s="Chrome":t.includes("Safari")&&!t.includes("Chrome")?s="Safari":t.includes("Firefox")?s="Firefox":t.includes("Edg")&&(s="Edge");let n="Unknown device";return t.includes("Windows")?n="Windows":t.includes("Mac")?n="macOS":t.includes("Linux")?n="Linux":t.includes("iPhone")||t.includes("iPad")?n="iOS":t.includes("Android")&&(n="Android"),{browser:s,os:n}}function mc(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),r=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),c=Math.floor(o/(1e3*60*60*24));return r<1?"just now":r<60?`${r} minute${r>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function gc(t){const s=new Date(t),n=new Date,o=3600*1e3;return s.getTime()-n.getTime()<o}function wc({userAgent:t}){return t?.includes("iPhone")||t?.includes("iPad")||t?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function bc(){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 so({words:t,onConfirm:s,className:n=""}){const[o,r]=d.useState(!1),[a,c]=d.useState(!1),i=d.useRef(null),l=Hi(t),u=d.useCallback(async()=>{try{await navigator.clipboard.writeText(t.join(" ")),r(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>r(!1),2e3)}catch{}},[t]);d.useEffect(()=>()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]);const f=d.useCallback(()=>{a&&s()},[a,s]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${n}`,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((h,m)=>e.jsx("div",{className:"cedros-word-group",children:h.map((b,g)=>{const p=m*4+g+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[p,"."]}),e.jsx("span",{className:"cedros-word-text",children:b})]},p)})},m))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,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:h=>c(h.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:f,disabled:!a,children:"Continue"})]})]})}function ro({onSubmit:t,onCancel:s,isSubmitting:n=!1,error:o,className:r=""}){const[a,c]=d.useState(Array(ue).fill("")),[i,l]=d.useState(null),[u,f]=d.useState([]),[h,m]=d.useState(null),b=d.useId(),g=d.useRef(null),p=d.useCallback((w,v)=>{const A=[...a];if(A[w]=v.toLowerCase().trim(),c(A),v.length>0){const x=zi(v,5);f(x)}else f([]);m(null)},[a]),k=d.useCallback(w=>{l(w),f([])},[]),y=d.useCallback(w=>{const v=a[w];v&&!ct(v)&&m(`Word ${w+1} is not in the wordlist`),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{i===w&&f([])},200)},[a,i]);d.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]);const N=d.useCallback(w=>{if(i!==null){const v=[...a];v[i]=w,c(v),f([]),document.querySelector(`[data-word-index="${i+1}"]`)?.focus()}},[i,a]),j=d.useCallback(w=>{const v=w.clipboardData.getData("text"),A=Vi(v);A.length===ue&&(w.preventDefault(),c(A),m(null))},[]),C=d.useCallback(w=>{if(w.preventDefault(),a.filter(x=>!x).length>0){m(`Please enter all ${ue} words`);return}const A=a.map((x,E)=>({word:x,index:E+1})).filter(({word:x})=>!ct(x));if(A.length>0){m(`Invalid words: ${A.map(x=>`#${x.index}`).join(", ")}`);return}if(!$n(a)){m("Invalid recovery phrase - please check your words");return}t(a)},[a,t]),L=o||h;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${r}`,onSubmit:C,onPaste:j,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:ue},(w,v)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[v+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${a[v]&&!ct(a[v])?"cedros-word-invalid":a[v]&&ct(a[v])?"cedros-word-valid":""}`,value:a[v],onChange:A=>p(v,A.target.value),onFocus:()=>k(v),onBlur:()=>y(v),"data-word-index":v,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:n,"aria-label":`Word ${v+1}`})]},v))}),i!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${b}-suggestions`,children:u.map(w=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>N(w),role:"option",children:w},w))}),L&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:L}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:s,disabled:n,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:n,children:n?"Recovering...":"Recover Wallet"})]})]})}function yc({capabilities:t,className:s=""}){if(t.allSupported)return null;const n=I.getMissingCapabilitiesMessage(t),o=I.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${s}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:n}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",o.browser," ",o.version,o.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:t.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",t.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:t.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",t.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:t.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",t.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",t.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",t.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:t.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",t.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const xc=["share_c_only","full_seed","none"];function Ac(t){return t&&xc.includes(t)?t:"share_c_only"}const vc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function no(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(null),[o,r]=d.useState(!!t),[a,c]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts}):null,[t]),l=d.useCallback(async()=>{if(i){r(!0),c(null);try{const u=await i.get("/discovery");u.wallet?n({enabled:u.wallet.enabled,recoveryMode:Ac(u.wallet.recoveryMode),unlockTtlSeconds:u.wallet.unlockTtlSeconds}):n({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(u){const f=u instanceof Error?u.message:"Failed to fetch wallet config";c(f),n({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{r(!1)}}},[i]);return d.useEffect(()=>{i&&l()},[i,l]),t?{walletEnabled:s?.enabled??!1,recoveryMode:s?.recoveryMode??"share_c_only",unlockTtlSeconds:s?.unlockTtlSeconds??900,isLoading:o,error:a,refetch:l}:vc}function oo(){const{user:t}=T.useCedrosLogin(),{enroll:s}=I.useWalletMaterial(),{recoveryMode:n}=no(),[o,r]=d.useState({step:"idle"}),[a,c]=d.useState(!1),i=d.useRef([]),l=d.useCallback(()=>{I.wipeAll(...i.current),i.current=[]},[]);d.useEffect(()=>()=>{l()},[l]);const u=d.useCallback(async(g,p,k,y)=>{r({step:"generating_seed"});const N=I.generateSeed();i.current.push(N),r({step:"splitting_shares"});const{shareA:j,shareB:C,shareC:L}=Un(N);i.current.push(j,C,L),r({step:"encrypting_shares"});const w=await I.aesGcmEncryptToBase64(j,I.toEncryptionKey(p)),v=Dn(N),A=_n(v);r({step:"uploading"});const x={solanaPubkey:A,shareAAuthMethod:g,shareACiphertext:w.ciphertext,shareANonce:w.nonce,shareB:I.uint8ArrayToBase64(C)};if(g==="password"){if(!k)throw new Error("KDF salt required for password method");x.shareAKdfSalt=I.uint8ArrayToBase64(k),x.shareAKdfParams=I.DEFAULT_KDF_PARAMS}if(g==="passkey"&&y&&(x.prfSalt=y),await s(x),n==="none")l(),r({step:"complete",solanaPubkey:A});else{const E=n==="full_seed"?Wi(N):Fi(I.toShamirShare(L));r({step:"showing_recovery",recoveryPhrase:E,solanaPubkey:A})}},[s,n,l]),f=d.useCallback(async g=>{if(!t){r({step:"error",error:"User not authenticated"});return}c(!0),l();try{const p=I.generateArgon2Salt(),k=await pn(g,p,I.DEFAULT_KDF_PARAMS);i.current.push(k),await u("password",k,p)}catch(p){r({step:"error",error:p instanceof Error?p.message:"Enrollment failed"})}finally{c(!1)}},[t,l,u]),h=d.useCallback(async()=>{if(!t){r({step:"error",error:"User not authenticated"});return}c(!0),l();try{const g=I.generatePrfSalt(),p=I.uint8ArrayToBase64(g);r({step:"encrypting_shares"});const y=(await I.authenticateWithDiscoverablePrf(p)).prfOutput;i.current.push(y);const N=await I.deriveKeyFromPrf(y,g);i.current.push(N),await u("passkey",N,void 0,p)}catch(g){r({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{c(!1)}},[t,l,u]),m=d.useCallback(()=>{const g=o.solanaPubkey;l(),r({step:"complete",solanaPubkey:g})},[o.solanaPubkey,l]),b=d.useCallback(()=>{l(),r({step:"idle"}),c(!1)},[l]);return{state:o,startEnrollmentWithPassword:f,startEnrollmentWithPasskey:h,confirmRecoveryPhrase:m,cancel:b,isEnrolling:a}}function ao(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(null),c=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken]);return{setPassword:d.useCallback(async l=>{o(!0),a(null);try{await c.post("/set-password",{password:l})}catch(u){const f=T.handleApiError(u,"Failed to set password");throw a(f),f}finally{o(!1)}},[c]),isLoading:n,error:r}}function jc(t){return t.includes("email")?"password":t.includes("webauthn")?"passkey":"set-password"}function io({onComplete:t,onCancel:s,className:n=""}){const{user:o}=T.useCedrosLogin(),{state:r,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:c,confirmRecoveryPhrase:i,cancel:l,isEnrolling:u}=oo(),{setPassword:f,isLoading:h}=ao(),m=o?jc(o.authMethods):"password",[b,g]=d.useState(""),[p,k]=d.useState(""),[y,N]=d.useState(null);d.useEffect(()=>{g(""),k(""),N(null)},[o?.id]);const j=d.useCallback(async x=>{x.preventDefault(),N(null),await a(b)},[b,a]),C=d.useCallback(async x=>{if(x.preventDefault(),b!==p){N("Passwords do not match");return}const E=Re.validatePassword(b);if(!E.isValid){const P=Object.values(E.errors)[0];N(P??"Password does not meet requirements");return}N(null);try{await f(b),await a(b)}catch{}},[b,p,f,a]),L=d.useCallback(async()=>{await c()},[c]),w=d.useCallback(()=>{i(),r.solanaPubkey&&t?.(r.solanaPubkey)},[i,r.solanaPubkey,t]),v=d.useCallback(()=>{l(),s?.()},[l,s]),A=u||h;return r.step==="generating_seed"||r.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,"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..."})]})}):r.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,"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..."})]})}):r.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,"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..."})]})}):r.step==="showing_recovery"&&r.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,children:e.jsx(so,{words:r.recoveryPhrase,onConfirm:w})}):r.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,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:"})," ",r.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):r.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,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:r.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,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 ${n}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),m==="password"&&e.jsx("p",{children:"Enter your account password to secure your wallet."}),m==="passkey"&&e.jsx("p",{children:"Authenticate with your passkey to secure your wallet."}),m==="set-password"&&e.jsx("p",{children:"Set a password for your account to secure your wallet."})]}),m==="password"&&e.jsxs("form",{onSubmit:j,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"Account Password",value:b,onChange:x=>g(x.target.value),disabled:A,required:!0,placeholder:"Enter your account password"}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:A||!b,children:A?"Creating...":"Continue"})]})]}),m==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:L,disabled:A,children:A?"Creating...":"Use Passkey"})]})]}),m==="set-password"&&e.jsxs("form",{onSubmit:C,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"New Password",value:b,onChange:x=>g(x.target.value),showStrengthMeter:!0,disabled:A,required:!0,minLength:8,placeholder:"Choose a strong password"}),e.jsx(Q.PasswordInput,{label:"Confirm Password",value:p,onChange:x=>k(x.target.value),error:y??void 0,disabled:A,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will also be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:A||!b||!p,children:A?"Creating...":"Continue"})]})]})]})}function co(){const{user:t}=T.useCedrosLogin(),{signTransaction:s}=I.useWalletMaterial(),[n,o]=d.useState(!1),[r,a]=d.useState(null),c=d.useCallback(async(l,u)=>{if(!t){const f="User not authenticated";throw a(f),new Error(f)}o(!0),a(null);try{const f={transaction:I.uint8ArrayToBase64(l),...u?{credential:I.toCredentialRequest(u)}:{}},h=await s(f);return I.base64ToUint8Array(h.signature)}catch(f){const h=f instanceof Error?f.message:"Signing failed";throw a(h),f}finally{o(!1)}},[t,s]),i=d.useCallback(()=>a(null),[]);return{signTransaction:c,isSigning:n,error:r,clearError:i}}function lo(){const{getMaterial:t}=I.useWalletMaterial(),[s,n]=d.useState(!1),[o,r]=d.useState(null),a=d.useCallback(async()=>{n(!0),r(null);try{const i=await t();if(!i)throw new Error("No wallet enrolled");if(i.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!i.prfSalt)throw new Error("No PRF salt configured for wallet");const l=await I.authenticateWithDiscoverablePrf(i.prfSalt);try{return{type:"prfOutput",prfOutput:I.uint8ArrayToBase64(l.prfOutput)}}finally{l.prfOutput.fill(0)}}catch(i){const l=i instanceof Error?i.message:"Passkey authentication failed";return r(l),null}finally{n(!1)}},[t]),c=d.useCallback(()=>r(null),[]);return{getPasskeyCredential:a,isAuthenticating:s,error:o,clearError:c}}function uo({mode:t,isLoading:s=!1,error:n,onPrompt:o,onRetry:r,onCancel:a,title:c,description:i,className:l=""}){const u=d.useCallback(()=>{s||o?.()},[s,o]),f=d.useCallback(()=>{r?.()},[r]),h=t==="register"?"Set Up Passkey":"Verify with Passkey",m=t==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${l}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:s?e.jsx(Nc,{}):n?e.jsx(Cc,{}):e.jsx(kc,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:c??h}),e.jsx("p",{className:"cedros-passkey-description",children:i??m}),n&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:n})}),e.jsx("div",{className:"cedros-passkey-actions",children:n?e.jsxs(e.Fragment,{children:[r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:f,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:u,disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):t==="register"?"Create Passkey":"Use Passkey"}),a&&!s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]})}),s&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",t==="register"?"create":"verify"," your passkey."]})]})}function kc(){return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4"}),e.jsx("path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88"}),e.jsx("path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02"}),e.jsx("path",{d:"M2 12a10 10 0 0 1 18-6"}),e.jsx("path",{d:"M2 16h.01"}),e.jsx("path",{d:"M21.8 16c.2-2 .131-5.354 0-6"}),e.jsx("path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2"}),e.jsx("path",{d:"M8.65 22c.21-.66.45-1.32.57-2"}),e.jsx("path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2"})]})}function Nc(){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 Cc(){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 ho({onUnlock:t,onCancel:s,showCancel:n=!0,authMethod:o,className:r=""}){T.useCedrosLogin();const{unlock:a,getMaterial:c,isLoading:i}=I.useWalletMaterial(),{getPasskeyCredential:l,isAuthenticating:u}=lo(),[f,h]=d.useState("idle"),[m,b]=d.useState(o??null),[g,p]=d.useState(""),[k,y]=d.useState(null);d.useEffect(()=>{o!==void 0&&b(o)},[o]);const N=m==="password",j=m==="passkey",C=d.useCallback(async()=>{if(h("credential"),y(null),!m)try{const P=await c();P?b(P.shareAAuthMethod):(y("No wallet enrolled"),h("error"))}catch(P){y(P instanceof Error?P.message:"Failed to get wallet info"),h("error")}},[m,c]),L=d.useCallback(async P=>{P.preventDefault(),y(null),h("unlocking");try{let S;if(N)S={type:"password",password:g};else throw new Error("Invalid auth method");await a(S),h("unlocked"),t?.()}catch(S){y(S instanceof Error?S.message:"Failed to unlock wallet"),h("error")}},[N,g,a,t]),w=d.useCallback(async()=>{y(null),h("unlocking");try{const P=await l();if(!P){h("credential");return}await a(P),h("unlocked"),t?.()}catch(P){y(P instanceof Error?P.message:"Failed to unlock wallet"),h("error")}},[l,a,t]),v=d.useCallback(()=>{p(""),h("idle"),y(null),s?.()},[s]),A=d.useCallback(()=>{p(""),h("credential"),y(null)},[]),x=i||u,E=()=>{switch(f){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Sc,{})}),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:C,children:"Unlock Wallet"})]});case"credential":return N?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:L,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(Q.PasswordInput,{label:"Password",value:g,onChange:P=>p(P.target.value),disabled:x,autoComplete:"current-password",error:k??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:x||g.length===0,children:x?"Unlocking...":"Unlock"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:x,children:"Cancel"})]})]}):j?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(uo,{mode:"authenticate",isLoading:x,error:k??void 0,onPrompt:w,onRetry:w,onCancel:n?v: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(Ec,{})}),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(Lc,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:k??"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:A,children:"Try Again"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${r}`,children:E()})}function Sc(){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 Ec(){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 Lc(){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 fo(){const{recover:t,getShareBForRecovery:s}=I.useWalletMaterial(),{recoveryMode:n}=no(),[o,r]=d.useState({step:"idle"}),[a,c]=d.useState(!1),i=d.useRef([]),l=d.useCallback(()=>{I.wipeAll(...i.current),i.current=[]},[]);d.useEffect(()=>()=>{l()},[l]);const u=d.useCallback(async(h,m,b)=>{c(!0),l();try{if(r({step:"validating"}),!$n(h))throw new Error("Invalid recovery phrase. Please check your words.");let g;if(n==="share_c_only"){const A=Oi(h);i.current.push(A);const x=I.uint8ArrayToBase64(A),E=await s({shareC:x}),P=I.base64ToUint8Array(E.shareB);i.current.push(P),g=Ci(I.toShamirShare(P),I.toShamirShare(A)),i.current.push(g)}else g=qi(h),i.current.push(g);const p=Dn(g),k=_n(p),{shareA:y,shareB:N}=Un(g);i.current.push(y,N),r({step:"encrypting"});let j,C,L;if(m==="passkey"){const A=I.generatePrfSalt();L=I.uint8ArrayToBase64(A);const x=await I.authenticateWithDiscoverablePrf(L);i.current.push(x.prfOutput),j=await I.deriveKeyFromPrf(x.prfOutput,A),i.current.push(j)}else C=I.generateArgon2Salt(),j=await pn(b,C,I.DEFAULT_KDF_PARAMS),i.current.push(j);const w=await I.aesGcmEncryptToBase64(y,I.toEncryptionKey(j));r({step:"uploading"});const v={solanaPubkey:k,shareAAuthMethod:m,shareACiphertext:w.ciphertext,shareANonce:w.nonce,shareB:I.uint8ArrayToBase64(N)};m==="password"&&(v.shareAKdfSalt=I.uint8ArrayToBase64(C),v.shareAKdfParams=I.DEFAULT_KDF_PARAMS),m==="passkey"&&(v.prfSalt=L),await t(v),l(),r({step:"complete"})}catch(g){l(),r({step:"error",error:g instanceof Error?g.message:"Recovery failed"})}finally{c(!1)}},[t,s,n,l]),f=d.useCallback(()=>{l(),r({step:"idle"}),c(!1)},[l]);return{state:o,startRecovery:u,cancel:f,isRecovering:a}}function po({onComplete:t,onCancel:s,className:n="",defaultAuthMethod:o="password"}){const{state:r,startRecovery:a,cancel:c,isRecovering:i}=fo(),[l,u]=d.useState([]),[f,h]=d.useState(!1),[m,b]=d.useState(o),[g,p]=d.useState(""),[k,y]=d.useState(""),[N,j]=d.useState(null),C=d.useCallback(x=>{u(x),h(!0)},[]),L=d.useCallback(async x=>{if(x.preventDefault(),j(null),m!=="passkey"){if(g!==k){j("Passwords do not match");return}if(m==="password"&&g.length<8){j("Password must be at least 8 characters");return}}await a(l,m,g)},[l,m,g,k,a]),w=d.useCallback(()=>{c(),u([]),h(!1),p(""),y(""),s?.()},[c,s]),v=d.useCallback(()=>{h(!1),p(""),y("")},[]),A=d.useCallback(()=>{t?.()},[t]);return r.step==="validating"||r.step==="encrypting"||r.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${n}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Pc,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[r.step==="validating"&&"Validating Recovery Phrase",r.step==="encrypting"&&"Encrypting Wallet",r.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[r.step==="validating"&&"Checking your recovery phrase...",r.step==="encrypting"&&"Securing your wallet with new encryption...",r.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):r.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${n}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Bc,{})}),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"," ",m==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:A,children:"Done"})})]})}):r.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${n}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Mc,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:r.error??"An error occurred during recovery. Please try again."}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:w,children:"Start Over"})})]})}):f?e.jsx("div",{className:`cedros-wallet-recovery ${n}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:L,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:m==="password",onChange:()=>b("password"),disabled:i}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:m==="passkey",onChange:()=>b("passkey"),disabled:i}),e.jsx("span",{children:"Passkey"})]})]}),m==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:g,onChange:x=>p(x.target.value),disabled:i,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:k,onChange:x=>y(x.target.value),disabled:i,"aria-invalid":N?"true":void 0,placeholder:"Confirm your password"}),N&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:N})]})]}),m==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(Rc,{}),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:v,disabled:i,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:i||m!=="passkey"&&(g.length===0||k.length===0),children:i?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${n}`,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(ro,{onSubmit:C,onCancel:w,isSubmitting:!1})]})})}function Pc(){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 Bc(){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 Mc(){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 Rc(){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 mo({address:t,label:s="Wallet Address",showCopy:n=!0,showExplorerLink:o=!0,allowReveal:r=!0,className:a=""}){const c=T.useCedrosLoginOptional(),[i,l]=d.useState(!1),[u,f]=d.useState(null),[h,m]=d.useState(!1),b=d.useRef(null),g=c?.config.solana?.network??"mainnet-beta",p=d.useMemo(()=>{const j=`https://explorer.solana.com/address/${t}`;return g==="mainnet-beta"?j:`${j}?cluster=${encodeURIComponent(g)}`},[t,g]),k=r&&t.length>18,y=d.useMemo(()=>!k||h?t:`${t.slice(0,8)}...${t.slice(-8)}`,[t,k,h]),N=d.useCallback(async()=>{try{f(null),await navigator.clipboard.writeText(t),l(!0),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{l(!1),b.current=null},2e3)}catch(j){l(!1),f(j instanceof Error?j.message:"Copy failed")}},[t]);return d.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${a}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:s}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[k&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>m(j=>!j),"aria-label":h?"Hide full wallet address":"Show full wallet address",children:h?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:p,target:"_blank",rel:"noreferrer",children:"Explorer"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:N,"aria-label":"Copy wallet address",children:i?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:t,children:y}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function go({status:t,publicKey:s,onLock:n,onEnroll:o,onUnlock:r,onRecover:a,showActions:c=!0,compact:i=!1,className:l=""}){const u=t!==void 0,f=I.useWallet(),h=u?t:f.status,m=u?s??null:f.solanaPubkey,b=u?null:f.error,g=u?()=>{}:f.refresh,p=u?()=>{}:f.clearError,k=Tc(h,b);return i?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${l}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${k.color}`,title:k.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:k.label}),m&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:m,children:Ic(m)})]}):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-${k.color}`,children:e.jsx(Dc,{status:h})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:k.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:k.description})]})]}),m&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(mo,{address:m})}),b&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:p,children:"Dismiss"})]}),c&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[h==="not_enrolled"&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:o,children:"Create Wallet"}),h==="enrolled_locked"&&r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:r,children:"Unlock Wallet"}),(h==="not_enrolled"||h==="error")&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:"Recover Wallet"}),h==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:g,children:"Retry"})]})]})}function Tc(t,s){switch(t){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:s??"An error occurred with your wallet.",color:"error"}}}function Ic(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function Dc({status:t}){switch(t){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function _c({className:t="",showActions:s=!0}){const n=I.useWallet(),[o,r]=d.useState("status"),a=d.useMemo(()=>{switch(o){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[o]),c=d.useCallback(()=>r("status"),[]),i=d.useCallback(async()=>{r("status"),await n.refresh()},[n]),l=d.useCallback(async()=>{r("status"),await n.refresh()},[n]),u=d.useCallback(async()=>{r("status"),await n.refresh()},[n]);return e.jsxs("div",{className:`cedros-wallet-manager ${t}`,children:[o!=="status"&&a&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:a.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:a.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:c,children:"Back"})]}),o==="status"&&e.jsx(go,{onEnroll:()=>r("enroll"),onUnlock:()=>r("unlock"),onRecover:()=>r("recover_intro"),showActions:s}),o==="enroll"&&e.jsx(io,{onComplete:()=>{i()},onCancel:c}),o==="unlock"&&e.jsx(ho,{onUnlock:()=>{l()},onCancel:c}),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:()=>r("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:c,children:"Cancel"})]})]})}),o==="recover"&&e.jsx(po,{onComplete:()=>{u()},onCancel:c})]})}function Uc({showDescriptions:t=!0,className:s="",onSave:n}){const{settings:o,isLoading:r,isUpdating:a,error:c,fetchSettings:i,updateSettings:l}=ln.useSystemSettings(),[u,f]=d.useState({}),[h,m]=d.useState(null),[b,g]=d.useState(!1);d.useEffect(()=>{i()},[i]),d.useEffect(()=>{if(b){const L=setTimeout(()=>g(!1),3e3);return()=>clearTimeout(L)}},[b]);const p=d.useCallback((L,w)=>{f(v=>({...v,[L]:w})),m(null),g(!1)},[]),k=d.useCallback(async()=>{const L=Object.entries(u).map(([w,v])=>({key:w,value:v}));if(L.length!==0)try{await l(L),f({}),m(null),g(!0),n?.()}catch(w){m(w instanceof Error?w.message:"Failed to save settings")}},[u,l,n]),y=d.useCallback(()=>{f({}),m(null),g(!1)},[]),N=Object.keys(u).length>0,j=Object.keys(u).length;if(r&&Object.keys(o).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(c)return e.jsx("div",{className:`cedros-system-settings ${s}`,children:e.jsx(Z.ErrorMessage,{error:c.message})});const C=Object.keys(o).sort();return C.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${s}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${s}`,children:[h&&e.jsx(Z.ErrorMessage,{error:h}),b&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),C.map(L=>e.jsx(Fc,{category:L,settings:o[L],edits:u,showDescription:t,onChange:p},L)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[N&&e.jsxs("span",{className:"cedros-settings-change-count",children:[j," unsaved change",j!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:y,disabled:!N||a,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:k,disabled:!N||a,children:a?e.jsx(z.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const Er=Object.keys(We.SETTING_METADATA);function Fc({category:t,settings:s,edits:n,showDescription:o,onChange:r}){const a=We.CATEGORY_METADATA[t]||{label:t,description:"",icon:""},c=d.useMemo(()=>[...s].sort((i,l)=>{const u=Er.indexOf(i.key),f=Er.indexOf(l.key);return(u===-1?1/0:u)-(f===-1?1/0:f)}),[s]);return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:a.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:a.label}),o&&a.description&&e.jsx("p",{className:"cedros-settings-section-description",children:a.description})]})]}),e.jsx(We.SettingsSection,{settings:c,edits:n,onChange:r})]})}class Oc{client;constructor(s,n,o){this.client=new T.ApiClient({baseUrl:s,timeoutMs:n,retryAttempts:o})}async getStatus(){try{return await this.client.get("/setup/status")}catch(s){throw T.handleApiError(s,"Failed to check setup status")}}async createFirstAdmin(s){try{return await this.client.post("/setup/admin",s)}catch(n){throw T.handleApiError(n,"Failed to create admin account")}}}function zs(){const{config:t}=T.useCedrosLogin(),[s,n]=d.useState(null),[o,r]=d.useState(!1),[a,c]=d.useState(!1),[i,l]=d.useState(null),u=d.useRef(0),f=d.useMemo(()=>new Oc(t.serverUrl,t.requestTimeout,t.retryAttempts),[t.serverUrl,t.requestTimeout,t.retryAttempts]),h=d.useRef(f);h.current=f;const m=d.useCallback(async()=>{r(!0),l(null);const g=++u.current;try{const p=await h.current.getStatus();if(g!==u.current)return;n(p)}catch(p){if(g!==u.current)return;l(p instanceof Error?p:new Error("Failed to check setup status"))}finally{g===u.current&&r(!1)}},[]),b=d.useCallback(async g=>{c(!0),l(null);try{const p=await h.current.createFirstAdmin(g);return await m(),p}catch(p){const k=p instanceof Error?p:new Error("Failed to create admin");throw l(k),k}finally{c(!1)}},[m]);return{status:s,isLoading:o,isCreating:a,error:i,checkStatus:m,createAdmin:b}}const Wc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Lr=8;function qc(t){const s={};return t.email?Wc.test(t.email)||(s.email="Invalid email format"):s.email="Email is required",t.password?t.password.length<Lr&&(s.password=`Password must be at least ${Lr} characters`):s.password="Password is required",t.confirmPassword?t.password!==t.confirmPassword&&(s.confirmPassword="Passwords do not match"):s.confirmPassword="Please confirm your password",s}function wo({onComplete:t,className:s=""}){const{status:n,isLoading:o,isCreating:r,error:a,checkStatus:c,createAdmin:i}=zs(),[l,u]=d.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[f,h]=d.useState({}),[m,b]=d.useState(!1);d.useEffect(()=>{c()},[c]);const g=d.useCallback(k=>y=>{u(N=>({...N,[k]:y.target.value})),h(N=>({...N,[k]:void 0}))},[]),p=d.useCallback(async k=>{k.preventDefault();const y=qc(l);if(Object.keys(y).length>0){h(y);return}try{await i({email:l.email,password:l.password,name:l.name||void 0,orgName:l.orgName||void 0}),b(!0),t?.()}catch{}},[l,i,t]);return o?e.jsx("div",{className:`cedros-setup ${s}`,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..."})]})}):n&&!n.needsSetup?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):m?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:p,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 ${f.email?"cedros-setup__input--error":""}`,value:l.email,onChange:g("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:r}),f.email&&e.jsx("span",{className:"cedros-setup__error",children:f.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:g("name"),placeholder:"Admin",autoComplete:"name",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:l.orgName,onChange:g("orgName"),placeholder:"My Organization",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${f.password?"cedros-setup__input--error":""}`,value:l.password,onChange:g("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:r}),f.password&&e.jsx("span",{className:"cedros-setup__error",children:f.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 ${f.confirmPassword?"cedros-setup__input--error":""}`,value:l.confirmPassword,onChange:g("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:r}),f.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:f.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:r,children:r?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."}),n?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",n.serverVersion]})]})]})})}const zc=["security","rate_limit"];function Hc({className:t}){return e.jsx(Rs.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:zc,className:t})}const Pr=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Vc({className:t}){const{settings:s,edits:n,isLoading:o,autosaveStatus:r,autosaveError:a,error:c,fetchSettings:i,handleChange:l,getEffectiveValue:u}=We.useSettingsAutosave(),[f,h]=d.useState("email");d.useEffect(()=>{i()},[i]);const m=Pr.find(C=>C.id===f),b=m?.category??"",p=(u("email_provider")||"custom")==="custom",k=u("email_smtp_host"),y=!p||k!=null&&k!=="",N=d.useMemo(()=>{const C=s[b]??[];if(f!=="email")return C;const L=p?ut.ALL_EMAIL_FIELDS:ut.SIMPLIFIED_EMAIL_FIELDS;return C.filter(w=>L.includes(w.key)).sort((w,v)=>L.indexOf(w.key)-L.indexOf(v.key))},[s,b,f,p]),j=(C,L)=>{if(l(C,L),C==="email_provider"&&L!=="custom"){const w=ut.PROVIDER_SMTP_HOSTS[L];w&&(l("email_smtp_host",w),l("email_smtp_port","587"),l("email_smtp_tls","true"))}};return o&&Object.keys(s).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t??""}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${t??""}`,children:e.jsx(Z.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${t??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(We.AutosaveStatus,{status:r,error:a})]}),f==="email"&&!y&&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:Pr.map(C=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${f===C.id?"cedros-admin-tab-active":""}`,onClick:()=>h(C.id),"aria-selected":f===C.id,role:"tab",children:C.label},C.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:N.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",m?.label??"this section","."]})}):e.jsx(We.SettingsSection,{settings:N,edits:n,onChange:f==="email"?j:l})})]})}const fe={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]})},$c=[{id:"users",label:"Users",icon:fe.users},{id:"team",label:"Team",icon:fe.members},{id:"deposits",label:"Deposits",icon:fe.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:fe.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:fe.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:fe.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:fe.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:fe.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:fe.server,group:"Configuration"}];function Gc({title:t="Dashboard",sections:s=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],defaultSection:n="users",refreshInterval:o=0,pageSize:r=20,onSectionChange:a,onSettingsClick:c,onLogoutClick:i,className:l=""}){const[u,f]=d.useState(n),[h,m]=d.useState(!0),{user:b,logout:g}=T.useCedrosLogin(),{activeOrg:p,role:k,isLoading:y,fetchOrgs:N,hasPermission:j}=Bs.useOrgs(),{status:C,isLoading:L,checkStatus:w}=zs(),{features:v,isLoading:A}=ce.useServerFeatures(),{canAccess:x}=ce.useDashboardPermissions(),E=d.useCallback(R=>{f(R),a?.(R)},[a]),P=$c.filter(R=>!(!s.includes(R.id)||R.requiredFeature&&!v[R.requiredFeature]||!x(R.id))),S=P.find(R=>R.id===u),B=!S&&!A;return d.useEffect(()=>{N(),w()},[N,w]),d.useEffect(()=>{B&&P.length>0&&f("users")},[B,P.length]),!L&&C?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${l}`,children:e.jsx(wo,{onComplete:()=>w()})}):(y||L||A)&&!p?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..."})]}):u==="team"&&!p?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:[fe.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:t})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),P.filter(R=>!R.group).map(R=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===R.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>E(R.id),"aria-current":u===R.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:R.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:R.label})]},R.id))]}),P.some(R=>R.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:()=>m(!h),"aria-expanded":h,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${h?"cedros-dashboard__nav-chevron--expanded":""}`,children:fe.chevronRight})]}),h&&P.filter(R=>R.group==="Configuration").map(R=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===R.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>E(R.id),"aria-current":u===R.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:R.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:R.label})]},R.id))]})]}),b&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(Pe.ProfileDropdown,{name:b.name,email:b.email,picture:b.picture,onSettings:c,onLogout:i??g})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:t}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:fe.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:S?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(Qc,{pageSize:r,currentUserId:b?.id}),u==="team"&&p&&e.jsx(Kc,{orgId:p.id,currentUserId:b?.id,hasPermission:j,role:k}),u==="deposits"&&e.jsx(Yc,{pageSize:r,refreshInterval:o}),u==="withdrawals"&&e.jsx(Zc,{pageSize:r,refreshInterval:o}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(un.AuthenticationSettings,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(hn.EmbeddedWalletSettings,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Vc,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ms.CreditSystemSettings,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(fn.ServerSettings,{})})]})]})]})}function Qc({pageSize:t,currentUserId:s}){const[n,o]=d.useState(null),{statsItems:r,isLoading:a,error:c,refresh:i}=Ze.useUsersStatsSummary();return n?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ze.AdminUserDetail,{userId:n.id,currentUserId:s,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(dn.StatsBar,{stats:r,isLoading:a,onRefresh:i}),c&&e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx(Ze.AdminUserList,{pageSize:t,currentUserId:s,onUserClick:l=>o(l)})]})}function Kc({orgId:t,currentUserId:s,hasPermission:n,role:o}){const[r,a]=d.useState("members"),{members:c,isLoading:i,error:l,fetchMembers:u,updateMemberRole:f,removeMember:h}=ce.useMembers(t),{invites:m,isLoading:b,error:g,fetchInvites:p,createInvite:k,cancelInvite:y,resendInvite:N}=ce.useInvites(t);d.useEffect(()=>{u(),p()},[u,p]);const j=n("invite:create"),C=n("invite:cancel"),L=m.length,w=c.reduce((E,P)=>(E[P.role]=(E[P.role]??0)+1,E),{}),v=w.owner??0,A=w.admin??0,x=w.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(dn.StatsBar,{stats:[{label:"Owners",value:v},{label:"Admins",value:A},{label:"Members",value:x},{label:"Pending Invites",value:L}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="members"?"cedros-admin-tab-active":""}`,onClick:()=>a("members"),"aria-selected":r==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${r==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>a("invites"),"aria-selected":r==="invites",role:"tab",children:["Pending Invites",L>0&&` (${L})`]}),o==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>a("permissions"),"aria-selected":r==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[r==="members"&&e.jsx(ce.MemberList,{members:c,currentUserId:s,isLoading:i,error:l?.message,canManage:n("member:remove"),canChangeRoles:n("member:role_change"),onUpdateRole:f,onRemove:h}),r==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[j&&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(ce.InviteForm,{onSubmit:k,isLoading:b,error:g?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(ce.InviteList,{invites:m,isLoading:b,error:g?.message,canManage:C||j,onCancel:C?y:void 0,onResend:j?N:void 0})})]}),r==="permissions"&&o==="owner"&&e.jsx(ce.PermissionsSection,{userRole:o})]})]})}function Yc({pageSize:t,refreshInterval:s}){const[n,o]=d.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(mt.AdminDepositStats,{refreshInterval:s}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:n,onChange:r=>o(r.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(mt.AdminDepositList,{statusFilter:n||void 0,pageSize:t,refreshInterval:s})]})]})}function Zc({pageSize:t,refreshInterval:s}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Le.AdminWithdrawalStats,{refreshInterval:s}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(Le.AdminPrivacyPeriodDeposits,{pageSize:t,refreshInterval:s}),e.jsx(Le.AdminWithdrawalQueue,{pageSize:t,refreshInterval:s}),e.jsx(Le.AdminWithdrawalHistory,{pageSize:t,refreshInterval:s})]})]})}var Fe={},Gt,Br;function Xc(){return Br||(Br=1,Gt=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Gt}var Qt={},Ee={},Mr;function Te(){if(Mr)return Ee;Mr=1;let t;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Ee.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},Ee.getSymbolTotalCodewords=function(o){return s[o]},Ee.getBCHDigit=function(n){let o=0;for(;n!==0;)o++,n>>>=1;return o},Ee.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');t=o},Ee.isKanjiModeEnabled=function(){return typeof t<"u"},Ee.toSJIS=function(o){return t(o)},Ee}var Kt={},Rr;function Hs(){return Rr||(Rr=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},t.from=function(o,r){if(t.isValid(o))return o;try{return s(o)}catch{return r}}})(Kt)),Kt}var Yt,Tr;function Jc(){if(Tr)return Yt;Tr=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const n=Math.floor(s/8);return(this.buffer[n]>>>7-s%8&1)===1},put:function(s,n){for(let o=0;o<n;o++)this.putBit((s>>>n-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),s&&(this.buffer[n]|=128>>>this.length%8),this.length++}},Yt=t,Yt}var Zt,Ir;function el(){if(Ir)return Zt;Ir=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,n,o,r){const a=s*this.size+n;this.data[a]=o,r&&(this.reservedBit[a]=!0)},t.prototype.get=function(s,n){return this.data[s*this.size+n]},t.prototype.xor=function(s,n,o){this.data[s*this.size+n]^=o},t.prototype.isReserved=function(s,n){return this.reservedBit[s*this.size+n]},Zt=t,Zt}var Xt={},Dr;function tl(){return Dr||(Dr=1,(function(t){const s=Te().getSymbolSize;t.getRowColCoords=function(o){if(o===1)return[];const r=Math.floor(o/7)+2,a=s(o),c=a===145?26:Math.ceil((a-13)/(2*r-2))*2,i=[a-7];for(let l=1;l<r-1;l++)i[l]=i[l-1]-c;return i.push(6),i.reverse()},t.getPositions=function(o){const r=[],a=t.getRowColCoords(o),c=a.length;for(let i=0;i<c;i++)for(let l=0;l<c;l++)i===0&&l===0||i===0&&l===c-1||i===c-1&&l===0||r.push([a[i],a[l]]);return r}})(Xt)),Xt}var Jt={},_r;function sl(){if(_r)return Jt;_r=1;const t=Te().getSymbolSize,s=7;return Jt.getPositions=function(o){const r=t(o);return[[0,0],[r-s,0],[0,r-s]]},Jt}var es={},Ur;function rl(){return Ur||(Ur=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},t.from=function(r){return t.isValid(r)?parseInt(r,10):void 0},t.getPenaltyN1=function(r){const a=r.size;let c=0,i=0,l=0,u=null,f=null;for(let h=0;h<a;h++){i=l=0,u=f=null;for(let m=0;m<a;m++){let b=r.get(h,m);b===u?i++:(i>=5&&(c+=s.N1+(i-5)),u=b,i=1),b=r.get(m,h),b===f?l++:(l>=5&&(c+=s.N1+(l-5)),f=b,l=1)}i>=5&&(c+=s.N1+(i-5)),l>=5&&(c+=s.N1+(l-5))}return c},t.getPenaltyN2=function(r){const a=r.size;let c=0;for(let i=0;i<a-1;i++)for(let l=0;l<a-1;l++){const u=r.get(i,l)+r.get(i,l+1)+r.get(i+1,l)+r.get(i+1,l+1);(u===4||u===0)&&c++}return c*s.N2},t.getPenaltyN3=function(r){const a=r.size;let c=0,i=0,l=0;for(let u=0;u<a;u++){i=l=0;for(let f=0;f<a;f++)i=i<<1&2047|r.get(u,f),f>=10&&(i===1488||i===93)&&c++,l=l<<1&2047|r.get(f,u),f>=10&&(l===1488||l===93)&&c++}return c*s.N3},t.getPenaltyN4=function(r){let a=0;const c=r.data.length;for(let l=0;l<c;l++)a+=r.data[l];return Math.abs(Math.ceil(a*100/c/5)-10)*s.N4};function n(o,r,a){switch(o){case t.Patterns.PATTERN000:return(r+a)%2===0;case t.Patterns.PATTERN001:return r%2===0;case t.Patterns.PATTERN010:return a%3===0;case t.Patterns.PATTERN011:return(r+a)%3===0;case t.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(a/3))%2===0;case t.Patterns.PATTERN101:return r*a%2+r*a%3===0;case t.Patterns.PATTERN110:return(r*a%2+r*a%3)%2===0;case t.Patterns.PATTERN111:return(r*a%3+(r+a)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}t.applyMask=function(r,a){const c=a.size;for(let i=0;i<c;i++)for(let l=0;l<c;l++)a.isReserved(l,i)||a.xor(l,i,n(r,l,i))},t.getBestMask=function(r,a){const c=Object.keys(t.Patterns).length;let i=0,l=1/0;for(let u=0;u<c;u++){a(u),t.applyMask(u,r);const f=t.getPenaltyN1(r)+t.getPenaltyN2(r)+t.getPenaltyN3(r)+t.getPenaltyN4(r);t.applyMask(u,r),f<l&&(l=f,i=u)}return i}})(es)),es}var lt={},Fr;function bo(){if(Fr)return lt;Fr=1;const t=Hs(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[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 lt.getBlocksCount=function(r,a){switch(a){case t.L:return s[(r-1)*4+0];case t.M:return s[(r-1)*4+1];case t.Q:return s[(r-1)*4+2];case t.H:return s[(r-1)*4+3];default:return}},lt.getTotalCodewordsCount=function(r,a){switch(a){case t.L:return n[(r-1)*4+0];case t.M:return n[(r-1)*4+1];case t.Q:return n[(r-1)*4+2];case t.H:return n[(r-1)*4+3];default:return}},lt}var ts={},Ke={},Or;function nl(){if(Or)return Ke;Or=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let o=1;for(let r=0;r<255;r++)t[r]=o,s[o]=r,o<<=1,o&256&&(o^=285);for(let r=255;r<512;r++)t[r]=t[r-255]})(),Ke.log=function(o){if(o<1)throw new Error("log("+o+")");return s[o]},Ke.exp=function(o){return t[o]},Ke.mul=function(o,r){return o===0||r===0?0:t[s[o]+s[r]]},Ke}var Wr;function ol(){return Wr||(Wr=1,(function(t){const s=nl();t.mul=function(o,r){const a=new Uint8Array(o.length+r.length-1);for(let c=0;c<o.length;c++)for(let i=0;i<r.length;i++)a[c+i]^=s.mul(o[c],r[i]);return a},t.mod=function(o,r){let a=new Uint8Array(o);for(;a.length-r.length>=0;){const c=a[0];for(let l=0;l<r.length;l++)a[l]^=s.mul(r[l],c);let i=0;for(;i<a.length&&a[i]===0;)i++;a=a.slice(i)}return a},t.generateECPolynomial=function(o){let r=new Uint8Array([1]);for(let a=0;a<o;a++)r=t.mul(r,new Uint8Array([1,s.exp(a)]));return r}})(ts)),ts}var ss,qr;function al(){if(qr)return ss;qr=1;const t=ol();function s(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(o){this.degree=o,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(o.length+this.degree);r.set(o);const a=t.mod(r,this.genPoly),c=this.degree-a.length;if(c>0){const i=new Uint8Array(this.degree);return i.set(a,c),i}return a},ss=s,ss}var rs={},ns={},os={},zr;function yo(){return zr||(zr=1,os.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),os}var we={},Hr;function xo(){if(Hr)return we;Hr=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
2050
- ]))+`;we.KANJI=new RegExp(n,"g"),we.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),we.BYTE=new RegExp(o,"g"),we.NUMERIC=new RegExp(t,"g"),we.ALPHANUMERIC=new RegExp(s,"g");const r=new RegExp("^"+n+"$"),a=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return we.testKanji=function(l){return r.test(l)},we.testNumeric=function(l){return a.test(l)},we.testAlphanumeric=function(l){return c.test(l)},we}var Vr;function Ie(){return Vr||(Vr=1,(function(t){const s=yo(),n=xo();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(a,c){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!s.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?a.ccBits[0]:c<27?a.ccBits[1]:a.ccBits[2]},t.getBestModeForData=function(a){return n.testNumeric(a)?t.NUMERIC:n.testAlphanumeric(a)?t.ALPHANUMERIC:n.testKanji(a)?t.KANJI:t.BYTE},t.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},t.isValid=function(a){return a&&a.bit&&a.ccBits};function o(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+r)}}t.from=function(a,c){if(t.isValid(a))return a;try{return o(a)}catch{return c}}})(ns)),ns}var $r;function il(){return $r||($r=1,(function(t){const s=Te(),n=bo(),o=Hs(),r=Ie(),a=yo(),c=7973,i=s.getBCHDigit(c);function l(m,b,g){for(let p=1;p<=40;p++)if(b<=t.getCapacity(p,g,m))return p}function u(m,b){return r.getCharCountIndicator(m,b)+4}function f(m,b){let g=0;return m.forEach(function(p){const k=u(p.mode,b);g+=k+p.getBitsLength()}),g}function h(m,b){for(let g=1;g<=40;g++)if(f(m,g)<=t.getCapacity(g,b,r.MIXED))return g}t.from=function(b,g){return a.isValid(b)?parseInt(b,10):g},t.getCapacity=function(b,g,p){if(!a.isValid(b))throw new Error("Invalid QR Code version");typeof p>"u"&&(p=r.BYTE);const k=s.getSymbolTotalCodewords(b),y=n.getTotalCodewordsCount(b,g),N=(k-y)*8;if(p===r.MIXED)return N;const j=N-u(p,b);switch(p){case r.NUMERIC:return Math.floor(j/10*3);case r.ALPHANUMERIC:return Math.floor(j/11*2);case r.KANJI:return Math.floor(j/13);case r.BYTE:default:return Math.floor(j/8)}},t.getBestVersionForData=function(b,g){let p;const k=o.from(g,o.M);if(Array.isArray(b)){if(b.length>1)return h(b,k);if(b.length===0)return 1;p=b[0]}else p=b;return l(p.mode,p.getLength(),k)},t.getEncodedBits=function(b){if(!a.isValid(b)||b<7)throw new Error("Invalid QR Code version");let g=b<<12;for(;s.getBCHDigit(g)-i>=0;)g^=c<<s.getBCHDigit(g)-i;return b<<12|g}})(rs)),rs}var as={},Gr;function cl(){if(Gr)return as;Gr=1;const t=Te(),s=1335,n=21522,o=t.getBCHDigit(s);return as.getEncodedBits=function(a,c){const i=a.bit<<3|c;let l=i<<10;for(;t.getBCHDigit(l)-o>=0;)l^=s<<t.getBCHDigit(l)-o;return(i<<10|l)^n},as}var is={},cs,Qr;function ll(){if(Qr)return cs;Qr=1;const t=Ie();function s(n){this.mode=t.NUMERIC,this.data=n.toString()}return s.getBitsLength=function(o){return 10*Math.floor(o/3)+(o%3?o%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(o){let r,a,c;for(r=0;r+3<=this.data.length;r+=3)a=this.data.substr(r,3),c=parseInt(a,10),o.put(c,10);const i=this.data.length-r;i>0&&(a=this.data.substr(r),c=parseInt(a,10),o.put(c,i*3+1))},cs=s,cs}var ls,Kr;function dl(){if(Kr)return ls;Kr=1;const t=Ie(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(o){this.mode=t.ALPHANUMERIC,this.data=o}return n.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let a;for(a=0;a+2<=this.data.length;a+=2){let c=s.indexOf(this.data[a])*45;c+=s.indexOf(this.data[a+1]),r.put(c,11)}this.data.length%2&&r.put(s.indexOf(this.data[a]),6)},ls=n,ls}var ds,Yr;function ul(){if(Yr)return ds;Yr=1;const t=Ie();function s(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return s.getBitsLength=function(o){return o*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(n){for(let o=0,r=this.data.length;o<r;o++)n.put(this.data[o],8)},ds=s,ds}var us,Zr;function hl(){if(Zr)return us;Zr=1;const t=Ie(),s=Te();function n(o){this.mode=t.KANJI,this.data=o}return n.getBitsLength=function(r){return r*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let r;for(r=0;r<this.data.length;r++){let a=s.toSJIS(this.data[r]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
2051
- Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},us=n,us}var hs={exports:{}},Xr;function fl(){return Xr||(Xr=1,(function(t){var s={single_source_shortest_paths:function(n,o,r){var a={},c={};c[o]=0;var i=s.PriorityQueue.make();i.push(o,0);for(var l,u,f,h,m,b,g,p,k;!i.empty();){l=i.pop(),u=l.value,h=l.cost,m=n[u]||{};for(f in m)m.hasOwnProperty(f)&&(b=m[f],g=h+b,p=c[f],k=typeof c[f]>"u",(k||p>g)&&(c[f]=g,i.push(f,g),a[f]=u))}if(typeof r<"u"&&typeof c[r]>"u"){var y=["Could not find a path from ",o," to ",r,"."].join("");throw new Error(y)}return a},extract_shortest_path_from_predecessor_list:function(n,o){for(var r=[],a=o;a;)r.push(a),n[a],a=n[a];return r.reverse(),r},find_path:function(n,o,r){var a=s.single_source_shortest_paths(n,o,r);return s.extract_shortest_path_from_predecessor_list(a,r)},PriorityQueue:{make:function(n){var o=s.PriorityQueue,r={},a;n=n||{};for(a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);return r.queue=[],r.sorter=n.sorter||o.default_sorter,r},default_sorter:function(n,o){return n.cost-o.cost},push:function(n,o){var r={value:n,cost:o};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=s})(hs)),hs.exports}var Jr;function pl(){return Jr||(Jr=1,(function(t){const s=Ie(),n=ll(),o=dl(),r=ul(),a=hl(),c=xo(),i=Te(),l=fl();function u(y){return unescape(encodeURIComponent(y)).length}function f(y,N,j){const C=[];let L;for(;(L=y.exec(j))!==null;)C.push({data:L[0],index:L.index,mode:N,length:L[0].length});return C}function h(y){const N=f(c.NUMERIC,s.NUMERIC,y),j=f(c.ALPHANUMERIC,s.ALPHANUMERIC,y);let C,L;return i.isKanjiModeEnabled()?(C=f(c.BYTE,s.BYTE,y),L=f(c.KANJI,s.KANJI,y)):(C=f(c.BYTE_KANJI,s.BYTE,y),L=[]),N.concat(j,C,L).sort(function(v,A){return v.index-A.index}).map(function(v){return{data:v.data,mode:v.mode,length:v.length}})}function m(y,N){switch(N){case s.NUMERIC:return n.getBitsLength(y);case s.ALPHANUMERIC:return o.getBitsLength(y);case s.KANJI:return a.getBitsLength(y);case s.BYTE:return r.getBitsLength(y)}}function b(y){return y.reduce(function(N,j){const C=N.length-1>=0?N[N.length-1]:null;return C&&C.mode===j.mode?(N[N.length-1].data+=j.data,N):(N.push(j),N)},[])}function g(y){const N=[];for(let j=0;j<y.length;j++){const C=y[j];switch(C.mode){case s.NUMERIC:N.push([C,{data:C.data,mode:s.ALPHANUMERIC,length:C.length},{data:C.data,mode:s.BYTE,length:C.length}]);break;case s.ALPHANUMERIC:N.push([C,{data:C.data,mode:s.BYTE,length:C.length}]);break;case s.KANJI:N.push([C,{data:C.data,mode:s.BYTE,length:u(C.data)}]);break;case s.BYTE:N.push([{data:C.data,mode:s.BYTE,length:u(C.data)}])}}return N}function p(y,N){const j={},C={start:{}};let L=["start"];for(let w=0;w<y.length;w++){const v=y[w],A=[];for(let x=0;x<v.length;x++){const E=v[x],P=""+w+x;A.push(P),j[P]={node:E,lastCount:0},C[P]={};for(let S=0;S<L.length;S++){const B=L[S];j[B]&&j[B].node.mode===E.mode?(C[B][P]=m(j[B].lastCount+E.length,E.mode)-m(j[B].lastCount,E.mode),j[B].lastCount+=E.length):(j[B]&&(j[B].lastCount=E.length),C[B][P]=m(E.length,E.mode)+4+s.getCharCountIndicator(E.mode,N))}}L=A}for(let w=0;w<L.length;w++)C[L[w]].end=0;return{map:C,table:j}}function k(y,N){let j;const C=s.getBestModeForData(y);if(j=s.from(N,C),j!==s.BYTE&&j.bit<C.bit)throw new Error('"'+y+'" cannot be encoded with mode '+s.toString(j)+`.
2052
- Suggested mode is: `+s.toString(C));switch(j===s.KANJI&&!i.isKanjiModeEnabled()&&(j=s.BYTE),j){case s.NUMERIC:return new n(y);case s.ALPHANUMERIC:return new o(y);case s.KANJI:return new a(y);case s.BYTE:return new r(y)}}t.fromArray=function(N){return N.reduce(function(j,C){return typeof C=="string"?j.push(k(C,null)):C.data&&j.push(k(C.data,C.mode)),j},[])},t.fromString=function(N,j){const C=h(N,i.isKanjiModeEnabled()),L=g(C),w=p(L,j),v=l.find_path(w.map,"start","end"),A=[];for(let x=1;x<v.length-1;x++)A.push(w.table[v[x]].node);return t.fromArray(b(A))},t.rawSplit=function(N){return t.fromArray(h(N,i.isKanjiModeEnabled()))}})(is)),is}var en;function ml(){if(en)return Qt;en=1;const t=Te(),s=Hs(),n=Jc(),o=el(),r=tl(),a=sl(),c=rl(),i=bo(),l=al(),u=il(),f=cl(),h=Ie(),m=pl();function b(w,v){const A=w.size,x=a.getPositions(v);for(let E=0;E<x.length;E++){const P=x[E][0],S=x[E][1];for(let B=-1;B<=7;B++)if(!(P+B<=-1||A<=P+B))for(let M=-1;M<=7;M++)S+M<=-1||A<=S+M||(B>=0&&B<=6&&(M===0||M===6)||M>=0&&M<=6&&(B===0||B===6)||B>=2&&B<=4&&M>=2&&M<=4?w.set(P+B,S+M,!0,!0):w.set(P+B,S+M,!1,!0))}}function g(w){const v=w.size;for(let A=8;A<v-8;A++){const x=A%2===0;w.set(A,6,x,!0),w.set(6,A,x,!0)}}function p(w,v){const A=r.getPositions(v);for(let x=0;x<A.length;x++){const E=A[x][0],P=A[x][1];for(let S=-2;S<=2;S++)for(let B=-2;B<=2;B++)S===-2||S===2||B===-2||B===2||S===0&&B===0?w.set(E+S,P+B,!0,!0):w.set(E+S,P+B,!1,!0)}}function k(w,v){const A=w.size,x=u.getEncodedBits(v);let E,P,S;for(let B=0;B<18;B++)E=Math.floor(B/3),P=B%3+A-8-3,S=(x>>B&1)===1,w.set(E,P,S,!0),w.set(P,E,S,!0)}function y(w,v,A){const x=w.size,E=f.getEncodedBits(v,A);let P,S;for(P=0;P<15;P++)S=(E>>P&1)===1,P<6?w.set(P,8,S,!0):P<8?w.set(P+1,8,S,!0):w.set(x-15+P,8,S,!0),P<8?w.set(8,x-P-1,S,!0):P<9?w.set(8,15-P-1+1,S,!0):w.set(8,15-P-1,S,!0);w.set(x-8,8,1,!0)}function N(w,v){const A=w.size;let x=-1,E=A-1,P=7,S=0;for(let B=A-1;B>0;B-=2)for(B===6&&B--;;){for(let M=0;M<2;M++)if(!w.isReserved(E,B-M)){let R=!1;S<v.length&&(R=(v[S]>>>P&1)===1),w.set(E,B-M,R),P--,P===-1&&(S++,P=7)}if(E+=x,E<0||A<=E){E-=x,x=-x;break}}}function j(w,v,A){const x=new n;A.forEach(function(M){x.put(M.mode.bit,4),x.put(M.getLength(),h.getCharCountIndicator(M.mode,w)),M.write(x)});const E=t.getSymbolTotalCodewords(w),P=i.getTotalCodewordsCount(w,v),S=(E-P)*8;for(x.getLengthInBits()+4<=S&&x.put(0,4);x.getLengthInBits()%8!==0;)x.putBit(0);const B=(S-x.getLengthInBits())/8;for(let M=0;M<B;M++)x.put(M%2?17:236,8);return C(x,w,v)}function C(w,v,A){const x=t.getSymbolTotalCodewords(v),E=i.getTotalCodewordsCount(v,A),P=x-E,S=i.getBlocksCount(v,A),B=x%S,M=S-B,R=Math.floor(x/S),U=Math.floor(P/S),F=U+1,W=R-U,q=new l(W);let D=0;const _=new Array(S),$=new Array(S);let X=0;const oe=new Uint8Array(w.buffer);for(let Y=0;Y<S;Y++){const he=Y<M?U:F;_[Y]=oe.slice(D,D+he),$[Y]=q.encode(_[Y]),D+=he,X=Math.max(X,he)}const be=new Uint8Array(x);let pe=0,V,H;for(V=0;V<X;V++)for(H=0;H<S;H++)V<_[H].length&&(be[pe++]=_[H][V]);for(V=0;V<W;V++)for(H=0;H<S;H++)be[pe++]=$[H][V];return be}function L(w,v,A,x){let E;if(Array.isArray(w))E=m.fromArray(w);else if(typeof w=="string"){let R=v;if(!R){const U=m.rawSplit(w);R=u.getBestVersionForData(U,A)}E=m.fromString(w,R||40)}else throw new Error("Invalid data");const P=u.getBestVersionForData(E,A);if(!P)throw new Error("The amount of data is too big to be stored in a QR Code");if(!v)v=P;else if(v<P)throw new Error(`
2049
+ `),le=12;function qi(t){if(t.length!==16)throw new Error(`Invalid share length: expected 16, got ${t.length}`);const n=Kn(t,Ae).split(" ");if(n.length!==le)throw new Error(`Unexpected word count: expected ${le}, got ${n.length}`);return n}function zi(t){if(t.length!==le)throw new Error(`Invalid word count: expected ${le}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!zs(s,Ae))throw new Error("Invalid recovery phrase: checksum mismatch");const n=qs(s,Ae);if(n.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${n.length}`);return I.toShamirShare(n)}function Hi(t){if(t.length!==16)throw new Error(`Invalid seed length: expected 16, got ${t.length}`);const n=Kn(t,Ae).split(" ");if(n.length!==le)throw new Error(`Unexpected word count: expected ${le}, got ${n.length}`);return n}function Vi(t){if(t.length!==le)throw new Error(`Invalid word count: expected ${le}, got ${t.length}`);const s=t.join(" ").toLowerCase().trim();if(!zs(s,Ae))throw new Error("Invalid recovery phrase: checksum mismatch");const n=qs(s,Ae);if(n.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${n.length}`);return I.toSeed(n)}function Yn(t){if(t.length!==le)return!1;const s=t.join(" ").toLowerCase().trim();return zs(s,Ae)}function ct(t){return Ae.includes(t.toLowerCase().trim())}function $i(t,s=5){const n=t.toLowerCase().trim();return n.length===0?[]:Ae.filter(o=>o.startsWith(n)).slice(0,s)}function Gi(t){const s=[];for(let n=0;n<t.length;n+=4)s.push(t.slice(n,n+4));return s}function Qi(t){return t.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(s=>s.trim()).filter(s=>s.length>0)}function Ki({className:t="",variant:s="default",size:n="md",children:o,menuItems:r=[],hideSignOut:a=!1}){const{user:c,isAuthenticated:i,isLoading:l,openLoginModal:u,logout:f}=I.useAuth(),[h,p]=d.useState(!1),[b,w]=d.useState(-1),m=d.useRef(null),k=d.useRef(null),x=d.useMemo(()=>[...r,...a?[]:[{label:"Sign out",onClick:f}]],[r,a,f]);d.useEffect(()=>{if(!h)return;const g=A=>{m.current&&!m.current.contains(A.target)&&(p(!1),w(-1))},v=A=>{A.key==="Escape"&&(p(!1),w(-1),k.current?.focus())};return document.addEventListener("mousedown",g),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",v)}},[h]);const N=d.useCallback(g=>{if(!(!h||x.length===0))switch(g.key){case"ArrowDown":g.preventDefault(),w(v=>(v+1)%x.length);break;case"ArrowUp":g.preventDefault(),w(v=>(v-1+x.length)%x.length);break;case"Home":g.preventDefault(),w(0);break;case"End":g.preventDefault(),w(x.length-1);break;case"Enter":case" ":b>=0&&(g.preventDefault(),x[b].onClick(),p(!1),w(-1));break}},[h,b,x]),j=d.useCallback(()=>{x.length!==0&&(p(g=>!g),w(-1))},[x.length]),C={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},P={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(l)return e.jsx("button",{type:"button",className:`cedros-button ${P[s]} ${C[n]} ${t}`,disabled:!0,children:e.jsx(z.LoadingSpinner,{size:"sm"})});if(i&&c){const g=c.name||c.email||"User",v=Bs.sanitizeImageUrl(c.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:m,onKeyDown:N,children:[e.jsxs("button",{ref:k,type:"button",className:`cedros-button cedros-user-button ${C[n]} ${t}`,"aria-haspopup":"menu","aria-expanded":h,"aria-label":`User menu for ${g}`,onClick:j,children:[v?e.jsx("img",{src:v,alt:g,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(g[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:g})]}),h&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[r.map((A,y)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${b===y?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===y?0:-1,onClick:()=>{A.onClick(),p(!1)},children:[A.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:A.icon}),A.label]},y)),r.length>0&&!a&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!a&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${b===r.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:b===r.length?0:-1,onClick:()=>{f(),p(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${P[s]} ${C[n]} ${t}`,onClick:u,children:o||"Sign in"})}function St(){const{config:t}=T.useCedrosLogin(),[s,n]=d.useState(!1),[o,r]=d.useState(!1),[a,c]=d.useState(null),i=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:l,getRemainingAttempts:u}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),f=d.useCallback(async w=>{if(!Te.validateEmail(w)){const m={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw c(m),m}try{l()}catch(m){const k={code:"RATE_LIMITED",message:m instanceof Error?m.message:"Too many attempts"};throw c(k),k}n(!0),c(null),r(!1);try{await i.post("/forgot-password",{email:w}),r(!0)}catch(m){const k=T.handleApiError(m,"Unable to send the reset email. Please try again.");throw c(k),k}finally{n(!1)}},[i,l]),h=d.useCallback(async(w,m)=>{n(!0),c(null),r(!1);try{await i.post("/reset-password",{token:w,newPassword:m}),r(!0)}catch(k){const x=T.handleApiError(k,"Unable to reset your password. Please try again.");throw c(x),x}finally{n(!1)}},[i]),p=d.useCallback(()=>c(null),[]),b=d.useCallback(()=>{c(null),r(!1),n(!1)},[]);return{forgotPassword:f,resetPassword:h,isLoading:s,isSuccess:o,error:a,clearError:p,reset:b,remainingAttempts:u()}}function Yi(t){return typeof t=="object"&&t!==null&&"mfaRequired"in t&&t.mfaRequired===!0}function Zn(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(!1),[c,i]=d.useState(null),l=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]),{checkLimit:u,getRemainingAttempts:f}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),h=d.useCallback(async m=>{if(!Te.validateEmail(m)){const k={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw i(k),k}try{u()}catch(k){const x={code:"RATE_LIMITED",message:k instanceof Error?k.message:"Too many attempts"};throw i(x),x}o(!0),i(null),a(!1);try{await l.post("/instant-link",{email:m}),a(!0)}catch(k){const x=T.handleApiError(k,"Unable to send the sign-in link. Please try again.");throw i(x),x}finally{o(!1)}},[l,u]),p=d.useCallback(async m=>{if(!m||m.trim().length===0){const k={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw i(k),k}o(!0),i(null),a(!1);try{const k=await l.post("/instant-link/verify",{token:m});return Yi(k)||(t.callbacks?.onLoginSuccess?.(k.user,"email"),s?.handleLoginSuccess(k.user,k.tokens)),k}catch(k){const x=T.handleApiError(k,"Unable to verify the sign-in link. Please try again.");throw i(x),x}finally{o(!1)}},[l,t.callbacks,s]),b=d.useCallback(()=>i(null),[]),w=d.useCallback(()=>{i(null),a(!1),o(!1)},[]);return{sendInstantLink:h,verifyInstantLink:p,isLoading:n,isSuccess:r,error:c,clearError:b,reset:w,remainingAttempts:f()}}const Zi={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:t=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:t}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:t=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:t}),". Click the link to sign in."]})}};function Xn({mode:t="reset",onSuccess:s,onCancel:n,className:o=""}){const[r,a]=d.useState(""),c=St(),i=Zn(),l=d.useId(),u=t==="instantLink"?{submit:i.sendInstantLink,isLoading:i.isLoading,isSuccess:i.isSuccess,error:i.error,clearError:i.clearError}:{submit:c.forgotPassword,isLoading:c.isLoading,isSuccess:c.isSuccess,error:c.error,clearError:c.clearError},f=Zi[t],h=async p=>{p.preventDefault();try{await u.submit(r),s?.()}catch{}};return u.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:f.successMessage(r)}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:n,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${o}`,onSubmit:h,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:f.subtitle})]}),e.jsx(X.ErrorMessage,{error:u.error,onDismiss:u.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:r,onChange:p=>a(p.target.value),placeholder:"you@example.com",required:!0,autoComplete:"email",disabled:u.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:u.isLoading||!r,children:u.isLoading?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),"Sending..."]}):f.button}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:n,disabled:u.isLoading,children:"Back to login"})]})]})}const Xi={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s})}):(this.loading=!0,new Promise((t,s)=>{this.callbacks.push({resolve:t,reject:s});const n=document.getElementById("apple-signin-script");if(n){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]):n.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.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(r=>r.resolve()),this.callbacks=[]},o.onerror=()=>{this.loading=!1,o.remove();const r=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(a=>a.reject(r)),this.callbacks=[]},document.head.appendChild(o)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function Jn(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(!1),[c,i]=d.useState(null),[l,u]=d.useState(null),f=d.useRef(t),h=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts}),[t.serverUrl,t.requestTimeout,t.retryAttempts]);d.useEffect(()=>{f.current=t},[t]),d.useEffect(()=>{if(!t.appleClientId)return;let m=!0;const k=()=>{if(m)try{window.AppleID?.auth?.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),m&&a(!0)}catch{m&&i({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return Xi.load().then(()=>{m&&k()}).catch(()=>{m&&i({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{m=!1}},[t.appleClientId]);const p=d.useCallback(async()=>{if(!t.appleClientId){const k={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw i(k),k}if(!r){const k={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw i(k),k}o(!0),i(null);let m;try{const k=crypto.getRandomValues(new Uint8Array(32)),x=Array.from(k,v=>v.toString(16).padStart(2,"0")).join(""),N=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(x)),j=Array.from(new Uint8Array(N),v=>v.toString(16).padStart(2,"0")).join("");window.AppleID.auth.init({clientId:t.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0,nonce:j});const C=await window.AppleID.auth.signIn();if(m=C.authorization?.id_token,!m)throw new Error("No ID token received from Apple");const P=C.user?.name?`${C.user.name.firstName||""} ${C.user.name.lastName||""}`.trim():void 0,g=await h.post("/apple",{idToken:m,name:P||void 0,nonce:x});return f.current.callbacks?.onLoginSuccess?.(g.user,"apple"),s?.handleLoginSuccess(g.user,g.tokens),o(!1),g}catch(k){if(k.error==="popup_closed_by_user"){const j={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw i(j),o(!1),j}const N=T.handleApiError(k,"Unable to sign in with Apple. Please try again.");throw N.code==="ACCOUNT_LINK_REQUIRED"&&m&&u(m),i(N),o(!1),N}},[t.appleClientId,r,h,s]),b=d.useCallback(()=>i(null),[]),w=d.useCallback(()=>u(null),[]);return{signIn:p,isLoading:n,isInitialized:r,error:c,clearError:b,pendingLinkIdToken:l,clearPendingLink:w}}function eo(){if(typeof window>"u"||typeof navigator>"u")return!1;const t=navigator.userAgent.toLowerCase(),s=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(t)||s.includes("mac")||/macintosh/.test(t)||s==="macintel"&&navigator.maxTouchPoints>1)}function to({onSuccess:t,onError:s,className:n="",variant:o="default",size:r="md",disabled:a=!1,hideOnNonApple:c=!0}){const{signIn:i,isLoading:l,isInitialized:u}=Jn(),[f]=d.useState(()=>eo());if(c&&!f)return null;const h=async()=>{try{await i(),t?.()}catch(w){const m=w instanceof Error?w:new Error(String(w));s?.(m)}},p={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},b={default:"cedros-button-social",outline:"cedros-button-social-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${b[o]} ${p[r]} ${n}`,onClick:h,disabled:a||!u||l,"aria-label":"Sign in with Apple",children:[l?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 ne(t,s){if(!t)throw new Error(s)}function Ji(t){return t.replace(/-/g,"+").replace(/_/g,"/")}function jt(t){ne(typeof t=="string"&&t.length>0,"Expected base64url string");const s=Ji(t),n=s+"=".repeat((4-s.length%4)%4),o=atob(n),r=new Uint8Array(o.length);for(let a=0;a<o.length;a++)r[a]=o.charCodeAt(a);return r.buffer}function Oe(t){const s=new Uint8Array(t);let n="";for(let r=0;r<s.length;r++)n+=String.fromCharCode(s[r]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function so(t){ne(typeof t=="object"&&t!==null,"Invalid credential descriptor");const s=t;return ne(typeof s.type=="string","Invalid credential descriptor type"),ne(typeof s.id=="string","Invalid credential descriptor id"),{type:s.type,id:jt(s.id),transports:Array.isArray(s.transports)?s.transports:void 0}}function Qt(t){ne(t&&typeof t=="object","Missing creation options");const s=t.publicKey;ne(s&&typeof s=="object","Missing creation options.publicKey"),ne(typeof s.challenge=="string","Missing creation challenge"),ne(typeof s.rp=="object"&&s.rp!==null,"Missing rp"),ne(typeof s.user=="object"&&s.user!==null,"Missing user");const n=s.rp,o=s.user;ne(typeof n.name=="string","Missing rp.name"),ne(typeof o.id=="string","Missing user.id"),ne(typeof o.name=="string","Missing user.name"),ne(typeof o.displayName=="string","Missing user.displayName");const r=Array.isArray(s.excludeCredentials)?s.excludeCredentials.map(so):void 0,a=Array.isArray(s.pubKeyCredParams)?s.pubKeyCredParams.map(i=>({type:i.type,alg:i.alg})):[],c={challenge:jt(s.challenge),rp:{name:n.name,id:typeof n.id=="string"?n.id:void 0},user:{id:jt(o.id),name:o.name,displayName:o.displayName},pubKeyCredParams:a,timeout:typeof s.timeout=="number"?s.timeout:void 0,attestation:typeof s.attestation=="string"?s.attestation:void 0,authenticatorSelection:typeof s.authenticatorSelection=="object"&&s.authenticatorSelection!==null?s.authenticatorSelection:void 0,excludeCredentials:r,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return c.hints=["client-device"],c}function Pr(t){ne(t&&typeof t=="object","Missing request options");const s=t.publicKey;ne(s&&typeof s=="object","Missing request options.publicKey"),ne(typeof s.challenge=="string","Missing request challenge");const n=Array.isArray(s.allowCredentials)?s.allowCredentials.map(so):void 0,o={challenge:jt(s.challenge),rpId:typeof s.rpId=="string"?s.rpId:void 0,timeout:typeof s.timeout=="number"?s.timeout:void 0,userVerification:typeof s.userVerification=="string"?s.userVerification:void 0,allowCredentials:n,extensions:typeof s.extensions=="object"&&s.extensions!==null?s.extensions:void 0};return o.hints=["client-device"],o}function Ke(t){const s=Oe(t.rawId),n=t.response,r={...{clientDataJSON:Oe(n.clientDataJSON)}};if("attestationObject"in n){const a=n;if(r.attestationObject=Oe(a.attestationObject),typeof a.getTransports=="function")try{r.transports=a.getTransports()}catch{}}if("authenticatorData"in n){const a=n;r.authenticatorData=Oe(a.authenticatorData),r.signature=Oe(a.signature),a.userHandle&&(r.userHandle=Oe(a.userHandle))}return{id:t.id,rawId:s,type:t.type,authenticatorAttachment:t.authenticatorAttachment??void 0,clientExtensionResults:t.getClientExtensionResults?.()??{},response:r}}function ec(){if(typeof window<"u"){const t=window.location?.hostname,s=t==="localhost"||t==="127.0.0.1"||t?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!s)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function tc(t){return typeof t=="object"&&t!==null&&"code"in t&&"message"in t&&typeof t.code=="string"&&typeof t.message=="string"}function Ye(t){if(!(t instanceof Error))return null;const s=t.name;return s==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:s==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:s==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function Hs(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(null),c=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[s?.getAccessToken,t.serverUrl,t.requestTimeout,t.retryAttempts]),i=d.useCallback(()=>a(null),[]),l=ec(),u=d.useCallback(async k=>{if(!l){const x={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(x),x}o(!0),a(null);try{const x=await c.post("/webauthn/auth/options",{email:k?.email}),N=Pr(x.options),j=await navigator.credentials.get({publicKey:N});if(!j)throw new Error("Passkey authentication returned no credential");const C=await c.post("/webauthn/auth/verify",{challengeId:x.challengeId,credential:Ke(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),C}catch(x){const j=Ye(x)??T.handleApiError(x,"Unable to sign in with passkey. Please try again.");throw a(j),j}finally{o(!1)}},[c,t.callbacks,s,l]),f=d.useCallback(async k=>{if(!l){const x={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(x),x}o(!0),a(null);try{const x=await c.post("/webauthn/register/options",{}),N=Qt(x.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey registration returned no credential");const C=await c.post("/webauthn/register/verify",{challengeId:x.challengeId,credential:Ke(j),label:k?.label});if(!C.success)throw new Error("Passkey registration failed");return{credentialId:C.credentialId,label:C.label}}catch(x){const j=Ye(x)??T.handleApiError(x,"Unable to register passkey. Please try again.");throw a(j),j}finally{o(!1)}},[c,l]),h=d.useCallback(async k=>{if(!l){const x={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(x),x}o(!0),a(null);try{const x=await c.post("/webauthn/signup/options",{}),N=Qt(x.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey signup returned no credential");const C=await c.post("/webauthn/signup/verify",{challengeId:x.challengeId,credential:Ke(j),email:k?.email,name:k?.name,label:k?.label});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),C}catch(x){const j=Ye(x)??T.handleApiError(x,"Unable to sign up with passkey. Please try again.");throw a(j),j}finally{o(!1)}},[c,t.callbacks,s,l]),p=d.useCallback(async()=>{if(!l){const N={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw a(N),N}o(!0),a(null);const k=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",x=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return k?b(x):w(x)},[c,t.callbacks,s,l]),b=d.useCallback(async k=>{try{const x=await c.post("/webauthn/auth/options",{}),N=Pr(x.options),j=await navigator.credentials.get({publicKey:N});if(!j)throw new Error("Passkey authentication returned no credential");const C=await c.post("/webauthn/auth/verify",{challengeId:x.challengeId,credential:Ke(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),k(),C}catch(x){if(x instanceof Error&&(x.name==="NotAllowedError"||x.name==="InvalidStateError"))return m(k);if(typeof x=="object"&&x!==null&&"isApiError"in x&&x.data?.code==="INVALID_CREDENTIALS"){const g={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(g),g}const P=Ye(x)??T.handleApiError(x,"Unable to sign in with passkey. Please try again.");throw a(P),P}finally{o(!1)}},[c,t.callbacks,s]),w=d.useCallback(async k=>{try{return await m(k)}catch(x){if(x instanceof Error&&(x.name==="InvalidStateError"||x.name==="NotAllowedError"))return b(k);if(!tc(x)){const C=Ye(x)??T.handleApiError(x,"Unable to create passkey. Please try again.");throw a(C),C}throw x}finally{o(!1)}},[c,t.callbacks,s]),m=d.useCallback(async k=>{const x=await c.post("/webauthn/signup/options",{}),N=Qt(x.options),j=await navigator.credentials.create({publicKey:N});if(!j)throw new Error("Passkey signup returned no credential");const C=await c.post("/webauthn/signup/verify",{challengeId:x.challengeId,credential:Ke(j)});return t.callbacks?.onLoginSuccess?.(C.user,"webauthn"),s?.handleLoginSuccess(C.user,C.tokens),k(),C},[c,t.callbacks,s]);return{isSupported:l,isLoading:n,error:r,clearError:i,continueWithPasskey:p,authenticatePasskey:u,registerPasskey:f,signupWithPasskey:h}}function ro({onSuccess:t,className:s="",children:n,disabled:o}){const{continueWithPasskey:r,isLoading:a,isSupported:c}=Hs(),i=o||!c||a;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${s}`,onClick:async()=>{try{await r(),t?.()}catch{}},disabled:i,"aria-disabled":i,children:[a?e.jsx(z.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(sc,{})}),e.jsx("span",{children:n??"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 Ze=["login","register"];function Et({onSuccess:t,className:s="",defaultTab:n="login"}){const{config:o,socialButtonOrder:r}=T.useCedrosLogin(),[a,c]=d.useState(n),[i,l]=d.useState("form"),[u,f]=d.useState(()=>qe.detectSolanaWallets()),[h]=d.useState(()=>eo());d.useEffect(()=>{const P=()=>f(qe.detectSolanaWallets());return P(),window.addEventListener("load",P),window.addEventListener("focus",P),()=>{window.removeEventListener("load",P),window.removeEventListener("focus",P)}},[]);const p=o.forms?.forgotPassword?.mode??(o.features?.instantLink?"instantLink":"reset"),b=d.useCallback(P=>{const g=Ze.indexOf(a);let v=g;switch(P.key){case"ArrowLeft":case"ArrowUp":v=g===0?Ze.length-1:g-1;break;case"ArrowRight":case"ArrowDown":v=g===Ze.length-1?0:g+1;break;case"Home":v=0;break;case"End":v=Ze.length-1;break;default:return}P.preventDefault();const A=Ze[v];c(A),document.getElementById(`cedros-tab-${A}`)?.focus()},[a]),w=o.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},m=w.email!==!1,k=w.google!==!1&&o.googleClientId,x=w.apple!==!1&&o.appleClientId&&h,N=w.solana!==!1&&u,j=w.webauthn!==!1,C=m&&(k||x||N||j);return i==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${s}`,children:e.jsx(Xn,{mode:p,onCancel:()=>l("form")})}):e.jsxs("div",{className:`cedros-login-form ${s}`,children:[(j||k||x||N)&&(()=>{const P={webauthn:j?e.jsx(ro,{onSuccess:t}):null,google:k?e.jsx(Ms.GoogleLoginButton,{onSuccess:t}):null,apple:x?e.jsx(to,{onSuccess:t}):null,solana:N?e.jsx(qe.SolanaLoginButton,{onSuccess:t}):null},g=r??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:g.map(v=>{const A=P[v];return A?e.jsx(d.Fragment,{children:A},v):null})})})(),C&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-tabs",role:"tablist","aria-label":"Authentication method",children:[e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-login",className:`cedros-tab ${a==="login"?"cedros-tab-active":""}`,onClick:()=>c("login"),onKeyDown:b,"aria-selected":a==="login","aria-controls":"cedros-tabpanel-login",tabIndex:a==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${a==="register"?"cedros-tab-active":""}`,onClick:()=>c("register"),onKeyDown:b,"aria-selected":a==="register","aria-controls":"cedros-tabpanel-register",tabIndex:a==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${a}`,"aria-labelledby":`cedros-tab-${a}`,children:a==="login"?e.jsx(Q.EmailLoginForm,{onSuccess:t,onSwitchToRegister:()=>c("register"),onForgotPassword:()=>l("forgotPassword")}):e.jsx(Q.EmailRegisterForm,{onSuccess:t,onSwitchToLogin:()=>c("login")})})]})]})}class no extends d.Component{constructor(s){super(s),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(s){return{hasError:!0,error:s}}componentDidCatch(s,n){this.setState({errorInfo:n}),console.error("[Cedros Login] Error caught by ErrorBoundary:",s),console.error("[Cedros Login] Component stack:",n.componentStack),this.props.onError?.(s,n)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:s,error:n,errorInfo:o}=this.state,{children:r,fallback:a,showDetails:c=!1}=this.props;return s?a||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),c&&n&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[n.toString(),o?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):r}}function rc({className:t="",title:s="Sign in to your account"}){const{isModalOpen:n,closeModal:o}=T.useCedrosLogin(),r=d.useRef(null),a=d.useRef(null),c=d.useRef(o);if(d.useEffect(()=>{c.current=o},[o]),d.useEffect(()=>{if(!n)return;a.current=document.activeElement,r.current?.focus();const l=f=>{if(f.key==="Escape"&&c.current(),f.key==="Tab"&&r.current){const h=r.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),p=h[0],b=h[h.length-1];f.shiftKey&&document.activeElement===p?(f.preventDefault(),b?.focus()):!f.shiftKey&&document.activeElement===b&&(f.preventDefault(),p?.focus())}};document.addEventListener("keydown",l);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",l),document.body.style.overflow=u,a.current instanceof HTMLElement&&a.current.focus()}},[n]),!n)return null;const i=l=>{l.target===l.currentTarget&&o()};return e.jsx("div",{className:`cedros-modal-backdrop ${t}`,onClick:i,role:"presentation",children:e.jsxs("div",{ref:r,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:s}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:o,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(no,{children:e.jsx(Et,{onSuccess:o})})})]})})}function nc({token:t,onSuccess:s,onLoginClick:n,className:o=""}){const[r,a]=d.useState(""),[c,i]=d.useState(""),[l,u]=d.useState(null),{resetPassword:f,isLoading:h,isSuccess:p,error:b,clearError:w}=St(),m=r===c,k=l?.isValid&&m&&r.length>0,x=async N=>{if(N.preventDefault(),!!k)try{await f(t,r),s?.()}catch{}};return p?e.jsxs("div",{className:`cedros-reset-password-success ${o}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:n,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${o}`,onSubmit:x,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(X.ErrorMessage,{error:b,onDismiss:w}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"New password",value:r,onChange:N=>{a(N.target.value),u(Te.validatePassword(N.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:h,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(Q.PasswordInput,{label:"Confirm password",value:c,onChange:N=>i(N.target.value),disabled:h,autoComplete:"new-password",error:c&&!m?"Passwords do not match":void 0})}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:h||!k,children:h?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:n,disabled:h,children:"Back to login"})]})]})}function Ls({org:t,size:s="lg",className:n=""}){const o=Bs.sanitizeImageUrl(t.logoUrl),r=s==="lg"?"cedros-org-avatar-lg":"",a=["cedros-org-avatar",r,n].filter(Boolean).join(" "),c=["cedros-org-avatar-placeholder",r,n].filter(Boolean).join(" ");return o?e.jsx("img",{src:o,alt:t.name,className:a,referrerPolicy:"no-referrer"}):e.jsx("div",{className:c,children:t.name[0]?.toUpperCase()||"?"})}function oc({orgs:t,activeOrg:s,isLoading:n=!1,onSelect:o,onCreateClick:r,className:a="",placeholder:c="Select organization"}){const[i,l]=d.useState(!1),u=d.useRef(null);d.useEffect(()=>{const b=w=>{u.current&&!u.current.contains(w.target)&&l(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]),d.useEffect(()=>{const b=w=>{w.key==="Escape"&&l(!1)};if(i)return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[i]);const f=d.useCallback(b=>{o(b),l(!1)},[o]),h=d.useCallback(()=>{l(!1),r?.()},[r]),p=d.useCallback(()=>{l(b=>!b)},[]);return n?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:u,className:`cedros-org-selector ${a}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:p,"aria-haspopup":"listbox","aria-expanded":i,children:[s?e.jsxs(e.Fragment,{children:[e.jsx(Ls,{org:s,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:s.name}),e.jsx(Br,{role:s.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:c}),e.jsx(ac,{isOpen:i})]}),i&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[t.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:t.map(b=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${b.id===s?.id?"cedros-org-selector-item-active":""}`,onClick:()=>f(b.id),role:"option","aria-selected":b.id===s?.id,children:[e.jsx(Ls,{org:b,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:b.name}),e.jsx(Br,{role:b.membership.role}),b.id===s?.id&&e.jsx(ic,{})]})},b.id))}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:h,children:[e.jsx(cc,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function Br({role:t}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${t}`,children:t})}function ac({isOpen:t}){return e.jsx("svg",{className:`cedros-org-chevron ${t?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function ic(){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 cc(){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 lc(){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 dc(){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 uc(){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 hc({orgs:t,activeOrg:s,isLoading:n,onSelect:o,onCreateClick:r}){return n?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[t.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:t.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${a.id===s?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>o(a.id),children:[e.jsx(Ls,{org:a}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:a.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",a.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${a.membership.role}`,children:a.membership.role}),a.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),a.id===s?.id&&e.jsx(dc,{})]})},a.id))}),r&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:r,children:[e.jsx(uc,{}),e.jsx("span",{children:"Create new organization"})]})]})}function fc({isLoading:t,onSubmit:s,onCancel:n}){const[o,r]=d.useState(""),[a,c]=d.useState(""),[i,l]=d.useState(null),u=d.useCallback(h=>{r(h);const p=h.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);c(p)},[]),f=d.useCallback(async h=>{if(h.preventDefault(),l(null),!o.trim()){l("Organization name is required");return}if(!a.trim()){l("Organization slug is required");return}try{await s({name:o.trim(),slug:a.trim()})}catch(p){l(p.message||"Failed to create organization")}},[o,a,s]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:f,children:[i&&e.jsx(X.ErrorMessage,{error:i}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:o,onChange:h=>u(h.target.value),placeholder:"My Organization",maxLength:255,disabled:t,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:a,onChange:h=>c(h.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:t})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:n,disabled:t,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:t||!o.trim()||!a.trim(),children:t?e.jsx(z.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function pc({isOpen:t,onClose:s,orgs:n,activeOrg:o,isLoading:r=!1,error:a,onSelect:c,onCreate:i,className:l=""}){return t?e.jsx(mc,{onClose:s,orgs:n,activeOrg:o,isLoading:r,error:a,onSelect:c,onCreate:i,className:l}):null}function mc({onClose:t,orgs:s,activeOrg:n,isLoading:o=!1,error:r,onSelect:a,onCreate:c,className:i}){const[l,u]=d.useState("list"),f=d.useRef(null),h=d.useRef(null);d.useEffect(()=>(h.current=document.activeElement,f.current?.querySelector(".cedros-modal-close")?.focus(),()=>{h.current?.focus()}),[]),d.useEffect(()=>{const m=k=>{if(k.key==="Escape"){t();return}if(k.key==="Tab"&&f.current){const x=f.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),N=x[0],j=x[x.length-1];k.shiftKey?document.activeElement===N&&(k.preventDefault(),j?.focus()):document.activeElement===j&&(k.preventDefault(),N?.focus())}};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[t]);const p=d.useCallback(m=>{m.target===m.currentTarget&&t()},[t]),b=d.useCallback(m=>{a(m),t()},[a,t]),w=d.useCallback(async m=>{await c?.(m),t()},[c,t]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:p,children:e.jsxs("div",{ref:f,className:`cedros-modal cedros-org-switcher ${i}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:l==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:t,"aria-label":"Close",children:e.jsx(lc,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[r&&e.jsx(X.ErrorMessage,{error:r}),l==="list"?e.jsx(hc,{orgs:s,activeOrg:n,isLoading:o,onSelect:b,onCreateClick:c?()=>u("create"):void 0}):e.jsx(fc,{isLoading:o,onSubmit:w,onCancel:()=>u("list")})]})]})})}function oo({sessions:t,isLoading:s=!1,error:n,onRevokeAll:o,className:r=""}){const[a,c]=d.useState(!1),[i,l]=d.useState(!1),u=d.useRef(null),f=d.useMemo(()=>t.filter(p=>!p.isCurrent).length,[t]),h=d.useCallback(async()=>{if(!o)return;const p=t.filter(w=>!w.isCurrent).length;if(!(p===0||!window.confirm(`Are you sure you want to sign out of ${p} other device(s)? This will log you out everywhere except this browser.`))){c(!0),l(!1);try{await o(),l(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{l(!1),u.current=null},3e3)}finally{c(!1)}}},[o,t]);return d.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),s&&t.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${r}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):n?e.jsx("div",{className:`cedros-session-list ${r}`,children:e.jsx(X.ErrorMessage,{error:n})}):t.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${r}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${r}`,children:[i&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Ac,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:t.map(p=>e.jsx(gc,{session:p},p.id))}),o&&f>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:h,disabled:a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${f} other device${f>1?"s":""}`})})]})}function gc({session:t}){const s=wc(t.userAgent),n=yc(t.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${t.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(xc,{userAgent:t.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[s.browser," on ",s.os]}),t.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[t.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",t.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",bc(t.createdAt)]}),n&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function wc(t){if(!t)return{browser:"Unknown browser",os:"Unknown device"};let s="Unknown browser";t.includes("Chrome")&&!t.includes("Edg")?s="Chrome":t.includes("Safari")&&!t.includes("Chrome")?s="Safari":t.includes("Firefox")?s="Firefox":t.includes("Edg")&&(s="Edge");let n="Unknown device";return t.includes("Windows")?n="Windows":t.includes("Mac")?n="macOS":t.includes("Linux")?n="Linux":t.includes("iPhone")||t.includes("iPad")?n="iOS":t.includes("Android")&&(n="Android"),{browser:s,os:n}}function bc(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),r=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),c=Math.floor(o/(1e3*60*60*24));return r<1?"just now":r<60?`${r} minute${r>1?"s":""} ago`:a<24?`${a} hour${a>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function yc(t){const s=new Date(t),n=new Date,o=3600*1e3;return s.getTime()-n.getTime()<o}function xc({userAgent:t}){return t?.includes("iPhone")||t?.includes("iPad")||t?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function Ac(){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 ao({words:t,onConfirm:s,className:n=""}){const[o,r]=d.useState(!1),[a,c]=d.useState(!1),i=d.useRef(null),l=Gi(t),u=d.useCallback(async()=>{try{await navigator.clipboard.writeText(t.join(" ")),r(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>r(!1),2e3)}catch{}},[t]);d.useEffect(()=>()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null)},[]);const f=d.useCallback(()=>{a&&s()},[a,s]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${n}`,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((h,p)=>e.jsx("div",{className:"cedros-word-group",children:h.map((b,w)=>{const m=p*4+w+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[m,"."]}),e.jsx("span",{className:"cedros-word-text",children:b})]},m)})},p))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,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:h=>c(h.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:f,disabled:!a,children:"Continue"})]})]})}function io({onSubmit:t,onCancel:s,isSubmitting:n=!1,error:o,className:r=""}){const[a,c]=d.useState(Array(le).fill("")),[i,l]=d.useState(null),[u,f]=d.useState([]),[h,p]=d.useState(null),b=d.useId(),w=d.useRef(null),m=d.useCallback((g,v)=>{const A=[...a];if(A[g]=v.toLowerCase().trim(),c(A),v.length>0){const y=$i(v,5);f(y)}else f([]);p(null)},[a]),k=d.useCallback(g=>{l(g),f([])},[]),x=d.useCallback(g=>{const v=a[g];v&&!ct(v)&&p(`Word ${g+1} is not in the wordlist`),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{i===g&&f([])},200)},[a,i]);d.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]);const N=d.useCallback(g=>{if(i!==null){const v=[...a];v[i]=g,c(v),f([]),document.querySelector(`[data-word-index="${i+1}"]`)?.focus()}},[i,a]),j=d.useCallback(g=>{const v=g.clipboardData.getData("text"),A=Qi(v);A.length===le&&(g.preventDefault(),c(A),p(null))},[]),C=d.useCallback(g=>{if(g.preventDefault(),a.filter(y=>!y).length>0){p(`Please enter all ${le} words`);return}const A=a.map((y,S)=>({word:y,index:S+1})).filter(({word:y})=>!ct(y));if(A.length>0){p(`Invalid words: ${A.map(y=>`#${y.index}`).join(", ")}`);return}if(!Yn(a)){p("Invalid recovery phrase - please check your words");return}t(a)},[a,t]),P=o||h;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${r}`,onSubmit:C,onPaste:j,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:le},(g,v)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[v+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${a[v]&&!ct(a[v])?"cedros-word-invalid":a[v]&&ct(a[v])?"cedros-word-valid":""}`,value:a[v],onChange:A=>m(v,A.target.value),onFocus:()=>k(v),onBlur:()=>x(v),"data-word-index":v,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:n,"aria-label":`Word ${v+1}`})]},v))}),i!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${b}-suggestions`,children:u.map(g=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>N(g),role:"option",children:g},g))}),P&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:P}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:s,disabled:n,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:n,children:n?"Recovering...":"Recover Wallet"})]})]})}function vc({capabilities:t,className:s=""}){if(t.allSupported)return null;const n=I.getMissingCapabilitiesMessage(t),o=I.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${s}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:n}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",o.browser," ",o.version,o.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:t.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",t.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:t.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",t.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:t.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",t.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",t.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:t.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",t.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:t.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",t.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const jc=["share_c_only","full_seed","none"];function kc(t){return t&&jc.includes(t)?t:"share_c_only"}const Nc={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function co(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(null),[o,r]=d.useState(!!t),[a,c]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts}):null,[t]),l=d.useCallback(async()=>{if(i){r(!0),c(null);try{const u=await i.get("/discovery");u.wallet?n({enabled:u.wallet.enabled,recoveryMode:kc(u.wallet.recoveryMode),unlockTtlSeconds:u.wallet.unlockTtlSeconds}):n({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(u){const f=u instanceof Error?u.message:"Failed to fetch wallet config";c(f),n({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{r(!1)}}},[i]);return d.useEffect(()=>{i&&l()},[i,l]),t?{walletEnabled:s?.enabled??!1,recoveryMode:s?.recoveryMode??"share_c_only",unlockTtlSeconds:s?.unlockTtlSeconds??900,isLoading:o,error:a,refetch:l}:Nc}function lo(){const{user:t}=T.useCedrosLogin(),{enroll:s}=I.useWalletMaterial(),{recoveryMode:n}=co(),[o,r]=d.useState({step:"idle"}),[a,c]=d.useState(!1),i=d.useRef([]),l=d.useCallback(()=>{I.wipeAll(...i.current),i.current=[]},[]);d.useEffect(()=>()=>{l()},[l]);const u=d.useCallback(async(w,m,k,x)=>{r({step:"generating_seed"});const N=I.generateSeed();i.current.push(N),r({step:"splitting_shares"});const{shareA:j,shareB:C,shareC:P}=qn(N);i.current.push(j,C,P),r({step:"encrypting_shares"});const g=await I.aesGcmEncryptToBase64(j,I.toEncryptionKey(m)),v=On(N),A=Wn(v);r({step:"uploading"});const y={solanaPubkey:A,shareAAuthMethod:w,shareACiphertext:g.ciphertext,shareANonce:g.nonce,shareB:I.uint8ArrayToBase64(C)};if(w==="password"){if(!k)throw new Error("KDF salt required for password method");y.shareAKdfSalt=I.uint8ArrayToBase64(k),y.shareAKdfParams=I.DEFAULT_KDF_PARAMS}if(w==="passkey"&&x&&(y.prfSalt=x),await s(y),n==="none")l(),r({step:"complete",solanaPubkey:A});else{const S=n==="full_seed"?Hi(N):qi(I.toShamirShare(P));r({step:"showing_recovery",recoveryPhrase:S,solanaPubkey:A})}},[s,n,l]),f=d.useCallback(async w=>{if(!t){r({step:"error",error:"User not authenticated"});return}c(!0),l();try{const m=I.generateArgon2Salt(),k=await bn(w,m,I.DEFAULT_KDF_PARAMS);i.current.push(k),await u("password",k,m)}catch(m){r({step:"error",error:m instanceof Error?m.message:"Enrollment failed"})}finally{c(!1)}},[t,l,u]),h=d.useCallback(async()=>{if(!t){r({step:"error",error:"User not authenticated"});return}c(!0),l();try{const w=I.generatePrfSalt(),m=I.uint8ArrayToBase64(w);r({step:"encrypting_shares"});const x=(await I.authenticateWithDiscoverablePrf(m)).prfOutput;i.current.push(x);const N=await I.deriveKeyFromPrf(x,w);i.current.push(N),await u("passkey",N,void 0,m)}catch(w){r({step:"error",error:w instanceof Error?w.message:"Enrollment failed"})}finally{c(!1)}},[t,l,u]),p=d.useCallback(()=>{const w=o.solanaPubkey;l(),r({step:"complete",solanaPubkey:w})},[o.solanaPubkey,l]),b=d.useCallback(()=>{l(),r({step:"idle"}),c(!1)},[l]);return{state:o,startEnrollmentWithPassword:f,startEnrollmentWithPasskey:h,confirmRecoveryPhrase:p,cancel:b,isEnrolling:a}}function uo(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(null),c=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken]);return{setPassword:d.useCallback(async l=>{o(!0),a(null);try{await c.post("/set-password",{password:l})}catch(u){const f=T.handleApiError(u,"Failed to set password");throw a(f),f}finally{o(!1)}},[c]),isLoading:n,error:r}}function Cc(t){return t.includes("email")?"password":t.includes("webauthn")?"passkey":"set-password"}function ho({onComplete:t,onCancel:s,className:n=""}){const{user:o}=T.useCedrosLogin(),{state:r,startEnrollmentWithPassword:a,startEnrollmentWithPasskey:c,confirmRecoveryPhrase:i,cancel:l,isEnrolling:u}=lo(),{setPassword:f,isLoading:h}=uo(),p=o?Cc(o.authMethods):"password",[b,w]=d.useState(""),[m,k]=d.useState(""),[x,N]=d.useState(null);d.useEffect(()=>{w(""),k(""),N(null)},[o?.id]);const j=d.useCallback(async y=>{y.preventDefault(),N(null),await a(b)},[b,a]),C=d.useCallback(async y=>{if(y.preventDefault(),b!==m){N("Passwords do not match");return}const S=Te.validatePassword(b);if(!S.isValid){const E=Object.values(S.errors)[0];N(E??"Password does not meet requirements");return}N(null);try{await f(b),await a(b)}catch{}},[b,m,f,a]),P=d.useCallback(async()=>{await c()},[c]),g=d.useCallback(()=>{i(),r.solanaPubkey&&t?.(r.solanaPubkey)},[i,r.solanaPubkey,t]),v=d.useCallback(()=>{l(),s?.()},[l,s]),A=u||h;return r.step==="generating_seed"||r.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,"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..."})]})}):r.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,"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..."})]})}):r.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,"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..."})]})}):r.step==="showing_recovery"&&r.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,children:e.jsx(ao,{words:r.recoveryPhrase,onConfirm:g})}):r.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,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:"})," ",r.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):r.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${n}`,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:r.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,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 ${n}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),p==="password"&&e.jsx("p",{children:"Enter your account password to secure your wallet."}),p==="passkey"&&e.jsx("p",{children:"Authenticate with your passkey to secure your wallet."}),p==="set-password"&&e.jsx("p",{children:"Set a password for your account to secure your wallet."})]}),p==="password"&&e.jsxs("form",{onSubmit:j,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"Account Password",value:b,onChange:y=>w(y.target.value),disabled:A,required:!0,placeholder:"Enter your account password"}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:A||!b,children:A?"Creating...":"Continue"})]})]}),p==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:P,disabled:A,children:A?"Creating...":"Use Passkey"})]})]}),p==="set-password"&&e.jsxs("form",{onSubmit:C,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"New Password",value:b,onChange:y=>w(y.target.value),showStrengthMeter:!0,disabled:A,required:!0,minLength:8,placeholder:"Choose a strong password"}),e.jsx(Q.PasswordInput,{label:"Confirm Password",value:m,onChange:y=>k(y.target.value),error:x??void 0,disabled:A,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will also be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:A,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:A||!b||!m,children:A?"Creating...":"Continue"})]})]})]})}function fo(){const{user:t}=T.useCedrosLogin(),{signTransaction:s}=I.useWalletMaterial(),[n,o]=d.useState(!1),[r,a]=d.useState(null),c=d.useCallback(async(l,u)=>{if(!t){const f="User not authenticated";throw a(f),new Error(f)}o(!0),a(null);try{const f={transaction:I.uint8ArrayToBase64(l),...u?{credential:I.toCredentialRequest(u)}:{}},h=await s(f);return I.base64ToUint8Array(h.signature)}catch(f){const h=f instanceof Error?f.message:"Signing failed";throw a(h),f}finally{o(!1)}},[t,s]),i=d.useCallback(()=>a(null),[]);return{signTransaction:c,isSigning:n,error:r,clearError:i}}function po(){const{getMaterial:t}=I.useWalletMaterial(),[s,n]=d.useState(!1),[o,r]=d.useState(null),a=d.useCallback(async()=>{n(!0),r(null);try{const i=await t();if(!i)throw new Error("No wallet enrolled");if(i.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!i.prfSalt)throw new Error("No PRF salt configured for wallet");const l=await I.authenticateWithDiscoverablePrf(i.prfSalt);try{return{type:"prfOutput",prfOutput:I.uint8ArrayToBase64(l.prfOutput)}}finally{l.prfOutput.fill(0)}}catch(i){const l=i instanceof Error?i.message:"Passkey authentication failed";return r(l),null}finally{n(!1)}},[t]),c=d.useCallback(()=>r(null),[]);return{getPasskeyCredential:a,isAuthenticating:s,error:o,clearError:c}}function mo({mode:t,isLoading:s=!1,error:n,onPrompt:o,onRetry:r,onCancel:a,title:c,description:i,className:l=""}){const u=d.useCallback(()=>{s||o?.()},[s,o]),f=d.useCallback(()=>{r?.()},[r]),h=t==="register"?"Set Up Passkey":"Verify with Passkey",p=t==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${l}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:s?e.jsx(Ec,{}):n?e.jsx(Lc,{}):e.jsx(Sc,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:c??h}),e.jsx("p",{className:"cedros-passkey-description",children:i??p}),n&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:n})}),e.jsx("div",{className:"cedros-passkey-actions",children:n?e.jsxs(e.Fragment,{children:[r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:f,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:u,disabled:s,children:s?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):t==="register"?"Create Passkey":"Use Passkey"}),a&&!s&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:a,children:"Cancel"})]})}),s&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",t==="register"?"create":"verify"," your passkey."]})]})}function Sc(){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 Ec(){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 Lc(){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 go({onUnlock:t,onCancel:s,showCancel:n=!0,authMethod:o,className:r=""}){T.useCedrosLogin();const{unlock:a,getMaterial:c,isLoading:i}=I.useWalletMaterial(),{getPasskeyCredential:l,isAuthenticating:u}=po(),[f,h]=d.useState("idle"),[p,b]=d.useState(o??null),[w,m]=d.useState(""),[k,x]=d.useState(null);d.useEffect(()=>{o!==void 0&&b(o)},[o]);const N=p==="password",j=p==="passkey",C=d.useCallback(async()=>{if(h("credential"),x(null),!p)try{const E=await c();E?b(E.shareAAuthMethod):(x("No wallet enrolled"),h("error"))}catch(E){x(E instanceof Error?E.message:"Failed to get wallet info"),h("error")}},[p,c]),P=d.useCallback(async E=>{E.preventDefault(),x(null),h("unlocking");try{let B;if(N)B={type:"password",password:w};else throw new Error("Invalid auth method");await a(B),h("unlocked"),t?.()}catch(B){x(B instanceof Error?B.message:"Failed to unlock wallet"),h("error")}},[N,w,a,t]),g=d.useCallback(async()=>{x(null),h("unlocking");try{const E=await l();if(!E){h("credential");return}await a(E),h("unlocked"),t?.()}catch(E){x(E instanceof Error?E.message:"Failed to unlock wallet"),h("error")}},[l,a,t]),v=d.useCallback(()=>{m(""),h("idle"),x(null),s?.()},[s]),A=d.useCallback(()=>{m(""),h("credential"),x(null)},[]),y=i||u,S=()=>{switch(f){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(Pc,{})}),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:C,children:"Unlock Wallet"})]});case"credential":return N?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:P,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(Q.PasswordInput,{label:"Password",value:w,onChange:E=>m(E.target.value),disabled:y,autoComplete:"current-password",error:k??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:y||w.length===0,children:y?"Unlocking...":"Unlock"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,disabled:y,children:"Cancel"})]})]}):j?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(mo,{mode:"authenticate",isLoading:y,error:k??void 0,onPrompt:g,onRetry:g,onCancel:n?v: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(Bc,{})}),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(Mc,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:k??"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:A,children:"Try Again"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:v,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${r}`,children:S()})}function Pc(){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 Bc(){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 Mc(){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 wo(){const{recover:t,getShareBForRecovery:s}=I.useWalletMaterial(),{recoveryMode:n}=co(),[o,r]=d.useState({step:"idle"}),[a,c]=d.useState(!1),i=d.useRef([]),l=d.useCallback(()=>{I.wipeAll(...i.current),i.current=[]},[]);d.useEffect(()=>()=>{l()},[l]);const u=d.useCallback(async(h,p,b)=>{c(!0),l();try{if(r({step:"validating"}),!Yn(h))throw new Error("Invalid recovery phrase. Please check your words.");let w;if(n==="share_c_only"){const A=zi(h);i.current.push(A);const y=I.uint8ArrayToBase64(A),S=await s({shareC:y}),E=I.base64ToUint8Array(S.shareB);i.current.push(E),w=Li(I.toShamirShare(E),I.toShamirShare(A)),i.current.push(w)}else w=Vi(h),i.current.push(w);const m=On(w),k=Wn(m),{shareA:x,shareB:N}=qn(w);i.current.push(x,N),r({step:"encrypting"});let j,C,P;if(p==="passkey"){const A=I.generatePrfSalt();P=I.uint8ArrayToBase64(A);const y=await I.authenticateWithDiscoverablePrf(P);i.current.push(y.prfOutput),j=await I.deriveKeyFromPrf(y.prfOutput,A),i.current.push(j)}else C=I.generateArgon2Salt(),j=await bn(b,C,I.DEFAULT_KDF_PARAMS),i.current.push(j);const g=await I.aesGcmEncryptToBase64(x,I.toEncryptionKey(j));r({step:"uploading"});const v={solanaPubkey:k,shareAAuthMethod:p,shareACiphertext:g.ciphertext,shareANonce:g.nonce,shareB:I.uint8ArrayToBase64(N)};p==="password"&&(v.shareAKdfSalt=I.uint8ArrayToBase64(C),v.shareAKdfParams=I.DEFAULT_KDF_PARAMS),p==="passkey"&&(v.prfSalt=P),await t(v),l(),r({step:"complete"})}catch(w){l(),r({step:"error",error:w instanceof Error?w.message:"Recovery failed"})}finally{c(!1)}},[t,s,n,l]),f=d.useCallback(()=>{l(),r({step:"idle"}),c(!1)},[l]);return{state:o,startRecovery:u,cancel:f,isRecovering:a}}function bo({onComplete:t,onCancel:s,className:n="",defaultAuthMethod:o="password"}){const{state:r,startRecovery:a,cancel:c,isRecovering:i}=wo(),[l,u]=d.useState([]),[f,h]=d.useState(!1),[p,b]=d.useState(o),[w,m]=d.useState(""),[k,x]=d.useState(""),[N,j]=d.useState(null),C=d.useCallback(y=>{u(y),h(!0)},[]),P=d.useCallback(async y=>{if(y.preventDefault(),j(null),p!=="passkey"){if(w!==k){j("Passwords do not match");return}if(p==="password"&&w.length<8){j("Password must be at least 8 characters");return}}await a(l,p,w)},[l,p,w,k,a]),g=d.useCallback(()=>{c(),u([]),h(!1),m(""),x(""),s?.()},[c,s]),v=d.useCallback(()=>{h(!1),m(""),x("")},[]),A=d.useCallback(()=>{t?.()},[t]);return r.step==="validating"||r.step==="encrypting"||r.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${n}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Rc,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[r.step==="validating"&&"Validating Recovery Phrase",r.step==="encrypting"&&"Encrypting Wallet",r.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[r.step==="validating"&&"Checking your recovery phrase...",r.step==="encrypting"&&"Securing your wallet with new encryption...",r.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):r.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${n}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Tc,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Wallet Recovered"}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:["Your wallet has been successfully recovered and secured with your new"," ",p==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:A,children:"Done"})})]})}):r.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${n}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(Ic,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recovery Failed"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:r.error??"An error occurred during recovery. Please try again."}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:g,children:"Start Over"})})]})}):f?e.jsx("div",{className:`cedros-wallet-recovery ${n}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:P,children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Set New Security"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Choose how to secure your recovered wallet."})]}),e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:p==="password",onChange:()=>b("password"),disabled:i}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:p==="passkey",onChange:()=>b("passkey"),disabled:i}),e.jsx("span",{children:"Passkey"})]})]}),p==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:w,onChange:y=>m(y.target.value),disabled:i,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:k,onChange:y=>x(y.target.value),disabled:i,"aria-invalid":N?"true":void 0,placeholder:"Confirm your password"}),N&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:N})]})]}),p==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(Dc,{}),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:v,disabled:i,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:i||p!=="passkey"&&(w.length===0||k.length===0),children:i?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${n}`,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(io,{onSubmit:C,onCancel:g,isSubmitting:!1})]})})}function Rc(){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 Tc(){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 Ic(){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 Dc(){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 yo({address:t,label:s="Wallet Address",showCopy:n=!0,showExplorerLink:o=!0,allowReveal:r=!0,className:a=""}){const c=T.useCedrosLoginOptional(),[i,l]=d.useState(!1),[u,f]=d.useState(null),[h,p]=d.useState(!1),b=d.useRef(null),w=c?.config.solana?.network??"mainnet-beta",m=d.useMemo(()=>{const j=`https://explorer.solana.com/address/${t}`;return w==="mainnet-beta"?j:`${j}?cluster=${encodeURIComponent(w)}`},[t,w]),k=r&&t.length>18,x=d.useMemo(()=>!k||h?t:`${t.slice(0,8)}...${t.slice(-8)}`,[t,k,h]),N=d.useCallback(async()=>{try{f(null),await navigator.clipboard.writeText(t),l(!0),b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{l(!1),b.current=null},2e3)}catch(j){l(!1),f(j instanceof Error?j.message:"Copy failed")}},[t]);return d.useEffect(()=>()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${a}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:s}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[k&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>p(j=>!j),"aria-label":h?"Hide full wallet address":"Show full wallet address",children:h?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:m,target:"_blank",rel:"noreferrer",children:"Explorer"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:N,"aria-label":"Copy wallet address",children:i?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:t,children:x}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function xo({status:t,publicKey:s,onLock:n,onEnroll:o,onUnlock:r,onRecover:a,showActions:c=!0,compact:i=!1,className:l=""}){const u=t!==void 0,f=I.useWallet(),h=u?t:f.status,p=u?s??null:f.solanaPubkey,b=u?null:f.error,w=u?()=>{}:f.refresh,m=u?()=>{}:f.clearError,k=_c(h,b);return i?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${l}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${k.color}`,title:k.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:k.label}),p&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:p,children:Uc(p)})]}):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-${k.color}`,children:e.jsx(Fc,{status:h})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:k.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:k.description})]})]}),p&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(yo,{address:p})}),b&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:b}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:m,children:"Dismiss"})]}),c&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[h==="not_enrolled"&&o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:o,children:"Create Wallet"}),h==="enrolled_locked"&&r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:r,children:"Unlock Wallet"}),(h==="not_enrolled"||h==="error")&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:"Recover Wallet"}),h==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:w,children:"Retry"})]})]})}function _c(t,s){switch(t){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:s??"An error occurred with your wallet.",color:"error"}}}function Uc(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function Fc({status:t}){switch(t){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function Oc({className:t="",showActions:s=!0}){const n=I.useWallet(),[o,r]=d.useState("status"),a=d.useMemo(()=>{switch(o){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[o]),c=d.useCallback(()=>r("status"),[]),i=d.useCallback(async()=>{r("status"),await n.refresh()},[n]),l=d.useCallback(async()=>{r("status"),await n.refresh()},[n]),u=d.useCallback(async()=>{r("status"),await n.refresh()},[n]);return e.jsxs("div",{className:`cedros-wallet-manager ${t}`,children:[o!=="status"&&a&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:a.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:a.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:c,children:"Back"})]}),o==="status"&&e.jsx(xo,{onEnroll:()=>r("enroll"),onUnlock:()=>r("unlock"),onRecover:()=>r("recover_intro"),showActions:s}),o==="enroll"&&e.jsx(ho,{onComplete:()=>{i()},onCancel:c}),o==="unlock"&&e.jsx(go,{onUnlock:()=>{l()},onCancel:c}),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:()=>r("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:c,children:"Cancel"})]})]})}),o==="recover"&&e.jsx(bo,{onComplete:()=>{u()},onCancel:c})]})}function Wc({showDescriptions:t=!0,className:s="",onSave:n}){const{settings:o,isLoading:r,isUpdating:a,error:c,fetchSettings:i,updateSettings:l}=fn.useSystemSettings(),[u,f]=d.useState({}),[h,p]=d.useState(null),[b,w]=d.useState(!1);d.useEffect(()=>{i()},[i]),d.useEffect(()=>{if(b){const P=setTimeout(()=>w(!1),3e3);return()=>clearTimeout(P)}},[b]);const m=d.useCallback((P,g)=>{f(v=>({...v,[P]:g})),p(null),w(!1)},[]),k=d.useCallback(async()=>{const P=Object.entries(u).map(([g,v])=>({key:g,value:v}));if(P.length!==0)try{await l(P),f({}),p(null),w(!0),n?.()}catch(g){p(g instanceof Error?g.message:"Failed to save settings")}},[u,l,n]),x=d.useCallback(()=>{f({}),p(null),w(!1)},[]),N=Object.keys(u).length>0,j=Object.keys(u).length;if(r&&Object.keys(o).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(c)return e.jsx("div",{className:`cedros-system-settings ${s}`,children:e.jsx(X.ErrorMessage,{error:c.message})});const C=Object.keys(o).sort();return C.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${s}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${s}`,children:[h&&e.jsx(X.ErrorMessage,{error:h}),b&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),C.map(P=>e.jsx(qc,{category:P,settings:o[P],edits:u,showDescription:t,onChange:m},P)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[N&&e.jsxs("span",{className:"cedros-settings-change-count",children:[j," unsaved change",j!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:x,disabled:!N||a,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:k,disabled:!N||a,children:a?e.jsx(z.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const Mr=Object.keys(ze.SETTING_METADATA);function qc({category:t,settings:s,edits:n,showDescription:o,onChange:r}){const a=ze.CATEGORY_METADATA[t]||{label:t,description:"",icon:""},c=d.useMemo(()=>[...s].sort((i,l)=>{const u=Mr.indexOf(i.key),f=Mr.indexOf(l.key);return(u===-1?1/0:u)-(f===-1?1/0:f)}),[s]);return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:a.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:a.label}),o&&a.description&&e.jsx("p",{className:"cedros-settings-section-description",children:a.description})]})]}),e.jsx(ze.SettingsSection,{settings:c,edits:n,onChange:r})]})}class zc{client;constructor(s,n,o){this.client=new T.ApiClient({baseUrl:s,timeoutMs:n,retryAttempts:o})}async getStatus(){try{return await this.client.get("/setup/status")}catch(s){throw T.handleApiError(s,"Failed to check setup status")}}async createFirstAdmin(s){try{return await this.client.post("/setup/admin",s)}catch(n){throw T.handleApiError(n,"Failed to create admin account")}}}function Vs(){const{config:t}=T.useCedrosLogin(),[s,n]=d.useState(null),[o,r]=d.useState(!1),[a,c]=d.useState(!1),[i,l]=d.useState(null),u=d.useRef(0),f=d.useMemo(()=>new zc(t.serverUrl,t.requestTimeout,t.retryAttempts),[t.serverUrl,t.requestTimeout,t.retryAttempts]),h=d.useRef(f);h.current=f;const p=d.useCallback(async()=>{r(!0),l(null);const w=++u.current;try{const m=await h.current.getStatus();if(w!==u.current)return;n(m)}catch(m){if(w!==u.current)return;l(m instanceof Error?m:new Error("Failed to check setup status"))}finally{w===u.current&&r(!1)}},[]),b=d.useCallback(async w=>{c(!0),l(null);try{const m=await h.current.createFirstAdmin(w);return await p(),m}catch(m){const k=m instanceof Error?m:new Error("Failed to create admin");throw l(k),k}finally{c(!1)}},[p]);return{status:s,isLoading:o,isCreating:a,error:i,checkStatus:p,createAdmin:b}}const Hc=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Rr=8;function Vc(t){const s={};return t.email?Hc.test(t.email)||(s.email="Invalid email format"):s.email="Email is required",t.password?t.password.length<Rr&&(s.password=`Password must be at least ${Rr} characters`):s.password="Password is required",t.confirmPassword?t.password!==t.confirmPassword&&(s.confirmPassword="Passwords do not match"):s.confirmPassword="Please confirm your password",s}function Ao({onComplete:t,className:s=""}){const{status:n,isLoading:o,isCreating:r,error:a,checkStatus:c,createAdmin:i}=Vs(),[l,u]=d.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[f,h]=d.useState({}),[p,b]=d.useState(!1);d.useEffect(()=>{c()},[c]);const w=d.useCallback(k=>x=>{u(N=>({...N,[k]:x.target.value})),h(N=>({...N,[k]:void 0}))},[]),m=d.useCallback(async k=>{k.preventDefault();const x=Vc(l);if(Object.keys(x).length>0){h(x);return}try{await i({email:l.email,password:l.password,name:l.name||void 0,orgName:l.orgName||void 0}),b(!0),t?.()}catch{}},[l,i,t]);return o?e.jsx("div",{className:`cedros-setup ${s}`,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..."})]})}):n&&!n.needsSetup?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):p?e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${s}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:m,children:[a&&e.jsx(X.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 ${f.email?"cedros-setup__input--error":""}`,value:l.email,onChange:w("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:r}),f.email&&e.jsx("span",{className:"cedros-setup__error",children:f.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:w("name"),placeholder:"Admin",autoComplete:"name",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:l.orgName,onChange:w("orgName"),placeholder:"My Organization",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${f.password?"cedros-setup__input--error":""}`,value:l.password,onChange:w("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:r}),f.password&&e.jsx("span",{className:"cedros-setup__error",children:f.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 ${f.confirmPassword?"cedros-setup__input--error":""}`,value:l.confirmPassword,onChange:w("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:r}),f.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:f.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:r,children:r?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."}),n?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",n.serverVersion]})]})]})})}const $c=["security","rate_limit"];function Gc({className:t}){return e.jsx(Is.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:$c,className:t})}const Tr=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Qc({className:t}){const{settings:s,edits:n,isLoading:o,autosaveStatus:r,autosaveError:a,error:c,fetchSettings:i,handleChange:l,getEffectiveValue:u}=ze.useSettingsAutosave(),[f,h]=d.useState("email");d.useEffect(()=>{i()},[i]);const p=Tr.find(C=>C.id===f),b=p?.category??"",m=(u("email_provider")||"custom")==="custom",k=u("email_smtp_host"),x=!m||k!=null&&k!=="",N=d.useMemo(()=>{const C=s[b]??[];if(f!=="email")return C;const P=m?ut.ALL_EMAIL_FIELDS:ut.SIMPLIFIED_EMAIL_FIELDS;return C.filter(g=>P.includes(g.key)).sort((g,v)=>P.indexOf(g.key)-P.indexOf(v.key))},[s,b,f,m]),j=(C,P)=>{if(l(C,P),C==="email_provider"&&P!=="custom"){const g=ut.PROVIDER_SMTP_HOSTS[P];g&&(l("email_smtp_host",g),l("email_smtp_port","587"),l("email_smtp_tls","true"))}};return o&&Object.keys(s).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t??""}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${t??""}`,children:e.jsx(X.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${t??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(ze.AutosaveStatus,{status:r,error:a})]}),f==="email"&&!x&&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:Tr.map(C=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${f===C.id?"cedros-admin-tab-active":""}`,onClick:()=>h(C.id),"aria-selected":f===C.id,role:"tab",children:C.label},C.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:N.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",p?.label??"this section","."]})}):e.jsx(ze.SettingsSection,{settings:N,edits:n,onChange:f==="email"?j:l})})]})}const he={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]})},Kc=[{id:"users",label:"Users",icon:he.users},{id:"team",label:"Team",icon:he.members},{id:"deposits",label:"Deposits",icon:he.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:he.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:he.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:he.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:he.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:he.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:he.server,group:"Configuration"}];function Yc({title:t="Dashboard",sections:s=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],defaultSection:n="users",refreshInterval:o=0,pageSize:r=20,onSectionChange:a,onSettingsClick:c,onLogoutClick:i,className:l=""}){const[u,f]=d.useState(n),[h,p]=d.useState(!0),{user:b,logout:w}=T.useCedrosLogin(),{activeOrg:m,role:k,isLoading:x,fetchOrgs:N,hasPermission:j}=Rs.useOrgs(),{status:C,isLoading:P,checkStatus:g}=Vs(),{features:v,isLoading:A}=ie.useServerFeatures(),{canAccess:y}=ie.useDashboardPermissions(),S=d.useCallback(R=>{f(R),a?.(R)},[a]),E=Kc.filter(R=>!(!s.includes(R.id)||R.requiredFeature&&!v[R.requiredFeature]||!y(R.id))),B=E.find(R=>R.id===u),L=!B&&!A;return d.useEffect(()=>{N(),g()},[N,g]),d.useEffect(()=>{L&&E.length>0&&f("users")},[L,E.length]),!P&&C?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${l}`,children:e.jsx(Ao,{onComplete:()=>g()})}):(x||P||A)&&!m?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..."})]}):u==="team"&&!m?e.jsx("div",{className:`cedros-admin cedros-dashboard ${l}`,children:e.jsx(X.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:[he.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:t})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),E.filter(R=>!R.group).map(R=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===R.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>S(R.id),"aria-current":u===R.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:R.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:R.label})]},R.id))]}),E.some(R=>R.group==="Configuration")&&e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsxs("button",{type:"button",className:"cedros-dashboard__nav-label cedros-dashboard__nav-label--collapsible",onClick:()=>p(!h),"aria-expanded":h,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${h?"cedros-dashboard__nav-chevron--expanded":""}`,children:he.chevronRight})]}),h&&E.filter(R=>R.group==="Configuration").map(R=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===R.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>S(R.id),"aria-current":u===R.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:R.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:R.label})]},R.id))]})]}),b&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(Be.ProfileDropdown,{name:b.name,email:b.email,picture:b.picture,onSettings:c,onLogout:i??w})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:t}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:he.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:B?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(Zc,{pageSize:r,currentUserId:b?.id}),u==="team"&&m&&e.jsx(Xc,{orgId:m.id,currentUserId:b?.id,hasPermission:j,role:k}),u==="deposits"&&e.jsx(Jc,{pageSize:r,refreshInterval:o}),u==="withdrawals"&&e.jsx(el,{pageSize:r,refreshInterval:o}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(mn.AuthenticationSettings,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(gn.EmbeddedWalletSettings,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Qc,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Ts.CreditSystemSettings,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(wn.ServerSettings,{})})]})]})]})}function Zc({pageSize:t,currentUserId:s}){const[n,o]=d.useState(null),{statsItems:r,isLoading:a,error:c,refresh:i}=et.useUsersStatsSummary();return n?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(et.AdminUserDetail,{userId:n.id,currentUserId:s,onBack:()=>o(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(pn.StatsBar,{stats:r,isLoading:a,onRefresh:i}),c&&e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx(et.AdminUserList,{pageSize:t,currentUserId:s,onUserClick:l=>o(l)})]})}function Xc({orgId:t,currentUserId:s,hasPermission:n,role:o}){const[r,a]=d.useState("members"),{members:c,isLoading:i,error:l,fetchMembers:u,updateMemberRole:f,removeMember:h}=ie.useMembers(t),{invites:p,isLoading:b,error:w,fetchInvites:m,createInvite:k,cancelInvite:x,resendInvite:N}=ie.useInvites(t);d.useEffect(()=>{u(),m()},[u,m]);const j=n("invite:create"),C=n("invite:cancel"),P=p.length,g=c.reduce((S,E)=>(S[E.role]=(S[E.role]??0)+1,S),{}),v=g.owner??0,A=g.admin??0,y=g.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(pn.StatsBar,{stats:[{label:"Owners",value:v},{label:"Admins",value:A},{label:"Members",value:y},{label:"Pending Invites",value:P}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="members"?"cedros-admin-tab-active":""}`,onClick:()=>a("members"),"aria-selected":r==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${r==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>a("invites"),"aria-selected":r==="invites",role:"tab",children:["Pending Invites",P>0&&` (${P})`]}),o==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>a("permissions"),"aria-selected":r==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[r==="members"&&e.jsx(ie.MemberList,{members:c,currentUserId:s,isLoading:i,error:l?.message,canManage:n("member:remove"),canChangeRoles:n("member:role_change"),onUpdateRole:f,onRemove:h}),r==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[j&&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(ie.InviteForm,{onSubmit:k,isLoading:b,error:w?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(ie.InviteList,{invites:p,isLoading:b,error:w?.message,canManage:C||j,onCancel:C?x:void 0,onResend:j?N:void 0})})]}),r==="permissions"&&o==="owner"&&e.jsx(ie.PermissionsSection,{userRole:o})]})]})}function Jc({pageSize:t,refreshInterval:s}){const[n,o]=d.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(mt.AdminDepositStats,{refreshInterval:s}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:n,onChange:r=>o(r.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(mt.AdminDepositList,{statusFilter:n||void 0,pageSize:t,refreshInterval:s})]})]})}function el({pageSize:t,refreshInterval:s}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(Pe.AdminWithdrawalStats,{refreshInterval:s}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(Pe.AdminPrivacyPeriodDeposits,{pageSize:t,refreshInterval:s}),e.jsx(Pe.AdminWithdrawalQueue,{pageSize:t,refreshInterval:s}),e.jsx(Pe.AdminWithdrawalHistory,{pageSize:t,refreshInterval:s})]})]})}var We={},Kt,Ir;function tl(){return Ir||(Ir=1,Kt=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Kt}var Yt={},Le={},Dr;function Ie(){if(Dr)return Le;Dr=1;let t;const s=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return 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 s[o]},Le.getBCHDigit=function(n){let o=0;for(;n!==0;)o++,n>>>=1;return o},Le.setToSJISFunction=function(o){if(typeof o!="function")throw new Error('"toSJISFunc" is not a valid function.');t=o},Le.isKanjiModeEnabled=function(){return typeof t<"u"},Le.toSJIS=function(o){return t(o)},Le}var Zt={},_r;function $s(){return _r||(_r=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function s(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+n)}}t.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},t.from=function(o,r){if(t.isValid(o))return o;try{return s(o)}catch{return r}}})(Zt)),Zt}var Xt,Ur;function sl(){if(Ur)return Xt;Ur=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(s){const n=Math.floor(s/8);return(this.buffer[n]>>>7-s%8&1)===1},put:function(s,n){for(let o=0;o<n;o++)this.putBit((s>>>n-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(s){const n=Math.floor(this.length/8);this.buffer.length<=n&&this.buffer.push(0),s&&(this.buffer[n]|=128>>>this.length%8),this.length++}},Xt=t,Xt}var Jt,Fr;function rl(){if(Fr)return Jt;Fr=1;function t(s){if(!s||s<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=s,this.data=new Uint8Array(s*s),this.reservedBit=new Uint8Array(s*s)}return t.prototype.set=function(s,n,o,r){const a=s*this.size+n;this.data[a]=o,r&&(this.reservedBit[a]=!0)},t.prototype.get=function(s,n){return this.data[s*this.size+n]},t.prototype.xor=function(s,n,o){this.data[s*this.size+n]^=o},t.prototype.isReserved=function(s,n){return this.reservedBit[s*this.size+n]},Jt=t,Jt}var es={},Or;function nl(){return Or||(Or=1,(function(t){const s=Ie().getSymbolSize;t.getRowColCoords=function(o){if(o===1)return[];const r=Math.floor(o/7)+2,a=s(o),c=a===145?26:Math.ceil((a-13)/(2*r-2))*2,i=[a-7];for(let l=1;l<r-1;l++)i[l]=i[l-1]-c;return i.push(6),i.reverse()},t.getPositions=function(o){const r=[],a=t.getRowColCoords(o),c=a.length;for(let i=0;i<c;i++)for(let l=0;l<c;l++)i===0&&l===0||i===0&&l===c-1||i===c-1&&l===0||r.push([a[i],a[l]]);return r}})(es)),es}var ts={},Wr;function ol(){if(Wr)return ts;Wr=1;const t=Ie().getSymbolSize,s=7;return ts.getPositions=function(o){const r=t(o);return[[0,0],[r-s,0],[0,r-s]]},ts}var ss={},qr;function al(){return qr||(qr=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const s={N1:3,N2:3,N3:40,N4:10};t.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},t.from=function(r){return t.isValid(r)?parseInt(r,10):void 0},t.getPenaltyN1=function(r){const a=r.size;let c=0,i=0,l=0,u=null,f=null;for(let h=0;h<a;h++){i=l=0,u=f=null;for(let p=0;p<a;p++){let b=r.get(h,p);b===u?i++:(i>=5&&(c+=s.N1+(i-5)),u=b,i=1),b=r.get(p,h),b===f?l++:(l>=5&&(c+=s.N1+(l-5)),f=b,l=1)}i>=5&&(c+=s.N1+(i-5)),l>=5&&(c+=s.N1+(l-5))}return c},t.getPenaltyN2=function(r){const a=r.size;let c=0;for(let i=0;i<a-1;i++)for(let l=0;l<a-1;l++){const u=r.get(i,l)+r.get(i,l+1)+r.get(i+1,l)+r.get(i+1,l+1);(u===4||u===0)&&c++}return c*s.N2},t.getPenaltyN3=function(r){const a=r.size;let c=0,i=0,l=0;for(let u=0;u<a;u++){i=l=0;for(let f=0;f<a;f++)i=i<<1&2047|r.get(u,f),f>=10&&(i===1488||i===93)&&c++,l=l<<1&2047|r.get(f,u),f>=10&&(l===1488||l===93)&&c++}return c*s.N3},t.getPenaltyN4=function(r){let a=0;const c=r.data.length;for(let l=0;l<c;l++)a+=r.data[l];return Math.abs(Math.ceil(a*100/c/5)-10)*s.N4};function n(o,r,a){switch(o){case t.Patterns.PATTERN000:return(r+a)%2===0;case t.Patterns.PATTERN001:return r%2===0;case t.Patterns.PATTERN010:return a%3===0;case t.Patterns.PATTERN011:return(r+a)%3===0;case t.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(a/3))%2===0;case t.Patterns.PATTERN101:return r*a%2+r*a%3===0;case t.Patterns.PATTERN110:return(r*a%2+r*a%3)%2===0;case t.Patterns.PATTERN111:return(r*a%3+(r+a)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}t.applyMask=function(r,a){const c=a.size;for(let i=0;i<c;i++)for(let l=0;l<c;l++)a.isReserved(l,i)||a.xor(l,i,n(r,l,i))},t.getBestMask=function(r,a){const c=Object.keys(t.Patterns).length;let i=0,l=1/0;for(let u=0;u<c;u++){a(u),t.applyMask(u,r);const f=t.getPenaltyN1(r)+t.getPenaltyN2(r)+t.getPenaltyN3(r)+t.getPenaltyN4(r);t.applyMask(u,r),f<l&&(l=f,i=u)}return i}})(ss)),ss}var lt={},zr;function vo(){if(zr)return lt;zr=1;const t=$s(),s=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],n=[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 lt.getBlocksCount=function(r,a){switch(a){case t.L:return s[(r-1)*4+0];case t.M:return s[(r-1)*4+1];case t.Q:return s[(r-1)*4+2];case t.H:return s[(r-1)*4+3];default:return}},lt.getTotalCodewordsCount=function(r,a){switch(a){case t.L:return n[(r-1)*4+0];case t.M:return n[(r-1)*4+1];case t.Q:return n[(r-1)*4+2];case t.H:return n[(r-1)*4+3];default:return}},lt}var rs={},Xe={},Hr;function il(){if(Hr)return Xe;Hr=1;const t=new Uint8Array(512),s=new Uint8Array(256);return(function(){let o=1;for(let r=0;r<255;r++)t[r]=o,s[o]=r,o<<=1,o&256&&(o^=285);for(let r=255;r<512;r++)t[r]=t[r-255]})(),Xe.log=function(o){if(o<1)throw new Error("log("+o+")");return s[o]},Xe.exp=function(o){return t[o]},Xe.mul=function(o,r){return o===0||r===0?0:t[s[o]+s[r]]},Xe}var Vr;function cl(){return Vr||(Vr=1,(function(t){const s=il();t.mul=function(o,r){const a=new Uint8Array(o.length+r.length-1);for(let c=0;c<o.length;c++)for(let i=0;i<r.length;i++)a[c+i]^=s.mul(o[c],r[i]);return a},t.mod=function(o,r){let a=new Uint8Array(o);for(;a.length-r.length>=0;){const c=a[0];for(let l=0;l<r.length;l++)a[l]^=s.mul(r[l],c);let i=0;for(;i<a.length&&a[i]===0;)i++;a=a.slice(i)}return a},t.generateECPolynomial=function(o){let r=new Uint8Array([1]);for(let a=0;a<o;a++)r=t.mul(r,new Uint8Array([1,s.exp(a)]));return r}})(rs)),rs}var ns,$r;function ll(){if($r)return ns;$r=1;const t=cl();function s(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}return s.prototype.initialize=function(o){this.degree=o,this.genPoly=t.generateECPolynomial(this.degree)},s.prototype.encode=function(o){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(o.length+this.degree);r.set(o);const a=t.mod(r,this.genPoly),c=this.degree-a.length;if(c>0){const i=new Uint8Array(this.degree);return i.set(a,c),i}return a},ns=s,ns}var os={},as={},is={},Gr;function jo(){return Gr||(Gr=1,is.isValid=function(s){return!isNaN(s)&&s>=1&&s<=40}),is}var we={},Qr;function ko(){if(Qr)return we;Qr=1;const t="[0-9]+",s="[A-Z $%*+\\-./:]+";let n="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";n=n.replace(/u/g,"\\u");const o="(?:(?![A-Z0-9 $%*+\\-./:]|"+n+`)(?:.|[\r
2050
+ ]))+`;we.KANJI=new RegExp(n,"g"),we.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),we.BYTE=new RegExp(o,"g"),we.NUMERIC=new RegExp(t,"g"),we.ALPHANUMERIC=new RegExp(s,"g");const r=new RegExp("^"+n+"$"),a=new RegExp("^"+t+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return we.testKanji=function(l){return r.test(l)},we.testNumeric=function(l){return a.test(l)},we.testAlphanumeric=function(l){return c.test(l)},we}var Kr;function De(){return Kr||(Kr=1,(function(t){const s=jo(),n=ko();t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(a,c){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!s.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?a.ccBits[0]:c<27?a.ccBits[1]:a.ccBits[2]},t.getBestModeForData=function(a){return n.testNumeric(a)?t.NUMERIC:n.testAlphanumeric(a)?t.ALPHANUMERIC:n.testKanji(a)?t.KANJI:t.BYTE},t.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")},t.isValid=function(a){return a&&a.bit&&a.ccBits};function o(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+r)}}t.from=function(a,c){if(t.isValid(a))return a;try{return o(a)}catch{return c}}})(as)),as}var Yr;function dl(){return Yr||(Yr=1,(function(t){const s=Ie(),n=vo(),o=$s(),r=De(),a=jo(),c=7973,i=s.getBCHDigit(c);function l(p,b,w){for(let m=1;m<=40;m++)if(b<=t.getCapacity(m,w,p))return m}function u(p,b){return r.getCharCountIndicator(p,b)+4}function f(p,b){let w=0;return p.forEach(function(m){const k=u(m.mode,b);w+=k+m.getBitsLength()}),w}function h(p,b){for(let w=1;w<=40;w++)if(f(p,w)<=t.getCapacity(w,b,r.MIXED))return w}t.from=function(b,w){return a.isValid(b)?parseInt(b,10):w},t.getCapacity=function(b,w,m){if(!a.isValid(b))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=r.BYTE);const k=s.getSymbolTotalCodewords(b),x=n.getTotalCodewordsCount(b,w),N=(k-x)*8;if(m===r.MIXED)return N;const j=N-u(m,b);switch(m){case r.NUMERIC:return Math.floor(j/10*3);case r.ALPHANUMERIC:return Math.floor(j/11*2);case r.KANJI:return Math.floor(j/13);case r.BYTE:default:return Math.floor(j/8)}},t.getBestVersionForData=function(b,w){let m;const k=o.from(w,o.M);if(Array.isArray(b)){if(b.length>1)return h(b,k);if(b.length===0)return 1;m=b[0]}else m=b;return l(m.mode,m.getLength(),k)},t.getEncodedBits=function(b){if(!a.isValid(b)||b<7)throw new Error("Invalid QR Code version");let w=b<<12;for(;s.getBCHDigit(w)-i>=0;)w^=c<<s.getBCHDigit(w)-i;return b<<12|w}})(os)),os}var cs={},Zr;function ul(){if(Zr)return cs;Zr=1;const t=Ie(),s=1335,n=21522,o=t.getBCHDigit(s);return cs.getEncodedBits=function(a,c){const i=a.bit<<3|c;let l=i<<10;for(;t.getBCHDigit(l)-o>=0;)l^=s<<t.getBCHDigit(l)-o;return(i<<10|l)^n},cs}var ls={},ds,Xr;function hl(){if(Xr)return ds;Xr=1;const t=De();function s(n){this.mode=t.NUMERIC,this.data=n.toString()}return s.getBitsLength=function(o){return 10*Math.floor(o/3)+(o%3?o%3*3+1:0)},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(o){let r,a,c;for(r=0;r+3<=this.data.length;r+=3)a=this.data.substr(r,3),c=parseInt(a,10),o.put(c,10);const i=this.data.length-r;i>0&&(a=this.data.substr(r),c=parseInt(a,10),o.put(c,i*3+1))},ds=s,ds}var us,Jr;function fl(){if(Jr)return us;Jr=1;const t=De(),s=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function n(o){this.mode=t.ALPHANUMERIC,this.data=o}return n.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(r){let a;for(a=0;a+2<=this.data.length;a+=2){let c=s.indexOf(this.data[a])*45;c+=s.indexOf(this.data[a+1]),r.put(c,11)}this.data.length%2&&r.put(s.indexOf(this.data[a]),6)},us=n,us}var hs,en;function pl(){if(en)return hs;en=1;const t=De();function s(n){this.mode=t.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}return s.getBitsLength=function(o){return o*8},s.prototype.getLength=function(){return this.data.length},s.prototype.getBitsLength=function(){return s.getBitsLength(this.data.length)},s.prototype.write=function(n){for(let o=0,r=this.data.length;o<r;o++)n.put(this.data[o],8)},hs=s,hs}var fs,tn;function ml(){if(tn)return fs;tn=1;const t=De(),s=Ie();function n(o){this.mode=t.KANJI,this.data=o}return n.getBitsLength=function(r){return r*13},n.prototype.getLength=function(){return this.data.length},n.prototype.getBitsLength=function(){return n.getBitsLength(this.data.length)},n.prototype.write=function(o){let r;for(r=0;r<this.data.length;r++){let a=s.toSJIS(this.data[r]);if(a>=33088&&a<=40956)a-=33088;else if(a>=57408&&a<=60351)a-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
2051
+ Make sure your charset is UTF-8`);a=(a>>>8&255)*192+(a&255),o.put(a,13)}},fs=n,fs}var ps={exports:{}},sn;function gl(){return sn||(sn=1,(function(t){var s={single_source_shortest_paths:function(n,o,r){var a={},c={};c[o]=0;var i=s.PriorityQueue.make();i.push(o,0);for(var l,u,f,h,p,b,w,m,k;!i.empty();){l=i.pop(),u=l.value,h=l.cost,p=n[u]||{};for(f in p)p.hasOwnProperty(f)&&(b=p[f],w=h+b,m=c[f],k=typeof c[f]>"u",(k||m>w)&&(c[f]=w,i.push(f,w),a[f]=u))}if(typeof r<"u"&&typeof c[r]>"u"){var x=["Could not find a path from ",o," to ",r,"."].join("");throw new Error(x)}return a},extract_shortest_path_from_predecessor_list:function(n,o){for(var r=[],a=o;a;)r.push(a),n[a],a=n[a];return r.reverse(),r},find_path:function(n,o,r){var a=s.single_source_shortest_paths(n,o,r);return s.extract_shortest_path_from_predecessor_list(a,r)},PriorityQueue:{make:function(n){var o=s.PriorityQueue,r={},a;n=n||{};for(a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);return r.queue=[],r.sorter=n.sorter||o.default_sorter,r},default_sorter:function(n,o){return n.cost-o.cost},push:function(n,o){var r={value:n,cost:o};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=s})(ps)),ps.exports}var rn;function wl(){return rn||(rn=1,(function(t){const s=De(),n=hl(),o=fl(),r=pl(),a=ml(),c=ko(),i=Ie(),l=gl();function u(x){return unescape(encodeURIComponent(x)).length}function f(x,N,j){const C=[];let P;for(;(P=x.exec(j))!==null;)C.push({data:P[0],index:P.index,mode:N,length:P[0].length});return C}function h(x){const N=f(c.NUMERIC,s.NUMERIC,x),j=f(c.ALPHANUMERIC,s.ALPHANUMERIC,x);let C,P;return i.isKanjiModeEnabled()?(C=f(c.BYTE,s.BYTE,x),P=f(c.KANJI,s.KANJI,x)):(C=f(c.BYTE_KANJI,s.BYTE,x),P=[]),N.concat(j,C,P).sort(function(v,A){return v.index-A.index}).map(function(v){return{data:v.data,mode:v.mode,length:v.length}})}function p(x,N){switch(N){case s.NUMERIC:return n.getBitsLength(x);case s.ALPHANUMERIC:return o.getBitsLength(x);case s.KANJI:return a.getBitsLength(x);case s.BYTE:return r.getBitsLength(x)}}function b(x){return x.reduce(function(N,j){const C=N.length-1>=0?N[N.length-1]:null;return C&&C.mode===j.mode?(N[N.length-1].data+=j.data,N):(N.push(j),N)},[])}function w(x){const N=[];for(let j=0;j<x.length;j++){const C=x[j];switch(C.mode){case s.NUMERIC:N.push([C,{data:C.data,mode:s.ALPHANUMERIC,length:C.length},{data:C.data,mode:s.BYTE,length:C.length}]);break;case s.ALPHANUMERIC:N.push([C,{data:C.data,mode:s.BYTE,length:C.length}]);break;case s.KANJI:N.push([C,{data:C.data,mode:s.BYTE,length:u(C.data)}]);break;case s.BYTE:N.push([{data:C.data,mode:s.BYTE,length:u(C.data)}])}}return N}function m(x,N){const j={},C={start:{}};let P=["start"];for(let g=0;g<x.length;g++){const v=x[g],A=[];for(let y=0;y<v.length;y++){const S=v[y],E=""+g+y;A.push(E),j[E]={node:S,lastCount:0},C[E]={};for(let B=0;B<P.length;B++){const L=P[B];j[L]&&j[L].node.mode===S.mode?(C[L][E]=p(j[L].lastCount+S.length,S.mode)-p(j[L].lastCount,S.mode),j[L].lastCount+=S.length):(j[L]&&(j[L].lastCount=S.length),C[L][E]=p(S.length,S.mode)+4+s.getCharCountIndicator(S.mode,N))}}P=A}for(let g=0;g<P.length;g++)C[P[g]].end=0;return{map:C,table:j}}function k(x,N){let j;const C=s.getBestModeForData(x);if(j=s.from(N,C),j!==s.BYTE&&j.bit<C.bit)throw new Error('"'+x+'" cannot be encoded with mode '+s.toString(j)+`.
2052
+ Suggested mode is: `+s.toString(C));switch(j===s.KANJI&&!i.isKanjiModeEnabled()&&(j=s.BYTE),j){case s.NUMERIC:return new n(x);case s.ALPHANUMERIC:return new o(x);case s.KANJI:return new a(x);case s.BYTE:return new r(x)}}t.fromArray=function(N){return N.reduce(function(j,C){return typeof C=="string"?j.push(k(C,null)):C.data&&j.push(k(C.data,C.mode)),j},[])},t.fromString=function(N,j){const C=h(N,i.isKanjiModeEnabled()),P=w(C),g=m(P,j),v=l.find_path(g.map,"start","end"),A=[];for(let y=1;y<v.length-1;y++)A.push(g.table[v[y]].node);return t.fromArray(b(A))},t.rawSplit=function(N){return t.fromArray(h(N,i.isKanjiModeEnabled()))}})(ls)),ls}var nn;function bl(){if(nn)return Yt;nn=1;const t=Ie(),s=$s(),n=sl(),o=rl(),r=nl(),a=ol(),c=al(),i=vo(),l=ll(),u=dl(),f=ul(),h=De(),p=wl();function b(g,v){const A=g.size,y=a.getPositions(v);for(let S=0;S<y.length;S++){const E=y[S][0],B=y[S][1];for(let L=-1;L<=7;L++)if(!(E+L<=-1||A<=E+L))for(let M=-1;M<=7;M++)B+M<=-1||A<=B+M||(L>=0&&L<=6&&(M===0||M===6)||M>=0&&M<=6&&(L===0||L===6)||L>=2&&L<=4&&M>=2&&M<=4?g.set(E+L,B+M,!0,!0):g.set(E+L,B+M,!1,!0))}}function w(g){const v=g.size;for(let A=8;A<v-8;A++){const y=A%2===0;g.set(A,6,y,!0),g.set(6,A,y,!0)}}function m(g,v){const A=r.getPositions(v);for(let y=0;y<A.length;y++){const S=A[y][0],E=A[y][1];for(let B=-2;B<=2;B++)for(let L=-2;L<=2;L++)B===-2||B===2||L===-2||L===2||B===0&&L===0?g.set(S+B,E+L,!0,!0):g.set(S+B,E+L,!1,!0)}}function k(g,v){const A=g.size,y=u.getEncodedBits(v);let S,E,B;for(let L=0;L<18;L++)S=Math.floor(L/3),E=L%3+A-8-3,B=(y>>L&1)===1,g.set(S,E,B,!0),g.set(E,S,B,!0)}function x(g,v,A){const y=g.size,S=f.getEncodedBits(v,A);let E,B;for(E=0;E<15;E++)B=(S>>E&1)===1,E<6?g.set(E,8,B,!0):E<8?g.set(E+1,8,B,!0):g.set(y-15+E,8,B,!0),E<8?g.set(8,y-E-1,B,!0):E<9?g.set(8,15-E-1+1,B,!0):g.set(8,15-E-1,B,!0);g.set(y-8,8,1,!0)}function N(g,v){const A=g.size;let y=-1,S=A-1,E=7,B=0;for(let L=A-1;L>0;L-=2)for(L===6&&L--;;){for(let M=0;M<2;M++)if(!g.isReserved(S,L-M)){let R=!1;B<v.length&&(R=(v[B]>>>E&1)===1),g.set(S,L-M,R),E--,E===-1&&(B++,E=7)}if(S+=y,S<0||A<=S){S-=y,y=-y;break}}}function j(g,v,A){const y=new n;A.forEach(function(M){y.put(M.mode.bit,4),y.put(M.getLength(),h.getCharCountIndicator(M.mode,g)),M.write(y)});const S=t.getSymbolTotalCodewords(g),E=i.getTotalCodewordsCount(g,v),B=(S-E)*8;for(y.getLengthInBits()+4<=B&&y.put(0,4);y.getLengthInBits()%8!==0;)y.putBit(0);const L=(B-y.getLengthInBits())/8;for(let M=0;M<L;M++)y.put(M%2?17:236,8);return C(y,g,v)}function C(g,v,A){const y=t.getSymbolTotalCodewords(v),S=i.getTotalCodewordsCount(v,A),E=y-S,B=i.getBlocksCount(v,A),L=y%B,M=B-L,R=Math.floor(y/B),U=Math.floor(E/B),F=U+1,q=R-U,W=new l(q);let D=0;const _=new Array(B),$=new Array(B);let J=0;const oe=new Uint8Array(g.buffer);for(let Y=0;Y<B;Y++){const de=Y<M?U:F;_[Y]=oe.slice(D,D+de),$[Y]=W.encode(_[Y]),D+=de,J=Math.max(J,de)}const be=new Uint8Array(y);let fe=0,V,H;for(V=0;V<J;V++)for(H=0;H<B;H++)V<_[H].length&&(be[fe++]=_[H][V]);for(V=0;V<q;V++)for(H=0;H<B;H++)be[fe++]=$[H][V];return be}function P(g,v,A,y){let S;if(Array.isArray(g))S=p.fromArray(g);else if(typeof g=="string"){let R=v;if(!R){const U=p.rawSplit(g);R=u.getBestVersionForData(U,A)}S=p.fromString(g,R||40)}else throw new Error("Invalid data");const E=u.getBestVersionForData(S,A);if(!E)throw new Error("The amount of data is too big to be stored in a QR Code");if(!v)v=E;else if(v<E)throw new Error(`
2053
2053
  The chosen QR Code version cannot contain this amount of data.
2054
- Minimum version required to store current data is: `+P+`.
2055
- `);const S=j(v,A,E),B=t.getSymbolSize(v),M=new o(B);return b(M,v),g(M),p(M,v),y(M,A,0),v>=7&&k(M,v),N(M,S),isNaN(x)&&(x=c.getBestMask(M,y.bind(null,M,A))),c.applyMask(x,M),y(M,A,x),{modules:M,version:v,errorCorrectionLevel:A,maskPattern:x,segments:E}}return Qt.create=function(v,A){if(typeof v>"u"||v==="")throw new Error("No input text");let x=s.M,E,P;return typeof A<"u"&&(x=s.from(A.errorCorrectionLevel,s.M),E=u.from(A.version),P=c.from(A.maskPattern),A.toSJISFunc&&t.setToSJISFunction(A.toSJISFunc)),L(v,E,x,P)},Qt}var fs={},ps={},tn;function Ao(){return tn||(tn=1,(function(t){function s(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let o=n.slice().replace("#","").split("");if(o.length<3||o.length===5||o.length>8)throw new Error("Invalid hex color: "+n);(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 r=parseInt(o.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+o.slice(0,6).join("")}}t.getOptions=function(o){o||(o={}),o.color||(o.color={});const r=typeof o.margin>"u"||o.margin===null||o.margin<0?4:o.margin,a=o.width&&o.width>=21?o.width:void 0,c=o.scale||4;return{width:a,scale:a?4:c,margin:r,color:{dark:s(o.color.dark||"#000000ff"),light:s(o.color.light||"#ffffffff")},type:o.type,rendererOpts:o.rendererOpts||{}}},t.getScale=function(o,r){return r.width&&r.width>=o+r.margin*2?r.width/(o+r.margin*2):r.scale},t.getImageWidth=function(o,r){const a=t.getScale(o,r);return Math.floor((o+r.margin*2)*a)},t.qrToImageData=function(o,r,a){const c=r.modules.size,i=r.modules.data,l=t.getScale(c,a),u=Math.floor((c+a.margin*2)*l),f=a.margin*l,h=[a.color.light,a.color.dark];for(let m=0;m<u;m++)for(let b=0;b<u;b++){let g=(m*u+b)*4,p=a.color.light;if(m>=f&&b>=f&&m<u-f&&b<u-f){const k=Math.floor((m-f)/l),y=Math.floor((b-f)/l);p=h[i[k*c+y]?1:0]}o[g++]=p.r,o[g++]=p.g,o[g++]=p.b,o[g]=p.a}}})(ps)),ps}var sn;function gl(){return sn||(sn=1,(function(t){const s=Ao();function n(r,a,c){r.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=c,a.width=c,a.style.height=c+"px",a.style.width=c+"px"}function o(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(a,c,i){let l=i,u=c;typeof l>"u"&&(!c||!c.getContext)&&(l=c,c=void 0),c||(u=o()),l=s.getOptions(l);const f=s.getImageWidth(a.modules.size,l),h=u.getContext("2d"),m=h.createImageData(f,f);return s.qrToImageData(m.data,a,l),n(h,u,f),h.putImageData(m,0,0),u},t.renderToDataURL=function(a,c,i){let l=i;typeof l>"u"&&(!c||!c.getContext)&&(l=c,c=void 0),l||(l={});const u=t.render(a,c,l),f=l.type||"image/png",h=l.rendererOpts||{};return u.toDataURL(f,h.quality)}})(fs)),fs}var ms={},rn;function wl(){if(rn)return ms;rn=1;const t=Ao();function s(r,a){const c=r.a/255,i=a+'="'+r.hex+'"';return c<1?i+" "+a+'-opacity="'+c.toFixed(2).slice(1)+'"':i}function n(r,a,c){let i=r+a;return typeof c<"u"&&(i+=" "+c),i}function o(r,a,c){let i="",l=0,u=!1,f=0;for(let h=0;h<r.length;h++){const m=Math.floor(h%a),b=Math.floor(h/a);!m&&!u&&(u=!0),r[h]?(f++,h>0&&m>0&&r[h-1]||(i+=u?n("M",m+c,.5+b+c):n("m",l,0),l=0,u=!1),m+1<a&&r[h+1]||(i+=n("h",f),f=0)):l++}return i}return ms.render=function(a,c,i){const l=t.getOptions(c),u=a.modules.size,f=a.modules.data,h=u+l.margin*2,m=l.color.light.a?"<path "+s(l.color.light,"fill")+' d="M0 0h'+h+"v"+h+'H0z"/>':"",b="<path "+s(l.color.dark,"stroke")+' d="'+o(f,u,l.margin)+'"/>',g='viewBox="0 0 '+h+" "+h+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(l.width?'width="'+l.width+'" height="'+l.width+'" ':"")+g+' shape-rendering="crispEdges">'+m+b+`</svg>
2056
- `;return typeof i=="function"&&i(null,k),k},ms}var nn;function bl(){if(nn)return Fe;nn=1;const t=Xc(),s=ml(),n=gl(),o=wl();function r(a,c,i,l,u){const f=[].slice.call(arguments,1),h=f.length,m=typeof f[h-1]=="function";if(!m&&!t())throw new Error("Callback required as last argument");if(m){if(h<2)throw new Error("Too few arguments provided");h===2?(u=i,i=c,c=l=void 0):h===3&&(c.getContext&&typeof u>"u"?(u=l,l=void 0):(u=l,l=i,i=c,c=void 0))}else{if(h<1)throw new Error("Too few arguments provided");return h===1?(i=c,c=l=void 0):h===2&&!c.getContext&&(l=i,i=c,c=void 0),new Promise(function(b,g){try{const p=s.create(i,l);b(a(p,c,l))}catch(p){g(p)}})}try{const b=s.create(i,l);u(null,a(b,c,l))}catch(b){u(b)}}return Fe.create=s.create,Fe.toCanvas=r.bind(null,n.render),Fe.toDataURL=r.bind(null,n.renderToDataURL),Fe.toString=r.bind(null,function(a,c,i){return o.render(a,i)}),Fe}var yl=bl();const xl=mn(yl);function Al({value:t,size:s=200,alt:n="QR code",className:o=""}){const r=d.useRef(null),[a,c]=d.useState(null);return d.useEffect(()=>{!r.current||!t||xl.toCanvas(r.current,t,{width:s,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{c(null)}).catch(i=>{c(i instanceof Error?i.message:"Failed to generate QR code")})},[t,s]),a?e.jsx("div",{className:`cedros-qr-error ${o}`,style:{width:s,height:s},role:"img","aria-label":n,children:e.jsx("p",{children:"Failed to generate QR code"})}):e.jsx("canvas",{ref:r,className:`cedros-totp-qr-image ${o}`,role:"img","aria-label":n,style:{borderRadius:"0.5rem"}})}function Vs(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(null),[r,a]=d.useState("idle"),[c,i]=d.useState(null),[l,u]=d.useState(!1),[f,h]=d.useState(null),m=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),b=d.useCallback(async()=>{u(!0),h(null);try{const C=await m.get("/mfa/status");return o(C),C}catch(C){const L=T.handleApiError(C,"Unable to load two-factor authentication status. Please try again.");throw h(L),L}finally{u(!1)}},[m]),g=d.useCallback(async()=>{u(!0),h(null),a("loading");try{const C=await m.post("/mfa/setup",{});return i(C),a("setup"),C}catch(C){const L=T.handleApiError(C,"Unable to start two-factor setup. Please try again.");throw h(L),a("error"),L}finally{u(!1)}},[m]),p=d.useCallback(async C=>{if(!/^\d{6}$/.test(C)){const L={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw h(L),L}u(!0),h(null),a("verifying");try{await m.post("/mfa/enable",{code:C}),a("success");try{const L=await m.get("/mfa/status");o(L)}catch{o({enabled:!0,recoveryCodesRemaining:0})}}catch(L){const w=T.handleApiError(L,"Incorrect verification code. Please check and try again.");throw h(w),a("error"),w}finally{u(!1)}},[m]),k=d.useCallback(async C=>{if(!C){const L={code:"VALIDATION_ERROR",message:"Please enter your password"};throw h(L),L}u(!0),h(null);try{await m.post("/mfa/disable",{password:C}),o({enabled:!1,recoveryCodesRemaining:0}),i(null),a("idle")}catch(L){const w=T.handleApiError(L,"Unable to disable two-factor authentication. Please try again.");throw h(w),w}finally{u(!1)}},[m]),y=d.useCallback(async C=>{if(!/^\d{6}$/.test(C)){const L={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw h(L),L}u(!0),h(null);try{return await m.post("/mfa/recovery-codes/regenerate",{code:C})}catch(L){const w=T.handleApiError(L,"Unable to regenerate recovery codes. Please try again.");throw h(w),w}finally{u(!1)}},[m]),N=d.useCallback(()=>h(null),[]),j=d.useCallback(()=>{h(null),i(null),a("idle"),u(!1)},[]);return{status:n,setupState:r,setupData:c,isLoading:l,error:f,getStatus:b,beginSetup:g,enableTotp:p,disableTotp:k,regenerateBackupCodes:y,clearError:N,reset:j}}function $s({onSuccess:t,onCancel:s,className:n=""}){const{setupState:o,setupData:r,isLoading:a,error:c,beginSetup:i,enableTotp:l,clearError:u,reset:f}=Vs(),[h,m]=d.useState("qr"),[b,g]=d.useState(""),[p,k]=d.useState(!1),[y,N]=d.useState(!1),j=d.useRef(null);d.useEffect(()=>{o==="idle"&&i().catch(()=>{})},[o,i]),d.useEffect(()=>{o==="success"&&t?.()},[o,t]);const C=async()=>{r?.secret&&(await navigator.clipboard.writeText(r.secret),k(!0),j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>k(!1),2e3))},L=async()=>{if(r?.recoveryCodes){const A=r.recoveryCodes.join(`
2057
- `);await navigator.clipboard.writeText(A)}},w=async()=>{try{await l(b)}catch{g("")}},v=()=>{f(),s?.()};return d.useEffect(()=>()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null)},[]),o==="loading"||o==="idle"&&a?e.jsx("div",{className:`cedros-totp-setup ${n}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(z.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):o==="error"&&!r?e.jsxs("div",{className:`cedros-totp-setup ${n}`,children:[e.jsx(Z.ErrorMessage,{error:c,onDismiss:u}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:v,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>i(),children:"Try again"})]})]}):o==="success"?e.jsx("div",{className:`cedros-totp-setup ${n}`,children:e.jsxs("div",{className:"cedros-totp-success",children:[e.jsxs("svg",{className:"cedros-totp-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"var(--cedros-success)",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"var(--cedros-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication enabled"}),e.jsx("p",{className:"cedros-totp-description",children:"Your account is now protected with an additional layer of security."})]})}):r?e.jsxs("div",{className:`cedros-totp-setup ${n}`,children:[h==="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(Al,{value:r.otpauthUri,size:200,alt:"QR code for authenticator app"})}),e.jsxs("div",{className:"cedros-totp-manual",children:[e.jsx("p",{className:"cedros-totp-manual-label",children:"Or enter this code manually:"}),e.jsxs("div",{className:"cedros-totp-secret",children:[e.jsx("code",{className:"cedros-totp-secret-code",children:r.secret}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:C,"aria-label":"Copy secret",children:p?"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:v,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>m("backup"),children:"Continue"})]})]}),h==="backup"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Save recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. You can use them to access your account if you lose your authenticator device."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:r.recoveryCodes.map((A,x)=>e.jsx("code",{className:"cedros-totp-backup-code",children:A},x))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:L,children:"Copy all codes"}),e.jsxs("label",{className:"cedros-checkbox-label cedros-totp-confirm",children:[e.jsx("input",{type:"checkbox",className:"cedros-checkbox",checked:y,onChange:A=>N(A.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:()=>m("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>m("verify"),disabled:!y,children:"Continue"})]})]}),h==="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(Q.OtpInput,{value:b,onChange:g,onComplete:w,disabled:a,error:c?.message,autoFocus:!0}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>m("backup"),disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:w,disabled:a||b.length!==6,children:a?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function vo({onStatusChange:t,className:s=""}){const{status:n,isLoading:o,error:r,getStatus:a,disableTotp:c,regenerateBackupCodes:i,clearError:l}=Vs(),[u,f]=d.useState("status"),[h,m]=d.useState(""),[b,g]=d.useState(""),[p,k]=d.useState(null),[y,N]=d.useState(!1),[j,C]=d.useState(null);d.useEffect(()=>{a().catch(()=>{})},[a]);const L=d.useCallback(()=>{f("status"),t?.(!0)},[t]),w=async()=>{N(!0),C(null);try{await c(h),f("status"),m(""),t?.(!1)}catch(x){C(x instanceof Error?x.message:"Failed to disable 2FA"),m("")}finally{N(!1)}},v=async()=>{N(!0),C(null);try{const x=await i(b);k(x.recoveryCodes),g("")}catch(x){C(x instanceof Error?x.message:"Failed to regenerate codes"),g("")}finally{N(!1)}},A=async()=>{p&&await navigator.clipboard.writeText(p.join(`
2058
- `))};return o&&!n?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(z.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):r&&!n?e.jsxs("div",{className:`cedros-totp-settings ${s}`,children:[e.jsx(Z.ErrorMessage,{error:r,onDismiss:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>a(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx($s,{onSuccess:L,onCancel:()=>f("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),j&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:j},onDismiss:()=>C(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.PasswordInput,{label:"Password",placeholder:"Enter your password",value:h,onChange:x=>m(x.target.value),disabled:y,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("status"),m(""),C(null)},disabled:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:w,disabled:y||h.length===0,children:y?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?p?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:p.map((x,E)=>e.jsx("code",{className:"cedros-totp-backup-code",children:x},E))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:A,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:()=>{f("status"),k(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),j&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:j},onDismiss:()=>C(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.OtpInput,{value:b,onChange:g,onComplete:v,disabled:y,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("status"),g(""),C(null)},disabled:y,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:v,disabled:y||b.length!==6,children:y?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 ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${n?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:n?.enabled?"Enabled":"Disabled"})]}),n?.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:n.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>f("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>f("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("setup"),children:"Enable two-factor authentication"})]})})}class vl{client;constructor(s,n,o,r){this.client=new T.ApiClient({baseUrl:s,timeoutMs:n,retryAttempts:o,getAccessToken:r})}async changePassword(s){try{return await this.client.post("/auth/change-password",s)}catch(n){throw T.handleApiError(n,"Failed to change password")}}async updateProfile(s){try{return await this.client.patch("/auth/me",s)}catch(n){throw T.handleApiError(n,"Failed to update profile")}}}function Xe(){const{config:t,authState:s,_internal:n}=T.useCedrosLogin(),[o,r]=d.useState(!1),[a,c]=d.useState(null),i=d.useMemo(()=>new vl(t.serverUrl,t.requestTimeout,t.retryAttempts,n?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,n]),l=d.useCallback(()=>{c(null)},[]),u=d.useCallback(async h=>{if(s!=="authenticated")throw new Error("Must be authenticated to update profile");r(!0),c(null);try{return await i.updateProfile(h)}catch(m){const b=m instanceof Error?m:new Error("Failed to update profile");throw c(b),b}finally{r(!1)}},[s,i]),f=d.useCallback(async h=>{if(s!=="authenticated")throw new Error("Must be authenticated to change password");r(!0),c(null);try{await i.changePassword(h)}catch(m){const b=m instanceof Error?m:new Error("Failed to change password");throw c(b),b}finally{r(!1)}},[s,i]);return{isLoading:o,error:a,updateProfile:u,changePassword:f,clearError:l}}function jl({onPasswordChange:t,onClose:s,className:n=""}){const{user:o}=I.useAuth(),{isLoading:r,error:a,changePassword:c,clearError:i}=Xe(),[l,u]=d.useState("main"),[f,h]=d.useState(""),[m,b]=d.useState(""),[g,p]=d.useState(""),[k,y]=d.useState(null),[N,j]=d.useState(null),C=Re.validatePassword(m),L=m===g,w=f.length>0&&m.length>0&&g.length>0&&C.isValid&&L,v=d.useCallback(async()=>{if(w){y(null),j(null);try{await c({currentPassword:f,newPassword:m}),h(""),b(""),p(""),j("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>{u("main"),j(null)},2e3)}catch(E){y(E instanceof Error?E.message:"Failed to change password")}}},[w,f,m,c,t]),A=d.useCallback(()=>{u("main"),h(""),b(""),p(""),y(null),i()},[i]),x=()=>o?.name?o.name.split(" ").map(E=>E[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?";return l==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${n}`,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."}),(k||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k||a?.message||""},onDismiss:()=>{y(null),i()}})}),N&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),N]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:f,onChange:E=>h(E.target.value),disabled:r,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:m,onChange:E=>b(E.target.value),disabled:r,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:g,onChange:E=>p(E.target.value),disabled:r,error:g.length>0&&!L?"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:A,disabled:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:v,disabled:r||!w,children:r?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 ${n}`,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: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:x()})}),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:()=>u("change-password"),children:"Change"})]})]}),s&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})})}class kl{client;constructor(s,n,o,r){this.client=new T.ApiClient({baseUrl:s,timeoutMs:n,retryAttempts:o,getAccessToken:r})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(s){throw T.handleApiError(s,"Failed to list credentials")}}async unlinkCredential(s){try{await this.client.delete(`/credentials/${encodeURIComponent(s)}`)}catch(n){throw T.handleApiError(n,"Failed to unlink credential")}}}function Gs(){const{config:t,authState:s,_internal:n}=T.useCedrosLogin(),[o,r]=d.useState([]),[a,c]=d.useState(!1),[i,l]=d.useState(null),u=d.useMemo(()=>new kl(t.serverUrl,t.requestTimeout,t.retryAttempts,n?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,n]),f=d.useCallback(()=>{l(null)},[]),h=d.useCallback(async()=>{if(s!=="authenticated"){r([]);return}c(!0),l(null);try{const b=await u.listCredentials();r(b)}catch(b){l(b)}finally{c(!1)}},[s,u]);d.useEffect(()=>{s==="authenticated"?h():r([])},[s,h]);const m=d.useCallback(async b=>{c(!0),l(null);try{await u.unlinkCredential(b),await h()}catch(g){throw l(g),g}finally{c(!1)}},[u,h]);return{credentials:o,isLoading:a,error:i,fetchCredentials:h,unlinkCredential:m,clearError:f}}function Nl({onPasswordChange:t,onCancel:s,className:n=""}){const{isLoading:o,error:r,changePassword:a,clearError:c}=Xe(),[i,l]=d.useState(""),[u,f]=d.useState(""),[h,m]=d.useState(""),[b,g]=d.useState(null),[p,k]=d.useState(null),y=Re.validatePassword(u),N=u===h,j=i.length>0&&u.length>0&&h.length>0&&y.isValid&&N,C=d.useCallback(async()=>{if(j){g(null),k(null);try{await a({currentPassword:i,newPassword:u}),l(""),f(""),m(""),k("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>s(),2e3)}catch(w){g(w instanceof Error?w.message:"Failed to change password")}}},[j,i,u,a,t,s]),L=d.useCallback(()=>{g(null),c(),s()},[c,s]);return e.jsx("div",{className:`cedros-profile-settings ${n}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(b||r)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:b||r?.message||""},onDismiss:()=>{g(null),c()}})}),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(Q.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:i,onChange:w=>l(w.target.value),disabled:o,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:u,onChange:w=>f(w.target.value),disabled:o,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:h,onChange:w=>m(w.target.value),disabled:o,error:h.length>0&&!N?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:L,disabled:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:C,disabled:o||!j,children:o?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function jo({onPasswordChange:t,className:s=""}){const{user:n,refreshUser:o}=I.useAuth(),{isLoading:r,error:a,updateProfile:c,clearError:i}=Xe(),{credentials:l}=Gs(),{forgotPassword:u,isLoading:f,isSuccess:h,reset:m}=St(),b=l.some(x=>x.credentialType==="password"),[g,p]=d.useState("view"),[k,y]=d.useState(""),[N,j]=d.useState(null),C=()=>n?.name?n.name.split(" ").map(x=>x[0]).join("").toUpperCase().slice(0,2):n?.email?n.email[0].toUpperCase():"?",L=d.useCallback(()=>{y(n?.name||""),p("edit"),j(null)},[n?.name]),w=d.useCallback(async()=>{const x=k.trim();if(x){j(null);try{await c({name:x}),await o(),p("view")}catch(E){j(E instanceof Error?E.message:"Failed to update name")}}},[k,c,o]),v=d.useCallback(()=>{p("view"),y(""),j(null),i()},[i]),A=d.useCallback(async()=>{if(n?.email){j(null);try{await u(n.email)}catch(x){j(x instanceof Error?x.message:"Failed to send password setup email")}}},[n?.email,u]);return g==="change-password"?e.jsx(Nl,{onPasswordChange:t,onCancel:()=>p("view"),className:s}):e.jsx("div",{className:`cedros-profile-settings ${s}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:n?.picture?e.jsx("img",{src:n.picture,alt:n.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:C()})}),e.jsxs("div",{className:"cedros-profile-info",children:[g==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:k,onChange:x=>y(x.target.value),disabled:r,autoFocus:!0,onKeyDown:x=>{x.key==="Enter"&&w(),x.key==="Escape"&&v()}}),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:w,disabled:r||!k.trim(),children:r?e.jsx(z.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:v,disabled:r,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:n?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:L,title:"Edit name","aria-label":"Edit name",children:e.jsx(Cl,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:n?.email})]})]}),(N||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:N||a?.message||""},onDismiss:()=>{j(null),i()}})}),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:n?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:b?"••••••••":"Not set"})]}),b?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{p("change-password"),j(null)},children:"Change"}):h?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:m,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:A,disabled:f,children:f?e.jsx(z.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function Cl(){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 ko={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 No({onLinkGoogle:t,onLinkApple:s,onAddPasskey:n,onLinkSolana:o,className:r=""}){const{credentials:a,isLoading:c,error:i,unlinkCredential:l,clearError:u,fetchCredentials:f}=Gs(),{registerPasskey:h,isSupported:m}=qs(),[b,g]=d.useState(null),[p,k]=d.useState(!1),y=d.useCallback(async()=>{if(n){n();return}k(!0);try{await h(),await f()}catch{}finally{k(!1)}},[n,h,f]),N=d.useCallback(async x=>{const E=x.label||ko[x.credentialType];if(window.confirm(`Remove "${E}" as a sign-in method? You won't be able to sign in with it anymore.`)){g(x.id);try{await l(x.id)}catch{}finally{g(null)}}},[l]),j=new Set(a.map(x=>x.credentialType)),C=t&&!j.has("oauth_google"),L=s&&!j.has("oauth_apple"),w=(n||m)&&!j.has("webauthn_passkey"),v=o&&!j.has("solana"),A=C||L||w||v;return c&&a.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${r}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${r}`,children:[i&&e.jsx(Z.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:i.message},onDismiss:u}),a.length===0&&!c&&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(x=>e.jsx(Sl,{credential:x,isUnlinking:b===x.id,onUnlink:N},x.id))}),A&&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:[C&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(Co,{})," Google"]}),L&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(So,{})," Apple"]}),w&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:y,disabled:p,children:p?e.jsx(z.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Es,{})," Passkey"]})}),v&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(Eo,{})," Solana"]})]})]})]})}function Sl({credential:t,isUnlinking:s,onUnlink:n}){const o=t.label||ko[t.credentialType],r=El[t.credentialType]||Ll;return e.jsxs("li",{className:"cedros-linked-credential",children:[e.jsx("div",{className:"cedros-linked-credential__icon",children:e.jsx(r,{})}),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 ",on(t.createdAt),t.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",on(t.lastUsedAt)]}),t.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>n(t),disabled:s,title:t.isPrimary?"Cannot remove primary sign-in method":"Remove",children:s?e.jsx(z.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function on(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),r=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),c=Math.floor(o/(1e3*60*60*24));return r<1?"just now":r<60?`${r}m ago`:a<24?`${a}h ago`:c<30?`${c}d ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const El={password:Pl,oauth_google:Co,oauth_apple:So,solana:Eo,webauthn_passkey:Es,webauthn_security_key:Es,totp:Bl,sso_oidc:Ml};function Ll(){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 Pl(){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 Co(){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 So(){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 Eo(){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 Es(){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 Bl(){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 Ml(){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 Rl{client;constructor(s,n,o,r){this.client=new T.ApiClient({baseUrl:s,timeoutMs:n,retryAttempts:o,getAccessToken:r})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(s){throw T.handleApiError(s,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(s){throw T.handleApiError(s,"Failed to revoke sessions")}}}function Lo(){const{config:t,authState:s,_internal:n}=T.useCedrosLogin(),[o,r]=d.useState([]),[a,c]=d.useState(!1),[i,l]=d.useState(null),u=d.useMemo(()=>new Rl(t.serverUrl,t.requestTimeout,t.retryAttempts,n?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,n]),f=d.useCallback(async()=>{if(s!=="authenticated"){r([]);return}c(!0),l(null);try{const b=await u.listSessions();r(b)}catch(b){l(b)}finally{c(!1)}},[s,u]);d.useEffect(()=>{s==="authenticated"?f():r([])},[s,f]);const h=d.useCallback(async()=>{c(!0),l(null);try{const b=await u.revokeAllSessions();return await f(),b}catch(b){throw l(b),b}finally{c(!1)}},[u,f]),m=d.useMemo(()=>o.filter(b=>!b.isCurrent).length,[o]);return{sessions:o,isLoading:a,error:i,fetchSessions:f,revokeAllSessions:h,otherSessionCount:m}}const Tl={profile:"Profile",security:"Security",linked:"Linked Accounts"},Il=["profile","security","linked"];function Dl({defaultTab:t="profile",onClose:s,onPasswordChange:n,onTotpChange:o,onLinkGoogle:r,onLinkApple:a,onAddPasskey:c,onLinkSolana:i,className:l=""}){const[u,f]=d.useState(t),{sessions:h,isLoading:m,error:b,revokeAllSessions:g}=Lo();return e.jsxs("div",{className:`cedros-account-settings ${l}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:Il.map(p=>e.jsx("button",{type:"button",role:"tab","aria-selected":u===p,className:`cedros-account-tab ${u===p?"cedros-account-tab-active":""}`,onClick:()=>f(p),children:Tl[p]},p))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[u==="profile"&&e.jsx(jo,{onPasswordChange:n}),u==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(vo,{onStatusChange:o}),e.jsx(to,{sessions:h,isLoading:m,error:b??void 0,onRevokeAll:async()=>{await g()}})]}),u==="linked"&&e.jsx(No,{onLinkGoogle:r,onLinkApple:a,onAddPasskey:c,onLinkSolana:i})]}),s&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})}function _l({onComplete:t,className:s}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${s??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx($s,{onSuccess:t})})]})}function Ul({onComplete:t,onSkip:s,className:n}){const{user:o}=I.useAuth(),{isLoading:r,error:a,updateProfile:c,clearError:i}=Xe(),[l,u]=d.useState(o?.name??""),f=d.useCallback(async m=>{m.preventDefault(),i();const b=l.trim();if(!b){t?.();return}try{await c({name:b}),t?.()}catch{}},[l,c,i,t]),h=l.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${n??""}`,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:f,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:m=>u(m.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:r||!h,children:r?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:s,disabled:r,children:"Skip"})]})]})]})}function Po(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(null),c=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),i=d.useCallback(async f=>await c.get(`/username/available?username=${encodeURIComponent(f)}`,{credentials:"include"}),[c]),l=d.useCallback(async()=>{try{return(await c.get("/username/available?username=",{credentials:"include"})).suggestion??null}catch{return null}},[c]),u=d.useCallback(async f=>{o(!0),a(null);try{await c.patch("/me",{username:f})}catch(h){const m=h instanceof Error?h:new Error(String(h));throw a(m),m}finally{o(!1)}},[c]);return{checkAvailability:i,getSuggestion:l,setUsername:u,isLoading:n,error:r}}function Fl({onComplete:t,onSkip:s,className:n}){const{checkAvailability:o,getSuggestion:r,setUsername:a,isLoading:c,error:i}=Po(),[l,u]=d.useState(""),[f,h]=d.useState("idle"),[m,b]=d.useState(""),g=d.useRef(null),p=d.useRef(!0);d.useEffect(()=>(p.current=!0,r().then(j=>{p.current&&j&&(u(j),h("available"),b("Available"))}),()=>{p.current=!1}),[r]);const k=d.useCallback(j=>{const C=j.toLowerCase().replace(/[^a-z0-9_]/g,"");if(u(C),h("idle"),b(""),g.current&&clearTimeout(g.current),C.length<3){C.length>0&&(h("error"),b("At least 3 characters"));return}h("checking"),g.current=setTimeout(async()=>{try{const L=await o(C);if(!p.current)return;L.error?(h("error"),b(L.error)):L.available?(h("available"),b("Available")):(h("taken"),b("Already taken"),L.suggestion)}catch{if(!p.current)return;h("error"),b("Could not check availability")}},400)},[o]),y=d.useCallback(async j=>{if(j.preventDefault(),!(f!=="available"||!l.trim()))try{await a(l.trim()),t?.()}catch{}},[l,f,a,t]),N=f==="available"&&!c;return e.jsxs("div",{className:`cedros-choose-username ${n??""}`,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:y,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:j=>k(j.target.value),placeholder:"swift_falcon_42",className:"cedros-choose-username__input",maxLength:30,autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),m&&e.jsx("span",{className:`cedros-choose-username__status cedros-choose-username__status--${f}`,role:f==="error"||f==="taken"?"alert":void 0,children:f==="checking"?"Checking...":m})]}),i&&e.jsx("div",{className:"cedros-choose-username__error",role:"alert",children:i.message}),e.jsxs("div",{className:"cedros-choose-username__actions",children:[e.jsx("button",{type:"submit",className:"cedros-choose-username__button cedros-choose-username__button--primary",disabled:!N,children:c?"Saving...":"Continue"}),e.jsx("button",{type:"button",className:"cedros-choose-username__button cedros-choose-username__button--secondary",onClick:s,disabled:c,children:"Skip"})]})]})]})}function Bo(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(!1),[o,r]=d.useState(null),a=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(()=>{r(null)},[]),i=d.useCallback(async g=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(g)||g<=0){const p=new Error(`Invalid deposit amount: ${g}. Must be a positive integer (lamports).`);throw r(p.message),p}n(!0),r(null);try{return await a.post("/deposit",{amount_lamports:g})}catch(p){const k=T.handleApiError(p,"Failed to execute deposit");throw r(k.message),k}finally{n(!1)}},[a]),l=d.useCallback(async g=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.get(`/deposit/status/${encodeURIComponent(g)}`)}catch(p){const k=T.handleApiError(p,"Failed to get deposit status");throw r(k.message),k}finally{n(!1)}},[a]),u=d.useCallback(async()=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.get("/deposit/config")}catch(g){const p=T.handleApiError(g,"Failed to get deposit config");throw r(p.message),p}finally{n(!1)}},[a]),f=d.useCallback(async g=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{const p=new URLSearchParams;g?.limit!==void 0&&p.set("limit",String(g.limit)),g?.offset!==void 0&&p.set("offset",String(g.offset));const k=p.toString(),y=k?`/deposits?${k}`:"/deposits";return await a.get(y)}catch(p){const k=T.handleApiError(p,"Failed to list deposits");throw r(k.message),k}finally{n(!1)}},[a]),h=d.useCallback(async g=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{const p=new URLSearchParams({input_mint:g.inputMint,amount:String(g.amount),taker:g.taker});return await a.get(`/deposit/quote?${p}`)}catch(p){const k=T.handleApiError(p,"Failed to get deposit quote");throw r(k.message),k}finally{n(!1)}},[a]),m=d.useCallback(async g=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.post("/deposit/public",g)}catch(p){const k=T.handleApiError(p,"Failed to execute public deposit");throw r(k.message),k}finally{n(!1)}},[a]),b=d.useCallback(async g=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.post("/deposit/micro",g)}catch(p){const k=T.handleApiError(p,"Failed to execute micro deposit");throw r(k.message),k}finally{n(!1)}},[a]);return{deposit:i,getQuote:h,publicDeposit:m,microDeposit:b,getStatus:l,getConfig:u,listDeposits:f,isLoading:s,error:o,clearError:c}}function Qs({tokens:t,selectedToken:s,onSelect:n,openSignal:o,placeholder:r="Select token",disabled:a=!1,className:c="",searchable:i=!0}){const[l,u]=d.useState(!1),[f,h]=d.useState(""),m=d.useRef(null),b=d.useRef(null),g=d.useMemo(()=>{if(!f.trim())return t;const N=f.toLowerCase();return t.filter(j=>j.symbol.toLowerCase().includes(N)||j.name.toLowerCase().includes(N)||j.mint.toLowerCase().includes(N))},[t,f]);d.useEffect(()=>{const N=j=>{m.current&&!m.current.contains(j.target)&&(u(!1),h(""))};if(l)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[l]),d.useEffect(()=>{l&&i&&b.current&&b.current.focus()},[l,i]),d.useEffect(()=>{o===void 0||a||(u(!0),h(""))},[o,a]);const p=d.useCallback(()=>{a||(u(N=>!N),l&&h(""))},[a,l]),k=d.useCallback(N=>{n(N),u(!1),h("")},[n]),y=d.useCallback(N=>{N.key==="Escape"?(u(!1),h("")):N.key==="Enter"&&g.length===1&&k(g[0])},[g,k]);return e.jsxs("div",{ref:m,className:`cedros-token-selector ${l?"cedros-token-selector-open":""} ${a?"cedros-token-selector-disabled":""} ${c}`,onKeyDown:y,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:p,disabled:a,"aria-haspopup":"listbox","aria-expanded":l,children:[s?e.jsxs("span",{className:"cedros-token-selector-selected",children:[s.logoUrl&&e.jsx("img",{src:s.logoUrl,alt:s.symbol,className:"cedros-token-icon",onError:N=>{N.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:s.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:r}),e.jsx("span",{className:"cedros-token-selector-arrow",children:l?"▲":"▼"})]}),l&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[i&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:b,type:"text",value:f,onChange:N=>h(N.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:g.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:g.map(N=>e.jsxs("button",{type:"button",className:`cedros-token-option ${s?.mint===N.mint?"cedros-token-option-selected":""}`,onClick:()=>k(N),role:"option","aria-selected":s?.mint===N.mint,children:[N.logoUrl&&e.jsx("img",{src:N.logoUrl,alt:N.symbol,className:"cedros-token-icon",onError:j=>{j.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:N.symbol}),e.jsx("span",{className:"cedros-token-name",children:N.name})]}),s?.mint===N.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},N.mint))})})]})]})}function Lt(t,s){return s.privateDepositsEnabled&&t>=s.privateMinUsd?"private":t>=s.publicMinUsd?"public":"sol_micro"}const Ks="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=",Ol=1e4,kt=1e3,Mo=3;function Wl(t){return Number.isFinite(t)?`$${Math.round(t)}`:"$0"}function ql(t,s){switch(t){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${Wl(s.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function Ys(t,s,n){return Math.min(Math.max(t,s),n)}function zl(t,s){if(s<=0)return 0;const n=Ys(t/s,0,1);return Math.round(Math.pow(n,1/Mo)*kt)}function Hl(t,s){const n=Ys(t/kt,0,1);return s*Math.pow(n,Mo)}function Ro(t){return t<10?.01:t<100?1:t<500?5:t<1e3?10:t<5e3?25:50}function Vl(t){return t<1?2:0}function an(t){const s=Ro(t),n=Math.round(t/s)*s,o=Vl(s);return Number(n.toFixed(o))}function Zs({config:t,valueUsd:s,onChange:n,maxUsd:o=Ol,disabled:r=!1,className:a=""}){const c=Ys(Number.isFinite(s)?s:0,0,o),i=d.useMemo(()=>Lt(c,t),[c,t]),l=ql(i,t),u=zl(c,o),f=u/kt*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:c||"",onChange:h=>n(an(parseFloat(h.target.value)||0)),placeholder:"Enter amount",disabled:r,min:0,step:Ro(c),className:"cedros-deposit-flow-input cedros-tiered-slider-input-field","aria-label":"Deposit amount"})]}),e.jsxs("div",{className:"cedros-tiered-slider-tier",children:[e.jsxs("span",{className:`cedros-tiered-slider-badge cedros-tiered-slider-badge-${i}`,children:[i==="sol_micro"&&e.jsx("img",{src:Ks,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:kt,step:1,value:u,onChange:h=>n(an(Hl(parseFloat(h.target.value),o))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${f}%, var(--cedros-border) ${f}%, var(--cedros-border) 100%)`},disabled:r,"aria-label":"Deposit amount slider"}),l.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:l.note})]})}function $l(t){return t.companyFeePercent>0||t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap"||t.feePolicy==="user_pays_privacy"}function Gl(t,s,n){const{feePolicy:o,privacyFeePercent:r,swapFeePercent:a,companyFeePercent:c}=t;let i=c;return n||(o==="user_pays_all"?(i+=a,s&&(i+=r)):o==="user_pays_privacy"&&s?i+=r:o==="user_pays_swap"&&(i+=a)),i}const pt=1e9,qe={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Ks},ze={mint:"other",symbol:"OTHER",name:"Other",decimals:6},To=1e4;function Ql(t,s){const n=s<t.publicMinUsd,o=s>=t.privateMinUsd,r=[],a=!n&&o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(t.privacyFeeFixedLamports>0||t.privacyFeePercent>0),c=!n&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(t.swapFeeFixedLamports>0||t.swapFeePercent>0),i=t.companyFeeFixedLamports>0||t.companyFeePercent>0;if(a){const l=t.privacyFeeFixedLamports/pt,u=t.privacyFeePercent,f=l*t.solPriceUsd,h=s*(u/100);r.push({label:"Privacy",solAmount:l,percent:u,usdAmount:f+h})}if(c){const l=t.swapFeeFixedLamports/pt,u=t.swapFeePercent,f=l*t.solPriceUsd,h=s*(u/100);r.push({label:"Swap",solAmount:l,percent:u,usdAmount:f+h})}if(i){const l=t.companyFeeFixedLamports/pt,u=t.companyFeePercent,f=l*t.solPriceUsd,h=s*(u/100);r.push({label:"Service",solAmount:l,percent:u,usdAmount:f+h})}return r}function Io(t,s,n){const o=Ql(t,s),r=n<.01?.01:n;if(o.length===0)return`Total: $${r.toFixed(2)}`;const a=o.reduce((g,p)=>g+p.solAmount,0),c=o.reduce((g,p)=>g+p.percent,0),i={fee:7,sol:8,rate:7,usd:8},l=g=>{const p=g.label.padEnd(i.fee),k=g.solAmount.toFixed(4).padStart(6).padEnd(i.sol),y=(g.percent.toFixed(2)+"%").padStart(5).padEnd(i.rate),N=("$"+Math.max(g.usdAmount,.01).toFixed(2)).padEnd(i.usd);return`${p} │ ${k} │ ${y} │ ${N}`},u=`${"Fee".padEnd(i.fee)} │ ${"SOL".padEnd(i.sol)} │ ${"+ Rate".padEnd(i.rate)} │ ${"= Total".padEnd(i.usd)}`,f=`${"─".repeat(i.fee)}─┼─${"─".repeat(i.sol)}─┼─${"─".repeat(i.rate)}─┼─${"─".repeat(i.usd)}`,h=("$"+r.toFixed(2)).padEnd(i.usd),m=`${"TOTAL".padEnd(i.fee)} │ ${a.toFixed(4).padStart(6).padEnd(i.sol)} │ ${(c.toFixed(2)+"%").padStart(5).padEnd(i.rate)} │ ${h}`;return[u,f,...o.map(l),f,m].join(`
2059
- `)}function Kl(t){const s=[],n=t.privacyFeeFixedLamports>0||t.privacyFeePercent>0,o=t.swapFeeFixedLamports>0||t.swapFeePercent>0,r=t.companyFeeFixedLamports>0||t.companyFeePercent>0;return n&&s.push("Privacy Cash fee"),o&&s.push("swap fee"),r&&s.push("company service fee"),s.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function Pt(t,s){if(s<=0)return 0;const n=s<t.publicMinUsd,o=s>=t.privateMinUsd,r=Gl(t,o,n);let a=t.companyFeeFixedLamports;n||(o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(a+=t.privacyFeeFixedLamports),(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(a+=t.swapFeeFixedLamports));const c=a/pt*t.solPriceUsd,i=s*(r/100);return c+i}function Do(t,s,n){return t==="sol"?"SOL":t==="single-token"?s.symbol:n.some(r=>r.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function cn(t){return t.map(s=>s.trim()).filter(Boolean)}const _o=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function Uo(t,s,n){if(_o.has(t.symbol))return 1;const o=s.tokenPrices?.[t.symbol];if(o&&o>0)return o;if(t.symbol==="SOL")return s.solPriceUsd||null;const r=n?.[t.symbol];return r&&r>0?r:null}function Fo(t,s){const n=_o.has(s)?2:4;return t.toFixed(n)}function Yl({config:t,currencyMode:s,depositMethod:n,tokens:o=[],defaultToken:r,minAmount:a,maxAmount:c=1e4,onSuccess:i,onError:l,onCancel:u,onUnlockRequired:f,onAuthorize:h,className:m="",showStepIndicator:b=!0,pollInterval:g=5e3,demoMode:p=!1,demoAutoConfirmMs:k,tokenPriceUsd:y,showExplainer:N=!1,siteName:j,explainerConfig:C}){const{deposit:L,getStatus:w,error:v,clearError:A}=Bo(),x=I.useWallet(),E=cn(t.quickActionTokens),P=cn(t.customTokenSymbols),S=d.useMemo(()=>{const O=t.customTokens??[];if(O.length===0)return o;const G=new Set(o.map(J=>J.symbol)),K=[...o];for(const J of O)G.has(J.symbol)||(K.push({mint:J.mint,symbol:J.symbol,name:J.symbol,decimals:J.decimals,logoUrl:J.logoUrl}),G.add(J.symbol));return K},[o,t.customTokens]),B=d.useMemo(()=>{if(P.length===0)return S;const O=S.filter(G=>P.includes(G.symbol));return O.length>0?O:S},[S,P]),M=t.privateDepositsEnabled,R=n?n==="sign"&&!M?"receive":n:M&&x.hasExternalWallet?"sign":"receive",U=E[0]?S.find(O=>O.symbol===E[0]):void 0,F=s==="sol"?qe:s==="single-token"?U??S.find(O=>O.symbol==="USDC")??S[0]??qe:r??U??S.find(O=>O.symbol==="USDC")??S.find(O=>O.symbol!=="SOL")??S[0]??qe,W=d.useCallback(()=>N?"explainer":"unlock",[N]),[q,D]=d.useState(W),[_,$]=d.useState(F),[X,oe]=d.useState(""),[be,pe]=d.useState(null),[V,H]=d.useState(null),[Y,he]=d.useState(null),[ve,tr]=d.useState(null),[Bt,Ve]=d.useState(!1),[zo,Mt]=d.useState(!1),[Je,sr]=d.useState(null);d.useEffect(()=>{D(W()),$(F),oe(""),pe(null),H(null),he(null),tr(null),Ve(!1),Mt(!1),sr(null),A()},[s,R,F,A,W]);const Ho=a??t.privateMinSol,Vo=c,et=parseFloat(X),rr=x.status==="enrolled_locked"||x.status==="enrolled_unlocked"||x.status==="unlocked",Rt=rr&&x.isUnlocked,Tt=rr&&!x.isUnlocked,nr=d.useCallback(()=>{let K=R==="sign"?[{key:"unlock",label:"Authorize"},{key:"confirm",label:"Send"},{key:"signing",label:"Signing"},{key:"success",label:"Complete"}]:[{key:"unlock",label:"Authorize"},{key:"show-address",label:"Send"},{key:"waiting",label:"Confirming"},{key:"success",label:"Complete"}];return N&&(K=[{key:"explainer",label:"Info"},...K]),K},[R,N])(),$o=nr.findIndex(O=>O.key===q),or=d.useCallback(O=>{$(O)},[]),Go=d.useCallback(async O=>{if(!h){D(R==="sign"?"confirm":"show-address");return}Mt(!0),H(null);try{const K=await h(O,R==="sign"?et:null,_);he(K.sessionId),tr(K.depositAddress),D(R==="sign"?"confirm":"show-address")}catch(G){const K=G instanceof Error?G:new Error("Authorization failed");H(K.message)}finally{Mt(!1)}},[h,R,et,_]),Qo=d.useCallback(async(O,G)=>{A(),H(null),D("signing");const K=O??et,J=G??_;if(!p){if(Tt&&f){f(),D("confirm");return}if(!Rt){H("Wallet not ready"),D("error");return}}try{const de=Math.floor(K*Math.pow(10,J.decimals));if(p){await new Promise(rt=>setTimeout(rt,1500));const st={token:s==="sol"?null:J,amount:K,amountSmallestUnit:de,txSignature:`demo-tx-${Date.now()}`,sessionId:Y||`demo-session-${Date.now()}`,response:{sessionId:Y||`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"};pe(st),D("success"),i?.(st);return}const ie=await L(de),tt={token:s==="sol"?null:J,amount:K,amountSmallestUnit:de,txSignature:ie.txSignature,sessionId:ie.sessionId,response:ie,method:"sign"};pe(tt),D("success"),i?.(tt)}catch(de){const ie=de instanceof Error?de:new Error("Deposit failed");H(ie.message),D("error"),l?.(ie)}},[L,et,_,s,p,Y,Rt,Tt,f,i,l,A]),Ko=d.useCallback(()=>{D("waiting")},[]),It=d.useCallback(async()=>{const O=ve||x.solanaPubkey;if(O)try{await navigator.clipboard.writeText(O),Ve(!0),setTimeout(()=>Ve(!1),2e3)}catch{const G=document.createElement("textarea");G.value=O,document.body.appendChild(G),G.select(),document.execCommand("copy"),document.body.removeChild(G),Ve(!0),setTimeout(()=>Ve(!1),2e3)}},[ve,x.solanaPubkey]);d.useEffect(()=>{if(!(q==="confirm"||q==="show-address"||q==="waiting")||!Y||p)return;let G=!1,K=0;const J=360,de=async()=>{if(!(G||K>=J)){K++;try{const ie=await w(Y);if(ie.status==="completed"||ie.status==="detected"){const tt=ie.amountLamports?ie.amountLamports/Math.pow(10,_.decimals):0,st=ie.amountLamports||0,rt={token:s==="sol"?null:_,amount:tt,amountSmallestUnit:st,txSignature:ie.txSignature||"",sessionId:Y,response:ie,method:"receive",depositAddress:x.solanaPubkey??void 0};pe(rt),D("success"),i?.(rt);return}}catch{}G||setTimeout(de,g)}};return de(),()=>{G=!0}},[q,Y,p,w,_,s,x.solanaPubkey,i,g]),d.useEffect(()=>{if(!p||!k||q!=="waiting"||R!=="receive"||!ve)return;const O=window.setTimeout(()=>{const G=Je??t.privateMinUsd,K=_.symbol==="SOL"&&t.solPriceUsd>0?G/t.solPriceUsd:G,J=Math.floor(K*Math.pow(10,_.decimals)),de={token:s==="sol"?null:_,amount:K,amountSmallestUnit:J,txSignature:`demo-tx-${Date.now()}`,sessionId:Y||`demo-session-${Date.now()}`,response:{sessionId:Y||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:J,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:ve??void 0};pe(de),D("success"),i?.(de)},k);return()=>window.clearTimeout(O)},[p,k,q,R,ve,Je,t,_,s,Y,i]);const Yo=d.useCallback(()=>{D(W()),oe(""),pe(null),H(null),A()},[W,A]);return t.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${m}`,children:[b&&q!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:nr.map((O,G)=>{const K=$o>=G,J=O.key===q;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${K?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${K?"active":""} ${J?"current":""}`,children:G+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${K?"active":""}`,children:O.label})]},O.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[q==="explainer"&&e.jsx(Zl,{siteName:j,config:C,depositConfig:t,currencyMode:s,token:_,tokens:B,onContinue:()=>D("unlock"),onCancel:u}),q==="unlock"&&e.jsx(Xl,{token:_,tokens:B,currencyMode:s,depositMethod:R,isAuthorizing:zo,error:V,onAuthorize:Go,onBack:N?()=>D("explainer"):void 0,onCancel:u}),q==="confirm"&&R==="sign"&&e.jsx(Jl,{token:_,tokens:S,quickActionSymbols:E,customTokenSymbols:P,currencyMode:s,minAmount:Ho,maxAmount:Vo,depositAddress:ve||x.solanaPubkey,walletReady:Rt||p,needsUnlock:Tt&&!p,copied:Bt,isListening:!!Y&&!p,config:t,onCopy:It,onTokenSelect:or,onUnlockRequired:f,onConfirm:(O,G)=>Qo(O,G),onBack:()=>D("unlock"),onCancel:u}),q==="signing"&&e.jsx(ed,{depositAddress:x.solanaPubkey}),q==="show-address"&&e.jsx(td,{token:_,tokens:S,quickActionSymbols:E,customTokenSymbols:P,tokenPriceUsd:y,currencyMode:s,depositAddress:ve||x.solanaPubkey,copied:Bt,isListening:!!Y&&!p,config:t,onCopy:It,onTokenSelect:or,onAmountChange:sr,onSent:Ko,onBack:()=>D("unlock"),onCancel:u}),q==="waiting"&&e.jsx(sd,{token:_,depositAddress:ve||x.solanaPubkey,copied:Bt,feeLine:Je?`Fees: $${Math.max(Pt(t,Je),.01).toFixed(2)} total`:"Fees: calculated after deposit",onCopy:It}),q==="success"&&be&&e.jsx(rd,{result:be,config:t,onNewDeposit:Yo}),q==="error"&&e.jsx(nd,{error:V||v||"An error occurred",onRetry:()=>D("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${m}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function Zl({siteName:t,config:s,depositConfig:n,currencyMode:o,token:r,tokens:a,onContinue:c,onCancel:i}){const l=s?.title??"How Deposits Work",u=s?.exchangeName??"Coinbase",f=Ls.sanitizeExternalUrl(s?.exchangeUrl)??"https://www.coinbase.com",h=s?.showExchangeSuggestion!==!1,m=Do(o,r,a),b=t?`${t} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",g=s?.body??b,p=$l(n),k=Kl(n);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:g}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:p?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:k})]})]})]}),h&&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 ",m," using your credit card at"," ",e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:u}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[i&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:i,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:c,children:"Continue"})]})]})}function Xl({token:t,tokens:s,currencyMode:n,depositMethod:o,isAuthorizing:r,error:a,onAuthorize:c,onBack:i}){const[l,u]=d.useState(""),f=Do(n,t,s),h=m=>{m.preventDefault(),l.trim()&&c(l)};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"?n==="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 ${f} deposit. This allows us to process your withdrawal when the privacy period ends.`:n==="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 ${f} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:h,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:m=>u(m.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:r,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:i,disabled:r,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!l.trim()||r,children:r?"Authorizing...":"Continue"})]})]})]})}function Jl({token:t,tokens:s,quickActionSymbols:n,customTokenSymbols:o,currencyMode:r,minAmount:a,maxAmount:c,depositAddress:i,walletReady:l,needsUnlock:u,copied:f,isListening:h,config:m,onCopy:b,onTokenSelect:g,onUnlockRequired:p,onConfirm:k,onBack:y}){const[N,j]=d.useState(m.privateMinUsd),[C,L]=d.useState(!1),[w,v]=d.useState(!1),[A,x]=d.useState(0),[E,P]=d.useState(null),B=Lt(N,m)==="sol_micro",M=t.symbol===ze.symbol,R=d.useMemo(()=>{const V=o.length===0?s:s.filter(he=>o.includes(he.symbol)),H=V.length>0?V:s;return H.some(he=>he.symbol===ze.symbol)?H:[...H,ze]},[s,o]),U=Pt(m,N),F=U<.01?.01:U,W=M?"Fees: calculated after deposit":`Fees: $${F.toFixed(2)} total`,q=M?"":Io(m,N,U),D=Uo(B?qe:t,m),_=D?N/D:t.symbol==="SOL"&&m.solPriceUsd>0?N/m.solPriceUsd:N,$=_?Fo(_,B?"SOL":t.symbol):null,oe=N-U<=0&&N>0,be=!M&&N>0&&!oe&&_>=a&&_<=c;d.useEffect(()=>{if(r==="multi-token")if(B&&t.symbol!=="SOL"){P(t);const V=s.find(H=>H.symbol==="SOL");V&&g(V)}else!B&&E&&t.symbol==="SOL"&&(g(E),P(null))},[B,t.symbol,r,s,g,E,t]);const pe=()=>{be&&k(_,t)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),r==="multi-token"&&!B&&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:[n.map(V=>{const H=s.find(he=>he.symbol===V),Y=t.symbol===V;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${Y?"is-active":""}`,onClick:()=>{H&&(L(!1),g(H))},disabled:!H,children:[H?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:H.logoUrl,alt:`${V} logo`}),V]},V)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${C?"is-active":""}`,onClick:()=>{L(!0),x(V=>V+1)},children:"Custom"})]}),C&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Qs,{tokens:R,selectedToken:t,onSelect:g,openSignal:A})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(Zs,{config:m,valueUsd:N,onChange:j,maxUsd:To})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:M?"Sign to send tokens to this address":`Sign to send ${$??"--"} ${B?"SOL":t.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:i||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:b,title:"Copy address",disabled:!i,children:f?"✓":"⧉"}),i&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${i}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),f&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),oe&&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 ${w?"is-open":""}`,"data-tooltip":q,"aria-label":`Fee breakdown: ${q.replaceAll(`
2060
- `,", ")}`,"aria-expanded":w,onClick:V=>{V.stopPropagation(),v(H=>!H)},onBlur:()=>v(!1),onKeyDown:V=>{V.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 network confirmation."})]})]}),h&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for incoming transfers. We will confirm automatically."}),u&&e.jsxs("div",{className:"cedros-deposit-flow-warning",children:[e.jsx("p",{children:"Your wallet is locked. Unlock it to continue."}),p&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:p,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:y,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:pe,disabled:!be||!l||!i,children:"Deposit"})]})]})}function ed({depositAddress:t}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Signing Transfer"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Approve the transfer in your wallet extension..."}),t&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[t.slice(0,6),"...",t.slice(-4)]})]})]})}function td({token:t,tokens:s,quickActionSymbols:n,customTokenSymbols:o,tokenPriceUsd:r,currencyMode:a,depositAddress:c,copied:i,isListening:l,config:u,onCopy:f,onTokenSelect:h,onAmountChange:m,onSent:b,onBack:g}){const[p,k]=d.useState(u.privateMinUsd),[y,N]=d.useState(!1),[j,C]=d.useState(!1),[L,w]=d.useState(0),[v,A]=d.useState(null),E=Lt(p,u)==="sol_micro",P=t.symbol===ze.symbol,S=d.useMemo(()=>{const _=o.length===0?s:s.filter(oe=>o.includes(oe.symbol)),$=_.length>0?_:s;return $.some(oe=>oe.symbol===ze.symbol)?$:[...$,ze]},[s,o]),B=Pt(u,p),M=B<.01?.01:B,R=P?"Fees: calculated after deposit":`Fees: $${M.toFixed(2)} total`,U=P?"":Io(u,p,B),F=P||p>0,W=Uo(E?qe:t,u,r),q=W?p/W:null,D=q?Fo(q,t.symbol):null;return d.useEffect(()=>{if(a==="multi-token")if(E&&t.symbol!=="SOL"){A(t);const _=s.find($=>$.symbol==="SOL");_&&h(_)}else!E&&v&&t.symbol==="SOL"&&(h(v),A(null))},[E,t.symbol,a,s,h,v,t]),d.useEffect(()=>{m(p)},[p,m]),c?e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Send Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Send funds to your deposit address. We'll confirm automatically."}),a==="multi-token"&&!E&&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:[n.map(_=>{const $=s.find(oe=>oe.symbol===_),X=t.symbol===_;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${X?"is-active":""}`,onClick:()=>{$&&(N(!1),h($))},disabled:!$,children:[$?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:$.logoUrl,alt:`${_} logo`}),_]},_)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${y?"is-active":""}`,onClick:()=>{N(!0),w(_=>_+1)},children:"Custom"})]}),y&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Qs,{tokens:S,selectedToken:t,onSelect:h,openSignal:L})})]}),!P&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(Zs,{config:u,valueUsd:p,onChange:k,maxUsd:To})]}),P&&e.jsx("div",{className:"cedros-deposit-flow-note",children:"Send any token you want. We'll detect the deposit, swap it, and credit your balance automatically."}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:P?"Send any token to this address":`Send ${D??"--"} ${E?"SOL":t.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:c}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:f,title:"Copy address",children:i?"✓":"📋"})]}),i&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[R,!P&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${j?"is-open":""}`,"data-tooltip":U,"aria-label":`Fee breakdown: ${U.replaceAll(`
2061
- `,", ")}`,"aria-expanded":j,onClick:_=>{_.stopPropagation(),C($=>!$)},onBlur:()=>C(!1),onKeyDown:_=>{_.key==="Escape"&&C(!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:g,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:b,disabled:!F,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function sd({token:t,depositAddress:s,copied:n,feeLine:o,onCopy:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:t.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),s&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[s.slice(0,6),"...",s.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:r,title:"Copy address",children:n?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${s}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:o})]})]})]})]})}function rd({result:t,config:s,onNewDeposit:n}){const o=t.token??qe,r=o.symbol==="SOL"&&s.solPriceUsd>0?t.amount*s.solPriceUsd:t.amount,a=Pt(s,r),c=Math.max(r-a,0),i=a<.01?.01:a;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",t.amount.toLocaleString()," ",o.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[t.txSignature.slice(0,8),"...",t.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",r.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",i.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Credits Added"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-credit",children:["+$",c.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:n,children:"Make Another Deposit"})})]})}function nd({error:t,onRetry:s,onCancel:n}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:t}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[n&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:n,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:s,children:"Try Again"})]})]})}const od="data:image/webp;base64,UklGRmIEAABXRUJQVlA4WAoAAAAIAAAAOwAAOwAAVlA4IIIDAADwDwCdASo8ADwAPm0qkUWkIqGWDVeYQAbEtgBOmZMBu+H816ov3b8R8R2g2FXtxdyh5s3+A60v0APLi9ktgGB/LZjWNAXqgpE6jfW0NF+P4xEhH2L7M+26iGwrTjjcQegyCZqxs+ifvZANjWd279diqZNKUrgOTVtjJGtW4IVtRhMECd5aWVgAAP7nDv3UY/8f1l//xTP/FM/8NU8c9g//sC3+bX/1HZXsNsM57VKG2LVf1a0KdncWO8uPo/Oh79m9ZqjJZwXfPXuvwkK+WDOl6+N8C2Ux6no/V/zkoucKK/JZek7MR5sS8TknXB+6BuVDXou9Rx4aUea2q2IzvLvFIujjKsVYLMab7j9zo48fhgm9YOtjmWuS0WZ4c+6ta0mr3xF4fcdAIFf6oXRSlqovOX0HUiMV//hXwSX1cfP5cLj8c7OTyT/4ce4olJARV95GoY8oF+2uU0blGul3ItlG7c2Hl2/uC6s2WZc7Zukwojx6ed8t97bZ68N1uzCLzPlG7BuYS17F19e0wXnc6vEl3q7ft0K7OEl7r8mY6Kh+Nt/5V/Lp68mFBjLem1JjvC371+lKwez4KCdXwNo2Z04FqyzGpFutY6YQ/r5Tfu7Oi+oNfN0R/W+D4aj1nqHhlqYJzpx2NK4mj0gJIXmX8EArelSQI8mV4Ux9MRPwC2PuZhLTjQZv+Vl4p0D8bSB+Z0rek3hS6G1r80fW3cn767Pz/bXanjVmm34wt1nQPqdJObrZ7vv2NWcEuQKj9d+V6DzeDrq0CtGNcanEB5MY9agi1E6BprEScTdfPXjBeMnPbpD+QO6P7IW4UZ9etCCHtX++S/fl5Iz5RzUr10ojRMw//35C0yTjSEhbe884dPwor64n//KByjUFEGsCPAAXPJp1+O+SiKfUaODq6ncjKayTHXjoXgM7XP1z4sBhIKJZJRiM7vGC/+v/Sk8/jbgZLZDAVz1vLou93y7Yd8hxcWM/BesxgWgeKvl8fjE/Ud8tQKp4425hWh66lzzwxa4J3ctA4/E50wX/eoBOgq0B7+7S6FK4wvPHSNgfh+vwSWIJsJLt/3yjBeb41RRyMDMZqFQTZPEdFpXp48ExEyDayZ6objbjTHoS5WQDnDQpRyqMNKfvd41nhEPdb/hxpzXeTIjWmfHHCT+CQYWXDqLehCh1cRyeYOBwsSlSw5PiquAbsgAARVhJRroAAABFeGlmAABJSSoACAAAAAYAEgEDAAEAAAABAAAAGgEFAAEAAABWAAAAGwEFAAEAAABeAAAAKAEDAAEAAAACAAAAEwIDAAEAAAABAAAAaYcEAAEAAABmAAAAAAAAAEgAAAABAAAASAAAAAEAAAAGAACQBwAEAAAAMDIxMAGRBwAEAAAAAQIDAACgBwAEAAAAMDEwMAGgAwABAAAA//8AAAKgBAABAAAAPAAAAAOgBAABAAAAPAAAAAAAAAA=",ad="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==",id="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",cd="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==",ld="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==",dd="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==",ud="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",hd="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",fd="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",Oo=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Ks},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:dd},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:fd},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:id},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:hd},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:ld},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:ud},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:ad},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:od},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:cd}];function Xs(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(!1),[o,r]=d.useState(null),a=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(()=>{r(null)},[]),i=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.get("/credits/balance/sol")}catch(f){const h=T.handleApiError(f,"Failed to fetch credit balance");throw r(h.message),h}finally{n(!1)}},[a]),l=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");n(!0),r(null);try{return(await a.get("/credits/balance")).balances}catch(f){const h=T.handleApiError(f,"Failed to fetch credit balances");throw r(h.message),h}finally{n(!1)}},[a]),u=d.useCallback(async f=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");n(!0),r(null);try{const h=new URLSearchParams;f?.currency&&h.set("currency",f.currency),f?.limit&&h.set("limit",f.limit.toString()),f?.offset&&h.set("offset",f.offset.toString());const m=h.toString(),b=m?`/credits/history?${m}`:"/credits/history";return await a.get(b)}catch(h){const m=T.handleApiError(h,"Failed to fetch transaction history");throw r(m.message),m}finally{n(!1)}},[a]);return{getBalance:i,getAllBalances:l,getHistory:u,isLoading:s,error:o,clearError:c}}function pd({showAllCurrencies:t=!1,refreshInterval:s=0,compact:n=!1,className:o="",onLoad:r}){const{getBalance:a,getAllBalances:c,isLoading:i,error:l,clearError:u}=Xs(),[f,h]=d.useState([]),[m,b]=d.useState(null),g=d.useCallback(async()=>{try{if(t){const p=await c();h(p),r?.(p)}else{const p=await a();h([p]),r?.([p])}b(null)}catch(p){b(p instanceof Error?p.message:"Failed to load balance")}},[t,a,c,r]);if(d.useEffect(()=>{g()},[g]),d.useEffect(()=>{if(s<=0)return;const p=setInterval(g,s);return()=>clearInterval(p)},[s,g]),m||l)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${o}`,children:[e.jsx("p",{className:"cedros-credit-error",children:m||l}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),b(null),g()},children:"Retry"})]});if(i&&f.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(n){const p=f[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${o}`,children:[p?e.jsx("span",{className:"cedros-credit-value",title:`${p.balanceLamports} lamports`,children:p.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),i&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${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:g,disabled:i,title:"Refresh balance",children:i?"...":"↻"})]}),f.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:f.map(p=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:p.currency}),e.jsx("span",{className:"cedros-credit-amount",children:p.display})]},p.currency))})]})}const gs=[{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 md(t,s){const n=t<0,o=Math.abs(t),r=s.toUpperCase()==="SOL",c=o/Math.pow(10,r?9:6),i=n?"-":"+";return r?`${i}${c.toFixed(4)} SOL`:`${i}$${c.toFixed(2)}`}function gd(t){const s=new Date(t),n=new Date,o=n.getTime()-s.getTime(),r=Math.floor(o/(1e3*60*60*24));if(r===0){const a=Math.floor(o/36e5);if(a===0){const c=Math.floor(o/6e4);return c<1?"Just now":`${c}m ago`}return`${a}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==n.getFullYear()?"numeric":void 0})}function wd(t){return t?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[t.toLowerCase()]||t:"Transaction"}function bd(t,s){const n=(t||"").toLowerCase();return n==="deposit"?"↓":n==="spend"||n==="usage"||n==="charge"?"↑":n==="refund"?"←":n==="bonus"||n==="credit"?"★":s?"+":"−"}function yd({defaultTab:t="all",pageSize:s=10,refreshInterval:n=0,className:o="",onLoad:r,onTransactionClick:a}){const{getHistory:c,isLoading:i,error:l,clearError:u}=Xs(),[f,h]=d.useState(t),[m,b]=d.useState([]),[g,p]=d.useState(0),[k,y]=d.useState(0),[N,j]=d.useState(null),C=gs.find(S=>S.key===f)||gs[0],L=d.useMemo(()=>C.txTypes===null?m:m.filter(S=>{const B=S.txType||"";return C.txTypes.some(M=>B.toLowerCase().includes(M.toLowerCase()))}),[m,C.txTypes]),w=d.useCallback(async()=>{try{const S=await c({limit:s*3,offset:k});b(S.transactions),p(S.total),r?.(S),j(null)}catch(S){j(S instanceof Error?S.message:"Failed to load history")}},[s,k,c,r]);d.useEffect(()=>{y(0)},[f]),d.useEffect(()=>{w()},[w]),d.useEffect(()=>{if(n<=0)return;const S=setInterval(w,n);return()=>clearInterval(S)},[n,w]);const v=Math.ceil(g/s),A=Math.floor(k/s)+1,x=S=>{const B=(S-1)*s;y(Math.max(0,Math.min(B,Math.max(0,g-1))))},E=S=>{h(S)};if(N||l)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${o}`,children:[e.jsx("p",{className:"cedros-tx-error",children:N||l}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),j(null),w()},children:"Retry"})]});if(i&&m.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=S=>S.txTypes===null?m.length:m.filter(B=>{const M=B.txType||"";return S.txTypes.some(R=>M.toLowerCase().includes(R.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:w,disabled:i,title:"Refresh",children:i?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:gs.map(S=>{const B=P(S),M=f===S.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${M?"cedros-tx-tab-active":""}`,onClick:()=>E(S.key),children:[S.label,B>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:B})]},S.key)})}),L.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:f==="all"?"No transactions yet.":`No ${C.label.toLowerCase()} found.`}),f==="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:L.slice(0,s).map(S=>{const B=S.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${B?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>a?.(S),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),a?.(S))},role:a?"button":void 0,tabIndex:a?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${B?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:bd(S.txType,B)}),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:wd(S.txType)}),e.jsx("span",{className:`cedros-tx-amount ${B?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:md(S.amountLamports,S.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:S.description}),e.jsx("span",{className:"cedros-tx-date",children:gd(S.createdAt)})]})]})]},S.id)})}),v>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>x(A-1),disabled:A<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",A," of ",v]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>x(A+1),disabled:A>=v,children:"Next"})]})]})]})}function Js(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(!1),[o,r]=d.useState(null),[a,c]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),l=d.useCallback(()=>{r(null)},[]),u=d.useCallback(async()=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await i.get("/wallet/withdraw/balances")}catch(b){const g=T.handleApiError(b,"Failed to fetch wallet balances");throw r(g.message),g}},[i]),f=d.useCallback(async(b,g)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");n(!0),r(null);try{const p=await i.post("/wallet/withdraw/sol",{destination:b,amount_lamports:g});return c(p),p}catch(p){const k=T.handleApiError(p,"Failed to withdraw SOL");throw r(k.message),k}finally{n(!1)}},[i]),h=d.useCallback(async(b,g,p)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");n(!0),r(null);try{const k=await i.post("/wallet/withdraw/spl",{destination:b,token_mint:g,amount:p});return c(k),k}catch(k){const y=T.handleApiError(k,"Failed to withdraw token");throw r(y.message),y}finally{n(!1)}},[i]),m=d.useCallback(async(b=10,g=0)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const p=Math.max(1,Math.min(100,Math.trunc(b))),k=Math.max(0,Math.trunc(g)),y=new URLSearchParams({limit:String(p),offset:String(k)});return await i.get(`/wallet/withdraw/history?${y}`)}catch(p){const k=T.handleApiError(p,"Failed to fetch withdrawal history");throw r(k.message),k}},[i]);return{withdrawSol:f,withdrawSpl:h,getBalances:u,getHistory:m,isSubmitting:s,error:o,clearError:l,lastResult:a}}const ws="So11111111111111111111111111111111111111112",xd={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Ad(t){return t.length<32||t.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(t)}function bs(t){return t.length<=16?t:`${t.slice(0,6)}...${t.slice(-6)}`}function dt(t,s){return(Number(t)/Math.pow(10,s)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(s,6)})}function vd({onSuccess:t,onError:s,onCancel:n,className:o=""}){const r=T.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:c,getBalances:i,isSubmitting:l,error:u,clearError:f}=Js(),[h,m]=d.useState("loading"),[b,g]=d.useState([]),[p,k]=d.useState(null),[y,N]=d.useState(""),[j,C]=d.useState(""),[L,w]=d.useState(null),[v,A]=d.useState(null),[x,E]=d.useState(null),P=r?.config.solana?.network??"mainnet-beta",S=d.useMemo(()=>{if(!L?.txSignature)return"";const D=`https://explorer.solana.com/tx/${L.txSignature}`;return P==="mainnet-beta"?D:`${D}?cluster=${encodeURIComponent(P)}`},[L,P]),B=d.useMemo(()=>{if(!p||!j)return"0";const D=parseFloat(j);return isNaN(D)||D<=0?"0":Math.floor(D*Math.pow(10,p.decimals)).toString()},[j,p]);d.useEffect(()=>{if(!r)return;let D=!1;return(async()=>{try{const _=await i();if(D)return;const $=[];_.solLamports>0&&$.push({symbol:"SOL",mint:ws,decimals:9,rawBalance:String(_.solLamports),displayBalance:dt(String(_.solLamports),9)});for(const X of _.tokens){const oe=xd[X.mint]??bs(X.mint);$.push({symbol:oe,mint:X.mint,decimals:X.decimals,rawBalance:X.amount,displayBalance:dt(X.amount,X.decimals)})}g($),m(($.length>0,"select"))}catch{D||(E("Failed to load wallet balances"),m("select"))}})(),()=>{D=!0}},[r,i]);const M=d.useCallback(D=>{k(D),m("form"),f(),A(null),C("")},[f]),R=d.useCallback(()=>{if(!p)return;const D=Number(p.rawBalance)/Math.pow(10,p.decimals);p.mint===ws?C(String(Math.max(0,D-.01))):C(String(D))},[p]),U=d.useCallback(()=>{if(A(null),!y.trim()){A("Destination address is required");return}if(!Ad(y.trim())){A("Invalid Solana address");return}if(!j||parseFloat(j)<=0||isNaN(parseFloat(j))){A("Please enter a valid amount");return}if(B==="0"){A("Amount is too small");return}m("confirm")},[y,j,B]),F=d.useCallback(async()=>{if(p){m("processing"),f();try{let D;p.mint===ws?D=await a(y.trim(),Number(B)):D=await c(y.trim(),p.mint,B),w(D),m("success"),t?.(D)}catch(D){m("confirm"),s?.(D instanceof Error?D:new Error(String(D)))}}},[p,y,B,a,c,f,t,s]),W=d.useCallback(()=>{f(),A(null),h==="form"?(m("select"),k(null),C(""),N("")):h==="confirm"&&m("form")},[h,f]),q=d.useCallback(()=>{m("select"),k(null),N(""),C(""),w(null),f(),A(null)},[f]);return r?e.jsxs("div",{className:`cedros-withdrawal ${o}`,children:[h==="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..."})]}),h==="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"})]}),x&&e.jsx(Z.ErrorMessage,{error:x}),b.length===0&&!x&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:b.map(D=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>M(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))}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:n,children:"Cancel"})]}),h==="form"&&p&&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 ",p.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",p.displayBalance," ",p.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:y,onChange:D=>N(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 (",p.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:j,onChange:D=>C(D.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:R,children:"Max"})]})]}),(v||u)&&e.jsx(Z.ErrorMessage,{error:v||u||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:U,children:"Review Withdrawal"})]}),h==="confirm"&&p&&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:p.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:[dt(B,p.decimals)," ",p.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:y,children:bs(y)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),u&&e.jsx(Z.ErrorMessage,{error:u}),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"})]})]}),h==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(z.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",p?.symbol,"..."]})]}),h==="success"&&L&&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:[dt(B,p?.decimals??9)," ",p?.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:S,target:"_blank",rel:"noreferrer",children:bs(L.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:q,children:"Done"})]})]}):null}function jd(t,s){if(t==="sol")return"SOL";if(!s)return"SPL";const n=Oo.find(o=>o.mint===s);return n?n.symbol:`${s.slice(0,4)}...${s.slice(-4)}`}function kd(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function Nd(t){const s=new Date(t),n=new Date,o=n.getTime()-s.getTime(),r=Math.floor(o/(1e3*60*60*24));if(r===0){const a=Math.floor(o/36e5);if(a===0){const c=Math.floor(o/6e4);return c<1?"Just now":`${c}m ago`}return`${a}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==n.getFullYear()?"numeric":void 0})}function Cd({pageSize:t=10,className:s="",onTransactionClick:n,explorerUrl:o="https://solscan.io"}){const{getHistory:r,error:a,clearError:c}=Js(),[i,l]=d.useState([]),[u,f]=d.useState(0),[h,m]=d.useState(0),[b,g]=d.useState(!1),[p,k]=d.useState(null),y=d.useCallback(async()=>{g(!0);try{const L=await r(t,h);l(L.items),f(L.total),k(null)}catch(L){k(L instanceof Error?L.message:"Failed to load withdrawal history")}finally{g(!1)}},[t,h,r]);d.useEffect(()=>{y()},[y]);const N=Math.ceil(u/t),j=Math.floor(h/t)+1,C=L=>{const w=(L-1)*t;m(Math.max(0,Math.min(w,Math.max(0,u-1))))};return p||a?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${s}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:p||a}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{c(),k(null),y()},children:"Retry"})]}):b&&i.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${s}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${s}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:y,disabled:b,title:"Refresh",children:b?"...":"↻"})]}),i.length===0?e.jsx("div",{className:"cedros-tx-empty",children:e.jsx("p",{className:"cedros-tx-empty-message",children:"No withdrawal history yet."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:i.map(L=>{const w=jd(L.tokenType,L.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>n?.(L),onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),n?.(L))},role:n?"button":void 0,tabIndex:n?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:[w," Withdrawal"]}),e.jsxs("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:[L.amount," ",w==="SOL"?"lamports":""]})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${o}/account/${L.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:v=>v.stopPropagation(),children:kd(L.destination)})," · ",e.jsx("a",{href:`${o}/tx/${L.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:v=>v.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:Nd(L.createdAt)})]})]})]},L.id)})}),N>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>C(j-1),disabled:j<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",j," of ",N]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>C(j+1),disabled:j>=N,children:"Next"})]})]})]})}function Sd({brandLogo:t,brandName:s,title:n="Welcome back",subtitle:o="Login with your Apple or Google account",termsText:r,onSuccess:a,defaultTab:c="login",children:i,className:l=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${l}`,children:[(t||s)&&e.jsxs("div",{className:"cedros-brand-header",children:[t,s&&e.jsx("span",{className:"cedros-brand-name",children:s})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:n}),o&&e.jsx("p",{className:"cedros-full-page-subtitle",children:o})]}),i??e.jsx(Et,{defaultTab:c,onSuccess:a})]}),r&&e.jsx("p",{className:"cedros-terms-footer",children:r})]})}function Ed({brandName:t="Your Brand",brandLogo:s,tagline:n="Your tagline goes here. Make it compelling.",title:o="Sign in",subtitle:r="Enter your credentials to access your account",onSuccess:a,defaultTab:c="login",children:i,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:[s??e.jsx("div",{className:"cedros-split-page-logo",children:t.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:t}),n&&e.jsx("p",{className:"cedros-split-page-tagline",children:n})]})}),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}),r&&e.jsx("p",{className:"cedros-split-page-subtitle",children:r}),i??e.jsx(Et,{defaultTab:c,onSuccess:a})]})})]})}function Ld(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),r=d.useMemo(()=>new Bs.OrgApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),a=d.useCallback(async l=>{o(u=>({...u,isLoading:!0,error:null}));try{const u=await r.authorize(l),f={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return o(f),f}catch(u){const f={allowed:!1,reason:void 0,isLoading:!1,error:u};return o(f),f}},[r]),c=d.useCallback(async l=>(await a(l)).allowed,[a]),i=d.useCallback(()=>{o({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:c,lastCheck:n,clearCheck:i,checkAuthorization:a}}function Pd(){const{listAllWallets:t,createDerivedWallet:s,deleteDerivedWallet:n}=I.useWalletMaterial(),[o,r]=d.useState([]),[a,c]=d.useState(!1),[i,l]=d.useState(null),u=d.useCallback(async()=>{c(!0),l(null);try{const b=await t();r(b.wallets)}catch(b){const g=b instanceof Error?b.message:"Failed to list wallets";l(g)}finally{c(!1)}},[t]),f=d.useCallback(async b=>{c(!0),l(null);try{const g=await s({label:b});return await u(),g}catch(g){const p=g instanceof Error?g.message:"Failed to create wallet";throw l(p),g}finally{c(!1)}},[s,u]),h=d.useCallback(async b=>{c(!0),l(null);try{await n(b),await u()}catch(g){const p=g instanceof Error?g.message:"Failed to delete wallet";throw l(p),g}finally{c(!1)}},[n,u]),m=d.useCallback(()=>l(null),[]);return{wallets:o,isLoading:a,createWallet:f,deleteWallet:h,refresh:u,error:i,clearError:m}}function Bd(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(!1),[o,r]=d.useState(null),[a,c]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),l=d.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");n(!0),r(null);try{const h=await i.get("/wallet/pending-recovery");c(h)}catch(h){const m=T.handleApiError(h,"Failed to fetch pending recovery");throw r(m.message),m}finally{n(!1)}},[i]),u=d.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");n(!0),r(null);try{const h={confirmed:!0};await i.post("/wallet/acknowledge-recovery",h),c(null)}catch(h){const m=T.handleApiError(h,"Failed to acknowledge recovery");throw r(m.message),m}finally{n(!1)}},[i]),f=d.useCallback(()=>r(null),[]);return d.useEffect(()=>{i&&t?.authState==="authenticated"&&l().catch(()=>{})},[i,t?.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:u,isLoading:s,error:o,clearError:f}}function Md(t={}){const{onExternalSign:s}=t,{solanaPubkey:n,hasExternalWallet:o,status:r,isUnlocked:a}=I.useWallet(),{signTransaction:c,isSigning:i,error:l,clearError:u}=co(),f=d.useMemo(()=>o&&s?"external":r==="enrolled_locked"||r==="enrolled_unlocked"?"sss":"none",[o,s,r]),h=f!=="none",m=r==="enrolled_locked"||r==="enrolled_unlocked";return{signTransaction:d.useCallback(async(g,p)=>{if(f==="external"){if(!s)throw new Error("External wallet signing callback not provided");return s(g)}if(f==="sss"){if(!p&&!a)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return p?c(g,p):c(g)}throw new Error("No signing method available. Enroll a wallet first.")},[f,s,a,c]),signingMethod:f,canSign:h,isSigning:i,publicKey:n,hasExternalWallet:o,hasSssWallet:m,isSssUnlocked:a,error:l,clearError:u}}function Rd(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(null),[r,a]=d.useState(!1),[c,i]=d.useState(null),l=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),u=d.useCallback(async()=>{a(!0),i(null);try{await l.post("/welcome-completed",{})}catch(h){const m=h instanceof Error?h:new Error(String(h));throw i(m),m}finally{a(!1)}},[l]),f=d.useCallback(()=>{o(null)},[]);return{postLoginAction:n,setPostLoginAction:o,markWelcomeCompleted:u,clearPostLogin:f,isLoading:r,error:c}}const er=d.createContext(null),Nt={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 Wo(t,s){return qo(t,s)}function qo(t,s){const n={...t};for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)){const r=t[o],a=s[o];typeof r=="object"&&r!==null&&typeof a=="object"&&a!==null?n[o]=qo(r,a):a!==void 0&&(n[o]=a)}return n}function Td({children:t,locale:s="en",translations:n}){const o=d.useMemo(()=>({t:n?Wo(Nt,n):Nt,locale:s}),[n,s]);return e.jsx(er.Provider,{value:o,children:t})}function Id(){return d.useContext(er)?.t??Nt}function Dd(){return d.useContext(er)?.locale??"en"}exports.CedrosLoginProvider=I.CedrosLoginProvider;exports.getEmbeddedWalletInfo=I.getEmbeddedWalletInfo;exports.isEmbeddedWalletAvailable=I.isEmbeddedWalletAvailable;exports.useAuth=I.useAuth;exports.useWallet=I.useWallet;exports.useWalletMaterial=I.useWalletMaterial;exports.useAuthState=T.useAuthState;exports.useAuthUI=T.useAuthUI;exports.useCedrosLogin=T.useCedrosLogin;exports.LoadingSpinner=z.LoadingSpinner;exports.EmailLoginForm=Q.EmailLoginForm;exports.EmailRegisterForm=Q.EmailRegisterForm;exports.OtpInput=Q.OtpInput;exports.PasswordInput=Q.PasswordInput;exports.TotpVerify=Q.TotpVerify;exports.useEmailAuth=Q.useEmailAuth;exports.useTotpVerify=Q.useTotpVerify;exports.validatePassword=Re.validatePassword;exports.ErrorMessage=Z.ErrorMessage;exports.GoogleLoginButton=Ps.GoogleLoginButton;exports.useGoogleAuth=Ps.useGoogleAuth;exports.SolanaLoginButton=Oe.SolanaLoginButton;exports.registerMobileWallet=Oe.registerMobileWallet;exports.useSolanaAuth=Oe.useSolanaAuth;exports.InviteForm=ce.InviteForm;exports.InviteList=ce.InviteList;exports.MemberList=ce.MemberList;exports.useInvites=ce.useInvites;exports.useMembers=ce.useMembers;exports.useServerFeatures=ce.useServerFeatures;exports.useSystemSettings=ln.useSystemSettings;exports.useOrgs=Bs.useOrgs;exports.AdminDepositList=mt.AdminDepositList;exports.AdminDepositStats=mt.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Le.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Le.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Le.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Le.AdminWithdrawalStats;exports.AdminUserList=Ze.AdminUserList;exports.useAdminUsers=Ze.useAdminUsers;exports.AdminIcons=Pe.Icons;exports.AdminShell=Pe.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=Pe.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=Pe.ProfileDropdown;exports.cedrosLoginPlugin=Pe.cedrosLoginPlugin;exports.loginPlugin=Pe.cedrosLoginPlugin;exports.useAdminShell=Pe.useAdminShell;exports.AuthenticationSettings=un.AuthenticationSettings;exports.EmbeddedWalletSettings=hn.EmbeddedWalletSettings;exports.EmailSettings=ut.EmailSettings;exports.CreditSystemSettings=Ms.CreditSystemSettings;exports.PrivacyCashSettings=Ms.CreditSystemSettings;exports.ServerSettings=fn.ServerSettings;exports.useAdminDeposits=Zo.useAdminDeposits;exports.SettingsPageLayout=Rs.SettingsPageLayout;exports.WebhookSettings=Rs.WebhookSettings;exports.AccountSettings=Dl;exports.AppleLoginButton=Zn;exports.CapabilityWarning=yc;exports.CedrosAdminDashboard=Gc;exports.ChooseUsernamePrompt=Fl;exports.CompleteAccountPrompt=Ul;exports.CreditBalance=pd;exports.DepositFlow=Yl;exports.ErrorBoundary=eo;exports.ForgotPasswordForm=Qn;exports.FullPageLayout=Sd;exports.History=yd;exports.I18nProvider=Td;exports.LinkedAccounts=No;exports.LoginButton=$i;exports.LoginForm=Et;exports.LoginModal=ec;exports.MfaSetupPrompt=_l;exports.OrgSelector=sc;exports.OrgSwitcher=uc;exports.PasskeyLoginButton=Jn;exports.PasskeyPrompt=uo;exports.ProfileTab=jo;exports.RecoveryPhraseDisplay=so;exports.RecoveryPhraseInput=ro;exports.ResetPasswordForm=tc;exports.SUPPORTED_TOKENS=Oo;exports.SecuritySettings=Hc;exports.SessionList=to;exports.SetupWizard=wo;exports.SplitPageLayout=Ed;exports.SystemSettings=Uc;exports.TieredAmountSlider=Zs;exports.TokenSelector=Qs;exports.TotpSettings=vo;exports.TotpSetup=$s;exports.UserProfileSettings=jl;exports.WalletAddressRow=mo;exports.WalletEnrollment=io;exports.WalletManager=_c;exports.WalletRecovery=po;exports.WalletStatus=go;exports.WalletUnlock=ho;exports.WithdrawalFlow=vd;exports.WithdrawalHistory=Cd;exports.defaultTranslations=Nt;exports.getTierForAmount=Lt;exports.mergeTranslations=Wo;exports.useAppleAuth=Kn;exports.useAuthorize=Ld;exports.useCredentials=Gs;exports.useCredits=Xs;exports.useDeposit=Bo;exports.useInstantLink=Gn;exports.useLocale=Dd;exports.usePasskeySigning=lo;exports.usePasswordReset=St;exports.usePendingRecovery=Bd;exports.usePostLogin=Rd;exports.useProfile=Xe;exports.useSessions=Lo;exports.useSetPassword=ao;exports.useSetup=zs;exports.useTotp=Vs;exports.useTransactionSigning=Md;exports.useTranslations=Id;exports.useUsername=Po;exports.useWalletEnrollment=oo;exports.useWalletRecovery=fo;exports.useWalletSigning=co;exports.useWallets=Pd;exports.useWebAuthn=qs;exports.useWithdrawal=Js;
2054
+ Minimum version required to store current data is: `+E+`.
2055
+ `);const B=j(v,A,S),L=t.getSymbolSize(v),M=new o(L);return b(M,v),w(M),m(M,v),x(M,A,0),v>=7&&k(M,v),N(M,B),isNaN(y)&&(y=c.getBestMask(M,x.bind(null,M,A))),c.applyMask(y,M),x(M,A,y),{modules:M,version:v,errorCorrectionLevel:A,maskPattern:y,segments:S}}return Yt.create=function(v,A){if(typeof v>"u"||v==="")throw new Error("No input text");let y=s.M,S,E;return typeof A<"u"&&(y=s.from(A.errorCorrectionLevel,s.M),S=u.from(A.version),E=c.from(A.maskPattern),A.toSJISFunc&&t.setToSJISFunction(A.toSJISFunc)),P(v,S,y,E)},Yt}var ms={},gs={},on;function No(){return on||(on=1,(function(t){function s(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let o=n.slice().replace("#","").split("");if(o.length<3||o.length===5||o.length>8)throw new Error("Invalid hex color: "+n);(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 r=parseInt(o.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+o.slice(0,6).join("")}}t.getOptions=function(o){o||(o={}),o.color||(o.color={});const r=typeof o.margin>"u"||o.margin===null||o.margin<0?4:o.margin,a=o.width&&o.width>=21?o.width:void 0,c=o.scale||4;return{width:a,scale:a?4:c,margin:r,color:{dark:s(o.color.dark||"#000000ff"),light:s(o.color.light||"#ffffffff")},type:o.type,rendererOpts:o.rendererOpts||{}}},t.getScale=function(o,r){return r.width&&r.width>=o+r.margin*2?r.width/(o+r.margin*2):r.scale},t.getImageWidth=function(o,r){const a=t.getScale(o,r);return Math.floor((o+r.margin*2)*a)},t.qrToImageData=function(o,r,a){const c=r.modules.size,i=r.modules.data,l=t.getScale(c,a),u=Math.floor((c+a.margin*2)*l),f=a.margin*l,h=[a.color.light,a.color.dark];for(let p=0;p<u;p++)for(let b=0;b<u;b++){let w=(p*u+b)*4,m=a.color.light;if(p>=f&&b>=f&&p<u-f&&b<u-f){const k=Math.floor((p-f)/l),x=Math.floor((b-f)/l);m=h[i[k*c+x]?1:0]}o[w++]=m.r,o[w++]=m.g,o[w++]=m.b,o[w]=m.a}}})(gs)),gs}var an;function yl(){return an||(an=1,(function(t){const s=No();function n(r,a,c){r.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=c,a.width=c,a.style.height=c+"px",a.style.width=c+"px"}function o(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(a,c,i){let l=i,u=c;typeof l>"u"&&(!c||!c.getContext)&&(l=c,c=void 0),c||(u=o()),l=s.getOptions(l);const f=s.getImageWidth(a.modules.size,l),h=u.getContext("2d"),p=h.createImageData(f,f);return s.qrToImageData(p.data,a,l),n(h,u,f),h.putImageData(p,0,0),u},t.renderToDataURL=function(a,c,i){let l=i;typeof l>"u"&&(!c||!c.getContext)&&(l=c,c=void 0),l||(l={});const u=t.render(a,c,l),f=l.type||"image/png",h=l.rendererOpts||{};return u.toDataURL(f,h.quality)}})(ms)),ms}var ws={},cn;function xl(){if(cn)return ws;cn=1;const t=No();function s(r,a){const c=r.a/255,i=a+'="'+r.hex+'"';return c<1?i+" "+a+'-opacity="'+c.toFixed(2).slice(1)+'"':i}function n(r,a,c){let i=r+a;return typeof c<"u"&&(i+=" "+c),i}function o(r,a,c){let i="",l=0,u=!1,f=0;for(let h=0;h<r.length;h++){const p=Math.floor(h%a),b=Math.floor(h/a);!p&&!u&&(u=!0),r[h]?(f++,h>0&&p>0&&r[h-1]||(i+=u?n("M",p+c,.5+b+c):n("m",l,0),l=0,u=!1),p+1<a&&r[h+1]||(i+=n("h",f),f=0)):l++}return i}return ws.render=function(a,c,i){const l=t.getOptions(c),u=a.modules.size,f=a.modules.data,h=u+l.margin*2,p=l.color.light.a?"<path "+s(l.color.light,"fill")+' d="M0 0h'+h+"v"+h+'H0z"/>':"",b="<path "+s(l.color.dark,"stroke")+' d="'+o(f,u,l.margin)+'"/>',w='viewBox="0 0 '+h+" "+h+'"',k='<svg xmlns="http://www.w3.org/2000/svg" '+(l.width?'width="'+l.width+'" height="'+l.width+'" ':"")+w+' shape-rendering="crispEdges">'+p+b+`</svg>
2056
+ `;return typeof i=="function"&&i(null,k),k},ws}var ln;function Al(){if(ln)return We;ln=1;const t=tl(),s=bl(),n=yl(),o=xl();function r(a,c,i,l,u){const f=[].slice.call(arguments,1),h=f.length,p=typeof f[h-1]=="function";if(!p&&!t())throw new Error("Callback required as last argument");if(p){if(h<2)throw new Error("Too few arguments provided");h===2?(u=i,i=c,c=l=void 0):h===3&&(c.getContext&&typeof u>"u"?(u=l,l=void 0):(u=l,l=i,i=c,c=void 0))}else{if(h<1)throw new Error("Too few arguments provided");return h===1?(i=c,c=l=void 0):h===2&&!c.getContext&&(l=i,i=c,c=void 0),new Promise(function(b,w){try{const m=s.create(i,l);b(a(m,c,l))}catch(m){w(m)}})}try{const b=s.create(i,l);u(null,a(b,c,l))}catch(b){u(b)}}return We.create=s.create,We.toCanvas=r.bind(null,n.render),We.toDataURL=r.bind(null,n.renderToDataURL),We.toString=r.bind(null,function(a,c,i){return o.render(a,i)}),We}var vl=Al();const jl=yn(vl);function kl({value:t,size:s=200,alt:n="QR code",className:o=""}){const r=d.useRef(null),[a,c]=d.useState(null);return d.useEffect(()=>{!r.current||!t||jl.toCanvas(r.current,t,{width:s,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{c(null)}).catch(i=>{c(i instanceof Error?i.message:"Failed to generate QR code")})},[t,s]),a?e.jsx("div",{className:`cedros-qr-error ${o}`,style:{width:s,height:s},role:"img","aria-label":n,children:e.jsx("p",{children:"Failed to generate QR code"})}):e.jsx("canvas",{ref:r,className:`cedros-totp-qr-image ${o}`,role:"img","aria-label":n,style:{borderRadius:"0.5rem"}})}function Gs(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(null),[r,a]=d.useState("idle"),[c,i]=d.useState(null),[l,u]=d.useState(!1),[f,h]=d.useState(null),p=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,retryAttempts:t.retryAttempts,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),b=d.useCallback(async()=>{u(!0),h(null);try{const C=await p.get("/mfa/status");return o(C),C}catch(C){const P=T.handleApiError(C,"Unable to load two-factor authentication status. Please try again.");throw h(P),P}finally{u(!1)}},[p]),w=d.useCallback(async()=>{u(!0),h(null),a("loading");try{const C=await p.post("/mfa/setup",{});return i(C),a("setup"),C}catch(C){const P=T.handleApiError(C,"Unable to start two-factor setup. Please try again.");throw h(P),a("error"),P}finally{u(!1)}},[p]),m=d.useCallback(async C=>{if(!/^\d{6}$/.test(C)){const P={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw h(P),P}u(!0),h(null),a("verifying");try{await p.post("/mfa/enable",{code:C}),a("success");try{const P=await p.get("/mfa/status");o(P)}catch{o({enabled:!0,recoveryCodesRemaining:0})}}catch(P){const g=T.handleApiError(P,"Incorrect verification code. Please check and try again.");throw h(g),a("error"),g}finally{u(!1)}},[p]),k=d.useCallback(async C=>{if(!C){const P={code:"VALIDATION_ERROR",message:"Please enter your password"};throw h(P),P}u(!0),h(null);try{await p.post("/mfa/disable",{password:C}),o({enabled:!1,recoveryCodesRemaining:0}),i(null),a("idle")}catch(P){const g=T.handleApiError(P,"Unable to disable two-factor authentication. Please try again.");throw h(g),g}finally{u(!1)}},[p]),x=d.useCallback(async C=>{if(!/^\d{6}$/.test(C)){const P={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw h(P),P}u(!0),h(null);try{return await p.post("/mfa/recovery-codes/regenerate",{code:C})}catch(P){const g=T.handleApiError(P,"Unable to regenerate recovery codes. Please try again.");throw h(g),g}finally{u(!1)}},[p]),N=d.useCallback(()=>h(null),[]),j=d.useCallback(()=>{h(null),i(null),a("idle"),u(!1)},[]);return{status:n,setupState:r,setupData:c,isLoading:l,error:f,getStatus:b,beginSetup:w,enableTotp:m,disableTotp:k,regenerateBackupCodes:x,clearError:N,reset:j}}function Qs({onSuccess:t,onCancel:s,className:n=""}){const{setupState:o,setupData:r,isLoading:a,error:c,beginSetup:i,enableTotp:l,clearError:u,reset:f}=Gs(),[h,p]=d.useState("qr"),[b,w]=d.useState(""),[m,k]=d.useState(!1),[x,N]=d.useState(!1),j=d.useRef(null);d.useEffect(()=>{o==="idle"&&i().catch(()=>{})},[o,i]),d.useEffect(()=>{o==="success"&&t?.()},[o,t]);const C=async()=>{r?.secret&&(await navigator.clipboard.writeText(r.secret),k(!0),j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>k(!1),2e3))},P=async()=>{if(r?.recoveryCodes){const A=r.recoveryCodes.join(`
2057
+ `);await navigator.clipboard.writeText(A)}},g=async()=>{try{await l(b)}catch{w("")}},v=()=>{f(),s?.()};return d.useEffect(()=>()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null)},[]),o==="loading"||o==="idle"&&a?e.jsx("div",{className:`cedros-totp-setup ${n}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(z.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):o==="error"&&!r?e.jsxs("div",{className:`cedros-totp-setup ${n}`,children:[e.jsx(X.ErrorMessage,{error:c,onDismiss:u}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:v,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>i(),children:"Try again"})]})]}):o==="success"?e.jsx("div",{className:`cedros-totp-setup ${n}`,children:e.jsxs("div",{className:"cedros-totp-success",children:[e.jsxs("svg",{className:"cedros-totp-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"var(--cedros-success)",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"var(--cedros-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication enabled"}),e.jsx("p",{className:"cedros-totp-description",children:"Your account is now protected with an additional layer of security."})]})}):r?e.jsxs("div",{className:`cedros-totp-setup ${n}`,children:[h==="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(kl,{value:r.otpauthUri,size:200,alt:"QR code for authenticator app"})}),e.jsxs("div",{className:"cedros-totp-manual",children:[e.jsx("p",{className:"cedros-totp-manual-label",children:"Or enter this code manually:"}),e.jsxs("div",{className:"cedros-totp-secret",children:[e.jsx("code",{className:"cedros-totp-secret-code",children:r.secret}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:C,"aria-label":"Copy secret",children:m?"Copied!":"Copy"})]})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:v,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>p("backup"),children:"Continue"})]})]}),h==="backup"&&e.jsxs("div",{className:"cedros-totp-step",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Save recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. You can use them to access your account if you lose your authenticator device."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:r.recoveryCodes.map((A,y)=>e.jsx("code",{className:"cedros-totp-backup-code",children:A},y))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:P,children:"Copy all codes"}),e.jsxs("label",{className:"cedros-checkbox-label cedros-totp-confirm",children:[e.jsx("input",{type:"checkbox",className:"cedros-checkbox",checked:x,onChange:A=>N(A.target.checked)}),e.jsx("span",{className:"cedros-checkbox-text",children:"I have saved these recovery codes"})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>p("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>p("verify"),disabled:!x,children:"Continue"})]})]}),h==="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(Q.OtpInput,{value:b,onChange:w,onComplete:g,disabled:a,error:c?.message,autoFocus:!0}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>p("backup"),disabled:a,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:g,disabled:a||b.length!==6,children:a?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function Co({onStatusChange:t,className:s=""}){const{status:n,isLoading:o,error:r,getStatus:a,disableTotp:c,regenerateBackupCodes:i,clearError:l}=Gs(),[u,f]=d.useState("status"),[h,p]=d.useState(""),[b,w]=d.useState(""),[m,k]=d.useState(null),[x,N]=d.useState(!1),[j,C]=d.useState(null);d.useEffect(()=>{a().catch(()=>{})},[a]);const P=d.useCallback(()=>{f("status"),t?.(!0)},[t]),g=async()=>{N(!0),C(null);try{await c(h),f("status"),p(""),t?.(!1)}catch(y){C(y instanceof Error?y.message:"Failed to disable 2FA"),p("")}finally{N(!1)}},v=async()=>{N(!0),C(null);try{const y=await i(b);k(y.recoveryCodes),w("")}catch(y){C(y instanceof Error?y.message:"Failed to regenerate codes"),w("")}finally{N(!1)}},A=async()=>{m&&await navigator.clipboard.writeText(m.join(`
2058
+ `))};return o&&!n?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(z.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):r&&!n?e.jsxs("div",{className:`cedros-totp-settings ${s}`,children:[e.jsx(X.ErrorMessage,{error:r,onDismiss:l}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>a(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsx(Qs,{onSuccess:P,onCancel:()=>f("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),j&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(X.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:j},onDismiss:()=>C(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.PasswordInput,{label:"Password",placeholder:"Enter your password",value:h,onChange:y=>p(y.target.value),disabled:x,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("status"),p(""),C(null)},disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:g,disabled:x||h.length===0,children:x?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?m?e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:m.map((y,S)=>e.jsx("code",{className:"cedros-totp-backup-code",children:y},S))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:A,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:()=>{f("status"),k(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),j&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(X.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:j},onDismiss:()=>C(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.OtpInput,{value:b,onChange:w,onComplete:v,disabled:x,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("status"),w(""),C(null)},disabled:x,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:v,disabled:x||b.length!==6,children:x?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 ${s}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${n?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:n?.enabled?"Enabled":"Disabled"})]}),n?.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:n.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>f("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>f("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("setup"),children:"Enable two-factor authentication"})]})})}class Nl{client;constructor(s,n,o,r){this.client=new T.ApiClient({baseUrl:s,timeoutMs:n,retryAttempts:o,getAccessToken:r})}async changePassword(s){try{return await this.client.post("/auth/change-password",s)}catch(n){throw T.handleApiError(n,"Failed to change password")}}async updateProfile(s){try{return await this.client.patch("/auth/me",s)}catch(n){throw T.handleApiError(n,"Failed to update profile")}}}function tt(){const{config:t,authState:s,_internal:n}=T.useCedrosLogin(),[o,r]=d.useState(!1),[a,c]=d.useState(null),i=d.useMemo(()=>new Nl(t.serverUrl,t.requestTimeout,t.retryAttempts,n?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,n]),l=d.useCallback(()=>{c(null)},[]),u=d.useCallback(async h=>{if(s!=="authenticated")throw new Error("Must be authenticated to update profile");r(!0),c(null);try{return await i.updateProfile(h)}catch(p){const b=p instanceof Error?p:new Error("Failed to update profile");throw c(b),b}finally{r(!1)}},[s,i]),f=d.useCallback(async h=>{if(s!=="authenticated")throw new Error("Must be authenticated to change password");r(!0),c(null);try{await i.changePassword(h)}catch(p){const b=p instanceof Error?p:new Error("Failed to change password");throw c(b),b}finally{r(!1)}},[s,i]);return{isLoading:o,error:a,updateProfile:u,changePassword:f,clearError:l}}function Cl({onPasswordChange:t,onClose:s,className:n=""}){const{user:o}=I.useAuth(),{isLoading:r,error:a,changePassword:c,clearError:i}=tt(),[l,u]=d.useState("main"),[f,h]=d.useState(""),[p,b]=d.useState(""),[w,m]=d.useState(""),[k,x]=d.useState(null),[N,j]=d.useState(null),C=Te.validatePassword(p),P=p===w,g=f.length>0&&p.length>0&&w.length>0&&C.isValid&&P,v=d.useCallback(async()=>{if(g){x(null),j(null);try{await c({currentPassword:f,newPassword:p}),h(""),b(""),m(""),j("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>{u("main"),j(null)},2e3)}catch(S){x(S instanceof Error?S.message:"Failed to change password")}}},[g,f,p,c,t]),A=d.useCallback(()=>{u("main"),h(""),b(""),m(""),x(null),i()},[i]),y=()=>o?.name?o.name.split(" ").map(S=>S[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?";return l==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${n}`,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."}),(k||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(X.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:k||a?.message||""},onDismiss:()=>{x(null),i()}})}),N&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),N]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:f,onChange:S=>h(S.target.value),disabled:r,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:p,onChange:S=>b(S.target.value),disabled:r,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:w,onChange:S=>m(S.target.value),disabled:r,error:w.length>0&&!P?"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:A,disabled:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:v,disabled:r||!g,children:r?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 ${n}`,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: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:y()})}),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:()=>u("change-password"),children:"Change"})]})]}),s&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})})}class Sl{client;constructor(s,n,o,r){this.client=new T.ApiClient({baseUrl:s,timeoutMs:n,retryAttempts:o,getAccessToken:r})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(s){throw T.handleApiError(s,"Failed to list credentials")}}async unlinkCredential(s){try{await this.client.delete(`/credentials/${encodeURIComponent(s)}`)}catch(n){throw T.handleApiError(n,"Failed to unlink credential")}}}function Ks(){const{config:t,authState:s,_internal:n}=T.useCedrosLogin(),[o,r]=d.useState([]),[a,c]=d.useState(!1),[i,l]=d.useState(null),u=d.useMemo(()=>new Sl(t.serverUrl,t.requestTimeout,t.retryAttempts,n?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,n]),f=d.useCallback(()=>{l(null)},[]),h=d.useCallback(async()=>{if(s!=="authenticated"){r([]);return}c(!0),l(null);try{const b=await u.listCredentials();r(b)}catch(b){l(b)}finally{c(!1)}},[s,u]);d.useEffect(()=>{s==="authenticated"?h():r([])},[s,h]);const p=d.useCallback(async b=>{c(!0),l(null);try{await u.unlinkCredential(b),await h()}catch(w){throw l(w),w}finally{c(!1)}},[u,h]);return{credentials:o,isLoading:a,error:i,fetchCredentials:h,unlinkCredential:p,clearError:f}}function El({onPasswordChange:t,onCancel:s,className:n=""}){const{isLoading:o,error:r,changePassword:a,clearError:c}=tt(),[i,l]=d.useState(""),[u,f]=d.useState(""),[h,p]=d.useState(""),[b,w]=d.useState(null),[m,k]=d.useState(null),x=Te.validatePassword(u),N=u===h,j=i.length>0&&u.length>0&&h.length>0&&x.isValid&&N,C=d.useCallback(async()=>{if(j){w(null),k(null);try{await a({currentPassword:i,newPassword:u}),l(""),f(""),p(""),k("Password changed successfully. Other sessions have been logged out."),t?.(),setTimeout(()=>s(),2e3)}catch(g){w(g instanceof Error?g.message:"Failed to change password")}}},[j,i,u,a,t,s]),P=d.useCallback(()=>{w(null),c(),s()},[c,s]);return e.jsx("div",{className:`cedros-profile-settings ${n}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(b||r)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(X.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:b||r?.message||""},onDismiss:()=>{w(null),c()}})}),m&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),m]}),e.jsxs("div",{className:"cedros-profile-form",children:[e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Current password",placeholder:"Enter your current password",value:i,onChange:g=>l(g.target.value),disabled:o,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:u,onChange:g=>f(g.target.value),disabled:o,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:h,onChange:g=>p(g.target.value),disabled:o,error:h.length>0&&!N?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:P,disabled:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:C,disabled:o||!j,children:o?e.jsxs(e.Fragment,{children:[e.jsx(z.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function So({onPasswordChange:t,className:s=""}){const{user:n,refreshUser:o}=I.useAuth(),{isLoading:r,error:a,updateProfile:c,clearError:i}=tt(),{credentials:l}=Ks(),{forgotPassword:u,isLoading:f,isSuccess:h,reset:p}=St(),b=l.some(y=>y.credentialType==="password"),[w,m]=d.useState("view"),[k,x]=d.useState(""),[N,j]=d.useState(null),C=()=>n?.name?n.name.split(" ").map(y=>y[0]).join("").toUpperCase().slice(0,2):n?.email?n.email[0].toUpperCase():"?",P=d.useCallback(()=>{x(n?.name||""),m("edit"),j(null)},[n?.name]),g=d.useCallback(async()=>{const y=k.trim();if(y){j(null);try{await c({name:y}),await o(),m("view")}catch(S){j(S instanceof Error?S.message:"Failed to update name")}}},[k,c,o]),v=d.useCallback(()=>{m("view"),x(""),j(null),i()},[i]),A=d.useCallback(async()=>{if(n?.email){j(null);try{await u(n.email)}catch(y){j(y instanceof Error?y.message:"Failed to send password setup email")}}},[n?.email,u]);return w==="change-password"?e.jsx(El,{onPasswordChange:t,onCancel:()=>m("view"),className:s}):e.jsx("div",{className:`cedros-profile-settings ${s}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:n?.picture?e.jsx("img",{src:n.picture,alt:n.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:C()})}),e.jsxs("div",{className:"cedros-profile-info",children:[w==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:k,onChange:y=>x(y.target.value),disabled:r,autoFocus:!0,onKeyDown:y=>{y.key==="Enter"&&g(),y.key==="Escape"&&v()}}),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:g,disabled:r||!k.trim(),children:r?e.jsx(z.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:v,disabled:r,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:n?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:P,title:"Edit name","aria-label":"Edit name",children:e.jsx(Ll,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:n?.email})]})]}),(N||a)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(X.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:N||a?.message||""},onDismiss:()=>{j(null),i()}})}),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:n?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:b?"••••••••":"Not set"})]}),b?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{m("change-password"),j(null)},children:"Change"}):h?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:p,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:A,disabled:f,children:f?e.jsx(z.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function Ll(){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 Eo={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 Lo({onLinkGoogle:t,onLinkApple:s,onAddPasskey:n,onLinkSolana:o,className:r=""}){const{credentials:a,isLoading:c,error:i,unlinkCredential:l,clearError:u,fetchCredentials:f}=Ks(),{registerPasskey:h,isSupported:p}=Hs(),[b,w]=d.useState(null),[m,k]=d.useState(!1),x=d.useCallback(async()=>{if(n){n();return}k(!0);try{await h(),await f()}catch{}finally{k(!1)}},[n,h,f]),N=d.useCallback(async y=>{const S=y.label||Eo[y.credentialType];if(window.confirm(`Remove "${S}" as a sign-in method? You won't be able to sign in with it anymore.`)){w(y.id);try{await l(y.id)}catch{}finally{w(null)}}},[l]),j=new Set(a.map(y=>y.credentialType)),C=t&&!j.has("oauth_google"),P=s&&!j.has("oauth_apple"),g=(n||p)&&!j.has("webauthn_passkey"),v=o&&!j.has("solana"),A=C||P||g||v;return c&&a.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${r}`,children:[e.jsx(z.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${r}`,children:[i&&e.jsx(X.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:i.message},onDismiss:u}),a.length===0&&!c&&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(y=>e.jsx(Pl,{credential:y,isUnlinking:b===y.id,onUnlink:N},y.id))}),A&&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:[C&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(Po,{})," Google"]}),P&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(Bo,{})," Apple"]}),g&&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"}):e.jsxs(e.Fragment,{children:[e.jsx(Ps,{})," Passkey"]})}),v&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:o,children:[e.jsx(Mo,{})," Solana"]})]})]})]})}function Pl({credential:t,isUnlinking:s,onUnlink:n}){const o=t.label||Eo[t.credentialType],r=Bl[t.credentialType]||Ml;return e.jsxs("li",{className:"cedros-linked-credential",children:[e.jsx("div",{className:"cedros-linked-credential__icon",children:e.jsx(r,{})}),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 ",dn(t.createdAt),t.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",dn(t.lastUsedAt)]}),t.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>n(t),disabled:s,title:t.isPrimary?"Cannot remove primary sign-in method":"Remove",children:s?e.jsx(z.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function dn(t){const s=new Date(t),o=new Date().getTime()-s.getTime(),r=Math.floor(o/(1e3*60)),a=Math.floor(o/(1e3*60*60)),c=Math.floor(o/(1e3*60*60*24));return r<1?"just now":r<60?`${r}m ago`:a<24?`${a}h ago`:c<30?`${c}d ago`:s.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const Bl={password:Rl,oauth_google:Po,oauth_apple:Bo,solana:Mo,webauthn_passkey:Ps,webauthn_security_key:Ps,totp:Tl,sso_oidc:Il};function Ml(){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 Rl(){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 Po(){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 Bo(){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 Mo(){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 Ps(){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 Tl(){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 Il(){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 Dl{client;constructor(s,n,o,r){this.client=new T.ApiClient({baseUrl:s,timeoutMs:n,retryAttempts:o,getAccessToken:r})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(s){throw T.handleApiError(s,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(s){throw T.handleApiError(s,"Failed to revoke sessions")}}}function Ro(){const{config:t,authState:s,_internal:n}=T.useCedrosLogin(),[o,r]=d.useState([]),[a,c]=d.useState(!1),[i,l]=d.useState(null),u=d.useMemo(()=>new Dl(t.serverUrl,t.requestTimeout,t.retryAttempts,n?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,n]),f=d.useCallback(async()=>{if(s!=="authenticated"){r([]);return}c(!0),l(null);try{const b=await u.listSessions();r(b)}catch(b){l(b)}finally{c(!1)}},[s,u]);d.useEffect(()=>{s==="authenticated"?f():r([])},[s,f]);const h=d.useCallback(async()=>{c(!0),l(null);try{const b=await u.revokeAllSessions();return await f(),b}catch(b){throw l(b),b}finally{c(!1)}},[u,f]),p=d.useMemo(()=>o.filter(b=>!b.isCurrent).length,[o]);return{sessions:o,isLoading:a,error:i,fetchSessions:f,revokeAllSessions:h,otherSessionCount:p}}const _l={profile:"Profile",security:"Security",linked:"Linked Accounts"},Ul=["profile","security","linked"];function Fl({defaultTab:t="profile",onClose:s,onPasswordChange:n,onTotpChange:o,onLinkGoogle:r,onLinkApple:a,onAddPasskey:c,onLinkSolana:i,className:l=""}){const[u,f]=d.useState(t),{sessions:h,isLoading:p,error:b,revokeAllSessions:w}=Ro();return e.jsxs("div",{className:`cedros-account-settings ${l}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:Ul.map(m=>e.jsx("button",{type:"button",role:"tab","aria-selected":u===m,className:`cedros-account-tab ${u===m?"cedros-account-tab-active":""}`,onClick:()=>f(m),children:_l[m]},m))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[u==="profile"&&e.jsx(So,{onPasswordChange:n}),u==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Co,{onStatusChange:o}),e.jsx(oo,{sessions:h,isLoading:p,error:b??void 0,onRevokeAll:async()=>{await w()}})]}),u==="linked"&&e.jsx(Lo,{onLinkGoogle:r,onLinkApple:a,onAddPasskey:c,onLinkSolana:i})]}),s&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:s,children:"Close"})})]})}function Ol({onComplete:t,className:s}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${s??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(Qs,{onSuccess:t})})]})}function Wl({onComplete:t,onSkip:s,className:n}){const{user:o}=I.useAuth(),{isLoading:r,error:a,updateProfile:c,clearError:i}=tt(),[l,u]=d.useState(o?.name??""),f=d.useCallback(async p=>{p.preventDefault(),i();const b=l.trim();if(!b){t?.();return}try{await c({name:b}),t?.()}catch{}},[l,c,i,t]),h=l.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${n??""}`,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:f,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:p=>u(p.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),a&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:a.message}),e.jsxs("div",{className:"cedros-complete-account__actions",children:[e.jsx("button",{type:"submit",className:"cedros-complete-account__button cedros-complete-account__button--primary",disabled:r||!h,children:r?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:s,disabled:r,children:"Skip"})]})]})]})}function To(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(!1),[r,a]=d.useState(null),c=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),i=d.useCallback(async f=>await c.get(`/username/available?username=${encodeURIComponent(f)}`,{credentials:"include"}),[c]),l=d.useCallback(async()=>{try{return(await c.get("/username/available?username=",{credentials:"include"})).suggestion??null}catch{return null}},[c]),u=d.useCallback(async f=>{o(!0),a(null);try{await c.patch("/me",{username:f})}catch(h){const p=h instanceof Error?h:new Error(String(h));throw a(p),p}finally{o(!1)}},[c]);return{checkAvailability:i,getSuggestion:l,setUsername:u,isLoading:n,error:r}}function ql({onComplete:t,onSkip:s,className:n}){const{checkAvailability:o,getSuggestion:r,setUsername:a,isLoading:c,error:i}=To(),[l,u]=d.useState(""),[f,h]=d.useState("idle"),[p,b]=d.useState(""),w=d.useRef(null),m=d.useRef(!0);d.useEffect(()=>(m.current=!0,r().then(j=>{m.current&&j&&(u(j),h("available"),b("Available"))}),()=>{m.current=!1}),[r]);const k=d.useCallback(j=>{const C=j.toLowerCase().replace(/[^a-z0-9_]/g,"");if(u(C),h("idle"),b(""),w.current&&clearTimeout(w.current),C.length<3){C.length>0&&(h("error"),b("At least 3 characters"));return}h("checking"),w.current=setTimeout(async()=>{try{const P=await o(C);if(!m.current)return;P.error?(h("error"),b(P.error)):P.available?(h("available"),b("Available")):(h("taken"),b("Already taken"),P.suggestion)}catch{if(!m.current)return;h("error"),b("Could not check availability")}},400)},[o]),x=d.useCallback(async j=>{if(j.preventDefault(),!(f!=="available"||!l.trim()))try{await a(l.trim()),t?.()}catch{}},[l,f,a,t]),N=f==="available"&&!c;return e.jsxs("div",{className:`cedros-choose-username ${n??""}`,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:x,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:j=>k(j.target.value),placeholder:"swift_falcon_42",className:"cedros-choose-username__input",maxLength:30,autoFocus:!0,autoComplete:"off",spellCheck:!1})]}),p&&e.jsx("span",{className:`cedros-choose-username__status cedros-choose-username__status--${f}`,role:f==="error"||f==="taken"?"alert":void 0,children:f==="checking"?"Checking...":p})]}),i&&e.jsx("div",{className:"cedros-choose-username__error",role:"alert",children:i.message}),e.jsxs("div",{className:"cedros-choose-username__actions",children:[e.jsx("button",{type:"submit",className:"cedros-choose-username__button cedros-choose-username__button--primary",disabled:!N,children:c?"Saving...":"Continue"}),e.jsx("button",{type:"button",className:"cedros-choose-username__button cedros-choose-username__button--secondary",onClick:s,disabled:c,children:"Skip"})]})]})]})}function Io(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(!1),[o,r]=d.useState(null),a=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(()=>{r(null)},[]),i=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(w)||w<=0){const m=new Error(`Invalid deposit amount: ${w}. Must be a positive integer (lamports).`);throw r(m.message),m}n(!0),r(null);try{return await a.post("/deposit",{amount_lamports:w})}catch(m){const k=T.handleApiError(m,"Failed to execute deposit");throw r(k.message),k}finally{n(!1)}},[a]),l=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");return await a.get(`/deposit/status/${encodeURIComponent(w)}`)},[a]),u=d.useCallback(async()=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.get("/deposit/config")}catch(w){const m=T.handleApiError(w,"Failed to get deposit config");throw r(m.message),m}finally{n(!1)}},[a]),f=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{const m=new URLSearchParams;w?.limit!==void 0&&m.set("limit",String(w.limit)),w?.offset!==void 0&&m.set("offset",String(w.offset));const k=m.toString(),x=k?`/deposits?${k}`:"/deposits";return await a.get(x)}catch(m){const k=T.handleApiError(m,"Failed to list deposits");throw r(k.message),k}finally{n(!1)}},[a]),h=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{const m=new URLSearchParams({input_mint:w.inputMint,amount:String(w.amount),taker:w.taker});return await a.get(`/deposit/quote?${m}`)}catch(m){const k=T.handleApiError(m,"Failed to get deposit quote");throw r(k.message),k}finally{n(!1)}},[a]),p=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.post("/deposit/public",w)}catch(m){const k=T.handleApiError(m,"Failed to execute public deposit");throw r(k.message),k}finally{n(!1)}},[a]),b=d.useCallback(async w=>{if(!a)throw new Error("useDeposit must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.post("/deposit/micro",w)}catch(m){const k=T.handleApiError(m,"Failed to execute micro deposit");throw r(k.message),k}finally{n(!1)}},[a]);return{deposit:i,getQuote:h,publicDeposit:p,microDeposit:b,getStatus:l,getConfig:u,listDeposits:f,isLoading:s,error:o,clearError:c}}function Ys({tokens:t,selectedToken:s,onSelect:n,openSignal:o,placeholder:r="Select token",disabled:a=!1,className:c="",searchable:i=!0}){const[l,u]=d.useState(!1),[f,h]=d.useState(""),p=d.useRef(null),b=d.useRef(null),w=d.useMemo(()=>{if(!f.trim())return t;const N=f.toLowerCase();return t.filter(j=>j.symbol.toLowerCase().includes(N)||j.name.toLowerCase().includes(N)||j.mint.toLowerCase().includes(N))},[t,f]);d.useEffect(()=>{const N=j=>{p.current&&!p.current.contains(j.target)&&(u(!1),h(""))};if(l)return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[l]),d.useEffect(()=>{l&&i&&b.current&&b.current.focus()},[l,i]),d.useEffect(()=>{o===void 0||a||(u(!0),h(""))},[o,a]);const m=d.useCallback(()=>{a||(u(N=>!N),l&&h(""))},[a,l]),k=d.useCallback(N=>{n(N),u(!1),h("")},[n]),x=d.useCallback(N=>{N.key==="Escape"?(u(!1),h("")):N.key==="Enter"&&w.length===1&&k(w[0])},[w,k]);return e.jsxs("div",{ref:p,className:`cedros-token-selector ${l?"cedros-token-selector-open":""} ${a?"cedros-token-selector-disabled":""} ${c}`,onKeyDown:x,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:m,disabled:a,"aria-haspopup":"listbox","aria-expanded":l,children:[s?e.jsxs("span",{className:"cedros-token-selector-selected",children:[s.logoUrl&&e.jsx("img",{src:s.logoUrl,alt:s.symbol,className:"cedros-token-icon",onError:N=>{N.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:s.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:r}),e.jsx("span",{className:"cedros-token-selector-arrow",children:l?"▲":"▼"})]}),l&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[i&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:b,type:"text",value:f,onChange:N=>h(N.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:w.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:w.map(N=>e.jsxs("button",{type:"button",className:`cedros-token-option ${s?.mint===N.mint?"cedros-token-option-selected":""}`,onClick:()=>k(N),role:"option","aria-selected":s?.mint===N.mint,children:[N.logoUrl&&e.jsx("img",{src:N.logoUrl,alt:N.symbol,className:"cedros-token-icon",onError:j=>{j.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:N.symbol}),e.jsx("span",{className:"cedros-token-name",children:N.name})]}),s?.mint===N.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},N.mint))})})]})]})}function Lt(t,s){return s.privateDepositsEnabled&&t>=s.privateMinUsd?"private":t>=s.publicMinUsd?"public":"sol_micro"}const Zs="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=",zl=1e4,kt=1e3,Do=3;function Hl(t){return Number.isFinite(t)?`$${Math.round(t)}`:"$0"}function Vl(t,s){switch(t){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${Hl(s.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function Xs(t,s,n){return Math.min(Math.max(t,s),n)}function $l(t,s){if(s<=0)return 0;const n=Xs(t/s,0,1);return Math.round(Math.pow(n,1/Do)*kt)}function Gl(t,s){const n=Xs(t/kt,0,1);return s*Math.pow(n,Do)}function _o(t){return t<10?.01:t<100?1:t<500?5:t<1e3?10:t<5e3?25:50}function Ql(t){return t<1?2:0}function un(t){const s=_o(t),n=Math.round(t/s)*s,o=Ql(s);return Number(n.toFixed(o))}function Js({config:t,valueUsd:s,onChange:n,maxUsd:o=zl,disabled:r=!1,className:a=""}){const c=Xs(Number.isFinite(s)?s:0,0,o),i=d.useMemo(()=>Lt(c,t),[c,t]),l=Vl(i,t),u=$l(c,o),f=u/kt*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:c||"",onChange:h=>n(un(Math.max(0,Math.min(parseFloat(h.target.value)||0,o)))),placeholder:"Enter amount",disabled:r,min:0,step:_o(c),className:"cedros-deposit-flow-input cedros-tiered-slider-input-field","aria-label":"Deposit amount"})]}),e.jsxs("div",{className:"cedros-tiered-slider-tier",children:[e.jsxs("span",{className:`cedros-tiered-slider-badge cedros-tiered-slider-badge-${i}`,children:[i==="sol_micro"&&e.jsx("img",{src:Zs,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:kt,step:1,value:u,onChange:h=>n(un(Gl(parseFloat(h.target.value),o))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${f}%, var(--cedros-border) ${f}%, var(--cedros-border) 100%)`},disabled:r,"aria-label":"Deposit amount slider"}),l.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:l.note})]})}const Kl="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=",Yl="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==",Zl="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",Xl="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==",Jl="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==",ed="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==",td="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",sd="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",rd="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 Uo(t){const s=t.toUpperCase();return Pt.find(o=>o.symbol===s)?.decimals??6}function nd(t,s){const n=t.toUpperCase(),r=Pt.find(a=>a.symbol===n)?.decimals??s;return r===void 0?2:n==="SOL"?4:r===6&&n!=="SOL"?2:r>6?6:r}const Pt=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Zs},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:ed},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:rd},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:Zl},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:sd},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Jl},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:td},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Yl},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Kl},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:Xl}];function od(t){return t.companyFeePercent>0||t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap"||t.feePolicy==="user_pays_privacy"}function ad(t,s,n){const{feePolicy:o,privacyFeePercent:r,swapFeePercent:a,companyFeePercent:c}=t;let i=c;return n||(o==="user_pays_all"?(i+=a,s&&(i+=r)):o==="user_pays_privacy"&&s?i+=r:o==="user_pays_swap"&&(i+=a)),i}const pt=1e9,He={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:Zs},Ve={mint:"other",symbol:"OTHER",name:"Other",decimals:6},Fo=1e4;function id(t,s){const n=s<t.publicMinUsd,o=s>=t.privateMinUsd,r=[],a=!n&&o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(t.privacyFeeFixedLamports>0||t.privacyFeePercent>0),c=!n&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(t.swapFeeFixedLamports>0||t.swapFeePercent>0),i=t.companyFeeFixedLamports>0||t.companyFeePercent>0;if(a){const l=t.privacyFeeFixedLamports/pt,u=t.privacyFeePercent,f=l*t.solPriceUsd,h=s*(u/100);r.push({label:"Privacy",solAmount:l,percent:u,usdAmount:f+h})}if(c){const l=t.swapFeeFixedLamports/pt,u=t.swapFeePercent,f=l*t.solPriceUsd,h=s*(u/100);r.push({label:"Swap",solAmount:l,percent:u,usdAmount:f+h})}if(i){const l=t.companyFeeFixedLamports/pt,u=t.companyFeePercent,f=l*t.solPriceUsd,h=s*(u/100);r.push({label:"Service",solAmount:l,percent:u,usdAmount:f+h})}return r}function Oo(t,s,n){const o=id(t,s),r=n===0?0:n<.01?.01:n;if(o.length===0)return n===0?"No fees":`Total: $${r.toFixed(2)}`;const a=o.reduce((w,m)=>w+m.solAmount,0),c=o.reduce((w,m)=>w+m.percent,0),i={fee:7,sol:8,rate:7,usd:8},l=w=>{const m=w.label.padEnd(i.fee),k=w.solAmount.toFixed(4).padStart(6).padEnd(i.sol),x=(w.percent.toFixed(2)+"%").padStart(5).padEnd(i.rate),j=("$"+(w.usdAmount===0?0:Math.max(w.usdAmount,.01)).toFixed(2)).padEnd(i.usd);return`${m} │ ${k} │ ${x} │ ${j}`},u=`${"Fee".padEnd(i.fee)} │ ${"SOL".padEnd(i.sol)} │ ${"+ Rate".padEnd(i.rate)} │ ${"= Total".padEnd(i.usd)}`,f=`${"─".repeat(i.fee)}─┼─${"─".repeat(i.sol)}─┼─${"─".repeat(i.rate)}─┼─${"─".repeat(i.usd)}`,h=("$"+r.toFixed(2)).padEnd(i.usd),p=`${"TOTAL".padEnd(i.fee)} │ ${a.toFixed(4).padStart(6).padEnd(i.sol)} │ ${(c.toFixed(2)+"%").padStart(5).padEnd(i.rate)} │ ${h}`;return[u,f,...o.map(l),f,p].join(`
2059
+ `)}function cd(t){const s=[],n=t.privacyFeeFixedLamports>0||t.privacyFeePercent>0,o=t.swapFeeFixedLamports>0||t.swapFeePercent>0,r=t.companyFeeFixedLamports>0||t.companyFeePercent>0;return n&&s.push("Privacy Cash fee"),o&&s.push("swap fee"),r&&s.push("company service fee"),s.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function Bt(t,s){if(s<=0)return 0;const n=s<t.publicMinUsd,o=s>=t.privateMinUsd,r=ad(t,o,n);let a=t.companyFeeFixedLamports;n||(o&&(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_privacy")&&(a+=t.privacyFeeFixedLamports),(t.feePolicy==="user_pays_all"||t.feePolicy==="user_pays_swap")&&(a+=t.swapFeeFixedLamports));const c=a/pt*t.solPriceUsd,i=s*(r/100);return c+i}function Wo(t,s,n){return t==="sol"?"SOL":t==="single-token"?s.symbol:n.some(r=>r.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function hn(t){return t.map(s=>s.trim()).filter(Boolean)}const ld=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function er(t,s,n){if(ld.has(t.symbol))return 1;const o=s.tokenPrices?.[t.symbol];if(o&&o>0)return o;if(t.symbol==="SOL")return s.solPriceUsd||null;const r=n?.[t.symbol];return r&&r>0?r:null}function qo(t,s){return t.toFixed(nd(s))}function dd({config:t,currencyMode:s,depositMethod:n,tokens:o=[],defaultToken:r,minAmount:a,maxAmount:c=1e4,onSuccess:i,onError:l,onCancel:u,onUnlockRequired:f,onAuthorize:h,className:p="",showStepIndicator:b=!0,pollInterval:w=5e3,demoMode:m=!1,demoAutoConfirmMs:k,tokenPriceUsd:x,showExplainer:N=!1,siteName:j,explainerConfig:C}){const{deposit:P,getStatus:g,error:v,clearError:A}=Io(),y=I.useWallet(),S=hn(t.quickActionTokens),E=hn(t.customTokenSymbols),B=d.useMemo(()=>{const O=t.customTokens??[];if(O.length===0)return o;const G=new Set(o.map(Z=>Z.symbol)),K=[...o];for(const Z of O)G.has(Z.symbol)||(K.push({mint:Z.mint,symbol:Z.symbol,name:Z.symbol,decimals:Z.decimals,logoUrl:Z.logoUrl}),G.add(Z.symbol));return K},[o,t.customTokens]),L=d.useMemo(()=>{if(E.length===0)return B;const O=B.filter(G=>E.includes(G.symbol));return O.length>0?O:B},[B,E]),M=t.privateDepositsEnabled,R=n?n==="sign"&&!M?"receive":n:M&&y.hasExternalWallet?"sign":"receive",U=S[0]?B.find(O=>O.symbol===S[0]):void 0,F=s==="sol"?He:s==="single-token"?U??B.find(O=>O.symbol==="USDC")??B[0]??He:r??U??B.find(O=>O.symbol==="USDC")??B.find(O=>O.symbol!=="SOL")??B[0]??He,q=d.useCallback(()=>N?"explainer":"unlock",[N]),[W,D]=d.useState(q),[_,$]=d.useState(F),[J,oe]=d.useState(""),[be,fe]=d.useState(null),[V,H]=d.useState(null),[Y,de]=d.useState(null),[ve,nr]=d.useState(null),[Mt,Ge]=d.useState(!1),[Vo,Rt]=d.useState(!1),[st,or]=d.useState(null),_e=d.useRef(null);d.useEffect(()=>()=>{_e.current&&clearTimeout(_e.current)},[]),d.useEffect(()=>{D(q()),$(F),oe(""),fe(null),H(null),de(null),nr(null),Ge(!1),Rt(!1),or(null),A()},[s,R,F,A]);const $o=a??t.privateMinSol,Go=c,rt=parseFloat(J),ar=y.status==="enrolled_locked"||y.status==="enrolled_unlocked"||y.status==="unlocked",Tt=ar&&y.isUnlocked,It=ar&&!y.isUnlocked,ir=d.useCallback(()=>{let K=R==="sign"?[{key:"unlock",label:"Authorize"},{key:"confirm",label:"Send"},{key:"signing",label:"Signing"},{key:"success",label:"Complete"}]:[{key:"unlock",label:"Authorize"},{key:"show-address",label:"Send"},{key:"waiting",label:"Confirming"},{key:"success",label:"Complete"}];return N&&(K=[{key:"explainer",label:"Info"},...K]),K},[R,N])(),Qo=ir.findIndex(O=>O.key===W),cr=d.useCallback(O=>{$(O)},[]),Ko=d.useCallback(async O=>{if(!h){D(R==="sign"?"confirm":"show-address");return}Rt(!0),H(null);try{const K=await h(O,R==="sign"?rt:null,_);de(K.sessionId),nr(K.depositAddress),D(R==="sign"?"confirm":"show-address")}catch(G){const K=G instanceof Error?G:new Error("Authorization failed");H(K.message)}finally{Rt(!1)}},[h,R,rt,_]),Yo=d.useCallback(async(O,G)=>{A(),H(null),D("signing");const K=O??rt,Z=G??_;if(!m){if(It&&f){f(),D("confirm");return}if(!Tt){H("Wallet not ready"),D("error");return}}try{const ue=Math.round(K*Math.pow(10,Z.decimals));if(m){await new Promise(_t=>setTimeout(_t,1500));const pe={token:s==="sol"?null:Z,amount:K,amountSmallestUnit:ue,txSignature:`demo-tx-${Date.now()}`,sessionId:Y||`demo-session-${Date.now()}`,response:{sessionId:Y||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:ue,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};fe(pe),D("success"),i?.(pe);return}const je=await P(ue),Qe={token:s==="sol"?null:Z,amount:K,amountSmallestUnit:ue,txSignature:je.txSignature,sessionId:je.sessionId,response:je,method:"sign"};fe(Qe),D("success"),i?.(Qe)}catch(ue){const je=ue instanceof Error?ue:new Error("Deposit failed");H(je.message),D("error"),l?.(je)}},[P,rt,_,s,m,Y,Tt,It,f,i,l,A]),Zo=d.useCallback(()=>{D("waiting")},[]),Dt=d.useCallback(async()=>{const O=ve||y.solanaPubkey;if(O){_e.current&&clearTimeout(_e.current);try{await navigator.clipboard.writeText(O),Ge(!0),_e.current=setTimeout(()=>Ge(!1),2e3)}catch{const G=document.createElement("textarea");G.value=O,document.body.appendChild(G),G.select(),document.execCommand("copy"),document.body.removeChild(G),Ge(!0),_e.current=setTimeout(()=>Ge(!1),2e3)}}},[ve,y.solanaPubkey]);d.useEffect(()=>{if(!(W==="confirm"||W==="show-address"||W==="waiting")||!Y||m)return;let G=!1,K=0,Z=0;const ue=360,je=5,Qe=async()=>{if(!(G||K>=ue)){K++;try{const pe=await g(Y);if(Z=0,pe.status==="completed"||pe.status==="detected"){const _t=pe.amountLamports?pe.amountLamports/Math.pow(10,_.decimals):0,Jo=pe.amountLamports||0,lr={token:s==="sol"?null:_,amount:_t,amountSmallestUnit:Jo,txSignature:pe.txSignature||"",sessionId:Y,response:pe,method:"receive",depositAddress:y.solanaPubkey??void 0};fe(lr),D("success"),i?.(lr);return}}catch{if(Z++,Z>=je){H("Unable to check deposit status. Please check your connection and try again.");return}}G||setTimeout(Qe,w)}};return Qe(),()=>{G=!0}},[W,Y,m,g,_,s,y.solanaPubkey,i,w]),d.useEffect(()=>{if(!m||!k||W!=="waiting"||R!=="receive"||!ve)return;const O=window.setTimeout(()=>{const G=st??t.privateMinUsd,K=_.symbol==="SOL"&&t.solPriceUsd>0?G/t.solPriceUsd:G,Z=Math.round(K*Math.pow(10,_.decimals)),ue={token:s==="sol"?null:_,amount:K,amountSmallestUnit:Z,txSignature:`demo-tx-${Date.now()}`,sessionId:Y||`demo-session-${Date.now()}`,response:{sessionId:Y||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:Z,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:ve??void 0};fe(ue),D("success"),i?.(ue)},k);return()=>window.clearTimeout(O)},[m,k,W,R,ve,st,t,_,s,Y,i]);const Xo=d.useCallback(()=>{D(q()),oe(""),fe(null),H(null),A()},[q,A]);return t.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${p}`,children:[b&&W!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:ir.map((O,G)=>{const K=Qo>=G,Z=O.key===W;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${K?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${K?"active":""} ${Z?"current":""}`,children:G+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${K?"active":""}`,children:O.label})]},O.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[W==="explainer"&&e.jsx(ud,{siteName:j,config:C,depositConfig:t,currencyMode:s,token:_,tokens:L,onContinue:()=>D("unlock"),onCancel:u}),W==="unlock"&&e.jsx(hd,{token:_,tokens:L,currencyMode:s,depositMethod:R,isAuthorizing:Vo,error:V,onAuthorize:Ko,onBack:N?()=>D("explainer"):void 0,onCancel:u}),W==="confirm"&&R==="sign"&&e.jsx(fd,{token:_,tokens:B,quickActionSymbols:S,customTokenSymbols:E,currencyMode:s,minAmount:$o,maxAmount:Go,depositAddress:ve||y.solanaPubkey,walletReady:Tt||m,needsUnlock:It&&!m,copied:Mt,isListening:!!Y&&!m,config:t,onCopy:Dt,onTokenSelect:cr,onUnlockRequired:f,onConfirm:(O,G)=>Yo(O,G),onBack:()=>D("unlock"),onCancel:u}),W==="signing"&&e.jsx(pd,{depositAddress:y.solanaPubkey}),W==="show-address"&&e.jsx(md,{token:_,tokens:B,quickActionSymbols:S,customTokenSymbols:E,tokenPriceUsd:x,currencyMode:s,depositAddress:ve||y.solanaPubkey,copied:Mt,isListening:!!Y&&!m,config:t,onCopy:Dt,onTokenSelect:cr,onAmountChange:or,onSent:Zo,onBack:()=>D("unlock"),onCancel:u}),W==="waiting"&&e.jsx(gd,{token:_,depositAddress:ve||y.solanaPubkey,copied:Mt,feeLine:st?(()=>{const O=Bt(t,st);return O===0?"No fees":`Fees: $${Math.max(O,.01).toFixed(2)} total`})():"Fees: calculated after deposit",onCopy:Dt}),W==="success"&&be&&e.jsx(wd,{result:be,config:t,onNewDeposit:Xo}),W==="error"&&e.jsx(bd,{error:V||v||"An error occurred",onRetry:()=>D("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${p}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function ud({siteName:t,config:s,depositConfig:n,currencyMode:o,token:r,tokens:a,onContinue:c,onCancel:i}){const l=s?.title??"How Deposits Work",u=s?.exchangeName??"Coinbase",f=Bs.sanitizeExternalUrl(s?.exchangeUrl)??"https://www.coinbase.com",h=s?.showExchangeSuggestion!==!1,p=Wo(o,r,a),b=t?`${t} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",w=s?.body??b,m=od(n),k=cd(n);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:w}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:m?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:k})]})]})]}),h&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",p," using your credit card at"," ",e.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",children:u}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[i&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:i,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:c,children:"Continue"})]})]})}function hd({token:t,tokens:s,currencyMode:n,depositMethod:o,isAuthorizing:r,error:a,onAuthorize:c,onBack:i}){const[l,u]=d.useState(""),f=Wo(n,t,s),h=p=>{p.preventDefault(),l.trim()&&(c(l),u(""))};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"?n==="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 ${f} deposit. This allows us to process your withdrawal when the privacy period ends.`:n==="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 ${f} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:h,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:p=>u(p.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:r,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:i,disabled:r,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!l.trim()||r,children:r?"Authorizing...":"Continue"})]})]})]})}function fd({token:t,tokens:s,quickActionSymbols:n,customTokenSymbols:o,currencyMode:r,minAmount:a,maxAmount:c,depositAddress:i,walletReady:l,needsUnlock:u,copied:f,isListening:h,config:p,onCopy:b,onTokenSelect:w,onUnlockRequired:m,onConfirm:k,onBack:x}){const[N,j]=d.useState(p.privateMinUsd),[C,P]=d.useState(!1),[g,v]=d.useState(!1),[A,y]=d.useState(0),[S,E]=d.useState(null),L=Lt(N,p)==="sol_micro",M=t.symbol===Ve.symbol,R=d.useMemo(()=>{const V=o.length===0?s:s.filter(de=>o.includes(de.symbol)),H=V.length>0?V:s;return H.some(de=>de.symbol===Ve.symbol)?H:[...H,Ve]},[s,o]),U=Bt(p,N),F=U===0?0:U<.01?.01:U,q=M?"Fees: calculated after deposit":U===0?"No fees":`Fees: $${F.toFixed(2)} total`,W=M?"":Oo(p,N,U),D=er(L?He:t,p),_=D?N/D:t.symbol==="SOL"&&p.solPriceUsd>0?N/p.solPriceUsd:null,$=_!=null?qo(_,L?"SOL":t.symbol):null,oe=N-U<=0&&N>0,be=!M&&N>0&&!oe&&_!=null&&_>=a&&_<=c;d.useEffect(()=>{if(r==="multi-token")if(L&&t.symbol!=="SOL"){E(t);const V=s.find(H=>H.symbol==="SOL");V&&w(V)}else!L&&S&&t.symbol==="SOL"&&(w(S),E(null))},[L,t.symbol,r,s,w,S,t]);const fe=()=>{be&&_!=null&&k(_,t)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),r==="multi-token"&&!L&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[n.map(V=>{const H=s.find(de=>de.symbol===V),Y=t.symbol===V;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${Y?"is-active":""}`,onClick:()=>{H&&(P(!1),w(H))},disabled:!H,children:[H?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:H.logoUrl,alt:`${V} logo`}),V]},V)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${C?"is-active":""}`,onClick:()=>{P(!0),y(V=>V+1)},children:"Custom"})]}),C&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Ys,{tokens:R,selectedToken:t,onSelect:w,openSignal:A})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(Js,{config:p,valueUsd:N,onChange:j,maxUsd:Fo})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:M?"Sign to send tokens to this address":`Sign to send ${$??"--"} ${L?"SOL":t.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:i||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:b,title:"Copy address",disabled:!i,children:f?"✓":"⧉"}),i&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${i}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),f&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),oe&&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:[q,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${g?"is-open":""}`,"data-tooltip":W,"aria-label":`Fee breakdown: ${W.replaceAll(`
2060
+ `,", ")}`,"aria-expanded":g,onClick:V=>{V.stopPropagation(),v(H=>!H)},onBlur:()=>v(!1),onKeyDown:V=>{V.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 network confirmation."})]})]}),h&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for incoming transfers. We will confirm automatically."}),u&&e.jsxs("div",{className:"cedros-deposit-flow-warning",children:[e.jsx("p",{children:"Your wallet is locked. Unlock it to continue."}),m&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:m,children:"Unlock Wallet"})]}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:x,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:fe,disabled:!be||!l||!i,children:"Deposit"})]})]})}function pd({depositAddress:t}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Signing Transfer"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Approve the transfer in your wallet extension..."}),t&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[t.slice(0,6),"...",t.slice(-4)]})]})]})}function md({token:t,tokens:s,quickActionSymbols:n,customTokenSymbols:o,tokenPriceUsd:r,currencyMode:a,depositAddress:c,copied:i,isListening:l,config:u,onCopy:f,onTokenSelect:h,onAmountChange:p,onSent:b,onBack:w}){const[m,k]=d.useState(u.privateMinUsd),[x,N]=d.useState(!1),[j,C]=d.useState(!1),[P,g]=d.useState(0),[v,A]=d.useState(null),S=Lt(m,u)==="sol_micro",E=t.symbol===Ve.symbol,B=d.useMemo(()=>{const _=o.length===0?s:s.filter(oe=>o.includes(oe.symbol)),$=_.length>0?_:s;return $.some(oe=>oe.symbol===Ve.symbol)?$:[...$,Ve]},[s,o]),L=Bt(u,m),M=L===0?0:L<.01?.01:L,R=E?"Fees: calculated after deposit":L===0?"No fees":`Fees: $${M.toFixed(2)} total`,U=E?"":Oo(u,m,L),F=E||m>0,q=er(S?He:t,u,r),W=q?m/q:null,D=W?qo(W,t.symbol):null;return d.useEffect(()=>{if(a==="multi-token")if(S&&t.symbol!=="SOL"){A(t);const _=s.find($=>$.symbol==="SOL");_&&h(_)}else!S&&v&&t.symbol==="SOL"&&(h(v),A(null))},[S,t.symbol,a,s,h,v,t]),d.useEffect(()=>{p(m)},[m,p]),c?e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Send Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Send funds to your deposit address. We'll confirm automatically."}),a==="multi-token"&&!S&&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:[n.map(_=>{const $=s.find(oe=>oe.symbol===_),J=t.symbol===_;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${J?"is-active":""}`,onClick:()=>{$&&(N(!1),h($))},disabled:!$,children:[$?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:$.logoUrl,alt:`${_} logo`}),_]},_)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${x?"is-active":""}`,onClick:()=>{N(!0),g(_=>_+1)},children:"Custom"})]}),x&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(Ys,{tokens:B,selectedToken:t,onSelect:h,openSignal:P})})]}),!E&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(Js,{config:u,valueUsd:m,onChange:k,maxUsd:Fo})]}),E&&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:E?"Send any token to this address":`Send ${D??"--"} ${S?"SOL":t.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:c}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:f,title:"Copy address",children:i?"✓":"📋"})]}),i&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[R,!E&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${j?"is-open":""}`,"data-tooltip":U,"aria-label":`Fee breakdown: ${U.replaceAll(`
2061
+ `,", ")}`,"aria-expanded":j,onClick:_=>{_.stopPropagation(),C($=>!$)},onBlur:()=>C(!1),onKeyDown:_=>{_.key==="Escape"&&C(!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:w,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:b,disabled:!F,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function gd({token:t,depositAddress:s,copied:n,feeLine:o,onCopy:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:t.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),s&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[s.slice(0,6),"...",s.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:r,title:"Copy address",children:n?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${s}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:o})]})]})]})]})}function wd({result:t,config:s,onNewDeposit:n}){const o=t.token??He,r=er(o,s),a=r?t.amount*r:t.amount,c=Bt(s,a),i=Math.max(a-c,0),l=c===0?0:c<.01?.01:c;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",t.amount.toLocaleString()," ",o.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[t.txSignature&&e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[t.txSignature.slice(0,8),"...",t.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${t.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",a.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",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:["+$",i.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:n,children:"Make Another Deposit"})})]})}function bd({error:t,onRetry:s,onCancel:n}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:t}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[n&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:n,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:s,children:"Try Again"})]})]})}function tr(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(!1),[o,r]=d.useState(null),a=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),c=d.useCallback(()=>{r(null)},[]),i=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");n(!0),r(null);try{return await a.get("/credits/balance/sol")}catch(f){const h=T.handleApiError(f,"Failed to fetch credit balance");throw r(h.message),h}finally{n(!1)}},[a]),l=d.useCallback(async()=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");n(!0),r(null);try{return(await a.get("/credits/balance")).balances}catch(f){const h=T.handleApiError(f,"Failed to fetch credit balances");throw r(h.message),h}finally{n(!1)}},[a]),u=d.useCallback(async f=>{if(!a)throw new Error("useCredits must be used within a CedrosLoginProvider");n(!0),r(null);try{const h=new URLSearchParams;f?.currency&&h.set("currency",f.currency),f?.limit!==void 0&&h.set("limit",f.limit.toString()),f?.offset!==void 0&&h.set("offset",f.offset.toString());const p=h.toString(),b=p?`/credits/history?${p}`:"/credits/history";return await a.get(b)}catch(h){const p=T.handleApiError(h,"Failed to fetch transaction history");throw r(p.message),p}finally{n(!1)}},[a]);return{getBalance:i,getAllBalances:l,getHistory:u,isLoading:s,error:o,clearError:c}}function yd({showAllCurrencies:t=!1,refreshInterval:s=0,compact:n=!1,className:o="",onLoad:r}){const{getBalance:a,getAllBalances:c,isLoading:i,error:l,clearError:u}=tr(),[f,h]=d.useState([]),[p,b]=d.useState(null),w=d.useCallback(async()=>{try{if(t){const m=await c();h(m),r?.(m)}else{const m=await a();h([m]),r?.([m])}b(null)}catch(m){b(m instanceof Error?m.message:"Failed to load balance")}},[t,a,c,r]);if(d.useEffect(()=>{w()},[w]),d.useEffect(()=>{if(s<=0)return;const m=setInterval(w,s);return()=>clearInterval(m)},[s,w]),p||l)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${o}`,children:[e.jsx("p",{className:"cedros-credit-error",children:p||l}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),b(null),w()},children:"Retry"})]});if(i&&f.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(n){const m=f[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${o}`,children:[m?e.jsx("span",{className:"cedros-credit-value",title:`${m.balanceLamports} lamports`,children:m.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),i&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${o}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:w,disabled:i,title:"Refresh balance",children:i?"...":"↻"})]}),f.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:f.map(m=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:m.currency}),e.jsx("span",{className:"cedros-credit-amount",children:m.display})]},m.currency))})]})}const bs=[{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 xd(t,s){const n=t<0,o=Math.abs(t),r=Uo(s),a=o/Math.pow(10,r),c=n?"-":"+";return s.toUpperCase()==="SOL"?`${c}${a.toFixed(4)} SOL`:`${c}$${a.toFixed(2)}`}function Ad(t){const s=new Date(t),n=new Date,o=n.getTime()-s.getTime();if(o<0)return"Just now";const r=Math.floor(o/(1e3*60*60*24));if(r===0){const a=Math.floor(o/36e5);if(a===0){const c=Math.floor(o/6e4);return c<1?"Just now":`${c}m ago`}return`${a}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==n.getFullYear()?"numeric":void 0})}function vd(t){return t?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[t.toLowerCase()]||t:"Transaction"}function jd(t,s){const n=(t||"").toLowerCase();return n==="deposit"?"↓":n==="spend"||n==="usage"||n==="charge"?"↑":n==="refund"?"←":n==="bonus"||n==="credit"?"★":s?"+":"−"}function kd({defaultTab:t="all",pageSize:s=10,refreshInterval:n=0,className:o="",onLoad:r,onTransactionClick:a}){const{getHistory:c,isLoading:i,error:l,clearError:u}=tr(),[f,h]=d.useState(t),[p,b]=d.useState([]),[w,m]=d.useState(0),[k,x]=d.useState(0),[N,j]=d.useState(null),C=bs.find(L=>L.key===f)||bs[0],P=d.useMemo(()=>C.txTypes===null?p:p.filter(L=>{const M=L.txType||"";return C.txTypes.some(R=>M.toLowerCase()===R.toLowerCase())}),[p,C.txTypes]),g=d.useCallback(async()=>{try{const L=await c({limit:s*3,offset:k});b(L.transactions),m(L.total),r?.(L),j(null)}catch(L){j(L instanceof Error?L.message:"Failed to load history")}},[s,k,c,r]);d.useEffect(()=>{x(0)},[f]),d.useEffect(()=>{g()},[g]),d.useEffect(()=>{if(n<=0)return;const L=setInterval(g,n);return()=>clearInterval(L)},[n,g]);const v=C.txTypes===null?w:P.length,A=Math.ceil(v/s),y=Math.floor(k/s)+1,S=L=>{const M=(L-1)*s;x(Math.max(0,Math.min(M,Math.max(0,v-s))))},E=L=>{h(L)};if(N||l)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${o}`,children:[e.jsx("p",{className:"cedros-tx-error",children:N||l}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),j(null),g()},children:"Retry"})]});if(i&&p.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${o}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const B=L=>L.txTypes===null?p.length:p.filter(M=>{const R=M.txType||"";return L.txTypes.some(U=>R.toLowerCase()===U.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:g,disabled:i,title:"Refresh",children:i?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:bs.map(L=>{const M=B(L),R=f===L.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${R?"cedros-tx-tab-active":""}`,onClick:()=>E(L.key),children:[L.label,M>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:M})]},L.key)})}),P.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:f==="all"?"No transactions yet.":`No ${C.label.toLowerCase()} found.`}),f==="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:P.slice(0,s).map(L=>{const M=L.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${M?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>a?.(L),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),a?.(L))},role:a?"button":void 0,tabIndex:a?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${M?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:jd(L.txType,M)}),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:vd(L.txType)}),e.jsx("span",{className:`cedros-tx-amount ${M?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:xd(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:Ad(L.createdAt)})]})]})]},L.id)})}),A>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>S(y-1),disabled:y<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",y," of ",A]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>S(y+1),disabled:y>=A,children:"Next"})]})]})]})}function sr(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(!1),[o,r]=d.useState(null),[a,c]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),l=d.useCallback(()=>{r(null)},[]),u=d.useCallback(async()=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await i.get("/wallet/withdraw/balances")}catch(b){const w=T.handleApiError(b,"Failed to fetch wallet balances");throw r(w.message),w}},[i]),f=d.useCallback(async(b,w)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");n(!0),r(null);try{const m=await i.post("/wallet/withdraw/sol",{destination:b,amount_lamports:w});return c(m),m}catch(m){const k=T.handleApiError(m,"Failed to withdraw SOL");throw r(k.message),k}finally{n(!1)}},[i]),h=d.useCallback(async(b,w,m)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");n(!0),r(null);try{const k=await i.post("/wallet/withdraw/spl",{destination:b,token_mint:w,amount:m});return c(k),k}catch(k){const x=T.handleApiError(k,"Failed to withdraw token");throw r(x.message),x}finally{n(!1)}},[i]),p=d.useCallback(async(b=10,w=0)=>{if(!i)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const m=Math.max(1,Math.min(100,Math.trunc(b))),k=Math.max(0,Math.trunc(w)),x=new URLSearchParams({limit:String(m),offset:String(k)});return await i.get(`/wallet/withdraw/history?${x}`)}catch(m){const k=T.handleApiError(m,"Failed to fetch withdrawal history");throw r(k.message),k}},[i]);return{withdrawSol:f,withdrawSpl:h,getBalances:u,getHistory:p,isSubmitting:s,error:o,clearError:l,lastResult:a}}const ys="So11111111111111111111111111111111111111112",Nd={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function Cd(t){return t.length<32||t.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(t)}function xs(t){return t.length<=16?t:`${t.slice(0,6)}...${t.slice(-6)}`}function dt(t,s){return(Number(t)/Math.pow(10,s)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(s,6)})}function Sd({onSuccess:t,onError:s,onCancel:n,className:o=""}){const r=T.useCedrosLoginOptional(),{withdrawSol:a,withdrawSpl:c,getBalances:i,isSubmitting:l,error:u,clearError:f}=sr(),[h,p]=d.useState("loading"),[b,w]=d.useState([]),[m,k]=d.useState(null),[x,N]=d.useState(""),[j,C]=d.useState(""),[P,g]=d.useState(null),[v,A]=d.useState(null),[y,S]=d.useState(null),E=r?.config.solana?.network??"mainnet-beta",B=d.useMemo(()=>{if(!P?.txSignature)return"";const D=`https://explorer.solana.com/tx/${P.txSignature}`;return E==="mainnet-beta"?D:`${D}?cluster=${encodeURIComponent(E)}`},[P,E]),L=d.useMemo(()=>{if(!m||!j)return"0";const D=parseFloat(j);return isNaN(D)||D<=0?"0":Math.floor(D*Math.pow(10,m.decimals)).toString()},[j,m]);d.useEffect(()=>{if(!r)return;let D=!1;return(async()=>{try{const _=await i();if(D)return;const $=[];_.solLamports>0&&$.push({symbol:"SOL",mint:ys,decimals:9,rawBalance:String(_.solLamports),displayBalance:dt(String(_.solLamports),9)});for(const J of _.tokens){const oe=Nd[J.mint]??xs(J.mint);$.push({symbol:oe,mint:J.mint,decimals:J.decimals,rawBalance:J.amount,displayBalance:dt(J.amount,J.decimals)})}w($),p(($.length>0,"select"))}catch{D||(S("Failed to load wallet balances"),p("select"))}})(),()=>{D=!0}},[r,i]);const M=d.useCallback(D=>{k(D),p("form"),f(),A(null),C("")},[f]),R=d.useCallback(()=>{if(!m)return;const D=Number(m.rawBalance)/Math.pow(10,m.decimals);m.mint===ys?C(String(Math.max(0,D-.01))):C(String(D))},[m]),U=d.useCallback(()=>{if(A(null),!x.trim()){A("Destination address is required");return}if(!Cd(x.trim())){A("Invalid Solana address");return}if(!j||parseFloat(j)<=0||isNaN(parseFloat(j))){A("Please enter a valid amount");return}if(L==="0"){A("Amount is too small");return}p("confirm")},[x,j,L]),F=d.useCallback(async()=>{if(m){p("processing"),f();try{let D;m.mint===ys?D=await a(x.trim(),Number(L)):D=await c(x.trim(),m.mint,L),g(D),p("success"),t?.(D)}catch(D){p("confirm"),s?.(D instanceof Error?D:new Error(String(D)))}}},[m,x,L,a,c,f,t,s]),q=d.useCallback(()=>{f(),A(null),h==="form"?(p("select"),k(null),C(""),N("")):h==="confirm"&&p("form")},[h,f]),W=d.useCallback(()=>{p("select"),k(null),N(""),C(""),g(null),f(),A(null)},[f]);return r?e.jsxs("div",{className:`cedros-withdrawal ${o}`,children:[h==="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..."})]}),h==="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"})]}),y&&e.jsx(X.ErrorMessage,{error:y}),b.length===0&&!y&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:b.map(D=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>M(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))}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:n,children:"Cancel"})]}),h==="form"&&m&&e.jsxs("div",{className:"cedros-withdrawal-form",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:q,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",m.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",m.displayBalance," ",m.symbol]}),e.jsxs("div",{className:"cedros-withdrawal-field",children:[e.jsx("label",{className:"cedros-label",htmlFor:"cedros-withdrawal-destination",children:"Destination Address"}),e.jsx("input",{id:"cedros-withdrawal-destination",type:"text",className:"cedros-input",placeholder:"Solana address (base58)",value:x,onChange:D=>N(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 (",m.symbol,")"]}),e.jsxs("div",{className:"cedros-withdrawal-amount-row",children:[e.jsx("input",{id:"cedros-withdrawal-amount",type:"number",className:"cedros-input",placeholder:"0.00",value:j,onChange:D=>C(D.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:R,children:"Max"})]})]}),(v||u)&&e.jsx(X.ErrorMessage,{error:v||u||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:U,children:"Review Withdrawal"})]}),h==="confirm"&&m&&e.jsxs("div",{className:"cedros-withdrawal-confirm",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:q,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:m.symbol})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Amount"}),e.jsxs("span",{className:"cedros-withdrawal-summary-value",children:[dt(L,m.decimals)," ",m.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Destination"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",title:x,children:xs(x)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),u&&e.jsx(X.ErrorMessage,{error:u}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:q,disabled:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:F,disabled:l,children:l?"Sending...":"Confirm & Send"})]})]}),h==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(z.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",m?.symbol,"..."]})]}),h==="success"&&P&&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:[dt(L,m?.decimals??9)," ",m?.symbol," ","sent"]}),e.jsxs("div",{className:"cedros-withdrawal-tx",children:[e.jsx("span",{className:"cedros-withdrawal-tx-label",children:"Transaction"}),e.jsx("a",{className:"cedros-withdrawal-tx-link",href:B,target:"_blank",rel:"noreferrer",children:xs(P.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:W,children:"Done"})]})]}):null}function Ed(t,s){if(t==="sol")return"SOL";if(!s)return"SPL";const n=Pt.find(o=>o.mint===s);return n?n.symbol:`${s.slice(0,4)}...${s.slice(-4)}`}function Ld(t,s){const n=Number(t);if(Number.isNaN(n))return t;const o=Uo(s),r=n/Math.pow(10,o);return s==="SOL"?`${r.toFixed(4)} SOL`:`${r.toFixed(2)} ${s}`}function Pd(t){return t.length<=12?t:`${t.slice(0,4)}...${t.slice(-4)}`}function Bd(t){const s=new Date(t),n=new Date,o=n.getTime()-s.getTime();if(o<0)return"Just now";const r=Math.floor(o/(1e3*60*60*24));if(r===0){const a=Math.floor(o/36e5);if(a===0){const c=Math.floor(o/6e4);return c<1?"Just now":`${c}m ago`}return`${a}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==n.getFullYear()?"numeric":void 0})}function Md({pageSize:t=10,className:s="",onTransactionClick:n,explorerUrl:o="https://solscan.io"}){const r=o.startsWith("https://")?o:"https://solscan.io",{getHistory:a,error:c,clearError:i}=sr(),[l,u]=d.useState([]),[f,h]=d.useState(0),[p,b]=d.useState(0),[w,m]=d.useState(!1),[k,x]=d.useState(null),N=d.useCallback(async()=>{m(!0);try{const g=await a(t,p);u(g.items),h(g.total),x(null)}catch(g){x(g instanceof Error?g.message:"Failed to load withdrawal history")}finally{m(!1)}},[t,p,a]);d.useEffect(()=>{N()},[N]);const j=Math.ceil(f/t),C=Math.floor(p/t)+1,P=g=>{const v=(g-1)*t;b(Math.max(0,Math.min(v,Math.max(0,f-t))))};return k||c?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${s}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:k||c}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{i(),x(null),N()},children:"Retry"})]}):w&&l.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${s}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${s}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:N,disabled:w,title:"Refresh",children:w?"...":"↻"})]}),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(g=>{const v=Ed(g.tokenType,g.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>n?.(g),onKeyDown:A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),n?.(g))},role:n?"button":void 0,tabIndex:n?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:[v," Withdrawal"]}),e.jsx("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:Ld(g.amount,v)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${r}/account/${g.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:A=>A.stopPropagation(),children:Pd(g.destination)})," · ",e.jsx("a",{href:`${r}/tx/${g.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:A=>A.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:Bd(g.createdAt)})]})]})]},g.id)})}),j>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>P(C-1),disabled:C<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",C," of ",j]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>P(C+1),disabled:C>=j,children:"Next"})]})]})]})}function Rd({brandLogo:t,brandName:s,title:n="Welcome back",subtitle:o="Login with your Apple or Google account",termsText:r,onSuccess:a,defaultTab:c="login",children:i,className:l=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${l}`,children:[(t||s)&&e.jsxs("div",{className:"cedros-brand-header",children:[t,s&&e.jsx("span",{className:"cedros-brand-name",children:s})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:n}),o&&e.jsx("p",{className:"cedros-full-page-subtitle",children:o})]}),i??e.jsx(Et,{defaultTab:c,onSuccess:a})]}),r&&e.jsx("p",{className:"cedros-terms-footer",children:r})]})}function Td({brandName:t="Your Brand",brandLogo:s,tagline:n="Your tagline goes here. Make it compelling.",title:o="Sign in",subtitle:r="Enter your credentials to access your account",onSuccess:a,defaultTab:c="login",children:i,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:[s??e.jsx("div",{className:"cedros-split-page-logo",children:t.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:t}),n&&e.jsx("p",{className:"cedros-split-page-tagline",children:n})]})}),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}),r&&e.jsx("p",{className:"cedros-split-page-subtitle",children:r}),i??e.jsx(Et,{defaultTab:c,onSuccess:a})]})})]})}function Id(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),r=d.useMemo(()=>new Rs.OrgApiClient(t.serverUrl,t.requestTimeout,t.retryAttempts,s?.getAccessToken),[t.serverUrl,t.requestTimeout,t.retryAttempts,s]),a=d.useCallback(async l=>{o(u=>({...u,isLoading:!0,error:null}));try{const u=await r.authorize(l),f={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return o(f),f}catch(u){const f={allowed:!1,reason:void 0,isLoading:!1,error:u};return o(f),f}},[r]),c=d.useCallback(async l=>(await a(l)).allowed,[a]),i=d.useCallback(()=>{o({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:c,lastCheck:n,clearCheck:i,checkAuthorization:a}}function Dd(){const{listAllWallets:t,createDerivedWallet:s,deleteDerivedWallet:n}=I.useWalletMaterial(),[o,r]=d.useState([]),[a,c]=d.useState(!1),[i,l]=d.useState(null),u=d.useCallback(async()=>{c(!0),l(null);try{const b=await t();r(b.wallets)}catch(b){const w=b instanceof Error?b.message:"Failed to list wallets";l(w)}finally{c(!1)}},[t]),f=d.useCallback(async b=>{c(!0),l(null);try{const w=await s({label:b});return await u(),w}catch(w){const m=w instanceof Error?w.message:"Failed to create wallet";throw l(m),w}finally{c(!1)}},[s,u]),h=d.useCallback(async b=>{c(!0),l(null);try{await n(b),await u()}catch(w){const m=w instanceof Error?w.message:"Failed to delete wallet";throw l(m),w}finally{c(!1)}},[n,u]),p=d.useCallback(()=>l(null),[]);return{wallets:o,isLoading:a,createWallet:f,deleteWallet:h,refresh:u,error:i,clearError:p}}function _d(){const t=T.useCedrosLoginOptional(),[s,n]=d.useState(!1),[o,r]=d.useState(null),[a,c]=d.useState(null),i=d.useMemo(()=>t?new T.ApiClient({baseUrl:t.config.serverUrl,timeoutMs:t.config.requestTimeout,retryAttempts:t.config.retryAttempts,getAccessToken:t._internal?.getAccessToken}):null,[t]),l=d.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");n(!0),r(null);try{const h=await i.get("/wallet/pending-recovery");c(h)}catch(h){const p=T.handleApiError(h,"Failed to fetch pending recovery");throw r(p.message),p}finally{n(!1)}},[i]),u=d.useCallback(async()=>{if(!i)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");n(!0),r(null);try{const h={confirmed:!0};await i.post("/wallet/acknowledge-recovery",h),c(null)}catch(h){const p=T.handleApiError(h,"Failed to acknowledge recovery");throw r(p.message),p}finally{n(!1)}},[i]),f=d.useCallback(()=>r(null),[]);return d.useEffect(()=>{i&&t?.authState==="authenticated"&&l().catch(()=>{})},[i,t?.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:u,isLoading:s,error:o,clearError:f}}function Ud(t={}){const{onExternalSign:s}=t,{solanaPubkey:n,hasExternalWallet:o,status:r,isUnlocked:a}=I.useWallet(),{signTransaction:c,isSigning:i,error:l,clearError:u}=fo(),f=d.useMemo(()=>o&&s?"external":r==="enrolled_locked"||r==="enrolled_unlocked"?"sss":"none",[o,s,r]),h=f!=="none",p=r==="enrolled_locked"||r==="enrolled_unlocked";return{signTransaction:d.useCallback(async(w,m)=>{if(f==="external"){if(!s)throw new Error("External wallet signing callback not provided");return s(w)}if(f==="sss"){if(!m&&!a)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return m?c(w,m):c(w)}throw new Error("No signing method available. Enroll a wallet first.")},[f,s,a,c]),signingMethod:f,canSign:h,isSigning:i,publicKey:n,hasExternalWallet:o,hasSssWallet:p,isSssUnlocked:a,error:l,clearError:u}}function Fd(){const{config:t,_internal:s}=T.useCedrosLogin(),[n,o]=d.useState(null),[r,a]=d.useState(!1),[c,i]=d.useState(null),l=d.useMemo(()=>new T.ApiClient({baseUrl:t.serverUrl,timeoutMs:t.requestTimeout,getAccessToken:s?.getAccessToken}),[t.serverUrl,t.requestTimeout,s]),u=d.useCallback(async()=>{a(!0),i(null);try{await l.post("/welcome-completed",{})}catch(h){const p=h instanceof Error?h:new Error(String(h));throw i(p),p}finally{a(!1)}},[l]),f=d.useCallback(()=>{o(null)},[]);return{postLoginAction:n,setPostLoginAction:o,markWelcomeCompleted:u,clearPostLogin:f,isLoading:r,error:c}}const rr=d.createContext(null),Nt={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 zo(t,s){return Ho(t,s)}function Ho(t,s){const n={...t};for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)){const r=t[o],a=s[o];typeof r=="object"&&r!==null&&typeof a=="object"&&a!==null?n[o]=Ho(r,a):a!==void 0&&(n[o]=a)}return n}function Od({children:t,locale:s="en",translations:n}){const o=d.useMemo(()=>({t:n?zo(Nt,n):Nt,locale:s}),[n,s]);return e.jsx(rr.Provider,{value:o,children:t})}function Wd(){return d.useContext(rr)?.t??Nt}function qd(){return d.useContext(rr)?.locale??"en"}exports.CedrosLoginProvider=I.CedrosLoginProvider;exports.getEmbeddedWalletInfo=I.getEmbeddedWalletInfo;exports.isEmbeddedWalletAvailable=I.isEmbeddedWalletAvailable;exports.useAuth=I.useAuth;exports.useWallet=I.useWallet;exports.useWalletMaterial=I.useWalletMaterial;exports.useAuthState=T.useAuthState;exports.useAuthUI=T.useAuthUI;exports.useCedrosLogin=T.useCedrosLogin;exports.LoadingSpinner=z.LoadingSpinner;exports.EmailLoginForm=Q.EmailLoginForm;exports.EmailRegisterForm=Q.EmailRegisterForm;exports.OtpInput=Q.OtpInput;exports.PasswordInput=Q.PasswordInput;exports.TotpVerify=Q.TotpVerify;exports.useEmailAuth=Q.useEmailAuth;exports.useTotpVerify=Q.useTotpVerify;exports.validatePassword=Te.validatePassword;exports.ErrorMessage=X.ErrorMessage;exports.GoogleLoginButton=Ms.GoogleLoginButton;exports.useGoogleAuth=Ms.useGoogleAuth;exports.SolanaLoginButton=qe.SolanaLoginButton;exports.registerMobileWallet=qe.registerMobileWallet;exports.useSolanaAuth=qe.useSolanaAuth;exports.InviteForm=ie.InviteForm;exports.InviteList=ie.InviteList;exports.MemberList=ie.MemberList;exports.useInvites=ie.useInvites;exports.useMembers=ie.useMembers;exports.useServerFeatures=ie.useServerFeatures;exports.useSystemSettings=fn.useSystemSettings;exports.useOrgs=Rs.useOrgs;exports.AdminDepositList=mt.AdminDepositList;exports.AdminDepositStats=mt.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=Pe.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=Pe.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=Pe.AdminWithdrawalQueue;exports.AdminWithdrawalStats=Pe.AdminWithdrawalStats;exports.AdminUserList=et.AdminUserList;exports.useAdminUsers=et.useAdminUsers;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=mn.AuthenticationSettings;exports.EmbeddedWalletSettings=gn.EmbeddedWalletSettings;exports.EmailSettings=ut.EmailSettings;exports.CreditSystemSettings=Ts.CreditSystemSettings;exports.PrivacyCashSettings=Ts.CreditSystemSettings;exports.ServerSettings=wn.ServerSettings;exports.useAdminDeposits=ea.useAdminDeposits;exports.SettingsPageLayout=Is.SettingsPageLayout;exports.WebhookSettings=Is.WebhookSettings;exports.AccountSettings=Fl;exports.AppleLoginButton=to;exports.CapabilityWarning=vc;exports.CedrosAdminDashboard=Yc;exports.ChooseUsernamePrompt=ql;exports.CompleteAccountPrompt=Wl;exports.CreditBalance=yd;exports.DepositFlow=dd;exports.ErrorBoundary=no;exports.ForgotPasswordForm=Xn;exports.FullPageLayout=Rd;exports.History=kd;exports.I18nProvider=Od;exports.LinkedAccounts=Lo;exports.LoginButton=Ki;exports.LoginForm=Et;exports.LoginModal=rc;exports.MfaSetupPrompt=Ol;exports.OrgSelector=oc;exports.OrgSwitcher=pc;exports.PasskeyLoginButton=ro;exports.PasskeyPrompt=mo;exports.ProfileTab=So;exports.RecoveryPhraseDisplay=ao;exports.RecoveryPhraseInput=io;exports.ResetPasswordForm=nc;exports.SUPPORTED_TOKENS=Pt;exports.SecuritySettings=Gc;exports.SessionList=oo;exports.SetupWizard=Ao;exports.SplitPageLayout=Td;exports.SystemSettings=Wc;exports.TieredAmountSlider=Js;exports.TokenSelector=Ys;exports.TotpSettings=Co;exports.TotpSetup=Qs;exports.UserProfileSettings=Cl;exports.WalletAddressRow=yo;exports.WalletEnrollment=ho;exports.WalletManager=Oc;exports.WalletRecovery=bo;exports.WalletStatus=xo;exports.WalletUnlock=go;exports.WithdrawalFlow=Sd;exports.WithdrawalHistory=Md;exports.defaultTranslations=Nt;exports.getTierForAmount=Lt;exports.mergeTranslations=zo;exports.useAppleAuth=Jn;exports.useAuthorize=Id;exports.useCredentials=Ks;exports.useCredits=tr;exports.useDeposit=Io;exports.useInstantLink=Zn;exports.useLocale=qd;exports.usePasskeySigning=po;exports.usePasswordReset=St;exports.usePendingRecovery=_d;exports.usePostLogin=Fd;exports.useProfile=tt;exports.useSessions=Ro;exports.useSetPassword=uo;exports.useSetup=Vs;exports.useTotp=Gs;exports.useTransactionSigning=Ud;exports.useTranslations=Wd;exports.useUsername=To;exports.useWalletEnrollment=lo;exports.useWalletRecovery=wo;exports.useWalletSigning=fo;exports.useWallets=Dd;exports.useWebAuthn=Hs;exports.useWithdrawal=sr;