@cedros/login-react 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1943 -1910
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/mockServiceWorker.js +0 -349
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./useAuth-XZaciuLg.cjs"),T=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),i=require("react"),_=require("./LoadingSpinner-d6sSxgQN.cjs"),Os=require("./sanitization-Bo_tn-L2.cjs"),Q=require("./EmailRegisterForm-B_TiJkD6.cjs"),we=require("./validation-BuGQrA-K.cjs"),Y=require("./ErrorMessage-CHbYbVi2.cjs"),qs=require("./GoogleLoginButton-BDCbxoCB.cjs"),ve=require("./SolanaLoginButton-nSJHVFpZ.cjs"),te=require("./PermissionsSection-DEMVp7X3.cjs"),Yt=require("./useSystemSettings-B2jY51ob.cjs"),je=require("./AutosaveStatus-DGNI4lXn.cjs"),zs=require("./useOrgs-CNqfn-fk.cjs"),He=require("./AdminDepositList-B_z6x3j5.cjs"),fe=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),Te=require("./useUsersStatsSummary-DgKaUIfs.cjs"),Gt=require("./StatsBar-DTUZCwDD.cjs"),ge=require("./plugin-Xca67fp7.cjs"),$t=require("./AuthenticationSettings-CoTic-d_.cjs"),Jt=require("./EmbeddedWalletSettings-BRjt2PAj.cjs"),ze=require("./EmailSettings-BF5EiPl9.cjs"),Vs=require("./CreditSystemSettings-DM9ep1TF.cjs"),Xt=require("./ServerSettings-CKfiLfXi.cjs"),ie=require("./shamir-DBpHm7WN.cjs"),io=require("./useAdminDeposits-CpLd68oP.cjs"),Hs=require("./WebhookSettings-DXjnq-c7.cjs");function Qe(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Zt(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(o=>typeof o=="string"):t.every(o=>Number.isSafeInteger(o)):!1}function lo(s){if(typeof s!="function")throw new Error("function expected");return!0}function Ke(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function Ce(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function Ye(s){if(!Array.isArray(s))throw new Error("array expected")}function Ge(s,t){if(!Zt(!0,t))throw new Error(`${s}: array of strings expected`)}function er(s,t){if(!Zt(!1,t))throw new Error(`${s}: array of numbers expected`)}function co(...s){const t=n=>n,o=(n,c)=>l=>n(c(l)),a=s.map(n=>n.encode).reduceRight(o,t),r=s.map(n=>n.decode).reduce(o,t);return{encode:a,decode:r}}function uo(s){const t=typeof s=="string"?s.split(""):s,o=t.length;Ge("alphabet",t);const a=new Map(t.map((r,n)=>[r,n]));return{encode:r=>(Ye(r),r.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=o)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${s}`);return t[n]})),decode:r=>(Ye(r),r.map(n=>{Ke("alphabet.decode",n);const c=a.get(n);if(c===void 0)throw new Error(`Unknown letter: "${n}". Allowed: ${s}`);return c}))}}function ho(s=""){return Ke("join",s),{encode:t=>(Ge("join.decode",t),t.join(s)),decode:t=>(Ke("join.decode",t),t.split(s))}}function po(s,t="="){return Ce(s),Ke("padding",t),{encode(o){for(Ge("padding.encode",o);o.length*s%8;)o.push(t);return o},decode(o){Ge("padding.decode",o);let a=o.length;if(a*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;a>0&&o[a-1]===t;a--)if((a-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return o.slice(0,a)}}}function Fs(s,t,o){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(o<2)throw new Error(`convertRadix: invalid to=${o}, base cannot be less than 2`);if(Ye(s),!s.length)return[];let a=0;const r=[],n=Array.from(s,l=>{if(Ce(l),l<0||l>=t)throw new Error(`invalid integer: ${l}`);return l}),c=n.length;for(;;){let l=0,d=!0;for(let u=a;u<c;u++){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./useAuth-XZaciuLg.cjs"),T=require("./useCedrosLogin-DtJorrE7.cjs"),e=require("react/jsx-runtime"),i=require("react"),_=require("./LoadingSpinner-d6sSxgQN.cjs"),Os=require("./sanitization-Bo_tn-L2.cjs"),Q=require("./EmailRegisterForm-B_TiJkD6.cjs"),we=require("./validation-BuGQrA-K.cjs"),Y=require("./ErrorMessage-CHbYbVi2.cjs"),qs=require("./GoogleLoginButton-BDCbxoCB.cjs"),ve=require("./SolanaLoginButton-nSJHVFpZ.cjs"),te=require("./PermissionsSection-DEMVp7X3.cjs"),Yt=require("./useSystemSettings-B2jY51ob.cjs"),je=require("./AutosaveStatus-DGNI4lXn.cjs"),zs=require("./useOrgs-CNqfn-fk.cjs"),He=require("./AdminDepositList-B_z6x3j5.cjs"),fe=require("./AdminWithdrawalHistory-B2EY2ZmH.cjs"),Te=require("./useUsersStatsSummary-DgKaUIfs.cjs"),Gt=require("./StatsBar-DTUZCwDD.cjs"),ge=require("./plugin-Xca67fp7.cjs"),$t=require("./AuthenticationSettings-CoTic-d_.cjs"),Jt=require("./EmbeddedWalletSettings-BRjt2PAj.cjs"),ze=require("./EmailSettings-BF5EiPl9.cjs"),Vs=require("./CreditSystemSettings-DM9ep1TF.cjs"),Xt=require("./ServerSettings-CKfiLfXi.cjs"),ie=require("./shamir-DBpHm7WN.cjs"),io=require("./useAdminDeposits-CpLd68oP.cjs"),Hs=require("./WebhookSettings-DXjnq-c7.cjs");function Qe(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Zt(s,t){return Array.isArray(t)?t.length===0?!0:s?t.every(o=>typeof o=="string"):t.every(o=>Number.isSafeInteger(o)):!1}function lo(s){if(typeof s!="function")throw new Error("function expected");return!0}function Ke(s,t){if(typeof t!="string")throw new Error(`${s}: string expected`);return!0}function Ce(s){if(!Number.isSafeInteger(s))throw new Error(`invalid integer: ${s}`)}function Ye(s){if(!Array.isArray(s))throw new Error("array expected")}function Ge(s,t){if(!Zt(!0,t))throw new Error(`${s}: array of strings expected`)}function er(s,t){if(!Zt(!1,t))throw new Error(`${s}: array of numbers expected`)}function co(...s){const t=n=>n,o=(n,c)=>l=>n(c(l)),a=s.map(n=>n.encode).reduceRight(o,t),r=s.map(n=>n.decode).reduce(o,t);return{encode:a,decode:r}}function uo(s){const t=typeof s=="string"?s.split(""):s,o=t.length;Ge("alphabet",t);const a=new Map(t.map((r,n)=>[r,n]));return{encode:r=>(Ye(r),r.map(n=>{if(!Number.isSafeInteger(n)||n<0||n>=o)throw new Error(`alphabet.encode: digit index outside alphabet "${n}". Allowed: ${s}`);return t[n]})),decode:r=>(Ye(r),r.map(n=>{Ke("alphabet.decode",n);const c=a.get(n);if(c===void 0)throw new Error(`Unknown letter: "${n}". Allowed: ${s}`);return c}))}}function ho(s=""){return Ke("join",s),{encode:t=>(Ge("join.decode",t),t.join(s)),decode:t=>(Ke("join.decode",t),t.split(s))}}function po(s,t="="){return Ce(s),Ke("padding",t),{encode(o){for(Ge("padding.encode",o);o.length*s%8;)o.push(t);return o},decode(o){Ge("padding.decode",o);let a=o.length;if(a*s%8)throw new Error("padding: invalid, string should have whole number of bytes");for(;a>0&&o[a-1]===t;a--)if((a-1)*s%8===0)throw new Error("padding: invalid, string has too much padding");return o.slice(0,a)}}}function Fs(s,t,o){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(o<2)throw new Error(`convertRadix: invalid to=${o}, base cannot be less than 2`);if(Ye(s),!s.length)return[];let a=0;const r=[],n=Array.from(s,l=>{if(Ce(l),l<0||l>=t)throw new Error(`invalid integer: ${l}`);return l}),c=n.length;for(;;){let l=0,d=!0;for(let u=a;u<c;u++){const h=n[u],m=t*l,f=m+h;if(!Number.isSafeInteger(f)||m/t!==l||f-h!==m)throw new Error("convertRadix: carry overflow");const w=f/o;l=f%o;const g=Math.floor(w);if(n[u]=g,!Number.isSafeInteger(g)||g*o+l!==f)throw new Error("convertRadix: carry overflow");if(d)g?d=!1:a=u;else continue}if(r.push(l),d)break}for(let l=0;l<s.length-1&&s[l]===0;l++)r.push(0);return r.reverse()}const sr=(s,t)=>t===0?s:sr(t,s%t),$e=(s,t)=>s+(t-sr(s,t)),cs=(()=>{let s=[];for(let t=0;t<40;t++)s.push(2**t);return s})();function Us(s,t,o,a){if(Ye(s),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(o<=0||o>32)throw new Error(`convertRadix2: wrong to=${o}`);if($e(t,o)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${o} carryBits=${$e(t,o)}`);let r=0,n=0;const c=cs[t],l=cs[o]-1,d=[];for(const u of s){if(Ce(u),u>=c)throw new Error(`convertRadix2: invalid data word=${u} from=${t}`);if(r=r<<t|u,n+t>32)throw new Error(`convertRadix2: carry overflow pos=${n} from=${t}`);for(n+=t;n>=o;n-=o)d.push((r>>n-o&l)>>>0);const h=cs[n];if(h===void 0)throw new Error("invalid carry");r&=h-1}if(r=r<<o-n&l,!a&&n>=t)throw new Error("Excess padding");if(!a&&r>0)throw new Error(`Non-zero padding: ${r}`);return a&&n>0&&d.push(r>>>0),d}function mo(s){Ce(s);const t=2**8;return{encode:o=>{if(!Qe(o))throw new Error("radix.encode input should be Uint8Array");return Fs(Array.from(o),t,s)},decode:o=>(er("radix.decode",o),Uint8Array.from(Fs(o,s,t)))}}function fo(s,t=!1){if(Ce(s),s<=0||s>32)throw new Error("radix2: bits should be in (0..32]");if($e(8,s)>32||$e(s,8)>32)throw new Error("radix2: carry overflow");return{encode:o=>{if(!Qe(o))throw new Error("radix2.encode input should be Uint8Array");return Us(Array.from(o),8,s,!t)},decode:o=>(er("radix2.decode",o),Uint8Array.from(Us(o,s,8,t)))}}function go(s,t){return Ce(s),lo(t),{encode(o){if(!Qe(o))throw new Error("checksum.encode: input should be Uint8Array");const a=t(o).slice(0,s),r=new Uint8Array(o.length+s);return r.set(o),r.set(a,o.length),r},decode(o){if(!Qe(o))throw new Error("checksum.decode: input should be Uint8Array");const a=o.slice(0,-s),r=o.slice(-s),n=t(a).slice(0,s);for(let c=0;c<s;c++)if(n[c]!==r[c])throw new Error("Invalid checksum");return a}}}const _e={alphabet:uo,chain:co,checksum:go,convertRadix:Fs,convertRadix2:Us,radix:mo,radix2:fo,join:ho,padding:po};const wo=s=>s[0]==="あいこくしん";function yo(s){if(typeof s!="string")throw new TypeError("invalid mnemonic type: "+typeof s);return s.normalize("NFKD")}function bo(s){const t=yo(s),o=t.split(" ");if(![12,15,18,21,24].includes(o.length))throw new Error("Invalid mnemonic");return{nfkd:t,words:o}}function tr(s){ie.abytes(s,16,20,24,28,32)}const xo=s=>{const t=8-s.length/4;return new Uint8Array([ie.sha256(s)[0]>>t<<t])};function rr(s){if(!Array.isArray(s)||s.length!==2048||typeof s[0]!="string")throw new Error("Wordlist: expected array of 2048 strings");return s.forEach(t=>{if(typeof t!="string")throw new Error("wordlist: non-string element: "+t)}),_e.chain(_e.checksum(1,xo),_e.radix2(11,!0),_e.alphabet(s))}function Qs(s,t){const{words:o}=bo(s),a=rr(t).decode(o);return tr(a),a}function or(s,t){return tr(s),rr(t).encode(s).join(wo(t)?" ":" ")}function Ks(s,t){try{Qs(s,t)}catch{return!1}return!0}const he=`abandon
|
|
2
2
|
ability
|
|
3
3
|
able
|
|
4
4
|
about
|
|
@@ -2046,16 +2046,16 @@ zebra
|
|
|
2046
2046
|
zero
|
|
2047
2047
|
zone
|
|
2048
2048
|
zoo`.split(`
|
|
2049
|
-
`),oe=12;function Ao(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const o=or(s,he).split(" ");if(o.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${o.length}`);return o}function vo(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ks(t,he))throw new Error("Invalid recovery phrase: checksum mismatch");const o=Qs(t,he);if(o.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${o.length}`);return I.toShamirShare(o)}function jo(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const o=or(s,he).split(" ");if(o.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${o.length}`);return o}function ko(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ks(t,he))throw new Error("Invalid recovery phrase: checksum mismatch");const o=Qs(t,he);if(o.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${o.length}`);return I.toSeed(o)}function nr(s){if(s.length!==oe)return!1;const t=s.join(" ").toLowerCase().trim();return Ks(t,he)}function We(s){return he.includes(s.toLowerCase().trim())}function No(s,t=5){const o=s.toLowerCase().trim();return o.length===0?[]:he.filter(a=>a.startsWith(o)).slice(0,t)}function Co(s){const t=[];for(let o=0;o<s.length;o+=4)t.push(s.slice(o,o+4));return t}function So(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function Eo({className:s="",variant:t="default",size:o="md",children:a,menuItems:r=[],hideSignOut:n=!1}){const{user:c,isAuthenticated:l,isLoading:d,openLoginModal:u,logout:m}=I.useAuth(),[f,g]=i.useState(!1),[w,p]=i.useState(-1),h=i.useRef(null),y=i.useRef(null),b=i.useMemo(()=>[...r,...n?[]:[{label:"Sign out",onClick:m}]],[r,n,m]);i.useEffect(()=>{if(!f)return;const A=S=>{h.current&&!h.current.contains(S.target)&&(g(!1),p(-1))},N=S=>{S.key==="Escape"&&(g(!1),p(-1),y.current?.focus())};return document.addEventListener("mousedown",A),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",N)}},[f]);const x=i.useCallback(A=>{if(!(!f||b.length===0))switch(A.key){case"ArrowDown":A.preventDefault(),p(N=>(N+1)%b.length);break;case"ArrowUp":A.preventDefault(),p(N=>(N-1+b.length)%b.length);break;case"Home":A.preventDefault(),p(0);break;case"End":A.preventDefault(),p(b.length-1);break;case"Enter":case" ":w>=0&&(A.preventDefault(),b[w].onClick(),g(!1),p(-1));break}},[f,w,b]),v=i.useCallback(()=>{b.length!==0&&(g(A=>!A),p(-1))},[b.length]),k={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},C={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(d)return e.jsx("button",{type:"button",className:`cedros-button ${C[t]} ${k[o]} ${s}`,disabled:!0,children:e.jsx(_.LoadingSpinner,{size:"sm"})});if(l&&c){const A=c.name||c.email||"User",N=Os.sanitizeImageUrl(c.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:h,onKeyDown:x,children:[e.jsxs("button",{ref:y,type:"button",className:`cedros-button cedros-user-button ${k[o]} ${s}`,"aria-haspopup":"menu","aria-expanded":f,"aria-label":`User menu for ${A}`,onClick:v,children:[N?e.jsx("img",{src:N,alt:A,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(A[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:A})]}),f&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[r.map((S,j)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${w===j?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===j?0:-1,onClick:()=>{S.onClick(),g(!1)},children:[S.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:S.icon}),S.label]},j)),r.length>0&&!n&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!n&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${w===r.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===r.length?0:-1,onClick:()=>{m(),g(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${C[t]} ${k[o]} ${s}`,onClick:u,children:a||"Sign in"})}function es(){const{config:s}=T.useCedrosLogin(),[t,o]=i.useState(!1),[a,r]=i.useState(!1),[n,c]=i.useState(null),l=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:d,getRemainingAttempts:u}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),m=i.useCallback(async p=>{if(!we.validateEmail(p)){const h={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw c(h),h}try{d()}catch(h){const y={code:"RATE_LIMITED",message:h instanceof Error?h.message:"Too many attempts"};throw c(y),y}o(!0),c(null),r(!1);try{await l.post("/forgot-password",{email:p}),r(!0)}catch(h){const y=T.handleApiError(h,"Unable to send the reset email. Please try again.");throw c(y),y}finally{o(!1)}},[l,d]),f=i.useCallback(async(p,h)=>{o(!0),c(null),r(!1);try{await l.post("/reset-password",{token:p,newPassword:h}),r(!0)}catch(y){const b=T.handleApiError(y,"Unable to reset your password. Please try again.");throw c(b),b}finally{o(!1)}},[l]),g=i.useCallback(()=>c(null),[]),w=i.useCallback(()=>{c(null),r(!1),o(!1)},[]);return{forgotPassword:m,resetPassword:f,isLoading:t,isSuccess:a,error:n,clearError:g,reset:w,remainingAttempts:u()}}function Lo(s){return typeof s=="object"&&s!==null&&"mfaRequired"in s&&s.mfaRequired===!0}function ar(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(!1),[r,n]=i.useState(!1),[c,l]=i.useState(null),d=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:u,getRemainingAttempts:m}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),f=i.useCallback(async h=>{if(!we.validateEmail(h)){const y={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw l(y),y}try{u()}catch(y){const b={code:"RATE_LIMITED",message:y instanceof Error?y.message:"Too many attempts"};throw l(b),b}a(!0),l(null),n(!1);try{await d.post("/instant-link",{email:h}),n(!0)}catch(y){const b=T.handleApiError(y,"Unable to send the sign-in link. Please try again.");throw l(b),b}finally{a(!1)}},[d,u]),g=i.useCallback(async h=>{if(!h||h.trim().length===0){const y={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw l(y),y}a(!0),l(null),n(!1);try{const y=await d.post("/instant-link/verify",{token:h});return Lo(y)||(s.callbacks?.onLoginSuccess?.(y.user,"email"),t?.handleLoginSuccess(y.user,y.tokens)),y}catch(y){const b=T.handleApiError(y,"Unable to verify the sign-in link. Please try again.");throw l(b),b}finally{a(!1)}},[d,s.callbacks,t]),w=i.useCallback(()=>l(null),[]),p=i.useCallback(()=>{l(null),n(!1),a(!1)},[]);return{sendInstantLink:f,verifyInstantLink:g,isLoading:o,isSuccess:r,error:c,clearError:w,reset:p,remainingAttempts:m()}}const Po={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:s=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:s}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:s=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:s}),". Click the link to sign in."]})}};function ir({mode:s="reset",onSuccess:t,onCancel:o,className:a=""}){const[r,n]=i.useState(""),c=es(),l=ar(),d=i.useId(),u=s==="instantLink"?{submit:l.sendInstantLink,isLoading:l.isLoading,isSuccess:l.isSuccess,error:l.error,clearError:l.clearError}:{submit:c.forgotPassword,isLoading:c.isLoading,isSuccess:c.isSuccess,error:c.error,clearError:c.clearError},m=Po[s],f=async g=>{g.preventDefault();try{await u.submit(r),t?.()}catch{}};return u.isSuccess?e.jsxs("div",{className:`cedros-forgot-password-success ${a}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Check your email"}),e.jsx("p",{className:"cedros-success-message",children:m.successMessage(r)}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:o,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${a}`,onSubmit:f,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Forgot password?"}),e.jsx("p",{className:"cedros-form-subtitle",children:m.subtitle})]}),e.jsx(Y.ErrorMessage,{error:u.error,onDismiss:u.clearError}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:d,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:d,type:"email",className:"cedros-input",value:r,onChange:g=>n(g.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(_.LoadingSpinner,{size:"sm"}),"Sending..."]}):m.button}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:o,disabled:u.isLoading,children:"Back to login"})]})]})}const Mo={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t})}):(this.loading=!0,new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t});const o=document.getElementById("apple-signin-script");if(o){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]):o.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]});return}const a=document.createElement("script");a.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",a.async=!0,a.defer=!0,a.id="apple-signin-script",a.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]},a.onerror=()=>{this.loading=!1,a.remove();const r=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(n=>n.reject(r)),this.callbacks=[]},document.head.appendChild(a)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function lr(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(!1),[r,n]=i.useState(!1),[c,l]=i.useState(null),[d,u]=i.useState(null),m=i.useRef(s),f=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);i.useEffect(()=>{m.current=s},[s]),i.useEffect(()=>{if(!s.appleClientId)return;let h=!0;const y=()=>{if(h)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),h&&n(!0)}catch{h&&l({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return Mo.load().then(()=>{h&&y()}).catch(()=>{h&&l({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{h=!1}},[s.appleClientId]);const g=i.useCallback(async()=>{if(!s.appleClientId){const y={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw l(y),y}if(!r){const y={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw l(y),y}a(!0),l(null);let h;try{const y=await window.AppleID.auth.signIn();if(h=y.authorization?.id_token,!h)throw new Error("No ID token received from Apple");const b=y.user?.name?`${y.user.name.firstName||""} ${y.user.name.lastName||""}`.trim():void 0,x=await f.post("/apple",{idToken:h,name:b||void 0});return m.current.callbacks?.onLoginSuccess?.(x.user,"apple"),t?.handleLoginSuccess(x.user,x.tokens),a(!1),x}catch(y){if(y.error==="popup_closed_by_user"){const v={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw l(v),a(!1),v}const x=T.handleApiError(y,"Unable to sign in with Apple. Please try again.");throw x.code==="ACCOUNT_LINK_REQUIRED"&&h&&u(h),l(x),a(!1),x}},[s.appleClientId,r,f,t]),w=i.useCallback(()=>l(null),[]),p=i.useCallback(()=>u(null),[]);return{signIn:g,isLoading:o,isInitialized:r,error:c,clearError:w,pendingLinkIdToken:d,clearPendingLink:p}}function cr(){if(typeof window>"u"||typeof navigator>"u")return!1;const s=navigator.userAgent.toLowerCase(),t=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(s)||t.includes("mac")||/macintosh/.test(s)||t==="macintel"&&navigator.maxTouchPoints>1)}function dr({onSuccess:s,onError:t,className:o="",variant:a="default",size:r="md",disabled:n=!1,hideOnNonApple:c=!0}){const{signIn:l,isLoading:d,isInitialized:u}=lr(),[m]=i.useState(()=>cr());if(c&&!m)return null;const f=async()=>{try{await l(),s?.()}catch(p){const h=p instanceof Error?p:new Error(String(p));t?.(h)}},g={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},w={default:"cedros-button-social",outline:"cedros-button-social-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${w[a]} ${g[r]} ${o}`,onClick:f,disabled:n||!u||d,"aria-label":"Sign in with Apple",children:[d?e.jsx(_.LoadingSpinner,{size:"sm"}):e.jsx("svg",{className:"cedros-button-icon",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),e.jsx("span",{children:"Continue with Apple"})]})}function Z(s,t){if(!s)throw new Error(t)}function To(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function Je(s){Z(typeof s=="string"&&s.length>0,"Expected base64url string");const t=To(s),o=t+"=".repeat((4-t.length%4)%4),a=atob(o),r=new Uint8Array(a.length);for(let n=0;n<a.length;n++)r[n]=a.charCodeAt(n);return r.buffer}function xe(s){const t=new Uint8Array(s);let o="";for(let r=0;r<t.length;r++)o+=String.fromCharCode(t[r]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function ur(s){Z(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return Z(typeof t.type=="string","Invalid credential descriptor type"),Z(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:Je(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function ds(s){Z(s&&typeof s=="object","Missing creation options");const t=s.publicKey;Z(t&&typeof t=="object","Missing creation options.publicKey"),Z(typeof t.challenge=="string","Missing creation challenge"),Z(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),Z(typeof t.user=="object"&&t.user!==null,"Missing user");const o=t.rp,a=t.user;Z(typeof o.name=="string","Missing rp.name"),Z(typeof a.id=="string","Missing user.id"),Z(typeof a.name=="string","Missing user.name"),Z(typeof a.displayName=="string","Missing user.displayName");const r=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(ur):void 0,n=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(l=>({type:l.type,alg:l.alg})):[],c={challenge:Je(t.challenge),rp:{name:o.name,id:typeof o.id=="string"?o.id:void 0},user:{id:Je(a.id),name:a.name,displayName:a.displayName},pubKeyCredParams:n,timeout:typeof t.timeout=="number"?t.timeout:void 0,attestation:typeof t.attestation=="string"?t.attestation:void 0,authenticatorSelection:typeof t.authenticatorSelection=="object"&&t.authenticatorSelection!==null?t.authenticatorSelection:void 0,excludeCredentials:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return c.hints=["client-device"],c}function ht(s){Z(s&&typeof s=="object","Missing request options");const t=s.publicKey;Z(t&&typeof t=="object","Missing request options.publicKey"),Z(typeof t.challenge=="string","Missing request challenge");const o=Array.isArray(t.allowCredentials)?t.allowCredentials.map(ur):void 0,a={challenge:Je(t.challenge),rpId:typeof t.rpId=="string"?t.rpId:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,userVerification:typeof t.userVerification=="string"?t.userVerification:void 0,allowCredentials:o,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return a.hints=["client-device"],a}function Ee(s){const t=xe(s.rawId),o=s.response,r={...{clientDataJSON:xe(o.clientDataJSON)}};if("attestationObject"in o){const n=o;if(r.attestationObject=xe(n.attestationObject),typeof n.getTransports=="function")try{r.transports=n.getTransports()}catch{}}if("authenticatorData"in o){const n=o;r.authenticatorData=xe(n.authenticatorData),r.signature=xe(n.signature),n.userHandle&&(r.userHandle=xe(n.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:r}}function Ro(){if(typeof window<"u"){const s=window.location?.hostname,t=s==="localhost"||s==="127.0.0.1"||s?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!t)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function Le(s){if(!(s instanceof Error))return null;const t=s.name;return t==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:t==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:t==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function Ys(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(!1),[r,n]=i.useState(null),c=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),l=i.useCallback(()=>n(null),[]),d=Ro(),u=i.useCallback(async w=>{if(!d){const p={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(p),p}a(!0),n(null);try{const p=await c.post("/webauthn/auth/options",{email:w?.email}),h=ht(p.options),y=await navigator.credentials.get({publicKey:h});if(!y)throw new Error("Passkey authentication returned no credential");const b=await c.post("/webauthn/auth/verify",{challengeId:p.challengeId,credential:Ee(y)});return s.callbacks?.onLoginSuccess?.(b.user,"webauthn"),t?.handleLoginSuccess(b.user,b.tokens),b}catch(p){const y=Le(p)??T.handleApiError(p,"Unable to sign in with passkey. Please try again.");throw n(y),y}finally{a(!1)}},[c,s.callbacks,t,d]),m=i.useCallback(async w=>{if(!d){const p={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(p),p}a(!0),n(null);try{const p=await c.post("/webauthn/register/options",{}),h=ds(p.options),y=await navigator.credentials.create({publicKey:h});if(!y)throw new Error("Passkey registration returned no credential");const b=await c.post("/webauthn/register/verify",{challengeId:p.challengeId,credential:Ee(y),label:w?.label});if(!b.success)throw new Error("Passkey registration failed");return{credentialId:b.credentialId,label:b.label}}catch(p){const y=Le(p)??T.handleApiError(p,"Unable to register passkey. Please try again.");throw n(y),y}finally{a(!1)}},[c,d]),f=i.useCallback(async w=>{if(!d){const p={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(p),p}a(!0),n(null);try{const p=await c.post("/webauthn/signup/options",{}),h=ds(p.options),y=await navigator.credentials.create({publicKey:h});if(!y)throw new Error("Passkey signup returned no credential");const b=await c.post("/webauthn/signup/verify",{challengeId:p.challengeId,credential:Ee(y),email:w?.email,name:w?.name,label:w?.label});return s.callbacks?.onLoginSuccess?.(b.user,"webauthn"),t?.handleLoginSuccess(b.user,b.tokens),b}catch(p){const y=Le(p)??T.handleApiError(p,"Unable to sign up with passkey. Please try again.");throw n(y),y}finally{a(!1)}},[c,s.callbacks,t,d]),g=i.useCallback(async()=>{if(!d){const w={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(w),w}a(!0),n(null);try{const w=await c.post("/webauthn/auth/options",{}),p=ht(w.options),h=await navigator.credentials.get({publicKey:p});if(!h)throw new Error("Passkey authentication returned no credential");const y=await c.post("/webauthn/auth/verify",{challengeId:w.challengeId,credential:Ee(h)});return s.callbacks?.onLoginSuccess?.(y.user,"webauthn"),t?.handleLoginSuccess(y.user,y.tokens),y}catch(w){if(w instanceof Error&&(w.name==="NotAllowedError"||w.name==="InvalidStateError"))try{const x=await c.post("/webauthn/signup/options",{}),v=ds(x.options),k=await navigator.credentials.create({publicKey:v});if(!k)throw new Error("Passkey signup returned no credential");const C=await c.post("/webauthn/signup/verify",{challengeId:x.challengeId,credential:Ee(k)});return s.callbacks?.onLoginSuccess?.(C.user,"webauthn"),t?.handleLoginSuccess(C.user,C.tokens),C}catch(x){const k=Le(x)??T.handleApiError(x,"Unable to create passkey. Please try again.");throw n(k),k}if(typeof w=="object"&&w!==null&&"isApiError"in w&&w.data?.code==="INVALID_CREDENTIALS"){const x={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 n(x),x}const b=Le(w)??T.handleApiError(w,"Unable to sign in with passkey. Please try again.");throw n(b),b}finally{a(!1)}},[c,s.callbacks,t,d]);return{isSupported:d,isLoading:o,error:r,clearError:l,continueWithPasskey:g,authenticatePasskey:u,registerPasskey:m,signupWithPasskey:f}}function hr({onSuccess:s,className:t="",children:o,disabled:a}){const{continueWithPasskey:r,isLoading:n,isSupported:c}=Ys(),l=a||!c||n;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${t}`,onClick:async()=>{try{await r(),s?.()}catch{}},disabled:l,"aria-disabled":l,children:[n?e.jsx(_.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(Bo,{})}),e.jsx("span",{children:o??"Continue with Passkey"})]})}function Bo(){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 Pe=["login","register"];function ss({onSuccess:s,className:t="",defaultTab:o="login"}){const{config:a,socialButtonOrder:r}=T.useCedrosLogin(),[n,c]=i.useState(o),[l,d]=i.useState("form"),[u,m]=i.useState(()=>ve.detectSolanaWallets()),[f]=i.useState(()=>cr());i.useEffect(()=>{const C=()=>m(ve.detectSolanaWallets());return C(),window.addEventListener("load",C),window.addEventListener("focus",C),()=>{window.removeEventListener("load",C),window.removeEventListener("focus",C)}},[]);const g=a.forms?.forgotPassword?.mode??(a.features?.instantLink?"instantLink":"reset"),w=i.useCallback(C=>{const A=Pe.indexOf(n);let N=A;switch(C.key){case"ArrowLeft":case"ArrowUp":N=A===0?Pe.length-1:A-1;break;case"ArrowRight":case"ArrowDown":N=A===Pe.length-1?0:A+1;break;case"Home":N=0;break;case"End":N=Pe.length-1;break;default:return}C.preventDefault();const S=Pe[N];c(S),document.getElementById(`cedros-tab-${S}`)?.focus()},[n]),p=a.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},h=p.email!==!1,y=p.google!==!1&&a.googleClientId,b=p.apple!==!1&&a.appleClientId&&f,x=p.solana!==!1&&u,v=p.webauthn!==!1,k=h&&(y||b||x||v);return l==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx(ir,{mode:g,onCancel:()=>d("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[(v||y||b||x)&&(()=>{const C={webauthn:v?e.jsx(hr,{onSuccess:s}):null,google:y?e.jsx(qs.GoogleLoginButton,{onSuccess:s}):null,apple:b?e.jsx(dr,{onSuccess:s}):null,solana:x?e.jsx(ve.SolanaLoginButton,{onSuccess:s}):null},A=r??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:A.map(N=>{const S=C[N];return S?e.jsx(i.Fragment,{children:S},N):null})})})(),k&&e.jsx("div",{className:"cedros-divider",children:e.jsx("span",{children:"Or continue with"})}),h&&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 ${n==="login"?"cedros-tab-active":""}`,onClick:()=>c("login"),onKeyDown:w,"aria-selected":n==="login","aria-controls":"cedros-tabpanel-login",tabIndex:n==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${n==="register"?"cedros-tab-active":""}`,onClick:()=>c("register"),onKeyDown:w,"aria-selected":n==="register","aria-controls":"cedros-tabpanel-register",tabIndex:n==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${n}`,"aria-labelledby":`cedros-tab-${n}`,children:n==="login"?e.jsx(Q.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>c("register"),onForgotPassword:()=>d("forgotPassword")}):e.jsx(Q.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>c("login")})})]})]})}class pr extends i.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",o.componentStack),this.props.onError?.(t,o)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:o,errorInfo:a}=this.state,{children:r,fallback:n,showDetails:c=!1}=this.props;return t?n||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),c&&o&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[o.toString(),a?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):r}}function Io({className:s="",title:t="Sign in to your account"}){const{isModalOpen:o,closeModal:a}=T.useCedrosLogin(),r=i.useRef(null),n=i.useRef(null),c=i.useRef(a);if(i.useEffect(()=>{c.current=a},[a]),i.useEffect(()=>{if(!o)return;n.current=document.activeElement,r.current?.focus();const d=m=>{if(m.key==="Escape"&&c.current(),m.key==="Tab"&&r.current){const f=r.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),g=f[0],w=f[f.length-1];m.shiftKey&&document.activeElement===g?(m.preventDefault(),w?.focus()):!m.shiftKey&&document.activeElement===w&&(m.preventDefault(),g?.focus())}};document.addEventListener("keydown",d);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=u,n.current instanceof HTMLElement&&n.current.focus()}},[o]),!o)return null;const l=d=>{d.target===d.currentTarget&&a()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,onClick:l,role:"presentation",children:e.jsxs("div",{ref:r,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:t}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:a,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(pr,{children:e.jsx(ss,{onSuccess:a})})})]})})}function Do({token:s,onSuccess:t,onLoginClick:o,className:a=""}){const[r,n]=i.useState(""),[c,l]=i.useState(""),[d,u]=i.useState(null),{resetPassword:m,isLoading:f,isSuccess:g,error:w,clearError:p}=es(),h=r===c,y=d?.isValid&&h&&r.length>0,b=async x=>{if(x.preventDefault(),!!y)try{await m(s,r),t?.()}catch{}};return g?e.jsxs("div",{className:`cedros-reset-password-success ${a}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:o,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${a}`,onSubmit:b,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Reset your password"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your new password below."})]}),e.jsx(Y.ErrorMessage,{error:w,onDismiss:p}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"New password",value:r,onChange:x=>{n(x.target.value),u(we.validatePassword(x.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:f,autoComplete:"new-password",error:d&&!d.isValid?Object.values(d.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"Confirm password",value:c,onChange:x=>l(x.target.value),disabled:f,autoComplete:"new-password",error:c&&!h?"Passwords do not match":void 0})}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-md cedros-button-primary cedros-button-full",disabled:f||!y,children:f?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:o,disabled:f,children:"Back to login"})]})]})}function _s({org:s,size:t="lg",className:o=""}){const a=Os.sanitizeImageUrl(s.logoUrl),r=t==="lg"?"cedros-org-avatar-lg":"",n=["cedros-org-avatar",r,o].filter(Boolean).join(" "),c=["cedros-org-avatar-placeholder",r,o].filter(Boolean).join(" ");return a?e.jsx("img",{src:a,alt:s.name,className:n,referrerPolicy:"no-referrer"}):e.jsx("div",{className:c,children:s.name[0]?.toUpperCase()||"?"})}function Fo({orgs:s,activeOrg:t,isLoading:o=!1,onSelect:a,onCreateClick:r,className:n="",placeholder:c="Select organization"}){const[l,d]=i.useState(!1),u=i.useRef(null);i.useEffect(()=>{const w=p=>{u.current&&!u.current.contains(p.target)&&d(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),i.useEffect(()=>{const w=p=>{p.key==="Escape"&&d(!1)};if(l)return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[l]);const m=i.useCallback(w=>{a(w),d(!1)},[a]),f=i.useCallback(()=>{d(!1),r?.()},[r]),g=i.useCallback(()=>{d(w=>!w)},[]);return o?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${n}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:u,className:`cedros-org-selector ${n}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:g,"aria-haspopup":"listbox","aria-expanded":l,children:[t?e.jsxs(e.Fragment,{children:[e.jsx(_s,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(pt,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:c}),e.jsx(Uo,{isOpen:l})]}),l&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[s.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:s.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${w.id===t?.id?"cedros-org-selector-item-active":""}`,onClick:()=>m(w.id),role:"option","aria-selected":w.id===t?.id,children:[e.jsx(_s,{org:w,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:w.name}),e.jsx(pt,{role:w.membership.role}),w.id===t?.id&&e.jsx(_o,{})]})},w.id))}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:f,children:[e.jsx(Wo,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function pt({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function Uo({isOpen:s}){return e.jsx("svg",{className:`cedros-org-chevron ${s?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function _o(){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 Wo(){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 Oo(){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 qo(){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 zo(){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 Vo({orgs:s,activeOrg:t,isLoading:o,onSelect:a,onCreateClick:r}){return o?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[s.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:s.map(n=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${n.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>a(n.id),children:[e.jsx(_s,{org:n}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:n.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",n.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${n.membership.role}`,children:n.membership.role}),n.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),n.id===t?.id&&e.jsx(qo,{})]})},n.id))}),r&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:r,children:[e.jsx(zo,{}),e.jsx("span",{children:"Create new organization"})]})]})}function Ho({isLoading:s,onSubmit:t,onCancel:o}){const[a,r]=i.useState(""),[n,c]=i.useState(""),[l,d]=i.useState(null),u=i.useCallback(f=>{r(f);const g=f.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);c(g)},[]),m=i.useCallback(async f=>{if(f.preventDefault(),d(null),!a.trim()){d("Organization name is required");return}if(!n.trim()){d("Organization slug is required");return}try{await t({name:a.trim(),slug:n.trim()})}catch(g){d(g.message||"Failed to create organization")}},[a,n,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:m,children:[l&&e.jsx(Y.ErrorMessage,{error:l}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:a,onChange:f=>u(f.target.value),placeholder:"My Organization",maxLength:255,disabled:s,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:n,onChange:f=>c(f.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:s})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:o,disabled:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!a.trim()||!n.trim(),children:s?e.jsx(_.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function Qo({isOpen:s,onClose:t,orgs:o,activeOrg:a,isLoading:r=!1,error:n,onSelect:c,onCreate:l,className:d=""}){return s?e.jsx(Ko,{onClose:t,orgs:o,activeOrg:a,isLoading:r,error:n,onSelect:c,onCreate:l,className:d}):null}function Ko({onClose:s,orgs:t,activeOrg:o,isLoading:a=!1,error:r,onSelect:n,onCreate:c,className:l}){const[d,u]=i.useState("list"),m=i.useRef(null),f=i.useRef(null);i.useEffect(()=>(f.current=document.activeElement,m.current?.querySelector(".cedros-modal-close")?.focus(),()=>{f.current?.focus()}),[]),i.useEffect(()=>{const h=y=>{if(y.key==="Escape"){s();return}if(y.key==="Tab"&&m.current){const b=m.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),x=b[0],v=b[b.length-1];y.shiftKey?document.activeElement===x&&(y.preventDefault(),v?.focus()):document.activeElement===v&&(y.preventDefault(),x?.focus())}};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[s]);const g=i.useCallback(h=>{h.target===h.currentTarget&&s()},[s]),w=i.useCallback(h=>{n(h),s()},[n,s]),p=i.useCallback(async h=>{await c?.(h),s()},[c,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:g,children:e.jsxs("div",{ref:m,className:`cedros-modal cedros-org-switcher ${l}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:d==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(Oo,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[r&&e.jsx(Y.ErrorMessage,{error:r}),d==="list"?e.jsx(Vo,{orgs:t,activeOrg:o,isLoading:a,onSelect:w,onCreateClick:c?()=>u("create"):void 0}):e.jsx(Ho,{isLoading:a,onSubmit:p,onCancel:()=>u("list")})]})]})})}function mr({sessions:s,isLoading:t=!1,error:o,onRevokeAll:a,className:r=""}){const[n,c]=i.useState(!1),[l,d]=i.useState(!1),u=i.useRef(null),m=i.useMemo(()=>s.filter(g=>!g.isCurrent).length,[s]),f=i.useCallback(async()=>{if(!a)return;const g=s.filter(p=>!p.isCurrent).length;if(!(g===0||!window.confirm(`Are you sure you want to sign out of ${g} other device(s)? This will log you out everywhere except this browser.`))){c(!0),d(!1);try{await a(),d(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(!1),u.current=null},3e3)}finally{c(!1)}}},[a,s]);return i.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${r}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):o?e.jsx("div",{className:`cedros-session-list ${r}`,children:e.jsx(Y.ErrorMessage,{error:o})}):s.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${r}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${r}`,children:[l&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(Zo,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(g=>e.jsx(Yo,{session:g},g.id))}),a&&m>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:f,disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${m} other device${m>1?"s":""}`})})]})}function Yo({session:s}){const t=Go(s.userAgent),o=Jo(s.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${s.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(Xo,{userAgent:s.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[t.browser," on ",t.os]}),s.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[s.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",s.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",$o(s.createdAt)]}),o&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function Go(s){if(!s)return{browser:"Unknown browser",os:"Unknown device"};let t="Unknown browser";s.includes("Chrome")&&!s.includes("Edg")?t="Chrome":s.includes("Safari")&&!s.includes("Chrome")?t="Safari":s.includes("Firefox")?t="Firefox":s.includes("Edg")&&(t="Edge");let o="Unknown device";return s.includes("Windows")?o="Windows":s.includes("Mac")?o="macOS":s.includes("Linux")?o="Linux":s.includes("iPhone")||s.includes("iPad")?o="iOS":s.includes("Android")&&(o="Android"),{browser:t,os:o}}function $o(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),r=Math.floor(a/(1e3*60)),n=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return r<1?"just now":r<60?`${r} minute${r>1?"s":""} ago`:n<24?`${n} hour${n>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Jo(s){const t=new Date(s),o=new Date,a=3600*1e3;return t.getTime()-o.getTime()<a}function Xo({userAgent:s}){return s?.includes("iPhone")||s?.includes("iPad")||s?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function Zo(){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 fr({words:s,onConfirm:t,className:o=""}){const[a,r]=i.useState(!1),[n,c]=i.useState(!1),l=i.useRef(null),d=Co(s),u=i.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),r(!0),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>r(!1),2e3)}catch{}},[s]);i.useEffect(()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]);const m=i.useCallback(()=>{n&&t()},[n,t]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${o}`,children:[e.jsxs("div",{className:"cedros-recovery-header",children:[e.jsx("h3",{className:"cedros-recovery-title",children:"Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-warning",children:"Write down these 12 words in order and store them securely. This is the only way to recover your wallet if you lose access."})]}),e.jsx("div",{className:"cedros-recovery-grid",children:d.map((f,g)=>e.jsx("div",{className:"cedros-word-group",children:f.map((w,p)=>{const h=g*4+p+1;return e.jsxs("div",{className:"cedros-word-item",children:[e.jsxs("span",{className:"cedros-word-number",children:[h,"."]}),e.jsx("span",{className:"cedros-word-text",children:w})]},h)})},g))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,children:a?"Copied!":"Copy to Clipboard"}),e.jsx("div",{className:"cedros-recovery-security",children:e.jsxs("div",{className:"cedros-warning-box",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M10 6v4m0 4h.01M19 10a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsxs("div",{className:"cedros-warning-content",children:[e.jsx("strong",{children:"Security Warning"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Never share this phrase with anyone"}),e.jsx("li",{children:"Store it offline in a secure location"}),e.jsx("li",{children:"Anyone with this phrase can access your wallet"}),e.jsx("li",{children:"Cedros cannot recover this phrase for you"})]})]})]})}),e.jsxs("div",{className:"cedros-recovery-confirm",children:[e.jsxs("label",{className:"cedros-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:f=>c(f.target.checked),className:"cedros-checkbox"}),e.jsx("span",{children:"I have written down and securely stored my recovery phrase"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,disabled:!n,children:"Continue"})]})]})}function gr({onSubmit:s,onCancel:t,isSubmitting:o=!1,error:a,className:r=""}){const[n,c]=i.useState(Array(oe).fill("")),[l,d]=i.useState(null),[u,m]=i.useState([]),[f,g]=i.useState(null),w=i.useId(),p=i.useRef(null),h=i.useCallback((A,N)=>{const S=[...n];if(S[A]=N.toLowerCase().trim(),c(S),N.length>0){const j=No(N,5);m(j)}else m([]);g(null)},[n]),y=i.useCallback(A=>{d(A),m([])},[]),b=i.useCallback(A=>{const N=n[A];N&&!We(N)&&g(`Word ${A+1} is not in the wordlist`),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{l===A&&m([])},200)},[n,l]);i.useEffect(()=>()=>{p.current!==null&&(window.clearTimeout(p.current),p.current=null)},[]);const x=i.useCallback(A=>{if(l!==null){const N=[...n];N[l]=A,c(N),m([]),document.querySelector(`[data-word-index="${l+1}"]`)?.focus()}},[l,n]),v=i.useCallback(A=>{const N=A.clipboardData.getData("text"),S=So(N);S.length===oe&&(A.preventDefault(),c(S),g(null))},[]),k=i.useCallback(A=>{if(A.preventDefault(),n.filter(j=>!j).length>0){g(`Please enter all ${oe} words`);return}const S=n.map((j,P)=>({word:j,index:P+1})).filter(({word:j})=>!We(j));if(S.length>0){g(`Invalid words: ${S.map(j=>`#${j.index}`).join(", ")}`);return}if(!nr(n)){g("Invalid recovery phrase - please check your words");return}s(n)},[n,s]),C=a||f;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${r}`,onSubmit:k,onPaste:v,children:[e.jsxs("div",{className:"cedros-recovery-input-header",children:[e.jsx("h3",{className:"cedros-recovery-input-title",children:"Enter Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-input-description",children:"Enter your 12-word recovery phrase. You can paste the entire phrase at once."})]}),e.jsx("div",{className:"cedros-word-inputs",children:Array.from({length:oe},(A,N)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[N+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${n[N]&&!We(n[N])?"cedros-word-invalid":n[N]&&We(n[N])?"cedros-word-valid":""}`,value:n[N],onChange:S=>h(N,S.target.value),onFocus:()=>y(N),onBlur:()=>b(N),"data-word-index":N,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:o,"aria-label":`Word ${N+1}`})]},N))}),l!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${w}-suggestions`,children:u.map(A=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>x(A),role:"option",children:A},A))}),C&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:C}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:o,children:o?"Recovering...":"Recover Wallet"})]})]})}function en({capabilities:s,className:t=""}){if(s.allSupported)return null;const o=I.getMissingCapabilitiesMessage(s),a=I.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${t}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:o}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",a.browser," ",a.version,a.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:s.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",s.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:s.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",s.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:s.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",s.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",s.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",s.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:s.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",s.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const sn=["share_c_only","full_seed","none"];function tn(s){return s&&sn.includes(s)?s:"share_c_only"}const rn={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function wr(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(null),[a,r]=i.useState(!!s),[n,c]=i.useState(null),l=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),d=i.useCallback(async()=>{if(l){r(!0),c(null);try{const u=await l.get("/discovery");u.wallet?o({enabled:u.wallet.enabled,recoveryMode:tn(u.wallet.recoveryMode),unlockTtlSeconds:u.wallet.unlockTtlSeconds}):o({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(u){const m=u instanceof Error?u.message:"Failed to fetch wallet config";c(m),o({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{r(!1)}}},[l]);return i.useEffect(()=>{l&&d()},[l,d]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:a,error:n,refetch:d}:rn}function yr(){const{user:s}=T.useCedrosLogin(),{enroll:t}=I.useWalletMaterial(),{recoveryMode:o}=wr(),[a,r]=i.useState({step:"idle"}),[n,c]=i.useState(!1),l=i.useRef([]),d=i.useCallback(()=>{I.wipeAll(...l.current),l.current=[]},[]);i.useEffect(()=>()=>{d()},[d]);const u=i.useCallback(async(p,h,y,b)=>{r({step:"generating_seed"});const x=I.generateSeed();l.current.push(x),r({step:"splitting_shares"});const{shareA:v,shareB:k,shareC:C}=ie.splitSecret(x);l.current.push(v,k,C),r({step:"encrypting_shares"});const A=await I.aesGcmEncryptToBase64(v,I.toEncryptionKey(h)),N=ie.getPublicKeyFromSeed(x),S=ie.publicKeyToBase58(N);r({step:"uploading"});const j={solanaPubkey:S,shareAAuthMethod:p,shareACiphertext:A.ciphertext,shareANonce:A.nonce,shareB:I.uint8ArrayToBase64(k)};if(p==="password"){if(!y)throw new Error("KDF salt required for password method");j.shareAKdfSalt=I.uint8ArrayToBase64(y),j.shareAKdfParams=I.DEFAULT_KDF_PARAMS}if(p==="passkey"&&b&&(j.prfSalt=b),await t(j),o==="none")d(),r({step:"complete",solanaPubkey:S});else{const P=o==="full_seed"?jo(x):Ao(I.toShamirShare(C));r({step:"showing_recovery",recoveryPhrase:P,solanaPubkey:S})}},[t,o,d]),m=i.useCallback(async p=>{if(!s){r({step:"error",error:"User not authenticated"});return}c(!0),d();try{const h=I.generateArgon2Salt(),y=await ie.argon2DeriveInWorker(p,h,I.DEFAULT_KDF_PARAMS);l.current.push(y),await u("password",y,h)}catch(h){r({step:"error",error:h instanceof Error?h.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),f=i.useCallback(async()=>{if(!s){r({step:"error",error:"User not authenticated"});return}c(!0),d();try{const p=I.generatePrfSalt(),h=I.uint8ArrayToBase64(p);r({step:"registering_passkey"});let y;try{const x=new TextEncoder().encode(s.id),v=s.name??s.email??"User",k=s.email??s.id;y=(await I.registerPasskeyWithPrf(x,k,v,p)).prfOutput}catch(x){if(x?.name!=="InvalidStateError")throw x;y=(await I.authenticateWithDiscoverablePrf(h)).prfOutput}l.current.push(y);const b=await I.deriveKeyFromPrf(y,p);l.current.push(b),await u("passkey",b,void 0,h)}catch(p){r({step:"error",error:p instanceof Error?p.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),g=i.useCallback(()=>{const p=a.solanaPubkey;d(),r({step:"complete",solanaPubkey:p})},[a.solanaPubkey,d]),w=i.useCallback(()=>{d(),r({step:"idle"}),c(!1)},[d]);return{state:a,startEnrollmentWithPassword:m,startEnrollmentWithPasskey:f,confirmRecoveryPhrase:g,cancel:w,isEnrolling:n}}function br({onComplete:s,onCancel:t,className:o="",forceAuthMethod:a}){const{user:r}=T.useCedrosLogin(),{state:n,startEnrollmentWithPassword:c,startEnrollmentWithPasskey:l,confirmRecoveryPhrase:d,cancel:u,isEnrolling:m}=yr(),f=()=>a||"password",[g,w]=i.useState(f),[p,h]=i.useState(""),[y,b]=i.useState(""),[x,v]=i.useState(null);i.useEffect(()=>{w(f())},[r?.id,a]);const k=i.useCallback(async S=>{if(S.preventDefault(),p!==y){v("Passwords do not match");return}const j=we.validatePassword(p);if(!j.isValid){const P=Object.values(j.errors)[0];v(P??"Password does not meet requirements");return}v(null),await c(p)},[p,y,c]),C=i.useCallback(async()=>{await l()},[l]),A=i.useCallback(()=>{d(),n.solanaPubkey&&s?.(n.solanaPubkey)},[d,n.solanaPubkey,s]),N=i.useCallback(()=>{u(),t?.()},[u,t]);return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Generating secure wallet..."})]})}):n.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Encrypting wallet shares..."})]})}):n.step==="registering_passkey"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsx("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:e.jsxs("div",{className:"cedros-passkey-prompt",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Authenticate with Passkey"}),e.jsx("p",{children:"Follow your browser's prompt to use your passkey."})]})})}):n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Saving wallet..."})]})}):n.step==="showing_recovery"&&n.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsx(fr,{words:n.recoveryPhrase,onConfirm:A})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsxs("div",{className:"cedros-enrollment-complete",children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M16 24l6 6 12-12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{children:"Wallet Created!"}),e.jsxs("p",{className:"cedros-pubkey",children:[e.jsx("strong",{children:"Address:"})," ",n.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsxs("div",{className:"cedros-enrollment-error",children:[e.jsxs("svg",{className:"cedros-error-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 16v12m0 6h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Enrollment Failed"}),e.jsx("p",{className:"cedros-error-message",children:n.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>u(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${o}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),e.jsxs("p",{children:["Secure your wallet with a ",g==="passkey"?"passkey":"password","."]})]}),!a&&e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:g==="password",onChange:()=>w("password"),disabled:m}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:g==="passkey",onChange:()=>w("passkey"),disabled:m}),e.jsx("span",{children:"Passkey"})]})]}),g==="password"&&e.jsxs("form",{onSubmit:k,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"Password",value:p,onChange:S=>h(S.target.value),showStrengthMeter:!0,disabled:m,required:!0,minLength:8,placeholder:"Enter a strong password"}),e.jsx(Q.PasswordInput,{label:"Confirm Password",value:y,onChange:S=>b(S.target.value),error:x??void 0,disabled:m,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,disabled:m,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:m||!p||!y,children:m?"Creating...":"Continue"})]})]}),g==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."}),e.jsx("p",{children:"You'll use the same passkey to sign transactions."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,disabled:m,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:C,disabled:m,children:m?"Creating...":"Use Passkey"})]})]})]})}function xr(){const{user:s}=T.useCedrosLogin(),{signTransaction:t}=I.useWalletMaterial(),[o,a]=i.useState(!1),[r,n]=i.useState(null),c=i.useCallback(async(d,u)=>{if(!s){const m="User not authenticated";throw n(m),new Error(m)}a(!0),n(null);try{const m={transaction:I.uint8ArrayToBase64(d),...u?{credential:I.toCredentialRequest(u)}:{}},f=await t(m);return I.base64ToUint8Array(f.signature)}catch(m){const f=m instanceof Error?m.message:"Signing failed";throw n(f),m}finally{a(!1)}},[s,t]),l=i.useCallback(()=>n(null),[]);return{signTransaction:c,isSigning:o,error:r,clearError:l}}function Ar(){const{getMaterial:s}=I.useWalletMaterial(),[t,o]=i.useState(!1),[a,r]=i.useState(null),n=i.useCallback(async()=>{o(!0),r(null);try{const l=await s();if(!l)throw new Error("No wallet enrolled");if(l.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!l.prfSalt)throw new Error("No PRF salt configured for wallet");const d=await I.authenticateWithDiscoverablePrf(l.prfSalt);try{return{type:"prfOutput",prfOutput:I.uint8ArrayToBase64(d.prfOutput)}}finally{d.prfOutput.fill(0)}}catch(l){const d=l instanceof Error?l.message:"Passkey authentication failed";return r(d),null}finally{o(!1)}},[s]),c=i.useCallback(()=>r(null),[]);return{getPasskeyCredential:n,isAuthenticating:t,error:a,clearError:c}}function vr({mode:s,isLoading:t=!1,error:o,onPrompt:a,onRetry:r,onCancel:n,title:c,description:l,className:d=""}){const u=i.useCallback(()=>{t||a?.()},[t,a]),m=i.useCallback(()=>{r?.()},[r]),f=s==="register"?"Set Up Passkey":"Verify with Passkey",g=s==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${d}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(nn,{}):o?e.jsx(an,{}):e.jsx(on,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:c??f}),e.jsx("p",{className:"cedros-passkey-description",children:l??g}),o&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:o})}),e.jsx("div",{className:"cedros-passkey-actions",children:o?e.jsxs(e.Fragment,{children:[r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:m,children:"Try Again"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:n,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:u,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):s==="register"?"Create Passkey":"Use Passkey"}),n&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:n,children:"Cancel"})]})}),t&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",s==="register"?"create":"verify"," your passkey."]})]})}function on(){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 nn(){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 an(){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 jr({onUnlock:s,onCancel:t,showCancel:o=!0,authMethod:a,className:r=""}){T.useCedrosLogin();const{unlock:n,getMaterial:c,isLoading:l}=I.useWalletMaterial(),{getPasskeyCredential:d,isAuthenticating:u}=Ar(),[m,f]=i.useState("idle"),[g,w]=i.useState(a??null),[p,h]=i.useState(""),[y,b]=i.useState(null);i.useEffect(()=>{a!==void 0&&w(a)},[a]);const x=g==="password",v=g==="passkey",k=i.useCallback(async()=>{if(f("credential"),b(null),!g)try{const L=await c();L?w(L.shareAAuthMethod):(b("No wallet enrolled"),f("error"))}catch(L){b(L instanceof Error?L.message:"Failed to get wallet info"),f("error")}},[g,c]),C=i.useCallback(async L=>{L.preventDefault(),b(null),f("unlocking");try{let E;if(x)E={type:"password",password:p};else throw new Error("Invalid auth method");await n(E),f("unlocked"),s?.()}catch(E){b(E instanceof Error?E.message:"Failed to unlock wallet"),f("error")}},[x,p,n,s]),A=i.useCallback(async()=>{b(null),f("unlocking");try{const L=await d();if(!L){f("credential");return}await n(L),f("unlocked"),s?.()}catch(L){b(L instanceof Error?L.message:"Failed to unlock wallet"),f("error")}},[d,n,s]),N=i.useCallback(()=>{h(""),f("idle"),b(null),t?.()},[t]),S=i.useCallback(()=>{h(""),f("credential"),b(null)},[]),j=l||u,P=()=>{switch(m){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(ln,{})}),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:k,children:"Unlock Wallet"})]});case"credential":return x?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:C,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:p,onChange:L=>h(L.target.value),disabled:j,autoComplete:"current-password",error:y??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:j||p.length===0,children:j?"Unlocking...":"Unlock"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,disabled:j,children:"Cancel"})]})]}):v?e.jsxs("div",{className:"cedros-wallet-unlock-passkey",children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Verify with Passkey"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Use your passkey to unlock your wallet."}),e.jsx(vr,{mode:"authenticate",isLoading:j,error:y??void 0,onPrompt:A,onRetry:A,onCancel:o?N:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(_.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(_.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(cn,{})}),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(dn,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:y??"Failed to unlock wallet. Please try again."}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,children:"Try Again"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${r}`,children:P()})}function ln(){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 cn(){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 dn(){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 kr(){const{recover:s,getShareBForRecovery:t}=I.useWalletMaterial(),{recoveryMode:o}=wr(),[a,r]=i.useState({step:"idle"}),[n,c]=i.useState(!1),l=i.useRef([]),d=i.useCallback(()=>{I.wipeAll(...l.current),l.current=[]},[]);i.useEffect(()=>()=>{d()},[d]);const u=i.useCallback(async(f,g,w)=>{c(!0),d();try{if(r({step:"validating"}),!nr(f))throw new Error("Invalid recovery phrase. Please check your words.");let p;if(o==="share_c_only"){const S=vo(f);l.current.push(S);const j=I.uint8ArrayToBase64(S),P=await t({shareC:j}),L=I.base64ToUint8Array(P.shareB);l.current.push(L),p=ie.combineShares(I.toShamirShare(L),I.toShamirShare(S)),l.current.push(p)}else p=ko(f),l.current.push(p);const h=ie.getPublicKeyFromSeed(p),y=ie.publicKeyToBase58(h),{shareA:b,shareB:x}=ie.splitSecret(p);l.current.push(b,x),r({step:"encrypting"});let v,k,C;if(g==="passkey"){const S=I.generatePrfSalt();C=I.uint8ArrayToBase64(S);const j=await I.authenticateWithDiscoverablePrf(C);l.current.push(j.prfOutput),v=await I.deriveKeyFromPrf(j.prfOutput,S),l.current.push(v)}else k=I.generateArgon2Salt(),v=await ie.argon2DeriveInWorker(w,k,I.DEFAULT_KDF_PARAMS),l.current.push(v);const A=await I.aesGcmEncryptToBase64(b,I.toEncryptionKey(v));r({step:"uploading"});const N={solanaPubkey:y,shareAAuthMethod:g,shareACiphertext:A.ciphertext,shareANonce:A.nonce,shareB:I.uint8ArrayToBase64(x)};g==="password"&&(N.shareAKdfSalt=I.uint8ArrayToBase64(k),N.shareAKdfParams=I.DEFAULT_KDF_PARAMS),g==="passkey"&&(N.prfSalt=C),await s(N),d(),r({step:"complete"})}catch(p){d(),r({step:"error",error:p instanceof Error?p.message:"Recovery failed"})}finally{c(!1)}},[s,t,o,d]),m=i.useCallback(()=>{d(),r({step:"idle"}),c(!1)},[d]);return{state:a,startRecovery:u,cancel:m,isRecovering:n}}function Nr({onComplete:s,onCancel:t,className:o="",defaultAuthMethod:a="password"}){const{state:r,startRecovery:n,cancel:c,isRecovering:l}=kr(),[d,u]=i.useState([]),[m,f]=i.useState(!1),[g,w]=i.useState(a),[p,h]=i.useState(""),[y,b]=i.useState(""),[x,v]=i.useState(null),k=i.useCallback(j=>{u(j),f(!0)},[]),C=i.useCallback(async j=>{if(j.preventDefault(),v(null),g!=="passkey"){if(p!==y){v("Passwords do not match");return}if(g==="password"&&p.length<8){v("Password must be at least 8 characters");return}}await n(d,g,p)},[d,g,p,y,n]),A=i.useCallback(()=>{c(),u([]),f(!1),h(""),b(""),t?.()},[c,t]),N=i.useCallback(()=>{f(!1),h(""),b("")},[]),S=i.useCallback(()=>{s?.()},[s]);return r.step==="validating"||r.step==="encrypting"||r.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(un,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[r.step==="validating"&&"Validating Recovery Phrase",r.step==="encrypting"&&"Encrypting Wallet",r.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[r.step==="validating"&&"Checking your recovery phrase...",r.step==="encrypting"&&"Securing your wallet with new encryption...",r.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):r.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(hn,{})}),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"," ",g==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,children:"Done"})})]})}):r.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(pn,{})}),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:A,children:"Start Over"})})]})}):m?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:C,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:g==="password",onChange:()=>w("password"),disabled:l}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:g==="passkey",onChange:()=>w("passkey"),disabled:l}),e.jsx("span",{children:"Passkey"})]})]}),g==="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:p,onChange:j=>h(j.target.value),disabled:l,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:y,onChange:j=>b(j.target.value),disabled:l,"aria-invalid":x?"true":void 0,placeholder:"Confirm your password"}),x&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:x})]})]}),g==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(mn,{}),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:N,disabled:l,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:l||g!=="passkey"&&(p.length===0||y.length===0),children:l?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-phrase",children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recover Your Wallet"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Enter your 12-word recovery phrase to restore your wallet."})]}),e.jsx(gr,{onSubmit:k,onCancel:A,isSubmitting:!1})]})})}function un(){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 hn(){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 pn(){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 mn(){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 Cr({address:s,label:t="Wallet Address",showCopy:o=!0,showExplorerLink:a=!0,allowReveal:r=!0,className:n=""}){const c=T.useCedrosLoginOptional(),[l,d]=i.useState(!1),[u,m]=i.useState(null),[f,g]=i.useState(!1),w=i.useRef(null),p=c?.config.solana?.network??"mainnet-beta",h=i.useMemo(()=>{const v=`https://explorer.solana.com/address/${s}`;return p==="mainnet-beta"?v:`${v}?cluster=${encodeURIComponent(p)}`},[s,p]),y=r&&s.length>18,b=i.useMemo(()=>!y||f?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,y,f]),x=i.useCallback(async()=>{try{m(null),await navigator.clipboard.writeText(s),d(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{d(!1),w.current=null},2e3)}catch(v){d(!1),m(v instanceof Error?v.message:"Copy failed")}},[s]);return i.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${n}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:t}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[y&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>g(v=>!v),"aria-label":f?"Hide full wallet address":"Show full wallet address",children:f?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.7 10.7a3 3 0 0 0 4.24 4.24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.88 5.09A10.94 10.94 0 0 1 12 5c5 0 9.27 3.11 11 7-0.55 1.23-1.32 2.33-2.27 3.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.61 6.61C4.4 7.9 2.74 9.8 1 12c1.73 3.89 6 7 11 7 1.14 0 2.25-0.16 3.3-0.46",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),a&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:h,target:"_blank",rel:"noreferrer",children:"Explorer"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:x,"aria-label":"Copy wallet address",children:l?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:b}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function Sr({status:s,publicKey:t,onLock:o,onEnroll:a,onUnlock:r,onRecover:n,showActions:c=!0,compact:l=!1,className:d=""}){const u=s!==void 0,m=I.useWallet(),f=u?s:m.status,g=u?t??null:m.solanaPubkey,w=u?null:m.error,p=u?()=>{}:m.refresh,h=u?()=>{}:m.clearError,y=fn(f,w);return l?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${d}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${y.color}`,title:y.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:y.label}),g&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:g,children:gn(g)})]}):e.jsxs("div",{className:`cedros-wallet-status ${d}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${y.color}`,children:e.jsx(wn,{status:f})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:y.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:y.description})]})]}),g&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(Cr,{address:g})}),w&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:w}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:h,children:"Dismiss"})]}),c&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[f==="not_enrolled"&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,children:"Create Wallet"}),f==="enrolled_locked"&&r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:r,children:"Unlock Wallet"}),(f==="not_enrolled"||f==="error")&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:n,children:"Recover Wallet"}),f==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:p,children:"Retry"})]})]})}function fn(s,t){switch(s){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:t??"An error occurred with your wallet.",color:"error"}}}function gn(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function wn({status:s}){switch(s){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function yn({className:s="",showActions:t=!0}){const o=I.useWallet(),[a,r]=i.useState("status"),n=i.useMemo(()=>{switch(a){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[a]),c=i.useCallback(()=>r("status"),[]),l=i.useCallback(async()=>{r("status"),await o.refresh()},[o]),d=i.useCallback(async()=>{r("status"),await o.refresh()},[o]),u=i.useCallback(async()=>{r("status"),await o.refresh()},[o]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[a!=="status"&&n&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:n.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:n.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:c,children:"Back"})]}),a==="status"&&e.jsx(Sr,{onEnroll:()=>r("enroll"),onUnlock:()=>r("unlock"),onRecover:()=>r("recover_intro"),showActions:t}),a==="enroll"&&e.jsx(br,{onComplete:()=>{l()},onCancel:c}),a==="unlock"&&e.jsx(jr,{onUnlock:()=>{d()},onCancel:c}),a==="recover_intro"&&e.jsx("div",{className:"cedros-wallet-manager-intro",children:e.jsxs("div",{className:"cedros-wallet-manager-intro-card",children:[e.jsx("h4",{className:"cedros-wallet-manager-intro-title",children:"Before you start"}),e.jsxs("ul",{className:"cedros-wallet-manager-intro-list",children:[e.jsx("li",{children:"You’ll need your 12-word recovery phrase."}),e.jsx("li",{children:"You’ll set a new password or passkey for this wallet."}),e.jsx("li",{children:"If you’re on a shared device, avoid copying the phrase into other apps."})]}),e.jsxs("div",{className:"cedros-wallet-manager-intro-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>r("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:c,children:"Cancel"})]})]})}),a==="recover"&&e.jsx(Nr,{onComplete:()=>{u()},onCancel:c})]})}function bn({showDescriptions:s=!0,className:t="",onSave:o}){const{settings:a,isLoading:r,isUpdating:n,error:c,fetchSettings:l,updateSettings:d}=Yt.useSystemSettings(),[u,m]=i.useState({}),[f,g]=i.useState(null),[w,p]=i.useState(!1);i.useEffect(()=>{l()},[l]),i.useEffect(()=>{if(w){const C=setTimeout(()=>p(!1),3e3);return()=>clearTimeout(C)}},[w]);const h=i.useCallback((C,A)=>{m(N=>({...N,[C]:A})),g(null),p(!1)},[]),y=i.useCallback(async()=>{const C=Object.entries(u).map(([A,N])=>({key:A,value:N}));if(C.length!==0)try{await d(C),m({}),g(null),p(!0),o?.()}catch(A){g(A instanceof Error?A.message:"Failed to save settings")}},[u,d,o]),b=i.useCallback(()=>{m({}),g(null),p(!1)},[]),x=Object.keys(u).length>0,v=Object.keys(u).length;if(r&&Object.keys(a).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(c)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(Y.ErrorMessage,{error:c.message})});const k=Object.keys(a).sort();return k.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${t}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${t}`,children:[f&&e.jsx(Y.ErrorMessage,{error:f}),w&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),k.map(C=>e.jsx(xn,{category:C,settings:a[C],edits:u,showDescription:s,onChange:h},C)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[x&&e.jsxs("span",{className:"cedros-settings-change-count",children:[v," unsaved change",v!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:b,disabled:!x||n,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:y,disabled:!x||n,children:n?e.jsx(_.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const mt=Object.keys(je.SETTING_METADATA);function xn({category:s,settings:t,edits:o,showDescription:a,onChange:r}){const n=je.CATEGORY_METADATA[s]||{label:s,description:"",icon:""},c=i.useMemo(()=>[...t].sort((l,d)=>{const u=mt.indexOf(l.key),m=mt.indexOf(d.key);return(u===-1?1/0:u)-(m===-1?1/0:m)}),[t]);return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:n.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:n.label}),a&&n.description&&e.jsx("p",{className:"cedros-settings-section-description",children:n.description})]})]}),e.jsx(je.SettingsSection,{settings:c,edits:o,onChange:r})]})}class An{client;constructor(t,o,a){this.client=new T.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a})}async getStatus(){try{return await this.client.get("/setup/status")}catch(t){throw T.handleApiError(t,"Failed to check setup status")}}async createFirstAdmin(t){try{return await this.client.post("/setup/admin",t)}catch(o){throw T.handleApiError(o,"Failed to create admin account")}}}function Gs(){const{config:s}=T.useCedrosLogin(),[t,o]=i.useState(null),[a,r]=i.useState(!1),[n,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useRef(0),m=i.useMemo(()=>new An(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),f=i.useRef(m);f.current=m;const g=i.useCallback(async()=>{r(!0),d(null);const p=++u.current;try{const h=await f.current.getStatus();if(p!==u.current)return;o(h)}catch(h){if(p!==u.current)return;d(h instanceof Error?h:new Error("Failed to check setup status"))}finally{p===u.current&&r(!1)}},[]),w=i.useCallback(async p=>{c(!0),d(null);try{const h=await f.current.createFirstAdmin(p);return await g(),h}catch(h){const y=h instanceof Error?h:new Error("Failed to create admin");throw d(y),y}finally{c(!1)}},[g]);return{status:t,isLoading:a,isCreating:n,error:l,checkStatus:g,createAdmin:w}}const vn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ft=8;function jn(s){const t={};return s.email?vn.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<ft&&(t.password=`Password must be at least ${ft} characters`):t.password="Password is required",s.confirmPassword?s.password!==s.confirmPassword&&(t.confirmPassword="Passwords do not match"):t.confirmPassword="Please confirm your password",t}function Er({onComplete:s,className:t=""}){const{status:o,isLoading:a,isCreating:r,error:n,checkStatus:c,createAdmin:l}=Gs(),[d,u]=i.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[m,f]=i.useState({}),[g,w]=i.useState(!1);i.useEffect(()=>{c()},[c]);const p=i.useCallback(y=>b=>{u(x=>({...x,[y]:b.target.value})),f(x=>({...x,[y]:void 0}))},[]),h=i.useCallback(async y=>{y.preventDefault();const b=jn(d);if(Object.keys(b).length>0){f(b);return}try{await l({email:d.email,password:d.password,name:d.name||void 0,orgName:d.orgName||void 0}),w(!0),s?.()}catch{}},[d,l,s]);return a?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):o&&!o.needsSetup?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):g?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:h,children:[n&&e.jsx(Y.ErrorMessage,{error:n.message}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-email",className:"cedros-setup__label",children:["Email Address ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-email",type:"email",className:`cedros-setup__input ${m.email?"cedros-setup__input--error":""}`,value:d.email,onChange:p("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:r}),m.email&&e.jsx("span",{className:"cedros-setup__error",children:m.email})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-name",className:"cedros-setup__label",children:"Display Name"}),e.jsx("input",{id:"setup-name",type:"text",className:"cedros-setup__input",value:d.name,onChange:p("name"),placeholder:"Admin",autoComplete:"name",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:d.orgName,onChange:p("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 ${m.password?"cedros-setup__input--error":""}`,value:d.password,onChange:p("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:r}),m.password&&e.jsx("span",{className:"cedros-setup__error",children:m.password})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-confirm-password",className:"cedros-setup__label",children:["Confirm Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-confirm-password",type:"password",className:`cedros-setup__input ${m.confirmPassword?"cedros-setup__input--error":""}`,value:d.confirmPassword,onChange:p("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:r}),m.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:m.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Creating Account..."})]}):"Create Admin Account"})]}),e.jsxs("div",{className:"cedros-setup__footer",children:[e.jsx("p",{className:"cedros-setup__note",children:"This will be the first administrator account for your installation."}),o?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",o.serverVersion]})]})]})})}const kn=["security","rate_limit"];function Nn({className:s}){return e.jsx(Hs.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:kn,className:s})}const gt=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Cn({className:s}){const{settings:t,edits:o,isLoading:a,autosaveStatus:r,autosaveError:n,error:c,fetchSettings:l,handleChange:d,getEffectiveValue:u}=je.useSettingsAutosave(),[m,f]=i.useState("email");i.useEffect(()=>{l()},[l]);const g=gt.find(k=>k.id===m),w=g?.category??"",h=(u("email_provider")||"custom")==="custom",y=u("email_smtp_host"),b=!h||y!=null&&y!=="",x=i.useMemo(()=>{const k=t[w]??[];if(m!=="email")return k;const C=h?ze.ALL_EMAIL_FIELDS:ze.SIMPLIFIED_EMAIL_FIELDS;return k.filter(A=>C.includes(A.key)).sort((A,N)=>C.indexOf(A.key)-C.indexOf(N.key))},[t,w,m,h]),v=(k,C)=>{if(d(k,C),k==="email_provider"&&C!=="custom"){const A=ze.PROVIDER_SMTP_HOSTS[C];A&&(d("email_smtp_host",A),d("email_smtp_port","587"),d("email_smtp_tls","true"))}};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(Y.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(je.AutosaveStatus,{status:r,error:n})]}),m==="email"&&!b&&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:gt.map(k=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${m===k.id?"cedros-admin-tab-active":""}`,onClick:()=>f(k.id),"aria-selected":m===k.id,role:"tab",children:k.label},k.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:x.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",g?.label??"this section","."]})}):e.jsx(je.SettingsSection,{settings:x,edits:o,onChange:m==="email"?v:d})})]})}const ae={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]})},Sn=[{id:"users",label:"Users",icon:ae.users},{id:"team",label:"Team",icon:ae.members},{id:"deposits",label:"Deposits",icon:ae.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ae.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:ae.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ae.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ae.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ae.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:ae.server,group:"Configuration"}];function En({title:s="Dashboard",sections:t=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],defaultSection:o="users",refreshInterval:a=0,pageSize:r=20,onSectionChange:n,onSettingsClick:c,onLogoutClick:l,className:d=""}){const[u,m]=i.useState(o),[f,g]=i.useState(!0),{user:w,logout:p}=T.useCedrosLogin(),{activeOrg:h,role:y,isLoading:b,fetchOrgs:x,hasPermission:v}=zs.useOrgs(),{status:k,isLoading:C,checkStatus:A}=Gs(),{features:N,isLoading:S}=te.useServerFeatures(),{canAccess:j}=te.useDashboardPermissions(),P=i.useCallback(D=>{m(D),n?.(D)},[n]),L=Sn.filter(D=>!(!t.includes(D.id)||D.requiredFeature&&!N[D.requiredFeature]||!j(D.id))),E=L.find(D=>D.id===u),M=!E&&!S;return i.useEffect(()=>{x(),A()},[x,A]),i.useEffect(()=>{M&&L.length>0&&m("users")},[M,L.length]),!C&&k?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${d}`,children:e.jsx(Er,{onComplete:()=>A()})}):(b||C||S)&&!h?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${d}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):u==="team"&&!h?e.jsx("div",{className:`cedros-admin cedros-dashboard ${d}`,children:e.jsx(Y.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${d}`,children:[e.jsxs("aside",{className:"cedros-dashboard__sidebar",children:[e.jsx("div",{className:"cedros-dashboard__sidebar-header",children:e.jsxs("div",{className:"cedros-dashboard__logo",children:[ae.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:s})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),L.filter(D=>!D.group).map(D=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===D.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>P(D.id),"aria-current":u===D.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:D.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:D.label})]},D.id))]}),L.some(D=>D.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:()=>g(!f),"aria-expanded":f,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${f?"cedros-dashboard__nav-chevron--expanded":""}`,children:ae.chevronRight})]}),f&&L.filter(D=>D.group==="Configuration").map(D=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===D.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>P(D.id),"aria-current":u===D.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:D.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:D.label})]},D.id))]})]}),w&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(ge.ProfileDropdown,{name:w.name,email:w.email,picture:w.picture,onSettings:c,onLogout:l??p})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:s}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:ae.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:E?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(Ln,{pageSize:r,currentUserId:w?.id}),u==="team"&&h&&e.jsx(Pn,{orgId:h.id,currentUserId:w?.id,hasPermission:v,role:y}),u==="deposits"&&e.jsx(Mn,{pageSize:r,refreshInterval:a}),u==="withdrawals"&&e.jsx(Tn,{pageSize:r,refreshInterval:a}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx($t.AuthenticationSettings,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Jt.EmbeddedWalletSettings,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Cn,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Vs.CreditSystemSettings,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Xt.ServerSettings,{})})]})]})]})}function Ln({pageSize:s,currentUserId:t}){const[o,a]=i.useState(null),{statsItems:r,isLoading:n,error:c,refresh:l}=Te.useUsersStatsSummary();return o?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Te.AdminUserDetail,{userId:o.id,currentUserId:t,onBack:()=>a(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Gt.StatsBar,{stats:r,isLoading:n,onRefresh:l}),c&&e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx(Te.AdminUserList,{pageSize:s,currentUserId:t,onUserClick:d=>a(d)})]})}function Pn({orgId:s,currentUserId:t,hasPermission:o,role:a}){const[r,n]=i.useState("members"),{members:c,isLoading:l,error:d,fetchMembers:u,updateMemberRole:m,removeMember:f}=te.useMembers(s),{invites:g,isLoading:w,error:p,fetchInvites:h,createInvite:y,cancelInvite:b,resendInvite:x}=te.useInvites(s);i.useEffect(()=>{u(),h()},[u,h]);const v=o("invite:create"),k=o("invite:cancel"),C=g.length,A=c.reduce((P,L)=>(P[L.role]=(P[L.role]??0)+1,P),{}),N=A.owner??0,S=A.admin??0,j=A.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Gt.StatsBar,{stats:[{label:"Owners",value:N},{label:"Admins",value:S},{label:"Members",value:j},{label:"Pending Invites",value:C}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="members"?"cedros-admin-tab-active":""}`,onClick:()=>n("members"),"aria-selected":r==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${r==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>n("invites"),"aria-selected":r==="invites",role:"tab",children:["Pending Invites",C>0&&` (${C})`]}),a==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>n("permissions"),"aria-selected":r==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[r==="members"&&e.jsx(te.MemberList,{members:c,currentUserId:t,isLoading:l,error:d?.message,canManage:o("member:remove"),canChangeRoles:o("member:role_change"),onUpdateRole:m,onRemove:f}),r==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[v&&e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx("div",{className:"cedros-dashboard__section-header",children:e.jsx("h3",{className:"cedros-dashboard__section-title",children:"Send Invitation"})}),e.jsx(te.InviteForm,{onSubmit:y,isLoading:w,error:p?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(te.InviteList,{invites:g,isLoading:w,error:p?.message,canManage:k||v,onCancel:k?b:void 0,onResend:v?x:void 0})})]}),r==="permissions"&&a==="owner"&&e.jsx(te.PermissionsSection,{userRole:a})]})]})}function Mn({pageSize:s,refreshInterval:t}){const[o,a]=i.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(He.AdminDepositStats,{refreshInterval:t}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:o,onChange:r=>a(r.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(He.AdminDepositList,{statusFilter:o||void 0,pageSize:s,refreshInterval:t})]})]})}function Tn({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(fe.AdminWithdrawalStats,{refreshInterval:t}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(fe.AdminPrivacyPeriodDeposits,{pageSize:s,refreshInterval:t}),e.jsx(fe.AdminWithdrawalQueue,{pageSize:s,refreshInterval:t}),e.jsx(fe.AdminWithdrawalHistory,{pageSize:s,refreshInterval:t})]})]})}var Ae={},us,wt;function Rn(){return wt||(wt=1,us=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),us}var hs={},me={},yt;function ye(){if(yt)return me;yt=1;let s;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return me.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},me.getSymbolTotalCodewords=function(a){return t[a]},me.getBCHDigit=function(o){let a=0;for(;o!==0;)a++,o>>>=1;return a},me.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');s=a},me.isKanjiModeEnabled=function(){return typeof s<"u"},me.toSJIS=function(a){return s(a)},me}var ps={},bt;function $s(){return bt||(bt=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+o)}}s.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},s.from=function(a,r){if(s.isValid(a))return a;try{return t(a)}catch{return r}}})(ps)),ps}var ms,xt;function Bn(){if(xt)return ms;xt=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const o=Math.floor(t/8);return(this.buffer[o]>>>7-t%8&1)===1},put:function(t,o){for(let a=0;a<o;a++)this.putBit((t>>>o-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),t&&(this.buffer[o]|=128>>>this.length%8),this.length++}},ms=s,ms}var fs,At;function In(){if(At)return fs;At=1;function s(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return s.prototype.set=function(t,o,a,r){const n=t*this.size+o;this.data[n]=a,r&&(this.reservedBit[n]=!0)},s.prototype.get=function(t,o){return this.data[t*this.size+o]},s.prototype.xor=function(t,o,a){this.data[t*this.size+o]^=a},s.prototype.isReserved=function(t,o){return this.reservedBit[t*this.size+o]},fs=s,fs}var gs={},vt;function Dn(){return vt||(vt=1,(function(s){const t=ye().getSymbolSize;s.getRowColCoords=function(a){if(a===1)return[];const r=Math.floor(a/7)+2,n=t(a),c=n===145?26:Math.ceil((n-13)/(2*r-2))*2,l=[n-7];for(let d=1;d<r-1;d++)l[d]=l[d-1]-c;return l.push(6),l.reverse()},s.getPositions=function(a){const r=[],n=s.getRowColCoords(a),c=n.length;for(let l=0;l<c;l++)for(let d=0;d<c;d++)l===0&&d===0||l===0&&d===c-1||l===c-1&&d===0||r.push([n[l],n[d]]);return r}})(gs)),gs}var ws={},jt;function Fn(){if(jt)return ws;jt=1;const s=ye().getSymbolSize,t=7;return ws.getPositions=function(a){const r=s(a);return[[0,0],[r-t,0],[0,r-t]]},ws}var ys={},kt;function Un(){return kt||(kt=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};s.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},s.from=function(r){return s.isValid(r)?parseInt(r,10):void 0},s.getPenaltyN1=function(r){const n=r.size;let c=0,l=0,d=0,u=null,m=null;for(let f=0;f<n;f++){l=d=0,u=m=null;for(let g=0;g<n;g++){let w=r.get(f,g);w===u?l++:(l>=5&&(c+=t.N1+(l-5)),u=w,l=1),w=r.get(g,f),w===m?d++:(d>=5&&(c+=t.N1+(d-5)),m=w,d=1)}l>=5&&(c+=t.N1+(l-5)),d>=5&&(c+=t.N1+(d-5))}return c},s.getPenaltyN2=function(r){const n=r.size;let c=0;for(let l=0;l<n-1;l++)for(let d=0;d<n-1;d++){const u=r.get(l,d)+r.get(l,d+1)+r.get(l+1,d)+r.get(l+1,d+1);(u===4||u===0)&&c++}return c*t.N2},s.getPenaltyN3=function(r){const n=r.size;let c=0,l=0,d=0;for(let u=0;u<n;u++){l=d=0;for(let m=0;m<n;m++)l=l<<1&2047|r.get(u,m),m>=10&&(l===1488||l===93)&&c++,d=d<<1&2047|r.get(m,u),m>=10&&(d===1488||d===93)&&c++}return c*t.N3},s.getPenaltyN4=function(r){let n=0;const c=r.data.length;for(let d=0;d<c;d++)n+=r.data[d];return Math.abs(Math.ceil(n*100/c/5)-10)*t.N4};function o(a,r,n){switch(a){case s.Patterns.PATTERN000:return(r+n)%2===0;case s.Patterns.PATTERN001:return r%2===0;case s.Patterns.PATTERN010:return n%3===0;case s.Patterns.PATTERN011:return(r+n)%3===0;case s.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case s.Patterns.PATTERN101:return r*n%2+r*n%3===0;case s.Patterns.PATTERN110:return(r*n%2+r*n%3)%2===0;case s.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}s.applyMask=function(r,n){const c=n.size;for(let l=0;l<c;l++)for(let d=0;d<c;d++)n.isReserved(d,l)||n.xor(d,l,o(r,d,l))},s.getBestMask=function(r,n){const c=Object.keys(s.Patterns).length;let l=0,d=1/0;for(let u=0;u<c;u++){n(u),s.applyMask(u,r);const m=s.getPenaltyN1(r)+s.getPenaltyN2(r)+s.getPenaltyN3(r)+s.getPenaltyN4(r);s.applyMask(u,r),m<d&&(d=m,l=u)}return l}})(ys)),ys}var Oe={},Nt;function Lr(){if(Nt)return Oe;Nt=1;const s=$s(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Oe.getBlocksCount=function(r,n){switch(n){case s.L:return t[(r-1)*4+0];case s.M:return t[(r-1)*4+1];case s.Q:return t[(r-1)*4+2];case s.H:return t[(r-1)*4+3];default:return}},Oe.getTotalCodewordsCount=function(r,n){switch(n){case s.L:return o[(r-1)*4+0];case s.M:return o[(r-1)*4+1];case s.Q:return o[(r-1)*4+2];case s.H:return o[(r-1)*4+3];default:return}},Oe}var bs={},Me={},Ct;function _n(){if(Ct)return Me;Ct=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let a=1;for(let r=0;r<255;r++)s[r]=a,t[a]=r,a<<=1,a&256&&(a^=285);for(let r=255;r<512;r++)s[r]=s[r-255]})(),Me.log=function(a){if(a<1)throw new Error("log("+a+")");return t[a]},Me.exp=function(a){return s[a]},Me.mul=function(a,r){return a===0||r===0?0:s[t[a]+t[r]]},Me}var St;function Wn(){return St||(St=1,(function(s){const t=_n();s.mul=function(a,r){const n=new Uint8Array(a.length+r.length-1);for(let c=0;c<a.length;c++)for(let l=0;l<r.length;l++)n[c+l]^=t.mul(a[c],r[l]);return n},s.mod=function(a,r){let n=new Uint8Array(a);for(;n.length-r.length>=0;){const c=n[0];for(let d=0;d<r.length;d++)n[d]^=t.mul(r[d],c);let l=0;for(;l<n.length&&n[l]===0;)l++;n=n.slice(l)}return n},s.generateECPolynomial=function(a){let r=new Uint8Array([1]);for(let n=0;n<a;n++)r=s.mul(r,new Uint8Array([1,t.exp(n)]));return r}})(bs)),bs}var xs,Et;function On(){if(Et)return xs;Et=1;const s=Wn();function t(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(a){this.degree=a,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(a.length+this.degree);r.set(a);const n=s.mod(r,this.genPoly),c=this.degree-n.length;if(c>0){const l=new Uint8Array(this.degree);return l.set(n,c),l}return n},xs=t,xs}var As={},vs={},js={},Lt;function Pr(){return Lt||(Lt=1,js.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),js}var de={},Pt;function Mr(){if(Pt)return de;Pt=1;const s="[0-9]+",t="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
|
|
2050
|
-
]))+`;de.KANJI=new RegExp(o,"g"),de.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),de.BYTE=new RegExp(a,"g"),de.NUMERIC=new RegExp(s,"g"),de.ALPHANUMERIC=new RegExp(t,"g");const r=new RegExp("^"+o+"$"),n=new RegExp("^"+s+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return de.testKanji=function(d){return r.test(d)},de.testNumeric=function(d){return n.test(d)},de.testAlphanumeric=function(d){return c.test(d)},de}var Mt;function be(){return Mt||(Mt=1,(function(s){const t=Pr(),o=Mr();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(n,c){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?n.ccBits[0]:c<27?n.ccBits[1]:n.ccBits[2]},s.getBestModeForData=function(n){return o.testNumeric(n)?s.NUMERIC:o.testAlphanumeric(n)?s.ALPHANUMERIC:o.testKanji(n)?s.KANJI:s.BYTE},s.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},s.isValid=function(n){return n&&n.bit&&n.ccBits};function a(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+r)}}s.from=function(n,c){if(s.isValid(n))return n;try{return a(n)}catch{return c}}})(vs)),vs}var Tt;function
|
|
2051
|
-
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),a.put(n,13)}},Ls=o,Ls}var Ps={exports:{}},Ut;function
|
|
2052
|
-
Suggested mode is: `+t.toString(
|
|
2049
|
+
`),oe=12;function Ao(s){if(s.length!==16)throw new Error(`Invalid share length: expected 16, got ${s.length}`);const o=or(s,he).split(" ");if(o.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${o.length}`);return o}function vo(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ks(t,he))throw new Error("Invalid recovery phrase: checksum mismatch");const o=Qs(t,he);if(o.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${o.length}`);return I.toShamirShare(o)}function jo(s){if(s.length!==16)throw new Error(`Invalid seed length: expected 16, got ${s.length}`);const o=or(s,he).split(" ");if(o.length!==oe)throw new Error(`Unexpected word count: expected ${oe}, got ${o.length}`);return o}function ko(s){if(s.length!==oe)throw new Error(`Invalid word count: expected ${oe}, got ${s.length}`);const t=s.join(" ").toLowerCase().trim();if(!Ks(t,he))throw new Error("Invalid recovery phrase: checksum mismatch");const o=Qs(t,he);if(o.length!==16)throw new Error(`Invalid entropy length: expected 16, got ${o.length}`);return I.toSeed(o)}function nr(s){if(s.length!==oe)return!1;const t=s.join(" ").toLowerCase().trim();return Ks(t,he)}function We(s){return he.includes(s.toLowerCase().trim())}function No(s,t=5){const o=s.toLowerCase().trim();return o.length===0?[]:he.filter(a=>a.startsWith(o)).slice(0,t)}function Co(s){const t=[];for(let o=0;o<s.length;o+=4)t.push(s.slice(o,o+4));return t}function So(s){return s.toLowerCase().replace(/[,\n\r\t]+/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>0)}function Eo({className:s="",variant:t="default",size:o="md",children:a,menuItems:r=[],hideSignOut:n=!1}){const{user:c,isAuthenticated:l,isLoading:d,openLoginModal:u,logout:h}=I.useAuth(),[m,f]=i.useState(!1),[w,g]=i.useState(-1),p=i.useRef(null),y=i.useRef(null),b=i.useMemo(()=>[...r,...n?[]:[{label:"Sign out",onClick:h}]],[r,n,h]);i.useEffect(()=>{if(!m)return;const A=S=>{p.current&&!p.current.contains(S.target)&&(f(!1),g(-1))},N=S=>{S.key==="Escape"&&(f(!1),g(-1),y.current?.focus())};return document.addEventListener("mousedown",A),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",A),document.removeEventListener("keydown",N)}},[m]);const x=i.useCallback(A=>{if(!(!m||b.length===0))switch(A.key){case"ArrowDown":A.preventDefault(),g(N=>(N+1)%b.length);break;case"ArrowUp":A.preventDefault(),g(N=>(N-1+b.length)%b.length);break;case"Home":A.preventDefault(),g(0);break;case"End":A.preventDefault(),g(b.length-1);break;case"Enter":case" ":w>=0&&(A.preventDefault(),b[w].onClick(),f(!1),g(-1));break}},[m,w,b]),v=i.useCallback(()=>{b.length!==0&&(f(A=>!A),g(-1))},[b.length]),j={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},C={default:"cedros-button-primary",outline:"cedros-button-outline",ghost:"cedros-button-ghost"};if(d)return e.jsx("button",{type:"button",className:`cedros-button ${C[t]} ${j[o]} ${s}`,disabled:!0,children:e.jsx(_.LoadingSpinner,{size:"sm"})});if(l&&c){const A=c.name||c.email||"User",N=Os.sanitizeImageUrl(c.picture);return e.jsxs("div",{className:"cedros-user-menu",ref:p,onKeyDown:x,children:[e.jsxs("button",{ref:y,type:"button",className:`cedros-button cedros-user-button ${j[o]} ${s}`,"aria-haspopup":"menu","aria-expanded":m,"aria-label":`User menu for ${A}`,onClick:v,children:[N?e.jsx("img",{src:N,alt:A,className:"cedros-user-avatar",referrerPolicy:"no-referrer",crossOrigin:"anonymous"}):e.jsx("div",{className:"cedros-user-avatar-placeholder",children:(A[0]||"?").toUpperCase()}),e.jsx("span",{className:"cedros-user-name",children:A})]}),m&&e.jsxs("div",{className:"cedros-dropdown cedros-dropdown-open",role:"menu",children:[r.map((S,k)=>e.jsxs("button",{type:"button",className:`cedros-dropdown-item ${w===k?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===k?0:-1,onClick:()=>{S.onClick(),f(!1)},children:[S.icon&&e.jsx("span",{className:"cedros-dropdown-icon",children:S.icon}),S.label]},k)),r.length>0&&!n&&e.jsx("div",{className:"cedros-dropdown-divider",role:"separator"}),!n&&e.jsx("button",{type:"button",className:`cedros-dropdown-item cedros-dropdown-item-danger ${w===r.length?"cedros-dropdown-item-focused":""}`,role:"menuitem",tabIndex:w===r.length?0:-1,onClick:()=>{h(),f(!1)},children:"Sign out"})]})]})}return e.jsx("button",{type:"button",className:`cedros-button ${C[t]} ${j[o]} ${s}`,onClick:u,children:a||"Sign in"})}function es(){const{config:s}=T.useCedrosLogin(),[t,o]=i.useState(!1),[a,r]=i.useState(!1),[n,c]=i.useState(null),l=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:d,getRemainingAttempts:u}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),h=i.useCallback(async g=>{if(!we.validateEmail(g)){const p={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw c(p),p}try{d()}catch(p){const y={code:"RATE_LIMITED",message:p instanceof Error?p.message:"Too many attempts"};throw c(y),y}o(!0),c(null),r(!1);try{await l.post("/forgot-password",{email:g}),r(!0)}catch(p){const y=T.handleApiError(p,"Unable to send the reset email. Please try again.");throw c(y),y}finally{o(!1)}},[l,d]),m=i.useCallback(async(g,p)=>{o(!0),c(null),r(!1);try{await l.post("/reset-password",{token:g,newPassword:p}),r(!0)}catch(y){const b=T.handleApiError(y,"Unable to reset your password. Please try again.");throw c(b),b}finally{o(!1)}},[l]),f=i.useCallback(()=>c(null),[]),w=i.useCallback(()=>{c(null),r(!1),o(!1)},[]);return{forgotPassword:h,resetPassword:m,isLoading:t,isSuccess:a,error:n,clearError:f,reset:w,remainingAttempts:u()}}function Lo(s){return typeof s=="object"&&s!==null&&"mfaRequired"in s&&s.mfaRequired===!0}function ar(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(!1),[r,n]=i.useState(!1),[c,l]=i.useState(null),d=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]),{checkLimit:u,getRemainingAttempts:h}=Q.useRateLimiter({maxAttempts:3,windowMs:3e5}),m=i.useCallback(async p=>{if(!we.validateEmail(p)){const y={code:"VALIDATION_ERROR",message:"Please enter a valid email address"};throw l(y),y}try{u()}catch(y){const b={code:"RATE_LIMITED",message:y instanceof Error?y.message:"Too many attempts"};throw l(b),b}a(!0),l(null),n(!1);try{await d.post("/instant-link",{email:p}),n(!0)}catch(y){const b=T.handleApiError(y,"Unable to send the sign-in link. Please try again.");throw l(b),b}finally{a(!1)}},[d,u]),f=i.useCallback(async p=>{if(!p||p.trim().length===0){const y={code:"VALIDATION_ERROR",message:"Invalid or missing sign-in link token"};throw l(y),y}a(!0),l(null),n(!1);try{const y=await d.post("/instant-link/verify",{token:p});return Lo(y)||(s.callbacks?.onLoginSuccess?.(y.user,"email"),t?.handleLoginSuccess(y.user,y.tokens)),y}catch(y){const b=T.handleApiError(y,"Unable to verify the sign-in link. Please try again.");throw l(b),b}finally{a(!1)}},[d,s.callbacks,t]),w=i.useCallback(()=>l(null),[]),g=i.useCallback(()=>{l(null),n(!1),a(!1)},[]);return{sendInstantLink:m,verifyInstantLink:f,isLoading:o,isSuccess:r,error:c,clearError:w,reset:g,remainingAttempts:h()}}const Po={reset:{subtitle:"Enter your email address and we'll send you a link to reset your password.",button:"Send reset link",successMessage:s=>e.jsxs(e.Fragment,{children:["If an account exists for ",e.jsx("strong",{children:s}),", you will receive a password reset link shortly."]})},instantLink:{subtitle:"Enter your email and we'll send you a sign-in link. You can change your password in your account settings once signed in.",button:"Send sign-in link",successMessage:s=>e.jsxs(e.Fragment,{children:["We sent a sign-in link to ",e.jsx("strong",{children:s}),". Click the link to sign in."]})}};function ir({mode:s="reset",onSuccess:t,onCancel:o,className:a=""}){const[r,n]=i.useState(""),c=es(),l=ar(),d=i.useId(),u=s==="instantLink"?{submit:l.sendInstantLink,isLoading:l.isLoading,isSuccess:l.isSuccess,error:l.error,clearError:l.clearError}:{submit:c.forgotPassword,isLoading:c.isLoading,isSuccess:c.isSuccess,error:c.error,clearError:c.clearError},h=Po[s],m=async f=>{f.preventDefault();try{await u.submit(r),t?.()}catch{}};return u.isSuccess?e.jsxs("div",{className:`cedros-forgot-password-success ${a}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Check your email"}),e.jsx("p",{className:"cedros-success-message",children:h.successMessage(r)}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-outline",onClick:o,children:"Back to login"})]}):e.jsxs("form",{className:`cedros-forgot-password-form ${a}`,onSubmit:m,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:h.subtitle})]}),e.jsx(Y.ErrorMessage,{error:u.error,onDismiss:u.clearError}),e.jsxs("div",{className:"cedros-form-field",children:[e.jsx("label",{htmlFor:d,className:"cedros-label",children:"Email address"}),e.jsx("input",{id:d,type:"email",className:"cedros-input",value:r,onChange:f=>n(f.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(_.LoadingSpinner,{size:"sm"}),"Sending..."]}):h.button}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:o,disabled:u.isLoading,children:"Back to login"})]})]})}const Mo={loading:!1,loaded:!1,error:null,callbacks:[],load(){return typeof window>"u"||typeof document>"u"?Promise.reject(new Error("Apple Sign-In script loader cannot run in SSR")):this.loaded?Promise.resolve():this.loading?new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t})}):(this.loading=!0,new Promise((s,t)=>{this.callbacks.push({resolve:s,reject:t});const o=document.getElementById("apple-signin-script");if(o){window.AppleID?(this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]):o.addEventListener("load",()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]});return}const a=document.createElement("script");a.src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js",a.async=!0,a.defer=!0,a.id="apple-signin-script",a.onload=()=>{this.loaded=!0,this.loading=!1,this.callbacks.forEach(r=>r.resolve()),this.callbacks=[]},a.onerror=()=>{this.loading=!1,a.remove();const r=new Error("Failed to load Apple Sign In script");this.callbacks.forEach(n=>n.reject(r)),this.callbacks=[]},document.head.appendChild(a)}))},_reset(){this.loading=!1,this.loaded=!1,this.error=null,this.callbacks=[]}};function lr(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(!1),[r,n]=i.useState(!1),[c,l]=i.useState(null),[d,u]=i.useState(null),h=i.useRef(s),m=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts}),[s.serverUrl,s.requestTimeout,s.retryAttempts]);i.useEffect(()=>{h.current=s},[s]),i.useEffect(()=>{if(!s.appleClientId)return;let p=!0;const y=()=>{if(p)try{window.AppleID?.auth?.init({clientId:s.appleClientId,scope:"name email",redirectURI:window.location.origin,usePopup:!0}),p&&n(!0)}catch{p&&l({code:"SERVER_ERROR",message:"Unable to initialize Apple sign-in. Please refresh and try again."})}};return Mo.load().then(()=>{p&&y()}).catch(()=>{p&&l({code:"SERVER_ERROR",message:"Unable to load Apple sign-in. Please refresh and try again."})}),()=>{p=!1}},[s.appleClientId]);const f=i.useCallback(async()=>{if(!s.appleClientId){const y={code:"VALIDATION_ERROR",message:"Apple Client ID not configured"};throw l(y),y}if(!r){const y={code:"VALIDATION_ERROR",message:"Apple sign-in is not ready yet. Please wait a moment and try again."};throw l(y),y}a(!0),l(null);let p;try{const y=await window.AppleID.auth.signIn();if(p=y.authorization?.id_token,!p)throw new Error("No ID token received from Apple");const b=y.user?.name?`${y.user.name.firstName||""} ${y.user.name.lastName||""}`.trim():void 0,x=await m.post("/apple",{idToken:p,name:b||void 0});return h.current.callbacks?.onLoginSuccess?.(x.user,"apple"),t?.handleLoginSuccess(x.user,x.tokens),a(!1),x}catch(y){if(y.error==="popup_closed_by_user"){const v={code:"SERVER_ERROR",message:"Apple sign-in was cancelled."};throw l(v),a(!1),v}const x=T.handleApiError(y,"Unable to sign in with Apple. Please try again.");throw x.code==="ACCOUNT_LINK_REQUIRED"&&p&&u(p),l(x),a(!1),x}},[s.appleClientId,r,m,t]),w=i.useCallback(()=>l(null),[]),g=i.useCallback(()=>u(null),[]);return{signIn:f,isLoading:o,isInitialized:r,error:c,clearError:w,pendingLinkIdToken:d,clearPendingLink:g}}function cr(){if(typeof window>"u"||typeof navigator>"u")return!1;const s=navigator.userAgent.toLowerCase(),t=(navigator.platform||"").toLowerCase();return!!(/iphone|ipad|ipod/.test(s)||t.includes("mac")||/macintosh/.test(s)||t==="macintel"&&navigator.maxTouchPoints>1)}function dr({onSuccess:s,onError:t,className:o="",variant:a="default",size:r="md",disabled:n=!1,hideOnNonApple:c=!0}){const{signIn:l,isLoading:d,isInitialized:u}=lr(),[h]=i.useState(()=>cr());if(c&&!h)return null;const m=async()=>{try{await l(),s?.()}catch(g){const p=g instanceof Error?g:new Error(String(g));t?.(p)}},f={sm:"cedros-button-sm",md:"cedros-button-md",lg:"cedros-button-lg"},w={default:"cedros-button-social",outline:"cedros-button-social-outline"};return e.jsxs("button",{type:"button",className:`cedros-button ${w[a]} ${f[r]} ${o}`,onClick:m,disabled:n||!u||d,"aria-label":"Sign in with Apple",children:[d?e.jsx(_.LoadingSpinner,{size:"sm"}):e.jsx("svg",{className:"cedros-button-icon",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"})}),e.jsx("span",{children:"Continue with Apple"})]})}function Z(s,t){if(!s)throw new Error(t)}function To(s){return s.replace(/-/g,"+").replace(/_/g,"/")}function Je(s){Z(typeof s=="string"&&s.length>0,"Expected base64url string");const t=To(s),o=t+"=".repeat((4-t.length%4)%4),a=atob(o),r=new Uint8Array(a.length);for(let n=0;n<a.length;n++)r[n]=a.charCodeAt(n);return r.buffer}function xe(s){const t=new Uint8Array(s);let o="";for(let r=0;r<t.length;r++)o+=String.fromCharCode(t[r]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function ur(s){Z(typeof s=="object"&&s!==null,"Invalid credential descriptor");const t=s;return Z(typeof t.type=="string","Invalid credential descriptor type"),Z(typeof t.id=="string","Invalid credential descriptor id"),{type:t.type,id:Je(t.id),transports:Array.isArray(t.transports)?t.transports:void 0}}function ds(s){Z(s&&typeof s=="object","Missing creation options");const t=s.publicKey;Z(t&&typeof t=="object","Missing creation options.publicKey"),Z(typeof t.challenge=="string","Missing creation challenge"),Z(typeof t.rp=="object"&&t.rp!==null,"Missing rp"),Z(typeof t.user=="object"&&t.user!==null,"Missing user");const o=t.rp,a=t.user;Z(typeof o.name=="string","Missing rp.name"),Z(typeof a.id=="string","Missing user.id"),Z(typeof a.name=="string","Missing user.name"),Z(typeof a.displayName=="string","Missing user.displayName");const r=Array.isArray(t.excludeCredentials)?t.excludeCredentials.map(ur):void 0,n=Array.isArray(t.pubKeyCredParams)?t.pubKeyCredParams.map(l=>({type:l.type,alg:l.alg})):[],c={challenge:Je(t.challenge),rp:{name:o.name,id:typeof o.id=="string"?o.id:void 0},user:{id:Je(a.id),name:a.name,displayName:a.displayName},pubKeyCredParams:n,timeout:typeof t.timeout=="number"?t.timeout:void 0,attestation:typeof t.attestation=="string"?t.attestation:void 0,authenticatorSelection:typeof t.authenticatorSelection=="object"&&t.authenticatorSelection!==null?t.authenticatorSelection:void 0,excludeCredentials:r,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return c.hints=["client-device"],c}function ht(s){Z(s&&typeof s=="object","Missing request options");const t=s.publicKey;Z(t&&typeof t=="object","Missing request options.publicKey"),Z(typeof t.challenge=="string","Missing request challenge");const o=Array.isArray(t.allowCredentials)?t.allowCredentials.map(ur):void 0,a={challenge:Je(t.challenge),rpId:typeof t.rpId=="string"?t.rpId:void 0,timeout:typeof t.timeout=="number"?t.timeout:void 0,userVerification:typeof t.userVerification=="string"?t.userVerification:void 0,allowCredentials:o,extensions:typeof t.extensions=="object"&&t.extensions!==null?t.extensions:void 0};return a.hints=["client-device"],a}function Ee(s){const t=xe(s.rawId),o=s.response,r={...{clientDataJSON:xe(o.clientDataJSON)}};if("attestationObject"in o){const n=o;if(r.attestationObject=xe(n.attestationObject),typeof n.getTransports=="function")try{r.transports=n.getTransports()}catch{}}if("authenticatorData"in o){const n=o;r.authenticatorData=xe(n.authenticatorData),r.signature=xe(n.signature),n.userHandle&&(r.userHandle=xe(n.userHandle))}return{id:s.id,rawId:t,type:s.type,authenticatorAttachment:s.authenticatorAttachment??void 0,clientExtensionResults:s.getClientExtensionResults?.()??{},response:r}}function Ro(){if(typeof window<"u"){const s=window.location?.hostname,t=s==="localhost"||s==="127.0.0.1"||s?.endsWith(".localhost");if(!(window.isSecureContext===!0)&&!t)return!1}return typeof window<"u"&&typeof window.PublicKeyCredential<"u"&&typeof navigator<"u"&&typeof navigator.credentials<"u"}function Bo(s){return typeof s=="object"&&s!==null&&"code"in s&&"message"in s&&typeof s.code=="string"&&typeof s.message=="string"}function Le(s){if(!(s instanceof Error))return null;const t=s.name;return t==="NotAllowedError"?{code:"SERVER_ERROR",message:"Passkey operation was cancelled or timed out"}:t==="InvalidStateError"?{code:"VALIDATION_ERROR",message:"Passkey is not available for this operation"}:t==="SecurityError"?{code:"VALIDATION_ERROR",message:"Passkeys require HTTPS and a correctly configured relying party (WEBAUTHN_RP_ID / WEBAUTHN_RP_ORIGIN)"}:null}function Ys(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(!1),[r,n]=i.useState(null),c=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[t?.getAccessToken,s.serverUrl,s.requestTimeout,s.retryAttempts]),l=i.useCallback(()=>n(null),[]),d=Ro(),u=i.useCallback(async y=>{if(!d){const b={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(b),b}a(!0),n(null);try{const b=await c.post("/webauthn/auth/options",{email:y?.email}),x=ht(b.options),v=await navigator.credentials.get({publicKey:x});if(!v)throw new Error("Passkey authentication returned no credential");const j=await c.post("/webauthn/auth/verify",{challengeId:b.challengeId,credential:Ee(v)});return s.callbacks?.onLoginSuccess?.(j.user,"webauthn"),t?.handleLoginSuccess(j.user,j.tokens),j}catch(b){const v=Le(b)??T.handleApiError(b,"Unable to sign in with passkey. Please try again.");throw n(v),v}finally{a(!1)}},[c,s.callbacks,t,d]),h=i.useCallback(async y=>{if(!d){const b={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(b),b}a(!0),n(null);try{const b=await c.post("/webauthn/register/options",{}),x=ds(b.options),v=await navigator.credentials.create({publicKey:x});if(!v)throw new Error("Passkey registration returned no credential");const j=await c.post("/webauthn/register/verify",{challengeId:b.challengeId,credential:Ee(v),label:y?.label});if(!j.success)throw new Error("Passkey registration failed");return{credentialId:j.credentialId,label:j.label}}catch(b){const v=Le(b)??T.handleApiError(b,"Unable to register passkey. Please try again.");throw n(v),v}finally{a(!1)}},[c,d]),m=i.useCallback(async y=>{if(!d){const b={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(b),b}a(!0),n(null);try{const b=await c.post("/webauthn/signup/options",{}),x=ds(b.options),v=await navigator.credentials.create({publicKey:x});if(!v)throw new Error("Passkey signup returned no credential");const j=await c.post("/webauthn/signup/verify",{challengeId:b.challengeId,credential:Ee(v),email:y?.email,name:y?.name,label:y?.label});return s.callbacks?.onLoginSuccess?.(j.user,"webauthn"),t?.handleLoginSuccess(j.user,j.tokens),j}catch(b){const v=Le(b)??T.handleApiError(b,"Unable to sign up with passkey. Please try again.");throw n(v),v}finally{a(!1)}},[c,s.callbacks,t,d]),f=i.useCallback(async()=>{if(!d){const x={code:"VALIDATION_ERROR",message:"Passkeys are not supported in this browser"};throw n(x),x}a(!0),n(null);const y=typeof localStorage<"u"&&localStorage.getItem("cedros-passkey-registered")==="1",b=()=>{try{localStorage.setItem("cedros-passkey-registered","1")}catch{}};return y?w(b):g(b)},[c,s.callbacks,t,d]),w=i.useCallback(async y=>{try{const b=await c.post("/webauthn/auth/options",{}),x=ht(b.options),v=await navigator.credentials.get({publicKey:x});if(!v)throw new Error("Passkey authentication returned no credential");const j=await c.post("/webauthn/auth/verify",{challengeId:b.challengeId,credential:Ee(v)});return s.callbacks?.onLoginSuccess?.(j.user,"webauthn"),t?.handleLoginSuccess(j.user,j.tokens),y(),j}catch(b){if(b instanceof Error&&(b.name==="NotAllowedError"||b.name==="InvalidStateError"))return p(y);if(typeof b=="object"&&b!==null&&"isApiError"in b&&b.data?.code==="INVALID_CREDENTIALS"){const A={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 n(A),A}const C=Le(b)??T.handleApiError(b,"Unable to sign in with passkey. Please try again.");throw n(C),C}finally{a(!1)}},[c,s.callbacks,t]),g=i.useCallback(async y=>{try{return await p(y)}catch(b){if(b instanceof Error&&(b.name==="InvalidStateError"||b.name==="NotAllowedError"))return w(y);if(!Bo(b)){const j=Le(b)??T.handleApiError(b,"Unable to create passkey. Please try again.");throw n(j),j}throw b}finally{a(!1)}},[c,s.callbacks,t]),p=i.useCallback(async y=>{const b=await c.post("/webauthn/signup/options",{}),x=ds(b.options),v=await navigator.credentials.create({publicKey:x});if(!v)throw new Error("Passkey signup returned no credential");const j=await c.post("/webauthn/signup/verify",{challengeId:b.challengeId,credential:Ee(v)});return s.callbacks?.onLoginSuccess?.(j.user,"webauthn"),t?.handleLoginSuccess(j.user,j.tokens),y(),j},[c,s.callbacks,t]);return{isSupported:d,isLoading:o,error:r,clearError:l,continueWithPasskey:f,authenticatePasskey:u,registerPasskey:h,signupWithPasskey:m}}function hr({onSuccess:s,className:t="",children:o,disabled:a}){const{continueWithPasskey:r,isLoading:n,isSupported:c}=Ys(),l=a||!c||n;return e.jsxs("button",{type:"button",className:`cedros-button cedros-button-social ${t}`,onClick:async()=>{try{await r(),s?.()}catch{}},disabled:l,"aria-disabled":l,children:[n?e.jsx(_.LoadingSpinner,{size:"sm"}):e.jsx("span",{className:"cedros-social-icon","aria-hidden":"true",children:e.jsx(Io,{})}),e.jsx("span",{children:o??"Continue with Passkey"})]})}function Io(){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 Pe=["login","register"];function ss({onSuccess:s,className:t="",defaultTab:o="login"}){const{config:a,socialButtonOrder:r}=T.useCedrosLogin(),[n,c]=i.useState(o),[l,d]=i.useState("form"),[u,h]=i.useState(()=>ve.detectSolanaWallets()),[m]=i.useState(()=>cr());i.useEffect(()=>{const C=()=>h(ve.detectSolanaWallets());return C(),window.addEventListener("load",C),window.addEventListener("focus",C),()=>{window.removeEventListener("load",C),window.removeEventListener("focus",C)}},[]);const f=a.forms?.forgotPassword?.mode??(a.features?.instantLink?"instantLink":"reset"),w=i.useCallback(C=>{const A=Pe.indexOf(n);let N=A;switch(C.key){case"ArrowLeft":case"ArrowUp":N=A===0?Pe.length-1:A-1;break;case"ArrowRight":case"ArrowDown":N=A===Pe.length-1?0:A+1;break;case"Home":N=0;break;case"End":N=Pe.length-1;break;default:return}C.preventDefault();const S=Pe[N];c(S),document.getElementById(`cedros-tab-${S}`)?.focus()},[n]),g=a.features??{email:!0,google:!0,apple:!0,solana:!0,webauthn:!0},p=g.email!==!1,y=g.google!==!1&&a.googleClientId,b=g.apple!==!1&&a.appleClientId&&m,x=g.solana!==!1&&u,v=g.webauthn!==!1,j=p&&(y||b||x||v);return l==="forgotPassword"?e.jsx("div",{className:`cedros-login-form ${t}`,children:e.jsx(ir,{mode:f,onCancel:()=>d("form")})}):e.jsxs("div",{className:`cedros-login-form ${t}`,children:[(v||y||b||x)&&(()=>{const C={webauthn:v?e.jsx(hr,{onSuccess:s}):null,google:y?e.jsx(qs.GoogleLoginButton,{onSuccess:s}):null,apple:b?e.jsx(dr,{onSuccess:s}):null,solana:x?e.jsx(ve.SolanaLoginButton,{onSuccess:s}):null},A=r??["webauthn","google","apple","solana"];return e.jsx("div",{className:"cedros-social-buttons",children:A.map(N=>{const S=C[N];return S?e.jsx(i.Fragment,{children:S},N):null})})})(),j&&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 ${n==="login"?"cedros-tab-active":""}`,onClick:()=>c("login"),onKeyDown:w,"aria-selected":n==="login","aria-controls":"cedros-tabpanel-login",tabIndex:n==="login"?0:-1,children:"Sign in"}),e.jsx("button",{type:"button",role:"tab",id:"cedros-tab-register",className:`cedros-tab ${n==="register"?"cedros-tab-active":""}`,onClick:()=>c("register"),onKeyDown:w,"aria-selected":n==="register","aria-controls":"cedros-tabpanel-register",tabIndex:n==="register"?0:-1,children:"Sign up"})]}),e.jsx("div",{role:"tabpanel",id:`cedros-tabpanel-${n}`,"aria-labelledby":`cedros-tab-${n}`,children:n==="login"?e.jsx(Q.EmailLoginForm,{onSuccess:s,onSwitchToRegister:()=>c("register"),onForgotPassword:()=>d("forgotPassword")}):e.jsx(Q.EmailRegisterForm,{onSuccess:s,onSwitchToLogin:()=>c("login")})})]})]})}class pr extends i.Component{constructor(t){super(t),this.state={hasError:!1,error:null,errorInfo:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){this.setState({errorInfo:o}),console.error("[Cedros Login] Error caught by ErrorBoundary:",t),console.error("[Cedros Login] Component stack:",o.componentStack),this.props.onError?.(t,o)}handleRetry=()=>{this.setState({hasError:!1,error:null,errorInfo:null})};render(){const{hasError:t,error:o,errorInfo:a}=this.state,{children:r,fallback:n,showDetails:c=!1}=this.props;return t?n||e.jsx("div",{className:"cedros-error-boundary",role:"alert","aria-live":"assertive",children:e.jsxs("div",{className:"cedros-error-boundary-content",children:[e.jsxs("svg",{className:"cedros-error-boundary-icon",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e.jsx("h2",{className:"cedros-error-boundary-title",children:"Something went wrong"}),e.jsx("p",{className:"cedros-error-boundary-message",children:"We encountered an unexpected error. Please try again."}),c&&o&&e.jsxs("details",{className:"cedros-error-boundary-details",children:[e.jsx("summary",{children:"Error details"}),e.jsxs("pre",{children:[o.toString(),a?.componentStack]})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:this.handleRetry,children:"Try again"})]})}):r}}function Do({className:s="",title:t="Sign in to your account"}){const{isModalOpen:o,closeModal:a}=T.useCedrosLogin(),r=i.useRef(null),n=i.useRef(null),c=i.useRef(a);if(i.useEffect(()=>{c.current=a},[a]),i.useEffect(()=>{if(!o)return;n.current=document.activeElement,r.current?.focus();const d=h=>{if(h.key==="Escape"&&c.current(),h.key==="Tab"&&r.current){const m=r.current.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),f=m[0],w=m[m.length-1];h.shiftKey&&document.activeElement===f?(h.preventDefault(),w?.focus()):!h.shiftKey&&document.activeElement===w&&(h.preventDefault(),f?.focus())}};document.addEventListener("keydown",d);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",d),document.body.style.overflow=u,n.current instanceof HTMLElement&&n.current.focus()}},[o]),!o)return null;const l=d=>{d.target===d.currentTarget&&a()};return e.jsx("div",{className:`cedros-modal-backdrop ${s}`,onClick:l,role:"presentation",children:e.jsxs("div",{ref:r,className:"cedros-modal",role:"dialog","aria-modal":"true","aria-labelledby":"cedros-modal-title",tabIndex:-1,children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"cedros-modal-title",className:"cedros-modal-title",children:t}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:a,"aria-label":"Close",children:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})})]}),e.jsx("div",{className:"cedros-modal-content",children:e.jsx(pr,{children:e.jsx(ss,{onSuccess:a})})})]})})}function Fo({token:s,onSuccess:t,onLoginClick:o,className:a=""}){const[r,n]=i.useState(""),[c,l]=i.useState(""),[d,u]=i.useState(null),{resetPassword:h,isLoading:m,isSuccess:f,error:w,clearError:g}=es(),p=r===c,y=d?.isValid&&p&&r.length>0,b=async x=>{if(x.preventDefault(),!!y)try{await h(s,r),t?.()}catch{}};return f?e.jsxs("div",{className:`cedros-reset-password-success ${a}`,children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-success-title",children:"Password reset successful"}),e.jsx("p",{className:"cedros-success-message",children:"Your password has been reset. You can now log in with your new password."}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-primary",onClick:o,children:"Go to login"})]}):e.jsxs("form",{className:`cedros-reset-password-form ${a}`,onSubmit:b,children:[e.jsxs("div",{className:"cedros-form-header",children:[e.jsx("h3",{className:"cedros-form-title",children:"Reset your password"}),e.jsx("p",{className:"cedros-form-subtitle",children:"Enter your new password below."})]}),e.jsx(Y.ErrorMessage,{error:w,onDismiss:g}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"New password",value:r,onChange:x=>{n(x.target.value),u(we.validatePassword(x.target.value))},showStrengthMeter:!0,onValidationChange:u,disabled:m,autoComplete:"new-password",error:d&&!d.isValid?Object.values(d.errors).find(Boolean):void 0})}),e.jsx("div",{className:"cedros-form-field",children:e.jsx(Q.PasswordInput,{label:"Confirm password",value:c,onChange:x=>l(x.target.value),disabled:m,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:m||!y,children:m?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),"Resetting..."]}):"Reset password"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-md cedros-button-ghost cedros-button-full",onClick:o,disabled:m,children:"Back to login"})]})]})}function _s({org:s,size:t="lg",className:o=""}){const a=Os.sanitizeImageUrl(s.logoUrl),r=t==="lg"?"cedros-org-avatar-lg":"",n=["cedros-org-avatar",r,o].filter(Boolean).join(" "),c=["cedros-org-avatar-placeholder",r,o].filter(Boolean).join(" ");return a?e.jsx("img",{src:a,alt:s.name,className:n,referrerPolicy:"no-referrer"}):e.jsx("div",{className:c,children:s.name[0]?.toUpperCase()||"?"})}function Uo({orgs:s,activeOrg:t,isLoading:o=!1,onSelect:a,onCreateClick:r,className:n="",placeholder:c="Select organization"}){const[l,d]=i.useState(!1),u=i.useRef(null);i.useEffect(()=>{const w=g=>{u.current&&!u.current.contains(g.target)&&d(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]),i.useEffect(()=>{const w=g=>{g.key==="Escape"&&d(!1)};if(l)return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[l]);const h=i.useCallback(w=>{a(w),d(!1)},[a]),m=i.useCallback(()=>{d(!1),r?.()},[r]),f=i.useCallback(()=>{d(w=>!w)},[]);return o?e.jsxs("div",{className:`cedros-org-selector cedros-org-selector-loading ${n}`,"aria-busy":"true","aria-live":"polite",children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Loading..."})]}):e.jsxs("div",{ref:u,className:`cedros-org-selector ${n}`,children:[e.jsxs("button",{type:"button",className:"cedros-org-selector-trigger",onClick:f,"aria-haspopup":"listbox","aria-expanded":l,children:[t?e.jsxs(e.Fragment,{children:[e.jsx(_s,{org:t,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-name",children:t.name}),e.jsx(pt,{role:t.membership.role})]}):e.jsx("span",{className:"cedros-org-selector-placeholder",children:c}),e.jsx(_o,{isOpen:l})]}),l&&e.jsxs("div",{className:"cedros-org-selector-dropdown",role:"listbox",children:[s.length===0?e.jsx("div",{className:"cedros-org-selector-empty",children:"No organizations"}):e.jsx("ul",{className:"cedros-org-selector-list",children:s.map(w=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-selector-item ${w.id===t?.id?"cedros-org-selector-item-active":""}`,onClick:()=>h(w.id),role:"option","aria-selected":w.id===t?.id,children:[e.jsx(_s,{org:w,size:"sm"}),e.jsx("span",{className:"cedros-org-selector-item-name",children:w.name}),e.jsx(pt,{role:w.membership.role}),w.id===t?.id&&e.jsx(Wo,{})]})},w.id))}),r&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-org-selector-divider"}),e.jsxs("button",{type:"button",className:"cedros-org-selector-create",onClick:m,children:[e.jsx(Oo,{}),e.jsx("span",{children:"Create organization"})]})]})]})]})}function pt({role:s}){return e.jsx("span",{className:`cedros-org-role cedros-org-role-${s}`,children:s})}function _o({isOpen:s}){return e.jsx("svg",{className:`cedros-org-chevron ${s?"cedros-org-chevron-open":""}`,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Wo(){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 Oo(){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 qo(){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 zo(){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 Vo(){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 Ho({orgs:s,activeOrg:t,isLoading:o,onSelect:a,onCreateClick:r}){return o?e.jsxs("div",{className:"cedros-org-switcher-loading",children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading organizations..."})]}):e.jsxs(e.Fragment,{children:[s.length===0?e.jsx("div",{className:"cedros-org-switcher-empty",children:e.jsx("p",{children:"You don't belong to any organizations yet."})}):e.jsx("ul",{className:"cedros-org-switcher-list",children:s.map(n=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:`cedros-org-switcher-item ${n.id===t?.id?"cedros-org-switcher-item-active":""}`,onClick:()=>a(n.id),children:[e.jsx(_s,{org:n}),e.jsxs("div",{className:"cedros-org-switcher-item-content",children:[e.jsx("span",{className:"cedros-org-switcher-item-name",children:n.name}),e.jsxs("span",{className:"cedros-org-switcher-item-slug",children:["@",n.slug]})]}),e.jsxs("div",{className:"cedros-org-switcher-item-meta",children:[e.jsx("span",{className:`cedros-org-role cedros-org-role-${n.membership.role}`,children:n.membership.role}),n.isPersonal&&e.jsx("span",{className:"cedros-org-personal-badge",children:"Personal"})]}),n.id===t?.id&&e.jsx(zo,{})]})},n.id))}),r&&e.jsxs("button",{type:"button",className:"cedros-org-switcher-create",onClick:r,children:[e.jsx(Vo,{}),e.jsx("span",{children:"Create new organization"})]})]})}function Qo({isLoading:s,onSubmit:t,onCancel:o}){const[a,r]=i.useState(""),[n,c]=i.useState(""),[l,d]=i.useState(null),u=i.useCallback(m=>{r(m);const f=m.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").substring(0,50);c(f)},[]),h=i.useCallback(async m=>{if(m.preventDefault(),d(null),!a.trim()){d("Organization name is required");return}if(!n.trim()){d("Organization slug is required");return}try{await t({name:a.trim(),slug:n.trim()})}catch(f){d(f.message||"Failed to create organization")}},[a,n,t]);return e.jsxs("form",{className:"cedros-org-create-form",onSubmit:h,children:[l&&e.jsx(Y.ErrorMessage,{error:l}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-name",className:"cedros-form-label",children:"Organization Name"}),e.jsx("input",{id:"org-name",type:"text",className:"cedros-form-input",value:a,onChange:m=>u(m.target.value),placeholder:"My Organization",maxLength:255,disabled:s,autoFocus:!0})]}),e.jsxs("div",{className:"cedros-form-group",children:[e.jsx("label",{htmlFor:"org-slug",className:"cedros-form-label",children:"URL Slug"}),e.jsxs("div",{className:"cedros-form-input-prefix",children:[e.jsx("span",{className:"cedros-form-prefix",children:"@"}),e.jsx("input",{id:"org-slug",type:"text",className:"cedros-form-input",value:n,onChange:m=>c(m.target.value.toLowerCase()),placeholder:"my-organization",maxLength:100,pattern:"[a-z0-9-]+",disabled:s})]}),e.jsx("span",{className:"cedros-form-hint",children:"Only lowercase letters, numbers, and hyphens"})]}),e.jsxs("div",{className:"cedros-form-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:o,disabled:s,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:s||!a.trim()||!n.trim(),children:s?e.jsx(_.LoadingSpinner,{size:"sm"}):"Create Organization"})]})]})}function Ko({isOpen:s,onClose:t,orgs:o,activeOrg:a,isLoading:r=!1,error:n,onSelect:c,onCreate:l,className:d=""}){return s?e.jsx(Yo,{onClose:t,orgs:o,activeOrg:a,isLoading:r,error:n,onSelect:c,onCreate:l,className:d}):null}function Yo({onClose:s,orgs:t,activeOrg:o,isLoading:a=!1,error:r,onSelect:n,onCreate:c,className:l}){const[d,u]=i.useState("list"),h=i.useRef(null),m=i.useRef(null);i.useEffect(()=>(m.current=document.activeElement,h.current?.querySelector(".cedros-modal-close")?.focus(),()=>{m.current?.focus()}),[]),i.useEffect(()=>{const p=y=>{if(y.key==="Escape"){s();return}if(y.key==="Tab"&&h.current){const b=h.current.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'),x=b[0],v=b[b.length-1];y.shiftKey?document.activeElement===x&&(y.preventDefault(),v?.focus()):document.activeElement===v&&(y.preventDefault(),x?.focus())}};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[s]);const f=i.useCallback(p=>{p.target===p.currentTarget&&s()},[s]),w=i.useCallback(p=>{n(p),s()},[n,s]),g=i.useCallback(async p=>{await c?.(p),s()},[c,s]);return e.jsx("div",{className:"cedros-modal-backdrop",onClick:f,children:e.jsxs("div",{ref:h,className:`cedros-modal cedros-org-switcher ${l}`,role:"dialog","aria-modal":"true","aria-labelledby":"org-switcher-title",children:[e.jsxs("div",{className:"cedros-modal-header",children:[e.jsx("h2",{id:"org-switcher-title",className:"cedros-modal-title",children:d==="list"?"Switch Organization":"Create Organization"}),e.jsx("button",{type:"button",className:"cedros-modal-close",onClick:s,"aria-label":"Close",children:e.jsx(qo,{})})]}),e.jsxs("div",{className:"cedros-modal-body",children:[r&&e.jsx(Y.ErrorMessage,{error:r}),d==="list"?e.jsx(Ho,{orgs:t,activeOrg:o,isLoading:a,onSelect:w,onCreateClick:c?()=>u("create"):void 0}):e.jsx(Qo,{isLoading:a,onSubmit:g,onCancel:()=>u("list")})]})]})})}function mr({sessions:s,isLoading:t=!1,error:o,onRevokeAll:a,className:r=""}){const[n,c]=i.useState(!1),[l,d]=i.useState(!1),u=i.useRef(null),h=i.useMemo(()=>s.filter(f=>!f.isCurrent).length,[s]),m=i.useCallback(async()=>{if(!a)return;const f=s.filter(g=>!g.isCurrent).length;if(!(f===0||!window.confirm(`Are you sure you want to sign out of ${f} other device(s)? This will log you out everywhere except this browser.`))){c(!0),d(!1);try{await a(),d(!0),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>{d(!1),u.current=null},3e3)}finally{c(!1)}}},[a,s]);return i.useEffect(()=>()=>{u.current!==null&&(window.clearTimeout(u.current),u.current=null)},[]),t&&s.length===0?e.jsxs("div",{className:`cedros-session-list cedros-session-list-loading ${r}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading sessions..."})]}):o?e.jsx("div",{className:`cedros-session-list ${r}`,children:e.jsx(Y.ErrorMessage,{error:o})}):s.length===0?e.jsx("div",{className:`cedros-session-list cedros-session-list-empty ${r}`,children:e.jsx("p",{children:"No active sessions found."})}):e.jsxs("div",{className:`cedros-session-list ${r}`,children:[l&&e.jsxs("div",{className:"cedros-session-success",role:"status",children:[e.jsx(en,{}),e.jsx("span",{children:"All other sessions have been revoked."})]}),e.jsx("ul",{className:"cedros-session-items",children:s.map(f=>e.jsx(Go,{session:f},f.id))}),a&&h>0&&e.jsx("div",{className:"cedros-session-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-danger",onClick:m,disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Signing out..."})]}):`Sign out of ${h} other device${h>1?"s":""}`})})]})}function Go({session:s}){const t=$o(s.userAgent),o=Xo(s.expiresAt);return e.jsxs("li",{className:`cedros-session-item ${s.isCurrent?"cedros-session-item-current":""}`,children:[e.jsx("div",{className:"cedros-session-item-icon",children:e.jsx(Zo,{userAgent:s.userAgent})}),e.jsxs("div",{className:"cedros-session-item-info",children:[e.jsxs("div",{className:"cedros-session-item-main",children:[e.jsxs("span",{className:"cedros-session-item-device",children:[t.browser," on ",t.os]}),s.isCurrent&&e.jsx("span",{className:"cedros-session-current-badge",children:"Current session"})]}),e.jsxs("div",{className:"cedros-session-item-meta",children:[s.ipAddress&&e.jsxs("span",{className:"cedros-session-item-ip",children:["IP: ",s.ipAddress]}),e.jsxs("span",{className:"cedros-session-item-created",children:["Started ",Jo(s.createdAt)]}),o&&e.jsx("span",{className:"cedros-session-expiring",children:"Expires soon"})]})]})]})}function $o(s){if(!s)return{browser:"Unknown browser",os:"Unknown device"};let t="Unknown browser";s.includes("Chrome")&&!s.includes("Edg")?t="Chrome":s.includes("Safari")&&!s.includes("Chrome")?t="Safari":s.includes("Firefox")?t="Firefox":s.includes("Edg")&&(t="Edge");let o="Unknown device";return s.includes("Windows")?o="Windows":s.includes("Mac")?o="macOS":s.includes("Linux")?o="Linux":s.includes("iPhone")||s.includes("iPad")?o="iOS":s.includes("Android")&&(o="Android"),{browser:t,os:o}}function Jo(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),r=Math.floor(a/(1e3*60)),n=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return r<1?"just now":r<60?`${r} minute${r>1?"s":""} ago`:n<24?`${n} hour${n>1?"s":""} ago`:c<7?`${c} day${c>1?"s":""} ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Xo(s){const t=new Date(s),o=new Date,a=3600*1e3;return t.getTime()-o.getTime()<a}function Zo({userAgent:s}){return s?.includes("iPhone")||s?.includes("iPad")||s?.includes("Android")?e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("circle",{cx:"12",cy:"18",r:"1",fill:"currentColor"})]}):e.jsxs("svg",{className:"cedros-session-device-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("rect",{x:"2",y:"4",width:"20",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),e.jsx("path",{d:"M8 21H16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M12 18V21",stroke:"currentColor",strokeWidth:"1.5"})]})}function en(){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 fr({words:s,onConfirm:t,className:o=""}){const[a,r]=i.useState(!1),[n,c]=i.useState(!1),l=i.useRef(null),d=Co(s),u=i.useCallback(async()=>{try{await navigator.clipboard.writeText(s.join(" ")),r(!0),l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>r(!1),2e3)}catch{}},[s]);i.useEffect(()=>()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},[]);const h=i.useCallback(()=>{n&&t()},[n,t]);return e.jsxs("div",{className:`cedros-recovery-phrase-display ${o}`,children:[e.jsxs("div",{className:"cedros-recovery-header",children:[e.jsx("h3",{className:"cedros-recovery-title",children:"Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-warning",children:"Write down these 12 words in order and store them securely. This is the only way to recover your wallet if you lose access."})]}),e.jsx("div",{className:"cedros-recovery-grid",children:d.map((m,f)=>e.jsx("div",{className:"cedros-word-group",children:m.map((w,g)=>{const p=f*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:w})]},p)})},f))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary cedros-copy-btn",onClick:u,children:a?"Copied!":"Copy to Clipboard"}),e.jsx("div",{className:"cedros-recovery-security",children:e.jsxs("div",{className:"cedros-warning-box",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M10 6v4m0 4h.01M19 10a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsxs("div",{className:"cedros-warning-content",children:[e.jsx("strong",{children:"Security Warning"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Never share this phrase with anyone"}),e.jsx("li",{children:"Store it offline in a secure location"}),e.jsx("li",{children:"Anyone with this phrase can access your wallet"}),e.jsx("li",{children:"Cedros cannot recover this phrase for you"})]})]})]})}),e.jsxs("div",{className:"cedros-recovery-confirm",children:[e.jsxs("label",{className:"cedros-checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:m=>c(m.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:h,disabled:!n,children:"Continue"})]})]})}function gr({onSubmit:s,onCancel:t,isSubmitting:o=!1,error:a,className:r=""}){const[n,c]=i.useState(Array(oe).fill("")),[l,d]=i.useState(null),[u,h]=i.useState([]),[m,f]=i.useState(null),w=i.useId(),g=i.useRef(null),p=i.useCallback((A,N)=>{const S=[...n];if(S[A]=N.toLowerCase().trim(),c(S),N.length>0){const k=No(N,5);h(k)}else h([]);f(null)},[n]),y=i.useCallback(A=>{d(A),h([])},[]),b=i.useCallback(A=>{const N=n[A];N&&!We(N)&&f(`Word ${A+1} is not in the wordlist`),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>{l===A&&h([])},200)},[n,l]);i.useEffect(()=>()=>{g.current!==null&&(window.clearTimeout(g.current),g.current=null)},[]);const x=i.useCallback(A=>{if(l!==null){const N=[...n];N[l]=A,c(N),h([]),document.querySelector(`[data-word-index="${l+1}"]`)?.focus()}},[l,n]),v=i.useCallback(A=>{const N=A.clipboardData.getData("text"),S=So(N);S.length===oe&&(A.preventDefault(),c(S),f(null))},[]),j=i.useCallback(A=>{if(A.preventDefault(),n.filter(k=>!k).length>0){f(`Please enter all ${oe} words`);return}const S=n.map((k,P)=>({word:k,index:P+1})).filter(({word:k})=>!We(k));if(S.length>0){f(`Invalid words: ${S.map(k=>`#${k.index}`).join(", ")}`);return}if(!nr(n)){f("Invalid recovery phrase - please check your words");return}s(n)},[n,s]),C=a||m;return e.jsxs("form",{className:`cedros-recovery-phrase-input ${r}`,onSubmit:j,onPaste:v,children:[e.jsxs("div",{className:"cedros-recovery-input-header",children:[e.jsx("h3",{className:"cedros-recovery-input-title",children:"Enter Recovery Phrase"}),e.jsx("p",{className:"cedros-recovery-input-description",children:"Enter your 12-word recovery phrase. You can paste the entire phrase at once."})]}),e.jsx("div",{className:"cedros-word-inputs",children:Array.from({length:oe},(A,N)=>e.jsxs("div",{className:"cedros-word-input-wrapper",children:[e.jsxs("label",{className:"cedros-word-label",children:[N+1,"."]}),e.jsx("input",{type:"text",className:`cedros-word-input ${n[N]&&!We(n[N])?"cedros-word-invalid":n[N]&&We(n[N])?"cedros-word-valid":""}`,value:n[N],onChange:S=>p(N,S.target.value),onFocus:()=>y(N),onBlur:()=>b(N),"data-word-index":N,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,disabled:o,"aria-label":`Word ${N+1}`})]},N))}),l!==null&&u.length>0&&e.jsx("div",{className:"cedros-suggestions",role:"listbox",id:`${w}-suggestions`,children:u.map(A=>e.jsx("button",{type:"button",className:"cedros-suggestion",onClick:()=>x(A),role:"option",children:A},A))}),C&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:C}),e.jsxs("div",{className:"cedros-recovery-input-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:t,disabled:o,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:o,children:o?"Recovering...":"Recover Wallet"})]})]})}function sn({capabilities:s,className:t=""}){if(s.allSupported)return null;const o=I.getMissingCapabilitiesMessage(s),a=I.getBrowserSupportInfo();return e.jsxs("div",{className:`cedros-capability-warning ${t}`,role:"alert",children:[e.jsxs("div",{className:"cedros-warning-header",children:[e.jsx("svg",{className:"cedros-warning-icon",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})}),e.jsx("h3",{className:"cedros-warning-title",children:"Wallet Feature Unavailable"})]}),e.jsx("p",{className:"cedros-warning-message",children:o}),e.jsxs("div",{className:"cedros-capability-details",children:[e.jsx("h4",{children:"Browser Compatibility"}),e.jsxs("p",{children:["Detected: ",a.browser," ",a.version,a.likelySupported?" (likely supported)":" (may not be supported)"]}),e.jsx("h4",{children:"Required Features"}),e.jsxs("ul",{className:"cedros-capability-list",children:[e.jsxs("li",{className:s.webCrypto?"cedros-cap-ok":"cedros-cap-missing",children:["Web Crypto API: ",s.webCrypto?"Available":"Missing"]}),e.jsxs("li",{className:s.aesGcm?"cedros-cap-ok":"cedros-cap-missing",children:["AES-GCM Encryption: ",s.aesGcm?"Available":"Missing"]}),e.jsxs("li",{className:s.hkdf?"cedros-cap-ok":"cedros-cap-missing",children:["HKDF Key Derivation: ",s.hkdf?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthn?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn/Passkeys: ",s.webAuthn?"Available":"Missing"]}),e.jsxs("li",{className:s.webAuthnPrf?"cedros-cap-ok":"cedros-cap-missing",children:["WebAuthn PRF Extension: ",s.webAuthnPrf?"Available":"Missing"]}),e.jsxs("li",{className:s.argon2?"cedros-cap-ok":"cedros-cap-missing",children:["Argon2 Password Hashing: ",s.argon2?"Available":"Missing"]})]})]}),e.jsxs("div",{className:"cedros-capability-help",children:[e.jsx("h4",{children:"Recommended Browsers"}),e.jsxs("ul",{children:[e.jsx("li",{children:"Chrome 116+ on Windows, macOS, or Android"}),e.jsx("li",{children:"Safari 17+ on macOS or iOS"}),e.jsx("li",{children:"Edge 116+ on Windows"})]}),e.jsx("p",{className:"cedros-capability-note",children:"A platform authenticator (Touch ID, Face ID, or Windows Hello) is required."})]})]})}const tn=["share_c_only","full_seed","none"];function rn(s){return s&&tn.includes(s)?s:"share_c_only"}const on={walletEnabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900,isLoading:!1,error:null,refetch:async()=>{}};function wr(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(null),[a,r]=i.useState(!!s),[n,c]=i.useState(null),l=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts}):null,[s]),d=i.useCallback(async()=>{if(l){r(!0),c(null);try{const u=await l.get("/discovery");u.wallet?o({enabled:u.wallet.enabled,recoveryMode:rn(u.wallet.recoveryMode),unlockTtlSeconds:u.wallet.unlockTtlSeconds}):o({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}catch(u){const h=u instanceof Error?u.message:"Failed to fetch wallet config";c(h),o({enabled:!1,recoveryMode:"share_c_only",unlockTtlSeconds:900})}finally{r(!1)}}},[l]);return i.useEffect(()=>{l&&d()},[l,d]),s?{walletEnabled:t?.enabled??!1,recoveryMode:t?.recoveryMode??"share_c_only",unlockTtlSeconds:t?.unlockTtlSeconds??900,isLoading:a,error:n,refetch:d}:on}function yr(){const{user:s}=T.useCedrosLogin(),{enroll:t}=I.useWalletMaterial(),{recoveryMode:o}=wr(),[a,r]=i.useState({step:"idle"}),[n,c]=i.useState(!1),l=i.useRef([]),d=i.useCallback(()=>{I.wipeAll(...l.current),l.current=[]},[]);i.useEffect(()=>()=>{d()},[d]);const u=i.useCallback(async(g,p,y,b)=>{r({step:"generating_seed"});const x=I.generateSeed();l.current.push(x),r({step:"splitting_shares"});const{shareA:v,shareB:j,shareC:C}=ie.splitSecret(x);l.current.push(v,j,C),r({step:"encrypting_shares"});const A=await I.aesGcmEncryptToBase64(v,I.toEncryptionKey(p)),N=ie.getPublicKeyFromSeed(x),S=ie.publicKeyToBase58(N);r({step:"uploading"});const k={solanaPubkey:S,shareAAuthMethod:g,shareACiphertext:A.ciphertext,shareANonce:A.nonce,shareB:I.uint8ArrayToBase64(j)};if(g==="password"){if(!y)throw new Error("KDF salt required for password method");k.shareAKdfSalt=I.uint8ArrayToBase64(y),k.shareAKdfParams=I.DEFAULT_KDF_PARAMS}if(g==="passkey"&&b&&(k.prfSalt=b),await t(k),o==="none")d(),r({step:"complete",solanaPubkey:S});else{const P=o==="full_seed"?jo(x):Ao(I.toShamirShare(C));r({step:"showing_recovery",recoveryPhrase:P,solanaPubkey:S})}},[t,o,d]),h=i.useCallback(async g=>{if(!s){r({step:"error",error:"User not authenticated"});return}c(!0),d();try{const p=I.generateArgon2Salt(),y=await ie.argon2DeriveInWorker(g,p,I.DEFAULT_KDF_PARAMS);l.current.push(y),await u("password",y,p)}catch(p){r({step:"error",error:p instanceof Error?p.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),m=i.useCallback(async()=>{if(!s){r({step:"error",error:"User not authenticated"});return}c(!0),d();try{const g=I.generatePrfSalt(),p=I.uint8ArrayToBase64(g);r({step:"registering_passkey"});let y;try{const x=new TextEncoder().encode(s.id),v=s.name??s.email??"User",j=s.email??s.id;y=(await I.registerPasskeyWithPrf(x,j,v,g)).prfOutput}catch(x){if(x?.name!=="InvalidStateError")throw x;y=(await I.authenticateWithDiscoverablePrf(p)).prfOutput}l.current.push(y);const b=await I.deriveKeyFromPrf(y,g);l.current.push(b),await u("passkey",b,void 0,p)}catch(g){r({step:"error",error:g instanceof Error?g.message:"Enrollment failed"})}finally{c(!1)}},[s,d,u]),f=i.useCallback(()=>{const g=a.solanaPubkey;d(),r({step:"complete",solanaPubkey:g})},[a.solanaPubkey,d]),w=i.useCallback(()=>{d(),r({step:"idle"}),c(!1)},[d]);return{state:a,startEnrollmentWithPassword:h,startEnrollmentWithPasskey:m,confirmRecoveryPhrase:f,cancel:w,isEnrolling:n}}function br({onComplete:s,onCancel:t,className:o="",forceAuthMethod:a}){const{user:r}=T.useCedrosLogin(),{state:n,startEnrollmentWithPassword:c,startEnrollmentWithPasskey:l,confirmRecoveryPhrase:d,cancel:u,isEnrolling:h}=yr(),m=()=>a||"password",[f,w]=i.useState(m),[g,p]=i.useState(""),[y,b]=i.useState(""),[x,v]=i.useState(null);i.useEffect(()=>{w(m())},[r?.id,a]);const j=i.useCallback(async S=>{if(S.preventDefault(),g!==y){v("Passwords do not match");return}const k=we.validatePassword(g);if(!k.isValid){const P=Object.values(k.errors)[0];v(P??"Password does not meet requirements");return}v(null),await c(g)},[g,y,c]),C=i.useCallback(async()=>{await l()},[l]),A=i.useCallback(()=>{d(),n.solanaPubkey&&s?.(n.solanaPubkey)},[d,n.solanaPubkey,s]),N=i.useCallback(()=>{u(),t?.()},[u,t]);return n.step==="generating_seed"||n.step==="splitting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Generating secure wallet..."})]})}):n.step==="encrypting_shares"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Encrypting wallet shares..."})]})}):n.step==="registering_passkey"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsx("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:e.jsxs("div",{className:"cedros-passkey-prompt",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Authenticate with Passkey"}),e.jsx("p",{children:"Follow your browser's prompt to use your passkey."})]})})}):n.step==="uploading"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,"aria-busy":"true",children:e.jsxs("div",{className:"cedros-enrollment-progress",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"cedros-spinner","aria-hidden":"true"}),e.jsx("p",{children:"Saving wallet..."})]})}):n.step==="showing_recovery"&&n.recoveryPhrase?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsx(fr,{words:n.recoveryPhrase,onConfirm:A})}):n.step==="complete"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsxs("div",{className:"cedros-enrollment-complete",children:[e.jsxs("svg",{className:"cedros-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M16 24l6 6 12-12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{children:"Wallet Created!"}),e.jsxs("p",{className:"cedros-pubkey",children:[e.jsx("strong",{children:"Address:"})," ",n.solanaPubkey]}),e.jsx("p",{children:"Your non-custodial Solana wallet is ready to use."})]})}):n.step==="error"?e.jsx("div",{className:`cedros-wallet-enrollment ${o}`,children:e.jsxs("div",{className:"cedros-enrollment-error",children:[e.jsxs("svg",{className:"cedros-error-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"20",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 16v12m0 6h.01",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("h3",{children:"Enrollment Failed"}),e.jsx("p",{className:"cedros-error-message",children:n.error}),e.jsxs("div",{className:"cedros-error-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>u(),children:"Try Again"})]})]})}):e.jsxs("div",{className:`cedros-wallet-enrollment ${o}`,children:[e.jsxs("div",{className:"cedros-enrollment-header",children:[e.jsx("h2",{children:"Create Wallet"}),e.jsxs("p",{children:["Secure your wallet with a ",f==="passkey"?"passkey":"password","."]})]}),!a&&e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:f==="password",onChange:()=>w("password"),disabled:h}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:f==="passkey",onChange:()=>w("passkey"),disabled:h}),e.jsx("span",{children:"Passkey"})]})]}),f==="password"&&e.jsxs("form",{onSubmit:j,className:"cedros-enrollment-form",children:[e.jsx(Q.PasswordInput,{label:"Password",value:g,onChange:S=>p(S.target.value),showStrengthMeter:!0,disabled:h,required:!0,minLength:8,placeholder:"Enter a strong password"}),e.jsx(Q.PasswordInput,{label:"Confirm Password",value:y,onChange:S=>b(S.target.value),error:x??void 0,disabled:h,required:!0,minLength:8,placeholder:"Confirm your password"}),e.jsx("div",{className:"cedros-password-info",children:e.jsx("p",{children:"This password will be used to sign transactions."})}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,disabled:h,children:"Cancel"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:h||!g||!y,children:h?"Creating...":"Continue"})]})]}),f==="passkey"&&e.jsxs("div",{className:"cedros-enrollment-form",children:[e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsxs("svg",{className:"cedros-passkey-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("rect",{x:"8",y:"16",width:"32",height:"24",rx:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"24",cy:"28",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M24 32v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e.jsx("p",{children:"Use your passkey (Touch ID, Face ID, or Windows Hello) to secure your wallet."}),e.jsx("p",{children:"You'll use the same passkey to sign transactions."})]}),e.jsxs("div",{className:"cedros-enrollment-actions",children:[t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,disabled:h,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:C,disabled:h,children:h?"Creating...":"Use Passkey"})]})]})]})}function xr(){const{user:s}=T.useCedrosLogin(),{signTransaction:t}=I.useWalletMaterial(),[o,a]=i.useState(!1),[r,n]=i.useState(null),c=i.useCallback(async(d,u)=>{if(!s){const h="User not authenticated";throw n(h),new Error(h)}a(!0),n(null);try{const h={transaction:I.uint8ArrayToBase64(d),...u?{credential:I.toCredentialRequest(u)}:{}},m=await t(h);return I.base64ToUint8Array(m.signature)}catch(h){const m=h instanceof Error?h.message:"Signing failed";throw n(m),h}finally{a(!1)}},[s,t]),l=i.useCallback(()=>n(null),[]);return{signTransaction:c,isSigning:o,error:r,clearError:l}}function Ar(){const{getMaterial:s}=I.useWalletMaterial(),[t,o]=i.useState(!1),[a,r]=i.useState(null),n=i.useCallback(async()=>{o(!0),r(null);try{const l=await s();if(!l)throw new Error("No wallet enrolled");if(l.shareAAuthMethod!=="passkey")throw new Error("Wallet is not configured for passkey authentication");if(!l.prfSalt)throw new Error("No PRF salt configured for wallet");const d=await I.authenticateWithDiscoverablePrf(l.prfSalt);try{return{type:"prfOutput",prfOutput:I.uint8ArrayToBase64(d.prfOutput)}}finally{d.prfOutput.fill(0)}}catch(l){const d=l instanceof Error?l.message:"Passkey authentication failed";return r(d),null}finally{o(!1)}},[s]),c=i.useCallback(()=>r(null),[]);return{getPasskeyCredential:n,isAuthenticating:t,error:a,clearError:c}}function vr({mode:s,isLoading:t=!1,error:o,onPrompt:a,onRetry:r,onCancel:n,title:c,description:l,className:d=""}){const u=i.useCallback(()=>{t||a?.()},[t,a]),h=i.useCallback(()=>{r?.()},[r]),m=s==="register"?"Set Up Passkey":"Verify with Passkey",f=s==="register"?"Create a passkey to securely encrypt your wallet on this device. You will use your fingerprint, face, or device PIN.":"Use your passkey to unlock your wallet. You will be prompted for biometric verification.";return e.jsxs("div",{className:`cedros-passkey-prompt ${d}`,children:[e.jsx("div",{className:"cedros-passkey-icon",children:t?e.jsx(an,{}):o?e.jsx(ln,{}):e.jsx(nn,{})}),e.jsx("h3",{className:"cedros-passkey-title",children:c??m}),e.jsx("p",{className:"cedros-passkey-description",children:l??f}),o&&e.jsx("div",{className:"cedros-passkey-error",role:"alert",children:e.jsx("p",{children:o})}),e.jsx("div",{className:"cedros-passkey-actions",children:o?e.jsxs(e.Fragment,{children:[r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:h,children:"Try Again"}),n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:n,children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:u,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"cedros-button-spinner","aria-hidden":"true"}),"Waiting for passkey..."]}):s==="register"?"Create Passkey":"Use Passkey"}),n&&!t&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:n,children:"Cancel"})]})}),t&&e.jsxs("p",{className:"cedros-passkey-hint",children:["Follow the prompts on your device to ",s==="register"?"create":"verify"," your passkey."]})]})}function nn(){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 an(){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 ln(){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 jr({onUnlock:s,onCancel:t,showCancel:o=!0,authMethod:a,className:r=""}){T.useCedrosLogin();const{unlock:n,getMaterial:c,isLoading:l}=I.useWalletMaterial(),{getPasskeyCredential:d,isAuthenticating:u}=Ar(),[h,m]=i.useState("idle"),[f,w]=i.useState(a??null),[g,p]=i.useState(""),[y,b]=i.useState(null);i.useEffect(()=>{a!==void 0&&w(a)},[a]);const x=f==="password",v=f==="passkey",j=i.useCallback(async()=>{if(m("credential"),b(null),!f)try{const L=await c();L?w(L.shareAAuthMethod):(b("No wallet enrolled"),m("error"))}catch(L){b(L instanceof Error?L.message:"Failed to get wallet info"),m("error")}},[f,c]),C=i.useCallback(async L=>{L.preventDefault(),b(null),m("unlocking");try{let E;if(x)E={type:"password",password:g};else throw new Error("Invalid auth method");await n(E),m("unlocked"),s?.()}catch(E){b(E instanceof Error?E.message:"Failed to unlock wallet"),m("error")}},[x,g,n,s]),A=i.useCallback(async()=>{b(null),m("unlocking");try{const L=await d();if(!L){m("credential");return}await n(L),m("unlocked"),s?.()}catch(L){b(L instanceof Error?L.message:"Failed to unlock wallet"),m("error")}},[d,n,s]),N=i.useCallback(()=>{p(""),m("idle"),b(null),t?.()},[t]),S=i.useCallback(()=>{p(""),m("credential"),b(null)},[]),k=l||u,P=()=>{switch(h){case"idle":return e.jsxs("div",{className:"cedros-wallet-unlock-idle",children:[e.jsx("div",{className:"cedros-wallet-unlock-icon",children:e.jsx(cn,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Wallet Locked"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Unlock your wallet to sign transactions."}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:j,children:"Unlock Wallet"})]});case"credential":return x?e.jsxs("form",{className:"cedros-wallet-unlock-form",onSubmit:C,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:L=>p(L.target.value),disabled:k,autoComplete:"current-password",error:y??void 0}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:k||g.length===0,children:k?"Unlocking...":"Unlock"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,disabled:k,children:"Cancel"})]})]}):v?e.jsxs("div",{className:"cedros-wallet-unlock-passkey",children:[e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Verify with Passkey"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:"Use your passkey to unlock your wallet."}),e.jsx(vr,{mode:"authenticate",isLoading:k,error:y??void 0,onPrompt:A,onRetry:A,onCancel:o?N:void 0})]}):e.jsxs("div",{className:"cedros-wallet-unlock-loading",children:[e.jsx(_.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(_.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(dn,{})}),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(un,{})}),e.jsx("h3",{className:"cedros-wallet-unlock-title",children:"Unlock Failed"}),e.jsx("p",{className:"cedros-wallet-unlock-description",children:y??"Failed to unlock wallet. Please try again."}),e.jsxs("div",{className:"cedros-wallet-unlock-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,children:"Try Again"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:N,children:"Cancel"})]})]})}};return e.jsx("div",{className:`cedros-wallet-unlock ${r}`,children:P()})}function cn(){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 dn(){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 un(){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 kr(){const{recover:s,getShareBForRecovery:t}=I.useWalletMaterial(),{recoveryMode:o}=wr(),[a,r]=i.useState({step:"idle"}),[n,c]=i.useState(!1),l=i.useRef([]),d=i.useCallback(()=>{I.wipeAll(...l.current),l.current=[]},[]);i.useEffect(()=>()=>{d()},[d]);const u=i.useCallback(async(m,f,w)=>{c(!0),d();try{if(r({step:"validating"}),!nr(m))throw new Error("Invalid recovery phrase. Please check your words.");let g;if(o==="share_c_only"){const S=vo(m);l.current.push(S);const k=I.uint8ArrayToBase64(S),P=await t({shareC:k}),L=I.base64ToUint8Array(P.shareB);l.current.push(L),g=ie.combineShares(I.toShamirShare(L),I.toShamirShare(S)),l.current.push(g)}else g=ko(m),l.current.push(g);const p=ie.getPublicKeyFromSeed(g),y=ie.publicKeyToBase58(p),{shareA:b,shareB:x}=ie.splitSecret(g);l.current.push(b,x),r({step:"encrypting"});let v,j,C;if(f==="passkey"){const S=I.generatePrfSalt();C=I.uint8ArrayToBase64(S);const k=await I.authenticateWithDiscoverablePrf(C);l.current.push(k.prfOutput),v=await I.deriveKeyFromPrf(k.prfOutput,S),l.current.push(v)}else j=I.generateArgon2Salt(),v=await ie.argon2DeriveInWorker(w,j,I.DEFAULT_KDF_PARAMS),l.current.push(v);const A=await I.aesGcmEncryptToBase64(b,I.toEncryptionKey(v));r({step:"uploading"});const N={solanaPubkey:y,shareAAuthMethod:f,shareACiphertext:A.ciphertext,shareANonce:A.nonce,shareB:I.uint8ArrayToBase64(x)};f==="password"&&(N.shareAKdfSalt=I.uint8ArrayToBase64(j),N.shareAKdfParams=I.DEFAULT_KDF_PARAMS),f==="passkey"&&(N.prfSalt=C),await s(N),d(),r({step:"complete"})}catch(g){d(),r({step:"error",error:g instanceof Error?g.message:"Recovery failed"})}finally{c(!1)}},[s,t,o,d]),h=i.useCallback(()=>{d(),r({step:"idle"}),c(!1)},[d]);return{state:a,startRecovery:u,cancel:h,isRecovering:n}}function Nr({onComplete:s,onCancel:t,className:o="",defaultAuthMethod:a="password"}){const{state:r,startRecovery:n,cancel:c,isRecovering:l}=kr(),[d,u]=i.useState([]),[h,m]=i.useState(!1),[f,w]=i.useState(a),[g,p]=i.useState(""),[y,b]=i.useState(""),[x,v]=i.useState(null),j=i.useCallback(k=>{u(k),m(!0)},[]),C=i.useCallback(async k=>{if(k.preventDefault(),v(null),f!=="passkey"){if(g!==y){v("Passwords do not match");return}if(f==="password"&&g.length<8){v("Password must be at least 8 characters");return}}await n(d,f,g)},[d,f,g,y,n]),A=i.useCallback(()=>{c(),u([]),m(!1),p(""),b(""),t?.()},[c,t]),N=i.useCallback(()=>{m(!1),p(""),b("")},[]),S=i.useCallback(()=>{s?.()},[s]);return r.step==="validating"||r.step==="encrypting"||r.step==="uploading"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-progress",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(hn,{})}),e.jsxs("h3",{className:"cedros-wallet-recovery-title",children:[r.step==="validating"&&"Validating Recovery Phrase",r.step==="encrypting"&&"Encrypting Wallet",r.step==="uploading"&&"Saving to Server"]}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:[r.step==="validating"&&"Checking your recovery phrase...",r.step==="encrypting"&&"Securing your wallet with new encryption...",r.step==="uploading"&&"Uploading encrypted wallet data..."]})]})}):r.step==="complete"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-success",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(pn,{})}),e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Wallet Recovered"}),e.jsxs("p",{className:"cedros-wallet-recovery-description",children:["Your wallet has been successfully recovered and secured with your new"," ",f==="passkey"?"passkey":"password","."]}),e.jsx("div",{className:"cedros-wallet-recovery-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:S,children:"Done"})})]})}):r.step==="error"?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-error",children:[e.jsx("div",{className:"cedros-wallet-recovery-icon",children:e.jsx(mn,{})}),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:A,children:"Start Over"})})]})}):h?e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("form",{className:"cedros-wallet-recovery-credential",onSubmit:C,children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Set New Security"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Choose how to secure your recovered wallet."})]}),e.jsxs("div",{className:"cedros-auth-method-selector",children:[e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"password",checked:f==="password",onChange:()=>w("password"),disabled:l}),e.jsx("span",{children:"Password"})]}),e.jsxs("label",{className:"cedros-radio-label",children:[e.jsx("input",{type:"radio",name:"authMethod",value:"passkey",checked:f==="passkey",onChange:()=>w("passkey"),disabled:l}),e.jsx("span",{children:"Passkey"})]})]}),f==="password"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password",className:"cedros-label",children:"New Password"}),e.jsx("input",{id:"recovery-password",type:"password",className:"cedros-input",value:g,onChange:k=>p(k.target.value),disabled:l,minLength:8,placeholder:"Enter a strong password"})]}),e.jsxs("div",{className:"cedros-password-input",children:[e.jsx("label",{htmlFor:"recovery-password-confirm",className:"cedros-label",children:"Confirm Password"}),e.jsx("input",{id:"recovery-password-confirm",type:"password",className:"cedros-input",value:y,onChange:k=>b(k.target.value),disabled:l,"aria-invalid":x?"true":void 0,placeholder:"Confirm your password"}),x&&e.jsx("p",{className:"cedros-input-error",role:"alert",children:x})]})]}),f==="passkey"&&e.jsxs("div",{className:"cedros-passkey-info",children:[e.jsx(fn,{}),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:N,disabled:l,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-button cedros-button-primary",disabled:l||f!=="passkey"&&(g.length===0||y.length===0),children:l?"Recovering...":"Recover Wallet"})]})]})}):e.jsx("div",{className:`cedros-wallet-recovery ${o}`,children:e.jsxs("div",{className:"cedros-wallet-recovery-phrase",children:[e.jsxs("div",{className:"cedros-wallet-recovery-header",children:[e.jsx("h3",{className:"cedros-wallet-recovery-title",children:"Recover Your Wallet"}),e.jsx("p",{className:"cedros-wallet-recovery-description",children:"Enter your 12-word recovery phrase to restore your wallet."})]}),e.jsx(gr,{onSubmit:j,onCancel:A,isSubmitting:!1})]})})}function hn(){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 pn(){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 mn(){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 fn(){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 Cr({address:s,label:t="Wallet Address",showCopy:o=!0,showExplorerLink:a=!0,allowReveal:r=!0,className:n=""}){const c=T.useCedrosLoginOptional(),[l,d]=i.useState(!1),[u,h]=i.useState(null),[m,f]=i.useState(!1),w=i.useRef(null),g=c?.config.solana?.network??"mainnet-beta",p=i.useMemo(()=>{const v=`https://explorer.solana.com/address/${s}`;return g==="mainnet-beta"?v:`${v}?cluster=${encodeURIComponent(g)}`},[s,g]),y=r&&s.length>18,b=i.useMemo(()=>!y||m?s:`${s.slice(0,8)}...${s.slice(-8)}`,[s,y,m]),x=i.useCallback(async()=>{try{h(null),await navigator.clipboard.writeText(s),d(!0),w.current!==null&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{d(!1),w.current=null},2e3)}catch(v){d(!1),h(v instanceof Error?v.message:"Copy failed")}},[s]);return i.useEffect(()=>()=>{w.current!==null&&(window.clearTimeout(w.current),w.current=null)},[]),e.jsxs("div",{className:`cedros-wallet-address-row ${n}`,children:[e.jsxs("div",{className:"cedros-wallet-address-row-header",children:[e.jsx("span",{className:"cedros-wallet-status-pubkey-label",children:t}),e.jsxs("div",{className:"cedros-wallet-address-row-actions",children:[y&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:()=>f(v=>!v),"aria-label":m?"Hide full wallet address":"Show full wallet address",children:m?e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M10.7 10.7a3 3 0 0 0 4.24 4.24",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M9.88 5.09A10.94 10.94 0 0 1 12 5c5 0 9.27 3.11 11 7-0.55 1.23-1.32 2.33-2.27 3.25",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M6.61 6.61C4.4 7.9 2.74 9.8 1 12c1.73 3.89 6 7 11 7 1.14 0 2.25-0.16 3.3-0.46",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}):e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),a&&e.jsx("a",{className:"cedros-button cedros-button-sm cedros-button-ghost",href:p,target:"_blank",rel:"noreferrer",children:"Explorer"}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-outline",onClick:x,"aria-label":"Copy wallet address",children:l?"Copied":"Copy"})]})]}),e.jsx("code",{className:"cedros-wallet-status-pubkey-value",title:s,children:b}),u&&e.jsx("p",{className:"cedros-input-hint",role:"status",children:u})]})}function Sr({status:s,publicKey:t,onLock:o,onEnroll:a,onUnlock:r,onRecover:n,showActions:c=!0,compact:l=!1,className:d=""}){const u=s!==void 0,h=I.useWallet(),m=u?s:h.status,f=u?t??null:h.solanaPubkey,w=u?null:h.error,g=u?()=>{}:h.refresh,p=u?()=>{}:h.clearError,y=gn(m,w);return l?e.jsxs("div",{className:`cedros-wallet-status cedros-wallet-status-compact ${d}`,children:[e.jsx("span",{className:`cedros-wallet-status-dot cedros-wallet-status-${y.color}`,title:y.label}),e.jsx("span",{className:"cedros-wallet-status-label",children:y.label}),f&&e.jsx("span",{className:"cedros-wallet-status-pubkey",title:f,children:wn(f)})]}):e.jsxs("div",{className:`cedros-wallet-status ${d}`,children:[e.jsxs("div",{className:"cedros-wallet-status-header",children:[e.jsx("div",{className:`cedros-wallet-status-icon cedros-wallet-status-icon-${y.color}`,children:e.jsx(yn,{status:m})}),e.jsxs("div",{className:"cedros-wallet-status-info",children:[e.jsx("h4",{className:"cedros-wallet-status-title",children:y.title}),e.jsx("p",{className:"cedros-wallet-status-description",children:y.description})]})]}),f&&e.jsx("div",{className:"cedros-wallet-status-pubkey-full",children:e.jsx(Cr,{address:f})}),w&&e.jsxs("div",{className:"cedros-wallet-status-error-box",role:"alert",children:[e.jsx("p",{children:w}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-secondary",onClick:p,children:"Dismiss"})]}),c&&e.jsxs("div",{className:"cedros-wallet-status-actions",children:[m==="not_enrolled"&&a&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:a,children:"Create Wallet"}),m==="enrolled_locked"&&r&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-sm",onClick:r,children:"Unlock Wallet"}),(m==="not_enrolled"||m==="error")&&n&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:n,children:"Recover Wallet"}),m==="error"&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:g,children:"Retry"})]})]})}function gn(s,t){switch(s){case"loading":return{label:"Loading",title:"Checking Wallet",description:"Verifying wallet status...",color:"loading"};case"not_enrolled":return{label:"Not Set Up",title:"No Wallet",description:"Create a wallet to start using Solana.",color:"muted"};case"enrolled_locked":return{label:"Locked",title:"Wallet Locked",description:"Unlock your wallet to sign transactions.",color:"warning"};case"enrolled_unlocked":case"unlocked":return{label:"Ready",title:"Wallet Ready",description:"Your wallet is unlocked and ready to use.",color:"success"};case"error":default:return{label:"Error",title:"Wallet Error",description:t??"An error occurred with your wallet.",color:"error"}}}function wn(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function yn({status:s}){switch(s){case"loading":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:"cedros-spinner",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2",opacity:"0.25"}),e.jsx("path",{d:"M12 3a9 9 0 0 1 9 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]});case"not_enrolled":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M8 12h8M12 8v8"})]});case"enrolled_locked":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),e.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]});case"enrolled_unlocked":case"unlocked":return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 6L9 17l-5-5"})});case"error":return e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4M12 17h.01"})]});default:return null}}function bn({className:s="",showActions:t=!0}){const o=I.useWallet(),[a,r]=i.useState("status"),n=i.useMemo(()=>{switch(a){case"enroll":return{title:"Create Wallet",description:"Set up your embedded wallet."};case"unlock":return{title:"Unlock Wallet",description:"Unlock to sign transactions."};case"recover_intro":case"recover":return{title:"Recover Wallet",description:"Restore access using your recovery phrase."};case"status":default:return null}},[a]),c=i.useCallback(()=>r("status"),[]),l=i.useCallback(async()=>{r("status"),await o.refresh()},[o]),d=i.useCallback(async()=>{r("status"),await o.refresh()},[o]),u=i.useCallback(async()=>{r("status"),await o.refresh()},[o]);return e.jsxs("div",{className:`cedros-wallet-manager ${s}`,children:[a!=="status"&&n&&e.jsxs("div",{className:"cedros-wallet-manager-header",children:[e.jsxs("div",{className:"cedros-wallet-manager-header-text",children:[e.jsx("h3",{className:"cedros-wallet-manager-title",children:n.title}),e.jsx("p",{className:"cedros-wallet-manager-subtitle",children:n.description})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-sm cedros-button-ghost",onClick:c,children:"Back"})]}),a==="status"&&e.jsx(Sr,{onEnroll:()=>r("enroll"),onUnlock:()=>r("unlock"),onRecover:()=>r("recover_intro"),showActions:t}),a==="enroll"&&e.jsx(br,{onComplete:()=>{l()},onCancel:c}),a==="unlock"&&e.jsx(jr,{onUnlock:()=>{d()},onCancel:c}),a==="recover_intro"&&e.jsx("div",{className:"cedros-wallet-manager-intro",children:e.jsxs("div",{className:"cedros-wallet-manager-intro-card",children:[e.jsx("h4",{className:"cedros-wallet-manager-intro-title",children:"Before you start"}),e.jsxs("ul",{className:"cedros-wallet-manager-intro-list",children:[e.jsx("li",{children:"You’ll need your 12-word recovery phrase."}),e.jsx("li",{children:"You’ll set a new password or passkey for this wallet."}),e.jsx("li",{children:"If you’re on a shared device, avoid copying the phrase into other apps."})]}),e.jsxs("div",{className:"cedros-wallet-manager-intro-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:()=>r("recover"),children:"Start recovery"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:c,children:"Cancel"})]})]})}),a==="recover"&&e.jsx(Nr,{onComplete:()=>{u()},onCancel:c})]})}function xn({showDescriptions:s=!0,className:t="",onSave:o}){const{settings:a,isLoading:r,isUpdating:n,error:c,fetchSettings:l,updateSettings:d}=Yt.useSystemSettings(),[u,h]=i.useState({}),[m,f]=i.useState(null),[w,g]=i.useState(!1);i.useEffect(()=>{l()},[l]),i.useEffect(()=>{if(w){const C=setTimeout(()=>g(!1),3e3);return()=>clearTimeout(C)}},[w]);const p=i.useCallback((C,A)=>{h(N=>({...N,[C]:A})),f(null),g(!1)},[]),y=i.useCallback(async()=>{const C=Object.entries(u).map(([A,N])=>({key:A,value:N}));if(C.length!==0)try{await d(C),h({}),f(null),g(!0),o?.()}catch(A){f(A instanceof Error?A.message:"Failed to save settings")}},[u,d,o]),b=i.useCallback(()=>{h({}),f(null),g(!1)},[]),x=Object.keys(u).length>0,v=Object.keys(u).length;if(r&&Object.keys(a).length===0)return e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${t}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]});if(c)return e.jsx("div",{className:`cedros-system-settings ${t}`,children:e.jsx(Y.ErrorMessage,{error:c.message})});const j=Object.keys(a).sort();return j.length===0?e.jsx("div",{className:`cedros-system-settings cedros-system-settings-empty ${t}`,children:e.jsx("p",{children:"No system settings found."})}):e.jsxs("div",{className:`cedros-system-settings ${t}`,children:[m&&e.jsx(Y.ErrorMessage,{error:m}),w&&e.jsx("div",{className:"cedros-settings-success",children:"Settings saved successfully."}),j.map(C=>e.jsx(An,{category:C,settings:a[C],edits:u,showDescription:s,onChange:p},C)),e.jsxs("div",{className:"cedros-system-settings-actions",children:[x&&e.jsxs("span",{className:"cedros-settings-change-count",children:[v," unsaved change",v!==1?"s":""]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-secondary",onClick:b,disabled:!x||n,children:"Reset"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:y,disabled:!x||n,children:n?e.jsx(_.LoadingSpinner,{size:"sm"}):"Save Changes"})]})]})}const mt=Object.keys(je.SETTING_METADATA);function An({category:s,settings:t,edits:o,showDescription:a,onChange:r}){const n=je.CATEGORY_METADATA[s]||{label:s,description:"",icon:""},c=i.useMemo(()=>[...t].sort((l,d)=>{const u=mt.indexOf(l.key),h=mt.indexOf(d.key);return(u===-1?1/0:u)-(h===-1?1/0:h)}),[t]);return e.jsxs("section",{className:"cedros-settings-section",children:[e.jsxs("div",{className:"cedros-settings-section-header",children:[e.jsx("span",{className:"cedros-settings-section-icon",children:n.icon}),e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-settings-section-title",children:n.label}),a&&n.description&&e.jsx("p",{className:"cedros-settings-section-description",children:n.description})]})]}),e.jsx(je.SettingsSection,{settings:c,edits:o,onChange:r})]})}class vn{client;constructor(t,o,a){this.client=new T.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a})}async getStatus(){try{return await this.client.get("/setup/status")}catch(t){throw T.handleApiError(t,"Failed to check setup status")}}async createFirstAdmin(t){try{return await this.client.post("/setup/admin",t)}catch(o){throw T.handleApiError(o,"Failed to create admin account")}}}function Gs(){const{config:s}=T.useCedrosLogin(),[t,o]=i.useState(null),[a,r]=i.useState(!1),[n,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useRef(0),h=i.useMemo(()=>new vn(s.serverUrl,s.requestTimeout,s.retryAttempts),[s.serverUrl,s.requestTimeout,s.retryAttempts]),m=i.useRef(h);m.current=h;const f=i.useCallback(async()=>{r(!0),d(null);const g=++u.current;try{const p=await m.current.getStatus();if(g!==u.current)return;o(p)}catch(p){if(g!==u.current)return;d(p instanceof Error?p:new Error("Failed to check setup status"))}finally{g===u.current&&r(!1)}},[]),w=i.useCallback(async g=>{c(!0),d(null);try{const p=await m.current.createFirstAdmin(g);return await f(),p}catch(p){const y=p instanceof Error?p:new Error("Failed to create admin");throw d(y),y}finally{c(!1)}},[f]);return{status:t,isLoading:a,isCreating:n,error:l,checkStatus:f,createAdmin:w}}const jn=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,ft=8;function kn(s){const t={};return s.email?jn.test(s.email)||(t.email="Invalid email format"):t.email="Email is required",s.password?s.password.length<ft&&(t.password=`Password must be at least ${ft} characters`):t.password="Password is required",s.confirmPassword?s.password!==s.confirmPassword&&(t.confirmPassword="Passwords do not match"):t.confirmPassword="Please confirm your password",t}function Er({onComplete:s,className:t=""}){const{status:o,isLoading:a,isCreating:r,error:n,checkStatus:c,createAdmin:l}=Gs(),[d,u]=i.useState({email:"",password:"",confirmPassword:"",name:"",orgName:""}),[h,m]=i.useState({}),[f,w]=i.useState(!1);i.useEffect(()=>{c()},[c]);const g=i.useCallback(y=>b=>{u(x=>({...x,[y]:b.target.value})),m(x=>({...x,[y]:void 0}))},[]),p=i.useCallback(async y=>{y.preventDefault();const b=kn(d);if(Object.keys(b).length>0){m(b);return}try{await l({email:d.email,password:d.password,name:d.name||void 0,orgName:d.orgName||void 0}),w(!0),s?.()}catch{}},[d,l,s]);return a?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__loading",children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{className:"cedros-setup__loading-text",children:"Checking setup status..."})]})}):o&&!o.needsSetup?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Setup Complete"}),e.jsx("p",{className:"cedros-setup__text",children:"An admin account already exists. You can now log in."})]})}):f?e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__complete",children:[e.jsx("div",{className:"cedros-setup__icon cedros-setup__icon--success",children:e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]})}),e.jsx("h2",{className:"cedros-setup__title",children:"Admin Account Created"}),e.jsx("p",{className:"cedros-setup__text",children:"Your admin account has been created successfully. You can now log in with your credentials."})]})}):e.jsx("div",{className:`cedros-setup ${t}`,children:e.jsxs("div",{className:"cedros-setup__container",children:[e.jsxs("div",{className:"cedros-setup__header",children:[e.jsx("div",{className:"cedros-setup__logo",children:e.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]})}),e.jsx("h1",{className:"cedros-setup__title",children:"Welcome to Cedros"}),e.jsx("p",{className:"cedros-setup__subtitle",children:"Let's set up your admin account to get started."})]}),e.jsxs("form",{className:"cedros-setup__form",onSubmit:p,children:[n&&e.jsx(Y.ErrorMessage,{error:n.message}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-email",className:"cedros-setup__label",children:["Email Address ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-email",type:"email",className:`cedros-setup__input ${h.email?"cedros-setup__input--error":""}`,value:d.email,onChange:g("email"),placeholder:"admin@example.com",autoComplete:"email",autoFocus:!0,disabled:r}),h.email&&e.jsx("span",{className:"cedros-setup__error",children:h.email})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-name",className:"cedros-setup__label",children:"Display Name"}),e.jsx("input",{id:"setup-name",type:"text",className:"cedros-setup__input",value:d.name,onChange:g("name"),placeholder:"Admin",autoComplete:"name",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsx("label",{htmlFor:"setup-org-name",className:"cedros-setup__label",children:"Organization Name"}),e.jsx("input",{id:"setup-org-name",type:"text",className:"cedros-setup__input",value:d.orgName,onChange:g("orgName"),placeholder:"My Organization",disabled:r})]}),e.jsxs("div",{className:"cedros-setup__field",children:[e.jsxs("label",{htmlFor:"setup-password",className:"cedros-setup__label",children:["Password ",e.jsx("span",{className:"cedros-setup__required",children:"*"})]}),e.jsx("input",{id:"setup-password",type:"password",className:`cedros-setup__input ${h.password?"cedros-setup__input--error":""}`,value:d.password,onChange:g("password"),placeholder:"At least 8 characters",autoComplete:"new-password",disabled:r}),h.password&&e.jsx("span",{className:"cedros-setup__error",children:h.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 ${h.confirmPassword?"cedros-setup__input--error":""}`,value:d.confirmPassword,onChange:g("confirmPassword"),placeholder:"Confirm your password",autoComplete:"new-password",disabled:r}),h.confirmPassword&&e.jsx("span",{className:"cedros-setup__error",children:h.confirmPassword})]}),e.jsx("button",{type:"submit",className:"cedros-setup__button",disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Creating Account..."})]}):"Create Admin Account"})]}),e.jsxs("div",{className:"cedros-setup__footer",children:[e.jsx("p",{className:"cedros-setup__note",children:"This will be the first administrator account for your installation."}),o?.serverVersion&&e.jsxs("p",{className:"cedros-setup__version",children:["Server version: ",o.serverVersion]})]})]})})}const Nn=["security","rate_limit"];function Cn({className:s}){return e.jsx(Hs.SettingsPageLayout,{title:"Security",description:"Configure CORS, cookies, sessions, JWT, and rate limiting settings.",categories:Nn,className:s})}const gt=[{id:"email",label:"Email",category:"email"},{id:"webhooks",label:"Webhooks",category:"webhook"}];function Sn({className:s}){const{settings:t,edits:o,isLoading:a,autosaveStatus:r,autosaveError:n,error:c,fetchSettings:l,handleChange:d,getEffectiveValue:u}=je.useSettingsAutosave(),[h,m]=i.useState("email");i.useEffect(()=>{l()},[l]);const f=gt.find(j=>j.id===h),w=f?.category??"",p=(u("email_provider")||"custom")==="custom",y=u("email_smtp_host"),b=!p||y!=null&&y!=="",x=i.useMemo(()=>{const j=t[w]??[];if(h!=="email")return j;const C=p?ze.ALL_EMAIL_FIELDS:ze.SIMPLIFIED_EMAIL_FIELDS;return j.filter(A=>C.includes(A.key)).sort((A,N)=>C.indexOf(A.key)-C.indexOf(N.key))},[t,w,h,p]),v=(j,C)=>{if(d(j,C),j==="email_provider"&&C!=="custom"){const A=ze.PROVIDER_SMTP_HOSTS[C];A&&(d("email_smtp_host",A),d("email_smtp_port","587"),d("email_smtp_tls","true"))}};return a&&Object.keys(t).length===0?e.jsxs("div",{className:`cedros-system-settings cedros-system-settings-loading ${s??""}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading settings..."})]}):c?e.jsx("div",{className:`cedros-system-settings ${s??""}`,children:e.jsx(Y.ErrorMessage,{error:c.message})}):e.jsxs("div",{className:`cedros-system-settings ${s??""}`,children:[e.jsxs("div",{className:"cedros-settings-page-header",children:[e.jsxs("div",{className:"cedros-settings-page-header-content",children:[e.jsx("h2",{className:"cedros-settings-page-title",children:"Auth Messages"}),e.jsx("p",{className:"cedros-settings-page-description",children:"Configure email delivery for verification emails, password resets, and instant link login. Webhook notifications can be sent to Discord or Slack."})]}),e.jsx(je.AutosaveStatus,{status:r,error:n})]}),h==="email"&&!b&&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:gt.map(j=>e.jsx("button",{type:"button",className:`cedros-admin-tab ${h===j.id?"cedros-admin-tab-active":""}`,onClick:()=>m(j.id),"aria-selected":h===j.id,role:"tab",children:j.label},j.id))}),e.jsx("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:x.length===0?e.jsx("div",{className:"cedros-system-settings-empty",children:e.jsxs("p",{children:["No settings found for ",f?.label??"this section","."]})}):e.jsx(je.SettingsSection,{settings:x,edits:o,onChange:h==="email"?v:d})})]})}const ae={users:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),members:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"9",cy:"7",r:"4"}),e.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),e.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),deposits:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8"}),e.jsx("path",{d:"M12 18V6"})]}),withdrawals:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2"}),e.jsx("path",{d:"M9 22v-4h6v4"}),e.jsx("path",{d:"M8 6h.01"}),e.jsx("path",{d:"M16 6h.01"}),e.jsx("path",{d:"M12 6h.01"}),e.jsx("path",{d:"M12 10h.01"}),e.jsx("path",{d:"M12 14h.01"}),e.jsx("path",{d:"M16 10h.01"}),e.jsx("path",{d:"M16 14h.01"}),e.jsx("path",{d:"M8 10h.01"}),e.jsx("path",{d:"M8 14h.01"})]}),wallet:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1"}),e.jsx("path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4"})]}),chevronRight:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),key:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"})}),mail:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),e.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]}),coins:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"8",cy:"8",r:"6"}),e.jsx("path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18"}),e.jsx("path",{d:"M7 6h1v4"}),e.jsx("path",{d:"m16.71 13.88.7.71-2.82 2.82"})]}),server:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),e.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),e.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]})},En=[{id:"users",label:"Users",icon:ae.users},{id:"team",label:"Team",icon:ae.members},{id:"deposits",label:"Deposits",icon:ae.deposits,requiredFeature:"credits"},{id:"withdrawals",label:"Withdrawals",icon:ae.withdrawals,requiredFeature:"credits"},{id:"settings-auth",label:"Authentication",icon:ae.key,group:"Configuration"},{id:"settings-messaging",label:"Auth Messages",icon:ae.mail,group:"Configuration"},{id:"settings-wallet",label:"User Wallets",icon:ae.wallet,group:"Configuration"},{id:"settings-credits",label:"Credit System",icon:ae.coins,group:"Configuration",requiredFeature:"credits"},{id:"settings-server",label:"Auth Server",icon:ae.server,group:"Configuration"}];function Ln({title:s="Dashboard",sections:t=["users","team","deposits","withdrawals","settings-wallet","settings-auth","settings-messaging","settings-credits","settings-server"],defaultSection:o="users",refreshInterval:a=0,pageSize:r=20,onSectionChange:n,onSettingsClick:c,onLogoutClick:l,className:d=""}){const[u,h]=i.useState(o),[m,f]=i.useState(!0),{user:w,logout:g}=T.useCedrosLogin(),{activeOrg:p,role:y,isLoading:b,fetchOrgs:x,hasPermission:v}=zs.useOrgs(),{status:j,isLoading:C,checkStatus:A}=Gs(),{features:N,isLoading:S}=te.useServerFeatures(),{canAccess:k}=te.useDashboardPermissions(),P=i.useCallback(D=>{h(D),n?.(D)},[n]),L=En.filter(D=>!(!t.includes(D.id)||D.requiredFeature&&!N[D.requiredFeature]||!k(D.id))),E=L.find(D=>D.id===u),M=!E&&!S;return i.useEffect(()=>{x(),A()},[x,A]),i.useEffect(()=>{M&&L.length>0&&h("users")},[M,L.length]),!C&&j?.needsSetup?e.jsx("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--setup ${d}`,children:e.jsx(Er,{onComplete:()=>A()})}):(b||C||S)&&!p?e.jsxs("div",{className:`cedros-admin cedros-dashboard cedros-dashboard--loading ${d}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{className:"cedros-dashboard__loading-text",children:"Loading..."})]}):u==="team"&&!p?e.jsx("div",{className:`cedros-admin cedros-dashboard ${d}`,children:e.jsx(Y.ErrorMessage,{error:"No organization selected. Please select an organization first."})}):e.jsxs("div",{className:`cedros-admin cedros-dashboard ${d}`,children:[e.jsxs("aside",{className:"cedros-dashboard__sidebar",children:[e.jsx("div",{className:"cedros-dashboard__sidebar-header",children:e.jsxs("div",{className:"cedros-dashboard__logo",children:[ae.wallet,e.jsx("span",{className:"cedros-dashboard__logo-text",children:s})]})}),e.jsxs("nav",{className:"cedros-dashboard__nav",children:[e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsx("span",{className:"cedros-dashboard__nav-label",children:"Menu"}),L.filter(D=>!D.group).map(D=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===D.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>P(D.id),"aria-current":u===D.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:D.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:D.label})]},D.id))]}),L.some(D=>D.group==="Configuration")&&e.jsxs("div",{className:"cedros-dashboard__nav-group",children:[e.jsxs("button",{type:"button",className:"cedros-dashboard__nav-label cedros-dashboard__nav-label--collapsible",onClick:()=>f(!m),"aria-expanded":m,children:[e.jsx("span",{children:"Configuration"}),e.jsx("span",{className:`cedros-dashboard__nav-chevron ${m?"cedros-dashboard__nav-chevron--expanded":""}`,children:ae.chevronRight})]}),m&&L.filter(D=>D.group==="Configuration").map(D=>e.jsxs("button",{type:"button",className:`cedros-dashboard__nav-item ${u===D.id?"cedros-dashboard__nav-item--active":""}`,onClick:()=>P(D.id),"aria-current":u===D.id?"page":void 0,children:[e.jsx("span",{className:"cedros-dashboard__nav-icon",children:D.icon}),e.jsx("span",{className:"cedros-dashboard__nav-text",children:D.label})]},D.id))]})]}),w&&e.jsx("div",{className:"cedros-dashboard__sidebar-footer",children:e.jsx(ge.ProfileDropdown,{name:w.name,email:w.email,picture:w.picture,onSettings:c,onLogout:l??g})})]}),e.jsxs("main",{className:"cedros-dashboard__main",children:[e.jsx("header",{className:"cedros-dashboard__header",children:e.jsxs("div",{className:"cedros-dashboard__breadcrumb",children:[e.jsx("span",{className:"cedros-dashboard__breadcrumb-root",children:s}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-sep",children:ae.chevronRight}),e.jsx("span",{className:"cedros-dashboard__breadcrumb-current",children:E?.label})]})}),e.jsxs("div",{className:"cedros-dashboard__content",children:[u==="users"&&e.jsx(Pn,{pageSize:r,currentUserId:w?.id}),u==="team"&&p&&e.jsx(Mn,{orgId:p.id,currentUserId:w?.id,hasPermission:v,role:y}),u==="deposits"&&e.jsx(Tn,{pageSize:r,refreshInterval:a}),u==="withdrawals"&&e.jsx(Rn,{pageSize:r,refreshInterval:a}),u==="settings-auth"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx($t.AuthenticationSettings,{})}),u==="settings-wallet"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Jt.EmbeddedWalletSettings,{})}),u==="settings-messaging"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Sn,{})}),u==="settings-credits"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Vs.CreditSystemSettings,{})}),u==="settings-server"&&e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Xt.ServerSettings,{})})]})]})]})}function Pn({pageSize:s,currentUserId:t}){const[o,a]=i.useState(null),{statsItems:r,isLoading:n,error:c,refresh:l}=Te.useUsersStatsSummary();return o?e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(Te.AdminUserDetail,{userId:o.id,currentUserId:t,onBack:()=>a(null)})}):e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx(Gt.StatsBar,{stats:r,isLoading:n,onRefresh:l}),c&&e.jsx("p",{className:"cedros-admin-error-inline",children:c}),e.jsx(Te.AdminUserList,{pageSize:s,currentUserId:t,onUserClick:d=>a(d)})]})}function Mn({orgId:s,currentUserId:t,hasPermission:o,role:a}){const[r,n]=i.useState("members"),{members:c,isLoading:l,error:d,fetchMembers:u,updateMemberRole:h,removeMember:m}=te.useMembers(s),{invites:f,isLoading:w,error:g,fetchInvites:p,createInvite:y,cancelInvite:b,resendInvite:x}=te.useInvites(s);i.useEffect(()=>{u(),p()},[u,p]);const v=o("invite:create"),j=o("invite:cancel"),C=f.length,A=c.reduce((P,L)=>(P[L.role]=(P[L.role]??0)+1,P),{}),N=A.owner??0,S=A.admin??0,k=A.member??0;return e.jsxs("div",{className:"cedros-dashboard__team",children:[e.jsx(Gt.StatsBar,{stats:[{label:"Owners",value:N},{label:"Admins",value:S},{label:"Members",value:k},{label:"Pending Invites",value:C}]}),e.jsxs("div",{className:"cedros-admin-tabs cedros-admin-tabs--line",children:[e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="members"?"cedros-admin-tab-active":""}`,onClick:()=>n("members"),"aria-selected":r==="members",role:"tab",children:"Members"}),e.jsxs("button",{type:"button",className:`cedros-admin-tab ${r==="invites"?"cedros-admin-tab-active":""}`,onClick:()=>n("invites"),"aria-selected":r==="invites",role:"tab",children:["Pending Invites",C>0&&` (${C})`]}),a==="owner"&&e.jsx("button",{type:"button",className:`cedros-admin-tab ${r==="permissions"?"cedros-admin-tab-active":""}`,onClick:()=>n("permissions"),"aria-selected":r==="permissions",role:"tab",children:"Permissions"})]}),e.jsxs("div",{className:"cedros-admin-tab-content",role:"tabpanel",children:[r==="members"&&e.jsx(te.MemberList,{members:c,currentUserId:t,isLoading:l,error:d?.message,canManage:o("member:remove"),canChangeRoles:o("member:role_change"),onUpdateRole:h,onRemove:m}),r==="invites"&&e.jsxs("div",{className:"cedros-dashboard__invites",children:[v&&e.jsxs("div",{className:"cedros-dashboard__section",children:[e.jsx("div",{className:"cedros-dashboard__section-header",children:e.jsx("h3",{className:"cedros-dashboard__section-title",children:"Send Invitation"})}),e.jsx(te.InviteForm,{onSubmit:y,isLoading:w,error:g?.message})]}),e.jsx("div",{className:"cedros-dashboard__section",children:e.jsx(te.InviteList,{invites:f,isLoading:w,error:g?.message,canManage:j||v,onCancel:j?b:void 0,onResend:v?x:void 0})})]}),r==="permissions"&&a==="owner"&&e.jsx(te.PermissionsSection,{userRole:a})]})]})}function Tn({pageSize:s,refreshInterval:t}){const[o,a]=i.useState("");return e.jsxs("div",{className:"cedros-dashboard__deposits",children:[e.jsx(He.AdminDepositStats,{refreshInterval:t}),e.jsxs("div",{className:"cedros-dashboard__deposits-list",children:[e.jsx("div",{className:"cedros-dashboard__toolbar",children:e.jsxs("div",{className:"cedros-dashboard__filter",children:[e.jsx("label",{className:"cedros-dashboard__filter-label",htmlFor:"status-filter",children:"Status"}),e.jsxs("select",{id:"status-filter",className:"cedros-dashboard__select",value:o,onChange:r=>a(r.target.value),children:[e.jsx("option",{value:"",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"detected",children:"Detected"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"completed",children:"Completed"}),e.jsx("option",{value:"withdrawn",children:"Withdrawn"}),e.jsx("option",{value:"expired",children:"Expired"}),e.jsx("option",{value:"failed",children:"Failed"})]})]})}),e.jsx(He.AdminDepositList,{statusFilter:o||void 0,pageSize:s,refreshInterval:t})]})]})}function Rn({pageSize:s,refreshInterval:t}){return e.jsxs("div",{className:"cedros-dashboard__withdrawals",children:[e.jsx(fe.AdminWithdrawalStats,{refreshInterval:t}),e.jsx("p",{className:"cedros-dashboard__text-muted",children:"Track deposits through the withdrawal pipeline: privacy period, ready for processing, and completed."}),e.jsxs("div",{className:"cedros-dashboard__pipeline",children:[e.jsx(fe.AdminPrivacyPeriodDeposits,{pageSize:s,refreshInterval:t}),e.jsx(fe.AdminWithdrawalQueue,{pageSize:s,refreshInterval:t}),e.jsx(fe.AdminWithdrawalHistory,{pageSize:s,refreshInterval:t})]})]})}var Ae={},us,wt;function Bn(){return wt||(wt=1,us=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),us}var hs={},me={},yt;function ye(){if(yt)return me;yt=1;let s;const t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return me.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},me.getSymbolTotalCodewords=function(a){return t[a]},me.getBCHDigit=function(o){let a=0;for(;o!==0;)a++,o>>>=1;return a},me.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');s=a},me.isKanjiModeEnabled=function(){return typeof s<"u"},me.toSJIS=function(a){return s(a)},me}var ps={},bt;function $s(){return bt||(bt=1,(function(s){s.L={bit:1},s.M={bit:0},s.Q={bit:3},s.H={bit:2};function t(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return s.L;case"m":case"medium":return s.M;case"q":case"quartile":return s.Q;case"h":case"high":return s.H;default:throw new Error("Unknown EC Level: "+o)}}s.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},s.from=function(a,r){if(s.isValid(a))return a;try{return t(a)}catch{return r}}})(ps)),ps}var ms,xt;function In(){if(xt)return ms;xt=1;function s(){this.buffer=[],this.length=0}return s.prototype={get:function(t){const o=Math.floor(t/8);return(this.buffer[o]>>>7-t%8&1)===1},put:function(t,o){for(let a=0;a<o;a++)this.putBit((t>>>o-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const o=Math.floor(this.length/8);this.buffer.length<=o&&this.buffer.push(0),t&&(this.buffer[o]|=128>>>this.length%8),this.length++}},ms=s,ms}var fs,At;function Dn(){if(At)return fs;At=1;function s(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}return s.prototype.set=function(t,o,a,r){const n=t*this.size+o;this.data[n]=a,r&&(this.reservedBit[n]=!0)},s.prototype.get=function(t,o){return this.data[t*this.size+o]},s.prototype.xor=function(t,o,a){this.data[t*this.size+o]^=a},s.prototype.isReserved=function(t,o){return this.reservedBit[t*this.size+o]},fs=s,fs}var gs={},vt;function Fn(){return vt||(vt=1,(function(s){const t=ye().getSymbolSize;s.getRowColCoords=function(a){if(a===1)return[];const r=Math.floor(a/7)+2,n=t(a),c=n===145?26:Math.ceil((n-13)/(2*r-2))*2,l=[n-7];for(let d=1;d<r-1;d++)l[d]=l[d-1]-c;return l.push(6),l.reverse()},s.getPositions=function(a){const r=[],n=s.getRowColCoords(a),c=n.length;for(let l=0;l<c;l++)for(let d=0;d<c;d++)l===0&&d===0||l===0&&d===c-1||l===c-1&&d===0||r.push([n[l],n[d]]);return r}})(gs)),gs}var ws={},jt;function Un(){if(jt)return ws;jt=1;const s=ye().getSymbolSize,t=7;return ws.getPositions=function(a){const r=s(a);return[[0,0],[r-t,0],[0,r-t]]},ws}var ys={},kt;function _n(){return kt||(kt=1,(function(s){s.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};s.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},s.from=function(r){return s.isValid(r)?parseInt(r,10):void 0},s.getPenaltyN1=function(r){const n=r.size;let c=0,l=0,d=0,u=null,h=null;for(let m=0;m<n;m++){l=d=0,u=h=null;for(let f=0;f<n;f++){let w=r.get(m,f);w===u?l++:(l>=5&&(c+=t.N1+(l-5)),u=w,l=1),w=r.get(f,m),w===h?d++:(d>=5&&(c+=t.N1+(d-5)),h=w,d=1)}l>=5&&(c+=t.N1+(l-5)),d>=5&&(c+=t.N1+(d-5))}return c},s.getPenaltyN2=function(r){const n=r.size;let c=0;for(let l=0;l<n-1;l++)for(let d=0;d<n-1;d++){const u=r.get(l,d)+r.get(l,d+1)+r.get(l+1,d)+r.get(l+1,d+1);(u===4||u===0)&&c++}return c*t.N2},s.getPenaltyN3=function(r){const n=r.size;let c=0,l=0,d=0;for(let u=0;u<n;u++){l=d=0;for(let h=0;h<n;h++)l=l<<1&2047|r.get(u,h),h>=10&&(l===1488||l===93)&&c++,d=d<<1&2047|r.get(h,u),h>=10&&(d===1488||d===93)&&c++}return c*t.N3},s.getPenaltyN4=function(r){let n=0;const c=r.data.length;for(let d=0;d<c;d++)n+=r.data[d];return Math.abs(Math.ceil(n*100/c/5)-10)*t.N4};function o(a,r,n){switch(a){case s.Patterns.PATTERN000:return(r+n)%2===0;case s.Patterns.PATTERN001:return r%2===0;case s.Patterns.PATTERN010:return n%3===0;case s.Patterns.PATTERN011:return(r+n)%3===0;case s.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case s.Patterns.PATTERN101:return r*n%2+r*n%3===0;case s.Patterns.PATTERN110:return(r*n%2+r*n%3)%2===0;case s.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}s.applyMask=function(r,n){const c=n.size;for(let l=0;l<c;l++)for(let d=0;d<c;d++)n.isReserved(d,l)||n.xor(d,l,o(r,d,l))},s.getBestMask=function(r,n){const c=Object.keys(s.Patterns).length;let l=0,d=1/0;for(let u=0;u<c;u++){n(u),s.applyMask(u,r);const h=s.getPenaltyN1(r)+s.getPenaltyN2(r)+s.getPenaltyN3(r)+s.getPenaltyN4(r);s.applyMask(u,r),h<d&&(d=h,l=u)}return l}})(ys)),ys}var Oe={},Nt;function Lr(){if(Nt)return Oe;Nt=1;const s=$s(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],o=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return Oe.getBlocksCount=function(r,n){switch(n){case s.L:return t[(r-1)*4+0];case s.M:return t[(r-1)*4+1];case s.Q:return t[(r-1)*4+2];case s.H:return t[(r-1)*4+3];default:return}},Oe.getTotalCodewordsCount=function(r,n){switch(n){case s.L:return o[(r-1)*4+0];case s.M:return o[(r-1)*4+1];case s.Q:return o[(r-1)*4+2];case s.H:return o[(r-1)*4+3];default:return}},Oe}var bs={},Me={},Ct;function Wn(){if(Ct)return Me;Ct=1;const s=new Uint8Array(512),t=new Uint8Array(256);return(function(){let a=1;for(let r=0;r<255;r++)s[r]=a,t[a]=r,a<<=1,a&256&&(a^=285);for(let r=255;r<512;r++)s[r]=s[r-255]})(),Me.log=function(a){if(a<1)throw new Error("log("+a+")");return t[a]},Me.exp=function(a){return s[a]},Me.mul=function(a,r){return a===0||r===0?0:s[t[a]+t[r]]},Me}var St;function On(){return St||(St=1,(function(s){const t=Wn();s.mul=function(a,r){const n=new Uint8Array(a.length+r.length-1);for(let c=0;c<a.length;c++)for(let l=0;l<r.length;l++)n[c+l]^=t.mul(a[c],r[l]);return n},s.mod=function(a,r){let n=new Uint8Array(a);for(;n.length-r.length>=0;){const c=n[0];for(let d=0;d<r.length;d++)n[d]^=t.mul(r[d],c);let l=0;for(;l<n.length&&n[l]===0;)l++;n=n.slice(l)}return n},s.generateECPolynomial=function(a){let r=new Uint8Array([1]);for(let n=0;n<a;n++)r=s.mul(r,new Uint8Array([1,t.exp(n)]));return r}})(bs)),bs}var xs,Et;function qn(){if(Et)return xs;Et=1;const s=On();function t(o){this.genPoly=void 0,this.degree=o,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(a){this.degree=a,this.genPoly=s.generateECPolynomial(this.degree)},t.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const r=new Uint8Array(a.length+this.degree);r.set(a);const n=s.mod(r,this.genPoly),c=this.degree-n.length;if(c>0){const l=new Uint8Array(this.degree);return l.set(n,c),l}return n},xs=t,xs}var As={},vs={},js={},Lt;function Pr(){return Lt||(Lt=1,js.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40}),js}var de={},Pt;function Mr(){if(Pt)return de;Pt=1;const s="[0-9]+",t="[A-Z $%*+\\-./:]+";let o="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";o=o.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+o+`)(?:.|[\r
|
|
2050
|
+
]))+`;de.KANJI=new RegExp(o,"g"),de.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),de.BYTE=new RegExp(a,"g"),de.NUMERIC=new RegExp(s,"g"),de.ALPHANUMERIC=new RegExp(t,"g");const r=new RegExp("^"+o+"$"),n=new RegExp("^"+s+"$"),c=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return de.testKanji=function(d){return r.test(d)},de.testNumeric=function(d){return n.test(d)},de.testAlphanumeric=function(d){return c.test(d)},de}var Mt;function be(){return Mt||(Mt=1,(function(s){const t=Pr(),o=Mr();s.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},s.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},s.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},s.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},s.MIXED={bit:-1},s.getCharCountIndicator=function(n,c){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!t.isValid(c))throw new Error("Invalid version: "+c);return c>=1&&c<10?n.ccBits[0]:c<27?n.ccBits[1]:n.ccBits[2]},s.getBestModeForData=function(n){return o.testNumeric(n)?s.NUMERIC:o.testAlphanumeric(n)?s.ALPHANUMERIC:o.testKanji(n)?s.KANJI:s.BYTE},s.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},s.isValid=function(n){return n&&n.bit&&n.ccBits};function a(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return s.NUMERIC;case"alphanumeric":return s.ALPHANUMERIC;case"kanji":return s.KANJI;case"byte":return s.BYTE;default:throw new Error("Unknown mode: "+r)}}s.from=function(n,c){if(s.isValid(n))return n;try{return a(n)}catch{return c}}})(vs)),vs}var Tt;function zn(){return Tt||(Tt=1,(function(s){const t=ye(),o=Lr(),a=$s(),r=be(),n=Pr(),c=7973,l=t.getBCHDigit(c);function d(f,w,g){for(let p=1;p<=40;p++)if(w<=s.getCapacity(p,g,f))return p}function u(f,w){return r.getCharCountIndicator(f,w)+4}function h(f,w){let g=0;return f.forEach(function(p){const y=u(p.mode,w);g+=y+p.getBitsLength()}),g}function m(f,w){for(let g=1;g<=40;g++)if(h(f,g)<=s.getCapacity(g,w,r.MIXED))return g}s.from=function(w,g){return n.isValid(w)?parseInt(w,10):g},s.getCapacity=function(w,g,p){if(!n.isValid(w))throw new Error("Invalid QR Code version");typeof p>"u"&&(p=r.BYTE);const y=t.getSymbolTotalCodewords(w),b=o.getTotalCodewordsCount(w,g),x=(y-b)*8;if(p===r.MIXED)return x;const v=x-u(p,w);switch(p){case r.NUMERIC:return Math.floor(v/10*3);case r.ALPHANUMERIC:return Math.floor(v/11*2);case r.KANJI:return Math.floor(v/13);case r.BYTE:default:return Math.floor(v/8)}},s.getBestVersionForData=function(w,g){let p;const y=a.from(g,a.M);if(Array.isArray(w)){if(w.length>1)return m(w,y);if(w.length===0)return 1;p=w[0]}else p=w;return d(p.mode,p.getLength(),y)},s.getEncodedBits=function(w){if(!n.isValid(w)||w<7)throw new Error("Invalid QR Code version");let g=w<<12;for(;t.getBCHDigit(g)-l>=0;)g^=c<<t.getBCHDigit(g)-l;return w<<12|g}})(As)),As}var ks={},Rt;function Vn(){if(Rt)return ks;Rt=1;const s=ye(),t=1335,o=21522,a=s.getBCHDigit(t);return ks.getEncodedBits=function(n,c){const l=n.bit<<3|c;let d=l<<10;for(;s.getBCHDigit(d)-a>=0;)d^=t<<s.getBCHDigit(d)-a;return(l<<10|d)^o},ks}var Ns={},Cs,Bt;function Hn(){if(Bt)return Cs;Bt=1;const s=be();function t(o){this.mode=s.NUMERIC,this.data=o.toString()}return t.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(a){let r,n,c;for(r=0;r+3<=this.data.length;r+=3)n=this.data.substr(r,3),c=parseInt(n,10),a.put(c,10);const l=this.data.length-r;l>0&&(n=this.data.substr(r),c=parseInt(n,10),a.put(c,l*3+1))},Cs=t,Cs}var Ss,It;function Qn(){if(It)return Ss;It=1;const s=be(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function o(a){this.mode=s.ALPHANUMERIC,this.data=a}return o.getBitsLength=function(r){return 11*Math.floor(r/2)+6*(r%2)},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(r){let n;for(n=0;n+2<=this.data.length;n+=2){let c=t.indexOf(this.data[n])*45;c+=t.indexOf(this.data[n+1]),r.put(c,11)}this.data.length%2&&r.put(t.indexOf(this.data[n]),6)},Ss=o,Ss}var Es,Dt;function Kn(){if(Dt)return Es;Dt=1;const s=be();function t(o){this.mode=s.BYTE,typeof o=="string"?this.data=new TextEncoder().encode(o):this.data=new Uint8Array(o)}return t.getBitsLength=function(a){return a*8},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(o){for(let a=0,r=this.data.length;a<r;a++)o.put(this.data[a],8)},Es=t,Es}var Ls,Ft;function Yn(){if(Ft)return Ls;Ft=1;const s=be(),t=ye();function o(a){this.mode=s.KANJI,this.data=a}return o.getBitsLength=function(r){return r*13},o.prototype.getLength=function(){return this.data.length},o.prototype.getBitsLength=function(){return o.getBitsLength(this.data.length)},o.prototype.write=function(a){let r;for(r=0;r<this.data.length;r++){let n=t.toSJIS(this.data[r]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[r]+`
|
|
2051
|
+
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),a.put(n,13)}},Ls=o,Ls}var Ps={exports:{}},Ut;function Gn(){return Ut||(Ut=1,(function(s){var t={single_source_shortest_paths:function(o,a,r){var n={},c={};c[a]=0;var l=t.PriorityQueue.make();l.push(a,0);for(var d,u,h,m,f,w,g,p,y;!l.empty();){d=l.pop(),u=d.value,m=d.cost,f=o[u]||{};for(h in f)f.hasOwnProperty(h)&&(w=f[h],g=m+w,p=c[h],y=typeof c[h]>"u",(y||p>g)&&(c[h]=g,l.push(h,g),n[h]=u))}if(typeof r<"u"&&typeof c[r]>"u"){var b=["Could not find a path from ",a," to ",r,"."].join("");throw new Error(b)}return n},extract_shortest_path_from_predecessor_list:function(o,a){for(var r=[],n=a;n;)r.push(n),o[n],n=o[n];return r.reverse(),r},find_path:function(o,a,r){var n=t.single_source_shortest_paths(o,a,r);return t.extract_shortest_path_from_predecessor_list(n,r)},PriorityQueue:{make:function(o){var a=t.PriorityQueue,r={},n;o=o||{};for(n in a)a.hasOwnProperty(n)&&(r[n]=a[n]);return r.queue=[],r.sorter=o.sorter||a.default_sorter,r},default_sorter:function(o,a){return o.cost-a.cost},push:function(o,a){var r={value:o,cost:a};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};s.exports=t})(Ps)),Ps.exports}var _t;function $n(){return _t||(_t=1,(function(s){const t=be(),o=Hn(),a=Qn(),r=Kn(),n=Yn(),c=Mr(),l=ye(),d=Gn();function u(b){return unescape(encodeURIComponent(b)).length}function h(b,x,v){const j=[];let C;for(;(C=b.exec(v))!==null;)j.push({data:C[0],index:C.index,mode:x,length:C[0].length});return j}function m(b){const x=h(c.NUMERIC,t.NUMERIC,b),v=h(c.ALPHANUMERIC,t.ALPHANUMERIC,b);let j,C;return l.isKanjiModeEnabled()?(j=h(c.BYTE,t.BYTE,b),C=h(c.KANJI,t.KANJI,b)):(j=h(c.BYTE_KANJI,t.BYTE,b),C=[]),x.concat(v,j,C).sort(function(N,S){return N.index-S.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function f(b,x){switch(x){case t.NUMERIC:return o.getBitsLength(b);case t.ALPHANUMERIC:return a.getBitsLength(b);case t.KANJI:return n.getBitsLength(b);case t.BYTE:return r.getBitsLength(b)}}function w(b){return b.reduce(function(x,v){const j=x.length-1>=0?x[x.length-1]:null;return j&&j.mode===v.mode?(x[x.length-1].data+=v.data,x):(x.push(v),x)},[])}function g(b){const x=[];for(let v=0;v<b.length;v++){const j=b[v];switch(j.mode){case t.NUMERIC:x.push([j,{data:j.data,mode:t.ALPHANUMERIC,length:j.length},{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.ALPHANUMERIC:x.push([j,{data:j.data,mode:t.BYTE,length:j.length}]);break;case t.KANJI:x.push([j,{data:j.data,mode:t.BYTE,length:u(j.data)}]);break;case t.BYTE:x.push([{data:j.data,mode:t.BYTE,length:u(j.data)}])}}return x}function p(b,x){const v={},j={start:{}};let C=["start"];for(let A=0;A<b.length;A++){const N=b[A],S=[];for(let k=0;k<N.length;k++){const P=N[k],L=""+A+k;S.push(L),v[L]={node:P,lastCount:0},j[L]={};for(let E=0;E<C.length;E++){const M=C[E];v[M]&&v[M].node.mode===P.mode?(j[M][L]=f(v[M].lastCount+P.length,P.mode)-f(v[M].lastCount,P.mode),v[M].lastCount+=P.length):(v[M]&&(v[M].lastCount=P.length),j[M][L]=f(P.length,P.mode)+4+t.getCharCountIndicator(P.mode,x))}}C=S}for(let A=0;A<C.length;A++)j[C[A]].end=0;return{map:j,table:v}}function y(b,x){let v;const j=t.getBestModeForData(b);if(v=t.from(x,j),v!==t.BYTE&&v.bit<j.bit)throw new Error('"'+b+'" cannot be encoded with mode '+t.toString(v)+`.
|
|
2052
|
+
Suggested mode is: `+t.toString(j));switch(v===t.KANJI&&!l.isKanjiModeEnabled()&&(v=t.BYTE),v){case t.NUMERIC:return new o(b);case t.ALPHANUMERIC:return new a(b);case t.KANJI:return new n(b);case t.BYTE:return new r(b)}}s.fromArray=function(x){return x.reduce(function(v,j){return typeof j=="string"?v.push(y(j,null)):j.data&&v.push(y(j.data,j.mode)),v},[])},s.fromString=function(x,v){const j=m(x,l.isKanjiModeEnabled()),C=g(j),A=p(C,v),N=d.find_path(A.map,"start","end"),S=[];for(let k=1;k<N.length-1;k++)S.push(A.table[N[k]].node);return s.fromArray(w(S))},s.rawSplit=function(x){return s.fromArray(m(x,l.isKanjiModeEnabled()))}})(Ns)),Ns}var Wt;function Jn(){if(Wt)return hs;Wt=1;const s=ye(),t=$s(),o=In(),a=Dn(),r=Fn(),n=Un(),c=_n(),l=Lr(),d=qn(),u=zn(),h=Vn(),m=be(),f=$n();function w(A,N){const S=A.size,k=n.getPositions(N);for(let P=0;P<k.length;P++){const L=k[P][0],E=k[P][1];for(let M=-1;M<=7;M++)if(!(L+M<=-1||S<=L+M))for(let R=-1;R<=7;R++)E+R<=-1||S<=E+R||(M>=0&&M<=6&&(R===0||R===6)||R>=0&&R<=6&&(M===0||M===6)||M>=2&&M<=4&&R>=2&&R<=4?A.set(L+M,E+R,!0,!0):A.set(L+M,E+R,!1,!0))}}function g(A){const N=A.size;for(let S=8;S<N-8;S++){const k=S%2===0;A.set(S,6,k,!0),A.set(6,S,k,!0)}}function p(A,N){const S=r.getPositions(N);for(let k=0;k<S.length;k++){const P=S[k][0],L=S[k][1];for(let E=-2;E<=2;E++)for(let M=-2;M<=2;M++)E===-2||E===2||M===-2||M===2||E===0&&M===0?A.set(P+E,L+M,!0,!0):A.set(P+E,L+M,!1,!0)}}function y(A,N){const S=A.size,k=u.getEncodedBits(N);let P,L,E;for(let M=0;M<18;M++)P=Math.floor(M/3),L=M%3+S-8-3,E=(k>>M&1)===1,A.set(P,L,E,!0),A.set(L,P,E,!0)}function b(A,N,S){const k=A.size,P=h.getEncodedBits(N,S);let L,E;for(L=0;L<15;L++)E=(P>>L&1)===1,L<6?A.set(L,8,E,!0):L<8?A.set(L+1,8,E,!0):A.set(k-15+L,8,E,!0),L<8?A.set(8,k-L-1,E,!0):L<9?A.set(8,15-L-1+1,E,!0):A.set(8,15-L-1,E,!0);A.set(k-8,8,1,!0)}function x(A,N){const S=A.size;let k=-1,P=S-1,L=7,E=0;for(let M=S-1;M>0;M-=2)for(M===6&&M--;;){for(let R=0;R<2;R++)if(!A.isReserved(P,M-R)){let D=!1;E<N.length&&(D=(N[E]>>>L&1)===1),A.set(P,M-R,D),L--,L===-1&&(E++,L=7)}if(P+=k,P<0||S<=P){P-=k,k=-k;break}}}function v(A,N,S){const k=new o;S.forEach(function(R){k.put(R.mode.bit,4),k.put(R.getLength(),m.getCharCountIndicator(R.mode,A)),R.write(k)});const P=s.getSymbolTotalCodewords(A),L=l.getTotalCodewordsCount(A,N),E=(P-L)*8;for(k.getLengthInBits()+4<=E&&k.put(0,4);k.getLengthInBits()%8!==0;)k.putBit(0);const M=(E-k.getLengthInBits())/8;for(let R=0;R<M;R++)k.put(R%2?17:236,8);return j(k,A,N)}function j(A,N,S){const k=s.getSymbolTotalCodewords(N),P=l.getTotalCodewordsCount(N,S),L=k-P,E=l.getBlocksCount(N,S),M=k%E,R=E-M,D=Math.floor(k/E),$=Math.floor(L/E),le=$+1,J=D-$,z=new d(J);let B=0;const F=new Array(E),V=new Array(E);let X=0;const ee=new Uint8Array(A.buffer);for(let K=0;K<E;K++){const ne=K<R?$:le;F[K]=ee.slice(B,B+ne),V[K]=z.encode(F[K]),B+=ne,X=Math.max(X,ne)}const ue=new Uint8Array(k);let ce=0,O,W;for(O=0;O<X;O++)for(W=0;W<E;W++)O<F[W].length&&(ue[ce++]=F[W][O]);for(O=0;O<J;O++)for(W=0;W<E;W++)ue[ce++]=V[W][O];return ue}function C(A,N,S,k){let P;if(Array.isArray(A))P=f.fromArray(A);else if(typeof A=="string"){let D=N;if(!D){const $=f.rawSplit(A);D=u.getBestVersionForData($,S)}P=f.fromString(A,D||40)}else throw new Error("Invalid data");const L=u.getBestVersionForData(P,S);if(!L)throw new Error("The amount of data is too big to be stored in a QR Code");if(!N)N=L;else if(N<L)throw new Error(`
|
|
2053
2053
|
The chosen QR Code version cannot contain this amount of data.
|
|
2054
2054
|
Minimum version required to store current data is: `+L+`.
|
|
2055
|
-
`);const E=v(N,S,P),M=s.getSymbolSize(N),R=new a(M);return w(R,N),
|
|
2056
|
-
`;return typeof l=="function"&&l(null,y),y},Rs}var Vt;function
|
|
2057
|
-
`);await navigator.clipboard.writeText(S)}},A=async()=>{try{await d(w)}catch{
|
|
2058
|
-
`))};return a&&!o?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(_.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):r&&!o?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(Y.ErrorMessage,{error:r,onDismiss:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>n(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(Xs,{onSuccess:C,onCancel:()=>m("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),v&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v},onDismiss:()=>k(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.PasswordInput,{label:"Password",placeholder:"Enter your password",value:f,onChange:j=>g(j.target.value),disabled:b,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{m("status"),g(""),k(null)},disabled:b,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:A,disabled:b||f.length===0,children:b?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?h?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:h.map((j,P)=>e.jsx("code",{className:"cedros-totp-backup-code",children:j},P))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:S,children:"Copy all codes"}),e.jsx("div",{className:"cedros-totp-actions",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>{m("status"),y(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),v&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v},onDismiss:()=>k(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.OtpInput,{value:w,onChange:p,onComplete:N,disabled:b,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{m("status"),p(""),k(null)},disabled:b,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:N,disabled:b||w.length!==6,children:b?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${o?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:o?.enabled?"Enabled":"Disabled"})]}),o?.enabled?e.jsxs("div",{className:"cedros-totp-enabled-actions",children:[e.jsxs("div",{className:"cedros-totp-description",style:{marginTop:"0.25rem"},children:["Recovery codes remaining: ",e.jsx("strong",{children:o.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>m("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>m("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>m("setup"),children:"Enable two-factor authentication"})]})})}class ra{client;constructor(t,o,a,r){this.client=new T.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(o){throw T.handleApiError(o,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(o){throw T.handleApiError(o,"Failed to update profile")}}}function Re(){const{config:s,authState:t,_internal:o}=T.useCedrosLogin(),[a,r]=i.useState(!1),[n,c]=i.useState(null),l=i.useMemo(()=>new ra(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),d=i.useCallback(()=>{c(null)},[]),u=i.useCallback(async f=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");r(!0),c(null);try{return await l.updateProfile(f)}catch(g){const w=g instanceof Error?g:new Error("Failed to update profile");throw c(w),w}finally{r(!1)}},[t,l]),m=i.useCallback(async f=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");r(!0),c(null);try{await l.changePassword(f)}catch(g){const w=g instanceof Error?g:new Error("Failed to change password");throw c(w),w}finally{r(!1)}},[t,l]);return{isLoading:a,error:n,updateProfile:u,changePassword:m,clearError:d}}function oa({onPasswordChange:s,onClose:t,className:o=""}){const{user:a}=I.useAuth(),{isLoading:r,error:n,changePassword:c,clearError:l}=Re(),[d,u]=i.useState("main"),[m,f]=i.useState(""),[g,w]=i.useState(""),[p,h]=i.useState(""),[y,b]=i.useState(null),[x,v]=i.useState(null),k=we.validatePassword(g),C=g===p,A=m.length>0&&g.length>0&&p.length>0&&k.isValid&&C,N=i.useCallback(async()=>{if(A){b(null),v(null);try{await c({currentPassword:m,newPassword:g}),f(""),w(""),h(""),v("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{u("main"),v(null)},2e3)}catch(P){b(P instanceof Error?P.message:"Failed to change password")}}},[A,m,g,c,s]),S=i.useCallback(()=>{u("main"),f(""),w(""),h(""),b(null),l()},[l]),j=()=>a?.name?a.name.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2):a?.email?a.email[0].toUpperCase():"?";return d==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(y||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:y||n?.message||""},onDismiss:()=>{b(null),l()}})}),x&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),x]}),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:m,onChange:P=>f(P.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:g,onChange:P=>w(P.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:p,onChange:P=>h(P.target.value),disabled:r,error:p.length>0&&!C?"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:S,disabled:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:N,disabled:r||!A,children:r?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:a?.picture?e.jsx("img",{src:a.picture,alt:a.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:j()})}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:a?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:a?.email})]})]}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:a?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:"••••••••"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u("change-password"),children:"Change"})]})]}),t&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})})}class na{client;constructor(t,o,a,r){this.client=new T.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(t){throw T.handleApiError(t,"Failed to list credentials")}}async unlinkCredential(t){try{await this.client.delete(`/credentials/${encodeURIComponent(t)}`)}catch(o){throw T.handleApiError(o,"Failed to unlink credential")}}}function Zs(){const{config:s,authState:t,_internal:o}=T.useCedrosLogin(),[a,r]=i.useState([]),[n,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useMemo(()=>new na(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),m=i.useCallback(()=>{d(null)},[]),f=i.useCallback(async()=>{if(t!=="authenticated"){r([]);return}c(!0),d(null);try{const w=await u.listCredentials();r(w)}catch(w){d(w)}finally{c(!1)}},[t,u]);i.useEffect(()=>{t==="authenticated"?f():r([])},[t,f]);const g=i.useCallback(async w=>{c(!0),d(null);try{await u.unlinkCredential(w),await f()}catch(p){throw d(p),p}finally{c(!1)}},[u,f]);return{credentials:a,isLoading:n,error:l,fetchCredentials:f,unlinkCredential:g,clearError:m}}function aa({onPasswordChange:s,onCancel:t,className:o=""}){const{isLoading:a,error:r,changePassword:n,clearError:c}=Re(),[l,d]=i.useState(""),[u,m]=i.useState(""),[f,g]=i.useState(""),[w,p]=i.useState(null),[h,y]=i.useState(null),b=we.validatePassword(u),x=u===f,v=l.length>0&&u.length>0&&f.length>0&&b.isValid&&x,k=i.useCallback(async()=>{if(v){p(null),y(null);try{await n({currentPassword:l,newPassword:u}),d(""),m(""),g(""),y("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>t(),2e3)}catch(A){p(A instanceof Error?A.message:"Failed to change password")}}},[v,l,u,n,s,t]),C=i.useCallback(()=>{p(null),c(),t()},[c,t]);return e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(w||r)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:w||r?.message||""},onDismiss:()=>{p(null),c()}})}),h&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),h]}),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:l,onChange:A=>d(A.target.value),disabled:a,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:u,onChange:A=>m(A.target.value),disabled:a,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:f,onChange:A=>g(A.target.value),disabled:a,error:f.length>0&&!x?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:C,disabled:a,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:k,disabled:a||!v,children:a?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function Br({onPasswordChange:s,className:t=""}){const{user:o,refreshUser:a}=I.useAuth(),{isLoading:r,error:n,updateProfile:c,clearError:l}=Re(),{credentials:d}=Zs(),{forgotPassword:u,isLoading:m,isSuccess:f,reset:g}=es(),w=d.some(j=>j.credentialType==="password"),[p,h]=i.useState("view"),[y,b]=i.useState(""),[x,v]=i.useState(null),k=()=>o?.name?o.name.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?",C=i.useCallback(()=>{b(o?.name||""),h("edit"),v(null)},[o?.name]),A=i.useCallback(async()=>{const j=y.trim();if(j){v(null);try{await c({name:j}),await a(),h("view")}catch(P){v(P instanceof Error?P.message:"Failed to update name")}}},[y,c,a]),N=i.useCallback(()=>{h("view"),b(""),v(null),l()},[l]),S=i.useCallback(async()=>{if(o?.email){v(null);try{await u(o.email)}catch(j){v(j instanceof Error?j.message:"Failed to send password setup email")}}},[o?.email,u]);return p==="change-password"?e.jsx(aa,{onPasswordChange:s,onCancel:()=>h("view"),className:t}):e.jsx("div",{className:`cedros-profile-settings ${t}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children: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:k()})}),e.jsxs("div",{className:"cedros-profile-info",children:[p==="edit"?e.jsxs("div",{className:"cedros-profile-name-edit",children:[e.jsx("input",{type:"text",className:"cedros-input",value:y,onChange:j=>b(j.target.value),disabled:r,autoFocus:!0,onKeyDown:j=>{j.key==="Enter"&&A(),j.key==="Escape"&&N()}}),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:A,disabled:r||!y.trim(),children:r?e.jsx(_.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:N,disabled:r,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:o?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:C,title:"Edit name","aria-label":"Edit name",children:e.jsx(ia,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:o?.email})]})]}),(x||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:x||n?.message||""},onDismiss:()=>{v(null),l()}})}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children: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:w?"••••••••":"Not set"})]}),w?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{h("change-password"),v(null)},children:"Change"}):f?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:g,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:S,disabled:m,children:m?e.jsx(_.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function ia(){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 Ir={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 Dr({onLinkGoogle:s,onLinkApple:t,onAddPasskey:o,onLinkSolana:a,className:r=""}){const{credentials:n,isLoading:c,error:l,unlinkCredential:d,clearError:u,fetchCredentials:m}=Zs(),{registerPasskey:f,isSupported:g}=Ys(),[w,p]=i.useState(null),[h,y]=i.useState(!1),b=i.useCallback(async()=>{if(o){o();return}y(!0);try{await f(),await m()}catch{}finally{y(!1)}},[o,f,m]),x=i.useCallback(async j=>{const P=j.label||Ir[j.credentialType];if(window.confirm(`Remove "${P}" as a sign-in method? You won't be able to sign in with it anymore.`)){p(j.id);try{await d(j.id)}catch{}finally{p(null)}}},[d]),v=new Set(n.map(j=>j.credentialType)),k=s&&!v.has("oauth_google"),C=t&&!v.has("oauth_apple"),A=(o||g)&&!v.has("webauthn_passkey"),N=a&&!v.has("solana"),S=k||C||A||N;return c&&n.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${r}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${r}`,children:[l&&e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:l.message},onDismiss:u}),n.length===0&&!c&&e.jsx("p",{className:"cedros-linked-accounts-empty",children:"No linked sign-in methods found."}),n.length>0&&e.jsx("ul",{className:"cedros-linked-credential-list",children:n.map(j=>e.jsx(la,{credential:j,isUnlinking:w===j.id,onUnlink:x},j.id))}),S&&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:[k&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(Fr,{})," Google"]}),C&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(Ur,{})," Apple"]}),A&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:b,disabled:h,children:h?e.jsx(_.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Ws,{})," Passkey"]})}),N&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:[e.jsx(_r,{})," Solana"]})]})]})]})}function la({credential:s,isUnlinking:t,onUnlink:o}){const a=s.label||Ir[s.credentialType],r=ca[s.credentialType]||da;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:a}),e.jsxs("span",{className:"cedros-linked-credential__meta",children:["Added ",Ht(s.createdAt),s.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",Ht(s.lastUsedAt)]}),s.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>o(s),disabled:t,title:s.isPrimary?"Cannot remove primary sign-in method":"Remove",children:t?e.jsx(_.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function Ht(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),r=Math.floor(a/(1e3*60)),n=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return r<1?"just now":r<60?`${r}m ago`:n<24?`${n}h ago`:c<30?`${c}d ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const ca={password:ua,oauth_google:Fr,oauth_apple:Ur,solana:_r,webauthn_passkey:Ws,webauthn_security_key:Ws,totp:ha,sso_oidc:pa};function da(){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 ua(){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 Fr(){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 Ur(){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 _r(){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 Ws(){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 ha(){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 pa(){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 ma{client;constructor(t,o,a,r){this.client=new T.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(t){throw T.handleApiError(t,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(t){throw T.handleApiError(t,"Failed to revoke sessions")}}}function Wr(){const{config:s,authState:t,_internal:o}=T.useCedrosLogin(),[a,r]=i.useState([]),[n,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useMemo(()=>new ma(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),m=i.useCallback(async()=>{if(t!=="authenticated"){r([]);return}c(!0),d(null);try{const w=await u.listSessions();r(w)}catch(w){d(w)}finally{c(!1)}},[t,u]);i.useEffect(()=>{t==="authenticated"?m():r([])},[t,m]);const f=i.useCallback(async()=>{c(!0),d(null);try{const w=await u.revokeAllSessions();return await m(),w}catch(w){throw d(w),w}finally{c(!1)}},[u,m]),g=i.useMemo(()=>a.filter(w=>!w.isCurrent).length,[a]);return{sessions:a,isLoading:n,error:l,fetchSessions:m,revokeAllSessions:f,otherSessionCount:g}}const fa={profile:"Profile",security:"Security",linked:"Linked Accounts"},ga=["profile","security","linked"];function wa({defaultTab:s="profile",onClose:t,onPasswordChange:o,onTotpChange:a,onLinkGoogle:r,onLinkApple:n,onAddPasskey:c,onLinkSolana:l,className:d=""}){const[u,m]=i.useState(s),{sessions:f,isLoading:g,error:w,revokeAllSessions:p}=Wr();return e.jsxs("div",{className:`cedros-account-settings ${d}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:ga.map(h=>e.jsx("button",{type:"button",role:"tab","aria-selected":u===h,className:`cedros-account-tab ${u===h?"cedros-account-tab-active":""}`,onClick:()=>m(h),children:fa[h]},h))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[u==="profile"&&e.jsx(Br,{onPasswordChange:o}),u==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Rr,{onStatusChange:a}),e.jsx(mr,{sessions:f,isLoading:g,error:w??void 0,onRevokeAll:async()=>{await p()}})]}),u==="linked"&&e.jsx(Dr,{onLinkGoogle:r,onLinkApple:n,onAddPasskey:c,onLinkSolana:l})]}),t&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})}function ya({onComplete:s,className:t}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${t??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(Xs,{onSuccess:s})})]})}function ba({onComplete:s,onSkip:t,className:o}){const{user:a}=I.useAuth(),{isLoading:r,error:n,updateProfile:c,clearError:l}=Re(),[d,u]=i.useState(a?.name??""),m=i.useCallback(async g=>{g.preventDefault(),l();const w=d.trim();if(!w){s?.();return}try{await c({name:w}),s?.()}catch{}},[d,c,l,s]),f=d.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${o??""}`,children:[e.jsxs("div",{className:"cedros-complete-account__header",children:[e.jsx("h2",{className:"cedros-complete-account__title",children:"Complete Your Profile"}),e.jsx("p",{className:"cedros-complete-account__description",children:"Please fill in your name to get started."})]}),e.jsxs("form",{onSubmit:m,className:"cedros-complete-account__form",children:[e.jsxs("div",{className:"cedros-complete-account__field",children:[e.jsx("label",{htmlFor:"cedros-complete-name",className:"cedros-complete-account__label",children:"Name"}),e.jsx("input",{id:"cedros-complete-name",type:"text",value:d,onChange:g=>u(g.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),n&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:n.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||!f,children:r?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:t,disabled:r,children:"Skip"})]})]})]})}function Or(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(!1),[a,r]=i.useState(null),n=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{r(null)},[]),l=i.useCallback(async p=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");if(!Number.isInteger(p)||p<=0){const h=new Error(`Invalid deposit amount: ${p}. Must be a positive integer (lamports).`);throw r(h.message),h}o(!0),r(null);try{return await n.post("/deposit",{amount_lamports:p})}catch(h){const y=T.handleApiError(h,"Failed to execute deposit");throw r(y.message),y}finally{o(!1)}},[n]),d=i.useCallback(async p=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get(`/deposit/status/${encodeURIComponent(p)}`)}catch(h){const y=T.handleApiError(h,"Failed to get deposit status");throw r(y.message),y}finally{o(!1)}},[n]),u=i.useCallback(async()=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get("/deposit/config")}catch(p){const h=T.handleApiError(p,"Failed to get deposit config");throw r(h.message),h}finally{o(!1)}},[n]),m=i.useCallback(async p=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{const h=new URLSearchParams;p?.limit!==void 0&&h.set("limit",String(p.limit)),p?.offset!==void 0&&h.set("offset",String(p.offset));const y=h.toString(),b=y?`/deposits?${y}`:"/deposits";return await n.get(b)}catch(h){const y=T.handleApiError(h,"Failed to list deposits");throw r(y.message),y}finally{o(!1)}},[n]),f=i.useCallback(async p=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{const h=new URLSearchParams({input_mint:p.inputMint,amount:String(p.amount),taker:p.taker});return await n.get(`/deposit/quote?${h}`)}catch(h){const y=T.handleApiError(h,"Failed to get deposit quote");throw r(y.message),y}finally{o(!1)}},[n]),g=i.useCallback(async p=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.post("/deposit/public",p)}catch(h){const y=T.handleApiError(h,"Failed to execute public deposit");throw r(y.message),y}finally{o(!1)}},[n]),w=i.useCallback(async p=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.post("/deposit/micro",p)}catch(h){const y=T.handleApiError(h,"Failed to execute micro deposit");throw r(y.message),y}finally{o(!1)}},[n]);return{deposit:l,getQuote:f,publicDeposit:g,microDeposit:w,getStatus:d,getConfig:u,listDeposits:m,isLoading:t,error:a,clearError:c}}function et({tokens:s,selectedToken:t,onSelect:o,openSignal:a,placeholder:r="Select token",disabled:n=!1,className:c="",searchable:l=!0}){const[d,u]=i.useState(!1),[m,f]=i.useState(""),g=i.useRef(null),w=i.useRef(null),p=i.useMemo(()=>{if(!m.trim())return s;const x=m.toLowerCase();return s.filter(v=>v.symbol.toLowerCase().includes(x)||v.name.toLowerCase().includes(x)||v.mint.toLowerCase().includes(x))},[s,m]);i.useEffect(()=>{const x=v=>{g.current&&!g.current.contains(v.target)&&(u(!1),f(""))};if(d)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[d]),i.useEffect(()=>{d&&l&&w.current&&w.current.focus()},[d,l]),i.useEffect(()=>{a===void 0||n||(u(!0),f(""))},[a,n]);const h=i.useCallback(()=>{n||(u(x=>!x),d&&f(""))},[n,d]),y=i.useCallback(x=>{o(x),u(!1),f("")},[o]),b=i.useCallback(x=>{x.key==="Escape"?(u(!1),f("")):x.key==="Enter"&&p.length===1&&y(p[0])},[p,y]);return e.jsxs("div",{ref:g,className:`cedros-token-selector ${d?"cedros-token-selector-open":""} ${n?"cedros-token-selector-disabled":""} ${c}`,onKeyDown:b,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:h,disabled:n,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs("span",{className:"cedros-token-selector-selected",children:[t.logoUrl&&e.jsx("img",{src:t.logoUrl,alt:t.symbol,className:"cedros-token-icon",onError:x=>{x.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:r}),e.jsx("span",{className:"cedros-token-selector-arrow",children:d?"▲":"▼"})]}),d&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[l&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:w,type:"text",value:m,onChange:x=>f(x.target.value),placeholder:"Search tokens...",className:"cedros-token-search-input"})}),e.jsx("div",{className:"cedros-token-list",children:p.length===0?e.jsx("div",{className:"cedros-token-empty",children:"No tokens found"}):e.jsx(e.Fragment,{children:p.map(x=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===x.mint?"cedros-token-option-selected":""}`,onClick:()=>y(x),role:"option","aria-selected":t?.mint===x.mint,children:[x.logoUrl&&e.jsx("img",{src:x.logoUrl,alt:x.symbol,className:"cedros-token-icon",onError:v=>{v.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:x.symbol}),e.jsx("span",{className:"cedros-token-name",children:x.name})]}),t?.mint===x.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},x.mint))})})]})]})}function ts(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const st="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=",xa=1e4,Xe=1e3,qr=3;function Aa(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function va(s,t){switch(s){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${Aa(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function tt(s,t,o){return Math.min(Math.max(s,t),o)}function ja(s,t){if(t<=0)return 0;const o=tt(s/t,0,1);return Math.round(Math.pow(o,1/qr)*Xe)}function ka(s,t){const o=tt(s/Xe,0,1);return t*Math.pow(o,qr)}function zr(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function Na(s){return s<1?2:0}function Qt(s){const t=zr(s),o=Math.round(s/t)*t,a=Na(t);return Number(o.toFixed(a))}function rt({config:s,valueUsd:t,onChange:o,maxUsd:a=xa,disabled:r=!1,className:n=""}){const c=tt(Number.isFinite(t)?t:0,0,a),l=i.useMemo(()=>ts(c,s),[c,s]),d=va(l,s),u=ja(c,a),m=u/Xe*100;return e.jsxs("div",{className:`cedros-tiered-slider ${n}`,children:[e.jsxs("div",{className:"cedros-tiered-slider-input-row",children:[e.jsxs("div",{className:"cedros-tiered-slider-input",children:[e.jsx("span",{className:"cedros-tiered-slider-currency",children:"$"}),e.jsx("input",{type:"number",value:c||"",onChange:f=>o(Qt(parseFloat(f.target.value)||0)),placeholder:"Enter amount",disabled:r,min:0,step:zr(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-${l}`,children:[l==="sol_micro"&&e.jsx("img",{src:st,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),d.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:d.detail})]})]}),e.jsx("input",{type:"range",min:0,max:Xe,step:1,value:u,onChange:f=>o(Qt(ka(parseFloat(f.target.value),a))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${m}%, var(--cedros-border) ${m}%, var(--cedros-border) 100%)`},disabled:r,"aria-label":"Deposit amount slider"}),d.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:d.note})]})}function Ca(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function Sa(s,t,o){const{feePolicy:a,privacyFeePercent:r,swapFeePercent:n,companyFeePercent:c}=s;let l=c;return o||(a==="user_pays_all"?(l+=n,t&&(l+=r)):a==="user_pays_privacy"&&t?l+=r:a==="user_pays_swap"&&(l+=n)),l}const Ve=1e9,ke={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:st},Ne={mint:"other",symbol:"OTHER",name:"Other",decimals:6},Vr=1e4;function Ea(s,t){const o=t<s.publicMinUsd,a=t>=s.privateMinUsd,r=[],n=!o&&a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),c=!o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),l=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(n){const d=s.privacyFeeFixedLamports/Ve,u=s.privacyFeePercent,m=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Privacy",solAmount:d,percent:u,usdAmount:m+f})}if(c){const d=s.swapFeeFixedLamports/Ve,u=s.swapFeePercent,m=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Swap",solAmount:d,percent:u,usdAmount:m+f})}if(l){const d=s.companyFeeFixedLamports/Ve,u=s.companyFeePercent,m=d*s.solPriceUsd,f=t*(u/100);r.push({label:"Service",solAmount:d,percent:u,usdAmount:m+f})}return r}function Hr(s,t,o){const a=Ea(s,t),r=o<.01?.01:o;if(a.length===0)return`Total: $${r.toFixed(2)}`;const n=a.reduce((p,h)=>p+h.solAmount,0),c=a.reduce((p,h)=>p+h.percent,0),l={fee:7,sol:8,rate:7,usd:8},d=p=>{const h=p.label.padEnd(l.fee),y=p.solAmount.toFixed(4).padStart(6).padEnd(l.sol),b=(p.percent.toFixed(2)+"%").padStart(5).padEnd(l.rate),x=("$"+Math.max(p.usdAmount,.01).toFixed(2)).padEnd(l.usd);return`${h} │ ${y} │ ${b} │ ${x}`},u=`${"Fee".padEnd(l.fee)} │ ${"SOL".padEnd(l.sol)} │ ${"+ Rate".padEnd(l.rate)} │ ${"= Total".padEnd(l.usd)}`,m=`${"─".repeat(l.fee)}─┼─${"─".repeat(l.sol)}─┼─${"─".repeat(l.rate)}─┼─${"─".repeat(l.usd)}`,f=("$"+r.toFixed(2)).padEnd(l.usd),g=`${"TOTAL".padEnd(l.fee)} │ ${n.toFixed(4).padStart(6).padEnd(l.sol)} │ ${(c.toFixed(2)+"%").padStart(5).padEnd(l.rate)} │ ${f}`;return[u,m,...a.map(d),m,g].join(`
|
|
2059
|
-
`)}function La(s){const t=[],o=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,a=s.swapFeeFixedLamports>0||s.swapFeePercent>0,r=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return o&&t.push("Privacy Cash fee"),a&&t.push("swap fee"),r&&t.push("company service fee"),t.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function rs(s,t){if(t<=0)return 0;const o=t<s.publicMinUsd,a=t>=s.privateMinUsd,r=Sa(s,a,o);let n=s.companyFeeFixedLamports;o||(a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(n+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(n+=s.swapFeeFixedLamports));const c=n/Ve*s.solPriceUsd,l=t*(r/100);return c+l}function Qr(s,t,o){return s==="sol"?"SOL":s==="single-token"?t.symbol:o.some(r=>r.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function Kt(s){return s.map(t=>t.trim()).filter(Boolean)}const Kr=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function Yr(s,t,o){if(Kr.has(s.symbol))return 1;const a=t.tokenPrices?.[s.symbol];if(a&&a>0)return a;if(s.symbol==="SOL")return t.solPriceUsd||null;const r=o?.[s.symbol];return r&&r>0?r:null}function Gr(s,t){const o=Kr.has(t)?2:4;return s.toFixed(o)}function Pa({config:s,currencyMode:t,depositMethod:o,tokens:a=[],defaultToken:r,minAmount:n,maxAmount:c=1e4,onSuccess:l,onError:d,onCancel:u,onUnlockRequired:m,onAuthorize:f,className:g="",showStepIndicator:w=!0,pollInterval:p=5e3,demoMode:h=!1,demoAutoConfirmMs:y,tokenPriceUsd:b,showExplainer:x=!1,siteName:v,explainerConfig:k}){const{deposit:C,getStatus:A,error:N,clearError:S}=Or(),j=I.useWallet(),P=Kt(s.quickActionTokens),L=Kt(s.customTokenSymbols),E=i.useMemo(()=>{const U=s.customTokens??[];if(U.length===0)return a;const q=new Set(a.map(G=>G.symbol)),H=[...a];for(const G of U)q.has(G.symbol)||(H.push({mint:G.mint,symbol:G.symbol,name:G.symbol,decimals:G.decimals,logoUrl:G.logoUrl}),q.add(G.symbol));return H},[a,s.customTokens]),M=i.useMemo(()=>{if(L.length===0)return E;const U=E.filter(q=>L.includes(q.symbol));return U.length>0?U:E},[E,L]),R=s.privateDepositsEnabled,D=o?o==="sign"&&!R?"receive":o:R&&j.hasExternalWallet?"sign":"receive",$=P[0]?E.find(U=>U.symbol===P[0]):void 0,le=t==="sol"?ke:t==="single-token"?$??E.find(U=>U.symbol==="USDC")??E[0]??ke:r??$??E.find(U=>U.symbol==="USDC")??E.find(U=>U.symbol!=="SOL")??E[0]??ke,J=i.useCallback(()=>x?"explainer":"unlock",[x]),[z,B]=i.useState(J),[F,V]=i.useState(le),[X,ee]=i.useState(""),[ue,ce]=i.useState(null),[O,W]=i.useState(null),[K,ne]=i.useState(null),[pe,it]=i.useState(null),[os,Se]=i.useState(!1),[Zr,ns]=i.useState(!1),[Be,lt]=i.useState(null);i.useEffect(()=>{B(J()),V(le),ee(""),ce(null),W(null),ne(null),it(null),Se(!1),ns(!1),lt(null),S()},[t,D,le,S,J]);const eo=n??s.privateMinSol,so=c,Ie=parseFloat(X),ct=j.status==="enrolled_locked"||j.status==="enrolled_unlocked"||j.status==="unlocked",as=ct&&j.isUnlocked,is=ct&&!j.isUnlocked,dt=i.useCallback(()=>{let H=D==="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 x&&(H=[{key:"explainer",label:"Info"},...H]),H},[D,x])(),to=dt.findIndex(U=>U.key===z),ut=i.useCallback(U=>{V(U)},[]),ro=i.useCallback(async U=>{if(!f){B(D==="sign"?"confirm":"show-address");return}ns(!0),W(null);try{const H=await f(U,D==="sign"?Ie:null,F);ne(H.sessionId),it(H.depositAddress),B(D==="sign"?"confirm":"show-address")}catch(q){const H=q instanceof Error?q:new Error("Authorization failed");W(H.message)}finally{ns(!1)}},[f,D,Ie,F]),oo=i.useCallback(async(U,q)=>{S(),W(null),B("signing");const H=U??Ie,G=q??F;if(!h){if(is&&m){m(),B("confirm");return}if(!as){W("Wallet not ready"),B("error");return}}try{const re=Math.floor(H*Math.pow(10,G.decimals));if(h){await new Promise(Ue=>setTimeout(Ue,1500));const Fe={token:t==="sol"?null:G,amount:H,amountSmallestUnit:re,txSignature:`demo-tx-${Date.now()}`,sessionId:K||`demo-session-${Date.now()}`,response:{sessionId:K||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:re,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};ce(Fe),B("success"),l?.(Fe);return}const se=await C(re),De={token:t==="sol"?null:G,amount:H,amountSmallestUnit:re,txSignature:se.txSignature,sessionId:se.sessionId,response:se,method:"sign"};ce(De),B("success"),l?.(De)}catch(re){const se=re instanceof Error?re:new Error("Deposit failed");W(se.message),B("error"),d?.(se)}},[C,Ie,F,t,h,K,as,is,m,l,d,S]),no=i.useCallback(()=>{B("waiting")},[]),ls=i.useCallback(async()=>{const U=pe||j.solanaPubkey;if(U)try{await navigator.clipboard.writeText(U),Se(!0),setTimeout(()=>Se(!1),2e3)}catch{const q=document.createElement("textarea");q.value=U,document.body.appendChild(q),q.select(),document.execCommand("copy"),document.body.removeChild(q),Se(!0),setTimeout(()=>Se(!1),2e3)}},[pe,j.solanaPubkey]);i.useEffect(()=>{if(!(z==="confirm"||z==="show-address"||z==="waiting")||!K||h)return;let q=!1,H=0;const G=360,re=async()=>{if(!(q||H>=G)){H++;try{const se=await A(K);if(se.status==="completed"||se.status==="detected"){const De=se.amountLamports?se.amountLamports/Math.pow(10,F.decimals):0,Fe=se.amountLamports||0,Ue={token:t==="sol"?null:F,amount:De,amountSmallestUnit:Fe,txSignature:se.txSignature||"",sessionId:K,response:se,method:"receive",depositAddress:j.solanaPubkey??void 0};ce(Ue),B("success"),l?.(Ue);return}}catch{}q||setTimeout(re,p)}};return re(),()=>{q=!0}},[z,K,h,A,F,t,j.solanaPubkey,l,p]),i.useEffect(()=>{if(!h||!y||z!=="waiting"||D!=="receive"||!pe)return;const U=window.setTimeout(()=>{const q=Be??s.privateMinUsd,H=F.symbol==="SOL"&&s.solPriceUsd>0?q/s.solPriceUsd:q,G=Math.floor(H*Math.pow(10,F.decimals)),re={token:t==="sol"?null:F,amount:H,amountSmallestUnit:G,txSignature:`demo-tx-${Date.now()}`,sessionId:K||`demo-session-${Date.now()}`,response:{sessionId:K||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:G,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:pe??void 0};ce(re),B("success"),l?.(re)},y);return()=>window.clearTimeout(U)},[h,y,z,D,pe,Be,s,F,t,K,l]);const ao=i.useCallback(()=>{B(J()),ee(""),ce(null),W(null),S()},[J,S]);return s.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${g}`,children:[w&&z!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:dt.map((U,q)=>{const H=to>=q,G=U.key===z;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${H?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${H?"active":""} ${G?"current":""}`,children:q+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${H?"active":""}`,children:U.label})]},U.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[z==="explainer"&&e.jsx(Ma,{siteName:v,config:k,depositConfig:s,currencyMode:t,token:F,tokens:M,onContinue:()=>B("unlock"),onCancel:u}),z==="unlock"&&e.jsx(Ta,{token:F,tokens:M,currencyMode:t,depositMethod:D,isAuthorizing:Zr,error:O,onAuthorize:ro,onBack:x?()=>B("explainer"):void 0,onCancel:u}),z==="confirm"&&D==="sign"&&e.jsx(Ra,{token:F,tokens:E,quickActionSymbols:P,customTokenSymbols:L,currencyMode:t,minAmount:eo,maxAmount:so,depositAddress:pe||j.solanaPubkey,walletReady:as||h,needsUnlock:is&&!h,copied:os,isListening:!!K&&!h,config:s,onCopy:ls,onTokenSelect:ut,onUnlockRequired:m,onConfirm:(U,q)=>oo(U,q),onBack:()=>B("unlock"),onCancel:u}),z==="signing"&&e.jsx(Ba,{depositAddress:j.solanaPubkey}),z==="show-address"&&e.jsx(Ia,{token:F,tokens:E,quickActionSymbols:P,customTokenSymbols:L,tokenPriceUsd:b,currencyMode:t,depositAddress:pe||j.solanaPubkey,copied:os,isListening:!!K&&!h,config:s,onCopy:ls,onTokenSelect:ut,onAmountChange:lt,onSent:no,onBack:()=>B("unlock"),onCancel:u}),z==="waiting"&&e.jsx(Da,{token:F,depositAddress:pe||j.solanaPubkey,copied:os,feeLine:Be?`Fees: $${Math.max(rs(s,Be),.01).toFixed(2)} total`:"Fees: calculated after deposit",onCopy:ls}),z==="success"&&ue&&e.jsx(Fa,{result:ue,config:s,onNewDeposit:ao}),z==="error"&&e.jsx(Ua,{error:O||N||"An error occurred",onRetry:()=>B("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${g}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function Ma({siteName:s,config:t,depositConfig:o,currencyMode:a,token:r,tokens:n,onContinue:c,onCancel:l}){const d=t?.title??"How Deposits Work",u=t?.exchangeName??"Coinbase",m=Os.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",f=t?.showExchangeSuggestion!==!1,g=Qr(a,r,n),w=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",p=t?.body??w,h=Ca(o),y=La(o);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:d}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:p}),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:h?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:y})]})]})]}),f&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",g," using your credit card at"," ",e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",children:u}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[l&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:c,children:"Continue"})]})]})}function Ta({token:s,tokens:t,currencyMode:o,depositMethod:a,isAuthorizing:r,error:n,onAuthorize:c,onBack:l}){const[d,u]=i.useState(""),m=Qr(o,s,t),f=g=>{g.preventDefault(),d.trim()&&c(d)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Authorize Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:a==="sign"?o==="multi-token"?"Enter your password to authorize a deposit. This allows us to process your withdrawal when the privacy period ends.":`Enter your password to authorize a ${m} deposit. This allows us to process your withdrawal when the privacy period ends.`:o==="multi-token"?"Enter your password to get your deposit address. Any supported token sent to this address will be credited to your account.":`Enter your password to get your deposit address. Any ${m} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",htmlFor:"deposit-password",children:"Password"}),e.jsx("input",{id:"deposit-password",type:"password",value:d,onChange:g=>u(g.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:r,autoComplete:"current-password"})]}),n&&e.jsx("p",{className:"cedros-deposit-flow-error",children:n}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:l,disabled:r,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!d.trim()||r,children:r?"Authorizing...":"Continue"})]})]})]})}function Ra({token:s,tokens:t,quickActionSymbols:o,customTokenSymbols:a,currencyMode:r,minAmount:n,maxAmount:c,depositAddress:l,walletReady:d,needsUnlock:u,copied:m,isListening:f,config:g,onCopy:w,onTokenSelect:p,onUnlockRequired:h,onConfirm:y,onBack:b}){const[x,v]=i.useState(g.privateMinUsd),[k,C]=i.useState(!1),[A,N]=i.useState(!1),[S,j]=i.useState(0),[P,L]=i.useState(null),M=ts(x,g)==="sol_micro",R=s.symbol===Ne.symbol,D=i.useMemo(()=>{const O=a.length===0?t:t.filter(ne=>a.includes(ne.symbol)),W=O.length>0?O:t;return W.some(ne=>ne.symbol===Ne.symbol)?W:[...W,Ne]},[t,a]),$=rs(g,x),le=$<.01?.01:$,J=R?"Fees: calculated after deposit":`Fees: $${le.toFixed(2)} total`,z=R?"":Hr(g,x,$),B=Yr(M?ke:s,g),F=B?x/B:s.symbol==="SOL"&&g.solPriceUsd>0?x/g.solPriceUsd:x,V=F?Gr(F,M?"SOL":s.symbol):null,ee=x-$<=0&&x>0,ue=!R&&x>0&&!ee&&F>=n&&F<=c;i.useEffect(()=>{if(r==="multi-token")if(M&&s.symbol!=="SOL"){L(s);const O=t.find(W=>W.symbol==="SOL");O&&p(O)}else!M&&P&&s.symbol==="SOL"&&(p(P),L(null))},[M,s.symbol,r,t,p,P,s]);const ce=()=>{ue&&y(F,s)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),r==="multi-token"&&!M&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[o.map(O=>{const W=t.find(ne=>ne.symbol===O),K=s.symbol===O;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${K?"is-active":""}`,onClick:()=>{W&&(C(!1),p(W))},disabled:!W,children:[W?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:W.logoUrl,alt:`${O} logo`}),O]},O)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${k?"is-active":""}`,onClick:()=>{C(!0),j(O=>O+1)},children:"Custom"})]}),k&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(et,{tokens:D,selectedToken:s,onSelect:p,openSignal:S})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(rt,{config:g,valueUsd:x,onChange:v,maxUsd:Vr})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:R?"Sign to send tokens to this address":`Sign to send ${V??"--"} ${M?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:l||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:w,title:"Copy address",disabled:!l,children:m?"✓":"⧉"}),l&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${l}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),m&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),ee&&e.jsx("div",{className:"cedros-deposit-flow-warning",children:e.jsx("p",{children:"Deposit amount is less than the fees. Increase the amount to proceed."})}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[J,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${A?"is-open":""}`,"data-tooltip":z,"aria-label":`Fee breakdown: ${z.replaceAll(`
|
|
2060
|
-
`,", ")}`,"aria-expanded":A,onClick:O=>{O.stopPropagation(),N(W=>!W)},onBlur:()=>N(!1),onKeyDown:O=>{O.key==="Escape"&&N(!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."})]})]}),
|
|
2061
|
-
`,", ")}`,"aria-expanded":v,onClick:F=>{F.stopPropagation(),k(V=>!V)},onBlur:()=>k(!1),onKeyDown:F=>{F.key==="Escape"&&k(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after confirmation (typically ~30s)."})]})]}),d&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for your deposit. We'll notify you when it arrives."}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:p,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:w,disabled:!le,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function Da({token:s,depositAddress:t,copied:o,feeLine:a,onCopy:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:s.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),t&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[t.slice(0,6),"...",t.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:r,title:"Copy address",children:o?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${t}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:a})]})]})]})]})}function Fa({result:s,config:t,onNewDeposit:o}){const a=s.token??ke,r=a.symbol==="SOL"&&t.solPriceUsd>0?s.amount*t.solPriceUsd:s.amount,n=rs(t,r),c=Math.max(r-n,0),l=n<.01?.01:n;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",s.amount.toLocaleString()," ",a.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[s.txSignature.slice(0,8),"...",s.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",r.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",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:["+$",c.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:o,children:"Make Another Deposit"})})]})}function Ua({error:s,onRetry:t,onCancel:o}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:s}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[o&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:t,children:"Try Again"})]})]})}const _a="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=",Wa="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==",Oa="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",qa="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==",za="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==",Va="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==",Ha="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",Qa="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",Ka="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",$r=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:st},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Va},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Ka},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:Oa},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:Qa},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:za},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Ha},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Wa},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:_a},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:qa}];function ot(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(!1),[a,r]=i.useState(null),n=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{r(null)},[]),l=i.useCallback(async()=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get("/credits/balance/sol")}catch(m){const f=T.handleApiError(m,"Failed to fetch credit balance");throw r(f.message),f}finally{o(!1)}},[n]),d=i.useCallback(async()=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{return(await n.get("/credits/balance")).balances}catch(m){const f=T.handleApiError(m,"Failed to fetch credit balances");throw r(f.message),f}finally{o(!1)}},[n]),u=i.useCallback(async m=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{const f=new URLSearchParams;m?.currency&&f.set("currency",m.currency),m?.limit&&f.set("limit",m.limit.toString()),m?.offset&&f.set("offset",m.offset.toString());const g=f.toString(),w=g?`/credits/history?${g}`:"/credits/history";return await n.get(w)}catch(f){const g=T.handleApiError(f,"Failed to fetch transaction history");throw r(g.message),g}finally{o(!1)}},[n]);return{getBalance:l,getAllBalances:d,getHistory:u,isLoading:t,error:a,clearError:c}}function Ya({showAllCurrencies:s=!1,refreshInterval:t=0,compact:o=!1,className:a="",onLoad:r}){const{getBalance:n,getAllBalances:c,isLoading:l,error:d,clearError:u}=ot(),[m,f]=i.useState([]),[g,w]=i.useState(null),p=i.useCallback(async()=>{try{if(s){const h=await c();f(h),r?.(h)}else{const h=await n();f([h]),r?.([h])}w(null)}catch(h){w(h instanceof Error?h.message:"Failed to load balance")}},[s,n,c,r]);if(i.useEffect(()=>{p()},[p]),i.useEffect(()=>{if(t<=0)return;const h=setInterval(p,t);return()=>clearInterval(h)},[t,p]),g||d)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${a}`,children:[e.jsx("p",{className:"cedros-credit-error",children:g||d}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),w(null),p()},children:"Retry"})]});if(l&&m.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${a}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(o){const h=m[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${a}`,children:[h?e.jsx("span",{className:"cedros-credit-value",title:`${h.balanceLamports} lamports`,children:h.display}):e.jsx("span",{className:"cedros-credit-value cedros-credit-value-zero",children:"0.0000 SOL"}),l&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${a}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:p,disabled:l,title:"Refresh balance",children:l?"...":"↻"})]}),m.length===0?e.jsxs("div",{className:"cedros-credit-empty",children:[e.jsx("p",{className:"cedros-credit-empty-message",children:"No credit balance yet."}),e.jsx("p",{className:"cedros-credit-empty-hint",children:"Make a deposit to get started."})]}):e.jsx("div",{className:"cedros-credit-list",children:m.map(h=>e.jsxs("div",{className:"cedros-credit-item",children:[e.jsx("span",{className:"cedros-credit-currency",children:h.currency}),e.jsx("span",{className:"cedros-credit-amount",children:h.display})]},h.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 Ga(s,t){const o=s<0,a=Math.abs(s),r=t.toUpperCase()==="SOL",c=a/Math.pow(10,r?9:6),l=o?"-":"+";return r?`${l}${c.toFixed(4)} SOL`:`${l}$${c.toFixed(2)}`}function $a(s){const t=new Date(s),o=new Date,a=o.getTime()-t.getTime(),r=Math.floor(a/(1e3*60*60*24));if(r===0){const n=Math.floor(a/36e5);if(n===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${n}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==o.getFullYear()?"numeric":void 0})}function Ja(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function Xa(s,t){const o=(s||"").toLowerCase();return o==="deposit"?"↓":o==="spend"||o==="usage"||o==="charge"?"↑":o==="refund"?"←":o==="bonus"||o==="credit"?"★":t?"+":"−"}function Za({defaultTab:s="all",pageSize:t=10,refreshInterval:o=0,className:a="",onLoad:r,onTransactionClick:n}){const{getHistory:c,isLoading:l,error:d,clearError:u}=ot(),[m,f]=i.useState(s),[g,w]=i.useState([]),[p,h]=i.useState(0),[y,b]=i.useState(0),[x,v]=i.useState(null),k=Bs.find(E=>E.key===m)||Bs[0],C=i.useMemo(()=>k.txTypes===null?g:g.filter(E=>{const M=E.txType||"";return k.txTypes.some(R=>M.toLowerCase().includes(R.toLowerCase()))}),[g,k.txTypes]),A=i.useCallback(async()=>{try{const E=await c({limit:t*3,offset:y});w(E.transactions),h(E.total),r?.(E),v(null)}catch(E){v(E instanceof Error?E.message:"Failed to load history")}},[t,y,c,r]);i.useEffect(()=>{b(0)},[m]),i.useEffect(()=>{A()},[A]),i.useEffect(()=>{if(o<=0)return;const E=setInterval(A,o);return()=>clearInterval(E)},[o,A]);const N=Math.ceil(p/t),S=Math.floor(y/t)+1,j=E=>{const M=(E-1)*t;b(Math.max(0,Math.min(M,Math.max(0,p-1))))},P=E=>{f(E)};if(x||d)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${a}`,children:[e.jsx("p",{className:"cedros-tx-error",children:x||d}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),v(null),A()},children:"Retry"})]});if(l&&g.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${a}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const L=E=>E.txTypes===null?g.length:g.filter(M=>{const R=M.txType||"";return E.txTypes.some(D=>R.toLowerCase().includes(D.toLowerCase()))}).length;return e.jsxs("div",{className:`cedros-tx-history ${a}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Transaction History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:A,disabled:l,title:"Refresh",children:l?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:Bs.map(E=>{const M=L(E),R=m===E.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${R?"cedros-tx-tab-active":""}`,onClick:()=>P(E.key),children:[E.label,M>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:M})]},E.key)})}),C.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:m==="all"?"No transactions yet.":`No ${k.label.toLowerCase()} found.`}),m==="all"&&e.jsx("p",{className:"cedros-tx-empty-hint",children:"Make a deposit to get started."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"cedros-tx-list",children:C.slice(0,t).map(E=>{const M=E.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${M?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>n?.(E),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),n?.(E))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${M?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:Xa(E.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:Ja(E.txType)}),e.jsx("span",{className:`cedros-tx-amount ${M?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:Ga(E.amountLamports,E.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:E.description}),e.jsx("span",{className:"cedros-tx-date",children:$a(E.createdAt)})]})]})]},E.id)})}),N>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>j(S-1),disabled:S<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",S," of ",N]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>j(S+1),disabled:S>=N,children:"Next"})]})]})]})}function nt(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(!1),[a,r]=i.useState(null),[n,c]=i.useState(null),l=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=i.useCallback(()=>{r(null)},[]),u=i.useCallback(async()=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await l.get("/wallet/withdraw/balances")}catch(w){const p=T.handleApiError(w,"Failed to fetch wallet balances");throw r(p.message),p}},[l]),m=i.useCallback(async(w,p)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");o(!0),r(null);try{const h=await l.post("/wallet/withdraw/sol",{destination:w,amount_lamports:p});return c(h),h}catch(h){const y=T.handleApiError(h,"Failed to withdraw SOL");throw r(y.message),y}finally{o(!1)}},[l]),f=i.useCallback(async(w,p,h)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");o(!0),r(null);try{const y=await l.post("/wallet/withdraw/spl",{destination:w,token_mint:p,amount:h});return c(y),y}catch(y){const b=T.handleApiError(y,"Failed to withdraw token");throw r(b.message),b}finally{o(!1)}},[l]),g=i.useCallback(async(w=10,p=0)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const h=Math.max(1,Math.min(100,Math.trunc(w))),y=Math.max(0,Math.trunc(p)),b=new URLSearchParams({limit:String(h),offset:String(y)});return await l.get(`/wallet/withdraw/history?${b}`)}catch(h){const y=T.handleApiError(h,"Failed to fetch withdrawal history");throw r(y.message),y}},[l]);return{withdrawSol:m,withdrawSpl:f,getBalances:u,getHistory:g,isSubmitting:t,error:a,clearError:d,lastResult:n}}const Is="So11111111111111111111111111111111111111112",ei={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function si(s){return s.length<32||s.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(s)}function Ds(s){return s.length<=16?s:`${s.slice(0,6)}...${s.slice(-6)}`}function qe(s,t){return(Number(s)/Math.pow(10,t)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(t,6)})}function ti({onSuccess:s,onError:t,onCancel:o,className:a=""}){const r=T.useCedrosLoginOptional(),{withdrawSol:n,withdrawSpl:c,getBalances:l,isSubmitting:d,error:u,clearError:m}=nt(),[f,g]=i.useState("loading"),[w,p]=i.useState([]),[h,y]=i.useState(null),[b,x]=i.useState(""),[v,k]=i.useState(""),[C,A]=i.useState(null),[N,S]=i.useState(null),[j,P]=i.useState(null),L=r?.config.solana?.network??"mainnet-beta",E=i.useMemo(()=>{if(!C?.txSignature)return"";const B=`https://explorer.solana.com/tx/${C.txSignature}`;return L==="mainnet-beta"?B:`${B}?cluster=${encodeURIComponent(L)}`},[C,L]),M=i.useMemo(()=>{if(!h||!v)return"0";const B=parseFloat(v);return isNaN(B)||B<=0?"0":Math.floor(B*Math.pow(10,h.decimals)).toString()},[v,h]);i.useEffect(()=>{if(!r)return;let B=!1;return(async()=>{try{const F=await l();if(B)return;const V=[];F.solLamports>0&&V.push({symbol:"SOL",mint:Is,decimals:9,rawBalance:String(F.solLamports),displayBalance:qe(String(F.solLamports),9)});for(const X of F.tokens){const ee=ei[X.mint]??Ds(X.mint);V.push({symbol:ee,mint:X.mint,decimals:X.decimals,rawBalance:X.amount,displayBalance:qe(X.amount,X.decimals)})}p(V),g((V.length>0,"select"))}catch{B||(P("Failed to load wallet balances"),g("select"))}})(),()=>{B=!0}},[r,l]);const R=i.useCallback(B=>{y(B),g("form"),m(),S(null),k("")},[m]),D=i.useCallback(()=>{if(!h)return;const B=Number(h.rawBalance)/Math.pow(10,h.decimals);h.mint===Is?k(String(Math.max(0,B-.01))):k(String(B))},[h]),$=i.useCallback(()=>{if(S(null),!b.trim()){S("Destination address is required");return}if(!si(b.trim())){S("Invalid Solana address");return}if(!v||parseFloat(v)<=0||isNaN(parseFloat(v))){S("Please enter a valid amount");return}if(M==="0"){S("Amount is too small");return}g("confirm")},[b,v,M]),le=i.useCallback(async()=>{if(h){g("processing"),m();try{let B;h.mint===Is?B=await n(b.trim(),Number(M)):B=await c(b.trim(),h.mint,M),A(B),g("success"),s?.(B)}catch(B){g("confirm"),t?.(B instanceof Error?B:new Error(String(B)))}}},[h,b,M,n,c,m,s,t]),J=i.useCallback(()=>{m(),S(null),f==="form"?(g("select"),y(null),k(""),x("")):f==="confirm"&&g("form")},[f,m]),z=i.useCallback(()=>{g("select"),y(null),x(""),k(""),A(null),m(),S(null)},[m]);return r?e.jsxs("div",{className:`cedros-withdrawal ${a}`,children:[f==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(_.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),f==="select"&&e.jsxs("div",{className:"cedros-withdrawal-select",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("h3",{className:"cedros-withdrawal-title",children:"Withdraw"}),e.jsx("p",{className:"cedros-withdrawal-subtitle",children:"Select a token to withdraw"})]}),j&&e.jsx(Y.ErrorMessage,{error:j}),w.length===0&&!j&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:w.map(B=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>R(B),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:B.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:B.displayBalance})]},B.mint))}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:o,children:"Cancel"})]}),f==="form"&&h&&e.jsxs("div",{className:"cedros-withdrawal-form",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:J,children:"Back"}),e.jsxs("h3",{className:"cedros-withdrawal-title",children:["Withdraw ",h.symbol]})]}),e.jsxs("div",{className:"cedros-withdrawal-balance-hint",children:["Balance: ",h.displayBalance," ",h.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:b,onChange:B=>x(B.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 (",h.symbol,")"]}),e.jsxs("div",{className:"cedros-withdrawal-amount-row",children:[e.jsx("input",{id:"cedros-withdrawal-amount",type:"number",className:"cedros-input",placeholder:"0.00",value:v,onChange:B=>k(B.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:D,children:"Max"})]})]}),(N||u)&&e.jsx(Y.ErrorMessage,{error:N||u||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:$,children:"Review Withdrawal"})]}),f==="confirm"&&h&&e.jsxs("div",{className:"cedros-withdrawal-confirm",children:[e.jsxs("div",{className:"cedros-withdrawal-header",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:J,disabled:d,children:"Back"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Confirm Withdrawal"})]}),e.jsxs("div",{className:"cedros-withdrawal-summary",children:[e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Token"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:h.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:[qe(M,h.decimals)," ",h.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:b,children:Ds(b)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),u&&e.jsx(Y.ErrorMessage,{error:u}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:J,disabled:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:le,disabled:d,children:d?"Sending...":"Confirm & Send"})]})]}),f==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(_.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",h?.symbol,"..."]})]}),f==="success"&&C&&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:[qe(M,h?.decimals??9)," ",h?.symbol," ","sent"]}),e.jsxs("div",{className:"cedros-withdrawal-tx",children:[e.jsx("span",{className:"cedros-withdrawal-tx-label",children:"Transaction"}),e.jsx("a",{className:"cedros-withdrawal-tx-link",href:E,target:"_blank",rel:"noreferrer",children:Ds(C.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:z,children:"Done"})]})]}):null}function ri(s,t){if(s==="sol")return"SOL";if(!t)return"SPL";const o=$r.find(a=>a.mint===t);return o?o.symbol:`${t.slice(0,4)}...${t.slice(-4)}`}function oi(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function ni(s){const t=new Date(s),o=new Date,a=o.getTime()-t.getTime(),r=Math.floor(a/(1e3*60*60*24));if(r===0){const n=Math.floor(a/36e5);if(n===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${n}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==o.getFullYear()?"numeric":void 0})}function ai({pageSize:s=10,className:t="",onTransactionClick:o,explorerUrl:a="https://solscan.io"}){const{getHistory:r,error:n,clearError:c}=nt(),[l,d]=i.useState([]),[u,m]=i.useState(0),[f,g]=i.useState(0),[w,p]=i.useState(!1),[h,y]=i.useState(null),b=i.useCallback(async()=>{p(!0);try{const C=await r(s,f);d(C.items),m(C.total),y(null)}catch(C){y(C instanceof Error?C.message:"Failed to load withdrawal history")}finally{p(!1)}},[s,f,r]);i.useEffect(()=>{b()},[b]);const x=Math.ceil(u/s),v=Math.floor(f/s)+1,k=C=>{const A=(C-1)*s;g(Math.max(0,Math.min(A,Math.max(0,u-1))))};return h||n?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${t}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:h||n}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{c(),y(null),b()},children:"Retry"})]}):w&&l.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${t}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${t}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:b,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(C=>{const A=ri(C.tokenType,C.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>o?.(C),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),o?.(C))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsx("div",{className:"cedros-tx-icon cedros-tx-icon-negative",children:"↑"}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsxs("span",{className:"cedros-tx-type",children:[A," Withdrawal"]}),e.jsxs("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:[C.amount," ",A==="SOL"?"lamports":""]})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${a}/account/${C.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:N=>N.stopPropagation(),children:oi(C.destination)})," · ",e.jsx("a",{href:`${a}/tx/${C.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:N=>N.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:ni(C.createdAt)})]})]})]},C.id)})}),x>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>k(v-1),disabled:v<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",v," of ",x]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>k(v+1),disabled:v>=x,children:"Next"})]})]})]})}function ii({brandLogo:s,brandName:t,title:o="Welcome back",subtitle:a="Login with your Apple or Google account",termsText:r,onSuccess:n,defaultTab:c="login",children:l,className:d=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${d}`,children:[(s||t)&&e.jsxs("div",{className:"cedros-brand-header",children:[s,t&&e.jsx("span",{className:"cedros-brand-name",children:t})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:o}),a&&e.jsx("p",{className:"cedros-full-page-subtitle",children:a})]}),l??e.jsx(ss,{defaultTab:c,onSuccess:n})]}),r&&e.jsx("p",{className:"cedros-terms-footer",children:r})]})}function li({brandName:s="Your Brand",brandLogo:t,tagline:o="Your tagline goes here. Make it compelling.",title:a="Sign in",subtitle:r="Enter your credentials to access your account",onSuccess:n,defaultTab:c="login",children:l,className:d=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${d}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[t??e.jsx("div",{className:"cedros-split-page-logo",children:s.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:s}),o&&e.jsx("p",{className:"cedros-split-page-tagline",children:o})]})}),e.jsx("div",{className:"cedros-split-page-form",children:e.jsxs("div",{className:"cedros-split-page-form-content",children:[e.jsx("h2",{className:"cedros-split-page-title",children:a}),r&&e.jsx("p",{className:"cedros-split-page-subtitle",children:r}),l??e.jsx(ss,{defaultTab:c,onSuccess:n})]})})]})}function ci(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),r=i.useMemo(()=>new zs.OrgApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),n=i.useCallback(async d=>{a(u=>({...u,isLoading:!0,error:null}));try{const u=await r.authorize(d),m={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return a(m),m}catch(u){const m={allowed:!1,reason:void 0,isLoading:!1,error:u};return a(m),m}},[r]),c=i.useCallback(async d=>(await n(d)).allowed,[n]),l=i.useCallback(()=>{a({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:c,lastCheck:o,clearCheck:l,checkAuthorization:n}}function di(){const{listAllWallets:s,createDerivedWallet:t,deleteDerivedWallet:o}=I.useWalletMaterial(),[a,r]=i.useState([]),[n,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useCallback(async()=>{c(!0),d(null);try{const w=await s();r(w.wallets)}catch(w){const p=w instanceof Error?w.message:"Failed to list wallets";d(p)}finally{c(!1)}},[s]),m=i.useCallback(async w=>{c(!0),d(null);try{const p=await t({label:w});return await u(),p}catch(p){const h=p instanceof Error?p.message:"Failed to create wallet";throw d(h),p}finally{c(!1)}},[t,u]),f=i.useCallback(async w=>{c(!0),d(null);try{await o(w),await u()}catch(p){const h=p instanceof Error?p.message:"Failed to delete wallet";throw d(h),p}finally{c(!1)}},[o,u]),g=i.useCallback(()=>d(null),[]);return{wallets:a,isLoading:n,createWallet:m,deleteWallet:f,refresh:u,error:l,clearError:g}}function ui(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(!1),[a,r]=i.useState(null),[n,c]=i.useState(null),l=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=i.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");o(!0),r(null);try{const f=await l.get("/wallet/pending-recovery");c(f)}catch(f){const g=T.handleApiError(f,"Failed to fetch pending recovery");throw r(g.message),g}finally{o(!1)}},[l]),u=i.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");o(!0),r(null);try{const f={confirmed:!0};await l.post("/wallet/acknowledge-recovery",f),c(null)}catch(f){const g=T.handleApiError(f,"Failed to acknowledge recovery");throw r(g.message),g}finally{o(!1)}},[l]),m=i.useCallback(()=>r(null),[]);return i.useEffect(()=>{l&&s?.authState==="authenticated"&&d().catch(()=>{})},[l,s?.authState,d]),{hasPendingRecovery:n?.hasPendingRecovery??!1,recoveryType:n?.recoveryType??null,recoveryPhrase:n?.recoveryPhrase??null,expiresAt:n?.expiresAt?new Date(n.expiresAt):null,fetchPendingRecovery:d,acknowledgeRecovery:u,isLoading:t,error:a,clearError:m}}function hi(s={}){const{onExternalSign:t}=s,{solanaPubkey:o,hasExternalWallet:a,status:r,isUnlocked:n}=I.useWallet(),{signTransaction:c,isSigning:l,error:d,clearError:u}=xr(),m=i.useMemo(()=>a&&t?"external":r==="enrolled_locked"||r==="enrolled_unlocked"?"sss":"none",[a,t,r]),f=m!=="none",g=r==="enrolled_locked"||r==="enrolled_unlocked";return{signTransaction:i.useCallback(async(p,h)=>{if(m==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(p)}if(m==="sss"){if(!h&&!n)throw new Error("Credential required for signing. Unlock wallet first or provide credential.");return h?c(p,h):c(p)}throw new Error("No signing method available. Enroll a wallet first.")},[m,t,n,c]),signingMethod:m,canSign:f,isSigning:l,publicKey:o,hasExternalWallet:a,hasSssWallet:g,isSssUnlocked:n,error:d,clearError:u}}function pi(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(null),[r,n]=i.useState(!1),[c,l]=i.useState(null),d=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),u=i.useCallback(async()=>{n(!0),l(null);try{await d.post("/welcome-completed",{})}catch(f){const g=f instanceof Error?f:new Error(String(f));throw l(g),g}finally{n(!1)}},[d]),m=i.useCallback(()=>{a(null)},[]);return{postLoginAction:o,setPostLoginAction:a,markWelcomeCompleted:u,clearPostLogin:m,isLoading:r,error:c}}const at=i.createContext(null),Ze={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 Jr(s,t){return Xr(s,t)}function Xr(s,t){const o={...s};for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const r=s[a],n=t[a];typeof r=="object"&&r!==null&&typeof n=="object"&&n!==null?o[a]=Xr(r,n):n!==void 0&&(o[a]=n)}return o}function mi({children:s,locale:t="en",translations:o}){const a=i.useMemo(()=>({t:o?Jr(Ze,o):Ze,locale:t}),[o,t]);return e.jsx(at.Provider,{value:a,children:s})}function fi(){return i.useContext(at)?.t??Ze}function gi(){return i.useContext(at)?.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=_.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=we.validatePassword;exports.ErrorMessage=Y.ErrorMessage;exports.GoogleLoginButton=qs.GoogleLoginButton;exports.useGoogleAuth=qs.useGoogleAuth;exports.SolanaLoginButton=ve.SolanaLoginButton;exports.registerMobileWallet=ve.registerMobileWallet;exports.useSolanaAuth=ve.useSolanaAuth;exports.InviteForm=te.InviteForm;exports.InviteList=te.InviteList;exports.MemberList=te.MemberList;exports.useInvites=te.useInvites;exports.useMembers=te.useMembers;exports.useServerFeatures=te.useServerFeatures;exports.useSystemSettings=Yt.useSystemSettings;exports.useOrgs=zs.useOrgs;exports.AdminDepositList=He.AdminDepositList;exports.AdminDepositStats=He.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=fe.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=fe.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=fe.AdminWithdrawalQueue;exports.AdminWithdrawalStats=fe.AdminWithdrawalStats;exports.AdminUserList=Te.AdminUserList;exports.useAdminUsers=Te.useAdminUsers;exports.AdminIcons=ge.Icons;exports.AdminShell=ge.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=ge.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=ge.ProfileDropdown;exports.cedrosLoginPlugin=ge.cedrosLoginPlugin;exports.loginPlugin=ge.cedrosLoginPlugin;exports.useAdminShell=ge.useAdminShell;exports.AuthenticationSettings=$t.AuthenticationSettings;exports.EmbeddedWalletSettings=Jt.EmbeddedWalletSettings;exports.EmailSettings=ze.EmailSettings;exports.CreditSystemSettings=Vs.CreditSystemSettings;exports.PrivacyCashSettings=Vs.CreditSystemSettings;exports.ServerSettings=Xt.ServerSettings;exports.useAdminDeposits=io.useAdminDeposits;exports.SettingsPageLayout=Hs.SettingsPageLayout;exports.WebhookSettings=Hs.WebhookSettings;exports.AccountSettings=wa;exports.AppleLoginButton=dr;exports.CapabilityWarning=en;exports.CedrosAdminDashboard=En;exports.CompleteAccountPrompt=ba;exports.CreditBalance=Ya;exports.DepositFlow=Pa;exports.ErrorBoundary=pr;exports.ForgotPasswordForm=ir;exports.FullPageLayout=ii;exports.History=Za;exports.I18nProvider=mi;exports.LinkedAccounts=Dr;exports.LoginButton=Eo;exports.LoginForm=ss;exports.LoginModal=Io;exports.MfaSetupPrompt=ya;exports.OrgSelector=Fo;exports.OrgSwitcher=Qo;exports.PasskeyLoginButton=hr;exports.PasskeyPrompt=vr;exports.ProfileTab=Br;exports.RecoveryPhraseDisplay=fr;exports.RecoveryPhraseInput=gr;exports.ResetPasswordForm=Do;exports.SUPPORTED_TOKENS=$r;exports.SecuritySettings=Nn;exports.SessionList=mr;exports.SetupWizard=Er;exports.SplitPageLayout=li;exports.SystemSettings=bn;exports.TieredAmountSlider=rt;exports.TokenSelector=et;exports.TotpSettings=Rr;exports.TotpSetup=Xs;exports.UserProfileSettings=oa;exports.WalletAddressRow=Cr;exports.WalletEnrollment=br;exports.WalletManager=yn;exports.WalletRecovery=Nr;exports.WalletStatus=Sr;exports.WalletUnlock=jr;exports.WithdrawalFlow=ti;exports.WithdrawalHistory=ai;exports.defaultTranslations=Ze;exports.getTierForAmount=ts;exports.mergeTranslations=Jr;exports.useAppleAuth=lr;exports.useAuthorize=ci;exports.useCredentials=Zs;exports.useCredits=ot;exports.useDeposit=Or;exports.useInstantLink=ar;exports.useLocale=gi;exports.usePasskeySigning=Ar;exports.usePasswordReset=es;exports.usePendingRecovery=ui;exports.usePostLogin=pi;exports.useProfile=Re;exports.useSessions=Wr;exports.useSetup=Gs;exports.useTotp=Js;exports.useTransactionSigning=hi;exports.useTranslations=fi;exports.useWalletEnrollment=yr;exports.useWalletRecovery=kr;exports.useWalletSigning=xr;exports.useWallets=di;exports.useWebAuthn=Ys;exports.useWithdrawal=nt;
|
|
2055
|
+
`);const E=v(N,S,P),M=s.getSymbolSize(N),R=new a(M);return w(R,N),g(R),p(R,N),b(R,S,0),N>=7&&y(R,N),x(R,E),isNaN(k)&&(k=c.getBestMask(R,b.bind(null,R,S))),c.applyMask(k,R),b(R,S,k),{modules:R,version:N,errorCorrectionLevel:S,maskPattern:k,segments:P}}return hs.create=function(N,S){if(typeof N>"u"||N==="")throw new Error("No input text");let k=t.M,P,L;return typeof S<"u"&&(k=t.from(S.errorCorrectionLevel,t.M),P=u.from(S.version),L=c.from(S.maskPattern),S.toSJISFunc&&s.setToSJISFunction(S.toSJISFunc)),C(N,P,k,L)},hs}var Ms={},Ts={},Ot;function Tr(){return Ot||(Ot=1,(function(s){function t(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let a=o.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+o);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(n){return[n,n]}))),a.length===6&&a.push("F","F");const r=parseInt(a.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+a.slice(0,6).join("")}}s.getOptions=function(a){a||(a={}),a.color||(a.color={});const r=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,n=a.width&&a.width>=21?a.width:void 0,c=a.scale||4;return{width:n,scale:n?4:c,margin:r,color:{dark:t(a.color.dark||"#000000ff"),light:t(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},s.getScale=function(a,r){return r.width&&r.width>=a+r.margin*2?r.width/(a+r.margin*2):r.scale},s.getImageWidth=function(a,r){const n=s.getScale(a,r);return Math.floor((a+r.margin*2)*n)},s.qrToImageData=function(a,r,n){const c=r.modules.size,l=r.modules.data,d=s.getScale(c,n),u=Math.floor((c+n.margin*2)*d),h=n.margin*d,m=[n.color.light,n.color.dark];for(let f=0;f<u;f++)for(let w=0;w<u;w++){let g=(f*u+w)*4,p=n.color.light;if(f>=h&&w>=h&&f<u-h&&w<u-h){const y=Math.floor((f-h)/d),b=Math.floor((w-h)/d);p=m[l[y*c+b]?1:0]}a[g++]=p.r,a[g++]=p.g,a[g++]=p.b,a[g]=p.a}}})(Ts)),Ts}var qt;function Xn(){return qt||(qt=1,(function(s){const t=Tr();function o(r,n,c){r.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=c,n.width=c,n.style.height=c+"px",n.style.width=c+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}s.render=function(n,c,l){let d=l,u=c;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),c||(u=a()),d=t.getOptions(d);const h=t.getImageWidth(n.modules.size,d),m=u.getContext("2d"),f=m.createImageData(h,h);return t.qrToImageData(f.data,n,d),o(m,u,h),m.putImageData(f,0,0),u},s.renderToDataURL=function(n,c,l){let d=l;typeof d>"u"&&(!c||!c.getContext)&&(d=c,c=void 0),d||(d={});const u=s.render(n,c,d),h=d.type||"image/png",m=d.rendererOpts||{};return u.toDataURL(h,m.quality)}})(Ms)),Ms}var Rs={},zt;function Zn(){if(zt)return Rs;zt=1;const s=Tr();function t(r,n){const c=r.a/255,l=n+'="'+r.hex+'"';return c<1?l+" "+n+'-opacity="'+c.toFixed(2).slice(1)+'"':l}function o(r,n,c){let l=r+n;return typeof c<"u"&&(l+=" "+c),l}function a(r,n,c){let l="",d=0,u=!1,h=0;for(let m=0;m<r.length;m++){const f=Math.floor(m%n),w=Math.floor(m/n);!f&&!u&&(u=!0),r[m]?(h++,m>0&&f>0&&r[m-1]||(l+=u?o("M",f+c,.5+w+c):o("m",d,0),d=0,u=!1),f+1<n&&r[m+1]||(l+=o("h",h),h=0)):d++}return l}return Rs.render=function(n,c,l){const d=s.getOptions(c),u=n.modules.size,h=n.modules.data,m=u+d.margin*2,f=d.color.light.a?"<path "+t(d.color.light,"fill")+' d="M0 0h'+m+"v"+m+'H0z"/>':"",w="<path "+t(d.color.dark,"stroke")+' d="'+a(h,u,d.margin)+'"/>',g='viewBox="0 0 '+m+" "+m+'"',y='<svg xmlns="http://www.w3.org/2000/svg" '+(d.width?'width="'+d.width+'" height="'+d.width+'" ':"")+g+' shape-rendering="crispEdges">'+f+w+`</svg>
|
|
2056
|
+
`;return typeof l=="function"&&l(null,y),y},Rs}var Vt;function ea(){if(Vt)return Ae;Vt=1;const s=Bn(),t=Jn(),o=Xn(),a=Zn();function r(n,c,l,d,u){const h=[].slice.call(arguments,1),m=h.length,f=typeof h[m-1]=="function";if(!f&&!s())throw new Error("Callback required as last argument");if(f){if(m<2)throw new Error("Too few arguments provided");m===2?(u=l,l=c,c=d=void 0):m===3&&(c.getContext&&typeof u>"u"?(u=d,d=void 0):(u=d,d=l,l=c,c=void 0))}else{if(m<1)throw new Error("Too few arguments provided");return m===1?(l=c,c=d=void 0):m===2&&!c.getContext&&(d=l,l=c,c=void 0),new Promise(function(w,g){try{const p=t.create(l,d);w(n(p,c,d))}catch(p){g(p)}})}try{const w=t.create(l,d);u(null,n(w,c,d))}catch(w){u(w)}}return Ae.create=t.create,Ae.toCanvas=r.bind(null,o.render),Ae.toDataURL=r.bind(null,o.renderToDataURL),Ae.toString=r.bind(null,function(n,c,l){return a.render(n,l)}),Ae}var sa=ea();const ta=ie.getDefaultExportFromCjs(sa);function ra({value:s,size:t=200,alt:o="QR code",className:a=""}){const r=i.useRef(null),[n,c]=i.useState(null);return i.useEffect(()=>{!r.current||!s||ta.toCanvas(r.current,s,{width:t,margin:2,color:{dark:"#000000",light:"#ffffff"},errorCorrectionLevel:"M"}).then(()=>{c(null)}).catch(l=>{c(l instanceof Error?l.message:"Failed to generate QR code")})},[s,t]),n?e.jsx("div",{className:`cedros-qr-error ${a}`,style:{width:t,height:t},role:"img","aria-label":o,children:e.jsx("p",{children:"Failed to generate QR code"})}):e.jsx("canvas",{ref:r,className:`cedros-totp-qr-image ${a}`,role:"img","aria-label":o,style:{borderRadius:"0.5rem"}})}function Js(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(null),[r,n]=i.useState("idle"),[c,l]=i.useState(null),[d,u]=i.useState(!1),[h,m]=i.useState(null),f=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,retryAttempts:s.retryAttempts,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),w=i.useCallback(async()=>{u(!0),m(null);try{const j=await f.get("/mfa/status");return a(j),j}catch(j){const C=T.handleApiError(j,"Unable to load two-factor authentication status. Please try again.");throw m(C),C}finally{u(!1)}},[f]),g=i.useCallback(async()=>{u(!0),m(null),n("loading");try{const j=await f.post("/mfa/setup",{});return l(j),n("setup"),j}catch(j){const C=T.handleApiError(j,"Unable to start two-factor setup. Please try again.");throw m(C),n("error"),C}finally{u(!1)}},[f]),p=i.useCallback(async j=>{if(!/^\d{6}$/.test(j)){const C={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw m(C),C}u(!0),m(null),n("verifying");try{await f.post("/mfa/enable",{code:j}),n("success");try{const C=await f.get("/mfa/status");a(C)}catch{a({enabled:!0,recoveryCodesRemaining:0})}}catch(C){const A=T.handleApiError(C,"Incorrect verification code. Please check and try again.");throw m(A),n("error"),A}finally{u(!1)}},[f]),y=i.useCallback(async j=>{if(!j){const C={code:"VALIDATION_ERROR",message:"Please enter your password"};throw m(C),C}u(!0),m(null);try{await f.post("/mfa/disable",{password:j}),a({enabled:!1,recoveryCodesRemaining:0}),l(null),n("idle")}catch(C){const A=T.handleApiError(C,"Unable to disable two-factor authentication. Please try again.");throw m(A),A}finally{u(!1)}},[f]),b=i.useCallback(async j=>{if(!/^\d{6}$/.test(j)){const C={code:"VALIDATION_ERROR",message:"Please enter a 6-digit code"};throw m(C),C}u(!0),m(null);try{return await f.post("/mfa/recovery-codes/regenerate",{code:j})}catch(C){const A=T.handleApiError(C,"Unable to regenerate recovery codes. Please try again.");throw m(A),A}finally{u(!1)}},[f]),x=i.useCallback(()=>m(null),[]),v=i.useCallback(()=>{m(null),l(null),n("idle"),u(!1)},[]);return{status:o,setupState:r,setupData:c,isLoading:d,error:h,getStatus:w,beginSetup:g,enableTotp:p,disableTotp:y,regenerateBackupCodes:b,clearError:x,reset:v}}function Xs({onSuccess:s,onCancel:t,className:o=""}){const{setupState:a,setupData:r,isLoading:n,error:c,beginSetup:l,enableTotp:d,clearError:u,reset:h}=Js(),[m,f]=i.useState("qr"),[w,g]=i.useState(""),[p,y]=i.useState(!1),[b,x]=i.useState(!1),v=i.useRef(null);i.useEffect(()=>{a==="idle"&&l().catch(()=>{})},[a,l]),i.useEffect(()=>{a==="success"&&s?.()},[a,s]);const j=async()=>{r?.secret&&(await navigator.clipboard.writeText(r.secret),y(!0),v.current!==null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>y(!1),2e3))},C=async()=>{if(r?.recoveryCodes){const S=r.recoveryCodes.join(`
|
|
2057
|
+
`);await navigator.clipboard.writeText(S)}},A=async()=>{try{await d(w)}catch{g("")}},N=()=>{h(),t?.()};return i.useEffect(()=>()=>{v.current!==null&&(window.clearTimeout(v.current),v.current=null)},[]),a==="loading"||a==="idle"&&n?e.jsx("div",{className:`cedros-totp-setup ${o}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(_.LoadingSpinner,{size:"lg",label:"Setting up two-factor authentication"})})}):a==="error"&&!r?e.jsxs("div",{className:`cedros-totp-setup ${o}`,children:[e.jsx(Y.ErrorMessage,{error:c,onDismiss:u}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:N,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>l(),children:"Try again"})]})]}):a==="success"?e.jsx("div",{className:`cedros-totp-setup ${o}`,children:e.jsxs("div",{className:"cedros-totp-success",children:[e.jsxs("svg",{className:"cedros-totp-success-icon",width:"48",height:"48",viewBox:"0 0 48 48",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"var(--cedros-success)",strokeWidth:"2"}),e.jsx("path",{d:"M14 24l7 7 13-13",stroke:"var(--cedros-success)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication enabled"}),e.jsx("p",{className:"cedros-totp-description",children:"Your account is now protected with an additional layer of security."})]})}):r?e.jsxs("div",{className:`cedros-totp-setup ${o}`,children:[m==="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(ra,{value:r.otpauthUri,size:200,alt:"QR code for authenticator app"})}),e.jsxs("div",{className:"cedros-totp-manual",children:[e.jsx("p",{className:"cedros-totp-manual-label",children:"Or enter this code manually:"}),e.jsxs("div",{className:"cedros-totp-secret",children:[e.jsx("code",{className:"cedros-totp-secret-code",children:r.secret}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:j,"aria-label":"Copy secret",children: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:N,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("backup"),children:"Continue"})]})]}),m==="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((S,k)=>e.jsx("code",{className:"cedros-totp-backup-code",children:S},k))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:C,children:"Copy all codes"}),e.jsxs("label",{className:"cedros-checkbox-label cedros-totp-confirm",children:[e.jsx("input",{type:"checkbox",className:"cedros-checkbox",checked:b,onChange:S=>x(S.target.checked)}),e.jsx("span",{className:"cedros-checkbox-text",children:"I have saved these recovery codes"})]}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>f("qr"),children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>f("verify"),disabled:!b,children:"Continue"})]})]}),m==="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:w,onChange:g,onComplete:A,disabled:n,error:c?.message,autoFocus:!0}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>f("backup"),disabled:n,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:A,disabled:n||w.length!==6,children:n?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Verifying..."})]}):"Enable 2FA"})]})]})]}):null}function Rr({onStatusChange:s,className:t=""}){const{status:o,isLoading:a,error:r,getStatus:n,disableTotp:c,regenerateBackupCodes:l,clearError:d}=Js(),[u,h]=i.useState("status"),[m,f]=i.useState(""),[w,g]=i.useState(""),[p,y]=i.useState(null),[b,x]=i.useState(!1),[v,j]=i.useState(null);i.useEffect(()=>{n().catch(()=>{})},[n]);const C=i.useCallback(()=>{h("status"),s?.(!0)},[s]),A=async()=>{x(!0),j(null);try{await c(m),h("status"),f(""),s?.(!1)}catch(k){j(k instanceof Error?k.message:"Failed to disable 2FA"),f("")}finally{x(!1)}},N=async()=>{x(!0),j(null);try{const k=await l(w);y(k.recoveryCodes),g("")}catch(k){j(k instanceof Error?k.message:"Failed to regenerate codes"),g("")}finally{x(!1)}},S=async()=>{p&&await navigator.clipboard.writeText(p.join(`
|
|
2058
|
+
`))};return a&&!o?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx("div",{className:"cedros-totp-loading",children:e.jsx(_.LoadingSpinner,{size:"md",label:"Loading security settings"})})}):r&&!o?e.jsxs("div",{className:`cedros-totp-settings ${t}`,children:[e.jsx(Y.ErrorMessage,{error:r,onDismiss:d}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>n(),children:"Retry"})]}):u==="setup"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsx(Xs,{onSuccess:C,onCancel:()=>h("status")})}):u==="disable"?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Disable two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description cedros-totp-warning",children:"This will make your account less secure. Enter your password to confirm."}),v&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v},onDismiss:()=>j(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.PasswordInput,{label:"Password",placeholder:"Enter your password",value:m,onChange:k=>f(k.target.value),disabled:b,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{h("status"),f(""),j(null)},disabled:b,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive cedros-button-md",onClick:A,disabled:b||m.length===0,children:b?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Disabling..."})]}):"Disable 2FA"})]})]})}):u==="regenerate"?p?e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"New recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"Save these codes in a secure place. Your old codes are no longer valid."}),e.jsx("div",{className:"cedros-totp-backup-codes",children:p.map((k,P)=>e.jsx("code",{className:"cedros-totp-backup-code",children:k},P))}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md cedros-button-full",onClick:S,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:()=>{h("status"),y(null)},children:"Done"})})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Regenerate recovery codes"}),e.jsx("p",{className:"cedros-totp-description",children:"This will invalidate all existing recovery codes. Enter your authenticator code to confirm."}),v&&e.jsx("div",{className:"cedros-totp-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:v},onDismiss:()=>j(null)})}),e.jsx("div",{className:"cedros-totp-verify-input",children:e.jsx(Q.OtpInput,{value:w,onChange:g,onComplete:N,disabled:b,autoFocus:!0})}),e.jsxs("div",{className:"cedros-totp-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>{h("status"),g(""),j(null)},disabled:b,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:N,disabled:b||w.length!==6,children:b?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Regenerating..."})]}):"Regenerate codes"})]})]})}):e.jsx("div",{className:`cedros-totp-settings ${t}`,children:e.jsxs("div",{className:"cedros-totp-panel",children:[e.jsxs("div",{className:"cedros-totp-status-header",children:[e.jsxs("div",{className:"cedros-totp-status-info",children:[e.jsx("h3",{className:"cedros-totp-title",children:"Two-factor authentication"}),e.jsx("p",{className:"cedros-totp-description",children:"Add an extra layer of security to your account by requiring a verification code from your authenticator app when signing in with email and password. Other sign-in methods (Google, Apple, passkeys) use their own built-in verification."})]}),e.jsx("div",{className:`cedros-totp-badge ${o?.enabled?"cedros-totp-badge-enabled":"cedros-totp-badge-disabled"}`,children:o?.enabled?"Enabled":"Disabled"})]}),o?.enabled?e.jsxs("div",{className:"cedros-totp-enabled-actions",children:[e.jsxs("div",{className:"cedros-totp-description",style:{marginTop:"0.25rem"},children:["Recovery codes remaining: ",e.jsx("strong",{children:o.recoveryCodesRemaining})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:()=>h("regenerate"),children:"Regenerate recovery codes"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-destructive-outline cedros-button-md",onClick:()=>h("disable"),children:"Disable 2FA"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:()=>h("setup"),children:"Enable two-factor authentication"})]})})}class oa{client;constructor(t,o,a,r){this.client=new T.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async changePassword(t){try{return await this.client.post("/auth/change-password",t)}catch(o){throw T.handleApiError(o,"Failed to change password")}}async updateProfile(t){try{return await this.client.patch("/auth/me",t)}catch(o){throw T.handleApiError(o,"Failed to update profile")}}}function Re(){const{config:s,authState:t,_internal:o}=T.useCedrosLogin(),[a,r]=i.useState(!1),[n,c]=i.useState(null),l=i.useMemo(()=>new oa(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),d=i.useCallback(()=>{c(null)},[]),u=i.useCallback(async m=>{if(t!=="authenticated")throw new Error("Must be authenticated to update profile");r(!0),c(null);try{return await l.updateProfile(m)}catch(f){const w=f instanceof Error?f:new Error("Failed to update profile");throw c(w),w}finally{r(!1)}},[t,l]),h=i.useCallback(async m=>{if(t!=="authenticated")throw new Error("Must be authenticated to change password");r(!0),c(null);try{await l.changePassword(m)}catch(f){const w=f instanceof Error?f:new Error("Failed to change password");throw c(w),w}finally{r(!1)}},[t,l]);return{isLoading:a,error:n,updateProfile:u,changePassword:h,clearError:d}}function na({onPasswordChange:s,onClose:t,className:o=""}){const{user:a}=I.useAuth(),{isLoading:r,error:n,changePassword:c,clearError:l}=Re(),[d,u]=i.useState("main"),[h,m]=i.useState(""),[f,w]=i.useState(""),[g,p]=i.useState(""),[y,b]=i.useState(null),[x,v]=i.useState(null),j=we.validatePassword(f),C=f===g,A=h.length>0&&f.length>0&&g.length>0&&j.isValid&&C,N=i.useCallback(async()=>{if(A){b(null),v(null);try{await c({currentPassword:h,newPassword:f}),m(""),w(""),p(""),v("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>{u("main"),v(null)},2e3)}catch(P){b(P instanceof Error?P.message:"Failed to change password")}}},[A,h,f,c,s]),S=i.useCallback(()=>{u("main"),m(""),w(""),p(""),b(null),l()},[l]),k=()=>a?.name?a.name.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2):a?.email?a.email[0].toUpperCase():"?";return d==="change-password"?e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(y||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:y||n?.message||""},onDismiss:()=>{b(null),l()}})}),x&&e.jsxs("div",{className:"cedros-profile-success",children:[e.jsx("span",{className:"cedros-profile-success-icon",children:"✓"}),x]}),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:h,onChange:P=>m(P.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:f,onChange:P=>w(P.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:P=>p(P.target.value),disabled:r,error:g.length>0&&!C?"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:S,disabled:r,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:N,disabled:r||!A,children:r?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})}):e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children:a?.picture?e.jsx("img",{src:a.picture,alt:a.name||"Profile",className:"cedros-profile-avatar"}):e.jsx("div",{className:"cedros-profile-avatar cedros-profile-avatar-fallback",children:k()})}),e.jsxs("div",{className:"cedros-profile-info",children:[e.jsx("h3",{className:"cedros-profile-name",children:a?.name||"User"}),e.jsx("p",{className:"cedros-profile-email",children:a?.email})]})]}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children:a?.email||"Not set"})]})}),e.jsxs("div",{className:"cedros-profile-row",children:[e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Password"}),e.jsx("span",{className:"cedros-profile-row-value",children:"••••••••"})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>u("change-password"),children:"Change"})]})]}),t&&e.jsx("div",{className:"cedros-profile-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})})}class aa{client;constructor(t,o,a,r){this.client=new T.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async listCredentials(){try{return(await this.client.get("/credentials")).credentials}catch(t){throw T.handleApiError(t,"Failed to list credentials")}}async unlinkCredential(t){try{await this.client.delete(`/credentials/${encodeURIComponent(t)}`)}catch(o){throw T.handleApiError(o,"Failed to unlink credential")}}}function Zs(){const{config:s,authState:t,_internal:o}=T.useCedrosLogin(),[a,r]=i.useState([]),[n,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useMemo(()=>new aa(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),h=i.useCallback(()=>{d(null)},[]),m=i.useCallback(async()=>{if(t!=="authenticated"){r([]);return}c(!0),d(null);try{const w=await u.listCredentials();r(w)}catch(w){d(w)}finally{c(!1)}},[t,u]);i.useEffect(()=>{t==="authenticated"?m():r([])},[t,m]);const f=i.useCallback(async w=>{c(!0),d(null);try{await u.unlinkCredential(w),await m()}catch(g){throw d(g),g}finally{c(!1)}},[u,m]);return{credentials:a,isLoading:n,error:l,fetchCredentials:m,unlinkCredential:f,clearError:h}}function ia({onPasswordChange:s,onCancel:t,className:o=""}){const{isLoading:a,error:r,changePassword:n,clearError:c}=Re(),[l,d]=i.useState(""),[u,h]=i.useState(""),[m,f]=i.useState(""),[w,g]=i.useState(null),[p,y]=i.useState(null),b=we.validatePassword(u),x=u===m,v=l.length>0&&u.length>0&&m.length>0&&b.isValid&&x,j=i.useCallback(async()=>{if(v){g(null),y(null);try{await n({currentPassword:l,newPassword:u}),d(""),h(""),f(""),y("Password changed successfully. Other sessions have been logged out."),s?.(),setTimeout(()=>t(),2e3)}catch(A){g(A instanceof Error?A.message:"Failed to change password")}}},[v,l,u,n,s,t]),C=i.useCallback(()=>{g(null),c(),t()},[c,t]);return e.jsx("div",{className:`cedros-profile-settings ${o}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsx("h3",{className:"cedros-profile-title",children:"Change password"}),e.jsx("p",{className:"cedros-profile-description",children:"Enter your current password and choose a new one. This will log you out of other devices."}),(w||r)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:w||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:l,onChange:A=>d(A.target.value),disabled:a,autoFocus:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"New password",placeholder:"Enter new password",value:u,onChange:A=>h(A.target.value),disabled:a,showStrengthMeter:!0})}),e.jsx("div",{className:"cedros-profile-field",children:e.jsx(Q.PasswordInput,{label:"Confirm new password",placeholder:"Confirm new password",value:m,onChange:A=>f(A.target.value),disabled:a,error:m.length>0&&!x?"Passwords do not match":void 0})})]}),e.jsxs("div",{className:"cedros-profile-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:C,disabled:a,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-button-md",onClick:j,disabled:a||!v,children:a?e.jsxs(e.Fragment,{children:[e.jsx(_.LoadingSpinner,{size:"sm"}),e.jsx("span",{children:"Changing..."})]}):"Change password"})]})]})})}function Br({onPasswordChange:s,className:t=""}){const{user:o,refreshUser:a}=I.useAuth(),{isLoading:r,error:n,updateProfile:c,clearError:l}=Re(),{credentials:d}=Zs(),{forgotPassword:u,isLoading:h,isSuccess:m,reset:f}=es(),w=d.some(k=>k.credentialType==="password"),[g,p]=i.useState("view"),[y,b]=i.useState(""),[x,v]=i.useState(null),j=()=>o?.name?o.name.split(" ").map(k=>k[0]).join("").toUpperCase().slice(0,2):o?.email?o.email[0].toUpperCase():"?",C=i.useCallback(()=>{b(o?.name||""),p("edit"),v(null)},[o?.name]),A=i.useCallback(async()=>{const k=y.trim();if(k){v(null);try{await c({name:k}),await a(),p("view")}catch(P){v(P instanceof Error?P.message:"Failed to update name")}}},[y,c,a]),N=i.useCallback(()=>{p("view"),b(""),v(null),l()},[l]),S=i.useCallback(async()=>{if(o?.email){v(null);try{await u(o.email)}catch(k){v(k instanceof Error?k.message:"Failed to send password setup email")}}},[o?.email,u]);return g==="change-password"?e.jsx(ia,{onPasswordChange:s,onCancel:()=>p("view"),className:t}):e.jsx("div",{className:`cedros-profile-settings ${t}`,children:e.jsxs("div",{className:"cedros-profile-panel",children:[e.jsxs("div",{className:"cedros-profile-header",children:[e.jsx("div",{className:"cedros-profile-avatar-container",children: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:j()})}),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:y,onChange:k=>b(k.target.value),disabled:r,autoFocus:!0,onKeyDown:k=>{k.key==="Enter"&&A(),k.key==="Escape"&&N()}}),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:A,disabled:r||!y.trim(),children:r?e.jsx(_.LoadingSpinner,{size:"sm"}):"Save"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:N,disabled:r,children:"Cancel"})]})]}):e.jsxs("div",{className:"cedros-profile-name-row",children:[e.jsx("h3",{className:"cedros-profile-name",children:o?.name||"User"}),e.jsx("button",{type:"button",className:"cedros-profile-edit-btn",onClick:C,title:"Edit name","aria-label":"Edit name",children:e.jsx(la,{})})]}),e.jsx("p",{className:"cedros-profile-email",children:o?.email})]})]}),(x||n)&&e.jsx("div",{className:"cedros-profile-error",children:e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:x||n?.message||""},onDismiss:()=>{v(null),l()}})}),e.jsxs("div",{className:"cedros-profile-section",children:[e.jsx("h4",{className:"cedros-profile-section-title",children:"Account"}),e.jsx("div",{className:"cedros-profile-row",children:e.jsxs("div",{className:"cedros-profile-row-content",children:[e.jsx("span",{className:"cedros-profile-row-label",children:"Email"}),e.jsx("span",{className:"cedros-profile-row-value",children: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:w?"••••••••":"Not set"})]}),w?e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:()=>{p("change-password"),v(null)},children:"Change"}):m?e.jsxs("span",{className:"cedros-profile-row-sent",children:["Check your email",e.jsx("button",{type:"button",className:"cedros-profile-row-sent-dismiss",onClick:f,"aria-label":"Dismiss",children:"×"})]}):e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:S,disabled:h,children:h?e.jsx(_.LoadingSpinner,{size:"sm"}):"Add password"})]})]})]})})}function la(){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 Ir={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 Dr({onLinkGoogle:s,onLinkApple:t,onAddPasskey:o,onLinkSolana:a,className:r=""}){const{credentials:n,isLoading:c,error:l,unlinkCredential:d,clearError:u,fetchCredentials:h}=Zs(),{registerPasskey:m,isSupported:f}=Ys(),[w,g]=i.useState(null),[p,y]=i.useState(!1),b=i.useCallback(async()=>{if(o){o();return}y(!0);try{await m(),await h()}catch{}finally{y(!1)}},[o,m,h]),x=i.useCallback(async k=>{const P=k.label||Ir[k.credentialType];if(window.confirm(`Remove "${P}" as a sign-in method? You won't be able to sign in with it anymore.`)){g(k.id);try{await d(k.id)}catch{}finally{g(null)}}},[d]),v=new Set(n.map(k=>k.credentialType)),j=s&&!v.has("oauth_google"),C=t&&!v.has("oauth_apple"),A=(o||f)&&!v.has("webauthn_passkey"),N=a&&!v.has("solana"),S=j||C||A||N;return c&&n.length===0?e.jsxs("div",{className:`cedros-linked-accounts ${r}`,children:[e.jsx(_.LoadingSpinner,{}),e.jsx("span",{children:"Loading linked accounts..."})]}):e.jsxs("div",{className:`cedros-linked-accounts ${r}`,children:[l&&e.jsx(Y.ErrorMessage,{error:{code:"UNKNOWN_ERROR",message:l.message},onDismiss:u}),n.length===0&&!c&&e.jsx("p",{className:"cedros-linked-accounts-empty",children:"No linked sign-in methods found."}),n.length>0&&e.jsx("ul",{className:"cedros-linked-credential-list",children:n.map(k=>e.jsx(ca,{credential:k,isUnlinking:w===k.id,onUnlink:x},k.id))}),S&&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:[j&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:s,children:[e.jsx(Fr,{})," Google"]}),C&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:t,children:[e.jsx(Ur,{})," Apple"]}),A&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:b,disabled:p,children:p?e.jsx(_.LoadingSpinner,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Ws,{})," Passkey"]})}),N&&e.jsxs("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm",onClick:a,children:[e.jsx(_r,{})," Solana"]})]})]})]})}function ca({credential:s,isUnlinking:t,onUnlink:o}){const a=s.label||Ir[s.credentialType],r=da[s.credentialType]||ua;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:a}),e.jsxs("span",{className:"cedros-linked-credential__meta",children:["Added ",Ht(s.createdAt),s.lastUsedAt&&e.jsxs(e.Fragment,{children:[" · Last used ",Ht(s.lastUsedAt)]}),s.isPrimary&&e.jsx(e.Fragment,{children:" · Primary"})]})]}),e.jsx("div",{className:"cedros-linked-credential__action",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-sm cedros-button-danger-outline",onClick:()=>o(s),disabled:t,title:s.isPrimary?"Cannot remove primary sign-in method":"Remove",children:t?e.jsx(_.LoadingSpinner,{size:"sm"}):"Remove"})})]})}function Ht(s){const t=new Date(s),a=new Date().getTime()-t.getTime(),r=Math.floor(a/(1e3*60)),n=Math.floor(a/(1e3*60*60)),c=Math.floor(a/(1e3*60*60*24));return r<1?"just now":r<60?`${r}m ago`:n<24?`${n}h ago`:c<30?`${c}d ago`:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}const da={password:ha,oauth_google:Fr,oauth_apple:Ur,solana:_r,webauthn_passkey:Ws,webauthn_security_key:Ws,totp:pa,sso_oidc:ma};function ua(){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 ha(){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 Fr(){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 Ur(){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 _r(){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 Ws(){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 pa(){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 ma(){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 fa{client;constructor(t,o,a,r){this.client=new T.ApiClient({baseUrl:t,timeoutMs:o,retryAttempts:a,getAccessToken:r})}async listSessions(){try{return(await this.client.get("/sessions")).sessions}catch(t){throw T.handleApiError(t,"Failed to list sessions")}}async revokeAllSessions(){try{return await this.client.delete("/sessions")}catch(t){throw T.handleApiError(t,"Failed to revoke sessions")}}}function Wr(){const{config:s,authState:t,_internal:o}=T.useCedrosLogin(),[a,r]=i.useState([]),[n,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useMemo(()=>new fa(s.serverUrl,s.requestTimeout,s.retryAttempts,o?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,o]),h=i.useCallback(async()=>{if(t!=="authenticated"){r([]);return}c(!0),d(null);try{const w=await u.listSessions();r(w)}catch(w){d(w)}finally{c(!1)}},[t,u]);i.useEffect(()=>{t==="authenticated"?h():r([])},[t,h]);const m=i.useCallback(async()=>{c(!0),d(null);try{const w=await u.revokeAllSessions();return await h(),w}catch(w){throw d(w),w}finally{c(!1)}},[u,h]),f=i.useMemo(()=>a.filter(w=>!w.isCurrent).length,[a]);return{sessions:a,isLoading:n,error:l,fetchSessions:h,revokeAllSessions:m,otherSessionCount:f}}const ga={profile:"Profile",security:"Security",linked:"Linked Accounts"},wa=["profile","security","linked"];function ya({defaultTab:s="profile",onClose:t,onPasswordChange:o,onTotpChange:a,onLinkGoogle:r,onLinkApple:n,onAddPasskey:c,onLinkSolana:l,className:d=""}){const[u,h]=i.useState(s),{sessions:m,isLoading:f,error:w,revokeAllSessions:g}=Wr();return e.jsxs("div",{className:`cedros-account-settings ${d}`,children:[e.jsx("div",{className:"cedros-account-tabs--line",role:"tablist",children:wa.map(p=>e.jsx("button",{type:"button",role:"tab","aria-selected":u===p,className:`cedros-account-tab ${u===p?"cedros-account-tab-active":""}`,onClick:()=>h(p),children:ga[p]},p))}),e.jsxs("div",{className:"cedros-account-tab-content",role:"tabpanel",children:[u==="profile"&&e.jsx(Br,{onPasswordChange:o}),u==="security"&&e.jsxs("div",{className:"cedros-account-security",children:[e.jsx(Rr,{onStatusChange:a}),e.jsx(mr,{sessions:m,isLoading:f,error:w??void 0,onRevokeAll:async()=>{await g()}})]}),u==="linked"&&e.jsx(Dr,{onLinkGoogle:r,onLinkApple:n,onAddPasskey:c,onLinkSolana:l})]}),t&&e.jsx("div",{className:"cedros-account-footer",children:e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-button-md",onClick:t,children:"Close"})})]})}function ba({onComplete:s,className:t}){return e.jsxs("div",{className:`cedros-mfa-setup-prompt ${t??""}`,children:[e.jsxs("div",{className:"cedros-mfa-setup-prompt__header",children:[e.jsx("h2",{className:"cedros-mfa-setup-prompt__title",children:"Two-factor authentication required"}),e.jsx("p",{className:"cedros-mfa-setup-prompt__description",children:"Your administrator requires you to set up two-factor authentication before continuing. This adds an extra layer of security to your account."})]}),e.jsx("div",{className:"cedros-mfa-setup-prompt__body",children:e.jsx(Xs,{onSuccess:s})})]})}function xa({onComplete:s,onSkip:t,className:o}){const{user:a}=I.useAuth(),{isLoading:r,error:n,updateProfile:c,clearError:l}=Re(),[d,u]=i.useState(a?.name??""),h=i.useCallback(async f=>{f.preventDefault(),l();const w=d.trim();if(!w){s?.();return}try{await c({name:w}),s?.()}catch{}},[d,c,l,s]),m=d.trim().length>0;return e.jsxs("div",{className:`cedros-complete-account ${o??""}`,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:h,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:d,onChange:f=>u(f.target.value),placeholder:"Enter your name",className:"cedros-complete-account__input",maxLength:100,autoFocus:!0})]}),n&&e.jsx("div",{className:"cedros-complete-account__error",role:"alert",children:n.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||!m,children:r?"Saving...":"Save"}),e.jsx("button",{type:"button",className:"cedros-complete-account__button cedros-complete-account__button--secondary",onClick:t,disabled:r,children:"Skip"})]})]})]})}function Or(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(!1),[a,r]=i.useState(null),n=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{r(null)},[]),l=i.useCallback(async g=>{if(!n)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}o(!0),r(null);try{return await n.post("/deposit",{amount_lamports:g})}catch(p){const y=T.handleApiError(p,"Failed to execute deposit");throw r(y.message),y}finally{o(!1)}},[n]),d=i.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get(`/deposit/status/${encodeURIComponent(g)}`)}catch(p){const y=T.handleApiError(p,"Failed to get deposit status");throw r(y.message),y}finally{o(!1)}},[n]),u=i.useCallback(async()=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get("/deposit/config")}catch(g){const p=T.handleApiError(g,"Failed to get deposit config");throw r(p.message),p}finally{o(!1)}},[n]),h=i.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!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 y=p.toString(),b=y?`/deposits?${y}`:"/deposits";return await n.get(b)}catch(p){const y=T.handleApiError(p,"Failed to list deposits");throw r(y.message),y}finally{o(!1)}},[n]),m=i.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{const p=new URLSearchParams({input_mint:g.inputMint,amount:String(g.amount),taker:g.taker});return await n.get(`/deposit/quote?${p}`)}catch(p){const y=T.handleApiError(p,"Failed to get deposit quote");throw r(y.message),y}finally{o(!1)}},[n]),f=i.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.post("/deposit/public",g)}catch(p){const y=T.handleApiError(p,"Failed to execute public deposit");throw r(y.message),y}finally{o(!1)}},[n]),w=i.useCallback(async g=>{if(!n)throw new Error("useDeposit must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.post("/deposit/micro",g)}catch(p){const y=T.handleApiError(p,"Failed to execute micro deposit");throw r(y.message),y}finally{o(!1)}},[n]);return{deposit:l,getQuote:m,publicDeposit:f,microDeposit:w,getStatus:d,getConfig:u,listDeposits:h,isLoading:t,error:a,clearError:c}}function et({tokens:s,selectedToken:t,onSelect:o,openSignal:a,placeholder:r="Select token",disabled:n=!1,className:c="",searchable:l=!0}){const[d,u]=i.useState(!1),[h,m]=i.useState(""),f=i.useRef(null),w=i.useRef(null),g=i.useMemo(()=>{if(!h.trim())return s;const x=h.toLowerCase();return s.filter(v=>v.symbol.toLowerCase().includes(x)||v.name.toLowerCase().includes(x)||v.mint.toLowerCase().includes(x))},[s,h]);i.useEffect(()=>{const x=v=>{f.current&&!f.current.contains(v.target)&&(u(!1),m(""))};if(d)return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[d]),i.useEffect(()=>{d&&l&&w.current&&w.current.focus()},[d,l]),i.useEffect(()=>{a===void 0||n||(u(!0),m(""))},[a,n]);const p=i.useCallback(()=>{n||(u(x=>!x),d&&m(""))},[n,d]),y=i.useCallback(x=>{o(x),u(!1),m("")},[o]),b=i.useCallback(x=>{x.key==="Escape"?(u(!1),m("")):x.key==="Enter"&&g.length===1&&y(g[0])},[g,y]);return e.jsxs("div",{ref:f,className:`cedros-token-selector ${d?"cedros-token-selector-open":""} ${n?"cedros-token-selector-disabled":""} ${c}`,onKeyDown:b,children:[e.jsxs("button",{type:"button",className:"cedros-token-selector-trigger",onClick:p,disabled:n,"aria-haspopup":"listbox","aria-expanded":d,children:[t?e.jsxs("span",{className:"cedros-token-selector-selected",children:[t.logoUrl&&e.jsx("img",{src:t.logoUrl,alt:t.symbol,className:"cedros-token-icon",onError:x=>{x.target.style.display="none"}}),e.jsx("span",{className:"cedros-token-symbol",children:t.symbol})]}):e.jsx("span",{className:"cedros-token-selector-placeholder",children:r}),e.jsx("span",{className:"cedros-token-selector-arrow",children:d?"▲":"▼"})]}),d&&e.jsxs("div",{className:"cedros-token-selector-dropdown",role:"listbox",children:[l&&e.jsx("div",{className:"cedros-token-search",children:e.jsx("input",{ref:w,type:"text",value:h,onChange:x=>m(x.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(x=>e.jsxs("button",{type:"button",className:`cedros-token-option ${t?.mint===x.mint?"cedros-token-option-selected":""}`,onClick:()=>y(x),role:"option","aria-selected":t?.mint===x.mint,children:[x.logoUrl&&e.jsx("img",{src:x.logoUrl,alt:x.symbol,className:"cedros-token-icon",onError:v=>{v.target.style.display="none"}}),e.jsxs("span",{className:"cedros-token-info",children:[e.jsx("span",{className:"cedros-token-symbol",children:x.symbol}),e.jsx("span",{className:"cedros-token-name",children:x.name})]}),t?.mint===x.mint&&e.jsx("span",{className:"cedros-token-check",children:"✓"})]},x.mint))})})]})]})}function ts(s,t){return t.privateDepositsEnabled&&s>=t.privateMinUsd?"private":s>=t.publicMinUsd?"public":"sol_micro"}const st="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=",Aa=1e4,Xe=1e3,qr=3;function va(s){return Number.isFinite(s)?`$${Math.round(s)}`:"$0"}function ja(s,t){switch(s){case"private":return{label:"Private",detail:"Private transaction, instant credit",note:null};case"public":return{label:"Public",detail:"Visible on-chain, instant credit",note:null};case"sol_micro":return{label:"SOL Only",detail:`SOL only under ${va(t.solMicroMaxUsd)}`,note:"Small deposits must be sent in SOL and are visible on-chain. Increase the amount to use tokens."}}}function tt(s,t,o){return Math.min(Math.max(s,t),o)}function ka(s,t){if(t<=0)return 0;const o=tt(s/t,0,1);return Math.round(Math.pow(o,1/qr)*Xe)}function Na(s,t){const o=tt(s/Xe,0,1);return t*Math.pow(o,qr)}function zr(s){return s<10?.01:s<100?1:s<500?5:s<1e3?10:s<5e3?25:50}function Ca(s){return s<1?2:0}function Qt(s){const t=zr(s),o=Math.round(s/t)*t,a=Ca(t);return Number(o.toFixed(a))}function rt({config:s,valueUsd:t,onChange:o,maxUsd:a=Aa,disabled:r=!1,className:n=""}){const c=tt(Number.isFinite(t)?t:0,0,a),l=i.useMemo(()=>ts(c,s),[c,s]),d=ja(l,s),u=ka(c,a),h=u/Xe*100;return e.jsxs("div",{className:`cedros-tiered-slider ${n}`,children:[e.jsxs("div",{className:"cedros-tiered-slider-input-row",children:[e.jsxs("div",{className:"cedros-tiered-slider-input",children:[e.jsx("span",{className:"cedros-tiered-slider-currency",children:"$"}),e.jsx("input",{type:"number",value:c||"",onChange:m=>o(Qt(parseFloat(m.target.value)||0)),placeholder:"Enter amount",disabled:r,min:0,step:zr(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-${l}`,children:[l==="sol_micro"&&e.jsx("img",{src:st,alt:"SOL",className:"cedros-tiered-slider-badge-icon"}),d.label]}),e.jsx("span",{className:"cedros-tiered-slider-tier-detail",children:d.detail})]})]}),e.jsx("input",{type:"range",min:0,max:Xe,step:1,value:u,onChange:m=>o(Qt(Na(parseFloat(m.target.value),a))),className:"cedros-tiered-slider-range",style:{background:`linear-gradient(to right, var(--cedros-primary) 0%, var(--cedros-primary) ${h}%, var(--cedros-border) ${h}%, var(--cedros-border) 100%)`},disabled:r,"aria-label":"Deposit amount slider"}),d.note&&e.jsx("div",{className:"cedros-tiered-slider-note",children:d.note})]})}function Sa(s){return s.companyFeePercent>0||s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap"||s.feePolicy==="user_pays_privacy"}function Ea(s,t,o){const{feePolicy:a,privacyFeePercent:r,swapFeePercent:n,companyFeePercent:c}=s;let l=c;return o||(a==="user_pays_all"?(l+=n,t&&(l+=r)):a==="user_pays_privacy"&&t?l+=r:a==="user_pays_swap"&&(l+=n)),l}const Ve=1e9,ke={mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:st},Ne={mint:"other",symbol:"OTHER",name:"Other",decimals:6},Vr=1e4;function La(s,t){const o=t<s.publicMinUsd,a=t>=s.privateMinUsd,r=[],n=!o&&a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(s.privacyFeeFixedLamports>0||s.privacyFeePercent>0),c=!o&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(s.swapFeeFixedLamports>0||s.swapFeePercent>0),l=s.companyFeeFixedLamports>0||s.companyFeePercent>0;if(n){const d=s.privacyFeeFixedLamports/Ve,u=s.privacyFeePercent,h=d*s.solPriceUsd,m=t*(u/100);r.push({label:"Privacy",solAmount:d,percent:u,usdAmount:h+m})}if(c){const d=s.swapFeeFixedLamports/Ve,u=s.swapFeePercent,h=d*s.solPriceUsd,m=t*(u/100);r.push({label:"Swap",solAmount:d,percent:u,usdAmount:h+m})}if(l){const d=s.companyFeeFixedLamports/Ve,u=s.companyFeePercent,h=d*s.solPriceUsd,m=t*(u/100);r.push({label:"Service",solAmount:d,percent:u,usdAmount:h+m})}return r}function Hr(s,t,o){const a=La(s,t),r=o<.01?.01:o;if(a.length===0)return`Total: $${r.toFixed(2)}`;const n=a.reduce((g,p)=>g+p.solAmount,0),c=a.reduce((g,p)=>g+p.percent,0),l={fee:7,sol:8,rate:7,usd:8},d=g=>{const p=g.label.padEnd(l.fee),y=g.solAmount.toFixed(4).padStart(6).padEnd(l.sol),b=(g.percent.toFixed(2)+"%").padStart(5).padEnd(l.rate),x=("$"+Math.max(g.usdAmount,.01).toFixed(2)).padEnd(l.usd);return`${p} │ ${y} │ ${b} │ ${x}`},u=`${"Fee".padEnd(l.fee)} │ ${"SOL".padEnd(l.sol)} │ ${"+ Rate".padEnd(l.rate)} │ ${"= Total".padEnd(l.usd)}`,h=`${"─".repeat(l.fee)}─┼─${"─".repeat(l.sol)}─┼─${"─".repeat(l.rate)}─┼─${"─".repeat(l.usd)}`,m=("$"+r.toFixed(2)).padEnd(l.usd),f=`${"TOTAL".padEnd(l.fee)} │ ${n.toFixed(4).padStart(6).padEnd(l.sol)} │ ${(c.toFixed(2)+"%").padStart(5).padEnd(l.rate)} │ ${m}`;return[u,h,...a.map(d),h,f].join(`
|
|
2059
|
+
`)}function Pa(s){const t=[],o=s.privacyFeeFixedLamports>0||s.privacyFeePercent>0,a=s.swapFeeFixedLamports>0||s.swapFeePercent>0,r=s.companyFeeFixedLamports>0||s.companyFeePercent>0;return o&&t.push("Privacy Cash fee"),a&&t.push("swap fee"),r&&t.push("company service fee"),t.length===0?"No processing fees apply to deposits.":"A small fee may apply. We'll show exact totals before you confirm."}function rs(s,t){if(t<=0)return 0;const o=t<s.publicMinUsd,a=t>=s.privateMinUsd,r=Ea(s,a,o);let n=s.companyFeeFixedLamports;o||(a&&(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_privacy")&&(n+=s.privacyFeeFixedLamports),(s.feePolicy==="user_pays_all"||s.feePolicy==="user_pays_swap")&&(n+=s.swapFeeFixedLamports));const c=n/Ve*s.solPriceUsd,l=t*(r/100);return c+l}function Qr(s,t,o){return s==="sol"?"SOL":s==="single-token"?t.symbol:o.some(r=>r.symbol==="USDC")?"SOL or USDC":"SOL or supported tokens"}function Kt(s){return s.map(t=>t.trim()).filter(Boolean)}const Kr=new Set(["USDC","USDT","USD1","PYUSD","USDH","CASH"]);function Yr(s,t,o){if(Kr.has(s.symbol))return 1;const a=t.tokenPrices?.[s.symbol];if(a&&a>0)return a;if(s.symbol==="SOL")return t.solPriceUsd||null;const r=o?.[s.symbol];return r&&r>0?r:null}function Gr(s,t){const o=Kr.has(t)?2:4;return s.toFixed(o)}function Ma({config:s,currencyMode:t,depositMethod:o,tokens:a=[],defaultToken:r,minAmount:n,maxAmount:c=1e4,onSuccess:l,onError:d,onCancel:u,onUnlockRequired:h,onAuthorize:m,className:f="",showStepIndicator:w=!0,pollInterval:g=5e3,demoMode:p=!1,demoAutoConfirmMs:y,tokenPriceUsd:b,showExplainer:x=!1,siteName:v,explainerConfig:j}){const{deposit:C,getStatus:A,error:N,clearError:S}=Or(),k=I.useWallet(),P=Kt(s.quickActionTokens),L=Kt(s.customTokenSymbols),E=i.useMemo(()=>{const U=s.customTokens??[];if(U.length===0)return a;const q=new Set(a.map(G=>G.symbol)),H=[...a];for(const G of U)q.has(G.symbol)||(H.push({mint:G.mint,symbol:G.symbol,name:G.symbol,decimals:G.decimals,logoUrl:G.logoUrl}),q.add(G.symbol));return H},[a,s.customTokens]),M=i.useMemo(()=>{if(L.length===0)return E;const U=E.filter(q=>L.includes(q.symbol));return U.length>0?U:E},[E,L]),R=s.privateDepositsEnabled,D=o?o==="sign"&&!R?"receive":o:R&&k.hasExternalWallet?"sign":"receive",$=P[0]?E.find(U=>U.symbol===P[0]):void 0,le=t==="sol"?ke:t==="single-token"?$??E.find(U=>U.symbol==="USDC")??E[0]??ke:r??$??E.find(U=>U.symbol==="USDC")??E.find(U=>U.symbol!=="SOL")??E[0]??ke,J=i.useCallback(()=>x?"explainer":"unlock",[x]),[z,B]=i.useState(J),[F,V]=i.useState(le),[X,ee]=i.useState(""),[ue,ce]=i.useState(null),[O,W]=i.useState(null),[K,ne]=i.useState(null),[pe,it]=i.useState(null),[os,Se]=i.useState(!1),[Zr,ns]=i.useState(!1),[Be,lt]=i.useState(null);i.useEffect(()=>{B(J()),V(le),ee(""),ce(null),W(null),ne(null),it(null),Se(!1),ns(!1),lt(null),S()},[t,D,le,S,J]);const eo=n??s.privateMinSol,so=c,Ie=parseFloat(X),ct=k.status==="enrolled_locked"||k.status==="enrolled_unlocked"||k.status==="unlocked",as=ct&&k.isUnlocked,is=ct&&!k.isUnlocked,dt=i.useCallback(()=>{let H=D==="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 x&&(H=[{key:"explainer",label:"Info"},...H]),H},[D,x])(),to=dt.findIndex(U=>U.key===z),ut=i.useCallback(U=>{V(U)},[]),ro=i.useCallback(async U=>{if(!m){B(D==="sign"?"confirm":"show-address");return}ns(!0),W(null);try{const H=await m(U,D==="sign"?Ie:null,F);ne(H.sessionId),it(H.depositAddress),B(D==="sign"?"confirm":"show-address")}catch(q){const H=q instanceof Error?q:new Error("Authorization failed");W(H.message)}finally{ns(!1)}},[m,D,Ie,F]),oo=i.useCallback(async(U,q)=>{S(),W(null),B("signing");const H=U??Ie,G=q??F;if(!p){if(is&&h){h(),B("confirm");return}if(!as){W("Wallet not ready"),B("error");return}}try{const re=Math.floor(H*Math.pow(10,G.decimals));if(p){await new Promise(Ue=>setTimeout(Ue,1500));const Fe={token:t==="sol"?null:G,amount:H,amountSmallestUnit:re,txSignature:`demo-tx-${Date.now()}`,sessionId:K||`demo-session-${Date.now()}`,response:{sessionId:K||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:re,message:"Demo deposit successful",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"sign"};ce(Fe),B("success"),l?.(Fe);return}const se=await C(re),De={token:t==="sol"?null:G,amount:H,amountSmallestUnit:re,txSignature:se.txSignature,sessionId:se.sessionId,response:se,method:"sign"};ce(De),B("success"),l?.(De)}catch(re){const se=re instanceof Error?re:new Error("Deposit failed");W(se.message),B("error"),d?.(se)}},[C,Ie,F,t,p,K,as,is,h,l,d,S]),no=i.useCallback(()=>{B("waiting")},[]),ls=i.useCallback(async()=>{const U=pe||k.solanaPubkey;if(U)try{await navigator.clipboard.writeText(U),Se(!0),setTimeout(()=>Se(!1),2e3)}catch{const q=document.createElement("textarea");q.value=U,document.body.appendChild(q),q.select(),document.execCommand("copy"),document.body.removeChild(q),Se(!0),setTimeout(()=>Se(!1),2e3)}},[pe,k.solanaPubkey]);i.useEffect(()=>{if(!(z==="confirm"||z==="show-address"||z==="waiting")||!K||p)return;let q=!1,H=0;const G=360,re=async()=>{if(!(q||H>=G)){H++;try{const se=await A(K);if(se.status==="completed"||se.status==="detected"){const De=se.amountLamports?se.amountLamports/Math.pow(10,F.decimals):0,Fe=se.amountLamports||0,Ue={token:t==="sol"?null:F,amount:De,amountSmallestUnit:Fe,txSignature:se.txSignature||"",sessionId:K,response:se,method:"receive",depositAddress:k.solanaPubkey??void 0};ce(Ue),B("success"),l?.(Ue);return}}catch{}q||setTimeout(re,g)}};return re(),()=>{q=!0}},[z,K,p,A,F,t,k.solanaPubkey,l,g]),i.useEffect(()=>{if(!p||!y||z!=="waiting"||D!=="receive"||!pe)return;const U=window.setTimeout(()=>{const q=Be??s.privateMinUsd,H=F.symbol==="SOL"&&s.solPriceUsd>0?q/s.solPriceUsd:q,G=Math.floor(H*Math.pow(10,F.decimals)),re={token:t==="sol"?null:F,amount:H,amountSmallestUnit:G,txSignature:`demo-tx-${Date.now()}`,sessionId:K||`demo-session-${Date.now()}`,response:{sessionId:K||`demo-session-${Date.now()}`,txSignature:`demo-tx-${Date.now()}`,amountLamports:G,message:"Demo deposit detected",withdrawalAvailableAt:new Date(Date.now()+1440*60*1e3).toISOString()},method:"receive",depositAddress:pe??void 0};ce(re),B("success"),l?.(re)},y);return()=>window.clearTimeout(U)},[p,y,z,D,pe,Be,s,F,t,K,l]);const ao=i.useCallback(()=>{B(J()),ee(""),ce(null),W(null),S()},[J,S]);return s.enabled?e.jsxs("div",{className:`cedros-deposit-flow ${f}`,children:[w&&z!=="error"&&e.jsx("div",{className:"cedros-deposit-flow-steps",children:dt.map((U,q)=>{const H=to>=q,G=U.key===z;return e.jsxs("div",{className:`cedros-deposit-flow-step-item ${H?"step-active":""}`,children:[e.jsx("div",{className:`cedros-deposit-flow-step-circle ${H?"active":""} ${G?"current":""}`,children:q+1}),e.jsx("span",{className:`cedros-deposit-flow-step-label ${H?"active":""}`,children:U.label})]},U.key)})}),e.jsxs("div",{className:"cedros-deposit-flow-content",children:[z==="explainer"&&e.jsx(Ta,{siteName:v,config:j,depositConfig:s,currencyMode:t,token:F,tokens:M,onContinue:()=>B("unlock"),onCancel:u}),z==="unlock"&&e.jsx(Ra,{token:F,tokens:M,currencyMode:t,depositMethod:D,isAuthorizing:Zr,error:O,onAuthorize:ro,onBack:x?()=>B("explainer"):void 0,onCancel:u}),z==="confirm"&&D==="sign"&&e.jsx(Ba,{token:F,tokens:E,quickActionSymbols:P,customTokenSymbols:L,currencyMode:t,minAmount:eo,maxAmount:so,depositAddress:pe||k.solanaPubkey,walletReady:as||p,needsUnlock:is&&!p,copied:os,isListening:!!K&&!p,config:s,onCopy:ls,onTokenSelect:ut,onUnlockRequired:h,onConfirm:(U,q)=>oo(U,q),onBack:()=>B("unlock"),onCancel:u}),z==="signing"&&e.jsx(Ia,{depositAddress:k.solanaPubkey}),z==="show-address"&&e.jsx(Da,{token:F,tokens:E,quickActionSymbols:P,customTokenSymbols:L,tokenPriceUsd:b,currencyMode:t,depositAddress:pe||k.solanaPubkey,copied:os,isListening:!!K&&!p,config:s,onCopy:ls,onTokenSelect:ut,onAmountChange:lt,onSent:no,onBack:()=>B("unlock"),onCancel:u}),z==="waiting"&&e.jsx(Fa,{token:F,depositAddress:pe||k.solanaPubkey,copied:os,feeLine:Be?`Fees: $${Math.max(rs(s,Be),.01).toFixed(2)} total`:"Fees: calculated after deposit",onCopy:ls}),z==="success"&&ue&&e.jsx(Ua,{result:ue,config:s,onNewDeposit:ao}),z==="error"&&e.jsx(_a,{error:O||N||"An error occurred",onRetry:()=>B("confirm"),onCancel:u})]})]}):e.jsx("div",{className:`cedros-deposit-flow cedros-deposit-flow-disabled ${f}`,children:e.jsx("p",{children:"Deposits are not currently available."})})}function Ta({siteName:s,config:t,depositConfig:o,currencyMode:a,token:r,tokens:n,onContinue:c,onCancel:l}){const d=t?.title??"How Deposits Work",u=t?.exchangeName??"Coinbase",h=Os.sanitizeExternalUrl(t?.exchangeUrl)??"https://www.coinbase.com",m=t?.showExchangeSuggestion!==!1,f=Qr(a,r,n),w=s?`${s} uses the Solana blockchain to process secure, private payments.`:"This site uses the Solana blockchain to process secure, private payments.",g=t?.body??w,p=Sa(o),y=Pa(o);return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:d}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:g}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-content",children:[e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-shield"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Private & Secure"}),e.jsx("p",{children:"Your deposits are protected by cryptographic privacy technology."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-bolt"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Fast Transactions"}),e.jsx("p",{children:"Solana transactions confirm in seconds, not minutes."})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-explainer-item",children:[e.jsx("span",{className:"cedros-deposit-flow-explainer-icon cedros-deposit-flow-icon-coin"}),e.jsxs("div",{children:[e.jsx("strong",{children:p?"Transparent Fees":"Low Fees"}),e.jsx("p",{children:y})]})]})]}),m&&e.jsx("div",{className:"cedros-deposit-flow-explainer-exchange",children:e.jsxs("p",{className:"cedros-deposit-flow-explainer-exchange-text",children:[e.jsx("strong",{children:"New to Solana?"})," You can purchase ",f," using your credit card at"," ",e.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:u}),", then send it here to fund your account."]})}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[l&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:l,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:c,children:"Continue"})]})]})}function Ra({token:s,tokens:t,currencyMode:o,depositMethod:a,isAuthorizing:r,error:n,onAuthorize:c,onBack:l}){const[d,u]=i.useState(""),h=Qr(o,s,t),m=f=>{f.preventDefault(),d.trim()&&c(d)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Authorize Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:a==="sign"?o==="multi-token"?"Enter your password to authorize a deposit. This allows us to process your withdrawal when the privacy period ends.":`Enter your password to authorize a ${h} deposit. This allows us to process your withdrawal when the privacy period ends.`:o==="multi-token"?"Enter your password to get your deposit address. Any supported token sent to this address will be credited to your account.":`Enter your password to get your deposit address. Any ${h} sent to this address will be credited to your account.`}),e.jsxs("form",{onSubmit:m,children:[e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",htmlFor:"deposit-password",children:"Password"}),e.jsx("input",{id:"deposit-password",type:"password",value:d,onChange:f=>u(f.target.value),className:"cedros-deposit-flow-input",placeholder:"Enter your password",disabled:r,autoComplete:"current-password"})]}),n&&e.jsx("p",{className:"cedros-deposit-flow-error",children:n}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:l,disabled:r,children:"Back"}),e.jsx("button",{type:"submit",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",disabled:!d.trim()||r,children:r?"Authorizing...":"Continue"})]})]})]})}function Ba({token:s,tokens:t,quickActionSymbols:o,customTokenSymbols:a,currencyMode:r,minAmount:n,maxAmount:c,depositAddress:l,walletReady:d,needsUnlock:u,copied:h,isListening:m,config:f,onCopy:w,onTokenSelect:g,onUnlockRequired:p,onConfirm:y,onBack:b}){const[x,v]=i.useState(f.privateMinUsd),[j,C]=i.useState(!1),[A,N]=i.useState(!1),[S,k]=i.useState(0),[P,L]=i.useState(null),M=ts(x,f)==="sol_micro",R=s.symbol===Ne.symbol,D=i.useMemo(()=>{const O=a.length===0?t:t.filter(ne=>a.includes(ne.symbol)),W=O.length>0?O:t;return W.some(ne=>ne.symbol===Ne.symbol)?W:[...W,Ne]},[t,a]),$=rs(f,x),le=$<.01?.01:$,J=R?"Fees: calculated after deposit":`Fees: $${le.toFixed(2)} total`,z=R?"":Hr(f,x,$),B=Yr(M?ke:s,f),F=B?x/B:s.symbol==="SOL"&&f.solPriceUsd>0?x/f.solPriceUsd:x,V=F?Gr(F,M?"SOL":s.symbol):null,ee=x-$<=0&&x>0,ue=!R&&x>0&&!ee&&F>=n&&F<=c;i.useEffect(()=>{if(r==="multi-token")if(M&&s.symbol!=="SOL"){L(s);const O=t.find(W=>W.symbol==="SOL");O&&g(O)}else!M&&P&&s.symbol==="SOL"&&(g(P),L(null))},[M,s.symbol,r,t,g,P,s]);const ce=()=>{ue&&y(F,s)};return e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Choose Amount"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Set how much you want to deposit. Higher tiers unlock privacy."}),r==="multi-token"&&!M&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[o.map(O=>{const W=t.find(ne=>ne.symbol===O),K=s.symbol===O;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${K?"is-active":""}`,onClick:()=>{W&&(C(!1),g(W))},disabled:!W,children:[W?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:W.logoUrl,alt:`${O} logo`}),O]},O)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${j?"is-active":""}`,onClick:()=>{C(!0),k(O=>O+1)},children:"Custom"})]}),j&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(et,{tokens:D,selectedToken:s,onSelect:g,openSignal:S})})]}),e.jsx("div",{className:"cedros-deposit-flow-field",children:e.jsx(rt,{config:f,valueUsd:x,onChange:v,maxUsd:Vr})}),e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:R?"Sign to send tokens to this address":`Sign to send ${V??"--"} ${M?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:l||"Loading..."}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:w,title:"Copy address",disabled:!l,children:h?"✓":"⧉"}),l&&e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${l}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]}),h&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),ee&&e.jsx("div",{className:"cedros-deposit-flow-warning",children:e.jsx("p",{children:"Deposit amount is less than the fees. Increase the amount to proceed."})}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[J,e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${A?"is-open":""}`,"data-tooltip":z,"aria-label":`Fee breakdown: ${z.replaceAll(`
|
|
2060
|
+
`,", ")}`,"aria-expanded":A,onClick:O=>{O.stopPropagation(),N(W=>!W)},onBlur:()=>N(!1),onKeyDown:O=>{O.key==="Escape"&&N(!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."})]})]}),m&&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:b,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:ce,disabled:!ue||!d||!l,children:"Deposit"})]})]})}function Ia({depositAddress:s}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Signing Transfer"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Approve the transfer in your wallet extension..."}),s&&e.jsxs("p",{className:"cedros-deposit-flow-signing-dest",children:["Sending to:"," ",e.jsxs("code",{children:[s.slice(0,6),"...",s.slice(-4)]})]})]})}function Da({token:s,tokens:t,quickActionSymbols:o,customTokenSymbols:a,tokenPriceUsd:r,currencyMode:n,depositAddress:c,copied:l,isListening:d,config:u,onCopy:h,onTokenSelect:m,onAmountChange:f,onSent:w,onBack:g}){const[p,y]=i.useState(u.privateMinUsd),[b,x]=i.useState(!1),[v,j]=i.useState(!1),[C,A]=i.useState(0),[N,S]=i.useState(null),P=ts(p,u)==="sol_micro",L=s.symbol===Ne.symbol,E=i.useMemo(()=>{const F=a.length===0?t:t.filter(ee=>a.includes(ee.symbol)),V=F.length>0?F:t;return V.some(ee=>ee.symbol===Ne.symbol)?V:[...V,Ne]},[t,a]),M=rs(u,p),R=M<.01?.01:M,D=L?"Fees: calculated after deposit":`Fees: $${R.toFixed(2)} total`,$=L?"":Hr(u,p,M),le=L||p>0,J=Yr(P?ke:s,u,r),z=J?p/J:null,B=z?Gr(z,s.symbol):null;return i.useEffect(()=>{if(n==="multi-token")if(P&&s.symbol!=="SOL"){S(s);const F=t.find(V=>V.symbol==="SOL");F&&m(F)}else!P&&N&&s.symbol==="SOL"&&(m(N),S(null))},[P,s.symbol,n,t,m,N,s]),i.useEffect(()=>{f(p)},[p,f]),c?e.jsxs("div",{className:"cedros-deposit-flow-step",children:[e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Send Deposit"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Send funds to your deposit address. We'll confirm automatically."}),n==="multi-token"&&!P&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Token"}),e.jsxs("div",{className:"cedros-deposit-flow-token-quick",children:[o.map(F=>{const V=t.find(ee=>ee.symbol===F),X=s.symbol===F;return e.jsxs("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${X?"is-active":""}`,onClick:()=>{V&&(x(!1),m(V))},disabled:!V,children:[V?.logoUrl&&e.jsx("img",{className:"cedros-deposit-flow-token-quick-icon",src:V.logoUrl,alt:`${F} logo`}),F]},F)}),e.jsx("button",{type:"button",className:`cedros-deposit-flow-token-quick-btn ${b?"is-active":""}`,onClick:()=>{x(!0),A(F=>F+1)},children:"Custom"})]}),b&&e.jsx("div",{className:"cedros-deposit-flow-token-custom",children:e.jsx(et,{tokens:E,selectedToken:s,onSelect:m,openSignal:C})})]}),!L&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit Amount"}),e.jsx(rt,{config:u,valueUsd:p,onChange:y,maxUsd:Vr})]}),L&&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:L?"Send any token to this address":`Send ${B??"--"} ${P?"SOL":s.symbol} to this address`}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsx("code",{className:"cedros-deposit-flow-address",children:c}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn",onClick:h,title:"Copy address",children:l?"✓":"📋"})]}),l&&e.jsx("p",{className:"cedros-deposit-flow-copied-msg",children:"Copied!"})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsxs("span",{children:[D,!L&&e.jsx("button",{type:"button",className:`cedros-deposit-flow-fee-info ${v?"is-open":""}`,"data-tooltip":$,"aria-label":`Fee breakdown: ${$.replaceAll(`
|
|
2061
|
+
`,", ")}`,"aria-expanded":v,onClick:F=>{F.stopPropagation(),j(V=>!V)},onBlur:()=>j(!1),onKeyDown:F=>{F.key==="Escape"&&j(!1)},children:"i"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Credits appear after confirmation (typically ~30s)."})]})]}),d&&e.jsx("div",{className:"cedros-deposit-flow-info-banner",children:"Listening for your deposit. We'll notify you when it arrives."}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:g,children:"Back"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:w,disabled:!le,children:"I've Sent It"})]})]}):e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"!"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Wallet Not Ready"}),e.jsx("p",{className:"cedros-deposit-flow-step-desc",children:"Your embedded wallet is not set up. Please complete wallet enrollment first."})]})}function Fa({token:s,depositAddress:t,copied:o,feeLine:a,onCopy:r}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-spinner"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Waiting for Deposit"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Looking for incoming ",e.jsx("strong",{children:s.symbol})," deposits..."]}),e.jsxs("div",{className:"cedros-deposit-flow-waiting-info",children:[e.jsx("p",{className:"cedros-deposit-flow-waiting-text",children:"Once your transaction is confirmed on the Solana network, your account will be credited automatically. This usually takes 20-30 seconds."}),t&&e.jsxs("div",{className:"cedros-deposit-flow-field",children:[e.jsx("label",{className:"cedros-deposit-flow-label",children:"Deposit address"}),e.jsxs("div",{className:"cedros-deposit-flow-address-box",children:[e.jsxs("code",{className:"cedros-deposit-flow-address",children:[t.slice(0,6),"...",t.slice(-6)]}),e.jsxs("div",{className:"cedros-deposit-flow-address-actions",children:[e.jsx("button",{type:"button",className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-icon",onClick:r,title:"Copy address",children:o?"✓":"⧉"}),e.jsx("a",{className:"cedros-deposit-flow-copy-btn cedros-deposit-flow-copy-link cedros-deposit-flow-copy-icon",href:`https://orbmarkets.io/account/${t}`,target:"_blank",rel:"noopener noreferrer",title:"View on Orb Markets",children:"↗"})]})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-stack",children:[e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:"Send only on the Solana network."})]}),e.jsxs("div",{className:"cedros-deposit-flow-info-item",children:[e.jsx("span",{className:"cedros-deposit-flow-info-dot"}),e.jsx("span",{children:a})]})]})]})]})}function Ua({result:s,config:t,onNewDeposit:o}){const a=s.token??ke,r=a.symbol==="SOL"&&t.solPriceUsd>0?s.amount*t.solPriceUsd:s.amount,n=rs(t,r),c=Math.max(r-n,0),l=n<.01?.01:n;return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-success-icon",children:"✓"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Successful!"}),e.jsxs("p",{className:"cedros-deposit-flow-step-desc",children:["Your deposit of ",s.amount.toLocaleString()," ",a.symbol," has been received."]}),e.jsxs("div",{className:"cedros-deposit-flow-summary",children:[e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Transaction"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-tx",children:[e.jsxs("a",{href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer",children:[s.txSignature.slice(0,8),"...",s.txSignature.slice(-8)]}),e.jsx("a",{className:"cedros-deposit-flow-tx-action",href:`https://orbmarkets.io/tx/${s.txSignature}`,target:"_blank",rel:"noopener noreferrer","aria-label":"View transaction on Orb Markets",title:"View transaction",children:"↗"})]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Deposit Amount"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value",children:["$",r.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Total Fees"}),e.jsxs("span",{className:"cedros-deposit-flow-summary-value cedros-deposit-flow-fee",children:["-$",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:["+$",c.toFixed(2)]})]}),e.jsxs("div",{className:"cedros-deposit-flow-summary-row",children:[e.jsx("span",{className:"cedros-deposit-flow-summary-label",children:"Available"}),e.jsx("span",{className:"cedros-deposit-flow-summary-value",children:"Immediately"})]})]}),e.jsx("div",{className:"cedros-deposit-flow-actions",children:e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:o,children:"Make Another Deposit"})})]})}function _a({error:s,onRetry:t,onCancel:o}){return e.jsxs("div",{className:"cedros-deposit-flow-step cedros-deposit-flow-step-centered",children:[e.jsx("div",{className:"cedros-deposit-flow-error-icon",children:"✕"}),e.jsx("h4",{className:"cedros-deposit-flow-step-title",children:"Deposit Failed"}),e.jsx("p",{className:"cedros-deposit-flow-error-message",children:s}),e.jsxs("div",{className:"cedros-deposit-flow-actions",children:[o&&e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-secondary",onClick:o,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-deposit-flow-button cedros-deposit-flow-button-primary",onClick:t,children:"Try Again"})]})]})}const Wa="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=",Oa="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==",qa="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",za="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==",Va="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==",Ha="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==",Qa="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",Ka="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",Ya="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",$r=[{mint:"So11111111111111111111111111111111111111112",symbol:"SOL",name:"Solana",decimals:9,logoUrl:st},{mint:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",symbol:"USDC",name:"Circle USD",decimals:6,logoUrl:Ha},{mint:"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",symbol:"USDT",name:"Tether USD",decimals:6,logoUrl:Ya},{mint:"HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr",symbol:"EURC",name:"Circle Euro",decimals:6,logoUrl:qa},{mint:"USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB",symbol:"USD1",name:"WLFI USD",decimals:6,logoUrl:Ka},{mint:"2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo",symbol:"PYUSD",name:"PayPal USD",decimals:6,logoUrl:Va},{mint:"USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",symbol:"USDH",name:"Hubble USD",decimals:6,logoUrl:Qa},{mint:"CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT",symbol:"CASH",name:"Stripe USD",decimals:6,logoUrl:Oa},{mint:"DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",symbol:"BONK",name:"Bonk",decimals:5,logoUrl:Wa},{mint:"oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp",symbol:"ORE",name:"Ore",decimals:11,logoUrl:za}];function ot(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(!1),[a,r]=i.useState(null),n=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),c=i.useCallback(()=>{r(null)},[]),l=i.useCallback(async()=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{return await n.get("/credits/balance/sol")}catch(h){const m=T.handleApiError(h,"Failed to fetch credit balance");throw r(m.message),m}finally{o(!1)}},[n]),d=i.useCallback(async()=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{return(await n.get("/credits/balance")).balances}catch(h){const m=T.handleApiError(h,"Failed to fetch credit balances");throw r(m.message),m}finally{o(!1)}},[n]),u=i.useCallback(async h=>{if(!n)throw new Error("useCredits must be used within a CedrosLoginProvider");o(!0),r(null);try{const m=new URLSearchParams;h?.currency&&m.set("currency",h.currency),h?.limit&&m.set("limit",h.limit.toString()),h?.offset&&m.set("offset",h.offset.toString());const f=m.toString(),w=f?`/credits/history?${f}`:"/credits/history";return await n.get(w)}catch(m){const f=T.handleApiError(m,"Failed to fetch transaction history");throw r(f.message),f}finally{o(!1)}},[n]);return{getBalance:l,getAllBalances:d,getHistory:u,isLoading:t,error:a,clearError:c}}function Ga({showAllCurrencies:s=!1,refreshInterval:t=0,compact:o=!1,className:a="",onLoad:r}){const{getBalance:n,getAllBalances:c,isLoading:l,error:d,clearError:u}=ot(),[h,m]=i.useState([]),[f,w]=i.useState(null),g=i.useCallback(async()=>{try{if(s){const p=await c();m(p),r?.(p)}else{const p=await n();m([p]),r?.([p])}w(null)}catch(p){w(p instanceof Error?p.message:"Failed to load balance")}},[s,n,c,r]);if(i.useEffect(()=>{g()},[g]),i.useEffect(()=>{if(t<=0)return;const p=setInterval(g,t);return()=>clearInterval(p)},[t,g]),f||d)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-error ${a}`,children:[e.jsx("p",{className:"cedros-credit-error",children:f||d}),e.jsx("button",{type:"button",className:"cedros-credit-retry",onClick:()=>{u(),w(null),g()},children:"Retry"})]});if(l&&h.length===0)return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-loading ${a}`,children:[e.jsx("span",{className:"cedros-credit-loading-indicator"}),e.jsx("span",{className:"cedros-credit-loading-text",children:"Loading balance..."})]});if(o){const p=h[0];return e.jsxs("div",{className:`cedros-credit-balance cedros-credit-balance-compact ${a}`,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"}),l&&e.jsx("span",{className:"cedros-credit-refresh-indicator",title:"Refreshing..."})]})}return e.jsxs("div",{className:`cedros-credit-balance ${a}`,children:[e.jsxs("div",{className:"cedros-credit-header",children:[e.jsx("h4",{className:"cedros-credit-title",children:"Credit Balance"}),e.jsx("button",{type:"button",className:"cedros-credit-refresh",onClick:g,disabled:l,title:"Refresh balance",children:l?"...":"↻"})]}),h.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:h.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 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 $a(s,t){const o=s<0,a=Math.abs(s),r=t.toUpperCase()==="SOL",c=a/Math.pow(10,r?9:6),l=o?"-":"+";return r?`${l}${c.toFixed(4)} SOL`:`${l}$${c.toFixed(2)}`}function Ja(s){const t=new Date(s),o=new Date,a=o.getTime()-t.getTime(),r=Math.floor(a/(1e3*60*60*24));if(r===0){const n=Math.floor(a/36e5);if(n===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${n}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==o.getFullYear()?"numeric":void 0})}function Xa(s){return s?{deposit:"Deposit",spend:"Usage",usage:"Usage",charge:"Charge",refund:"Refund",adjustment:"Adjustment",bonus:"Bonus",credit:"Credit"}[s.toLowerCase()]||s:"Transaction"}function Za(s,t){const o=(s||"").toLowerCase();return o==="deposit"?"↓":o==="spend"||o==="usage"||o==="charge"?"↑":o==="refund"?"←":o==="bonus"||o==="credit"?"★":t?"+":"−"}function ei({defaultTab:s="all",pageSize:t=10,refreshInterval:o=0,className:a="",onLoad:r,onTransactionClick:n}){const{getHistory:c,isLoading:l,error:d,clearError:u}=ot(),[h,m]=i.useState(s),[f,w]=i.useState([]),[g,p]=i.useState(0),[y,b]=i.useState(0),[x,v]=i.useState(null),j=Bs.find(E=>E.key===h)||Bs[0],C=i.useMemo(()=>j.txTypes===null?f:f.filter(E=>{const M=E.txType||"";return j.txTypes.some(R=>M.toLowerCase().includes(R.toLowerCase()))}),[f,j.txTypes]),A=i.useCallback(async()=>{try{const E=await c({limit:t*3,offset:y});w(E.transactions),p(E.total),r?.(E),v(null)}catch(E){v(E instanceof Error?E.message:"Failed to load history")}},[t,y,c,r]);i.useEffect(()=>{b(0)},[h]),i.useEffect(()=>{A()},[A]),i.useEffect(()=>{if(o<=0)return;const E=setInterval(A,o);return()=>clearInterval(E)},[o,A]);const N=Math.ceil(g/t),S=Math.floor(y/t)+1,k=E=>{const M=(E-1)*t;b(Math.max(0,Math.min(M,Math.max(0,g-1))))},P=E=>{m(E)};if(x||d)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-error ${a}`,children:[e.jsx("p",{className:"cedros-tx-error",children:x||d}),e.jsx("button",{type:"button",className:"cedros-tx-retry",onClick:()=>{u(),v(null),A()},children:"Retry"})]});if(l&&f.length===0)return e.jsxs("div",{className:`cedros-tx-history cedros-tx-history-loading ${a}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading transactions..."})]});const L=E=>E.txTypes===null?f.length:f.filter(M=>{const R=M.txType||"";return E.txTypes.some(D=>R.toLowerCase().includes(D.toLowerCase()))}).length;return e.jsxs("div",{className:`cedros-tx-history ${a}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Transaction History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:A,disabled:l,title:"Refresh",children:l?"...":"↻"})]}),e.jsx("div",{className:"cedros-tx-tabs",children:Bs.map(E=>{const M=L(E),R=h===E.key;return e.jsxs("button",{type:"button",className:`cedros-tx-tab ${R?"cedros-tx-tab-active":""}`,onClick:()=>P(E.key),children:[E.label,M>0&&e.jsx("span",{className:"cedros-tx-tab-count",children:M})]},E.key)})}),C.length===0?e.jsxs("div",{className:"cedros-tx-empty",children:[e.jsx("p",{className:"cedros-tx-empty-message",children:h==="all"?"No transactions yet.":`No ${j.label.toLowerCase()} found.`}),h==="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:C.slice(0,t).map(E=>{const M=E.amountLamports>=0;return e.jsxs("div",{className:`cedros-tx-item ${M?"cedros-tx-item-positive":"cedros-tx-item-negative"}`,onClick:()=>n?.(E),onKeyDown:R=>{(R.key==="Enter"||R.key===" ")&&(R.preventDefault(),n?.(E))},role:n?"button":void 0,tabIndex:n?0:void 0,children:[e.jsx("div",{className:`cedros-tx-icon ${M?"cedros-tx-icon-positive":"cedros-tx-icon-negative"}`,children:Za(E.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:Xa(E.txType)}),e.jsx("span",{className:`cedros-tx-amount ${M?"cedros-tx-amount-positive":"cedros-tx-amount-negative"}`,children:$a(E.amountLamports,E.currency)})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsx("span",{className:"cedros-tx-description",children:E.description}),e.jsx("span",{className:"cedros-tx-date",children:Ja(E.createdAt)})]})]})]},E.id)})}),N>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>k(S-1),disabled:S<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",S," of ",N]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>k(S+1),disabled:S>=N,children:"Next"})]})]})]})}function nt(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(!1),[a,r]=i.useState(null),[n,c]=i.useState(null),l=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=i.useCallback(()=>{r(null)},[]),u=i.useCallback(async()=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{return await l.get("/wallet/withdraw/balances")}catch(w){const g=T.handleApiError(w,"Failed to fetch wallet balances");throw r(g.message),g}},[l]),h=i.useCallback(async(w,g)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");o(!0),r(null);try{const p=await l.post("/wallet/withdraw/sol",{destination:w,amount_lamports:g});return c(p),p}catch(p){const y=T.handleApiError(p,"Failed to withdraw SOL");throw r(y.message),y}finally{o(!1)}},[l]),m=i.useCallback(async(w,g,p)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");o(!0),r(null);try{const y=await l.post("/wallet/withdraw/spl",{destination:w,token_mint:g,amount:p});return c(y),y}catch(y){const b=T.handleApiError(y,"Failed to withdraw token");throw r(b.message),b}finally{o(!1)}},[l]),f=i.useCallback(async(w=10,g=0)=>{if(!l)throw new Error("useWithdrawal must be used within a CedrosLoginProvider");try{const p=Math.max(1,Math.min(100,Math.trunc(w))),y=Math.max(0,Math.trunc(g)),b=new URLSearchParams({limit:String(p),offset:String(y)});return await l.get(`/wallet/withdraw/history?${b}`)}catch(p){const y=T.handleApiError(p,"Failed to fetch withdrawal history");throw r(y.message),y}},[l]);return{withdrawSol:h,withdrawSpl:m,getBalances:u,getHistory:f,isSubmitting:t,error:a,clearError:d,lastResult:n}}const Is="So11111111111111111111111111111111111111112",si={EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v:"USDC",Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB:"USDT",HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr:"EURC",USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB:"USD1","2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo":"PYUSD",USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX:"USDH",CASHVDm2wsJXfhj6VWxb7GiMdoLc17Du7paH4bNr5woT:"CASH",DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263:"BONK",oreoU2P8bN6jkk3jbaiVxYnG1dCXcYxwhwyK9jSybcp:"ORE"};function ti(s){return s.length<32||s.length>50?!1:/^[1-9A-HJ-NP-Za-km-z]+$/.test(s)}function Ds(s){return s.length<=16?s:`${s.slice(0,6)}...${s.slice(-6)}`}function qe(s,t){return(Number(s)/Math.pow(10,t)).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:Math.min(t,6)})}function ri({onSuccess:s,onError:t,onCancel:o,className:a=""}){const r=T.useCedrosLoginOptional(),{withdrawSol:n,withdrawSpl:c,getBalances:l,isSubmitting:d,error:u,clearError:h}=nt(),[m,f]=i.useState("loading"),[w,g]=i.useState([]),[p,y]=i.useState(null),[b,x]=i.useState(""),[v,j]=i.useState(""),[C,A]=i.useState(null),[N,S]=i.useState(null),[k,P]=i.useState(null),L=r?.config.solana?.network??"mainnet-beta",E=i.useMemo(()=>{if(!C?.txSignature)return"";const B=`https://explorer.solana.com/tx/${C.txSignature}`;return L==="mainnet-beta"?B:`${B}?cluster=${encodeURIComponent(L)}`},[C,L]),M=i.useMemo(()=>{if(!p||!v)return"0";const B=parseFloat(v);return isNaN(B)||B<=0?"0":Math.floor(B*Math.pow(10,p.decimals)).toString()},[v,p]);i.useEffect(()=>{if(!r)return;let B=!1;return(async()=>{try{const F=await l();if(B)return;const V=[];F.solLamports>0&&V.push({symbol:"SOL",mint:Is,decimals:9,rawBalance:String(F.solLamports),displayBalance:qe(String(F.solLamports),9)});for(const X of F.tokens){const ee=si[X.mint]??Ds(X.mint);V.push({symbol:ee,mint:X.mint,decimals:X.decimals,rawBalance:X.amount,displayBalance:qe(X.amount,X.decimals)})}g(V),f((V.length>0,"select"))}catch{B||(P("Failed to load wallet balances"),f("select"))}})(),()=>{B=!0}},[r,l]);const R=i.useCallback(B=>{y(B),f("form"),h(),S(null),j("")},[h]),D=i.useCallback(()=>{if(!p)return;const B=Number(p.rawBalance)/Math.pow(10,p.decimals);p.mint===Is?j(String(Math.max(0,B-.01))):j(String(B))},[p]),$=i.useCallback(()=>{if(S(null),!b.trim()){S("Destination address is required");return}if(!ti(b.trim())){S("Invalid Solana address");return}if(!v||parseFloat(v)<=0||isNaN(parseFloat(v))){S("Please enter a valid amount");return}if(M==="0"){S("Amount is too small");return}f("confirm")},[b,v,M]),le=i.useCallback(async()=>{if(p){f("processing"),h();try{let B;p.mint===Is?B=await n(b.trim(),Number(M)):B=await c(b.trim(),p.mint,M),A(B),f("success"),s?.(B)}catch(B){f("confirm"),t?.(B instanceof Error?B:new Error(String(B)))}}},[p,b,M,n,c,h,s,t]),J=i.useCallback(()=>{h(),S(null),m==="form"?(f("select"),y(null),j(""),x("")):m==="confirm"&&f("form")},[m,h]),z=i.useCallback(()=>{f("select"),y(null),x(""),j(""),A(null),h(),S(null)},[h]);return r?e.jsxs("div",{className:`cedros-withdrawal ${a}`,children:[m==="loading"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(_.LoadingSpinner,{}),e.jsx("p",{className:"cedros-withdrawal-processing-text",children:"Loading wallet balances..."})]}),m==="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"})]}),k&&e.jsx(Y.ErrorMessage,{error:k}),w.length===0&&!k&&e.jsx("p",{className:"cedros-withdrawal-empty",children:"No tokens found in your wallet."}),e.jsx("div",{className:"cedros-withdrawal-tokens",children:w.map(B=>e.jsxs("button",{type:"button",className:"cedros-withdrawal-token-pill",onClick:()=>R(B),children:[e.jsx("span",{className:"cedros-withdrawal-token-symbol",children:B.symbol}),e.jsx("span",{className:"cedros-withdrawal-token-balance",children:B.displayBalance})]},B.mint))}),o&&e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-withdrawal-cancel",onClick:o,children:"Cancel"})]}),m==="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:J,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:b,onChange:B=>x(B.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:v,onChange:B=>j(B.target.value),min:"0",step:"any"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-ghost cedros-button-sm",onClick:D,children:"Max"})]})]}),(N||u)&&e.jsx(Y.ErrorMessage,{error:N||u||""}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary cedros-withdrawal-submit",onClick:$,children:"Review Withdrawal"})]}),m==="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:J,disabled:d,children:"Back"}),e.jsx("h3",{className:"cedros-withdrawal-title",children:"Confirm Withdrawal"})]}),e.jsxs("div",{className:"cedros-withdrawal-summary",children:[e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Token"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children: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:[qe(M,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:b,children:Ds(b)})]}),e.jsxs("div",{className:"cedros-withdrawal-summary-row",children:[e.jsx("span",{className:"cedros-withdrawal-summary-label",children:"Est. Fee"}),e.jsx("span",{className:"cedros-withdrawal-summary-value",children:"~0.000005 SOL"})]})]}),u&&e.jsx(Y.ErrorMessage,{error:u}),e.jsxs("div",{className:"cedros-withdrawal-actions",children:[e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline",onClick:J,disabled:d,children:"Cancel"}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-primary",onClick:le,disabled:d,children:d?"Sending...":"Confirm & Send"})]})]}),m==="processing"&&e.jsxs("div",{className:"cedros-withdrawal-processing",children:[e.jsx(_.LoadingSpinner,{}),e.jsxs("p",{className:"cedros-withdrawal-processing-text",children:["Sending ",p?.symbol,"..."]})]}),m==="success"&&C&&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:[qe(M,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:E,target:"_blank",rel:"noreferrer",children:Ds(C.txSignature)})]}),e.jsx("button",{type:"button",className:"cedros-button cedros-button-outline cedros-withdrawal-done",onClick:z,children:"Done"})]})]}):null}function oi(s,t){if(s==="sol")return"SOL";if(!t)return"SPL";const o=$r.find(a=>a.mint===t);return o?o.symbol:`${t.slice(0,4)}...${t.slice(-4)}`}function ni(s){return s.length<=12?s:`${s.slice(0,4)}...${s.slice(-4)}`}function ai(s){const t=new Date(s),o=new Date,a=o.getTime()-t.getTime(),r=Math.floor(a/(1e3*60*60*24));if(r===0){const n=Math.floor(a/36e5);if(n===0){const c=Math.floor(a/6e4);return c<1?"Just now":`${c}m ago`}return`${n}h ago`}return r===1?"Yesterday":r<7?`${r}d ago`:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:t.getFullYear()!==o.getFullYear()?"numeric":void 0})}function ii({pageSize:s=10,className:t="",onTransactionClick:o,explorerUrl:a="https://solscan.io"}){const{getHistory:r,error:n,clearError:c}=nt(),[l,d]=i.useState([]),[u,h]=i.useState(0),[m,f]=i.useState(0),[w,g]=i.useState(!1),[p,y]=i.useState(null),b=i.useCallback(async()=>{g(!0);try{const C=await r(s,m);d(C.items),h(C.total),y(null)}catch(C){y(C instanceof Error?C.message:"Failed to load withdrawal history")}finally{g(!1)}},[s,m,r]);i.useEffect(()=>{b()},[b]);const x=Math.ceil(u/s),v=Math.floor(m/s)+1,j=C=>{const A=(C-1)*s;f(Math.max(0,Math.min(A,Math.max(0,u-1))))};return p||n?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-error ${t}`,children:[e.jsx("p",{className:"cedros-withdrawal-error",children:p||n}),e.jsx("button",{type:"button",className:"cedros-withdrawal-retry",onClick:()=>{c(),y(null),b()},children:"Retry"})]}):w&&l.length===0?e.jsxs("div",{className:`cedros-withdrawal-history cedros-withdrawal-history-loading ${t}`,children:[e.jsx("span",{className:"cedros-tx-loading-indicator"}),e.jsx("span",{className:"cedros-tx-loading-text",children:"Loading withdrawal history..."})]}):e.jsxs("div",{className:`cedros-withdrawal-history ${t}`,children:[e.jsxs("div",{className:"cedros-tx-header",children:[e.jsx("h4",{className:"cedros-tx-title",children:"Withdrawal History"}),e.jsx("button",{type:"button",className:"cedros-tx-refresh",onClick:b,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(C=>{const A=oi(C.tokenType,C.tokenMint);return e.jsxs("div",{className:"cedros-tx-item cedros-tx-item-negative",onClick:()=>o?.(C),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),o?.(C))},role:o?"button":void 0,tabIndex:o?0:void 0,children:[e.jsx("div",{className:"cedros-tx-icon cedros-tx-icon-negative",children:"↑"}),e.jsxs("div",{className:"cedros-tx-content",children:[e.jsxs("div",{className:"cedros-tx-row-main",children:[e.jsxs("span",{className:"cedros-tx-type",children:[A," Withdrawal"]}),e.jsxs("span",{className:"cedros-tx-amount cedros-tx-amount-negative",children:[C.amount," ",A==="SOL"?"lamports":""]})]}),e.jsxs("div",{className:"cedros-tx-row-details",children:[e.jsxs("span",{className:"cedros-tx-description",children:["To"," ",e.jsx("a",{href:`${a}/account/${C.destination}`,target:"_blank",rel:"noopener noreferrer",onClick:N=>N.stopPropagation(),children:ni(C.destination)})," · ",e.jsx("a",{href:`${a}/tx/${C.txSignature}`,target:"_blank",rel:"noopener noreferrer",onClick:N=>N.stopPropagation(),children:"tx"})]}),e.jsx("span",{className:"cedros-tx-date",children:ai(C.createdAt)})]})]})]},C.id)})}),x>1&&e.jsxs("div",{className:"cedros-tx-pagination",children:[e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>j(v-1),disabled:v<=1,children:"Previous"}),e.jsxs("span",{className:"cedros-tx-page-info",children:["Page ",v," of ",x]}),e.jsx("button",{type:"button",className:"cedros-tx-page-btn",onClick:()=>j(v+1),disabled:v>=x,children:"Next"})]})]})]})}function li({brandLogo:s,brandName:t,title:o="Welcome back",subtitle:a="Login with your Apple or Google account",termsText:r,onSuccess:n,defaultTab:c="login",children:l,className:d=""}){return e.jsxs("div",{className:`cedros-full-page-layout ${d}`,children:[(s||t)&&e.jsxs("div",{className:"cedros-brand-header",children:[s,t&&e.jsx("span",{className:"cedros-brand-name",children:t})]}),e.jsxs("div",{className:"cedros-full-page-card",children:[e.jsxs("div",{className:"cedros-full-page-header",children:[e.jsx("h1",{className:"cedros-full-page-title",children:o}),a&&e.jsx("p",{className:"cedros-full-page-subtitle",children:a})]}),l??e.jsx(ss,{defaultTab:c,onSuccess:n})]}),r&&e.jsx("p",{className:"cedros-terms-footer",children:r})]})}function ci({brandName:s="Your Brand",brandLogo:t,tagline:o="Your tagline goes here. Make it compelling.",title:a="Sign in",subtitle:r="Enter your credentials to access your account",onSuccess:n,defaultTab:c="login",children:l,className:d=""}){return e.jsxs("div",{className:`cedros-split-page-layout ${d}`,children:[e.jsx("div",{className:"cedros-split-page-brand",children:e.jsxs("div",{className:"cedros-split-page-brand-content",children:[t??e.jsx("div",{className:"cedros-split-page-logo",children:s.charAt(0).toUpperCase()}),e.jsx("h1",{className:"cedros-split-page-brand-name",children:s}),o&&e.jsx("p",{className:"cedros-split-page-tagline",children:o})]})}),e.jsx("div",{className:"cedros-split-page-form",children:e.jsxs("div",{className:"cedros-split-page-form-content",children:[e.jsx("h2",{className:"cedros-split-page-title",children:a}),r&&e.jsx("p",{className:"cedros-split-page-subtitle",children:r}),l??e.jsx(ss,{defaultTab:c,onSuccess:n})]})})]})}function di(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState({allowed:!1,reason:void 0,isLoading:!1,error:null}),r=i.useMemo(()=>new zs.OrgApiClient(s.serverUrl,s.requestTimeout,s.retryAttempts,t?.getAccessToken),[s.serverUrl,s.requestTimeout,s.retryAttempts,t]),n=i.useCallback(async d=>{a(u=>({...u,isLoading:!0,error:null}));try{const u=await r.authorize(d),h={allowed:u.allowed,reason:u.reason,isLoading:!1,error:null};return a(h),h}catch(u){const h={allowed:!1,reason:void 0,isLoading:!1,error:u};return a(h),h}},[r]),c=i.useCallback(async d=>(await n(d)).allowed,[n]),l=i.useCallback(()=>{a({allowed:!1,reason:void 0,isLoading:!1,error:null})},[]);return{authorize:c,lastCheck:o,clearCheck:l,checkAuthorization:n}}function ui(){const{listAllWallets:s,createDerivedWallet:t,deleteDerivedWallet:o}=I.useWalletMaterial(),[a,r]=i.useState([]),[n,c]=i.useState(!1),[l,d]=i.useState(null),u=i.useCallback(async()=>{c(!0),d(null);try{const w=await s();r(w.wallets)}catch(w){const g=w instanceof Error?w.message:"Failed to list wallets";d(g)}finally{c(!1)}},[s]),h=i.useCallback(async w=>{c(!0),d(null);try{const g=await t({label:w});return await u(),g}catch(g){const p=g instanceof Error?g.message:"Failed to create wallet";throw d(p),g}finally{c(!1)}},[t,u]),m=i.useCallback(async w=>{c(!0),d(null);try{await o(w),await u()}catch(g){const p=g instanceof Error?g.message:"Failed to delete wallet";throw d(p),g}finally{c(!1)}},[o,u]),f=i.useCallback(()=>d(null),[]);return{wallets:a,isLoading:n,createWallet:h,deleteWallet:m,refresh:u,error:l,clearError:f}}function hi(){const s=T.useCedrosLoginOptional(),[t,o]=i.useState(!1),[a,r]=i.useState(null),[n,c]=i.useState(null),l=i.useMemo(()=>s?new T.ApiClient({baseUrl:s.config.serverUrl,timeoutMs:s.config.requestTimeout,retryAttempts:s.config.retryAttempts,getAccessToken:s._internal?.getAccessToken}):null,[s]),d=i.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");o(!0),r(null);try{const m=await l.get("/wallet/pending-recovery");c(m)}catch(m){const f=T.handleApiError(m,"Failed to fetch pending recovery");throw r(f.message),f}finally{o(!1)}},[l]),u=i.useCallback(async()=>{if(!l)throw new Error("usePendingRecovery must be used within a CedrosLoginProvider");o(!0),r(null);try{const m={confirmed:!0};await l.post("/wallet/acknowledge-recovery",m),c(null)}catch(m){const f=T.handleApiError(m,"Failed to acknowledge recovery");throw r(f.message),f}finally{o(!1)}},[l]),h=i.useCallback(()=>r(null),[]);return i.useEffect(()=>{l&&s?.authState==="authenticated"&&d().catch(()=>{})},[l,s?.authState,d]),{hasPendingRecovery:n?.hasPendingRecovery??!1,recoveryType:n?.recoveryType??null,recoveryPhrase:n?.recoveryPhrase??null,expiresAt:n?.expiresAt?new Date(n.expiresAt):null,fetchPendingRecovery:d,acknowledgeRecovery:u,isLoading:t,error:a,clearError:h}}function pi(s={}){const{onExternalSign:t}=s,{solanaPubkey:o,hasExternalWallet:a,status:r,isUnlocked:n}=I.useWallet(),{signTransaction:c,isSigning:l,error:d,clearError:u}=xr(),h=i.useMemo(()=>a&&t?"external":r==="enrolled_locked"||r==="enrolled_unlocked"?"sss":"none",[a,t,r]),m=h!=="none",f=r==="enrolled_locked"||r==="enrolled_unlocked";return{signTransaction:i.useCallback(async(g,p)=>{if(h==="external"){if(!t)throw new Error("External wallet signing callback not provided");return t(g)}if(h==="sss"){if(!p&&!n)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.")},[h,t,n,c]),signingMethod:h,canSign:m,isSigning:l,publicKey:o,hasExternalWallet:a,hasSssWallet:f,isSssUnlocked:n,error:d,clearError:u}}function mi(){const{config:s,_internal:t}=T.useCedrosLogin(),[o,a]=i.useState(null),[r,n]=i.useState(!1),[c,l]=i.useState(null),d=i.useMemo(()=>new T.ApiClient({baseUrl:s.serverUrl,timeoutMs:s.requestTimeout,getAccessToken:t?.getAccessToken}),[s.serverUrl,s.requestTimeout,t]),u=i.useCallback(async()=>{n(!0),l(null);try{await d.post("/welcome-completed",{})}catch(m){const f=m instanceof Error?m:new Error(String(m));throw l(f),f}finally{n(!1)}},[d]),h=i.useCallback(()=>{a(null)},[]);return{postLoginAction:o,setPostLoginAction:a,markWelcomeCompleted:u,clearPostLogin:h,isLoading:r,error:c}}const at=i.createContext(null),Ze={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 Jr(s,t){return Xr(s,t)}function Xr(s,t){const o={...s};for(const a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const r=s[a],n=t[a];typeof r=="object"&&r!==null&&typeof n=="object"&&n!==null?o[a]=Xr(r,n):n!==void 0&&(o[a]=n)}return o}function fi({children:s,locale:t="en",translations:o}){const a=i.useMemo(()=>({t:o?Jr(Ze,o):Ze,locale:t}),[o,t]);return e.jsx(at.Provider,{value:a,children:s})}function gi(){return i.useContext(at)?.t??Ze}function wi(){return i.useContext(at)?.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=_.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=we.validatePassword;exports.ErrorMessage=Y.ErrorMessage;exports.GoogleLoginButton=qs.GoogleLoginButton;exports.useGoogleAuth=qs.useGoogleAuth;exports.SolanaLoginButton=ve.SolanaLoginButton;exports.registerMobileWallet=ve.registerMobileWallet;exports.useSolanaAuth=ve.useSolanaAuth;exports.InviteForm=te.InviteForm;exports.InviteList=te.InviteList;exports.MemberList=te.MemberList;exports.useInvites=te.useInvites;exports.useMembers=te.useMembers;exports.useServerFeatures=te.useServerFeatures;exports.useSystemSettings=Yt.useSystemSettings;exports.useOrgs=zs.useOrgs;exports.AdminDepositList=He.AdminDepositList;exports.AdminDepositStats=He.AdminDepositStats;exports.AdminPrivacyPeriodDeposits=fe.AdminPrivacyPeriodDeposits;exports.AdminWithdrawalHistory=fe.AdminWithdrawalHistory;exports.AdminWithdrawalQueue=fe.AdminWithdrawalQueue;exports.AdminWithdrawalStats=fe.AdminWithdrawalStats;exports.AdminUserList=Te.AdminUserList;exports.useAdminUsers=Te.useAdminUsers;exports.AdminIcons=ge.Icons;exports.AdminShell=ge.AdminShell;exports.CEDROS_LOGIN_SECTION_IDS=ge.CEDROS_LOGIN_SECTION_IDS;exports.ProfileDropdown=ge.ProfileDropdown;exports.cedrosLoginPlugin=ge.cedrosLoginPlugin;exports.loginPlugin=ge.cedrosLoginPlugin;exports.useAdminShell=ge.useAdminShell;exports.AuthenticationSettings=$t.AuthenticationSettings;exports.EmbeddedWalletSettings=Jt.EmbeddedWalletSettings;exports.EmailSettings=ze.EmailSettings;exports.CreditSystemSettings=Vs.CreditSystemSettings;exports.PrivacyCashSettings=Vs.CreditSystemSettings;exports.ServerSettings=Xt.ServerSettings;exports.useAdminDeposits=io.useAdminDeposits;exports.SettingsPageLayout=Hs.SettingsPageLayout;exports.WebhookSettings=Hs.WebhookSettings;exports.AccountSettings=ya;exports.AppleLoginButton=dr;exports.CapabilityWarning=sn;exports.CedrosAdminDashboard=Ln;exports.CompleteAccountPrompt=xa;exports.CreditBalance=Ga;exports.DepositFlow=Ma;exports.ErrorBoundary=pr;exports.ForgotPasswordForm=ir;exports.FullPageLayout=li;exports.History=ei;exports.I18nProvider=fi;exports.LinkedAccounts=Dr;exports.LoginButton=Eo;exports.LoginForm=ss;exports.LoginModal=Do;exports.MfaSetupPrompt=ba;exports.OrgSelector=Uo;exports.OrgSwitcher=Ko;exports.PasskeyLoginButton=hr;exports.PasskeyPrompt=vr;exports.ProfileTab=Br;exports.RecoveryPhraseDisplay=fr;exports.RecoveryPhraseInput=gr;exports.ResetPasswordForm=Fo;exports.SUPPORTED_TOKENS=$r;exports.SecuritySettings=Cn;exports.SessionList=mr;exports.SetupWizard=Er;exports.SplitPageLayout=ci;exports.SystemSettings=xn;exports.TieredAmountSlider=rt;exports.TokenSelector=et;exports.TotpSettings=Rr;exports.TotpSetup=Xs;exports.UserProfileSettings=na;exports.WalletAddressRow=Cr;exports.WalletEnrollment=br;exports.WalletManager=bn;exports.WalletRecovery=Nr;exports.WalletStatus=Sr;exports.WalletUnlock=jr;exports.WithdrawalFlow=ri;exports.WithdrawalHistory=ii;exports.defaultTranslations=Ze;exports.getTierForAmount=ts;exports.mergeTranslations=Jr;exports.useAppleAuth=lr;exports.useAuthorize=di;exports.useCredentials=Zs;exports.useCredits=ot;exports.useDeposit=Or;exports.useInstantLink=ar;exports.useLocale=wi;exports.usePasskeySigning=Ar;exports.usePasswordReset=es;exports.usePendingRecovery=hi;exports.usePostLogin=mi;exports.useProfile=Re;exports.useSessions=Wr;exports.useSetup=Gs;exports.useTotp=Js;exports.useTransactionSigning=pi;exports.useTranslations=gi;exports.useWalletEnrollment=yr;exports.useWalletRecovery=kr;exports.useWalletSigning=xr;exports.useWallets=ui;exports.useWebAuthn=Ys;exports.useWithdrawal=nt;
|