@native-systems/utility 1.2.0 → 2.0.0

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.
package/dist/index.cjs CHANGED
@@ -1,5 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var Handlebars = require('handlebars');
4
+ var sanitizeHtml = require('sanitize-html');
5
+ var MarkdownIt = require('markdown-it');
6
+
3
7
  var PostgresError = /*#__PURE__*/ (function (PostgresError) {
4
8
  PostgresError['SUCCESSFUL_COMPLETION'] = '00000';
5
9
  PostgresError['WARNING'] = '01000';
@@ -296,7 +300,7 @@ function _call_super$1(_this, derived, args) {
296
300
  : derived.apply(_this, args)
297
301
  );
298
302
  }
299
- function _class_call_check$4(instance, Constructor) {
303
+ function _class_call_check$6(instance, Constructor) {
300
304
  if (!(instance instanceof Constructor)) {
301
305
  throw new TypeError('Cannot call a class as a function');
302
306
  }
@@ -316,7 +320,7 @@ function _construct$1(Parent, args, Class) {
316
320
  }
317
321
  return _construct$1.apply(null, arguments);
318
322
  }
319
- function _define_property$3(obj, key, value) {
323
+ function _define_property$5(obj, key, value) {
320
324
  if (key in obj) {
321
325
  Object.defineProperty(obj, key, {
322
326
  value: value,
@@ -354,7 +358,7 @@ function _is_native_function$1(fn) {
354
358
  return Function.toString.call(fn).indexOf('[native code]') !== -1;
355
359
  }
356
360
  function _possible_constructor_return$1(self, call) {
357
- if (call && (_type_of$1(call) === 'object' || typeof call === 'function')) {
361
+ if (call && (_type_of$2(call) === 'object' || typeof call === 'function')) {
358
362
  return call;
359
363
  }
360
364
  return _assert_this_initialized$1(self);
@@ -368,7 +372,7 @@ function _set_prototype_of$1(o, p) {
368
372
  };
369
373
  return _set_prototype_of$1(o, p);
370
374
  }
371
- function _type_of$1(obj) {
375
+ function _type_of$2(obj) {
372
376
  '@swc/helpers - typeof';
373
377
  return obj && typeof Symbol !== 'undefined' && obj.constructor === Symbol
374
378
  ? 'symbol'
@@ -417,10 +421,10 @@ function _is_native_reflect_construct$1() {
417
421
  var NativeException = /*#__PURE__*/ (function (Error1) {
418
422
  _inherits$1(NativeException, Error1);
419
423
  function NativeException(code, message) {
420
- _class_call_check$4(this, NativeException);
424
+ _class_call_check$6(this, NativeException);
421
425
  var _this;
422
426
  (_this = _call_super$1(this, NativeException, [message])),
423
- _define_property$3(_this, 'code', void 0);
427
+ _define_property$5(_this, 'code', void 0);
424
428
  _this.name = 'NativeError';
425
429
  _this.code = code;
426
430
  return _this;
@@ -449,7 +453,7 @@ function _call_super(_this, derived, args) {
449
453
  : derived.apply(_this, args)
450
454
  );
451
455
  }
452
- function _class_call_check$3(instance, Constructor) {
456
+ function _class_call_check$5(instance, Constructor) {
453
457
  if (!(instance instanceof Constructor)) {
454
458
  throw new TypeError('Cannot call a class as a function');
455
459
  }
@@ -469,7 +473,7 @@ function _construct(Parent, args, Class) {
469
473
  }
470
474
  return _construct.apply(null, arguments);
471
475
  }
472
- function _defineProperties$3(target, props) {
476
+ function _defineProperties$5(target, props) {
473
477
  for (var i = 0; i < props.length; i++) {
474
478
  var descriptor = props[i];
475
479
  descriptor.enumerable = descriptor.enumerable || false;
@@ -478,11 +482,11 @@ function _defineProperties$3(target, props) {
478
482
  Object.defineProperty(target, descriptor.key, descriptor);
479
483
  }
480
484
  }
481
- function _create_class$3(Constructor, protoProps, staticProps) {
482
- if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
485
+ function _create_class$5(Constructor, protoProps, staticProps) {
486
+ if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
483
487
  return Constructor;
484
488
  }
485
- function _define_property$2(obj, key, value) {
489
+ function _define_property$4(obj, key, value) {
486
490
  if (key in obj) {
487
491
  Object.defineProperty(obj, key, {
488
492
  value: value,
@@ -520,7 +524,7 @@ function _is_native_function(fn) {
520
524
  return Function.toString.call(fn).indexOf('[native code]') !== -1;
521
525
  }
522
526
  function _possible_constructor_return(self, call) {
523
- if (call && (_type_of(call) === 'object' || typeof call === 'function')) {
527
+ if (call && (_type_of$1(call) === 'object' || typeof call === 'function')) {
524
528
  return call;
525
529
  }
526
530
  return _assert_this_initialized(self);
@@ -534,7 +538,7 @@ function _set_prototype_of(o, p) {
534
538
  };
535
539
  return _set_prototype_of(o, p);
536
540
  }
537
- function _type_of(obj) {
541
+ function _type_of$1(obj) {
538
542
  '@swc/helpers - typeof';
539
543
  return obj && typeof Symbol !== 'undefined' && obj.constructor === Symbol
540
544
  ? 'symbol'
@@ -579,17 +583,17 @@ function _is_native_reflect_construct() {
579
583
  var PgException = /*#__PURE__*/ (function (Error1) {
580
584
  _inherits(PgException, Error1);
581
585
  function PgException(err, message, specific) {
582
- _class_call_check$3(this, PgException);
586
+ _class_call_check$5(this, PgException);
583
587
  var _this;
584
588
  (_this = _call_super(this, PgException, [message])),
585
- _define_property$2(_this, 'err', void 0),
586
- _define_property$2(_this, 'specific', void 0);
589
+ _define_property$4(_this, 'err', void 0),
590
+ _define_property$4(_this, 'specific', void 0);
587
591
  _this.name = 'PgError';
588
592
  _this.err = err;
589
593
  _this.specific = specific;
590
594
  return _this;
591
595
  }
592
- _create_class$3(PgException, [
596
+ _create_class$5(PgException, [
593
597
  {
594
598
  key: 'getStatus',
595
599
  value: function getStatus() {
@@ -616,12 +620,12 @@ var PgException = /*#__PURE__*/ (function (Error1) {
616
620
  return PgException;
617
621
  })(_wrap_native_super(Error));
618
622
 
619
- function _class_call_check$2(instance, Constructor) {
623
+ function _class_call_check$4(instance, Constructor) {
620
624
  if (!(instance instanceof Constructor)) {
621
625
  throw new TypeError('Cannot call a class as a function');
622
626
  }
623
627
  }
624
- function _defineProperties$2(target, props) {
628
+ function _defineProperties$4(target, props) {
625
629
  for (var i = 0; i < props.length; i++) {
626
630
  var descriptor = props[i];
627
631
  descriptor.enumerable = descriptor.enumerable || false;
@@ -630,11 +634,11 @@ function _defineProperties$2(target, props) {
630
634
  Object.defineProperty(target, descriptor.key, descriptor);
631
635
  }
632
636
  }
633
- function _create_class$2(Constructor, protoProps, staticProps) {
634
- if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
637
+ function _create_class$4(Constructor, protoProps, staticProps) {
638
+ if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
635
639
  return Constructor;
636
640
  }
637
- function _define_property$1(obj, key, value) {
641
+ function _define_property$3(obj, key, value) {
638
642
  if (key in obj) {
639
643
  Object.defineProperty(obj, key, {
640
644
  value: value,
@@ -662,10 +666,10 @@ var NO_OP = function (_message) {
662
666
  };
663
667
  var ConsoleLogger = /*#__PURE__*/ (function () {
664
668
  function ConsoleLogger(options) {
665
- _class_call_check$2(this, ConsoleLogger);
666
- _define_property$1(this, 'log', void 0);
667
- _define_property$1(this, 'warn', void 0);
668
- _define_property$1(this, 'error', void 0);
669
+ _class_call_check$4(this, ConsoleLogger);
670
+ _define_property$3(this, 'log', void 0);
671
+ _define_property$3(this, 'warn', void 0);
672
+ _define_property$3(this, 'error', void 0);
669
673
  var level = (options || {}).level;
670
674
  this.error = console.error.bind(console);
671
675
  this.warn = NO_OP;
@@ -680,7 +684,7 @@ var ConsoleLogger = /*#__PURE__*/ (function () {
680
684
  break;
681
685
  }
682
686
  }
683
- _create_class$2(ConsoleLogger, [
687
+ _create_class$4(ConsoleLogger, [
684
688
  {
685
689
  key: 'disable',
686
690
  value: function disable() {
@@ -716,12 +720,12 @@ var logger = new ConsoleLogger({
716
720
  level: LOG_LEVEL,
717
721
  });
718
722
 
719
- function _class_call_check$1(instance, Constructor) {
723
+ function _class_call_check$3(instance, Constructor) {
720
724
  if (!(instance instanceof Constructor)) {
721
725
  throw new TypeError('Cannot call a class as a function');
722
726
  }
723
727
  }
724
- function _defineProperties$1(target, props) {
728
+ function _defineProperties$3(target, props) {
725
729
  for (var i = 0; i < props.length; i++) {
726
730
  var descriptor = props[i];
727
731
  descriptor.enumerable = descriptor.enumerable || false;
@@ -730,15 +734,15 @@ function _defineProperties$1(target, props) {
730
734
  Object.defineProperty(target, descriptor.key, descriptor);
731
735
  }
732
736
  }
733
- function _create_class$1(Constructor, protoProps, staticProps) {
734
- if (staticProps) _defineProperties$1(Constructor, staticProps);
737
+ function _create_class$3(Constructor, protoProps, staticProps) {
738
+ if (staticProps) _defineProperties$3(Constructor, staticProps);
735
739
  return Constructor;
736
740
  }
737
741
  var HttpHandler = /*#__PURE__*/ (function () {
738
742
  function HttpHandler() {
739
- _class_call_check$1(this, HttpHandler);
743
+ _class_call_check$3(this, HttpHandler);
740
744
  }
741
- _create_class$1(HttpHandler, null, [
745
+ _create_class$3(HttpHandler, null, [
742
746
  {
743
747
  key: 'response',
744
748
  value: function response(response) {
@@ -782,12 +786,12 @@ var HttpHandler = /*#__PURE__*/ (function () {
782
786
  return HttpHandler;
783
787
  })();
784
788
 
785
- function _class_call_check(instance, Constructor) {
789
+ function _class_call_check$2(instance, Constructor) {
786
790
  if (!(instance instanceof Constructor)) {
787
791
  throw new TypeError('Cannot call a class as a function');
788
792
  }
789
793
  }
790
- function _defineProperties(target, props) {
794
+ function _defineProperties$2(target, props) {
791
795
  for (var i = 0; i < props.length; i++) {
792
796
  var descriptor = props[i];
793
797
  descriptor.enumerable = descriptor.enumerable || false;
@@ -796,11 +800,11 @@ function _defineProperties(target, props) {
796
800
  Object.defineProperty(target, descriptor.key, descriptor);
797
801
  }
798
802
  }
799
- function _create_class(Constructor, protoProps, staticProps) {
800
- if (staticProps) _defineProperties(Constructor, staticProps);
803
+ function _create_class$2(Constructor, protoProps, staticProps) {
804
+ if (staticProps) _defineProperties$2(Constructor, staticProps);
801
805
  return Constructor;
802
806
  }
803
- function _define_property(obj, key, value) {
807
+ function _define_property$2(obj, key, value) {
804
808
  if (key in obj) {
805
809
  Object.defineProperty(obj, key, {
806
810
  value: value,
@@ -815,9 +819,9 @@ function _define_property(obj, key, value) {
815
819
  }
816
820
  var CookieHelper = /*#__PURE__*/ (function () {
817
821
  function CookieHelper() {
818
- _class_call_check(this, CookieHelper);
822
+ _class_call_check$2(this, CookieHelper);
819
823
  }
820
- _create_class(CookieHelper, null, [
824
+ _create_class$2(CookieHelper, null, [
821
825
  {
822
826
  key: 'isProduction',
823
827
  value: function isProduction() {
@@ -833,11 +837,634 @@ var CookieHelper = /*#__PURE__*/ (function () {
833
837
  ]);
834
838
  return CookieHelper;
835
839
  })();
836
- _define_property(CookieHelper, 'cookieSecurePrefix', '__Secure-');
840
+ _define_property$2(CookieHelper, 'cookieSecurePrefix', '__Secure-');
841
+
842
+ function _type_of(obj) {
843
+ '@swc/helpers - typeof';
844
+ return obj && typeof Symbol !== 'undefined' && obj.constructor === Symbol
845
+ ? 'symbol'
846
+ : typeof obj;
847
+ }
848
+ function encodeReserved(str) {
849
+ return str
850
+ .split(/(%[0-9A-Fa-f]{2})/g)
851
+ .map(function (part) {
852
+ if (!/%[0-9A-Fa-f]/.test(part)) {
853
+ part = encodeURI(part).replace(/%5B/g, '[').replace(/%5D/g, ']');
854
+ }
855
+ return part;
856
+ })
857
+ .join('');
858
+ }
859
+ function encodeUnreserved(str) {
860
+ return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
861
+ return '%' + c.charCodeAt(0).toString(16).toUpperCase();
862
+ });
863
+ }
864
+ function encodeValue(operator, value, key) {
865
+ value =
866
+ operator === '+' || operator === '#'
867
+ ? encodeReserved(value)
868
+ : encodeUnreserved(value);
869
+ if (key) {
870
+ return encodeUnreserved(key) + '=' + value;
871
+ } else {
872
+ return value;
873
+ }
874
+ }
875
+ function isDefined(value) {
876
+ return value !== undefined && value !== null;
877
+ }
878
+ function isKeyOperator(operator) {
879
+ return operator === ';' || operator === '&' || operator === '?';
880
+ }
881
+ function getValues(context, operator, key, modifier) {
882
+ var value = context[key],
883
+ result = [];
884
+ if (isDefined(value) && value !== '') {
885
+ if (
886
+ typeof value === 'string' ||
887
+ typeof value === 'number' ||
888
+ typeof value === 'boolean'
889
+ ) {
890
+ value = value.toString();
891
+ if (modifier && modifier !== '*') {
892
+ value = value.substring(0, parseInt(modifier, 10));
893
+ }
894
+ result.push(
895
+ encodeValue(operator, value, isKeyOperator(operator) ? key : null)
896
+ );
897
+ } else {
898
+ if (modifier === '*') {
899
+ if (Array.isArray(value)) {
900
+ value.filter(isDefined).forEach(function (value) {
901
+ result.push(
902
+ encodeValue(
903
+ operator,
904
+ String(value),
905
+ isKeyOperator(operator) ? key : null
906
+ )
907
+ );
908
+ });
909
+ } else if (
910
+ (typeof value === 'undefined' ? 'undefined' : _type_of(value)) ===
911
+ 'object' &&
912
+ value !== null
913
+ ) {
914
+ Object.keys(value).forEach(function (k) {
915
+ if (isDefined(value[k])) {
916
+ result.push(encodeValue(operator, String(value[k]), k));
917
+ }
918
+ });
919
+ }
920
+ } else {
921
+ var tmp = [];
922
+ if (Array.isArray(value)) {
923
+ value.filter(isDefined).forEach(function (value) {
924
+ tmp.push(encodeValue(operator, String(value)));
925
+ });
926
+ } else if (
927
+ (typeof value === 'undefined' ? 'undefined' : _type_of(value)) ===
928
+ 'object' &&
929
+ value !== null
930
+ ) {
931
+ Object.keys(value).forEach(function (k) {
932
+ if (isDefined(value[k])) {
933
+ tmp.push(encodeUnreserved(k));
934
+ tmp.push(encodeValue(operator, String(value[k])));
935
+ }
936
+ });
937
+ }
938
+ if (isKeyOperator(operator)) {
939
+ result.push(encodeUnreserved(key) + '=' + tmp.join(','));
940
+ } else if (tmp.length !== 0) {
941
+ result.push(tmp.join(','));
942
+ }
943
+ }
944
+ }
945
+ } else {
946
+ if (operator === ';') {
947
+ if (isDefined(value)) {
948
+ result.push(encodeUnreserved(key));
949
+ }
950
+ } else if (value === '' && (operator === '&' || operator === '?')) {
951
+ result.push(encodeUnreserved(key) + '=');
952
+ } else if (value === '') {
953
+ result.push('');
954
+ }
955
+ }
956
+ return result;
957
+ }
958
+ function parseTemplate(template) {
959
+ var operators = ['+', '#', '.', '/', ';', '?', '&'];
960
+ return {
961
+ expand: function expand(context) {
962
+ return template.replace(
963
+ /\{([^{}]+)}|([^{}]+)/g,
964
+ function (_, expression, literal) {
965
+ if (expression) {
966
+ var operator = null,
967
+ values = [];
968
+ if (operators.indexOf(expression.charAt(0)) !== -1) {
969
+ operator = expression.charAt(0);
970
+ expression = expression.substring(1);
971
+ }
972
+ expression.split(/,/g).forEach(function (variable) {
973
+ var tmp = /([^:*]*)(?::(\d+)|(\*))?/.exec(variable);
974
+ if (tmp) {
975
+ values.push.apply(
976
+ values,
977
+ getValues(context, operator, tmp[1], tmp[2] || tmp[3])
978
+ );
979
+ }
980
+ });
981
+ if (operator && operator !== '+') {
982
+ var separator = ',';
983
+ if (operator === '?') {
984
+ separator = '&';
985
+ } else if (operator !== '#') {
986
+ separator = operator;
987
+ }
988
+ return (
989
+ (values.length !== 0 ? operator : '') + values.join(separator)
990
+ );
991
+ } else {
992
+ return values.join(',');
993
+ }
994
+ } else {
995
+ return encodeReserved(literal);
996
+ }
997
+ }
998
+ );
999
+ },
1000
+ };
1001
+ }
1002
+
1003
+ function _class_call_check$1(instance, Constructor) {
1004
+ if (!(instance instanceof Constructor)) {
1005
+ throw new TypeError('Cannot call a class as a function');
1006
+ }
1007
+ }
1008
+ function _defineProperties$1(target, props) {
1009
+ for (var i = 0; i < props.length; i++) {
1010
+ var descriptor = props[i];
1011
+ descriptor.enumerable = descriptor.enumerable || false;
1012
+ descriptor.configurable = true;
1013
+ if ('value' in descriptor) descriptor.writable = true;
1014
+ Object.defineProperty(target, descriptor.key, descriptor);
1015
+ }
1016
+ }
1017
+ function _create_class$1(Constructor, protoProps, staticProps) {
1018
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
1019
+ if (staticProps) _defineProperties$1(Constructor, staticProps);
1020
+ return Constructor;
1021
+ }
1022
+ function _define_property$1(obj, key, value) {
1023
+ if (key in obj) {
1024
+ Object.defineProperty(obj, key, {
1025
+ value: value,
1026
+ enumerable: true,
1027
+ configurable: true,
1028
+ writable: true,
1029
+ });
1030
+ } else {
1031
+ obj[key] = value;
1032
+ }
1033
+ return obj;
1034
+ }
1035
+ function _object_spread(target) {
1036
+ for (var i = 1; i < arguments.length; i++) {
1037
+ var source = arguments[i] != null ? arguments[i] : {};
1038
+ var ownKeys = Object.keys(source);
1039
+ if (typeof Object.getOwnPropertySymbols === 'function') {
1040
+ ownKeys = ownKeys.concat(
1041
+ Object.getOwnPropertySymbols(source).filter(function (sym) {
1042
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
1043
+ })
1044
+ );
1045
+ }
1046
+ ownKeys.forEach(function (key) {
1047
+ _define_property$1(target, key, source[key]);
1048
+ });
1049
+ }
1050
+ return target;
1051
+ }
1052
+ var PatternCompiler = /*#__PURE__*/ (function () {
1053
+ function PatternCompiler(defaultView, installPlugins) {
1054
+ _class_call_check$1(this, PatternCompiler);
1055
+ _define_property$1(this, 'defaultView', void 0);
1056
+ _define_property$1(this, 'handlebars', void 0);
1057
+ this.defaultView = defaultView;
1058
+ this.handlebars = Handlebars.create();
1059
+ installPlugins(this.handlebars);
1060
+ }
1061
+ _create_class$1(
1062
+ PatternCompiler,
1063
+ [
1064
+ {
1065
+ key: 'compile',
1066
+ value: function compile(source, partialView) {
1067
+ if (!source) return '';
1068
+ var compiler = this.handlebars.compile(source);
1069
+ return compiler(_object_spread({}, this.defaultView, partialView));
1070
+ },
1071
+ },
1072
+ {
1073
+ key: 'keyToTemplate',
1074
+ value: function keyToTemplate(key) {
1075
+ return PatternCompiler.keyToTemplate(key);
1076
+ },
1077
+ },
1078
+ ],
1079
+ [
1080
+ {
1081
+ key: 'keyToTemplate',
1082
+ value: function keyToTemplate(key) {
1083
+ return '{{'.concat(key, '}}');
1084
+ },
1085
+ },
1086
+ ]
1087
+ );
1088
+ return PatternCompiler;
1089
+ })();
1090
+
1091
+ var eqPlugin = function (handlebars) {
1092
+ handlebars.registerHelper('eq', function (a, b) {
1093
+ return a === b;
1094
+ });
1095
+ };
1096
+
1097
+ function _array_like_to_array(arr, len) {
1098
+ if (len == null || len > arr.length) len = arr.length;
1099
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1100
+ return arr2;
1101
+ }
1102
+ function _array_without_holes(arr) {
1103
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
1104
+ }
1105
+ function _iterable_to_array(iter) {
1106
+ if (
1107
+ (typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
1108
+ iter['@@iterator'] != null
1109
+ )
1110
+ return Array.from(iter);
1111
+ }
1112
+ function _non_iterable_spread() {
1113
+ throw new TypeError(
1114
+ 'Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
1115
+ );
1116
+ }
1117
+ function _to_consumable_array(arr) {
1118
+ return (
1119
+ _array_without_holes(arr) ||
1120
+ _iterable_to_array(arr) ||
1121
+ _unsupported_iterable_to_array(arr) ||
1122
+ _non_iterable_spread()
1123
+ );
1124
+ }
1125
+ function _unsupported_iterable_to_array(o, minLen) {
1126
+ if (!o) return;
1127
+ if (typeof o === 'string') return _array_like_to_array(o, minLen);
1128
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1129
+ if (n === 'Object' && o.constructor) n = o.constructor.name;
1130
+ if (n === 'Map' || n === 'Set') return Array.from(n);
1131
+ if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
1132
+ return _array_like_to_array(o, minLen);
1133
+ }
1134
+ var mdParser = new MarkdownIt();
1135
+ var markdownPlugin = function (handlebars) {
1136
+ handlebars.registerHelper('md', function (markdownText) {
1137
+ if (!markdownText) return '';
1138
+ var cleanHtml = sanitizeHtml(mdParser.render(markdownText), {
1139
+ allowedTags: _to_consumable_array([
1140
+ 'h1',
1141
+ 'h2',
1142
+ 'h3',
1143
+ 'h4',
1144
+ 'h5',
1145
+ 'h6',
1146
+ 'b',
1147
+ ]).concat(
1148
+ _to_consumable_array([
1149
+ 'i',
1150
+ 'strong',
1151
+ 'em',
1152
+ 'a',
1153
+ 'ul',
1154
+ 'ol',
1155
+ 'li',
1156
+ 'p',
1157
+ 'br',
1158
+ ])
1159
+ ),
1160
+ allowedAttributes: {
1161
+ a: ['href', 'title', 'target'],
1162
+ },
1163
+ transformTags: {
1164
+ a: sanitizeHtml.simpleTransform('a', {
1165
+ target: '_blank',
1166
+ rel: 'noopener',
1167
+ }),
1168
+ },
1169
+ });
1170
+ return new Handlebars.SafeString(cleanHtml);
1171
+ });
1172
+ };
1173
+
1174
+ var stringPlugin = function (handlebars) {
1175
+ handlebars.registerHelper('subString', function (passedString, start, end) {
1176
+ var theString =
1177
+ passedString === null || passedString === void 0
1178
+ ? void 0
1179
+ : passedString.substring(start, end);
1180
+ return new Handlebars.SafeString(
1181
+ theString !== null && theString !== void 0 ? theString : ''
1182
+ );
1183
+ });
1184
+ };
1185
+
1186
+ function _class_call_check(instance, Constructor) {
1187
+ if (!(instance instanceof Constructor)) {
1188
+ throw new TypeError('Cannot call a class as a function');
1189
+ }
1190
+ }
1191
+ function _defineProperties(target, props) {
1192
+ for (var i = 0; i < props.length; i++) {
1193
+ var descriptor = props[i];
1194
+ descriptor.enumerable = descriptor.enumerable || false;
1195
+ descriptor.configurable = true;
1196
+ if ('value' in descriptor) descriptor.writable = true;
1197
+ Object.defineProperty(target, descriptor.key, descriptor);
1198
+ }
1199
+ }
1200
+ function _create_class(Constructor, protoProps, staticProps) {
1201
+ if (staticProps) _defineProperties(Constructor, staticProps);
1202
+ return Constructor;
1203
+ }
1204
+ function _define_property(obj, key, value) {
1205
+ if (key in obj) {
1206
+ Object.defineProperty(obj, key, {
1207
+ value: value,
1208
+ enumerable: true,
1209
+ configurable: true,
1210
+ writable: true,
1211
+ });
1212
+ } else {
1213
+ obj[key] = value;
1214
+ }
1215
+ return obj;
1216
+ }
1217
+ function _instanceof(left, right) {
1218
+ if (
1219
+ right != null &&
1220
+ typeof Symbol !== 'undefined' &&
1221
+ right[Symbol.hasInstance]
1222
+ ) {
1223
+ return !!right[Symbol.hasInstance](left);
1224
+ } else {
1225
+ return left instanceof right;
1226
+ }
1227
+ }
1228
+ var DateFormatter = /*#__PURE__*/ (function () {
1229
+ function DateFormatter() {
1230
+ _class_call_check(this, DateFormatter);
1231
+ }
1232
+ _create_class(DateFormatter, null, [
1233
+ {
1234
+ key: 'format',
1235
+ value: function format(date) {
1236
+ var validDate;
1237
+ if (typeof date === 'string') {
1238
+ validDate = new Date(date);
1239
+ } else {
1240
+ validDate = date;
1241
+ }
1242
+ return new Intl.DateTimeFormat('de-DE', {
1243
+ day: '2-digit',
1244
+ month: '2-digit',
1245
+ year: 'numeric',
1246
+ hour: '2-digit',
1247
+ minute: '2-digit',
1248
+ }).format(validDate);
1249
+ },
1250
+ },
1251
+ {
1252
+ key: 'formatFormal',
1253
+ value: function formatFormal(date) {
1254
+ var validDate;
1255
+ if (typeof date === 'string') {
1256
+ validDate = new Date(date);
1257
+ } else if (_instanceof(date, Date)) {
1258
+ validDate = date;
1259
+ } else {
1260
+ return 'INVALID '.concat(date);
1261
+ }
1262
+ return new Intl.DateTimeFormat('de-DE', {
1263
+ day: '2-digit',
1264
+ month: '2-digit',
1265
+ year: 'numeric',
1266
+ }).format(validDate);
1267
+ },
1268
+ },
1269
+ {
1270
+ key: 'formatMini',
1271
+ value: function formatMini(date) {
1272
+ var validDate;
1273
+ if (typeof date === 'string') {
1274
+ validDate = new Date(date);
1275
+ } else if (_instanceof(date, Date)) {
1276
+ validDate = date;
1277
+ } else {
1278
+ throw new RangeError('Invalid time value: ' + date);
1279
+ }
1280
+ return new Intl.DateTimeFormat('de-DE', {
1281
+ day: 'numeric',
1282
+ month: 'long',
1283
+ year: 'numeric',
1284
+ }).format(validDate);
1285
+ },
1286
+ },
1287
+ ]);
1288
+ return DateFormatter;
1289
+ })();
1290
+ _define_property(
1291
+ DateFormatter,
1292
+ 'getZoneAdjustedWeekday',
1293
+ function (dateString, options) {
1294
+ var timezone = options.timezone;
1295
+ return new Date(dateString).toLocaleDateString(options.locale, {
1296
+ weekday: 'long',
1297
+ timeZone: timezone,
1298
+ });
1299
+ }
1300
+ );
1301
+ _define_property(
1302
+ DateFormatter,
1303
+ 'getZoneAdjustedDate',
1304
+ function (dateString, options) {
1305
+ var timezone = options.timezone;
1306
+ return new Date(dateString).toLocaleDateString(options.locale, {
1307
+ month: 'long',
1308
+ day: 'numeric',
1309
+ timeZone: timezone,
1310
+ });
1311
+ }
1312
+ );
1313
+ _define_property(
1314
+ DateFormatter,
1315
+ 'getZoneAdjustedTime',
1316
+ function (dateString, options) {
1317
+ var timezone = options.timezone;
1318
+ return new Date(dateString)
1319
+ .toLocaleTimeString(options.locale, {
1320
+ hour: '2-digit',
1321
+ minute: '2-digit',
1322
+ hour12: false,
1323
+ timeZone: timezone,
1324
+ })
1325
+ .replace(/^0/, '');
1326
+ }
1327
+ );
1328
+
1329
+ var timezonePlugin = function (handlebars, param) {
1330
+ var timezone = param.timezone,
1331
+ locale = param.locale;
1332
+ handlebars.registerHelper('getZoneAdjustedWeekday', function (dateString) {
1333
+ return DateFormatter.getZoneAdjustedWeekday(dateString, {
1334
+ timezone: timezone,
1335
+ locale: locale,
1336
+ });
1337
+ });
1338
+ handlebars.registerHelper('getZoneAdjustedDate', function (dateString) {
1339
+ return DateFormatter.getZoneAdjustedDate(dateString, {
1340
+ timezone: timezone,
1341
+ locale: locale,
1342
+ });
1343
+ });
1344
+ handlebars.registerHelper('getZoneAdjustedTime', function (dateString) {
1345
+ return DateFormatter.getZoneAdjustedTime(dateString, {
1346
+ timezone: timezone,
1347
+ locale: locale,
1348
+ });
1349
+ });
1350
+ };
1351
+
1352
+ var urlPlugin = function (handlebars) {
1353
+ handlebars.registerHelper('urlSafe', function (inputString) {
1354
+ return encodeURIComponent(String(inputString));
1355
+ });
1356
+ };
1357
+
1358
+ var userTimezonePlugin = function (handlebars, param) {
1359
+ var timezone = param.timezone,
1360
+ locale = param.locale;
1361
+ handlebars.registerHelper(
1362
+ 'getUserZoneAdjustedWeekday',
1363
+ function (dateString, options) {
1364
+ var _options_hash, _options_hash1;
1365
+ var _options_hash_timezone, _options_hash_locale;
1366
+ return DateFormatter.getZoneAdjustedWeekday(dateString, {
1367
+ timezone:
1368
+ (_options_hash_timezone =
1369
+ options === null || options === void 0
1370
+ ? void 0
1371
+ : (_options_hash = options.hash) === null ||
1372
+ _options_hash === void 0
1373
+ ? void 0
1374
+ : _options_hash.timezone) !== null &&
1375
+ _options_hash_timezone !== void 0
1376
+ ? _options_hash_timezone
1377
+ : timezone,
1378
+ locale:
1379
+ (_options_hash_locale =
1380
+ options === null || options === void 0
1381
+ ? void 0
1382
+ : (_options_hash1 = options.hash) === null ||
1383
+ _options_hash1 === void 0
1384
+ ? void 0
1385
+ : _options_hash1.locale) !== null &&
1386
+ _options_hash_locale !== void 0
1387
+ ? _options_hash_locale
1388
+ : locale,
1389
+ });
1390
+ }
1391
+ );
1392
+ handlebars.registerHelper(
1393
+ 'getUserZoneAdjustedDate',
1394
+ function (dateString, options) {
1395
+ var _options_hash, _options_hash1;
1396
+ var _options_hash_timezone, _options_hash_locale;
1397
+ return DateFormatter.getZoneAdjustedDate(dateString, {
1398
+ timezone:
1399
+ (_options_hash_timezone =
1400
+ options === null || options === void 0
1401
+ ? void 0
1402
+ : (_options_hash = options.hash) === null ||
1403
+ _options_hash === void 0
1404
+ ? void 0
1405
+ : _options_hash.timezone) !== null &&
1406
+ _options_hash_timezone !== void 0
1407
+ ? _options_hash_timezone
1408
+ : timezone,
1409
+ locale:
1410
+ (_options_hash_locale =
1411
+ options === null || options === void 0
1412
+ ? void 0
1413
+ : (_options_hash1 = options.hash) === null ||
1414
+ _options_hash1 === void 0
1415
+ ? void 0
1416
+ : _options_hash1.locale) !== null &&
1417
+ _options_hash_locale !== void 0
1418
+ ? _options_hash_locale
1419
+ : locale,
1420
+ });
1421
+ }
1422
+ );
1423
+ handlebars.registerHelper(
1424
+ 'getUserZoneAdjustedTime',
1425
+ function (dateString, options) {
1426
+ var _options_hash, _options_hash1;
1427
+ var _options_hash_timezone, _options_hash_locale;
1428
+ return DateFormatter.getZoneAdjustedTime(dateString, {
1429
+ timezone:
1430
+ (_options_hash_timezone =
1431
+ options === null || options === void 0
1432
+ ? void 0
1433
+ : (_options_hash = options.hash) === null ||
1434
+ _options_hash === void 0
1435
+ ? void 0
1436
+ : _options_hash.timezone) !== null &&
1437
+ _options_hash_timezone !== void 0
1438
+ ? _options_hash_timezone
1439
+ : timezone,
1440
+ locale:
1441
+ (_options_hash_locale =
1442
+ options === null || options === void 0
1443
+ ? void 0
1444
+ : (_options_hash1 = options.hash) === null ||
1445
+ _options_hash1 === void 0
1446
+ ? void 0
1447
+ : _options_hash1.locale) !== null &&
1448
+ _options_hash_locale !== void 0
1449
+ ? _options_hash_locale
1450
+ : locale,
1451
+ });
1452
+ }
1453
+ );
1454
+ };
837
1455
 
838
1456
  exports.CookieHelper = CookieHelper;
1457
+ exports.DateFormatter = DateFormatter;
839
1458
  exports.HttpHandler = HttpHandler;
840
1459
  exports.NativeException = NativeException;
1460
+ exports.PatternCompiler = PatternCompiler;
841
1461
  exports.PgException = PgException;
842
1462
  exports.PostgresError = PostgresError;
1463
+ exports.eqPlugin = eqPlugin;
843
1464
  exports.logger = logger;
1465
+ exports.markdownPlugin = markdownPlugin;
1466
+ exports.parseTemplate = parseTemplate;
1467
+ exports.stringPlugin = stringPlugin;
1468
+ exports.timezonePlugin = timezonePlugin;
1469
+ exports.urlPlugin = urlPlugin;
1470
+ exports.userTimezonePlugin = userTimezonePlugin;