(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,90667,e=>{"use strict";let t="/dashboard";function r(e){let r=(e??"").trim();if(!r||"/"===r)return"/";let a=r.startsWith("/")?r:`/${r}`;for(;a===t||a.startsWith(`${t}/`);)a=a.slice(t.length)||"/";return a}e.s(["toDashboardAppPath",0,r,"toPublicDashboardPath",0,function(e){let a=r(e);return"/"===a?t:`${t}${a}`}])},12911,e=>{"use strict";var t=e.i(43476),r=e.i(57688),a=e.i(22016),n=e.i(71645),o=e.i(18566),s=e.i(56322),i=e.i(87849),d=e.i(40829),l=e.i(94327),c=e.i(90667);function u(e){window.parent!==window&&window.parent.postMessage(e,"*")}function p({dict:e}){let r=(0,o.useSearchParams)(),{setLanguage:i}=(0,s.useDashboardI18n)(),[x,h]=(0,n.useState)(""),[m,g]=(0,n.useState)(""),[b,f]=(0,n.useState)(""),[w,y]=(0,n.useState)("credentials"),[k,v]=(0,n.useState)(!1),[j,N]=(0,n.useState)(!1),[C,S]=(0,n.useState)(null);r.get("next");let P=r.get("redirect")||"/dashboard";async function E(t){t.preventDefault(),N(!0),S(null);try{let t=await fetch(`${l.API_BASE}/auth/employee/login`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:x,password:m})}),r=await t.json();if(t.ok&&r?.data?.employee){let e=(0,c.toPublicDashboardPath)(P);if(r?.data?.employee){localStorage.setItem(l.EMPLOYEE_PROFILE_KEY,JSON.stringify(r.data.employee));let e=r.data.employee?.preferredLanguage;("en"===e||"fr"===e||"ar"===e)&&(i(e),document.cookie=`rentaldrivego-language=${e}; path=/; max-age=31536000; samesite=lax`)}window.dispatchEvent(new CustomEvent("rentaldrivego:auth-changed")),u({type:"rentaldrivego:employee-login",path:e}),window.location.replace(e);return}if(r?.error==="password_not_set")return void S(e.passwordNotSet);let a=await fetch(`${l.API_BASE}/admin/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:x,password:m})}),n=await a.json();if(a.ok&&n?.data?.admin){window.location.href=`${d.adminUrl}/dashboard`;return}if(401===a.status&&n?.error==="totp_required")return void y("totp");S(e.invalidCredentials)}catch{S(e.unexpectedError)}finally{N(!1)}}async function A(t){t.preventDefault(),N(!0),S(null);try{let t=b.trim().toUpperCase(),r=/^\d{6}$/.test(t)?{totpCode:t}:{recoveryCode:t},a=await fetch(`${l.API_BASE}/admin/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:x,password:m,...r})}),n=await a.json();if(a.ok&&n?.data?.admin){window.location.href=`${d.adminUrl}/dashboard`;return}S(e.invalidCredentials)}catch{S(e.unexpectedError)}finally{N(!1)}}return(0,t.jsxs)(t.Fragment,{children:[C?(0,t.jsx)("div",{className:"mb-5 rounded-[1.5rem] border border-red-200/80 bg-red-50/90 px-4 py-3 text-sm text-red-700 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-300",children:C}):null,"credentials"===w?(0,t.jsxs)("form",{onSubmit:E,className:"space-y-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-stone-700 dark:text-stone-200",children:e.email}),(0,t.jsx)("input",{type:"email",required:!0,value:x,onChange:e=>h(e.target.value),placeholder:"owner@company.com",className:"w-full rounded-2xl border border-stone-200 bg-white px-4 py-3 text-sm text-stone-900 transition-colors placeholder:text-stone-400 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-orange-500 dark:border-blue-800 dark:bg-blue-950/80 dark:text-stone-100 dark:placeholder:text-stone-500"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-stone-700 dark:text-stone-200",children:e.password}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:k?"text":"password",required:!0,value:m,onChange:e=>g(e.target.value),placeholder:"••••••••",className:"w-full rounded-2xl border border-stone-200 bg-white px-4 py-3 pr-10 text-sm text-stone-900 transition-colors placeholder:text-stone-400 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-orange-500 dark:border-blue-800 dark:bg-blue-950/80 dark:text-stone-100 dark:placeholder:text-stone-500"}),(0,t.jsx)("button",{type:"button",onClick:()=>v(e=>!e),className:"absolute inset-y-0 right-3 flex items-center text-stone-400 hover:text-stone-700 dark:text-stone-500 dark:hover:text-stone-200",tabIndex:-1,children:k?(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21"})}):(0,t.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]})})]})]}),(0,t.jsx)("button",{type:"submit",disabled:j,className:"inline-flex w-full justify-center rounded-full bg-orange-600 px-6 py-3 text-sm font-semibold text-white transition hover:bg-orange-700 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-orange-400 dark:text-white dark:hover:bg-orange-300",children:j?e.signingIn:e.signIn}),(0,t.jsx)("div",{className:"text-center",children:(0,t.jsx)(a.default,{href:"/forgot-password",className:"text-sm text-stone-500 underline decoration-stone-300 underline-offset-4 hover:text-stone-900 dark:text-stone-400 dark:decoration-stone-600 dark:hover:text-stone-100",children:e.forgotPassword})})]}):(0,t.jsxs)("form",{onSubmit:A,className:"space-y-5",children:[(0,t.jsx)("div",{className:"rounded-[1.5rem] border border-stone-200/80 bg-stone-50/90 px-4 py-4 text-center text-sm text-stone-600 dark:border-blue-800 dark:bg-blue-950/50 dark:text-stone-300",children:e.enterCode}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-stone-700 dark:text-stone-200",children:e.authCode}),(0,t.jsx)("input",{type:"text",inputMode:"text",pattern:"[0-9A-Za-z-]{6,14}",maxLength:14,required:!0,value:b,onChange:e=>f(e.target.value.replace(/[^0-9A-Za-z-]/g,"").toUpperCase()),placeholder:"000000 or XXXX-XXXX-XXXX",className:"w-full rounded-2xl border border-stone-200 bg-white px-4 py-3 text-center text-xl tracking-[0.45em] text-stone-900 transition-colors placeholder:text-stone-400 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-orange-500 dark:border-blue-800 dark:bg-blue-950/80 dark:text-stone-100 dark:placeholder:text-stone-500"})]}),(0,t.jsx)("button",{type:"submit",disabled:j,className:"inline-flex w-full justify-center rounded-full bg-orange-600 px-6 py-3 text-sm font-semibold text-white transition hover:bg-orange-700 disabled:cursor-not-allowed disabled:opacity-60 dark:bg-orange-400 dark:text-white dark:hover:bg-orange-300",children:j?e.verifying:e.verify}),(0,t.jsx)("button",{type:"button",onClick:()=>{y("credentials"),f(""),S(null)},className:"w-full text-sm text-stone-500 hover:text-stone-900 dark:text-stone-400 dark:hover:text-stone-100",children:e.back})]})]})}e.s(["default",0,function({embedded:e=!1}){let{language:a,theme:l,setLanguage:c,setTheme:x}=(0,s.useDashboardI18n)(),h=(0,o.usePathname)(),m=(0,o.useRouter)(),g=(0,o.useSearchParams)(),b=g.get("lang"),f=g.get("theme"),w=(0,n.useRef)(!1),y={en:{brandName:"Space Agency",title:"Sign in",subtitle:"Enter your credentials to access your account.",email:"Email",password:"Password",signIn:"Sign in",signingIn:"Signing in…",verify:"Verify code",verifying:"Verifying…",authCode:"Authentication code",enterCode:"Enter the 6-digit code from your authenticator app.",back:"Back to credentials",forgotPassword:"Forgot your password?",invalidCredentials:"Invalid email or password.",passwordNotSet:'No password set yet. Check your invitation email or use "Forgot your password?"',unexpectedError:"Something went wrong. Please try again."},fr:{brandName:"Espace agence",title:"Connexion",subtitle:"Saisissez vos identifiants pour accéder à votre compte.",email:"Email",password:"Mot de passe",signIn:"Connexion",signingIn:"Connexion…",verify:"Vérifier le code",verifying:"Vérification…",authCode:"Code d'authentification",enterCode:"Entrez le code à 6 chiffres de votre application d'authentification.",back:"Retour aux identifiants",forgotPassword:"Mot de passe oublié ?",invalidCredentials:"Adresse e-mail ou mot de passe invalide.",passwordNotSet:"Aucun mot de passe défini. Vérifiez votre e-mail d'invitation ou utilisez « Mot de passe oublié ? »",unexpectedError:"Une erreur est survenue. Veuillez réessayer."},ar:{brandName:"مساحة الوكالة",title:"تسجيل الدخول",subtitle:"أدخل بياناتك للوصول إلى حسابك.",email:"البريد الإلكتروني",password:"كلمة المرور",signIn:"تسجيل الدخول",signingIn:"جارٍ تسجيل الدخول…",verify:"تحقق من الرمز",verifying:"جارٍ التحقق…",authCode:"رمز المصادقة",enterCode:"أدخل الرمز المكون من 6 أرقام من تطبيق المصادقة.",back:"العودة إلى بيانات الدخول",forgotPassword:"نسيت كلمة المرور؟",invalidCredentials:"البريد الإلكتروني أو كلمة المرور غير صحيحة.",passwordNotSet:'لم يتم تعيين كلمة مرور بعد. تحقق من بريد الدعوة أو استخدم "نسيت كلمة المرور؟"',unexpectedError:"حدث خطأ ما. يرجى المحاولة مرة أخرى."}}[a];return(0,n.useEffect)(()=>{w.current||(("en"===b||"fr"===b||"ar"===b)&&b!==a&&c(b),("light"===f||"dark"===f)&&f!==l&&x(f),w.current=!0)},[a,b,f,c,x,l]),(0,n.useEffect)(()=>{if(!w.current)return;let t=new URLSearchParams(g.toString()),r=!1;if(t.get("lang")!==a&&(t.set("lang",a),r=!0),t.get("theme")!==l&&(t.set("theme",l),r=!0),e&&"1"!==t.get("embedded")&&(t.set("embedded","1"),r=!0),!r)return;let n=t.toString();m.replace(n?`${h}?${n}`:h,{scroll:!1})},[e,a,h,m,g,l]),(0,n.useEffect)(()=>{u({type:"rentaldrivego:embedded-path",path:window.location.pathname+(window.location.search||"")})},[h,g]),(0,t.jsx)(i.default,{embedded:e,children:(0,t.jsx)("main",{className:"flex flex-1 items-center justify-center px-4 py-12",children:(0,t.jsxs)("div",{className:"w-full max-w-md",children:[(0,t.jsxs)("div",{className:"mb-8 text-center",children:[(0,t.jsx)("div",{className:"flex justify-center",children:(0,t.jsx)("a",{href:d.marketplaceUrl,target:"_top",children:(0,t.jsx)(r.default,{src:"/dashboard/rentalcardrive.png",alt:"RentalDriveGo",width:104,height:104,priority:!0,className:"h-24 w-24 rounded-[1.75rem] border border-stone-200/80 bg-white/85 p-1.5 shadow-sm transition-colors dark:border-blue-800 dark:bg-blue-950/80"})})}),(0,t.jsx)("p",{className:"mt-5 text-xs font-bold uppercase tracking-[0.28em] text-orange-700 dark:text-orange-300",children:"RentalDriveGo"}),(0,t.jsx)("h1",{className:"mt-3 text-3xl font-black tracking-[-0.03em] text-blue-950 dark:text-stone-50",children:y.brandName}),(0,t.jsx)("p",{className:"mt-2 text-sm text-stone-600 dark:text-stone-300",children:y.subtitle}),(0,t.jsx)("div",{className:"mt-4 flex items-center justify-center gap-2",children:["en","fr","ar"].map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>c(e),className:`rounded-full px-3 py-1 text-xs font-semibold uppercase tracking-wider transition-colors text-orange-700 dark:text-orange-300 ${a===e?"ring-1 ring-current opacity-100":"opacity-45 hover:opacity-80"}`,children:e},e))})]}),(0,t.jsx)("section",{className:"rounded-[2rem] border border-stone-200/80 bg-white/82 p-8 shadow-[0_30px_80px_rgba(28,25,23,0.08)] backdrop-blur transition-colors dark:border-blue-900 dark:bg-blue-950/78 dark:shadow-[0_30px_80px_rgba(0,0,0,0.26)]",children:(0,t.jsx)(p,{dict:y})})]})})})}])}]);