// source --> https://forexinstitute.pl/wp-content/plugins/gp-notification-bar/public/js/front.js?ver=1.1 
/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!**********************!*\
  !*** ./src/front.js ***!
  \**********************/
(function ($) {
  'use strict';

  $(document).ready(function () {
    if (gnb_settings) {
      $(gnb_settings.settings).each(function (key, widget) {
        console.log(key);
        var widget_text = widget.widget_setting.widget_text;
        var btn_on_desktop = widget.button_setting.in_desktop;
        var btn_on_mobile = widget.button_setting.in_mobile;
        var btn_text = widget.button_setting.widget_text;
        var close_on_desktop = widget.close_btn_setting.in_desktop;
        var close_on_mobile = widget.close_btn_setting.in_mobile;
        var current_device = gnb_settings.current_device;
        var position = widget.widget_setting.position;
        var widget_html = "";
        widget_html += "<div class='ginger-bar-message ginger-bar-message-" + widget.id + " " + position + "-position'>";
        widget_html += "<div class='ginger-bar-inner-box'>";
        widget_html += "<div class='ginger-bar-message-text'>";
        widget_html += widget_text;
        widget_html += "</div>";
        if ((btn_on_desktop == "yes" && current_device == "desktop" || btn_on_mobile == "yes" && current_device == "mobile") && btn_text != "") {
          widget_html += "<div class='ginger-bar-button-container'>";
          widget_html += '<button type="button" class="ginger-bar-message-button">';
          widget_html += btn_text;
          widget_html += '</button>';
          widget_html += '</div>';
        }
        if (close_on_desktop == "yes" && current_device == "desktop" || close_on_mobile == "yes" && current_device == "mobile") {
          widget_html += "<div class='ginger-bar-close-button'>";
          widget_html += '<a role="button" href="javascript:;"><svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="348.333px" height="348.334px" viewBox="0 0 348.333 348.334" xml:space="preserve"><g><path d="M336.559,68.611L231.016,174.165l105.543,105.549c15.699,15.705,15.699,41.145,0,56.85c-7.844,7.844-18.128,11.769-28.407,11.769c-10.296,0-20.581-3.919-28.419-11.769L174.167,231.003L68.609,336.563c-7.843,7.844-18.128,11.769-28.416,11.769c-10.285,0-20.563-3.919-28.413-11.769c-15.699-15.698-15.699-41.139,0-56.85l105.54-105.549L11.774,68.611c-15.699-15.699-15.699-41.145,0-56.844c15.696-15.687,41.127-15.687,56.829,0l105.563,105.554L279.721,11.767c15.705-15.687,41.139-15.687,56.832,0C352.258,27.466,352.258,52.912,336.559,68.611z"></path></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g></svg></a>';
          widget_html += "</div>";
        }
        widget_html += "</div>";
        widget_html += "</div>";
        if ($("#wpadminbar").length) {
          $("#wpadminbar").before(widget_html);
        } else {
          $("body").append(widget_html);
        }
        var back_color = widget.widget_setting.bg_color;
        var font_color = widget.widget_setting.text_color;
        var font_family = widget.widget_setting.font_family;
        var font_size = widget.widget_setting.font_size;
        var text_align = widget.widget_setting.text_align;
        var box_shadow = widget.widget_setting.box_shadow;
        var padding_left = widget.widget_setting.padding.left;
        var padding_right = widget.widget_setting.padding.right;
        var padding_top = widget.widget_setting.padding.top;
        var padding_bottom = widget.widget_setting.padding.bottom;
        var btn_animation = widget.button_setting.animation;
        var btn_back_color = widget.button_setting.bg_color;
        var btn_font_color = widget.button_setting.text_color;
        var close_color = widget.close_btn_setting.text_color;
        if (position == "top") {
          if ($("#wpadminbar").length) {
            var adminbarHeight = $("#wpadminbar").outerHeight(true);
            $(".ginger-bar-message-" + widget.id).css({
              "top": adminbarHeight,
              "bottom": "auto"
            });
          } else {
            $(".ginger-bar-message-" + widget.id).css({
              "top": "0",
              "bottom": "auto"
            });
          }
        } else {
          $(".ginger-bar-message-" + widget.id).css({
            "top": "auto",
            "bottom": "0"
          });
        }
        $("#gnb-google-font").remove();
        if (font_family != "" && font_family != "Arial" && font_family != "Tahoma" && font_family != "Verdana" && font_family != "Helvetica" && font_family != "Times New Roman" && font_family != "Trebuchet MS" && font_family != "Georgia" && font_family != 'Geneva' && font_family != 'Trebuchet') {
          $("head").append("<link id='gnb-google-font' href='https://fonts.googleapis.com/css?family=" + font_family + "' rel='stylesheet' type='text/css' >");
        }
        $(".ginger-bar-message-" + widget.id).css({
          "background-color": back_color,
          "color": font_color,
          "font-family": font_family,
          "font-size": font_size + "px"
        });
        if (box_shadow == "yes") {
          $(".ginger-bar-message-" + widget.id).addClass("ginger-bar-shadow");
        } else {
          $(".ginger-bar-message-" + widget.id).removeClass("ginger-bar-shadow");
        }
        $(".ginger-bar-message-" + widget.id + " .ginger-bar-inner-box").css({
          "padding-top": padding_top + "px",
          "padding-bottom": padding_bottom + "px",
          "padding-left": padding_left + "px",
          "padding-right": padding_right + "px"
        });
        $(".ginger-bar-message-" + widget.id + " .ginger-bar-inner-box").css("justify-content", text_align);
        $(".ginger-bar-message-" + widget.id + " .ginger-bar-message-button").css({
          "background-color": btn_back_color,
          "color": btn_font_color
        });
        $(".ginger-bar-message-" + widget.id + " .ginger-bar-message-button").addClass(btn_animation + "-animation");
        $(".ginger-bar-message-" + widget.id + " .ginger-bar-close-button svg").css("fill", close_color);
        var isHidden = getCookie("ginger-notification-bar-" + widget.id);
        if (isHidden == "close") {
          $(".ginger-bar-message-" + widget.id).remove();
        }
        $(".ginger-bar-message-" + widget.id).addClass("active");
        auto_hide_notification_bar(widget);
        $(document).on("click", ".ginger-bar-message-" + widget.id + " .ginger-bar-message-button", function (e) {
          e.preventDefault();
          if (widget.button_setting.action == "nothing") {} else if (widget.button_setting.action == "open_url") {
            window.location = widget.button_setting.action_url;
          } else if (widget.button_setting.action == "open_url_in_new_tab") {
            window.open(widget.button_setting.action_url, '_blank');
          }
          if (widget.button_setting.close_button == "yes") {
            hide_notification_bar(widget);
          }
        });
        $(document).on("click", ".ginger-bar-message-" + widget.id + " .ginger-bar-close-button", function (e) {
          e.preventDefault();
          hide_notification_bar(widget);
        });
      });
    }
  });
  function auto_hide_notification_bar(widget) {
    var secondsToHide = parseInt(widget.widget_setting.auto_close_after);
    if (secondsToHide != "" && secondsToHide != 0) {
      setTimeout(function () {
        hide_notification_bar(widget);
      }, secondsToHide * 1000);
    }
  }
  function hide_notification_bar(widget) {
    var noOfDays = parseInt(widget.widget_setting.keep_closed_for);
    setCookie("ginger-notification-bar-" + widget.id, "close", noOfDays);
    $(".ginger-bar-message-" + widget.id).remove();
  }
  function getCookie(name) {
    var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
    return v ? v[2] : null;
  }
  function setCookie(name, value, days) {
    var d = new Date();
    d.setTime(d.getTime() + 24 * 60 * 60 * 1000 * days);
    document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString();
  }
  function deleteCookie(name) {
    setCookie(name, '', -1);
  }
})(jQuery);
/******/ })()
;