/* Minification failed. Returning unminified contents.
(28,86-87): run-time warning JS1014: Invalid character: `
 */
$(document).ready(function () {

    const MOBILE_MAX_WIDTH = 767;

    var $stickyPanel = $(".sticky-panel");

    var liveChatOffsetStyle = null;
    var liveChatScrollBottom = '92px';
    var liveChatScrollRight = '12px';
    var liveChatButtonSelectors = '#fc_frame';

    function setPositionsAndVisibility() {
        var scrollTop = $(window).scrollTop();
        var targetOffsetTop = $(".sticky-panel-target").offset().top;
        var windowWidth = $(window).width();
        var mobileView = windowWidth <= MOBILE_MAX_WIDTH;
        var isScrolled = scrollTop >= targetOffsetTop;

        updateStyles(mobileView, isScrolled);
        setStickyPanelVisibility(mobileView, isScrolled);
    }

    function updateStyles(mobileView, isScrolled) {

        if (mobileView) {
            if (isScrolled) {
                if (!liveChatOffsetStyle) {
                    liveChatOffsetStyle = $('<style>').prop('type', 'text/css').html(`
                        ${liveChatButtonSelectors} { 
                            bottom: ${liveChatScrollBottom} !important; 
                            right: ${liveChatScrollRight} !important; 
                        }`).appendTo('head');
                }
            }
            else if (liveChatOffsetStyle) {
                liveChatOffsetStyle.remove();
                liveChatOffsetStyle = null;
            }
        }
        else if (liveChatOffsetStyle) {
            liveChatOffsetStyle.remove();
            liveChatOffsetStyle = null;
        }
    }

    function setStickyPanelVisibility(mobileView, isScrolled) {
        if (mobileView && isScrolled) {
            $stickyPanel.show();
        } else {
            $stickyPanel.hide();
        }
    }

    $(window).on('scroll resize', function () {
        setPositionsAndVisibility();
    });

    setPositionsAndVisibility();
});
;