@esri/solutions-components 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (314) hide show
  1. package/dist/cjs/deduct-calculator.cjs.entry.js +1 -1
  2. package/dist/cjs/pci-calculator.cjs.entry.js +1 -1
  3. package/dist/cjs/{pciUtils-6a806ba4.js → pciUtils-423cfc68.js} +25 -7
  4. package/dist/collection/demos/deduct-calculator.html +2 -5
  5. package/dist/collection/demos/new-public-notification.html +6 -4
  6. package/dist/collection/utils/pciUtils.js +25 -7
  7. package/dist/collection/utils/pciUtils.ts +30 -7
  8. package/dist/components/ExpandToggle.js +110 -0
  9. package/dist/components/Heading.js +22 -0
  10. package/dist/components/_commonjsHelpers.js +22 -0
  11. package/dist/components/action-bar.js +276 -0
  12. package/dist/components/action-group.js +149 -0
  13. package/dist/components/action-menu.js +356 -0
  14. package/dist/components/action.js +214 -0
  15. package/dist/components/add-record-modal.d.ts +11 -0
  16. package/dist/components/add-record-modal.js +171 -0
  17. package/dist/components/array.js +15 -0
  18. package/dist/components/block.js +272 -0
  19. package/dist/components/buffer-tools.d.ts +11 -0
  20. package/dist/components/buffer-tools.js +11 -0
  21. package/dist/components/buffer-tools2.js +262 -0
  22. package/dist/components/button.js +263 -0
  23. package/dist/components/calcite-accordion-item.js +244 -0
  24. package/dist/components/calcite-accordion.js +180 -0
  25. package/dist/components/calcite-action-bar.js +11 -0
  26. package/dist/components/calcite-action-group.js +11 -0
  27. package/dist/components/calcite-action-menu.js +11 -0
  28. package/dist/components/calcite-action-pad.js +197 -0
  29. package/dist/components/calcite-action.js +11 -0
  30. package/dist/components/calcite-alert.js +297 -0
  31. package/dist/components/calcite-avatar.js +182 -0
  32. package/dist/components/calcite-block-section.js +155 -0
  33. package/dist/components/calcite-block.js +11 -0
  34. package/dist/components/calcite-button.js +11 -0
  35. package/dist/components/calcite-card.js +187 -0
  36. package/dist/components/calcite-checkbox.js +11 -0
  37. package/dist/components/calcite-chip.js +11 -0
  38. package/dist/components/calcite-color-picker-hex-input.js +11 -0
  39. package/dist/components/calcite-color-picker-swatch.js +11 -0
  40. package/dist/components/calcite-color-picker.js +1036 -0
  41. package/dist/components/calcite-combobox-item-group.js +75 -0
  42. package/dist/components/calcite-combobox-item.js +11 -0
  43. package/dist/components/calcite-combobox.js +11 -0
  44. package/dist/components/calcite-date-picker-day.js +11 -0
  45. package/dist/components/calcite-date-picker-month-header.js +11 -0
  46. package/dist/components/calcite-date-picker-month.js +11 -0
  47. package/dist/components/calcite-date-picker.js +11 -0
  48. package/dist/components/calcite-dropdown-group.js +11 -0
  49. package/dist/components/calcite-dropdown-item.js +11 -0
  50. package/dist/components/calcite-dropdown.js +11 -0
  51. package/dist/components/calcite-fab.js +144 -0
  52. package/dist/components/calcite-filter.js +195 -0
  53. package/dist/components/calcite-flow-item.js +243 -0
  54. package/dist/components/calcite-flow.js +147 -0
  55. package/dist/components/calcite-graph.js +11 -0
  56. package/dist/components/calcite-handle.js +11 -0
  57. package/dist/components/calcite-icon.js +11 -0
  58. package/dist/components/calcite-inline-editable.js +294 -0
  59. package/dist/components/calcite-input-date-picker.js +713 -0
  60. package/dist/components/calcite-input-message.js +11 -0
  61. package/dist/components/calcite-input-number.js +637 -0
  62. package/dist/components/calcite-input-text.js +400 -0
  63. package/dist/components/calcite-input-time-picker.js +434 -0
  64. package/dist/components/calcite-input.js +11 -0
  65. package/dist/components/calcite-label.js +11 -0
  66. package/dist/components/calcite-link.js +11 -0
  67. package/dist/components/calcite-list-item-group.js +65 -0
  68. package/dist/components/calcite-list-item.js +11 -0
  69. package/dist/components/calcite-list.js +11 -0
  70. package/dist/components/calcite-loader.js +11 -0
  71. package/dist/components/calcite-modal.js +11 -0
  72. package/dist/components/calcite-notice.js +11 -0
  73. package/dist/components/calcite-option-group.js +64 -0
  74. package/dist/components/calcite-option.js +11 -0
  75. package/dist/components/calcite-pagination.js +258 -0
  76. package/dist/components/calcite-panel.js +11 -0
  77. package/dist/components/calcite-pick-list-group.js +74 -0
  78. package/dist/components/calcite-pick-list-item.js +11 -0
  79. package/dist/components/calcite-pick-list.js +11 -0
  80. package/dist/components/calcite-popover-manager.js +94 -0
  81. package/dist/components/calcite-popover.js +11 -0
  82. package/dist/components/calcite-progress.js +11 -0
  83. package/dist/components/calcite-radio-button-group.js +132 -0
  84. package/dist/components/calcite-radio-button.js +310 -0
  85. package/dist/components/calcite-radio-group-item.js +11 -0
  86. package/dist/components/calcite-radio-group.js +11 -0
  87. package/dist/components/calcite-rating.js +201 -0
  88. package/dist/components/calcite-scrim.js +11 -0
  89. package/dist/components/calcite-select.js +11 -0
  90. package/dist/components/calcite-shell-center-row.js +100 -0
  91. package/dist/components/calcite-shell-panel.js +11 -0
  92. package/dist/components/calcite-shell.js +11 -0
  93. package/dist/components/calcite-slider.js +11 -0
  94. package/dist/components/calcite-sortable-list.js +202 -0
  95. package/dist/components/calcite-split-button.js +11 -0
  96. package/dist/components/calcite-stepper-item.js +271 -0
  97. package/dist/components/calcite-stepper.js +256 -0
  98. package/dist/components/calcite-switch.js +11 -0
  99. package/dist/components/calcite-tab-nav.js +11 -0
  100. package/dist/components/calcite-tab-title.js +11 -0
  101. package/dist/components/calcite-tab.js +11 -0
  102. package/dist/components/calcite-tabs.js +11 -0
  103. package/dist/components/calcite-tile-select-group.js +65 -0
  104. package/dist/components/calcite-tile-select.js +266 -0
  105. package/dist/components/calcite-tile.js +11 -0
  106. package/dist/components/calcite-time-picker.js +11 -0
  107. package/dist/components/calcite-tip-group.js +41 -0
  108. package/dist/components/calcite-tip-manager.js +223 -0
  109. package/dist/components/calcite-tip.js +162 -0
  110. package/dist/components/calcite-tooltip-manager.js +57 -0
  111. package/dist/components/calcite-tooltip.js +11 -0
  112. package/dist/components/calcite-tree-item.js +11 -0
  113. package/dist/components/calcite-tree.js +11 -0
  114. package/dist/components/calcite-value-list-item.js +11 -0
  115. package/dist/components/calcite-value-list.js +11 -0
  116. package/dist/components/card-manager.d.ts +11 -0
  117. package/dist/components/card-manager.js +143 -0
  118. package/dist/components/check-list.d.ts +11 -0
  119. package/dist/components/check-list.js +11 -0
  120. package/dist/components/check-list2.js +131 -0
  121. package/dist/components/checkbox.js +165 -0
  122. package/dist/components/chip.js +170 -0
  123. package/dist/components/color-picker-hex-input.js +363 -0
  124. package/dist/components/color-picker-swatch.js +2034 -0
  125. package/dist/components/combobox-item.js +182 -0
  126. package/dist/components/combobox.js +912 -0
  127. package/dist/components/comment-card.d.ts +11 -0
  128. package/dist/components/comment-card.js +90 -0
  129. package/dist/components/conditionalSlot.js +50 -0
  130. package/dist/components/config-buffer-tools.d.ts +11 -0
  131. package/dist/components/config-buffer-tools.js +187 -0
  132. package/dist/components/config-draw-tools.d.ts +11 -0
  133. package/dist/components/config-draw-tools.js +121 -0
  134. package/dist/components/config-layer-picker.d.ts +11 -0
  135. package/dist/components/config-layer-picker.js +163 -0
  136. package/dist/components/config-pdf-download.d.ts +11 -0
  137. package/dist/components/config-pdf-download.js +154 -0
  138. package/dist/components/crowdsource-manager.d.ts +11 -0
  139. package/dist/components/crowdsource-manager.js +90 -0
  140. package/dist/components/crowdsource-reporter.d.ts +11 -0
  141. package/dist/components/crowdsource-reporter.js +90 -0
  142. package/dist/components/csvUtils.js +74 -0
  143. package/dist/components/date-picker-day.js +111 -0
  144. package/dist/components/date-picker-month-header.js +224 -0
  145. package/dist/components/date-picker-month.js +344 -0
  146. package/dist/components/date-picker.js +575 -0
  147. package/dist/components/date.js +180 -0
  148. package/dist/components/debounce.js +487 -0
  149. package/dist/components/deduct-calculator.d.ts +11 -0
  150. package/dist/components/deduct-calculator.js +11 -0
  151. package/dist/components/deduct-calculator2.js +1002 -0
  152. package/dist/components/dom.js +231 -0
  153. package/dist/components/dropdown-group.js +96 -0
  154. package/dist/components/dropdown-item.js +232 -0
  155. package/dist/components/dropdown.js +505 -0
  156. package/dist/components/edit-record-modal.d.ts +11 -0
  157. package/dist/components/edit-record-modal.js +11 -0
  158. package/dist/components/edit-record-modal2.js +161 -0
  159. package/dist/components/filter.js +763 -0
  160. package/dist/components/floating-ui.js +1768 -0
  161. package/dist/components/form.js +228 -0
  162. package/dist/components/graph.js +254 -0
  163. package/dist/components/guid.js +24 -0
  164. package/dist/components/handle.js +119 -0
  165. package/dist/components/icon.js +202 -0
  166. package/dist/components/index.d.ts +61 -0
  167. package/dist/components/index.js +196 -0
  168. package/dist/components/index2.js +199 -0
  169. package/dist/components/info-card.d.ts +11 -0
  170. package/dist/components/info-card.js +11 -0
  171. package/dist/components/info-card2.js +97 -0
  172. package/dist/components/input-message.js +101 -0
  173. package/dist/components/input.js +740 -0
  174. package/dist/components/interactive.js +51 -0
  175. package/dist/components/interfaces.js +19 -0
  176. package/dist/components/interfaces2.js +21 -0
  177. package/dist/components/interfaces3.js +80 -0
  178. package/dist/components/json-editor.d.ts +11 -0
  179. package/dist/components/json-editor.js +11 -0
  180. package/dist/components/json-editor2.js +441 -0
  181. package/dist/components/key.js +16 -0
  182. package/dist/components/label.js +106 -0
  183. package/dist/components/label2.js +131 -0
  184. package/dist/components/labelFormats.js +210 -0
  185. package/dist/components/layer-table.d.ts +11 -0
  186. package/dist/components/layer-table.js +453 -0
  187. package/dist/components/link.js +123 -0
  188. package/dist/components/list-item.d.ts +11 -0
  189. package/dist/components/list-item.js +90 -0
  190. package/dist/components/list-item2.js +149 -0
  191. package/dist/components/list.js +83 -0
  192. package/dist/components/loadModules.js +28 -0
  193. package/dist/components/loader.js +116 -0
  194. package/dist/components/locale.js +412 -0
  195. package/dist/components/locale2.js +413 -0
  196. package/dist/components/map-card.d.ts +11 -0
  197. package/dist/components/map-card.js +354 -0
  198. package/dist/components/map-draw-tools.d.ts +11 -0
  199. package/dist/components/map-draw-tools.js +11 -0
  200. package/dist/components/map-draw-tools2.js +228 -0
  201. package/dist/components/map-layer-picker.d.ts +11 -0
  202. package/dist/components/map-layer-picker.js +11 -0
  203. package/dist/components/map-layer-picker2.js +188 -0
  204. package/dist/components/map-search.d.ts +11 -0
  205. package/dist/components/map-search.js +155 -0
  206. package/dist/components/map-select-tools.d.ts +11 -0
  207. package/dist/components/map-select-tools.js +11 -0
  208. package/dist/components/map-select-tools2.js +588 -0
  209. package/dist/components/mapViewUtils.js +129 -0
  210. package/dist/components/math.js +24 -0
  211. package/dist/components/media-card.d.ts +11 -0
  212. package/dist/components/media-card.js +11 -0
  213. package/dist/components/media-card2.js +177 -0
  214. package/dist/components/modal.js +495 -0
  215. package/dist/components/nonChromiumPlatformUtils.js +503 -0
  216. package/dist/components/notice.js +192 -0
  217. package/dist/components/observers.js +56 -0
  218. package/dist/components/openCloseComponent.js +56 -0
  219. package/dist/components/option.js +109 -0
  220. package/dist/components/panel.js +459 -0
  221. package/dist/components/pci-calculator.d.ts +11 -0
  222. package/dist/components/pci-calculator.js +193 -0
  223. package/dist/components/pdf-download.d.ts +11 -0
  224. package/dist/components/pdf-download.js +11 -0
  225. package/dist/components/pdf-download2.js +189 -0
  226. package/dist/components/pick-list-item.js +255 -0
  227. package/dist/components/pick-list.js +170 -0
  228. package/dist/components/popover.js +500 -0
  229. package/dist/components/progress.js +60 -0
  230. package/dist/components/public-notification.d.ts +11 -0
  231. package/dist/components/public-notification.js +825 -0
  232. package/dist/components/publicNotificationStore.js +38 -0
  233. package/dist/components/queryUtils.js +187 -0
  234. package/dist/components/radio-group-item.js +101 -0
  235. package/dist/components/radio-group.js +235 -0
  236. package/dist/components/refine-selection-tools.d.ts +11 -0
  237. package/dist/components/refine-selection-tools.js +11 -0
  238. package/dist/components/refine-selection-tools2.js +492 -0
  239. package/dist/components/refine-selection.d.ts +11 -0
  240. package/dist/components/refine-selection.js +11 -0
  241. package/dist/components/refine-selection2.js +376 -0
  242. package/dist/components/resources.js +24 -0
  243. package/dist/components/resources2.js +21 -0
  244. package/dist/components/resources3.js +38 -0
  245. package/dist/components/scrim.js +83 -0
  246. package/dist/components/select.js +259 -0
  247. package/dist/components/shared-list-render.js +319 -0
  248. package/dist/components/shell-panel.js +281 -0
  249. package/dist/components/shell.js +121 -0
  250. package/dist/components/slider.js +896 -0
  251. package/dist/components/solution-configuration.d.ts +11 -0
  252. package/dist/components/solution-configuration.js +2233 -0
  253. package/dist/components/solution-contents.d.ts +11 -0
  254. package/dist/components/solution-contents.js +11 -0
  255. package/dist/components/solution-contents2.js +128 -0
  256. package/dist/components/solution-item-details.d.ts +11 -0
  257. package/dist/components/solution-item-details.js +11 -0
  258. package/dist/components/solution-item-details2.js +234 -0
  259. package/dist/components/solution-item-icon.d.ts +11 -0
  260. package/dist/components/solution-item-icon.js +11 -0
  261. package/dist/components/solution-item-icon2.js +342 -0
  262. package/dist/components/solution-item-sharing.d.ts +11 -0
  263. package/dist/components/solution-item-sharing.js +11 -0
  264. package/dist/components/solution-item-sharing2.js +167 -0
  265. package/dist/components/solution-item.d.ts +11 -0
  266. package/dist/components/solution-item.js +11 -0
  267. package/dist/components/solution-item2.js +315 -0
  268. package/dist/components/solution-organization-variables.d.ts +11 -0
  269. package/dist/components/solution-organization-variables.js +11 -0
  270. package/dist/components/solution-organization-variables2.js +132 -0
  271. package/dist/components/solution-resource-item.d.ts +11 -0
  272. package/dist/components/solution-resource-item.js +11 -0
  273. package/dist/components/solution-resource-item2.js +356 -0
  274. package/dist/components/solution-spatial-ref.d.ts +11 -0
  275. package/dist/components/solution-spatial-ref.js +11 -0
  276. package/dist/components/solution-spatial-ref2.js +21446 -0
  277. package/dist/components/solution-store.js +4092 -0
  278. package/dist/components/solution-template-data.d.ts +11 -0
  279. package/dist/components/solution-template-data.js +11 -0
  280. package/dist/components/solution-template-data2.js +233 -0
  281. package/dist/components/solution-variables.d.ts +11 -0
  282. package/dist/components/solution-variables.js +11 -0
  283. package/dist/components/solution-variables2.js +150 -0
  284. package/dist/components/sortable.esm.js +3026 -0
  285. package/dist/components/split-button.js +165 -0
  286. package/dist/components/store-manager.d.ts +11 -0
  287. package/dist/components/store-manager.js +83 -0
  288. package/dist/components/switch.js +139 -0
  289. package/dist/components/tab-nav.js +241 -0
  290. package/dist/components/tab-title.js +276 -0
  291. package/dist/components/tab.js +154 -0
  292. package/dist/components/tabs.js +188 -0
  293. package/dist/components/tile.js +129 -0
  294. package/dist/components/time-picker.js +943 -0
  295. package/dist/components/tooltip.js +399 -0
  296. package/dist/components/tree-item.js +294 -0
  297. package/dist/components/tree.js +327 -0
  298. package/dist/components/utils.js +119 -0
  299. package/dist/components/utils2.js +51 -0
  300. package/dist/components/value-list-item.js +204 -0
  301. package/dist/components/value-list.js +333 -0
  302. package/dist/esm/deduct-calculator.entry.js +1 -1
  303. package/dist/esm/pci-calculator.entry.js +1 -1
  304. package/dist/esm/{pciUtils-e3007a1c.js → pciUtils-ecda46e5.js} +25 -7
  305. package/dist/solutions-components/demos/deduct-calculator.html +2 -5
  306. package/dist/solutions-components/demos/new-public-notification.html +6 -4
  307. package/dist/solutions-components/{p-ff80ffbb.entry.js → p-0512635b.entry.js} +1 -1
  308. package/dist/solutions-components/{p-5ec407c2.entry.js → p-0c088725.entry.js} +1 -1
  309. package/dist/solutions-components/p-cc815aca.js +21 -0
  310. package/dist/solutions-components/solutions-components.esm.js +1 -1
  311. package/dist/solutions-components/utils/pciUtils.ts +30 -7
  312. package/dist/types/utils/pciUtils.d.ts +2 -1
  313. package/package.json +4 -3
  314. package/dist/solutions-components/p-647bbd18.js +0 -21
