PageSourceSearch

https://impacto.com.pe/_next/static/chunks/2645-4b1e968e8fa836b4.js

js impacto.com.pe collected 2026-10-04 00:00:05 UTC 17,908 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2645],{74433:(e,t,a)=>{a.d(t,{A:()=>m});var r=a(95155),o=a(12115),s=a(93518),i=a(40767),n=a(59020),l=a(30814),c=a(76046);let d=e=>{let{isLoading:t,loadingText:a,defaultText:o,onClick:s,disabled:i=!1}=e;return(0,r.jsx)("button",{type:"submit",disabled:t||i,className:"w-full rounded-xl bg-blue-900 px-4 py-3.5 text-sm font-bold text-white hover:bg-blue-800 disabled:bg-gray-300 disabled:cursor-not-allowed transition-all shadow-md hover:shadow-lg active:scale-[0.98]",children:t?(0,r.jsxs)("span",{className:"flex items-center justify-center gap-2",children:[(0,r.jsx)("span",{className:"h-4 w-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),a]}):o})},u=e=>{let{onClick:t}=e;return(0,r.jsx)("button",{type:"button",onClick:t,className:"absolute top-3 left-3 p-2 text-gray-400 hover:text-gray-800 hover:bg-gray-100 rounded-full transition-colors z-20",children:(0,r.jsx)(s.A,{size:20})})};function m(e){let{onClose:t}=e,{email:a,password:s,code:m,step:g,isRecoveryFlow:p,isRegisterFlow:x,setEmail:h,setStep:y,setCode:f,setPassword:b,setIsRecoveryFlow:v,setIsRegisterFlow:w,handleSubmitLogin:j,handleRequestCode:N,handleSubmitCode:k,handleSubmitCodePassword:C,handleSubmitRecovery:R}=(0,n.w)(),T="/checkout"===(0,c.usePathname)(),[S,_]=(0,o.useState)(""),[E,O]=(0,o.useState)({login:!1,code:!1,password:!1,recovery:!1,register:!1}),I=(e,t)=>async a=>{a&&a.preventDefault(),O(t=>({...t,[e]:!0}));try{await t()}finally{O(t=>({...t,[e]:!1}))}},L=I("login",()=>j(a,s)),q=I("register",()=>N(a)),F=I("recovery",()=>R(a)),P=async e=>{if(e&&e.preventDefault(),m.length<6){l.oR.warning("El c\xf3digo debe tener 6 d\xedgitos.");return}p||x?y(7):await I("code",()=>k(a,m))(e)},z=async e=>{if(e&&e.preventDefault(),s!==S){l.oR.error("Las contrase\xf1as no coinciden");return}await I("password",()=>C(a,s,m))(e)};return(0,o.useEffect)(()=>{let e=e=>{"Escape"===e.key&&t()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t]),(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"fixed inset-0 z-[300] flex items-center justify-center p-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm transition-opacity animate-in fade-in duration-300",onClick:t}),(0,r.jsxs)("div",{className:"relative w-full max-w-[400px] bg-white rounded-3xl shadow-2xl overflow-hidden flex flex-col max-h-[90dvh] animate-in zoom-in-95 slide-in-from-bottom-4 duration-300",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center p-4 border-b border-transparent sticky top-0 z-10",children:[(0,r.jsx)("div",{}),g>1?(0,r.jsx)(u,{onClick:()=>{7===g?y(5):5===g?y(p||x?3:1):4===g?y(2):y(1)}}):(0,r.jsx)("div",{className:"w-8"}),(0,r.jsx)("button",{onClick:t,className:"p-2 rounded-full hover:bg-gray-100 text-gray-400 hover:text-gray-900 transition-colors",children:(0,r.jsx)(i.A,{size:22})})]}),(0,r.jsx)("div",{className:"px-6 pb-8 pt-0 overflow-y-auto custom-scrollbar",children:(()=>{switch(g){case 1:return(0,r.jsxs)("div",{className:"space-y-4 pt-2 animate-in fade-in zoom-in-95 duration-200",children:[(0,r.jsx)("div",{className:"flex justify-center mb-6",children:(0,r.jsx)("img",{src:"/LOGO.svg",alt:"Logo",className:"h-12 w-auto object-contain"})}),(0,r.jsxs)("div",{className:"text-center mb-6",children:[(0,r.jsx)("h2",{className:"text-2xl font-extrabold text-gray-900 tracking-tight",children:T?"\xa1Estamos a un paso!":"\xa1Bienvenido!"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:T?"Para terminar con tu pedido por favor logu\xe9ate":"Ingresa para comprar y ver tus pedidos"})]}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("button",{onClick:()=>{y(3),v(!1),w(!1),f("")},className:"w-full rounded-xl bg-blue-900 py-4 text-sm font-bold text-white hover:bg-blue-800 transition-all shadow-md active:scale-[0.98]",children:"Ingresar con C\xf3digo (Email)"}),(0,r.jsx)("button",{onClick:()=>{y(2),v(!1),w(!1)},className:"w-full rounded-xl bg-white border-2 border-gray-100 py-3.5 text-sm font-bold text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-all",children:"Usar Contrase\xf1a"})]}),(0,r.jsxs)("div",{className:"relative py-4",children:[(0,r.jsx)("div",{className:"absolute inset-0 flex items-center",children:(0,r.jsx)("span",{className:"w-full border-t border-gray-100"})}),(0,r.jsx)("div",{className:"relative flex justify-center text-xs uppercase",children:(0,r.jsx)("span",{className:"bg-white px-3 text-gray-400 font-medium tracking-wide",children:"O contin\xfaa con"})})]}),(0,r.jsxs)("button",{className:"flex w-full items-center justify-center gap-3 rounded-xl border border-gray-200 py-3.5 text-sm font-medium hover:bg-gray-50 transition-colors",children:[(0,r.jsx)("img",{src:"https://www.svgrepo.com/show/475656/google-color.svg",className:"h-5 w-5",alt:"Google"})," Google"]})]});case 2:return(0,r.jsxs)("form",{onSubmit:L,className:"space-y-5 pt-0 animate-in slide-in-from-right-8 duration-200",children:[(0,r.jsx)("div",{className:"flex justify-center mb-4",children:(0,r.jsx)("img",{src:"/LOGO.svg",alt:"Logo",className:"h-8 w-auto object-contain opacity-80"})}),(0,r.jsx)("div",{className:"text-center mb-4",children:(0,r.jsx)("h3",{className:"text-lg font-bold text-gray-900",children:"Iniciar Sesi\xf3n"})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs font-bold text-gray-700 mb-1.5 block uppercase tracking-wide",children:"Correo electr\xf3nico"}),(0,r.jsx)("input",{type:"email",autoFocus:!0,required:!0,value:a,onChange:e=>h(e.target.value),className:"w-full rounded-lg border-gray-300 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 outline-none bg-gray-50 focus:bg-white transition-all",placeholder:"[email protected]"})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs font-bold text-gray-700 mb-1.5 block uppercase tracking-wide",children:"Contrase\xf1a"}),(0,r.jsx)("input",{type:"password",required:!0,value:s,onChange:e=>b(e.target.value),className:"w-full rounded-lg border-gray-300 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 outline-none bg-gray-50 focus:bg-white transition-all",placeholder:"••••••••"})]})]}),(0,r.jsx)("button",{type:"button",className:"text-xs text-blue-600 hover:text-blue-800 hover:underline block w-full text-right font-medium",onClick:()=>{y(4),v(!0),w(!1)},children:"\xbfOlvidaste tu contrase\xf1a?"}),(0,r.jsx)(d,{isLoading:E.login,loadingText:"Verificando...",defaultText:"Ingresar"}),(0,r.jsxs)("div",{className:"text-center pt-2",children:[(0,r.jsx)("span",{className:"text-xs text-gray-500",children:"\xbfNo tienes cuenta? "}),(0,r.jsx)("button",{type:"button",className:"text-xs font-bold text-blue-600 hover:underline",onClick:()=>{y(3),v(!1),w(!0)},children:"Reg\xedstrate gratis"})]})]});default:let e;let t="",o="",i="",n=!1;return 3===g?(e=q,t=x?"Crear Cuenta":"Ingreso R\xe1pido",o="Te enviaremos un c\xf3digo a tu correo para verificar tu identidad.",i="Enviar C\xf3digo",n=E.register):4===g?(e=F,t="Recuperar Cuenta",o="Ingresa tu correo para recibir un c\xf3digo de recuperaci\xf3n.",i="Enviar C\xf3digo",n=E.recovery):5===g?(e=P,t="Verificaci\xf3n",o=(0,r.jsxs)("span",{children:["Ingresa el c\xf3digo enviado a ",(0,r.jsx)("br",{}),(0,r.jsx)("strong",{className:"text-gray-900",children:a})]}),i=p||x?"Verificar C\xf3digo":"Ingresar",n=E.code):(e=z,t=x?"Crear Contrase\xf1a":"Nueva Contrase\xf1a",o="Crea una contrase\xf1a segura para tu cuenta.",i=x?"Guardar Contrase\xf1a":"Confirmar Cambio",n=E.password),(0,r.jsxs)("form",{onSubmit:e,className:"space-y-6 pt-2 animate-in slide-in-from-right-8 duration-200",children:[(0,r.jsxs)("div",{className:"text-center",children:[(0,r.jsx)("div",{className:"flex justify-center mb-4",children:(0,r.jsx)("div",{className:"h-10 w-10 bg-blue-50 rounded-full flex items-center justify-center text-blue-600",children:3===g?(0,r.jsx)("span",{className:"font-bold",children:"@"}):5===g?(0,r.jsx)("span",{className:"font-mono font-bold",children:"123"}):(0,r.jsx)("span",{className:"font-bold",children:"?"})})}),(0,r.jsx)("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:t}),(0,r.jsx)("p",{className:"text-sm text-gray-600 leading-relaxed px-4",children:o})]}),(3===g||4===g)&&(0,r.jsx)("input",{type:"email",required:!0,value:a,autoFocus:!0,onChange:e=>h(e.target.value),className:"w-full rounded-lg border-gray-300 px-4 py-3.5 text-sm focus:ring-2 focus:ring-blue-500 outline-none bg-gray-50 focus:bg-white transition-all",placeholder:"[email protected]"}),5===g&&(0,r.jsx)("input",{type:"text",required:!0,value:m,autoFocus:!0,onChange:e=>f(e.target.value),maxLength:6,className:"w-full rounded-xl border-gray-300 px-4 py-4 text-3xl text-center tracking-[0.5em] font-bold font-mono focus:ring-2 focus:ring-blue-500 outline-none uppercase bg-gray-50 text-gray-800",placeholder:"000000"}),7===g&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("input",{type:"text",value:m,readOnly:!0,className:"w-full rounded-lg border-gray-200 px-4 py-3 text-sm bg-gray-100 text-gray-500 cursor-not-allowed",placeholder:"C\xf3digo verificado"}),(0,r.jsx)("input",{type:"password",required:!0,value:s,onChange:e=>b(e.target.value),className:"w-full rounded-lg border-gray-300 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 outline-none",placeholder:"Nueva contrase\xf1a"}),(0,r.jsx)("input",{type:"password",required:!0,value:S,onChange:e=>_(e.target.value),className:"w-full rounded-lg border-gray-300 px-4 py-3 text-sm focus:ring-2 focus:ring-blue-500 outline-none",placeholder:"Confirmar contrase\xf1a"})]}),(0,r.jsxs)("div",{className:"pt-2 flex flex-col gap-3",children:[(0,r.jsx)(d,{isLoading:n,loadingText:"Procesando...",defaultText:i}),7!==g&&(0,r.jsx)("button",{type:"button",onClick:()=>{5===g?y(p||x?3:1):y(1)},className:"w-full text-xs font-semibold text-gray-400 hover:text-gray-800 transition-colors py-2",children:"Cancelar"})]})]})}})()})]})]})})}},59020:(e,t,a)=>{a.d(t,{v:()=>l,w:()=>c});var r=a(99827),o=a(60709),s=a(30814);let i=!1,n=!1,l=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{token:a,logoutAuthUser:r}=c.getState(),o=await fetch(e,{...t,headers:{...t.headers,...a?{Authorization:"Bearer ".concat(a)}:{}}});return 401!==o.status||i||(i=!0,await r(),window.location.href="/"),o},c=(0,r.v)((0,o.Zr)(e=>({name:"",password:"",code:"",user:null,email:"",username:"",token:null,
1step:1,isOpen:!1,isOpenMenu:!1,isLogin:!1,isLogout:!1,isRecoveryFlow:!1,isRegisterFlow:!1,setIsLogout:t=>e({isLogout:t}),setIsLogin:t=>e({isLogin:t}),setIsRecoveryFlow:t=>e({isRecoveryFlow:t}),setIsRegisterFlow:t=>e({isRegisterFlow:t}),setIsOpen:t=>e({isOpen:t,step:1,isRecoveryFlow:!1,isRegisterFlow:!1}),setIsOpenMenu:t=>e({isOpenMenu:t}),setEmail:t=>e({email:t}),setPassword:t=>e({password:t}),setCode:t=>e({code:t}),setStep:t=>e({step:t}),handleSubmitLogin:async(t,a)=>{try{let l=await fetch("".concat("/api/backend","/ecommerce/clients/login"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:t,password:a})}),c=await l.json();if(l.ok){var r,o,i,n;s.oR.success("\xa1Bienvenido!"),e({isOpen:!1,isOpenMenu:!0,step:1,isLogin:!0,isLogout:!1,token:null===(r=c.tokens)||void 0===r?void 0:r.access,user:c.user||null,email:(null===(o=c.user)||void 0===o?void 0:o.email)||t,username:(null===(i=c.user)||void 0===i?void 0:i.username)||(null===(n=c.user)||void 0===n?void 0:n.email)||""})}else s.oR.error(c.message||"Error al iniciar sesi\xf3n")}catch(e){console.error(e),s.oR.error("Error de conexi\xf3n")}},handleRequestCode:async t=>{try{let a=await fetch("".concat("/api/backend","/ecommerce/clients/request_code"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t})}),r=await a.json();a.ok?(s.oR.success(r.message||"C\xf3digo enviado a tu correo."),e({step:5})):s.oR.error(r.message||"Error al solicitar c\xf3digo.")}catch(e){s.oR.error("Error de conexi\xf3n")}},handleSubmitCode:async(t,a)=>{try{let o=await fetch("".concat("/api/backend","/ecommerce/clients/loginMail"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:t,validation_code:a})}),i=await o.json();if(o.ok){var r;s.oR.success("\xa1Bienvenido!"),e({isOpen:!1,isOpenMenu:!0,step:1,isLogin:!0,isLogout:!1,token:null===(r=i.tokens)||void 0===r?void 0:r.access,user:i.user||null})}else s.oR.error(i.message||"C\xf3digo inv\xe1lido o expirado")}catch(e){s.oR.error("Error de conexi\xf3n")}},handleSubmitRecovery:async t=>{try{let a=await fetch("".concat("/api/backend","/ecommerce/clients/send_recovery_code"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t})}),r=await a.json();a.ok?(s.oR.success("C\xf3digo de recuperaci\xf3n enviado."),e({step:5,isRecoveryFlow:!0,isRegisterFlow:!1})):s.oR.error(r.message||"Error enviando c\xf3digo.")}catch(e){s.oR.error("Error de conexi\xf3n")}},handleSubmitCodePassword:async(t,a,r)=>{try{let o=await fetch("".concat("/api/backend","/ecommerce/clients/updateRegister"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,validation_code:r,password:a})});if(o.ok)s.oR.success("Contrase\xf1a guardada correctamente. Ahora inicia sesi\xf3n."),e({step:2,isRecoveryFlow:!1,isRegisterFlow:!1,code:"",password:""});else{let e=await o.json();s.oR.error(e.message||"Error al actualizar.")}}catch(e){s.oR.error("Error de conexi\xf3n")}},logoutAuthUser:async()=>{if(!n){n=!0,e({password:"",code:"",email:"",username:"",user:null,token:null,step:1,isOpen:!1,isOpenMenu:!1,isLogin:!1,isLogout:!0,isRecoveryFlow:!1,isRegisterFlow:!1}),localStorage.removeItem("auth-storage");try{let e=new AbortController,t=setTimeout(()=>e.abort(),5e3);await fetch("".concat("/api/backend","/ecommerce/clients/logout"),{method:"POST",credentials:"include",signal:e.signal}),clearTimeout(t)}catch(e){console.error("Error logout (API)",e)}finally{s.oR.info("Has cerrado sesi\xf3n."),n=!1}}},handleSubmit:async t=>{try{let a=await fetch("".concat("/api/backend","/ecommerce/clients/register"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,password:t,username:t})});if(a.ok)s.oR.success("C\xf3digo enviado."),e({step:5,isRecoveryFlow:!1});else{let e=await a.json();s.oR.error(e.message||"Error al registrar.")}}catch(e){s.oR.error("Error de conexi\xf3n")}}}),{name:"auth-storage",partialize:e=>({token:e.token,isLogin:e.isLogin,user:e.user,email:e.email,username:e.username}),onRehydrateStorage:()=>e=>
1{e&&e.isLogin&&!e.token&&(console.warn("Estado de auth corrupto detectado (isLogin sin token), limpiando..."),e.isLogin=!1,e.user=null,e.username="")}}))},80581:(e,t,a)=>{a.d(t,{_:()=>n});var r=a(99827),o=a(60709);async function s(e){let t=await fetch("/api/backend/ecommerce/products/validate-cart-stock",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:e}),cache:"no-store"});if(!t.ok)throw Error("Error validando el stock del carrito");return t.json()}var i=a(30814);let n=(0,r.v)((0,o.Zr)((e,t)=>({items:[],item_order:[],currentId:1,cartTimestamp:null,clearExpiredCart:()=>{let a=t(),r=a.cartTimestamp;return!!r&&0!==a.item_order.length&&new Date().getTime()>r+2592e5&&(e({item_order:[],currentId:1,cartTimestamp:null}),(0,i.oR)({title:"Carrito actualizado",description:"Tu carrito ten\xeda m\xe1s de 24 horas. Los productos han sido eliminados para verificar disponibilidad.",variant:"destructive"}),!0)},getTimeLeft:()=>{let e=t(),a=e.cartTimestamp;if(!a||0===e.item_order.length)return"Sin l\xedmite";let r=a+2592e5-new Date().getTime();if(r<=0)return"Expirado";let o=Math.floor(r/36e5),s=Math.floor(r%36e5/6e4);return o>0?"".concat(o,"h ").concat(s,"m"):"".concat(s," min")},updateItemQuantity:(a,r)=>{e({item_order:t().item_order.map(e=>e.id===a?{...e,quantity:r}:e),cartTimestamp:new Date().getTime()})},addItem:(a,r)=>{let o=t().item_order,s=t().currentId,i=o.findIndex(e=>e.items.some(e=>e.id===a.id));-1!==i?e({item_order:o.map((e,t)=>t===i?{...e,quantity:e.quantity+r}:e),cartTimestamp:new Date().getTime()}):e({item_order:[...o,{id:s,quantity:r,items:[a]}],currentId:s+1,cartTimestamp:new Date().getTime()})},validateStock:async()=>{let e=t();if(0===e.item_order.length)return;let a=e.item_order.flatMap(e=>e.items.map(t=>({product_id:t.id,quantity:e.quantity})));try{for(let e of(await s(a)).updated_items){let a=t().item_order.find(t=>t.items.some(t=>t.id===e.product_id));if(a){if(e.deleted||e.available_quantity<=0)t().removeItem(a.id),i.oR.success("Un producto de tu carrito ya no est\xe1 disponible.");else if(e.available_quantity<a.quantity){var r;let o=(null===(r=a.items[0])||void 0===r?void 0:r.name)||"Producto",s=o.split(" "),n=s.length>6?s.slice(0,6).join(" ")+"...":o;a.quantity;let l=e.available_quantity;t().updateItemQuantity(a.id,l),i.oR.success("".concat(n," ahora tiene cantidad ").concat(l," por disponibilidad."))}}}0===t().item_order.length&&i.oR.success("Los productos de tu carrito ya no est\xe1n disponibles.")}catch(e){console.error("❌ [validateStock] Error validando stock:",e)}},validateAndUpdateCart:async()=>{let e=t();e.clearExpiredCart(),await e.validateStock()},removeItem:a=>{let r=t().item_order.filter(e=>e.id!==a);e({item_order:r,cartTimestamp:r.length>0?new Date().getTime():null}),i.oR.success("El producto fue eliminado del carrito")},removeAll:()=>{e({item_order:[],currentId:1,cartTimestamp:null}),i.oR.success("El producto fue eliminado del carrito")}}),{name:"cart-storage",storage:(0,o.KU)(()=>localStorage),migrate:(e,t)=>
10===t?e&&e.item_order&&e.item_order.length>0?{...e,cartTimestamp:new Date().getTime(),items:e.items||[],currentId:e.currentId||1}:{...e,cartTimestamp:null,items:(null==e?void 0:e.items)||[],currentId:(null==e?void 0:e.currentId)||1}:e,version:1}))}}]);

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.