try{
    if(!$) {
        $ = jQuery;
    }
} catch(err) {}

const toggle_kirb_loader = (flg) => {
    if(flg) {
        $(".kirb_loader").css("display", "flex");
    } else {
        $(".kirb_loader").css("display", "none");
    }
};
// changed the const function to the window.
window.kirb_load_360 = (e) => {
    let videoUrl = e.dataset.videoUrl;
    let title = e.dataset.title;
    if($(document).width() < 768) {
        let width = parseInt($("#kirb_360_frame").width());
        $("#kirb_360_frame").css("width", width);
        $("#kirb_360_frame").css("height", width);
        videoUrl = videoUrl.replace("500/500", `${width}/${width}`);
    }
    $("#kirb_360_frame").attr("src", videoUrl + "/true");
    if(title) {
        $("#kirb_360_frame_title").html(title);
    }
};

$(document).ready(function() {
    setTimeout(() => {
        $("body").append(`
            <div class="kirb_loader loading-overlay__spinner main_loader" style="display:none;">
                <div class="kirb_dots_loader">
                    <div class="loader3">
                        <span class="circle1"></span>
                        <span class="circle1"></span>
                        <span class="circle1"></span>
                    </div>
                </div>
            </div>
        `);
    },2000);

    if(KIRB_GLOBALS.byor_strip_reload == 'true') {
        // Solve cache issue for wp-rocket enabled websites
        $.ajax({
            url: KIRB_GLOBALS.ajax_url,
            type: "GET",
            data: {
                action: "kirb_fetch_latest_byor_strip",
                page_id: KIRB_GLOBALS.page_id,
                nonce: KIRB_GLOBALS.nonce,
                uid: KIRB_GLOBALS.byor_page_uid
            },
            cache: false,
            success: function(response) {
                $(".byor_strip_css_js").remove();
                $(".kirb-byor-strip-container").replaceWith(response.html);
            }
        });
    }
});