@leavittsoftware/web 1.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.
Files changed (294) hide show
  1. package/leavitt/api-service/HttpError.d.ts +10 -0
  2. package/leavitt/api-service/HttpError.js +2 -0
  3. package/leavitt/api-service/HttpError.js.map +1 -0
  4. package/leavitt/api-service/api-service.d.ts +27 -0
  5. package/leavitt/api-service/api-service.js +332 -0
  6. package/leavitt/api-service/api-service.js.map +1 -0
  7. package/leavitt/api-service/api2-service.d.ts +338 -0
  8. package/leavitt/api-service/api2-service.js +17 -0
  9. package/leavitt/api-service/api2-service.js.map +1 -0
  10. package/leavitt/api-service/authenticated-token-provider.d.ts +5 -0
  11. package/leavitt/api-service/authenticated-token-provider.js +7 -0
  12. package/leavitt/api-service/authenticated-token-provider.js.map +1 -0
  13. package/leavitt/api-service/bearer-token-provider.d.ts +4 -0
  14. package/leavitt/api-service/bearer-token-provider.js +2 -0
  15. package/leavitt/api-service/bearer-token-provider.js.map +1 -0
  16. package/leavitt/api-service/mapi-service.d.ts +338 -0
  17. package/leavitt/api-service/mapi-service.js +17 -0
  18. package/leavitt/api-service/mapi-service.js.map +1 -0
  19. package/leavitt/api-service/no-authentication-token-provider.d.ts +5 -0
  20. package/leavitt/api-service/no-authentication-token-provider.js +6 -0
  21. package/leavitt/api-service/no-authentication-token-provider.js.map +1 -0
  22. package/leavitt/api-service/odata-dto.d.ts +6 -0
  23. package/leavitt/api-service/odata-dto.js +7 -0
  24. package/leavitt/api-service/odata-dto.js.map +1 -0
  25. package/leavitt/api-service/odata-model-info.d.ts +5 -0
  26. package/leavitt/api-service/odata-model-info.js +7 -0
  27. package/leavitt/api-service/odata-model-info.js.map +1 -0
  28. package/leavitt/api-service/odata-response.d.ts +15 -0
  29. package/leavitt/api-service/odata-response.js +50 -0
  30. package/leavitt/api-service/odata-response.js.map +1 -0
  31. package/leavitt/api-service/status-codes.d.ts +2 -0
  32. package/leavitt/api-service/status-codes.js +44 -0
  33. package/leavitt/api-service/status-codes.js.map +1 -0
  34. package/leavitt/company-select/company-select.d.ts +50 -0
  35. package/leavitt/company-select/company-select.js +157 -0
  36. package/leavitt/company-select/company-select.js.map +1 -0
  37. package/leavitt/person-company-select/person-company-select.d.ts +41 -0
  38. package/leavitt/person-company-select/person-company-select.js +180 -0
  39. package/leavitt/person-company-select/person-company-select.js.map +1 -0
  40. package/leavitt/person-group-select/people-group-icons.d.ts +5 -0
  41. package/leavitt/person-group-select/people-group-icons.js +66 -0
  42. package/leavitt/person-group-select/people-group-icons.js.map +1 -0
  43. package/leavitt/person-group-select/person-group-select.d.ts +41 -0
  44. package/leavitt/person-group-select/person-group-select.js +186 -0
  45. package/leavitt/person-group-select/person-group-select.js.map +1 -0
  46. package/leavitt/person-select/person-select.d.ts +33 -0
  47. package/leavitt/person-select/person-select.js +128 -0
  48. package/leavitt/person-select/person-select.js.map +1 -0
  49. package/leavitt/profile-picture/profile-picture-menu.d.ts +44 -0
  50. package/leavitt/profile-picture/profile-picture-menu.js +197 -0
  51. package/leavitt/profile-picture/profile-picture-menu.js.map +1 -0
  52. package/leavitt/profile-picture/profile-picture.d.ts +39 -0
  53. package/leavitt/profile-picture/profile-picture.js +151 -0
  54. package/leavitt/profile-picture/profile-picture.js.map +1 -0
  55. package/leavitt/user-feedback/user-feedback.d.ts +357 -0
  56. package/leavitt/user-feedback/user-feedback.js +207 -0
  57. package/leavitt/user-feedback/user-feedback.js.map +1 -0
  58. package/leavitt/user-manager/LssJwtToken.d.ts +21 -0
  59. package/leavitt/user-manager/LssJwtToken.js +2 -0
  60. package/leavitt/user-manager/LssJwtToken.js.map +1 -0
  61. package/leavitt/user-manager/user-manager-events.d.ts +5 -0
  62. package/leavitt/user-manager/user-manager-events.js +7 -0
  63. package/leavitt/user-manager/user-manager-events.js.map +1 -0
  64. package/leavitt/user-manager/user-manager.d.ts +37 -0
  65. package/leavitt/user-manager/user-manager.js +364 -0
  66. package/leavitt/user-manager/user-manager.js.map +1 -0
  67. package/package.json +36 -0
  68. package/titanium/access-denied-page/access-denied-page.d.ts +16 -0
  69. package/titanium/access-denied-page/access-denied-page.js +360 -0
  70. package/titanium/access-denied-page/access-denied-page.js.map +1 -0
  71. package/titanium/address-input/Address.js.map +1 -0
  72. package/titanium/address-input/address-input.d.ts +29 -0
  73. package/titanium/address-input/address-input.js +77 -0
  74. package/titanium/address-input/address-input.js.map +1 -0
  75. package/titanium/address-input/google-address-input.d.ts +30 -0
  76. package/titanium/address-input/google-address-input.js +202 -0
  77. package/titanium/address-input/google-address-input.js.map +1 -0
  78. package/titanium/address-input/manual-address-dialog.d.ts +30 -0
  79. package/titanium/address-input/manual-address-dialog.js +250 -0
  80. package/titanium/address-input/manual-address-dialog.js.map +1 -0
  81. package/titanium/address-input/types/address-input-address.d.ts +17 -0
  82. package/titanium/address-input/types/address-input-address.js +2 -0
  83. package/titanium/address-input/types/address-input-address.js.map +1 -0
  84. package/titanium/address-input/types/address.js.map +1 -0
  85. package/titanium/address-input/types/autocomplete-prediction-suggestion.js.map +1 -0
  86. package/titanium/address-input/utils/address-to-string.d.ts +3 -0
  87. package/titanium/address-input/utils/address-to-string.js +13 -0
  88. package/titanium/address-input/utils/address-to-string.js.map +1 -0
  89. package/titanium/address-input/utils/place-result-to-address.d.ts +4 -0
  90. package/titanium/address-input/utils/place-result-to-address.js +33 -0
  91. package/titanium/address-input/utils/place-result-to-address.js.map +1 -0
  92. package/titanium/address-input/utils/validate-street.d.ts +2 -0
  93. package/titanium/address-input/utils/validate-street.js +8 -0
  94. package/titanium/address-input/utils/validate-street.js.map +1 -0
  95. package/titanium/card/card.d.ts +23 -0
  96. package/titanium/card/card.js +160 -0
  97. package/titanium/card/card.js.map +1 -0
  98. package/titanium/chip-multi-select/chip-multi-select.d.ts +55 -0
  99. package/titanium/chip-multi-select/chip-multi-select.js +119 -0
  100. package/titanium/chip-multi-select/chip-multi-select.js.map +1 -0
  101. package/titanium/data-table/data-table-header.d.ts +67 -0
  102. package/titanium/data-table/data-table-header.js +207 -0
  103. package/titanium/data-table/data-table-header.js.map +1 -0
  104. package/titanium/data-table/data-table-item.d.ts +100 -0
  105. package/titanium/data-table/data-table-item.js +511 -0
  106. package/titanium/data-table/data-table-item.js.map +1 -0
  107. package/titanium/data-table/data-table.d.ts +146 -0
  108. package/titanium/data-table/data-table.js +605 -0
  109. package/titanium/data-table/data-table.js.map +1 -0
  110. package/titanium/data-table/filter-controller.d.ts +23 -0
  111. package/titanium/data-table/filter-controller.js +119 -0
  112. package/titanium/data-table/filter-controller.js.map +1 -0
  113. package/titanium/data-table/filter.d.ts +8 -0
  114. package/titanium/data-table/filter.js +11 -0
  115. package/titanium/data-table/filter.js.map +1 -0
  116. package/titanium/data-table/page-control.d.ts +54 -0
  117. package/titanium/data-table/page-control.js +196 -0
  118. package/titanium/data-table/page-control.js.map +1 -0
  119. package/titanium/date-range-selector/date-range-change-event.d.ts +8 -0
  120. package/titanium/date-range-selector/date-range-change-event.js +10 -0
  121. package/titanium/date-range-selector/date-range-change-event.js.map +1 -0
  122. package/titanium/date-range-selector/date-range-selector.d.ts +65 -0
  123. package/titanium/date-range-selector/date-range-selector.js +423 -0
  124. package/titanium/date-range-selector/date-range-selector.js.map +1 -0
  125. package/titanium/date-range-selector/range-label.d.ts +4 -0
  126. package/titanium/date-range-selector/range-label.js +25 -0
  127. package/titanium/date-range-selector/range-label.js.map +1 -0
  128. package/titanium/drawer/drawer.d.ts +39 -0
  129. package/titanium/drawer/drawer.js +233 -0
  130. package/titanium/drawer/drawer.js.map +1 -0
  131. package/titanium/duration-input/duration-input.d.ts +26 -0
  132. package/titanium/duration-input/duration-input.js +86 -0
  133. package/titanium/duration-input/duration-input.js.map +1 -0
  134. package/titanium/duration-input/human-interval.d.ts +19 -0
  135. package/titanium/duration-input/human-interval.js +74 -0
  136. package/titanium/duration-input/human-interval.js.map +1 -0
  137. package/titanium/error-page/error-page.d.ts +16 -0
  138. package/titanium/error-page/error-page.js +96 -0
  139. package/titanium/error-page/error-page.js.map +1 -0
  140. package/titanium/event-bus/event-bus.d.ts +10 -0
  141. package/titanium/event-bus/event-bus.js +52 -0
  142. package/titanium/event-bus/event-bus.js.map +1 -0
  143. package/titanium/extendable-outlined-text-field/extendable-outlined-text-field.d.ts +160 -0
  144. package/titanium/extendable-outlined-text-field/extendable-outlined-text-field.js +295 -0
  145. package/titanium/extendable-outlined-text-field/extendable-outlined-text-field.js.map +1 -0
  146. package/titanium/extendable-outlined-text-field/extensible-outlined-text-field.d.ts +45 -0
  147. package/titanium/extendable-outlined-text-field/extensible-outlined-text-field.js.map +1 -0
  148. package/titanium/full-page-loading-indicator/full-page-loading-indicator.d.ts +19 -0
  149. package/titanium/full-page-loading-indicator/full-page-loading-indicator.js +170 -0
  150. package/titanium/full-page-loading-indicator/full-page-loading-indicator.js.map +1 -0
  151. package/titanium/hacks/dialog-overflow-hacks.d.ts +4 -0
  152. package/titanium/hacks/dialog-overflow-hacks.js +21 -0
  153. package/titanium/hacks/dialog-overflow-hacks.js.map +1 -0
  154. package/titanium/header/header.d.ts +39 -0
  155. package/titanium/header/header.js +148 -0
  156. package/titanium/header/header.js.map +1 -0
  157. package/titanium/helpers/csv-download.d.ts +3 -0
  158. package/titanium/helpers/csv-download.js +78 -0
  159. package/titanium/helpers/csv-download.js.map +1 -0
  160. package/titanium/helpers/debouncer.d.ts +13 -0
  161. package/titanium/helpers/debouncer.js +33 -0
  162. package/titanium/helpers/debouncer.js.map +1 -0
  163. package/titanium/helpers/delay.d.ts +2 -0
  164. package/titanium/helpers/delay.js +6 -0
  165. package/titanium/helpers/delay.js.map +1 -0
  166. package/titanium/helpers/dev-detection.d.ts +3 -0
  167. package/titanium/helpers/dev-detection.js +12 -0
  168. package/titanium/helpers/dev-detection.js.map +1 -0
  169. package/titanium/helpers/helpers.d.ts +14 -0
  170. package/titanium/helpers/helpers.js +14 -0
  171. package/titanium/helpers/helpers.js.map +1 -0
  172. package/titanium/helpers/join.d.ts +2 -0
  173. package/titanium/helpers/join.js +5 -0
  174. package/titanium/helpers/join.js.map +1 -0
  175. package/titanium/helpers/leavitt-cdn.d.ts +5 -0
  176. package/titanium/helpers/leavitt-cdn.js +38 -0
  177. package/titanium/helpers/leavitt-cdn.js.map +1 -0
  178. package/titanium/helpers/load-while.d.ts +343 -0
  179. package/titanium/helpers/load-while.js +27 -0
  180. package/titanium/helpers/load-while.js.map +1 -0
  181. package/titanium/helpers/media-query.d.ts +2 -0
  182. package/titanium/helpers/media-query.js +6 -0
  183. package/titanium/helpers/media-query.js.map +1 -0
  184. package/titanium/helpers/middle-ellipsis.d.ts +2 -0
  185. package/titanium/helpers/middle-ellipsis.js +7 -0
  186. package/titanium/helpers/middle-ellipsis.js.map +1 -0
  187. package/titanium/helpers/not-null-or-undefined.d.ts +2 -0
  188. package/titanium/helpers/not-null-or-undefined.js +4 -0
  189. package/titanium/helpers/not-null-or-undefined.js.map +1 -0
  190. package/titanium/helpers/not-null.d.ts +2 -0
  191. package/titanium/helpers/not-null.js +4 -0
  192. package/titanium/helpers/not-null.js.map +1 -0
  193. package/titanium/helpers/not-undefined.d.ts +2 -0
  194. package/titanium/helpers/not-undefined.js +4 -0
  195. package/titanium/helpers/not-undefined.js.map +1 -0
  196. package/titanium/helpers/odata-helpers.d.ts +2 -0
  197. package/titanium/helpers/odata-helpers.js +2 -0
  198. package/titanium/helpers/odata-helpers.js.map +1 -0
  199. package/titanium/helpers/search-token.d.ts +2 -0
  200. package/titanium/helpers/search-token.js +17 -0
  201. package/titanium/helpers/search-token.js.map +1 -0
  202. package/titanium/icon-picker/icon-picker.d.ts +23 -0
  203. package/titanium/icon-picker/icon-picker.js +75 -0
  204. package/titanium/icon-picker/icon-picker.js.map +1 -0
  205. package/titanium/icon-picker/material-symbols.d.ts +3 -0
  206. package/titanium/icon-picker/material-symbols.js +3297 -0
  207. package/titanium/icon-picker/material-symbols.js.map +1 -0
  208. package/titanium/input-validator/input-validator.d.ts +20 -0
  209. package/titanium/input-validator/input-validator.js +45 -0
  210. package/titanium/input-validator/input-validator.js.map +1 -0
  211. package/titanium/search-input/search-input.d.ts +47 -0
  212. package/titanium/search-input/search-input.js +237 -0
  213. package/titanium/search-input/search-input.js.map +1 -0
  214. package/titanium/service-worker-notifier/service-worker-notifier.d.ts +9 -0
  215. package/titanium/service-worker-notifier/service-worker-notifier.js +57 -0
  216. package/titanium/service-worker-notifier/service-worker-notifier.js.map +1 -0
  217. package/titanium/show-hide/show-hide.d.ts +36 -0
  218. package/titanium/show-hide/show-hide.js +144 -0
  219. package/titanium/show-hide/show-hide.js.map +1 -0
  220. package/titanium/single-select-base/single-select-base.d.ts +449 -0
  221. package/titanium/single-select-base/single-select-base.js +411 -0
  222. package/titanium/single-select-base/single-select-base.js.map +1 -0
  223. package/titanium/smart-attachment-input/crop-and-save-image-dialog.d.ts +370 -0
  224. package/titanium/smart-attachment-input/crop-and-save-image-dialog.js +270 -0
  225. package/titanium/smart-attachment-input/crop-and-save-image-dialog.js.map +1 -0
  226. package/titanium/smart-attachment-input/cropper-styles.d.ts +3 -0
  227. package/titanium/smart-attachment-input/cropper-styles.js +311 -0
  228. package/titanium/smart-attachment-input/cropper-styles.js.map +1 -0
  229. package/titanium/smart-attachment-input/image-formats.d.ts +5 -0
  230. package/titanium/smart-attachment-input/image-formats.js +37 -0
  231. package/titanium/smart-attachment-input/image-formats.js.map +1 -0
  232. package/titanium/smart-attachment-input/image-preview-dialog.d.ts +21 -0
  233. package/titanium/smart-attachment-input/image-preview-dialog.js +83 -0
  234. package/titanium/smart-attachment-input/image-preview-dialog.js.map +1 -0
  235. package/titanium/smart-attachment-input/smart-attachment-input.d.ts +126 -0
  236. package/titanium/smart-attachment-input/smart-attachment-input.js +422 -0
  237. package/titanium/smart-attachment-input/smart-attachment-input.js.map +1 -0
  238. package/titanium/smart-attachment-input/type/smart-attachment.d.ts +7 -0
  239. package/titanium/smart-attachment-input/type/smart-attachment.js +2 -0
  240. package/titanium/smart-attachment-input/type/smart-attachment.js.map +1 -0
  241. package/titanium/snackbar/snackbar.d.ts +79 -0
  242. package/titanium/snackbar/snackbar.js +302 -0
  243. package/titanium/snackbar/snackbar.js.map +1 -0
  244. package/titanium/styles/a.d.ts +2 -0
  245. package/titanium/styles/a.js +18 -0
  246. package/titanium/styles/a.js.map +1 -0
  247. package/titanium/styles/data-row.d.ts +2 -0
  248. package/titanium/styles/data-row.js +52 -0
  249. package/titanium/styles/data-row.js.map +1 -0
  250. package/titanium/styles/ellipsis.d.ts +2 -0
  251. package/titanium/styles/ellipsis.js +9 -0
  252. package/titanium/styles/ellipsis.js.map +1 -0
  253. package/titanium/styles/h1.d.ts +2 -0
  254. package/titanium/styles/h1.js +17 -0
  255. package/titanium/styles/h1.js.map +1 -0
  256. package/titanium/styles/h2.d.ts +2 -0
  257. package/titanium/styles/h2.js +17 -0
  258. package/titanium/styles/h2.js.map +1 -0
  259. package/titanium/styles/h3.d.ts +2 -0
  260. package/titanium/styles/h3.js +17 -0
  261. package/titanium/styles/h3.js.map +1 -0
  262. package/titanium/styles/h4.d.ts +2 -0
  263. package/titanium/styles/h4.js +17 -0
  264. package/titanium/styles/h4.js.map +1 -0
  265. package/titanium/styles/h5.d.ts +2 -0
  266. package/titanium/styles/h5.js +19 -0
  267. package/titanium/styles/h5.js.map +1 -0
  268. package/titanium/styles/p.d.ts +2 -0
  269. package/titanium/styles/p.js +17 -0
  270. package/titanium/styles/p.js.map +1 -0
  271. package/titanium/styles/styles.d.ts +17 -0
  272. package/titanium/styles/styles.js +17 -0
  273. package/titanium/styles/styles.js.map +1 -0
  274. package/titanium/toolbar/toolbar.d.ts +34 -0
  275. package/titanium/toolbar/toolbar.js +104 -0
  276. package/titanium/toolbar/toolbar.js.map +1 -0
  277. package/titanium/types/any-function.d.ts +5 -0
  278. package/titanium/types/any-function.js +2 -0
  279. package/titanium/types/any-function.js.map +1 -0
  280. package/titanium/types/dom-event.d.ts +4 -0
  281. package/titanium/types/dom-event.js +2 -0
  282. package/titanium/types/dom-event.js.map +1 -0
  283. package/titanium/types/identifier-interface.d.ts +4 -0
  284. package/titanium/types/identifier-interface.js +2 -0
  285. package/titanium/types/identifier-interface.js.map +1 -0
  286. package/titanium/types/pending-state-event.d.ts +7 -0
  287. package/titanium/types/pending-state-event.js +7 -0
  288. package/titanium/types/pending-state-event.js.map +1 -0
  289. package/titanium/types/string-map.d.ts +7 -0
  290. package/titanium/types/string-map.js +5 -0
  291. package/titanium/types/string-map.js.map +1 -0
  292. package/titanium/youtube-input/youtube-input.d.ts +17 -0
  293. package/titanium/youtube-input/youtube-input.js +52 -0
  294. package/titanium/youtube-input/youtube-input.js.map +1 -0
