"use strict";
(self.webpackChunk_N_E = self.webpackChunk_N_E || []).push([
    [863], {
        2863: (e, t, a) => {
            a.d(t, {
                A: () => s
            });
            var r = a(5155),
                o = a(2115),
                n = a(2615),
                i = a(2651);
            let l = async e => {
                    try {
                        let t = await i.A.post("/api/sembark", e);
                        if (t.data.success) return console.log("Sembark API call successful:", t.data), t.data;
                        throw console.error("Sembark API call failed:", t.data), Error(t.data.error || "API call failed")
                    } catch (e) {
                        throw console.error("Error calling Sembark API:", e), e
                    }
                },
                s = e => {
                    let {
                        isOpen: t,
                        onClose: a,
                        onSubmit: i,
                        title: s
                    } = e, {
                        data: d
                    } = (0, n.useSession)(), [m, c] = (0, o.useState)({
                        firstName: "",
                        email: "",
                        mobile: "",
                        destination: "",
                        comment: "",
                        numAdults: 1,
                        kids: 0,
                        bookingAmount: 0,
                        Toddlers: 0,
                        packageDate: "",
                        occupancy: "",
                        rooms: 1,
                        adults: 1,
                        children: 0,
                        toddlers: 0
                    }), [u, g] = (0, o.useState)(!1), [b, h] = (0, o.useState)(""), [x, f] = (0, o.useState)(""), p = e => {
                        let {
                            name: t,
                            value: a
                        } = e.target;
                        c(e => ({ ...e,
                            [t]: a
                        }))
                    }, v = () => {
                        let {
                            mobile: e
                        } = m;
                        return "" !== e
                    }, k = async e => {
                        if (e.preventDefault(), !v()) {
                            h("Please fill Mobile number."), f("error");
                            return
                        }
                        g(!0), h("");
                        try {
                            (await fetch("/api/google-sheets", {
                                method: "POST",
                                headers: {
                                    "Content-Type": "application/json"
                                },
                                body: JSON.stringify({
                                    Name: m.firstName,
                                    Email: m.email,
                                    Mobile: m.mobile,
                                    Location: m.destination,
                                    Comment: m.comment,
                                    PackageDate: m.packageDate || "",
                                    Occupancy: m.occupancy || "",
                                    Adults: m.adults.toString(),
                                    Children: m.children.toString(),
                                    Toddlers: m.toddlers.toString(),
                                    BookingAmount: m.bookingAmount.toString(),
                                    Rooms: m.rooms.toString()
                                })
                            })).ok || console.warn("Google Sheets API failed, but continuing with other operations");
                            let e = {
                                name: m.firstName,
                                phone_number: m.mobile,
                                email: m.email,
                                start_date: m.packageDate,
                                no_of_days: null,
                                no_of_adults: m.adults,
                                no_of_children: m.children,
                                destination: m.destination,
                                comments: m.comment,
                                reference_id: null
                            };
                            try {
                                await l(e)
                            } catch (e) {
                                console.warn("Sembark API error:", e)
                            }
                            try {
                                if ((await fetch("/api/send-email", {
                                        method: "POST",
                                        headers: {
                                            "Content-Type": "application/json"
                                        },
                                        body: JSON.stringify({
                                            firstName: m.firstName,
                                            email: m.email,
                                            mobile: m.mobile,
                                            destination: m.destination,
                                            comment: m.comment,
                                            numAdults: m.adults,
                                            kids: m.children,
                                            Toddlers: m.toddlers,
                                            bookingAmount: m.bookingAmount,
                                            packageDate: m.packageDate
                                        })
                                    })).ok) h("Your form has been successfully submitted!"), f("success"), setTimeout(() => {
                                    i(m)
                                }, 5e3), c({
                                    firstName: "",
                                    email: "",
                                    mobile: "",
                                    destination: s,
                                    comment: "",
                                    numAdults: 1,
                                    kids: 0,
                                    bookingAmount: 0,
                                    Toddlers: 0,
                                    packageDate: "",
                                    occupancy: "",
                                    rooms: 1,
                                    adults: 1,
                                    children: 0,
                                    toddlers: 0
                                });
                                else throw Error("Email sending failed")
                            } catch (e) {
                                console.warn("Email error:", e), h("Form submitted but there was an issue sending the confirmation email."), f("error")
                            }
                        } catch (e) {
                            console.warn(e), h("There was an error with the submission. Please try again."), f("error")
                        } finally {
                            g(!1)
                        }
                    };
                    return ((0, o.useEffect)(() => {
                        {
                            let o = localStorage.getItem("bookingData");
                            if (o) try {
                                var e, t, a, r;
                                let n = JSON.parse(o),
                                    i = (null == n ? void 0 : null === (t = n.selectedPlace) || void 0 === t ? void 0 : null === (e = t.availableBatches[n.selectedBatch - 1]) || void 0 === e ? void 0 : e.startTime) || "",
                                    l = (null == n ? void 0 : null === (r = n.selectedPlace) || void 0 === r ? void 0 : null === (a = r.availableBatches[n.selectedBatch - 1]) || void 0 === a ? void 0 : a.endTime) || "";
                                c(e => {
                                    var t, a, r, o, s;
                                    return { ...e,
                                        destination: (null === (t = n.selectedPlace) || void 0 === t ? void 0 : t.title) + " Group Trip",
                                        bookingAmount: 1.05 * (parseFloat(n.totalPrice) || 0),
                                        packageDate: "".concat(i, " to ").concat(l),
                                        occupancy: (null == n ? void 0 : n.occupancy) || "Single",
                                        adults: parseInt(null === (a = n.tickets) || void 0 === a ? void 0 : a.adult) || 1,
                                        children: parseInt(null === (r = n.tickets) || void 0 === r ? void 0 : r.child) || 0,
                                        toddlers: parseInt(null === (o = n.tickets) || void 0 === o ? void 0 : o.toddler) || 0,
                                        rooms: parseInt(null === (s = n.tickets) || void 0 === s ? void 0 : s.room) || 1
                                    }
                                })
                            } catch (e) {
                                console.warn("Error parsing booking data:", e)
                            } else c(e => ({ ...e,
                                destination: s || ""
                            }))
                        }
                    }, [s]), (0, o.useEffect)(() => {
                        t && (null == d ? void 0 : d.user) && c(e => {
                            var t, a;
                            return { ...e,
                                firstName: (null == d ? void 0 : null === (t = d.user) || void 0 === t ? void 0 : t.name) || "",
                                email: (null == d ? void 0 : null === (a = d.user) || void 0 === a ? void 0 : a.email) || ""
                            }
                        })
                    }, [t, d]), t) ? (0, r.jsx)("div", {
                        className: "fixed inset-0 bg-black/30 backdrop-blur-sm flex justify-center items-center z-[90] animate-fadeIn",
                        children: (0, r.jsxs)("div", {
                            className: "h-[100vh] md:h-auto bg-white/95 p-8 rounded-2xl shadow-[0_20px_70px_-10px_rgba(0,0,0,0.3)] w-full max-w-3xl relative transform animate-slideUp",
                            children: [(0, r.jsx)("div", {
                                className: "absolute inset-0 bg-gradient-to-br from-orange-50 to-transparent rounded-2xl pointer-events-none",
                                "aria-hidden": "true"
                            }), (0, r.jsxs)("div", {
                                className: "relative h-full grid items-center overflow-y-auto",
                                children: [(0, r.jsx)("button", {
                                    onClick: a,
                                    className: "absolute top-4 right-4 text-gray-400 hover:text-gray-600 transition-colors duration-200 bg-white/80 rounded-full p-2 backdrop-blur-sm hover:bg-white/95 group",
                                    children: (0, r.jsx)("svg", {
                                        className: "w-5 h-5 transform group-hover:rotate-90 transition-transform duration-200",
                                        fill: "none",
                                        stroke: "currentColor",
                                        viewBox: "0 0 24 24",
                                        children: (0, r.jsx)("path", {
                                            strokeLinecap: "round",
                                            strokeLinejoin: "round",
                                            strokeWidth: 2,
                                            d: "M6 18L18 6M6 6l12 12"
                                        })
                                    })
                                }), (0, r.jsxs)("div", {
                                    className: "text-center mb-8",
                                    children: [(0, r.jsx)("h2", {
                                        className: "text-xl md:text-3xl font-bold bg-gradient-to-r from-orange-600 to-orange-400 bg-clip-text text-transparent",
                                        children: "Your next adventure awaits!"
                                    }), (0, r.jsx)("p", {
                                        className: "text-sm md:text-base text-gray-500 mt-2",
                                        children: "Fill in your details and let's make it happen"
                                    })]
                                }), (0, r.jsxs)("form", {
                                    onSubmit: k,
                                    className: "space-y-6 text-gray-600",
                                    children: [(0, r.jsxs)("div", {
                                        className: "grid grid-cols-1 md:grid-cols-2 gap-4",
                                        children: [(0, r.jsxs)("div", {
                                            children: [(0, r.jsx)("label", {
                                                htmlFor: "firstName",
                                                className: "block text-xs md:text-sm font-medium text-gray-700",
                                                children: "Full Name"
                                            }), (0, r.jsx)("input", {
                                                type: "text",
                                                id: "firstName",
                                                name: "firstName",
                                                value: m.firstName,
                                                onChange: p,
                                                required: !0,
                                                className: "mt-1 p-2 w-full text-sm border border-gray-200 rounded-lg bg-white/50 backdrop-blur-sm focus:ring-2 focus:ring-orange-500/20 focus:border-orange-500 transition-all duration-200 hover:border-orange-500/50"
                                            })]
                                        }), (0, r.jsxs)("div", {
                                            children: [(0, r.jsx)("label", {
                                                htmlFor: "email",
                                                className: "block text-xs md:text-sm font-medium text-gray-700",
                                                children: "Email"
                                            }), (0, r.jsx)("input", {
                                                type: "email",
                                                id: "email",
                                                name: "email",
                                                value: m.email,
                                                onChange: p,
                                                required: !0,
                                                disabled: !0,
                                                className: "mt-1 p-2 w-full text-sm border border-gray-200 rounded-lg bg-white/50 backdrop-blur-sm focus:ring-2 focus:ring-orange-500/20 focus:border-orange-500 transition-all duration-200 hover:border-orange-500/50"
                                            })]
                                        }), (0, r.jsxs)("div", {
                                            children: [(0, r.jsx)("label", {
                                                htmlFor: "mobile",
                                                className: "block text-xs md:text-sm font-medium text-gray-700",
                                                children: "Mobile"
                                            }), (0, r.jsx)("input", {
                                                type: "tel",
                                                id: "mobile",
                                                name: "mobile",
                                                value: m.mobile,
                                                onChange: e => {
                                                    let t = e.target.value;
                                                    t.length <= 10 && /^\d*$/.test(t) && p(e)
                                                },
                                                pattern: "[0-9]{10}",
                                                maxLength: 10,
                                                required: !0,
                                                className: "mt-1 p-2 w-full text-sm border border-gray-200 rounded-lg bg-white/50 backdrop-blur-sm focus:ring-2 focus:ring-orange-500/20 focus:border-orange-500 transition-all duration-200 hover:border-orange-500/50"
                                            })]
                                        }), (0, r.jsxs)("div", {
                                            children: [(0, r.jsx)("label", {
                                                htmlFor: "destination",
                                                className: "block text-xs md:text-sm font-medium text-gray-700",
                                                children: "Your Selected Package"
                                            }), (0, r.jsx)("input", {
                                                type: "text",
                                                id: "destination",
                                                name: "destination",
                                                value: m.destination,
                                                onChange: p,
                                                required: !0,
                                                disabled: !0,
                                                className: "mt-1 capitalize p-2 w-full text-sm border border-gray-200 rounded-lg bg-white/50 backdrop-blur-sm focus:ring-2 focus:ring-orange-500/20 focus:border-orange-500 transition-all duration-200 hover:border-orange-500/50"
                                            })]
                                        })]
                                    }), (0, r.jsxs)("div", {
                                        children: [(0, r.jsx)("label", {
                                            htmlFor: "comment",
                                            className: "block text-xs md:text-sm font-medium text-gray-700",
                                            children: "Comment"
                                        }), (0, r.jsx)("textarea", {
                                            id: "comment",
                                            name: "comment",
                                            value: m.comment,
                                            onChange: p,
                                            required: !0,
                                            className: "mt-1 p-2 w-full h-16 text-sm resize-none border border-gray-200 rounded-lg bg-white/50 backdrop-blur-sm focus:ring-2 focus:ring-orange-500/20 focus:border-orange-500 transition-all duration-200 hover:border-orange-500/50"
                                        })]
                                    }), b && (0, r.jsx)("div", {
                                        className: "p-4 rounded-xl text-center backdrop-blur-sm animate-fadeIn ".concat("success" === x ? "bg-green-500 text-white" : "bg-red-500 text-white"),
                                        children: b
                                    }), (0, r.jsx)("div", {
                                        className: "flex flex-col md:flex-row justify-end gap-4",
                                        children: (0, r.jsx)("button", {
                                            type: "submit",
                                            disabled: u,
                                            className: "w-full md:w-auto px-8 py-3 bg-gradient-to-r from-orange-500 to-orange-600 text-white rounded-xl hover:from-orange-600 hover:to-orange-700 disabled:from-gray-400 disabled:to-gray-500 transition-all duration-200 transform hover:-translate-y-0.5 active:translate-y-0 shadow-lg hover:shadow-orange-500/25 font-medium",
                                            children: u ? "Submitting..." : "Submit"
                                        })
                                    })]
                                })]
                            })]
                        })
                    }) : null
                }
        }
    }
]);