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C,iBACNhC,EAAKS,QACL,MAAMwB,EAAOhC,KAAKiC,aAAa,QAClB,OAATD,GAA0B,MAATA,IACnBb,OAAOe,SAASF,KAAOA,EAE3B,IAEAb,OAAOC,IAAIC,aAAaO,KAAK,gBAAiB7B,EAAKG,KACrD,CACF,CA9FAiC,QAAQC,IAAI,CACV,iEACA,uCACA,4CACA,uCACA,8CACCC,MAAK,KACNpC,EAAE,qBAAqBqC,MAAK,SAAUC,EAAG1C,GACvCI,EAAEJ,GAAI2C,KAAK,SAAU,IAAI5C,EAASC,EAAI0C,IACtCtC,EAAEwC,UAAUC,OAAM,WAChBzC,EAAEJ,GAAI2C,KAAK,UAAUtB,MACvB,GACF,GAAE,G","sources":["webpack://disp0001/./src/widgets/dhp-popup/dhp-popup.js"],"sourcesContent":["import Cookies from 'js-cookie'\r\n\r\nPromise.all([\r\n import('./dhp-popup.scss'),\r\n import('../../plugins/semantic/modal.scss'),\r\n import('../../plugins/semantic/modal'),\r\n import('../../plugins/semantic/dimmer.scss'),\r\n import('../../plugins/semantic/dimmer'),\r\n]).then(() => {\r\n $('.widget.dhp-popup').each(function (i, el) {\r\n $(el).data('widget', new DhpPopup(el, i))\r\n $(document).ready(function () {\r\n $(el).data('widget').init()\r\n })\r\n })\r\n})\r\n\r\nfunction DhpPopup(el, index) {\r\n const self = this\r\n self.el = $(el)\r\n self.uid = `DhpPopup_${index}`\r\n self.modal = self.el.find('.pop-up-modal.ui.modal-dhp')\r\n\r\n self.getAppearanceLimit = () => parseInt(self.modal.find('#dhp-popup-appearance-limit').val())\r\n\r\n self.close = function () {\r\n const hasUserOptOut = self.modal.find('#dhp-popup-opt-out').is(':checked')\r\n let appearanceCount = parseInt(Cookies.get('DhpPopUpAppearanceCount'))\r\n\r\n if (hasUserOptOut === true) {\r\n appearanceCount = self.getAppearanceLimit\r\n } else {\r\n appearanceCount > 0 ? appearanceCount++ : (appearanceCount = 1)\r\n }\r\n\r\n // Store if user has 'opt out'\r\n Cookies.set('DisableDhpPopUp', hasUserOptOut, {\r\n path: '/',\r\n })\r\n\r\n // Store the number of times this modal has appeared\r\n Cookies.set('DhpPopUpAppearanceCount', appearanceCount, {\r\n expires: 365, // in days\r\n path: '/',\r\n })\r\n\r\n self.modal.modal('hide')\r\n }\r\n\r\n self.hasReachedAppearanceLimit = function () {\r\n const appearanceCount = parseInt(Cookies.get('DhpPopUpAppearanceCount'))\r\n return appearanceCount >= self.getAppearanceLimit()\r\n }\r\n\r\n self.init = function () {\r\n if (process.env.NODE_ENV === 'development') {\r\n console.log('DhpPopup init', self)\r\n }\r\n\r\n // Check if we should show the modal on page load\r\n if (self.hasReachedAppearanceLimit() || Cookies.get('DisableDhpPopUp') === 'true') return\r\n\r\n // NOTE: The contents of the widget is moved in the DOM\r\n // outside the widget element to the bottom of the page.\r\n // As such, this just sets opacity on the widget element\r\n // which will be empty.\r\n // self.el.css('opacity', 1);\r\n\r\n window.dbs.globalEvents.subscribe('shepherdNext', function (item) {\r\n if (item !== self.uid) return\r\n console.log('[SHEPHERD][popup]', item === self.uid, item)\r\n\r\n self.modal\r\n .modal({\r\n closable: false,\r\n onHidden: () => window.dbs.globalEvents.emit('shepherdDone', self.uid),\r\n })\r\n .modal('show')\r\n })\r\n\r\n self.modal.find('.js-modal-close').click(function (event) {\r\n event.preventDefault()\r\n self.close()\r\n })\r\n\r\n self.modal.find('.js-modal-cta-link').click(function (event) {\r\n event.preventDefault()\r\n self.close()\r\n const href = this.getAttribute('href')\r\n if (href !== null && href !== '#') {\r\n window.location.href = href\r\n }\r\n })\r\n\r\n window.dbs.globalEvents.emit('shepherdQueue', self.uid)\r\n }\r\n}\r\n"],"names":["DhpPopup","el","index","self","this","$","uid","modal","find","getAppearanceLimit","parseInt","val","close","hasUserOptOut","is","appearanceCount","Cookies","get","set","path","expires","hasReachedAppearanceLimit","init","window","dbs","globalEvents","subscribe","item","console","log","closable","onHidden","emit","click","event","preventDefault","href","getAttribute","location","Promise","all","then","each","i","data","document","ready"],"sourceRoot":""}