@@ -0,0 +1,207 @@
1
+ import { __decorate } from "tslib";
2
+ import '../../titanium/header/header';
3
+ import '../../titanium/card/card';
4
+ import '../../titanium/smart-attachment-input/smart-attachment-input';
5
+ import '@material/web/button/filled-tonal-button';
6
+ import '@material/web/textfield/outlined-text-field';
7
+ import '@material/web/tabs/primary-tab';
8
+ import '@material/web/tabs/tabs';
9
+ import { LitElement, css, html } from 'lit';
10
+ import { customElement, property, query, state } from 'lit/decorators.js';
11
+ import { LoadWhile, isDevelopment } from '../../titanium/helpers/helpers';
12
+ import { PendingStateEvent } from '../../titanium/types/pending-state-event';
13
+ import { TitaniumSnackbarSingleton } from '../../titanium/snackbar/snackbar';
14
+ import { h1, p } from '../../titanium/styles/styles';
15
+ import { AuthenticatedTokenProvider } from '../api-service/authenticated-token-provider';
16
+ import ApiService from '../api-service//api-service';
17
+ const websiteBugApiService = new ApiService(new AuthenticatedTokenProvider());
18
+ websiteBugApiService.baseUrl = isDevelopment ? 'https://devapi3.leavitt.com/' : 'https://api3.leavitt.com/';
19
+ websiteBugApiService.addHeader('X-LGAppName', 'WebsiteBug');
20
+ Object.freeze(websiteBugApiService);
21
+ const feedbackApiService = new ApiService(new AuthenticatedTokenProvider());
22
+ feedbackApiService.baseUrl = isDevelopment ? 'https://devapi3.leavitt.com/' : 'https://api3.leavitt.com/';
23
+ feedbackApiService.addHeader('X-LGAppName', 'WebsiteFeedback');
24
+ Object.freeze(feedbackApiService);
25
+ let LeavittUserFeedback = class LeavittUserFeedback extends LoadWhile(LitElement) {
26
+ #isActive_accessor_storage = false;
27
+ get isActive() { return this.#isActive_accessor_storage; }
28
+ set isActive(value) { this.#isActive_accessor_storage = value; }
29
+ #activeIndex_accessor_storage = 0;
30
+ get activeIndex() { return this.#activeIndex_accessor_storage; }
31
+ set activeIndex(value) { this.#activeIndex_accessor_storage = value; }
32
+ #textArea_accessor_storage;
33
+ get textArea() { return this.#textArea_accessor_storage; }
34
+ set textArea(value) { this.#textArea_accessor_storage = value; }
35
+ #imageInput_accessor_storage;
36
+ get imageInput() { return this.#imageInput_accessor_storage; }
37
+ set imageInput(value) { this.#imageInput_accessor_storage = value; }
38
+ async updated(changedProps) {
39
+ if (changedProps.has('isActive') && this.isActive) {
40
+ this.reset();
41
+ }
42
+ }
43
+ reset() {
44
+ this.imageInput?.reset();
45
+ this.textArea?.reset();
46
+ }
47
+ async #submitProblem() {
48
+ if (!this.textArea.reportValidity() || this.isLoading) {
49
+ return;
50
+ }
51
+ const dto = {
52
+ SiteName: location.hostname,
53
+ Description: this.textArea.value,
54
+ Attachments: (this.imageInput?.getFiles() ?? []).map((o) => o.file),
55
+ };
56
+ try {
57
+ const post = websiteBugApiService.postAsync('WebsiteBugs/ReportProblem', dto, { sendAsFormData: true });
58
+ this.dispatchEvent(new PendingStateEvent(post));
59
+ this.loadWhile(post);
60
+ const entity = (await post).entity;
61
+ if (!entity) {
62
+ throw new Error('Error submitting problem. Please try again.');
63
+ }
64
+ else {
65
+ TitaniumSnackbarSingleton.open(html `Thank you for bringing this issue to our attention!<br />
66
+ <br />
67
+ Our engineering teams will promptly investigate and address it.`);
68
+ this.reset();
69
+ }
70
+ }
71
+ catch (error) {
72
+ TitaniumSnackbarSingleton.open(error);
73
+ }
74
+ }
75
+ async #submitFeedback() {
76
+ if (!this.textArea.reportValidity() || this.isLoading) {
77
+ return;
78
+ }
79
+ const dto = {
80
+ SiteName: location.hostname,
81
+ Comment: this.textArea.value,
82
+ };
83
+ try {
84
+ const post = feedbackApiService.postAsync('WebsiteFeedbacks', dto);
85
+ this.dispatchEvent(new PendingStateEvent(post));
86
+ this.loadWhile(post);
87
+ const entity = (await post).entity;
88
+ if (!entity) {
89
+ throw new Error('Error submitting feedback. Please try again.');
90
+ }
91
+ else {
92
+ TitaniumSnackbarSingleton.open('We appreciate your input, and we will promptly conduct a review!');
93
+ this.reset();
94
+ }
95
+ }
96
+ catch (error) {
97
+ TitaniumSnackbarSingleton.open(error);
98
+ }
99
+ }
100
+ static { this.styles = [
101
+ h1,
102
+ p,
103
+ css `
104
+ :host {
105
+ display: grid;
106
+ grid-template-columns: minmax(0, 1fr);
107
+ gap: 24px;
108
+ }
109
+
110
+ form {
111
+ display: flex;
112
+ flex-direction: column;
113
+ gap: 24px;
114
+ margin: 24px 0;
115
+ }
116
+
117
+ titanium-card {
118
+ padding-top: 0;
119
+ }
120
+
121
+ md-tabs {
122
+ margin-bottom: 16px;
123
+ --md-primary-tab-container-shape: 12px;
124
+ }
125
+
126
+ [hidden] {
127
+ display: none !important;
128
+ }
129
+ `,
130
+ ]; }
131
+ render() {
132
+ return html `
133
+ <titanium-header header="Report a problem" subHeader="Report bugs and provide feedback for this site" no-nav></titanium-header>
134
+
135
+ <titanium-card has-footer>
136
+ <md-tabs
137
+ full-width
138
+ @change=${(event) => {
139
+ this.reset();
140
+ this.activeIndex = event.target.activeTabIndex;
141
+ }}
142
+ >
143
+ <md-primary-tab
144
+ >Report a problem
145
+ <md-icon slot="icon">person_alert</md-icon>
146
+ </md-primary-tab>
147
+ <md-primary-tab
148
+ >Provide feedback
149
+ <md-icon slot="icon">rate_review</md-icon>
150
+ </md-primary-tab>
151
+ </md-tabs>
152
+
153
+ <main>
154
+ ${this.activeIndex === 0
155
+ ? html ` <form>
156
+ <p full-width>
157
+ Please be specific and provide screenshots of the issue if possible in your report. Your report goes directly to our engineering teams so it
158
+ can be addressed as soon as possible.
159
+ </p>
160
+ <md-outlined-text-field type="textarea" problem label="Describe the issue" rows="5" required outlined></md-outlined-text-field>
161
+ <titanium-smart-attachment-input
162
+ multiple
163
+ full-width
164
+ label="Supporting files"
165
+ noItemsText="No files"
166
+ addButtonLabel="Add file"
167
+ ></titanium-smart-attachment-input>
168
+ </form>`
169
+ : html ` <form>
170
+ <p full-width>
171
+ User feedback is a valuable tool that empowers our users to share their thoughts, suggestions, and concerns, helping us improve the overall
172
+ user experience of our websites and tools. We welcome and appreciate user feedback as it enables us to make informed decisions and enhance our
173
+ website based on the needs and expectations of our users.
174
+ </p>
175
+ <p full-width>
176
+ Please be specific and provide as much detail as possible in your feedback. Your feedback goes directly to our development teams so it can be
177
+ carefully reviewed and planned into the next development cycle.
178
+ </p>
179
+ <md-outlined-text-field type="textarea" feedback label="Feedback" rows="5" required outlined></md-outlined-text-field>
180
+ </form>`}
181
+ </main>
182
+ <span nav card-footer>
183
+ <md-filled-tonal-button @click=${() => (this.activeIndex === 0 ? this.#submitProblem() : this.#submitFeedback())} ?disabled=${this.isLoading}
184
+ >Submit</md-filled-tonal-button
185
+ >
186
+ </span>
187
+ </titanium-card>
188
+ `;
189
+ }
190
+ };
191
+ __decorate([
192
+ property({ type: Boolean })
193
+ ], LeavittUserFeedback.prototype, "isActive", null);
194
+ __decorate([
195
+ state()
196
+ ], LeavittUserFeedback.prototype, "activeIndex", null);
197
+ __decorate([
198
+ query('md-outlined-text-field')
199
+ ], LeavittUserFeedback.prototype, "textArea", null);
200
+ __decorate([
201
+ query('titanium-smart-attachment-input')
202
+ ], LeavittUserFeedback.prototype, "imageInput", null);
203
+ LeavittUserFeedback = __decorate([
204
+ customElement('leavitt-user-feedback')
205
+ ], LeavittUserFeedback);
206
+ export { LeavittUserFeedback };
207
+ //# sourceMappingURL=user-feedback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-feedback.js","sourceRoot":"","sources":["user-feedback.ts"],"names":[],"mappings":";A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KAAK,EAAE;YACd,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvC;IACH,CAAC;aAEM,WAAM,GAAG;QACd,EAAE;QACF,CAAC;QACD,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;KA0BF;KACF,AA9BY,CA8BX;IAEF,MAAM;QACJ,OAAO,IAAI,CAAA;;;;;;oBAMK,CAAC,KAAK,EAAE,EAAE;YAClB,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC;QACjD,CAAC;;;;;;;;;;;;;YAaC,IAAI,CAAC,WAAW,KAAK,CAAC;YACtB,CAAC,CAAC,IAAI,CAAA;;;;;;;;;;;;;sBAaI;YACV,CAAC,CAAC,IAAI,CAAA;;;;;;;;;;;sBAWI;;;2CAGqB,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,cAAc,IAAI,CAAC,SAAS;;;;;KAKjJ,CAAC;IACJ,CAAC;;AAvKqC;IAArC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAoC;AAEtC;IAAzB,KAAK,EAAE;sDAA0C;AAEA;IAAjD,KAAK,CAAC,wBAAwB,CAAC;mDAAgD;AACrB;IAA1D,KAAK,CAAC,iCAAiC,CAAC;qDAAkE;AANhG,mBAAmB;IAD/B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,mBAAmB,CAyK/B"}
@@ -0,0 +1,21 @@
1
+ export interface LssJwtToken {
2
+ IsActiveEmployee: string;
3
+ RefreshTokenId: string;
4
+ aud: string;
5
+ birthdate: string;
6
+ exp: Date | number;
7
+ family_name: string;
8
+ gender: string;
9
+ given_name: string;
10
+ Company?: string;
11
+ CompanyId?: string;
12
+ PicCdnFileName?: string;
13
+ iss: string;
14
+ nameid: string;
15
+ nbf: number;
16
+ role: Array<string>;
17
+ unique_name: string;
18
+ email: string;
19
+ username: string;
20
+ }
21
+ //# sourceMappingURL=LssJwtToken.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=LssJwtToken.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LssJwtToken.js","sourceRoot":"","sources":["LssJwtToken.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export declare class UserManagerUpdatedEvent extends Event {
2
+ static eventName: string;
3
+ constructor();
4
+ }
5
+ //# sourceMappingURL=user-manager-events.d.ts.map
@@ -0,0 +1,7 @@
1
+ export class UserManagerUpdatedEvent extends Event {
2
+ static { this.eventName = 'um-updated'; }
3
+ constructor() {
4
+ super(UserManagerUpdatedEvent.eventName, { bubbles: false, composed: true });
5
+ }
6
+ }
7
+ //# sourceMappingURL=user-manager-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-manager-events.js","sourceRoot":"","sources":["user-manager-events.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAwB,SAAQ,KAAK;aACzC,cAAS,GAAG,YAAY,CAAC;IAChC;QACE,KAAK,CAAC,uBAAuB,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC"}
@@ -0,0 +1,37 @@
1
+ import { LitElement } from 'lit';
2
+ import { LssJwtToken } from './LssJwtToken';
3
+ export declare const GetUserManagerInstance: () => UserManager;
4
+ export declare class UserManager extends LitElement {
5
+ #private;
6
+ roles: Array<string>;
7
+ fullname: string;
8
+ username: string;
9
+ firstName: string;
10
+ lastName: string;
11
+ company: string;
12
+ companyId: number | null;
13
+ profilePictureFileName: string | null;
14
+ email: string;
15
+ personId: number;
16
+ refreshTokenId: number;
17
+ redirectUrl: string;
18
+ redirectDevUrl: string;
19
+ tokenUri: string;
20
+ issuerIdentifier: string;
21
+ disableAutoload: boolean;
22
+ isActiveEmployee: boolean;
23
+ constructor();
24
+ firstUpdated(): Promise<void>;
25
+ isRefreshTokenValid(refreshToken: string): Promise<boolean>;
26
+ getAccessTokenAsync(): Promise<string>;
27
+ /**
28
+ * Returns true is the user is currently signed in.
29
+ * Will not redirect if user is not authenticated.
30
+ *
31
+ * Avoid calling multiple times concurrently.
32
+ */
33
+ isAuthenticatedAsync(): Promise<boolean>;
34
+ authenticateAsync(): Promise<LssJwtToken>;
35
+ logout(): void;
36
+ }
37
+ //# sourceMappingURL=user-manager.d.ts.map
@@ -0,0 +1,364 @@
1
+ import { __decorate } from "tslib";
2
+ import { jwtDecode } from 'jwt-decode';
3
+ import { LitElement } from 'lit';
4
+ import { property, customElement } from 'lit/decorators.js';
5
+ import { isDevelopment } from '../../titanium/helpers/helpers';
6
+ import { UserManagerUpdatedEvent } from './user-manager-events';
7
+ let instance = null;
8
+ export const GetUserManagerInstance = () => {
9
+ if (instance) {
10
+ return instance;
11
+ }
12
+ throw 'GetUserManagerInstance requested before an instance was created. Did you forget to add the <user-manager> element to your project?';
13
+ };
14
+ let UserManager = class UserManager extends LitElement {
15
+ #isAuthenticating;
16
+ constructor() {
17
+ super();
18
+ this.roles = [];
19
+ this.personId = 0;
20
+ this.refreshTokenId = 0;
21
+ this.redirectUrl = 'https://signin.leavitt.com/';
22
+ this.redirectDevUrl = 'https://devsignin.leavitt.com/';
23
+ this.tokenUri = isDevelopment ? 'https://devoauth2.leavitt.com/token' : 'https://oauth2.leavitt.com/token';
24
+ this.issuerIdentifier = 'https://oauth2.leavitt.com/';
25
+ if (!instance) {
26
+ /* eslint-disable @typescript-eslint/no-this-alias */
27
+ instance = this;
28
+ }
29
+ else {
30
+ console.warn('More than one <user-manager> element has been used in this web application, consider removing one.');
31
+ }
32
+ }
33
+ async firstUpdated() {
34
+ if (!this.disableAutoload || this.#getTokenfromUrl('refreshToken')) {
35
+ try {
36
+ await this.authenticateAsync();
37
+ }
38
+ catch (error) { }
39
+ }
40
+ console.log('UserManager Ready.');
41
+ }
42
+ async isRefreshTokenValid(refreshToken) {
43
+ try {
44
+ await this.#getAccessTokenFromApiAsync(refreshToken, this.tokenUri);
45
+ return true;
46
+ }
47
+ catch (error) { }
48
+ return false;
49
+ }
50
+ #redirectToLogin(continueUrl) {
51
+ const redirectUrl = `${isDevelopment ? this.redirectDevUrl : this.redirectUrl}?continue=${encodeURIComponent(continueUrl)}`;
52
+ if (document.location) {
53
+ document.location.href = redirectUrl;
54
+ }
55
+ }
56
+ #redirectToSignOut(continueUrl) {
57
+ const redirectUrl = `${isDevelopment ? this.redirectDevUrl : this.redirectUrl}sign-out/?continue=${encodeURIComponent(continueUrl)}`;
58
+ if (document.location) {
59
+ document.location.href = redirectUrl;
60
+ }
61
+ }
62
+ #getHashParametersFromUrl() {
63
+ const hashParams = [];
64
+ if (window.location.hash) {
65
+ let hash = window.location.hash.substring(1);
66
+ hash = decodeURIComponent(hash);
67
+ const hashArray = hash.split('&');
68
+ for (const i in hashArray) {
69
+ if (hashArray.hasOwnProperty(i)) {
70
+ const keyValPair = hashArray[i].split('=');
71
+ if (keyValPair.length > 1) {
72
+ hashParams.push({ key: keyValPair[0], value: decodeURIComponent(keyValPair[1]) });
73
+ }
74
+ }
75
+ }
76
+ }
77
+ return hashParams;
78
+ }
79
+ #getClaimScopes(localStorageKey) {
80
+ try {
81
+ return JSON.parse(window.localStorage.getItem(localStorageKey) || '[]');
82
+ }
83
+ catch (error) {
84
+ console.warn(`Failed to parse scopes in local storage. ${error}`);
85
+ return [];
86
+ }
87
+ }
88
+ #clearHashFromUrl() {
89
+ if (document.location && document.location.hash && document.location.hash.indexOf('refreshToken') > -1) {
90
+ document.location.hash = '';
91
+ }
92
+ }
93
+ #getTokenfromUrl(tokenName) {
94
+ const hashParameters = this.#getHashParametersFromUrl();
95
+ const accessTokenArray = hashParameters.filter((value) => value.key === tokenName);
96
+ if (accessTokenArray.length === 0) {
97
+ return null;
98
+ }
99
+ else {
100
+ return accessTokenArray[0].value;
101
+ }
102
+ }
103
+ #decodeAccessToken(accessToken) {
104
+ if (!accessToken) {
105
+ return null;
106
+ }
107
+ let token;
108
+ try {
109
+ token = jwtDecode(accessToken);
110
+ }
111
+ catch (error) {
112
+ // Invalid JWT token format
113
+ return null;
114
+ }
115
+ if (token) {
116
+ token.exp = new Date(0).setUTCSeconds(token.exp);
117
+ }
118
+ return token;
119
+ }
120
+ #validateToken(accessToken) {
121
+ const currentDate = new Date();
122
+ currentDate.setSeconds(currentDate.getSeconds() + 30);
123
+ if (accessToken.iss !== this.issuerIdentifier) {
124
+ return false;
125
+ }
126
+ if (accessToken.exp <= currentDate) {
127
+ return false;
128
+ }
129
+ return true;
130
+ }
131
+ #getAccessTokenFromLocalStorage() {
132
+ return window.localStorage.getItem('LG-AUTH-AT') || '';
133
+ }
134
+ #saveAccessTokenToLocalStorage(accessToken) {
135
+ window.localStorage.setItem('LG-AUTH-AT', accessToken);
136
+ }
137
+ #getRefreshTokenFromLocalStorage() {
138
+ return window.localStorage.getItem('LG-AUTH-RT') || '';
139
+ }
140
+ #saveRefreshTokenToLocalStorage(accessToken) {
141
+ window.localStorage.setItem('LG-AUTH-RT', accessToken || '');
142
+ }
143
+ async #getAccessTokenFromApiAsync(refreshToken, uri) {
144
+ if (!window.navigator.onLine) {
145
+ return Promise.reject('Computer not connected. Make sure your computer is connected to the internet.');
146
+ }
147
+ const claimScopes = this.#getClaimScopes('LgClaimScopes');
148
+ // eslint-disable-next-line @typescript-eslint/naming-convention
149
+ const body = { grant_type: 'refresh_token', refresh_token: refreshToken };
150
+ if (claimScopes.length > 0) {
151
+ // eslint-disable-next-line @typescript-eslint/naming-convention
152
+ body.claim_scopes = claimScopes;
153
+ }
154
+ const response = await fetch(uri, {
155
+ method: 'POST',
156
+ body: JSON.stringify(body),
157
+ headers: [
158
+ ['Content-Type', 'application/json'],
159
+ ['Accept', 'application/json'],
160
+ ],
161
+ });
162
+ let json;
163
+ try {
164
+ json = await response.json();
165
+ }
166
+ catch (error) {
167
+ return Promise.reject('Get Auth Token: The server sent back invalid JSON.');
168
+ }
169
+ if (response.status === 200 && json.access_token) {
170
+ return Promise.resolve(json.access_token);
171
+ }
172
+ if (json.error) {
173
+ if (json.error === 'unauthorized_client') {
174
+ return Promise.reject('Not authenticated');
175
+ }
176
+ return Promise.reject(json.error);
177
+ }
178
+ return Promise.reject('Not authenticated');
179
+ }
180
+ #setLocalProperties(_jwtToken) {
181
+ this.personId = Number(_jwtToken.nameid);
182
+ this.refreshTokenId = Number(_jwtToken.RefreshTokenId);
183
+ this.fullname = _jwtToken.unique_name;
184
+ this.username = _jwtToken.username;
185
+ this.firstName = _jwtToken.given_name;
186
+ this.lastName = _jwtToken.family_name;
187
+ this.email = _jwtToken.email;
188
+ this.isActiveEmployee = _jwtToken.IsActiveEmployee === 'True';
189
+ this.roles = typeof _jwtToken.role === 'string' ? [_jwtToken.role] : _jwtToken.role ?? [];
190
+ this.company = _jwtToken.Company ?? '';
191
+ this.companyId = _jwtToken.CompanyId ? Number(_jwtToken.CompanyId) : 0;
192
+ this.profilePictureFileName = _jwtToken.PicCdnFileName || null;
193
+ this.dispatchEvent(new UserManagerUpdatedEvent());
194
+ }
195
+ async #getTokenAsync() {
196
+ const refreshTokenFromUrl = this.#getTokenfromUrl('refreshToken');
197
+ //If a new refresh token is sent, clear the access token incase one is still valid from another user
198
+ let accessToken = refreshTokenFromUrl ? '' : this.#getAccessTokenFromLocalStorage();
199
+ const refreshToken = refreshTokenFromUrl || this.#getRefreshTokenFromLocalStorage() || null;
200
+ this.#clearHashFromUrl();
201
+ // validate uri access token
202
+ const jwtToken = this.#decodeAccessToken(accessToken);
203
+ if (jwtToken && this.#validateToken(jwtToken)) {
204
+ this.#saveAccessTokenToLocalStorage(accessToken);
205
+ this.#saveRefreshTokenToLocalStorage(refreshToken);
206
+ this.#setLocalProperties(jwtToken);
207
+ return Promise.resolve(jwtToken);
208
+ }
209
+ if (refreshToken != null) {
210
+ try {
211
+ accessToken = await this.#getAccessTokenFromApiAsync(refreshToken, this.tokenUri);
212
+ }
213
+ catch (error) {
214
+ return Promise.reject(error);
215
+ }
216
+ const jwtToken = this.#decodeAccessToken(accessToken);
217
+ if (jwtToken && this.#validateToken(jwtToken)) {
218
+ this.#saveAccessTokenToLocalStorage(accessToken);
219
+ this.#saveRefreshTokenToLocalStorage(refreshToken);
220
+ this.#setLocalProperties(jwtToken);
221
+ return Promise.resolve(jwtToken);
222
+ }
223
+ }
224
+ return Promise.reject('Not authenticated');
225
+ }
226
+ async getAccessTokenAsync() {
227
+ await this.authenticateAsync();
228
+ return this.#getAccessTokenFromLocalStorage();
229
+ }
230
+ /**
231
+ * Returns true is the user is currently signed in.
232
+ * Will not redirect if user is not authenticated.
233
+ *
234
+ * Avoid calling multiple times concurrently.
235
+ */
236
+ async isAuthenticatedAsync() {
237
+ try {
238
+ await this.#getTokenAsync();
239
+ }
240
+ catch (error) {
241
+ return false;
242
+ }
243
+ return true;
244
+ }
245
+ async authenticateAsync() {
246
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
247
+ const self = this;
248
+ if (this.#isAuthenticating) {
249
+ return new Promise((resolve, reject) => {
250
+ const listener = function listener(e) {
251
+ self.removeEventListener('token', listener);
252
+ if (e.detail.rejected) {
253
+ reject(e.detail.message);
254
+ }
255
+ resolve(e.detail.accessToken);
256
+ };
257
+ this.addEventListener('token', listener);
258
+ });
259
+ }
260
+ return new Promise(async (resolve, reject) => {
261
+ let jwtToken;
262
+ try {
263
+ this.#isAuthenticating = true;
264
+ jwtToken = await this.#getTokenAsync();
265
+ }
266
+ catch (error) {
267
+ if (error === 'Not authenticated') {
268
+ if (document.location) {
269
+ this.#redirectToLogin(document.location.href);
270
+ }
271
+ this.#isAuthenticating = false;
272
+ this.dispatchEvent(new CustomEvent('token', { detail: { rejected: true, message: error } }));
273
+ return; // Wait for the redirect to happen with a unreturned promise
274
+ }
275
+ this.#isAuthenticating = false;
276
+ reject(error);
277
+ }
278
+ this.#isAuthenticating = false;
279
+ self.dispatchEvent(new CustomEvent('token', { detail: jwtToken }));
280
+ resolve(jwtToken);
281
+ });
282
+ }
283
+ logout() {
284
+ localStorage.removeItem('LG-AUTH-AT');
285
+ localStorage.removeItem('LG-AUTH-RT');
286
+ this.personId = 0;
287
+ this.refreshTokenId = 0;
288
+ this.username = '';
289
+ this.fullname = '';
290
+ this.company = '';
291
+ this.companyId = null;
292
+ this.profilePictureFileName = null;
293
+ this.firstName = '';
294
+ this.lastName = '';
295
+ this.email = '';
296
+ this.isActiveEmployee = false;
297
+ this.roles = [];
298
+ this.dispatchEvent(new UserManagerUpdatedEvent());
299
+ this.roles.forEach((o) => {
300
+ window.dispatchEvent(new CustomEvent('um-role-removed', { detail: { role: o } }));
301
+ });
302
+ this.roles = [];
303
+ if (document.location) {
304
+ this.#redirectToSignOut(document.location.href);
305
+ }
306
+ return;
307
+ }
308
+ };
309
+ __decorate([
310
+ property({ type: Array })
311
+ ], UserManager.prototype, "roles", void 0);
312
+ __decorate([
313
+ property({ type: String })
314
+ ], UserManager.prototype, "fullname", void 0);
315
+ __decorate([
316
+ property({ type: String })
317
+ ], UserManager.prototype, "username", void 0);
318
+ __decorate([
319
+ property({ type: String })
320
+ ], UserManager.prototype, "firstName", void 0);
321
+ __decorate([
322
+ property({ type: String })
323
+ ], UserManager.prototype, "lastName", void 0);
324
+ __decorate([
325
+ property({ type: String })
326
+ ], UserManager.prototype, "company", void 0);
327
+ __decorate([
328
+ property({ type: Number })
329
+ ], UserManager.prototype, "companyId", void 0);
330
+ __decorate([
331
+ property({ type: String })
332
+ ], UserManager.prototype, "profilePictureFileName", void 0);
333
+ __decorate([
334
+ property({ type: String })
335
+ ], UserManager.prototype, "email", void 0);
336
+ __decorate([
337
+ property({ type: Number })
338
+ ], UserManager.prototype, "personId", void 0);
339
+ __decorate([
340
+ property({ type: Number })
341
+ ], UserManager.prototype, "refreshTokenId", void 0);
342
+ __decorate([
343
+ property({ type: String })
344
+ ], UserManager.prototype, "redirectUrl", void 0);
345
+ __decorate([
346
+ property({ type: String })
347
+ ], UserManager.prototype, "redirectDevUrl", void 0);
348
+ __decorate([
349
+ property({ type: String })
350
+ ], UserManager.prototype, "tokenUri", void 0);
351
+ __decorate([
352
+ property({ type: String })
353
+ ], UserManager.prototype, "issuerIdentifier", void 0);
354
+ __decorate([
355
+ property({ type: Boolean })
356
+ ], UserManager.prototype, "disableAutoload", void 0);
357
+ __decorate([
358
+ property({ type: Boolean })
359
+ ], UserManager.prototype, "isActiveEmployee", void 0);
360
+ UserManager = __decorate([
361
+ customElement('user-manager')
362
+ ], UserManager);
363
+ export { UserManager };
364
+ //# sourceMappingURL=user-manager.js.map