@@ -0,0 +1,1002 @@
1
+ /*!
2
+ * Copyright 2022 Esri
3
+ * Licensed under the Apache License, Version 2.0
4
+ * http://www.apache.org/licenses/LICENSE-2.0
5
+ */
6
+ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
7
+ import { d as defineCustomElement$8 } from './button.js';
8
+ import { d as defineCustomElement$7 } from './icon.js';
9
+ import { d as defineCustomElement$6 } from './input.js';
10
+ import { d as defineCustomElement$5 } from './label.js';
11
+ import { d as defineCustomElement$4 } from './loader.js';
12
+ import { d as defineCustomElement$3 } from './option.js';
13
+ import { d as defineCustomElement$2 } from './progress.js';
14
+ import { d as defineCustomElement$1 } from './select.js';
15
+
16
+ /** @license
17
+ * Copyright 2022 Esri
18
+ *
19
+ * Licensed under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License.
21
+ * You may obtain a copy of the License at
22
+ *
23
+ * http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ /**
32
+ * Effect of the distresses on ride quality.
33
+ *
34
+ * L - Low. Individual bumps or settlements, or both, cause the vehicle to bounce slightly,
35
+ * but create little discomfort.
36
+ *
37
+ * M - Medium. Individual bumps or settlements, or both, cause the vehicle to bounce significantly,
38
+ * creating some discomfort.
39
+ *
40
+ * H - High. Individual bumps or settlements, or both, cause the vehicle to bounce excessively,
41
+ * creating substantial discomfort, safety hazard, or high potential vehicle damage.
42
+ *
43
+ * @returns Promise resolving when function is done
44
+ *
45
+ */
46
+ var ESeverity;
47
+ (function (ESeverity) {
48
+ ESeverity["H"] = "H";
49
+ ESeverity["M"] = "M";
50
+ ESeverity["L"] = "L";
51
+ })(ESeverity || (ESeverity = {}));
52
+ /**
53
+ * Type of distress as defined by ASTM standard
54
+ *
55
+ */
56
+ var EDistressType;
57
+ (function (EDistressType) {
58
+ EDistressType[EDistressType["ALLIGATOR_CRACKING"] = 1] = "ALLIGATOR_CRACKING";
59
+ EDistressType[EDistressType["BLEEDING"] = 2] = "BLEEDING";
60
+ EDistressType[EDistressType["BLOCK_CRACKING"] = 3] = "BLOCK_CRACKING";
61
+ EDistressType[EDistressType["BUMPS_SAGS"] = 4] = "BUMPS_SAGS";
62
+ EDistressType[EDistressType["CORRUGATION"] = 5] = "CORRUGATION";
63
+ EDistressType[EDistressType["DEPRESSION"] = 6] = "DEPRESSION";
64
+ EDistressType[EDistressType["EDGE_CRACKING"] = 7] = "EDGE_CRACKING";
65
+ EDistressType[EDistressType["REFLECTION_CRACKING"] = 8] = "REFLECTION_CRACKING";
66
+ EDistressType[EDistressType["LANE_SHOULDER_DROP_OFF"] = 9] = "LANE_SHOULDER_DROP_OFF";
67
+ EDistressType[EDistressType["LONG_TRANS_CRACKING"] = 10] = "LONG_TRANS_CRACKING";
68
+ EDistressType[EDistressType["PATCHING_UTIL_CUT_PATCHING"] = 11] = "PATCHING_UTIL_CUT_PATCHING";
69
+ EDistressType[EDistressType["POLISHED_AGGREGATE"] = 12] = "POLISHED_AGGREGATE";
70
+ EDistressType[EDistressType["POTHOLES"] = 13] = "POTHOLES";
71
+ EDistressType[EDistressType["RAILROAD_CROSSING"] = 14] = "RAILROAD_CROSSING";
72
+ EDistressType[EDistressType["RUTTING"] = 15] = "RUTTING";
73
+ EDistressType[EDistressType["SHOVING"] = 16] = "SHOVING";
74
+ EDistressType[EDistressType["SLIPPAGE_CRACKING"] = 17] = "SLIPPAGE_CRACKING";
75
+ EDistressType[EDistressType["SWELL"] = 18] = "SWELL";
76
+ EDistressType[EDistressType["RAVELING"] = 19] = "RAVELING";
77
+ EDistressType[EDistressType["WEATHERING"] = 20] = "WEATHERING";
78
+ })(EDistressType || (EDistressType = {}));
79
+ /**
80
+ * Calculate the deduct value for the given distress.
81
+ *
82
+ * @param type expects 1-19 as a string
83
+ * @param severity expects "H" | "M" | "L"
84
+ * @param density the calculated percent density ralative to the total sample area
85
+ * @param showDebugging used to control debugging messages to show the various
86
+ * calculations a required steps along the way.
87
+ * The main reason this is optional is that it provides no value when used within
88
+ * Survey123 as we have nowhere to see the messages and I wasn't sure if writing to a
89
+ * console in that context could have any negative side effects.
90
+ *
91
+ * @returns pipe delimited string: type|severity|roundedDeductValue|density
92
+ */
93
+ function calculateDeductValue(type, severity, density, showDebugging = false) {
94
+ // When called from survey123 we will get the args as strings
95
+ // not sure if they could be numbers so a little extra conversion to make sure with the density
96
+ const _type = parseInt(type);
97
+ const _severity = ESeverity[severity];
98
+ const _density = parseFloat(density.toString());
99
+ // When called from survey123 all distress types and severities will be passed in
100
+ // We only need to calculate the deduct value if we have a valid density
101
+ if (Number.isNaN(_density) || _density === 0) {
102
+ return "";
103
+ }
104
+ const _showDebugging = showDebugging === true || showDebugging.toString().toLowerCase() === "true";
105
+ let calc;
106
+ switch (_type) {
107
+ case EDistressType.ALLIGATOR_CRACKING:
108
+ calc = _calcAlligator;
109
+ break;
110
+ case EDistressType.BLEEDING:
111
+ calc = _calcBleeding;
112
+ break;
113
+ case EDistressType.BLOCK_CRACKING:
114
+ calc = _calcBlockCracking;
115
+ break;
116
+ case EDistressType.BUMPS_SAGS:
117
+ calc = _calcBumpsSags;
118
+ break;
119
+ case EDistressType.CORRUGATION:
120
+ calc = _calcCorrugation;
121
+ break;
122
+ case EDistressType.DEPRESSION:
123
+ calc = _calcDepression;
124
+ break;
125
+ case EDistressType.EDGE_CRACKING:
126
+ calc = _calcEdgeCracking;
127
+ break;
128
+ case EDistressType.REFLECTION_CRACKING:
129
+ calc = _calcReflectionCracking;
130
+ break;
131
+ case EDistressType.LANE_SHOULDER_DROP_OFF:
132
+ calc = _calcLaneShoulderDropOff;
133
+ break;
134
+ case EDistressType.LONG_TRANS_CRACKING:
135
+ calc = _calcLongTransCracking;
136
+ break;
137
+ case EDistressType.PATCHING_UTIL_CUT_PATCHING:
138
+ calc = _calcPatchingUtilCutPatching;
139
+ break;
140
+ case EDistressType.POLISHED_AGGREGATE:
141
+ calc = _calcPolishedAggregate;
142
+ break;
143
+ case EDistressType.POTHOLES:
144
+ calc = _calcPotholes;
145
+ break;
146
+ case EDistressType.RAILROAD_CROSSING:
147
+ calc = _calcRailroadCrossing;
148
+ break;
149
+ case EDistressType.RUTTING:
150
+ calc = _calcRutting;
151
+ break;
152
+ case EDistressType.SHOVING:
153
+ calc = _calcShoving;
154
+ break;
155
+ case EDistressType.SLIPPAGE_CRACKING:
156
+ calc = _calcSlippageCracking;
157
+ break;
158
+ case EDistressType.SWELL:
159
+ calc = _calcSwell;
160
+ break;
161
+ case EDistressType.RAVELING:
162
+ calc = _calcRaveling;
163
+ break;
164
+ case EDistressType.WEATHERING:
165
+ calc = _calcWeathering;
166
+ break;
167
+ }
168
+ const dv = calc(_severity, Math.log10(_density));
169
+ const roundedDV = _round(dv);
170
+ const formattedDV = `${type}|${severity}|${roundedDV}|${_density}`;
171
+ if (_showDebugging) {
172
+ console.log(`Deduct value: ${dv}`);
173
+ console.log(`Rounded deduct value: ${roundedDV}`);
174
+ console.log(`Formatted devduct value (type|severity|roundedDV|density): ${formattedDV}`);
175
+ }
176
+ return formattedDV;
177
+ }
178
+ /**
179
+ * Calculate the pavement condition index (PCI)
180
+ *
181
+ * @param deductValues string of comma delimited values
182
+ * @param showDebugging used to control debugging messages to show the various
183
+ * calculations a required steps along the way.
184
+ * The main reason this is optional is that it provides no value when used within
185
+ * Survey123 as we have nowhere to see the messages and I wasn't sure if writing to a
186
+ * console in that context could have any negative side effects.
187
+ *
188
+ * @returns the calculated PCI
189
+ */
190
+ function calculatePCI(deductValues, showDebugging = false) {
191
+ // When called from survey123 we will get the args as strings
192
+ // When comparing multi-severities calculatePCI will be called multiple times
193
+ // When called from _evaluateMultiSeverity we will just recieve a comma delimited string
194
+ // When its just comma delimited we don't need to re-evaluate the multiple severities
195
+ let _deductValues = deductValues.indexOf("|") > -1 ?
196
+ _evaluateMultiSeverity(deductValues, showDebugging) :
197
+ deductValues.split(",").map(dv => parseFloat(dv));
198
+ const _showDebugging = showDebugging === true || showDebugging.toString().toLowerCase() === "true";
199
+ let pci = 0;
200
+ // filter out non-numbers
201
+ _deductValues = _deductValues.filter(dv => Math.abs(dv) > 0);
202
+ if (_deductValues.length > 0) {
203
+ const maxCDV = _getMaxCDV(_deductValues, _showDebugging);
204
+ pci = 100 - _round(maxCDV);
205
+ }
206
+ return pci;
207
+ }
208
+ /**
209
+ * Determine if corrections are required when we have multiple severities of a single distress type.
210
+ *
211
+ * @param deductValues string of comma delimited values e.g. "1|L|10|0.52,1|H|7|0.58"
212
+ * @param showDebugging used to control debugging messages to show the various
213
+ * calculations a required steps along the way.
214
+ *
215
+ * @returns an object that will contain any corrections for the current distress type
216
+ */
217
+ function _evaluateMultiSeverity(deductValues, showDebugging) {
218
+ const updates = {};
219
+ const _dvObject = _parseDeductValues(deductValues);
220
+ const multiSeverityKeys = Object.keys(_dvObject).filter(k => Object.keys(_dvObject[k]).length > 1);
221
+ if (multiSeverityKeys.length > 0) {
222
+ multiSeverityKeys.forEach(k => {
223
+ let hDeductValue;
224
+ let mDeductValue;
225
+ let lDeductValue;
226
+ let hDensity;
227
+ let mDensity;
228
+ let lDensity;
229
+ // need to know if 2 or 3 severity case
230
+ Object.keys(_dvObject[k]).forEach(_k => {
231
+ if (_k === "H") {
232
+ hDeductValue = _dvObject[k][_k].deductValue;
233
+ hDensity = _dvObject[k][_k].density;
234
+ }
235
+ else if (_k === "M") {
236
+ mDeductValue = _dvObject[k][_k].deductValue;
237
+ mDensity = _dvObject[k][_k].density;
238
+ }
239
+ else {
240
+ lDeductValue = _dvObject[k][_k].deductValue;
241
+ lDensity = _dvObject[k][_k].density;
242
+ }
243
+ });
244
+ const func = (hDensity && mDensity && lDensity) ?
245
+ _getThreeSeverityCaseUpdates : _getTwoSeverityCaseUpdates;
246
+ const update = func(k, hDeductValue, mDeductValue, lDeductValue, hDensity, mDensity, lDensity, showDebugging);
247
+ if (update) {
248
+ updates[k] = update;
249
+ if (showDebugging) {
250
+ console.log("updates");
251
+ console.log(updates);
252
+ }
253
+ }
254
+ });
255
+ }
256
+ return _getFinalDeductValues(deductValues, updates);
257
+ }
258
+ /**
259
+ * Determine if corrections are required when we have 3 severities of a single distress type.
260
+ *
261
+ * @param type the distress type 1-19 as a string
262
+ * @param hDeductValue high severity deduct value
263
+ * @param mDeductValue med severity deduct value
264
+ * @param lDeductValue low severity deduct value
265
+ * @param hDensity high severity density
266
+ * @param mDensity med severity density
267
+ * @param lDensity low severity density
268
+ * @param showDebugging used to control debugging messages to show the various
269
+ * calculations a required steps along the way.
270
+ *
271
+ * @returns undefined or an object that will contain any corrections for the current distress type
272
+ */
273
+ function _getThreeSeverityCaseUpdates(type, hDeductValue, mDeductValue, lDeductValue, hDensity, mDensity, lDensity, showDebugging) {
274
+ const pci1 = calculatePCI(`${hDeductValue},${mDeductValue},${lDeductValue}`, true);
275
+ if (showDebugging) {
276
+ console.log("pci1");
277
+ console.log(pci1);
278
+ }
279
+ const lm = lDensity + mDensity;
280
+ const lmPCI2 = _getPCI2(type, "M", lm.toString(), hDeductValue, showDebugging);
281
+ const mh = mDensity + hDensity;
282
+ const mhPCI2 = _getPCI2(type, "H", mh.toString(), lDeductValue, showDebugging);
283
+ const lh = lDensity + hDensity;
284
+ const lhPCI2 = _getPCI2(type, "H", lh.toString(), mDeductValue, showDebugging);
285
+ const lmh = lDensity + mDensity + hDensity;
286
+ const lmhPCI2 = _getPCI2(type, "H", lmh.toString(), 0, showDebugging);
287
+ if (showDebugging) {
288
+ console.log("low med pci2");
289
+ console.log(lmPCI2.pci);
290
+ console.log("med high pci2");
291
+ console.log(mhPCI2.pci);
292
+ console.log("low high pci2");
293
+ console.log(lhPCI2.pci);
294
+ console.log("low med high pci2");
295
+ console.log(lmhPCI2.pci);
296
+ }
297
+ const pcis = [lmPCI2, mhPCI2, lhPCI2, lmhPCI2];
298
+ const highest = pcis.reduce((prev, cur) => {
299
+ return cur.pci > pci1 && (!prev || cur.pci > prev.pci) ? cur : prev;
300
+ }, undefined);
301
+ return highest ? highest.dv : undefined;
302
+ }
303
+ /**
304
+ * Determine if corrections are required when we have 2 severities of a single distress type.
305
+ *
306
+ * @param type the distress type 1-19 as a string
307
+ * @param hDeductValue high severity deduct value
308
+ * @param mDeductValue med severity deduct value
309
+ * @param lDeductValue low severity deduct value
310
+ * @param hDensity high severity density
311
+ * @param mDensity med severity density
312
+ * @param lDensity low severity density
313
+ * @param showDebugging used to control debugging messages to show the various
314
+ * calculations a required steps along the way.
315
+ *
316
+ * @returns undefined or an object that will contain any corrections for the current distress type
317
+ */
318
+ function _getTwoSeverityCaseUpdates(type, hDeductValue, mDeductValue, lDeductValue, hDensity, mDensity, lDensity, showDebugging) {
319
+ const hDV = hDeductValue || mDeductValue;
320
+ const lDV = lDeductValue || mDeductValue;
321
+ const pci1 = calculatePCI(`${hDV},${lDV}`, true);
322
+ if (showDebugging) {
323
+ console.log("pci1");
324
+ console.log(pci1);
325
+ }
326
+ const hDen = hDensity || mDensity;
327
+ const lDen = lDensity || mDensity;
328
+ const sumDen = hDen + lDen;
329
+ const highestSeverity = hDen === hDensity ? "H" : "M";
330
+ const pci2 = _getPCI2(type, highestSeverity, sumDen.toString(), 0, showDebugging);
331
+ if (showDebugging) {
332
+ console.log("pci2");
333
+ console.log(pci2.pci);
334
+ }
335
+ return pci2.pci > pci1 ? pci2.dv : undefined;
336
+ }
337
+ /**
338
+ * Used to test for highest PCI when we have multiple severity cases for a single distress type.
339
+ *
340
+ * @param type the distress type 1-19 as a string
341
+ * @param severity expects "H" | "M" | "L"
342
+ * @param density the calculated percent density ralative to the total sample area
343
+ * @param secondDeductValue optional deduct value will be 0 for all 2 severity cases and will be a non 0 number for 3 severity cases
344
+ * @param showDebugging used to control debugging messages to show the various
345
+ * calculations a required steps along the way.
346
+ *
347
+ * @returns ICorrection that contains the new PCI as well as the deduct values that should be used for corrections
348
+ */
349
+ function _getPCI2(type, severity, density, secondDeductValue, showDebugging) {
350
+ const deductValue = calculateDeductValue(type, severity, density);
351
+ const splitVal = deductValue.split("|");
352
+ const newDV = parseFloat(splitVal[2]);
353
+ return {
354
+ pci: calculatePCI(`${splitVal[2]},${secondDeductValue}`, showDebugging),
355
+ dv: secondDeductValue ? [newDV, secondDeductValue] : [newDV]
356
+ };
357
+ }
358
+ /**
359
+ * Parse the deduct value string into individual values for type, severity, deduct value, and density
360
+ *
361
+ * @param deductValues string of comma delimited values for type, severity, deduct value, and density
362
+ *
363
+ * @returns an object with the parsed values
364
+ */
365
+ function _parseDeductValues(deductValues) {
366
+ return deductValues.split(",").reduce((prev, cur) => {
367
+ const splitVal = cur.split("|");
368
+ const type = splitVal[0];
369
+ const severity = splitVal[1];
370
+ const deductValue = parseFloat(splitVal[2]);
371
+ const density = parseFloat(splitVal[3]);
372
+ if (!prev[type]) {
373
+ prev[type] = {};
374
+ }
375
+ prev[type][severity] = {
376
+ deductValue,
377
+ density
378
+ };
379
+ return prev;
380
+ }, {});
381
+ }
382
+ /**
383
+ * Replace any deduct values for the given distress types when it is determined that corrections
384
+ * are required for a multi-severity case
385
+ *
386
+ * @param deductValues string of comma delimited values for type, severity, deduct value, and density
387
+ * @param updates will contain the new corrected deduct value(s) that should be substituted for the original deduct value
388
+ *
389
+ * @returns an object with the parsed and updated deduct values to use for final PCI calculation
390
+ */
391
+ function _getFinalDeductValues(deductValues, updates) {
392
+ const skipAdditionalTypes = [];
393
+ return deductValues.split(",").reduce((prev, cur) => {
394
+ //0: type, 1: severity, 2: deductValue, 3: density
395
+ const splitVal = cur.split("|");
396
+ const type = splitVal[0];
397
+ const deductValue = parseFloat(splitVal[2]);
398
+ if (Object.keys(updates).length > 0 && updates[type]) {
399
+ skipAdditionalTypes.push(type);
400
+ prev.push(...updates[type]);
401
+ delete (updates[type]);
402
+ }
403
+ else if (skipAdditionalTypes.indexOf(type) < 0) {
404
+ prev.push(deductValue);
405
+ }
406
+ return prev;
407
+ }, []);
408
+ }
409
+ /**
410
+ * Executes the polynomial equation using the provided values and density.
411
+ * In the ASTM standard this is the step represented by finding the values
412
+ * on the plotted graphs.
413
+ *
414
+ * @returns the calculated deduct value
415
+ */
416
+ function _calc(density, vals) {
417
+ return vals.reduce((prev, cur, i) => {
418
+ return prev += i === 0 ? cur :
419
+ i === 1 ? (cur * density) :
420
+ (cur * Math.pow(density, i));
421
+ }, 0);
422
+ }
423
+ /**
424
+ * Round to the nerest decimal in the 10ths place
425
+ */
426
+ function _round(v) {
427
+ return Math.round(v * 10) / 10;
428
+ }
429
+ /**
430
+ * Execute the deduct value calculation for the distress type
431
+ *
432
+ * @param severity The severity of the distress type
433
+ * @param density percent density of the distress type
434
+ *
435
+ * @returns the calculated deduct value
436
+ */
437
+ function _calcAlligator(severity, density) {
438
+ const vals = severity === ESeverity.H ? [30.71, 29.22, 9.407, -6.981, -2.158, 3.047, -0.6578] :
439
+ severity === ESeverity.M ? [21.62, 21.32, 5.194, -1.343, 0.2341] :
440
+ [11.31, 16.05, 7.572, -1.471];
441
+ return _calc(density, vals);
442
+ }
443
+ /**
444
+ * Execute the deduct value calculation for the distress type
445
+ *
446
+ * @param severity The severity of the distress type
447
+ * @param density percent density of the distress type
448
+ *
449
+ * @returns the calculated deduct value
450
+ */
451
+ function _calcBleeding(severity, density) {
452
+ const vals = severity === ESeverity.H ? [5.343, 6.927, 7.926, 4.265, -0.7582] :
453
+ severity === ESeverity.M ? [2.38, 5.483, 4.128, 0.8366, 0.03659, 0.1052] :
454
+ [0.01391, 0.5079, 1.576, 1.191, 0.1329, 0.03823];
455
+ return _calc(density, vals);
456
+ }
457
+ /**
458
+ * Execute the deduct value calculation for the distress type
459
+ *
460
+ * @param severity The severity of the distress type
461
+ * @param density percent density of the distress type
462
+ *
463
+ * @returns the calculated deduct value
464
+ */
465
+ function _calcBlockCracking(severity, density) {
466
+ const vals = severity === ESeverity.H ? [7.926, 11.93, 8.826, 3.432, -1.382] :
467
+ severity === ESeverity.M ? [2.587, 9.142, 6.647, -0.455, -0.2439, 0.1107] :
468
+ [0.646, 4.002, 4.2, 0.4987, -0.06269];
469
+ return _calc(density, vals);
470
+ }
471
+ /**
472
+ * Execute the deduct value calculation for the distress type
473
+ *
474
+ * @param severity The severity of the distress type
475
+ * @param density percent density of the distress type
476
+ *
477
+ * @returns the calculated deduct value
478
+ */
479
+ function _calcBumpsSags(severity, density) {
480
+ const vals = severity === ESeverity.H ? [52.77, 38.07, 8.964, -0.4148, -1.589, 2.478] :
481
+ severity === ESeverity.M ? [24.66, 27.86, 15.73, 3.295, -5.27, 5.921, 7.959] :
482
+ [8.768, 13.79, 7.064, 7.455, 6.041, -1.739, -1.371];
483
+ return _calc(density, vals);
484
+ }
485
+ /**
486
+ * Execute the deduct value calculation for the distress type
487
+ *
488
+ * @param severity The severity of the distress type
489
+ * @param density percent density of the distress type
490
+ *
491
+ * @returns the calculated deduct value
492
+ */
493
+ function _calcCorrugation(severity, density) {
494
+ const vals = severity === ESeverity.H ? [34.21, 21.59, 1.863, 6.1410, -0.687, -1.885, 0.4916] :
495
+ severity === ESeverity.M ? [15.78, 19.69, 6.276, -2.124, 0.5868, 0.06045] :
496
+ [2.173, 5.609, 5.976, -0.7348, -0.2172, 1.494, -0.5659];
497
+ return _calc(density, vals);
498
+ }
499
+ /**
500
+ * Execute the deduct value calculation for the distress type
501
+ *
502
+ * @param severity The severity of the distress type
503
+ * @param density percent density of the distress type
504
+ *
505
+ * @returns the calculated deduct value
506
+ */
507
+ function _calcDepression(severity, density) {
508
+ const vals = severity === ESeverity.H ? [17.84, 5.904, 9.406, 18.28, -2.753, -7.798, 2.402] :
509
+ severity === ESeverity.M ? [8.471, 3.171, 10.25, 12.2, -0.9687, -4.601, 1.079] :
510
+ [4.836, -0.7572, 4.786, 12.39, 1.233, -4.871, 0.9749];
511
+ return _calc(density, vals);
512
+ }
513
+ /**
514
+ * Execute the deduct value calculation for the distress type
515
+ *
516
+ * @param severity The severity of the distress type
517
+ * @param density percent density of the distress type
518
+ *
519
+ * @returns the calculated deduct value
520
+ */
521
+ function _calcEdgeCracking(severity, density) {
522
+ const vals = severity === ESeverity.H ? [14.99, 13.5, 10.62, 5.15, -1.792, -2.826] :
523
+ severity === ESeverity.M ? [9.177, 10.26, 5.704, -0.6812, -0.8588, 0.2123] :
524
+ [3.049, 4.802, 4.058, -0.3556, -1.55, 1.02];
525
+ return _calc(density, vals);
526
+ }
527
+ /**
528
+ * Execute the deduct value calculation for the distress type
529
+ *
530
+ * @param severity The severity of the distress type
531
+ * @param density percent density of the distress type
532
+ *
533
+ * @returns the calculated deduct value
534
+ */
535
+ function _calcReflectionCracking(severity, density) {
536
+ const vals = severity === ESeverity.H ? [14.99, 17.21, 27.63, 31.13, -20.94, -18.82, 9.985] :
537
+ severity === ESeverity.M ? [9.9193, 10.88, 8.073, 14.8, -3.792, -9.583, 3.651] :
538
+ [2.356, 6.664, 3.717, -1.393, 1.94, 1.785, -0.9707];
539
+ return _calc(density, vals);
540
+ }
541
+ /**
542
+ * Execute the deduct value calculation for the distress type
543
+ *
544
+ * @param severity The severity of the distress type
545
+ * @param density percent density of the distress type
546
+ *
547
+ * @returns the calculated deduct value
548
+ */
549
+ function _calcLaneShoulderDropOff(severity, density) {
550
+ const vals = severity === ESeverity.H ? [7.549, 6.907, 7.284, 9.304, 2.064] :
551
+ severity === ESeverity.M ? [4.02, 1.744, 14.36, 15.92, -40.22, 23.6] :
552
+ [2.004, 1.065, 9.706, 11.75, -27.52, 15.04];
553
+ return _calc(density, vals);
554
+ }
555
+ /**
556
+ * Execute the deduct value calculation for the distress type
557
+ *
558
+ * @param severity The severity of the distress type
559
+ * @param density percent density of the distress type
560
+ *
561
+ * @returns the calculated deduct value
562
+ */
563
+ function _calcLongTransCracking(severity, density) {
564
+ const vals = severity === ESeverity.H ? [19.56, 24.06, 12.12, 9.336, 1.532, -4.396] :
565
+ severity === ESeverity.M ? [9.751, 15.53, 4.719, 1.369, 1.206, -1.164] :
566
+ [2.347, 9.074, 8.424, -1.338, -1.873, 1.144];
567
+ return _calc(density, vals);
568
+ }
569
+ /**
570
+ * Execute the deduct value calculation for the distress type
571
+ *
572
+ * @param severity The severity of the distress type
573
+ * @param density percent density of the distress type
574
+ *
575
+ * @returns the calculated deduct value
576
+ */
577
+ function _calcPatchingUtilCutPatching(severity, density) {
578
+ const vals = severity === ESeverity.H ? [20.15, 16.55, 5.415, 10.77, 3.257, -4.502] :
579
+ severity === ESeverity.M ? [10.28, 12.71, 6.174, 1.928, 0.6923, -0.4673] :
580
+ [2.523, 6.892, 5.702, 2.407, 0.2185, -0.8722];
581
+ return _calc(density, vals);
582
+ }
583
+ /**
584
+ * Execute the deduct value calculation for the distress type
585
+ *
586
+ * @param severity The severity of the distress type
587
+ * @param density percent density of the distress type
588
+ *
589
+ * @returns the calculated deduct value
590
+ */
591
+ function _calcPolishedAggregate(severity, density) {
592
+ const vals = severity === "H" || severity === "M" || severity === "L" ?
593
+ [3.417, -26.82, 71.15, -76.22, 38.52, -6.904] : [];
594
+ return _calc(density, vals);
595
+ }
596
+ /**
597
+ * Execute the deduct value calculation for the distress type
598
+ *
599
+ * @param severity The severity of the distress type
600
+ * @param density percent density of the distress type
601
+ *
602
+ * @returns the calculated deduct value
603
+ */
604
+ function _calcPotholes(severity, density) {
605
+ const vals = severity === ESeverity.H ? [110.7, 60.66, 2.378, -2.664] :
606
+ severity === ESeverity.M ? [90.47, 60.41, -0.1123, -4.746] :
607
+ [58.19, 40.53, 2.884, -1.443, 0.1195];
608
+ return _calc(density, vals);
609
+ }
610
+ /**
611
+ * Execute the deduct value calculation for the distress type
612
+ *
613
+ * @param severity The severity of the distress type
614
+ * @param density percent density of the distress type
615
+ *
616
+ * @returns the calculated deduct value
617
+ */
618
+ function _calcRailroadCrossing(severity, density) {
619
+ const vals = severity === ESeverity.H ? [20, 38.64, -62.82, 193.6, -162.7, 41.22] :
620
+ severity === ESeverity.M ? [6.994, 23.47, -52.3, 167.3, -143.6, 37.64] :
621
+ [1.998, -0.7488, 13.8, -0.7917, -1.981];
622
+ return _calc(density, vals);
623
+ }
624
+ /**
625
+ * Execute the deduct value calculation for the distress type
626
+ *
627
+ * @param severity The severity of the distress type
628
+ * @param density percent density of the distress type
629
+ *
630
+ * @returns the calculated deduct value
631
+ */
632
+ function _calcRutting(severity, density) {
633
+ const vals = severity === ESeverity.H ? [27.61, 25.19, 8.557, 1.65, -2.2030] :
634
+ severity === ESeverity.M ? [18.47, 20.77, 6.617, -1.13, -2.286] :
635
+ [8.833, 14.84, 3.129, 0.1451, 2.438, -1.279];
636
+ return _calc(density, vals);
637
+ }
638
+ /**
639
+ * Execute the deduct value calculation for the distress type
640
+ *
641
+ * @param severity The severity of the distress type
642
+ * @param density percent density of the distress type
643
+ *
644
+ * @returns the calculated deduct value
645
+ */
646
+ function _calcShoving(severity, density) {
647
+ const vals = severity === ESeverity.H ? [18.7, 20.17, 10.3, 4.694, 1.331, -2.61] :
648
+ severity === ESeverity.M ? [10.39, 14.78, 5.488, 4.001, 3.23, -2.387] :
649
+ [4.002, 10.66, 6.332, -0.5226, -0.1923];
650
+ return _calc(density, vals);
651
+ }
652
+ /**
653
+ * Execute the deduct value calculation for the distress type
654
+ *
655
+ * @param severity The severity of the distress type
656
+ * @param density percent density of the distress type
657
+ *
658
+ * @returns the calculated deduct value
659
+ */
660
+ function _calcSlippageCracking(severity, density) {
661
+ const vals = severity === ESeverity.H ? [19.73, 32.21, 25.87, -2.871, -10.55, 1.496, 0.7393] :
662
+ severity === ESeverity.M ? [11.38, 18.55, 18.38, 1.628, -7.596, 0.5841, 0.5946] :
663
+ [5.144, 12.95, 11.95, -0.833, -2.995, 1.325, -0.2113];
664
+ return _calc(density, vals);
665
+ }
666
+ /**
667
+ * Execute the deduct value calculation for the distress type
668
+ *
669
+ * @param severity The severity of the distress type
670
+ * @param density percent density of the distress type
671
+ *
672
+ * @returns the calculated deduct value
673
+ */
674
+ function _calcSwell(severity, density) {
675
+ const vals = severity === ESeverity.H ? [34, 16.84, -23.09, 41.17, -14.84] :
676
+ severity === ESeverity.M ? [12, 15.67, 20.59, -28.33, 21, -5.508] :
677
+ [1.995, 11.9, -12.83, 16.74, -5.361];
678
+ return _calc(density, vals);
679
+ }
680
+ /**
681
+ * Execute the deduct value calculation for the distress type
682
+ *
683
+ * @param severity The severity of the distress type
684
+ * @param density percent density of the distress type
685
+ *
686
+ * @returns the calculated deduct value
687
+ */
688
+ function _calcRaveling(severity, density) {
689
+ const vals = severity === ESeverity.H ? [16.77, 10.67, 5.758, 12.9, -0.0633, -5.659, 1.48] :
690
+ severity === ESeverity.M ? [8.512, 5.106, 1.63, 3.469, 1.028, -1.211, 0.1938] :
691
+ [];
692
+ return _calc(density, vals);
693
+ }
694
+ /**
695
+ * Execute the deduct value calculation for the distress type
696
+ *
697
+ * @param severity The severity of the distress type
698
+ * @param density percent density of the distress type
699
+ *
700
+ * @returns the calculated deduct value
701
+ */
702
+ function _calcWeathering(severity, density) {
703
+ const vals = severity === ESeverity.H ? [3.673, 3.349, 2.598, -1.233, 2.754, 2.434, -1.485] :
704
+ severity === ESeverity.M ? [1.12, 0.9769, 0.93, -0.5955, 1.041, 1.111, -0.614] :
705
+ [-0.0386, -0.0736, 0.834, 1.63, -0.0287, -0.639, 0.1515];
706
+ return _calc(density, vals);
707
+ }
708
+ /**
709
+ * Determine maximum Corrected Deduct Value (CDV) iteratively
710
+ *
711
+ * @param deductValues The calculated deduct values that will be used to determine max CDV
712
+ * @param showDebugging used to optionally show debugging messages
713
+ *
714
+ * @returns the max CDV value
715
+ */
716
+ function _getMaxCDV(deductValues, showDebugging) {
717
+ let maxCDV;
718
+ // If none or only one individual deduct value is greater
719
+ // than two, the total value is used in place of the maximum CD
720
+ const valuesGreaterThan2 = deductValues.filter(deductValue => deductValue > 2);
721
+ if (valuesGreaterThan2.length <= 1) {
722
+ maxCDV = valuesGreaterThan2.reduce((prev, cur) => {
723
+ prev += cur;
724
+ return prev;
725
+ }, 0);
726
+ if (showDebugging) {
727
+ console.log("If none or only one individual deduct value is greater");
728
+ console.log("than two, the total value is used in place of the maximum CD");
729
+ console.log(`Max CDV: ${maxCDV}`);
730
+ }
731
+ }
732
+ else {
733
+ // sort in descending order (section 9.5.2 in ASTM doc)
734
+ const sortedDVs = deductValues.sort((a, b) => b - a);
735
+ // Determine the allowable number of deducts, m (section 9.5.3 in ASTM doc)
736
+ const highestDV = sortedDVs[0];
737
+ // m = allowable number of deducts including fractions (must be less than or equal to ten)
738
+ const m = 1 + (9 / 98) * (100 - highestDV);
739
+ if (showDebugging) {
740
+ console.log(`Deduct values sorted in descending order: ${sortedDVs}`);
741
+ console.log(`Highest deduct value: ${highestDV}`);
742
+ console.log(`Allowable number of deducts including fractions: ${m}`);
743
+ }
744
+ // TODO they mention (must be less than or equal to ten) but don't say what happens if its over
745
+ if (m <= 10) {
746
+ const vals = _reduceDeductValues(sortedDVs, m);
747
+ if (showDebugging) {
748
+ console.log(`Reduce deduct values to the m largest including the fractional part: ${vals}`);
749
+ }
750
+ // iteratively determined cdv values
751
+ const cdvs = _getCDVs(vals, showDebugging);
752
+ maxCDV = Math.max(...cdvs);
753
+ if (showDebugging) {
754
+ console.log(`Max CDV: ${maxCDV}`);
755
+ }
756
+ }
757
+ else {
758
+ if (showDebugging) {
759
+ console.log("Allowable number of deducts including fractions (must be less than or equal to ten)");
760
+ }
761
+ }
762
+ }
763
+ return maxCDV;
764
+ }
765
+ /**
766
+ * Reduce deduct values to the m largest including the fractional part
767
+ *
768
+ * @param sortedDVs individual deduct values in descending order
769
+ * @param m allowable number of deducts (9.5.3 in ASTM standard)
770
+ *
771
+ * @returns updated deduct values
772
+ */
773
+ function _reduceDeductValues(sortedDVs, m) {
774
+ const fractionalPart = m - Math.floor(m);
775
+ // If less than m deduct values are available, all of the deduct values are used
776
+ return sortedDVs.length < m ? sortedDVs :
777
+ sortedDVs.reduce((prev, cur, i) => {
778
+ if (i + 1 < m) {
779
+ prev.push(cur);
780
+ }
781
+ else if (fractionalPart > 0) {
782
+ prev.push(_round(cur * fractionalPart));
783
+ }
784
+ return prev;
785
+ }, []);
786
+ }
787
+ /**
788
+ * Reduce the smallest individual deduct value greater to 2.0 and repeat
789
+ *
790
+ * @param vals the list of deduct values
791
+ * @param showDebugging optionally show debugging messages
792
+ *
793
+ * @returns array of CDV values
794
+ */
795
+ function _getCDVs(vals, showDebugging) {
796
+ let len = vals.length;
797
+ const cdvs = [];
798
+ while (len >= 1) {
799
+ if (showDebugging) {
800
+ console.log(`vals: ${vals}`);
801
+ }
802
+ cdvs.push(_getCDV(vals, showDebugging));
803
+ len -= 1;
804
+ vals.splice(len, 1, 2);
805
+ }
806
+ return cdvs;
807
+ }
808
+ /**
809
+ * Determine the total and max number deducts higher than two and calculate the CDV
810
+ *
811
+ * @param vals the list of deduct values
812
+ * @param showDebugging optionally show debugging messages
813
+ *
814
+ * @returns the calculated CDV
815
+ */
816
+ function _getCDV(vals, showDebugging) {
817
+ // section 9.5.5.1 in ASTM doc
818
+ const totalDV = vals.reduce((prev, cur) => prev += cur, 0);
819
+ // section 9.5.5.2 in ASTM doc
820
+ // the number of deducts with a value greater than 2.0
821
+ const q = vals.reduce((prev, cur) => cur > 2 ? prev + 1 : prev, 0);
822
+ // section 9.5.5.3 in ASTM doc
823
+ return _calcCDV(totalDV, q, showDebugging);
824
+ }
825
+ /**
826
+ * Determine the total and max number deducts higher than two and calculate the CDV
827
+ *
828
+ * @param total the sum of all deduct values
829
+ * @param q the number of deducts with a value greater than 2.0
830
+ * @param showDebugging optionally show debugging messages
831
+ *
832
+ * @returns the calculated CDV
833
+ */
834
+ function _calcCDV(total, q, showDebugging) {
835
+ // Determine the CDV from total deduct value and q
836
+ const vals2 = {
837
+ 7: [-9.482, 0.6045, 0.0003563, -5.448e-06],
838
+ 6: [-8.165, 0.5724, 0.0004266, -4.254e-06],
839
+ 5: [-7.932, 0.6091, 0.0003464, -4.265e-06],
840
+ 4: [-6.78, 0.6301, 0.0007376, -6.357e-06],
841
+ 3: [-5.015, 0.7546, -0.00043, -3.075e-06],
842
+ 2: [-1.668, 0.7992, -0.0003013, -5.214e-06],
843
+ 1: [1.651e-15, 1, -4.249e-18, 1.149e-19]
844
+ };
845
+ const cdv = _calc(total, vals2[q >= 7 ? 7 : q]);
846
+ if (showDebugging) {
847
+ console.log(`totalDV: ${total}`);
848
+ console.log(`q: ${q}`);
849
+ console.log(`CDV: ${cdv}`);
850
+ }
851
+ return cdv;
852
+ }
853
+
854
+ const deductCalculatorCss = ":host{display:block;--calcite-label-margin-bottom:0}.label-display{display:block;padding-bottom:1rem}";
855
+
856
+ const DeductCalculator = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
857
+ constructor() {
858
+ super();
859
+ this.__registerHost();
860
+ this.__attachShadow();
861
+ this.deductValueComplete = createEvent(this, "deductValueComplete", 7);
862
+ /**
863
+ * string[]: Array of the distress types
864
+ */
865
+ this._types = Object.keys(EDistressType).filter(k => !isNaN(Number(EDistressType[k])));
866
+ }
867
+ //--------------------------------------------------------------------------
868
+ //
869
+ // Functions (lifecycle)
870
+ //
871
+ //--------------------------------------------------------------------------
872
+ /**
873
+ * Renders the component.
874
+ */
875
+ render() {
876
+ return (h(Host, null, h("div", { class: "label-display" }, h("calcite-label", { class: "label-display" }, "Density %", this._getDensityInput()), h("calcite-label", { class: "label-display" }, "Type", this._getTypeInput()), h("calcite-label", { class: "label-display" }, "Severity", this._getSeverityInput())), h("div", null, this._getCalculateInput())));
877
+ }
878
+ //--------------------------------------------------------------------------
879
+ //
880
+ // Functions (protected)
881
+ //
882
+ //--------------------------------------------------------------------------
883
+ /**
884
+ * Render the density input
885
+ *
886
+ * @returns a node with a control to set the density number (float)
887
+ *
888
+ * @protected
889
+ */
890
+ _getDensityInput() {
891
+ return (h("calcite-input", { max: 100, min: 0, ref: (el) => { this._densityElement = el; }, type: 'number' }));
892
+ }
893
+ /**
894
+ * Render the distress type input
895
+ *
896
+ * @returns a node with a control that shows the distress type name and value
897
+ * for example ALLIGATOR_CRACKING (1)
898
+ *
899
+ * @protected
900
+ */
901
+ _getTypeInput() {
902
+ return (h("calcite-select", { label: '', ref: (el) => { this._typeElement = el; } }, this._types.map((t, i) => h("calcite-option", { value: EDistressType[t].toString() }, `${t} (${i + 1})`))));
903
+ }
904
+ /**
905
+ * Render the distress type input
906
+ *
907
+ * @returns a node with a control that shows the distress type name and value
908
+ * for example ALLIGATOR_CRACKING (1)
909
+ *
910
+ * @protected
911
+ */
912
+ _getSeverityInput() {
913
+ return (h("calcite-select", { label: '', ref: (el) => { this._severityElement = el; } }, h("calcite-option", { value: ESeverity.H }, "High"), h("calcite-option", { value: ESeverity.M }, "Medium"), h("calcite-option", { value: ESeverity.L }, "Low")));
914
+ }
915
+ /**
916
+ * Render calculate deduct value button
917
+ *
918
+ * @returns a node with a control that calculates the deduct value
919
+ *
920
+ * @protected
921
+ */
922
+ _getCalculateInput() {
923
+ return (h("calcite-button", { onClick: () => this._calculateDeduct(parseFloat(this._typeElement.value), this._severityElement.value, parseFloat(this._densityElement.value)) }, "Calculate Deduct Value"));
924
+ }
925
+ /**
926
+ * Calculate the deduct value based on the user inputs using the ASTM methodology
927
+ *
928
+ * @param type distress type 1-19 based on ASTM
929
+ * @param severity "H" | "M" | "L" high, med, low based on ASTM
930
+ * @param density percent density of the distress type and severity based on total sample area
931
+ *
932
+ * @protected
933
+ */
934
+ _calculateDeduct(type, severity, density) {
935
+ if (type && severity && !isNaN(density)) {
936
+ const dv = calculateDeductValue(type.toString(), severity.toString(), density.toString(), true);
937
+ this.deductValueComplete.emit(dv);
938
+ alert(dv);
939
+ }
940
+ else {
941
+ alert("Type, severity, and a density number are required");
942
+ }
943
+ }
944
+ get el() { return this; }
945
+ static get style() { return deductCalculatorCss; }
946
+ }, [1, "deduct-calculator"]);
947
+ function defineCustomElement() {
948
+ if (typeof customElements === "undefined") {
949
+ return;
950
+ }
951
+ const components = ["deduct-calculator", "calcite-button", "calcite-icon", "calcite-input", "calcite-label", "calcite-loader", "calcite-option", "calcite-progress", "calcite-select"];
952
+ components.forEach(tagName => { switch (tagName) {
953
+ case "deduct-calculator":
954
+ if (!customElements.get(tagName)) {
955
+ customElements.define(tagName, DeductCalculator);
956
+ }
957
+ break;
958
+ case "calcite-button":
959
+ if (!customElements.get(tagName)) {
960
+ defineCustomElement$8();
961
+ }
962
+ break;
963
+ case "calcite-icon":
964
+ if (!customElements.get(tagName)) {
965
+ defineCustomElement$7();
966
+ }
967
+ break;
968
+ case "calcite-input":
969
+ if (!customElements.get(tagName)) {
970
+ defineCustomElement$6();
971
+ }
972
+ break;
973
+ case "calcite-label":
974
+ if (!customElements.get(tagName)) {
975
+ defineCustomElement$5();
976
+ }
977
+ break;
978
+ case "calcite-loader":
979
+ if (!customElements.get(tagName)) {
980
+ defineCustomElement$4();
981
+ }
982
+ break;
983
+ case "calcite-option":
984
+ if (!customElements.get(tagName)) {
985
+ defineCustomElement$3();
986
+ }
987
+ break;
988
+ case "calcite-progress":
989
+ if (!customElements.get(tagName)) {
990
+ defineCustomElement$2();
991
+ }
992
+ break;
993
+ case "calcite-select":
994
+ if (!customElements.get(tagName)) {
995
+ defineCustomElement$1();
996
+ }
997
+ break;
998
+ } });
999
+ }
1000
+ defineCustomElement();
1001
+
1002
+ export { DeductCalculator as D, calculatePCI as c, defineCustomElement as d };