"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[238],{4274:function(e,r,t){t.d(r,{z:function(){return l}});var a=t(7437),s=t(2265);let n={primary:"bg-primary-500 hover:bg-primary-600 active:bg-primary-700 text-white shadow-sm disabled:bg-primary-300",secondary:"bg-secondary-500 hover:bg-secondary-600 active:bg-secondary-700 text-white shadow-sm disabled:bg-secondary-300",ghost:"bg-transparent hover:bg-gray-100 active:bg-gray-200 text-gray-700 dark:hover:bg-gray-800 dark:active:bg-gray-700 dark:text-gray-200",danger:"bg-error-500 hover:bg-error-600 active:bg-error-700 text-white shadow-sm disabled:bg-error-300"},o={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"},l=s.forwardRef((e,r)=>{let{variant:t="primary",size:s="md",isLoading:l=!1,fullWidth:i=!1,className:c="",disabled:d,children:u,...m}=e,h="".concat("inline-flex items-center justify-center font-semibold rounded-md transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-60"," ").concat(n[t]," ").concat(o[s]," ").concat(i?"w-full":""," ").concat(c).trim();return(0,a.jsxs)("button",{ref:r,className:h,disabled:d||l,"aria-busy":l,...m,children:[l&&(0,a.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24","aria-hidden":"true",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),u]})});l.displayName="Button"},3607:function(e,r,t){t.d(r,{X:function(){return s}});var a=t(7437);let s=t(2265).forwardRef((e,r)=>{let{label:t,error:s,className:n="",id:o,...l}=e,i=o||"checkbox-".concat(Math.random().toString(36).substr(2,9)),c="".concat(i,"-error"),d=!!s;return(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)("div",{className:"flex items-center h-5",children:(0,a.jsx)("input",{ref:r,type:"checkbox",id:i,className:"".concat("h-4 w-4 rounded border-gray-300 text-primary-600 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-800 dark:ring-offset-gray-900"," ").concat(d?"border-error-500":""," ").concat(n).trim(),"aria-invalid":d,"aria-describedby":d?c:void 0,...l})}),t&&(0,a.jsxs)("div",{className:"ml-3 text-sm",children:[(0,a.jsx)("label",{htmlFor:i,className:"text-gray-700 dark:text-gray-200",children:t}),s&&(0,a.jsx)("p",{className:"text-error-500 mt-1",id:c,role:"alert",children:s})]})]})});s.displayName="Checkbox"},3813:function(e,r,t){t.d(r,{I:function(){return s}});var a=t(7437);let s=t(2265).forwardRef((e,r)=>{let{type:t="text",label:s,error:n,helperText:o,fullWidth:l=!1,leftIcon:i,rightIcon:c,className:d="",id:u,required:m,disabled:h,...x}=e,g=u||"input-".concat(Math.random().toString(36).substr(2,9)),y="".concat(g,"-error"),f="".concat(g,"-helper"),p=!!n,b=i||c?"px-10 py-2":"px-4 py-2",v="".concat("block w-full rounded-md border transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-offset-0"," ").concat(p?"border-error-500 focus:border-error-500 focus:ring-error-500":"border-gray-300 focus:border-primary-500 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-800 dark:text-white"," ").concat("disabled:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-60 dark:disabled:bg-gray-900"," ").concat(b," ").concat(d).trim();return(0,a.jsxs)("div",{className:l?"w-full":"",children:[s&&(0,a.jsxs)("label",{htmlFor:g,className:"block text-sm font-medium text-gray-700 dark:text-gray-200 mb-1",children:[s,m&&(0,a.jsx)("span",{className:"text-error-500 ml-1","aria-label":"required",children:"*"})]}),(0,a.jsxs)("div",{className:"relative",children:[i&&(0,a.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none text-gray-400",children:i}),(0,a.jsx)("input",{ref:r,type:t,id:g,className:v,"aria-invalid":p,"aria-describedby":p?y:o?f:void 0,required:m,disabled:h,...x}),c&&(0,a.jsx)("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none text-gray-400",children:c}),p&&(0,a.jsx)("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-error-500",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:(0,a.jsx)("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",clipRule:"evenodd"})})})]}),n&&(0,a.jsx)("p",{className:"mt-1 text-sm text-error-500",id:y,role:"alert",children:n}),o&&!n&&(0,a.jsx)("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",id:f,children:o})]})});s.displayName="Input"},1649:function(e,r,t){t.d(r,{r:function(){return o}});var a=t(7437),s=t(7648);t(2265);let n={primary:"text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300",secondary:"text-secondary-600 hover:text-secondary-700 dark:text-secondary-400 dark:hover:text-secondary-300",neutral:"text-gray-700 hover:text-gray-900 dark:text-gray-300 dark:hover:text-gray-100"},o=e=>{let{href:r,children:t,variant:o="primary",external:l=!1,className:i="",onClick:c}=e,d="".concat("underline decoration-1 underline-offset-2 hover:decoration-2 transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 rounded-sm"," ").concat(n[o]," ").concat(i).trim();return l?(0,a.jsx)("a",{href:r,className:d,target:"_blank",rel:"noopener noreferrer",onClick:c,children:t}):(0,a.jsx)(s.default,{href:r,className:d,onClick:c,children:t})}},5965:function(e,r,t){t.d(r,{g:function(){return n}});var a=t(7437);t(2265);var s=t(1649);let n=e=>{let{children:r,title:t,subtitle:n}=e;return(0,a.jsxs)("div",{className:"min-h-screen flex flex-col bg-gray-50 dark:bg-gray-900",children:[(0,a.jsx)("header",{className:"py-6",children:(0,a.jsx)("div",{className:"max-w-md mx-auto px-4 sm:px-6 lg:px-8",children:(0,a.jsx)(s.r,{href:"/",variant:"neutral",className:"no-underline",children:(0,a.jsx)("h1",{className:"text-2xl font-bold text-primary-600 dark:text-primary-400 text-center",children:"MoreThanADiagnosis"})})})}),(0,a.jsx)("main",{className:"flex-1 flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8",children:(0,a.jsxs)("div",{className:"w-full max-w-md space-y-8",children:[(t||n)&&(0,a.jsxs)("div",{className:"text-center",children:[t&&(0,a.jsx)("h2",{className:"text-3xl font-bold text-gray-900 dark:text-white",children:t}),n&&(0,a.jsx)("p",{className:"mt-2 text-sm text-gray-600 dark:text-gray-400",children:n})]}),(0,a.jsx)("div",{className:"bg-white dark:bg-gray-800 py-8 px-6 shadow-lg rounded-lg",children:r})]})}),(0,a.jsx)("footer",{className:"py-6",children:(0,a.jsx)("div",{className:"max-w-md mx-auto px-4 sm:px-6 lg:px-8",children:(0,a.jsxs)("p",{className:"text-center text-sm text-gray-600 dark:text-gray-400",children:["\xa9 ",new Date().getFullYear()," MoreThanADiagnosis. All rights reserved."]})})})]})}},4463:function(e,r,t){t.d(r,{h:function(){return l}});var a=t(2265),s=t(3464);let n="https://mtd.runfoo.run/api/v1",o=s.Z.create({baseURL:n,headers:{"Content-Type":"application/json"},timeout:3e4});function l(e){let[r,t]=(0,a.useState)(null),[s,n]=(0,a.useState)(null),[l,i]=(0,a.useState)(!1);return{data:r,error:s,isLoading:l,execute:(0,a.useCallback)(async r=>{i(!0),n(null);try{let a=await o.request(r);return t(a.data),(null==e?void 0:e.onSuccess)&&e.onSuccess(a.data),a.data}catch(t){var a;let r=Error((null===(a=t.response)||void 0===a?void 0:a.data)?JSON.stringify(t.response.data):t.message);return n(r),(null==e?void 0:e.onError)&&e.onError(r),null}finally{i(!1)}},[e]),reset:(0,a.useCallback)(()=>{t(null),n(null),i(!1)},[])}}o.interceptors.request.use(e=>{{let r=localStorage.getItem("access_token");r&&e.headers&&(e.headers.Authorization="Bearer ".concat(r))}return e},e=>Promise.reject(e)),o.interceptors.response.use(e=>e,async e=>{var r;let t=e.config;if((null===(r=e.response)||void 0===r?void 0:r.status)===401&&!t._retry){t._retry=!0;try{let e=localStorage.getItem("refresh_token");if(!e)throw Error("No refresh token available");let{access_token:r}=(await s.Z.post("".concat(n,"/auth/refresh"),{refresh_token:e})).data;return localStorage.setItem("access_token",r),t.headers&&(t.headers.Authorization="Bearer ".concat(r)),o(t)}catch(e){return localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),window.location.href="/auth/login",Promise.reject(e)}}return Promise.reject(e)})},4774:function(e,r,t){t.d(r,{a:function(){return i}});var a=t(9625),s=t(6885);let n=(0,a.Ue)()((0,s.tJ)(e=>({user:null,accessToken:null,refreshToken:null,isAuthenticated:!1,setAuth:(r,t,a)=>{localStorage.setItem("access_token",t),localStorage.setItem("refresh_token",a),e({user:r,accessToken:t,refreshToken:a,isAuthenticated:!0})},updateUser:r=>{e(e=>({user:e.user?{...e.user,...r}:null}))},clearAuth:()=>{localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),e({user:null,accessToken:null,refreshToken:null,isAuthenticated:!1})}}),{name:"auth-storage",partialize:e=>({user:e.user})}));var o=t(4463),l=t(9376);function i(){let e=(0,l.useRouter)(),{user:r,isAuthenticated:t,setAuth:a,clearAuth:s,updateUser:i}=n(),c=(0,o.h)(),d=(0,o.h)();return{user:r,isAuthenticated:t,login:async r=>{let t=await c.execute({method:"POST",url:"/auth/login",data:r});return!!t&&(a(t.user,t.access_token,t.refresh_token),e.push("/dashboard"),!0)},signup:async r=>{let t=await d.execute({method:"POST",url:"/auth/signup",data:r});return!!t&&(a(t.user,t.access_token,t.refresh_token),e.push("/dashboard"),!0)},logout:async()=>{try{await c.execute({method:"POST",url:"/auth/logout"})}catch(e){console.error("Logout error:",e)}finally{s(),e.push("/")}},updateUser:i,isLoading:c.isLoading||d.isLoading,error:c.error||d.error}}}}]);