(() => {
      // fetch('https://trustmate.io/widget/api/def5bd98-7662-43cd-bee3-17ff56a59336/html?product=1566') - TODO: remove after platform multihornet fix - !!!frontend do not remove 
  
  const UI = {
    last: (where, what) => {where?.append(what)},
    first: (where, what) => {where?.insertBefore(what, where.firstChild)},
    after: (where, what) => {where?.parentNode.insertBefore(what, where.nextSibling)},
    before: (where, what) => {where?.parentNode.insertBefore(what, where)},
    replace: (where, what) => {where?.replaceWith(what)}
  };

  const RELOADS_LIMIT = 10;
  let reloadsCount = 0;

  function loadWidgetHtml() {
    const tag = document.getElementById('tm-widget-hornet');

    if (tag) {
      widgetConfig = {
        target: tag.dataset.t,
        action: tag.dataset.a,
        observe: tag.dataset.o
      };

      if (widgetConfig.target && widgetConfig.action) {
        if (!Object.hasOwn(UI, widgetConfig.action)) {
          console.error(`TrustMate: action '${widgetConfig.action}' is wrong`);
          return;
        }

        const target = document.querySelector(widgetConfig.target);

        if (!target) {
          console.error(`TrustMate: target '${widgetConfig.target}' not found`);
          return;
        }

        UI[widgetConfig.action](target, tag);
      }

      tag.innerHTML = `<link rel="stylesheet" href="https://trustmate.io/build/css/widget/hornet.320fad72.css"><style>
 .tm-hornet-container{}
</style><div
 class="tm-hornet-container"
 style="display: none;"
 data-tmdisableExtra=""
 data-tmShowWithModal="1"
 data-tmShowWithoutReviews=""
 data-tmShowZeroReviewsNumber=""
 data-tmShowOnMobile="1"
 data-tmScrollToWidget="1"
 data-url="https://trustmate.io/"
 data-rating-image="tm-new-star"
 data-reviews-slide-modal-url="https://trustmate.io/api/widget/def5bd98-7662-43cd-bee3-17ff56a59336/reviews-slide-modal?product=1566"
 data-tmRatingPrecision="1"
></div><script type="application/ld+json">{"@context":"https://schema.org/","@type":"Product","name":"Olejek eteryczny Eukaliptusowy","image":["https://zielonykredens.pl/1255-large_default/olejek-eteryczny-eukaliptusowy.jpg"],"brand":{"@type":"Brand","name":"Bamer"},"description":"Naturalny olejek eteryczny eukaliptusowy, uzyskany z liści i gałązek eukaliptusa. Posiada właściwotści przeciwzapalne, antyseptyczne, idealnie nadaje się do inhalacji","gtin13":"5906764840003","mpn":"BAMER-20","offers":{"@type":"Offer","url":"https://zielonykredens.pl/olejki-na-kleszcze/1566-olejek-eteryczny-eukaliptusowy-5906764840003.html","priceCurrency":"PLN","price":"7.99","availability":"https://schema.org/InStock"}}</script>`;

      if (widgetConfig.target && widgetConfig.action && widgetConfig.observe) {
        const observeTag = document.querySelector(widgetConfig.observe);
        if (observeTag) {
          const widgetObserver = new MutationObserver((mutations, observer) => {
            const tag = document.getElementById('tm-widget-hornet');
            if (tag) return;
            observer.disconnect();
            if (reloadsCount >= RELOADS_LIMIT) {
              console.error('TrustMate: widget tm-widget-hornet reload limit reached');
              return;
            }
            ++reloadsCount;
            const newTag = document.createElement('div');
            newTag.id = 'tm-widget-hornet';
            newTag.dataset.a = widgetConfig.action;
            newTag.dataset.t = widgetConfig.target;
            newTag.dataset.o = widgetConfig.observe;
            const target = document.querySelector(widgetConfig.target);
            if (!target) {
              console.error(`TrustMate: target '${widgetConfig.target}' not found after last html change`);
              return;
            }
            UI[widgetConfig.action](target, newTag);
            loadWidgetScript();
          });
          widgetObserver.observe(observeTag, {childList: true, subtree: true});
        }
      }
    } else {
      console.error('TrustMate: No tag for tm-widget-hornet');
    }
  }

  function waitForWindow() {
    let index = 0;
    const intervalWindowId = setInterval(function() {
      if (typeof window !== 'undefined') {
        clearInterval(intervalWindowId);
        loadWidgetScript();
      }
      index += 1;
      if (index > 50) {
        clearInterval(intervalWindowId);
      }
    }, 50);
  }

  function loadWidgetScript() {
    if (1297 < 10) return;

    function scriptExists(url) {
      return document.querySelectorAll(`script[src="${url}"]`).length > 0;
    }

    if(scriptExists('https\u003A\/\/trustmate.io\/build\/js\/widget\/hornet.489302a7.js')) {
      function removeJs(src) {
        document.querySelector(`script[src="${src}"]`).remove();
      }

      removeJs('https\u003A\/\/trustmate.io\/build\/js\/widget\/hornet.489302a7.js');
    }

    const widgetScript = document.createElement('script');
    widgetScript.src = 'https\u003A\/\/trustmate.io\/build\/js\/widget\/hornet.489302a7.js';
    widgetScript.defer = true;
    widgetScript.onload = () => {
      loadWidgetHtml();
    };
    document.body.appendChild(widgetScript);
  }

  if (typeof window === 'undefined') {
    waitForWindow();
  } else {
    loadWidgetScript();
  }
})();
