@stemy/ngx-utils 13.6.9 → 13.6.11

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.
@@ -1,17 +1,17 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, PLATFORM_ID, Injectable, Inject, Optional, Injector, EventEmitter, isDevMode, ErrorHandler, NgZone, Pipe, Directive, Input, Output, HostBinding, HostListener, Component, ContentChildren, ViewChild, ContentChild, APP_INITIALIZER, NgModule } from '@angular/core';
3
3
  import 'reflect-metadata';
4
- import moment from 'moment';
5
- import { first, skipWhile, mergeMap, timeout, map } from 'rxjs/operators';
6
- import { Subject, BehaviorSubject, Observable, Subscription, from, TimeoutError, combineLatest } from 'rxjs';
7
- import { Invokable } from 'invokable';
8
4
  import { __awaiter } from 'tslib';
9
5
  import * as i2 from '@angular/router';
10
6
  import { ActivatedRouteSnapshot, NavigationEnd, DefaultUrlSerializer, UrlTree, UrlSegmentGroup, UrlSegment, UrlSerializer } from '@angular/router';
7
+ import { BehaviorSubject, Observable, Subject, Subscription, from, TimeoutError, combineLatest } from 'rxjs';
8
+ import { skipWhile, first, mergeMap, timeout, map } from 'rxjs/operators';
11
9
  import * as i1$3 from '@angular/common';
12
10
  import { isPlatformBrowser, isPlatformServer, DOCUMENT, APP_BASE_HREF, CommonModule } from '@angular/common';
13
11
  import * as i1 from 'ngx-device-detector';
14
12
  import { DeviceDetectorService } from 'ngx-device-detector';
13
+ import moment from 'moment';
14
+ import { Invokable } from 'invokable';
15
15
  import * as i1$1 from '@angular/common/http';
16
16
  import { HttpClient, HttpHeaders, HttpParams, HttpUrlEncodingCodec, HttpEventType } from '@angular/common/http';
17
17
  import JSON5 from 'json5';
@@ -531,1280 +531,1406 @@ class AjaxRequestHandler {
531
531
  }
532
532
  AjaxRequestHandler.isOverridden = false;
533
533
 
