"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[685],{9685:(e,t,r)=>{r.d(t,{Bx:()=>C,Xb:()=>A,id:()=>k});var s=r(95155),a=r(6874),n=r.n(a),i=r(35695),l=r(12115),o=r(53999),c=r(97168),d=r(73783),h=r(18186),x=r(17576),m=r(33109),u=r(71007),f=r(381),p=r(71539),g=r(74783),b=r(54416),j=r(34835),v=r(31886),y=r(56671);let N=[{name:"Dashboard",href:"/dashboard",icon:d.A},{name:"Competitions",href:"/competitions",icon:h.A},{name:"Portfolios",href:"/portfolios",icon:x.A},{name:"Market",href:"/market",icon:m.A},{name:"Profile",href:"/profile",icon:u.A}],w=[{name:"Leaderboard",href:"/leaderboard",icon:h.A},{name:"Settings",href:"/settings",icon:f.A}];function k(){let[e,t]=(0,l.useState)(!1),r=(0,i.useRouter)(),a=async()=>{try{await (0,v.ri)(),y.oR.success("Successfully logged out"),r.push("/"),t(!1)}catch(e){y.oR.error("Failed to logout. Please try again.")}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed top-0 left-0 right-0 z-50 bg-gradient-to-br from-slate-900 via-purple-900 to-slate-900 md:hidden",children:(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",onClick:()=>r.push("/"),children:[(0,s.jsx)("div",{className:"p-1.5 bg-gradient-to-r from-purple-500 to-blue-500 rounded-lg",children:(0,s.jsx)(p.A,{className:"h-5 w-5 text-white"})}),(0,s.jsx)("div",{children:(0,s.jsx)("h1",{className:"text-lg font-bold bg-gradient-to-r from-purple-400 to-blue-400 bg-clip-text text-transparent",children:"Profitly"})})]}),(0,s.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,s.jsx)("div",{className:"w-8 h-8 bg-gradient-to-r from-purple-500 to-blue-500 rounded-full flex items-center justify-center",children:(0,s.jsx)(u.A,{className:"h-4 w-4 text-white"})}),(0,s.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>t(!0),className:"text-gray-400 hover:text-white",children:(0,s.jsx)(g.A,{className:"h-5 w-5"})})]})]})}),e&&(0,s.jsxs)("div",{className:"fixed inset-0 z-50 md:hidden",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black/50",onClick:()=>t(!1)}),(0,s.jsx)("div",{className:"absolute top-0 right-0 w-80 max-w-[85vw] h-full bg-slate-900 border-l border-slate-800",children:(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-slate-800",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("div",{className:"w-8 h-8 bg-gradient-to-r from-purple-500 to-blue-500 rounded-full flex items-center justify-center",children:(0,s.jsx)(u.A,{className:"h-4 w-4 text-white"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-white text-sm",children:(0,o.T)()}),(0,s.jsx)("p",{className:"text-xs text-gray-400",children:"Level 5 Trader"})]})]}),(0,s.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>t(!1),className:"text-gray-400 hover:text-white",children:(0,s.jsx)(b.A,{className:"h-5 w-5"})})]}),(0,s.jsxs)("nav",{className:"flex-1 p-4 space-y-2",children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2",children:"Main Navigation"}),N.map(e=>(0,s.jsx)(P,{item:e,onClose:()=>t(!1)},e.name))]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2",children:"More"}),w.map(e=>(0,s.jsx)(P,{item:e,onClose:()=>t(!1)},e.name))]})]}),(0,s.jsx)("div",{className:"p-4 border-t border-slate-800",children:(0,s.jsxs)(c.$,{variant:"ghost",className:"w-full justify-start text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:a,children:[(0,s.jsx)(j.A,{className:"h-4 w-4 mr-2"}),"Logout"]})})]})})]})]})}function P(e){let{item:t,onClose:r}=e,a=(0,i.usePathname)(),l=a===t.href||a.startsWith("".concat(t.href,"/"));return(0,s.jsx)(n(),{href:t.href,onClick:r,children:(0,s.jsxs)(c.$,{variant:"ghost",className:(0,o.cn)("w-full justify-start space-x-3 h-11 mb-1",l?"bg-gradient-to-r from-purple-500/20 to-blue-500/20 text-purple-300 border border-purple-500/30":"text-gray-400 hover:text-white hover:bg-slate-800"),children:[(0,s.jsx)(t.icon,{className:"h-4 w-4"}),(0,s.jsx)("span",{children:t.name})]})})}function A(){let e=(0,i.usePathname)();return(0,s.jsx)("div",{className:"fixed bottom-0 left-0 right-0 z-40 bg-slate-900/95 backdrop-blur-sm border-t border-slate-800 md:hidden",children:(0,s.jsx)("div",{className:"flex items-center justify-around px-2 py-2",children:N.map(t=>{let r=e===t.href||e.startsWith("".concat(t.href,"/"));return(0,s.jsx)(n(),{href:t.href,className:"flex-1",children:(0,s.jsxs)("div",{className:(0,o.cn)("flex flex-col items-center justify-center py-2 px-1 rounded-lg transition-colors",r?"text-purple-400":"text-gray-500 hover:text-gray-300"),children:[(0,s.jsx)(t.icon,{className:(0,o.cn)("h-5 w-5 mb-1",r&&"text-purple-400")}),(0,s.jsx)("span",{className:"text-xs font-medium truncate",children:t.name}),r&&(0,s.jsx)("div",{className:"w-4 h-0.5 bg-purple-400 rounded-full mt-1"})]})},t.name)})})})}function C(){let e=(0,i.usePathname)(),t=(0,i.useRouter)(),r=async()=>{try{await (0,v.ri)(),y.oR.success("Successfully logged out"),t.push("/")}catch(e){y.oR.error("Failed to logout. Please try again.")}};return(0,s.jsx)("div",{className:"fixed inset-y-0 left-0 z-50 w-64 bg-slate-900/95 backdrop-blur-sm border-r border-slate-800 hidden md:block",children:(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsx)("div",{className:"flex items-center px-6 py-4 border-b border-slate-800",children:(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)("div",{className:"p-2 bg-gradient-to-r from-purple-500 to-blue-500 rounded-lg",children:(0,s.jsx)(p.A,{className:"h-6 w-6 text-white"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-xl font-bold bg-gradient-to-r from-purple-400 to-blue-400 bg-clip-text text-transparent",children:"Profitly"}),(0,s.jsx)("p",{className:"text-xs text-gray-400",children:"Pro Trading"})]})]})}),(0,s.jsx)("nav",{className:"flex-1 px-4 py-6 space-y-2",children:[...N,...w].map(t=>{let r=e===t.href||e.startsWith("".concat(t.href,"/"));return(0,s.jsx)(n(),{href:t.href,children:(0,s.jsxs)(c.$,{variant:"ghost",className:(0,o.cn)("w-full justify-start space-x-3 h-12",r?"bg-gradient-to-r from-purple-500/20 to-blue-500/20 text-purple-300 border border-purple-500/30":"text-gray-400 hover:text-white hover:bg-slate-800"),children:[(0,s.jsx)(t.icon,{className:"h-5 w-5"}),(0,s.jsx)("span",{children:t.name})]})},t.name)})}),(0,s.jsxs)("div",{className:"p-4 border-t border-slate-800",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-3 mb-4",children:[(0,s.jsx)("div",{className:"w-10 h-10 bg-gradient-to-r from-purple-500 to-blue-500 rounded-full flex items-center justify-center",children:(0,s.jsx)(u.A,{className:"h-5 w-5 text-white"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-white",children:(0,o.T)()}),(0,s.jsx)("p",{className:"text-xs text-gray-400",children:"Level 5 Trader"})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(c.$,{variant:"ghost",size:"sm",className:"w-full justify-start text-gray-400 hover:text-white",children:[(0,s.jsx)(f.A,{className:"h-4 w-4 mr-2"}),"Settings"]}),(0,s.jsxs)(c.$,{variant:"ghost",size:"sm",className:"w-full justify-start text-gray-400 hover:text-white",onClick:r,children:[(0,s.jsx)(j.A,{className:"h-4 w-4 mr-2"}),"Logout"]})]})]})]})})}},31886:(e,t,r)=>{r.d(t,{iD:()=>l,kz:()=>i,ri:()=>o});let s=(0,r(88783).$_)("production","NEXT_PUBLIC_API_URL")+"/api/v1";class a extends Error{constructor(e){super(e),this.name="APIErrorResponse"}}let n=async e=>{let t=await e.json();throw new a({"email already exists":"This email is already registered. Please use a different email or try logging in.","username already exists":"This username is already taken. Please choose a different username.","invalid credentials":"Invalid email or password. Please try again.","authorization header required":"Please log in to access this resource.","invalid token":"Your session has expired. Please log in again."}[t.error]||t.error||"An unexpected error occurred")},i=async e=>{try{let t=await fetch("".concat(s,"/auth/register"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)return n(t);return t.json()}catch(e){if(e instanceof a)throw e;throw new a("Network error. Please check your connection and try again.")}},l=async e=>{try{let t=await fetch("".concat(s,"/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)return n(t);return t.json()}catch(e){if(e instanceof a)throw e;throw new a("Network error. Please check your connection and try again.")}},o=async()=>{try{let e=await fetch("".concat(s,"/auth/logout"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(localStorage.getItem("token"))}});if(!e.ok)return n(e);localStorage.removeItem("token"),document.cookie="token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"}catch(e){if(e instanceof a)throw e;throw new a("Network error. Please check your connection and try again.")}}},53999:(e,t,r)=>{r.d(t,{J:()=>i,T:()=>l,cn:()=>n});var s=r(52596),a=r(39688);function n(){for(var e=arguments.length,t=Array(e),r=0;r{let e=localStorage.getItem("token");return e?JSON.parse(window.atob(e.split(".")[1])):""},l=()=>i().username},88783:(e,t,r)=>{r.d(t,{$_:()=>n});let s={NEXT_PUBLIC_API_URL:"https://portfolio-backend-1-6akd.onrender.com"},a={development:s,stage:s,production:{NEXT_PUBLIC_API_URL:"https://portfolio-backend-1-6akd.onrender.com"}};function n(e,t){return a[e][t]}},97168:(e,t,r)=>{r.d(t,{$:()=>c});var s=r(95155),a=r(12115),n=r(99708),i=r(74466),l=r(53999);let o=(0,i.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),c=a.forwardRef((e,t)=>{let{className:r,variant:a,size:i,asChild:c=!1,...d}=e,h=c?n.DX:"button";return(0,s.jsx)(h,{className:(0,l.cn)(o({variant:a,size:i,className:r})),ref:t,...d})});c.displayName="Button"}}]);