ngx-material-entity 15.3.1 → 16.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/classes/entity.model.d.ts +2 -2
  2. package/components/confirm-dialog/confirm-dialog-data.d.ts +1 -1
  3. package/components/edit-page/edit-page.component.d.ts +1 -1
  4. package/components/edit-page/page-edit-data.builder.d.ts +1 -1
  5. package/components/input/array/array-string-chips-input/array-string-chips-input.component.d.ts +1 -0
  6. package/components/input/array/array-table.class.d.ts +1 -1
  7. package/components/input/base-input.component.d.ts +5 -1
  8. package/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.d.ts +1 -1
  9. package/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.d.ts +1 -1
  10. package/components/input/file/file-input/file-input.component.d.ts +1 -1
  11. package/components/input/input.component.d.ts +2 -1
  12. package/components/table/display-column-value/base-display-column-value.component.d.ts +1 -1
  13. package/components/table/display-column-value/display-column-value.component.d.ts +1 -1
  14. package/components/table/table-data.builder.d.ts +1 -1
  15. package/components/table/table-data.d.ts +1 -1
  16. package/components/table/table.component.d.ts +1 -1
  17. package/decorators/base/decorator-types.enum.d.ts +1 -1
  18. package/decorators/base/property-decorator.data.d.ts +1 -1
  19. package/decorators/file/file-decorator.data.d.ts +1 -1
  20. package/decorators/number/number-decorator.data.d.ts +1 -1
  21. package/decorators/string/string-decorator.data.d.ts +1 -1
  22. package/encapsulation/jszip.utilities.d.ts +1 -1
  23. package/encapsulation/uuid.utilities.d.ts +11 -0
  24. package/esm2022/classes/base.builder.mjs +44 -0
  25. package/esm2022/classes/entity.model.mjs +26 -0
  26. package/esm2022/components/confirm-dialog/confirm-dialog-data.builder.mjs +58 -0
  27. package/esm2022/components/confirm-dialog/confirm-dialog.component.mjs +60 -0
  28. package/esm2022/components/edit-page/edit-page.component.mjs +291 -0
  29. package/esm2022/components/input/array/array-date-input/array-date-input.component.mjs +23 -0
  30. package/esm2022/components/input/array/array-date-range-input/array-date-range-input.component.mjs +49 -0
  31. package/esm2022/components/input/array/array-date-time-input/array-date-time-input.component.mjs +49 -0
  32. package/esm2022/components/input/array/array-string-autocomplete-chips/array-string-autocomplete-chips.component.mjs +50 -0
  33. package/esm2022/components/input/array/array-string-chips-input/array-string-chips-input.component.mjs +69 -0
  34. package/esm2022/components/input/array/array-table.class.mjs +100 -0
  35. package/esm2022/components/input/base-input.component.mjs +88 -0
  36. package/esm2022/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.mjs +21 -0
  37. package/esm2022/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.mjs +17 -0
  38. package/esm2022/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.mjs +21 -0
  39. package/esm2022/components/input/custom/custom.component.mjs +28 -0
  40. package/esm2022/components/input/date/date-input/date-input.component.mjs +19 -0
  41. package/esm2022/components/input/date/date-range-input/date-range-input.component.mjs +68 -0
  42. package/esm2022/components/input/date/date-time-input/date-time-input.component.mjs +69 -0
  43. package/{esm2020 → esm2022}/components/input/file/file-default-input/file-default-input.component.mjs +4 -4
  44. package/esm2022/components/input/file/file-image-input/file-image-input.component.mjs +101 -0
  45. package/esm2022/components/input/file/file-input/dragDrop.directive.mjs +62 -0
  46. package/esm2022/components/input/file/file-input/file-input.component.mjs +206 -0
  47. package/esm2022/components/input/input.component.mjs +849 -0
  48. package/esm2022/components/input/input.module.mjs +172 -0
  49. package/esm2022/components/input/number/number-dropdown-input/number-dropdown-input.component.mjs +23 -0
  50. package/esm2022/components/input/number/number-input/number-input.component.mjs +16 -0
  51. package/esm2022/components/input/number/number-slider-input/number-slider-input.component.mjs +17 -0
  52. package/esm2022/components/input/relations/references-many-input/references-many-input.component.mjs +102 -0
  53. package/esm2022/components/input/string/string-autocomplete-input/string-autocomplete-input.component.mjs +36 -0
  54. package/esm2022/components/input/string/string-dropdown-input/string-dropdown-input.component.mjs +23 -0
  55. package/esm2022/components/input/string/string-input/string-input.component.mjs +16 -0
  56. package/esm2022/components/input/string/string-password-input/string-password-input.component.mjs +39 -0
  57. package/esm2022/components/input/string/string-textbox-input/string-textbox-input.component.mjs +17 -0
  58. package/esm2022/components/table/create-dialog/create-dialog-data.builder.mjs +42 -0
  59. package/esm2022/components/table/create-dialog/create-entity-dialog-data.builder.mjs +32 -0
  60. package/esm2022/components/table/create-dialog/create-entity-dialog.component.mjs +107 -0
  61. package/esm2022/components/table/display-column-value/base-display-column-value.component.mjs +28 -0
  62. package/esm2022/components/table/display-column-value/display-column-value.component.mjs +37 -0
  63. package/esm2022/components/table/edit-dialog/edit-data.builder.mjs +106 -0
  64. package/esm2022/components/table/edit-dialog/edit-entity-dialog.component.mjs +209 -0
  65. package/esm2022/components/table/edit-dialog/edit-entity.builder.mjs +39 -0
  66. package/esm2022/components/table/table-data.builder.mjs +269 -0
  67. package/esm2022/components/table/table.component.mjs +348 -0
  68. package/esm2022/decorators/array/array-decorator-internal.data.mjs +286 -0
  69. package/esm2022/decorators/array/array-decorator.data.mjs +21 -0
  70. package/esm2022/decorators/base/property-decorator-internal.data.mjs +82 -0
  71. package/esm2022/decorators/base/property-decorator.data.mjs +56 -0
  72. package/esm2022/decorators/boolean/boolean-decorator-internal.data.mjs +43 -0
  73. package/esm2022/decorators/boolean/boolean-decorator.data.mjs +11 -0
  74. package/esm2022/decorators/custom/custom-decorator-internal.data.mjs +35 -0
  75. package/{esm2020 → esm2022}/decorators/date/date-decorator-internal.data.mjs +43 -1
  76. package/esm2022/decorators/date/date-decorator.data.mjs +11 -0
  77. package/esm2022/decorators/file/file-decorator-internal.data.mjs +143 -0
  78. package/esm2022/decorators/file/file-decorator.data.mjs +64 -0
  79. package/esm2022/decorators/has-many/has-many-decorator-internal.data.mjs +42 -0
  80. package/esm2022/decorators/number/number-decorator-internal.data.mjs +76 -0
  81. package/esm2022/decorators/number/number-decorator.data.mjs +11 -0
  82. package/esm2022/decorators/object/object-decorator-internal.data.mjs +20 -0
  83. package/esm2022/decorators/object/object-decorator.data.mjs +22 -0
  84. package/esm2022/decorators/references-many/references-many-decorator-internal.data.mjs +48 -0
  85. package/esm2022/decorators/references-one/references-one-decorator-internal.data.mjs +24 -0
  86. package/esm2022/decorators/string/string-decorator-internal.data.mjs +114 -0
  87. package/esm2022/decorators/string/string-decorator.data.mjs +11 -0
  88. package/esm2022/encapsulation/uuid.utilities.mjs +15 -0
  89. package/esm2022/services/entity.service.mjs +276 -0
  90. package/esm2022/utilities/date.utilities.mjs +159 -0
  91. package/esm2022/utilities/entity.utilities.mjs +905 -0
  92. package/{fesm2020 → fesm2022}/ngx-material-entity.mjs +1225 -376
  93. package/fesm2022/ngx-material-entity.mjs.map +1 -0
  94. package/package.json +14 -19
  95. package/utilities/date.utilities.d.ts +1 -1
  96. package/esm2020/classes/base.builder.mjs +0 -42
  97. package/esm2020/classes/entity.model.mjs +0 -22
  98. package/esm2020/components/confirm-dialog/confirm-dialog-data.builder.mjs +0 -44
  99. package/esm2020/components/confirm-dialog/confirm-dialog.component.mjs +0 -57
  100. package/esm2020/components/edit-page/edit-page.component.mjs +0 -277
  101. package/esm2020/components/input/array/array-date-input/array-date-input.component.mjs +0 -26
  102. package/esm2020/components/input/array/array-date-range-input/array-date-range-input.component.mjs +0 -50
  103. package/esm2020/components/input/array/array-date-time-input/array-date-time-input.component.mjs +0 -49
  104. package/esm2020/components/input/array/array-string-autocomplete-chips/array-string-autocomplete-chips.component.mjs +0 -49
  105. package/esm2020/components/input/array/array-string-chips-input/array-string-chips-input.component.mjs +0 -70
  106. package/esm2020/components/input/array/array-table.class.mjs +0 -96
  107. package/esm2020/components/input/base-input.component.mjs +0 -64
  108. package/esm2020/components/input/boolean/boolean-checkbox-input/boolean-checkbox-input.component.mjs +0 -21
  109. package/esm2020/components/input/boolean/boolean-dropdown-input/boolean-dropdown-input.component.mjs +0 -17
  110. package/esm2020/components/input/boolean/boolean-toggle-input/boolean-toggle-input.component.mjs +0 -21
  111. package/esm2020/components/input/custom/custom.component.mjs +0 -26
  112. package/esm2020/components/input/date/date-input/date-input.component.mjs +0 -22
  113. package/esm2020/components/input/date/date-range-input/date-range-input.component.mjs +0 -71
  114. package/esm2020/components/input/date/date-time-input/date-time-input.component.mjs +0 -71
  115. package/esm2020/components/input/file/file-image-input/file-image-input.component.mjs +0 -100
  116. package/esm2020/components/input/file/file-input/dragDrop.directive.mjs +0 -63
  117. package/esm2020/components/input/file/file-input/file-input.component.mjs +0 -198
  118. package/esm2020/components/input/input.component.mjs +0 -755
  119. package/esm2020/components/input/input.module.mjs +0 -173
  120. package/esm2020/components/input/number/number-dropdown-input/number-dropdown-input.component.mjs +0 -26
  121. package/esm2020/components/input/number/number-input/number-input.component.mjs +0 -16
  122. package/esm2020/components/input/number/number-slider-input/number-slider-input.component.mjs +0 -17
  123. package/esm2020/components/input/relations/references-many-input/references-many-input.component.mjs +0 -100
  124. package/esm2020/components/input/string/string-autocomplete-input/string-autocomplete-input.component.mjs +0 -34
  125. package/esm2020/components/input/string/string-dropdown-input/string-dropdown-input.component.mjs +0 -26
  126. package/esm2020/components/input/string/string-input/string-input.component.mjs +0 -16
  127. package/esm2020/components/input/string/string-password-input/string-password-input.component.mjs +0 -42
  128. package/esm2020/components/input/string/string-textbox-input/string-textbox-input.component.mjs +0 -17
  129. package/esm2020/components/table/create-dialog/create-dialog-data.builder.mjs +0 -32
  130. package/esm2020/components/table/create-dialog/create-entity-dialog-data.builder.mjs +0 -26
  131. package/esm2020/components/table/create-dialog/create-entity-dialog.component.mjs +0 -100
  132. package/esm2020/components/table/display-column-value/base-display-column-value.component.mjs +0 -27
  133. package/esm2020/components/table/display-column-value/display-column-value.component.mjs +0 -33
  134. package/esm2020/components/table/edit-dialog/edit-data.builder.mjs +0 -76
  135. package/esm2020/components/table/edit-dialog/edit-entity-dialog.component.mjs +0 -198
  136. package/esm2020/components/table/edit-dialog/edit-entity.builder.mjs +0 -29
  137. package/esm2020/components/table/table-data.builder.mjs +0 -205
  138. package/esm2020/components/table/table.component.mjs +0 -333
  139. package/esm2020/decorators/array/array-decorator-internal.data.mjs +0 -150
  140. package/esm2020/decorators/array/array-decorator.data.mjs +0 -7
  141. package/esm2020/decorators/base/property-decorator-internal.data.mjs +0 -58
  142. package/esm2020/decorators/base/property-decorator.data.mjs +0 -6
  143. package/esm2020/decorators/boolean/boolean-decorator-internal.data.mjs +0 -33
  144. package/esm2020/decorators/boolean/boolean-decorator.data.mjs +0 -7
  145. package/esm2020/decorators/custom/custom-decorator-internal.data.mjs +0 -27
  146. package/esm2020/decorators/date/date-decorator.data.mjs +0 -7
  147. package/esm2020/decorators/file/file-decorator-internal.data.mjs +0 -97
  148. package/esm2020/decorators/file/file-decorator.data.mjs +0 -7
  149. package/esm2020/decorators/has-many/has-many-decorator-internal.data.mjs +0 -32
  150. package/esm2020/decorators/number/number-decorator-internal.data.mjs +0 -54
  151. package/esm2020/decorators/number/number-decorator.data.mjs +0 -7
  152. package/esm2020/decorators/object/object-decorator-internal.data.mjs +0 -14
  153. package/esm2020/decorators/object/object-decorator.data.mjs +0 -7
  154. package/esm2020/decorators/references-many/references-many-decorator-internal.data.mjs +0 -30
  155. package/esm2020/decorators/references-one/references-one-decorator-internal.data.mjs +0 -16
  156. package/esm2020/decorators/string/string-decorator-internal.data.mjs +0 -72
  157. package/esm2020/decorators/string/string-decorator.data.mjs +0 -7
  158. package/esm2020/services/entity.service.mjs +0 -274
  159. package/esm2020/utilities/date.utilities.mjs +0 -159
  160. package/esm2020/utilities/entity.utilities.mjs +0 -905
  161. package/fesm2015/ngx-material-entity.mjs +0 -6322
  162. package/fesm2015/ngx-material-entity.mjs.map +0 -1
  163. package/fesm2020/ngx-material-entity.mjs.map +0 -1
  164. /package/{esm2020 → esm2022}/components/confirm-dialog/confirm-dialog-data.mjs +0 -0
  165. /package/{esm2020 → esm2022}/components/edit-page/edit-data.route.mjs +0 -0
  166. /package/{esm2020 → esm2022}/components/edit-page/page-edit-data.builder.mjs +0 -0
  167. /package/{esm2020 → esm2022}/components/get-validation-error-message.function.mjs +0 -0
  168. /package/{esm2020 → esm2022}/components/table/create-dialog/create-entity-dialog-data.mjs +0 -0
  169. /package/{esm2020 → esm2022}/components/table/default.actions.mjs +0 -0
  170. /package/{esm2020 → esm2022}/components/table/edit-dialog/edit-entity-data.mjs +0 -0
  171. /package/{esm2020 → esm2022}/components/table/table-data.mjs +0 -0
  172. /package/{esm2020 → esm2022}/decorators/array/array.decorator.mjs +0 -0
  173. /package/{esm2020 → esm2022}/decorators/base/base-property.decorator.mjs +0 -0
  174. /package/{esm2020 → esm2022}/decorators/base/decorator-types.enum.mjs +0 -0
  175. /package/{esm2020 → esm2022}/decorators/base/dropdown-value.interface.mjs +0 -0
  176. /package/{esm2020 → esm2022}/decorators/boolean/boolean.decorator.mjs +0 -0
  177. /package/{esm2020 → esm2022}/decorators/custom/custom-decorator.data.mjs +0 -0
  178. /package/{esm2020 → esm2022}/decorators/custom/custom.decorator.mjs +0 -0
  179. /package/{esm2020 → esm2022}/decorators/date/date.decorator.mjs +0 -0
  180. /package/{esm2020 → esm2022}/decorators/file/file.decorator.mjs +0 -0
  181. /package/{esm2020 → esm2022}/decorators/has-many/has-many-decorator.data.mjs +0 -0
  182. /package/{esm2020 → esm2022}/decorators/has-many/has-many.decorator.mjs +0 -0
  183. /package/{esm2020 → esm2022}/decorators/number/number.decorator.mjs +0 -0
  184. /package/{esm2020 → esm2022}/decorators/object/object.decorator.mjs +0 -0
  185. /package/{esm2020 → esm2022}/decorators/references-many/references-many-decorator.data.mjs +0 -0
  186. /package/{esm2020 → esm2022}/decorators/references-many/references-many.decorator.mjs +0 -0
  187. /package/{esm2020 → esm2022}/decorators/references-one/references-one-decorator.data.mjs +0 -0
  188. /package/{esm2020 → esm2022}/decorators/references-one/references-one.decorator.mjs +0 -0
  189. /package/{esm2020 → esm2022}/decorators/string/string.decorator.mjs +0 -0
  190. /package/{esm2020 → esm2022}/encapsulation/js-2-xml.utilities.mjs +0 -0
  191. /package/{esm2020 → esm2022}/encapsulation/jszip.utilities.mjs +0 -0
  192. /package/{esm2020 → esm2022}/encapsulation/lodash.utilities.mjs +0 -0
  193. /package/{esm2020 → esm2022}/encapsulation/reflect.utilities.mjs +0 -0
  194. /package/{esm2020 → esm2022}/functions/default-false.function.mjs +0 -0
  195. /package/{esm2020 → esm2022}/functions/default-true.function.mjs +0 -0
  196. /package/{esm2020 → esm2022}/functions/is-async-function.function.mjs +0 -0
  197. /package/{esm2020 → esm2022}/mocks/placeholder-data.png.mjs +0 -0
  198. /package/{esm2020 → esm2022}/ngx-material-entity.mjs +0 -0
  199. /package/{esm2020 → esm2022}/public-api.mjs +0 -0
  200. /package/{esm2020 → esm2022}/services/unsaved-changes.guard.mjs +0 -0
  201. /package/{esm2020 → esm2022}/utilities/file.utilities.mjs +0 -0
  202. /package/{esm2020 → esm2022}/utilities/selection.utilities.mjs +0 -0
