"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useConfirmationQuery = void 0;
const react_1 = require("react");
const Query_1 = require("./Query");
const useConfirmationQuery = () => {
    const hashQuery = (0, Query_1.useHashQuery)();
    const query = (0, Query_1.useQuery)();
    const [queryPaymentMethod, queryRoomstayId, queryPlanpayCheckoutId, returnFromPayment, success, paymentId] = (0, react_1.useMemo)(() => ['paymentMethod', 'roomstayId', 'planpay_checkout_id', 'returnFromPayment', 'success', 'paymentId'].map((name) => query.get(name) || hashQuery.get(name)), [hashQuery, query]);
    const isReturnFromPayment = returnFromPayment === 'true';
    const isSuccess = success === 'true';
    const isBackFromPlanpay = !!queryPlanpayCheckoutId && !!queryRoomstayId && !!queryPaymentMethod;
    const isBackFromExternalPayment = isReturnFromPayment && (isSuccess || !isBackFromPlanpay) && !!queryRoomstayId;
    const isInitialCheckout = !isBackFromExternalPayment && !isBackFromPlanpay;
    return {
        queryPaymentMethod,
        queryRoomstayId,
        queryPlanpayCheckoutId,
        returnFromPayment: isReturnFromPayment,
        success: isSuccess,
        paymentId,
        isBackFromPlanpay,
        isBackFromExternalPayment,
        isInitialCheckout,
    };
};
exports.useConfirmationQuery = useConfirmationQuery;
//# sourceMappingURL=ConfirmationQuery.js.map