1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2626,7922,1637,5526,8120],{19103:function(e,t,a){Promise.resolve().then(a.bind(a,58986))},58986:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return login_Login}});var n=a(57437),o=a(2265);let r="/dashboard";function destinoDepoisDoLogin(e,t){let a=void 0!==globalThis.window,n=null!=e?e:a?globalThis.location.search:null,o=null!=t?t:a?globalThis.location.origin:null;if(!n||!o)return r;let s=new URLSearchParams(n).get("next");if(!s)return r;try{let e=new URL(s,o);if(e.origin!==new URL(o).origin)return r;return"".concat(e.pathname).concat(e.search).concat(e.hash)}catch(e){return r}}var s=a(59378),i=a(61396),l=a.n(i),c=a(16691),d=a.n(c),u=a(91172),m=a(83116),h=a(3112),p=a(8353),g=a(17187),f=a(5925),x=a(88362);let LogoComponent=e=>{let{isMobile:t=!1}=e,{theme:a}=(0,u.O)();return(0,n.jsx)("div",{className:"".concat(t?"md:hidden order-1 w-full flex justify-center p-8":"hidden md:flex justify-center py-4 mb-12"," bg-white"),children:(0,n.jsx)(d(),{src:"dark"===a?h.Z:m.Z,unoptimized:!0,alt:"Luna Checkout",className:"".concat(t?"h-12":"h-10"," w-auto")})})},LayoutStructure=e=>{let{children:t}=e;return(0,n.jsxs)("div",{className:"flex flex-col md:flex-row h-dvh md:h-screen w-full bg-white",children:[(0,n.jsx)(LogoComponent,{isMobile:!0}),(0,n.jsx)("div",{className:"order-2 w-full md:w-1/2",children:(0,n.jsx)(p.Z,{})}),(0,n.jsxs)("div",{className:"order-3 md:order-1 w-full md:w-1/2 flex flex-col md:justify-between md:p-0 p-6 bg-white",children:[(0,n.jsx)(LogoComponent,{}),(0,n.jsx)("div",{className:"flex-1 flex items-center w-full mx-auto md:w-[70%] justify-center",children:(0,n.jsx)("div",{className:"w-full max-w-md",children:t})})]})]})};var login_Login=()=>{let[e,t]=(0,o.useState)(""),a=(0,s.Z)("email"),r=(0,s.Z)(),[i,c]=(0,o.useState)(!1),[d,u]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),[p,v]=(0,o.useState)(null),[A,b]=(0,o.useState)(null),[y,j]=(0,o.useState)(null),handlePhoneUpdate=async e=>{if(!A)return;let t=await fetch("".concat(x.Z.api.baseUrl,"/users/phone"),{method:"PUT",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(A.access_token)},body:JSON.stringify({phone:e})}),a=await t.json();if(t.ok)f.ZP.success("N\xfamero de telefone atualizado!");else throw Error(a.message||"Erro ao atualizar telefone")},completeLogin=(e,t,a)=>{let{access_token:n,refresh_token:o}=e;localStorage.setItem("user",JSON.stringify(t));let{config_checkout_theme:r,...s}=a;localStorage.setItem("store",JSON.stringify(s)||""),localStorage.setItem("access_token",n),localStorage.setItem("refresh_token",o),localStorage.removeItem("lc-onboarding-initial-loading"),globalThis.location.href=destinoDepoisDoLogin()};async function handleLogin(e){if(e.preventDefault(),a.validate()&&r.validate()){c(!0);try{let e=await fetch("".concat(x.Z.api.baseUrl,"/auth"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:a.value,password:r.value,keep_connected:d})}),o=await e.json();if(e.ok){let{tokens:e,data:t,store:a}=o;"0"===t.phone_validated?(v(t),b(e),j(a),h(!0)):completeLogin(e,t,a)}else{var n;let e=null===(n=o.message)||void 0===n?void 0:n.replace(/Cód\s\w+\d+/,"").trim();t(null!=e?e:"")}}catch(e){t("Erro ao conectar. Tente novamente.")}finally{c(!1)}}}return m?(0,n.jsx)(LayoutStructure,{children:(0,n.jsx)(g.Z,{initialPhone:(null==p?void 0:p.phone)||"",onVerificationSuccess:()=>{completeLogin(A,p,y)},loading:i,onPhoneUpdate:handlePhoneUpdate,authTokens:A})}):(0,n.jsxs)(LayoutStructure,{children:[(0,n.jsxs)("div",{className:"mb-8",children:[(0,n.jsx)("h1",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Ol\xe1, Bem-vindo de volta!"}),(0,n.jsx)("p",{className:"text-gray-600 text-sm",children:"Digite seu e-mail e senha para entrar em sua conta"})]}),(0,n.jsxs)("form",{onSubmit:handleLogin,className:"space-y-5",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"email",className:"block text-sm font-medium text-gray-700 mb-2",children:"Email"}),(0,n.jsx)("input",{id:"email",type:"email",placeholder:"Digite seu email",className:"w-full px-4 py-3 border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all",...a})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{htmlFor:"password",className:"block text-sm font-medium text-gray-700 mb-2",children:"Senha"}),(0,n.jsx)("input",{id:"password",type:"password",placeholder:"Digite sua senha",className:"w-full px-4 py-3 border border-gray-200 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none transition-all",...r})]}),(0,n.jsxs)("div",{className:"flex items-center justify-between",children:[(0,n.jsxs)("label",{className:"flex items-center text-sm text-gray-600",children:[(0,n.jsx)("input",{type:"checkbox",checked:d,onChange:e=>u(e.target.checked),className:"h-4 w-4 text-primary border-gray-300 rounded focus:ring-primary"}),(0,n.jsx)("span",{className:"pl-1",children:"Mantenha conectado"})]}),(0,n.jsx)(l(),{href:"/esqueceu-senha",className:"text-sm text-[--primary-700] hover:underline",children:"Esqueceu a senha?"})]}),e&&(0,n.jsx)("p",{className:"text-red-500 text-sm text-center",children:e}),(0,n.jsx)("button",{type:"submit",disabled:i,className:"w-full bg-[--primary-700] hover:bg-primary-dark disabled:bg-primary-light text-white font-medium py-3 rounded-lg transition-colors",children:i?"Carregando...":"Login"}),(0,n.jsxs)("p",{className:"text-center text-sm text-gray-600 mt-6",children:["Primeira vez na Luna Checkout?"," ",(0,n.jsx)(l(),{href:"/cadastro",className:"font-medium text-[--primary-700] hover:underline",children:"Cadastre-se"})]})]})]})}},8353:function(e,t,a){"use strict";a.d(t,{Z:function(){return AuthImage}});var n=a(57437),o=a(16691),r=a.n(o);function AuthImage(){return(0,n.jsxs)("div",{className:"block h-[30vh] md:h-screen overflow-hidden bg-[--background-1] relative",children:[(0,n.jsx)(r(),{src:"/images/earth/bg-world.png",alt:"Ilustra\xe7\xe3o de login",fill:!0,className:"object-cover h-full object-left-top",priority:!0}),(0,n.jsx)("div",{className:"absolute top-[12%] left-[65%] w-[42%] aspect-[3/4] transform -translate-x-1/2",children:(0,n.jsx)(r(),{src:"/images/login/ps.png",alt:"Notifica\xe7\xe3o",fill:!0,className:"object-contain",priority:!0})}
1),(0,n.jsx)("div",{className:"absolute bottom-[12%] left-[12%] w-[28%] aspect-square",children:(0,n.jsx)(r(),{src:"/images/login/graph.png",alt:"Gr\xe1fico",fill:!0,className:"object-contain",priority:!0})})]})}},17187:function(e,t,a){"use strict";var n=a(57437),o=a(2265),r=a(41751),s=a(67899),i=a(93665),l=a(88362);function cleanPhone(e){return e.replace(/\D/g,"")}t.Z=e=>{let{initialPhone:t,onVerificationSuccess:a,onPhoneUpdate:c,loading:d=!1,className:u="",authTokens:m}=e,[h,p]=(0,o.useState)(t),[g,f]=(0,o.useState)(""),[x,v]=(0,o.useState)(!1),[A,b]=(0,o.useState)(!1),[y,j]=(0,o.useState)(""),w=A||d;(0,o.useEffect)(()=>{sendVerificationCode(t)},[]);let sendVerificationCode=async e=>{try{b(!0),j("");let a=await fetch("".concat(l.Z.api.baseUrl,"/users/phone/validate/request"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(null==m?void 0:m.access_token)},body:JSON.stringify({phone:cleanPhone(null!=e?e:h)})}),n=await a.json();if(!a.ok){var t;j(null!==(t=n.detail)&&void 0!==t?t:"Erro ao enviar c\xf3digo")}}catch(e){j("Erro ao enviar c\xf3digo. Tente novamente.")}finally{b(!1)}},handleUpdatePhone=async()=>{if(!h.length){j("Por favor, insira um n\xfamero de telefone v\xe1lido");return}if(c)try{b(!0),j(""),await c(cleanPhone(h)),v(!1),await sendVerificationCode(h)}catch(e){j("Erro ao atualizar telefone. Tente novamente.")}finally{b(!1)}else v(!1),await sendVerificationCode(h)},handleVerifyCode=async()=>{if(6!==g.length){j("Por favor, insira um c\xf3digo de 6 d\xedgitos");return}try{b(!0),j("");let t=await fetch("".concat(l.Z.api.baseUrl,"/users/phone/validate/verify"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(null==m?void 0:m.access_token)},body:JSON.stringify({phone:cleanPhone(h),code:g})}),n=await t.json();if(t.ok)a();else{var e;j(null!==(e=n.detail)&&void 0!==e?e:"C\xf3digo inv\xe1lido")}}catch(e){j("Erro ao verificar c\xf3digo. Tente novamente.")}finally{b(!1)}};return(0,n.jsxs)("div",{className:"space-y-6 ".concat(u),children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{className:"text-2xl font-bold mb-1",children:"Verifique seu WhatsApp"}),(0,n.jsxs)("p",{className:"text-base mb-4",children:["Enviamos um c\xf3digo de 6 d\xedgitos para o n\xfamero:"," ",(0,n.jsx)("strong",{className:"text-[--primary-600]","data-testid":"phone-display",children:h}),". Insira abaixo para ativar sua conta e come\xe7ar a usar a LunaCheckout"]})]}),x?(0,n.jsxs)("form",{onSubmit:e=>{e.preventDefault(),handleUpdatePhone()},className:"space-y-4","data-testid":"phone-edit-form",children:[(0,n.jsx)(i.Z,{label:"Telefone",id:"phone",type:"phone",mask:"phone",placeholder:"Ex: (00) 00000-0000","data-testid":"phone-input",required:!0,value:h,onChange:e=>{let{target:t}=e;return p(t.value)}}),y&&(0,n.jsx)("p",{className:"text-red-500 text-sm text-center","data-testid":"error-message",children:y}),(0,n.jsxs)("div",{className:"flex gap-3",children:[(0,n.jsx)(r.A,{type:"button",variant:"bordered",onPress:()=>{v(!1),j(""),p(t)},className:"flex-1 h-12 font-medium border-[--primary-700] text-[--primary-700]","data-testid":"cancel-phone-edit",children:"Cancelar"}),(0,n.jsx)(r.A,{type:"submit",isLoading:w,className:"flex-1 h-12 font-medium text-white bg-[--primary-700] rounded-lg","data-testid":"update-phone-submit",children:w?"Atualizando...":"Atualizar"})]})]}):(0,n.jsxs)("form",{onSubmit:e=>{e.preventDefault(),handleVerifyCode()},className:"space-y-4","data-testid":"verification-form",children:[(0,n.jsx)("div",{className:"w-full flex justify-center","data-testid":"otp-container",children:(0,n.jsx)(s.h,{length:6,value:g,onValueChange:f,"data-testid":"otp-input"})}),y&&(0,n.jsx)("p",{className:"text-red-500 text-sm text-center","data-testid":"error-message",children:y}),(0,n.jsx)(r.A,{type:"submit",isLoading:w,className:"w-full h-12 font-medium text-white bg-[--primary-700] rounded-lg","data-testid":"verify-code-submit",children:w?"Verificando...":"Confirmar"}),(0,n.jsxs)("div",{className:"text-center text-sm space-y-2",children:[(0,n.jsx)("p",{className:"text-gray-600",children:"N\xe3o recebeu o c\xf3digo?"}),(0,n.jsx)("div",{className:"flex flex-col gap-2",children:(0,n.jsx)("button",{type:"button",onClick:()=>{v(!0),j("")},className:"text-[--primary-700] hover:underline","data-testid":"edit-phone-button",children:"Alterar n\xfamero de telefone"})})]})]})]})}},88362:function(e,t,a){"use strict";a.d(t,{Z:function(){return u}});var n,o=a(62601);let r={app:{name:"lc-web-painel",version:null!==(n=o.env.npm_package_version)&&void 0!==n?n:"0.0.0"},api:{timeout:3e5,retryAttempts:3,popupEngineUrl:"https://engine.lunacheckout.com"},features:{darkMode:!0,analytics:!1},constructor:{checkoutStylesType:"constructor:checkout-styles",checkoutStylesVersion:"1",checkoutLocalOrigin:void 0}},s={...r,env:"development",debug:!0,api:{...r.api,baseUrl:"https://api-dev.lunacheckout.com",storeEditorUrl:"https://editor-dev.lunacheckout.com",popupEngineUrl:"https://engine.lunacheckout.com",timeout:6e5,mockResponses:!0},features:{...r.features,experimentalFeatures:!0},devTools:{enableReduxLogger:!0,slowNetworkSimulation:!1},constructor:{...r.constructor,checkoutOrigin:"https://checkout.dev.lunacheckout.com",checkoutLocalOrigin:"http://localhost:3000"}},i={...r,env:"staging",debug:!0,api:{...r.api,baseUrl:"https://api-stg.lunacheckout.com",storeEditorUrl:"https://editor.lunacheckout.com",popupEngineUrl:"https://engine.lunacheckout.com",mockResponses:!1},features:{...r.features,analytics:!0,experimentalFeatures:!0},constructor:{...r.constructor,checkoutOrigin:"https://checkout.stg.lunacheckout.com"}},l={...r,env:"production",debug:!1,api:{...r.api,baseUrl:"https://api.lunacheckout.com",storeEditorUrl:"https://editor.lunacheckout.com",popupEngineUrl:"https://engine.lunacheckout.com",timeout:3e5,mockResponses:!1},features:{...r.features,analytics:!0,experimentalFeatures:!1},security:{contentSecurityPolicy:!0,strictTransportSecurity:!0},constructor:{...r.constructor,checkoutOrigin:"https://checkout.lunacheckout.com"}};var c=a(62601);let d=(()=>{var e;let t=null!==(e=c.env.APP_ENV)&&void 0!==e?e:c.env.NEXT_PUBLIC_APP_ENV;return t||"production"})();var u={development:s,staging:i,production:l}[d]||s},91172:function(e,t,a){"use strict";a.d(t,{O:function(){return useGlobal},V:function(){return GlobalStorage}});var n=a(57437),o=a(24033),r=a(2265);let s=(0,r.createContext)(null),useGlobal=()=>{let e=(0,r.useContext)(s);if(null===e)throw Error("globalContext deve estar dentro do Provider");return e},GlobalStorage=e=>{var t;let{children:a}=e,[i,l]=(0,r.useState)(!0),[c,d]=(0,r.useState)(!1),[u,m]=(0,r.useState)(null),h=(0,r.useRef)(null),p=null!==(t=(0,o.usePathname)())&&void 0!==t?t:"",[g,f]=(0,r.useState)("light"),[x,v]=(0,r.useState)(!1),[A,b]=(0,r.useState)(""),[y,j]=(0,r.useState)("normal"),[w,N]=(0,r.useState)(null),k=(0,r.useRef)(null),closeModal=()=>
1{v(!1),k.current&&clearTimeout(k.current),k.current=setTimeout(()=>{N(null),b("")},200)};return(0,r.useEffect)(()=>closeModal(),[p]),(0,r.useEffect)(()=>{let e=localStorage.getItem("theme");f(e&&"null"!==e?e:"light")},[]),(0,r.useEffect)(()=>{g&&"undefined"!=typeof document&&(document.body.classList.remove("dark","light"),document.body.classList.add(g),document.documentElement.classList.remove("dark","light"),document.documentElement.classList.add(g),window.localStorage.setItem("theme",g))},[g]),(0,n.jsx)(s.Provider,{value:{advice:c,adviceBody:u,showAdvice:function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2e3;h.current&&clearTimeout(h.current),d(!0),m({message:e,feedback:t}),h.current=setTimeout(()=>{d(!1),h.current=null},a)},theme:g,setTheme:f,modal:x,openModal:(e,t,a)=>{k.current&&clearTimeout(k.current),t&&N(t),b(e),a&&j(a),v(!0)},closeModal,modalContent:w,modalTitle:A,modalType:y,supportAdvice:i,setSupportAdvice:l},children:a})}},59378:function(e,t,a){"use strict";var n=a(2265);let o={email:{regex:/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,message:"Preencha um email v\xe1lido"},number:{regex:/^\d+$/,message:"Utilize n\xfameros apenas."},cep:{regex:/^\d{5}-?\d{3}$/,message:"Preencha um CEP v\xe1lido"},cpf:{regex:/^\d{3}\.\d{3}\.\d{3}-\d{2}$/,message:"Preencha um CPF v\xe1lido"},cnpj:{regex:/^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/,message:"Preencha um CNPJ v\xe1lido"},phone:{regex:/^\(\d{2}\) \d{5}-\d{4}$/,message:"Preencha um n\xfamero de telefone v\xe1lido"}};t.Z=(e,t)=>{let[a,r]=(0,n.useState)(t||""),[s,i]=(0,n.useState)(null);function validate(t){return!1===e||(0===t.length?(i("Preencha um valor."),!1):e&&o[e]&&!o[e].regex.test(t)?(i(o[e].message),!1):(i(!1),!0))}function onChange(e){let{target:t}=e;s&&validate(t.value),r(t.value)}function selectChange(e){let{target:t}=e;s&&validate(t.value),r(t.value)}function insert(e){r(e)}return{value:a,setValue:r,onChange,selectChange,insert,insertError:function(e){i(e)},validate:()=>validate(a),onBlur:()=>validate(a)}}},3112:function(e,t){"use strict";t.Z={src:"/_next/static/media/logo-dark.520898fa.png",height:516,width:1288,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAADCAMAAACZFr56AAAAMFBMVEX9/f3////////////+//////8AdJH///+MytPm8fQAqMFQoK4ngp4ArccAp7/+/v7UR5X8AAAAEHRSTlMcnH5ktVN7BR2UUyMton0/4rxhUgAAAAlwSFlzAAALEwAACxMBAJqcGAAAACNJREFUeJxj4OJg5WdmYmZi4OXmZGRhZGRh4GPjYWBgYGAHAAgEAIRvsVtAAAAAAElFTkSuQmCC",blurWidth:8,blurHeight:3}},83116:function(e,t){"use strict";t.Z={src:"/_next/static/media/logo-light.83a313fc.png",height:516,width:1288,blurDataURL:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAADCAMAAACZFr56AAAAMFBMVEUFGh0FCQoHBwcAWWwFBQUICAgGDQ0AAAAApb0FBQUGBgYGAwMGBgYAss0Ad
1pUAsMv8LvnNAAAAEHRSTlMal2QotT8nBX2BolN8U3ui2M8CKAAAAAlwSFlzAAALEwAACxMBAJqcGAAAACNJREFUeJxj4GXgZmXiZOJh4GdmZGRh5GJh4OBjZmBjYGAHAAfSAITrMWUtAAAAAElFTkSuQmCC",blurWidth:8,blurHeight:3}}},function(e){e.O(0,[5709,5592,3212,1751,4652,8660,8326,4758,4417,5142,2971,2472,1744],function(){return e(e.s=19103)}),_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.