PageSourceSearch

https://unbserved.com/assets/SettingsPage-CH3E-2SC.js

js unbserved.com collected 2026-10-02 01:47:54 UTC 53,979 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-ui-CmsjHIn-.js";import{B as vs}from"./BackIcon-M1vk_R5Y.js";import{P as ys}from"./planFeatures-C7Ce0nfX.js";import{u as Ye,b as ze,a as ws}from"./vendor-query-ByPjdCNj.js";import{t as Ns,a as I,g as Ve,r as h,s as y,K as _s,M as ks,bd as We,Q as Cs,be as Ss,Y as S,ee as Ps,b$ as Es,ef as Ds,bY as As,ac as Ge,c0 as Fs,c1 as Ls,c2 as Rs,aC as Us,c3 as Ts,c as $s,eg as Ms,b9 as Is,eh as Os,ei as Bs,ao as qs,af as Ys,a2 as zs,U as P,cV as Vs,a5 as U,bO as Fe,aM as Le,bW as Ws,bu as W,ae as Re,cm as Gs,cY as Ue,dP as Hs,cr as Ks,bU as Te,ej as Qs,ek as Js,cU as Zs,E as Xs}from"./main-CVSb0ivP.js";import{a as d,e as et,l as st,L as $e}from"./vendor-react-BIk3JZ8x.js";import{u as Me}from"./useRevokeObjectUrl-CGJQfkh3.js";import{A as tt,a as rt,b as at}from"./avatar-CbrgJHLW.js";import{i as it,I as nt}from"./reservedUsernames-DLjj0mTJ.js";import{F as ot}from"./FileSaver.min-BF9KhJwD.js";import{u as lt,a as Ie,D as dt,c as ct,S as mt,h as ut,d as xt,s as ht,K as ft,P as gt,b as bt,C as pt}from"./sortable.esm-BsAZCybZ.js";import{G as jt}from"./grip-vertical-BSzqKL8a.js";import{h as Oe}from"./Shield-DTBwoSEM.js";import"./submissionOffer-C5xWB-U2.js";import"./index-Bgb3GKdq.js";import"./triangle-alert-C-X7xUKj.js";import"./zap-RXDA8toK.js";import"./sliders-horizontal-CLqEqMaF.js";import"./check-Cs5as3tE.js";import"./download-COZD-iZ9.js";import"./image-plus-CqfGgfUd.js";import"./lock-DbdsG4Q5.js";import"./plus-Ba1NuFOA.js";import"./search-CRUaHbAt.js";import"./upload-B4YuwLsS.js";import"./vendor-motion-pIdvkJtl.js";import"./slider-7NIzg9b-.js";import"./index-_MhlqF8Y.js";import"./index-BdQq_4o_.js";import"./index-D-t6e6zq.js";var vt=Object.defineProperty,Be=Object.getOwnPropertySymbols,yt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable,qe=(r,n,o)=>n in r?vt(r,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[n]=o,oe=(r,n)=>{for(var o in n||(n={}))yt.call(n,o)&&qe(r,o,n[o]);if(Be)for(var o of Be(n))wt.call(n,o)&&qe(r,o,n[o]);return r};const Nt=(r,n)=>{const o=d.useContext(Ns),m=oe(oe({},o),r);return d.createElement("svg",oe({width:"1.5em",height:"1.5em",strokeWidth:1.5,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",color:"currentColor",ref:n},m),d.createElement("path",{d:"M10 12C10 14.2091 8.20914 16 6 16C3.79086 16 2 14.2091 2 12C2 9.79086 3.79086 8 6 8C8.20914 8 10 9.79086 10 12ZM10 12H22V15",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{d:"M18 12V15",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}))},_t=d.forwardRef(Nt);var kt=_t;function Ct(){const{user:r}=I(),{data:n,isLoading:o,error:m,refetch:a}=Ve(),c=Ye(),t=ze({mutationFn:async({key:f,value:u})=>{if(!r)throw new Error("Please sign in again");const{error:g,count:b}=await y.from("app_users").update({[f]:u},{count:"exact"}).eq("id",r.id);if(g)throw g;if(b!==1)throw new Error("Your preference could not be saved")},onSuccess:async()=>{await c.invalidateQueries({queryKey:["profile",r?.id]}),h.success("Notification preferences saved")},onError:()=>h.error("Could not save your preference. Please try again.")});return e.jsxs("section",{className:"space-y-5","aria-label":"Notification preferences",children:[m&&e.jsxs("div",{role:"alert",children:["Couldn’t load your preferences. ",e.jsx("button",{onClick:()=>{a()},className:"underline",children:"Try again"})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Notifications"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Choose what you hear from us. Changes save automatically."})]}),[["email_notifications","Activity notifications","Likes, follows, comments, collection invites and badges, in the app and by email."],["marketing_emails","Marketing emails","Optional tips, product updates and promotional content."]].map(([f,u,g])=>e.jsxs("label",{className:"flex items-center justify-between gap-6 rounded-2xl bg-secondary/40 p-5 cursor-pointer",children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:u}),e.jsx("span",{className:"block text-xs text-muted-foreground mt-1 leading-relaxed",children:g})]}),e.jsx("input",{type:"checkbox",role:"switch","aria-label":u,checked:f==="email_notifications"?n?.[f]!==!1:n?.[f]===!0,disabled:o||!n||t.isPending,onChange:b=>t.mutate({key:f,value:b.target.checked}),className:"notification-preference-switch"})]},f)),e.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:t.isPending?"Saving…":"Security, billing and submission updates remain enabled. Existing notifications are not deleted."})]})}function St(){const{user:r}=I();return ws({queryKey:["account-deletion",r?.id],enabled:!!r?.id,queryFn:async()=>{const{data:n,error:o}
1=await y.rpc("my_account_deletion_status");if(o)throw o;const m=Array.isArray(n)?n[0]:n;return m?.purge_after?m:null}})}function Pt(){const{user:r}=I(),n=Ye();return ze({mutationFn:async()=>{if(!r?.id)throw new Error("Not authenticated");const{error:o}=await y.rpc("cancel_account_deletion",{target_user_id:r.id});if(o)throw o},onSuccess:()=>{n.invalidateQueries({queryKey:["account-deletion"]}),n.invalidateQueries({queryKey:["profile"]}),h.success("Your account is active again")},onError:o=>{h.error(o instanceof Error?o.message:"Could not cancel the deletion")}})}const He=d.forwardRef(({isOpen:r,onClose:n,onSuccess:o,title:m="Confirm Identity",description:a="To continue, please enter your password",isVerifying:c=!1,onVerify:t},f)=>{const[u,g]=d.useState(""),[b,x]=d.useState("");if(!r)return null;const _=async j=>{if(j.preventDefault(),x(""),!u.trim()){x("Password is required");return}await t(u)?(g(""),o()):x("Invalid password")},p=()=>{g(""),x(""),n()};return e.jsx(_s,{open:r,onOpenChange:j=>{!j&&!c&&p()},children:e.jsxs(ks,{ref:f,hideClose:!0,className:"sm:max-w-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"p-2 bg-secondary rounded-full",children:e.jsx(We,{className:"w-5 h-5"})}),e.jsx(Cs,{className:"text-lg font-semibold",children:m})]}),e.jsx(Ss,{className:"text-sm text-muted-foreground mb-6",children:a}),e.jsxs("form",{onSubmit:_,children:[e.jsx("input",{"aria-label":"Password",type:"password",value:u,onChange:j=>g(j.target.value),className:`w-full px-3 py-2 bg-background border focus:border-foreground outline-none transition-colors mb-2 ${b?"border-destructive":"border-border"}`,placeholder:"Enter your password",autoFocus:!0,disabled:c}),b&&e.jsx("p",{className:"text-xs text-destructive mb-4",children:b}),e.jsxs("div",{className:"flex gap-3 justify-end mt-4",children:[e.jsx(S,{type:"button",variant:"outline",onClick:p,disabled:c,children:"Cancel"}),e.jsx(S,{type:"submit",disabled:c||!u.trim(),children:c?"Verifying...":"Confirm"})]})]})]})})});He.displayName="ReauthModal";function Et(){const{user:r}=I(),[n,o]=d.useState(!1),[m,a]=d.useState(!1),[c,t]=d.useState(null),f=d.useCallback(x=>{t(()=>x),o(!0)},[]),u=d.useCallback(async x=>{if(!r?.email)return!1;a(!0);try{const{error:_}=await y.auth.signInWithPassword({email:r.email,password:x});return!_}catch{return!1}finally{a(!1)}},[r?.email]),g=d.useCallback(()=>{c&&c(),o(!1),t(null)},[c]),b=d.useCallback(()=>{o(!1),t(null)},[]);return{isOpen:n,isVerifying:m,requireReauth:f,verify:u,handleSuccess:g,close:b}}function Dt({isPro:r,onUpgrade:n,isCheckingOut:o}){const{theme:m,setTheme:a}=Ps(),c=m==="dark";return r?e.jsx("button",{onClick:()=>a(c?"light":"dark"),className:`w-10 h-6 rounded-full relative transition-colors ${c?"bg-foreground":"bg-secondary"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 rounded-full transition ${c?"right-1 bg-background":"left-1 bg-muted-foreground"}`})}):e.jsx("button",{onClick:n,disabled:o,className:"w-10 h-6 rounded-full relative transition-colors bg-secondary opacity-50 cursor-not-allowed",children:e.jsx("span",{className:"absolute top-1 left-1 w-4 h-4 rounded-full bg-muted-foreground"})})}const G=500;async function At(r){let n=!1;const{data:{subscription:o}}=y.auth.onAuthStateChange((a,c)=>{c?.user.id!==r&&(n=!0)}),m=()=>{if(n)throw new Error("Your account changed. Please start the export again.")};try{const{data:a,error:c}=await y.rpc("get_my_app_user");if(m(),c)throw c;const t=Array.isArray(a)?a[0]:a;if(!t||t.id!==r)throw new Error("Your profile is unavailable. Please try again.");const f=[];let u;for(;;){m();let _=y.from("folders_metadata").select("id, name, slug, is_private, created_at").eq("owner_user_id",r).order("id").limit(G);u&&(_=_.gt("id",u));const{data:p,error:j}=await _;if(m(),j)throw j;if(f.push(...p||[]),!p||p.length<G)break;const N=p[p.length-1].id;if(u&&N<=u)throw new Error("Could not finish exporting collections. Please try again.");u=N}const g=[];for(u=void 0;;){m();let _=y.from("image_likes").select("id, image_id, created_at").eq("user_id",r).order("id").limit(G);u&&(_=_.gt("id",u));const{data:p,error:j}=await _;if(m(),j)throw j;if(g.push(...p||[]),!p||p.length<G)break;const N=p[p.length-1].id;if(u&&N<=u)throw new Error("Could not finish exporting likes. Please try again.");u=N}const{data:b,error:x}=await y.auth.getUser();if(m(),x)throw x;if(b.user?.id!==r)throw new Error("Your account changed. Please start the export again.");return{exportedAt:new Date().toISOString(),profile:t,folders:f,likes:g}}finally{o.unsubscribe()}}function Ft({userBadge:r}){const{attributes:n,listeners:o,setNodeRef:m,transform:a,transition:c,isDragging:t}=bt({id:r.badge_id}),f={transform:pt.Transform.toString(a),transition:c};return e.jsxs(Ls,{children:[e.jsx(Rs,{asChild:!0,children:e.jsxs("div",{ref:m,style:f,className:Us("flex flex-col items-center gap-2 p-3 rounded-lg border border-border bg-card","cursor-grab active:cursor-grabbing transition",t&&"opacity-50 scale-105 shadow-lg z-10"),...n,...o,children:[e.jsx("div",{className:"flex items-center gap-1 text-muted-foreground",children:e.jsx(jt,{className:"w-3 h-3"})}),e.jsx("span",{className:"w-10 h-10 inline-flex items-center justify-center [&_svg]:w-full [&_svg]:h-full",style:{color:"#F0FF00"},dangerouslySetInnerHTML:{__html:Ge(r.badge?.svg_content||"")}}),e.jsx("span",{className:"text-xs text-muted-foreground text-center w-24 min-h-8 leading-4 whitespace-normal break-words",children:r.badge?.name})]})}),e.jsx(Ts,{children:e.jsx("p",{children:r.badge?.tooltip||r.badge?.name})})]})}function Lt({userId:r}){const{data:n,isLoading:o}
1=Es(r),m=Ds(),[a,c]=d.useState([]),t=lt(Ie(gt,{activationConstraint:{distance:5}}),Ie(ft,{coordinateGetter:ht}));d.useEffect(()=>{n&&c(n)},[n]);const f=u=>{const{active:g,over:b}=u;if(b&&g.id!==b.id&&r){const x=a.findIndex(j=>j.badge_id===g.id),_=a.findIndex(j=>j.badge_id===b.id),p=xt(a,x,_);c(p),m.mutate({userId:r,orderedBadgeIds:p.map(j=>j.badge_id)})}};return o?e.jsx("div",{className:"flex gap-3",children:[1,2,3].map(u=>e.jsx(As,{className:"w-24 h-28 rounded-lg"},u))}):!a||a.length===0?e.jsx("div",{className:"py-8 text-center text-muted-foreground text-sm",children:"You don't have any badges yet."}):a.length===1?e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2 p-3 rounded-lg border border-border bg-card",children:[e.jsx("span",{className:"w-10 h-10 inline-flex items-center justify-center [&_svg]:w-full [&_svg]:h-full",style:{color:"#F0FF00"},dangerouslySetInnerHTML:{__html:Ge(a[0].badge?.svg_content||"")}}),e.jsx("span",{className:"text-xs text-muted-foreground text-center w-24 min-h-8 leading-4 whitespace-normal break-words",children:a[0].badge?.name})]}),e.jsx("p",{className:"text-xs text-muted-foreground self-center ml-2",children:"Earn more badges to reorder them."})]}):e.jsxs(Fs,{children:[e.jsx(dt,{sensors:t,collisionDetection:ct,onDragEnd:f,children:e.jsx(mt,{items:a.map(u=>u.badge_id),strategy:ut,children:e.jsx("div",{className:"flex flex-wrap gap-3",children:a.map(u=>e.jsx(Ft,{userBadge:u},u.badge_id))})})}),m.isPending&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Saving..."})]})}const Ke={instagram:{host:"instagram.com",pathPrefix:"/"},behance:{host:"behance.net",pathPrefix:"/"},twitter:{host:"x.com",pathPrefix:"/"},linkedin:{host:"linkedin.com",pathPrefix:"/in/"}},Rt=/^[a-zA-Z0-9._-]+$/;function Ut(r,n){const o=(r||"").trim();if(!o)return"";const m=Ke[n],a=o.startsWith("@")?o.slice(1):o;if(Rt.test(a)&&!a.includes(".")&&!a.includes("/"))return`https://${m.host}${m.pathPrefix}${a}`;let c=a;/^https?:\/\//i.test(c)||(c=`https://${c}`);try{const t=new URL(c);return n==="twitter"&&/(^|\.)twitter\.com$/i.test(t.hostname)&&(t.hostname="x.com"),t.hostname=t.hostname.replace(/^www\./i,"").toLowerCase(),t.toString().replace(/\/$/,"")}catch{return o}}function Tt(r,n){if(!r)return!0;try{const m=new URL(r).hostname.replace(/^www\./i,"").toLowerCase(),a=Ke[n].host;return m===a||m.endsWith(`.${a}`)}catch{return!1}}function $t(r){return{display_name:r?.display_name??"",bio:r?.bio??"",website_url:r?.
1website_url??"",location:r?.location??"",company:r?.company??"",job_title:r?.job_title??"",instagram_url:r?.instagram_url??"",behance_url:r?.behance_url??"",twitter_url:r?.twitter_url??"",linkedin_url:r?.linkedin_url??"",is_public:r?.is_public??!0,allow_comments:r?.allow_comments??!0,show_email:r?.show_email??!1,hide_likes_tab:r?.hide_likes_tab??!1}}function Mt(r,n){const o=$t(n),m={};for(const a of Object.keys(o))r[a]!==o[a]&&(m[a]=r[a]);return m}const It=/^[a-z0-9_.]+$/;function Ot(r,n,o=400){const[m,a]=d.useState({status:"idle",message:""});return d.useEffect(()=>{const c=r.trim().toLowerCase();if(!c){a({status:"idle",message:""});return}if(n&&c===n.toLowerCase()){a({status:"current",message:""});return}if(!It.test(c)){a({status:"invalid",message:"Only letters, numbers, underscores, and dots"});return}if(c.length<3){a({status:"too-short",message:"Minimum 3 characters"});return}if(it(c)){a({status:"reserved",message:"This username is reserved"});return}a({status:"checking",message:"Checking availability…"});let t=!1;const f=setTimeout(async()=>{try{const{data:u,error:g}=await y.rpc("is_username_available",{p_username:c});if(t)return;if(g){a({status:"error",message:"Could not verify username"});return}a(u?{status:"available",message:"Username is available"}:{status:"taken",message:"Username is already taken"})}catch{t||a({status:"error",message:"Could not verify username"})}},o);return()=>{t=!0,clearTimeout(f)}},[r,n,o]),m}function br({lab:r=!1}={}){$s({title:"Settings",noindex:!0});const n=et(),[o]=st(),{signOut:m,user:a}=I(),c=o.get("onboarding")==="true",{data:t,isLoading:f}=Ve(),u=St(),g=Pt(),b=Ms(),{isPro:x,isSubscribed:_,subscriptionEnd:p,isLoading:j,hasConfirmedStatus:N,startCheckout:H,isCheckingOut:O,openPortal:Qe,isOpeningPortal:le,refetchSubscription:Je,isTrial:K,trialDaysRemaining:de}=Is(),M=o.get("tab"),[D,A]=d.useState(M||"profile");d.useEffect(()=>{M&&["profile","account","notifications","privacy","subscription","feedback"].includes(M)&&A(M)},[M]),d.useMemo(()=>t?!t.username||!t.display_name||!t.avatar_url:!1,[t]);const[k,ce]=d.useState({username:""}),[me,ue]=d.useState(!1),xe=d.useRef(null),[B,he]=d.useState(!1),[Ze,Q]=d.useState(!1),[F,fe]=d.useState(null),[Xe,J]=d.useState(!1),[Z,X]=d.useState(!1),[ee,ge]=d.useState(""),[T,se]=d.useState(""),[te,be]=d.useState(!1),[es,re]=d.useState(!1),[ss,pe]=d.useState(!1),[ae,ie]=d.useState(null);Me(F),Me(ae);const[ts,je]=d.useState("feedback"),[ve,ye]=d.useState(!1),[we,Ne]=d.useState(!1),[_e,rs]=d.useState(!1),as=d.useMemo(()=>{if(!a)return!1;const s=a.app_metadata?.provider,l=a.identities||[];return s==="google"||l.some(w=>w.provider==="google")},[a]),{isOpen:is,isVerifying:ns,requireReauth:os,verify:ls,handleSuccess:ds,close:cs}=Et(),[i,C]=d.useState({display_name:"",bio:"",website_url:"",location:"",company:"",job_title:"",instagram_url:"",behance_url:"",twitter_url:"",linkedin_url:"",is_public:!0,email_notifications:!0,marketing_emails:!1,allow_comments:!0,show_email:!1,hide_likes_tab:!1});d.useEffect(()=>{t&&(C({display_name:t.display_name||"",bio:t.bio||"",website_url:t.website_url||"",location:t.location||"",company:t.company||"",job_title:t.job_title||"",instagram_url:t.instagram_url||"",behance_url:t.behance_url||"",twitter_url:t.twitter_url||"",linkedin_url:t.linkedin_url||"",is_public:!0,email_notifications:t.email_notifications??!0,marketing_emails:t.marketing_emails??!1,allow_comments:t.allow_comments??!0,show_email:t.show_email??!1,hide_likes_tab:t.hide_likes_tab??!1}),ce({username:t.username||""}))},[t]);const L=d.useMemo(()=>({display_name:t?.display_name||"",bio:t?.bio||"",website_url:t?.website_url||"",instagram_url:t?.instagram_url||"",behance_url:t?.behance_url||"",twitter_url:t?.twitter_url||"",linkedin_url:t?.linkedin_url||""}),[t]),q=d.useMemo(()=>i.display_name!==L.display_name||i.bio!==L.bio||i.website_url!==L.website_url||i.instagram_url!==L.instagram_url||i.behance_url!==L.behance_url||i.twitter_url!==L.twitter_url||i.linkedin_url!==L.linkedin_url||k.username!==(t?.username||"")||!!F,[i,L,k.username,t?.username,F]);d.useEffect(()=>{if(!q)return;const s=l=>{l.preventDefault(),l.returnValue=""};return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[q]);
1const[E,ms]=d.useState({}),v=Ot(k.username,t?.username),[Y,ke]=d.useState(!1),z=(s,l)=>{const w=i[l],R=Ut(w,s);R!==w&&C({...i,[l]:R}),ms($=>({...$,[s]:Tt(R,s)?"":`Doesn't look like a valid ${s} URL`}))},Ce=async()=>{const s=a?.email||t?.email;if(!s){h.error("No email found");return}he(!0);try{const{error:l}=await y.auth.resetPasswordForEmail(s,{redirectTo:`${window.location.origin}/auth/reset-password`});if(l)throw l;h.success("Password reset email sent! Check your inbox.")}catch{h.error("Failed to send password reset email")}finally{he(!1)}},us=async()=>{if(!T.trim()){h.error("Please enter a new email address");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(T)){h.error("Please enter a valid email address");return}if(T===t?.email){h.error("New email must be different from current email");return}be(!0);try{const{error:l}=await y.auth.updateUser({email:T});if(l)throw l;h.success("Check both email addresses to confirm the change"),re(!1),se("")}catch(l){h.error(l?.message||"Failed to update email")}finally{be(!1)}},xs=async()=>{if(a?.id){ye(!0);try{const s=await At(a.id),l=new Blob([JSON.stringify(s,null,2)],{type:"application/json"});ot.saveAs(l,`unbserved-data-export-${Date.now()}.json`),h.success("Data exported successfully")}catch(s){console.error("Export error:",s),h.error("Failed to export data")}finally{ye(!1)}}},[V,Se]=d.useState(""),Pe=async()=>{if(!k.username||k.username.trim().length<3){Se("Username is required (min 3 characters)"),A("profile");return}if(k.username!==(t?.username||"")&&(v.status==="taken"||v.status==="invalid"||v.status==="reserved"||v.status==="too-short"||v.status==="checking")){h.error(v.status==="checking"?"Please wait while we verify the username":v.message||"Username is not available"),A("profile");return}if(!i.display_name||i.display_name.trim().length<2){h.error("Display name is required (min 2 characters)"),A("profile");return}if(c&&!F&&!t?.avatar_url){h.error("Profile photo is required"),A("profile");return}try{const s=!!k.username&&k.username!==t?.username,{email_notifications:l,marketing_emails:w,...R}=i,$={...Mt(R,t),...s?{username:k.username.trim()}:{}};await b.mutateAsync($),h.success("Settings saved"),ke(!0),setTimeout(()=>ke(!1),1800);const ne=F||t?.avatar_url,fs=k.username||t?.username,gs=!!(i.bio&&i.bio.trim().length>0),bs=!!(i.instagram_url||i.behance_url||i.twitter_url||i.linkedin_url||i.website_url),ps=!!(i.display_name&&i.display_name.trim().length>=2);if(ne&&fs&&ps&&gs&&bs&&!t?.is_founding_member){const{error:js}=await y.from("app_users").update({is_founding_member:!0,updated_at:new Date().toISOString()}).eq("id",t?.id);js||h.success("🎉 You earned the Founding Member badge!","BADGE")}c&&k.username&&k.username.trim().length>=3&&(F||t?.avatar_url)&&n("/dashboard",{replace:!0})}catch(s){s instanceof Js?(h.error("This username is already taken"),A("profile")):h.error("Failed to save settings")}},Ee=async()=>{await m(),n("/")},hs=async()=>{if(ee!=="DELETE"){h.error("Please type DELETE to confirm");return}if(!a?.id){h.error("No user found");return}X(!0);try{const{data:s}=await y.auth.getSession(),l=s?.session?.access_token;if(!l){h.error("Session expired. Please sign in again."),X(!1);return}const w=await y.functions.invoke("delete-account",{headers:{Authorization:`Bearer ${l}`}});if(w.error)throw w.error;await m(),h.success("Account deleted successfully"),n("/")}catch(s){console.error("Delete account error:",s),h.error("Failed to delete account. Please contact support.")}finally{X(!1),J(!1)}},De=[{id:"profile",label:"Profile",icon:e.jsx(Re,{className:"w-4 h-4"})},{id:"account",label:"Account",icon:e.jsx(We,{className:"w-4 h-4"})},{id:"subscription",label:"Subscription",icon:e.jsx(Ue,{className:"w-4 h-4"})},{id:"notifications",label:"Notifications",icon:e.jsx(Zs,{className:"w-4 h-4"})},{id:"privacy",label:"Privacy",icon:e.jsx(Xs,{className:"w-4 h-4"})},{id:"feedback",label:"Feedback",icon:e.jsx(Te,{className:"w-4 h-4"}),badge:"BETA"}],Ae=s=>s?new Date(s).toLocaleDateString("en-US",{day:"2-digit",month:"long",year:"numeric"}):null;return f?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"border-b border-border",children:e.jsx("div",{className:"max-w-4xl mx-auto px-6 py-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})}),e.jsx("div",{className:"h-6 w-24 rounded bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})})]}),e.jsx("div",{className:"h-9 w-20 rounded-full bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})})]})})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 py-8",children:e.jsxs("div",{className:"flex gap-8",children:[e.jsx("div",{className:"hidden md:block w-48 space-y-2",children:Array.from({length:6}).map((s,l)=>e.jsx("div",{className:"h-9 rounded bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})},l))}),e.jsxs("div",{className:"flex-1 space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-32 rounded bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})}),e.jsx("div",{className:"h-3 w-20 rounded bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})})]})]}),Array.from({length:4}).map((s,l)=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 w-24 rounded bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})}),e.jsx("div",{className:"h-10 w-full rounded bg-secondary relative overflow-hidden",children:e.jsx("div",{className:"absolute inset-0 skeleton-shimmer"})})]},l))]})]})})]}):e.jsxs("div",{className:"settings-page min-h-screen bg-background",children:[e.jsx("div",{className:"settings-heading border-b border-border",children:e.jsx("div",{className:"max-w-4xl mx-auto px-6 py-6",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{"aria-label":"Back",onClick:()=>window.history.state?.idx>
10?n(-1):n("/dashboard"),className:"p-2 border border-border hover:border-foreground transition-colors rounded-full",children:e.jsx(vs,{})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-medium",children:"Settings"}),r&&e.jsx("p",{className:"account-lab-description",children:"Your profile, preferences and account."})]})]})})})}),e.jsxs("div",{className:"settings-layout max-w-4xl mx-auto px-4 sm:px-6 py-6 sm:py-8",children:[e.jsx("div",{className:"md:hidden mb-6 -mx-4 px-4 overflow-x-auto scrollbar-hide",children:e.jsx("div",{className:"flex gap-2 min-w-max pb-3",children:De.map(s=>{const l=c&&!t?.username&&s.id!=="profile";return e.jsxs("button",{"aria-pressed":D===s.id,onClick:()=>!l&&A(s.id),disabled:l,className:`flex items-center gap-2 px-4 py-2.5 rounded-full text-sm font-medium whitespace-nowrap min-h-11 transition-colors ${D===s.id?"bg-foreground text-background":l?"bg-secondary text-muted-foreground/40 cursor-not-allowed":"bg-secondary text-muted-foreground"}`,children:[s.icon,s.label,s.badge&&e.jsx("span",{className:"text-[9px] font-bold uppercase px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-600",children:s.badge})]},s.id)})})}),e.jsx("button",{onClick:Ee,className:"md:hidden mb-6 inline-flex items-center min-h-11 px-4 rounded-full bg-destructive/10 text-destructive text-sm font-medium",children:"Sign out"}),e.jsxs("div",{className:"settings-columns flex gap-8",children:[e.jsxs("div",{className:"hidden md:block w-48 flex-shrink-0",children:[e.jsx("nav",{className:"space-y-1",children:De.map(s=>{const l=c&&!t?.username&&s.id!=="profile";return e.jsxs("button",{"aria-pressed":D===s.id,onClick:()=>!l&&A(s.id),disabled:l,className:`w-full flex items-center gap-3 px-3 py-2 text-sm transition-colors rounded-lg ${D===s.id?"bg-secondary text-foreground font-medium":l?"text-muted-foreground/40 cursor-not-allowed":"text-muted-foreground hover:text-foreground"}`,children:[s.icon,e.jsx("span",{className:"flex-1 text-left",children:s.label}),s.badge&&e.jsx("span",{className:"text-[9px] font-bold uppercase px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-600",children:s.badge})]},s.id)})}),e.jsx("div",{className:"mt-8 pt-8 border-t border-border",children:e.jsx("button",{onClick:Ee,className:"w-full text-left px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors rounded-lg",children:"Sign out"})})]}),e.jsxs("div",{className:"settings-content flex-1",children:[D==="profile"&&e.jsxs("div",{className:"space-y-6 pb-24 md:pb-0",children:[(()=>{const s=Os({avatar_url:F||t?.avatar_url||null,display_name:i.display_name,username:k.username,bio:i.bio,website_url:i.website_url,instagram_url:i.instagram_url,behance_url:i.behance_url,twitter_url:i.twitter_url,linkedin_url:i.linkedin_url});return s.isComplete?null:e.jsxs("div",{className:"p-4 rounded-xl border border-border bg-secondary/30",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Profile ",s.percent,"% complete"]}),e.jsxs("span",{className:"text-xs text-muted-foreground tabular-nums",children:[s.items.filter(l=>l.done).length,"/",s.items.length]})]}),e.jsx("div",{className:"h-1 rounded-full bg-border overflow-hidden mb-3",children:e.jsx("div",{className:"h-full bg-primary transition duration-500",style:{width:`${s.percent}%`}})}),e.jsx("ul",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-1.5",children:s.items.map(l=>e.jsxs("li",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 ${l.done?"bg-primary text-primary-foreground":"border border-border"}`,children:l.done&&e.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 12 12",fill:"none",children:e.jsx("path",{d:"M2.5 6L5 8.5L9.5 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("span",{className:l.done?"text-muted-foreground line-through":"text-foreground",children:l.label})]},l.key))})]})})(),!t?.is_founding_member&&e.jsx("div",{className:"p-4 rounded-xl border border-yellow-500/30 bg-yellow-500/5",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Bs,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"Earn the Founding Member badge!"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Complete your profile with a photo, name, username, bio, and at least one social link to unlock it."})]})]})}),e.jsxs("div",{className:"pb-6 border-b border-border",children:[e.jsx("h2",{className:"text-lg font-medium mb-4",children:"Profile Photo"}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs(tt,{className:"h-24 w-24",children:[e.jsx(rt,{src:F||t?.avatar_url||void 0,alt:t?.display_name||"Avatar"}),e.jsx(at,{className:"text-2xl",children:(t?.display_name||t?.username||"U").charAt(0).toUpperCase()})]}),e.jsx("button",{onClick:()=>xe.current?.click(),disabled:me,className:"absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-full",children:me?e.jsx(qs,{className:"w-6 h-6 text-white animate-spin"}):e.jsx(Ys,{className:"w-6 h-6 text-white"})}),e.jsx("input",{ref:xe,type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:s=>{const l=s.target.files?.[0];if(!l||!a?.id)return;if(l.size>2*1024*1024){h.error("Image must be less than 2MB");return}const w=URL.createObjectURL(l);ie(w),pe(!0),s.target.value=""}})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to upload a new profile photo"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"JPG, PNG or WebP. Max 2MB."})]})]})]}),e.jsxs("div",{className:"pb-6 border-b border-border",children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:"Badges"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Drag to reorder how your badges appear on your profile."}),e.jsx(Lt,{userId:a?.id})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-medium",children:"Profile Information"}),t?.username&&e.jsxs($e,{to:`/u/${t.username}`,className:"flex items-center gap-2 px-3 py-1.5 text-sm border border-border hover:border-foreground transition-colors rounded-full",children:[e.jsx(zs,{className:"w-4 h-4"}),"View Profile"]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{htmlFor:"settings-username",className:"block text-sm font-medium mb-2",children:["Username ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none z-10",children:"@"}),e.jsx(P,{id:"settings-username",type:"text",value:k.username,onChange:s=>{Se(""),ce({...k,username:s.target.value.toLowerCase().replace(/[^a-z0-9_.]/g,"")})},className:`pl-8 pr-10 ${v.status==="taken"||v.status==="invalid"||v.status==="reserved"||V?"border-destructive":""}`,placeholder:"your_username",maxLength:20,autoComplete:"off"}),e.jsxs("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 pointer-events-none",children:[v.status==="checking"&&e.jsx(Vs,{className:"w-4 h-4 text-muted-foreground animate-spin"}),v.status==="available"&&e.jsx(U,{className:"w-4 h-4 text-emerald-500"}),(v.status==="taken"||v.status==="invalid"||v.status==="reserved")&&e.jsx(Fe,{className:"w-4 h-4 text-destructive"})]})]}),(V||v.message)&&e.jsx("p",{className:`text-xs mt-1 ${v.status==="available"?"text-emerald-600 dark:text-emerald-400":v.status==="checking"?"text-muted-foreground":"text-destructive"}`,children:V||v.message}),!V&&!v.message&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Only letters, numbers, underscores, and dots. Minimum 3 characters."})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-display-name",className:"block text-sm font-medium mb-2",children:"Display Name"}),e.jsx(P,{id:"settings-display-name",type:"text",value:i.display_name,onChange:s=>C({...i,display_name:s.target.value}),placeholder:"Your display name"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-bio",className:"block text-sm font-medium mb-2",children:"Bio"}),e.jsx("textarea",{id:"settings-bio",value:i.bio,onChange:s=>C({...i,bio:s.target.value}),rows:3,maxLength:280,className:"flex w-full rounded-2xl border border-input bg-secondary px-4 py-2.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:border-foreground
1/60 focus-visible:bg-background focus-visible:ring-2 focus-visible:ring-ring/30 focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50 transition-[background-color,border-color,box-shadow] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] resize-none",placeholder:"Tell us about yourself"}),e.jsx("div",{className:"flex justify-end mt-1",children:e.jsxs("span",{className:`text-xs tabular-nums ${i.bio.length>260?"text-destructive":"text-muted-foreground"}`,children:[i.bio.length,"/280"]})})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-website",className:"block text-sm font-medium mb-2",children:"Website"}),e.jsx(P,{id:"settings-website",type:"url",value:i.website_url,onChange:s=>C({...i,website_url:s.target.value}),placeholder:"https://yourwebsite.com"})]}),e.jsxs("div",{className:"pt-4 border-t border-border",children:[e.jsx("h3",{className:"text-sm font-medium mb-4",children:"Social Links"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-instagram",className:"block text-sm font-medium mb-2",children:"Instagram"}),e.jsx(P,{id:"settings-instagram",type:"text",value:i.instagram_url,onChange:s=>C({...i,instagram_url:s.target.value}),onBlur:()=>z("instagram","instagram_url"),className:E.instagram?"border-destructive":"",placeholder:"@username or full URL"}),E.instagram&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:E.instagram})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-behance",className:"block text-sm font-medium mb-2",children:"Behance"}),e.jsx(P,{id:"settings-behance",type:"text",value:i.behance_url,onChange:s=>C({...i,behance_url:s.target.value}),onBlur:()=>z("behance","behance_url"),className:E.behance?"border-destructive":"",placeholder:"@username or full URL"}),E.behance&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:E.behance})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-twitter",className:"block text-sm font-medium mb-2",children:"Twitter / X"}),e.jsx(P,{id:"settings-twitter",type:"text",value:i.twitter_url,onChange:s=>C({...i,twitter_url:s.target.value}),onBlur:()=>z("twitter","twitter_url"),className:E.twitter?"border-destructive":"",placeholder:"@username or full URL"}),E.twitter&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:E.twitter})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-linkedin",className:"block text-sm font-medium mb-2",children:"LinkedIn"}),e.jsx(P,{id:"settings-linkedin",type:"text",value:i.linkedin_url,onChange:s=>C({...i,linkedin_url:s.target.value}),onBlur:()=>z("linkedin","linkedin_url"),className:E.linkedin?"border-destructive":"",placeholder:"username or full URL"}),E.linkedin&&e.jsx("p",{className:"text-xs text-destructive mt-1",children:E.linkedin})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-location",className:"block text-sm font-medium mb-2",children:"Location"}),e.jsx(P,{id:"settings-location",type:"text",value:i.location,onChange:s=>C({...i,location:s.target.value}),placeholder:"City, Country"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-company",className:"block text-sm font-medium mb-2",children:"Company"}),e.jsx(P,{id:"settings-company",type:"text",value:i.company,onChange:s=>C({...i,company:s.target.value}),placeholder:"Company name"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"settings-job-title",className:"block text-sm font-medium mb-2",children:"Job Title"}),e.jsx(P,{id:"settings-job-title",type:"text",value:i.job_title,onChange:s=>C({...i,job_title:s.target.value}),placeholder:"Your role"})]})]}),e.jsxs("div",{className:"pt-6 border-t border-border",children:[e.jsx("h3",{className:"text-sm font-medium mb-4",children:"Profile Verification"}),t?.is_verified?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-emerald-600 dark:text-emerald-400",children:[e.jsx(U,{className:"w-4 h-4"}),e.jsx("span",{children:"Your profile is verified"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Request verification to get a verified badge on your profile."}),e.jsx(S,{variant:"outline",size:"sm",disabled:we||_e,onClick:async()=>
1{if(!(!a?.id||!t?.username)){Ne(!0);try{const{error:s}=await y.rpc("request_verification");if(s)throw s;h.success("Verification request sent"),rs(!0)}catch{h.error("Failed to send request")}finally{Ne(!1)}}},children:we?"Sending...":_e?"Request Sent":"Request Verification"})]})]})]}),e.jsx("div",{className:"pt-6 border-t border-border hidden md:block",children:e.jsxs("button",{onClick:Pe,disabled:b.isPending||!q,className:"flex items-center gap-2 px-6 py-2.5 bg-foreground text-background text-sm font-medium hover:bg-foreground/90 transition-[background-color,opacity] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] disabled:opacity-40 disabled:cursor-not-allowed rounded-full",children:[Y?e.jsx(U,{className:"w-4 h-4"}):e.jsx(Le,{className:"w-4 h-4"}),b.isPending?"Saving...":Y?"Saved":"Save Changes"]})})]})]}),D==="account"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium mb-4",children:"Account Settings"}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(Ws,{className:"w-4 h-4"}),"Email"]}),es?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"p-3 bg-muted/50 border border-border text-sm rounded-lg",children:[e.jsx("p",{className:"text-muted-foreground mb-1",children:"Current email:"}),e.jsx("p",{className:"font-medium",children:t?.email})]}),e.jsx(P,{type:"email",value:T,onChange:s=>se(s.target.value),placeholder:"Enter new email address"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{onClick:us,disabled:te||!T.trim(),children:te?"Updating...":"Update Email"}),e.jsx(S,{variant:"outline",onClick:()=>{re(!1),se("")},disabled:te,children:"Cancel"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"You'll receive confirmation emails at both addresses. Click the links to complete the change."})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsx(P,{type:"email",value:t?.email||"",disabled:!0,className:"flex-1"}),e.jsx(S,{onClick:()=>{os(()=>{re(!0)})},variant:"outline",children:"Change"})]})]})})]}),e.jsxs("div",{className:"pt-6 border-t border-border",children:[e.jsxs("h3",{className:"text-sm font-medium mb-4 flex items-center gap-2",children:[e.jsx(kt,{className:"w-4 h-4"}),"Password"]}),as?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"You signed in with Google. To set a password for your account, click the button below to receive a setup link via email."}),e.jsx(S,{onClick:Ce,disabled:B,variant:"outline",children:B?"Sending...":"Set Up Password"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Click the button below to receive a password reset link via email."}),e.jsx(S,{onClick:Ce,disabled:B,variant:"outline",children:B?"Sending...":"Send Password Reset Email"})]})]}),e.jsxs("div",{className:"pt-6 border-t border-border",children:[e.jsx("h3",{className:"text-sm font-medium text-destructive mb-2",children:"Danger Zone"}),u.data?.purge_after&&e.jsxs("div",{className:"mb-4 rounded-lg border border-destructive/40 bg-destructive/5 p-4",children:[e.jsxs("p",{className:"text-sm mb-3",children:["This account is scheduled for deletion on"," ",e.jsx("strong",{children:new Date(u.data.purge_after).toLocaleDateString()}),". It is hidden from everyone until then. Cancel to bring it back."]}),e.jsx("button",{onClick:()=>g.mutate(),disabled:g.isPending,className:"px-4 py-2 border border-foreground text-sm rounded-full hover:bg-foreground hover:text-background transition-colors disabled:opacity-60",children:g.isPending?"Cancelling…":"Cancel deletion"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Deactivate your account now and delete everything after 30 days."}),e.jsx("button",{onClick:()=>J(!0),className:"px-4 py-2 border border-destructive text-destructive text-sm hover:bg-destructive hover:text-destructive-foreground transition-colors rounded-full",children:"Delete Account"}),Xe&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs("div",{className:"bg-background border border-border p-6 max-w-md w-full mx-4 rounded-lg",children:[e.jsx("h3",{className:"text-lg font-semibold text-destructive mb-2",children:"Delete Account"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Your account is deactivated immediately and permanently deleted after 30 days. Sign in within that window to cancel. After 30 days, your data cannot be recovered."}),e.jsxs("p",{className:"text-sm mb-4",children:["Type ",e.jsx("strong",{children:"DELETE"})," to confirm:"]}),e.jsx(P,{type:"text",value:ee,onChange:s=>ge(s.target.value),className:"mb-4",placeholder:"Type DELETE"}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx(S,{variant:"outline",onClick:()=>{J(!1),ge("")},disabled:Z,children:"Cancel"}),e.jsx(S,{variant:"destructive",onClick:hs,disabled:Z||ee!=="DELETE",children:Z?"Deleting...":"Delete Account"})]})]})})]})]}),D==="subscription"&&e.jsx("div",{className:"space-y-6",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium mb-4",children:"Subscription"}),j?e.jsx("div",{className:"space-y-3",children:[1,2].map(s=>e.jsx("div",{className:"h-20 rounded-lg bg-secondary skeleton-shimmer"},s))}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:`p-6 border rounded-lg ${x?"border-primary bg-primary/5":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[x?e.jsx("div",{className:"w-10 h-10 bg-primary flex items-center justify-center rounded-lg",children:e.jsx(W,{className:"w-5 h-5 text-primary-foreground"})}):e.jsx("div",{className:"w-10 h-10 bg-secondary flex items-center justify-center rounded-lg",children:e.jsx(Re,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium",children:x?"Pro Plan":"Free Plan"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:x?"Full access to all features":"Basic features"})]})]}),x&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-3 py-1 bg-background text-foreground text-xs rounded-full",children:[e.jsx(U,{className:"w-3 h-3"}),"Active"]})]}),x&&e.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-4 border-t border-border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-mono uppercase tracking-widest text-muted-foreground mb-1",children:"Status"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${K?"bg-acid":"bg-green-500"}`}),e.jsx("span",{className:"text-sm",children:K?`Trial — ${de} day${de!==1?"s":""} remaining`:"Active subscription"})]})]}),p&&!K&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-mono uppercase tracking-widest text-muted-foreground mb-1",children:"Next billing"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Gs,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:Ae(p)})]})]}),t?.upgraded_at&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-mono uppercase tracking-widest text-muted-foreground mb-1",children:"Pro member since"}),e.jsx("span",{className:"text-sm",children:Ae(t.upgraded_at)})]})]})]}),e.jsxs("div",{className:"border border-border p-6 rounded-lg",children:[e.jsx("h3",{className:"text-sm font-medium mb-4",children:x?"Your Features":"Free vs Pro"}),e.jsx("ul",{className:"space-y-3",children:ys.map((s,l)=>{const w=x?s.pro:s.free;return e.jsxs("li",{className:"flex items-center gap-3 text-sm",children:[w?e.jsx(U,{className:"w-4 h-4 text-primary flex-shrink-0"}
1):e.jsx(Fe,{className:"w-4 h-4 text-muted-foreground/50 flex-shrink-0"}),e.jsxs("span",{className:w?"":"text-muted-foreground/60",children:[s.name,typeof w=="string"&&e.jsxs("span",{className:"text-muted-foreground",children:[" — ",w]})]}),!x&&s.pro&&!s.free&&e.jsx("span",{className:"text-[10px] uppercase font-medium text-primary bg-primary/10 px-1.5 py-0.5 rounded",children:"Pro"})]},l)})})]}),e.jsx("div",{className:"flex gap-3",children:x?e.jsxs(e.Fragment,{children:[_?e.jsxs(S,{variant:"outline",onClick:()=>Qe(),disabled:le,className:"flex items-center gap-2",children:[e.jsx(Ue,{className:"w-4 h-4"}),le?"Opening...":"Manage Subscription"]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground px-3 py-2 border border-border/50 rounded-md bg-muted/30",children:[e.jsx(U,{className:"w-4 h-4 text-green-500"}),e.jsx("span",{children:"Pro plan active"})]}),e.jsx(S,{variant:"ghost",onClick:()=>Je(),className:"text-muted-foreground",children:"Refresh status"})]}):e.jsxs(S,{onClick:()=>H(),disabled:O,className:"flex items-center gap-2 bg-primary text-primary-foreground hover:bg-primary/90",children:[e.jsx(W,{className:"w-4 h-4"}),O?"Processing...":"Upgrade to Pro"]})}),!j&&N&&!x&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["By upgrading, you agree to our"," ",e.jsx($e,{to:"/legal/terms",className:"underline hover:text-foreground",children:"Terms of Service"}),"."]})]})]})}),D==="notifications"&&e.jsx(Ct,{}),D==="privacy"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-lg font-medium mb-4",children:"Privacy Settings"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Show email"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Display your email on your public profile"})]}),e.jsx("button",{onClick:()=>C({...i,show_email:!i.show_email}),className:`w-10 h-6 rounded-full relative transition-colors ${i.show_email?"bg-foreground":"bg-secondary"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 rounded-full transition ${i.show_email?"right-1 bg-background":"left-1 bg-muted-foreground"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Allow comments"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Let others comment on your collections"})]}),e.jsx("button",{onClick:()=>C({...i,allow_comments:!i.allow_comments}),className:`w-10 h-6 rounded-full relative transition-colors ${i.allow_comments?"bg-foreground":"bg-secondary"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 rounded-full transition ${i.allow_comments?"right-1 bg-background":"left-1 bg-muted-foreground"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-border",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Hide likes tab"}),N&&x&&e.jsx(W,{className:"w-3.5 h-3.5 text-amber-500"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N&&x?"Hide the likes tab from your public profile":N&&!x?"Upgrade to Pro to hide your likes from public view":"Hide the likes tab from your public profile"})]}),e.jsx("button",{onClick:()=>{N&&x?C({...i,hide_likes_tab:!i.hide_likes_tab}):N&&!x&&H()},disabled:N&&!x&&O,className:`w-10 h-6 rounded-full relative transition-colors ${N&&!x?"bg-secondary opacity-50 cursor-not-allowed":i.hide_likes_tab?"bg-foreground":"bg-secondary"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 rounded-full transition ${i.hide_likes_tab&&N&&x?"right-1 bg-background":"left-1 bg-muted-foreground"}`})})]}),e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-border",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Hs,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("p",{className:"text-sm font-medium",children:"Dark Mode"}),x&&e.jsx(W,{className:"w-3.5 h-3.5 text-amber-500"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x?"Switch to dark theme for reduced eye strain":"Upgrade to Pro to unlock dark mode"})]}),e.jsx(Dt,{isPro:x,onUpgrade:()=>H(),isCheckingOut:O})]})]}),e.jsxs("div",{className:"pt-6 border-t border-border",children:[e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-secondary/50 border border-border mb-4 rounded-lg",children:[e.jsx(Oe,{className:"w-5 h-5 text-muted-foreground flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Data Protection"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Your data is protected and encrypted. We never share your personal information with third parties without your consent."})]})]}),e.jsxs("div",{className:"flex items-start gap-3 p-4 border border-border rounded-lg",children:[e.jsx(Ks,{className:"w-5 h-5 text-muted-foreground flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Export Your Data"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 mb-3",children:"Download a copy of all your personal data including profile information, collections, and saved images."}),e.jsx(S,{variant:"outline",size:"sm",disabled:ve,onClick:xs,children:ve?"Exporting...":"Download My Data"})]})]})]})]}),D==="feedback"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-medium mb-2",children:"Help Us Improve"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"We're in beta! Your feedback is essential to make Unbserved better."})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("button",{onClick:()=>{je("feedback"),Q(!0)},className:"flex items-center gap-4 p-4 border border-border rounded-lg hover:bg-secondary/50 transition-colors text-left",children:[e.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 text-blue-500",children:e.jsx(Te,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Send Feedback"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Share your thoughts, suggestions, or ideas"})]})]}),e.jsxs("button",{onClick:()=>{je("bug"),Q(!0)},className:"flex items-center gap-4 p-4 border border-border rounded-lg hover:bg-secondary/50 transition-colors text-left",children:[e.jsx("div",{className:"p-3 rounded-lg bg-primary/10 text-primary",children:e.jsx(Oe,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Report a Bug"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Found something broken? Let us know"})]})]})]}),e.jsxs("div",{className:"p-4 bg-amber-500/10 border border-amber-500/20 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-xs font-bold uppercase px-2 py-0.5 rounded bg-amber-500 text-amber-950",children:"BETA"}),e.jsx("span",{className:"text-sm font-medium",children:"We're still building!"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Unbserved is currently in beta. You might encounter bugs or missing features. Your patience and feedback help us improve!"})]})]})]})]})]}),e.jsx(Qs,{isOpen:Ze,onClose:()=>Q(!1),initialType:ts}),e.jsx(He,{isOpen:is,onClose:cs,onSuccess:ds,onVerify:ls,isVerifying:ns,title:"Confirm Identity",description:"Enter your password to continue with this action"}),ae&&e.jsx(nt,{isOpen:ss,onClose:()=>{pe(!1),ie(null)},imageSrc:ae,onCropComplete:async s=>{if(a?.id){ue(!0);try{const l=URL.createObjectURL(s);fe(l);const w=new File([s],"avatar.jpg",{type:"image/jpeg"}),R=`${a.id}/avatar.jpg`,{error:$}=await y.storage.from("avatars").upload(R,w,{upsert:!0});if($)throw $;const{data:ne}=y.storage.from("avatars").getPublicUrl(R);await b.mutateAsync({avatar_url:`${ne.publicUrl}?t=${Date.now()}`}),h.success("Avatar updated!")}catch(l){console.error("Avatar upload error:",l),h.error("Failed to upload avatar"),fe(null)}finally{ue(!1),ie(null)}}}}),D==="profile"&&q&&e.jsxs("div",{className:"fixed bottom-[calc(4rem+env(safe-area-inset-bottom,0px))] left-0 right-0 z-40 md:hidden border-t border-border bg-background/95 backdrop-blur-sm px-4 py-3 flex items-center justify-between gap-3 shadow-[0_-4px_20px_-4px_hsl(var(--foreground)/0.08)]",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"You have unsaved changes"}),e.jsxs("button",{onClick:Pe,disabled:b.isPending,className:"flex items-center gap-2 px-5 py-2 bg-foreground text-background text-sm font-medium hover:bg-foreground
1/90 transition-[background-color,opacity] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] disabled:opacity-40 disabled:cursor-not-allowed rounded-full",children:[Y?e.jsx(U,{className:"w-4 h-4"}):e.jsx(Le,{className:"w-4 h-4"}),b.isPending?"Saving...":Y?"Saved":"Save"]})]})]})}export{br as default};

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.