PageSourceSearch

https://fav.ing/_next/static/chunks/4513-dbf138865910d58f.js?dpl=dpl_4YANgsff5A7EnDEuZ41SP1mBLVZA

js fav.ing collected 2026-09-24 11:08:01 UTC 12,854 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4513,7192],{7192:(e,t,r)=>{r.r(t),r.d(t,{getSupabaseClient:()=>n,initSupabaseClient:()=>o,supabase:()=>i});let a=null;function o(e){a=e}function n(){if(!a)throw Error("@faving/shared: Supabase client not initialized. Call initSupabaseClient() at app startup.");return a}let i=new Proxy({},{get(e,t,r){let a=n(),o=Reflect.get(a,t,r);return"function"==typeof o?o.bind(a):o}})},7232:(e,t,r)=>{r.d(t,{R:()=>i});let a=(()=>{let e=null;return()=>{if(null!==e)return e;try{let t="__storage_test__";return localStorage.setItem(t,t),localStorage.removeItem(t),e=!0,!0}catch(t){return console.warn("[SafeStorage] localStorage not available:",t),e=!1,!1}}})(),o=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3;for(let t=0;t<e;t++){if(a())return!0;let e=Math.min(50*Math.pow(2,t),200);await new Promise(t=>setTimeout(t,e))}return a()},n=new Map,i={isReady:()=>a(),waitForReady:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3;return o(e)},getItem:e=>{var t,r;try{if(a())return localStorage.getItem(e);return null!=(t=n.get(e))?t:null}catch(t){return console.warn("[SafeStorage] Error getting ".concat(e,":"),t),null!=(r=n.get(e))?r:null}},setItem:(e,t)=>{try{a()&&localStorage.setItem(e,t),n.set(e,t)}catch(r){console.warn("[SafeStorage] Error setting ".concat(e,":"),r),n.set(e,t)}},setItemAsync:async(e,t)=>{await o(),i.setItem(e,t)},removeItem:e=>{try{a()&&localStorage.removeItem(e),n.delete(e)}catch(t){console.warn("[SafeStorage] Error removing ".concat(e,":"),t),n.delete(e)}},clear:()=>{try{a()&&localStorage.clear(),n.clear()}catch(e){console.warn("[SafeStorage] Error clearing storage:",e),n.clear()}},clearSupabaseKeys:()=>{let e=["supabase.auth.token","sb-qamzubzyngjpiuariusp-auth-token","supabase-auth-token","sb-auth-token"];e.forEach(e=>{i.removeItem(e)});try{"undefined"!=typeof sessionStorage&&e.forEach(e=>
1{try{sessionStorage.removeItem(e)}catch(e){}})}catch(e){console.warn("[SafeStorage] sessionStorage not accessible")}}}},21105:(e,t,r)=>{r.d(t,{Dm:()=>i,J8:()=>o,Si:()=>l,Ud:()=>u,oN:()=>s});var a=r(7192);let o=e=>{var t;if(!(null==e?void 0:e.user))return"none";let r=null==(t=e.user.app_metadata)?void 0:t.provider;return"google"===r?"google":"apple"===r?"apple":"email"===r?"email":e.user.email_confirmed_at?"email":"none"},n="user_",i=e=>!e||e.startsWith(n),l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();if(!e)return!1;let r=Date.parse(e);return!!Number.isFinite(r)&&t-r>6e5},s=async(e,t,r)=>{try{let t=async()=>{let{data:t,error:r}=await a.supabase.from("profiles").select("username, display_name").eq("id",e).maybeSingle();if(r)throw r;return t},o=await t();if(o||(await new Promise(e=>setTimeout(e,750)),o=await t()),!o&&l(r))return console.warn("[Auth] Own-profile read returned empty for an established account — failing open, not gating"),!1;return(e=>!e||!e.username||e.username.startsWith(n))(o)}catch(e){return console.error("Error checking profile completion status:",e),!1}},u=async e=>{try{let{data:t,error:r}=await a.supabase.from("profiles").select("onboarding_completed").eq("id",e).maybeSingle();if(r)return console.error("[Auth Utils] Error checking onboarding status:",r),!1;return!(null==t?void 0:t.onboarding_completed)}catch(e){return console.error("[Auth Utils] Error in onboarding check:",e),!1}}},48434:(e,t,r)=>{r.d(t,{Nu:()=>a.Nu,S:()=>a.S,rZ:()=>a.rZ,xx:()=>o,yw:()=>n});var a=r(94440);let o="0x4AAAAAAEjPZ0M0ZCACPj1Z",n=o.length>0},63371:(e,t,r)=>{r.d(t,{W:()=>n,c:()=>o});let a=null;function o(e){a=e}function n(){if(!a)throw Error("@faving/shared: Platform adapters not initialized. Call initPlatformAdapters() at app startup.");return a}},82557:(e,t,r)=>{r.d(t,{J8:()=>a.J8,Si:()=>a.Si,Ud:()=>a.Ud,oN:()=>a.oN});var a=r(21105)},84513:(e,t,r)=>{r.d(t,{cy:()=>w,OJ:()=>S,As:()=>v});var a=r(95155),o=r(12115),n=r(99776),i=r(15894),l=r(18733),s=r(82557),u=r(7232),c=r(48434),d=r(81715),h=r(63371);let m=new Set(["email","phone","none",""]),p=new Set,f=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now();if(!t||m.has(t)||!(null==e?void 0:e.id)||!e.created_at)return!1;let a=new Date(e.created_at).getTime();if(Number.isNaN(a))return!1;let o=r-a;return o>-6e4&&o<3e5};async function g(e,t,r){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Date.now();if(!f(e,t,a))return!1;let o=e.id;if(p.has(o))return!1;p.add(o);try{let{storage:e}=(0,h.W)(),n="signup_tracked_".concat(o);if(await e.getItem(n))return!1;return await e.setItem(n,new Date(a).toISOString()),r(t),!0}catch(e){return!1}}let y="geo_stamp_v1",w=(0,o.createContext)(void 0),v=()=>{let e=(0,o.useContext)(w);if(!e)throw Error("useAuth must be used within an AuthProvider");return e},S=e=>{let{children:t}=e,[r,h]=(0,o.useState)(null),[m,p]=(0,o.useState)(null),[f,v]=(0,o.useState)(!0),[S,b]=(0,o.useState)(!1),[_,I]=(0,o.useState)("none"),[A,E]=(0,o.useState)(!1),[N,k]=(0,o.useState)(!1),[P,C]=(0,o.useState)(!1),[R,T]=(0,o.useState)(!1),[D,O]=(0,o.useState)(null),[U,x]=(0,o.useState)(null),[J,W]=(0,o.useState)(0),{toast:q}=(0,i.dj)(),F=(0,n.jE)(),j="faving:affiliate-sub-cache",Z=async function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!r){T(!1),O(null),x(null);return}if(!e){let e=Date.now();if(J>0&&e-J<18e5)return;let t=(e=>{let t=u.R.getItem(j);if(!t)return null;try{let r=JSON.parse(t);if(r.userId!==e||Date.now()-r.timestamp>=18e5)return null;return r}catch(e){return null}})(r.id);if(t){T(t.subscribed),O(t.tier),x(t.subscriptionEnd),W(t.timestamp);return}}try{let{data:e,error:a}=await l.supabase.functions.invoke("check-affiliate-subscription");if(a)return void console.error("Error checking affiliate subscription:",a);let o=(null==e?void 0:e.subscribed)||!1,n=(null==e?void 0:e.tier)||null,i=(null==e?void 0:e.subscription_end)||null,s=Date.now();T(o),O(n),x(i),W(s);var t={userId:r.id,subscribed:o,tier:n,subscriptionEnd:i,timestamp:s};try{u.R.setItem(j,JSON.stringify(t))}catch(e){}}catch(e){console.error("Failed to check affiliate subscription:",e)}};(0,o.useEffect)(()=>{r&&0===J&&Z()},[null==r?void 0:r.id]),(0,o.useEffect)(()=>{let e=!0,t=null;t=setTimeout(()=>{e&&(console.error("[Auth] ⚠️ Emergency timeout - forcing ready state"),v(!1),b(!0))},1e4);let r=e=>new Promise((t,r)=>setTimeout(()=>r(Error("Timeout")),e)),a=async(e,t)=>{if(!(0,s.Si)(t))try{let{data:t}=await l.supabase.from("profiles").select("id").eq("id",e).maybeSingle();if(!t){let{error:t}=await l.supabase.from("profiles").upsert([{id:e}],{onConflict:"id"});t&&console.error("[Auth] Failed to create profile:",t)}}catch(e){console.error("[Auth] Profile validation error:",e)}};(async()=>{try{var o;let{data:{session:t}}=await l.supabase.auth.getSession();if(!e)return;if(p(t),h(null!=(o=null==t?void 0:t.user)?o:null),null==t?void 0:t.user)try{let o=(0,s.J8)(t);I(o),await a(t.user.id,t.user.created_at);let n=Promise.all([(0,s.oN)(t.user.id,o,t.user.created_at),(0,s.Ud)(t.user.id)]),[i,l]=await Promise.race([n,r(5e3).then(()=>(console.warn("[Auth] Checks timeout - using defaults"),[!1,!1]))]);e&&(k(i),E(l),Z())}catch(t){console.error("[Auth] Check error:",t),e&&(k(!1),E(!1))}}catch(e){console.error("[Auth] Init error:",e)}finally{e&&(t&&clearTimeout(t),v(!1),b(!0))}})();let{data:{subscription:o}}=l.supabase.auth.onAuthStateChange((t,o)=>{var n,i;if(e&&(p(o),h(null!=(n=null==o?void 0:o.user)?n:null),"SIGNED_IN"===t&&(null==o?void 0:o.user)&&C(!1),setTimeout(async()=>
1{if(e){if(null==o?void 0:o.user)try{let t=(0,s.J8)(o);I(t),await a(o.user.id,o.user.created_at);let n=Promise.all([(0,s.oN)(o.user.id,t,o.user.created_at),(0,s.Ud)(o.user.id)]),[i,u]=await Promise.race([n,r(5e3).then(()=>(console.warn("[Auth] State change checks timeout - using defaults"),[!1,!1]))]);e&&(k(i),E(u));let{data:c}=await l.supabase.from("profiles").select("email, username, display_name").eq("id",o.user.id).single();c&&(0,d.gm)(o.user.id,{email:c.email,username:c.username,displayName:c.display_name})}catch(t){console.error("[Auth] State change check error:",t),e&&(k(!1),E(!1))}else I("none"),k(!1),E(!1);e&&(v(!1),C(!0),b(!0))}},0),("SIGNED_IN"===t||"INITIAL_SESSION"===t)&&(null==o?void 0:o.user)&&(setTimeout(()=>(function(){try{var e;let t=null!=(e=Intl.DateTimeFormat().resolvedOptions().timeZone)?e:null,r=u.R.getItem(y);if(r){let[e,a]=r.split("|"),o=Number(a);if(e===t&&Number.isFinite(o)&&Date.now()-o<6048e5)return}fetch("/api/profile/geo-stamp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({timezone:t})}).then(e=>{e.ok&&u.R.setItem(y,"".concat(t,"|").concat(Date.now()))}).catch(()=>{})}catch(e){}})(),0),g(o.user,null==(i=o.user.app_metadata)?void 0:i.provider,e=>(0,d.mY)(e))),"SIGNED_IN"===t&&(null==o?void 0:o.user))){u.R.setItem("faving_ever_authenticated","true");let e=(0,s.J8)(o);u.R.setItem("last_auth_method",e);let t=u.R.getItem("pending_referral_code");t&&setTimeout(()=>{l.supabase.rpc("process_referral_signup",{p_user_id:o.user.id,p_referral_code:t}).then(e=>{let{error:t}=e;t?console.error("[Auth] Error processing referral:",t):(0,d.r)("invite_accepted",{type:"referral"}),u.R.removeItem("pending_referral_code")})},0)}});return()=>{e=!1,t&&clearTimeout(t),o.unsubscribe()}},[]);let L=async(e,t,r)=>{v(!0);try{let{error:a}=await l.supabase.auth.signInWithPassword({email:e,password:t,options:{...(0,c.Nu)(r)}});if(a)throw a;u.R.setItem("last_auth_method","email"),q({title:"Welcome back!",description:"You have successfully logged in."})}catch(e){throw e}finally{v(!1)}},Y=async(e,t,r,a)=>{v(!0);try{let{error:o}=await l.supabase.auth.signUp({email:e,password:t,options:{data:{username:r,display_name:r},...(0,c.Nu)(a)}});if(o)throw o;q({title:"Account Created",description:"Please check your email to verify your account."})}catch(e){throw q({title:"Signup Error",description:e.message,variant:"destructive"}),e}finally{v(!1)}},z=async()=>{v(!0);try{h(null),p(null),I("none"),E(!1),k(!1),T(!1),O(null),x(null);{let e=()=>document.body.style.removeProperty("pointer-events");e(),requestAnimationFrame(e),setTimeout(e,100),setTimeout(e,350)}(0,d.p3)(),u.R.clearSupabaseKeys(),u.R.removeItem(j);try{F.clear()}catch(e){console.warn("[Auth] queryClient.clear() failed (continuing):",e)}let{error:e}=await l.supabase.auth.signOut();e&&console.warn("[Auth] Supabase signOut error (proceeding anyway):",e),q({title:"Logged Out",description:"You have been successfully logged out."})}catch(e){console.error("[Auth] Logout error:",e),q({title:"Logged Out",description:"You have been logged out."})}finally{v(!1)}},G=async(e,t)=>{v(!0);try{let{error:r}=await l.supabase.auth.resetPasswordForEmail(e,{...(0,c.Nu)(t)});if(r)throw r;q({title:"Reset Email Sent",description:"Check your email for password reset instructions."})}catch(e){throw q({title:"Reset Error",description:e.message,variant:"destructive"}),e}finally{v(!1)}},M=async e=>{v(!0);try{let{error:t}=await l.supabase.auth.updateUser({password:e});if(t)throw t;q({title:"Password Updated",description:"Your password has been successfully updated."})}catch(e){throw q({title:"Update Error",description:e.message,variant:"destructive"}),e}finally{v(!1)}},K=async e=>{v(!0);try{let t=new URLSearchParams(window.location.search),r=t.get("ref");r&&u.R.setItem("pending_referral_code",r);let a=t.get("next"),o=a&&a.startsWith("/")&&!a.startsWith("//")?a:null,{error:n}=await l.supabase.auth.signInWithOAuth({provider:e,options:{redirectTo:o?"".concat(window.location.origin,"/auth/callback?next=").concat(encodeURIComponent(o)):window.location.origin,queryParams:{prompt:"select_account"}}});if(n)throw n}catch(e){throw q({title:"Provider Login Error",description:e.message,variant:"destructive"}),e}finally{v(!1)}},B=async()=>{await K("google")},H=async()=>
1{if(r)try{let{error:e}=await l.supabase.from("profiles").update({onboarding_completed:!0}).eq("id",r.id);if(e)throw console.error("[Auth] Error marking onboarding complete:",e),e;E(!1),(0,d.r)("onboarding_completed",{method:_})}catch(e){throw console.error("[Auth] Failed to complete onboarding:",e),e}};return(0,a.jsx)(w.Provider,{value:{user:r,session:m,isAuthenticated:!!r,isLoading:f,authReady:S,authProvider:_,needsOnboarding:A,needsProfileCompletion:N,gateResolved:P,affiliateSubscribed:R,affiliateTier:D,affiliateSubscriptionEnd:U,checkAffiliateSubscription:Z,setProfileCompleted:()=>{k(!1)},setOnboardingCompleted:H,login:L,signup:Y,logout:z,resetPassword:G,updatePassword:M,signInWithProvider:K,loginWithGoogle:B},children:t})}},94440:(e,t,r)=>{r.d(t,{Nu:()=>a,Ox:()=>i,S:()=>o,rZ:()=>n});let a=e=>e?{captchaToken:e}:{},o="We couldn't finish the security check. Give it a second and try again.",n=e=>{var t;let r="string"==typeof e?e:e&&"object"==typeof e&&"message"in e?String(null!=(t=e.message)?t:""):"";return/captcha/i.test(r)},i=1e4}}]);

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.