var Wick = Wick || {};

Wick.KlarnaModalScrollDisable = (function () {
    const $body = $('body'),
      klarnaPopUp = 'klarna-osm-interstitial',
      scrollDisableClass = 'overflow-hidden';

    window.addEventListener(klarnaPopUp, (e) => {
        let isKlarnaPopUpActive = e.detail.action === 'show';

        if (isKlarnaPopUpActive) {
            $body.addClass(scrollDisableClass);
            $body.trigger('tagKlarnaModalAdded')
        } else {
            $body.removeClass(scrollDisableClass);
            $body.trigger('tagKlarnaModalRemoved');
        };
    });
})();