534
- class DateUtils {
535
- static isHoliday(date) {
536
- return moment(date).isoWeekday() > 5;
537
- }
538
- static isBusinessDay(date) {
539
- return moment(date).isoWeekday() < 6;
540
- }
541
- static add(date, amount, unit) {
542
- return moment(date).add(amount, unit).toDate();
534
+ class ArrayUtils {
535
+ static has(arr, ...items) {
536
+ if (!ObjectUtils.isArray(arr) || !ObjectUtils.isArray(items))
537
+ return false;
538
+ for (let i = 0; i < items.length; i++) {
539
+ if (arr.indexOf(items[i]) >= 0)
540
+ return true;
541
+ }
542
+ return false;
543
543
  }
544
- static businessAdd(date, amount, unit, freeDays = []) {
545
- const signal = amount < 0 ? -1 : 1;
546
- const freeMoments = freeDays.map(d => moment(d));
547
- let remaining = Math.abs(amount);
548
- let day = date;
549
- while (remaining) {
550
- day = DateUtils.add(day, signal, unit);
551
- if (DateUtils.isBusinessDay(day) && !freeMoments.some(m => m.isSame(day, "day"))) {
552
- remaining--;
544
+ static match(arr, str) {
545
+ if (!ObjectUtils.isArray(arr) || !ObjectUtils.isString(str))
546
+ return false;
547
+ for (let i = 0; i < arr.length; i++) {
548
+ if (arr[i] instanceof RegExp) {
549
+ const regex = arr[i];
550
+ if (regex.test(str))
551
+ return true;
553
552
  }
554
553
  }
555
- return day;
556
- }
557
- static businessSubtract(date, amount, unit) {
558
- return DateUtils.businessAdd(date, -amount, unit);
554
+ return false;
559
555
  }
560
- }
561
-
562
- class BlurStack {
563
- constructor() {
564
- this.r = 0;
565
- this.g = 0;
566
- this.b = 0;
567
- this.a = 0;
568
- this.next = null;
556
+ static any(arr, cb) {
557
+ if (!ObjectUtils.isArray(arr) || !ObjectUtils.isFunction(cb))
558
+ return false;
559
+ for (let i = 0; i < arr.length; i++) {
560
+ if (cb(arr[i]))
561
+ return true;
562
+ }
563
+ return false;
569
564
  }
570
- }
571
- const mul_table = [
572
- 512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512,
573
- 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512,
574
- 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456,
575
- 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512,
576
- 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328,
577
- 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456,
578
- 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335,
579
- 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512,
580
- 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405,
581
- 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328,
582
- 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271,
583
- 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456,
584
- 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388,
585
- 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335,
586
- 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
587
- 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259
588
- ];
589
- const shg_table = [
590
- 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
591
- 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
592
- 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
593
- 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
594
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
595
- 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
596
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
597
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
598
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
599
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
600
- 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
601
- 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
602
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
603
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
604
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
605
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
606
- ];
607
- class CanvasUtils {
608
- static manipulatePixels(canvas, ctx, colorTransformer) {
609
- const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
610
- const pixels = imgData.data;
611
- for (let i = 0, n = pixels.length; i < n; i += 4) {
612
- const clr = new CanvasColor(pixels[i], pixels[i + 1], pixels[i + 2], pixels[i + 3]);
613
- const greyscale = clr.r * .3 + clr.g * .59 + clr.b * .11;
614
- const color = colorTransformer(clr, greyscale);
615
- pixels[i] = color.r;
616
- pixels[i + 1] = color.g;
617
- pixels[i + 2] = color.b;
618
- pixels[i + 3] = color.a;
565
+ static move(arr, oldIndex, newIndex) {
566
+ if (!ObjectUtils.isArray(arr))
567
+ return [];
568
+ const length = arr.length;
569
+ while (oldIndex < 0) {
570
+ oldIndex += length;
619
571
  }
620
- ctx.putImageData(imgData, 0, 0);
572
+ while (newIndex < 0) {
573
+ newIndex += length;
574
+ }
575
+ if (newIndex >= length) {
576
+ let k = newIndex - length + 1;
577
+ while (k--) {
578
+ arr.push(undefined);
579
+ }
580
+ }
581
+ arr.splice(newIndex, 0, arr.splice(oldIndex, 1)[0]);
582
+ return arr;
621
583
  }
622
- static thresholding(canvas, ctx, threshold = 50, colorTransformer) {
623
- const min = new CanvasColor(0, 0, 0, 255);
624
- const max = new CanvasColor(0, 0, 0, 0);
625
- colorTransformer = ObjectUtils.isFunction(colorTransformer) ? colorTransformer : ((color, limit) => {
626
- return limit ? max : min;
627
- });
628
- CanvasUtils.manipulatePixels(canvas, ctx, (color, greyscale) => {
629
- return colorTransformer(color, greyscale > threshold, greyscale);
630
- });
584
+ static reversed(arr) {
585
+ const result = [];
586
+ if (!ObjectUtils.isArray(arr))
587
+ return result;
588
+ for (let i = arr.length - 1; i >= 0; i--) {
589
+ result.push(arr[i]);
590
+ }
591
+ return result;
631
592
  }
632
- static stackBlur(canvas, ctx, radius = 10) {
633
- if (isNaN(radius) || radius < 1)
634
- return;
635
- radius |= 0;
636
- const top_x = 0;
637
- const top_y = 0;
638
- const width = canvas.width;
639
- const height = canvas.height;
640
- let imageData = null;
641
- try {
642
- try {
643
- imageData = ctx.getImageData(top_x, top_y, width, height);
593
+ static min(arr, cb) {
594
+ if (!ObjectUtils.isArray(arr))
595
+ return null;
596
+ let min = Number.MAX_SAFE_INTEGER;
597
+ let result = null;
598
+ for (let i = 0; i < arr.length; i++) {
599
+ const current = cb(arr[i], i);
600
+ if (current < min || result === null) {
601
+ min = current;
602
+ result = arr[i];
644
603
  }
645
- catch (e) {
646
- // NOTE: this part is supposedly only needed if you want to work with local files
647
- // so it might be okay to remove the whole try/catch block and just use
648
- // imageData = ctx.getImageData( top_x, top_y, width, height );
649
- try {
650
- netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
651
- imageData = ctx.getImageData(top_x, top_y, width, height);
652
- }
653
- catch (e) {
654
- alert("Cannot access local image");
655
- throw new Error("unable to access local image data: " + e);
656
- }
604
+ }
605
+ return result;
606
+ }
607
+ static max(arr, cb) {
608
+ if (!ObjectUtils.isArray(arr))
609
+ return null;
610
+ let max = Number.MIN_SAFE_INTEGER;
611
+ let result = null;
612
+ for (let i = 0; i < arr.length; i++) {
613
+ const current = cb(arr[i], i);
614
+ if (current > max || result === null) {
615
+ max = current;
616
+ result = arr[i];
657
617
  }
658
618
  }
659
- catch (e) {
660
- alert("Cannot access image");
661
- throw new Error("unable to access image data: " + e);
619
+ return result;
620
+ }
621
+ static chunk(arr, size) {
622
+ if (!ObjectUtils.isArray(arr))
623
+ return [];
624
+ size = Math.max(1, size);
625
+ const result = [];
626
+ for (let i = 0; i < arr.length; i += size) {
627
+ result.push(arr.slice(i, i + size));
662
628
  }
663
- const pixels = imageData.data;
664
- let x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
665
- const div = radius + radius + 1;
666
- const widthMinus1 = width - 1;
667
- const heightMinus1 = height - 1;
668
- const radiusPlus1 = radius + 1;
669
- const sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
670
- const stackStart = new BlurStack();
671
- let stackEnd = null;
672
- let stack = stackStart;
673
- for (i = 1; i < div; i++) {
674
- stack = stack.next = new BlurStack();
675
- if (i == radiusPlus1) {
676
- stackEnd = stack;
629
+ return result;
630
+ }
631
+ static unique(arr) {
632
+ if (!ObjectUtils.isArray(arr))
633
+ return [];
634
+ return arr.filter((value, index, self) => {
635
+ return self.indexOf(value) === index;
636
+ });
637
+ }
638
+ }
639
+
640
+ /**
641
+ * Use this service to determine which is the current environment
642
+ */
643
+ class UniversalService {
644
+ constructor(platformId, dds) {
645
+ this.platformId = platformId;
646
+ this.dds = dds;
647
+ const info = this.dds.getDeviceInfo();
648
+ this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST|PostmanRuntime)/gi.test(info.userAgent);
649
+ }
650
+ get isBrowser() {
651
+ return isPlatformBrowser(this.platformId);
652
+ }
653
+ get isServer() {
654
+ return isPlatformServer(this.platformId);
655
+ }
656
+ get deviceInfo() {
657
+ return this.isServer
658
+ ? {
659
+ userAgent: "angular-universal",
660
+ os: "unknown",
661
+ browser: "node",
662
+ device: "node",
663
+ os_version: "unknown",
664
+ browser_version: "unknown",
665
+ deviceType: "unknown",
666
+ orientation: "landscape"
677
667
  }
678
- }
679
- stack.next = stackStart;
680
- let stackIn = null;
681
- let stackOut = null;
682
- yw = yi = 0;
683
- const mul_sum = mul_table[radius];
684
- const shg_sum = shg_table[radius];
685
- for (y = 0; y < height; y++) {
686
- r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;
687
- r_out_sum = radiusPlus1 * (pr = pixels[yi]);
688
- g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
689
- b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
690
- a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
691
- r_sum += sumFactor * pr;
692
- g_sum += sumFactor * pg;
693
- b_sum += sumFactor * pb;
694
- a_sum += sumFactor * pa;
695
- stack = stackStart;
696
- for (i = 0; i < radiusPlus1; i++) {
697
- stack.r = pr;
698
- stack.g = pg;
699
- stack.b = pb;
700
- stack.a = pa;
701
- stack = stack.next;
702
- }
703
- for (i = 1; i < radiusPlus1; i++) {
704
- p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
705
- r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i);
706
- g_sum += (stack.g = (pg = pixels[p + 1])) * rbs;
707
- b_sum += (stack.b = (pb = pixels[p + 2])) * rbs;
708
- a_sum += (stack.a = (pa = pixels[p + 3])) * rbs;
709
- r_in_sum += pr;
710
- g_in_sum += pg;
711
- b_in_sum += pb;
712
- a_in_sum += pa;
713
- stack = stack.next;
714
- }
715
- stackIn = stackStart;
716
- stackOut = stackEnd;
717
- for (x = 0; x < width; x++) {
718
- pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;
719
- if (pa != 0) {
720
- pa = 255 / pa;
721
- pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;
722
- pixels[yi + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
723
- pixels[yi + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
724
- }
725
- else {
726
- pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;
727
- }
728
- r_sum -= r_out_sum;
729
- g_sum -= g_out_sum;
730
- b_sum -= b_out_sum;
731
- a_sum -= a_out_sum;
732
- r_out_sum -= stackIn.r;
733
- g_out_sum -= stackIn.g;
734
- b_out_sum -= stackIn.b;
735
- a_out_sum -= stackIn.a;
736
- p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;
737
- r_in_sum += (stackIn.r = pixels[p]);
738
- g_in_sum += (stackIn.g = pixels[p + 1]);
739
- b_in_sum += (stackIn.b = pixels[p + 2]);
740
- a_in_sum += (stackIn.a = pixels[p + 3]);
741
- r_sum += r_in_sum;
742
- g_sum += g_in_sum;
743
- b_sum += b_in_sum;
744
- a_sum += a_in_sum;
745
- stackIn = stackIn.next;
746
- r_out_sum += (pr = stackOut.r);
747
- g_out_sum += (pg = stackOut.g);
748
- b_out_sum += (pb = stackOut.b);
749
- a_out_sum += (pa = stackOut.a);
750
- r_in_sum -= pr;
751
- g_in_sum -= pg;
752
- b_in_sum -= pb;
753
- a_in_sum -= pa;
754
- stackOut = stackOut.next;
755
- yi += 4;
756
- }
757
- yw += width;
758
- }
759
- for (x = 0; x < width; x++) {
760
- g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;
761
- yi = x << 2;
762
- r_out_sum = radiusPlus1 * (pr = pixels[yi]);
763
- g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
764
- b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
765
- a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
766
- r_sum += sumFactor * pr;
767
- g_sum += sumFactor * pg;
768
- b_sum += sumFactor * pb;
769
- a_sum += sumFactor * pa;
770
- stack = stackStart;
771
- for (i = 0; i < radiusPlus1; i++) {
772
- stack.r = pr;
773
- stack.g = pg;
774
- stack.b = pb;
775
- stack.a = pa;
776
- stack = stack.next;
777
- }
778
- yp = width;
779
- for (i = 1; i <= radius; i++) {
780
- yi = (yp + x) << 2;
781
- r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i);
782
- g_sum += (stack.g = (pg = pixels[yi + 1])) * rbs;
783
- b_sum += (stack.b = (pb = pixels[yi + 2])) * rbs;
784
- a_sum += (stack.a = (pa = pixels[yi + 3])) * rbs;
785
- r_in_sum += pr;
786
- g_in_sum += pg;
787
- b_in_sum += pb;
788
- a_in_sum += pa;
789
- stack = stack.next;
790
- if (i < heightMinus1) {
791
- yp += width;
792
- }
793
- }
794
- yi = x;
795
- stackIn = stackStart;
796
- stackOut = stackEnd;
797
- for (y = 0; y < height; y++) {
798
- p = yi << 2;
799
- pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;
800
- if (pa > 0) {
801
- pa = 255 / pa;
802
- pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;
803
- pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
804
- pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
805
- }
806
- else {
807
- pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;
808
- }
809
- r_sum -= r_out_sum;
810
- g_sum -= g_out_sum;
811
- b_sum -= b_out_sum;
812
- a_sum -= a_out_sum;
813
- r_out_sum -= stackIn.r;
814
- g_out_sum -= stackIn.g;
815
- b_out_sum -= stackIn.b;
816
- a_out_sum -= stackIn.a;
817
- p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2;
818
- r_sum += (r_in_sum += (stackIn.r = pixels[p]));
819
- g_sum += (g_in_sum += (stackIn.g = pixels[p + 1]));
820
- b_sum += (b_in_sum += (stackIn.b = pixels[p + 2]));
821
- a_sum += (a_in_sum += (stackIn.a = pixels[p + 3]));
822
- stackIn = stackIn.next;
823
- r_out_sum += (pr = stackOut.r);
824
- g_out_sum += (pg = stackOut.g);
825
- b_out_sum += (pb = stackOut.b);
826
- a_out_sum += (pa = stackOut.a);
827
- r_in_sum -= pr;
828
- g_in_sum -= pg;
829
- b_in_sum -= pb;
830
- a_in_sum -= pa;
831
- stackOut = stackOut.next;
832
- yi += width;
833
- }
834
- }
835
- ctx.putImageData(imageData, top_x, top_y);
668
+ : this.dds.getDeviceInfo();
836
669
  }
837
- static measureTextFontSize(maxWidth, maxHeight, lines, font, lineHeightPercent = 1.1, canvas) {
838
- const startSize = maxHeight;
839
- const context = canvas.getContext("2d");
840
- if (!canvas) {
841
- canvas = document.createElement("canvas");
842
- document.body.appendChild(canvas);
843
- }
844
- canvas.width = maxWidth + maxHeight;
845
- canvas.height = maxHeight * 2;
846
- let fontSize = CanvasUtils.halveValidateFontSize(startSize, (size) => {
847
- CanvasUtils.setFontProps(context, font, size);
848
- const maxTextLinesWidth = CanvasUtils.getTextWidth(context, lines);
849
- return maxWidth - maxTextLinesWidth;
850
- });
851
- const bitmapHeight = CanvasUtils.getTextBitmapHeight(canvas, context, lines, font, fontSize, lineHeightPercent);
852
- if (bitmapHeight > maxHeight) {
853
- fontSize = CanvasUtils.halveValidateFontSize(fontSize, (size) => {
854
- return maxHeight - CanvasUtils.getTextBitmapHeight(canvas, context, lines, font, size, lineHeightPercent);
855
- });
856
- }
857
- return fontSize;
670
+ get browserName() {
671
+ return (this.dds.browser || "").toLowerCase();
858
672
  }
859
- static drawLines(context, lines, font, size, lineHeightPercent = 1.1, align = "left", baseLine = "top", x = 0, y = 0) {
860
- CanvasUtils.setFontProps(context, font, size, align, baseLine);
861
- for (let i = 0; i < lines.length; i++) {
862
- const line = lines[i];
863
- context.fillText(line, x, y);
864
- if (i < lines.length - 1) {
865
- y += size * lineHeightPercent;
866
- }
867
- }
868
- return y;
673
+ get browserVersion() {
674
+ return this.dds.browser_version;
869
675
  }
870
- static wrapText(context, text, x, y, maxWidth) {
871
- const words = text.split(" ");
872
- const lineHeight = context.measureText("M").width * 1.3;
873
- const lines = [];
874
- let line = "";
875
- for (let n = 0; n < words.length; n++) {
876
- const testLine = line + words[n] + " ";
877
- const metrics = context.measureText(testLine);
878
- const testWidth = metrics.width;
879
- if (testWidth > maxWidth && n > 0) {
880
- lines.push(line);
881
- line = words[n] + " ";
882
- }
883
- else {
884
- line = testLine;
885
- }
886
- }
887
- lines.push(line);
888
- y -= lineHeight * .5 * lines.length;
889
- lines.forEach(l => {
890
- context.fillText(l, x, y);
891
- y += lineHeight;
892
- });
676
+ get isExplorer() {
677
+ return this.checkBrowser("ie");
893
678
  }
894
- static setFontProps(context, font, fontSize, align = "left", baseLine = "top") {
895
- context.font = `${fontSize}px ${font}`;
896
- context.textAlign = align;
897
- context.textBaseline = baseLine;
679
+ get isEdge() {
680
+ return this.checkBrowser("edge");
898
681
  }
899
- static getTextWidth(context, lines) {
900
- let maxWidth = 0;
901
- for (let i = 0; i < lines.length; i++) {
902
- const line = lines[i];
903
- maxWidth = Math.max(maxWidth, context.measureText(line).width);
904
- }
905
- return maxWidth;
682
+ get isChrome() {
683
+ return this.checkBrowser("chrome");
906
684
  }
907
- static getTextBitmapHeight(canvas, context, lines, font, fontSize, lineHeightPercent) {
908
- const width = canvas.width;
909
- const height = canvas.height;
910
- context.clearRect(0, 0, width, height);
911
- const textY = CanvasUtils.drawLines(context, lines, font, fontSize, lineHeightPercent, "left", "top", fontSize * .5, fontSize * .5);
912
- const imageData = context.getImageData(0, 0, width, height);
913
- let textHeight = 0;
914
- yLoop: for (let y = 0; y < height; y++) {
915
- for (let x = 0; x < width; x++) {
916
- const index = (x + y * width) * 4;
917
- if (imageData.data[index + 3] > 0) {
918
- textHeight = y + 1;
919
- continue yLoop;
920
- }
921
- }
922
- }
923
- return Math.max(textHeight, textY + fontSize);
685
+ get isFirefox() {
686
+ return this.checkBrowser("firefox");
924
687
  }
925
- static halveValidateFontSize(startSize, callback) {
926
- let fontSize = startSize;
927
- let lastFontSize = 0;
928
- let direction;
929
- for (let i = 0; i < 20; i++) {
930
- direction = callback(fontSize);
931
- const tempSize = fontSize;
932
- if (direction < 0) {
933
- fontSize = fontSize - (Math.abs(fontSize - lastFontSize) / 2);
934
- }
935
- else {
936
- fontSize = fontSize + (Math.abs(fontSize - lastFontSize) / 2);
937
- }
938
- lastFontSize = tempSize;
939
- if (Math.abs(fontSize - lastFontSize) < 0.1) {
940
- break;
941
- }
942
- }
943
- fontSize = Math.floor(fontSize);
944
- return fontSize;
945
- }
946
- }
947
-
948
- class FileUtils {
949
- static getExtension(file) {
950
- return file ? file.name.substr(file.name.lastIndexOf(".")).toLowerCase() : null;
951
- }
952
- static getName(file) {
953
- return file ? file.name.substr(0, file.name.lastIndexOf(".")) : null;
954
- }
955
- static toFile(blob, fileName) {
956
- const data = blob;
957
- data.lastModifiedDate = new Date();
958
- data.name = fileName.split(/\\|\//g).pop();
959
- return data;
960
- }
961
- static dataToBlob(data) {
962
- const parts = data.split(",");
963
- const byteString = atob(parts[1]);
964
- const mimeString = parts[0].split(":")[1].split(";")[0];
965
- const ab = new ArrayBuffer(byteString.length);
966
- const ia = new Uint8Array(ab);
967
- for (let i = 0; i < byteString.length; i++) {
968
- ia[i] = byteString.charCodeAt(i);
969
- }
970
- return new Blob([ab], { type: mimeString });
688
+ get isSafari() {
689
+ return this.checkBrowser("safari");
971
690
  }
972
- static saveBlob(blob, fileName) {
973
- if (typeof saveAs == "undefined") {
974
- throw Error("FileSaver library is not loaded. Please load it: https://www.npmjs.com/package/file-saver");
975
- }
976
- saveAs(blob, fileName);
691
+ get isTablet() {
692
+ return this.dds.isTablet();
977
693
  }
978
- static saveJson(json, fileName) {
979
- if (!ObjectUtils.isObject(json))
980
- return;
981
- FileUtils.saveBlob(new Blob([JSON.stringify(json, null, 4)]), fileName);
694
+ get isMobile() {
695
+ return this.dds.isMobile();
982
696
  }
983
- static readFileAsText(file) {
984
- return FileUtils.readFile(
985
- // @dynamic
986
- reader => reader.readAsText(file));
697
+ get isDesktop() {
698
+ return this.dds.isDesktop();
987
699
  }
988
- static readFileAsBinaryString(file) {
989
- return FileUtils.readFile(
990
- // @dynamic
991
- reader => reader.readAsBinaryString(file));
700
+ get isCrawler() {
701
+ return this.crawler;
992
702
  }
993
- static readFileAsDataURL(file) {
994
- return FileUtils.readFile(
995
- // @dynamic
996
- reader => reader.readAsDataURL(file));
703
+ checkBrowser(name) {
704
+ return this.browserName.includes(name) || false;
997
705
  }
998
- static readDataFromUrl(http, url) {
999
- return new Promise(
1000
- // @dynamic
1001
- (resolve, reject) => {
1002
- if (!url) {
1003
- reject({
1004
- message: "The url is not specified"
1005
- });
1006
- return;
1007
- }
1008
- if ((/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/g).test(url)) {
1009
- resolve(url);
706
+ }
707
+ UniversalService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService, deps: [{ token: PLATFORM_ID }, { token: i1.DeviceDetectorService }], target: i0.ɵɵFactoryTarget.Injectable });
708
+ UniversalService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService });
709
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService, decorators: [{
710
+ type: Injectable
711
+ }], ctorParameters: function () {
712
+ return [{ type: undefined, decorators: [{
713
+ type: Inject,
714
+ args: [PLATFORM_ID]
715
+ }] }, { type: i1.DeviceDetectorService }];
716
+ } });
717
+
718
+ const emptySnapshot = new ActivatedRouteSnapshot();
719
+ const emptyData = { id: "" };
720
+ const emptyParams = {};
721
+ const emptySegments = [];
722
+ const emptyComponents = [];
723
+ class StateService extends BehaviorSubject {
724
+ constructor(injector, zone, universal, router = null) {
725
+ super(null);
726
+ this.injector = injector;
727
+ this.zone = zone;
728
+ this.universal = universal;
729
+ this.router = router;
730
+ this.handleRouterEvent = (event) => {
731
+ var _a;
732
+ if (!(event instanceof NavigationEnd))
1010
733
  return;
734
+ const routerStateSnapshot = this.router.routerState.snapshot;
735
+ let snapshot = routerStateSnapshot.root;
736
+ let context = (_a = this.contexts) === null || _a === void 0 ? void 0 : _a.getContext("primary");
737
+ let segments = snapshot.url;
738
+ const components = [];
739
+ const snapshots = [];
740
+ while (snapshot) {
741
+ snapshots.push(snapshot);
742
+ segments = segments.concat(snapshot.url);
743
+ if (context) {
744
+ if (context.outlet && context.outlet.isActivated)
745
+ components.push(context.outlet.component);
746
+ context = context.children.getContext("primary");
747
+ }
748
+ snapshot = snapshot.firstChild;
1011
749
  }
1012
- first()(http.get(url, {
1013
- responseType: "blob"
1014
- })).subscribe((blob) => {
1015
- FileUtils.readFileAsDataURL(blob).then(resolve, reject);
1016
- }, reason => {
1017
- if (reason.status > 0)
1018
- reject(reason);
1019
- else
1020
- resolve(url);
1021
- });
1022
- });
750
+ this.comp = components[components.length - 1];
751
+ this.shot = snapshots[snapshots.length - 1];
752
+ this.stateInfo = {
753
+ url: routerStateSnapshot.url,
754
+ segments: segments,
755
+ components: components
756
+ };
757
+ this.next(this.shot);
758
+ };
759
+ if (!this.router)
760
+ return;
761
+ this.globalExtras = {
762
+ queryParamsHandling: "merge"
763
+ };
764
+ this.router.events.subscribe(this.handleRouterEvent);
765
+ this.stateInfo = {
766
+ url: "",
767
+ segments: [],
768
+ components: []
769
+ };
770
+ this.contexts = router.rootContexts;
1023
771
  }
1024
- static readFile(callback) {
1025
- return new Promise(
1026
- // @dynamic
1027
- (resolve, reject) => {
1028
- const reader = new FileReader();
1029
- reader.onload = (event) => resolve(event.target.result);
1030
- reader.onerror = reject;
1031
- callback(reader);
772
+ static toPath(route, params) {
773
+ let path = route.path || "";
774
+ ObjectUtils.iterate(params, (value, key) => {
775
+ path = path.replace(`:${key}`, `${value}`);
1032
776
  });
777
+ return path;
1033
778
  }
1034
- }
1035
-
1036
- class GenericValue extends Subject {
1037
- constructor(value = null) {
1038
- super();
1039
- this._value = value;
1040
- }
1041
- get value() {
1042
- return this._value;
1043
- }
1044
- set value(value) {
1045
- if (value == this._value)
1046
- return;
1047
- this._value = value;
1048
- this.next(value);
779
+ get component() {
780
+ return this.comp;
1049
781
  }
1050
- setJustValue(value) {
1051
- this._value = value;
782
+ get snapshot() {
783
+ return this.shot || emptySnapshot;
1052
784
  }
1053
- }
1054
-
1055
- class FileSystemEntry {
1056
- constructor(label, meta, image, data, parent, openCb) {
1057
- this.label = label;
1058
- this.meta = meta;
1059
- this.image = image;
1060
- this.data = data;
1061
- this.parent = parent;
1062
- this.openCb = openCb;
1063
- this.path = !parent ? [this] : parent.path.concat([this]);
1064
- this.level = this.path.length - 1;
1065
- this.classes = this.path
1066
- .filter(t => typeof t.data === "string" && t.data.length > 0).map(t => t.data)
1067
- .concat([`level-${this.level}`]);
785
+ get route() {
786
+ return this.snapshot.routeConfig;
1068
787
  }
1069
- open() {
1070
- this.result = this.result || this.openCb(this.data, this);
1071
- this.result.then(res => {
1072
- if (Array.isArray(res))
1073
- return;
1074
- this.result = null;
1075
- });
1076
- return this.result;
788
+ get data() {
789
+ return this.snapshot.data || emptyData;
1077
790
  }
1078
- }
1079
-
1080
- class Rect {
1081
- constructor(x, y, width, height, rotation = 0) {
1082
- this.x = x;
1083
- this.y = y;
1084
- this.width = width;
1085
- this.height = height;
1086
- this.rotation = rotation;
791
+ get params() {
792
+ return this.snapshot.params || emptyParams;
1087
793
  }
1088
- get center() {
1089
- return new Point(this.x, this.y);
794
+ get queryParams() {
795
+ return this.snapshot.queryParams || emptyParams;
1090
796
  }
1091
- get left() {
1092
- return this.x - this.width * .5;
797
+ get url() {
798
+ return this.stateInfo.url || "";
1093
799
  }
1094
- get right() {
1095
- return this.x + this.width * .5;
800
+ get urlSegments() {
801
+ return this.stateInfo.segments || emptySegments;
1096
802
  }
1097
- get bottom() {
1098
- return this.y - this.height * .5;
803
+ get components() {
804
+ return this.stateInfo.components || emptyComponents;
1099
805
  }
1100
- get top() {
1101
- return this.y + this.height * .5;
806
+ get routerConfig() {
807
+ return this.router.config;
1102
808
  }
1103
- distance(p) {
1104
- p = p.rotateAround(this.center, -this.rotation);
1105
- const x = Math.max(this.left - p.x, 0, p.x - this.right);
1106
- const y = Math.max(this.bottom - p.y, 0, p.y - this.top);
1107
- return Math.sqrt(x * x + y * y);
1108
- }
1109
- }
1110
- class Circle {
1111
- constructor(x, y, radius) {
1112
- this.x = x;
1113
- this.y = y;
1114
- this.radius = radius;
1115
- }
1116
- get center() {
1117
- return new Point(this.x, this.y);
809
+ reload() {
810
+ return __awaiter(this, void 0, void 0, function* () {
811
+ const routerStateSnapshot = this.router.routerState.snapshot;
812
+ const resolvers = this.route.resolve || {};
813
+ const keys = Object.keys(resolvers);
814
+ for (const key of keys) {
815
+ const resolver = this.injector.get(resolvers[key]);
816
+ let resolved = resolver.resolve(this.snapshot, routerStateSnapshot);
817
+ if (resolved instanceof Observable) {
818
+ resolved = resolved.toPromise();
819
+ }
820
+ if (resolved instanceof Promise) {
821
+ resolved = yield resolved;
822
+ }
823
+ this.data[key] = resolved;
824
+ }
825
+ });
1118
826
  }
1119
- get left() {
1120
- return new Point(this.x - this.radius, this.y);
827
+ navigateByUrl(url, navigationExtras = {}) {
828
+ return __awaiter(this, void 0, void 0, function* () {
829
+ return this.navigate(url, navigationExtras);
830
+ });
1121
831
  }
1122
- get right() {
1123
- return new Point(this.x + this.radius, this.y);
832
+ navigate(url, navigationExtras = {}) {
833
+ return __awaiter(this, void 0, void 0, function* () {
834
+ if (!this.router)
835
+ return false;
836
+ const [tree, extras] = this.createUrlTree(url, navigationExtras);
837
+ return this.zone.run(() => {
838
+ return this.router.navigateByUrl(tree, extras);
839
+ });
840
+ });
1124
841
  }
1125
- get top() {
1126
- return new Point(this.x, this.y + this.radius);
842
+ open(url, target = "_blank", navigationExtras = {}) {
843
+ return __awaiter(this, void 0, void 0, function* () {
844
+ if (!this.router)
845
+ return false;
846
+ const [tree, extras] = this.createUrlTree(url, navigationExtras);
847
+ return this.zone.run(() => {
848
+ return this.openInNewWindow(tree, target) || this.router.navigateByUrl(tree, extras);
849
+ });
850
+ });
1127
851
  }
1128
- get bottom() {
1129
- return new Point(this.x, this.y - this.radius);
852
+ subscribeImmediately(next, error, complete) {
853
+ return this.pipe(skipWhile(v => v == null)).subscribe(next, error, complete);
1130
854
  }
1131
- get rect() {
1132
- return new Rect(this.x, this.y, this.radius * 2, this.radius * 2);
855
+ openInNewWindow(tree, target) {
856
+ if (!this.universal.isBrowser)
857
+ return false;
858
+ const baseUrl = window.location.href.replace(this.router.url, "");
859
+ try {
860
+ const serialized = this.router.serializeUrl(tree);
861
+ const separator = serialized.startsWith("/") ? "" : "/";
862
+ window.open(baseUrl + separator + serialized, target);
863
+ return true;
864
+ }
865
+ catch (e) {
866
+ console.log(`Can't open new window: ${e}`);
867
+ return false;
868
+ }
1133
869
  }
1134
- distance(p) {
1135
- return this.center.distance(p) - this.radius;
870
+ createUrlTree(url, extras) {
871
+ if (!this.router)
872
+ return null;
873
+ extras = Object.assign(extras, this.globalExtras, extras || {});
874
+ if (ObjectUtils.isArray(url)) {
875
+ return [this.router.createUrlTree(url, extras), extras];
876
+ }
877
+ if (ObjectUtils.isString(url)) {
878
+ return [this.router.parseUrl(url), extras];
879
+ }
880
+ return [url, extras];
1136
881
  }
1137
882
  }
1138
- class Point {
1139
- constructor(x, y) {
1140
- this.x = x;
1141
- this.y = y;
1142
- }
1143
- get length() {
1144
- return this.distance(Point.Zero);
1145
- }
1146
- get perpendicular() {
1147
- return new Point(this.y, -this.x);
1148
- }
1149
- add(p) {
1150
- return new Point(this.x + p.x, this.y + p.y);
883
+ StateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: UniversalService }, { token: i2.Router, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
884
+ StateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService });
885
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService, decorators: [{
886
+ type: Injectable
887
+ }], ctorParameters: function () {
888
+ return [{ type: i0.Injector }, { type: i0.NgZone }, { type: UniversalService }, { type: i2.Router, decorators: [{
889
+ type: Optional
890
+ }] }];
891
+ } });
892
+
893
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
894
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
895
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
896
+ r = Reflect.decorate(decorators, target, key, desc);
897
+ else
898
+ for (var i = decorators.length - 1; i >= 0; i--)
899
+ if (d = decorators[i])
900
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
901
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
902
+ };
903
+ var __metadata = (this && this.__metadata) || function (k, v) {
904
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
905
+ return Reflect.metadata(k, v);
906
+ };
907
+ class AuthGuard {
908
+ constructor(injector, state, auth) {
909
+ this.injector = injector;
910
+ this.state = state;
911
+ this.auth = auth;
1151
912
  }
1152
- subtract(p) {
1153
- return new Point(this.x - p.x, this.y - p.y);
913
+ static guardAuthenticated(auth) {
914
+ return Promise.resolve(auth.isAuthenticated);
1154
915
  }
1155
- multiply(p) {
1156
- if (p instanceof Point) {
1157
- return new Point(this.x * p.x, this.y * p.y);
1158
- }
1159
- return new Point(this.x * p, this.y * p);
916
+ static guardNotAuthenticated(auth) {
917
+ return Promise.resolve(!auth.isAuthenticated);
1160
918
  }
1161
- distance(b) {
1162
- const x = b.x - this.x;
1163
- const y = b.y - this.y;
1164
- return Math.sqrt(x * x + y * y);
919
+ static guardNothing() {
920
+ return Promise.resolve(true);
1165
921
  }
1166
- lerp(p, ratio) {
1167
- const diff = p.subtract(this);
1168
- return this.add(diff.multiply(ratio));
922
+ static guardAuthField(auth, expression = `auth.isAuthenticated`) {
923
+ // @dynamic
924
+ const lambda = () => {
925
+ return Promise.resolve(ObjectUtils.evaluate(expression, { auth }));
926
+ };
927
+ return lambda;
1169
928
  }
1170
- perpendicularTo(p, length) {
1171
- const diff = p.perpendicular.subtract(this.perpendicular);
1172
- const ratio = length / diff.length;
1173
- const center = this.lerp(p, .5);
1174
- return center.add(diff.multiply(ratio));
929
+ static guardStateField(state, expression = `state.data`) {
930
+ // @dynamic
931
+ const lambda = () => {
932
+ return Promise.resolve(ObjectUtils.evaluate(expression, { state }));
933
+ };
934
+ return lambda;
1175
935
  }
1176
- circleWith(a, b) {
1177
- const yDelta_a = b.y - a.y;
1178
- const xDelta_a = b.x - a.x;
1179
- const yDelta_b = this.y - b.y;
1180
- const xDelta_b = this.x - b.x;
1181
- const aSlope = yDelta_a / xDelta_a;
1182
- const bSlope = yDelta_b / xDelta_b;
1183
- const x = (aSlope * bSlope * (a.y - this.y) + bSlope * (a.x + b.x) - aSlope * (b.x + this.x)) / (2 * (bSlope - aSlope));
1184
- const y = -1 * (x - (a.x + b.x) / 2) / aSlope + (a.y + b.y) / 2;
1185
- const center = new Point(x, y);
1186
- return new Circle(center.x, center.y, center.distance(this));
936
+ static guardAuthStateField(auth, state, expression = `auth.isAuthenticated`) {
937
+ // @dynamic
938
+ const lambda = () => {
939
+ return Promise.resolve(ObjectUtils.evaluate(expression, { auth, state }));
940
+ };
941
+ return lambda;
1187
942
  }
1188
- tangents(c) {
1189
- const pd = c.center.subtract(this);
1190
- const a = Math.asin(c.radius / pd.length);
1191
- const b = Math.atan2(pd.y, pd.x);
1192
- // Tangent points
1193
- let t = b - a;
1194
- const t1 = new Point(c.x + c.radius * Math.sin(t), c.y + c.radius * -Math.cos(t));
1195
- t = b + a;
1196
- const t2 = new Point(c.x + c.radius * -Math.sin(t), c.y + c.radius * Math.cos(t));
1197
- return [t1, t2];
943
+ static wildRouteMatch(segments) {
944
+ return { consumed: segments };
1198
945
  }
1199
- angle(p) {
1200
- const diff = p.subtract(this);
1201
- return Math.atan2(diff.y, diff.x) * 180 / Math.PI;
946
+ static noRouteMatch() {
947
+ return null;
1202
948
  }
1203
- rotateAround(p, angle) {
1204
- const rotation = (p.angle(this) + angle) * Math.PI / 180;
1205
- const distance = p.distance(this);
1206
- const rotated = new Point(Math.cos(rotation) * distance, Math.sin(rotation) * distance);
1207
- return p.add(rotated);
949
+ checkRouteMenu(route) {
950
+ if (!route.data || !route.data.name)
951
+ return Promise.resolve(false);
952
+ return this.checkRoute(route);
1208
953
  }
1209
- }
1210
- Point.Zero = new Point(0, 0);
1211
-
1212
- class Initializer {
1213
- constructor(callback, shouldInit = true) {
1214
- this.callback = callback;
1215
- this.shouldInit = shouldInit;
1216
- this.initialized = !this.shouldInit;
1217
- // @ts-ignore
1218
- return Invokable.create(this);
954
+ checkRoute(route, next) {
955
+ const routeData = route.data || {};
956
+ if (!routeData.guards)
957
+ return Promise.resolve(!route.canActivate || this.auth.isAuthenticated);
958
+ return new Promise(resolve => {
959
+ const guards = routeData.guards.map(g => {
960
+ const guard = ReflectUtils.resolve(g, this.injector);
961
+ return guard(this.auth, route, next);
962
+ });
963
+ Promise.all(guards).then(results => {
964
+ resolve(results.indexOf(false) < 0);
965
+ });
966
+ });
1219
967
  }
1220
- get isInitialized() {
1221
- return this.initialized;
968
+ canActivate(next, state) {
969
+ const route = next.routeConfig;
970
+ return new Promise(resolve => {
971
+ this.auth.checkAuthenticated().then(() => {
972
+ this.checkRoute(route, next).then(hasRights => {
973
+ resolve(hasRights);
974
+ if (!hasRights) {
975
+ this.getReturnState(route).then(returnState => {
976
+ if (!returnState)
977
+ return;
978
+ this.state.navigate(returnState, { queryParams: next.queryParams });
979
+ });
980
+ }
981
+ });
982
+ });
983
+ });
1222
984
  }
1223
- [Invokable.call]() {
1224
- if (this.initialized)
985
+ getConfig(route, config, path) {
986
+ if (!config)
1225
987
  return null;
1226
- this.initialized = true;
1227
- return this.callback();
988
+ const match = config.findIndex(t => t == route);
989
+ if (match >= 0)
990
+ return config;
991
+ for (const subConfig of config) {
992
+ if (subConfig.path)
993
+ path.push(subConfig.path);
994
+ const loadedChildren = (subConfig["_loadedConfig"] || { routes: null }).routes || subConfig["_loadedRoutes"];
995
+ const match = this.getConfig(route, subConfig.children || loadedChildren, path);
996
+ if (!match) {
997
+ if (subConfig.path)
998
+ path.length -= 1;
999
+ continue;
1000
+ }
1001
+ return match;
1002
+ }
1003
+ return null;
1004
+ }
1005
+ getReturnState(route) {
1006
+ if (!route)
1007
+ return Promise.resolve(null);
1008
+ if (ObjectUtils.isObject(route.data) && ObjectUtils.isArray(route.data.returnState)) {
1009
+ return Promise.resolve(route.data.returnState);
1010
+ }
1011
+ const path = [];
1012
+ const config = this.getConfig(route, this.state.routerConfig, path);
1013
+ return new Promise(resolve => {
1014
+ this.getReturnStateRecursive(config).then(rs => {
1015
+ if (!ObjectUtils.isArray(rs)) {
1016
+ resolve(rs);
1017
+ return;
1018
+ }
1019
+ resolve(path.concat(rs));
1020
+ });
1021
+ });
1228
1022
  }
1023
+ getReturnStateRecursive(config, c = 0) {
1024
+ if (!config || c >= config.length)
1025
+ return Promise.resolve(null);
1026
+ return new Promise(resolve => {
1027
+ const route = config[c];
1028
+ const check = !route.component ? Promise.resolve(false) : this.checkRoute(route);
1029
+ check.then(res => {
1030
+ if (res) {
1031
+ resolve([route.path]);
1032
+ return;
1033
+ }
1034
+ this.getReturnStateRecursive(config, c + 1).then(resolve);
1035
+ });
1036
+ });
1037
+ }
1038
+ }
1039
+ AuthGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard, deps: [{ token: Injector }, { token: StateService }, { token: AUTH_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable });
1040
+ AuthGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard });
1041
+ __decorate([
1042
+ FactoryDependencies(AUTH_SERVICE),
1043
+ __metadata("design:type", Function),
1044
+ __metadata("design:paramtypes", [Object, String]),
1045
+ __metadata("design:returntype", Function)
1046
+ ], AuthGuard, "guardAuthField", null);
1047
+ __decorate([
1048
+ FactoryDependencies(StateService),
1049
+ __metadata("design:type", Function),
1050
+ __metadata("design:paramtypes", [StateService, String]),
1051
+ __metadata("design:returntype", Function)
1052
+ ], AuthGuard, "guardStateField", null);
1053
+ __decorate([
1054
+ FactoryDependencies(AUTH_SERVICE, StateService),
1055
+ __metadata("design:type", Function),
1056
+ __metadata("design:paramtypes", [Object, StateService, String]),
1057
+ __metadata("design:returntype", Function)
1058
+ ], AuthGuard, "guardAuthStateField", null);
1059
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard, decorators: [{
1060
+ type: Injectable
1061
+ }], ctorParameters: function () {
1062
+ return [{ type: i0.Injector, decorators: [{
1063
+ type: Inject,
1064
+ args: [Injector]
1065
+ }] }, { type: StateService, decorators: [{
1066
+ type: Inject,
1067
+ args: [StateService]
1068
+ }] }, { type: undefined, decorators: [{
1069
+ type: Inject,
1070
+ args: [AUTH_SERVICE]
1071
+ }] }];
1072
+ } });
1073
+
1074
+ function cachedFactory(types) {
1075
+ let cached = null;
1076
+ return (injector) => {
1077
+ if (cached !== null) {
1078
+ return cached;
1079
+ }
1080
+ const subInjector = Injector.create({
1081
+ providers: types.map(type => {
1082
+ return {
1083
+ provide: type,
1084
+ useClass: type,
1085
+ };
1086
+ }),
1087
+ parent: injector
1088
+ });
1089
+ cached = types.map(type => subInjector.get(type));
1090
+ return cached;
1091
+ };
1229
1092
  }
1230
1093
 
1231
- class JSONfn {
1232
- static parse(text) {
1233
- return JSON.parse(text, JSONfn.reviver);
1094
+ class BlurStack {
1095
+ constructor() {
1096
+ this.r = 0;
1097
+ this.g = 0;
1098
+ this.b = 0;
1099
+ this.a = 0;
1100
+ this.next = null;
1234
1101
  }
1235
- static stringify(obj) {
1236
- return JSON.stringify(obj, JSONfn.replacer);
1102
+ }
1103
+ const mul_table = [
1104
+ 512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512,
1105
+ 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512,
1106
+ 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456,
1107
+ 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512,
1108
+ 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328,
1109
+ 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456,
1110
+ 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335,
1111
+ 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512,
1112
+ 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405,
1113
+ 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328,
1114
+ 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271,
1115
+ 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456,
1116
+ 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388,
1117
+ 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335,
1118
+ 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
1119
+ 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259
1120
+ ];
1121
+ const shg_table = [
1122
+ 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
1123
+ 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
1124
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
1125
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
1126
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
1127
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
1128
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
1129
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
1130
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1131
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1132
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1133
+ 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1134
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1135
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1136
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1137
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
1138
+ ];
1139
+ class CanvasUtils {
1140
+ static manipulatePixels(canvas, ctx, colorTransformer) {
1141
+ const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
1142
+ const pixels = imgData.data;
1143
+ for (let i = 0, n = pixels.length; i < n; i += 4) {
1144
+ const clr = new CanvasColor(pixels[i], pixels[i + 1], pixels[i + 2], pixels[i + 3]);
1145
+ const greyscale = clr.r * .3 + clr.g * .59 + clr.b * .11;
1146
+ const color = colorTransformer(clr, greyscale);
1147
+ pixels[i] = color.r;
1148
+ pixels[i + 1] = color.g;
1149
+ pixels[i + 2] = color.b;
1150
+ pixels[i + 3] = color.a;
1151
+ }
1152
+ ctx.putImageData(imgData, 0, 0);
1237
1153
  }
1238
- static reviver(key, value) {
1239
- const iso8061 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:.\d+)?(?:Z|[+-]\d\d:\d\d)$/;
1240
- if (typeof value !== "string")
1241
- return value;
1242
- if (value.length < 8) {
1243
- return value;
1154
+ static thresholding(canvas, ctx, threshold = 50, colorTransformer) {
1155
+ const min = new CanvasColor(0, 0, 0, 255);
1156
+ const max = new CanvasColor(0, 0, 0, 0);
1157
+ colorTransformer = ObjectUtils.isFunction(colorTransformer) ? colorTransformer : ((color, limit) => {
1158
+ return limit ? max : min;
1159
+ });
1160
+ CanvasUtils.manipulatePixels(canvas, ctx, (color, greyscale) => {
1161
+ return colorTransformer(color, greyscale > threshold, greyscale);
1162
+ });
1163
+ }
1164
+ static stackBlur(canvas, ctx, radius = 10) {
1165
+ if (isNaN(radius) || radius < 1)
1166
+ return;
1167
+ radius |= 0;
1168
+ const top_x = 0;
1169
+ const top_y = 0;
1170
+ const width = canvas.width;
1171
+ const height = canvas.height;
1172
+ let imageData = null;
1173
+ try {
1174
+ try {
1175
+ imageData = ctx.getImageData(top_x, top_y, width, height);
1176
+ }
1177
+ catch (e) {
1178
+ // NOTE: this part is supposedly only needed if you want to work with local files
1179
+ // so it might be okay to remove the whole try/catch block and just use
1180
+ // imageData = ctx.getImageData( top_x, top_y, width, height );
1181
+ try {
1182
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
1183
+ imageData = ctx.getImageData(top_x, top_y, width, height);
1184
+ }
1185
+ catch (e) {
1186
+ alert("Cannot access local image");
1187
+ throw new Error("unable to access local image data: " + e);
1188
+ }
1189
+ }
1244
1190
  }
1245
- if (value.match(iso8061)) {
1246
- return new Date(value);
1191
+ catch (e) {
1192
+ alert("Cannot access image");
1193
+ throw new Error("unable to access image data: " + e);
1247
1194
  }
1248
- const prefix = value.substring(0, 8);
1249
- if (prefix === "function") {
1250
- return new Function(`return ${value}`)();
1195
+ const pixels = imageData.data;
1196
+ let x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
1197
+ const div = radius + radius + 1;
1198
+ const widthMinus1 = width - 1;
1199
+ const heightMinus1 = height - 1;
1200
+ const radiusPlus1 = radius + 1;
1201
+ const sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;
1202
+ const stackStart = new BlurStack();
1203
+ let stackEnd = null;
1204
+ let stack = stackStart;
1205
+ for (i = 1; i < div; i++) {
1206
+ stack = stack.next = new BlurStack();
1207
+ if (i == radiusPlus1) {
1208
+ stackEnd = stack;
1209
+ }
1251
1210
  }
1252
- if (prefix === "_NuFrRa_") {
1253
- return new Function(`return ${value.slice(8)}`)();
1211
+ stack.next = stackStart;
1212
+ let stackIn = null;
1213
+ let stackOut = null;
1214
+ yw = yi = 0;
1215
+ const mul_sum = mul_table[radius];
1216
+ const shg_sum = shg_table[radius];
1217
+ for (y = 0; y < height; y++) {
1218
+ r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;
1219
+ r_out_sum = radiusPlus1 * (pr = pixels[yi]);
1220
+ g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
1221
+ b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
1222
+ a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
1223
+ r_sum += sumFactor * pr;
1224
+ g_sum += sumFactor * pg;
1225
+ b_sum += sumFactor * pb;
1226
+ a_sum += sumFactor * pa;
1227
+ stack = stackStart;
1228
+ for (i = 0; i < radiusPlus1; i++) {
1229
+ stack.r = pr;
1230
+ stack.g = pg;
1231
+ stack.b = pb;
1232
+ stack.a = pa;
1233
+ stack = stack.next;
1234
+ }
1235
+ for (i = 1; i < radiusPlus1; i++) {
1236
+ p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
1237
+ r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i);
1238
+ g_sum += (stack.g = (pg = pixels[p + 1])) * rbs;
1239
+ b_sum += (stack.b = (pb = pixels[p + 2])) * rbs;
1240
+ a_sum += (stack.a = (pa = pixels[p + 3])) * rbs;
1241
+ r_in_sum += pr;
1242
+ g_in_sum += pg;
1243
+ b_in_sum += pb;
1244
+ a_in_sum += pa;
1245
+ stack = stack.next;
1246
+ }
1247
+ stackIn = stackStart;
1248
+ stackOut = stackEnd;
1249
+ for (x = 0; x < width; x++) {
1250
+ pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;
1251
+ if (pa != 0) {
1252
+ pa = 255 / pa;
1253
+ pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;
1254
+ pixels[yi + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
1255
+ pixels[yi + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
1256
+ }
1257
+ else {
1258
+ pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;
1259
+ }
1260
+ r_sum -= r_out_sum;
1261
+ g_sum -= g_out_sum;
1262
+ b_sum -= b_out_sum;
1263
+ a_sum -= a_out_sum;
1264
+ r_out_sum -= stackIn.r;
1265
+ g_out_sum -= stackIn.g;
1266
+ b_out_sum -= stackIn.b;
1267
+ a_out_sum -= stackIn.a;
1268
+ p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;
1269
+ r_in_sum += (stackIn.r = pixels[p]);
1270
+ g_in_sum += (stackIn.g = pixels[p + 1]);
1271
+ b_in_sum += (stackIn.b = pixels[p + 2]);
1272
+ a_in_sum += (stackIn.a = pixels[p + 3]);
1273
+ r_sum += r_in_sum;
1274
+ g_sum += g_in_sum;
1275
+ b_sum += b_in_sum;
1276
+ a_sum += a_in_sum;
1277
+ stackIn = stackIn.next;
1278
+ r_out_sum += (pr = stackOut.r);
1279
+ g_out_sum += (pg = stackOut.g);
1280
+ b_out_sum += (pb = stackOut.b);
1281
+ a_out_sum += (pa = stackOut.a);
1282
+ r_in_sum -= pr;
1283
+ g_in_sum -= pg;
1284
+ b_in_sum -= pb;
1285
+ a_in_sum -= pa;
1286
+ stackOut = stackOut.next;
1287
+ yi += 4;
1288
+ }
1289
+ yw += width;
1254
1290
  }
1255
- if (prefix === "_PxEgEr_") {
1256
- return new Function(`return ${value.slice(8)}`)();
1291
+ for (x = 0; x < width; x++) {
1292
+ g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;
1293
+ yi = x << 2;
1294
+ r_out_sum = radiusPlus1 * (pr = pixels[yi]);
1295
+ g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
1296
+ b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
1297
+ a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
1298
+ r_sum += sumFactor * pr;
1299
+ g_sum += sumFactor * pg;
1300
+ b_sum += sumFactor * pb;
1301
+ a_sum += sumFactor * pa;
1302
+ stack = stackStart;
1303
+ for (i = 0; i < radiusPlus1; i++) {
1304
+ stack.r = pr;
1305
+ stack.g = pg;
1306
+ stack.b = pb;
1307
+ stack.a = pa;
1308
+ stack = stack.next;
1309
+ }
1310
+ yp = width;
1311
+ for (i = 1; i <= radius; i++) {
1312
+ yi = (yp + x) << 2;
1313
+ r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i);
1314
+ g_sum += (stack.g = (pg = pixels[yi + 1])) * rbs;
1315
+ b_sum += (stack.b = (pb = pixels[yi + 2])) * rbs;
1316
+ a_sum += (stack.a = (pa = pixels[yi + 3])) * rbs;
1317
+ r_in_sum += pr;
1318
+ g_in_sum += pg;
1319
+ b_in_sum += pb;
1320
+ a_in_sum += pa;
1321
+ stack = stack.next;
1322
+ if (i < heightMinus1) {
1323
+ yp += width;
1324
+ }
1325
+ }
1326
+ yi = x;
1327
+ stackIn = stackStart;
1328
+ stackOut = stackEnd;
1329
+ for (y = 0; y < height; y++) {
1330
+ p = yi << 2;
1331
+ pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;
1332
+ if (pa > 0) {
1333
+ pa = 255 / pa;
1334
+ pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;
1335
+ pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
1336
+ pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
1337
+ }
1338
+ else {
1339
+ pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;
1340
+ }
1341
+ r_sum -= r_out_sum;
1342
+ g_sum -= g_out_sum;
1343
+ b_sum -= b_out_sum;
1344
+ a_sum -= a_out_sum;
1345
+ r_out_sum -= stackIn.r;
1346
+ g_out_sum -= stackIn.g;
1347
+ b_out_sum -= stackIn.b;
1348
+ a_out_sum -= stackIn.a;
1349
+ p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2;
1350
+ r_sum += (r_in_sum += (stackIn.r = pixels[p]));
1351
+ g_sum += (g_in_sum += (stackIn.g = pixels[p + 1]));
1352
+ b_sum += (b_in_sum += (stackIn.b = pixels[p + 2]));
1353
+ a_sum += (a_in_sum += (stackIn.a = pixels[p + 3]));
1354
+ stackIn = stackIn.next;
1355
+ r_out_sum += (pr = stackOut.r);
1356
+ g_out_sum += (pg = stackOut.g);
1357
+ b_out_sum += (pb = stackOut.b);
1358
+ a_out_sum += (pa = stackOut.a);
1359
+ r_in_sum -= pr;
1360
+ g_in_sum -= pg;
1361
+ b_in_sum -= pb;
1362
+ a_in_sum -= pa;
1363
+ stackOut = stackOut.next;
1364
+ yi += width;
1365
+ }
1257
1366
  }
1258
- return value;
1367
+ ctx.putImageData(imageData, top_x, top_y);
1259
1368
  }
1260
- static replacer(key, value) {
1261
- if (value instanceof Function || typeof value === "function") {
1262
- const fnBody = value.toString();
1263
- if (fnBody.length < 8 || fnBody.substring(0, 8) !== "function") {
1264
- // this is ES6 Arrow Function
1265
- return "_NuFrRa_" + fnBody;
1369
+ static measureTextFontSize(maxWidth, maxHeight, lines, font, lineHeightPercent = 1.1, canvas) {
1370
+ const startSize = maxHeight;
1371
+ const context = canvas.getContext("2d");
1372
+ if (!canvas) {
1373
+ canvas = document.createElement("canvas");
1374
+ document.body.appendChild(canvas);
1375
+ }
1376
+ canvas.width = maxWidth + maxHeight;
1377
+ canvas.height = maxHeight * 2;
1378
+ let fontSize = CanvasUtils.halveValidateFontSize(startSize, (size) => {
1379
+ CanvasUtils.setFontProps(context, font, size);
1380
+ const maxTextLinesWidth = CanvasUtils.getTextWidth(context, lines);
1381
+ return maxWidth - maxTextLinesWidth;
1382
+ });
1383
+ const bitmapHeight = CanvasUtils.getTextBitmapHeight(canvas, context, lines, font, fontSize, lineHeightPercent);
1384
+ if (bitmapHeight > maxHeight) {
1385
+ fontSize = CanvasUtils.halveValidateFontSize(fontSize, (size) => {
1386
+ return maxHeight - CanvasUtils.getTextBitmapHeight(canvas, context, lines, font, size, lineHeightPercent);
1387
+ });
1388
+ }
1389
+ return fontSize;
1390
+ }
1391
+ static drawLines(context, lines, font, size, lineHeightPercent = 1.1, align = "left", baseLine = "top", x = 0, y = 0) {
1392
+ CanvasUtils.setFontProps(context, font, size, align, baseLine);
1393
+ for (let i = 0; i < lines.length; i++) {
1394
+ const line = lines[i];
1395
+ context.fillText(line, x, y);
1396
+ if (i < lines.length - 1) {
1397
+ y += size * lineHeightPercent;
1398
+ }
1399
+ }
1400
+ return y;
1401
+ }
1402
+ static wrapText(context, text, x, y, maxWidth) {
1403
+ const words = text.split(" ");
1404
+ const lineHeight = context.measureText("M").width * 1.3;
1405
+ const lines = [];
1406
+ let line = "";
1407
+ for (let n = 0; n < words.length; n++) {
1408
+ const testLine = line + words[n] + " ";
1409
+ const metrics = context.measureText(testLine);
1410
+ const testWidth = metrics.width;
1411
+ if (testWidth > maxWidth && n > 0) {
1412
+ lines.push(line);
1413
+ line = words[n] + " ";
1414
+ }
1415
+ else {
1416
+ line = testLine;
1266
1417
  }
1267
- return fnBody;
1268
1418
  }
1269
- if (value instanceof RegExp) {
1270
- return "_PxEgEr_" + value;
1419
+ lines.push(line);
1420
+ y -= lineHeight * .5 * lines.length;
1421
+ lines.forEach(l => {
1422
+ context.fillText(l, x, y);
1423
+ y += lineHeight;
1424
+ });
1425
+ }
1426
+ static setFontProps(context, font, fontSize, align = "left", baseLine = "top") {
1427
+ context.font = `${fontSize}px ${font}`;
1428
+ context.textAlign = align;
1429
+ context.textBaseline = baseLine;
1430
+ }
1431
+ static getTextWidth(context, lines) {
1432
+ let maxWidth = 0;
1433
+ for (let i = 0; i < lines.length; i++) {
1434
+ const line = lines[i];
1435
+ maxWidth = Math.max(maxWidth, context.measureText(line).width);
1271
1436
  }
1272
- return value;
1437
+ return maxWidth;
1273
1438
  }
1274
- }
1275
-
1276
- class LoaderUtils {
1277
- static loadScript(src, async = false, type = "text/javascript") {
1278
- this.scriptPromises[src] = this.scriptPromises[src] || new Promise((resolve, reject) => {
1279
- // Load script
1280
- const script = document.createElement("script");
1281
- script.type = type;
1282
- script.src = src;
1283
- script.async = async;
1284
- if (script.readyState) {
1285
- // Internet explorer
1286
- script.onreadystatechange = () => {
1287
- if (script.readyState === "loaded" || script.readyState === "complete") {
1288
- script.onreadystatechange = null;
1289
- resolve(script);
1290
- }
1291
- };
1292
- }
1293
- else {
1294
- // Other browsers
1295
- script.onload = () => resolve(script);
1439
+ static getTextBitmapHeight(canvas, context, lines, font, fontSize, lineHeightPercent) {
1440
+ const width = canvas.width;
1441
+ const height = canvas.height;
1442
+ context.clearRect(0, 0, width, height);
1443
+ const textY = CanvasUtils.drawLines(context, lines, font, fontSize, lineHeightPercent, "left", "top", fontSize * .5, fontSize * .5);
1444
+ const imageData = context.getImageData(0, 0, width, height);
1445
+ let textHeight = 0;
1446
+ yLoop: for (let y = 0; y < height; y++) {
1447
+ for (let x = 0; x < width; x++) {
1448
+ const index = (x + y * width) * 4;
1449
+ if (imageData.data[index + 3] > 0) {
1450
+ textHeight = y + 1;
1451
+ continue yLoop;
1452
+ }
1296
1453
  }
1297
- script.onerror = (error) => reject(error);
1298
- document.body.appendChild(script);
1299
- });
1300
- return this.scriptPromises[src];
1454
+ }
1455
+ return Math.max(textHeight, textY + fontSize);
1301
1456
  }
1302
- static loadStyle(src) {
1303
- this.stylePromises[src] = this.stylePromises[src] || new Promise((resolve, reject) => {
1304
- // Load script
1305
- const link = document.createElement("link");
1306
- link.rel = "stylesheet";
1307
- link.type = "text/css";
1308
- link.href = src;
1309
- if (link.readyState) {
1310
- // Internet explorer
1311
- link.onreadystatechange = () => {
1312
- if (link.readyState === "loaded" || link.readyState === "complete") {
1313
- link.onreadystatechange = null;
1314
- resolve(link);
1315
- }
1316
- };
1457
+ static halveValidateFontSize(startSize, callback) {
1458
+ let fontSize = startSize;
1459
+ let lastFontSize = 0;
1460
+ let direction;
1461
+ for (let i = 0; i < 20; i++) {
1462
+ direction = callback(fontSize);
1463
+ const tempSize = fontSize;
1464
+ if (direction < 0) {
1465
+ fontSize = fontSize - (Math.abs(fontSize - lastFontSize) / 2);
1317
1466
  }
1318
1467
  else {
1319
- // Other browsers
1320
- link.onload = () => resolve(link);
1468
+ fontSize = fontSize + (Math.abs(fontSize - lastFontSize) / 2);
1321
1469
  }
1322
- link.onerror = (error) => reject(error);
1323
- document.body.appendChild(link);
1324
- });
1325
- return this.stylePromises[src];
1470
+ lastFontSize = tempSize;
1471
+ if (Math.abs(fontSize - lastFontSize) < 0.1) {
1472
+ break;
1473
+ }
1474
+ }
1475
+ fontSize = Math.floor(fontSize);
1476
+ return fontSize;
1326
1477
  }
1327
- }
1328
- LoaderUtils.scriptPromises = {};
1329
- LoaderUtils.stylePromises = {};
1478
+ }
1330
1479
 
1331
- class MathUtils {
1332
- static equal(a, b, epsilon = null) {
1333
- epsilon = ObjectUtils.isNumber(epsilon) ? epsilon : MathUtils.EPSILON;
1334
- return Math.abs(a - b) < epsilon;
1480
+ class DateUtils {
1481
+ static isHoliday(date) {
1482
+ return moment(date).isoWeekday() > 5;
1335
1483
  }
1336
- static clamp(value, min, max) {
1337
- return Math.max(Math.min(value, max), min);
1484
+ static isBusinessDay(date) {
1485
+ return moment(date).isoWeekday() < 6;
1338
1486
  }
1339
- static round(value, precision = 2, divider = 1) {
1340
- precision = Math.pow(10, precision);
1341
- return Math.round(value * precision / divider) / precision;
1487
+ static add(date, amount, unit) {
1488
+ return moment(date).add(amount, unit).toDate();
1342
1489
  }
1343
- static approxIndex(x, values, epsilon = null) {
1344
- if (!Array.isArray(values) || values.length == 0) {
1345
- return -1;
1346
- }
1347
- let s = 0;
1348
- let e = values.length - 1;
1349
- while (s <= e) {
1350
- const i = Math.floor((s + e) / 2);
1351
- const v = values[i];
1352
- if (MathUtils.equal(v, x, epsilon)) {
1353
- return i;
1354
- }
1355
- if (v < x) {
1356
- s = i + 1;
1357
- }
1358
- else {
1359
- e = i - 1;
1490
+ static businessAdd(date, amount, unit, freeDays = []) {
1491
+ const signal = amount < 0 ? -1 : 1;
1492
+ const freeMoments = freeDays.map(d => moment(d));
1493
+ let remaining = Math.abs(amount);
1494
+ let day = date;
1495
+ while (remaining) {
1496
+ day = DateUtils.add(day, signal, unit);
1497
+ if (DateUtils.isBusinessDay(day) && !freeMoments.some(m => m.isSame(day, "day"))) {
1498
+ remaining--;
1360
1499
  }
1361
1500
  }
1362
- const m = Math.max(e, 0);
1363
- const a = values[s];
1364
- const b = values[m];
1365
- return Math.abs(a - x) < Math.abs(b - x) ? s : m;
1501
+ return day;
1366
1502
  }
1367
- static approximate(x, values, epsilon = null) {
1368
- var _a;
1369
- const index = MathUtils.approxIndex(x, values, epsilon);
1370
- return (_a = values[index]) !== null && _a !== void 0 ? _a : null;
1503
+ static businessSubtract(date, amount, unit) {
1504
+ return DateUtils.businessAdd(date, -amount, unit);
1371
1505
  }
1372
- }
1373
- MathUtils.EPSILON = 1e-9;
1506
+ }
1374
1507
 
1375
- /**
1376
- * Use this service to determine which is the current environment
1377
- */
1378
- class UniversalService {
1379
- constructor(platformId, dds) {
1380
- this.platformId = platformId;
1381
- this.dds = dds;
1382
- const info = this.dds.getDeviceInfo();
1383
- this.crawler = /(bot|google|baidu|bing|msn|duckduckbot|teoma|slurp|yandex|lighthouse|angular-universal|PTST|PostmanRuntime)/gi.test(info.userAgent);
1508
+ class FileUtils {
1509
+ static getExtension(file) {
1510
+ return file ? file.name.substr(file.name.lastIndexOf(".")).toLowerCase() : null;
1384
1511
  }
1385
- get isBrowser() {
1386
- return isPlatformBrowser(this.platformId);
1512
+ static getName(file) {
1513
+ return file ? file.name.substr(0, file.name.lastIndexOf(".")) : null;
1387
1514
  }
1388
- get isServer() {
1389
- return isPlatformServer(this.platformId);
1515
+ static toFile(blob, fileName) {
1516
+ const data = blob;
1517
+ data.lastModifiedDate = new Date();
1518
+ data.name = fileName.split(/\\|\//g).pop();
1519
+ return data;
1390
1520
  }
1391
- get deviceInfo() {
1392
- return this.isServer
1393
- ? {
1394
- userAgent: "angular-universal",
1395
- os: "unknown",
1396
- browser: "node",
1397
- device: "node",
1398
- os_version: "unknown",
1399
- browser_version: "unknown",
1400
- deviceType: "unknown",
1401
- orientation: "landscape"
1402
- }
1403
- : this.dds.getDeviceInfo();
1521
+ static dataToBlob(data) {
1522
+ const parts = data.split(",");
1523
+ const byteString = atob(parts[1]);
1524
+ const mimeString = parts[0].split(":")[1].split(";")[0];
1525
+ const ab = new ArrayBuffer(byteString.length);
1526
+ const ia = new Uint8Array(ab);
1527
+ for (let i = 0; i < byteString.length; i++) {
1528
+ ia[i] = byteString.charCodeAt(i);
1529
+ }
1530
+ return new Blob([ab], { type: mimeString });
1404
1531
  }
1405
- get browserName() {
1406
- return (this.dds.browser || "").toLowerCase();
1532
+ static saveBlob(blob, fileName) {
1533
+ if (typeof saveAs == "undefined") {
1534
+ throw Error("FileSaver library is not loaded. Please load it: https://www.npmjs.com/package/file-saver");
1535
+ }
1536
+ saveAs(blob, fileName);
1407
1537
  }
1408
- get browserVersion() {
1409
- return this.dds.browser_version;
1538
+ static saveJson(json, fileName) {
1539
+ if (!ObjectUtils.isObject(json))
1540
+ return;
1541
+ FileUtils.saveBlob(new Blob([JSON.stringify(json, null, 4)]), fileName);
1410
1542
  }
1411
- get isExplorer() {
1412
- return this.checkBrowser("ie");
1543
+ static readFileAsText(file) {
1544
+ return FileUtils.readFile(
1545
+ // @dynamic
1546
+ reader => reader.readAsText(file));
1413
1547
  }
1414
- get isEdge() {
1415
- return this.checkBrowser("edge");
1548
+ static readFileAsBinaryString(file) {
1549
+ return FileUtils.readFile(
1550
+ // @dynamic
1551
+ reader => reader.readAsBinaryString(file));
1416
1552
  }
1417
- get isChrome() {
1418
- return this.checkBrowser("chrome");
1553
+ static readFileAsDataURL(file) {
1554
+ return FileUtils.readFile(
1555
+ // @dynamic
1556
+ reader => reader.readAsDataURL(file));
1557
+ }
1558
+ static readDataFromUrl(http, url) {
1559
+ return new Promise(
1560
+ // @dynamic
1561
+ (resolve, reject) => {
1562
+ if (!url) {
1563
+ reject({
1564
+ message: "The url is not specified"
1565
+ });
1566
+ return;
1567
+ }
1568
+ if ((/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/g).test(url)) {
1569
+ resolve(url);
1570
+ return;
1571
+ }
1572
+ first()(http.get(url, {
1573
+ responseType: "blob"
1574
+ })).subscribe((blob) => {
1575
+ FileUtils.readFileAsDataURL(blob).then(resolve, reject);
1576
+ }, reason => {
1577
+ if (reason.status > 0)
1578
+ reject(reason);
1579
+ else
1580
+ resolve(url);
1581
+ });
1582
+ });
1419
1583
  }
1420
- get isFirefox() {
1421
- return this.checkBrowser("firefox");
1584
+ static readFile(callback) {
1585
+ return new Promise(
1586
+ // @dynamic
1587
+ (resolve, reject) => {
1588
+ const reader = new FileReader();
1589
+ reader.onload = (event) => resolve(event.target.result);
1590
+ reader.onerror = reject;
1591
+ callback(reader);
1592
+ });
1422
1593
  }
1423
- get isSafari() {
1424
- return this.checkBrowser("safari");
1594
+ }
1595
+
1596
+ class GenericValue extends Subject {
1597
+ constructor(value = null) {
1598
+ super();
1599
+ this._value = value;
1425
1600
  }
1426
- get isTablet() {
1427
- return this.dds.isTablet();
1601
+ get value() {
1602
+ return this._value;
1428
1603
  }
1429
- get isMobile() {
1430
- return this.dds.isMobile();
1604
+ set value(value) {
1605
+ if (value == this._value)
1606
+ return;
1607
+ this._value = value;
1608
+ this.next(value);
1431
1609
  }
1432
- get isDesktop() {
1433
- return this.dds.isDesktop();
1610
+ setJustValue(value) {
1611
+ this._value = value;
1434
1612
  }
1435
- get isCrawler() {
1436
- return this.crawler;
1613
+ }
1614
+
1615
+ class FileSystemEntry {
1616
+ constructor(label, meta, image, data, parent, openCb) {
1617
+ this.label = label;
1618
+ this.meta = meta;
1619
+ this.image = image;
1620
+ this.data = data;
1621
+ this.parent = parent;
1622
+ this.openCb = openCb;
1623
+ this.path = !parent ? [this] : parent.path.concat([this]);
1624
+ this.level = this.path.length - 1;
1625
+ this.classes = this.path
1626
+ .filter(t => typeof t.data === "string" && t.data.length > 0).map(t => t.data)
1627
+ .concat([`level-${this.level}`]);
1437
1628
  }
1438
- checkBrowser(name) {
1439
- return this.browserName.includes(name) || false;
1629
+ open() {
1630
+ this.result = this.result || this.openCb(this.data, this);
1631
+ this.result.then(res => {
1632
+ if (Array.isArray(res))
1633
+ return;
1634
+ this.result = null;
1635
+ });
1636
+ return this.result;
1440
1637
  }
1441
- }
1442
- UniversalService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService, deps: [{ token: PLATFORM_ID }, { token: i1.DeviceDetectorService }], target: i0.ɵɵFactoryTarget.Injectable });
1443
- UniversalService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService });
1444
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: UniversalService, decorators: [{
1445
- type: Injectable
1446
- }], ctorParameters: function () {
1447
- return [{ type: undefined, decorators: [{
1448
- type: Inject,
1449
- args: [PLATFORM_ID]
1450
- }] }, { type: i1.DeviceDetectorService }];
1451
- } });
1638
+ }
1452
1639
 
1453
- const emptySnapshot = new ActivatedRouteSnapshot();
1454
- const emptyData = { id: "" };
1455
- const emptyParams = {};
1456
- const emptySegments = [];
1457
- const emptyComponents = [];
1458
- class StateService extends BehaviorSubject {
1459
- constructor(injector, zone, universal, router = null) {
1460
- super(null);
1461
- this.injector = injector;
1462
- this.zone = zone;
1463
- this.universal = universal;
1464
- this.router = router;
1465
- this.handleRouterEvent = (event) => {
1466
- var _a;
1467
- if (!(event instanceof NavigationEnd))
1468
- return;
1469
- const routerStateSnapshot = this.router.routerState.snapshot;
1470
- let snapshot = routerStateSnapshot.root;
1471
- let context = (_a = this.contexts) === null || _a === void 0 ? void 0 : _a.getContext("primary");
1472
- let segments = snapshot.url;
1473
- const components = [];
1474
- const snapshots = [];
1475
- while (snapshot) {
1476
- snapshots.push(snapshot);
1477
- segments = segments.concat(snapshot.url);
1478
- if (context) {
1479
- if (context.outlet && context.outlet.isActivated)
1480
- components.push(context.outlet.component);
1481
- context = context.children.getContext("primary");
1482
- }
1483
- snapshot = snapshot.firstChild;
1484
- }
1485
- this.comp = components[components.length - 1];
1486
- this.shot = snapshots[snapshots.length - 1];
1487
- this.stateInfo = {
1488
- url: routerStateSnapshot.url,
1489
- segments: segments,
1490
- components: components
1491
- };
1492
- this.next(this.shot);
1493
- };
1494
- if (!this.router)
1495
- return;
1496
- this.globalExtras = {
1497
- queryParamsHandling: "merge"
1498
- };
1499
- this.router.events.subscribe(this.handleRouterEvent);
1500
- this.stateInfo = {
1501
- url: "",
1502
- segments: [],
1503
- components: []
1504
- };
1505
- this.contexts = router.rootContexts;
1640
+ class Rect {
1641
+ constructor(x, y, width, height, rotation = 0) {
1642
+ this.x = x;
1643
+ this.y = y;
1644
+ this.width = width;
1645
+ this.height = height;
1646
+ this.rotation = rotation;
1506
1647
  }
1507
- static toPath(route, params) {
1508
- let path = route.path || "";
1509
- ObjectUtils.iterate(params, (value, key) => {
1510
- path = path.replace(`:${key}`, `${value}`);
1511
- });
1512
- return path;
1648
+ get center() {
1649
+ return new Point(this.x, this.y);
1513
1650
  }
1514
- get component() {
1515
- return this.comp;
1651
+ get left() {
1652
+ return this.x - this.width * .5;
1516
1653
  }
1517
- get snapshot() {
1518
- return this.shot || emptySnapshot;
1654
+ get right() {
1655
+ return this.x + this.width * .5;
1519
1656
  }
1520
- get route() {
1521
- return this.snapshot.routeConfig;
1657
+ get bottom() {
1658
+ return this.y - this.height * .5;
1522
1659
  }
1523
- get data() {
1524
- return this.snapshot.data || emptyData;
1660
+ get top() {
1661
+ return this.y + this.height * .5;
1525
1662
  }
1526
- get params() {
1527
- return this.snapshot.params || emptyParams;
1663
+ distance(p) {
1664
+ p = p.rotateAround(this.center, -this.rotation);
1665
+ const x = Math.max(this.left - p.x, 0, p.x - this.right);
1666
+ const y = Math.max(this.bottom - p.y, 0, p.y - this.top);
1667
+ return Math.sqrt(x * x + y * y);
1528
1668
  }
1529
- get queryParams() {
1530
- return this.snapshot.queryParams || emptyParams;
1669
+ }
1670
+ class Circle {
1671
+ constructor(x, y, radius) {
1672
+ this.x = x;
1673
+ this.y = y;
1674
+ this.radius = radius;
1531
1675
  }
1532
- get url() {
1533
- return this.stateInfo.url || "";
1676
+ get center() {
1677
+ return new Point(this.x, this.y);
1534
1678
  }
1535
- get urlSegments() {
1536
- return this.stateInfo.segments || emptySegments;
1679
+ get left() {
1680
+ return new Point(this.x - this.radius, this.y);
1537
1681
  }
1538
- get components() {
1539
- return this.stateInfo.components || emptyComponents;
1682
+ get right() {
1683
+ return new Point(this.x + this.radius, this.y);
1540
1684
  }
1541
- get routerConfig() {
1542
- return this.router.config;
1685
+ get top() {
1686
+ return new Point(this.x, this.y + this.radius);
1543
1687
  }
1544
- reload() {
1545
- return __awaiter(this, void 0, void 0, function* () {
1546
- const routerStateSnapshot = this.router.routerState.snapshot;
1547
- const resolvers = this.route.resolve || {};
1548
- const keys = Object.keys(resolvers);
1549
- for (const key of keys) {
1550
- const resolver = this.injector.get(resolvers[key]);
1551
- let resolved = resolver.resolve(this.snapshot, routerStateSnapshot);
1552
- if (resolved instanceof Observable) {
1553
- resolved = resolved.toPromise();
1554
- }
1555
- if (resolved instanceof Promise) {
1556
- resolved = yield resolved;
1557
- }
1558
- this.data[key] = resolved;
1559
- }
1560
- });
1688
+ get bottom() {
1689
+ return new Point(this.x, this.y - this.radius);
1561
1690
  }
1562
- navigateByUrl(url, navigationExtras = {}) {
1563
- return __awaiter(this, void 0, void 0, function* () {
1564
- return this.navigate(url, navigationExtras);
1565
- });
1691
+ get rect() {
1692
+ return new Rect(this.x, this.y, this.radius * 2, this.radius * 2);
1566
1693
  }
1567
- navigate(url, navigationExtras = {}) {
1568
- return __awaiter(this, void 0, void 0, function* () {
1569
- if (!this.router)
1570
- return false;
1571
- const [tree, extras] = this.createUrlTree(url, navigationExtras);
1572
- return this.zone.run(() => {
1573
- return this.router.navigateByUrl(tree, extras);
1574
- });
1575
- });
1694
+ distance(p) {
1695
+ return this.center.distance(p) - this.radius;
1576
1696
  }
1577
- open(url, target = "_blank", navigationExtras = {}) {
1578
- return __awaiter(this, void 0, void 0, function* () {
1579
- if (!this.router)
1580
- return false;
1581
- const [tree, extras] = this.createUrlTree(url, navigationExtras);
1582
- return this.zone.run(() => {
1583
- return this.openInNewWindow(tree, target) || this.router.navigateByUrl(tree, extras);
1584
- });
1585
- });
1697
+ }
1698
+ class Point {
1699
+ constructor(x, y) {
1700
+ this.x = x;
1701
+ this.y = y;
1702
+ }
1703
+ get length() {
1704
+ return this.distance(Point.Zero);
1586
1705
  }
1587
- subscribeImmediately(next, error, complete) {
1588
- return this.pipe(skipWhile(v => v == null)).subscribe(next, error, complete);
1706
+ get perpendicular() {
1707
+ return new Point(this.y, -this.x);
1589
1708
  }
1590
- openInNewWindow(tree, target) {
1591
- if (!this.universal.isBrowser)
1592
- return false;
1593
- const baseUrl = window.location.href.replace(this.router.url, "");
1594
- try {
1595
- const serialized = this.router.serializeUrl(tree);
1596
- const separator = serialized.startsWith("/") ? "" : "/";
1597
- window.open(baseUrl + separator + serialized, target);
1598
- return true;
1599
- }
1600
- catch (e) {
1601
- console.log(`Can't open new window: ${e}`);
1602
- return false;
1603
- }
1709
+ add(p) {
1710
+ return new Point(this.x + p.x, this.y + p.y);
1604
1711
  }
1605
- createUrlTree(url, extras) {
1606
- if (!this.router)
1607
- return null;
1608
- extras = Object.assign(extras, this.globalExtras, extras || {});
1609
- if (ObjectUtils.isArray(url)) {
1610
- return [this.router.createUrlTree(url, extras), extras];
1611
- }
1612
- if (ObjectUtils.isString(url)) {
1613
- return [this.router.parseUrl(url), extras];
1712
+ subtract(p) {
1713
+ return new Point(this.x - p.x, this.y - p.y);
1714
+ }
1715
+ multiply(p) {
1716
+ if (p instanceof Point) {
1717
+ return new Point(this.x * p.x, this.y * p.y);
1614
1718
  }
1615
- return [url, extras];
1719
+ return new Point(this.x * p, this.y * p);
1616
1720
  }
1617
- }
1618
- StateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: UniversalService }, { token: i2.Router, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1619
- StateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService });
1620
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: StateService, decorators: [{
1621
- type: Injectable
1622
- }], ctorParameters: function () {
1623
- return [{ type: i0.Injector }, { type: i0.NgZone }, { type: UniversalService }, { type: i2.Router, decorators: [{
1624
- type: Optional
1625
- }] }];
1626
- } });
1627
-
1628
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
1629
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1630
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1631
- r = Reflect.decorate(decorators, target, key, desc);
1632
- else
1633
- for (var i = decorators.length - 1; i >= 0; i--)
1634
- if (d = decorators[i])
1635
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1636
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1637
- };
1638
- var __metadata = (this && this.__metadata) || function (k, v) {
1639
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
1640
- return Reflect.metadata(k, v);
1641
- };
1642
- class AuthGuard {
1643
- constructor(injector, state, auth) {
1644
- this.injector = injector;
1645
- this.state = state;
1646
- this.auth = auth;
1721
+ distance(b) {
1722
+ const x = b.x - this.x;
1723
+ const y = b.y - this.y;
1724
+ return Math.sqrt(x * x + y * y);
1647
1725
  }
1648
- static guardAuthenticated(auth) {
1649
- return Promise.resolve(auth.isAuthenticated);
1726
+ lerp(p, ratio) {
1727
+ const diff = p.subtract(this);
1728
+ return this.add(diff.multiply(ratio));
1650
1729
  }
1651
- static guardNotAuthenticated(auth) {
1652
- return Promise.resolve(!auth.isAuthenticated);
1730
+ perpendicularTo(p, length) {
1731
+ const diff = p.perpendicular.subtract(this.perpendicular);
1732
+ const ratio = length / diff.length;
1733
+ const center = this.lerp(p, .5);
1734
+ return center.add(diff.multiply(ratio));
1653
1735
  }
1654
- static guardNothing() {
1655
- return Promise.resolve(true);
1736
+ circleWith(a, b) {
1737
+ const yDelta_a = b.y - a.y;
1738
+ const xDelta_a = b.x - a.x;
1739
+ const yDelta_b = this.y - b.y;
1740
+ const xDelta_b = this.x - b.x;
1741
+ const aSlope = yDelta_a / xDelta_a;
1742
+ const bSlope = yDelta_b / xDelta_b;
1743
+ const x = (aSlope * bSlope * (a.y - this.y) + bSlope * (a.x + b.x) - aSlope * (b.x + this.x)) / (2 * (bSlope - aSlope));
1744
+ const y = -1 * (x - (a.x + b.x) / 2) / aSlope + (a.y + b.y) / 2;
1745
+ const center = new Point(x, y);
1746
+ return new Circle(center.x, center.y, center.distance(this));
1656
1747
  }
1657
- static guardAuthField(auth, expression = `auth.isAuthenticated`) {
1658
- // @dynamic
1659
- const lambda = () => {
1660
- return Promise.resolve(ObjectUtils.evaluate(expression, { auth }));
1661
- };
1662
- return lambda;
1748
+ tangents(c) {
1749
+ const pd = c.center.subtract(this);
1750
+ const a = Math.asin(c.radius / pd.length);
1751
+ const b = Math.atan2(pd.y, pd.x);
1752
+ // Tangent points
1753
+ let t = b - a;
1754
+ const t1 = new Point(c.x + c.radius * Math.sin(t), c.y + c.radius * -Math.cos(t));
1755
+ t = b + a;
1756
+ const t2 = new Point(c.x + c.radius * -Math.sin(t), c.y + c.radius * Math.cos(t));
1757
+ return [t1, t2];
1663
1758
  }
1664
- static guardStateField(state, expression = `state.data`) {
1665
- // @dynamic
1666
- const lambda = () => {
1667
- return Promise.resolve(ObjectUtils.evaluate(expression, { state }));
1668
- };
1669
- return lambda;
1759
+ angle(p) {
1760
+ const diff = p.subtract(this);
1761
+ return Math.atan2(diff.y, diff.x) * 180 / Math.PI;
1670
1762
  }
1671
- static guardAuthStateField(auth, state, expression = `auth.isAuthenticated`) {
1672
- // @dynamic
1673
- const lambda = () => {
1674
- return Promise.resolve(ObjectUtils.evaluate(expression, { auth, state }));
1675
- };
1676
- return lambda;
1763
+ rotateAround(p, angle) {
1764
+ const rotation = (p.angle(this) + angle) * Math.PI / 180;
1765
+ const distance = p.distance(this);
1766
+ const rotated = new Point(Math.cos(rotation) * distance, Math.sin(rotation) * distance);
1767
+ return p.add(rotated);
1677
1768
  }
1678
- static wildRouteMatch(segments) {
1679
- return { consumed: segments };
1769
+ }
1770
+ Point.Zero = new Point(0, 0);
1771
+
1772
+ class Initializer {
1773
+ constructor(callback, shouldInit = true) {
1774
+ this.callback = callback;
1775
+ this.shouldInit = shouldInit;
1776
+ this.initialized = !this.shouldInit;
1777
+ // @ts-ignore
1778
+ return Invokable.create(this);
1680
1779
  }
1681
- static noRouteMatch() {
1682
- return null;
1780
+ get isInitialized() {
1781
+ return this.initialized;
1683
1782
  }
1684
- checkRouteMenu(route) {
1685
- if (!route.data || !route.data.name)
1686
- return Promise.resolve(false);
1687
- return this.checkRoute(route);
1783
+ [Invokable.call]() {
1784
+ if (this.initialized)
1785
+ return null;
1786
+ this.initialized = true;
1787
+ return this.callback();
1688
1788
  }
1689
- checkRoute(route, next) {
1690
- const routeData = route.data || {};
1691
- if (!routeData.guards)
1692
- return Promise.resolve(!route.canActivate || this.auth.isAuthenticated);
1693
- return new Promise(resolve => {
1694
- const guards = routeData.guards.map(g => {
1695
- const guard = ReflectUtils.resolve(g, this.injector);
1696
- return guard(this.auth, route, next);
1697
- });
1698
- Promise.all(guards).then(results => {
1699
- resolve(results.indexOf(false) < 0);
1700
- });
1789
+ }
1790
+
1791
+ class JSONfn {
1792
+ static parse(text) {
1793
+ return JSON.parse(text, JSONfn.reviver);
1794
+ }
1795
+ static stringify(obj) {
1796
+ return JSON.stringify(obj, JSONfn.replacer);
1797
+ }
1798
+ static reviver(key, value) {
1799
+ const iso8061 = /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:.\d+)?(?:Z|[+-]\d\d:\d\d)$/;
1800
+ if (typeof value !== "string")
1801
+ return value;
1802
+ if (value.length < 8) {
1803
+ return value;
1804
+ }
1805
+ if (value.match(iso8061)) {
1806
+ return new Date(value);
1807
+ }
1808
+ const prefix = value.substring(0, 8);
1809
+ if (prefix === "function") {
1810
+ return new Function(`return ${value}`)();
1811
+ }
1812
+ if (prefix === "_NuFrRa_") {
1813
+ return new Function(`return ${value.slice(8)}`)();
1814
+ }
1815
+ if (prefix === "_PxEgEr_") {
1816
+ return new Function(`return ${value.slice(8)}`)();
1817
+ }
1818
+ return value;
1819
+ }
1820
+ static replacer(key, value) {
1821
+ if (value instanceof Function || typeof value === "function") {
1822
+ const fnBody = value.toString();
1823
+ if (fnBody.length < 8 || fnBody.substring(0, 8) !== "function") {
1824
+ // this is ES6 Arrow Function
1825
+ return "_NuFrRa_" + fnBody;
1826
+ }
1827
+ return fnBody;
1828
+ }
1829
+ if (value instanceof RegExp) {
1830
+ return "_PxEgEr_" + value;
1831
+ }
1832
+ return value;
1833
+ }
1834
+ }
1835
+
1836
+ class LoaderUtils {
1837
+ static loadScript(src, async = false, type = "text/javascript") {
1838
+ this.scriptPromises[src] = this.scriptPromises[src] || new Promise((resolve, reject) => {
1839
+ // Load script
1840
+ const script = document.createElement("script");
1841
+ script.type = type;
1842
+ script.src = src;
1843
+ script.async = async;
1844
+ if (script.readyState) {
1845
+ // Internet explorer
1846
+ script.onreadystatechange = () => {
1847
+ if (script.readyState === "loaded" || script.readyState === "complete") {
1848
+ script.onreadystatechange = null;
1849
+ resolve(script);
1850
+ }
1851
+ };
1852
+ }
1853
+ else {
1854
+ // Other browsers
1855
+ script.onload = () => resolve(script);
1856
+ }
1857
+ script.onerror = (error) => reject(error);
1858
+ document.body.appendChild(script);
1701
1859
  });
1860
+ return this.scriptPromises[src];
1702
1861
  }
1703
- canActivate(next, state) {
1704
- const route = next.routeConfig;
1705
- return new Promise(resolve => {
1706
- this.auth.checkAuthenticated().then(() => {
1707
- this.checkRoute(route, next).then(hasRights => {
1708
- resolve(hasRights);
1709
- if (!hasRights) {
1710
- this.getReturnState(route).then(returnState => {
1711
- if (!returnState)
1712
- return;
1713
- this.state.navigate(returnState, { queryParams: next.queryParams });
1714
- });
1862
+ static loadStyle(src) {
1863
+ this.stylePromises[src] = this.stylePromises[src] || new Promise((resolve, reject) => {
1864
+ // Load script
1865
+ const link = document.createElement("link");
1866
+ link.rel = "stylesheet";
1867
+ link.type = "text/css";
1868
+ link.href = src;
1869
+ if (link.readyState) {
1870
+ // Internet explorer
1871
+ link.onreadystatechange = () => {
1872
+ if (link.readyState === "loaded" || link.readyState === "complete") {
1873
+ link.onreadystatechange = null;
1874
+ resolve(link);
1715
1875
  }
1716
- });
1717
- });
1876
+ };
1877
+ }
1878
+ else {
1879
+ // Other browsers
1880
+ link.onload = () => resolve(link);
1881
+ }
1882
+ link.onerror = (error) => reject(error);
1883
+ document.body.appendChild(link);
1718
1884
  });
1885
+ return this.stylePromises[src];
1719
1886
  }
1720
- getConfig(route, config, path) {
1721
- if (!config)
1722
- return null;
1723
- const match = config.findIndex(t => t == route);
1724
- if (match >= 0)
1725
- return config;
1726
- for (const subConfig of config) {
1727
- if (subConfig.path)
1728
- path.push(subConfig.path);
1729
- const loadedChildren = (subConfig["_loadedConfig"] || { routes: null }).routes || subConfig["_loadedRoutes"];
1730
- const match = this.getConfig(route, subConfig.children || loadedChildren, path);
1731
- if (!match) {
1732
- if (subConfig.path)
1733
- path.length -= 1;
1734
- continue;
1735
- }
1736
- return match;
1737
- }
1738
- return null;
1887
+ }
1888
+ LoaderUtils.scriptPromises = {};
1889
+ LoaderUtils.stylePromises = {};
1890
+
1891
+ class MathUtils {
1892
+ static equal(a, b, epsilon = null) {
1893
+ epsilon = ObjectUtils.isNumber(epsilon) ? epsilon : MathUtils.EPSILON;
1894
+ return Math.abs(a - b) < epsilon;
1739
1895
  }
1740
- getReturnState(route) {
1741
- if (!route)
1742
- return Promise.resolve(null);
1743
- if (ObjectUtils.isObject(route.data) && ObjectUtils.isArray(route.data.returnState)) {
1744
- return Promise.resolve(route.data.returnState);
1896
+ static clamp(value, min, max) {
1897
+ return Math.max(Math.min(value, max), min);
1898
+ }
1899
+ static round(value, precision = 2, divider = 1) {
1900
+ precision = Math.pow(10, precision);
1901
+ return Math.round(value * precision / divider) / precision;
1902
+ }
1903
+ static approxIndex(x, values, epsilon = null) {
1904
+ if (!Array.isArray(values) || values.length == 0) {
1905
+ return -1;
1745
1906
  }
1746
- const path = [];
1747
- const config = this.getConfig(route, this.state.routerConfig, path);
1748
- return new Promise(resolve => {
1749
- this.getReturnStateRecursive(config).then(rs => {
1750
- if (!ObjectUtils.isArray(rs)) {
1751
- resolve(rs);
1752
- return;
1753
- }
1754
- resolve(path.concat(rs));
1755
- });
1756
- });
1907
+ let s = 0;
1908
+ let e = values.length - 1;
1909
+ while (s <= e) {
1910
+ const i = Math.floor((s + e) / 2);
1911
+ const v = values[i];
1912
+ if (MathUtils.equal(v, x, epsilon)) {
1913
+ return i;
1914
+ }
1915
+ if (v < x) {
1916
+ s = i + 1;
1917
+ }
1918
+ else {
1919
+ e = i - 1;
1920
+ }
1921
+ }
1922
+ const m = Math.max(e, 0);
1923
+ const a = values[s];
1924
+ const b = values[m];
1925
+ return Math.abs(a - x) < Math.abs(b - x) ? s : m;
1757
1926
  }
1758
- getReturnStateRecursive(config, c = 0) {
1759
- if (!config || c >= config.length)
1760
- return Promise.resolve(null);
1761
- return new Promise(resolve => {
1762
- const route = config[c];
1763
- const check = !route.component ? Promise.resolve(false) : this.checkRoute(route);
1764
- check.then(res => {
1765
- if (res) {
1766
- resolve([route.path]);
1767
- return;
1768
- }
1769
- this.getReturnStateRecursive(config, c + 1).then(resolve);
1770
- });
1771
- });
1927
+ static approximate(x, values, epsilon = null) {
1928
+ var _a;
1929
+ const index = MathUtils.approxIndex(x, values, epsilon);
1930
+ return (_a = values[index]) !== null && _a !== void 0 ? _a : null;
1772
1931
  }
1773
1932
  }
1774
- AuthGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard, deps: [{ token: Injector }, { token: StateService }, { token: AUTH_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable });
1775
- AuthGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard });
1776
- __decorate([
1777
- FactoryDependencies(AUTH_SERVICE),
1778
- __metadata("design:type", Function),
1779
- __metadata("design:paramtypes", [Object, String]),
1780
- __metadata("design:returntype", Function)
1781
- ], AuthGuard, "guardAuthField", null);
1782
- __decorate([
1783
- FactoryDependencies(StateService),
1784
- __metadata("design:type", Function),
1785
- __metadata("design:paramtypes", [StateService, String]),
1786
- __metadata("design:returntype", Function)
1787
- ], AuthGuard, "guardStateField", null);
1788
- __decorate([
1789
- FactoryDependencies(AUTH_SERVICE, StateService),
1790
- __metadata("design:type", Function),
1791
- __metadata("design:paramtypes", [Object, StateService, String]),
1792
- __metadata("design:returntype", Function)
1793
- ], AuthGuard, "guardAuthStateField", null);
1794
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: AuthGuard, decorators: [{
1795
- type: Injectable
1796
- }], ctorParameters: function () {
1797
- return [{ type: i0.Injector, decorators: [{
1798
- type: Inject,
1799
- args: [Injector]
1800
- }] }, { type: StateService, decorators: [{
1801
- type: Inject,
1802
- args: [StateService]
1803
- }] }, { type: undefined, decorators: [{
1804
- type: Inject,
1805
- args: [AUTH_SERVICE]
1806
- }] }];
1807
- } });
1933
+ MathUtils.EPSILON = 1e-9;
1808
1934
 
1809
1935
  class TimerUtils {
1810
1936
  static createTimeout(func, time) {
@@ -1958,112 +2084,6 @@ class StringUtils {
1958
2084
  }
1959
2085
  }
1960
2086
 
1961
- class ArrayUtils {
1962
- static has(arr, ...items) {
1963
- if (!ObjectUtils.isArray(arr) || !ObjectUtils.isArray(items))
1964
- return false;
1965
- for (let i = 0; i < items.length; i++) {
1966
- if (arr.indexOf(items[i]) >= 0)
1967
- return true;
1968
- }
1969
- return false;
1970
- }
1971
- static match(arr, str) {
1972
- if (!ObjectUtils.isArray(arr) || !ObjectUtils.isString(str))
1973
- return false;
1974
- for (let i = 0; i < arr.length; i++) {
1975
- if (arr[i] instanceof RegExp) {
1976
- const regex = arr[i];
1977
- if (regex.test(str))
1978
- return true;
1979
- }
1980
- }
1981
- return false;
1982
- }
1983
- static any(arr, cb) {
1984
- if (!ObjectUtils.isArray(arr) || !ObjectUtils.isFunction(cb))
1985
- return false;
1986
- for (let i = 0; i < arr.length; i++) {
1987
- if (cb(arr[i]))
1988
- return true;
1989
- }
1990
- return false;
1991
- }
1992
- static move(arr, oldIndex, newIndex) {
1993
- if (!ObjectUtils.isArray(arr))
1994
- return [];
1995
- const length = arr.length;
1996
- while (oldIndex < 0) {
1997
- oldIndex += length;
1998
- }
1999
- while (newIndex < 0) {
2000
- newIndex += length;
2001
- }
2002
- if (newIndex >= length) {
2003
- let k = newIndex - length + 1;
2004
- while (k--) {
2005
- arr.push(undefined);
2006
- }
2007
- }
2008
- arr.splice(newIndex, 0, arr.splice(oldIndex, 1)[0]);
2009
- return arr;
2010
- }
2011
- static reversed(arr) {
2012
- const result = [];
2013
- if (!ObjectUtils.isArray(arr))
2014
- return result;
2015
- for (let i = arr.length - 1; i >= 0; i--) {
2016
- result.push(arr[i]);
2017
- }
2018
- return result;
2019
- }
2020
- static min(arr, cb) {
2021
- if (!ObjectUtils.isArray(arr))
2022
- return null;
2023
- let min = Number.MAX_SAFE_INTEGER;
2024
- let result = null;
2025
- for (let i = 0; i < arr.length; i++) {
2026
- const current = cb(arr[i], i);
2027
- if (current < min || result === null) {
2028
- min = current;
2029
- result = arr[i];
2030
- }
2031
- }
2032
- return result;
2033
- }
2034
- static max(arr, cb) {
2035
- if (!ObjectUtils.isArray(arr))
2036
- return null;
2037
- let max = Number.MIN_SAFE_INTEGER;
2038
- let result = null;
2039
- for (let i = 0; i < arr.length; i++) {
2040
- const current = cb(arr[i], i);
2041
- if (current > max || result === null) {
2042
- max = current;
2043
- result = arr[i];
2044
- }
2045
- }
2046
- return result;
2047
- }
2048
- static chunk(arr, size) {
2049
- if (!ObjectUtils.isArray(arr))
2050
- return [];
2051
- size = Math.max(1, size);
2052
- const result = [];
2053
- for (let i = 0; i < arr.length; i += size) {
2054
- result.push(arr.slice(i, i + size));
2055
- }
2056
- return result;
2057
- }
2058
- static unique(arr) {
2059
- if (!ObjectUtils.isArray(arr))
2060
- return [];
2061
- return arr.filter((value, index, self) => {
2062
- return self.indexOf(value) === index;
2063
- });
2064
- }
2065
- }
2066
-
2067
2087
  class SetUtils {
2068
2088
  static equals(set, obj) {
2069
2089
  if (!ObjectUtils.isSet(set) || !ObjectUtils.isSet(obj))
@@ -4783,8 +4803,8 @@ class PaginationDirective {
4783
4803
  this.refresh();
4784
4804
  }
4785
4805
  refresh(time) {
4786
- time = isNaN(time) || time < 0 ? this.updateTime : time;
4787
- this.updateTimer.time = isNaN(time) || time < 0 ? 100 : time;
4806
+ time = isNaN(time) || time <= 0 ? this.updateTime : time;
4807
+ this.updateTimer.time = isNaN(time) || time <= 0 ? 100 : time;
4788
4808
  this.waitFor.then(() => {
4789
4809
  this.updateTimer.run();
4790
4810
  });
@@ -5313,8 +5333,9 @@ class DynamicTableComponent {
5313
5333
  this.pagination.refresh(time);
5314
5334
  }
5315
5335
  setFilter(filter) {
5336
+ var _a;
5316
5337
  this.filter = filter;
5317
- this.refresh(450);
5338
+ this.refresh((_a = this.filterTime) !== null && _a !== void 0 ? _a : 300);
5318
5339
  }
5319
5340
  setOrder(column) {
5320
5341
  this.orderDescending = column == this.orderBy && !this.orderDescending;
@@ -5322,13 +5343,14 @@ class DynamicTableComponent {
5322
5343
  this.refresh();
5323
5344
  }
5324
5345
  updateQuery(col, value) {
5346
+ var _a;
5325
5347
  if (!value) {
5326
5348
  delete this.query[col];
5327
5349
  }
5328
5350
  else {
5329
5351
  this.query[col] = value;
5330
5352
  }
5331
- this.refresh(450);
5353
+ this.refresh((_a = this.filterTime) !== null && _a !== void 0 ? _a : 300);
5332
5354
  }
5333
5355
  loadLocalData(page, rowsPerPage, orderBy, orderDescending, filter) {
5334
5356
  if (!this.data) {
@@ -5362,7 +5384,7 @@ class DynamicTableComponent {
5362
5384
  }
5363
5385
  }
5364
5386
  DynamicTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DynamicTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
5365
- DynamicTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: DynamicTableComponent, selector: "dynamic-table", inputs: { label: "label", placeholder: "placeholder", dataLoader: "dataLoader", data: "data", parallelData: "parallelData", columns: "columns", showFilter: "showFilter", itemsPerPage: "itemsPerPage", updateTime: "updateTime", maxPages: "maxPages", directionLinks: "directionLinks", boundaryLinks: "boundaryLinks", orderBy: "orderBy", orderDescending: "orderDescending", testId: "testId" }, queries: [{ propertyName: "rowTemplate", first: true, predicate: ["rowTemplate"], descendants: true, static: true }, { propertyName: "wrapperTemplate", first: true, predicate: ["wrapperTemplate"], descendants: true, static: true }, { propertyName: "filterTemplate", first: true, predicate: ["filterTemplate"], descendants: true, static: true }, { propertyName: "templateDirectives", predicate: DynamicTableTemplateDirective }], viewQueries: [{ propertyName: "columnsTemplate", first: true, predicate: ["columnsTemplate"], descendants: true, static: true }, { propertyName: "defaultRowTemplate", first: true, predicate: ["defaultRowTemplate"], descendants: true, static: true }, { propertyName: "defaultWrapperTemplate", first: true, predicate: ["defaultWrapperTemplate"], descendants: true, static: true }, { propertyName: "defaultFilterTemplate", first: true, predicate: ["defaultFilterTemplate"], descendants: true, static: true }, { propertyName: "pagination", first: true, predicate: ["pagination"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"dynamic-table\" #pagination=\"pagination\" [pagination]=\"loadData\" [itemsPerPage]=\"itemsPerPage\" [updateTime]=\"updateTime\">\r\n <ng-template #defaultFilterTemplate let-table>\r\n <div class=\"table-search\" *ngIf=\"table.showFilter\">\r\n <label *ngIf=\"label\" [attr.for]=\"tableId\">{{ label | translate }}</label>\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n [attr.id]=\"tableId\"\r\n [attr.data-testid]=\"testId + '-filter-input'\"\r\n [placeholder]=\"placeholder | translate\"\r\n [ngModel]=\"table.filter\"\r\n (ngModelChange)=\"table.setFilter($event)\"/>\r\n </div>\r\n </ng-template>\r\n <ng-container [ngxTemplateOutlet]=\"filterTemplate || defaultFilterTemplate\" [context]=\"this\"></ng-container>\r\n <pagination-menu [maxSize]=\"maxPages\" [directionLinks]=\"directionLinks\" [boundaryLinks]=\"boundaryLinks\"></pagination-menu>\r\n <div class=\"table-responsive\">\r\n <ng-template #columnTemplate let-context let-column=\"column\" let-template=\"template\">\r\n <ng-template #defaultTemplate let-column=\"column\" let-item=\"item\">\r\n <span>{{ item[column] == undefined || item[column] == null ? '-' : item[column] }}</span>\r\n </ng-template>\r\n <ng-template #pureTemplate>\r\n <ng-container [ngxTemplateOutlet]=\"template.ref\" [context]=\"context\"></ng-container>\r\n </ng-template>\r\n <td [ngClass]=\"'column-' + column\"\r\n [attr.data-testid]=\"testId + '-' + column + '-' + context.rowIndex\" *ngIf=\"!template || !template.pure; else pureTemplate\">\r\n <ng-container [ngxTemplateOutlet]=\"!template ? defaultTemplate : template.ref\" [context]=\"context\"></ng-container>\r\n </td>\r\n </ng-template>\r\n\r\n <ng-template #columnsTemplate let-context>\r\n <ng-container *ngFor=\"let column of cols\"\r\n [ngxTemplateOutlet]=\"columnTemplate\"\r\n [context]=\"context\"\r\n [additionalContext]=\"{\r\n template: templates[column],\r\n column: column\r\n }\"></ng-container>\r\n </ng-template>\r\n\r\n <ng-template #defaultRowTemplate let-context>\r\n <tr>\r\n <ng-container [ngxTemplateOutlet]=\"columnsTemplate\" [context]=\"context\"></ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template #defaultWrapperTemplate>\r\n <table class=\"table table-striped\">\r\n <thead>\r\n <tr>\r\n <th *ngFor=\"let column of cols\" [ngClass]=\"'column-' + column\">\r\n <ng-template #defaultCol>\r\n <span>{{ realColumns[column].title | translate }}</span>\r\n </ng-template>\r\n <a *ngIf=\"realColumns[column].sort; else defaultCol\" (click)=\"setOrder(column)\">\r\n <span>{{ realColumns[column].title | translate }}</span>\r\n <i *ngIf=\"orderBy == column\"\r\n [icon]=\"orderDescending ? 'sort-desc' : 'sort-asc'\"\r\n [ngClass]=\"orderBy == column ? (orderDescending ? 'sort-desc': 'sort-asc') : ''\"></i>\r\n </a>\r\n </th>\r\n </tr>\r\n <tr *ngIf=\"hasQuery\">\r\n <th *ngFor=\"let column of cols\" [ngClass]=\"['column-' + column, 'filter-column']\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n [attr.data-testid]=\"testId + '-filter-' + column\"\r\n [placeholder]=\"realColumns[column].title | translate\"\r\n [ngModel]=\"query[column]\"\r\n (ngModelChange)=\"updateQuery(column, $event)\"/>\r\n </th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <ng-container *paginationItem=\"let context\"\r\n [ngxTemplateOutlet]=\"rowTemplate\"\r\n [context]=\"context\"\r\n [additionalContext]=\"this\"></ng-container>\r\n </tbody>\r\n </table>\r\n </ng-template>\r\n\r\n <ng-container [ngxTemplateOutlet]=\"wrapperTemplate || defaultWrapperTemplate\"\r\n [context]=\"this\"></ng-container>\r\n </div>\r\n <pagination-menu [maxSize]=\"maxPages\" [directionLinks]=\"directionLinks\" [boundaryLinks]=\"boundaryLinks\"></pagination-menu>\r\n</div>\r\n", components: [{ type: PaginationMenuComponent, selector: "pagination-menu", inputs: ["maxSize", "urlParam", "directionLinks", "boundaryLinks"] }], directives: [{ type: PaginationDirective, selector: "[pagination]", inputs: ["pagination", "page", "itemsPerPage", "updateTime", "waitFor"], outputs: ["pageChange", "onRefresh"], exportAs: ["pagination"] }, { type: i1$3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: NgxTemplateOutletDirective, selector: "[ngxTemplateOutlet]", inputs: ["context", "additionalContext", "ngxTemplateOutlet"] }, { type: i1$3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1$3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: IconDirective, selector: "[icon]", inputs: ["icon", "activeIcon", "active"], outputs: ["activeChange"] }, { type: PaginationItemDirective, selector: "[paginationItem]" }], pipes: { "translate": TranslatePipe } });
5387
+ DynamicTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: DynamicTableComponent, selector: "dynamic-table", inputs: { label: "label", placeholder: "placeholder", dataLoader: "dataLoader", data: "data", parallelData: "parallelData", columns: "columns", showFilter: "showFilter", itemsPerPage: "itemsPerPage", updateTime: "updateTime", filterTime: "filterTime", maxPages: "maxPages", directionLinks: "directionLinks", boundaryLinks: "boundaryLinks", orderBy: "orderBy", orderDescending: "orderDescending", testId: "testId" }, queries: [{ propertyName: "rowTemplate", first: true, predicate: ["rowTemplate"], descendants: true, static: true }, { propertyName: "wrapperTemplate", first: true, predicate: ["wrapperTemplate"], descendants: true, static: true }, { propertyName: "filterTemplate", first: true, predicate: ["filterTemplate"], descendants: true, static: true }, { propertyName: "templateDirectives", predicate: DynamicTableTemplateDirective }], viewQueries: [{ propertyName: "columnsTemplate", first: true, predicate: ["columnsTemplate"], descendants: true, static: true }, { propertyName: "defaultRowTemplate", first: true, predicate: ["defaultRowTemplate"], descendants: true, static: true }, { propertyName: "defaultWrapperTemplate", first: true, predicate: ["defaultWrapperTemplate"], descendants: true, static: true }, { propertyName: "defaultFilterTemplate", first: true, predicate: ["defaultFilterTemplate"], descendants: true, static: true }, { propertyName: "pagination", first: true, predicate: ["pagination"], descendants: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"dynamic-table\" #pagination=\"pagination\" [pagination]=\"loadData\" [itemsPerPage]=\"itemsPerPage\" [updateTime]=\"updateTime\">\r\n <ng-template #defaultFilterTemplate let-table>\r\n <div class=\"table-search\" *ngIf=\"table.showFilter\">\r\n <label *ngIf=\"label\" [attr.for]=\"tableId\">{{ label | translate }}</label>\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n [attr.id]=\"tableId\"\r\n [attr.data-testid]=\"testId + '-filter-input'\"\r\n [placeholder]=\"placeholder | translate\"\r\n [ngModel]=\"table.filter\"\r\n (ngModelChange)=\"table.setFilter($event)\"/>\r\n </div>\r\n </ng-template>\r\n <ng-container [ngxTemplateOutlet]=\"filterTemplate || defaultFilterTemplate\" [context]=\"this\"></ng-container>\r\n <pagination-menu [maxSize]=\"maxPages\" [directionLinks]=\"directionLinks\" [boundaryLinks]=\"boundaryLinks\"></pagination-menu>\r\n <div class=\"table-responsive\">\r\n <ng-template #columnTemplate let-context let-column=\"column\" let-template=\"template\">\r\n <ng-template #defaultTemplate let-column=\"column\" let-item=\"item\">\r\n <span>{{ item[column] == undefined || item[column] == null ? '-' : item[column] }}</span>\r\n </ng-template>\r\n <ng-template #pureTemplate>\r\n <ng-container [ngxTemplateOutlet]=\"template.ref\" [context]=\"context\"></ng-container>\r\n </ng-template>\r\n <td [ngClass]=\"'column-' + column\"\r\n [attr.data-testid]=\"testId + '-' + column + '-' + context.rowIndex\" *ngIf=\"!template || !template.pure; else pureTemplate\">\r\n <ng-container [ngxTemplateOutlet]=\"!template ? defaultTemplate : template.ref\" [context]=\"context\"></ng-container>\r\n </td>\r\n </ng-template>\r\n\r\n <ng-template #columnsTemplate let-context>\r\n <ng-container *ngFor=\"let column of cols\"\r\n [ngxTemplateOutlet]=\"columnTemplate\"\r\n [context]=\"context\"\r\n [additionalContext]=\"{\r\n template: templates[column],\r\n column: column\r\n }\"></ng-container>\r\n </ng-template>\r\n\r\n <ng-template #defaultRowTemplate let-context>\r\n <tr>\r\n <ng-container [ngxTemplateOutlet]=\"columnsTemplate\" [context]=\"context\"></ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template #defaultWrapperTemplate>\r\n <table class=\"table table-striped\">\r\n <thead>\r\n <tr>\r\n <th *ngFor=\"let column of cols\" [ngClass]=\"'column-' + column\">\r\n <ng-template #defaultCol>\r\n <span>{{ realColumns[column].title | translate }}</span>\r\n </ng-template>\r\n <a *ngIf=\"realColumns[column].sort; else defaultCol\" (click)=\"setOrder(column)\">\r\n <span>{{ realColumns[column].title | translate }}</span>\r\n <i *ngIf=\"orderBy == column\"\r\n [icon]=\"orderDescending ? 'sort-desc' : 'sort-asc'\"\r\n [ngClass]=\"orderBy == column ? (orderDescending ? 'sort-desc': 'sort-asc') : ''\"></i>\r\n </a>\r\n </th>\r\n </tr>\r\n <tr *ngIf=\"hasQuery\">\r\n <th *ngFor=\"let column of cols\" [ngClass]=\"['column-' + column, 'filter-column']\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n [attr.data-testid]=\"testId + '-filter-' + column\"\r\n [placeholder]=\"realColumns[column].title | translate\"\r\n [ngModel]=\"query[column]\"\r\n (ngModelChange)=\"updateQuery(column, $event)\"/>\r\n </th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <ng-container *paginationItem=\"let context\"\r\n [ngxTemplateOutlet]=\"rowTemplate\"\r\n [context]=\"context\"\r\n [additionalContext]=\"this\"></ng-container>\r\n </tbody>\r\n </table>\r\n </ng-template>\r\n\r\n <ng-container [ngxTemplateOutlet]=\"wrapperTemplate || defaultWrapperTemplate\"\r\n [context]=\"this\"></ng-container>\r\n </div>\r\n <pagination-menu [maxSize]=\"maxPages\" [directionLinks]=\"directionLinks\" [boundaryLinks]=\"boundaryLinks\"></pagination-menu>\r\n</div>\r\n", components: [{ type: PaginationMenuComponent, selector: "pagination-menu", inputs: ["maxSize", "urlParam", "directionLinks", "boundaryLinks"] }], directives: [{ type: PaginationDirective, selector: "[pagination]", inputs: ["pagination", "page", "itemsPerPage", "updateTime", "waitFor"], outputs: ["pageChange", "onRefresh"], exportAs: ["pagination"] }, { type: i1$3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: NgxTemplateOutletDirective, selector: "[ngxTemplateOutlet]", inputs: ["context", "additionalContext", "ngxTemplateOutlet"] }, { type: i1$3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1$3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: IconDirective, selector: "[icon]", inputs: ["icon", "activeIcon", "active"], outputs: ["activeChange"] }, { type: PaginationItemDirective, selector: "[paginationItem]" }], pipes: { "translate": TranslatePipe } });
5366
5388
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: DynamicTableComponent, decorators: [{
5367
5389
  type: Component,
5368
5390
  args: [{ selector: "dynamic-table", template: "<div class=\"dynamic-table\" #pagination=\"pagination\" [pagination]=\"loadData\" [itemsPerPage]=\"itemsPerPage\" [updateTime]=\"updateTime\">\r\n <ng-template #defaultFilterTemplate let-table>\r\n <div class=\"table-search\" *ngIf=\"table.showFilter\">\r\n <label *ngIf=\"label\" [attr.for]=\"tableId\">{{ label | translate }}</label>\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n [attr.id]=\"tableId\"\r\n [attr.data-testid]=\"testId + '-filter-input'\"\r\n [placeholder]=\"placeholder | translate\"\r\n [ngModel]=\"table.filter\"\r\n (ngModelChange)=\"table.setFilter($event)\"/>\r\n </div>\r\n </ng-template>\r\n <ng-container [ngxTemplateOutlet]=\"filterTemplate || defaultFilterTemplate\" [context]=\"this\"></ng-container>\r\n <pagination-menu [maxSize]=\"maxPages\" [directionLinks]=\"directionLinks\" [boundaryLinks]=\"boundaryLinks\"></pagination-menu>\r\n <div class=\"table-responsive\">\r\n <ng-template #columnTemplate let-context let-column=\"column\" let-template=\"template\">\r\n <ng-template #defaultTemplate let-column=\"column\" let-item=\"item\">\r\n <span>{{ item[column] == undefined || item[column] == null ? '-' : item[column] }}</span>\r\n </ng-template>\r\n <ng-template #pureTemplate>\r\n <ng-container [ngxTemplateOutlet]=\"template.ref\" [context]=\"context\"></ng-container>\r\n </ng-template>\r\n <td [ngClass]=\"'column-' + column\"\r\n [attr.data-testid]=\"testId + '-' + column + '-' + context.rowIndex\" *ngIf=\"!template || !template.pure; else pureTemplate\">\r\n <ng-container [ngxTemplateOutlet]=\"!template ? defaultTemplate : template.ref\" [context]=\"context\"></ng-container>\r\n </td>\r\n </ng-template>\r\n\r\n <ng-template #columnsTemplate let-context>\r\n <ng-container *ngFor=\"let column of cols\"\r\n [ngxTemplateOutlet]=\"columnTemplate\"\r\n [context]=\"context\"\r\n [additionalContext]=\"{\r\n template: templates[column],\r\n column: column\r\n }\"></ng-container>\r\n </ng-template>\r\n\r\n <ng-template #defaultRowTemplate let-context>\r\n <tr>\r\n <ng-container [ngxTemplateOutlet]=\"columnsTemplate\" [context]=\"context\"></ng-container>\r\n </tr>\r\n </ng-template>\r\n\r\n <ng-template #defaultWrapperTemplate>\r\n <table class=\"table table-striped\">\r\n <thead>\r\n <tr>\r\n <th *ngFor=\"let column of cols\" [ngClass]=\"'column-' + column\">\r\n <ng-template #defaultCol>\r\n <span>{{ realColumns[column].title | translate }}</span>\r\n </ng-template>\r\n <a *ngIf=\"realColumns[column].sort; else defaultCol\" (click)=\"setOrder(column)\">\r\n <span>{{ realColumns[column].title | translate }}</span>\r\n <i *ngIf=\"orderBy == column\"\r\n [icon]=\"orderDescending ? 'sort-desc' : 'sort-asc'\"\r\n [ngClass]=\"orderBy == column ? (orderDescending ? 'sort-desc': 'sort-asc') : ''\"></i>\r\n </a>\r\n </th>\r\n </tr>\r\n <tr *ngIf=\"hasQuery\">\r\n <th *ngFor=\"let column of cols\" [ngClass]=\"['column-' + column, 'filter-column']\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n [attr.data-testid]=\"testId + '-filter-' + column\"\r\n [placeholder]=\"realColumns[column].title | translate\"\r\n [ngModel]=\"query[column]\"\r\n (ngModelChange)=\"updateQuery(column, $event)\"/>\r\n </th>\r\n </tr>\r\n </thead>\r\n <tbody>\r\n <ng-container *paginationItem=\"let context\"\r\n [ngxTemplateOutlet]=\"rowTemplate\"\r\n [context]=\"context\"\r\n [additionalContext]=\"this\"></ng-container>\r\n </tbody>\r\n </table>\r\n </ng-template>\r\n\r\n <ng-container [ngxTemplateOutlet]=\"wrapperTemplate || defaultWrapperTemplate\"\r\n [context]=\"this\"></ng-container>\r\n </div>\r\n <pagination-menu [maxSize]=\"maxPages\" [directionLinks]=\"directionLinks\" [boundaryLinks]=\"boundaryLinks\"></pagination-menu>\r\n</div>\r\n" }]
@@ -5384,6 +5406,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
5384
5406
  type: Input
5385
5407
  }], updateTime: [{
5386
5408
  type: Input
5409
+ }], filterTime: [{
5410
+ type: Input
5387
5411
  }], maxPages: [{
5388
5412
  type: Input
5389
5413
  }], directionLinks: [{
@@ -5829,5 +5853,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
5829
5853
  * Generated bundle index. Do not edit.
5830
5854
  */
5831
5855
 
5832
- export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AuthGuard, BASE_CONFIG, BackgroundDirective, BaseHttpClient, BaseHttpService, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChunkPipe, Circle, ConfigService, ConsoleToasterService, DateUtils, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FileSystemEntry, FileUtils, FilterPipe, FindPipe, FormatNumberPipe, FormatterService, GLOBAL_TEMPLATES, GenericValue, GetOffsetPipe, GetTypePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_SERVICE, IConfiguration, IconDirective, IconService, Initializer, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, ValuedPromise, ValuesPipe, Vector, WASI_IMPLEMENTATION, WasmService };
5856
+ export { API_SERVICE, APP_BASE_URL, AUTH_SERVICE, AclService, AjaxRequestHandler, ApiService, ArrayUtils, AsyncMethodBase, AsyncMethodDirective, AuthGuard, BASE_CONFIG, BackgroundDirective, BaseHttpClient, BaseHttpService, CONFIG_SERVICE, CanvasColor, CanvasUtils, ChunkPipe, Circle, ConfigService, ConsoleToasterService, DateUtils, DynamicTableComponent, DynamicTableTemplateDirective, ERROR_HANDLER, EXPRESS_REQUEST, EntriesPipe, ErrorHandlerService, EventsService, ExtraItemPropertiesPipe, FactoryDependencies, FileSystemEntry, FileUtils, FilterPipe, FindPipe, FormatNumberPipe, FormatterService, GLOBAL_TEMPLATES, GenericValue, GetOffsetPipe, GetTypePipe, GlobalTemplateDirective, GlobalTemplatePipe, GlobalTemplateService, GroupByPipe, HttpPromise, ICON_SERVICE, IConfiguration, IconDirective, IconService, Initializer, IsTypePipe, JSONfn, JoinPipe, KeysPipe, LANGUAGE_SERVICE, LanguageService, LoaderUtils, LocalHttpService, MapPipe, MathUtils, MaxPipe, MinPipe, NgxTemplateOutletDirective, NgxUtilsModule, ObjectType, ObjectUtils, ObservableUtils, OpenApiService, PROMISE_SERVICE, PaginationDirective, PaginationItemContext, PaginationItemDirective, PaginationMenuComponent, Point, PopPipe, PromiseService, RESIZE_DELAY, RESIZE_STRATEGY, ROOT_ELEMENT, Rect, ReducePipe, ReflectUtils, RemapPipe, ReplacePipe, ResizeEventPlugin, ResourceIfContext, ResourceIfDirective, ReversePipe, RoundPipe, SCRIPT_PARAMS, SafeHtmlPipe, ScrollEventPlugin, SetUtils, ShiftPipe, SplitPipe, StateService, StaticAuthService, StaticLanguageService, StickyClassDirective, StickyDirective, StorageMode, StorageService, StringUtils, TOASTER_SERVICE, TimerUtils, TranslatePipe, TranslatedUrlSerializer, UniqueUtils, UniversalService, UnorderedListComponent, UnorderedListItemDirective, UnorderedListTemplateDirective, ValuedPromise, ValuesPipe, Vector, WASI_IMPLEMENTATION, WasmService, cachedFactory };
5833
5857
  //# sourceMappingURL=stemy-ngx-utils.mjs.map