"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2956],{4139:(e,t,r)=>{r.d(t,{O:()=>i});var n=r(95155),o=r(12115),l=r(73229),a=r(6707),s=r(18955);function i(e){let{children:t,allowedRoles:r}=e,{user:i,isLoading:d}=(0,a.A)(),c=(0,l.rd)(),u=(0,s.c)("common");return((0,o.useEffect)(()=>{d||(i?r&&!r.includes(i.role)&&c.push("/"):c.push("/login"))},[i,d,r,c]),d)?(0,n.jsx)("div",{className:"min-h-screen bg-gray-50 dark:bg-[#0f1419] flex items-center justify-center",children:(0,n.jsxs)("div",{className:"text-center",children:[(0,n.jsx)("div",{className:"inline-block animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600"}),(0,n.jsx)("p",{className:"mt-4 text-gray-600 dark:text-gray-400",children:u("loading")})]})}):i&&(!r||r.includes(i.role))?(0,n.jsx)(n.Fragment,{children:t}):null}},6707:(e,t,r)=>{r.d(t,{A:()=>s,AuthProvider:()=>a});var n=r(95155),o=r(12115);let l=(0,o.createContext)(void 0);function a(e){let{children:t}=e,[r,a]=(0,o.useState)(null),[s,i]=(0,o.useState)(null),[d,c]=(0,o.useState)(!0);(0,o.useEffect)(()=>{window.KOMERO=!0;let e=localStorage.getItem("authToken"),t=localStorage.getItem("user");if(e&&t)try{a(JSON.parse(t)),i(e)}catch(e){localStorage.removeItem("authToken"),localStorage.removeItem("user")}c(!1)},[]);let u=async(e,t)=>{try{let r=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,password:t})});if(!r.ok)return null;let n=await r.json(),o=n.token;return localStorage.setItem("authToken",o),localStorage.setItem("user",JSON.stringify(n.user)),a(n.user),i(o),{user:n.user,token:o}}catch(e){return null}};return(0,n.jsx)(l.Provider,{value:{user:r,token:s,login:u,logout:()=>{a(null),i(null),localStorage.removeItem("user"),localStorage.removeItem("authToken")},isLoading:d,getToken:()=>s||localStorage.getItem("authToken")},children:t})}function s(){let e=(0,o.useContext)(l);if(!e)throw Error("useAuth must be used within an AuthProvider");return e}},57376:(e,t,r)=>{r.d(t,{z:()=>d});var n=r(95155),o=r(6707),l=r(73229),a=r(95517),s=r(18955);let i={bg:"#141414",surface2:"#252525",border:"#2c2c2c",text:"#d0d0d0",muted:"#888",dim:"#4a4a4a",accent:"#3b97e3",danger:"#e34b3b"};function d(e){var t,r;let{title:d,description:c,showBackButton:u=!1,actionButton:h}=e,{user:g,logout:p}=(0,o.A)(),x=(0,l.rd)(),m=(0,s.c)("navigation");return(0,n.jsxs)("header",{style:{background:i.bg,borderBottom:"1px solid ".concat(i.border),position:"sticky",top:0,zIndex:50},children:[(0,n.jsxs)("div",{style:{maxWidth:1280,margin:"0 auto",padding:"0 20px",height:48,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0,flex:1},children:[u?(0,n.jsx)(l.N_,{href:"/",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:5,background:i.surface2,border:"1px solid ".concat(i.border),color:i.muted,flexShrink:0,transition:"color 0.12s, border-color 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color=i.accent,e.currentTarget.style.borderColor=i.accent},onMouseLeave:e=>{e.currentTarget.style.color=i.muted,e.currentTarget.style.borderColor=i.border},title:"Back",children:(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M19 12H5M12 5l-7 7 7 7"})})}):(0,n.jsx)(l.N_,{href:"/",style:{flexShrink:0,display:"flex",alignItems:"center",gap:7},children:(0,n.jsx)("img",{src:"/branding/logo.png",alt:"KOMERO",style:{height:22,width:"auto",objectFit:"contain"},onError:e=>e.currentTarget.style.display="none"})}),(0,n.jsx)("span",{style:{width:1,height:16,background:i.border,flexShrink:0}}),(0,n.jsxs)("div",{style:{minWidth:0},children:[(0,n.jsx)("h1",{style:{fontSize:16,fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",color:i.text,fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d}),(0,n.jsx)("p",{style:{fontSize:14,color:i.dim,fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",display:"none"},className:"hidden-desc",children:c})]})]}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[(null==g?void 0:g.username)&&(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",borderRadius:4,background:i.surface2,border:"1px solid ".concat(i.border)},children:[(0,n.jsx)("div",{style:{width:18,height:18,borderRadius:"50%",background:i.accent,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:800,color:"#fff",fontFamily:"monospace",flexShrink:0},children:null!=(r=null==(t=g.username[0])?void 0:t.toUpperCase())?r:"U"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[(0,n.jsx)("span",{style:{fontSize:14,fontWeight:700,color:i.text,fontFamily:"monospace",lineHeight:1.2,whiteSpace:"nowrap"},children:g.username}),g.email&&(0,n.jsx)("span",{style:{fontSize:11,color:i.muted,fontFamily:"monospace",lineHeight:1.2,whiteSpace:"nowrap"},children:g.email})]})]}),(0,n.jsx)("div",{style:{padding:"3px 6px",borderRadius:4,background:i.surface2,border:"1px solid ".concat(i.border),display:"flex",alignItems:"center"},children:(0,n.jsx)(a.c,{})}),h,(0,n.jsxs)("button",{onClick:()=>{p(),x.push("/login")},title:m("logout"),style:{display:"flex",alignItems:"center",gap:5,padding:"4px 8px",borderRadius:4,background:"transparent",border:"1px solid transparent",fontSize:14,fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",fontFamily:"monospace",color:i.muted,cursor:"pointer",transition:"color 0.12s, border-color 0.12s, background 0.12s"},onMouseEnter:e=>{e.currentTarget.style.color=i.danger,e.currentTarget.style.borderColor="rgba(227,75,59,0.3)",e.currentTarget.style.background="rgba(227,75,59,0.06)"},onMouseLeave:e=>{e.currentTarget.style.color=i.muted,e.currentTarget.style.borderColor="transparent",e.currentTarget.style.background="transparent"},children:[(0,n.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:(0,n.jsx)("path",{d:"M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4M16 17l5-5-5-5M21 12H9"})}),(0,n.jsx)("span",{className:"logout-label",children:m("logout")})]})]})]}),(0,n.jsx)("style",{children:"\n @media (max-width: 640px) {\n .logout-label { display: none; }\n .hidden-desc { display: none !important; }\n }\n @media (min-width: 768px) {\n .hidden-desc { display: block !important; }\n }\n "})]})}},73229:(e,t,r)=>{r.d(t,{N_:()=>l,a8:()=>s,rd:()=>i});var n=r(55251);let o=(0,r(84497).A)({locales:["en","ka"],defaultLocale:"ka",localePrefix:"always"}),{Link:l,redirect:a,usePathname:s,useRouter:i}=(0,n.A)(o)},95517:(e,t,r)=>{r.d(t,{c:()=>s});var n=r(95155),o=r(902),l=r(73229),a=r(12115);function s(){let e=(0,o.Ym)(),t=(0,l.rd)(),r=(0,l.a8)(),[s,i]=(0,a.useTransition)();return(0,n.jsx)("div",{className:"flex items-center gap-1",children:[{code:"en",label:"EN"},{code:"ka",label:"KA"}].map(o=>{let l=o.code===e;return(0,n.jsx)("button",{onClick:()=>{var n;(n=o.code)===e||s||i(()=>{t.push(r,{locale:n})})},disabled:s,className:"px-2.5 py-1 text-[12px] font-extrabold rounded-md transition-all duration-200 ".concat(l?"bg-brand-500 text-white shadow-sm":"text-gray-500 hover:text-gray-900 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800"," ").concat(s?"opacity-50 cursor-not-allowed":""),children:o.label},o.code)})})}}}]);