PageSourceSearch

https://skettra.com/assets/AccountModal-C9D5bNw8-v2.2.0.js

js skettra.com collected 2026-10-10 02:44:37 UTC 54,201 bytes, 3 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/packLibraryService-BGo58u3P-v2.2.0.js","assets/index-CxB_Ni1Z-v2.2.0.js","assets/vendor-lucide-C66To_pL-v2.2.0.js","assets/vendor-react-CXpudY0x-v2.2.0.js","assets/index-DBL4QoRA-v2.2.0.css"])))=>i.map(i=>d[i]);
2import{j as e,u as oe,_ as he}from"./index-CxB_Ni1Z-v2.2.0.js";import{a as i,i as _,C as L,L as z,b6 as ue,aH as pe,b7 as be,b8 as ce,E as O,q as fe,b9 as K,ba as ge,aI as Z,Z as G,A as de,bb as le,bc as re,bd as je,n as Ne,be as W,bf as Y,bg as X,t as ve,b as ye,bh as we,au as Ae,J as ke,bi as xe,T as Se,V as Q,d as H,bj as ie,ab as Ce,U as De,a7 as Ee,P as ze,ap as Pe,X as Te,bk as Le,bl as Ue,bm as Fe,G as Be}from"./vendor-lucide-C66To_pL-v2.2.0.js";import{o as Ie,p as Me,B as $e,s as Re,q as M,a as se,t as _e}from"./App-CtuAKzQd-v2.2.0.js";import{r as Oe,u as Ye,p as Ge,d as ee,C as te,v as J,t as q,y as Ve,z as He}from"./vendor-firebase-BgbigB6w-v2.2.0.js";import{r as ne,i as Je,c as qe}from"./stripeService-DAYGmJrP-v2.2.0.js";import"./vendor-react-CXpudY0x-v2.2.0.js";import"./provenance-Df7XIa2n-v2.2.0.js";const Ke=({user:s,onUpdateUser:h})=>{const[u,c]=i.useState(!1),[p,x]=i.useState(s.name),[g,b]=i.useState(!1),[v,N]=i.useState(!1),[j,l]=i.useState(null),[d,y]=i.useState(!1),k=i.useRef(null),t=()=>{var o;(o=k.current)==null||o.click()},n=async o=>{var U,F;const w=(U=o.target.files)==null?void 0:U[0];if(w){if(!w.type.startsWith("image/")){l("Please select an image file");return}if(w.size>5*1024*1024){l("Image must be less than 5MB");return}if(!Ie((F=Me.currentUser)==null?void 0:F.uid)){l($e);return}b(!0),l(null);try{const D=Oe(Re,`avatars/${s.id}/${Date.now()}_${w.name}`);await Ye(D,w);const P=await Ge(D),B=ee(M,"users",s.id);await te(B,{avatar:P}),await h({...s,avatar:P}),b(!1)}catch(D){console.error("Avatar upload error:",D),l("Failed to upload avatar. Please try again."),b(!1)}}},f=async()=>{if(p.trim()===s.name){c(!1);return}N(!0),y(!1);try{const o=ee(M,"users",s.id);await te(o,{name:p.trim()}),await h({...s,name:p.trim()}),y(!0),c(!1),setTimeout(()=>y(!1),3e3)}catch(o){console.error("Name update error:",o),l("Failed to update name. Please try again."),N(!1)}},S=o=>new Date(o).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),a=o=>{switch(o){case"free":return"bg-slate-500/10 text-slate-400 border-slate-500/20";case"pro":return"bg-[#C49A2A]/10 text-[#D4B454] border-[#C49A2A]/20";case"studio":return"bg-amber-500/10 text-amber-400 border-amber-500/20";default:return"bg-slate-500/10 text-slate-400 border-slate-500/20"}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:"Profile Settings"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Manage your personal information and avatar."})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-green-500/10 border border-green-500/20 rounded-lg text-green-400 text-sm animate-in slide-in-from-top-2 fade-in",children:[e.jsx(_,{size:16}),"Profile updated successfully!"]}),j&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-500/10 border border-red-500/20 rounded-lg text-red-400 text-sm",children:[e.jsx(L,{size:16}),j,e.jsx("button",{onClick:()=>l(null),className:"ml-auto text-xs hover:text-red-300",children:"Dismiss"})]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:[e.jsx("label",{className:"text-sm font-semibold text-slate-300 mb-3 block",children:"Profile Picture"}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"w-24 h-24 rounded-full bg-gradient-to-br from-[#4A7A9E] to-purple-600 flex items-center justify-center text-white text-3xl font-bold shadow-lg overflow-hidden",children:s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"w-full h-full object-cover"}):s.name.charAt(0).toUpperCase()}),g&&e.jsx("div",{className:"absolute inset-0 bg-black/70 rounded-full flex items-center justify-center",children:e.jsx(z,{className:"animate-spin text-white",size:24})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{ref:k,type:"file",accept:"image/*",onChange:n,className:"hidden"}),e.jsx("button",{onClick:t,disabled:g,className:"flex items-center gap-2 px-4 py-2 bg-[#4A7A9E] hover:bg-[#35607F] disabled:bg-slate-700 disabled:cursor-not-allowed rounded-lg text-sm text-white transition-colors",children:g?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"animate-spin",size:16}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:16}),"Change Avatar"]})}),e.jsx("p",{className:"text-xs text-slate-500 mt-2",children:"JPG, PNG or GIF. Max size 5MB."})]})]})]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:[e.jsx("label",{className:"text-sm font-semibold text-slate-300 mb-3 block",children:"Display Name"}),u?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"text",value:p,onChange:o=>x(o.target.value),className:"flex-1 px-4 py-2 bg-slate-900 border border-slate-700 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-[#4A7A9E]",placeholder:"Enter your name",autoFocus:!0}),e.jsx("button",{onClick:f,disabled:v||p.trim()==="",className:"px-4 py-2 bg-[#4A7A9E] hover:bg-[#35607F] disabled:bg-slate-700 disabled:cursor-not-allowed rounded-lg text-sm text-white transition-colors flex items-center gap-2",children:v?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"animate-spin",size:16}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_,{size:16}),"Save"]})}),e.jsx("button",{onClick:()=>{c(!1),x(s.name)},disabled:v,className:"px-4 py-2 bg-slate-700 hover:bg-slate-600 disabled:cursor-not-allowed rounded-lg text-sm text-white transition-colors",children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-white",children:s.name}),e.jsx("button",{onClick:()=>c(!0),className:"px-3 py-1 text-sm text-[#6A9DBD] hover:text-[#B2CDE1] transition-colors",children:"Edit"})]})]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:[e.jsx("label",{className:"text-sm font-semibold text-slate-300 mb-3 block",children:"Email Address"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400",children:s.email}),e.jsx("span",{className:"text-xs text-slate-500 bg-slate-700/50 px-2 py-1 rounded",children:"Connected via Google"})]})]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:[e.jsx("label",{className:"text-sm font-semibold text-slate-300 mb-4 block",children:"Account Information"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-700/50",children:[e.jsx("span",{className:"text-sm text-slate-400",children:"Account Tier"}),e.jsx("span",{className:`text-xs font-semibold px-2 py-1 rounded border uppercase ${a(s.tier)}`,children:s.tier})]}),e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-slate-700/50",children:[e.jsx("span",{className:"text-sm text-slate-400",children:"Member Since"}),e.jsx("span",{className:"text-sm text-white",children:S(s.createdAt)})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsx("span",{className:"text-sm text-slate-400",children:"Last Login"}),e.jsx("span",{className:"text-sm text-white",children:S(s.lastLoginAt||s.createdAt)})]})]})]})]})},Ze={free:150,pro:1e3,studio:3500},We={free:{label:"Starter",color:"text-slate-400",badge:"bg-slate-700 text-slate-300"},pro:{label:"Creator",color:"text-[#6A9DBD]",badge:"bg-[#35607F]/60 text-[#B2CDE1]"},studio:{label:"Studio",color:"text-amber-400",badge:"bg-amber-900/60 text-amber-300"}},Xe={active:{icon:ce,label:"Active",cls:"text-emerald-400 bg-emerald-900/40 border-emerald-700/50"},trialing:{icon:be,label:"Free Trial",cls:"text-blue-400 bg-blue-900/40 border-blue-700/50"},past_due:{icon:L,label:"Payment Due",cls:"text-amber-400 bg-amber-900/40 border-amber-700/50"},canceled:{icon:pe,label:"Canceled",cls:"text-red-400 bg-red-900/40 border-red-700/50"},incomplete:{icon:L,label:"Incomplete",cls:"text-amber-400 bg-amber-900/40 border-amber-700/50"}},Qe=({user:s,onUpdateUser:h,onBuyTokens:u})=>{var D,P,B,$,m;const{showToast:c}=oe(),[p,x]=i.useState(!1),[g,b]=i.useState(null),[v,N]=i.useState(null),j=[{id:"free",name:"Starter",price:0,interval:"forever",description:"Try everything — no credit card needed.",tokenAllocation:150,dailyLimit:50,accentColor:"border-slate-700",iconColor:"text-slate-400",features:[{text:"150 tokens / month",included:!0},{text:"1 active project",included:!0},{text:"All AI models",included:!0},{text:"Sketch Canvas",included:!0},{text:"Style Packs (official)",included:!0},{text:"50 generations / day limit",included:!0},{text:"2K & 4K resolution",included:!1},{text:"Video generation",included:!1},{text:"Character Packs",included:!1},{text:"Priority queue",included:!1}]},{id:"pro",name:"Creator",price:15,interval:"month",description:"For creators who generate daily.",tokenAllocation:1e3,dailyLimit:null,popular:!0,accentColor:"border-[#4A7A9E]",iconColor:"text-[#6A9DBD]",features:[{text:"1,000 tokens / month",included:!0},{text:"Unlimited projects",included:!0},{text:"All AI models",included:!0},{text:"2K & 4K resolution",included:!0},{text:"Video generation",included:!0},{text:"Character Packs",included:!0},{text:"Custom Style Packs",included:!0},{text:"Unlimited daily generations",included:!0},{text:"Priority queue",included:!0},{text:"Commercial usage rights",included:!0}]},{id:"studio",name:"Studio",price:45,interval:"month",description:"For studios, agencies, and power creators.",tokenAllocation:3500,dailyLimit:null,accentColor:"border-amber-500",iconColor:"text-amber-400",features:[{text:"3,500 tokens / month",included:!0},{text:"Everything in Creator",included:!0},{text:"Team collaboration",included:!0},{text:"API access",included:!0},{text:"Unlimited character slots",included:!0},{text:"Priority support",included:!0},{text:"Extended commercial rights",included:!0},{text:"Custom pack upload priority",included:!0}]}],l=j.find(r=>r.id===s.tier),d=Ze[s.tier]??100,y=Math.max(0,d-(((D=s.tokens)==null?void 0:D.monthly)??0)),k=Math.max(0,((P=s.tokens)==null?void 0:P.monthly)??0),t=Math.max(0,((B=s.tokens)==null?void 0:B.purchased)??0),n=Math.max(0,(($=s.tokens)==null?void 0:$.total)??0),f=d>0?Math.min(100,y/d*100):0,S=We[s.tier],a=s.subscriptionStatus,o=a?Xe[a]:null,w=r=>new Date(r).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),U=()=>{const r=new Date(s.tokens.lastRefresh);return r.setMonth(r.getMonth()+1),w(r.getTime())},F=async r=>{if(r!==s.tier){x(!0),N(null),b(r);try{if(r==="free"){if(!confirm("Downgrade to Starter? You will lose access to Creator features at the end of your billing period.")){x(!1),b(null);return}const E=await se("/api/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({operation:"downgrade"})});if(!E.ok){const T=await E.json().catch(()=>({}));N(T.error||"Failed to downgrade"),x(!1),b(null);return}await h({...s,tier:"free",limits:{...s.limits,dailyLimit:50}}),c("Downgraded to Starter plan.","success")}else{if(!Je()){N("Payment system not configured. Please contact support."),x(!1),b(null);return}const C=r,{sessionUrl:E,error:T}=await qe(s.id,C,s.email);if(T||!E){N(T||"Failed to start checkout. Please try again."),x(!1),b(null);return}window.open(E,"_blank","noopener,noreferrer")}}catch(C){console.error("Plan change error:",C),N("Failed to change plan. Please try again or c
2ontact support.")}finally{x(!1),b(null)}}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:"Membership & Tokens"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Track your usage, manage your plan, and top up tokens."})]}),v&&e.jsxs("div",{className:"flex items-center gap-2 p-3 bg-red-500/10 border border-red-500/20 rounded-lg text-red-400 text-sm",children:[e.jsx(L,{size:16,className:"flex-shrink-0"}),e.jsx("span",{className:"flex-1",children:v}),e.jsx("button",{onClick:()=>N(null),className:"text-xs hover:text-red-300 ml-auto",children:"Dismiss"})]}),o&&a!=="active"&&e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-xl border text-sm font-medium ${o.cls}`,children:[e.jsx(o.icon,{size:18,className:"flex-shrink-0"}),e.jsxs("span",{children:[a==="past_due"&&"Your last payment failed. Please update your payment method to keep your plan active.",a==="canceled"&&"Your subscription has been canceled. You'll keep access until the end of the billing period.",a==="trialing"&&"You're in your free trial period.",a==="incomplete"&&"Your subscription setup is incomplete. Please complete your payment."]}),(a==="past_due"||a==="incomplete")&&e.jsxs("button",{onClick:()=>ne(s.id),className:"ml-auto flex items-center gap-1 text-xs underline underline-offset-2 hover:opacity-80 flex-shrink-0",children:["Fix payment ",e.jsx(O,{size:12})]})]}),e.jsxs("div",{className:"bg-slate-800/60 border border-slate-700 rounded-xl p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[e.jsx(fe,{size:16,className:"text-amber-400"}),"Token Balance"]}),e.jsxs("div",{className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold border ${S.badge} border-transparent`,children:[e.jsx(K,{size:11}),S.label]})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-3xl font-bold text-white tabular-nums",children:n.toLocaleString()}),e.jsx("div",{className:"text-xs text-slate-400 mt-0.5",children:"tokens available"})]}),u&&e.jsxs("button",{onClick:u,className:"flex items-center gap-2 px-4 py-2 bg-amber-500 hover:bg-amber-400 text-black text-sm font-bold rounded-lg transition-colors",children:[e.jsx(ge,{size:14}),"Buy Tokens"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-slate-400",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Z,{size:10}),"Monthly allocation"]}),e.jsxs("span",{children:[e.jsxs("span",{className:f>80?"text-amber-400 font-medium":"text-slate-300",children:[y.toLocaleString()," used"]})," / ",d.toLocaleString()," total"]})]}),e.jsx("div",{className:"h-2 bg-slate-700 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${f>90?"bg-red-500":f>70?"bg-amber-500":"bg-[#4A7A9E]"}`,style:{width:`${f}%`}})}),e.jsxs("div",{className:"flex justify-between text-[10px] text-slate-500",children:[e.jsxs("span",{children:[k.toLocaleString()," monthly remaining"]}),s.tier!=="free"&&e.jsxs("span",{children:["Resets ",U()]})]})]}),t>0&&e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-slate-700/50 text-xs",children:[e.jsxs("span",{className:"text-slate-400 flex items-center gap-1",children:[e.jsx(G,{size:10,className:"text-emerald-400"}),"Purchased tokens"]}),e.jsxs("span",{className:"text-emerald-400 font-semibold",children:[t.toLocaleString()," remaining"]})]}),(((m=s.tokens)==null?void 0:m.lifetimeUsed)??0)>0&&e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-slate-600 pt-1",children:[e.jsx("span",{children:"Lifetime tokens used"}),e.jsx("span",{children:s.tokens.lifetimeUsed.toLocaleString()})]})]}),e.jsxs("div",{className:`bg-gradient-to-br from-[#D4512A]/15 to-purple-600/15 border-2 ${l.accentColor} rounded-xl p-5`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(K,{className:l.iconColor,size:20}),e.jsxs("h4",{className:"text-lg font-bold text-white",children:[l.name," Plan"]}),(a==="active"||!a)&&s.tier!=="free"&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 text-[10px] font-semibold rounded-full bg-emerald-900/50 text-emerald-400 border border-emerald-700/50",children:[e.jsx(ce,{size:10})," Active"]})]}),e.jsx("p",{className:"text-slate-400 text-sm",children:l.description})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsx("div",{className:"text-xl font-bold text-white",children:l.price===0?"Free":`$${l.price}`}),l.price>0&&e.jsxs("div",{className:"text-xs text-slate-400",children:["/",l.interval]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3 pt-3 border-t border-white/10",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-500 mb-0.5 uppercase tracking-wider",children:"Monthly tokens"}),e.jsx("div",{className:"text-sm font-bold text-white",children:l.tokenAllocation.toLocaleStr
2ing()})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-500 mb-0.5 uppercase tracking-wider",children:"Daily limit"}),e.jsx("div",{className:"text-sm font-bold text-white",children:l.dailyLimit?l.dailyLimit:"Unlimited"})]}),s.tier!=="free"&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-slate-500 mb-0.5 uppercase tracking-wider",children:"Next billing"}),e.jsx("div",{className:"text-sm font-bold text-white",children:U()})]})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold text-white mb-3",children:"Change Plan"}),e.jsx("div",{className:"grid md:grid-cols-3 gap-4",children:j.map(r=>{const C=r.id===s.tier,E=g===r.id,T=r.price>((l==null?void 0:l.price)??0);return e.jsxs("div",{className:`relative rounded-xl p-5 flex flex-col transition-all ${C?`bg-slate-800 border-2 ${r.accentColor} shadow-lg`:"bg-slate-800/30 border border-slate-700 hover:border-slate-600"} ${r.popular&&!C?"ring-2 ring-amber-500/40":""}`,children:[r.popular&&!C&&e.jsx("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2 bg-amber-500 text-black text-[10px] font-bold px-3 py-1 rounded-full whitespace-nowrap",children:"MOST POPULAR"}),C&&e.jsx("div",{className:"absolute top-0 right-0 bg-[#4A7A9E] text-white text-[10px] font-bold px-2 py-1 rounded-bl-lg rounded-tr-xl",children:"CURRENT"}),e.jsxs("div",{className:"mb-3",children:[e.jsx("h5",{className:`text-base font-bold mb-0.5 ${C?"text-white":"text-slate-300"}`,children:r.name}),e.jsxs("div",{className:"text-xl font-bold text-white",children:[r.price===0?"Free":`$${r.price}`,r.price>0&&e.jsxs("span",{className:"text-sm font-normal text-slate-400",children:["/",r.interval]})]}),e.jsx("p",{className:"text-[11px] text-slate-500 mt-1",children:r.description})]}),e.jsx("ul",{className:"space-y-1.5 mb-5 flex-1",children:r.features.map((I,V)=>e.jsxs("li",{className:`flex items-start gap-2 text-xs ${I.included?"text-slate-300":"text-slate-600"}`,children:[e.jsx(_,{size:13,className:`mt-0.5 flex-shrink-0 ${I.included?r.iconColor:"text-slate-700"}`}),e.jsx("span",{className:I.included?"":"line-through",children:I.text})]},V))}),e.jsx("button",{onClick:()=>F(r.id),disabled:C||p,className:`w-full py-2 rounded-lg font-semibold text-sm transition-all flex items-center justify-center gap-2 ${C?"bg-[#284A63]/50 text-[#B2CDE1] cursor-default":T?"bg-white text-black hover:bg-slate-100":"border border-slate-600 text-slate-300 hover:bg-slate-700 hover:text-white"} ${p?"opacity-50 cursor-not-allowed":""}`,children:p&&E?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"animate-spin",size:14})," Processing…"]}):C?e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14})," Current Plan"]}):T?e.jsxs(e.Fragment,{children:["Upgrade ",e.jsx(de,{size:14})]}):"Downgrade"})]},r.id)})})]}),s.tier!=="free"&&e.jsxs("div",{className:"bg-slate-800/40 border border-slate-700 rounded-xl p-5 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold text-white mb-1",children:"Payment Method & Invoices"}),e.jsx("p",{className:"text-xs text-slate-400",children:"Update your card or download invoices via the Stripe customer portal."})]}),e.jsxs("button",{onClick:()=>ne(s.id),className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 bg-[#D4512A] hover:bg-[#E8703E] rounded-lg text-sm text-white font-medium transition-colors",children:["Manage Billing ",e.jsx(O,{size:13})]})]}),s.tier!=="free"&&e.jsxs("div",{className:"bg-slate-800/20 border border-slate-800 rounded-xl p-5",children:[e.jsx("h4",{className:"text-sm font-semibold text-white mb-1",children:"Cancel Subscription"}),e.jsx("p",{className:"text-xs text-slate-400 mb-3",children:"Access stays active until the end of the current billing period."}),e.jsx("button",{onClick:()=>F("free"),className:"px-4 py-2 bg-red-500/10 hover:bg-red-500/20 border border-red-500/20 rounded-lg text-sm text-red-400 transition-colors",children:"Cancel Subscription"})]})]})},et=({user:s})=>{const[h,u]=i.useState([]),[c,p]=i.useState(!0),[x,g]=i.useState("all");i.useEffect(()=>{b()},[s.id]);const b=async()=>{p(!0);try{const t=await _e(s.id,50);u(t)}catch(t){console.error("Failed to load transactions:",t)}finally{p(!1)}},v=t=>{switch(t){case"deduction":return e.jsx(le,{className:"text-red-400",size:16});case"purchase":case"bonus":return e.jsx(re,{className:"text-green-400",size:16});case"refund":return e.jsx(de,{className:"text-blue-400",size:16});case"monthly_refresh":return e.jsx(W,{className:"text-purple-400",size:16});default:return e.jsx(G,{className:"text-slate-400",size:16})}},N=t=>{switch(t){case"deduction":return"text-red-400";case"purchase":case"bonus":return"text-green-400";case"refund":return"text-blue-400";case"monthly_refresh":return"text-purple-400";default:return"text-slate-400"}},j=t=>{var n;switch(t.type){case"deduction":return t.operation||"Generation";case"purchase":return"Token Purchase";case"bonus":return"Bonus Tokens";case"refund":return`Refund: ${((n=t.metadata)==null?void 0:n.reason)||"Unknown"}`;case"monthly_refresh":return"Monthly Allocation";case"manual_adjustment":return"Manual Adjustment";default:return"Transaction"}},l=t=>{const n=new Date(t),f=new Date,S=f.getTime()-n.getTime(),a=Math.floor(S/(1e3*60*60*24));if(a===0){const o=Math.floor(S/36e5);if(o===0){const w=Math.floor(S/6e4);return w<=1?"Just now":`${w} minutes ago`}return o===1?"1 hour ago":`${o} hours ago`}return a===1?"Yesterday":a<7?`${a} days ago`:n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:n.getFullYear()!==f.getFullYear()?"numeric":void 0})},d=x==="all"?h:h.filter(t=>t.type===x),y=h.filter(t=>t.type==="deduction").reduce((t,n)=>t+n.amount,0),k=h.filter(t=>t.type==="purchase"||t.type==="bonus").reduce((t,n)=>t+n.amount,0);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:"Token History"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"View your token usage and purchase history."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(G,{className:"text-amber-400",size:18}),e.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase",children:"Current Balance"})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:s.tokens.total.toLocaleStr
2ing()}),e.jsxs("div",{className:"text-xs text-slate-500 mt-1",children:[s.tokens.monthly.toLocaleString()," monthly + ",s.tokens.purchased.toLocaleString()," purchased"]})]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(le,{className:"text-red-400",size:18}),e.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase",children:"Lifetime Used"})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:s.tokens.lifetimeUsed.toLocaleString()}),e.jsxs("div",{className:"text-xs text-slate-500 mt-1",children:[y.toLocaleString()," this period"]})]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(re,{className:"text-green-400",size:18}),e.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase",children:"Total Purchased"})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:k.toLocaleString()}),e.jsx("div",{className:"text-xs text-slate-500 mt-1",children:"All-time purchases & bonuses"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{size:16,className:"text-slate-400"}),e.jsx("span",{className:"text-sm text-slate-400",children:"Filter:"}),e.jsx("div",{className:"flex gap-2",children:["all","deduction","purchase","refund"].map(t=>e.jsx("button",{onClick:()=>g(t),className:`px-3 py-1 rounded-lg text-xs font-medium transition-colors ${x===t?"bg-[#4A7A9E] text-white":"bg-slate-800 text-slate-400 hover:text-white hover:bg-slate-700"}`,children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]}),e.jsx("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl overflow-hidden",children:c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(z,{className:"animate-spin text-[#6A9DBD]",size:32})}):d.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(G,{className:"mx-auto text-slate-600 mb-3",size:48}),e.jsx("p",{className:"text-slate-400 text-sm",children:"No transactions yet"}),e.jsx("p",{className:"text-slate-500 text-xs mt-1",children:x==="all"?"Your token activity will appear here":`No ${x} transactions found`})]}):e.jsx("div",{className:"divide-y divide-slate-800",children:d.map(t=>{var n;return e.jsx("div",{className:"p-4 hover:bg-slate-800/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-slate-900 flex items-center justify-center",children:v(t.type)}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-white mb-0.5",children:j(t)}),e.jsx("div",{className:"text-xs text-slate-500",children:l(t.createdAt)}),((n=t.metadata)==null?void 0:n.imageId)&&e.jsxs("div",{className:"text-xs text-slate-600 flex items-center gap-1 mt-1",children:[e.jsx(Ne,{size:10}),"Image ID: ",t.metadata.imageId.slice(0,8),"..."]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:`text-lg font-bold ${N(t.type)}`,children:[t.type==="deduction"?"-":"+",t.amount]}),e.jsxs("div",{className:"text-xs text-slate-500",children:["Balance: ",t.balanceAfter.toLocaleString()]})]})]})},t.id)})})}),d.length>=50&&e.jsx("p",{className:"text-center py-3 text-xs text-slate-500",children:"Showing the last 50 transactions"})]})},tt=({user:s})=>{const[h,u]=i.useState([]),[c,p]=i.useState(null),[x,g]=i.useState(!0),[b,v]=i.useState(null),{showToast:N}=oe();i.useEffect(()=>{(async()=>{if(!s.stripeCustomerId){g(!1);return}try{const f=await(await se("/api/stripe/get-invoices")).json();f.success?(u(f.invoices),p(f.paymentMethod)):v(f.error||"Failed to fetch billing history")}catch(n){console.error("Error fetching invoices:",n),v("Failed to load billing history")}finally{g(!1)}})()},[s.stripeCustomerId]);const j=t=>new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),l=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(t),d=t=>{switch(t){case"paid":return e.jsxs("span",{className:"flex items-center gap-1 text-xs font-semibold px-2 py-1 rounded bg-green-500/10 text-green-400 border border-green-500/20",children:[e.jsx(ve,{size:12}),"Paid"]});
2case"pending":return e.jsxs("span",{className:"flex items-center gap-1 text-xs font-semibold px-2 py-1 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20",children:[e.jsx(L,{size:12}),"Pending"]});case"failed":return e.jsxs("span",{className:"flex items-center gap-1 text-xs font-semibold px-2 py-1 rounded bg-red-500/10 text-red-400 border border-red-500/20",children:[e.jsx(L,{size:12}),"Failed"]})}},y=t=>{t.invoiceUrl?window.open(t.invoiceUrl,"_blank","noopener,noreferrer"):N("Invoice URL not available.","warning")},k=h.filter(t=>t.status==="paid").reduce((t,n)=>t+n.amount,0);return x?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(z,{className:"animate-spin text-[#6A9DBD]",size:32})}):s.stripeCustomerId?b?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:"Billing & Invoices"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"View and download your billing history."})]}),e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-xl p-6 text-center",children:[e.jsx(L,{className:"mx-auto text-red-400 mb-2",size:32}),e.jsx("p",{className:"text-red-400 text-sm",children:b})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:"Billing & Invoices"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"View and download your billing history."})]}),e.jsx("div",{className:"bg-gradient-to-br from-slate-800/50 to-slate-900/50 border border-slate-800 rounded-xl p-6",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Y,{className:"text-[#6A9DBD]",size:18}),e.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase",children:"Total Spent"})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:l(k)}),e.jsx("div",{className:"text-xs text-slate-500 mt-1",children:"All-time billing"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(W,{className:"text-purple-400",size:18}),e.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase",children:"Next Payment"})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:s.tier==="free"?"—":j(Date.now()+720*60*60*1e3)}),e.jsx("div",{className:"text-xs text-slate-500 mt-1",children:s.tier==="free"?"No active subscription":"Monthly billing cycle"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(X,{className:"text-green-400",size:18}),e.jsx("span",{className:"text-xs font-semibold text-slate-400 uppercase",children:"Payment Method"})]}),e.jsx("div",{className:"text-lg font-bold text-white",children:c?`${c.brand.charAt(0).toUpperCase()+c.brand.slice(1)} •••• ${c.last4}`:"—"}),e.jsx("div",{className:"text-xs text-slate-500 mt-1",children:c?`Expires ${c.expMonth}/${c.expYear}`:"No payment method"})]})]})}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl overflow-hidden",children:[e.jsx("div",{className:"p-4 border-b border-slate-800",children:e.jsx("h4",{className:"text-sm font-bold text-white",children:"Invoice History"})}),h.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Y,{className:"mx-auto text-slate-600 mb-3",size:48}),e.jsx("p",{className:"text-slate-400 text-sm",children:"No invoices yet"}),e.jsx("p",{className:"text-slate-500 text-xs mt-1",children:"Your billing history will appear here after your first payment"})]}):e.jsx("div",{className:"divide-y divide-slate-800",children:h.map(t=>e.jsx("div",{className:"p-4 hover:bg-slate-800/50 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-slate-900 flex items-center justify-center",children:e.jsx(Y,{className:"text-[#6A9DBD]",size:20})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-medium text-white mb-0.5",children:t.description}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-slate-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(W,{size:12}),j(t.date)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{size:12}),t.paymentMethod]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-lg font-bold text-white",children:l(t.amount)}),d(t.status)]}),t.status==="paid"&&t.invoiceUrl&&e.jsx("button",{onClick:()=>y(t),className:"p-2 hover:bg-slate-700 rounded-lg text-slate-400 hover:text-white transition-colors group",title:"View Invoice",children:e.jsx(O,{size:18,className:"group-hover:text-[#6A9DBD]"})})]})]})},t.id))})]}),s.tier!=="free"&&e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:[e.jsx("h4",{className:"text-sm font-bold text-white mb-3",children:"Tax Information"}),e.jsx("p",{className:"text-sm text-slate-400",children:"Tax information management will be available through your Str
2ipe billing portal."})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:"Billing & Invoices"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"View and download your billing history."})]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-12 text-center",children:[e.jsx(Y,{className:"mx-auto text-slate-600 mb-4",size:48}),e.jsx("h4",{className:"text-lg font-bold text-white mb-2",children:"No Billing History"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"You're on the Starter (Free) plan. Upgrade to see your billing history."})]})]})},st=({user:s,onLogout:h,onResetTutorial:u})=>{var P,B,$;const[c,p]=i.useState(((P=s.notifications)==null?void 0:P.email)??!0),[x,g]=i.useState(((B=s.notifications)==null?void 0:B.productUpdates)??!0),[b,v]=i.useState((($=s.notifications)==null?void 0:$.usageAlerts)??!0),[N,j]=i.useState(!1),[l,d]=i.useState(""),[y,k]=i.useState(!1),[t,n]=i.useState(!1),[f,S]=i.useState(!1),[a,o]=i.useState(null),w=(m,r)=>{o({type:m,msg:r}),setTimeout(()=>o(null),4e3)},U=async()=>{n(!0);try{await te(ee(M,"users",s.id),{"notifications.email":c,"notifications.productUpdates":x,"notifications.usageAlerts":b}),w("success","Notification preferences saved.")}catch(m){console.error("Failed to save notification preferences:",m),w("error","Failed to save preferences. Please try again.")}finally{n(!1)}},F=async()=>{S(!0);try{const r=(await J(q(M,"users",s.id,"images"))).docs.map(A=>A.data()),E=(await J(q(M,"users",s.id,"projects"))).docs.map(A=>A.data()),I=(await J(Ve(q(M,"tokenTransactions"),He("userId","==",s.id)))).docs.map(A=>A.data()),V={exportedAt:new Date().toISOString(),profile:{id:s.id,name:s.name,email:s.email,tier:s.tier,createdAt:s.createdAt},tokens:s.tokens,notifications:s.notifications,images:r.map(A=>({prompt:A.prompt,model:A.model,createdAt:A.createdAt,url:A.url})),projects:E.map(A=>({name:A.name,createdAt:A.createdAt})),transactions:I.map(A=>({type:A.type,amount:A.amount,description:A.description,createdAt:A.createdAt}))},me=new Blob([JSON.stringify(V,null,2)],{type:"application/json"}),ae=URL.createObjectURL(me),R=document.createElement("a");R.href=ae,R.download=`storyscapepro-data-${s.id.slice(0,8)}-${Date.now()}.json`,document.body.appendChild(R),R.click(),document.body.removeChild(R),URL.revokeObjectURL(ae),w("success","Your data has been downloaded.")}catch(m){console.error("Data export failed:",m),w("error","Failed to export data. Please try again.")}finally{S(!1)}},D=async()=>{if(l!=="DELETE"){w("error","Please type DELETE to confirm.");return}k(!0);try{const m=await se("/api/delete-account",{method:"POST"});if(!m.ok){const r=await m.json().catch(()=>({}));throw new Error(r.error||"Account deletion failed")}h()}catch(m){console.error("Account deletion error:",m),w("error",m.message||"Failed to delete account. Please try again or contact support."),k(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white mb-1",children:"Account Settings"}),e.jsx("p",{className:"text-slate-400 text-sm",children:"Manage your preferences and account security."})]}),a&&e.jsxs("div",{className:`flex items-center gap-2 p-3 rounded-lg text-sm animate-in slide-in-from-top-2 fade-in ${a.type==="success"?"bg-green-500/10 border border-green-500/20 text-green-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[a.type==="success"?e.jsx(ye,{size:16}):e.jsx(L,{size:16}),a.msg]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(we,{className:"text-[#6A9DBD]",size:20}),e.jsx("h4",{className:"text-md font-bold text-white",children:"Notification Preferences"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-slate-700/50",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white mb-1",children:"Email Notifications"}),e.jsx("div",{className:"text-xs text-slate-400",children:"Receive updates about your account activity"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:m=>p(m.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-slate-700 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-[#4A7A9E] rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#4A7A9E]"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-slate-700/50",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white mb-1",children:"Product Updates"}),e.jsx("div",{className:"text-xs text-slate-400",children:"Get notified about new features and improvements"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:m=>g(m.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-slate-700 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-[#4A7A9E] rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#4A7A9E]"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white mb-1",children:"Usage Alerts"}),e.jsx("div",{className:"text-xs text-slate-400",children:"Get alerts when your token balance is low"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:b,onChange:m=>v(m.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-slate-700 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-[#4A7A9E] rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#4A7A9E]"})]})]})]}),e.jsx("button",{onClick:U,disabled:t,className:"mt-4 flex items-center gap-2 px-4 py-2 bg-[#4A7A9E] hover:bg-[#35607F] disabled:bg-slate-700 disabled:cursor-not-allowed rounded-lg text-sm text-white transition-colors",children:t?e.jsxs(e.Fragment,{children:[e.jsx(z,{size:14,className:"animate-spin"})," Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(_,{size:14})," Save Preferences"]})})]}),e.jsxs("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Ae,{className:"text-purple-400",size:20}),e.jsx("h4",{className:"text-md font-bold text-white",children:"Security & Privacy"})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-slate-700/50",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white mb-1",children:"Two-Factor Authentication"}),e.jsx("div",{className:"text-xs text-slate-400",children:"Managed through your Google Account"})]}),e.jsxs("a",{href:"https://myaccount.google.com/signinoptions/two-step-verification",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-3 py-1 text-sm text-[#6A9DBD] hover:text-[#B2CDE1] transition-colors",children:["Manage ",e.jsx(O,{size:12})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-slate-700/50",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white mb-1",children:"Active Sessions"}),e.jsx("div",{className:"text-xs text-slate-400",children:"View devices signed in to your Google Account"})]}),e.jsxs("a",{href:"https://myaccount.google.com/device-activity",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 px-3 py-1 text-sm text-[#6A9DBD] hover:text-[#B2CDE1] transition-colors",children:["View ",e.jsx(O,{size:12})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-white mb-1",children:"Download Your Data"}),e.jsx("div",{className:"text-xs text-slate-400",children:"Export a JSON copy of your account data"})]}),e.jsx("button",{onClick:F,disabled:f,className:"flex items-center gap-1 px-3 py-1 text-sm text-[#6A9DBD] hover:text-[#B2CDE1] disabled:text-slate-500 disabled:cursor-not-allowed transition-colors",children:f?e.jsxs(e.Fragment,{children:[e.jsx(z,{size:12,className:"animate-spin"})," Exporting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{size:12})," Export"]})})]})]})]}),u&&e.jsx("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-md font-bold text-white mb-1",children:"Replay Tutorial"}),e.jsx("p",{className:"text-sm text-slate-400",children:"Restart the getting-started walkthrough from the beginning"})]}),e.jsx("button",{onClick:u,className:"flex items-center gap-2 px-4 py-2 bg-[#4A7A9E]/20 border border-[#4A7A9E]/40 hover:bg-[#4A7A9E]/30 rounded-lg text-sm text-[#B2CDE1] transition-colors",children:"Reset Tutorial"})]})}),e.jsx("div",{className:"bg-slate-800/50 border border-slate-800 rounded-xl p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-md font-bold text-white mb-1",children:"Sign Out"}),e.jsx("p",{className:"text-sm text-slate-400",children:"Sign out of your account on this device"})]}),e.jsxs("button",{onClick:h,className:"flex items-center gap-2 px-4 py-2 bg-slate-700 hover:bg-slate-600 rounded-lg text-sm text-white transition-colors",children:[e.jsx(xe,{size:16}),"Sign Out"]})]})}),e.jsxs("div",{className:"bg-red-500/5 border border-red-500/20 rounded-xl p-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Se,{className:"text-red-400",size:20}),e.jsx("h4",{className:"text-md font-bold text-red-400",children:"Danger Zone"})]}),N?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-red-900/20 border border-red-500/30 rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-red-300 mb-3 font-medium",children:"⚠️ This action cannot be undone. This will permanently delete:"}),e.jsxs("ul",{className:"text-xs text-red-300/80 space-y-1 ml-4",children:[e.jsx("li",{children:"• Your account and profile information"}),e.jsx("li",{children:"• All generated images and artwork"}),e.jsx("li",{children:"• All projects and albums"}),e.jsxs("li",{children:["• Your token balance (",s.tokens.total.toLocaleStr
2ing()," tokens)"]}),e.jsx("li",{children:"• All transaction and billing history"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-red-400 mb-2",children:["Type ",e.jsx("span",{className:"font-bold",children:"DELETE"})," to confirm:"]}),e.jsx("input",{type:"text",value:l,onChange:m=>d(m.target.value),placeholder:"DELETE",className:"w-full px-4 py-2 bg-slate-900 border border-red-500/30 rounded-lg text-white placeholder-slate-600 focus:outline-none focus:ring-2 focus:ring-red-500"})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:D,disabled:l!=="DELETE"||y,className:"flex items-center gap-2 px-4 py-2 bg-red-600 hover:bg-red-700 disabled:bg-slate-700 disabled:cursor-not-allowed rounded-lg text-sm text-white transition-colors",children:y?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"animate-spin",size:16}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{size:16}),"Delete My Account"]})}),e.jsx("button",{onClick:()=>{j(!1),d("")},disabled:y,className:"px-4 py-2 bg-slate-700 hover:bg-slate-600 disabled:cursor-not-allowed rounded-lg text-sm text-white transition-colors",children:"Cancel"})]})]}):e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-400 mb-4",children:"Once you delete your account, there is no going back. All your data, images, projects, and token balance will be permanently deleted."}),e.jsxs("button",{onClick:()=>j(!0),className:"flex items-center gap-2 px-4 py-2 bg-red-500/10 hover:bg-red-500/20 border border-red-500/20 rounded-lg text-sm text-red-400 transition-colors",children:[e.jsx(Q,{size:16}),"Delete Account"]})]})]})]})},at=({user:s,onCreateStylePack:h,onCreateCharacterPack:u,onCreateBrushPack:c,onEditPack:p,onDeleteCustomPack:x})=>{const[g,b]=i.useState([]),[v,N]=i.useState(!0),[j,l]=i.useState("all"),[d,y]=i.useState(null),k=async()=>{N(!0),y(null);try{const{getCreatedPacks:a}=await he(async()=>{const{getCreatedPacks:w}=await import("./packLibraryService-BGo58u3P-v2.2.0.js");return{getCreatedPacks:w}},__vite__mapDeps([0,1,2,3,4])),o=await a(s.id);b(o)}catch(a){console.error("Failed to load creations:",a),y("Failed to load your creations.")}finally{N(!1)}};i.useEffect(()=>{k()},[s.id]);const t=j==="all"?g:g.filter(a=>a.type===j),n={all:g.length,style:g.filter(a=>a.type==="style").length,brush:g.filter(a=>a.type==="brush").length,character:g.filter(a=>a.type==="character").length},f=a=>{switch(a){case"style":return e.jsx(ze,{size:14,className:"text-pink-400"});case"brush":return e.jsx(Ee,{size:14,className:"text-amber-400"});case"character":return e.jsx(De,{size:14,className:"text-emerald-400"});default:return e.jsx(ie,{size:14,className:"text-slate-400"})}},S=[{id:"all",label:"All",count:n.all},{id:"style",label:"Styles",count:n.style}];return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"My Creations"}),e.jsx("p",{className:"text-slate-400 text-sm mt-1",children:"Custom packs you've created. Manage, edit, or create new ones."})]}),e.jsxs("button",{onClick:k,disabled:v,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-slate-800 text-slate-300 text-xs hover:bg-slate-700 disabled:opacity-50 transition-colors",children:[e.jsx(Z,{size:12,className:v?"animate-spin":""}),"Refresh"]})]}),(h||u||c)&&e.jsxs("div",{className:"flex flex-wrap gap-2 mb-5",children:[h&&e.jsxs("button",{onClick:h,className:"flex items-center gap-1.5 px-3 py-1.5 text-[12px] font-medium rounded-lg bg-[#4A7A9E]/20 text-[#6A9DBD] hover:bg-[#4A7A9E]/30 border border-[#4A7A9E]/20 transition-colors",children:[e.jsx(H,{size:13})," New Style Pack"]}),u&&e.jsxs("button",{onClick:u,className:"flex items-center gap-1.5 px-3 py-1.5 text-[12px] font-medium rounded-lg bg-amber-600/20 text-amber-400 hover:bg-amber-600/30 border border-amber-500/20 transition-colors",children:[e.jsx(H,{size:13})," New Character Pack"]}),c&&e.jsxs("button",{onClick:c,className:"flex items-center gap-1.5 px-3 py-1.5 text-[12px] font-medium rounded-lg bg-emerald-600/20 text-emerald-400 hover:bg-emerald-600/30 border border-emerald-500/20 transition-colors",children:[e.jsx(H,{size:13})," New Brush Pack"]})]}),e.jsx("div",{className:"flex gap-1 mb-6 p-1 bg-slate-800/50 rounded-lg w-fit",children:S.map(a=>e.jsxs("button",{onClick:()=>l(a.id),className:`px-3 py-1.5 rounded-md text-xs font-medium transition-colors ${j===a.id?"bg-[#4A7A9E] text-white":"text-slate-400 hover:text-white hover:bg-slate-700"}`,children:[a.label," (",a.count,")"]},a.id))}),d&&e.jsx("div",{className:"p-4 rounded-lg bg-red-500/10 border border-red-500/20 text-red-300 text-sm mb-4",children:d}),v?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(Z,{size:24,className:"animate-spin text-slate-500"})}):t.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(ie,{size:40,className:"mx-auto text-slate-600 mb-3"}),e.jsx("p",{className:"text-slate-400 text-sm",children:j==="all"?"No creations yet. Use the buttons above to create your first pack!":`No custom ${j}
2 packs found.`})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:t.map(a=>e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-xl border border-slate-700/60 bg-slate-800/40 hover:bg-slate-800/60 transition-colors group",children:[e.jsx("div",{className:"w-12 h-12 rounded-lg bg-slate-700/50 flex-shrink-0 overflow-hidden flex items-center justify-center",children:a.thumbnail?e.jsx("img",{src:a.thumbnail,alt:"",className:"w-full h-full object-cover"}):f(a.type)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[f(a.type),e.jsx("span",{className:"text-white text-sm font-medium truncate",children:a.name})]}),e.jsx("p",{className:"text-slate-500 text-xs mt-0.5 truncate",children:a.description||"No description"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[a.tags.slice(0,2).map(o=>e.jsxs("span",{className:"text-[10px] text-slate-500",children:["#",o]},o)),a.brushCount!==void 0&&e.jsxs("span",{className:"text-[10px] text-slate-500",children:[a.brushCount," brushes"]}),a.characterName&&e.jsx("span",{className:"text-[10px] text-slate-500",children:a.characterName})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity flex-shrink-0",children:[p&&e.jsx("button",{onClick:()=>p(a,a.type),className:"p-1.5 rounded-md text-slate-400 hover:text-white hover:bg-slate-700 transition-colors",title:"Edit pack",children:e.jsx(Ce,{size:13})}),x&&e.jsx("button",{onClick:()=>{confirm(`Delete "${a.name}"? This cannot be undone.`)&&x(a.id,a.type)},className:"p-1.5 rounded-md text-slate-400 hover:text-red-400 hover:bg-red-500/10 transition-colors",title:"Delete pack",children:e.jsx(Q,{size:13})})]})]},`${a.source}-${a.id}`))})]})},xt=({isOpen:s,onClose:h,user:u,onUpdateUser:c,onLogout:p,onResetTutorial:x,onBuyTokens:g,onCreateStylePack:b,onCreateCharacterPack:v,onCreateBrushPack:N,onEditPack:j,onDeleteCustomPack:l})=>{const[d,y]=i.useState("profile");if(!s)return null;const k=[{id:"profile",label:"Profile",icon:Le},{id:"subscription",label:"Membership",icon:K},{id:"library",label:"My Creations",icon:Ue},{id:"tokens",label:"Token History",icon:Fe},{id:"billing",label:"Billing",icon:X},{id:"settings",label:"Settings",icon:Be}];return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm p-4 animate-in fade-in duration-200",children:e.jsxs("div",{className:"w-full max-w-5xl bg-slate-900 border border-slate-800 rounded-2xl shadow-2xl overflow-hidden flex flex-col max-h-[90vh]",children:[e.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-slate-800",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[e.jsx(Pe,{className:"text-[#6A9DBD]"})," Account Management"]}),e.jsx("p",{className:"text-slate-400 text-sm mt-1",children:"Manage your profile, subscription, and settings."})]}),e.jsx("button",{onClick:h,className:"p-2 hover:bg-slate-800 rounded-full text-slate-400 hover:text-white transition-colors",children:e.jsx(Te,{size:20})})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"w-64 bg-slate-800/50 border-r border-slate-800 p-4 space-y-1",children:[k.map(t=>{const n=t.icon,f=d===t.id;return e.jsxs("button",{onClick:()=>y(t.id),className:`w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-all text-sm font-medium ${f?"bg-[#4A7A9E] text-white shadow-lg":"text-slate-400 hover:text-white hover:bg-slate-800"}`,children:[e.jsx(n,{size:18}),t.label]},t.id)}),e.jsx("div",{className:"border-t border-slate-700 mt-3 pt-3",children:e.jsxs("button",{onClick:p,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg transition-all text-sm font-medium text-red-400 hover:text-red-300 hover:bg-red-500/10",children:[e.jsx(xe,{size:18}),"Sign Out"]})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-8 custom-scrollbar",children:[d==="profile"&&e.jsx(Ke,{user:u,onUpdateUser:c}),d==="subscription"&&e.jsx(Qe,{user:u,onUpdateUser:c,onBuyTokens:g}),d==="library"&&e.jsx(at,{user:u,onCreateStylePack:b,onCreateCharacterPack:v,onCreateBrushPack:N,onEditPack:j,onDeleteCustomPack:l}),d==="tokens"&&e.jsx(et,{user:u}),d==="billing"&&e.jsx(tt,{user:u}),d==="settings"&&e.jsx(st,{user:u,onLogout:p,onResetTutorial:x})]})]})]})})};export{xt as default};
3//# sourceMappingURL=AccountModal-C9D5bNw8-v2.2.0.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.