(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7122],{2355:(e,s,t)=>{"use strict";t.d(s,{d:()=>u,t:()=>o});var r=t(5155),n=t(2115);let a=(0,n.createContext)(void 0);function o(e){let{children:s}=e,[t,o]=(0,n.useState)([]),u=(0,n.useCallback)(e=>{o(s=>s.filter(s=>s.id!==e))},[]),l=(0,n.useCallback)(e=>{var s;let t=Math.random().toString(36).substr(2,9),r=5e3;switch(e.type){case"success":r=4e3;break;case"error":r=7e3;break;case"warning":r=6e3;break;case"info":r=5e3}let n={id:t,duration:null!=(s=e.duration)?s:r,...e};o(e=>{let s=[...e,n];return s.length>5?s.slice(-5):s}),n.duration&&n.duration>0&&setTimeout(()=>{u(t)},n.duration)},[u]),i=(0,n.useCallback)((e,s)=>{l({type:"success",message:e,title:s})},[l]),c=(0,n.useCallback)((e,s)=>{l({type:"error",message:e,title:s})},[l]),d=(0,n.useCallback)((e,s)=>{l({type:"warning",message:e,title:s})},[l]),h=(0,n.useCallback)((e,s)=>{l({type:"info",message:e,title:s})},[l]);return(0,r.jsx)(a.Provider,{value:{toasts:t,addToast:l,removeToast:u,showSuccess:i,showError:c,showWarning:d,showInfo:h},children:s})}function u(){let e=(0,n.useContext)(a);if(!e)throw Error("useToast must be used within a ToastProvider");return e}},2454:(e,s,t)=>{Promise.resolve().then(t.bind(t,7404))},5695:(e,s,t)=>{"use strict";var r=t(8999);t.o(r,"useParams")&&t.d(s,{useParams:function(){return r.useParams}}),t.o(r,"usePathname")&&t.d(s,{usePathname:function(){return r.usePathname}}),t.o(r,"useRouter")&&t.d(s,{useRouter:function(){return r.useRouter}}),t.o(r,"useSearchParams")&&t.d(s,{useSearchParams:function(){return r.useSearchParams}})},7404:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>i});var r=t(5155),n=t(2108),a=t(5695),o=t(2115),u=t(2355),l=t(6821);function i(e){let{children:s,params:t}=e,{data:i,status:c}=(0,n.useSession)(),d=(0,a.useRouter)(),{showError:h}=(0,u.d)(),[f,g]=(0,o.useState)(""),[m,C]=(0,o.useState)(!0);return((0,o.useEffect)(()=>{(async()=>{g((await t).locale)})()},[t]),(0,o.useEffect)(()=>{var e;if(console.log("\uD83C\uDFE0 Client Layout - Session check:",{status:c,hasSession:!!i,userRole:(null==i?void 0:i.user)?i.user.role:"no-session",userName:null==i||null==(e=i.user)?void 0:e.name}),"loading"===c)return;if(!(null==i?void 0:i.user)){console.log("❌ Client Layout - No session, redirecting to login"),h("Please login to access this page","Access Denied"),d.push("/".concat(f,"/login"));return}let s=i.user.role;if(console.log("\uD83D\uDC64 Client Layout - User role:",s),"CLIENT"!==s){console.log("❌ Client Layout - Wrong role, redirecting"),h("This page is only accessible to clients","Access Denied"),"FREELANCER"===s?d.push("/".concat(f,"/freelancer/my-projects")):d.push("/".concat(f));return}console.log("✅ Client Layout - Access granted"),C(!1)},[i,c,d,f,h]),"loading"===c||m)?(0,r.jsx)("div",{className:"d-flex align-items-center justify-content-center loading-container",children:(0,r.jsx)("div",{className:"spinner-border text-primary",role:"status",children:(0,r.jsx)("span",{className:"visually-hidden",children:"Loading..."})})}):(null==i?void 0:i.user)&&"CLIENT"===i.user.role?(0,r.jsxs)(r.Fragment,{children:[s,(0,r.jsx)(l.default,{locale:f})]}):null}}},e=>{e.O(0,[2108,6821,8441,5964,7358],()=>e(e.s=2454)),_N_E=e.O()}]);