// source --> https://www.drakensberghiker.co.za/wp-content/plugins/yatra/assets/js/yatra.js?ver=2.3.4 
// @var yatra_params
window.yatra_global_tour_additional_price = 0;
(function ($) {
    let yatra_availability_enable_dates = yatra_params.single_tour.enabled_dates;
    let yatra_availability_date_data = yatra_params.single_tour.all_available_date_data;
    var YatraFrontend = function ($) {
        return {
            init: function () {
                this.cacheDom();
                this.bindEvents();
                this.initLib();
                this.initNiceNumber();
                this.initDateTimePicker();
                this.initPartsPagination();
            },
            initPartsPagination: function () {
                $('body').on('click', '.yatra-pagination-wrap .page-numbers', function (e) {
                    e.preventDefault();
                    var wrap = $(this).closest('.yatra-ajax-pagination');
                    var current_page = parseInt(wrap.find('.current').text());
                    var page_number = $(this).text();
                    if ($(this).hasClass('next')) {
                        page_number = current_page + 1;
                    } else if ($(this).hasClass('prev')) {
                        page_number = current_page - 1;
                    }
                    var attributes = wrap.attr('attributes')
                    var type = wrap.attr('type')
                    var data = {
                        page_number: page_number,
                        action: yatra_params.pagination.pagination_action,
                        yatra_nonce: yatra_params.pagination.pagination_nonce,
                        attributes: attributes,
                        type:type,
                    };
                    var list_wrap = $(this).closest('.yatra-pagination-wrap').closest('div').parent();
                    $.ajax({
                        type: "POST",
                        url: yatra_params.ajax_url,
                        data: data,
                        beforeSend: function () {
                            list_wrap.addClass('yatra-loading');
                        },
                        success: function (response) {
                            if (response.success === true) {
                                list_wrap.html(response.data);
                            } else {

                            }

                        },
                        complete: function () {
                            list_wrap.removeClass('yatra-loading');
                        }
                    });
                });
            },
            initNiceNumber: function () {
                var _that = this;
                $('body').on('click', '.yatra-nice-input-number button.plus-button', function () {
                    var input = $(this).closest('.yatra-nice-input-number').find('input');
                    _that.calculateNiceNumber(input, 'plus');
                });
                $('body').on('click', '.yatra-nice-input-number button.minus-button', function () {
                    var input = $(this).closest('.yatra-nice-input-number').find('input');
                    _that.calculateNiceNumber(input, 'minus');
                });
            },
            calculateNiceNumber: function (input, type) {
                var step = input.attr('data-step') === undefined ? 1 : parseInt(input.attr('data-step'));
                var max = input.attr('data-max') === undefined ? 99999 : parseInt(input.attr('data-max'));
                var min = input.attr('data-min') === undefined ? 0 : parseInt(input.attr('data-min'));
                var current = parseInt(input.val());

                if (type === 'plus') {
                    current = current + step;
                } else {
                    current = current - step;
                }

                if (current >= max) {
                    input.val(max).trigger('change');
                    return;
                }
                if (current < min) {
                    input.val(min).trigger('change');
                    return;
                }

                input.val(current).trigger('change');
            },
            cacheDom: function () {
                this.$booking_form = $('#yatra-tour-booking-form-fields');
                this.$enquiry_form = $('#yatra-tour-enquiry-form-fields');
                this.$yatra_update_cart = $('.yatra_update_cart');
            },

            bindEvents: function () {
                var $this = this;
                this.$booking_form.on('submit', function (e) {
                    e.preventDefault();
                    var tour_id = $(this).attr('data-tour-id');
                    var form_data = $(this).serialize();
                    $this.bookTour(form_data);
                });

                this.$enquiry_form.on('submit', function (e) {
                    e.preventDefault();
                    var selected_date = $('input.yatra-booking-calendar-choosen-date').val();
                    var form_data = $(this).serializeArray();
                    form_data.push({name: "selected_date", value: selected_date});
                    $this.sendEnquiry(form_data);
                });

                $('form.yatra-cart-form').on('submit', function (e) {
                    e.preventDefault();
                    var form = $(this);
                    var form_data = form.serialize();
                    $this.submit_cart_form(form_data, $(this));
                });
                $('body').on('click', '.yatra_update_cart', function (e) {
                    e.preventDefault();
                    var form = $(this).closest('form');
                    var field = $('<input type="hidden" name="yatra_cart_submit_type" value="update_cart"/>');
                    form.find('.yatra_cart_submit_type').remove();
                    form.append(field);
                    var form_data = form.serialize();
                    $this.submit_cart_form(form_data, $(this));
                });

                $('body').on('click', '.yatra_apply_coupon', function (e) {
                    e.preventDefault();
                    var form = $(this).closest('form');
                    var field = $('<input type="hidden" name="yatra_cart_submit_type" value="apply_coupon"/>');
                    form.find('.yatra_cart_submit_type').remove();
                    form.append(field);
                    var form_data = form.serialize();
                    $this.submit_cart_form(form_data, $(this));
                });
                $('body').on('change', 'table.yatra_cart_table input.yatra-number-of-person-field', function (e) {
                    e.preventDefault();

                    var yatra_cart_table = $(this).closest('.yatra_cart_table');

                    yatra_cart_table.find('.yatra_update_cart').removeAttr('disabled');

                });
                $('body').on('click',
                    '.yatra-itinerary-list-item .itinerary-heading, .yatra-itinerary-list-item .itinerary-heading, .yatra-faq-list-item .faq-heading, .yatra-faq-list-item .faq-heading', function () {

                        if ($(this).find('.yatra-icon').length === 0 && $(this).find('svg').length === 0) {
                            return;
                        }
                        var toggle_node = $(this).find('.yatra-icon').length !== 0 ? $(this).find('.yatra-icon') : $(this).find('svg');

                        if (toggle_node.hasClass('fa-angle-up')) {

                            $this.toggleYatraList(toggle_node, 'close');
                        } else {
                            $this.toggleYatraList(toggle_node, 'open');
                        }
                    });
                $('body').on('click', '.yatra-tab-content .tab-title, .yatra-tab-content .tab-title', function () {

                    if ($(this).find('.yatra-expand-collapse').length === 0 && $(this).find('svg').length === 0) {
                        return;
                    }
                    var toggle_node = $(this).find('.yatra-expand-collapse').length !== 0 ? $(this).find('.yatra-expand-collapse') : $(this).find('svg');
                    var expand_text = toggle_node.data('expand-text');
                    var collapse_text = toggle_node.data('collapse-text');
                    var toggle_status = 'close';
                    if (toggle_node.hasClass('expanded')) {
                        toggle_status = 'close';
                        toggle_node.removeClass('expanded').addClass('collapsed').text(expand_text);
                    } else {
                        toggle_status = 'open';
                        toggle_node.removeClass('collapsed').addClass('expanded').text(collapse_text);
                    }

                    $.each(toggle_node.closest('.yatra-tab-content').find('ul.yatra-list li.yatra-list-item .yatra-heading'), function () {

                        var icon = $(this).find('.yatra-icon');
                        if (icon.length > 0) {
                            $this.toggleYatraList(icon, toggle_status);
                        }
                    });


                    //heading.append(span);
                    //toggle_node.remove();

                });
                $('body').on('click', '.yatra-enquiry-now-btn', function (event) {
                    $('#yatra-tour-sidebar-tabs').find('.yatra-tab-wrap li').find('a[aria-controls="yatra-tour-enquiry-form"]').trigger('click');
                    event.preventDefault();

                });

                $('body').on('click', '.yatra-calendar-date-listing-item', function () {
                    if ($(this).hasClass('yatra-availability-none')) {
                        return;
                    }
                    var date = $(this).attr('data-date');
                    $(this).closest('ul').find('li span').removeClass('active');
                    $(this).addClass('active');
                    $this.onDateSelect(date);
                })

                $('body').on('change', '.yatra-availability-select-year-month', function () {
                    var value = $(this).val();
                    $this.calendarMonthChange(value);
                });


            },
            initLib: function () {

                if (typeof $().select2 !== 'undefined') {
                    $('.yatra-select2').select2();
                }
                if (typeof $().datepicker !== 'undefined') {
                    $('.yatra-date').datepicker();
                }
                tippy('.yatra-tippy-tooltip', {
                    allowHTML: true,
                });

            },
            toggleYatraList: function ($toggle_node, toggle_status) {
                var $this = this;


                if (toggle_status == 'open') {
                    $this.listToggleOpen($toggle_node);
                } else {
                    $this.listToggleClose($toggle_node);

                }
            },
            listToggleOpen: function ($toggle_node) {
                $toggle_node.closest('li.yatra-list-item').find('.yatra-content').slideDown('slow');
                var span = $('<span class="yatra-icon fa fa-angle-up"/>');
                var heading = $toggle_node.closest('h4');
                $toggle_node.hide();
                heading.append(span);
                $toggle_node.remove();

            },
            listToggleClose: function ($toggle_node) {
                $toggle_node.closest('li.yatra-list-item').find('.yatra-content').slideUp('slow');
                var span = $('<span class="yatra-icon fa fa-angle-down"/>');
                var heading = $toggle_node.closest('h4');
                $toggle_node.hide();
                heading.append(span);
                $toggle_node.remove();

            },
            addLoading: function ($node) {

                var type = $node[0].tagName.toLowerCase();

                if (type === "a" || type === "button") {
                    $node.text($node.attr('data-loading-text'));
                } else {
                    $node.val($node.attr('data-loading-text'));
                }

            }, removeLoading: function ($node) {
                var type = $node[0].tagName.toLowerCase();
                if (type === "a" || type === "button") {
                    $node.text($node.attr('data-text'));
                } else {
                    $node.val($node.attr('data-text'));
                }
            },
            submit_cart_form: function (form_data, cart_btn) {

                var cart_form = cart_btn.closest('form.yatra-cart-form');
                var $this = this;
                $.ajax({
                    type: "POST",
                    url: yatra_params.ajax_url,
                    data: form_data,
                    beforeSend: function () {
                        $this.table_loading(cart_btn);
                    },
                    success: function (response) {

                        var el = cart_form.closest('.yatra-shortcode-wrapper');
                        if (response.success === true) {
                            var table = response.data.table;
                            cart_form.find('.yatra-cart-table-wrapper').find('table.yatra_cart_table').remove();
                            cart_form.find('.yatra-cart-table-wrapper').append(table)
                            window.YatraMessages.showSuccess(el, response.data.message);

                        } else {
                            window.YatraMessages.showError(el, response.data);

                        }
                        cart_form.find('.yatra-overlay').remove();
                    },
                    complete: function () {
                        cart_form.find('.yatra-overlay').remove();
                    }
                });
            },
            table_loading: function (cart_btn) {
                cart_btn.closest('form').append('<div class="yatra-overlay"></div>');
            },
            bookTour: function (form_data) {
                var $this = this;
                var $btn = $this.$booking_form.find('.yatra-book-now-btn');
                $.ajax({
                    type: "POST",
                    url: yatra_params.ajax_url,
                    data: form_data,
                    beforeSend: function () {
                        $this.addLoading($btn);
                    },
                    success: function (data) {

                        var el = $('.yatra-book-btn-wrapper.book-btn');
                        if (data.success === true) {

                            window.location = data.data.cart_page_url;

                        } else {
                            YatraMessages.showError(el, data.data);

                        }
                    },
                    complete: function () {
                        $this.removeLoading($btn);
                    }
                });
            },

            sendEnquiry: function (form_data) {
                var $this = this;
                $.ajax({
                    type: "POST",
                    url: yatra_params.ajax_url,
                    data: form_data,
                    beforeSend: function () {
                        $this.$enquiry_form.find('fieldset').prop('disabled', true);
                    },
                    success: function (data) {
                        var el = $('.yatra-enquiry-submit-btn-wrapper');

                        if (data.success === true) {
                            YatraMessages.showSuccess(el, data.data);
                            $this.$enquiry_form[0].reset();

                        } else {
                            YatraMessages.showError(el, data.data);
                        }
                    },
                    complete: function () {
                        $this.$enquiry_form.find('fieldset').prop('disabled', false);
                    }
                });
            },
            initDateTimePicker: function () {

                var _that = this;
                if ($(".yatra_tour_start_date").length === 0) {
                    return;
                }

                if ($(".yatra-calendar-wrap").length < 1) {
                    return;
                }
                var single_tour = yatra_params.single_tour;

                var calendar_options = {

                    fixedStartDay: 0, // begin weeks by sunday


                    enable: function (d) {
                        return yatra_availability_enable_dates;
                    },

                    onDayCreate: function (el, fullDate, day, month, year) {
                        var date = fullDate.trim();
                        var object = yatra_availability_date_data[date];
                        if (object !== undefined && !$(el).hasClass('disabled')) {
                            var class_name = 'yatra-tippy-tooltip yatra-availability-' + object.availability;
                            $(el).addClass(class_name).attr('data-tippy-content', object.description);
                        }
                    },
                    onCalendarLoad: function () {
                        tippy('.yatra-tippy-tooltip', {
                            allowHTML: true,
                        });
                    },
                    onDateSelect: function (date, el) {

                        if ($(el).hasClass('yatra-availability-none')) {
                            $(el).closest('td').removeClass('active');
                            return;
                        }

                        _that.onDateSelect(date);
                    },

                    onBeforeMonthChange: function (month, year) {
                        var _that = this;
                        var selected_date = year + '-' + (month + 1) + '-01';
                        $("#yatra-tour-booking-form").addClass('yatra-loading');
                        $.ajax({
                            type: "POST",
                            url: yatra_params.ajax_url,
                            async: false,
                            data: {
                                tour_id: $('form#yatra-tour-booking-form-fields').find('input[name="tour_id"]').val(),
                                selected_date: selected_date,
                                action: yatra_params.single_tour.availability_month_action,
                                yatra_nonce: yatra_params.single_tour.availability_month_nonce
                            },
                            beforeSend: function () {

                            },
                            success: function (data) {
                                if (typeof data.success) {
                                    yatra_availability_enable_dates = data.data.enable_dates;
                                    yatra_availability_date_data = data.data.available_data;
                                }

                            },
                            complete: function () {
                            }
                        });
                        $("#yatra-tour-booking-form").removeClass('yatra-loading');
                    }

                };
                if (typeof yatra_params.week_days !== undefined) {
                    calendar_options.days = yatra_params.week_days;
                }
                if (typeof yatra_params.months !== undefined) {
                    calendar_options.months = yatra_params.months;
                }

                if (typeof yatra_params.fixedStartDay !== undefined && yatra_params.fixedStartDay!=='') {
                    calendar_options.fixedStartDay = parseInt(yatra_params.fixedStartDay);
                }
                
                let container = $(".yatra-calendar-wrap").YatraCalendar(calendar_options);

                tippy('.yatra-tippy-tooltip', {
                    allowHTML: true,
                });
            },
            onDateSelect: function (date) {
                $(".yatra_tour_start_date").find('input').attr('data-selected-date', date).val(date);
                const date_full = new Date(date);  // 2009-11-10

                let month = date_full.toLocaleString('default', {month: 'long'});

                if (typeof yatra_params.months !== undefined) {
                    if (yatra_params.months[date_full.getMonth()] !== undefined) {
                        month = yatra_params.months[date_full.getMonth()];
                    }
                }

                var date_string = month + ' ' + date_full.getDate() + ', ' + date_full.getFullYear();

                $('.tour-info-pricing-header').find('h2').html(date_string);
                $.ajax({
                    type: "POST",
                    url: yatra_params.ajax_url,
                    data: {
                        tour_id: $('form#yatra-tour-booking-form-fields').find('input[name="tour_id"]').val(),
                        selected_date: date,
                        action: yatra_params.single_tour.availability_action,
                        yatra_nonce: yatra_params.single_tour.availability_nonce
                    },
                    beforeSend: function () {
                        $("#yatra-tour-booking-form").addClass('yatra-loading');
                    },
                    success: function (data) {

                        if (typeof data.success !== undefined) {
                            if (data.success) {
                                $('.yatra-tour-booking-pricing-wrap').html(data.data);

                                if (yatra_params.show_enquiry_form === 'no') {

                                    $('#yatra-tour-sidebar-tabs').find('li.yatra-enquiry-form-list').addClass('yatra-hide');
                                    $('#yatra-tour-enquiry-form.yatra-tab-content ').addClass('yatra-hide');
                                }

                                if ($('.yatra-tour-booking-pricing-wrap').find('button.yatra-enquiry-now-btn').length === 1) {

                                    $('#yatra-tour-sidebar-tabs').find('li.yatra-enquiry-form-list').removeClass('yatra-hide');
                                    $('#yatra-tour-enquiry-form.yatra-tab-content ').removeClass('yatra-hide');

                                }

                                setTimeout(function () {
                                    tippy('.yatra-tippy-tooltip', {
                                        allowHTML: true,
                                    });
                                }, 500);

                            }
                        }

                    },
                    complete: function () {


                        $("#yatra-tour-booking-form").removeClass('yatra-loading');


                    }
                });
            },
            calendarMonthChange: function (selected_date) {
                $("#yatra-tour-booking-form").addClass('yatra-loading');
                $.ajax({
                    type: "POST",
                    url: yatra_params.ajax_url,
                    data: {
                        tour_id: $('form#yatra-tour-booking-form-fields').find('input[name="tour_id"]').val(),
                        selected_date: selected_date,
                        action: yatra_params.single_tour.availability_month_action,
                        yatra_nonce: yatra_params.single_tour.availability_month_nonce,
                        type: 'date_listing'
                    },
                    beforeSend: function () {

                    },
                    success: function (data) {
                        if (typeof data.success) {
                            var content = data.data.content;
                            $('.yatra-calendar-listing-wrap').html(content);

                        } else {
                            $('.yatra-calendar-listing-wrap').html('<h2>Somethign went wrong, please try again');
                        }

                    },
                    complete: function () {
                        $("#yatra-tour-booking-form").removeClass('yatra-loading');
                        tippy('.yatra-tippy-tooltip', {
                            allowHTML: true,
                        });
                    }
                });
            }


        };
    }(jQuery);

    $.fn.YatraTabs = function (params) {

        this.each(function () {

            // express a single node as a jQuery object
            var $el = $(this);

            var YatraTabsMethods = function ($) {
                return {

                    init: function ($el) {

                        this.cacheDom($el);
                        this.setupAria();
                        this.bindEvents();
                    },

                    cacheDom: function () {
                        this.$el = $el;
                        this.$tabList = this.$el.find('ul.yatra-tab-wrap');
                        this.$tab = this.$tabList.find('li.item');
                        this.$tabFirst = this.$tabList.find('li.item:first-child a');
                        this.$tabLink = this.$tabList.find('li.item > a')
                        this.$tabPanel = this.$el.find('section');
                        this.$tabPanelFirstContent = this.$el.find('section > *:first-child');
                        this.$tabPanelFirst = this.$el.find('section:first-child');
                        this.$tabPanelNotFirst = this.$el.find('section:not(:first-of-type)');
                    },

                    bindEvents: function () {
                        this.$tabLink.on('click', function (e) {
                            this.changeTab(e);
                        }.bind(this));
                        this.$tabLink.on('keydown', function (e) {
                            this.changeTabKey(e);
                        }.bind(this));
                    },

                    changeTab: function (event) {
                        var self = $(event.currentTarget);
                        event.preventDefault();
                        this.removeTabFocus();
                        this.setSelectedTab(self);
                        this.hideAllTabPanels();
                        this.setSelectedTabPanel(self);
                    },

                    changeTabKey: function (event) {
                        var self = $(event.target),
                            $target = this.setKeyboardDirection(self, event.keyCode);

                        if ($target.length) {
                            this.removeTabFocus(self);
                            this.setSelectedTab($target);
                        }
                        this.hideAllTabPanels();
                        this.setSelectedTabPanel($(document.activeElement));
                    },

                    hideAllTabPanels: function () {
                        this.$tabPanel.attr('aria-hidden', 'true');
                    },

                    removeTabFocus: function (self) {
                        var $this = this.$el.find('[role="tab"]');

                        $this.attr({
                            'tabindex': '-1',
                            'data-aria-selected': null
                        }).closest('li').removeClass('active');
                    },

                    selectFirstTab: function () {
                        this.$tabFirst.attr({
                            'data-aria-selected': 'true',
                            'tabindex': '0'
                        }).closest('li').addClass('active');
                    },

                    setupAria: function () {
                        this.$tabList.attr('role', 'tablist');
                        this.$tab.attr('role', 'presentation');
                        this.$tabLink.attr({
                            'role': 'tab',
                            'tabindex': '-1'
                        });
                        this.$tabLink.each(function () {
                            var $this = $(this);

                            $this.attr('aria-controls', $this.attr('href').substring(1));
                        });
                        this.$tabPanel.attr({
                            'role': 'tabpanel'
                        });
                        this.$tabPanelFirstContent.attr({
                            'tabindex': '0'
                        });
                        this.$tabPanelNotFirst.attr({
                            'aria-hidden': 'true'
                        });
                        this.selectFirstTab();
                    },

                    setKeyboardDirection: function (self, keycode) {
                        var $prev = self.parents('li').prev().children('[role="tab"]'),
                            $next = self.parents('li').next().children('[role="tab"]');

                        switch (keycode) {
                            case 37:
                                return $prev;
                                break;
                            case 39:
                                return $next;
                                break;
                            default:
                                return false;
                                break;
                        }
                    },

                    setSelectedTab: function (self) {
                        self.attr({
                            'data-aria-selected': true,
                            'tabindex': '0'
                        }).focus().closest('li').addClass('active');
                    },

                    setSelectedTabPanel: function (self) {
                        this.$el.find('#' + self.attr('aria-controls')).attr('aria-hidden', false);
                    },

                };
            }(jQuery);

            YatraTabsMethods.init($el);


        });

        // allow jQuery chaining
        return this;
    };


    window.YatraMessages = {

        getMessageHTML: function (messages) {
            var message_html = $("<ul/>");

            if (typeof messages === "object") {
                messages.forEach((value, index) => {
                    var li = $('<li/>').text(value);
                    message_html.append(li);
                });
            } else if (typeof messages === "string") {
                var li = $('<li/>').text(messages);
                message_html.append(li);
            }
            return message_html;
        },
        showError: function (el, messages, is_append = true, fade_out_delay = 5000) {

            var message_html = this.getMessageHTML(messages);

            var error_html = $('<div class="yatra-message yatra-error" id="yatra-message"/>');

            error_html.append(message_html);

            $(el).find('.yatra-message').remove();

            if (is_append) {
                $(el).append(error_html);

            } else {
                $(el).prepend(error_html);
            }
            let target = document.getElementById("yatra-message");

            if (target.getBoundingClientRect().bottom > window.innerHeight) {
                target.scrollIntoView(false);
            }

            if (target.getBoundingClientRect().top < 0) {
                target.scrollIntoView();
            }

            if (fade_out_delay > 0) {

                $(el).find('.yatra-message').delay(fade_out_delay).fadeOut(800, function () {
                    $(this).remove()
                });
            }

        },
        showSuccess: function (el, messages, is_append = true, fade_out_delay = 5000) {

            var message_html = this.getMessageHTML(messages);

            var error_html = $('<div class="yatra-message yatra-success" id="yatra-message"/>');

            error_html.append(message_html);

            $(el).find('.yatra-message').remove();

            if (is_append) {
                $(el).append(error_html);

            } else {
                $(el).prepend(error_html);
            }
            let target = document.getElementById("yatra-message");

            if (target.getBoundingClientRect().bottom > window.innerHeight) {
                target.scrollIntoView(false);
            }

            if (target.getBoundingClientRect().top < 0) {
                target.scrollIntoView();
            }

            if (fade_out_delay > 0) {
                $(el).find('.yatra-message').delay(fade_out_delay).fadeOut(800, function () {
                    $(this).remove()
                });
            }


        }
    };

    var YatraPricingCalculator = {

        init: function () {

            this.bindEvents();
        },
        bindEvents: function () {
            var _that = this;
            $('body').on('change', '.yatra-single-tour-number-of-person', function () {
                var price_field = $(this).closest('.yatra-price-item-field');
                var final_price = _that.getPriceItemFinalPrice(price_field);
                var finalPriceString = _that.getPrice(yatra_params.currency_symbol, final_price.final);
                var regularPriceString = _that.getPrice(yatra_params.currency_symbol, final_price.regular);
                price_field.find('.yatra-traveller-price').find('.final').text(finalPriceString);
                price_field.find('.yatra-traveller-price').find('.regular').text(regularPriceString);
                $(this).trigger('yatra_single_tour_number_of_person_changed', $(this).val());
                var total_price = _that.getTotalTourPrice();

                $('.yatra-tour-total-price').find('span').text(_that.getPrice(yatra_params.currency_symbol, total_price)).attr('data-total-price', total_price);


            });

        },
        getPrice(currency = null, price) {
            currency = currency === null ? yatra_params.currency_symbol : currency;

            price = this.numberFormat(price);

            var currency_position = yatra_params.currency_position;
            if (currency_position === "left_space") {
                return currency + ' ' + price;

            } else if (currency_position === "right_space") {
                return price + ' ' + currency;

            } else if (currency_position === "right") {
                return price + currency;

            } else {
                return currency + price;

            }
        },
        numberFormat: function (number) {
            var decimals = yatra_params.decimals;
            var dec_point = yatra_params.decimal_separator;
            var thousands_sep = yatra_params.thousand_separator;
            // Strip all characters but numerical ones.
            number = (number + '').replace(/[^0-9+\-Ee.]/g, '');
            var n = !isFinite(+number) ? 0 : +number,
                prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
                sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,
                dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
                s = '',
                toFixedFix = function (n, prec) {
                    var k = Math.pow(10, prec);
                    return '' + Math.round(n * k) / k;
                };
            // Fix for IE parseFloat(0.55).toFixed(0) = 0;
            s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
            if (s[0].length > 3) {
                s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
            }
            if ((s[1] || '').length < prec) {
                s[1] = s[1] || '';
                s[1] += new Array(prec - s[1].length + 1).join('0');
            }
            return s.join(dec);
        },
        getTotalTourPrice: function () {

            var _that = this;

            var total_price = 0;

            $.each($('.yatra-price-item-field'), function () {

                var final_price = _that.getPriceItemFinalPrice($(this));

                total_price += parseInt(final_price.final);
            });

            return ((parseInt(window.yatra_global_tour_additional_price)) + total_price);


        },

        getPriceItemFinalPrice: function (price_field) {

            var price = {
                'regular': price_field.data('regular-price'),
                'sales': price_field.data('sales-price'),
                'final': price_field.data('final-price'),
                'people': price_field.find('.yatra-single-tour-number-of-person').val(),
                'currency': price_field.data('currency-symbol'),
                'pricing_per': price_field.data('pricing-per'),
                'group_size': price_field.data('group-size')
            }

            var total_people = parseInt(price.people);
            var pricing_per = price.pricing_per;
            var person_count = total_people;
            if (pricing_per === "group" && total_people > 0) {
                var group_size = parseInt(price.group_size);
                group_size = group_size < 1 ? 1 : group_size;
                person_count = Math.ceil(total_people / group_size)

            }
            var total_regular_price = parseInt(price.regular) * person_count;
            var total_sales_price = (price.sales) === '' ? total_regular_price : parseInt(price.sales) * person_count;

            return {
                'regular': total_regular_price,
                'final': total_sales_price
            };

        }
    };

    $(document).ready(function () {
        YatraFrontend.init();
        YatraPricingCalculator.init();
        $('#yatra-tour-tabs').YatraTabs();
        $('#yatra-tour-sidebar-tabs').YatraTabs();
        window.YatraPricingCalculator = YatraPricingCalculator;


    });
}(jQuery));
// source --> https://www.drakensberghiker.co.za/wp-content/plugins/yatra/assets/js/yatra-single-tour.js?ver=2.3.4 
(function ($) {

    var YatraSingleTour = function ($) {
        return {
            init: function () {
                this.bindEvents();
            },
            bindEvents: function () {
                var _that = this;
                $('body').on('click', '.yatra-responsive-tab-title', _that.toggle_tabs);
                _that.initSlider();
            },
            toggle_tabs: function (event) {
                var _that = this;
                event.preventDefault();
                let id = $(this).attr('data-id');
                let wrap = $(this).closest('.yatra-single-tour-tabs');
                if (wrap.find('.yatra-tab-content#' + id).length > 0) {
                    if (wrap.find('.yatra-tab-content#' + id).is(':visible')) {
                        wrap.find('.yatra-tab-content#' + id).slideUp();
                        $(this).find('.yatra-toggle-icon').addClass('fa-angle-down').removeClass('fa-angle-up')
                    } else {
                        wrap.find('.yatra-tab-content#' + id).slideDown();

                        $(this).find('.yatra-toggle-icon').addClass('fa-angle-up').removeClass('fa-angle-down')
                    }
                    wrap.find('.yatra-tab-content:not(#' + id + ')').hide();
                    wrap.find('.yatra-responsive-tab-title:not([data-id="' + id + '"])').find('.yatra-toggle-icon').addClass('fa-angle-down').removeClass('fa-angle-up');

                }

            },
            initSlider: function () {

                $('#yatra-tour-slider').lightSlider({
                    gallery: true,
                    adaptiveHeight: false,
                    item: 1,
                    loop: true,
                    slideMargin: 0,
                    thumbItem: 9,
                    mode: 'fade',
                    prevHtml: '<i class="fa fa-angle-left prev" aria-hidden="true"></i>',
                    nextHtml: '<i class="fa fa-angle-right next" aria-hidden="true"></i>',
                    onSliderLoad: function (el) {
                        var maxHeight = 0,
                            container = $(el),
                            children = container.children();
                        children.each(function () {
                            var childHeight = $(this).height();
                            if (childHeight > maxHeight) {
                                maxHeight = childHeight;
                            }
                        });


                        //container.height(500);
                    }

                });
            }


        };
    }(jQuery);
    $(document).ready(function () {

        YatraSingleTour.init();


    });
}(jQuery));
// source --> https://www.drakensberghiker.co.za/wp-content/plugins/yatra/assets/lib/lightslider/js/lightslider.min.js?ver=1.1.3 
/*! lightslider - v1.1.6 - 2016-10-25
* https://github.com/sachinchoolur/lightslider
* Copyright (c) 2016 Sachin N; Licensed MIT */
!function(a,b){"use strict";var c={item:3,autoWidth:!1,slideMove:1,slideMargin:10,addClass:"",mode:"slide",useCSS:!0,cssEasing:"ease",easing:"linear",speed:400,auto:!1,pauseOnHover:!1,loop:!1,slideEndAnimation:!0,pause:2e3,keyPress:!1,controls:!0,prevHtml:"",nextHtml:"",rtl:!1,adaptiveHeight:!1,vertical:!1,verticalHeight:500,vThumbWidth:100,thumbItem:10,pager:!0,gallery:!1,galleryMargin:5,thumbMargin:5,currentPagerPosition:"middle",enableTouch:!0,enableDrag:!0,freeMove:!0,swipeThreshold:40,responsive:[],onBeforeStart:function(a){},onSliderLoad:function(a){},onBeforeSlide:function(a,b){},onAfterSlide:function(a,b){},onBeforeNextSlide:function(a,b){},onBeforePrevSlide:function(a,b){}};a.fn.lightSlider=function(b){if(0===this.length)return this;if(this.length>1)return this.each(function(){a(this).lightSlider(b)}),this;var d={},e=a.extend(!0,{},c,b),f={},g=this;d.$el=this,"fade"===e.mode&&(e.vertical=!1);var h=g.children(),i=a(window).width(),j=null,k=null,l=0,m=0,n=!1,o=0,p="",q=0,r=e.vertical===!0?"height":"width",s=e.vertical===!0?"margin-bottom":"margin-right",t=0,u=0,v=0,w=0,x=null,y="ontouchstart"in document.documentElement,z={};return z.chbreakpoint=function(){if(i=a(window).width(),e.responsive.length){var b;if(e.autoWidth===!1&&(b=e.item),i<e.responsive[0].breakpoint)for(var c=0;c<e.responsive.length;c++)i<e.responsive[c].breakpoint&&(j=e.responsive[c].breakpoint,k=e.responsive[c]);if("undefined"!=typeof k&&null!==k)for(var d in k.settings)k.settings.hasOwnProperty(d)&&(("undefined"==typeof f[d]||null===f[d])&&(f[d]=e[d]),e[d]=k.settings[d]);if(!a.isEmptyObject(f)&&i>e.responsive[0].breakpoint)for(var g in f)f.hasOwnProperty(g)&&(e[g]=f[g]);e.autoWidth===!1&&t>0&&v>0&&b!==e.item&&(q=Math.round(t/((v+e.slideMargin)*e.slideMove)))}},z.calSW=function(){e.autoWidth===!1&&(v=(o-(e.item*e.slideMargin-e.slideMargin))/e.item)},z.calWidth=function(a){var b=a===!0?p.find(".lslide").length:h.length;if(e.autoWidth===!1)m=b*(v+e.slideMargin);else{m=0;for(var c=0;b>c;c++)m+=parseInt(h.eq(c).width())+e.slideMargin}return m},d={doCss:function(){var a=function(){for(var a=["transition","MozTransition","WebkitTransition","OTransition","msTransition","KhtmlTransition"],b=document.documentElement,c=0;c<a.length;c++)if(a[c]in b.style)return!0};return e.useCSS&&a()?!0:!1},keyPress:function(){e.keyPress&&a(document).on("keyup.lightslider",function(b){a(":focus").is("input, textarea")||(b.preventDefault?b.preventDefault():b.returnValue=!1,37===b.keyCode?g.goToPrevSlide():39===b.keyCode&&g.goToNextSlide())})},controls:function(){e.controls&&(g.after('<div class="lSAction"><a class="lSPrev">'+e.prevHtml+'</a><a class="lSNext">'+e.nextHtml+"</a></div>"),e.autoWidth?z.calWidth(!1)<o&&p.find(".lSAction").hide():l<=e.item&&p.find(".lSAction").hide(),p.find(".lSAction a").on("click",function(b){return b.preventDefault?b.preventDefault():b.returnValue=!1,"lSPrev"===a(this).attr("class")?g.goToPrevSlide():g.goToNextSlide(),!1}))},initialStyle:function(){var a=this;"fade"===e.mode&&(e.autoWidth=!1,e.slideEndAnimation=!1),e.auto&&(e.slideEndAnimation=!1),e.autoWidth&&(e.slideMove=1,e.item=1),e.loop&&(e.slideMove=1,e.freeMove=!1),e.onBeforeStart.call(this,g),z.chbreakpoint(),g.addClass("lightSlider").wrap('<div class="lSSlideOuter '+e.addClass+'"><div class="lSSlideWrapper"></div></div>'),p=g.parent(".lSSlideWrapper"),e.rtl===!0&&p.parent().addClass("lSrtl"),e.vertical?(p.parent().addClass("vertical"),o=e.verticalHeight,p.css("height",o+"px")):o=g.outerWidth(),h.addClass("lslide"),e.loop===!0&&"slide"===e.mode&&(z.calSW(),z.clone=function(){if(z.calWidth(!0)>o){for(var b=0,c=0,d=0;d<h.length&&(b+=parseInt(g.find(".lslide").eq(d).width())+e.slideMargin,c++,!(b>=o+e.slideMargin));d++);var f=e.autoWidth===!0?c:e.item;if(f<g.find(".clone.left").length)for(var i=0;i<g.find(".clone.left").length-f;i++)h.eq(i).remove();if(f<g.find(".clone.right").length)for(var j=h.length-1;j>h.length-1-g.find(".clone.right").length;j--)q--,h.eq(j).remove();for(var k=g.find(".clone.right").length;f>k;k++)g.find(".lslide").eq(k).clone().removeClass("lslide").addClass("clone right").appendTo(g),q++;for(var l=g.find(".lslide").length-g.find(".clone.left").length;l>g.find(".lslide").length-f;l--)g.find(".lslide").eq(l-1).clone().removeClass("lslide").addClass("clone left").prependTo(g);h=g.children()}else h.hasClass("clone")&&(g.find(".clone").remove(),a.move(g,0))},z.clone()),z.sSW=function(){l=h.length,e.rtl===!0&&e.vertical===!1&&(s="margin-left"),e.autoWidth===!1&&h.css(r,v+"px"),h.css(s,e.slideMargin+"px"),m=z.calWidth(!1),g.css(r,m+"px"),e.loop===!0&&"slide"===e.mode&&n===!1&&(q=g.find(".clone.left").length)},z.calL=function(){h=g.children(),l=h.length},this.doCss()&&p.addClass("usingCss"),z.calL(),"slide"===e.mode?(z.calSW(),z.sSW(),e.loop===!0&&(t=a.slideValue(),this.move(g,t)),e.vertical===!1&&this.setHeight(g,!1)):(this.setHeight(g,!0),g.addClass("lSFade"),this.doCss()||(h.fadeOut(0),h.eq(q).fadeIn(0))),e.loop===!0&&"slide"===e.mode?h.eq(q).addClass("active"):h.first().addClass("active")},pager:function(){var a=this;if(z.createPager=function(){w=(o-(e.thumbItem*e.thumbMargin-e.thumbMargin))/e.thumbItem;var b=p.find(".lslide"),c=p.find(".lslide").length,d=0,f="",h=0;for(d=0;c>d;d++){"slide"===e.mode&&(e.autoWidth?h+=(parseInt(b.eq(d).width())+e.slideMargin)*e.slideMove:h=d*(v+e.slideMargin)*e.slideMove);var i=b.eq(d*e.slideMove).attr("data-thumb");if(f+=e.gallery===!0?'<li style="width:100%;'+r+":"+w+"px;"+s+":"+e.thumbMargin+'px"><a href="#"><img src="'+i+'" /></a></li>':'<li><a href="#">'+(d+1)+"</a></li>","slide"===e.mode&&h>=m-o-e.slideMargin){d+=1;var j=2;e.autoWidth&&(f+='<li><a href="#">'+(d+1)+"</a></li>",j=1),j>d?(f=null,p.parent().addClass("noPager")):p.parent().removeClass("noPager");break}}var k=p.parent();k.find(".lSPager").html(f),e.gallery===!0&&(e.vertical===!0&&k.find(".lSPager").css("width",e.vThumbWidth+"px"),u=d*(e.thumbMargin+w)+.5,k.find(".lSPager").css({property:u+"px","transition-duration":e.speed+"ms"}),e.vertical===!0&&p.parent().css("padding-right",e.vThumbWidth+e.galleryMargin+"px"),k.find(".lSPager").css(r,u+"px"));var l=k.find(".lSPager").find("li");l.first().addClass("active"),l.on("click",function(){return e.loop===!0&&"slide"===e.mode?q+=l.index(this)-k.find(".lSPager").find("li.active").index():q=l.index(this),g.mode(!1),e.gallery===!0&&a.slideThumb(),!1})},e.pager){var b="lSpg";e.gallery&&(b="lSGallery"),p.after('<ul class="lSPager '+b+'"></ul>');var c=e.vertical?"margin-left":"margin-top";p.parent().find(".lSPager").css(c,e.galleryMargin+"px"),z.createPager()}setTimeout(function(){z.init()},0)},setHeight:function(a,b){var c=null,d=this;c=e.loop?a.children(".lslide ").first():a.children().first();var f=function(){var d=c.outerHeight(),e=0,f=d;b&&(d=0,e=100*f/o),a.css({height:d+"px","padding-bottom":e+"%"})};f(),c.find("img").length?c.find("img")[0].complete?(f(),x||d.auto()):c.find("img").on("load",function(){setTimeout(function(){f(),x||d.auto()},100)}):x||d.auto()},active:function(a,b){this.doCss()&&"fade"===e.mode&&p.addClass("on");var c=0;if(q*e.slideMove<l){a.removeClass("active"),this.doCss()||"fade"!==e.mode||b!==!1||a.fadeOut(e.speed),c=b===!0?q:q*e.slideMove;var d,f;b===!0&&(d=a.length,f=d-1,c+1>=d&&(c=f)),e.loop===!0&&"slide"===e.mode&&(c=b===!0?q-g.find(".clone.left").length:q*e.slideMove,b===!0&&(d=a.length,f=d-1,c+1===d?c=f:c+1>d&&(c=0))),this.doCss()||"fade"!==e.mode||b!==!1||a.eq(c).fadeIn(e.speed),a.eq(c).addClass("active")}else a.removeClass("active"),a.eq(a.length-1).addClass("active"),this.doCss()||"fade"!==e.mode||b!==!1||(a.fadeOut(e.speed),a.eq(c).fadeIn(e.speed))},move:function(a,b){e.rtl===!0&&(b=-b),this.doCss()?a.css(e.vertical===!0?{transform:"translate3d(0px, "+-b+"px, 0px)","-webkit-transform":"translate3d(0px, "+-b+"px, 0px)"}:{transform:"translate3d("+-b+"px, 0px, 0px)","-webkit-transform":"translate3d("+-b+"px, 0px, 0px)"}):e.vertical===!0?a.css("position","relative").animate({top:-b+"px"},e.speed,e.easing):a.css("position","relative").animate({left:-b+"px"},e.speed,e.easing);var c=p.parent().find(".lSPager").find("li");this.active(c,!0)},fade:function(){this.active(h,!1);var a=p.parent().find(".lSPager").find("li");this.active(a,!0)},slide:function(){var a=this;z.calSlide=function(){m>o&&(t=a.slideValue(),a.active(h,!1),t>m-o-e.slideMargin?t=m-o-e.slideMargin:0>t&&(t=0),a.move(g,t),e.loop===!0&&"slide"===e.mode&&(q>=l-g.find(".clone.left").length/e.slideMove&&a.resetSlide(g.find(".clone.left").length),0===q&&a.resetSlide(p.find(".lslide").length)))},z.calSlide()},resetSlide:function(a){var b=this;p.find(".lSAction a").addClass("disabled"),setTimeout(function(){q=a,p.css("transition-duration","0ms"),t=b.slideValue(),b.active(h,!1),d.move(g,t),setTimeout(function(){p.css("transition-duration",e.speed+"ms"),p.find(".lSAction a").removeClass("disabled")},50)},e.speed+100)},slideValue:function(){var a=0;if(e.autoWidth===!1)a=q*(v+e.slideMargin)*e.slideMove;else{a=0;for(var b=0;q>b;b++)a+=parseInt(h.eq(b).width())+e.slideMargin}return a},slideThumb:function(){var a;switch(e.currentPagerPosition){case"left":a=0;break;case"middle":a=o/2-w/2;break;case"right":a=o-w}var b=q-g.find(".clone.left").length,c=p.parent().find(".lSPager");"slide"===e.mode&&e.loop===!0&&(b>=c.children().length?b=0:0>b&&(b=c.children().length));var d=b*(w+e.thumbMargin)-a;d+o>u&&(d=u-o-e.thumbMargin),0>d&&(d=0),this.move(c,d)},auto:function(){e.auto&&(clearInterval(x),x=setInterval(function(){g.goToNextSlide()},e.pause))},pauseOnHover:function(){var b=this;e.auto&&e.pauseOnHover&&(p.on("mouseenter",function(){a(this).addClass("ls-hover"),g.pause(),e.auto=!0}),p.on("mouseleave",function(){a(this).removeClass("ls-hover"),p.find(".lightSlider").hasClass("lsGrabbing")||b.auto()}))},touchMove:function(a,b){if(p.css("transition-duration","0ms"),"slide"===e.mode){var c=a-b,d=t-c;if(d>=m-o-e.slideMargin)if(e.freeMove===!1)d=m-o-e.slideMargin;else{var f=m-o-e.slideMargin;d=f+(d-f)/5}else 0>d&&(e.freeMove===!1?d=0:d/=5);this.move(g,d)}},touchEnd:function(a){if(p.css("transition-duration",e.speed+"ms"),"slide"===e.mode){var b=!1,c=!0;t-=a,t>m-o-e.slideMargin?(t=m-o-e.slideMargin,e.autoWidth===!1&&(b=!0)):0>t&&(t=0);var d=function(a){var c=0;if(b||a&&(c=1),e.autoWidth)for(var d=0,f=0;f<h.length&&(d+=parseInt(h.eq(f).width())+e.slideMargin,q=f+c,!(d>=t));f++);else{var g=t/((v+e.slideMargin)*e.slideMove);q=parseInt(g)+c,t>=m-o-e.slideMargin&&g%1!==0&&q++}};a>=e.swipeThreshold?(d(!1),c=!1):a<=-e.swipeThreshold&&(d(!0),c=!1),g.mode(c),this.slideThumb()}else a>=e.swipeThreshold?g.goToPrevSlide():a<=-e.swipeThreshold&&g.goToNextSlide()},enableDrag:function(){var b=this;if(!y){var c=0,d=0,f=!1;p.find(".lightSlider").addClass("lsGrab"),p.on("mousedown",function(b){return o>m&&0!==m?!1:void("lSPrev"!==a(b.target).attr("class")&&"lSNext"!==a(b.target).attr("class")&&(c=e.vertical===!0?b.pageY:b.pageX,f=!0,b.preventDefault?b.preventDefault():b.returnValue=!1,p.scrollLeft+=1,p.scrollLeft-=1,p.find(".lightSlider").removeClass("lsGrab").addClass("lsGrabbing"),clearInterval(x)))}),a(window).on("mousemove",function(a){f&&(d=e.vertical===!0?a.pageY:a.pageX,b.touchMove(d,c))}),a(window).on("mouseup",function(g){if(f){p.find(".lightSlider").removeClass("lsGrabbing").addClass("lsGrab"),f=!1,d=e.vertical===!0?g.pageY:g.pageX;var h=d-c;Math.abs(h)>=e.swipeThreshold&&a(window).on("click.ls",function(b){b.preventDefault?b.preventDefault():b.returnValue=!1,b.stopImmediatePropagation(),b.stopPropagation(),a(window).off("click.ls")}),b.touchEnd(h)}})}},enableTouch:function(){var a=this;if(y){var b={},c={};p.on("touchstart",function(a){c=a.originalEvent.targetTouches[0],b.pageX=a.originalEvent.targetTouches[0].pageX,b.pageY=a.originalEvent.targetTouches[0].pageY,clearInterval(x)}),p.on("touchmove",function(d){if(o>m&&0!==m)return!1;var f=d.originalEvent;c=f.targetTouches[0];var g=Math.abs(c.pageX-b.pageX),h=Math.abs(c.pageY-b.pageY);e.vertical===!0?(3*h>g&&d.preventDefault(),a.touchMove(c.pageY,b.pageY)):(3*g>h&&d.preventDefault(),a.touchMove(c.pageX,b.pageX))}),p.on("touchend",function(){if(o>m&&0!==m)return!1;var d;d=e.vertical===!0?c.pageY-b.pageY:c.pageX-b.pageX,a.touchEnd(d)})}},build:function(){var b=this;b.initialStyle(),this.doCss()&&(e.enableTouch===!0&&b.enableTouch(),e.enableDrag===!0&&b.enableDrag()),a(window).on("focus",function(){b.auto()}),a(window).on("blur",function(){clearInterval(x)}),b.pager(),b.pauseOnHover(),b.controls(),b.keyPress()}},d.build(),z.init=function(){z.chbreakpoint(),e.vertical===!0?(o=e.item>1?e.verticalHeight:h.outerHeight(),p.css("height",o+"px")):o=p.outerWidth(),e.loop===!0&&"slide"===e.mode&&z.clone(),z.calL(),"slide"===e.mode&&g.removeClass("lSSlide"),"slide"===e.mode&&(z.calSW(),z.sSW()),setTimeout(function(){"slide"===e.mode&&g.addClass("lSSlide")},1e3),e.pager&&z.createPager(),e.adaptiveHeight===!0&&e.vertical===!1&&g.css("height",h.eq(q).outerHeight(!0)),e.adaptiveHeight===!1&&("slide"===e.mode?e.vertical===!1?d.setHeight(g,!1):d.auto():d.setHeight(g,!0)),e.gallery===!0&&d.slideThumb(),"slide"===e.mode&&d.slide(),e.autoWidth===!1?h.length<=e.item?p.find(".lSAction").hide():p.find(".lSAction").show():z.calWidth(!1)<o&&0!==m?p.find(".lSAction").hide():p.find(".lSAction").show()},g.goToPrevSlide=function(){if(q>0)e.onBeforePrevSlide.call(this,g,q),q--,g.mode(!1),e.gallery===!0&&d.slideThumb();else if(e.loop===!0){if(e.onBeforePrevSlide.call(this,g,q),"fade"===e.mode){var a=l-1;q=parseInt(a/e.slideMove)}g.mode(!1),e.gallery===!0&&d.slideThumb()}else e.slideEndAnimation===!0&&(g.addClass("leftEnd"),setTimeout(function(){g.removeClass("leftEnd")},400))},g.goToNextSlide=function(){var a=!0;if("slide"===e.mode){var b=d.slideValue();a=b<m-o-e.slideMargin}q*e.slideMove<l-e.slideMove&&a?(e.onBeforeNextSlide.call(this,g,q),q++,g.mode(!1),e.gallery===!0&&d.slideThumb()):e.loop===!0?(e.onBeforeNextSlide.call(this,g,q),q=0,g.mode(!1),e.gallery===!0&&d.slideThumb()):e.slideEndAnimation===!0&&(g.addClass("rightEnd"),setTimeout(function(){g.removeClass("rightEnd")},400))},g.mode=function(a){e.adaptiveHeight===!0&&e.vertical===!1&&g.css("height",h.eq(q).outerHeight(!0)),n===!1&&("slide"===e.mode?d.doCss()&&(g.addClass("lSSlide"),""!==e.speed&&p.css("transition-duration",e.speed+"ms"),""!==e.cssEasing&&p.css("transition-timing-function",e.cssEasing)):d.doCss()&&(""!==e.speed&&g.css("transition-duration",e.speed+"ms"),""!==e.cssEasing&&g.css("transition-timing-function",e.cssEasing))),a||e.onBeforeSlide.call(this,g,q),"slide"===e.mode?d.slide():d.fade(),p.hasClass("ls-hover")||d.auto(),setTimeout(function(){a||e.onAfterSlide.call(this,g,q)},e.speed),n=!0},g.play=function(){g.goToNextSlide(),e.auto=!0,d.auto()},g.pause=function(){e.auto=!1,clearInterval(x)},g.refresh=function(){z.init()},g.getCurrentSlideCount=function(){var a=q;if(e.loop){var b=p.find(".lslide").length,c=g.find(".clone.left").length;a=c-1>=q?b+(q-c):q>=b+c?q-b-c:q-c}return a+1},g.getTotalSlideCount=function(){return p.find(".lslide").length},g.goToSlide=function(a){q=e.loop?a+g.find(".clone.left").length-1:a,g.mode(!1),e.gallery===!0&&d.slideThumb()},g.destroy=function(){g.lightSlider&&(g.goToPrevSlide=function(){},g.goToNextSlide=function(){},g.mode=function(){},g.play=function(){},g.pause=function(){},g.refresh=function(){},g.getCurrentSlideCount=function(){},g.getTotalSlideCount=function(){},g.goToSlide=function(){},g.lightSlider=null,z={init:function(){}},g.parent().parent().find(".lSAction, .lSPager").remove(),g.removeClass("lightSlider lSFade lSSlide lsGrab lsGrabbing leftEnd right").removeAttr("style").unwrap().unwrap(),g.children().removeAttr("style"),h.removeClass("lslide active"),g.find(".clone").remove(),h=null,x=null,n=!1,q=0)},setTimeout(function(){e.onSliderLoad.call(this,g)},10),a(window).on("resize orientationchange",function(a){setTimeout(function(){a.preventDefault?a.preventDefault():a.returnValue=!1,z.init()},200)}),this}}(jQuery);
// source --> https://www.drakensberghiker.co.za/wp-content/themes/ascend/assets/js/vendor/html5shiv.min.js?ver=1.4.17 
/**
* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document);
// source --> https://www.drakensberghiker.co.za/wp-content/themes/ascend/assets/js/vendor/respond.min.js?ver=1.4.17 
/*! Respond.js v1.4.2: min/max-width media query polyfill
 * Copyright 2013 Scott Jehl
 * Licensed under MIT
 * http://j.mp/respondjs */

!function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='&shy;<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;b<t.length;b++){var c=t[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!p[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(w(c.styleSheet.rawCssText,e,f),p[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!s||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}x()};y(),c.update=y,c.getEmValue=u,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);