@@ -0,0 +1,159 @@
1
+ import { LodashUtilities } from '../encapsulation/lodash.utilities';
2
+ import { defaultTrue } from '../functions/default-true.function';
3
+ const DAY_IN_MS = 1000 * 60 * 60 * 24;
4
+ /**
5
+ * Contains Helper Functions for handling date properties.
6
+ */
7
+ export class DateUtilities {
8
+ /**
9
+ * The default filter function to user when none was provided by the user.
10
+ */
11
+ static defaultDateFilter = defaultTrue;
12
+ /**
13
+ * Gets the given value as a date value.
14
+ *
15
+ * @param value - The value to get as a date.
16
+ * @returns The given value as a date.
17
+ */
18
+ static asDate(value) {
19
+ return value;
20
+ }
21
+ /**
22
+ * Gets the default times used by the DateTime picker when nothing is specified by the user.
23
+ *
24
+ * @param format - The time format. Defaults to 24.
25
+ * @param minuteSteps - The steps from one time value to the next. Defaults to 30.
26
+ * @returns Times in the 24 hour format from 0:00 until 23:30 in 30 minute steps.
27
+ */
28
+ static getDefaultTimes(format = 24, minuteSteps = 30) {
29
+ const res = [{ displayName: '-', value: undefined }];
30
+ for (let hour = 0; hour < 24; hour++) {
31
+ for (let minute = 0; minute < 60; minute += minuteSteps) {
32
+ res.push(DateUtilities.getTimeDropdownValue(format, hour, minute));
33
+ }
34
+ }
35
+ return res;
36
+ }
37
+ static getTimeDropdownValue(format, hour, minute) {
38
+ const displayHour = DateUtilities.getFormattedHour(format, LodashUtilities.cloneDeep(hour));
39
+ const displayMinute = DateUtilities.getFormattedMinute(format, hour, minute);
40
+ return {
41
+ displayName: `${displayHour}:${displayMinute}`,
42
+ value: {
43
+ hours: hour,
44
+ minutes: minute
45
+ }
46
+ };
47
+ }
48
+ static getFormattedHour(format, hour) {
49
+ if (format === 12 && hour > 12) {
50
+ hour -= 12;
51
+ }
52
+ return hour;
53
+ }
54
+ static getFormattedMinute(format, hour, minute) {
55
+ let res = `${minute}`;
56
+ if (format === 12) {
57
+ if (hour > 12) {
58
+ res = `${minute} PM`;
59
+ }
60
+ else {
61
+ res = `${minute} AM`;
62
+ }
63
+ }
64
+ if (minute.toString().length === 1) {
65
+ res = '0'.concat(res);
66
+ }
67
+ return res;
68
+ }
69
+ /**
70
+ * Gets the Time object from the given date.
71
+ *
72
+ * @param value - The date to get the time object from.
73
+ * @returns The Time object build from the date value.
74
+ */
75
+ static getTimeFromDate(value) {
76
+ if (!value) {
77
+ return undefined;
78
+ }
79
+ else {
80
+ return {
81
+ hours: new Date(value).getHours(),
82
+ minutes: new Date(value).getMinutes()
83
+ };
84
+ }
85
+ }
86
+ /**
87
+ * Gets the dates between the two given gates. Does additional filtering based on the provided DateRange metadata.
88
+ *
89
+ * @param startDate - The start date.
90
+ * @param endDate - The end date.
91
+ * @param filter - The custom filter from the metadata.
92
+ * @returns All dates between the two provided dates. Includes start and end date.
93
+ */
94
+ static getDatesBetween(startDate, endDate, filter) {
95
+ const res = [];
96
+ while (startDate.getFullYear() < endDate.getFullYear()
97
+ || startDate.getMonth() < endDate.getMonth()
98
+ || startDate.getDate() <= endDate.getDate()) {
99
+ res.push(new Date(startDate));
100
+ startDate.setTime(startDate.getTime() + DAY_IN_MS);
101
+ }
102
+ if (filter) {
103
+ return res.filter(d => filter(d));
104
+ }
105
+ else {
106
+ return res;
107
+ }
108
+ }
109
+ /**
110
+ * Get all valid times for the dropdown of a datetime property.
111
+ *
112
+ * @param times - All given times to filter.
113
+ * @param date - The date of the datetime.
114
+ * @param min - The function that defines the minimum time.
115
+ * @param max - The function that defines the maximum time.
116
+ * @param filter - A filter function to do more specific time filtering. This could be e.g. The removal of lunch breaks.
117
+ * @returns All valid dropdown values for the datetime property.
118
+ */
119
+ static getValidTimesForDropdown(times, date, min, max, filter) {
120
+ if (min) {
121
+ const minTime = min(date);
122
+ times = times.filter(t => !t.value
123
+ || t.value.hours > minTime.hours
124
+ || (t.value.hours === minTime.hours
125
+ && t.value.minutes >= minTime.minutes));
126
+ }
127
+ if (max) {
128
+ const maxTime = max(date);
129
+ times = times.filter(t => !t.value
130
+ || t.value.hours < maxTime.hours
131
+ || (t.value.hours === maxTime.hours
132
+ && t.value.minutes <= maxTime.minutes));
133
+ }
134
+ if (filter) {
135
+ times = times.filter(t => !t.value || filter(t.value));
136
+ }
137
+ return times;
138
+ }
139
+ /**
140
+ * Checks if the time object has processable hours and minutes properties.
141
+ * Doesn't check custom validators like min/max from the metadata configuration.
142
+ *
143
+ * @param time - The time to check.
144
+ * @returns Whether or not the time object is unprocessable.
145
+ */
146
+ static timeIsUnprocessable(time) {
147
+ if (!time
148
+ || time.hours == null
149
+ || typeof time.hours !== 'number'
150
+ || Number.isNaN(time.hours)
151
+ || time.minutes == null
152
+ || typeof time.minutes !== 'number'
153
+ || Number.isNaN(time.minutes)) {
154
+ return true;
155
+ }
156
+ return false;
157
+ }
158
+ }
159
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGF0ZS51dGlsaXRpZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9wcm9qZWN0cy9uZ3gtbWF0ZXJpYWwtZW50aXR5L3NyYy91dGlsaXRpZXMvZGF0ZS51dGlsaXRpZXMudHMiXSwibmFtZXMiOltdLC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yO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBob3VyO1xuICAgIH1cblxuICAgIHByaXZhdGUgc3RhdGljIGdldEZvcm1hdHRlZE1pbnV0ZShmb3JtYXQ6IDEyIHwgMjQsIGhvdXI6IG51bWJlciwgbWludXRlOiBudW1iZXIpOiBzdHJpbmcge1xuICAgICAgICBsZXQgcmVzOiBzdHJpbmcgPSBgJHttaW51dGV9YDtcbiAgICAgICAgaWYgKGZvcm1hdCA9PT0gMTIpIHtcbiAgICAgICAgICAgIGlmIChob3VyID4gMTIpIHtcbiAgICAgICAgICAgICAgICByZXMgPSBgJHttaW51dGV9IFBNYDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHJlcyA9IGAke21pbnV0ZX0gQU1gO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChtaW51dGUudG9TdHJpbmcoKS5sZW5ndGggPT09IDEpIHtcbiAgICAgICAgICAgIHJlcyA9ICcwJy5jb25jYXQocmVzKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gcmVzO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIEdldHMgdGhlIFRpbWUgb2JqZWN0IGZyb20gdGhlIGdpdmVuIGRhdGUuXG4gICAgICpcbiAgICAgKiBAcGFyYW0gdmFsdWUgLSBUaGUgZGF0ZSB0byBnZXQgdGhlIHRpbWUgb2JqZWN0IGZyb20uXG4gICAgICogQHJldHVybnMgVGhlIFRpbWUgb2JqZWN0IGJ1aWxkIGZyb20gdGhlIGRhdGUgdmFsdWUuXG4gICAgICovXG4gICAgc3RhdGljIGdldFRpbWVGcm9tRGF0ZSh2YWx1ZT86IERhdGUpOiBUaW1lIHwgdW5kZWZpbmVkIHtcbiAgICAgICAgaWYgKCF2YWx1ZSkge1xuICAgICAgICAgICAgcmV0dXJuIHVuZGVmaW5lZDtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICA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d24gdmFsdWVzIGZvciB0aGUgZGF0ZXRpbWUgcHJvcGVydHkuXG4gICAgICovXG4gICAgc3RhdGljIGdldFZhbGlkVGltZXNGb3JEcm9wZG93bihcbiAgICAgICAgdGltZXM6IERyb3Bkb3duVmFsdWU8VGltZSB8IHVuZGVmaW5lZD5bXSxcbiAgICAgICAgZGF0ZT86IERhdGUsXG4gICAgICAgIG1pbj86IChkYXRlPzogRGF0ZSkgPT4gVGltZSxcbiAgICAgICAgbWF4PzogKGRhdGU/OiBEYXRlKSA9PiBUaW1lLFxuICAgICAgICBmaWx0ZXI/OiAoKHRpbWU6IFRpbWUpID0+IGJvb2xlYW4pIHwgKCgpID0+IGJvb2xlYW4pXG4gICAgKTogRHJvcGRvd25WYWx1ZTxUaW1lIHwgdW5kZWZpbmVkPltdIHtcbiAgICAgICAgaWYgKG1pbikge1xuICAgICAgICAgICAgY29uc3QgbWluVGltZTogVGltZSA9IG1pbihkYXRlKTtcbiAgICAgICAgICAgIHRpbWVzID0gdGltZXMuZmlsdGVyKHQgPT5cbiAgICAgICAgICAgICAgICAhdC52YWx1ZVxuICAgICAgICAgICAgICAgIHx8IHQudmFsdWUuaG91cnMgPiBtaW5UaW1lLmhvdXJzXG4gICAgICAgICAgICAgICAgfHwgKFxuICAgICAgICAgICAgICAgICAgICB0LnZhbHVlLmhvdXJzID09PSBtaW5UaW1lLmhvdXJzXG4gICAgICAgICAgICAgICAgICAgICYmIHQudmFsdWUubWludXRlcyA+PSBtaW5UaW1lLm1pbnV0ZXNcbiAgICAgICAgICAgICAgICApXG4gICAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICAgIGlmIChtYXgpIHtcbiAgICAgICAgICAgIGNvbnN0IG1heFRpbWU6IFRpbWUgPSBtYXgoZGF0ZSk7XG4gICAgICAgICAgICB0aW1lcyA9IHRpbWVzLmZpbHRlcih0ID0+XG4gICAgICAgICAgICAgICAgIXQudmFsdWVcbiAgICAgICAgICAgICAgICB8fCB0LnZhbHVlLmhvdXJzIDwgbWF4VGltZS5ob3Vyc1xuICAgICAgICAgICAgICAgIHx8IChcbiAgICAgICAgICAgICAgICAgICAgdC52YWx1ZS5ob3VycyA9PT0gbWF4VGltZS5ob3Vyc1xuICAgICAgICAgICAgICAgICAgICAmJiB0LnZhbHVlLm1pbnV0ZXMgPD0gbWF4VGltZS5taW51dGVzXG4gICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoZmlsdGVyKSB7XG4gICAgICAgICAgICB0aW1lcyA9IHRpbWVzLmZpbHRlcih0ID0+ICF0LnZhbHVlIHx8IGZpbHRlcih0LnZhbHVlKSk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdGltZXM7XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ2hlY2tzIGlmIHRoZSB0aW1lIG9iamVjdCBoYXMgcHJvY2Vzc2FibGUgaG91cnMgYW5kIG1pbnV0ZXMgcHJvcGVydGllcy5cbiAgICAgKiBEb2Vzbid0IGNoZWNrIGN1c3RvbSB2YWxpZGF0b3JzIGxpa2UgbWluL21heCBmcm9tIHRoZSBtZXRhZGF0YSBjb25maWd1cmF0aW9uLlxuICAgICAqXG4gICAgICogQHBhcmFtIHRpbWUgLSBUaGUgdGltZSB0byBjaGVjay5cbiAgICAgKiBAcmV0dXJucyBXaGV0aGVyIG9yIG5vdCB0aGUgdGltZSBvYmplY3QgaXMgdW5wcm9jZXNzYWJsZS5cbiAgICAgKi9cbiAgICBzdGF0aWMgdGltZUlzVW5wcm9jZXNzYWJsZSh0aW1lPzogVGltZSk6IGJvb2xlYW4ge1xuICAgICAgICBpZiAoXG4gICAgICAgICAgICAhdGltZVxuICAgICAgICAgICAgfHwgdGltZS5ob3VycyA9PSBudWxsXG4gICAgICAgICAgICB8fCB0eXBlb2YgdGltZS5ob3VycyAhPT0gJ251bWJlcidcbiAgICAgICAgICAgIHx8IE51bWJlci5pc05hTih0aW1lLmhvdXJzKVxuICAgICAgICAgICAgfHwgdGltZS5taW51dGVzID09IG51bGxcbiAgICAgICAgICAgIHx8IHR5cGVvZiB0aW1lLm1pbnV0ZXMgIT09ICdudW1iZXInXG4gICAgICAgICAgICB8fCBOdW1iZXIuaXNOYU4odGltZS5taW51dGVzKVxuICAgICAgICApIHtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBmYWxzZTtcbiAgICB9XG59Il19