1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8126],{94853:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/repair-account",function(){return r(82406)}])},82406:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return x}});var a=r(85893),i=r(67294),n=r(11163),o=r(9309),s=r(316),l=r(86501),c=r(755),d=r(57712),u=r(9008),p=r.n(u),m=r(41664),g=r.n(m),h=r(71863),v=r(96229),f=r(31167);function x(){let e=(0,n.useRouter)(),[t,r]=(0,i.useState)(!1),[u,m]=(0,i.useState)(null),[x,_]=(0,i.useState)(null),w=async function(e,t,r,a){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"error";try{let n={type:e,message:t,email:(null==x?void 0:x.email)||(null==a?void 0:a.email)||"unknown",uid:(null==x?void 0:x.uid)||(null==a?void 0:a.uid)||"unknown",page:"/repair-account",userAgent:navigator.userAgent,timestamp:new Date().toISOString(),severity:i};(null==r?void 0:r.stack)&&(n.stack=r.stack),a&&(n.context=JSON.stringify(a)),await d.default.post("".concat("https://generateugc.ai/api","/errors/frontend-error"),n)}catch(e){c.K9.error("Failed to log error to backend:",e)}};(0,i.useEffect)(()=>{let t=!0;Object.keys(localStorage).forEach(e=>{if(e.startsWith("repair_in_progress_")){let t=localStorage.getItem("".concat(e,"_timestamp"));(!t||Date.now()-parseInt(t)>3e5)&&(localStorage.removeItem(e),localStorage.removeItem("".concat(e,"_timestamp")))}});let r=setTimeout(()=>{!t||x||u||(c.K9.error("Auth state check timed out after 10 seconds"),w("auth_state_timeout","Authentication state check timed out after 10 seconds",null,{timeout:1e4},"warning"),m("Authentication check is taking too long. Please refresh the page or try signing in again."))},1e4),a=(0,s.Aj)(o.auth,async a=>{if(t){clearTimeout(r);try{var i,n;if(!a){w("unauthenticated_repair_access","User attempted to access repair page without authentication",null,null,"info"),e.push("/login");return}let r="",o="";if(a.displayName&&a.displayName.trim()){let e=a.displayName.trim().split(/\s+/).filter(e=>e.length>0);e.length>=2?(r=e[0],o=e.slice(1).join(" ")):1===e.length&&(r=e[0],o="User")}if(!r||!o){let e=(null===(i=a.email)||void 0===i?void 0:i.split("@")[0])||"User";r=r||e.charAt(0).toUpperCase()+e.slice(1),o=o||"User"}if(r=r.charAt(0).toUpperCase()+r.slice(1).toLowerCase(),o=o.charAt(0).toUpperCase()+o.slice(1).toLowerCase(),r=r.replace(/[^a-zA-Z\s]/g,"").trim(),o=o.replace(/[^a-zA-Z\s]/g,"").trim(),r&&0!==r.length||(r="User"),o&&0!==o.length||(o="Account"),r.length>30&&(r=r.substring(0,30)),o.length>30&&(o=o.substring(0,30)),t){let e={email:a.email,firstName:r,lastName:o,uid:a.uid,provider:(null===(n=a.providerData[0])||void 0===n?void 0:n.providerId)||"email"};_(e),await y(e)}}catch(e){c.K9.error("Error in repair account check:",e),w("repair_account_check_error","Error occurred during repair account authentication check",e,{userEmail:null==a?void 0:a.email,userUid:null==a?void 0:a.uid}),t&&m("Unable to detect account information. Please try logging in again.")}}});return()=>{t=!1,clearTimeout(r),a()}},[e]);let y=async t=>{let a="repair_in_progress_".concat(t.uid);if(localStorage.getItem(a))return;localStorage.setItem(a,"true"),localStorage.setItem("".concat(a,"_timestamp"),Date.now().toString()),r(!0),m(null);let i="google.com"===t.provider,n=i?"/users/google-auth":"/users/repair-orphaned";try{let r=(0,h.Z)(),a={firstName:t.firstName,lastName:t.lastName,email:t.email,signupSource:r};a.email=a.email.toLowerCase().trim(),a.termsAccepted=!0,i||(a.turnstileToken="repair-account-bypass"),await d.default.post("".concat("https://generateugc.ai/api").concat(n),a);try{await d.default.post("".concat("https://generateugc.ai/api","/errors/orphaned-account-repaired"),{email:t.email,uid:t.uid,provider:t.provider,timestamp:new Date().toISOString(),repairMethod:i?"google-auth-endpoint":"repair-endpoint"})}catch(e){c.K9.error("Failed to log account repair:",e)}let o="repair_in_progress_".concat(t.uid);localStorage.removeItem(o),localStorage.removeItem("".concat(o,"_timestamp"));try{await d.default.get("".concat("https://generateugc.ai/api","/users")),e.push("/influencer")}catch(t){c.K9.error("Error getting user data after repair:",t),w("post_repair_user_fetch_error","Failed to fetch user data after successful account repair",t,{repairMethod:i?"google-auth-endpoint":"repair-endpoint",endpoint:n}),e.push("/influencer")}}catch(r){var s,u,p,g,f,x,_,y,j,N;c.K9.error("Failed to repair orphaned account:",r);try{await d.default.post("".concat("https://generateugc.ai/api","/errors/orphaned-account-repair-failed"),{email:t.email,uid:t.uid,error:r.message,timestamp:new Date().toISOString()})}catch(e){c.K9.error("Failed to log repair failure:",e)}w("account_repair_failed","Failed to repair orphaned account via frontend",r,{endpoint:n,provider:t.provider,repairMethod:i?"google-auth-endpoint":"repair-endpoint",statusCode:null===(s=r.response)||void 0===s?void 0:s.status,errorCode:null===(p=r.response)||void 0===p?void 0:null===(u=p.data)||void 0===u?void 0:u.code});let e="Failed to repair your account. Please contact support or try signing up again.";if((null===(g=r.response)||void 0===g?void 0:g.status)===403&&(null===(x=r.response)||void 0===x?void 0:null===(f=x.data)||void 0===f?void 0:f.isDeveloper)===!1){e=r.response.data.message||"Sign up is not allowed at this time. Please join the waitlist.",l.Am.error(e,{duration:6e3});try{await o.auth.signOut()}catch(e){c.K9.error("Error signing out after non-developer rejection:",e)}(0,v.X6)()}else(null===(_=r.response)||void 0===_?void 0:_.status)===409&&(null===(j=r.response)||void 0===j?void 0:null===(y=j.data)||void 0===y?void 0:y.code)==="EMAIL_CONFLICT"&&(e=r.response.data.message,(null===(N=r.response.data.details)||void 0===N?void 0:N.conflictType)==="duplicate_firebase_account"&&(e+='\n\nTip: Try signing out completely and then signing in with Google, or using "Forgot Password" if you originally created an account with email/password.'));m(e)}finally{let e="repair_in_progress_".concat(t.uid);localStorage.removeItem(e),localStorage.removeItem("".concat(e,"_timestamp")),r(!1)}},j=async()=>{try{if(await o.auth.signOut(),(0,v.X6)(),null==x?void 0:x.uid){let e="repair_in_progress_".concat(x.uid);localStorage.removeItem(e),localStorage.removeItem("".concat(e,"_timestamp"))}
1e.push("/login")}catch(e){c.K9.error("Error signing out:",e),w("repair_page_signout_error","Error occurred during sign out from repair page",e,{userWasRepairing:t})}};return!t&&(x||u)?u?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p(),{children:(0,a.jsx)("title",{children:"Account Setup Error - GenerateUGC.AI"})}),(0,a.jsx)("div",{className:"h-[100svh] md:min-h-screen flex items-center justify-center bg-transparent",children:(0,a.jsxs)("div",{className:"w-full sm:flex flex-col items-center",children:[(0,a.jsx)("div",{className:"relative pt-5 flex items-center justify-center w-full",children:(0,a.jsx)(g(),{href:"/",passHref:!0,className:"cursor-pointer",children:(0,a.jsx)("div",{className:"pb-5",children:(0,a.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,a.jsx)(f.Z,{}),(0,a.jsx)("span",{className:"app-logo text-white font-bold text-lg md:text-xl",children:"GenerateUGC.AI"})]})})})}),(0,a.jsx)("div",{className:"card sm:min-w-[450px] xl:min-w-[600px] rounded-2xl mx-6",style:{boxShadow:"0px 10px 32px black"},children:(0,a.jsxs)("div",{className:"px-6 pt-6 pb-6 sm:px-10",children:[(0,a.jsxs)("div",{className:"text-center mb-6",children:[(0,a.jsx)("p",{className:"text-gray-300 text-sm md:text-base",children:"We encountered an issue while setting up your account."}),u&&(0,a.jsx)("div",{className:"mt-4 p-3 bg-red-900/30 border border-red-500/50 rounded-lg",children:(0,a.jsx)("p",{className:"text-red-200 text-sm md:text-base whitespace-pre-line",children:u})})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("button",{onClick:()=>window.location.reload(),className:"bg-red-150 py-3 w-full rounded-lg font-semibold text-sm md:text-base",children:"Try Again"}),(0,a.jsx)("div",{className:"text-center",children:(0,a.jsx)("button",{onClick:j,className:"text-red-150 text-sm hover:underline",children:"Sign Out & Start Over"})})]}),(0,a.jsx)("div",{className:"mt-6 text-center"})]})})]})})]}):null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(p(),{children:(0,a.jsx)("title",{children:"GenerateUGC.AI"})}),(0,a.jsx)("div",{className:"h-[100svh] md:min-h-screen flex items-center justify-center bg-transparent",children:(0,a.jsx)("div",{className:"text-center",children:(0,a.jsx)("div",{className:"loader mb-6"})})})]})}},71863:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});let a=()=>"rap-ai"}},function(e){e.O(0,[9774,2888,179],function(){return e(e.s=94853)}),_N_E=e.O()}]);
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.