1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[92729],{28713:(e,t,r)=>{r.d(t,{U:()=>u});var s=r(57716);let n=null;function u(){return n||(n=(0,s.createBrowserClient)("https://uzxkhlnpoutzohovpdni.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InV6eGtobG5wb3V0em9ob3ZwZG5pIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTI5Mjk5NTQsImV4cCI6MjA2ODUwNTk1NH0.tuelxtG0L4LlMd2vGwznoq5xln7OTpVjKjsX_onoCIg"))}},62926:(e,t,r)=>{function s(e){if(!e.hasSession)return e.sessionError?.name==="AuthRetryableFetchError"?"unknown":"gone";if(e.user)return"alive";let t=e.error;return t&&"AuthSessionMissingError"!==t.name&&401!==t.status&&403!==t.status&&404!==t.status?"unknown":"gone"}function n(e,t){let r="";try{r=new URL(t??"").hostname.split(".")[0]}catch{return null}if(!r)return null;let s=RegExp(`^sb-${r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}-auth-token(\\.\\d+)?$`);return e.split(";").some(e=>{let t=e.indexOf("="),r=(-1===t?e:e.slice(0,t)).trim(),n=-1===t?"":e.slice(t+1).trim();return s.test(r)&&""!==n})}function u(e,t=""){let r=function(e,t=""){return(e.startsWith("/business/")?e:"/"===e||""===e||"/home"===e?"/business/dashboard/home":"/analytics"===e?"/business/dashboard":`/business/dashboard${e}`)+(t&&"?"!==t?t.startsWith("?")?t:`?${t}`:"")}(e,t);return"/business/dashboard/home"===r?"/business/login":`/business/login?next=${encodeURIComponent(r)}`}function a(e){let t="/business/dashboard/home";return e&&("/business/dashboard"===e||e.startsWith("/business/dashboard/")||e.startsWith("/business/dashboard?"))?e:t}r.d(t,{Fz:()=>n,PU:()=>u,xM:()=>a,ym:()=>s})},92729:(e,t,r)=>{r.d(t,{O:()=>d,A:()=>h});var s=r(95155),n=r(12115),u=r(28713),a=r(73321),i=r(39989);let o="user_logged_out";var l=r(62926);let c=(0,n.createContext)({user:null,loading:!0,signOut:async()=>{},recheckSession:async()=>{}});function d({children:e}){let[t,r]=(0,n.useState)(null),[d,h]=(0,n.useState)(!0),f=(0,a.useRouter)(),b=(0,u.U)(),p=(0,i.sf)(),g=(0,n.useRef)(!1),I=(0,n.useRef)(null),y=(0,n.useCallback)(()=>{if(I.current)return I.current;let e=(async()=>{try{let{data:{session:e},error:t}=await b.auth.getSession(),s=e?await b.auth.getUser():null,n=(0,l.ym)({hasSession:!!e,sessionError:t,user:!!s?.data.user,error:s?.error});if("gone"!==n)return;e&&await b.auth.signOut({scope:"local"}).catch(()=>{}),r(null)}catch{}finally{I.current=null}})();return I.current=e,e},[b]),_=(0,n.useRef)(null);(0,n.useEffect)(()=>{if("undefined"==typeof BroadcastChannel)return;let e=new BroadcastChannel("clutra-auth");return e.onmessage=e=>{"signed-out"===e.data&&y()},_.current=e,()=>{e.close(),_.current=null}},[y]),(0,n.useEffect)(()=>{if(!t)return;let e=!1,r=setInterval(()=>{e||"visible"!==document.visibilityState||!1===(0,l.Fz)(document.cookie,"https://uzxkhlnpoutzohovpdni.supabase.co")&&(e=!0,y())},1e3);return()=>clearInterval(r)},[t,y]),(0,n.useEffect)(()=>{b.auth.getSession().then(({data:{session:e}})=>{if(r(e?.user??null),h(!1),e?.user&&p&&1)try{p.identify(e.user.id,{created_at:e.user.created_at})}catch(e){}else if(!e?.user&&p&&1)try{p.__loaded&&p._isIdentified()&&p.reset()}catch{}});let{data:{subscription:e}}=b.auth.onAuthStateChange((e,t)=>{if(r(t?.user??null),h(!1),p&&1)try{"SIGNED_IN"===e&&t?.user&&!g.current?(p.identify(t.user.id,{created_at:t.user.created_at}),p.capture("user_logged_in"),g.current=!0):"SIGNED_OUT"===e&&(p.__loaded&&p._isIdentified()&&(p.capture(o),p.reset()),g.current=!1)}catch(e){}});return()=>e.unsubscribe()},[b,p]);let m=()=>{try{p&&p.__loaded&&p._isIdentified()&&(p.capture(o),p.reset())}catch{}},w=async()=>{try{let e=await fetch("/auth/signout",{method:"POST",headers:{"Content-Type":"application/json"}});if(!e.ok)throw Error("Failed to sign out");try{_.current?.postMessage("signed-out")}catch{}m(),e.redirected?window.location.href=e.url:f.push("/")}catch(t){console.error("Sign out error:",t);let{error:e}=await b.auth.signOut();e||m(),f.push("/")}};return(0,s.jsx)(c.Provider,{value:{user:t,loading:d,signOut:w,recheckSession:y},children:e})}let h=()=>{let e=(0,n.useContext)(c);if(!e)throw Error("useAuth must be used within an AuthProvider");return e}}}]);
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.