1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4921],{54921:(e,t,s)=>{s.r(t),s.d(t,{SessionContext:()=>Q,SessionProvider:()=>er,__NEXTAUTH:()=>J,getCsrfToken:()=>ee,getProviders:()=>et,getSession:()=>Z,signIn:()=>es,signOut:()=>en,useSession:()=>Y});var n=s(95155),r=s(12115);class a 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);const s=`https://errors.authjs.dev#${this.type.toLowerCase()}`;this.message+=`${this.message?". ":""}Read more at ${s}`}}class o extends a{}o.kind="signIn";class i extends a{}i.type="AdapterError";class c extends a{}c.type="AccessDenied";class l extends a{}l.type="CallbackRouteError";class d extends a{}d.type="ErrorPageLoop";class u extends a{}u.type="EventError";class h extends a{}h.type="InvalidCallbackUrl";class p extends o{constructor(){super(...arguments),this.code="credentials"}}p.type="CredentialsSignin";class w extends a{}w.type="InvalidEndpoints";class f extends a{}f.type="InvalidCheck";class g extends a{}g.type="JWTSessionError";class v extends a{}v.type="MissingAdapter";class y extends a{}y.type="MissingAdapterMethods";class E extends a{}E.type="MissingAuthorize";class x extends a{}x.type="MissingSecret";class S extends o{}S.type="OAuthAccountNotLinked";class m extends o{}m.type="OAuthCallbackError";class b extends a{}b.type="OAuthProfileParseError";class _ extends a{}_.type="SessionTokenError";class L extends o{}L.type="OAuthSignInError";class U extends o{}U.type="EmailSignInError";class k extends a{}k.type="SignOutError";class R extends a{}R.type="UnknownAction";class A extends a{}A.type="UnsupportedStrategy";class T extends a{}T.type="InvalidProvider";class C extends a{}C.type="UntrustedHost";class P extends a{}P.type="Verification";class $ extends o{}$.type="MissingCSRF";class N extends a{}N.type="DuplicateConditionalUI";class I extends a{}I.type="MissingWebAuthnAutocomplete";class M extends a{}M.type="WebAuthnVerificationError";class O extends o{}O.type="AccountNotLinked";class X extends a{}X.type="ExperimentalFeatureNotEnabled";class H extends a{}class j extends a{}async function W(e,t,s,n={}){let r=`${V(t)}/${e}`;try{let e={headers:{"Content-Type":"application/json",...n?.headers?.cookie?{cookie:n.headers.cookie}:{}}};n?.body&&(e.body=JSON.stringify(n.body),e.method="POST");let t=await fetch(r,e),s=await t.json();if(!t.ok)throw s;return s}catch(e){return s.error(new H(e.message,e)),null}}function V(e){return e.basePath}function D(){return Math.floor(Date.now()/1e3)}function F(e){let t=new URL("http://localhost:3000/api/auth");e&&!e.startsWith("http")&&(e=`https://${e}`);let s=new URL(e||t),n=("/"===s.pathname?t.pathname:s.pathname).replace(/\/$/,""),r=`${s.origin}${n}`;return{origin:s.origin,host:s.host,path:n,base:r,toString:()=>r}}var B=s(87358);let J={baseUrl:F(B.env.NEXTAUTH_URL??B.env.VERCEL_URL).origin,basePath:F(B.env.NEXTAUTH_URL).path,baseUrlServer:F(B.env.NEXTAUTH_URL_INTERNAL??B.env.NEXTAUTH_URL??B.env.VERCEL_URL).origin,basePathServer:F(B.env.NEXTAUTH_URL_INTERNAL??B.env.NEXTAUTH_URL).path,_lastSync:0,_session:void 0,_getSession:()=>{}},q=null;function z(){return"u"<typeof BroadcastChannel?{postMessage:()=>{},addEventListener:()=>{},removeEventListener:()=>{},name:"next-auth",onmessage:null,onmessageerror:null,close:()=>{},dispatchEvent:()=>!1}:new BroadcastChannel("next-auth")}function G(){return null===q&&(q=z()),q}let K={debug:console.debug,error:console.error,warn:console.warn},Q=r.createContext?.(void 0);function Y(e){if(!Q)throw Error("React Context is unavailable in Server Components");let t=r.useContext(Q),{required:s,onUnauthenticated:n}=e??{},a=s&&"unauthenticated"===t.status;return(r.useEffect(()=>{if(a){let e=`${J.basePath}/signin?${new URLSearchParams({error:"SessionRequired",callbackUrl:window.location.href})}`;n?n():window.location.href=e}},[a,n]),a)?{data:t.data,update:t.update,status:"loading"}:t}async function Z(e){let t=await W("session",J,K,e);return(e?.broadcast??!0)&&z().postMessage({event:"session",data:{trigger:"getSession"}}),t}async function ee(){let e=await W("csrf",J,K);return e?.csrfToken??""}async function et(){return W("providers",J,K)}async function es(e,t,s){let{callbackUrl:n,...r}=t??{},{redirect:a=!0,redirectTo:o=n??window.location.href,...i}=r,c=V(J),l=await et();if(!l){let e=`${c}/error`;window.location.href=e;return}if(!e||!l[e]){let e=`${c}/signin?${new URLSearchParams({callbackUrl:o})}`;window.location.href=e;return}let d=l[e].type;if("webauthn"===d)throw TypeError(`Provider id "${e}" refers to a WebAuthn provider. 2Please use \`import { signIn } from "next-auth/webauthn"\` instead.`);let u=`${c}/${"credentials"===d?"callback":"signin"}/${e}`,h=await ee(),p=await fetch(`${u}?${new URLSearchParams(s)}`,{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Auth-Return-Redirect":"1"},body:new URLSearchParams({...i,csrfToken:h,callbackUrl:o})}),w=await p.json();if(a){let e=w.url??o;window.location.href=e,e.includes("#")&&window.location.reload();return}let f=new URL(w.url).searchParams.get("error")??void 0,g=new URL(w.url).searchParams.get("code")??void 0;return p.ok&&await J._getSession({event:"storage"}),{error:f,code:g,status:p.status,ok:p.ok,url:f?null:w.url}}async function en(e){let{redirect:t=!0,redirectTo:s=e?.callbackUrl??window.location.href}=e??{},n=V(J),r=await ee(),a=await fetch(`${n}/signout`,{method:"post",headers:{"Content-Type":"application/x-www-form-urlencoded","X-Auth-Return-Redirect":"1"},body:new URLSearchParams({csrfToken:r,callbackUrl:s})}),o=await a.json();if(G().postMessage({event:"session",data:{trigger:"signout"}}),t){let e=o.url??s;window.location.href=e,e.includes("#")&&window.location.reload();return}return await J._getSession({event:"storage"}),o}function er(e){if(!Q)throw Error("React Context is unavailable in Server Components");let{children:t,basePath:s,refetchInterval:a,refetchWhenOffline:o}=e;s&&(J.basePath=s);let i=void 0!==e.session;J._lastSync=i?D():0;let[c,l]=r.useState(()=>(i&&(J._session=e.session),e.session)),[d,u]=r.useState(!i);r.useEffect(()=>(J._getSession=async({event:e}={})=>{try{let t="storage"===e;if(t||void 0===J._session){J._lastSync=D(),J._session=await Z({broadcast:!t}),l(J._session);return}if(!e||null===J._session||D()<J._lastSync)return;J._lastSync=D(),J._session=await Z(),l(J._session)}catch(e){K.error(new j(e.message,e))}finally{u(!1)}},J._getSession(),()=>{J._lastSync=0,J._session=void 0,J._getSession=()=>{}}),[]),r.useEffect(()=>{let e=()=>J._getSession({event:"storage"});return G().addEventListener("message",e),()=>G().removeEventListener("message",e)},[]),r.useEffect(()=>{let{refetchOnWindowFocus:t=!0}=e,s=()=>{t&&"visible"===document.visibilityState&&J._getSession({event:"visibilitychange"})};return document.addEventListener("visibilitychange",s,!1),()=>document.removeEventListener("visibilitychange",s,!1)},[e.refetchOnWindowFocus]);let h=function(){let[e,t]=r.useState("u">typeof navigator&&navigator.onLine),s=()=>t(!0),n=()=>t(!1);return r.useEffect(()=>(window.addEventListener("online",s),window.addEventListener("offline",n
2),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",n)}),[]),e}(),p=!1!==o||h;r.useEffect(()=>{if(a&&p){let e=setInterval(()=>{J._session&&J._getSession({event:"poll"})},1e3*a);return()=>clearInterval(e)}},[a,p]);let w=r.useMemo(()=>({data:c,status:d?"loading":c?"authenticated":"unauthenticated",async update(e){if(d)return;u(!0);let t=await W("session",J,K,void 0===e?void 0:{body:{csrfToken:await ee(),data:e}});return u(!1),t&&(l(t),G().postMessage({event:"session",data:{trigger:"getSession"}})),t}}),[c,d]);return(0,n.jsx)(Q.Provider,{value:w,children:t})}}}]); 3//# sourceMappingURL=4921-c0b6767c1e367b88.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.