(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7526],{40257:function(e,t,n){"use strict";var r,s;e.exports=(null==(r=n.g.process)?void 0:r.env)&&"object"==typeof(null==(s=n.g.process)?void 0:s.env)?n.g.process:n(44227)},44227:function(e){!function(){var t={229:function(e){var t,n,r,s=e.exports={};function o(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function a(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c=[],l=!1,u=-1;function d(){l&&r&&(l=!1,r.length?c=r.concat(c):u=-1,c.length&&f())}function f(){if(!l){var e=a(d);l=!0;for(var t=c.length;t;){for(r=c,c=[];++u<t;)r&&r[u].run();u=-1,t=c.length}r=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function h(){}s.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new v(e,t)),1!==c.length||l||a(f)},v.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=h,s.addListener=h,s.once=h,s.off=h,s.removeListener=h,s.removeAllListeners=h,s.emit=h,s.prependListener=h,s.prependOnceListener=h,s.listeners=function(e){return[]},s.binding=function(e){throw Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw Error("process.chdir is not supported")},s.umask=function(){return 0}}},n={};function r(e){var s=n[e];if(void 0!==s)return s.exports;var o=n[e]={exports:{}},i=!0;try{t[e](o,o.exports,r),i=!1}finally{i&&delete n[e]}return o.exports}r.ab="//";var s=r(229);e.exports=s}()},27526:function(e,t,n){"use strict";n.d(t,{eA:function(){return eu},Gg:function(){return eo},zB:function(){return ec},w7:function(){return el},kP:function(){return es}});var r,s,o,i,a,c=n(57437),l=n(2265),u=n.t(l,2);class d extends Error{constructor(e,t){e instanceof Error?super(void 0,{cause:{err:e,...e.cause,...t}}):"string"==typeof e?(t instanceof Error&&(t={err:t,...t.cause}),super(e,t)):super(void 0,e),this.name=this.constructor.name,this.type=this.constructor.type??"AuthError",this.kind=this.constructor.kind??"error",Error.captureStackTrace?.(this,this.constructor);let n=`https://errors.authjs.dev#${this.type.toLowerCase()}`;this.message+=`${this.message?". ":""}Read more at ${n}`}}class f extends d{}f.kind="signIn";class v extends d{}v.type="AdapterError";class h extends d{}h.type="AccessDenied";class p extends d{}p.type="CallbackRouteError";class y extends d{}y.type="ErrorPageLoop";class g extends d{}g.type="EventError";class w extends d{}w.type="InvalidCallbackUrl";class m extends f{constructor(){super(...arguments),this.code="credentials"}}m.type="CredentialsSignin";class E extends d{}E.type="InvalidEndpoints";class x extends d{}x.type="InvalidCheck";class b extends d{}b.type="JWTSessionError";class S extends d{}S.type="MissingAdapter";class T extends d{}T.type="MissingAdapterMethods";class L extends d{}L.type="MissingAuthorize";class _ extends d{}_.type="MissingSecret";class U extends f{}U.type="OAuthAccountNotLinked";class k extends f{}k.type="OAuthCallbackError";class R extends d{}R.type="OAuthProfileParseError";class A extends d{}A.type="SessionTokenError";class C extends f{}C.type="OAuthSignInError";class P extends f{}P.type="EmailSignInError";class N extends d{}N.type="SignOutError";class M extends d{}M.type="UnknownAction";class I extends d{}I.type="UnsupportedStrategy";class O extends d{}O.type="InvalidProvider";class X extends d{}X.type="UntrustedHost";class j extends d{}j.type="Verification";class H extends f{}H.type="MissingCSRF";class W extends d{}W.type="DuplicateConditionalUI";class V extends d{}V.type="MissingWebAuthnAutocomplete";class $ extends d{}$.type="WebAuthnVerificationError";class B extends f{}B.type="AccountNotLinked";class D extends d{}D.type="ExperimentalFeatureNotEnabled";class F extends d{}class z extends d{}async function J(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},s="".concat(q(t),"/").concat(e);try{var o;let e={headers:{"Content-Type":"application/json",...(null==r?void 0:null===(o=r.headers)||void 0===o?void 0:o.cookie)?{cookie:r.headers.cookie}:{}}};(null==r?void 0:r.body)&&(e.body=JSON.stringify(r.body),e.method="POST");let t=await fetch(s,e),n=await t.json();if(!t.ok)throw n;return n}catch(e){return n.error(new F(e.message,e)),null}}function q(e){return"undefined"==typeof window?"".concat(e.baseUrlServer).concat(e.basePathServer):e.basePath}function G(){return Math.floor(Date.now()/1e3)}function K(e){let t=new URL("http://localhost:3000/api/auth");e&&!e.startsWith("http")&&(e="https://".concat(e));let n=new URL(e||t),r=("/"===n.pathname?t.pathname:n.pathname).replace(/\/$/,""),s="".concat(n.origin).concat(r);return{origin:n.origin,host:n.host,path:r,base:s,toString:()=>s}}var Q=n(40257);let Y={baseUrl:K(null!==(s=Q.env.NEXTAUTH_URL)&&void 0!==s?s:Q.env.VERCEL_URL).origin,basePath:K(Q.env.NEXTAUTH_URL).path,baseUrlServer:K(null!==(i=null!==(o=Q.env.NEXTAUTH_URL_INTERNAL)&&void 0!==o?o:Q.env.NEXTAUTH_URL)&&void 0!==i?i:Q.env.VERCEL_URL).origin,basePathServer:K(null!==(a=Q.env.NEXTAUTH_URL_INTERNAL)&&void 0!==a?a:Q.env.NEXTAUTH_URL).path,_lastSync:0,_session:void 0,_getSession:()=>{}},Z=null;function ee(){return new BroadcastChannel("next-auth")}function et(){return"undefined"==typeof BroadcastChannel?{postMessage:()=>{},addEventListener:()=>{},removeEventListener:()=>{}}:(null===Z&&(Z=ee()),Z)}let en={debug:console.debug,error:console.error,warn:console.warn},er=null===(r=l.createContext)||void 0===r?void 0:r.call(u,void 0);function es(e){if(!er)throw Error("React Context is unavailable in Server Components");let t=l.useContext(er),{required:n,onUnauthenticated:r}=null!=e?e:{},s=n&&"unauthenticated"===t.status;return(l.useEffect(()=>{if(s){let e="".concat(Y.basePath,"/signin?").concat(new URLSearchParams({error:"SessionRequired",callbackUrl:window.location.href}));r?r():window.location.href=e}},[s,r]),s)?{data:t.data,update:t.update,status:"loading"}:t}async function eo(e){var t;let n=await J("session",Y,en,e);return(null===(t=null==e?void 0:e.broadcast)||void 0===t||t)&&ee().postMessage({event:"session",data:{trigger:"getSession"}}),n}async function ei(){var e;let t=await J("csrf",Y,en);return null!==(e=null==t?void 0:t.csrfToken)&&void 0!==e?e:""}async function ea(){return J("providers",Y,en)}async function ec(e,t,n){var r,s,o;let{redirect:i=!0}=null!=t?t:{},a=null!==(s=null!==(r=null==t?void 0:t.redirectTo)&&void 0!==r?r:null==t?void 0:t.callbackUrl)&&void 0!==s?s:window.location.href,c=q(Y),l=await ea();if(!l){window.location.href="".concat(c,"/error");return}if(!e||!(e in l)){window.location.href="".concat(c,"/signin?").concat(new URLSearchParams({callbackUrl:a}));return}let u="credentials"===l[e].type,d="email"===l[e].type,f="".concat(c,"/").concat(u?"callback":"signin","/").concat(e),v=await ei(),h=await fetch("".concat(f,"?").concat(new URLSearchParams(n)),{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Auth-Return-Redirect":"1"},body:new URLSearchParams({...t,csrfToken:v,callbackUrl:a})}),p=await h.json();if(i||!(u||d)){let e=null!==(o=p.url)&&void 0!==o?o:a;window.location.href=e,e.includes("#")&&window.location.reload();return}let y=new URL(p.url).searchParams.get("error"),g=new URL(p.url).searchParams.get("code");return h.ok&&await Y._getSession({event:"storage"}),{error:y,code:g,status:h.status,ok:h.ok,url:y?null:p.url}}async function el(e){var t,n,r,s;let o=null!==(n=null!==(t=null==e?void 0:e.redirectTo)&&void 0!==t?t:null==e?void 0:e.callbackUrl)&&void 0!==n?n:window.location.href,i=q(Y),a=await ei(),c=await fetch("".concat(i,"/signout"),{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Auth-Return-Redirect":"1"},body:new URLSearchParams({csrfToken:a,callbackUrl:o})}),l=await c.json();if(et().postMessage({event:"session",data:{trigger:"signout"}}),null===(r=null==e?void 0:e.redirect)||void 0===r||r){let e=null!==(s=l.url)&&void 0!==s?s:o;window.location.href=e,e.includes("#")&&window.location.reload();return}return await Y._getSession({event:"storage"}),l}function eu(e){if(!er)throw Error("React Context is unavailable in Server Components");let{children:t,basePath:n,refetchInterval:r,refetchWhenOffline:s}=e;n&&(Y.basePath=n);let o=void 0!==e.session;Y._lastSync=o?G():0;let[i,a]=l.useState(()=>(o&&(Y._session=e.session),e.session)),[u,d]=l.useState(!o);l.useEffect(()=>(Y._getSession=async function(){let{event:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let t="storage"===e;if(t||void 0===Y._session){Y._lastSync=G(),Y._session=await eo({broadcast:!t}),a(Y._session);return}if(!e||null===Y._session||G()<Y._lastSync)return;Y._lastSync=G(),Y._session=await eo(),a(Y._session)}catch(e){en.error(new z(e.message,e))}finally{d(!1)}},Y._getSession(),()=>{Y._lastSync=0,Y._session=void 0,Y._getSession=()=>{}}),[]),l.useEffect(()=>{let e=()=>Y._getSession({event:"storage"});return et().addEventListener("message",e),()=>et().removeEventListener("message",e)},[]),l.useEffect(()=>{let{refetchOnWindowFocus:t=!0}=e,n=()=>{t&&"visible"===document.visibilityState&&Y._getSession({event:"visibilitychange"})};return document.addEventListener("visibilitychange",n,!1),()=>document.removeEventListener("visibilitychange",n,!1)},[e.refetchOnWindowFocus]);let f=function(){let[e,t]=l.useState("undefined"!=typeof navigator&&navigator.onLine),n=()=>t(!0),r=()=>t(!1);return l.useEffect(()=>(window.addEventListener("online",n),window.addEventListener("offline",r),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}),[]),e}(),v=!1!==s||f;l.useEffect(()=>{if(r&&v){let e=setInterval(()=>{Y._session&&Y._getSession({event:"poll"})},1e3*r);return()=>clearInterval(e)}},[r,v]);let h=l.useMemo(()=>({data:i,status:u?"loading":i?"authenticated":"unauthenticated",async update(e){if(u)return;d(!0);let t=await J("session",Y,en,void 0===e?void 0:{body:{csrfToken:await ei(),data:e}});return d(!1),t&&(a(t),et().postMessage({event:"session",data:{trigger:"getSession"}})),t}}),[i,u]);return(0,c.jsx)(er.Provider,{value:h,children:t})}}}]);