UNPKG

@plasma-platform/promotions

Version:
1,655 lines (1,500 loc) 115 kB
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var dayjs=require('dayjs');function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPrimitive$1(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _toPropertyKey$1(arg) { var key = _toPrimitive$1(arg, "string"); return typeof key === "symbol" ? key : String(key); }var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; }var isomorphicCookie = {};var _rollupPluginBabelHelpers581c8744$1 = {};function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; } function _toConsumableArray$1(arr) { return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _nonIterableSpread$1(); } function _arrayWithoutHoles$1(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } } function _iterableToArray$1(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } function _nonIterableSpread$1() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }_rollupPluginBabelHelpers581c8744$1._=_createClass$1;_rollupPluginBabelHelpers581c8744$1.a=_classCallCheck$1;_rollupPluginBabelHelpers581c8744$1.b=_toConsumableArray$1;var js_cookie = {exports: {}};/*! * JavaScript Cookie v2.2.1 * https://github.com/js-cookie/js-cookie * * Copyright 2006, 2015 Klaus Hartl & Fagner Brack * Released under the MIT license */ (function (module, exports) { (function (factory) { var registeredInModuleLoader; { module.exports = factory(); registeredInModuleLoader = true; } if (!registeredInModuleLoader) { var OldCookies = window.Cookies; var api = window.Cookies = factory(); api.noConflict = function () { window.Cookies = OldCookies; return api; }; } }(function () { function extend () { var i = 0; var result = {}; for (; i < arguments.length; i++) { var attributes = arguments[ i ]; for (var key in attributes) { result[key] = attributes[key]; } } return result; } function decode (s) { return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent); } function init (converter) { function api() {} function set (key, value, attributes) { if (typeof document === 'undefined') { return; } attributes = extend({ path: '/' }, api.defaults, attributes); if (typeof attributes.expires === 'number') { attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5); } // We're using "expires" because "max-age" is not supported by IE attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; try { var result = JSON.stringify(value); if (/^[\{\[]/.test(result)) { value = result; } } catch (e) {} value = converter.write ? converter.write(value, key) : encodeURIComponent(String(value)) .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); key = encodeURIComponent(String(key)) .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent) .replace(/[\(\)]/g, escape); var stringifiedAttributes = ''; for (var attributeName in attributes) { if (!attributes[attributeName]) { continue; } stringifiedAttributes += '; ' + attributeName; if (attributes[attributeName] === true) { continue; } // Considers RFC 6265 section 5.2: // ... // 3. If the remaining unparsed-attributes contains a %x3B (";") // character: // Consume the characters of the unparsed-attributes up to, // not including, the first %x3B (";") character. // ... stringifiedAttributes += '=' + attributes[attributeName].split(';')[0]; } return (document.cookie = key + '=' + value + stringifiedAttributes); } function get (key, json) { if (typeof document === 'undefined') { return; } var jar = {}; // To prevent the for loop in the first place assign an empty array // in case there are no cookies at all. var cookies = document.cookie ? document.cookie.split('; ') : []; var i = 0; for (; i < cookies.length; i++) { var parts = cookies[i].split('='); var cookie = parts.slice(1).join('='); if (!json && cookie.charAt(0) === '"') { cookie = cookie.slice(1, -1); } try { var name = decode(parts[0]); cookie = (converter.read || converter)(cookie, name) || decode(cookie); if (json) { try { cookie = JSON.parse(cookie); } catch (e) {} } jar[name] = cookie; if (key === name) { break; } } catch (e) {} } return key ? jar[key] : jar; } api.set = set; api.get = function (key) { return get(key, false /* read as raw */); }; api.getJSON = function (key) { return get(key, true /* read as json */); }; api.remove = function (key, attributes) { set(key, '', extend(attributes, { expires: -1 })); }; api.defaults = {}; api.withConverter = init; return api; } return init(function () {}); })); } (js_cookie)); var js_cookieExports = js_cookie.exports;Object.defineProperty(isomorphicCookie,'__esModule',{value:true});function _interopDefault$1(e){return (e&&(typeof e==='object')&&'default'in e)?e['default']:e}var _rollupPluginBabelHelpers$2=_rollupPluginBabelHelpers581c8744$1,JSCookie=_interopDefault$1(js_cookieExports);/** * @class * @exports * @description Client-side utility for cookies */ var ClientCookie = /*#__PURE__*/ function () { function ClientCookie() { _rollupPluginBabelHelpers$2.a(this, ClientCookie); } _rollupPluginBabelHelpers$2._(ClientCookie, null, [{ key: "getItem", /** * getItem * * @method getItem * @name getItem * @static * @memberof ClientCookie * * @param {string} sKey - (required) key to get cookie * * @return {string} - cookie value * * @example * const locale = ClientCookie.getItem('country_code'); */ value: function getItem(sKey) { return JSCookie.get(sKey); } /** * setItem * * @method setItem * @name setItem * @static * @memberof ClientCookie * * @param {string} sKey - (required) for set cookie * @param {string} sValue - (required) value for set cookie * @param {string} vEnd - date to end * @param {string} sPath - cookie path * @param {string} sDomain - cookie domain * @param {boolean} bSecure - is secure ** * @example * ClientCookie.setItem('country_code', 'ua', 36000000, '/', '.templatemonster.me', false); */ }, { key: "setItem", value: function setItem(sKey, sValue, vEnd, sPath, sDomain, bSecure) { JSCookie.set(sKey, sValue, { path: sPath, domain: sDomain, secure: bSecure, expires: vEnd }); } /** * removeItem * * @method removeItem * @name removeItem * @static * @memberof ClientCookie * * @param {string} sKey - (required) key remove cookie * @param {string} sPath - (required) cookie path * @param {string} sDomain - (required) cookie domain * * @example * ClientCookie.removeItem('country_code', '/', '.templatemonster.com); */ }, { key: "removeItem", value: function removeItem(sKey, sPath, sDomain) { JSCookie.remove(sKey, { path: sPath, domain: sDomain }); } }]); return ClientCookie; }();/** * * @class * @exports * @description Creates server-side utility for cookies * * @param {object} oReq - (required) request object from Express * @param {object} oRes - (required) response object from Express */ var ServerCookie = /*#__PURE__*/ function () { function ServerCookie(oReq, oRes) { _rollupPluginBabelHelpers$2.a(this, ServerCookie); this.req = oReq; this.res = oRes; } /** * getItem * * @method getItem * @name getItem * @memberof ServerCookie * * @param {string} sKey - (required) key to get cookie * * @return {string} - cookie value * * @example * const locale = IsomorphicCookie.getItem('country_code'); */ _rollupPluginBabelHelpers$2._(ServerCookie, [{ key: "getItem", value: function getItem(sKey) { return this.req.cookies[sKey]; } /** * setItem * * @method setItem * @name setItem * @memberof ServerCookie * * @param {string} sKey - (required) for set cookie * @param {string} sValue - (required) value for set cookie * @param {string} vEnd - date to end * @param {string} sPath - cookie path * @param {string} sDomain - cookie domain * @param {boolean} bSecure - is secure * * @example * ServerCookie.setItem('country_code', 'ua', 36000000, '/', '.templatemonster.me', false); */ }, { key: "setItem", value: function setItem(sKey, sValue, vEnd, sPath, sDomain, bSecure) { this.res.cookie(sKey, sValue, { path: sPath, domain: sDomain, secure: bSecure, expires: vEnd }); } /** * removeItem * * @method removeItem * @name removeItem * @memberof ServerCookie * * @param {string} sKey - (required) key remove cookie * @param {string} sPath - (required) cookie path * @param {string} sDomain - (required) cookie domain * * @example * ServerCookie.removeItem('country_code', '/', '.templatemonster.com); */ }, { key: "removeItem", value: function removeItem(sKey, sPath, sDomain) { this.res.clearCookie(sKey, { path: sPath, domain: sDomain }); } }]); return ServerCookie; }();/** * * @class * @exports * @description Utility for interacting with cookies in isomorphic way */ var IsomorphicCookie = /*#__PURE__*/ function () { function IsomorphicCookie() { _rollupPluginBabelHelpers$2.a(this, IsomorphicCookie); this.util = ClientCookie; } /** * switchToServerMode * * @method switchToServerMode * @name switchToServerMode * @memberof IsomorphicCookie * * @param {object} oReq - (required) Express request object * @param {object} oRes - (required) Express response object * * @example * IsomorphicCookie.switchToServerMode(req, res); */ _rollupPluginBabelHelpers$2._(IsomorphicCookie, [{ key: "switchToServerMode", value: function switchToServerMode(oReq, oRes) { if (!oReq || !oRes) { throw new Error('Express request and response objects should be provided'); } this.util = new ServerCookie(oReq, oRes); } /** * getItem * * @method getItem * @name getItem * @memberof IsomorphicCookie * * @param {string} sKey - (required) key to get cookie * * @return {string} - cookie value * * @example * const locale = IsomorphicCookie.getItem('country_code'); */ }, { key: "getItem", value: function getItem(sKey) { if (!sKey) { throw new Error('Cookie key should be provided'); } return this.util.getItem(sKey); } /** * setItem * * @method setItem * @name setItem * @memberof IsomorphicCookie * * @param {string} sKey - (required) for set cookie * @param {(string|object)} cookieValue - (required) value for set cookie * @param {string} vEnd - date to end * @param {string} sPath - cookie path * @param {string} sDomain - cookie domain * @param {boolean} bSecure - is secure * * @example * IsomorphicCookie.setItem('country_code', 'ua', 36000000, '/', '.templatemonster.me', false); */ }, { key: "setItem", value: function setItem(sKey, cookieValue, vEnd, sPath, sDomain, bSecure) { if (!sKey) { throw new Error('Cookie key should be provided'); } if (typeof cookieValue === 'undefined') { throw new Error('Cookie value should be provided'); } var value = typeof cookieValue === 'object' ? JSON.stringify(cookieValue) : String(cookieValue); return this.util.setItem(sKey, value, vEnd, sPath, sDomain, bSecure); } /** * removeItem * * @method removeItem * @name removeItem * @memberof IsomorphicCookie * * @param {string} sKey - (required) key remove cookie * @param {string} sPath - (required) cookie path * @param {string} sDomain - (required) cookie domain * * @example * IsomorphicCookie.removeItem('country_code', '/', '.templatemonster.com); */ }, { key: "removeItem", value: function removeItem(sKey, sPath, sDomain) { if (!sKey || !sPath || !sDomain) { throw new Error('Cookie key, path and domain should be provided'); } return this.util.removeItem(sKey, sPath, sDomain); } }]); return IsomorphicCookie; }();var Cookies = new IsomorphicCookie();var _default$6 = isomorphicCookie.default=Cookies;var dispatchCustomEvent$1 = {};Object.defineProperty(dispatchCustomEvent$1,'__esModule',{value:true});/** * @method dispatchCustomEvent * @description Create and dispatch custom event with optional 'detail' parameter * @param {string} name - Event name * @param {any} [detail] - Additional data (read only) * @returns {boolean} * @example * dispatchCustomEvent('eventName', { data: 'myData' }) */ function dispatchCustomEvent(name, detail) { try { var customEvent = new CustomEvent(name, { detail: detail }); return document.dispatchEvent(customEvent); } catch (e) { return false; } }var _default$5 = dispatchCustomEvent$1.default=dispatchCustomEvent;var domHelper$1 = {};Object.defineProperty(domHelper$1,'__esModule',{value:true});var _rollupPluginBabelHelpers$1=_rollupPluginBabelHelpers581c8744$1;/* eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["wrapper"] }] */ var DomHelper$1 = /*#__PURE__*/ function () { function DomHelper() { _rollupPluginBabelHelpers$1.a(this, DomHelper); } _rollupPluginBabelHelpers$1._(DomHelper, null, [{ key: "getElement", /** * Get element by selector * @memberof ClockTimer * @param {string} selector * @returns {*} */ value: function getElement(selector) { try { var element = document.querySelector(selector); if (element === null) { return null; } return element; } catch (e) { return null; } } }, { key: "getAll", /** * Get all elements by selector * @memberof Initiators * @param {string} selector * @returns {*} */ value: function getAll(selector) { try { var elements = document.querySelectorAll(selector); if (elements.length < 1) { return null; } return elements; } catch (e) { return null; } } }, { key: "data", /** * Get data attributes * @memberof Initiators/DomService * @param element * @returns {{}} */ value: function data(element) { if (typeof element === 'undefined' || element === null) { return {}; } var dataAttr = element.dataset; var keys = Object.keys(dataAttr); var dataSet = {}; var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/; keys.forEach(function (key) { if (typeof dataAttr[key] !== 'undefined') { var value = dataAttr[key]; if (typeof value === 'string') { if (value === 'true') { value = true; } if (value === 'false') { value = false; } if (value === 'null') { value = null; } // Only convert to a number if it doesn't change the string if (value === `${+value}`) { value = +value; } if (rbrace.test(value)) { value = JSON.parse(value); } } dataSet[key] = value; } }); return dataSet; } /** * Add class * @memberof Initiators/DomService * @param element * @param classList * @returns {*} */ }, { key: "addClass", value: function addClass(element) { var classList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var el = element; if (typeof element === 'undefined' || element === null || typeof classList === 'undefined' || classList == null || classList.length < 1) { return null; } classList.forEach(function (className) { if (element.classList) { el.classList.add(className); } else { el.className += ` ${className}`; } }); return el; } /** * Attributes * @memberof Initiators/DomService * @param element * @param key * @param value * @returns {*} */ }, { key: "attr", value: function attr(element, key, value) { if (typeof element === 'undefined' || element === null) { return null; } if (typeof value === 'undefined') { return element.getAttribute(key); } element.setAttribute(key, value); return element; } /** * ParseHtmlString * @description parses html string to child node * @param {string} htmlString * @returns {ChildNode} */ }, { key: "parseHtmlString", value: function parseHtmlString(htmlString) { var parser = new DOMParser(); var domNode = parser.parseFromString(htmlString, "text/html"); return domNode.body.firstChild; } /** * Prepend * @description inserts element as first child of its parent * @param parent * @param element * @returns {null|any} */ }, { key: "prepend", value: function prepend(parent, element) { if (typeof element === 'undefined' || element === null || typeof parent === 'undefined' || parent === null) { return null; } return parent.insertBefore(element, parent.firstChild); } /** * Append * @description inserts element as last child of its parent * @param parent * @param element * @returns {null|any} */ }, { key: "append", value: function append(parent, element) { if (typeof element === 'undefined' || element === null || typeof parent === 'undefined' || parent === null) { return null; } return parent.insertBefore(element, parent.nextSibling); } /** * Remove class * @memberof Initiators/DomService * @param element * @param classList * @returns {*} */ }, { key: "removeClass", value: function removeClass(element, classList) { if (typeof element === 'undefined' || element === null || typeof classList === 'undefined' || classList === null) { return null; } var el = element; classList.forEach(function (className) { if (element.classList) { el.classList.remove(className); } else { el.className = element.className.replace(new RegExp(`(^|\\b)${className.split(' ').join('|')}(\\b|$)`, 'gi'), ' '); } }); return el; } /** * Has class * @memberof Initiators/DomService * @param element * @param className * @returns {boolean} */ }, { key: "hasClass", value: function hasClass(element, className) { if (typeof element === 'undefined' || element === null || typeof className === 'undefined' || className === null) { return null; } if (element.classList) { return element.classList.contains(className); } return new RegExp(`(^| )${className}( |$)`, 'gi').test(element.className); } /** * Remove Attribute * @memberof Initiators/DomService * @param element * @param name * @returns {*} */ }, { key: "removeAttribute", value: function removeAttribute(element, name) { if (typeof element === 'undefined' || element === null || typeof name === 'undefined' || name === null) { return null; } element.removeAttribute(name); return element; } /** * @method renderHtml * @description Appends timer to html page */ }, { key: "renderHtml", value: function renderHtml(wrapper, htmlString) { if (wrapper && wrapper instanceof HTMLElement) { wrapper.innerHTML = htmlString; } } }]); return DomHelper; }();var _default$4 = domHelper$1.default=DomHelper$1;var CNT1B$1 = {};var runtime_es3e5eb61d = {};function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }/** * @namespace ClockTimer * @description clock-timer model * @class * @exports */ class Timer { /** * @method constructor * @memberOf ClockTimer * @description Timer constructor * @param {Object} props * @param {string} [props.timerFace] - Timer type (daily | hourly | counter). 'daily' by default * @param {number} [props.count] - Quantity of ticks for 'counter' timerFace type. * @param {string} [props.direction] - Timer direction (decrement | increment). 'decrement' by default * @param {number} [props.startTimeStamp] - Timer start date * @param {number} props.endTimeStamp - Timer end date * @param {number} props.currentDateServerTimeStamp - Timer current date from server * @param {Object<function>} props.callbacks - Callbacks collection (beforeStart, afterStart, beforeTick, afterTick, beforeStop, afterStop) */ constructor(props) { var _this = this; _defineProperty(this, "props", { timerName: null, // uniq timerFace: 'daily', locale: 'en', count: null, // number direction: 'decrement', // decrement || increment startTimeStamp: null, endTimeStamp: null, currentDateTimeStamp: Date.now(), currentDateServerTimeStamp: null, invalid: false, callbacks: { beforeStart: () => {}, afterStart: () => {}, beforeTick: () => {}, afterTick: () => {}, beforeStop: () => {}, afterStop: () => {} } }); _defineProperty(this, "mainInterval", null); _defineProperty(this, "time", { days: '00', hours: '00', minutes: '00', seconds: '00', count: '0' }); /** * @method start * @description Start clock-timer */ _defineProperty(this, "start", () => { const { count, endTimeStamp, startTimeStamp, timerFace, callbacks: { beforeStart, afterStart, beforeTick, afterTick } } = this.props; if (!beforeStart || !afterStart || !beforeTick || !afterTick) { this.stop(); return false; } const intervalTime = count && timerFace === 'counter' ? Math.ceil((endTimeStamp - startTimeStamp) / count) : 1000; // init timer this.time = this.calculateTime(intervalTime); beforeStart(this.time); this.mainInterval = setInterval(() => { beforeTick(this.time); this.tick(intervalTime); afterTick(this.time); }, intervalTime || 1000); afterStart(); return true; }); /** * @method stop * @description Stops clock-timer */ _defineProperty(this, "stop", () => { return clearInterval(this.mainInterval); }); /** * @method calculateTime * @description Calculates initial time * @param {number} intervalTime - Interval time (for setInterval function) * @returns {Object | number} - 'time' object or 'count' (depends on 'timerFace' property) */ _defineProperty(this, "calculateTime", intervalTime => { const { endTimeStamp, timerFace } = this.props; const currentDateTimeStamp = this.props.currentDateServerTimeStamp ? this.props.currentDateServerTimeStamp += intervalTime : Date.now(); const timeDiff = endTimeStamp - currentDateTimeStamp; if (timeDiff < intervalTime) { this.stop(); return this.time; } if (timerFace === 'daily') { return { days: "0".concat(Math.floor(timeDiff / (1000 * 60 * 60 * 24))).slice(-2), hours: "0".concat(Math.floor(timeDiff % (1000 * 60 * 60 * 24) / (1000 * 60 * 60))).slice(-2), minutes: "0".concat(Math.floor(timeDiff % (1000 * 60 * 60) / (1000 * 60))).slice(-2), seconds: "0".concat(Math.floor(timeDiff % (1000 * 60) / 1000)).slice(-2) }; } if (timerFace === 'hourly') { let hours = Math.floor(timeDiff / (1000 * 60 * 60)); hours = String(hours).length < 2 ? "0".concat(hours) : hours; return { hours, minutes: "0".concat(Math.floor(timeDiff % (1000 * 60 * 60) / (1000 * 60))).slice(-2), seconds: "0".concat(Math.floor(timeDiff % (1000 * 60) / 1000)).slice(-2) }; } if (timerFace === 'counter') { const initialCount = String(this.props.count); const newCount = Math.ceil((endTimeStamp - currentDateTimeStamp) / intervalTime) - 1; if (!Number.isNaN(newCount) && newCount >= 0) { const newCountDigits = String(newCount).split(''); if (initialCount.length > newCountDigits.length) { for (let i = newCountDigits.length; i < initialCount.length; i += 1) { newCountDigits.unshift('0'); } } return { count: newCountDigits }; } } this.stop(); return false; }); /** * @method tick * @param {number} intervalTime - clock-timer interval in milliseconds * @description Function to be executed every timer tick. Calculates new time or count * @returns {boolean} */ _defineProperty(this, "tick", function () { let intervalTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000; try { _this.time = _this.calculateTime(intervalTime); } catch (e) { _this.stop(); } return false; }); /** * @method mergeDeep * @description Merges objects * @param {Array<object>} objects - one or more objects to be merged * @returns {object} */ _defineProperty(this, "mergeDeep", function () { const isObject = obj => obj && typeof obj === 'object'; for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) { objects[_key] = arguments[_key]; } return objects.reduce((acc, obj) => { Object.keys(obj).forEach(key => { const accValue = acc[key]; const objValue = obj[key]; if (isObject(accValue) && isObject(objValue)) { acc[key] = _this.mergeDeep(accValue, objValue); } else { acc[key] = objValue; } }); return acc; }, {}); }); this.props = this.mergeDeep(this.props, props); } }var domHelper = {};var _rollupPluginBabelHelpers581c8744 = {};function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } } function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }_rollupPluginBabelHelpers581c8744._=_createClass;_rollupPluginBabelHelpers581c8744.a=_classCallCheck;_rollupPluginBabelHelpers581c8744.b=_toConsumableArray;Object.defineProperty(domHelper,'__esModule',{value:true});var _rollupPluginBabelHelpers=_rollupPluginBabelHelpers581c8744;/* eslint no-param-reassign: ["error", { "props": true, "ignorePropertyModificationsFor": ["wrapper"] }] */ var DomHelper = /*#__PURE__*/ function () { function DomHelper() { _rollupPluginBabelHelpers.a(this, DomHelper); } _rollupPluginBabelHelpers._(DomHelper, null, [{ key: "getElement", /** * Get element by selector * @memberof ClockTimer * @param {string} selector * @returns {*} */ value: function getElement(selector) { try { var element = document.querySelector(selector); if (element === null) { return null; } return element; } catch (e) { return null; } } }, { key: "getAll", /** * Get all elements by selector * @memberof Initiators * @param {string} selector * @returns {*} */ value: function getAll(selector) { try { var elements = document.querySelectorAll(selector); if (elements.length < 1) { return null; } return elements; } catch (e) { return null; } } }, { key: "data", /** * Get data attributes * @memberof Initiators/DomService * @param element * @returns {{}} */ value: function data(element) { if (typeof element === 'undefined' || element === null) { return {}; } var dataAttr = element.dataset; var keys = Object.keys(dataAttr); var dataSet = {}; var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/; keys.forEach(function (key) { if (typeof dataAttr[key] !== 'undefined') { var value = dataAttr[key]; if (typeof value === 'string') { if (value === 'true') { value = true; } if (value === 'false') { value = false; } if (value === 'null') { value = null; } // Only convert to a number if it doesn't change the string if (value === `${+value}`) { value = +value; } if (rbrace.test(value)) { value = JSON.parse(value); } } dataSet[key] = value; } }); return dataSet; } /** * Add class * @memberof Initiators/DomService * @param element * @param classList * @returns {*} */ }, { key: "addClass", value: function addClass(element) { var classList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var el = element; if (typeof element === 'undefined' || element === null || typeof classList === 'undefined' || classList == null || classList.length < 1) { return null; } classList.forEach(function (className) { if (element.classList) { el.classList.add(className); } else { el.className += ` ${className}`; } }); return el; } /** * Attributes * @memberof Initiators/DomService * @param element * @param key * @param value * @returns {*} */ }, { key: "attr", value: function attr(element, key, value) { if (typeof element === 'undefined' || element === null) { return null; } if (typeof value === 'undefined') { return element.getAttribute(key); } element.setAttribute(key, value); return element; } /** * ParseHtmlString * @description parses html string to child node * @param {string} htmlString * @returns {ChildNode} */ }, { key: "parseHtmlString", value: function parseHtmlString(htmlString) { var parser = new DOMParser(); var domNode = parser.parseFromString(htmlString, "text/html"); return domNode.body.firstChild; } /** * Prepend * @description inserts element as first child of its parent * @param parent * @param element * @returns {null|any} */ }, { key: "prepend", value: function prepend(parent, element) { if (typeof element === 'undefined' || element === null || typeof parent === 'undefined' || parent === null) { return null; } return parent.insertBefore(element, parent.firstChild); } /** * Append * @description inserts element as last child of its parent * @param parent * @param element * @returns {null|any} */ }, { key: "append", value: function append(parent, element) { if (typeof element === 'undefined' || element === null || typeof parent === 'undefined' || parent === null) { return null; } return parent.insertBefore(element, parent.nextSibling); } /** * Remove class * @memberof Initiators/DomService * @param element * @param classList * @returns {*} */ }, { key: "removeClass", value: function removeClass(element, classList) { if (typeof element === 'undefined' || element === null || typeof classList === 'undefined' || classList === null) { return null; } var el = element; classList.forEach(function (className) { if (element.classList) { el.classList.remove(className); } else { el.className = element.className.replace(new RegExp(`(^|\\b)${className.split(' ').join('|')}(\\b|$)`, 'gi'), ' '); } }); return el; } /** * Has class * @memberof Initiators/DomService * @param element * @param className * @returns {boolean} */ }, { key: "hasClass", value: function hasClass(element, className) { if (typeof element === 'undefined' || element === null || typeof className === 'undefined' || className === null) { return null; } if (element.classList) { return element.classList.contains(className); } return new RegExp(`(^| )${className}( |$)`, 'gi').test(element.className); } /** * Remove Attribute * @memberof Initiators/DomService * @param element * @param name * @returns {*} */ }, { key: "removeAttribute", value: function removeAttribute(element, name) { if (typeof element === 'undefined' || element === null || typeof name === 'undefined' || name === null) { return null; } element.removeAttribute(name); return element; } /** * @method renderHtml * @description Appends timer to html page */ }, { key: "renderHtml", value: function renderHtml(wrapper, htmlString) { if (wrapper && wrapper instanceof HTMLElement) { wrapper.innerHTML = htmlString; } } }]); return DomHelper; }();var _default$3 = domHelper.default=DomHelper;var pug = (function (exports) { var pug_has_own_property = Object.prototype.hasOwnProperty; /** * Merge two attribute objects giving precedence * to values in object `b`. Classes are special-cased * allowing for arrays and merging/joining appropriately * resulting in a string. * * @param {Object} a * @param {Object} b * @return {Object} a * @api private */ exports.merge = pug_merge; function pug_merge(a, b) { if (arguments.length === 1) { var attrs = a[0]; for (var i = 1; i < a.length; i++) { attrs = pug_merge(attrs, a[i]); } return attrs; } for (var key in b) { if (key === 'class') { var valA = a[key] || []; a[key] = (Array.isArray(valA) ? valA : [valA]).concat(b[key] || []); } else if (key === 'style') { var valA = pug_style(a[key]); valA = valA && valA[valA.length - 1] !== ';' ? valA + ';' : valA; var valB = pug_style(b[key]); valB = valB && valB[valB.length - 1] !== ';' ? valB + ';' : valB; a[key] = valA + valB; } else { a[key] = b[key]; } } return a; } /** * Process array, object, or string as a string of classes delimited by a space. * * If `val` is an array, all members of it and its subarrays are counted as * classes. If `escaping` is an array, then whether or not the item in `val` is * escaped depends on the corresponding item in `escaping`. If `escaping` is * not an array, no escaping is done. * * If `val` is an object, all the keys whose value is truthy are counted as * classes. No escaping is done. * * If `val` is a string, it is counted as a class. No escaping is done. * * @param {(Array.<string>|Object.<string, boolean>|string)} val * @param {?Array.<string>} escaping * @return {String} */ exports.classes = pug_classes; function pug_classes_array(val, escaping) { var classString = '', className, padding = '', escapeEnabled = Array.isArray(escaping); for (var i = 0; i < val.length; i++) { className = pug_classes(val[i]); if (!className) continue; escapeEnabled && escaping[i] && (className = pug_escape(className)); classString = classString + padding + className; padding = ' '; } return classString; } function pug_classes_object(val) { var classString = '', padding = ''; for (var key in val) { if (key && val[key] && pug_has_own_property.call(val, key)) { classString = classString + padding + key; padding = ' '; } } return classString; } function pug_classes(val, escaping) { if (Array.isArray(val)) { return pug_classes_array(val, escaping); } else if (val && typeof val === 'object') { return pug_classes_object(val); } else { return val || ''; } } /** * Convert object or string to a string of CSS styles delimited by a semicolon. * * @param {(Object.<string, string>|string)} val * @return {String} */ exports.style = pug_style; function pug_style(val) { if (!val) return ''; if (typeof val === 'object') { var out = ''; for (var style in val) { /* istanbul ignore else */ if (pug_has_own_property.call(val, style)) { out = out + style + ':' + val[style] + ';'; } } return out; } else { return val + ''; } } /** * Render the given attribute. * * @param {String} key * @param {String} val * @param {Boolean} escaped * @param {Boolean} terse * @return {String} */ exports.attr = pug_attr; function pug_attr(key, val, escaped, terse) { if (val === false || val == null || !val && (key === 'class' || key === 'style')) { return ''; } if (val === true) { return ' ' + (terse ? key : key + '="' + key + '"'); } var type = typeof val; if ((type === 'object' || type === 'function') && typeof val.toJSON === 'function') { val = val.toJSON(); } if (typeof val !== 'string') { val = JSON.stringify(val); if (!escaped && val.indexOf('"') !== -1) { return ' ' + key + '=\'' + val.replace(/'/g, '&#39;') + '\''; } } if (escaped) val = pug_escape(val); return ' ' + key + '="' + val + '"'; } /** * Render the given attributes object. * * @param {Object} obj * @param {Object} terse whether to use HTML5 terse boolean attributes * @return {String} */ exports.attrs = pug_attrs; function pug_attrs(obj, terse) { var attrs = ''; for (var key in obj) { if (pug_has_own_property.call(obj, key)) { var val = obj[key]; if ('class' === key) { val = pug_classes(val); attrs = pug_attr(key, val, false, terse) + attrs; continue; } if ('style' === key) { val = pug_style(val); } attrs += pug_attr(key, val, false, terse); } } return attrs; } /** * Escape the given string of `html`. * * @param {String} html * @return {String} * @api private */ var pug_match_html = /["&<>]/; exports.escape = pug_escape; function pug_escape(_html) { var html = '' + _html; var regexResult = pug_match_html.exec(html); if (!regexResult) return _html; var result = ''; var i, lastIndex, escape; for (i = regexResult.index, lastIndex = 0; i < html.length; i++) { switch (html.charCodeAt(i)) { case 34: escape = '&quot;'; break; case 38: escape = '&amp;'; break; case 60: escape = '&lt;'; break; case 62: escape = '&gt;'; break; default: continue; } if (lastIndex !== i) result += html.substring(lastIndex, i); lastIndex = i + 1; result += escape; } if (lastIndex !== i) return result + html.substring(lastIndex, i);else return result; } /** * Re-throw the given `err` in context to the * the pug in `filename` at the given `lineno`. * * @param {Error} err * @param {String} filename * @param {String} lineno * @param {String} str original source * @api private */ exports.rethrow = pug_rethrow; function pug_rethrow(err, filename, lineno, str) { if (!(err instanceof Error)) throw err; if ((typeof window != 'undefined' || !filename) && !str) { err.message += ' on line ' + lineno; throw err; } try { str = str || require('fs').readFileSync(filename, 'utf8'); } catch (ex) { pug_rethrow(err, null, lineno); } var context = 3, lines = str.split('\n'), start = Math.max(lineno - context, 0), end = Math.min(lines.length, lineno + context); // Error context var context = lines.slice(start, end).map(function (line, i) { var curr = i + start + 1; return (curr == lineno ? ' > ' : ' ') + curr + '| ' + line; }).join('\n'); // Alter exception message err.path = filename; err.message = (filename || 'Pug') + ':' + lineno + '\n' + context + '\n\n' + err.message; throw err; } return exports; })({});runtime_es3e5eb61d.T=Timer;runtime_es3e5eb61d._=_defineProperty;runtime_es3e5eb61d.a=_default$3;runtime_es3e5eb61d.p=pug;var index9ec197f3 = {};const days$f="days";const hours$f="hours";const minutes$f="minutes";const seconds$f="seconds";var en = {days:days$f,hours:hours$f,minutes:minutes$f,seconds:seconds$f};const days$e="days";const hours$e="hrs";const minutes$e="mins";const seconds$e="secs";var enShort = {days:days$e,hours:hours$e,minutes:minutes$e,seconds:seconds$e};const days$d="días";const hours$d="horas";const minutes$d="minutos";const seconds$d="segundos";var es = {days:days$d,hours:hours$d,minutes:minutes$d,seconds:seconds$d};const days$c="дней";const hours$c="часов";const minutes$c="минут";const seconds$c="секунд";var ru = {days:days$c,hours:hours$c,minutes:minutes$c,seconds:seconds$c};const days$b="tage";const hours$b="stunden";const minutes$b="minuten";const seconds$b="sekunden";var de = {days:days$b,hours:hours$b,minutes:minutes$b,seconds:seconds$b};const days$a="dni";const hours$a="godziny";const minutes$a="minuty";const seconds$a="sekundy";var pl = {days:days$a,hours:hours$a,minutes:minutes$a,seconds:seconds$a};const days$9="giorni";const hours$9="ore";const minutes$9="minuti";const seconds$9="secondi";var it = {days:days$9,hours:hours$9,minutes:minutes$9,seconds:seconds$9};const days$8="gün";const hours$8="saat";const minutes$8="dakika";const seconds$8="saniye";var tr = {days:days$8,hours:hours$8,minutes:minutes$8,seconds:seconds$8};const days$7="jours";const hours$7="heures";const minutes$7="minutes";const seconds$7="secondes";var fr = {days:days$7,hours:hours$7,minutes:minutes$7,seconds:seconds$7};const days$6="dias";const hours$6="horas";const minutes$6="minutos";const seconds$6="segundos";var br = {days:days$6,hours:hours$6,minutes:minutes$6,seconds:seconds$6};const days$5="dagen";const hours$5="uren";const minutes$5="minuten";const seconds$5="seconden";var nl = {days:days$5,hours:hours$5,minutes:minutes$5,seconds:seconds$5};const days$4="日";const hours$4="时";const minutes$4="分";const seconds$4="秒";var cn = {days:days$4,hours:hours$4,minutes:minutes$4,seconds:seconds$4};const days$3="dny";const hours$3="hodiny";const minutes$3="minuty";const seconds$3="sekundy";var cz = {days:days$3,hours:hours$3,minutes:minutes$3,seconds:seconds$3};const days$2="днів";const hours$2="годин";const minutes$2="хвилин";const seconds$2="секунд";var ua = {days:days$2,hours:hours$2,minutes:minutes$2,seconds:seconds$2};const days$1="nap";const hours$1="óra";const minutes$1="perc";const seconds$1="másodperc";var hu = {days:days$1,hours:hours$1,minutes:minutes$1,seconds:seconds$1};const days="dagar";const hours="timmar";const minutes="minuter";const seconds="sekunder";var se = {days:days,hours:hours,minutes:minutes,seconds:seconds};var locales = { en, enShort, es, ru, de, pl, it, tr, fr, br, nl, cn, cz, ua, hu, se };index9ec197f3.l=locales;Object.defineProperty(CNT1B$1,'__esModule',{value:true});var runtime_es$2=runtime_es3e5eb61d,index$1=index9ec197f3;function template$2(locals) {var pug_html = "", pug_interp;var pug_debug_filename, pug_debug_line;try {var pug_debug_sources = {}; ;var locals_for_with = (locals || {});(function (labels, styles, time, timerFace, timerId, timerName) { if (timerFace === 'daily' || timerFace === 'hourly') { pug_html = pug_html + "\u003Cdiv" + (runtime_es$2.p.attr("class", runtime_es$2.p.classes([styles.TMClockTimer], [true]), false, true)) + "\u003E"; if (!(timerFace !== 'daily')) { pug_html = pug_html + "\u003Cdiv" + (runtime_es$2.p.attr("class", runtime_es$2.p.classes([styles.TMClockTimer__fragment], [true]), false, true)) + "\u003E"; pug_html = pug_html + "\u003Cdiv" + (runtime_es$2.p.attr("class", runtime_es$2.p.classes([styles.TMClockTimer__valueWrapper], [true]), false, true)) + "\u003E"; pug_html = pug_html + "\u003Cdiv" + (runtime_es$2.p.attr("class", runtime_es$2.p.classes([styles.TMClockTimer__clockFaceTop], [true]), false, true)) + "\u003E\u003C\u002Fdiv\u003E"; pug_html = pug_html + "\u003Cspan" + (runtime_es$2.p.attr("class", runtime_es$2.p.classes([`${styles.TMClockTimer__value} ${timerName + '_days_' + timerId}`], [true]), false, true)) + "\u003E"; pug_html = pug_html + (runtime_es$2.p.escape(null == (pug_interp = time ? time.days : null) ? "" : pug_interp)) + "\u003C\u002Fspan\u003E"; pug_html = pug_html + "\u003Cdiv" + (runtime_es$2.p.attr("class", runtime_es$2.p.classes([styles.TMClockTimer__clockFaceBottom], [true]), false, true)) + "\u003E\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E"; pug_html = pug_html + "\u003Cdiv" + (runtime_es$2.p.attr("class", runtime_es$2.p.class