hlp 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2846 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
+
18
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
19
+
20
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
21
+
22
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
23
+
24
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
25
+
26
+ require("@babel/polyfill/noConflict");
27
+
28
+ require("mdn-polyfills/NodeList.prototype.forEach");
29
+
30
+ require("mdn-polyfills/Node.prototype.remove");
31
+
32
+ require("mdn-polyfills/Node.prototype.before");
33
+
34
+ require("mdn-polyfills/Element.prototype.closest");
35
+
36
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
37
+
38
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
39
+
40
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
41
+
42
+ var hlp = /*#__PURE__*/function () {
43
+ function hlp() {
44
+ (0, _classCallCheck2.default)(this, hlp);
45
+ }
46
+
47
+ (0, _createClass2.default)(hlp, null, [{
48
+ key: "x",
49
+ value: function x(input) {
50
+ if (typeof input === 'function') {
51
+ try {
52
+ input = input();
53
+ return this.x(input);
54
+ } catch (e) {
55
+ return false;
56
+ }
57
+ }
58
+
59
+ if (input === null || input === false || typeof input === 'string' && input.trim() == '' || (0, _typeof2.default)(input) === 'object' && Object.keys(input).length === 0 && input.constructor === Object || typeof input === 'undefined' || Array.isArray(input) && input.length === 0 || Array.isArray(input) && input.length === 1 && input[0] === '') {
60
+ return false;
61
+ }
62
+
63
+ return true;
64
+ }
65
+ }, {
66
+ key: "nx",
67
+ value: function nx(input) {
68
+ return !this.x(input);
69
+ }
70
+ }, {
71
+ key: "true",
72
+ value: function _true(input) {
73
+ if (typeof input === 'function') {
74
+ try {
75
+ input = input();
76
+ return this.true(input);
77
+ } catch (e) {
78
+ return false;
79
+ }
80
+ }
81
+
82
+ if (input === undefined) {
83
+ return false;
84
+ }
85
+
86
+ if (input === null) {
87
+ return false;
88
+ }
89
+
90
+ if (input === false) {
91
+ return false;
92
+ }
93
+
94
+ if (Array.isArray(input) && input.length === 0) {
95
+ return false;
96
+ }
97
+
98
+ if (Array.isArray(input) && hlp.first(input) === '') {
99
+ return false;
100
+ }
101
+
102
+ if ((0, _typeof2.default)(input) === 'object' && Object.keys(input).length === 0 && input.constructor === Object) {
103
+ return false;
104
+ }
105
+
106
+ if (input === 0) {
107
+ return false;
108
+ }
109
+
110
+ if (input === '0') {
111
+ return false;
112
+ }
113
+
114
+ if (input === '') {
115
+ return false;
116
+ }
117
+
118
+ if (input === ' ') {
119
+ return false;
120
+ }
121
+
122
+ if (input === 'null') {
123
+ return false;
124
+ }
125
+
126
+ if (input === 'false') {
127
+ return false;
128
+ }
129
+
130
+ return true;
131
+ }
132
+ }, {
133
+ key: "false",
134
+ value: function _false(input) {
135
+ if (typeof input === 'function') {
136
+ try {
137
+ input = input();
138
+ return this.false(input);
139
+ } catch (e) {
140
+ return false;
141
+ }
142
+ }
143
+
144
+ if (input === undefined) {
145
+ return false;
146
+ }
147
+
148
+ if (input === null) {
149
+ return false;
150
+ }
151
+
152
+ if (input === false) {
153
+ return true;
154
+ }
155
+
156
+ if (Array.isArray(input) && input.length === 0) {
157
+ return false;
158
+ }
159
+
160
+ if (Array.isArray(input) && hlp.first(input) === '') {
161
+ return false;
162
+ }
163
+
164
+ if ((0, _typeof2.default)(input) === 'object' && Object.keys(input).length === 0 && input.constructor === Object) {
165
+ return false;
166
+ }
167
+
168
+ if (input === 0) {
169
+ return true;
170
+ }
171
+
172
+ if (input === '0') {
173
+ return true;
174
+ }
175
+
176
+ if (input === '') {
177
+ return false;
178
+ }
179
+
180
+ if (input === ' ') {
181
+ return false;
182
+ }
183
+
184
+ if (input === 'null') {
185
+ return false;
186
+ }
187
+
188
+ if (input === 'false') {
189
+ return true;
190
+ }
191
+
192
+ return false;
193
+ }
194
+ }, {
195
+ key: "v",
196
+ value: function v() {
197
+ if (this.nx(arguments)) {
198
+ return '';
199
+ }
200
+
201
+ for (var i = 0; i < arguments.length; i++) {
202
+ if (this.x(arguments[i])) {
203
+ return arguments[i];
204
+ }
205
+ }
206
+
207
+ return '';
208
+ }
209
+ }, {
210
+ key: "loop",
211
+ value: function loop(input, fun) {
212
+ if (this.nx(input)) {
213
+ return null;
214
+ }
215
+
216
+ if (Array.isArray(input)) {
217
+ input.forEach(function (input__value, input__key) {
218
+ fun(input__value, input__key);
219
+ });
220
+ } else if ((0, _typeof2.default)(input) === 'object') {
221
+ Object.entries(input).forEach(function (_ref) {
222
+ var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
223
+ input__key = _ref2[0],
224
+ input__value = _ref2[1];
225
+
226
+ fun(input__value, input__key);
227
+ });
228
+ }
229
+ }
230
+ }, {
231
+ key: "map",
232
+ value: function map(obj, fn, ctx) {
233
+ return Object.keys(obj).reduce(function (a, b) {
234
+ a[b] = fn.call(ctx || null, b, obj[b]);
235
+ return a;
236
+ }, {});
237
+ }
238
+ }, {
239
+ key: "first",
240
+ value: function first(input) {
241
+ if (Array.isArray(input)) {
242
+ var ret = null;
243
+ input.forEach(function (input__value, input__key) {
244
+ if (ret === null) {
245
+ ret = input__value;
246
+ }
247
+ });
248
+ return ret;
249
+ }
250
+
251
+ if ((0, _typeof2.default)(input) === 'object') {
252
+ var ret = null;
253
+ Object.entries(input).forEach(function (_ref3) {
254
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
255
+ input__key = _ref4[0],
256
+ input__value = _ref4[1];
257
+
258
+ if (ret === null) {
259
+ ret = input__value;
260
+ }
261
+ });
262
+ return ret;
263
+ }
264
+
265
+ return null;
266
+ }
267
+ }, {
268
+ key: "last",
269
+ value: function last(input) {
270
+ if (Array.isArray(input)) {
271
+ var ret = null;
272
+ input.forEach(function (input__value, input__key) {
273
+ ret = input__value;
274
+ });
275
+ return ret;
276
+ }
277
+
278
+ if ((0, _typeof2.default)(input) === 'object') {
279
+ var _ret = null;
280
+ Object.entries(input).forEach(function (_ref5) {
281
+ var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
282
+ input__key = _ref6[0],
283
+ input__value = _ref6[1];
284
+
285
+ _ret = input__value;
286
+ });
287
+ return _ret;
288
+ }
289
+
290
+ return null;
291
+ }
292
+ }, {
293
+ key: "rand",
294
+ value: function rand(input) {
295
+ if (Array.isArray(input)) {
296
+ return input[Math.floor(Math.random() * input.length)];
297
+ }
298
+
299
+ if ((0, _typeof2.default)(input) === 'object') {
300
+ var input = Object.values(input);
301
+ return input[Math.floor(Math.random() * input.length)];
302
+ }
303
+
304
+ return null;
305
+ }
306
+ }, {
307
+ key: "random_string",
308
+ value: function random_string() {
309
+ var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
310
+ var chars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
311
+
312
+ if (chars === null) {
313
+ chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
314
+ }
315
+
316
+ var chars_length = chars.length,
317
+ random_string = '';
318
+
319
+ for (var i = 0; i < length; i++) {
320
+ random_string += chars[~~(Math.random() * (chars_length - 1 - 0 + 1)) + 0];
321
+ }
322
+
323
+ return random_string;
324
+ }
325
+ }, {
326
+ key: "isInteger",
327
+ value: function isInteger(value) {
328
+ return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10));
329
+ }
330
+ }, {
331
+ key: "random_int",
332
+ value: function random_int() {
333
+ var min = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
334
+ var max = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 99999;
335
+
336
+ if (!this.isInteger(min) || !this.isInteger(max)) {
337
+ return false;
338
+ }
339
+
340
+ if (min > max) {
341
+ var _ref7 = [max, min];
342
+ min = _ref7[0];
343
+ max = _ref7[1];
344
+ }
345
+
346
+ return ~~(Math.random() * (max - min + 1)) + min;
347
+ }
348
+ }, {
349
+ key: "capitalize",
350
+ value: function capitalize() {
351
+ var string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
352
+
353
+ if (string === null) {
354
+ return string;
355
+ }
356
+
357
+ if (string === '') {
358
+ return string;
359
+ }
360
+
361
+ return string.charAt(0).toUpperCase() + string.slice(1);
362
+ }
363
+ }, {
364
+ key: "cookieExists",
365
+ value: function cookieExists(cookie_name) {
366
+ if (document.cookie !== undefined && this.cookieGet(cookie_name) !== null) {
367
+ return true;
368
+ }
369
+
370
+ return false;
371
+ }
372
+ }, {
373
+ key: "cookieGet",
374
+ value: function cookieGet(cookie_name) {
375
+ var cookie_match = document.cookie.match(new RegExp(cookie_name + '=([^;]+)'));
376
+
377
+ if (cookie_match) {
378
+ return decodeURIComponent(cookie_match[1]);
379
+ }
380
+
381
+ return null;
382
+ }
383
+ }, {
384
+ key: "cookieSet",
385
+ value: function cookieSet(cookie_name, cookie_value, days) {
386
+ var samesite = '';
387
+
388
+ if (window.location.protocol.indexOf('https') > -1) {
389
+ samesite = '; SameSite=None; Secure';
390
+ }
391
+
392
+ document.cookie = cookie_name + '=' + encodeURIComponent(cookie_value) + '; ' + 'expires=' + new Date(new Date().getTime() + days * 24 * 60 * 60 * 1000).toUTCString() + '; path=/' + samesite + '; domain=' + this.urlHostTopLevel();
393
+ }
394
+ }, {
395
+ key: "cookieDelete",
396
+ value: function cookieDelete(cookie_name) {
397
+ var samesite = '';
398
+
399
+ if (window.location.protocol.indexOf('https') > -1) {
400
+ samesite = '; SameSite=None; Secure';
401
+ }
402
+
403
+ document.cookie = cookie_name + '=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/' + samesite + '; domain=' + this.urlHostTopLevel();
404
+ }
405
+ }, {
406
+ key: "getParam",
407
+ value: function getParam(variable) {
408
+ var url = window.location.search;
409
+
410
+ if (this.nx(url)) {
411
+ return null;
412
+ }
413
+
414
+ var query = url.substring(1),
415
+ vars = query.split('&');
416
+
417
+ for (var i = 0; i < vars.length; i++) {
418
+ var pair = vars[i].split('=');
419
+
420
+ if (pair[0] == variable && this.x(pair[1])) {
421
+ return pair[1];
422
+ }
423
+ }
424
+
425
+ return null;
426
+ }
427
+ }, {
428
+ key: "getDevice",
429
+ value: function getDevice() {
430
+ if (this.isPhone()) {
431
+ return 'phone';
432
+ }
433
+
434
+ if (this.isTablet()) {
435
+ return 'tablet';
436
+ }
437
+
438
+ return 'desktop';
439
+ }
440
+ }, {
441
+ key: "isPhone",
442
+ value: function isPhone() {
443
+ // based on detectmobilebrowsers.com
444
+ var a = navigator.userAgent || navigator.vendor || window.opera;
445
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
446
+ }
447
+ }, {
448
+ key: "isTablet",
449
+ value: function isTablet() {
450
+ // based on detectmobilebrowsers.com
451
+ var a = navigator.userAgent || navigator.vendor || window.opera;
452
+ return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4));
453
+ }
454
+ }, {
455
+ key: "isDesktop",
456
+ value: function isDesktop() {
457
+ return !this.isPhone() && !this.isTablet();
458
+ }
459
+ }, {
460
+ key: "isMobile",
461
+ value: function isMobile() {
462
+ // viewport width based OR phone based
463
+ if (window.innerWidth < 750 || this.isPhone()) {
464
+ return true;
465
+ }
466
+
467
+ return false;
468
+ }
469
+ }, {
470
+ key: "isTouch",
471
+ value: function isTouch() {
472
+ return 'ontouchstart' in window || navigator.maxTouchPoints || false;
473
+ }
474
+ }, {
475
+ key: "isMac",
476
+ value: function isMac() {
477
+ return hlp.getOs() === 'mac';
478
+ }
479
+ }, {
480
+ key: "isLinux",
481
+ value: function isLinux() {
482
+ return hlp.getOs() === 'linux';
483
+ }
484
+ }, {
485
+ key: "isWindows",
486
+ value: function isWindows() {
487
+ return hlp.getOs() === 'windows';
488
+ }
489
+ }, {
490
+ key: "getOs",
491
+ value: function getOs() {
492
+ var userAgent = window.navigator.userAgent,
493
+ platform = window.navigator.platform,
494
+ macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'],
495
+ windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'],
496
+ iosPlatforms = ['iPhone', 'iPad', 'iPod'],
497
+ os = 'unknown';
498
+
499
+ if (macosPlatforms.indexOf(platform) !== -1) {
500
+ os = 'mac';
501
+ } else if (iosPlatforms.indexOf(platform) !== -1) {
502
+ os = 'mac';
503
+ } else if (windowsPlatforms.indexOf(platform) !== -1) {
504
+ os = 'windows';
505
+ } else if (/Android/.test(userAgent)) {
506
+ os = 'linux';
507
+ } else if (/Linux/.test(platform)) {
508
+ os = 'linux';
509
+ }
510
+
511
+ return os;
512
+ }
513
+ }, {
514
+ key: "getBrowser",
515
+ value: function getBrowser() {
516
+ var browser_name = '',
517
+ isIE =
518
+ /*@cc_on!@*/
519
+ false || !!document.documentMode,
520
+ isEdge = !isIE && !!window.StyleMedia;
521
+
522
+ if (navigator.userAgent.indexOf('Opera') != -1 || navigator.userAgent.indexOf('OPR') != -1) {
523
+ browser_name = 'opera';
524
+ } else if (navigator.userAgent.indexOf('Chrome') != -1 && !isEdge) {
525
+ browser_name = 'chrome';
526
+ } else if (navigator.userAgent.indexOf('Safari') != -1 && !isEdge) {
527
+ browser_name = 'safari';
528
+ } else if (navigator.userAgent.indexOf('Firefox') != -1) {
529
+ browser_name = 'firefox';
530
+ } else if (navigator.userAgent.indexOf('MSIE') != -1 || !!document.documentMode == true) {
531
+ //IF IE > 10
532
+ browser_name = 'ie';
533
+ } else if (isEdge) {
534
+ browser_name = 'edge';
535
+ } else {
536
+ browser_name = 'unknown';
537
+ }
538
+
539
+ return browser_name;
540
+ }
541
+ }, {
542
+ key: "isObject",
543
+ value: function isObject(a) {
544
+ return !!a && a.constructor === Object;
545
+ }
546
+ }, {
547
+ key: "isArray",
548
+ value: function isArray(a) {
549
+ return !!a && a.constructor === Array;
550
+ }
551
+ }, {
552
+ key: "isString",
553
+ value: function isString(string) {
554
+ return typeof string === 'string' || string instanceof String;
555
+ }
556
+ }, {
557
+ key: "isDate",
558
+ value: function isDate(string) {
559
+ if (this.nx(string)) {
560
+ return false;
561
+ } // if string is of object date
562
+
563
+
564
+ if (Object.prototype.toString.call(string) === '[object Date]') {
565
+ return true;
566
+ } // if this is not a string
567
+
568
+
569
+ if (!this.isString(string)) {
570
+ return false;
571
+ } // strong check
572
+
573
+
574
+ if (string.split('-').length !== 3) {
575
+ return false;
576
+ }
577
+
578
+ var day = parseInt(string.split('-')[2]),
579
+ month = parseInt(string.split('-')[1]),
580
+ year = parseInt(string.split('-')[0]),
581
+ date = new Date();
582
+ date.setFullYear(year, month - 1, day);
583
+
584
+ if (date.getFullYear() == year && date.getMonth() + 1 == month && date.getDate() == day) {
585
+ return true;
586
+ }
587
+
588
+ return false;
589
+ }
590
+ }, {
591
+ key: "formatDate",
592
+ value: function formatDate(format) {
593
+ var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
594
+
595
+ if (date === false || date === true || date === null || date === '') {
596
+ date = new Date();
597
+ } else if ((0, _typeof2.default)(date) !== 'object') {
598
+ date = new Date(date.replace(/-/g, '/'));
599
+ }
600
+
601
+ var string = '',
602
+ mo = date.getMonth(),
603
+ m1 = mo + 1,
604
+ dow = date.getDay(),
605
+ d = date.getDate(),
606
+ y = date.getFullYear(),
607
+ h = date.getHours(),
608
+ mi = date.getMinutes(),
609
+ s = date.getSeconds();
610
+
611
+ for (var i = 0, len = format.length; i < len; i++) {
612
+ switch (format[i]) {
613
+ case 'j':
614
+ string += d;
615
+ break;
616
+
617
+ case 'd':
618
+ string += d < 10 ? '0' + d : d;
619
+ break;
620
+
621
+ case 'l':
622
+ var days = Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
623
+ string += days[dow];
624
+ break;
625
+
626
+ case 'w':
627
+ string += dow;
628
+ break;
629
+
630
+ case 'D':
631
+ days = Array('Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat');
632
+ string += days[dow];
633
+ break;
634
+
635
+ case 'm':
636
+ string += m1 < 10 ? '0' + m1 : m1;
637
+ break;
638
+
639
+ case 'n':
640
+ string += m1;
641
+ break;
642
+
643
+ case 'F':
644
+ var months = Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
645
+ string += months[mo];
646
+ break;
647
+
648
+ case 'M':
649
+ months = Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
650
+ string += months[mo];
651
+ break;
652
+
653
+ case 'Y':
654
+ string += y;
655
+ break;
656
+
657
+ case 'y':
658
+ string += y.toString().slice(-2);
659
+ break;
660
+
661
+ case 'H':
662
+ string += h < 10 ? '0' + h : h;
663
+ break;
664
+
665
+ case 'g':
666
+ var hour = h === 0 ? 12 : h;
667
+ string += hour > 12 ? hour - 12 : hour;
668
+ break;
669
+
670
+ case 'h':
671
+ hour = h === 0 ? 12 : h;
672
+ hour = hour > 12 ? hour - 12 : hour;
673
+ string += hour < 10 ? '0' + hour : hour;
674
+ break;
675
+
676
+ case 'a':
677
+ string += h < 12 ? 'am' : 'pm';
678
+ break;
679
+
680
+ case 'i':
681
+ string += mi < 10 ? '0' + mi : mi;
682
+ break;
683
+
684
+ case 's':
685
+ string += s < 10 ? '0' + s : s;
686
+ break;
687
+
688
+ case 'c':
689
+ string += date.toISOString();
690
+ break;
691
+
692
+ default:
693
+ string += format[i];
694
+ }
695
+ }
696
+
697
+ return string;
698
+ }
699
+ }, {
700
+ key: "deepCopy",
701
+ value: function deepCopy(obj) {
702
+ var hash = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new WeakMap();
703
+ if (Object(obj) !== obj) return obj; // primitives
704
+
705
+ if (hash.has(obj)) return hash.get(obj); // cyclic reference
706
+
707
+ var result = obj instanceof Date ? new Date(obj) : obj instanceof RegExp ? new RegExp(obj.source, obj.flags) : obj.constructor ? new obj.constructor() : Object.create(null);
708
+ hash.set(obj, result);
709
+ if (obj instanceof Map) Array.from(obj, function (_ref8) {
710
+ var _ref9 = (0, _slicedToArray2.default)(_ref8, 2),
711
+ key = _ref9[0],
712
+ val = _ref9[1];
713
+
714
+ return result.set(key, hlp.deepCopy(val, hash));
715
+ });
716
+ return Object.assign.apply(Object, [result].concat((0, _toConsumableArray2.default)(Object.keys(obj).map(function (key) {
717
+ return (0, _defineProperty2.default)({}, key, hlp.deepCopy(obj[key], hash));
718
+ }))));
719
+ }
720
+ }, {
721
+ key: "jsonStringToObject",
722
+ value: function jsonStringToObject(string) {
723
+ if (this.nx(string) || !this.isString(string)) {
724
+ return null;
725
+ }
726
+
727
+ try {
728
+ return JSON.parse(string);
729
+ } catch (error) {
730
+ return null;
731
+ }
732
+ }
733
+ }, {
734
+ key: "isJsonString",
735
+ value: function isJsonString(string) {
736
+ if (this.nx(string) || !this.isString(string)) {
737
+ return false;
738
+ }
739
+
740
+ try {
741
+ var json = JSON.parse(string);
742
+ return true;
743
+ } catch (error) {
744
+ return false;
745
+ }
746
+ }
747
+ }, {
748
+ key: "jsonObjectToString",
749
+ value: function jsonObjectToString(object) {
750
+ try {
751
+ return JSON.stringify(object);
752
+ } catch (error) {
753
+ return null;
754
+ }
755
+ }
756
+ }, {
757
+ key: "uuid",
758
+ value: function uuid() {
759
+ function s4() {
760
+ return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
761
+ }
762
+
763
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
764
+ }
765
+ }, {
766
+ key: "guid",
767
+ value: function guid() {
768
+ return this.uuid();
769
+ }
770
+ }, {
771
+ key: "replaceAll",
772
+ value: function replaceAll(string, search, replace) {
773
+ return string.split(search).join(replace);
774
+ }
775
+ }, {
776
+ key: "replaceLast",
777
+ value: function replaceLast(string, search, replace) {
778
+ var n = string.lastIndexOf(search);
779
+ string = string.slice(0, n) + string.slice(n).replace(search, replace);
780
+ return string;
781
+ }
782
+ }, {
783
+ key: "replaceFirst",
784
+ value: function replaceFirst(string, search, replace) {
785
+ return string.replace(search, replace);
786
+ }
787
+ }, {
788
+ key: "findAllPositions",
789
+ value: function findAllPositions(searchStr, str) {
790
+ var searchStrLen = searchStr.length,
791
+ startIndex = 0,
792
+ index,
793
+ indices = [];
794
+
795
+ if (searchStrLen == 0) {
796
+ return [];
797
+ }
798
+
799
+ while ((index = str.indexOf(searchStr, startIndex)) > -1) {
800
+ indices.push(index);
801
+ startIndex = index + searchStrLen;
802
+ }
803
+
804
+ return indices;
805
+ }
806
+ }, {
807
+ key: "findAllPositionsCaseInsensitive",
808
+ value: function findAllPositionsCaseInsensitive(searchStr, str) {
809
+ var searchStrLen = searchStr.length,
810
+ startIndex = 0,
811
+ index,
812
+ indices = [];
813
+
814
+ if (searchStrLen == 0) {
815
+ return [];
816
+ }
817
+
818
+ while ((index = this.indexOfCaseInsensitive(searchStr, str, startIndex)) > -1) {
819
+ indices.push(index);
820
+ startIndex = index + searchStrLen;
821
+ }
822
+
823
+ return indices;
824
+ }
825
+ }, {
826
+ key: "countAllOccurences",
827
+ value: function countAllOccurences(value, str) {
828
+ var regExp = new RegExp(value, 'g');
829
+ return (str.match(regExp) || []).length;
830
+ }
831
+ }, {
832
+ key: "countAllOccurencesCaseInsensitive",
833
+ value: function countAllOccurencesCaseInsensitive(value, str) {
834
+ var regExp = new RegExp(value, 'gi');
835
+ return (str.match(regExp) || []).length;
836
+ }
837
+ }, {
838
+ key: "indexOfCaseInsensitive",
839
+ value: function indexOfCaseInsensitive(searchStr, str, offset) {
840
+ return str.toLowerCase().indexOf(searchStr.toLowerCase(), offset);
841
+ }
842
+ }, {
843
+ key: "highlight",
844
+ value: function highlight(string, query) {
845
+ var strip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
846
+ var strip_length = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500;
847
+
848
+ if (this.nx(string) || this.nx(query)) {
849
+ return string;
850
+ }
851
+
852
+ if (strip === true) {
853
+ var dots = '...'; // get all query begin positions in spot
854
+
855
+ var _positions = this.findAllPositionsCaseInsensitive(query, string); // strip away parts
856
+
857
+
858
+ var words = string.split(' ');
859
+ var i = 0;
860
+ words.forEach(function (words__value, words__key) {
861
+ var strip_now = true;
862
+
863
+ _positions.forEach(function (positions__value) {
864
+ if (i >= positions__value - strip_length && i <= positions__value + query.length + strip_length - 1) {
865
+ strip_now = false;
866
+ }
867
+ });
868
+
869
+ if (strip_now === true) {
870
+ words[words__key] = dots;
871
+ }
872
+
873
+ i += words__value.length + 1;
874
+ });
875
+ string = words.join(' ');
876
+
877
+ while (string.indexOf(dots + ' ' + dots) > -1) {
878
+ string = this.replaceAll(string, dots + ' ' + dots, dots);
879
+ }
880
+
881
+ string = string.trim();
882
+ } // again: get all query begin positions in spot
883
+
884
+
885
+ var positions = this.findAllPositionsCaseInsensitive(query, string); // wrap span element around them
886
+
887
+ var wrap_begin = '<strong class="highlight">';
888
+ var wrap_end = '</strong>';
889
+
890
+ for (var x = 0; x < positions.length; x++) {
891
+ string = string.substring(0, positions[x]) + wrap_begin + string.substring(positions[x], positions[x] + query.length) + wrap_end + string.substring(positions[x] + query.length); // shift other positions
892
+
893
+ for (var y = x + 1; y < positions.length; y++) {
894
+ positions[y] = positions[y] + wrap_begin.length + wrap_end.length;
895
+ }
896
+ }
897
+
898
+ return string;
899
+ }
900
+ }, {
901
+ key: "get",
902
+ value: function get(url) {
903
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
904
+ return this.call('GET', url, args);
905
+ }
906
+ }, {
907
+ key: "post",
908
+ value: function post(url) {
909
+ var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
910
+ return this.call('POST', url, args);
911
+ }
912
+ }, {
913
+ key: "call",
914
+ value: function call(method, url) {
915
+ var _this2 = this;
916
+
917
+ var args = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
918
+
919
+ if (args === null) {
920
+ args = {};
921
+ }
922
+
923
+ if (!('data' in args)) {
924
+ args.data = {};
925
+ }
926
+
927
+ if (!('headers' in args)) {
928
+ args.headers = null;
929
+ }
930
+
931
+ if (!('throttle' in args)) {
932
+ args.throttle = 0;
933
+ }
934
+
935
+ if (!('allow_errors' in args)) {
936
+ args.allow_errors = true;
937
+ }
938
+
939
+ return new Promise(function (resolve, reject) {
940
+ setTimeout(function () {
941
+ if (url.indexOf('http') !== 0) {
942
+ url = hlp.baseUrl() + '/' + url;
943
+ }
944
+
945
+ var xhr = new XMLHttpRequest();
946
+ xhr.open(method, url, true);
947
+
948
+ if (method === 'POST') {
949
+ if ('data' in args && args.data !== null && (0, _typeof2.default)(args.data) === 'object' && !(args.data instanceof FormData)) {
950
+ xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
951
+ args.data = JSON.stringify(args.data);
952
+ }
953
+
954
+ xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
955
+ }
956
+
957
+ if (_this2.x(args.headers)) {
958
+ Object.entries(args.headers).forEach(function (_ref11) {
959
+ var _ref12 = (0, _slicedToArray2.default)(_ref11, 2),
960
+ headers__key = _ref12[0],
961
+ headers__value = _ref12[1];
962
+
963
+ xhr.setRequestHeader(headers__key, headers__value);
964
+ });
965
+ }
966
+
967
+ xhr.onload = function () {
968
+ if (xhr.readyState != 4 || args.allow_errors !== true && xhr.status != 200 && xhr.status != 304) {
969
+ if (_this2.isJsonString(xhr.responseText)) {
970
+ reject(_this2.jsonStringToObject(xhr.responseText));
971
+ } else {
972
+ reject(xhr.responseText);
973
+ }
974
+ }
975
+
976
+ if (_this2.isJsonString(xhr.responseText)) {
977
+ resolve(_this2.jsonStringToObject(xhr.responseText));
978
+ } else {
979
+ resolve(xhr.responseText);
980
+ }
981
+ };
982
+
983
+ xhr.onerror = function () {
984
+ reject([xhr.readyState, xhr.status, xhr.statusText]);
985
+ };
986
+
987
+ if (method === 'GET') {
988
+ xhr.send(null);
989
+ }
990
+
991
+ if (method === 'POST') {
992
+ xhr.send(args.data);
993
+ }
994
+ }, args.throttle);
995
+ });
996
+ }
997
+ }, {
998
+ key: "onResizeHorizontal",
999
+ value: function onResizeHorizontal(fun) {
1000
+ var windowWidth = window.innerWidth,
1001
+ windowWidthNew,
1002
+ timeout;
1003
+ window.addEventListener('resize', function () {
1004
+ windowWidthNew = window.innerWidth;
1005
+
1006
+ if (windowWidthNew != windowWidth) {
1007
+ windowWidth = windowWidthNew;
1008
+
1009
+ if (timeout) {
1010
+ clearTimeout(timeout);
1011
+ }
1012
+
1013
+ timeout = window.setTimeout(function () {
1014
+ fun();
1015
+ }, 250);
1016
+ }
1017
+ });
1018
+ fun();
1019
+ }
1020
+ }, {
1021
+ key: "onResizeVertical",
1022
+ value: function onResizeVertical(fun) {
1023
+ var windowHeight = window.innerHeight,
1024
+ windowHeightNew,
1025
+ timeout;
1026
+ window.addEventListener('resize', function () {
1027
+ windowHeightNew = window.innerHeight;
1028
+
1029
+ if (windowHeightNew != windowHeight) {
1030
+ windowHeight = windowHeightNew;
1031
+
1032
+ if (timeout) {
1033
+ clearTimeout(timeout);
1034
+ }
1035
+
1036
+ timeout = window.setTimeout(function () {
1037
+ fun();
1038
+ }, 250);
1039
+ }
1040
+ });
1041
+ fun();
1042
+ }
1043
+ }, {
1044
+ key: "uniqueArray",
1045
+ value: function uniqueArray(array) {
1046
+ var seen = {},
1047
+ ret_arr = [];
1048
+
1049
+ for (var i = 0; i < array.length; i++) {
1050
+ if (!(array[i] in seen)) {
1051
+ ret_arr.push(array[i]);
1052
+ seen[array[i]] = true;
1053
+ }
1054
+ }
1055
+
1056
+ return ret_arr;
1057
+ }
1058
+ }, {
1059
+ key: "charToInt",
1060
+ value: function charToInt(val) {
1061
+ val = val.toUpperCase();
1062
+ var base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
1063
+ i,
1064
+ j,
1065
+ result = 0;
1066
+
1067
+ for (i = 0, j = val.length - 1; i < val.length; i += 1, j -= 1) {
1068
+ result += Math.pow(base.length, j) * (base.indexOf(val[i]) + 1);
1069
+ }
1070
+
1071
+ return result;
1072
+ }
1073
+ }, {
1074
+ key: "intToChar",
1075
+ value: function intToChar(num) {
1076
+ for (var ret = '', a = 1, b = 26; (num -= a) >= 0; a = b, b *= 26) {
1077
+ ret = String.fromCharCode(parseInt(num % b / a) + 65) + ret;
1078
+ }
1079
+
1080
+ return ret;
1081
+ }
1082
+ }, {
1083
+ key: "slugify",
1084
+ value: function slugify(text) {
1085
+ return text.toString().toLowerCase().trim().split('ä').join('ae').split('ö').join('oe').split('ü').join('ue').split('ß').join('ss').replace(/[^\w\s-]/g, '') // remove non-word [a-z0-9_], non-whitespace, non-hyphen characters
1086
+ .replace(/[\s_-]+/g, '-') // swap any length of whitespace, underscore, hyphen characters with a single -
1087
+ .replace(/^-+|-+$/g, ''); // remove leading, trailing -
1088
+ }
1089
+ }, {
1090
+ key: "incChar",
1091
+ value: function incChar(char) {
1092
+ var shift = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1093
+ return this.intToChar(this.charToInt(char) + shift);
1094
+ }
1095
+ }, {
1096
+ key: "decChar",
1097
+ value: function decChar(char) {
1098
+ var shift = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1099
+ return this.intToChar(this.charToInt(char) - shift);
1100
+ }
1101
+ }, {
1102
+ key: "range",
1103
+ value: function range(start, end) {
1104
+ var range = [],
1105
+ typeofStart = (0, _typeof2.default)(start),
1106
+ typeofEnd = (0, _typeof2.default)(end),
1107
+ step = 1;
1108
+
1109
+ if (typeofStart == 'undefined' || typeofEnd == 'undefined' || typeofStart != typeofEnd) {
1110
+ return null;
1111
+ }
1112
+
1113
+ if (end < start) {
1114
+ step = -step;
1115
+ }
1116
+
1117
+ if (typeofStart == 'number') {
1118
+ while (step > 0 ? end >= start : end <= start) {
1119
+ range.push(start);
1120
+ start += step;
1121
+ }
1122
+ } else if (typeofStart == 'string') {
1123
+ if (start.length != 1 || end.length != 1) {
1124
+ return null;
1125
+ }
1126
+
1127
+ start = start.charCodeAt(0);
1128
+ end = end.charCodeAt(0);
1129
+
1130
+ while (step > 0 ? end >= start : end <= start) {
1131
+ range.push(String.fromCharCode(start));
1132
+ start += step;
1133
+ }
1134
+ } else {
1135
+ return null;
1136
+ }
1137
+
1138
+ return range;
1139
+ }
1140
+ }, {
1141
+ key: "dateToWeek",
1142
+ value: function dateToWeek() {
1143
+ var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1144
+
1145
+ if (d === null) {
1146
+ d = new Date();
1147
+ }
1148
+
1149
+ d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
1150
+ d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
1151
+ var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1)),
1152
+ weekNo = Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
1153
+ return weekNo;
1154
+ }
1155
+ }, {
1156
+ key: "weekToDate",
1157
+ value: function weekToDate(w, y) {
1158
+ var simple = new Date(y, 0, 1 + (w - 1) * 7),
1159
+ dow = simple.getDay(),
1160
+ ISOweekStart = simple;
1161
+
1162
+ if (dow <= 4) {
1163
+ ISOweekStart.setDate(simple.getDate() - simple.getDay() + 1);
1164
+ } else {
1165
+ ISOweekStart.setDate(simple.getDate() + 8 - simple.getDay());
1166
+ }
1167
+
1168
+ ISOweekStart.setUTCHours(0, 0, 0, 0);
1169
+ return ISOweekStart;
1170
+ }
1171
+ }, {
1172
+ key: "addDays",
1173
+ value: function addDays(date, days) {
1174
+ var result = new Date(date);
1175
+ result.setDate(result.getDate() + days);
1176
+ return result;
1177
+ }
1178
+ }, {
1179
+ key: "objectsAreEqual",
1180
+ value: function objectsAreEqual(x, y) {
1181
+ var _this = this;
1182
+
1183
+ if (x === null || x === undefined || y === null || y === undefined) {
1184
+ return x === y;
1185
+ }
1186
+
1187
+ if (x.constructor !== y.constructor) {
1188
+ return false;
1189
+ }
1190
+
1191
+ if (x instanceof Function) {
1192
+ return x === y;
1193
+ }
1194
+
1195
+ if (x instanceof RegExp) {
1196
+ return x === y;
1197
+ }
1198
+
1199
+ if (x === y || x.valueOf() === y.valueOf()) {
1200
+ return true;
1201
+ }
1202
+
1203
+ if (Array.isArray(x) && x.length !== y.length) {
1204
+ return false;
1205
+ }
1206
+
1207
+ if (x instanceof Date) {
1208
+ return false;
1209
+ }
1210
+
1211
+ if (!(x instanceof Object)) {
1212
+ return false;
1213
+ }
1214
+
1215
+ if (!(y instanceof Object)) {
1216
+ return false;
1217
+ }
1218
+
1219
+ var p = Object.keys(x);
1220
+ return Object.keys(y).every(function (i) {
1221
+ return p.indexOf(i) !== -1;
1222
+ }) && p.every(function (i) {
1223
+ return _this.objectsAreEqual(x[i], y[i]);
1224
+ });
1225
+ }
1226
+ }, {
1227
+ key: "containsObject",
1228
+ value: function containsObject(obj, list) {
1229
+ var x;
1230
+
1231
+ for (x in list) {
1232
+ if (list.hasOwnProperty(x) && this.objectsAreEqual(list[x], obj)) {
1233
+ return true;
1234
+ }
1235
+ }
1236
+
1237
+ return false;
1238
+ }
1239
+ }, {
1240
+ key: "fadeOut",
1241
+ value: function fadeOut(el) {
1242
+ var speed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1243
+
1244
+ if (speed <= 25) {
1245
+ speed = 25;
1246
+ }
1247
+
1248
+ return new Promise(function (resolve) {
1249
+ el.style.opacity = 1;
1250
+
1251
+ (function fade() {
1252
+ if ((el.style.opacity -= 25 / speed) < 0) {
1253
+ el.style.display = 'none';
1254
+ resolve();
1255
+ } else {
1256
+ requestAnimationFrame(fade);
1257
+ }
1258
+ })();
1259
+ });
1260
+ }
1261
+ }, {
1262
+ key: "fadeIn",
1263
+ value: function fadeIn(el) {
1264
+ var speed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1265
+
1266
+ if (speed <= 25) {
1267
+ speed = 25;
1268
+ }
1269
+
1270
+ return new Promise(function (resolve) {
1271
+ el.style.opacity = 0;
1272
+ el.style.display = 'block';
1273
+
1274
+ (function fade() {
1275
+ var val = parseFloat(el.style.opacity);
1276
+
1277
+ if (!((val += 25 / speed) > 1)) {
1278
+ el.style.opacity = val;
1279
+ requestAnimationFrame(fade);
1280
+ } else {
1281
+ resolve();
1282
+ }
1283
+ })();
1284
+ });
1285
+ }
1286
+ }, {
1287
+ key: "scrollTop",
1288
+ value: function scrollTop() {
1289
+ var doc = document.documentElement;
1290
+ return (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
1291
+ }
1292
+ }, {
1293
+ key: "scrollLeft",
1294
+ value: function scrollLeft() {
1295
+ var doc = document.documentElement;
1296
+ return (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
1297
+ }
1298
+ }, {
1299
+ key: "offsetTop",
1300
+ value: function offsetTop(el) {
1301
+ return el.getBoundingClientRect().top + window.pageYOffset - document.documentElement.clientTop;
1302
+ }
1303
+ }, {
1304
+ key: "offsetLeft",
1305
+ value: function offsetLeft(el) {
1306
+ return el.getBoundingClientRect().left + window.pageXOffset - document.documentElement.clientLeft;
1307
+ }
1308
+ }, {
1309
+ key: "offsetRight",
1310
+ value: function offsetRight(el) {
1311
+ return el.getBoundingClientRect().left + window.pageXOffset - document.documentElement.clientLeft + el.offsetWidth;
1312
+ }
1313
+ }, {
1314
+ key: "offsetBottom",
1315
+ value: function offsetBottom(el) {
1316
+ return el.getBoundingClientRect().top + window.pageYOffset - document.documentElement.clientTop + el.offsetHeight;
1317
+ }
1318
+ }, {
1319
+ key: "documentHeight",
1320
+ value: function documentHeight() {
1321
+ return Math.max(document.body.offsetHeight, document.body.scrollHeight, document.documentElement.clientHeight, document.documentElement.offsetHeight, document.documentElement.scrollHeight);
1322
+ }
1323
+ }, {
1324
+ key: "documentWidth",
1325
+ value: function documentWidth() {
1326
+ return document.documentElement.clientWidth || document.body.clientWidth;
1327
+ }
1328
+ }, {
1329
+ key: "windowWidth",
1330
+ value: function windowWidth() {
1331
+ return window.innerWidth;
1332
+ }
1333
+ }, {
1334
+ key: "windowHeight",
1335
+ value: function windowHeight() {
1336
+ return window.innerHeight;
1337
+ }
1338
+ }, {
1339
+ key: "windowWidthWithoutScrollbar",
1340
+ value: function windowWidthWithoutScrollbar() {
1341
+ return document.documentElement.clientWidth || document.body.clientWidth;
1342
+ }
1343
+ }, {
1344
+ key: "windowHeightWithoutScrollbar",
1345
+ value: function windowHeightWithoutScrollbar() {
1346
+ return document.documentElement.clientHeight || document.body.clientHeight;
1347
+ }
1348
+ }, {
1349
+ key: "outerWidthWithMargin",
1350
+ value: function outerWidthWithMargin(el) {
1351
+ return el.offsetWidth + parseInt(getComputedStyle(el).marginLeft) + parseInt(getComputedStyle(el).marginRight);
1352
+ }
1353
+ }, {
1354
+ key: "outerHeightWithMargin",
1355
+ value: function outerHeightWithMargin(el) {
1356
+ return el.offsetHeight + parseInt(getComputedStyle(el).marginTop) + parseInt(getComputedStyle(el).marginBottom);
1357
+ }
1358
+ }, {
1359
+ key: "scrollTo",
1360
+ value: function scrollTo(to) {
1361
+ var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1362
+ return new Promise(function (resolve) {
1363
+ if (!hlp.isNumeric(to)) {
1364
+ to = to.getBoundingClientRect().top + window.pageYOffset - document.documentElement.clientTop;
1365
+ }
1366
+
1367
+ var element = document.scrollingElement || document.documentElement,
1368
+ start = element.scrollTop,
1369
+ change = to - start,
1370
+ startDate = +new Date(),
1371
+ // t = current time
1372
+ // b = start value
1373
+ // c = change in value
1374
+ // d = duration
1375
+ easeInOutQuad = function easeInOutQuad(t, b, c, d) {
1376
+ t /= d / 2;
1377
+ if (t < 1) return c / 2 * t * t + b;
1378
+ t--;
1379
+ return -c / 2 * (t * (t - 2) - 1) + b;
1380
+ },
1381
+ easeInOutCirc = function easeInOutCirc(t, b, c, d) {
1382
+ t /= d / 2;
1383
+ if (t < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
1384
+ t -= 2;
1385
+ return c / 2 * (Math.sqrt(1 - t * t) + 1) + b;
1386
+ },
1387
+ animateScroll = function animateScroll() {
1388
+ var currentDate = +new Date();
1389
+ var currentTime = currentDate - startDate;
1390
+ element.scrollTop = parseInt(easeInOutCirc(currentTime, start, change, duration));
1391
+
1392
+ if (currentTime < duration) {
1393
+ requestAnimationFrame(animateScroll);
1394
+ } else {
1395
+ element.scrollTop = to;
1396
+ resolve();
1397
+ }
1398
+ };
1399
+
1400
+ animateScroll();
1401
+ });
1402
+ }
1403
+ }, {
1404
+ key: "loadJs",
1405
+ value: function loadJs(urls) {
1406
+ if (!hlp.isArray(urls)) {
1407
+ urls = [urls];
1408
+ }
1409
+
1410
+ var promises = [];
1411
+ hlp.loop(urls, function (urls__value, urls__key) {
1412
+ promises.push(new Promise(function (resolve, reject) {
1413
+ var script = document.createElement('script');
1414
+ script.src = urls__value;
1415
+
1416
+ script.onload = function () {
1417
+ resolve();
1418
+ };
1419
+
1420
+ document.head.appendChild(script);
1421
+ }));
1422
+ });
1423
+ return Promise.all(promises);
1424
+ }
1425
+ }, {
1426
+ key: "loadJsSequentially",
1427
+ value: function () {
1428
+ var _loadJsSequentially = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(urls) {
1429
+ var _iterator, _step, urls__value;
1430
+
1431
+ return _regenerator.default.wrap(function _callee$(_context) {
1432
+ while (1) {
1433
+ switch (_context.prev = _context.next) {
1434
+ case 0:
1435
+ if (!hlp.isArray(urls)) {
1436
+ urls = [urls];
1437
+ }
1438
+
1439
+ _iterator = _createForOfIteratorHelper(urls);
1440
+ _context.prev = 2;
1441
+
1442
+ _iterator.s();
1443
+
1444
+ case 4:
1445
+ if ((_step = _iterator.n()).done) {
1446
+ _context.next = 10;
1447
+ break;
1448
+ }
1449
+
1450
+ urls__value = _step.value;
1451
+ _context.next = 8;
1452
+ return hlp.loadJs(urls__value);
1453
+
1454
+ case 8:
1455
+ _context.next = 4;
1456
+ break;
1457
+
1458
+ case 10:
1459
+ _context.next = 15;
1460
+ break;
1461
+
1462
+ case 12:
1463
+ _context.prev = 12;
1464
+ _context.t0 = _context["catch"](2);
1465
+
1466
+ _iterator.e(_context.t0);
1467
+
1468
+ case 15:
1469
+ _context.prev = 15;
1470
+
1471
+ _iterator.f();
1472
+
1473
+ return _context.finish(15);
1474
+
1475
+ case 18:
1476
+ return _context.abrupt("return");
1477
+
1478
+ case 19:
1479
+ case "end":
1480
+ return _context.stop();
1481
+ }
1482
+ }
1483
+ }, _callee, null, [[2, 12, 15, 18]]);
1484
+ }));
1485
+
1486
+ function loadJsSequentially(_x) {
1487
+ return _loadJsSequentially.apply(this, arguments);
1488
+ }
1489
+
1490
+ return loadJsSequentially;
1491
+ }()
1492
+ }, {
1493
+ key: "triggerAfterAllImagesLoaded",
1494
+ value: function triggerAfterAllImagesLoaded(selectorContainer, selectorImage, fn) {
1495
+ var _this3 = this;
1496
+
1497
+ window.addEventListener('load', function (e) {
1498
+ if (document.querySelector(selectorContainer + ' ' + selectorImage) !== null) {
1499
+ document.querySelectorAll(selectorContainer + ' ' + selectorImage).forEach(function (el) {
1500
+ _this3.triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn);
1501
+ });
1502
+ }
1503
+ });
1504
+ document.addEventListener('DOMContentLoaded', function () {
1505
+ if (document.querySelector(selectorContainer) !== null) {
1506
+ new MutationObserver(function (mutations) {
1507
+ mutations.forEach(function (mutation) {
1508
+ if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
1509
+ mutation.addedNodes.forEach(function (el) {
1510
+ _this3.triggerAfterAllImagesLoadedHandleEl(el, selectorContainer, selectorImage, fn);
1511
+ });
1512
+ } else if (mutation.type === 'attributes' && mutation.attributeName === 'src' && mutation.target.classList.contains(selectorImage.replace('.', '')) && mutation.oldValue !== mutation.target.getAttribute('src')) {
1513
+ _this3.triggerAfterAllImagesLoadedHandleEl(mutation.target, selectorContainer, selectorImage, fn);
1514
+ }
1515
+ });
1516
+ }).observe(document.querySelector(selectorContainer), {
1517
+ attributes: true,
1518
+ childList: true,
1519
+ characterData: false,
1520
+ subtree: true,
1521
+ attributeOldValue: true,
1522
+ characterDataOldValue: false
1523
+ });
1524
+ }
1525
+ });
1526
+ }
1527
+ }, {
1528
+ key: "triggerAfterAllImagesLoadedHandleEl",
1529
+ value: function triggerAfterAllImagesLoadedHandleEl(el, selectorContainer, selectorImage, fn) {
1530
+ var _this4 = this;
1531
+
1532
+ if (el.nodeType === Node.ELEMENT_NODE) {
1533
+ el.classList.remove('loaded-img');
1534
+ el.closest(selectorContainer).classList.remove('loaded-all'); // only bind if not yet binded
1535
+
1536
+ if (!el.classList.contains('binded-trigger')) {
1537
+ el.classList.add('binded-trigger');
1538
+ el.addEventListener('load', function () {
1539
+ _this4.triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn);
1540
+ });
1541
+ }
1542
+ }
1543
+ }
1544
+ }, {
1545
+ key: "triggerAfterAllImagesLoadedBindLoadEvent",
1546
+ value: function triggerAfterAllImagesLoadedBindLoadEvent(el, selectorContainer, selectorImage, fn) {
1547
+ el.classList.add('loaded-img');
1548
+
1549
+ if (el.closest(selectorContainer).querySelectorAll('.loaded-img').length === el.closest(selectorContainer).querySelectorAll(selectorImage).length) {
1550
+ el.closest(selectorContainer).classList.add('loaded-all');
1551
+ fn();
1552
+ }
1553
+ }
1554
+ }, {
1555
+ key: "isVisible",
1556
+ value: function isVisible(el) {
1557
+ return !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
1558
+ }
1559
+ }, {
1560
+ key: "isVisibleInViewport",
1561
+ value: function isVisibleInViewport(el) {
1562
+ if (!this.isVisible(el)) {
1563
+ return false;
1564
+ }
1565
+
1566
+ var rect = el.getBoundingClientRect();
1567
+ return !(rect.bottom < 0 || rect.right < 0 || rect.left > window.innerWidth || rect.top > window.innerHeight);
1568
+ }
1569
+ }, {
1570
+ key: "textareaAutoHeight",
1571
+ value: function textareaAutoHeight() {
1572
+ var _this5 = this;
1573
+
1574
+ var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'textarea';
1575
+ this.textareaSetHeights(selector);
1576
+ this.onResizeHorizontal(function () {
1577
+ _this5.textareaSetHeights(selector);
1578
+ });
1579
+ [].forEach.call(document.querySelectorAll(selector), function (el) {
1580
+ el.addEventListener('keyup', function (e) {
1581
+ _this5.textareaSetHeight(e.target);
1582
+ });
1583
+ });
1584
+ }
1585
+ }, {
1586
+ key: "textareaSetHeights",
1587
+ value: function textareaSetHeights() {
1588
+ var _this6 = this;
1589
+
1590
+ var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'textarea';
1591
+ [].forEach.call(document.querySelectorAll(selector), function (el) {
1592
+ if (_this6.isVisible(el)) {
1593
+ _this6.textareaSetHeight(el);
1594
+ }
1595
+ });
1596
+ }
1597
+ }, {
1598
+ key: "textareaSetHeight",
1599
+ value: function textareaSetHeight(el) {
1600
+ el.style.height = '5px';
1601
+ el.style.height = el.scrollHeight + 'px';
1602
+ }
1603
+ }, {
1604
+ key: "real100vh",
1605
+ value: function real100vh(selector) {
1606
+ document.querySelector(selector).style.height = window.innerHeight + 'px'; // onResizeHorizontal does not work, we really have to trigger on every resize
1607
+
1608
+ window.addEventListener('resize', function () {
1609
+ document.querySelector(selector).style.height = window.innerHeight + 'px';
1610
+ });
1611
+ }
1612
+ }, {
1613
+ key: "iOsRemoveHover",
1614
+ value: function iOsRemoveHover() {
1615
+ if (hlp.getBrowser() === 'safari' && hlp.getDevice() !== 'desktop') {
1616
+ hlp.on('touchend', 'a', function (e, el) {
1617
+ el.click();
1618
+ });
1619
+ }
1620
+ }
1621
+ }, {
1622
+ key: "isNumeric",
1623
+ value: function isNumeric(n) {
1624
+ return !isNaN(parseFloat(n)) && isFinite(n);
1625
+ }
1626
+ }, {
1627
+ key: "animate",
1628
+ value: function animate(el, from, to, easing, duration) {
1629
+ var _this7 = this;
1630
+
1631
+ return new Promise(function (resolve) {
1632
+ // on durations smaller than 50, the end event does not trigger!
1633
+ if (duration <= 50) {
1634
+ duration = 50;
1635
+ }
1636
+
1637
+ var properties = [];
1638
+ from.split(';').forEach(function (from__value) {
1639
+ properties.push(from__value.split(':')[0].trim());
1640
+ });
1641
+ var transition = [];
1642
+ properties.forEach(function (properties__value) {
1643
+ transition.push(properties__value + ' ' + Math.round(duration / 1000 * 10) / 10 + 's ' + easing);
1644
+ });
1645
+ transition = 'transition: ' + transition.join(', ') + ' !important;';
1646
+ var els = null;
1647
+
1648
+ if (NodeList.prototype.isPrototypeOf(el)) {
1649
+ els = Array.from(el);
1650
+ } else if (el === null) {
1651
+ console.log('cannot animate element from ' + from + ' to ' + to + ' because it does not exist');
1652
+ resolve();
1653
+ } else {
1654
+ els = [el];
1655
+ }
1656
+
1657
+ var toFinish = els.length;
1658
+ els.forEach(function (els__value, els__key) {
1659
+ // add random class
1660
+ var random_class = hlp.random_string(10, 'abcdefghijklmnopqrstuvwxyz');
1661
+ els__value.classList.add(random_class);
1662
+ window.requestAnimationFrame(function () {
1663
+ // set from style inline (don't fully remove previous style)
1664
+ var new_style = [];
1665
+ var prev_style = els__value.getAttribute('style');
1666
+
1667
+ if (prev_style !== null) {
1668
+ prev_style.split(';').forEach(function (prev_style__value) {
1669
+ if (!properties.includes(prev_style__value.split(':')[0].trim())) {
1670
+ new_style.push(prev_style__value);
1671
+ }
1672
+ });
1673
+ }
1674
+
1675
+ new_style = new_style.join(';') + from + ';';
1676
+ els__value.setAttribute('style', new_style);
1677
+ window.requestAnimationFrame(function () {
1678
+ // add transition property
1679
+ var style = document.createElement('style');
1680
+ style.innerHTML = '.' + random_class + ' { ' + transition + ' }';
1681
+ document.head.appendChild(style);
1682
+ window.requestAnimationFrame(function () {
1683
+ // set last style inline
1684
+ els__value.setAttribute('style', els__value.getAttribute('style').replace(from + ';', '') + to + ';');
1685
+
1686
+ if (_this7.isVisible(els__value)) {
1687
+ var fired = false;
1688
+ hlp.addEventListenerOnce(els__value, 'transitionend', function (event) {
1689
+ fired = true; // transitionend fires also, when animating child elements
1690
+ // the following line ensures, that those events do not bubble up
1691
+ // in that case, we return false and ensure, the event listener is still alive
1692
+
1693
+ if (event.target !== event.currentTarget) {
1694
+ return false;
1695
+ } // remove previous styles property
1696
+
1697
+
1698
+ document.head.removeChild(style); // remove random class
1699
+
1700
+ els__value.classList.remove(random_class); // resolve promise when last is finished
1701
+
1702
+ toFinish--;
1703
+
1704
+ if (toFinish <= 0) {
1705
+ window.requestAnimationFrame(function () {
1706
+ resolve();
1707
+ });
1708
+ }
1709
+ }); // safeguard
1710
+ // in some edge cases, transitionend does not fire
1711
+
1712
+ setTimeout(function () {
1713
+ if (fired === false) {
1714
+ document.head.removeChild(style);
1715
+ els__value.classList.remove(random_class);
1716
+ toFinish--;
1717
+
1718
+ if (toFinish <= 0) {
1719
+ resolve();
1720
+ }
1721
+ }
1722
+ }, duration * 1.5);
1723
+ } else {
1724
+ document.head.removeChild(style);
1725
+ els__value.classList.remove(random_class);
1726
+ toFinish--;
1727
+
1728
+ if (toFinish <= 0) {
1729
+ resolve();
1730
+ }
1731
+ }
1732
+ });
1733
+ });
1734
+ });
1735
+ });
1736
+ });
1737
+ }
1738
+ }, {
1739
+ key: "addEventListenerOnce",
1740
+ value: function addEventListenerOnce(target, type, listener, addOptions, removeOptions) {
1741
+ target.addEventListener(type, function fn(event) {
1742
+ var result = listener.apply(this, arguments, addOptions);
1743
+
1744
+ if (result !== false) {
1745
+ target.removeEventListener(type, fn, removeOptions);
1746
+ }
1747
+ });
1748
+ }
1749
+ }, {
1750
+ key: "htmlDecode",
1751
+ value: function htmlDecode(value) {
1752
+ var tmp = document.createElement('textarea');
1753
+ tmp.innerHTML = value;
1754
+ return tmp.value;
1755
+ }
1756
+ }, {
1757
+ key: "htmlEncode",
1758
+ value: function htmlEncode(value) {
1759
+ return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/`/g, '&#96;');
1760
+ }
1761
+ }, {
1762
+ key: "nl2br",
1763
+ value: function nl2br(str) {
1764
+ if (typeof str === 'undefined' || str === null) {
1765
+ return '';
1766
+ }
1767
+
1768
+ var breakTag = '<br/>',
1769
+ replaceStr = '$1' + breakTag;
1770
+ return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, replaceStr);
1771
+ }
1772
+ }, {
1773
+ key: "br2nl",
1774
+ value: function br2nl(str) {
1775
+ if (typeof str === 'undefined' || str === null) {
1776
+ return '';
1777
+ }
1778
+
1779
+ var replaceStr = '\n';
1780
+ return str.replace(/<\s*\/?br\s*[\/]?>/gi, replaceStr);
1781
+ }
1782
+ }, {
1783
+ key: "closest",
1784
+ value: function closest(el, selector) {
1785
+ if (!document.documentElement.contains(el)) {
1786
+ return null;
1787
+ }
1788
+
1789
+ do {
1790
+ if (this.matches(el, selector)) {
1791
+ return el;
1792
+ }
1793
+
1794
+ el = el.parentElement || el.parentNode;
1795
+ } while (el !== null && el.nodeType === 1);
1796
+
1797
+ return null;
1798
+ }
1799
+ }, {
1800
+ key: "matches",
1801
+ value: function matches(el, selector) {
1802
+ var node = el,
1803
+ nodes = (node.parentNode || node.document).querySelectorAll(selector),
1804
+ i = -1;
1805
+
1806
+ while (nodes[++i] && nodes[i] != node) {
1807
+ ;
1808
+ }
1809
+
1810
+ return !!nodes[i];
1811
+ }
1812
+ }, {
1813
+ key: "wrapTextNodes",
1814
+ value: function wrapTextNodes(el, tag) {
1815
+ if (el === null) {
1816
+ return;
1817
+ }
1818
+
1819
+ Array.from(el.childNodes).filter(function (node) {
1820
+ return node.nodeType === 3 && node.textContent.trim().length > 1;
1821
+ }).forEach(function (node) {
1822
+ var wrapper = document.createElement(tag);
1823
+ node.after(wrapper);
1824
+ wrapper.appendChild(node);
1825
+ });
1826
+ }
1827
+ }, {
1828
+ key: "html2dom",
1829
+ value: function html2dom(html) {
1830
+ var template = document.createElement('template');
1831
+ html = html.trim();
1832
+ template.innerHTML = html;
1833
+
1834
+ if (template.content === undefined) {
1835
+ return this.html2domLegacy(html);
1836
+ }
1837
+
1838
+ return template.content.firstChild;
1839
+ }
1840
+ }, {
1841
+ key: "html2domLegacy",
1842
+ value: function html2domLegacy(html) {
1843
+ /* source: https://gist.github.com/Munawwar/6e6362dbdf77c7865a99 */
1844
+ var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
1845
+ rtagName = /<([\w:]+)/,
1846
+ rhtml = /<|&#?\w+;/,
1847
+ wrapMap = {
1848
+ option: [1, "<select multiple='multiple'>", '</select>'],
1849
+ thead: [1, '<table>', '</table>'],
1850
+ col: [2, '<table><colgroup>', '</colgroup></table>'],
1851
+ tr: [2, '<table><tbody>', '</tbody></table>'],
1852
+ td: [3, '<table><tbody><tr>', '</tr></tbody></table>'],
1853
+ _default: [0, '', '']
1854
+ },
1855
+ context = document;
1856
+ var tmp,
1857
+ tag,
1858
+ wrap,
1859
+ j,
1860
+ fragment = context.createDocumentFragment();
1861
+
1862
+ if (!rhtml.test(html)) {
1863
+ fragment.appendChild(context.createTextNode(html));
1864
+ } else {
1865
+ tmp = fragment.appendChild(context.createElement('div'));
1866
+ tag = (rtagName.exec(html) || ['', ''])[1].toLowerCase();
1867
+ wrap = wrapMap[tag] || wrapMap._default;
1868
+ tmp.innerHTML = wrap[1] + html.replace(rxhtmlTag, '<$1></$2>') + wrap[2];
1869
+ j = wrap[0];
1870
+
1871
+ while (j--) {
1872
+ tmp = tmp.lastChild;
1873
+ }
1874
+
1875
+ fragment.removeChild(fragment.firstChild);
1876
+
1877
+ while (tmp.firstChild) {
1878
+ fragment.appendChild(tmp.firstChild);
1879
+ }
1880
+ }
1881
+
1882
+ return fragment.querySelector('*');
1883
+ }
1884
+ }, {
1885
+ key: "prevAll",
1886
+ value: function prevAll(elem, filter) {
1887
+ var sibs = [];
1888
+
1889
+ while (elem = elem.previousElementSibling) {
1890
+ if (filter === undefined || this.matches(elem, filter)) {
1891
+ sibs.push(elem);
1892
+ }
1893
+ }
1894
+
1895
+ return sibs;
1896
+ }
1897
+ }, {
1898
+ key: "nextAll",
1899
+ value: function nextAll(elem, filter) {
1900
+ var sibs = [];
1901
+
1902
+ while (elem = elem.nextElementSibling) {
1903
+ if (filter === undefined || this.matches(elem, filter)) {
1904
+ sibs.push(elem);
1905
+ }
1906
+ }
1907
+
1908
+ return sibs;
1909
+ }
1910
+ }, {
1911
+ key: "siblings",
1912
+ value: function siblings(elem, filter) {
1913
+ var sibs = [];
1914
+ var self = elem;
1915
+ elem = elem.parentNode.firstChild;
1916
+
1917
+ while (elem = elem.nextElementSibling) {
1918
+ if (filter === undefined || this.matches(elem, filter)) {
1919
+ if (self !== elem) {
1920
+ sibs.push(elem);
1921
+ }
1922
+ }
1923
+ }
1924
+
1925
+ return sibs;
1926
+ }
1927
+ }, {
1928
+ key: "parents",
1929
+ value: function parents(elem, selector) {
1930
+ var elements = [];
1931
+ var ishaveselector = selector !== undefined;
1932
+
1933
+ while ((elem = elem.parentElement) !== null) {
1934
+ if (elem.nodeType !== Node.ELEMENT_NODE) {
1935
+ continue;
1936
+ }
1937
+
1938
+ if (!ishaveselector || this.matches(elem, selector)) {
1939
+ elements.push(elem);
1940
+ }
1941
+ }
1942
+
1943
+ return elements;
1944
+ }
1945
+ }, {
1946
+ key: "css",
1947
+ value: function css(el) {
1948
+ var sheets = document.styleSheets,
1949
+ o = {};
1950
+
1951
+ for (var sheets__key in sheets) {
1952
+ try {
1953
+ var rules = sheets[sheets__key].rules || sheets[sheets__key].cssRules;
1954
+
1955
+ for (var rules__key in rules) {
1956
+ if (this.matches(el, rules[rules__key].selectorText)) {
1957
+ o = Object.assign(o, this.css2json(rules[rules__key].style), this.css2json(el.getAttribute('style')));
1958
+ }
1959
+ }
1960
+ } catch (e) {}
1961
+ }
1962
+
1963
+ return o;
1964
+ }
1965
+ }, {
1966
+ key: "css2json",
1967
+ value: function css2json(css) {
1968
+ var obj = {};
1969
+
1970
+ if (!css) {
1971
+ return obj;
1972
+ }
1973
+
1974
+ if (css instanceof CSSStyleDeclaration) {
1975
+ for (var css__key in css) {
1976
+ if (css[css__key].toLowerCase && css[css[css__key]] !== undefined) {
1977
+ obj[css[css__key].toLowerCase()] = css[css[css__key]];
1978
+ }
1979
+ }
1980
+ } else if (typeof css == 'string') {
1981
+ css = css.split(';');
1982
+
1983
+ for (var _css__key in css) {
1984
+ if (css[_css__key].indexOf(':') > -1) {
1985
+ var val = css[_css__key].split(':');
1986
+
1987
+ obj[val[0].toLowerCase().trim()] = val[1].trim();
1988
+ }
1989
+ }
1990
+ }
1991
+
1992
+ return obj;
1993
+ }
1994
+ }, {
1995
+ key: "compareDates",
1996
+ value: function compareDates(d1, d2) {
1997
+ // safari has problems in parsing "2019-01-01 00:00:00"
1998
+ if (typeof d1 === 'string') {
1999
+ d1 = d1.split(' ').join('T');
2000
+ }
2001
+
2002
+ if (typeof d2 === 'string') {
2003
+ d2 = d2.split(' ').join('T');
2004
+ }
2005
+
2006
+ d1 = new Date(d1);
2007
+ d2 = new Date(d2);
2008
+ d1.setHours(0);
2009
+ d1.setMinutes(0);
2010
+ d1.setSeconds(0);
2011
+ d1.setMilliseconds(0);
2012
+ d2.setHours(0);
2013
+ d2.setMinutes(0);
2014
+ d2.setSeconds(0);
2015
+ d2.setMilliseconds(0);
2016
+
2017
+ if (d1.getFullYear() === d2.getFullYear() && d1.getMonth() === d2.getMonth() && d1.getDate() === d2.getDate()) {
2018
+ return 0;
2019
+ }
2020
+
2021
+ if (d1 < d2) {
2022
+ return -1;
2023
+ }
2024
+
2025
+ return 1;
2026
+ }
2027
+ }, {
2028
+ key: "spaceship",
2029
+ value: function spaceship(val1, val2) {
2030
+ if (val1 === null || val2 === null || (0, _typeof2.default)(val1) != (0, _typeof2.default)(val2)) {
2031
+ return null;
2032
+ }
2033
+
2034
+ if (typeof val1 === 'string') {
2035
+ return val1.localeCompare(val2);
2036
+ } else {
2037
+ if (val1 > val2) {
2038
+ return 1;
2039
+ } else if (val1 < val2) {
2040
+ return -1;
2041
+ }
2042
+
2043
+ return 0;
2044
+ }
2045
+ }
2046
+ }, {
2047
+ key: "focus",
2048
+ value: function focus(selector) {
2049
+ hlp.unfocus();
2050
+ var el = document.querySelector(selector);
2051
+
2052
+ if (el !== null) {
2053
+ var mask = document.createElement('div');
2054
+ mask.classList.add('hlp-focus-mask');
2055
+ mask.style.position = 'fixed';
2056
+ mask.style.top = 0;
2057
+ mask.style.bottom = 0;
2058
+ mask.style.left = 0;
2059
+ mask.style.right = 0;
2060
+ mask.style.backgroundColor = 'rgba(0,0,0,0.8)';
2061
+ mask.style.zIndex = 2147483646;
2062
+ el.before(mask);
2063
+ el.setAttribute('data-focussed', 1);
2064
+ el.setAttribute('data-focussed-orig-z-index', el.style.zIndex);
2065
+ el.setAttribute('data-focussed-orig-position', el.style.position);
2066
+ el.setAttribute('data-focussed-orig-background-color', el.style.backgroundColor);
2067
+ el.setAttribute('data-focussed-orig-box-shadow', el.style.boxShadow);
2068
+ el.style.zIndex = 2147483647;
2069
+ el.style.position = 'relative';
2070
+ el.style.backgroundColor = '#ffffff';
2071
+ el.style.boxShadow = '0px 0px 0px 20px #fff';
2072
+ }
2073
+ }
2074
+ }, {
2075
+ key: "unfocus",
2076
+ value: function unfocus() {
2077
+ if (document.querySelector('.hlp-focus-mask') !== null) {
2078
+ document.querySelectorAll('.hlp-focus-mask').forEach(function (el) {
2079
+ hlp.remove(el);
2080
+ });
2081
+ }
2082
+
2083
+ if (document.querySelector('[data-focussed]') !== null) {
2084
+ document.querySelectorAll('[data-focussed]').forEach(function (el) {
2085
+ el.style.zIndex = el.getAttribute('data-focussed-orig-z-index');
2086
+ el.style.position = el.getAttribute('data-focussed-orig-position');
2087
+ el.style.backgroundColor = el.getAttribute('data-focussed-orig-background-color');
2088
+ el.style.boxShadow = el.getAttribute('data-focussed-orig-box-shadow');
2089
+ el.removeAttribute('data-focussed');
2090
+ el.removeAttribute('data-focussed-orig-z-index');
2091
+ el.removeAttribute('data-focussed-orig-position');
2092
+ el.removeAttribute('data-focussed-orig-background-color');
2093
+ el.removeAttribute('data-focussed-orig-box-shadow');
2094
+ });
2095
+ }
2096
+ }
2097
+ }, {
2098
+ key: "remove",
2099
+ value: function remove(el) {
2100
+ if (el !== null) {
2101
+ el.parentNode.removeChild(el);
2102
+ }
2103
+ }
2104
+ }, {
2105
+ key: "on",
2106
+ value: function on(event, selector, scope) {
2107
+ var callback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
2108
+
2109
+ if (callback === null) {
2110
+ callback = scope;
2111
+ scope = document;
2112
+ } else {
2113
+ scope = document.querySelector(scope);
2114
+ }
2115
+
2116
+ scope.addEventListener(event, function (e) {
2117
+ var el = hlp.closest(e.target, selector);
2118
+
2119
+ if (el) {
2120
+ callback(e, el);
2121
+ }
2122
+ }, false);
2123
+ }
2124
+ }, {
2125
+ key: "url",
2126
+ value: function url() {
2127
+ return window.location.protocol + '//' + window.location.host + window.location.pathname;
2128
+ }
2129
+ }, {
2130
+ key: "urlWithHash",
2131
+ value: function urlWithHash() {
2132
+ return window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.hash;
2133
+ }
2134
+ }, {
2135
+ key: "fullUrl",
2136
+ value: function fullUrl() {
2137
+ return window.location.href;
2138
+ }
2139
+ }, {
2140
+ key: "urlWithArgs",
2141
+ value: function urlWithArgs() {
2142
+ return window.location.href.split('#')[0];
2143
+ }
2144
+ }, {
2145
+ key: "baseUrl",
2146
+ value: function baseUrl() {
2147
+ return window.location.protocol + '//' + window.location.host;
2148
+ }
2149
+ }, {
2150
+ key: "urlProtocol",
2151
+ value: function urlProtocol() {
2152
+ return window.location.protocol + '//';
2153
+ }
2154
+ }, {
2155
+ key: "urlHost",
2156
+ value: function urlHost() {
2157
+ return window.location.host;
2158
+ }
2159
+ }, {
2160
+ key: "urlHostTopLevel",
2161
+ value: function urlHostTopLevel() {
2162
+ var host = window.location.host;
2163
+ host = host.split('.');
2164
+
2165
+ while (host.length > 2) {
2166
+ host.shift();
2167
+ }
2168
+
2169
+ host = host.join('.');
2170
+ return host;
2171
+ }
2172
+ }, {
2173
+ key: "urlPath",
2174
+ value: function urlPath() {
2175
+ return window.location.pathname;
2176
+ }
2177
+ }, {
2178
+ key: "urlHash",
2179
+ value: function urlHash() {
2180
+ return window.location.hash;
2181
+ }
2182
+ }, {
2183
+ key: "urlArgs",
2184
+ value: function urlArgs() {
2185
+ return window.location.search;
2186
+ }
2187
+ }, {
2188
+ key: "urlOfScript",
2189
+ value: function urlOfScript() {
2190
+ if (document.currentScript) {
2191
+ return document.currentScript.src;
2192
+ } else {
2193
+ var scripts = document.getElementsByTagName('script');
2194
+ return scripts[scripts.length - 1].src;
2195
+ }
2196
+ }
2197
+ }, {
2198
+ key: "pathOfScript",
2199
+ value: function pathOfScript() {
2200
+ var script = this.urlOfScript(),
2201
+ path = script.substring(0, script.lastIndexOf('/'));
2202
+ return path;
2203
+ }
2204
+ }, {
2205
+ key: "waitUntil",
2206
+ value: function waitUntil(selector) {
2207
+ var css_option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2208
+ var css_value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2209
+ return new Promise(function (resolve, reject) {
2210
+ var timeout = setInterval(function () {
2211
+ if (document.querySelector(selector) !== null && (css_option === null || css_value === null && window.getComputedStyle(document.querySelector(selector))[css_option] !== undefined && window.getComputedStyle(document.querySelector(selector))[css_option] != '' || css_value !== null && window.getComputedStyle(document.querySelector(selector))[css_option] === css_value)) {
2212
+ window.clearInterval(timeout);
2213
+ resolve();
2214
+ }
2215
+ }, 30);
2216
+ });
2217
+ }
2218
+ }, {
2219
+ key: "ready",
2220
+ value: function ready() {
2221
+ return new Promise(function (resolve) {
2222
+ if (document.readyState !== 'loading') {
2223
+ return resolve();
2224
+ } else {
2225
+ document.addEventListener('DOMContentLoaded', function () {
2226
+ return resolve();
2227
+ });
2228
+ }
2229
+ });
2230
+ }
2231
+ }, {
2232
+ key: "load",
2233
+ value: function load() {
2234
+ return new Promise(function (resolve) {
2235
+ if (document.readyState === 'complete') {
2236
+ return resolve();
2237
+ } else {
2238
+ window.addEventListener('load', function () {
2239
+ return resolve();
2240
+ });
2241
+ }
2242
+ });
2243
+ }
2244
+ }, {
2245
+ key: "runForEl",
2246
+ value: function runForEl(selector, callback) {
2247
+ hlp.ready().then(function () {
2248
+ // also run for existing
2249
+ if (document.querySelector(selector) !== null) {
2250
+ document.querySelectorAll(selector).forEach(function (el) {
2251
+ callback(el);
2252
+ });
2253
+ } // setup queue
2254
+
2255
+
2256
+ if (window.runForEl_queue === undefined) {
2257
+ window.runForEl_queue = [];
2258
+ } // setup observer
2259
+
2260
+
2261
+ if (window.runForEl_observer === undefined) {
2262
+ window.runForEl_observer = new MutationObserver(function (mutations) {
2263
+ mutations.forEach(function (mutations__value) {
2264
+ if (!mutations__value.addedNodes) {
2265
+ return;
2266
+ }
2267
+
2268
+ var _loop = function _loop(i) {
2269
+ var node = mutations__value.addedNodes[i];
2270
+
2271
+ if (node.nodeType === Node.ELEMENT_NODE) {
2272
+ window.runForEl_queue.forEach(function (queue__value) {
2273
+ if (node.matches(queue__value.selector)) {
2274
+ queue__value.callback(node);
2275
+ }
2276
+ });
2277
+ }
2278
+ };
2279
+
2280
+ for (var i = 0; i < mutations__value.addedNodes.length; i++) {
2281
+ _loop(i);
2282
+ }
2283
+ });
2284
+ }).observe(document.body, {
2285
+ attributes: false,
2286
+ childList: true,
2287
+ characterData: false,
2288
+ subtree: true,
2289
+ attributeOldValue: false,
2290
+ characterDataOldValue: false
2291
+ });
2292
+ } // push to queue
2293
+
2294
+
2295
+ window.runForEl_queue.push({
2296
+ selector: selector,
2297
+ callback: callback
2298
+ });
2299
+ });
2300
+ }
2301
+ }, {
2302
+ key: "fmath",
2303
+ value: function fmath(op, x, y) {
2304
+ var precision = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 8;
2305
+ var n = {
2306
+ '*': x * y,
2307
+ '-': x - y,
2308
+ '+': x + y,
2309
+ '/': x / y
2310
+ }[op];
2311
+ return Math.round(n * 10 * Math.pow(10, precision)) / (10 * Math.pow(10, precision));
2312
+ }
2313
+ }, {
2314
+ key: "trim",
2315
+ value: function trim(str, charlist) {
2316
+ var whitespace = [' ', '\n', '\r', '\t', '\f', '\x0b', '\xa0', "\u2000", "\u2001", "\u2002", "\u2003", "\u2004", "\u2005", "\u2006", "\u2007", "\u2008", "\u2009", "\u200A", "\u200B", "\u2028", "\u2029", "\u3000"].join('');
2317
+ var l = 0;
2318
+ var i = 0;
2319
+ str += '';
2320
+
2321
+ if (charlist) {
2322
+ whitespace = (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '$1');
2323
+ }
2324
+
2325
+ l = str.length;
2326
+
2327
+ for (i = 0; i < l; i++) {
2328
+ if (whitespace.indexOf(str.charAt(i)) === -1) {
2329
+ str = str.substring(i);
2330
+ break;
2331
+ }
2332
+ }
2333
+
2334
+ l = str.length;
2335
+
2336
+ for (i = l - 1; i >= 0; i--) {
2337
+ if (whitespace.indexOf(str.charAt(i)) === -1) {
2338
+ str = str.substring(0, i + 1);
2339
+ break;
2340
+ }
2341
+ }
2342
+
2343
+ return whitespace.indexOf(str.charAt(0)) === -1 ? str : '';
2344
+ }
2345
+ }, {
2346
+ key: "ltrim",
2347
+ value: function ltrim(str, charlist) {
2348
+ charlist = !charlist ? " \\s\xA0" : (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '$1');
2349
+ var re = new RegExp('^[' + charlist + ']+', 'g');
2350
+ return (str + '').replace(re, '');
2351
+ }
2352
+ }, {
2353
+ key: "rtrim",
2354
+ value: function rtrim(str, charlist) {
2355
+ charlist = !charlist ? " \\s\xA0" : (charlist + '').replace(/([[\]().?/*{}+$^:])/g, '\\$1');
2356
+ var re = new RegExp('[' + charlist + ']+$', 'g');
2357
+ return (str + '').replace(re, '');
2358
+ }
2359
+ }, {
2360
+ key: "pushId",
2361
+ value: function pushId() {
2362
+ /* source https://gist.github.com/mikelehen/3596a30bd69384624c11 */
2363
+ var pushIdData = null; // browser
2364
+
2365
+ if (window !== undefined) {
2366
+ if (window.pushIdDataGlobal === undefined) {
2367
+ window.pushIdDataGlobal = {};
2368
+ }
2369
+
2370
+ pushIdData = window.pushIdDataGlobal;
2371
+ } // node.js
2372
+
2373
+
2374
+ if (global !== undefined) {
2375
+ if (global.pushIdDataGlobal === undefined) {
2376
+ global.pushIdDataGlobal = {};
2377
+ }
2378
+
2379
+ pushIdData = global.pushIdDataGlobal;
2380
+ } // first run
2381
+
2382
+
2383
+ if (hlp.objectsAreEqual(pushIdData, {})) {
2384
+ pushIdData.lastPushTime = 0;
2385
+ pushIdData.lastRandChars = [];
2386
+ pushIdData.PUSH_CHARS = '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
2387
+ }
2388
+
2389
+ var now = new Date().getTime(),
2390
+ duplicateTime = now === pushIdData.lastPushTime;
2391
+ pushIdData.lastPushTime = now;
2392
+ var timeStampChars = new Array(8);
2393
+
2394
+ for (var i = 7; i >= 0; i--) {
2395
+ timeStampChars[i] = pushIdData.PUSH_CHARS.charAt(now % 64);
2396
+ now = Math.floor(now / 64);
2397
+ }
2398
+
2399
+ if (now !== 0) {
2400
+ throw new Error();
2401
+ }
2402
+
2403
+ var id = timeStampChars.join('');
2404
+
2405
+ if (!duplicateTime) {
2406
+ for (i = 0; i < 12; i++) {
2407
+ pushIdData.lastRandChars[i] = Math.floor(Math.random() * 64);
2408
+ }
2409
+ } else {
2410
+ for (i = 11; i >= 0 && pushIdData.lastRandChars[i] === 63; i--) {
2411
+ pushIdData.lastRandChars[i] = 0;
2412
+ }
2413
+
2414
+ pushIdData.lastRandChars[i]++;
2415
+ }
2416
+
2417
+ for (i = 0; i < 12; i++) {
2418
+ id += pushIdData.PUSH_CHARS.charAt(pushIdData.lastRandChars[i]);
2419
+ }
2420
+
2421
+ if (id.length != 20) {
2422
+ throw new Error();
2423
+ }
2424
+
2425
+ return id;
2426
+ }
2427
+ }, {
2428
+ key: "getProp",
2429
+ value: function getProp(obj, desc) {
2430
+ var arr = desc.split('.');
2431
+
2432
+ while (arr.length && (obj = obj[arr.shift()])) {
2433
+ ;
2434
+ }
2435
+
2436
+ return obj;
2437
+ }
2438
+ }, {
2439
+ key: "base64toblob",
2440
+ value: function base64toblob(base64) {
2441
+ var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2442
+ var sliceSize = 512,
2443
+ byteCharacters = atob(base64),
2444
+ byteArrays = [];
2445
+
2446
+ for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
2447
+ var slice = byteCharacters.slice(offset, offset + sliceSize),
2448
+ byteNumbers = new Array(slice.length);
2449
+
2450
+ for (var i = 0; i < slice.length; i++) {
2451
+ byteNumbers[i] = slice.charCodeAt(i);
2452
+ }
2453
+
2454
+ var byteArray = new Uint8Array(byteNumbers);
2455
+ byteArrays.push(byteArray);
2456
+ }
2457
+
2458
+ var blob = new Blob(byteArrays, {
2459
+ type: contentType
2460
+ });
2461
+ return blob;
2462
+ }
2463
+ }, {
2464
+ key: "blobtobase64",
2465
+ value: function blobtobase64(blob) {
2466
+ return new Promise(function (resolve) {
2467
+ var reader = new FileReader();
2468
+
2469
+ reader.onload = function () {
2470
+ var dataUrl = reader.result;
2471
+ var base64 = dataUrl.split(',')[1];
2472
+ resolve(base64);
2473
+ };
2474
+
2475
+ reader.readAsDataURL(blob);
2476
+ });
2477
+ }
2478
+ }, {
2479
+ key: "stringtoblob",
2480
+ value: function stringtoblob(string) {
2481
+ var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2482
+ var blob = new Blob([string], {
2483
+ type: contentType
2484
+ });
2485
+ return blob;
2486
+ }
2487
+ }, {
2488
+ key: "blobtostring",
2489
+ value: function blobtostring(blob) {
2490
+ return new Promise(function (resolve) {
2491
+ var reader = new FileReader();
2492
+
2493
+ reader.onload = function () {
2494
+ resolve(reader.result);
2495
+ };
2496
+
2497
+ reader.readAsText(blob);
2498
+ });
2499
+ }
2500
+ }, {
2501
+ key: "filetobase64",
2502
+ value: function filetobase64(file) {
2503
+ return new Promise(function (resolve, reject) {
2504
+ var reader = new FileReader();
2505
+ reader.readAsDataURL(file);
2506
+
2507
+ reader.onload = function () {
2508
+ return resolve(reader.result.split(',')[1]);
2509
+ };
2510
+
2511
+ reader.onerror = function (error) {
2512
+ return reject(error);
2513
+ };
2514
+ });
2515
+ }
2516
+ }, {
2517
+ key: "blobtofile",
2518
+ value: function blobtofile(blob) {
2519
+ var filename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'file.txt';
2520
+ var file = null;
2521
+
2522
+ try {
2523
+ file = new File([blob], filename);
2524
+ } catch (_unused) {
2525
+ // ie 11
2526
+ file = new Blob([blob], filename);
2527
+ }
2528
+
2529
+ return file;
2530
+ }
2531
+ }, {
2532
+ key: "filetoblob",
2533
+ value: function filetoblob(file) {
2534
+ return new Blob([file]);
2535
+ }
2536
+ }, {
2537
+ key: "base64tofile",
2538
+ value: function base64tofile(base64) {
2539
+ var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2540
+ var filename = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'file.txt';
2541
+ return this.blobtofile(this.base64toblob(base64, contentType), filename);
2542
+ }
2543
+ }, {
2544
+ key: "blobtourl",
2545
+ value: function blobtourl(blob) {
2546
+ return URL.createObjectURL(blob, {
2547
+ type: 'text/plain'
2548
+ });
2549
+ }
2550
+ }, {
2551
+ key: "stringtourl",
2552
+ value: function stringtourl(string) {
2553
+ return this.blobtourl(this.stringtoblob(string));
2554
+ }
2555
+ }, {
2556
+ key: "base64tostring",
2557
+ value: function base64tostring(base64) {
2558
+ return atob(base64);
2559
+ }
2560
+ }, {
2561
+ key: "stringtobase64",
2562
+ value: function stringtobase64(string) {
2563
+ return btoa(string);
2564
+ }
2565
+ }, {
2566
+ key: "base64tourl",
2567
+ value: function base64tourl(base64) {
2568
+ return this.blobtourl(this.base64toblob(base64));
2569
+ }
2570
+ }, {
2571
+ key: "filetourl",
2572
+ value: function filetourl(file) {
2573
+ return this.blobtourl(this.filetoblob(file));
2574
+ }
2575
+ }, {
2576
+ key: "getImageOrientation",
2577
+ value: function getImageOrientation(base64) {
2578
+ var _this8 = this;
2579
+
2580
+ return new Promise(function (resolve, reject) {
2581
+ base64 = base64.replace('data:image/jpeg;base64,', '');
2582
+
2583
+ var file = _this8.base64tofile(base64),
2584
+ reader = new FileReader();
2585
+
2586
+ reader.onload = function (e) {
2587
+ var view = new DataView(e.target.result);
2588
+
2589
+ if (view.getUint16(0, false) != 0xffd8) {
2590
+ resolve(-2);
2591
+ return;
2592
+ }
2593
+
2594
+ var length = view.byteLength,
2595
+ offset = 2;
2596
+
2597
+ while (offset < length) {
2598
+ if (view.getUint16(offset + 2, false) <= 8) {
2599
+ resolve(-1);
2600
+ return;
2601
+ }
2602
+
2603
+ var marker = view.getUint16(offset, false);
2604
+ offset += 2;
2605
+
2606
+ if (marker == 0xffe1) {
2607
+ if (view.getUint32(offset += 2, false) != 0x45786966) {
2608
+ resolve(-1);
2609
+ return;
2610
+ }
2611
+
2612
+ var little = view.getUint16(offset += 6, false) == 0x4949;
2613
+ offset += view.getUint32(offset + 4, little);
2614
+ var tags = view.getUint16(offset, little);
2615
+ offset += 2;
2616
+
2617
+ for (var i = 0; i < tags; i++) {
2618
+ if (view.getUint16(offset + i * 12, little) == 0x0112) {
2619
+ resolve(view.getUint16(offset + i * 12 + 8, little));
2620
+ return;
2621
+ }
2622
+ }
2623
+ } else if ((marker & 0xff00) != 0xff00) {
2624
+ break;
2625
+ } else {
2626
+ offset += view.getUint16(offset, false);
2627
+ }
2628
+ }
2629
+
2630
+ resolve(-1);
2631
+ return;
2632
+ };
2633
+
2634
+ reader.readAsArrayBuffer(file);
2635
+ });
2636
+ }
2637
+ }, {
2638
+ key: "resetImageOrientation",
2639
+ value: function resetImageOrientation(srcBase64, srcOrientation) {
2640
+ return new Promise(function (resolve, reject) {
2641
+ var img = new Image();
2642
+
2643
+ img.onload = function () {
2644
+ var width = img.width,
2645
+ height = img.height,
2646
+ canvas = document.createElement('canvas'),
2647
+ ctx = canvas.getContext('2d');
2648
+
2649
+ if (4 < srcOrientation && srcOrientation < 9) {
2650
+ canvas.width = height;
2651
+ canvas.height = width;
2652
+ } else {
2653
+ canvas.width = width;
2654
+ canvas.height = height;
2655
+ }
2656
+
2657
+ switch (srcOrientation) {
2658
+ case 2:
2659
+ ctx.transform(-1, 0, 0, 1, width, 0);
2660
+ break;
2661
+
2662
+ case 3:
2663
+ ctx.transform(-1, 0, 0, -1, width, height);
2664
+ break;
2665
+
2666
+ case 4:
2667
+ ctx.transform(1, 0, 0, -1, 0, height);
2668
+ break;
2669
+
2670
+ case 5:
2671
+ ctx.transform(0, 1, 1, 0, 0, 0);
2672
+ break;
2673
+
2674
+ case 6:
2675
+ ctx.transform(0, 1, -1, 0, height, 0);
2676
+ break;
2677
+
2678
+ case 7:
2679
+ ctx.transform(0, -1, -1, 0, height, width);
2680
+ break;
2681
+
2682
+ case 8:
2683
+ ctx.transform(0, -1, 1, 0, 0, width);
2684
+ break;
2685
+
2686
+ default:
2687
+ break;
2688
+ }
2689
+
2690
+ ctx.drawImage(img, 0, 0);
2691
+ var base64 = canvas.toDataURL();
2692
+ base64 = 'data:image/jpeg;base64,' + base64.split(',')[1];
2693
+ resolve(base64);
2694
+ return;
2695
+ };
2696
+
2697
+ img.src = srcBase64;
2698
+ });
2699
+ }
2700
+ }, {
2701
+ key: "fixImageOrientation",
2702
+ value: function fixImageOrientation(base64) {
2703
+ var _this9 = this;
2704
+
2705
+ return new Promise(function (resolve, reject) {
2706
+ if (base64.indexOf('data:') === -1) {
2707
+ resolve(base64);
2708
+ return;
2709
+ }
2710
+
2711
+ if (base64.indexOf('data:image/jpeg;base64,') === 0) {
2712
+ base64 = base64.replace('data:image/jpeg;base64,', '');
2713
+ }
2714
+
2715
+ _this9.getImageOrientation(base64).then(function (orientation) {
2716
+ base64 = 'data:image/jpeg;base64,' + base64;
2717
+
2718
+ if (orientation <= 1) {
2719
+ resolve(base64);
2720
+ return;
2721
+ } else {
2722
+ _this9.resetImageOrientation(base64, orientation).then(function (base64_new) {
2723
+ resolve(base64_new);
2724
+ return;
2725
+ });
2726
+ }
2727
+ });
2728
+ });
2729
+ }
2730
+ }, {
2731
+ key: "debounce",
2732
+ value: function debounce(func, wait, immediate) {
2733
+ var timeout;
2734
+ return function () {
2735
+ var context = this,
2736
+ args = arguments;
2737
+
2738
+ var later = function later() {
2739
+ timeout = null;
2740
+ if (!immediate) func.apply(context, args);
2741
+ };
2742
+
2743
+ var callNow = immediate && !timeout;
2744
+ clearTimeout(timeout);
2745
+ timeout = setTimeout(later, wait);
2746
+ if (callNow) func.apply(context, args);
2747
+ };
2748
+ }
2749
+ }, {
2750
+ key: "throttle",
2751
+ value: function throttle(func, wait, options) {
2752
+ var context, args, result;
2753
+ var timeout = null;
2754
+ var previous = 0;
2755
+ if (!options) options = {};
2756
+
2757
+ var later = function later() {
2758
+ previous = options.leading === false ? 0 : Date.now();
2759
+ timeout = null;
2760
+ result = func.apply(context, args);
2761
+ if (!timeout) context = args = null;
2762
+ };
2763
+
2764
+ return function () {
2765
+ var now = Date.now();
2766
+ if (!previous && options.leading === false) previous = now;
2767
+ var remaining = wait - (now - previous);
2768
+ context = this;
2769
+ args = arguments;
2770
+
2771
+ if (remaining <= 0 || remaining > wait) {
2772
+ if (timeout) {
2773
+ clearTimeout(timeout);
2774
+ timeout = null;
2775
+ }
2776
+
2777
+ previous = now;
2778
+ result = func.apply(context, args);
2779
+ if (!timeout) context = args = null;
2780
+ } else if (!timeout && options.trailing !== false) {
2781
+ timeout = setTimeout(later, remaining);
2782
+ }
2783
+
2784
+ return result;
2785
+ };
2786
+ }
2787
+ }, {
2788
+ key: "shuffle",
2789
+ value: function shuffle(array) {
2790
+ var currentIndex = array.length,
2791
+ temporaryValue,
2792
+ randomIndex;
2793
+
2794
+ while (0 !== currentIndex) {
2795
+ randomIndex = Math.floor(Math.random() * currentIndex);
2796
+ currentIndex -= 1;
2797
+ temporaryValue = array[currentIndex];
2798
+ array[currentIndex] = array[randomIndex];
2799
+ array[randomIndex] = temporaryValue;
2800
+ }
2801
+
2802
+ return array;
2803
+ }
2804
+ }, {
2805
+ key: "findRecursiveInObject",
2806
+ value: function findRecursiveInObject(object) {
2807
+ var key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2808
+ var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2809
+ var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
2810
+ var paths = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
2811
+
2812
+ if (object !== null && (0, _typeof2.default)(object) === 'object') {
2813
+ for (var _i = 0, _Object$entries = Object.entries(object); _i < _Object$entries.length; _i++) {
2814
+ var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
2815
+ object__key = _Object$entries$_i[0],
2816
+ object__value = _Object$entries$_i[1];
2817
+
2818
+ if (object__value !== null && (0, _typeof2.default)(object__value) === 'object') {
2819
+ this.findRecursiveInObject(object__value, key, value, (path === '' ? '' : path + '.') + object__key, paths);
2820
+ } else if ((key === null || object__key === key) && (value === null || object__value === value)) {
2821
+ paths.push(path);
2822
+ break; // only take first
2823
+ }
2824
+ }
2825
+ }
2826
+
2827
+ return paths;
2828
+ }
2829
+ }]);
2830
+ return hlp;
2831
+ }();
2832
+ /* expose all functions to window */
2833
+
2834
+
2835
+ exports.default = hlp;
2836
+
2837
+ if (typeof window !== 'undefined') {
2838
+ window.hlp = {};
2839
+ Object.getOwnPropertyNames(hlp).forEach(function (value, key) {
2840
+ if (value === 'length' || value === 'name' || value === 'prototype' || value === 'caller' || value === 'arguments') {
2841
+ return;
2842
+ }
2843
+
2844
+ window.hlp[value] = hlp[value];
2845
+ });
2846
+ }