1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6891],{6891:(e,r,t)=>{t.d(r,{ReservationController:()=>o});var a=t(7043);class o{static async createReservation(e){try{return this.validateReservationData(e),await a.E.createReservation(e)}catch(e){throw console.error("Error en controlador - crear reserva:",e),e}}static async getReservationById(e,r){try{if(!e)throw Error("ID de cliente es requerido");if(!r)throw Error("ID de reserva es requerido");return await a.E.getReservationById(e,r)}catch(e){throw console.error("Error en controlador - obtener reserva:",e),e}}static async getReservationsByClientId(e){try{if(!e)throw Error("ID de cliente es requerido");return await a.E.getReservationsByClientId(e)}catch(e){throw console.error("Error en controlador - obtener reservas del cliente:",e),e}}static async updateReservation(e,r,t){try{if(!e)throw Error("ID de cliente es requerido");if(!r)throw Error("ID de reserva es requerido");return t.customerInfo&&this.validateCustomerInfo(t.customerInfo),t.reservationDetails&&this.validateReservationDetails(t.reservationDetails),await a.E.updateReservation(e,r,t)}catch(e){throw console.error("Error en controlador - actualizar reserva:",e),e}}static async cancelReservation(e,r){try{if(!e)throw Error("ID de cliente es requerido");if(!r)throw Error("ID de reserva es requerido");await a.E.updateReservation(e,r,{status:"cancelled"})}catch(e){throw console.error("Error en controlador - cancelar reserva:",e),e}}static async confirmReservation(e,r){try{if(!e)throw Error("ID de cliente es requerido");if(!r)throw Error("ID de reserva es requerido");return await a.E.updateReservation(e,r,{status:"confirmed"})}catch(e){throw console.error("Error en controlador - confirmar reserva:",e),e}}static async getReservationsByDate(e,r){try{if(!e)throw Error("ID de cliente es requerido");if(!r)throw Error("Fecha es requerida");if(!/^\d{4}-\d{2}-\d{2}$/.test(r))throw Error("Formato de fecha inv\xe1lido. Use YYYY-MM-DD");return await a.E.getReservationsByDate(e,r)}catch(e){throw console.error("Error en controlador - obtener reservas por fecha:",e),e}}static async checkAvailability(e,r,t,o,s){try{if(!e||!r||!t||!o)throw Error("Todos los par\xe1metros son requeridos");if(o<=0)throw Error("El n\xfamero de personas debe ser mayor a 0");return await a.E.checkAvailability(e,r,t,o,s)}catch(e){throw console.error("Error en controlador - verificar disponibilidad:",e),e}}static validateReservationData(e){if(!e.clientId)throw Error("ID de cliente es requerido");this.validateCustomerInfo(e.customerInfo),this.validateReservationDetails(e.reservationDetails)}static validateCustomerInfo(e){if(!e.firstName||e.firstName.trim().length<2)throw Error("El nombre debe tener al menos 2 caracteres");if(!e.lastName||e.lastName.trim().length<2)throw Error("El apellido debe tener al menos 2 caracteres");if(!e.email)throw Error("El email es requerido");if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.email))throw Error("Formato de email inv\xe1lido");if(!e.phone)throw Error("El tel\xe9fono es requerido");if(e.phone.replace(/\D/g,"").length<10)throw Error("El tel\xe9fono debe tener al menos 10 d\xedgitos");if(e.birthday&&new Date(e.birthday)>new Date)throw Error("La fecha de cumplea\xf1os no puede ser en el futuro")}static validateReservationDetails(e){if(!e.persons||e.persons<1)throw Error("El n\xfamero de personas debe ser al menos 1");if(e.persons>50)throw Error("El n\xfamero m\xe1ximo de personas es 50");if(!e.date)throw Error("La fecha es requerida");if(!/^\d{4}-\d{2}-\d{2}$/.test(e.date))throw Error("Formato de fecha inv\xe1lido. Use YYYY-MM-DD");if(e.date,new Date().setHours(0,0,0,0),!e.hour)throw Error("La hora es requerida");if(!/^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/.test(e.hour))throw Error("Formato de hora inv\xe1lido. Use HH:MM")}}},7043:(e,r,t)=>{t.d(r,{E:()=>s});var a=t(85570),o=t(35317);class s{static async createReservation(e){try{let r=(0,o.H9)(a.db,this.COLLECTION_NAME,e.clientId),t="res_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9)),s=await (0,o.x7)(r),i={id:t,clientId:e.clientId,customerInfo:e.customerInfo,reservationDetail
1s:e.reservationDetails,status:"pending",createdAt:new Date,updatedAt:new Date};if(s.exists()){let e={...s.data().reservations,[t]:{...i,createdAt:(0,o.O5)(),updatedAt:(0,o.O5)()}};await (0,o.mZ)(r,{reservations:e,updatedAt:(0,o.O5)()})}else{let a={clientId:e.clientId,reservations:{[t]:{...i,createdAt:(0,o.O5)(),updatedAt:(0,o.O5)()}},createdAt:(0,o.O5)(),updatedAt:(0,o.O5)()};await (0,o.BN)(r,a)}return i}catch(e){throw console.error("Error al crear reserva:",e),Error("No se pudo crear la reserva")}}static async getReservationsByClientId(e){try{let r=await (0,o.x7)((0,o.H9)(a.db,this.COLLECTION_NAME,e));if(!r.exists())return[];let t=r.data(),s=[];return Object.entries(t.reservations||{}).forEach(e=>{var r,t;let[a,o]=e;s.push({id:a,clientId:o.clientId,customerInfo:o.customerInfo,reservationDetails:o.reservationDetails,status:o.status,createdAt:(null==(r=o.createdAt)?void 0:r.toDate)?o.createdAt.toDate():new Date(o.createdAt),updatedAt:(null==(t=o.updatedAt)?void 0:t.toDate)?o.updatedAt.toDate():new Date(o.updatedAt)})}),s.sort((e,r)=>e.createdAt&&r.createdAt?r.createdAt.getTime()-e.createdAt.getTime():0)}catch(e){throw console.error("Error al obtener reservas del cliente:",e),Error("No se pudieron obtener las reservas")}}static async getReservationById(e,r){try{var t,s,i;let n=await (0,o.x7)((0,o.H9)(a.db,this.COLLECTION_NAME,e));if(!n.exists())return null;let c=null==(t=n.data().reservations)?void 0:t[r];if(!c)return null;return{id:r,clientId:c.clientId,customerInfo:c.customerInfo,reservationDetails:c.reservationDetails,status:c.status,createdAt:(null==(s=c.createdAt)?void 0:s.toDate)?c.createdAt.toDate():new Date(c.createdAt),updatedAt:(null==(i=c.updatedAt)?void 0:i.toDate)?c.updatedAt.toDate():new Date(c.updatedAt)}}catch(e){throw console.error("Error al obtener reserva:",e),Error("No se pudo obtener la reserva")}}static async updateReservation(e,r,t){try{let s=(0,o.H9)(a.db,this.COLLECTION_NAME,e),i={["reservations.".concat(r,".updatedAt")]:(0,o.O5)()};t.customerInfo&&(i["reservations.".concat(r,".customerInfo")]=t.customerInfo),t.reservationDetails&&(i["reservations.".concat(r,".reservationDetails")]=t.reservationDetails),t.status&&(i["reservations.".concat(r,".status")]=t.status),await (0,o.mZ)(s,i);let n=await this.getReservationById(e,r);if(!n)throw Error("No se pudo obtener la reserva actualizada");return n}catch(e){throw console.error("Error al actualizar reserva:",e),Error("No se pudo actualizar la reserva")}}static async deleteReservation(e,r){try{let t=(0,o.H9)(a.db,this.COLLECTION_NAME,e);await (0,o.mZ)(t,{["reservations.".concat(r)]:(0,o.CL)(),updatedAt:(0,o.O5)()})}catch(e){throw console.error("Error al eliminar reserva:",e),Error("No se pudo eliminar la reserva")}}static async getReservationsByDate(e,r){try{return(await this.getReservationsByClientId(e)).filter(e=>e.reservationDetails.date===r)}catch(e){throw console.error("Error al obtener reservas por fecha:",e),Error("No se pudieron obtener las reservas por fecha")}}static async checkAvailability(e,r,t,a,o){try{return!0}catch(e){throw console.error("Error al verificar disponibilidad:",e),Error("No se pudo verificar la disponibilidad")}}}s.COLLECTION_NAME="Reservations"}}]);
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.