1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4889],{4889:function(e,t,n){n.d(t,{Z:function(){return x}});var r=n(57437),a=n(2265),o=n(27648),i=n(65934),l=n(51817);function c(){return(0,r.jsxs)("p",{className:"text-center text-[10px] sm:text-[11px] text-[var(--color-neutral-300)] mt-3",children:["By continuing, you agree to our"," ",(0,r.jsx)(o.default,{href:"/terms-condition",className:"text-[var(--color-neutral-500)] underline hover:text-[var(--color-neutral-dark)]",children:"Terms"})," ","and"," ",(0,r.jsx)(o.default,{href:"/privacy-policy",className:"text-[var(--color-neutral-500)] underline hover:text-[var(--color-neutral-dark)]",children:"Privacy Policy"})]})}function s(e){let{callbackUrl:t="/dashboard"}=e,[n,o]=(0,a.useState)(null),c=async()=>{o("google");try{await (0,i.zB)("google",{callbackUrl:t})}catch(e){console.error("Google sign-in error:",e),o(null)}};return(0,r.jsx)("div",{className:"flex gap-3",children:(0,r.jsxs)("button",{type:"button",onClick:c,disabled:null!==n,className:"flex-1 h-[44px] sm:h-[48px] border border-[var(--color-neutral-50)] rounded-[8px] flex items-center justify-center gap-2 hover:bg-[var(--color-surface-muted)] hover:border-[var(--color-neutral-100)] transition-all disabled:opacity-60 disabled:cursor-not-allowed",children:["google"===n?(0,r.jsx)(l.Z,{className:"animate-spin",size:18}):(0,r.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("path",{d:"M18.1711 8.36788H17.5V8.33329H10V11.6666H14.7095C14.0225 13.607 12.1761 15 10 15C7.23857 15 5 12.7614 5 9.99996C5 7.23854 7.23857 4.99996 10 4.99996C11.2745 4.99996 12.4343 5.48079 13.317 6.26621L15.6743 3.90888C14.1858 2.52204 12.195 1.66663 10 1.66663C5.39763 1.66663 1.66667 5.39758 1.66667 9.99996C1.66667 14.6023 5.39763 18.3333 10 18.3333C14.6024 18.3333 18.3333 14.6023 18.3333 9.99996C18.3333 9.44121 18.2757 8.89579 18.1711 8.36788Z",fill:"rgb(251,188,4)"}),(0,r.jsx)("path",{d:"M2.62744 6.12121L5.36536 8.12913C6.10619 6.29496 7.90036 4.99996 9.99994 4.99996C11.2745 4.99996 12.4343 5.48079 13.317 6.26621L15.6743 3.90888C14.1858 2.52204 12.195 1.66663 9.99994 1.66663C6.79911 1.66663 4.02327 3.47371 2.62744 6.12121Z",fill:"rgb(234,67,53)"}),(0,r.jsx)("path",{d:"M10 18.3333C12.1525 18.3333 14.1083 17.5095 15.5871 16.17L13.008 13.9875C12.1431 14.6451 11.0864 15.0008 10 15C7.83248 15 5.99164 13.6179 5.29914 11.6891L2.58081 13.783C3.96164 16.4816 6.76164 18.3333 10 18.3333Z",fill:"rgb(52,168,83)"}),(0,r.jsx)("path",{d:"M18.1711 8.36796H17.5V8.33337H10V11.6667H14.7095C14.3809 12.5902 13.7889 13.3972 13.0067 13.988L13.008 13.9871L15.5871 16.1696C15.4046 16.3355 18.3333 14.1667 18.3333 10C18.3333 9.44129 18.2757 8.89587 18.1711 8.36796Z",fill:"rgb(66,133,244)"})]}),(0,r.jsx)("span",{className:"text-[12px] sm:text-[13px] font-medium text-[var(--color-neutral-dark)]",children:"google"===n?"Connecting...":"Google"})]})})}var d=n(31839),u=n(94508),h=n(63220),p=n(90908);function x(e){let{mode:t}=e,n=(0,d.d)(),x=(0,a.useMemo)(()=>{let e=n.get("callbackUrl")||n.get("redirect")||"/dashboard";try{let t=decodeURIComponent(e);return t.startsWith("/")&&!t.startsWith("//")?t:"/dashboard"}catch(e){return"/dashboard"}},[n]),[m,f]=(0,a.useState)("phone"),[v,g]=(0,a.useState)(""),[b,y]=(0,a.useState)(""),[w,N]=(0,a.useState)(""),[j,C]=(0,a.useState)(""),[k,S]=(0,a.useState)(0),[I,U]=(0,a.useState)(""),[M,P]=(0,a.useState)(!1),L=(0,a.useRef)(!1);(0,a.useEffect)(()=>{if(k<=0)return;let e=window.setInterval(()=>S(e=>Math.max(0,e-1)),1e3);return()=>window.clearInterval(e)},[k]);let O=async()=>{let e=v.replace(/[\s-]/g,"");if(!(0,u.vJ)(e)){U("Enter a valid Pakistani mobile number.");return}P(!0),U("");try{var n,r,a;let o=await fetch("/api/auth/otp/start",{method:"POST",headers:{"content-type":"application/json","x-device-id":(0,p.N3)()},credentials:"include",body:JSON.stringify({phone:e,purpose:"register"===t?"signup":"login"})}),i=await (0,p.IK)(o),l=(null===(n=i.data)||void 0===n?void 0:n.challengeId)||"";if(!o.ok||!l){U((0,p.bS)(i,"Unable to send the verification code."));return}N(l),C((null===(r=i.data)||void 0===r?void 0:r.maskedPhone)||e),S((null===(a=i.data)||void 0===a?void 0:a.resendAfterSeconds)||60),y(""),f("otp")}catch(e){U("Unable to send the verification code. Check your connection and try again.")}finally{P(!1)}},A=async()=>
1{if(!/^\d{6}$/.test(b)){U("Enter the 6-digit verification code.");return}P(!0),U("");try{var e,t;let n=await fetch("/api/auth/otp/verify",{method:"POST",headers:{"content-type":"application/json","x-device-id":(0,p.N3)()},credentials:"include",body:JSON.stringify({challengeId:w,otp:b})}),r=await (0,p.IK)(n);if(!n.ok){U(r.message||"The verification code is invalid or expired.");return}let a=null===(t=r.data)||void 0===t?void 0:null===(e=t.user)||void 0===e?void 0:e.id,o=n.headers.get("x-fb-event-id-completeregistration");!L.current&&a&&o&&((0,h.pK)("CompleteRegistration",(0,h.lM)({userId:a,registrationMethod:"manual",eventId:o})),L.current=!0);let l=await (0,i.zB)("credentials",{otpSession:"cookie",redirect:!1,callbackUrl:x});if(!(null==l?void 0:l.ok)||l.error){U("Your phone was verified, but the website session could not be started.");return}window.location.href=x}catch(e){U("Unable to verify the code. Check your connection and try again.")}finally{P(!1)}},E=async()=>{if(w&&!(k>0)&&!M){P(!0),U("");try{var e;let t=await fetch("/api/auth/otp/resend",{method:"POST",headers:{"content-type":"application/json","x-device-id":(0,p.N3)()},credentials:"include",body:JSON.stringify({challengeId:w})}),n=await (0,p.IK)(t);if(!t.ok){U(n.message||"Unable to resend the verification code.");return}S((null===(e=n.data)||void 0===e?void 0:e.resendAfterSeconds)||60)}catch(e){U("Unable to resend the verification code.")}finally{P(!1)}}},R="w-full h-[44px] sm:h-[48px] px-4 border-2 rounded-[8px] text-[14px] sm:text-[15px] placeholder:text-[var(--color-neutral-200)] focus:outline-none transition-all bg-white disabled:opacity-50 ".concat(I?"border-[var(--color-brand-secondary-hover)] bg-[var(--color-border-lighter)]":"border-[var(--color-neutral-50)] focus:border-[var(--color-brand-primary)]");return(0,r.jsx)("div",{className:"w-full h-full flex flex-col justify-center px-4 sm:px-8 lg:px-12 relative overflow-y-auto overflow-x-hidden",children:(0,r.jsxs)("div",{className:"w-full max-w-[520px] mx-auto py-8 lg:py-0",children:[(0,r.jsxs)("div",{className:"mb-6 text-center sm:text-left",children:[(0,r.jsx)("h1",{className:"text-[24px] sm:text-[26px] font-bold text-[var(--color-neutral-dark)] mb-1",children:"login"===t?"Log in":"Register Now"}),(0,r.jsx)("p",{className:"text-[13px] sm:text-[14px] text-[var(--color-neutral-500)]",children:"Continue securely with your WhatsApp number"})]}),(0,r.jsxs)("form",{onSubmit:e=>{e.preventDefault(),"phone"===m?O():A()},className:"space-y-3",children:["phone"===m?(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"phone-auth-number",className:"block text-[13px] font-medium text-[var(--color-neutral-dark)] mb-1.5",children:"Phone Number"}),(0,r.jsx)("input",{id:"phone-auth-number",type:"tel",inputMode:"tel",autoComplete:"tel",placeholder:"0300 1234567",value:v,onChange:e=>{g(e.target.value),U("")},disabled:M,className:R})]}):(0,r.jsxs)("div",{children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1.5",children:[(0,r.jsx)("label",{htmlFor:"phone-auth-otp",className:"block text-[13px] font-medium text-[var(--color-neutral-dark)]",children:"Verification Code"}),(0,r.jsx)("button",{type:"button",onClick:()=>{f("phone"),N(""),C(""),y(""),U("")},disabled:M,className:"text-[12px] text-[var(--color-brand-primary-light)] font-medium hover:underline disabled:opacity-50",children:"Change number"})]}),(0,r.jsxs)("p",{className:"text-[12px] text-[var(--color-neutral-500)] mb-2",children:["Enter the code sent to ",j,"."]}),(0,r.jsx)("input",{id:"phone-auth-otp",type:"text",inputMode:"numeric",autoComplete:"one-time-code",placeholder:"6-digit code",value:b,onChange:e=>{y(e.target.value.replace(/\D/g,"").slice(0,6)),U("")},disabled:M,className:"".concat(R," text-center tracking-[0.35em]")})]}),I&&(0,r.jsx)("div",{role:"alert",className:"w-full min-h-[39px] flex items-center justify-center rounded-[8px] px-3 py-2",style:{backgroundColor:"rgba(247, 49, 49, 0.05)"},children:(0,r.jsx)("span",{className:"text-[var(--color-brand-secondary-hover)] text-[14px] font-medium text-center",children:I})}),(0,r.jsxs)("button",{type:"submit",disabled:M,className:"w-full h-[44px] sm:h-[48px] bg-[var(--color-brand-primary-dark)] text-white rounded-[8px] font-semibold text-[14px] sm:text-[15px] transition-colors disabled:opacity-70 flex items-center justify-center gap-2",children:[M&&(0,r.jsx)(l.Z,{className:"animate-spin",size:18}
1),"phone"===m?"Send OTP":"Verify & Continue"]}),"otp"===m&&(0,r.jsx)("button",{type:"button",onClick:()=>void E(),disabled:k>0||M,className:"w-full text-[12px] sm:text-[13px] text-[var(--color-brand-primary-light)] font-medium disabled:text-[var(--color-neutral-300)]",children:k>0?"Resend code in ".concat(k,"s"):"Resend code"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-3 my-5",children:[(0,r.jsx)("div",{className:"flex-1 h-px bg-[var(--color-neutral-50)]"}),(0,r.jsx)("span",{className:"text-[12px] sm:text-[13px] text-[var(--color-neutral-500)]",children:"Or Continue With"}),(0,r.jsx)("div",{className:"flex-1 h-px bg-[var(--color-neutral-50)]"})]}),(0,r.jsx)(s,{callbackUrl:x}),(0,r.jsxs)("p",{className:"text-center text-[12px] sm:text-[13px] text-[var(--color-neutral-500)] mt-4",children:["login"===t?"New to CarMandi? ":"Already have an account? ",(0,r.jsx)(o.default,{href:"".concat("login"===t?"/register":"/login","?callbackUrl=").concat(encodeURIComponent(x)),className:"text-[var(--color-brand-primary-light)] font-semibold hover:underline",children:"login"===t?"Register Now":"Login Now"})]}),(0,r.jsx)(c,{})]})})}},90908:function(e,t,n){n.d(t,{IK:function(){return i},N3:function(){return o},bS:function(){return a}});let r={ACCOUNT_ALREADY_EXISTS:"An account with this phone number already exists. Use Log in and continue with Phone OTP. If you need help recovering your account, contact CarMandi Support at [email protected].",PHONE_ALREADY_IN_USE:"This phone number is already linked to another CarMandi account. Sign out, then sign in with Phone OTP to access it. If you need help recovering or linking accounts, contact CarMandi Support at [email protected]."};function a(e,t){return e.code&&r[e.code]||e.message||t}function o(){let e="carmandi.authDeviceId",t=window.localStorage.getItem(e);if(t)return t;let n=window.crypto.randomUUID();return window.localStorage.setItem(e,n),n}async function i(e){let t=await e.text();try{return t?JSON.parse(t):{}}catch(e){return{message:"Unexpected response from the authentication service."}}}},94508:function(e,t,n){n.d(t,{R7:function(){return i},cn:function(){return a},qi:function(){return l},vJ:function(){return o}});var r=n(61994);function a(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,r.W)(t)}function o(e){return/^(\+92|0)?3[0-9]{9}$/.test(e.replace(/[\s-]/g,""))}function i(e){let t=String(e||"").replace(/\D/g,"");return t?t.startsWith("92")&&12===t.length?"0".concat(t.slice(2)):t.startsWith("0092")&&14===t.length?"0".concat(t.slice(4)):t.startsWith("3")&&10===t.length?"0".concat(t):t:""}function l(e,t,n,r){let a=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return"".concat(a(e),"-").concat(a(t),"-").concat(n,"-").concat(r)}},51817:function(e,t,n){n.d(t,{Z:function(){return r}});let r=(0,n(79205).Z)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]])}}]);
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.