@corva/ui 3.75.0-13 → 3.75.0-15

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 (228) hide show
  1. package/cjs-bundle/components/AddComment/Popover.js +1 -1
  2. package/cjs-bundle/components/AddComment/Popover.js.map +1 -1
  3. package/cjs-bundle/components/AddComment/components/Content.js +1 -1
  4. package/cjs-bundle/components/AddComment/components/Content.js.map +1 -1
  5. package/cjs-bundle/components/AttachmentPreview/useStoredAttachments.js +1 -1
  6. package/cjs-bundle/components/AttachmentPreview/useStoredAttachments.js.map +1 -1
  7. package/cjs-bundle/components/BICOffsetPickerDialog/components/Map/Map.js +1 -1
  8. package/cjs-bundle/components/BICOffsetPickerDialog/components/Map/Map.js.map +1 -1
  9. package/cjs-bundle/components/BICOffsetPickerDialog/index.js +1 -1
  10. package/cjs-bundle/components/BICOffsetPickerDialog/index.js.map +1 -1
  11. package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
  12. package/cjs-bundle/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
  13. package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js +1 -1
  14. package/cjs-bundle/components/Casing/CasingTableV2/components/Component.js.map +1 -1
  15. package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
  16. package/cjs-bundle/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
  17. package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js +1 -1
  18. package/cjs-bundle/components/CommentComposer/useAttachmentUpload.js.map +1 -1
  19. package/cjs-bundle/components/DocumentViewer/DocumentViewer.js +1 -1
  20. package/cjs-bundle/components/DocumentViewer/DocumentViewer.js.map +1 -1
  21. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
  22. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
  23. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
  24. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
  25. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
  26. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
  27. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
  28. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
  29. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
  30. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
  31. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
  32. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
  33. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
  34. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
  35. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
  36. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
  37. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
  38. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
  39. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
  40. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
  41. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
  42. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
  43. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
  44. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
  45. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
  46. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
  47. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
  48. package/cjs-bundle/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
  49. package/cjs-bundle/components/OffsetWellMap/OffsetWellMap.js +1 -1
  50. package/cjs-bundle/components/OffsetWellMap/OffsetWellMap.js.map +1 -1
  51. package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
  52. package/cjs-bundle/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
  53. package/cjs-bundle/components/OffsetWellPickerV2/components/Map/Map.js +1 -1
  54. package/cjs-bundle/components/OffsetWellPickerV2/components/Map/Map.js.map +1 -1
  55. package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
  56. package/cjs-bundle/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
  57. package/cjs-bundle/components/OffsetWellPickerV2/effects/index.js +1 -1
  58. package/cjs-bundle/components/OffsetWellPickerV2/effects/index.js.map +1 -1
  59. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js +1 -1
  60. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js.map +1 -1
  61. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
  62. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
  63. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/effects/index.js +1 -1
  64. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/effects/index.js.map +1 -1
  65. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
  66. package/cjs-bundle/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
  67. package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
  68. package/cjs-bundle/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
  69. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
  70. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
  71. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
  72. package/cjs-bundle/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
  73. package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
  74. package/cjs-bundle/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
  75. package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
  76. package/cjs-bundle/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
  77. package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
  78. package/cjs-bundle/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
  79. package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/useMapTooltipState.js +1 -1
  80. package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/useMapTooltipState.js.map +1 -1
  81. package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/useSelectionToolOrchestration.js +1 -1
  82. package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/useSelectionToolOrchestration.js.map +1 -1
  83. package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/utils/well-markers-utils.js +1 -1
  84. package/cjs-bundle/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/utils/well-markers-utils.js.map +1 -1
  85. package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
  86. package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
  87. package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/components/CompanySafeguardWrapper/CompanySafeguardWrapper.js +1 -1
  88. package/cjs-bundle/components/OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/components/CompanySafeguardWrapper/CompanySafeguardWrapper.js.map +1 -1
  89. package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/wellTransformations.js +1 -1
  90. package/cjs-bundle/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/wellTransformations.js.map +1 -1
  91. package/cjs-bundle/components/OffsetWellPickerV5/utils/getCoordinatedWells.js +1 -1
  92. package/cjs-bundle/components/OffsetWellPickerV5/utils/getCoordinatedWells.js.map +1 -1
  93. package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js +1 -1
  94. package/cjs-bundle/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
  95. package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
  96. package/cjs-bundle/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
  97. package/cjs-bundle/componentsV2/CompletionsOffsetWellPicker/hooks/usePadsByRadius.js +1 -1
  98. package/cjs-bundle/componentsV2/CompletionsOffsetWellPicker/hooks/usePadsByRadius.js.map +1 -1
  99. package/cjs-bundle/effects/useSignedURL.js +1 -1
  100. package/cjs-bundle/effects/useSignedURL.js.map +1 -1
  101. package/cjs-bundle/utils/signedLinkCache.js +2 -0
  102. package/cjs-bundle/utils/signedLinkCache.js.map +1 -0
  103. package/components/AddComment/Popover.js +1 -1
  104. package/components/AddComment/Popover.js.map +1 -1
  105. package/components/AddComment/components/Content.js +1 -1
  106. package/components/AddComment/components/Content.js.map +1 -1
  107. package/components/AttachmentPreview/useStoredAttachments.d.ts.map +1 -1
  108. package/components/AttachmentPreview/useStoredAttachments.js +1 -1
  109. package/components/AttachmentPreview/useStoredAttachments.js.map +1 -1
  110. package/components/BICOffsetPickerDialog/components/Map/Map.d.ts.map +1 -1
  111. package/components/BICOffsetPickerDialog/components/Map/Map.js +1 -1
  112. package/components/BICOffsetPickerDialog/components/Map/Map.js.map +1 -1
  113. package/components/BICOffsetPickerDialog/index.js +1 -1
  114. package/components/BICOffsetPickerDialog/index.js.map +1 -1
  115. package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js +1 -1
  116. package/components/Casing/CasingTableV2/components/CasingJoints/Editor.js.map +1 -1
  117. package/components/Casing/CasingTableV2/components/Component.js +1 -1
  118. package/components/Casing/CasingTableV2/components/Component.js.map +1 -1
  119. package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js +1 -1
  120. package/components/Casing/CasingTableV2/components/DrillPipe/Editor.js.map +1 -1
  121. package/components/CommentComposer/useAttachmentUpload.d.ts.map +1 -1
  122. package/components/CommentComposer/useAttachmentUpload.js +1 -1
  123. package/components/CommentComposer/useAttachmentUpload.js.map +1 -1
  124. package/components/DocumentViewer/DocumentViewer.js +1 -1
  125. package/components/DocumentViewer/DocumentViewer.js.map +1 -1
  126. package/components/Drillstring/BHAComponentDetail/constants.d.ts +2 -2
  127. package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js +1 -1
  128. package/components/Drillstring/BHAComponentsTable/components/Agitator/Editor.js.map +1 -1
  129. package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js +1 -1
  130. package/components/Drillstring/BHAComponentsTable/components/Bit/Editor.js.map +1 -1
  131. package/components/Drillstring/BHAComponentsTable/components/Component.js +1 -1
  132. package/components/Drillstring/BHAComponentsTable/components/Component.js.map +1 -1
  133. package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js +1 -1
  134. package/components/Drillstring/BHAComponentsTable/components/DrillCollar/Editor.js.map +1 -1
  135. package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js +1 -1
  136. package/components/Drillstring/BHAComponentsTable/components/DrillPipe/Editor.js.map +1 -1
  137. package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js +1 -1
  138. package/components/Drillstring/BHAComponentsTable/components/Jar/Editor.js.map +1 -1
  139. package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js +1 -1
  140. package/components/Drillstring/BHAComponentsTable/components/Lwd/Editor.js.map +1 -1
  141. package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js +1 -1
  142. package/components/Drillstring/BHAComponentsTable/components/Mwd/Editor.js.map +1 -1
  143. package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js +1 -1
  144. package/components/Drillstring/BHAComponentsTable/components/Pdm/Editor.js.map +1 -1
  145. package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js +1 -1
  146. package/components/Drillstring/BHAComponentsTable/components/Rss/Editor.js.map +1 -1
  147. package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js +1 -1
  148. package/components/Drillstring/BHAComponentsTable/components/Stabilizer/Editor.js.map +1 -1
  149. package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js +1 -1
  150. package/components/Drillstring/BHAComponentsTable/components/Sub/Editor.js.map +1 -1
  151. package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js +1 -1
  152. package/components/Drillstring/BHAComponentsTable/components/Ur/Editor.js.map +1 -1
  153. package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js +1 -1
  154. package/components/Drillstring/BHAComponentsTable/components/shared/ConfirmationPopup.js.map +1 -1
  155. package/components/OffsetWellMap/OffsetWellMap.d.ts.map +1 -1
  156. package/components/OffsetWellMap/OffsetWellMap.js +1 -1
  157. package/components/OffsetWellMap/OffsetWellMap.js.map +1 -1
  158. package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js +1 -1
  159. package/components/OffsetWellPickerV2/components/Filter/ToggleMapButton.js.map +1 -1
  160. package/components/OffsetWellPickerV2/components/Map/Map.d.ts.map +1 -1
  161. package/components/OffsetWellPickerV2/components/Map/Map.js +1 -1
  162. package/components/OffsetWellPickerV2/components/Map/Map.js.map +1 -1
  163. package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js +1 -1
  164. package/components/OffsetWellPickerV2/components/Table/MetricsAddMenu.js.map +1 -1
  165. package/components/OffsetWellPickerV2/effects/index.d.ts.map +1 -1
  166. package/components/OffsetWellPickerV2/effects/index.js +1 -1
  167. package/components/OffsetWellPickerV2/effects/index.js.map +1 -1
  168. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.d.ts.map +1 -1
  169. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js +1 -1
  170. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Map/Map.js.map +1 -1
  171. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js +1 -1
  172. package/components/OffsetWellPickerV3/components/CustomSelectionView/components/Table/MetricsAddMenu.js.map +1 -1
  173. package/components/OffsetWellPickerV3/components/CustomSelectionView/effects/index.d.ts.map +1 -1
  174. package/components/OffsetWellPickerV3/components/CustomSelectionView/effects/index.js +1 -1
  175. package/components/OffsetWellPickerV3/components/CustomSelectionView/effects/index.js.map +1 -1
  176. package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js +1 -1
  177. package/components/OffsetWellPickerV3/components/CustomSelectionView/index.js.map +1 -1
  178. package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js +1 -1
  179. package/components/OffsetWellPickerV3/components/OffsetWellSelectionView/index.js.map +1 -1
  180. package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js +1 -1
  181. package/components/OffsetWellPickerV3/components/TabSelection/ToggleMapButton.js.map +1 -1
  182. package/components/OffsetWellPickerV3/components/TabSelection/index.js +1 -1
  183. package/components/OffsetWellPickerV3/components/TabSelection/index.js.map +1 -1
  184. package/components/OffsetWellPickerV3/components/WellHubView/index.js +1 -1
  185. package/components/OffsetWellPickerV3/components/WellHubView/index.js.map +1 -1
  186. package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js +1 -1
  187. package/components/OffsetWellPickerV3/components/shared/OffsetWellTableHead.js.map +1 -1
  188. package/components/OffsetWellPickerV4/effects/useAdvancedWells.d.ts.map +1 -1
  189. package/components/OffsetWellPickerV4/utils/index.d.ts.map +1 -1
  190. package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js +1 -1
  191. package/components/OffsetWellPickerV5/components/Filter/components/CustomDateFields/CustomDateFields.js.map +1 -1
  192. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/useMapTooltipState.js +1 -1
  193. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/useMapTooltipState.js.map +1 -1
  194. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/useSelectionToolOrchestration.js +1 -1
  195. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/useSelectionToolOrchestration.js.map +1 -1
  196. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/utils/well-markers-utils.d.ts.map +1 -1
  197. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/utils/well-markers-utils.js +1 -1
  198. package/components/OffsetWellPickerV5/components/Map/OffsetWellMap/hooks/utils/well-markers-utils.js.map +1 -1
  199. package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js +1 -1
  200. package/components/OffsetWellPickerV5/components/OffsetWellPickerContent/OffsetWellPickerContent.js.map +1 -1
  201. package/components/OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/components/CompanySafeguardWrapper/CompanySafeguardWrapper.js +1 -1
  202. package/components/OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/components/CompanySafeguardWrapper/CompanySafeguardWrapper.js.map +1 -1
  203. package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/wellTransformations.d.ts.map +1 -1
  204. package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/wellTransformations.js +1 -1
  205. package/components/OffsetWellPickerV5/hooks/use-well-data-pipeline/wellTransformations.js.map +1 -1
  206. package/components/OffsetWellPickerV5/utils/getCoordinatedWells.d.ts.map +1 -1
  207. package/components/OffsetWellPickerV5/utils/getCoordinatedWells.js +1 -1
  208. package/components/OffsetWellPickerV5/utils/getCoordinatedWells.js.map +1 -1
  209. package/components/PadOffsetsPicker/StagesSelector.js +1 -1
  210. package/components/PadOffsetsPicker/StagesSelector.js.map +1 -1
  211. package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js +1 -1
  212. package/components/PadOffsetsPickerV2/PadOffsetsPickerV2.js.map +1 -1
  213. package/componentsV2/CompletionsOffsetWellPicker/hooks/usePadsByRadius.d.ts.map +1 -1
  214. package/componentsV2/CompletionsOffsetWellPicker/hooks/usePadsByRadius.js +1 -1
  215. package/componentsV2/CompletionsOffsetWellPicker/hooks/usePadsByRadius.js.map +1 -1
  216. package/effects/useSignedURL.d.ts +1 -1
  217. package/effects/useSignedURL.d.ts.map +1 -1
  218. package/effects/useSignedURL.js +1 -1
  219. package/effects/useSignedURL.js.map +1 -1
  220. package/mcp-server/server.mjs +4 -4
  221. package/package.json +1 -1
  222. package/tsconfig.tsbuildinfo +1 -1
  223. package/utils/__tests__/signedLinkCache.test.d.ts +2 -0
  224. package/utils/__tests__/signedLinkCache.test.d.ts.map +1 -0
  225. package/utils/signedLinkCache.d.ts +9 -0
  226. package/utils/signedLinkCache.d.ts.map +1 -0
  227. package/utils/signedLinkCache.js +2 -0
  228. package/utils/signedLinkCache.js.map +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"useAttachmentUpload.js","sources":["../../../src/components/CommentComposer/useAttachmentUpload.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport S3Upload from 'react-s3-uploader/s3upload';\n\nimport type {\n AttachmentKind,\n AttachmentPreviewItem,\n} from '../AttachmentPreview/AttachmentPreview.types';\nimport { getAttachmentKind } from '../AttachmentPreview/getAttachmentKind';\nimport { ACCEPTED_ATTACHMENT_TYPES } from '../AttachFileButton';\n\nimport { getS3SignedUrl, getS3DownloadLink } from '~/clients/jsonApi';\nimport { getUrlFileName } from '~/utils/links';\n\nexport type UploadedAttachment = {\n url: string;\n name: string;\n size?: number;\n};\n\ntype UseAttachmentUploadOptions = {\n value: UploadedAttachment[];\n onChange: (attachments: UploadedAttachment[]) => void;\n onError?: (message: string | null) => void;\n maxSizeBytes?: number;\n maxFiles?: number;\n /** Mirrors the file input's `accept`; also gates drag-and-drop. */\n accept?: string;\n};\n\n/** A picked or already-stored file, in the order the user arranged it. */\ntype Entry = {\n id: string;\n name: string;\n /** Set while the file is local; cleared entries come from `value`. */\n file: File | null;\n previewUrl: string;\n isUploading: boolean;\n error: string | null;\n uploaded: UploadedAttachment | null;\n};\n\nexport const DEFAULT_MAX_ATTACHMENTS = 10;\n\n/** Same rules the file input enforces via `accept`, so drag-and-drop can't smuggle a type past it. */\nconst isAcceptedType = (file: File, accept: string) =>\n accept\n .split(',')\n .map(rule => rule.trim().toLowerCase())\n .filter(Boolean)\n .some(rule => {\n if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);\n if (rule.endsWith('/*')) {\n const type = file.type.toLowerCase();\n if (type) return type.startsWith(rule.slice(0, -1));\n\n return getAttachmentKind({ name: file.name }) === rule.slice(0, -1);\n }\n\n return file.type.toLowerCase() === rule;\n });\n\nconst getFileKind = (file: File): AttachmentKind => {\n if (file.type.startsWith('image/')) return 'image';\n if (file.type.startsWith('video/')) return 'video';\n return 'file';\n};\n\nconst formatMb = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);\n\nconst getUploaded = (entries: Entry[]) =>\n entries.map(entry => entry.uploaded).filter(Boolean) as UploadedAttachment[];\n\nconst isSameList = (a: UploadedAttachment[], b: UploadedAttachment[]) =>\n a.length === b.length && a.every((item, index) => item.url === b[index].url);\n\nconst toStoredEntry = (attachment: UploadedAttachment): Entry => ({\n id: attachment.url,\n name: attachment.name,\n file: null,\n previewUrl: '',\n isUploading: false,\n error: null,\n uploaded: attachment,\n});\n\nlet entrySeq = 0;\nconst nextEntryId = () => {\n entrySeq += 1;\n return `attachment-${entrySeq}`;\n};\n\nexport const useAttachmentUpload = ({\n value,\n onChange,\n onError,\n maxSizeBytes,\n maxFiles = DEFAULT_MAX_ATTACHMENTS,\n accept = ACCEPTED_ATTACHMENT_TYPES,\n}: UseAttachmentUploadOptions) => {\n const [entries, setEntries] = useState<Entry[]>([]);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadersRef = useRef(new Map<string, S3Upload>());\n // Bumped per attempt so a superseded upload can't write state for a restarted entry.\n const sessionsRef = useRef(new Map<string, number>());\n // Mutations are driven from async upload callbacks, so the latest list lives in a ref.\n const entriesRef = useRef<Entry[]>([]);\n const onChangeRef = useRef(onChange);\n const onErrorRef = useRef(onError);\n\n onChangeRef.current = onChange;\n onErrorRef.current = onError;\n\n // What we last handed the parent. A `value` that still matches it is our own change echoing\n // back; anything else is a parent-driven reset we must adopt.\n const emittedRef = useRef<UploadedAttachment[]>([]);\n\n const commit = useCallback((updater: (prev: Entry[]) => Entry[]) => {\n const next = updater(entriesRef.current);\n entriesRef.current = next;\n setEntries(next);\n emittedRef.current = getUploaded(next);\n onChangeRef.current(emittedRef.current);\n }, []);\n\n const patchEntry = useCallback(\n (id: string, patch: Partial<Entry>) =>\n commit(prev => prev.map(entry => (entry.id === id ? { ...entry, ...patch } : entry))),\n [commit]\n );\n\n const abortUpload = useCallback((id: string) => {\n uploadersRef.current.get(id)?.abortUpload();\n uploadersRef.current.delete(id);\n // Bump, never delete: deleting would let the next attempt reuse session 1, so a callback\n // still in flight from the aborted attempt would pass `isCurrent` and clobber it.\n sessionsRef.current.set(id, (sessionsRef.current.get(id) ?? 0) + 1);\n }, []);\n\n const releasePreview = useCallback((entry?: Entry) => {\n if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n }, []);\n\n // The banner is shared by every tile, so recompute it rather than clear it — one file\n // succeeding must not hide a sibling that is still failing.\n const syncError = useCallback(() => {\n onErrorRef.current?.(entriesRef.current.find(entry => entry.error)?.error ?? null);\n }, []);\n\n useEffect(\n () => () => {\n uploadersRef.current.forEach(uploader => uploader.abortUpload());\n uploadersRef.current.clear();\n entriesRef.current.forEach(entry => {\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n },\n []\n );\n\n const startUpload = useCallback(\n (id: string, file: File) => {\n const session = (sessionsRef.current.get(id) ?? 0) + 1;\n sessionsRef.current.set(id, session);\n // A superseded upload must not write state for an entry that is gone or restarted.\n const isCurrent = () => sessionsRef.current.get(id) === session;\n\n const fail = (message: string) => {\n if (!isCurrent()) return;\n patchEntry(id, { isUploading: false, error: message });\n onErrorRef.current?.(message);\n };\n\n let storedKey = '';\n\n const uploader = new S3Upload({\n files: [file],\n preprocess: (target: File, next: (file: File) => void) => next(target),\n onProgress: () => {},\n getSignedUrl: async (\n target: File,\n callback: (data: { signedUrl: string; [key: string]: unknown }) => void\n ) => {\n try {\n const data = await getS3SignedUrl(target.name, target.type);\n storedKey = data.file_name;\n callback({ ...data, signedUrl: data.signed_url });\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onFinishS3Put: async () => {\n try {\n const { url } = await getS3DownloadLink(storedKey);\n if (!isCurrent()) return;\n\n uploadersRef.current.delete(id);\n patchEntry(id, {\n isUploading: false,\n error: null,\n uploaded: { url, name: storedKey, size: file.size },\n });\n syncError();\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onError: (message: string) => fail(message || 'Failed to upload the file'),\n });\n\n uploadersRef.current.set(id, uploader);\n },\n [patchEntry, syncError]\n );\n\n /** Nothing is uploaded: a comment attachment is a url, so the link itself is the attachment. */\n const addLinkedImage = useCallback(\n (url: string) => {\n const name = getUrlFileName(url);\n\n if (!name) return;\n if (entriesRef.current.length >= maxFiles) {\n onErrorRef.current?.(`You can attach up to ${maxFiles} files.`);\n\n return;\n }\n\n if (entriesRef.current.some(entry => entry.uploaded?.url === url)) return;\n\n commit(prev => [\n ...prev,\n {\n id: nextEntryId(),\n name,\n file: null,\n previewUrl: url,\n isUploading: false,\n error: null,\n uploaded: { url, name },\n },\n ]);\n },\n [commit, maxFiles]\n );\n\n const addFiles = useCallback(\n (files: File[]) => {\n const supported = files.filter(file => isAcceptedType(file, accept));\n const skipped = supported.length < files.length;\n // One banner, one message: report the most actionable reason once, at the end. Reporting\n // as we go would let a later call overwrite an earlier warning on a mixed drop.\n const unsupported = skipped\n ? (files.length === 1 && 'That file type is not supported.') ||\n 'Some files were skipped — unsupported file type.'\n : null;\n const tooMany = `You can attach up to ${maxFiles} files.`;\n\n const room = maxFiles - entriesRef.current.length;\n if (!supported.length || room <= 0) {\n onErrorRef.current?.(supported.length ? tooMany : unsupported);\n return;\n }\n\n const accepted = supported.slice(0, room);\n const added: Entry[] = accepted.map(file => {\n const kind = getFileKind(file);\n const isTooLarge = !!maxSizeBytes && file.size > maxSizeBytes;\n\n return {\n id: nextEntryId(),\n name: file.name,\n file,\n previewUrl: kind === 'file' ? '' : URL.createObjectURL(file),\n isUploading: !isTooLarge,\n error: isTooLarge\n ? `File is too large (${formatMb(file.size)} MB). Maximum size is ${formatMb(\n maxSizeBytes as number\n )} MB.`\n : null,\n uploaded: null,\n };\n });\n\n commit(prev => [...prev, ...added]);\n\n const overflow = supported.length > accepted.length ? tooMany : null;\n onErrorRef.current?.(\n entriesRef.current.find(entry => entry.error)?.error ?? unsupported ?? overflow\n );\n\n added\n .filter(entry => !entry.error)\n .forEach(entry => startUpload(entry.id, entry.file as File));\n },\n [commit, maxFiles, maxSizeBytes, startUpload, accept]\n );\n\n const handleFileSelect = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n // Reset the input so re-picking the same file still fires a change event.\n if (fileInputRef.current) fileInputRef.current.value = '';\n if (files.length) addFiles(files);\n },\n [addFiles]\n );\n\n const openFileDialog = useCallback(() => fileInputRef.current?.click(), []);\n\n const removeAttachment = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n abortUpload(key);\n releasePreview(entriesRef.current.find(entry => entry.id === key));\n commit(prev => prev.filter(entry => entry.id !== key));\n syncError();\n },\n [abortUpload, releasePreview, commit, syncError]\n );\n\n const handleRetry = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n const entry = entriesRef.current.find(item => item.id === key);\n if (!entry?.file) return;\n\n abortUpload(key);\n patchEntry(key, { isUploading: true, error: null });\n syncError();\n startUpload(key, entry.file);\n },\n [abortUpload, patchEntry, startUpload, syncError]\n );\n\n const reorderAttachments = useCallback(\n (orderedIds: AttachmentPreviewItem['id'][]) =>\n commit(prev => {\n const byId = new Map(prev.map(entry => [entry.id, entry]));\n const reordered = orderedIds.map(id => byId.get(String(id))).filter(Boolean) as Entry[];\n // Unlisted ids (a race with a removal) keep their place at the end.\n const missing = prev.filter(entry => !orderedIds.some(id => String(id) === entry.id));\n return [...reordered, ...missing];\n }),\n [commit]\n );\n\n const clearAttachments = useCallback(() => {\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n releasePreview(entry);\n });\n commit(() => []);\n onErrorRef.current?.(null);\n }, [abortUpload, commit, releasePreview]);\n\n // Adopt a value we didn't produce — an edit form's initial attachments, or a parent-side reset.\n // Compared against what we emitted, not against the current entries: a failed-only or\n // mid-upload list emits `[]` too, and treating that as \"in sync\" would strand those tiles\n // on screen and let a late upload write itself back into freshly reset parent state.\n useEffect(() => {\n if (isSameList(emittedRef.current, value)) return;\n\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n entriesRef.current = value.map(toStoredEntry);\n emittedRef.current = value;\n setEntries(entriesRef.current);\n onErrorRef.current?.(null);\n }, [value, abortUpload]);\n\n // A stored url has expired by now, so re-sign it for the preview.\n const [storedSrcs, setStoredSrcs] = useState<Record<string, string>>({});\n const storedSrcsRef = useRef(storedSrcs);\n storedSrcsRef.current = storedSrcs;\n\n const storedNames = entries\n // A linked image carries its own url, so there is no key of ours to sign.\n .filter(entry => !entry.file && !entry.previewUrl && entry.uploaded)\n .map(entry => (entry.uploaded as UploadedAttachment).name)\n .join('|');\n\n useEffect(() => {\n const pending = storedNames.split('|').filter(name => name && !(name in storedSrcsRef.current));\n if (!pending.length) return undefined;\n\n let isActive = true;\n Promise.all(\n pending.map(name =>\n getS3DownloadLink(name, 'inline')\n .then(({ url }: { url: string }) => [name, url] as const)\n .catch(error => {\n console.error(`Failed to sign stored attachment \"${name}\"`, error);\n\n return [name, ''] as const;\n })\n )\n ).then(resolved => {\n if (isActive) setStoredSrcs(prev => ({ ...prev, ...Object.fromEntries(resolved) }));\n });\n\n return () => {\n isActive = false;\n };\n }, [storedNames]);\n\n const items = entries.reduce<AttachmentPreviewItem[]>((acc, entry) => {\n if (entry.file) {\n acc.push({\n id: entry.id,\n name: entry.name,\n src: entry.previewUrl,\n kind: getFileKind(entry.file),\n size: entry.file.size,\n isUploading: entry.isUploading,\n hideDownload: true,\n error: entry.error ?? undefined,\n });\n return acc;\n }\n\n const stored = entry.uploaded as UploadedAttachment;\n const kind = getAttachmentKind(stored);\n // A linked image is already a url; only one of ours has an S3 key worth signing.\n const src = entry.previewUrl || storedSrcs[stored.name];\n // A thumbnail without its signed url would paint as a broken image, so hold it back.\n if (kind !== 'file' && !src) return acc;\n\n acc.push({ id: entry.id, name: stored.name, src, kind, size: stored.size, hideDownload: true });\n return acc;\n }, []);\n\n return {\n items,\n fileInputRef,\n openFileDialog,\n handleFileSelect,\n addFiles,\n addLinkedImage,\n removeAttachment,\n handleRetry,\n reorderAttachments,\n clearAttachments,\n isUploading: entries.some(entry => entry.isUploading),\n error: entries.find(entry => entry.error)?.error ?? null,\n count: entries.length,\n isFull: entries.length >= maxFiles,\n maxFiles,\n };\n};\n"],"names":["DEFAULT_MAX_ATTACHMENTS","getFileKind","file","type","startsWith","formatMb","bytes","toFixed","toStoredEntry","attachment","id","url","name","previewUrl","isUploading","error","uploaded","entrySeq","nextEntryId","concat","useAttachmentUpload","_ref","_entries$find$error","_entries$find","value","onChange","onError","maxSizeBytes","_ref$maxFiles","maxFiles","_ref$accept","accept","ACCEPTED_ATTACHMENT_TYPES","useState","_useState2","_slicedToArray","_useState","entries","setEntries","fileInputRef","useRef","uploadersRef","Map","sessionsRef","entriesRef","onChangeRef","onErrorRef","current","emittedRef","commit","useCallback","updater","next","map","entry","filter","Boolean","getUploaded","patchEntry","patch","prev","abortUpload","_uploadersRef$current","_sessionsRef$current$","get","delete","set","releasePreview","URL","revokeObjectURL","syncError","_onErrorRef$current","_entriesRef$current$f","_entriesRef$current$f2","find","useEffect","forEach","uploader","clear","startUpload","_sessionsRef$current$2","session","_onFinishS3Put","_getSignedUrl","isCurrent","fail","message","_onErrorRef$current2","storedKey","S3Upload","files","preprocess","target","onProgress","getSignedUrl","_asyncToGenerator","_regeneratorRuntime","mark","_callee","callback","_data","wrap","_context","getS3SignedUrl","data","sent","file_name","signedUrl","signed_url","t0","stop","_x","_x2","apply","this","arguments","onFinishS3Put","_callee2","_yield$getS3DownloadL","_context2","getS3DownloadLink","abrupt","size","addLinkedImage","_onErrorRef$current3","getUrlFileName","length","some","_entry$uploaded","_toConsumableArray","addFiles","_onErrorRef$current5","_ref2","_entriesRef$current$f3","_entriesRef$current$f4","supported","split","rule","trim","toLowerCase","endsWith","slice","getAttachmentKind","isAcceptedType","unsupported","tooMany","room","_onErrorRef$current4","accepted","added","kind","isTooLarge","createObjectURL","overflow","handleFileSelect","event","_event$target$files","Array","from","openFileDialog","_fileInputRef$current","click","removeAttachment","key","String","handleRetry","item","reorderAttachments","orderedIds","byId","reordered","missing","clearAttachments","_onErrorRef$current6","_onErrorRef$current7","a","b","every","index","_useState3","_useState4","storedSrcs","setStoredSrcs","storedSrcsRef","storedNames","join","pending","isActive","Promise","all","then","_ref3","catch","console","resolved","_objectSpread","Object","fromEntries","items","reduce","acc","_entry$error","push","src","hideDownload","undefined","stored","count","isFull"],"mappings":"uuCAyCO,IAAMA,EAA0B,GAoBjCC,EAAc,SAACC,GACnB,OAAIA,EAAKC,KAAKC,WAAW,UAAkB,QACvCF,EAAKC,KAAKC,WAAW,UAAkB,QACpC,MACT,EAEMC,EAAW,SAACC,GAAa,OAAMA,EAAK,SAAkBC,QAAQ,EAAE,EAQhEC,EAAgB,SAACC,GAA8B,MAAa,CAChEC,GAAID,EAAWE,IACfC,KAAMH,EAAWG,KACjBV,KAAM,KACNW,WAAY,GACZC,aAAa,EACbC,MAAO,KACPC,SAAUP,EACX,EAEGQ,EAAW,EACTC,EAAc,WAElB,MAAA,cAAAC,OADAF,GAAY,EAEd,EAEaG,EAAsB,SAODC,GAAA,IAAAC,EAAAC,EANhCC,IAAAA,MACAC,IAAAA,SACAC,IAAAA,QACAC,IAAAA,aAAYC,EAAAP,EACZQ,SAAAA,aAvDqC,GAuDHD,EAAAE,EAAAT,EAClCU,OAAAA,aAASC,EAAyBF,EAEJG,EAAAA,EAAkB,IAAGC,EAAAC,EAAAC,EAAA,GAA5CC,EAAOH,EAAA,GAAEI,EAAUJ,EAAA,GAEpBK,EAAeC,EAAyB,MACxCC,EAAeD,EAAO,IAAIE,KAE1BC,EAAcH,EAAO,IAAIE,KAEzBE,EAAaJ,EAAgB,IAC7BK,EAAcL,EAAOf,GACrBqB,EAAaN,EAAOd,GAE1BmB,EAAYE,QAAUtB,EACtBqB,EAAWC,QAAUrB,EAIrB,IAAMsB,EAAaR,EAA6B,IAE1CS,EAASC,GAAY,SAACC,GAC1B,IAAMC,EAAOD,EAAQP,EAAWG,SAChCH,EAAWG,QAAUK,EACrBd,EAAWc,GACXJ,EAAWD,QApDK,SAACV,GAAgB,OACnCA,EAAQg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AK,OAAIA,EAAMvC,KAAK,WAAjC,IAAAQ,OAAA,EAAAA,EAAoCR,aAAK,IAAAO,EAAAA,EAAI,KACpDyL,MAAO1K,EAAQyF,OACfkF,OAAQ3K,EAAQyF,QAAUjG,EAC1BA,SAAAA,EAEJ"}
1
+ {"version":3,"file":"useAttachmentUpload.js","sources":["../../../src/components/CommentComposer/useAttachmentUpload.ts"],"sourcesContent":["import { ChangeEvent, useCallback, useEffect, useRef, useState } from 'react';\nimport S3Upload from 'react-s3-uploader/s3upload';\n\nimport type {\n AttachmentKind,\n AttachmentPreviewItem,\n} from '../AttachmentPreview/AttachmentPreview.types';\nimport { getAttachmentKind } from '../AttachmentPreview/getAttachmentKind';\nimport { ACCEPTED_ATTACHMENT_TYPES } from '../AttachFileButton';\n\nimport { getS3SignedUrl } from '~/clients/jsonApi';\nimport { getUrlFileName } from '~/utils/links';\nimport { getSignedLink, peekSignedLink } from '~/utils/signedLinkCache';\n\nexport type UploadedAttachment = {\n url: string;\n name: string;\n size?: number;\n};\n\ntype UseAttachmentUploadOptions = {\n value: UploadedAttachment[];\n onChange: (attachments: UploadedAttachment[]) => void;\n onError?: (message: string | null) => void;\n maxSizeBytes?: number;\n maxFiles?: number;\n /** Mirrors the file input's `accept`; also gates drag-and-drop. */\n accept?: string;\n};\n\n/** A picked or already-stored file, in the order the user arranged it. */\ntype Entry = {\n id: string;\n name: string;\n /** Set while the file is local; cleared entries come from `value`. */\n file: File | null;\n previewUrl: string;\n isUploading: boolean;\n error: string | null;\n uploaded: UploadedAttachment | null;\n};\n\nexport const DEFAULT_MAX_ATTACHMENTS = 10;\n\n/** Same rules the file input enforces via `accept`, so drag-and-drop can't smuggle a type past it. */\nconst isAcceptedType = (file: File, accept: string) =>\n accept\n .split(',')\n .map(rule => rule.trim().toLowerCase())\n .filter(Boolean)\n .some(rule => {\n if (rule.startsWith('.')) return file.name.toLowerCase().endsWith(rule);\n if (rule.endsWith('/*')) {\n const type = file.type.toLowerCase();\n if (type) return type.startsWith(rule.slice(0, -1));\n\n return getAttachmentKind({ name: file.name }) === rule.slice(0, -1);\n }\n\n return file.type.toLowerCase() === rule;\n });\n\nconst getFileKind = (file: File): AttachmentKind => {\n if (file.type.startsWith('image/')) return 'image';\n if (file.type.startsWith('video/')) return 'video';\n return 'file';\n};\n\nconst formatMb = (bytes: number) => (bytes / (1024 * 1024)).toFixed(1);\n\nconst getUploaded = (entries: Entry[]) =>\n entries.map(entry => entry.uploaded).filter(Boolean) as UploadedAttachment[];\n\nconst isSameList = (a: UploadedAttachment[], b: UploadedAttachment[]) =>\n a.length === b.length && a.every((item, index) => item.url === b[index].url);\n\nconst toStoredEntry = (attachment: UploadedAttachment): Entry => ({\n id: attachment.url,\n name: attachment.name,\n file: null,\n previewUrl: '',\n isUploading: false,\n error: null,\n uploaded: attachment,\n});\n\nlet entrySeq = 0;\nconst nextEntryId = () => {\n entrySeq += 1;\n return `attachment-${entrySeq}`;\n};\n\nexport const useAttachmentUpload = ({\n value,\n onChange,\n onError,\n maxSizeBytes,\n maxFiles = DEFAULT_MAX_ATTACHMENTS,\n accept = ACCEPTED_ATTACHMENT_TYPES,\n}: UseAttachmentUploadOptions) => {\n const [entries, setEntries] = useState<Entry[]>([]);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const uploadersRef = useRef(new Map<string, S3Upload>());\n // Bumped per attempt so a superseded upload can't write state for a restarted entry.\n const sessionsRef = useRef(new Map<string, number>());\n // Mutations are driven from async upload callbacks, so the latest list lives in a ref.\n const entriesRef = useRef<Entry[]>([]);\n const onChangeRef = useRef(onChange);\n const onErrorRef = useRef(onError);\n\n onChangeRef.current = onChange;\n onErrorRef.current = onError;\n\n // What we last handed the parent. A `value` that still matches it is our own change echoing\n // back; anything else is a parent-driven reset we must adopt.\n const emittedRef = useRef<UploadedAttachment[]>([]);\n\n const commit = useCallback((updater: (prev: Entry[]) => Entry[]) => {\n const next = updater(entriesRef.current);\n entriesRef.current = next;\n setEntries(next);\n emittedRef.current = getUploaded(next);\n onChangeRef.current(emittedRef.current);\n }, []);\n\n const patchEntry = useCallback(\n (id: string, patch: Partial<Entry>) =>\n commit(prev => prev.map(entry => (entry.id === id ? { ...entry, ...patch } : entry))),\n [commit]\n );\n\n const abortUpload = useCallback((id: string) => {\n uploadersRef.current.get(id)?.abortUpload();\n uploadersRef.current.delete(id);\n // Bump, never delete: deleting would let the next attempt reuse session 1, so a callback\n // still in flight from the aborted attempt would pass `isCurrent` and clobber it.\n sessionsRef.current.set(id, (sessionsRef.current.get(id) ?? 0) + 1);\n }, []);\n\n const releasePreview = useCallback((entry?: Entry) => {\n if (entry?.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n }, []);\n\n // The banner is shared by every tile, so recompute it rather than clear it — one file\n // succeeding must not hide a sibling that is still failing.\n const syncError = useCallback(() => {\n onErrorRef.current?.(entriesRef.current.find(entry => entry.error)?.error ?? null);\n }, []);\n\n useEffect(\n () => () => {\n uploadersRef.current.forEach(uploader => uploader.abortUpload());\n uploadersRef.current.clear();\n entriesRef.current.forEach(entry => {\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n },\n []\n );\n\n const startUpload = useCallback(\n (id: string, file: File) => {\n const session = (sessionsRef.current.get(id) ?? 0) + 1;\n sessionsRef.current.set(id, session);\n // A superseded upload must not write state for an entry that is gone or restarted.\n const isCurrent = () => sessionsRef.current.get(id) === session;\n\n const fail = (message: string) => {\n if (!isCurrent()) return;\n patchEntry(id, { isUploading: false, error: message });\n onErrorRef.current?.(message);\n };\n\n let storedKey = '';\n\n const uploader = new S3Upload({\n files: [file],\n preprocess: (target: File, next: (file: File) => void) => next(target),\n onProgress: () => {},\n getSignedUrl: async (\n target: File,\n callback: (data: { signedUrl: string; [key: string]: unknown }) => void\n ) => {\n try {\n const data = await getS3SignedUrl(target.name, target.type);\n storedKey = data.file_name;\n callback({ ...data, signedUrl: data.signed_url });\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onFinishS3Put: async () => {\n try {\n const url = await getSignedLink(storedKey);\n if (!isCurrent()) return;\n\n uploadersRef.current.delete(id);\n patchEntry(id, {\n isUploading: false,\n error: null,\n uploaded: { url, name: storedKey, size: file.size },\n });\n syncError();\n } catch (e) {\n fail((e as Error)?.message || 'Failed to upload the file');\n }\n },\n onError: (message: string) => fail(message || 'Failed to upload the file'),\n });\n\n uploadersRef.current.set(id, uploader);\n },\n [patchEntry, syncError]\n );\n\n /** Nothing is uploaded: a comment attachment is a url, so the link itself is the attachment. */\n const addLinkedImage = useCallback(\n (url: string) => {\n const name = getUrlFileName(url);\n\n if (!name) return;\n if (entriesRef.current.length >= maxFiles) {\n onErrorRef.current?.(`You can attach up to ${maxFiles} files.`);\n\n return;\n }\n\n if (entriesRef.current.some(entry => entry.uploaded?.url === url)) return;\n\n commit(prev => [\n ...prev,\n {\n id: nextEntryId(),\n name,\n file: null,\n previewUrl: url,\n isUploading: false,\n error: null,\n uploaded: { url, name },\n },\n ]);\n },\n [commit, maxFiles]\n );\n\n const addFiles = useCallback(\n (files: File[]) => {\n const supported = files.filter(file => isAcceptedType(file, accept));\n const skipped = supported.length < files.length;\n // One banner, one message: report the most actionable reason once, at the end. Reporting\n // as we go would let a later call overwrite an earlier warning on a mixed drop.\n const unsupported = skipped\n ? (files.length === 1 && 'That file type is not supported.') ||\n 'Some files were skipped — unsupported file type.'\n : null;\n const tooMany = `You can attach up to ${maxFiles} files.`;\n\n const room = maxFiles - entriesRef.current.length;\n if (!supported.length || room <= 0) {\n onErrorRef.current?.(supported.length ? tooMany : unsupported);\n return;\n }\n\n const accepted = supported.slice(0, room);\n const added: Entry[] = accepted.map(file => {\n const kind = getFileKind(file);\n const isTooLarge = !!maxSizeBytes && file.size > maxSizeBytes;\n\n return {\n id: nextEntryId(),\n name: file.name,\n file,\n previewUrl: kind === 'file' ? '' : URL.createObjectURL(file),\n isUploading: !isTooLarge,\n error: isTooLarge\n ? `File is too large (${formatMb(file.size)} MB). Maximum size is ${formatMb(\n maxSizeBytes as number\n )} MB.`\n : null,\n uploaded: null,\n };\n });\n\n commit(prev => [...prev, ...added]);\n\n const overflow = supported.length > accepted.length ? tooMany : null;\n onErrorRef.current?.(\n entriesRef.current.find(entry => entry.error)?.error ?? unsupported ?? overflow\n );\n\n added\n .filter(entry => !entry.error)\n .forEach(entry => startUpload(entry.id, entry.file as File));\n },\n [commit, maxFiles, maxSizeBytes, startUpload, accept]\n );\n\n const handleFileSelect = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = Array.from(event.target.files ?? []);\n // Reset the input so re-picking the same file still fires a change event.\n if (fileInputRef.current) fileInputRef.current.value = '';\n if (files.length) addFiles(files);\n },\n [addFiles]\n );\n\n const openFileDialog = useCallback(() => fileInputRef.current?.click(), []);\n\n const removeAttachment = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n abortUpload(key);\n releasePreview(entriesRef.current.find(entry => entry.id === key));\n commit(prev => prev.filter(entry => entry.id !== key));\n syncError();\n },\n [abortUpload, releasePreview, commit, syncError]\n );\n\n const handleRetry = useCallback(\n (id: AttachmentPreviewItem['id']) => {\n const key = String(id);\n const entry = entriesRef.current.find(item => item.id === key);\n if (!entry?.file) return;\n\n abortUpload(key);\n patchEntry(key, { isUploading: true, error: null });\n syncError();\n startUpload(key, entry.file);\n },\n [abortUpload, patchEntry, startUpload, syncError]\n );\n\n const reorderAttachments = useCallback(\n (orderedIds: AttachmentPreviewItem['id'][]) =>\n commit(prev => {\n const byId = new Map(prev.map(entry => [entry.id, entry]));\n const reordered = orderedIds.map(id => byId.get(String(id))).filter(Boolean) as Entry[];\n // Unlisted ids (a race with a removal) keep their place at the end.\n const missing = prev.filter(entry => !orderedIds.some(id => String(id) === entry.id));\n return [...reordered, ...missing];\n }),\n [commit]\n );\n\n const clearAttachments = useCallback(() => {\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n releasePreview(entry);\n });\n commit(() => []);\n onErrorRef.current?.(null);\n }, [abortUpload, commit, releasePreview]);\n\n // Adopt a value we didn't produce — an edit form's initial attachments, or a parent-side reset.\n // Compared against what we emitted, not against the current entries: a failed-only or\n // mid-upload list emits `[]` too, and treating that as \"in sync\" would strand those tiles\n // on screen and let a late upload write itself back into freshly reset parent state.\n useEffect(() => {\n if (isSameList(emittedRef.current, value)) return;\n\n entriesRef.current.forEach(entry => {\n abortUpload(entry.id);\n if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl);\n });\n entriesRef.current = value.map(toStoredEntry);\n emittedRef.current = value;\n setEntries(entriesRef.current);\n onErrorRef.current?.(null);\n }, [value, abortUpload]);\n\n // A stored url has expired by now, so re-sign it for the preview.\n const [storedSrcs, setStoredSrcs] = useState<Record<string, string>>(() =>\n value.reduce<Record<string, string>>((acc, attachment) => {\n const src = peekSignedLink(attachment.name, 'inline');\n if (src) acc[attachment.name] = src;\n\n return acc;\n }, {})\n );\n const storedSrcsRef = useRef(storedSrcs);\n storedSrcsRef.current = storedSrcs;\n\n const storedNames = entries\n // A linked image carries its own url, so there is no key of ours to sign.\n .filter(entry => !entry.file && !entry.previewUrl && entry.uploaded)\n .map(entry => (entry.uploaded as UploadedAttachment).name)\n .join('|');\n\n useEffect(() => {\n const pending = storedNames.split('|').filter(name => name && !(name in storedSrcsRef.current));\n if (!pending.length) return undefined;\n\n let isActive = true;\n Promise.all(\n pending.map(name =>\n getSignedLink(name, 'inline')\n .then(url => [name, url] as const)\n .catch(error => {\n console.error(`Failed to sign stored attachment \"${name}\"`, error);\n\n return [name, ''] as const;\n })\n )\n ).then(resolved => {\n if (isActive) setStoredSrcs(prev => ({ ...prev, ...Object.fromEntries(resolved) }));\n });\n\n return () => {\n isActive = false;\n };\n }, [storedNames]);\n\n const items = entries.reduce<AttachmentPreviewItem[]>((acc, entry) => {\n if (entry.file) {\n acc.push({\n id: entry.id,\n name: entry.name,\n src: entry.previewUrl,\n kind: getFileKind(entry.file),\n size: entry.file.size,\n isUploading: entry.isUploading,\n hideDownload: true,\n error: entry.error ?? undefined,\n });\n return acc;\n }\n\n const stored = entry.uploaded as UploadedAttachment;\n const kind = getAttachmentKind(stored);\n // A linked image is already a url; only one of ours has an S3 key worth signing.\n const src = entry.previewUrl || storedSrcs[stored.name];\n // A thumbnail without its signed url would paint as a broken image, so hold it back.\n if (kind !== 'file' && !src) return acc;\n\n acc.push({ id: entry.id, name: stored.name, src, kind, size: stored.size, hideDownload: true });\n return acc;\n }, []);\n\n return {\n items,\n fileInputRef,\n openFileDialog,\n handleFileSelect,\n addFiles,\n addLinkedImage,\n removeAttachment,\n handleRetry,\n reorderAttachments,\n clearAttachments,\n isUploading: entries.some(entry => entry.isUploading),\n error: entries.find(entry => entry.error)?.error ?? null,\n count: entries.length,\n isFull: entries.length >= maxFiles,\n maxFiles,\n };\n};\n"],"names":["DEFAULT_MAX_ATTACHMENTS","getFileKind","file","type","startsWith","formatMb","bytes","toFixed","toStoredEntry","attachment","id","url","name","previewUrl","isUploading","error","uploaded","entrySeq","nextEntryId","concat","useAttachmentUpload","_ref","_entries$find$error","_entries$find","value","onChange","onError","maxSizeBytes","_ref$maxFiles","maxFiles","_ref$accept","accept","ACCEPTED_ATTACHMENT_TYPES","useState","_useState2","_slicedToArray","_useState","entries","setEntries","fileInputRef","useRef","uploadersRef","Map","sessionsRef","entriesRef","onChangeRef","onErrorRef","current","emittedRef","commit","useCallback","updater","next","map","entry","filter","Boolean","getUploaded","patchEntry","patch","prev","abortUpload","_uploadersRef$current","_sessionsRef$current$","get","delete","set","releasePreview","URL","revokeObjectURL","syncError","_onErrorRef$current","_entriesRef$current$f","_entriesRef$current$f2","find","useEffect","forEach","uploader","clear","startUpload","_sessionsRef$current$2","session","_onFinishS3Put","_getSignedUrl","isCurrent","fail","message","_onErrorRef$current2","storedKey","S3Upload","files","preprocess","target","onProgress","getSignedUrl","_asyncToGenerator","_regeneratorRuntime","mark","_callee","callback","_data","wrap","_context","getS3SignedUrl","data","sent","file_name","signedUrl","signed_url","t0","stop","_x","_x2","apply","this","arguments","onFinishS3Put","_callee2","_context2","getSignedLink","abrupt","size","addLinkedImage","_onErrorRef$current3","getUrlFileName","length","some","_entry$uploaded","_toConsumableArray","addFiles","_onErrorRef$current5","_ref2","_entriesRef$current$f3","_entriesRef$current$f4","supported","split","rule","trim","toLowerCase","endsWith","slice","getAttachmentKind","isAcceptedType","unsupported","tooMany","room","_onErrorRef$current4","accepted","added","kind","isTooLarge","createObjectURL","overflow","handleFileSelect","event","_event$target$files","Array","from","openFileDialog","_fileInputRef$current","click","removeAttachment","key","String","handleRetry","item","reorderAttachments","orderedIds","byId","reordered","missing","clearAttachments","_onErrorRef$current6","_onErrorRef$current7","a","b","every","index","_useState3","reduce","acc","src","peekSignedLink","_useState4","storedSrcs","setStoredSrcs","storedSrcsRef","storedNames","join","pending","isActive","Promise","all","then","catch","console","resolved","_objectSpread","Object","fromEntries","items","_entry$error","push","hideDownload","undefined","stored","count","isFull"],"mappings":"myCA0CO,IAAMA,EAA0B,GAoBjCC,EAAc,SAACC,GACnB,OAAIA,EAAKC,KAAKC,WAAW,UAAkB,QACvCF,EAAKC,KAAKC,WAAW,UAAkB,QACpC,MACT,EAEMC,EAAW,SAACC,GAAa,OAAMA,EAAK,SAAkBC,QAAQ,EAAE,EAQhEC,EAAgB,SAACC,GAA8B,MAAa,CAChEC,GAAID,EAAWE,IACfC,KAAMH,EAAWG,KACjBV,KAAM,KACNW,WAAY,GACZC,aAAa,EACbC,MAAO,KACPC,SAAUP,EACX,EAEGQ,EAAW,EACTC,EAAc,WAElB,MAAA,cAAAC,OADAF,GAAY,EAEd,EAEaG,EAAsB,SAODC,GAAA,IAAAC,EAAAC,EANhCC,IAAAA,MACAC,IAAAA,SACAC,IAAAA,QACAC,IAAAA,aAAYC,EAAAP,EACZQ,SAAAA,aAvDqC,GAuDHD,EAAAE,EAAAT,EAClCU,OAAAA,aAASC,EAAyBF,EAEJG,EAAAA,EAAkB,IAAGC,EAAAC,EAAAC,EAAA,GAA5CC,EAAOH,EAAA,GAAEI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kBgE,GAEzBxB,EAAM/H,EAAMzC,YAAc2K,GAAWqB,EAAOjM,MAElD,MAAa,SAATyI,GAAoBgC,GAExBD,EAAIsB,KAAK,CAAEhM,GAAI4C,EAAM5C,GAAIE,KAAMiM,EAAOjM,KAAMyK,IAAAA,EAAKhC,KAAAA,EAAM5B,KAAMoF,EAAOpF,KAAMkF,cAAc,IACjFvB,GAH6BA,CAIrC,GAAE,IAID7I,aAAAA,EACAuH,eAAAA,EACAL,iBAAAA,EACAxB,SAAAA,EACAP,eAAAA,EACAuC,iBAAAA,EACAG,YAAAA,EACAE,mBAAAA,GACAK,iBAAAA,GACA7J,YAAauB,EAAQyF,MAAK,SAAAxE,GAAK,OAAIA,EAAMxC,eACzCC,MAAgD,UAAzC,UAAAsB,EAAQqC,MAAK,SAAApB,GAAK,OAAIA,EAAMvC,KAAK,WAAjC,IAAAQ,OAAA,EAAAA,EAAoCR,aAAK,IAAAO,EAAAA,EAAI,KACpDwL,MAAOzK,EAAQwF,OACfkF,OAAQ1K,EAAQwF,QAAUhG,EAC1BA,SAAAA,EAEJ"}
@@ -1,2 +1,2 @@
1
- import e from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/slicedToArray";import{useState as t,createRef as s,useCallback as i,useEffect as n}from"react";import r from"prop-types";import p from"classnames";import{Modal as m,Typography as c,IconButton as a}from"@material-ui/core";import l from"@material-ui/icons/Close";import d from"@material-ui/icons/GetApp";import{useStyles as j}from"./styles.js";import"../DevCenter/DevCenterAppContainer/components/IsInsideIsolatedDcAppProvider.js";import"../DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/DcFullscreenElemsCoordinatorProvider.js";import"../DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/IsInsideDcFullscreenElemProvider.js";import"@babel/runtime/helpers/objectWithoutProperties";import"lodash";import"../Modal/CorvaModal.scss.js";import"@icon-park/react/es/all";import{jsx as u,jsxs as C}from"react/jsx-runtime";import"../../icons/IconParkProvider.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/DragOne.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/SearchOne.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/InfoRounded.js";import"../../icons/customIcons/icons/FlameFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import"../../icons/customIcons/icons/Pad.js";import"../../icons/customIcons/icons/DrilloutUnit.js";import"../../icons/customIcons/icons/FracFleet.js";import"../../icons/customIcons/icons/Global.js";import"../../icons/customIcons/icons/Program.js";import"../../icons/customIcons/icons/Rig.js";import"../../icons/customIcons/icons/Well.js";import"../../icons/customIcons/icons/Gap.js";import"../../icons/customIcons/icons/Pin.js";import"../../icons/customIcons/icons/CloseOneFilled.js";import"../../icons/customIcons/icons/AttentionFilled.js";import"../../icons/customIcons/icons/CheckOneFilled.js";import"../../icons/customIcons/icons/Archive.js";import"../../icons/customIcons/icons/ArchiveCancel.js";import"../../icons/customIcons/icons/Unarchive.js";import"../../icons/customIcons/icons/Archived.js";import"../../icons/customIcons/icons/InterventionUnit.js";import"../../icons/customIcons/icons/CloudDelete.js";import"../../icons/customIcons/icons/Lasso.js";import"../../icons/customIcons/icons/Radius.js";import"../../icons/customIcons/icons/ErrorOps.js";import"../../icons/customIcons/icons/DataTypeOps.js";import"../../icons/customIcons/icons/FalsePositiveOps.js";import"../../icons/customIcons/icons/CalibrationOps.js";import"../../icons/customIcons/icons/CriticalOps.js";import"../../icons/customIcons/icons/Company.js";import"../../icons/customIcons/icons/ArchiveOne.js";import"../../icons/customIcons/icons/ParseBotFusion.js";import"../../icons/customIcons/icons/Connect.js";import"../../icons/customIcons/icons/PuzzleOne.js";import"../../icons/customIcons/icons/Feed.js";import"../../icons/customIcons/icons/Prompt.js";import"../../icons/customIcons/icons/Companies.js";import"../../icons/customIcons/icons/ClipboardAi.js";import"../../icons/customIcons/icons/Key.js";import"../../icons/customIcons/icons/AtSignCrossed.js";import"../../icons/customIcons/icons/MappingManual.js";import"../../icons/customIcons/icons/Mapping.js";import"../../icons/customIcons/icons/Metrics.js";import"../../icons/customIcons/icons/Drops.js";import"../../icons/customIcons/icons/ClipboardSearch.js";import"../../icons/customIcons/icons/Template.js";import"../../icons/customIcons/icons/ClipboardMetrics.js";import"../../icons/customIcons/icons/ClipboardBuilder.js";import"../../icons/customIcons/icons/UnitConversion.js";import"../../icons/customIcons/icons/NPT.js";import"../../icons/customIcons/icons/GuidedFrac.js";import"../../utils/mobileDetect.js";import"../IconButton/index.js";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/appPackages.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import"../../constants/corvaCompanyId.js";import"../GradientManager/configuration/constants.js";import"uuid";import"../IconMenu/index.js";import"../StyledMenuItem/index.js";import"../AppIcon/AppIcon.js";import"../DevCenter/AppHeader/AppHeader.js";import"../DevCenter/AppSideBar/AppSideBar.js";import"../DevCenter/AppsDataProvider/AppsDataProvider.js";import"../DevCenter/AppContext.js";import"../DevCenter/DevCenterRouterContext/DevCenterRouterContext.js";import"../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import"react-router-dom";import"query-string";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/regenerator";import"../../utils/index.js";import"@material-ui/icons";import"../EmptyState/EmptyState.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/components/RemoveAppButton.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/components/SettingsAccordion.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/styles.js";import"@material-ui/pickers";import"@date-io/moment";import"moment";import"../../config/theme/index.js";import"../../hocs/withAssetEditorLockHOC.js";import"../ErrorBoundary/ErrorBoundary.js";import"../ErrorBoundary/DevCenterAppErrorView/DevCenterAppErrorView.js";import"../Button/components/Button/index.js";import"moment-timezone";import"../Button/components/LiveButton/components/LiveButtonStateIndicator/index.js";import"../Button/components/LiveButton/styles.js";import"../AssetEditorV2/index.js";import"../AppVersionsSelect/AppVersionsSelect.js";import"../DisabledSettingsMessage/DisabledSettingsMessage.js";import"../ConfirmationDialog.js";import"immutable";import"../../permissions/PermissionsContext.js";import"../../permissions/constants/index.js";import"../../permissions/withPermissionsHOC.js";import"../../clients/jsonApi/index.js";import"../../permissions/ProvidePermissions.js";import"../../componentsV2/AppHeader/V3/VersionSelect/VersionSelect.constants.js";import"../Annotations/components/AnnotationsList/index.js";import"../Annotations/components/LastAnnotation/index.js";import"../Annotations/AnnotationsContext.js";import"../../componentsV2/AppContainer/AppContainer.js";import"../../componentsV2/AppContainer/AppContainer.constants.js";import"../../componentsV2/Text/Text.js";import"../../componentsV2/Header/Header.scss.js";import"../../componentsV2/Tooltip/Tooltip.scss.js";import"../../componentsV2/TextEndTruncated/TextEndTruncated.scss.js";import"../../componentsV2/AppCommonsProvider/AppCommonsContext.js";import"../../componentsV2/AppHeader/AppHeader.constants.js";import"../../componentsV2/AppHeader/AppBadge/AppBadge.scss.js";import"../../componentsV2/Chip/Chip.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.constants.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.scss.js";import"../../componentsV2/AppHeader/AppAssets/utils.js";import"../../componentsV2/AppHeader/AppAssets/AppAssets.scss.js";import"../PadModeSelect/PadModeSelect.js";import"../../componentsV2/AppHeader/PadMode/PadMode.scss.js";import"../../constants/streamSourceType.js";import"../../componentsV2/PadModeSelect/PadModeSelect.js";import"../../componentsV2/PadModeSelect/PadModeSelect.constants.js";import"../../componentsV2/AppCommonsProvider/AppCommonsProvider.js";import"../../componentsV2/utils.js";import"../../componentsV2/AppHeader/V3/VersionSelect/VersionSelect.js";import"../../componentsV2/UniversalLink/UniversalLink.scss.js";import"../../componentsV2/AppHeader/V3/AssetChips/AssetChips.scss.js";import"../../componentsV2/Button/Button.js";import"../../componentsV2/AppHeader/V3/DqStatusIcon/DqStatusIcon.js";import"../../componentsV2/AppHeader/V3/DqStatusIcon/DqStatusIcon.constants.js";import"../../componentsV2/Popover/Popover.js";import"@babel/runtime/helpers/toConsumableArray";import"../../componentsV2/Accordion/Accordion.scss.js";import"../../componentsV2/ButtonIcon/ButtonIcon.js";import"../../componentsV2/AppFooter/DqPopover/DqStatusIcon/DqStatusIcon.js";import"../../componentsV2/AppDqPopover/DqAlertTooltip/DqAlertTooltip.scss.js";import"../../componentsV2/AppDqPopover/DqAlert/DqAlert.scss.js";import"../../componentsV2/AppDqPopover/DqAsset/DqAsset.scss.js";import"../../componentsV2/AppDqPopover/AppDqPopover.scss.js";import"../../componentsV2/Menu/Menu.js";import"../../componentsV2/ModalWindow/ModalWindow.js";import"../../componentsV2/Modal/Modal.scss.js";import"../../componentsV2/LoaderLogo/LoaderLogo.constants.js";import"../../componentsV2/LoaderLogo/LoaderLogo.scss.js";import"../../utils/getSingleAsset.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorChip/AssetSelectorChip.js";import"../../componentsV2/TextInput/TextInput.js";import"../../componentsV2/AppHeader/V3/AssetSelector/constants.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorSelect/AssetSelectorSelect.scss.js";import"../../componentsV2/ChipIndicator/ChipIndicator.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorSelect/loadAssets.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelector.scss.js";import"../../clients/subscriptions/constants.js";import"querystring";import"uuid/v1";import"../../clients/subscriptions.v1.js";import"../../clients/subscriptions/subscriptions-client.factory.js";import"jsona";import"../../utils/env.js";import"../StatusBadge/constants.js";import"lodash/set";import"lodash/get";import"lodash/unset";import"../../clients/api/apiCore.js";import"../../clients/constants.js";import"../../clients/sso/auth0.js";import"../../clients/sso/oauth2.js";import"../../clients/api/rateLimiter.js";import"lodash/isEmpty";import"lodash/sortBy";import"../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchContext.js";import"../../componentsV2/AppSettings/AppSettingsPinningContext.js";import"../../componentsV2/AppHeader/V3/AppTitle/AppTitle.constants.js";import"../../componentsV2/AppHeader/V3/AppTitle/AppTitle.scss.js";import"../../componentsV2/AppHeader/V3/constants.scss.js";import"@babel/runtime/helpers/typeof";import"../../componentsV2/AppHeader/V3/SettingsButton/SettingsButton.js";import"../../componentsV2/AppHeader/V3/SettingsButton/SettingsButton.constants.js";import"../../componentsV2/AppSettings/AppSettings.js";import"../../componentsV2/AppSettings/AppSettings.constants.js";import"../../componentsV2/AppSizeProvider/AppSizeProvider.js";import"../../componentsV2/AppHeader/V3/Actions/Actions.constants.js";import"../../componentsV2/AppHeader/V3/Actions/Actions.scss.js";import"../../componentsV2/AppHeader/V3/AppHeaderV3.scss.js";import"../../componentsV2/AppHeader/AppHeader.scss.js";import"../../componentsV2/EmptyState/EmptyState.scss.js";import"../DevCenter/DevCenterAppContainer/components/DevCenterAppView/components/ChooseAssetButton.js";import"../DevCenter/DevCenterAppContainer/components/DevCenterAppView/DevCenterAppView.scss.js";import"../DevCenter/DevCenterAppContainer/components/AppActions/AppActions.css.js";import"../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchButton.scss.js";import"../../componentsV2/Grid/Grid.js";import"../../componentsV2/Grid/Cell.js";import"../../componentsV2/PopoverPanel/PopoverPanel.js";import"../../componentsV2/Radio/Radio.js";import"../../componentsV2/RadioAndCheckboxGroup/RadioAndCheckboxGroup.scss.js";import"../../componentsV2/Checkbox/Checkbox.js";import"../../componentsV2/TextInputNext/TextInputNext.js";import"../../componentsV2/TextArea/TextArea.js";import"../../componentsV2/Label/Label.js";import"../../componentsV2/TextLink/TextLink.js";import"../../componentsV2/ChipAlert/ChipAlert.js";import"../../componentsV2/Avatar/Avatar.js";import"../../componentsV2/AvatarGroup/AvatarGroup.js";import"@material-ui/lab";import"../../componentsV2/ToggleButtons/ToggleButtons.scss.js";import"../../componentsV2/Paper/Paper.js";import"../../componentsV2/Hint/Hint.scss.js";import"../../componentsV2/Counter/Counter.js";import"../../componentsV2/BadgeBase/BadgeBase.scss.js";import"../../componentsV2/TemplatesControl/TemplatesControl.js";import"zustand";import"../../componentsV2/TemplatesControl/utils.js";import"../../componentsV2/TemplatesControl/icons/folder/index.js";import"../../componentsV2/TemplatesControl/Store/utils.js";import"../../componentsV2/TemplatesControl/types.js";import"../../componentsV2/BadgeDot/BadgeDot.scss.js";import"../../componentsV2/LoaderLinear/LoaderLinear.scss.js";import"../../componentsV2/Switch/Switch.js";import"../../componentsV2/Tabs/Tabs.js";import"../../componentsV2/FileIcon/FileIcon.js";import"../../componentsV2/Tag/Tag.js";import"react-dropzone";import"../../componentsV2/FilesDropzone/FilesDropzone.scss.js";import"../../componentsV2/FilesLoader/FilesLoader.scss.js";import"file-extension";import"image-extensions";import"video-extensions";import"../../componentsV2/FilesProcessor/FilesProcessor.scss.js";import"../../componentsV2/Skeleton/Skeleton.scss.js";import"../../utils/main.js";import"../../componentsV2/CopyToClipboard/CopyToClipboard.scss.js";import"../../componentsV2/Stepper/Step/Step.scss.js";import"../../componentsV2/Stepper/Stepper.scss.js";import"../../componentsV2/ButtonLive/ButtonLive.js";import"../../componentsV2/ButtonText/ButtonText.js";import"../../componentsV2/IndicatorLive/IndicatorLive.js";import"../../componentsV2/Breadcrumbs/Breadcrumbs.scss.js";import"../../componentsV2/BadgeComment/BadgeComment.js";import"../../componentsV2/AppFooter/AppFooter.js";import"../../componentsV2/OffsetWellsButton/OffsetWellsButton.js";import"../../componentsV2/ChartAxisExtreme/ChartAxisExtreme.scss.js";import"highcharts";import"../../componentsV2/ChartAxisExtreme/ChartAxisExtremeDragTracker.js";import"../../componentsV2/Autocomplete/Autocomplete.js";import"../../componentsV2/Select/Select.js";import"../../componentsV2/AppSettingsDivider/AppSettingsDivider.scss.js";import"../../componentsV2/WellArchivedMessage/WellArchivedMessage.js";import"../../componentsV2/DatePicker/DatePicker.js";import"../../componentsV2/DragHandle/DragHandle.js";import"../../componentsV2/CompletionsOffsetWellPicker/CompletionsOffsetWellPicker.js";import"../../componentsV2/Slider/constants.js";import"../../componentsV2/Slider/components/SliderThumb.js";import"../../componentsV2/Slider/Slider.scss.js";import"../../componentsV2/SliderAdvanced/SliderAdvanced.js";import"react-color";import"../../componentsV2/ColorPicker/Swatches/Swatches.scss.js";import"../../componentsV2/ColorPicker/OpacityDragtracker/OpacityDragTracker.scss.js";import"../../componentsV2/ColorPicker/ColorPicker.scss.js";import"../../componentsV2/ChartHelper/ChartHelper.scss.js";import"../../componentsV2/Hotkey/Hotkey.js";import"@tanstack/react-query";import"../../componentsV2/InterventionEventSelector/useInterventionUnitEvents.js";import"../../componentsV2/InterventionEventSelector/InterventionEventSelector.scss.js";import"../DevCenter/DevCenterAppContainer/components/FullscreenButton/FullscreenButton.css.js";import"../Icons/AnnotationIcon.js";import"../HelpCenter/HelpCenterIcon.js";import"../DevCenter/DevCenterAppContainer/components/RestoreAppSizeButton/RestoreAppSizeButton.css.js";import"../DevCenter/DevCenterAppContainer/DevCenterAppContainer.scss.js";import"../Toaster/Toaster.js";import"../DevCenter/NavigationBar/NavigationBar.js";import"../DevCenter/SideBar/SideBar.js";import"../DevCenter/AppSettingsPopover/AppSettingsPopover.js";import"../DevCenter/AppFilterPanelLayout/AppFilterPanelLayout.js";import"../DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.js";import"../DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.js";import"../AssetEditor/index.js";import I from"../LoadingIndicator/LoadingIndicator.js";import"../Typography.js";import"../RealTimeValuesSidebar/RealTimeSidebar.js";import"../CollapsableSidebar.js";import"../DateTimePicker/index.js";import"../DatePicker/index.js";import"../SlateFormattedText/SlateFormattedText.js";import"../SlateFormattedText/RenderElements.js";import"slate";import"../ParameterCharts/ParameterCharts.js";import"../ParameterCharts/AddEditTrack.js";import"../ChartActionsList/ChartActionsList.js";import"../CopyToClipboard/CopyToClipboard.js";import"../AssetEditor/AssetEditorAutocomplete.js";import"../AssetEditor/SingleAssetEditor.js";import"../SettingEditors/ColorEditor/style.css.js";import"../SettingEditors/DropdownEditor/index.js";import"../SwitchControl/index.js";import"../ColorPicker/ColorPicker.js";import"../Chart/components/ChartButton.js";import"../Chart/components/ChartButtons.js";import"../Chart/components/ChartWrapper.js";import"../Chart/components/AxisDropdown.js";import"../Chart/components/ChartSelect.js";import"../Chart/ChartWrapperContext.js";import"../Chart/effects/useChartModifier.js";import"../Chart/components/buttons/HideAxesButton.js";import"../Chart/components/buttons/ChartTypeButton.js";import"../ColorPicker/PaletteChromePicker/PaletteChromePicker.js";import"../TruncatedText/index.js";import"../MiddleTruncatedText/MiddleTruncatedText.js";import"../RangeSlider/constants.js";import"../RangeSlider/Input.css.js";import"../RangeSlider/RangeSlider.css.js";import"../AdvancedSlider/AdvancedSlider.js";import"../Breadcrumbs/index.js";import"../VirtualizedTable/index.js";import"../EmptyView/EmptyView.js";import"../EmptyView/EmptyAppView/EmptyAppView.js";import"../ContextMenuItem/index.js";import"../FolderMenuItem/index.js";import"../EditableItem/EditableItem/index.js";import"../EditableItem/EditableItemWithBadge/index.js";import"../Checkbox/index.js";import"../FolderMenuItemWithLinks/index.js";import"../TextField/index.js";import"../Chip/index.js";import"../Counter/index.js";import"../AnchorsList/AnchorsList.js";import"../Select/index.js";import"../Select/SelectFilterBy.js";import"../CustomSelect/index.js";import"../Tabs/Tabs.js";import"../Tabs/Tab.js";import"../ResizableTable/ResizableTable.js";import"../GradientPicker/GradientPicker.js";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"../GradientManager/GradientPreview/GradientPreview.js";import"../GradientManager/GradientSelect.scss.js";import"../GradientManager/GradientManager.styles.js";import"../Drillstring/BHASchematic.js";import"../Drillstring/BHATable/index.js";import"../Drillstring/BHAComponentIcon.js";import"../Drillstring/BHAComponentDetail/index.js";import"../Drillstring/BHATileIcon.js";import"../Drillstring/BHATile/BHATile.js";import"../Drillstring/BHAList/BHAList.js";import"../Drillstring/BHAComponentsTable/BHAComponentsTable.js";import"../Casing/CasingTable/index.js";import"../Casing/CasingComponentIcon.js";import"../Casing/CasingTileIcon.js";import"../Casing/CasingTableV2/CasingTableV2.js";import"../Casing/CasingTile/CasingTile.js";import"../WellSummary/WellSummaryItemLabel.js";import"../WellSummary/WellSummaryItemTitle.js";import"../WellSummary/WellSummaryItemValue.js";import"../WellSummary/ActivitySummaryChart.js";import"../WellSummary/FracWirelineTimeChart.js";import"../BICOffsetPickerDialog/index.js";import"../OffsetWellButton/OffsetWellButton.js";import"../OffsetWellPickerV2/OffsetWellPickerDialog.js";import"../OffsetWellPickerV3/index.js";import"../OffsetWellChips/Chip.js";import"../OffsetWellChips/ChipsContainer.js";import"../OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/OffsetWellPickerV5WithStore.js";import"../OffsetWellMap/OffsetWellMap.js";import"@material-ui/core/Snackbar";import"../Notifications/Toast.js";import"../Notifications/Notifications.scss.js";import"../TextLink/index.js";import"../Avatar/index.js";import"../Template/TemplatePopover/index.js";import"../Template/TemplateSharingDialog/index.js";import"../MenuItem/index.js";import"../MiddleTruncate/MiddleTruncate.js";import"../PinnableFilters/PinnableFilters.js";import"../HeaderLayout/HeaderLayout.js";import"../PadOffsetsPicker/PadOffsetsPicker.js";import"../PadOffsetsPicker/OffsetAssetChip.js";import"../PadOffsetsPicker/OffsetAssetsListExpander.js";import"../PadOffsetsPicker/StagesSelector.js";import"../PadOffsetsPickerV2/PadOffsetsPickerV2.js";import"../Table/TableToolbar/TableToolbar.js";import"../Table/TableContainer/TableContainer.js";import"../Table/TableCell/TableCell.js";import"../Table/TablePagination/TablePagination.js";import"../Table/TablePaginationActions/TablePaginationActions.js";import"../Tooltip/ScrollableTooltip.js";import"../PriceInput/PriceInput.js";import"../LabelsCounter/LabelsCounter.js";import"../Stepper/Stepper.js";import"../Stepper/Step/Step.js";import"../Stepper/StepsWrapper.js";import"../Comment/CommentIcon/index.js";import"../FilesLoader/FilesLoader.js";import"../../componentsV2/FileIcon/icons/ArchiveFileIcon.js";import"../../componentsV2/FileIcon/icons/CSVFileIcon.js";import"../../componentsV2/FileIcon/icons/DocFileIcon.js";import"../../componentsV2/FileIcon/icons/EDMFileIcon.js";import"../../componentsV2/FileIcon/icons/ExcelFileIcon.js";import"../../componentsV2/FileIcon/icons/ImageFileIcon.js";import"../../componentsV2/FileIcon/icons/JsonFileIcon.js";import"../../componentsV2/FileIcon/icons/LasFileIcon.js";import"../../componentsV2/FileIcon/icons/OtherFileIcon.js";import"../../componentsV2/FileIcon/icons/PdfFileIcon.js";import"../../componentsV2/FileIcon/icons/PowerPointFileIcon.js";import"../../componentsV2/FileIcon/icons/TxtFileIcon.js";import"../../componentsV2/FileIcon/icons/UnknownFileIcon.js";import"../../componentsV2/FileIcon/icons/VideoFileIcon.js";import"../../componentsV2/FileIcon/icons/XmlFileIcon.js";import"../SearchInput/index.js";import"../FeedItem/FeedItem.js";import"../FeedItem/FeedItemEditProvider/FeedItemEditProvider.js";import"../PostInput/PostInput.js";import"../KeyboardDateTimePicker.js";import"../AddComment/Popover.js";import"../AddComment/Popup.js";import"../StageDesignVActual/ComparisonBar/ComparisonBar.js";import"../StageDesignVActual/ElementsComparison/ElementsComparison.js";import"../StageDesignVActual/ComparisonHeader.js";import"../StageDesignVActual/ComparisonRow.js";import"../EmbeddedApp/DevCenterEmbeddedApp.js";import"../EmbeddedApp/EmbeddedApp.js";import"../Autocomplete/Autocomplete.js";import"../ColorPickerPalette/ColorPickerPalette.js";import"../Search/Search.js";import"../Search/components/Listbox.js";import"../Search/components/Paper.js";import"../Search/components/RecentSearches.js";import"../Search/components/Groups.js";import"../Search/components/SelectAllListItem.js";import"../StatusBadge/index.js";import"../Attachment/index.js";import"../EmojiIconButton.js";import"../FileUploadIconButton.js";import"../FilePreview/index.js";import"../FailedFileUploading.js";import"../UserMention/index.js";import"../CommentsInfo/index.js";import"../CommentInput/index.js";import"../Comment/index.js";import"../CommentLoader.js";import"../AssetNameLabel/AssetStatusBadge.js";import"../AssetEditorV2/components/PrimaryAssetSelect.js";import"../AssetEditorV2/components/SecondaryAssetSelect.js";import"../AssetEditorV2/components/SelectItem.js";import"../AssetEditorV2/components/MultipleAssetsToggle.js";import"../AssetEditorV2/components/PrimaryAssetSelectV2.js";import"../EChartsWrapper/EChartsWrapper.js";import"../AssetsMultipleSelector/AssetsMultipleSelector.js";import"../GoogleDocsViewer/index.js";import"../NewDocumentViewer/effects/useFileContent.js";import"../NewDocumentViewer/styles.js";import"../FilesLoaderV2/styles.js";import"../FilesDropzone/styles.js";import"../FilesProcessor/styles.js";import"../Hint/styles.js";import"@babel/runtime/helpers/taggedTemplateLiteral";import"fparser";import"../Formula/useFormulaStyles.js";import"../Formula/RootXIcon.js";import"../Formula/FormulaTextEditor.js";import"../Formula/CloseSuggestion.js";import"../Formula/SuggestionsMenu.js";import"../CommentCard/CommentCard.js";import"@material-ui/icons/AlternateEmail";import"../AttachFileButton/AttachFileButton.scss.js";import"../CommentInputNext/CommentInputNext.js";import"../UserMention/utils/index.js";import"react-s3-uploader/s3upload";import"../CommentComposer/CommentMetaLine.scss.js";import"../CommentComposer/ChatChannelSelector.scss.js";import"../CommentComposer/ShareToChatRow.scss.js";import"../CommentComposer/CommentComposer.scss.js";import"../AttachmentPreview/AttachmentPreview.js";import"../AttachmentPreview/AttachmentImage.js";import"../AttachmentPreview/AttachmentPreview.scss.js";import"../CommentPin/CommentPin.js";import"../FeedCard/FeedCard.js";import"../FeedItemCard/FeedItemCard.js";import"../NewCommentCursor/NewCommentCursor.js";import"../LinkedText/LinkedText.js";import"../FeedItem/feedItemTypes/AlertFeedItem.js";import"../FeedItem/feedItemTypes/PostFeedItem.js";import"../FeedItem/feedItemTypes/GeosteeringFeedItem.js";import"../FeedItem/feedItemTypes/DrillingOperationalNoteFeedItem.js";import"../FeedItem/feedItemTypes/DrillingOperationSummaryFeedItem.js";import"../FeedItem/feedItemTypes/DrillingDailyCostFeedItem.js";import"../FeedItem/feedItemTypes/DocumentFeedItem.js";import"../FeedItem/feedItemTypes/DrillerMemoFeedItem.js";import"../FeedItem/feedItemTypes/NptFeedItem.js";import"../FeedItem/feedItemTypes/SurveyStationFeedItem/index.js";import"../FeedItem/feedItemTypes/LessonsLearnedFeedItem/index.js";import"../FeedItem/feedItemTypes/TracesMemoFeedItem.js";import"../FeedItem/feedItemTypes/DepthCommentFeedItem.js";import"../FeedItem/feedItemTypes/CompletionOperationalNoteFeedItem.js";import"../FeedItem/feedItemTypes/CompletionOperationSummaryFeedItem.js";import"../FeedItem/feedItemTypes/CompletionDailyCostFeedItem.js";import"../FeedItem/feedItemTypes/CompletionDocumentFeedItem.js";import"../FeedItem/feedItemTypes/CompletionNptFeedItem.js";import"../FeedItem/feedItemTypes/StageOverviewFeedItem/index.js";import"../FeedItem/feedItemTypes/AppAnnotationFeedItem/index.js";import"../FeedItem/feedItemTypes/WellPlanFeedItem/index.js";import"../FeedItem/feedItemTypes/FluidReportFeedItem.js";import"../FeedItem/feedItemTypes/BhaFeedItem/BhaFeedItem.js";import"../FeedItem/feedItemTypes/DvDCommentFeedItem.js";import"../FeedItem/feedItemTypes/PCCommentFeedItem.js";import"../FeedItem/feedItemTypes/HookloadCommentFeedItem.js";import"../FeedItem/feedItemTypes/NptLessonsCommentFeedItem.js";import"../FeedItem/feedItemTypes/GenericDataCommentFeedItem.js";var A=function(r){var A=r.open,V=r.fileUrl,S=r.fileSize,F=r.fileName,v=r.webviewType,T=void 0===v?"google":v,h=r.onClose,g=t(!0),D=o(g,2),f=D[0],P=D[1],x=t(!1),b=o(x,2),y=b[0],B=b[1],k=s(null),E=s(null),L=j(),w=i((function(){return"office"===T?"https://view.officeapps.live.com/op/embed.aspx?src=".concat(window.encodeURIComponent(V)):"https://docs.google.com/viewer?url=".concat(encodeURIComponent(V),"&embedded=true")}),[V]),H=function(){E.current&&(E.current.src=w(),E.current.contentWindow.location.reload())},M=function(){k.current&&clearInterval(k.current),P(!1)};return n((function(){P(!0),B(!1);var e=S&&S>=1048576?S/1048576*1e4:1e4;return k&&A&&(clearInterval(k.current),k.current=setInterval(H,e)),function(){clearInterval(k.current)}}),[V,A]),u(m,{open:A,onClose:h,onContextMenu:function(e){return e.stopPropagation()},children:C("div",{className:L.cDocsViewer,children:[C("div",{className:L.cDocsViewerToolbar,children:[u(c,{children:F}),C("div",{children:[u(a,{size:"small",className:L.cDocsViewerToolbarIconButton,children:u("a",{download:!0,href:V,target:"_blank",rel:"noopener noreferrer",children:u(d,{fontSize:"small"})})}),u(a,{size:"small",onClick:h,className:L.cDocsViewerToolbarIconButton,children:u(l,{fontSize:"small"})})]})]}),f&&u("div",{className:L.cDocsViewerFrame,children:u(I,{white:!1})}),y?u("div",{className:L.cDocsViewerFrame,children:u(c,{variant:"body2",className:L.cDocsViewerFrameFailed,children:"Loading failed"})}):u("iframe",{className:p(L.cDocsViewerFrame,e({},L.cDocsViewerFrameHidden,f)),title:V,src:w(),onLoad:M,onError:function(){M(),B(!0)},ref:E})]})})};A.propTypes={open:r.bool.isRequired,fileUrl:r.string.isRequired,webviewType:r.oneOf(["google","office"]),fileName:r.string,fileSize:r.number,onClose:r.func.isRequired,classes:r.shape({}).isRequired};export{A as default};
1
+ import e from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/slicedToArray";import{useState as t,createRef as s,useCallback as i,useEffect as n}from"react";import r from"prop-types";import p from"classnames";import{Modal as m,Typography as c,IconButton as a}from"@material-ui/core";import l from"@material-ui/icons/Close";import d from"@material-ui/icons/GetApp";import{useStyles as j}from"./styles.js";import"../DevCenter/DevCenterAppContainer/components/IsInsideIsolatedDcAppProvider.js";import"../DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/DcFullscreenElemsCoordinatorProvider.js";import"../DevCenter/DevCenterAppContainer/components/DcFullscreenElemsCoordinatorProvider/IsInsideDcFullscreenElemProvider.js";import"@babel/runtime/helpers/objectWithoutProperties";import"lodash";import"../Modal/CorvaModal.scss.js";import"@icon-park/react/es/all";import{jsx as u,jsxs as C}from"react/jsx-runtime";import"../../icons/IconParkProvider.js";import"../../icons/customIcons/icons/AddMessage.js";import"../../icons/customIcons/icons/DragOne.js";import"../../icons/customIcons/icons/Attention.js";import"../../icons/customIcons/icons/Collapse.js";import"../../icons/customIcons/icons/Dashboard.js";import"../../icons/customIcons/icons/Expand.js";import"../../icons/customIcons/icons/FolderClosed.js";import"../../icons/customIcons/icons/FolderClosedFilled.js";import"../../icons/customIcons/icons/FolderOpened.js";import"../../icons/customIcons/icons/GreaterOrEqual.js";import"../../icons/customIcons/icons/LessOrEqual.js";import"../../icons/customIcons/icons/Search.js";import"../../icons/customIcons/icons/SearchOne.js";import"../../icons/customIcons/icons/Wellhub.js";import"../../icons/customIcons/icons/MultiRuler.js";import"../../icons/customIcons/icons/Checkbox.js";import"../../icons/customIcons/icons/CheckboxChecked.js";import"../../icons/customIcons/icons/CheckboxIndeterminate.js";import"../../icons/customIcons/icons/Radio.js";import"../../icons/customIcons/icons/RadioChecked.js";import"../../icons/customIcons/icons/SimulFrac.js";import"../../icons/customIcons/icons/ZipperFrac.js";import"../../icons/customIcons/icons/CautionFilled.js";import"../../icons/customIcons/icons/InfoRounded.js";import"../../icons/customIcons/icons/FlameFilled.js";import"../../icons/customIcons/icons/MoreApp.js";import"../../icons/customIcons/icons/Pad.js";import"../../icons/customIcons/icons/DrilloutUnit.js";import"../../icons/customIcons/icons/FracFleet.js";import"../../icons/customIcons/icons/Global.js";import"../../icons/customIcons/icons/Program.js";import"../../icons/customIcons/icons/Rig.js";import"../../icons/customIcons/icons/Well.js";import"../../icons/customIcons/icons/Gap.js";import"../../icons/customIcons/icons/Pin.js";import"../../icons/customIcons/icons/CloseOneFilled.js";import"../../icons/customIcons/icons/AttentionFilled.js";import"../../icons/customIcons/icons/CheckOneFilled.js";import"../../icons/customIcons/icons/Archive.js";import"../../icons/customIcons/icons/ArchiveCancel.js";import"../../icons/customIcons/icons/Unarchive.js";import"../../icons/customIcons/icons/Archived.js";import"../../icons/customIcons/icons/InterventionUnit.js";import"../../icons/customIcons/icons/CloudDelete.js";import"../../icons/customIcons/icons/Lasso.js";import"../../icons/customIcons/icons/Radius.js";import"../../icons/customIcons/icons/ErrorOps.js";import"../../icons/customIcons/icons/DataTypeOps.js";import"../../icons/customIcons/icons/FalsePositiveOps.js";import"../../icons/customIcons/icons/CalibrationOps.js";import"../../icons/customIcons/icons/CriticalOps.js";import"../../icons/customIcons/icons/Company.js";import"../../icons/customIcons/icons/ArchiveOne.js";import"../../icons/customIcons/icons/ParseBotFusion.js";import"../../icons/customIcons/icons/Connect.js";import"../../icons/customIcons/icons/PuzzleOne.js";import"../../icons/customIcons/icons/Feed.js";import"../../icons/customIcons/icons/Prompt.js";import"../../icons/customIcons/icons/Companies.js";import"../../icons/customIcons/icons/ClipboardAi.js";import"../../icons/customIcons/icons/Key.js";import"../../icons/customIcons/icons/AtSignCrossed.js";import"../../icons/customIcons/icons/MappingManual.js";import"../../icons/customIcons/icons/Mapping.js";import"../../icons/customIcons/icons/Metrics.js";import"../../icons/customIcons/icons/Drops.js";import"../../icons/customIcons/icons/ClipboardSearch.js";import"../../icons/customIcons/icons/Template.js";import"../../icons/customIcons/icons/ClipboardMetrics.js";import"../../icons/customIcons/icons/ClipboardBuilder.js";import"../../icons/customIcons/icons/UnitConversion.js";import"../../icons/customIcons/icons/NPT.js";import"../../icons/customIcons/icons/GuidedFrac.js";import"../../utils/mobileDetect.js";import"../IconButton/index.js";import"../../constants/goals.js";import"../../constants/segment.js";import"../../constants/alerts.js";import"../../constants/apps.js";import"../../constants/drillstring.js";import"../../constants/completion.js";import"../../constants/appPackages.js";import"../../constants/notifications.js";import"../../constants/feed.js";import"../../constants/bha.js";import"../../constants/corvaCompanyId.js";import"../GradientManager/configuration/constants.js";import"uuid";import"../IconMenu/index.js";import"../StyledMenuItem/index.js";import"../AppIcon/AppIcon.js";import"../DevCenter/AppHeader/AppHeader.js";import"../DevCenter/AppSideBar/AppSideBar.js";import"../DevCenter/AppsDataProvider/AppsDataProvider.js";import"../DevCenter/AppContext.js";import"../DevCenter/DevCenterRouterContext/DevCenterRouterContext.js";import"../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import"react-router-dom";import"query-string";import"@babel/runtime/helpers/asyncToGenerator";import"@babel/runtime/regenerator";import"../../utils/index.js";import"@material-ui/icons";import"../EmptyState/EmptyState.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/components/RemoveAppButton.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/components/SettingsAccordion.js";import"../DevCenter/DevCenterAppContainer/components/AppSettingsDialog/styles.js";import"@material-ui/pickers";import"@date-io/moment";import"moment";import"../../config/theme/index.js";import"../../hocs/withAssetEditorLockHOC.js";import"../ErrorBoundary/ErrorBoundary.js";import"../ErrorBoundary/DevCenterAppErrorView/DevCenterAppErrorView.js";import"../Button/components/Button/index.js";import"moment-timezone";import"../Button/components/LiveButton/components/LiveButtonStateIndicator/index.js";import"../Button/components/LiveButton/styles.js";import"../AssetEditorV2/index.js";import"../AppVersionsSelect/AppVersionsSelect.js";import"../DisabledSettingsMessage/DisabledSettingsMessage.js";import"../ConfirmationDialog.js";import"immutable";import"../../permissions/PermissionsContext.js";import"../../permissions/constants/index.js";import"../../permissions/withPermissionsHOC.js";import"../../clients/jsonApi/index.js";import"../../permissions/ProvidePermissions.js";import"../../componentsV2/AppHeader/V3/VersionSelect/VersionSelect.constants.js";import"../Annotations/components/AnnotationsList/index.js";import"../Annotations/components/LastAnnotation/index.js";import"../Annotations/AnnotationsContext.js";import"../../componentsV2/AppContainer/AppContainer.js";import"../../componentsV2/AppContainer/AppContainer.constants.js";import"../../componentsV2/Text/Text.js";import"../../componentsV2/Header/Header.scss.js";import"../../componentsV2/Tooltip/Tooltip.scss.js";import"../../componentsV2/TextEndTruncated/TextEndTruncated.scss.js";import"../../componentsV2/AppCommonsProvider/AppCommonsContext.js";import"../../componentsV2/AppHeader/AppHeader.constants.js";import"../../componentsV2/AppHeader/AppBadge/AppBadge.scss.js";import"../../componentsV2/Chip/Chip.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.constants.js";import"../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.scss.js";import"../../componentsV2/AppHeader/AppAssets/utils.js";import"../../componentsV2/AppHeader/AppAssets/AppAssets.scss.js";import"../PadModeSelect/PadModeSelect.js";import"../../componentsV2/AppHeader/PadMode/PadMode.scss.js";import"../../constants/streamSourceType.js";import"../../componentsV2/PadModeSelect/PadModeSelect.js";import"../../componentsV2/PadModeSelect/PadModeSelect.constants.js";import"../../componentsV2/AppCommonsProvider/AppCommonsProvider.js";import"../../componentsV2/utils.js";import"../../componentsV2/AppHeader/V3/VersionSelect/VersionSelect.js";import"../../componentsV2/UniversalLink/UniversalLink.scss.js";import"../../componentsV2/AppHeader/V3/AssetChips/AssetChips.scss.js";import"../../componentsV2/Button/Button.js";import"../../componentsV2/AppHeader/V3/DqStatusIcon/DqStatusIcon.js";import"../../componentsV2/AppHeader/V3/DqStatusIcon/DqStatusIcon.constants.js";import"../../componentsV2/Popover/Popover.js";import"@babel/runtime/helpers/toConsumableArray";import"../../componentsV2/Accordion/Accordion.scss.js";import"../../componentsV2/ButtonIcon/ButtonIcon.js";import"../../componentsV2/AppFooter/DqPopover/DqStatusIcon/DqStatusIcon.js";import"../../componentsV2/AppDqPopover/DqAlertTooltip/DqAlertTooltip.scss.js";import"../../componentsV2/AppDqPopover/DqAlert/DqAlert.scss.js";import"../../componentsV2/AppDqPopover/DqAsset/DqAsset.scss.js";import"../../componentsV2/AppDqPopover/AppDqPopover.scss.js";import"../../componentsV2/Menu/Menu.js";import"../../componentsV2/ModalWindow/ModalWindow.js";import"../../componentsV2/Modal/Modal.scss.js";import"../../componentsV2/LoaderLogo/LoaderLogo.constants.js";import"../../componentsV2/LoaderLogo/LoaderLogo.scss.js";import"../../utils/getSingleAsset.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorChip/AssetSelectorChip.js";import"../../componentsV2/TextInput/TextInput.js";import"../../componentsV2/AppHeader/V3/AssetSelector/constants.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorSelect/AssetSelectorSelect.scss.js";import"../../componentsV2/ChipIndicator/ChipIndicator.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelectorSelect/loadAssets.js";import"../../componentsV2/AppHeader/V3/AssetSelector/AssetSelector.scss.js";import"../../clients/subscriptions/constants.js";import"querystring";import"uuid/v1";import"../../clients/subscriptions.v1.js";import"../../clients/subscriptions/subscriptions-client.factory.js";import"jsona";import"../../utils/env.js";import"../StatusBadge/constants.js";import"lodash/set";import"lodash/get";import"lodash/unset";import"../../clients/api/apiCore.js";import"../../clients/constants.js";import"../../clients/sso/auth0.js";import"../../clients/sso/oauth2.js";import"../../clients/api/rateLimiter.js";import"lodash/isEmpty";import"lodash/sortBy";import"../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchContext.js";import"../../componentsV2/AppSettings/AppSettingsPinningContext.js";import"../../componentsV2/AppHeader/V3/AppTitle/AppTitle.constants.js";import"../../componentsV2/AppHeader/V3/AppTitle/AppTitle.scss.js";import"../../componentsV2/AppHeader/V3/constants.scss.js";import"@babel/runtime/helpers/typeof";import"../../componentsV2/AppHeader/V3/SettingsButton/SettingsButton.js";import"../../componentsV2/AppHeader/V3/SettingsButton/SettingsButton.constants.js";import"../../componentsV2/AppSettings/AppSettings.js";import"../../componentsV2/AppSettings/AppSettings.constants.js";import"../../componentsV2/AppSizeProvider/AppSizeProvider.js";import"../../componentsV2/AppHeader/V3/Actions/Actions.constants.js";import"../../componentsV2/AppHeader/V3/Actions/Actions.scss.js";import"../../componentsV2/AppHeader/V3/AppHeaderV3.scss.js";import"../../componentsV2/AppHeader/AppHeader.scss.js";import"../../componentsV2/EmptyState/EmptyState.scss.js";import"../DevCenter/DevCenterAppContainer/components/DevCenterAppView/components/ChooseAssetButton.js";import"../DevCenter/DevCenterAppContainer/components/DevCenterAppView/DevCenterAppView.scss.js";import"../DevCenter/DevCenterAppContainer/components/AppActions/AppActions.css.js";import"../DevCenter/DevCenterAppContainer/components/CommentsSwitch/CommentsSwitchButton.scss.js";import"../../componentsV2/Grid/Grid.js";import"../../componentsV2/Grid/Cell.js";import"../../componentsV2/PopoverPanel/PopoverPanel.js";import"../../componentsV2/Radio/Radio.js";import"../../componentsV2/RadioAndCheckboxGroup/RadioAndCheckboxGroup.scss.js";import"../../componentsV2/Checkbox/Checkbox.js";import"../../componentsV2/TextInputNext/TextInputNext.js";import"../../componentsV2/TextArea/TextArea.js";import"../../componentsV2/Label/Label.js";import"../../componentsV2/TextLink/TextLink.js";import"../../componentsV2/ChipAlert/ChipAlert.js";import"../../componentsV2/Avatar/Avatar.js";import"../../componentsV2/AvatarGroup/AvatarGroup.js";import"@material-ui/lab";import"../../componentsV2/ToggleButtons/ToggleButtons.scss.js";import"../../componentsV2/Paper/Paper.js";import"../../componentsV2/Hint/Hint.scss.js";import"../../componentsV2/Counter/Counter.js";import"../../componentsV2/BadgeBase/BadgeBase.scss.js";import"../../componentsV2/TemplatesControl/TemplatesControl.js";import"zustand";import"../../componentsV2/TemplatesControl/utils.js";import"../../componentsV2/TemplatesControl/icons/folder/index.js";import"../../componentsV2/TemplatesControl/Store/utils.js";import"../../componentsV2/TemplatesControl/types.js";import"../../componentsV2/BadgeDot/BadgeDot.scss.js";import"../../componentsV2/LoaderLinear/LoaderLinear.scss.js";import"../../componentsV2/Switch/Switch.js";import"../../componentsV2/Tabs/Tabs.js";import"../../componentsV2/FileIcon/FileIcon.js";import"../../componentsV2/Tag/Tag.js";import"react-dropzone";import"../../componentsV2/FilesDropzone/FilesDropzone.scss.js";import"../../componentsV2/FilesLoader/FilesLoader.scss.js";import"file-extension";import"image-extensions";import"video-extensions";import"../../componentsV2/FilesProcessor/FilesProcessor.scss.js";import"../../componentsV2/Skeleton/Skeleton.scss.js";import"../../utils/main.js";import"../../componentsV2/CopyToClipboard/CopyToClipboard.scss.js";import"../../componentsV2/Stepper/Step/Step.scss.js";import"../../componentsV2/Stepper/Stepper.scss.js";import"../../componentsV2/ButtonLive/ButtonLive.js";import"../../componentsV2/ButtonText/ButtonText.js";import"../../componentsV2/IndicatorLive/IndicatorLive.js";import"../../componentsV2/Breadcrumbs/Breadcrumbs.scss.js";import"../../componentsV2/BadgeComment/BadgeComment.js";import"../../componentsV2/AppFooter/AppFooter.js";import"../../componentsV2/OffsetWellsButton/OffsetWellsButton.js";import"../../componentsV2/ChartAxisExtreme/ChartAxisExtreme.scss.js";import"highcharts";import"../../componentsV2/ChartAxisExtreme/ChartAxisExtremeDragTracker.js";import"../../componentsV2/Autocomplete/Autocomplete.js";import"../../componentsV2/Select/Select.js";import"../../componentsV2/AppSettingsDivider/AppSettingsDivider.scss.js";import"../../componentsV2/WellArchivedMessage/WellArchivedMessage.js";import"../../componentsV2/DatePicker/DatePicker.js";import"../../componentsV2/DragHandle/DragHandle.js";import"../../componentsV2/CompletionsOffsetWellPicker/CompletionsOffsetWellPicker.js";import"../../componentsV2/Slider/constants.js";import"../../componentsV2/Slider/components/SliderThumb.js";import"../../componentsV2/Slider/Slider.scss.js";import"../../componentsV2/SliderAdvanced/SliderAdvanced.js";import"react-color";import"../../componentsV2/ColorPicker/Swatches/Swatches.scss.js";import"../../componentsV2/ColorPicker/OpacityDragtracker/OpacityDragTracker.scss.js";import"../../componentsV2/ColorPicker/ColorPicker.scss.js";import"../../componentsV2/ChartHelper/ChartHelper.scss.js";import"../../componentsV2/Hotkey/Hotkey.js";import"@tanstack/react-query";import"../../componentsV2/InterventionEventSelector/useInterventionUnitEvents.js";import"../../componentsV2/InterventionEventSelector/InterventionEventSelector.scss.js";import"../DevCenter/DevCenterAppContainer/components/FullscreenButton/FullscreenButton.css.js";import"../Icons/AnnotationIcon.js";import"../HelpCenter/HelpCenterIcon.js";import"../DevCenter/DevCenterAppContainer/components/RestoreAppSizeButton/RestoreAppSizeButton.css.js";import"../DevCenter/DevCenterAppContainer/DevCenterAppContainer.scss.js";import"../Toaster/Toaster.js";import"../DevCenter/NavigationBar/NavigationBar.js";import"../DevCenter/SideBar/SideBar.js";import"../DevCenter/AppSettingsPopover/AppSettingsPopover.js";import"../DevCenter/AppFilterPanelLayout/AppFilterPanelLayout.js";import"../DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedAppPage.js";import"../DevCenter/IsolatedDevCenterAppContainer/DevCenterIsolatedApp.js";import"../AssetEditor/index.js";import I from"../LoadingIndicator/LoadingIndicator.js";import"../Typography.js";import"../RealTimeValuesSidebar/RealTimeSidebar.js";import"../CollapsableSidebar.js";import"../DateTimePicker/index.js";import"../DatePicker/index.js";import"../SlateFormattedText/SlateFormattedText.js";import"../SlateFormattedText/RenderElements.js";import"slate";import"../ParameterCharts/ParameterCharts.js";import"../ParameterCharts/AddEditTrack.js";import"../ChartActionsList/ChartActionsList.js";import"../CopyToClipboard/CopyToClipboard.js";import"../AssetEditor/AssetEditorAutocomplete.js";import"../AssetEditor/SingleAssetEditor.js";import"../SettingEditors/ColorEditor/style.css.js";import"../SettingEditors/DropdownEditor/index.js";import"../SwitchControl/index.js";import"../ColorPicker/ColorPicker.js";import"../Chart/components/ChartButton.js";import"../Chart/components/ChartButtons.js";import"../Chart/components/ChartWrapper.js";import"../Chart/components/AxisDropdown.js";import"../Chart/components/ChartSelect.js";import"../Chart/ChartWrapperContext.js";import"../Chart/effects/useChartModifier.js";import"../Chart/components/buttons/HideAxesButton.js";import"../Chart/components/buttons/ChartTypeButton.js";import"../ColorPicker/PaletteChromePicker/PaletteChromePicker.js";import"../TruncatedText/index.js";import"../MiddleTruncatedText/MiddleTruncatedText.js";import"../RangeSlider/constants.js";import"../RangeSlider/Input.css.js";import"../RangeSlider/RangeSlider.css.js";import"../AdvancedSlider/AdvancedSlider.js";import"../Breadcrumbs/index.js";import"../VirtualizedTable/index.js";import"../EmptyView/EmptyView.js";import"../EmptyView/EmptyAppView/EmptyAppView.js";import"../ContextMenuItem/index.js";import"../FolderMenuItem/index.js";import"../EditableItem/EditableItem/index.js";import"../EditableItem/EditableItemWithBadge/index.js";import"../Checkbox/index.js";import"../FolderMenuItemWithLinks/index.js";import"../TextField/index.js";import"../Chip/index.js";import"../Counter/index.js";import"../AnchorsList/AnchorsList.js";import"../Select/index.js";import"../Select/SelectFilterBy.js";import"../CustomSelect/index.js";import"../Tabs/Tabs.js";import"../Tabs/Tab.js";import"../ResizableTable/ResizableTable.js";import"../GradientPicker/GradientPicker.js";import"@babel/runtime/helpers/classCallCheck";import"@babel/runtime/helpers/createClass";import"../GradientManager/GradientPreview/GradientPreview.js";import"../GradientManager/GradientSelect.scss.js";import"../GradientManager/GradientManager.styles.js";import"../Drillstring/BHASchematic.js";import"../Drillstring/BHATable/index.js";import"../Drillstring/BHAComponentIcon.js";import"../Drillstring/BHAComponentDetail/index.js";import"../Drillstring/BHATileIcon.js";import"../Drillstring/BHATile/BHATile.js";import"../Drillstring/BHAList/BHAList.js";import"../Drillstring/BHAComponentsTable/BHAComponentsTable.js";import"../Casing/CasingTable/index.js";import"../Casing/CasingComponentIcon.js";import"../Casing/CasingTileIcon.js";import"../Casing/CasingTableV2/CasingTableV2.js";import"../Casing/CasingTile/CasingTile.js";import"../WellSummary/WellSummaryItemLabel.js";import"../WellSummary/WellSummaryItemTitle.js";import"../WellSummary/WellSummaryItemValue.js";import"../WellSummary/ActivitySummaryChart.js";import"../WellSummary/FracWirelineTimeChart.js";import"../BICOffsetPickerDialog/index.js";import"../OffsetWellButton/OffsetWellButton.js";import"../OffsetWellPickerV2/OffsetWellPickerDialog.js";import"../OffsetWellPickerV3/index.js";import"../OffsetWellChips/Chip.js";import"../OffsetWellChips/ChipsContainer.js";import"../OffsetWellPickerV5/components/OffsetWellPickerV5WithStore/OffsetWellPickerV5WithStore.js";import"mapbox-gl/dist/mapbox-gl.css";import"@material-ui/icons/Info";import"@material-ui/icons/Block";import"../OffsetWellMap/WellTooltip.module.css.js";import"../OffsetWellMap/OffsetWellMap.module.css.js";import"../../config/mapboxGl/index.js";import"../../config/mapbox/index.js";import"react-dom";import"@material-ui/core/Snackbar";import"../Notifications/Toast.js";import"../Notifications/Notifications.scss.js";import"../TextLink/index.js";import"../Avatar/index.js";import"../Template/TemplatePopover/index.js";import"../Template/TemplateSharingDialog/index.js";import"../MenuItem/index.js";import"../MiddleTruncate/MiddleTruncate.js";import"../PinnableFilters/PinnableFilters.js";import"../HeaderLayout/HeaderLayout.js";import"../PadOffsetsPicker/PadOffsetsPicker.js";import"../PadOffsetsPicker/OffsetAssetChip.js";import"../PadOffsetsPicker/OffsetAssetsListExpander.js";import"../PadOffsetsPicker/StagesSelector.js";import"../PadOffsetsPickerV2/PadOffsetsPickerV2.js";import"../Table/TableToolbar/TableToolbar.js";import"../Table/TableContainer/TableContainer.js";import"../Table/TableCell/TableCell.js";import"../Table/TablePagination/TablePagination.js";import"../Table/TablePaginationActions/TablePaginationActions.js";import"../Tooltip/ScrollableTooltip.js";import"../PriceInput/PriceInput.js";import"../LabelsCounter/LabelsCounter.js";import"../Stepper/Stepper.js";import"../Stepper/Step/Step.js";import"../Stepper/StepsWrapper.js";import"../Comment/CommentIcon/index.js";import"../FilesLoader/FilesLoader.js";import"../../componentsV2/FileIcon/icons/ArchiveFileIcon.js";import"../../componentsV2/FileIcon/icons/CSVFileIcon.js";import"../../componentsV2/FileIcon/icons/DocFileIcon.js";import"../../componentsV2/FileIcon/icons/EDMFileIcon.js";import"../../componentsV2/FileIcon/icons/ExcelFileIcon.js";import"../../componentsV2/FileIcon/icons/ImageFileIcon.js";import"../../componentsV2/FileIcon/icons/JsonFileIcon.js";import"../../componentsV2/FileIcon/icons/LasFileIcon.js";import"../../componentsV2/FileIcon/icons/OtherFileIcon.js";import"../../componentsV2/FileIcon/icons/PdfFileIcon.js";import"../../componentsV2/FileIcon/icons/PowerPointFileIcon.js";import"../../componentsV2/FileIcon/icons/TxtFileIcon.js";import"../../componentsV2/FileIcon/icons/UnknownFileIcon.js";import"../../componentsV2/FileIcon/icons/VideoFileIcon.js";import"../../componentsV2/FileIcon/icons/XmlFileIcon.js";import"../SearchInput/index.js";import"../FeedItem/FeedItem.js";import"../FeedItem/FeedItemEditProvider/FeedItemEditProvider.js";import"../PostInput/PostInput.js";import"../KeyboardDateTimePicker.js";import"../AddComment/Popover.js";import"../AddComment/Popup.js";import"../StageDesignVActual/ComparisonBar/ComparisonBar.js";import"../StageDesignVActual/ElementsComparison/ElementsComparison.js";import"../StageDesignVActual/ComparisonHeader.js";import"../StageDesignVActual/ComparisonRow.js";import"../EmbeddedApp/DevCenterEmbeddedApp.js";import"../EmbeddedApp/EmbeddedApp.js";import"../Autocomplete/Autocomplete.js";import"../ColorPickerPalette/ColorPickerPalette.js";import"../Search/Search.js";import"../Search/components/Listbox.js";import"../Search/components/Paper.js";import"../Search/components/RecentSearches.js";import"../Search/components/Groups.js";import"../Search/components/SelectAllListItem.js";import"../StatusBadge/index.js";import"../Attachment/index.js";import"../EmojiIconButton.js";import"../FileUploadIconButton.js";import"../FilePreview/index.js";import"../FailedFileUploading.js";import"../UserMention/index.js";import"../CommentsInfo/index.js";import"../CommentInput/index.js";import"../Comment/index.js";import"../CommentLoader.js";import"../AssetNameLabel/AssetStatusBadge.js";import"../AssetEditorV2/components/PrimaryAssetSelect.js";import"../AssetEditorV2/components/SecondaryAssetSelect.js";import"../AssetEditorV2/components/SelectItem.js";import"../AssetEditorV2/components/MultipleAssetsToggle.js";import"../AssetEditorV2/components/PrimaryAssetSelectV2.js";import"../EChartsWrapper/EChartsWrapper.js";import"../AssetsMultipleSelector/AssetsMultipleSelector.js";import"../GoogleDocsViewer/index.js";import"../NewDocumentViewer/effects/useFileContent.js";import"../NewDocumentViewer/styles.js";import"../FilesLoaderV2/styles.js";import"../FilesDropzone/styles.js";import"../FilesProcessor/styles.js";import"../Hint/styles.js";import"@babel/runtime/helpers/taggedTemplateLiteral";import"fparser";import"../Formula/useFormulaStyles.js";import"../Formula/RootXIcon.js";import"../Formula/FormulaTextEditor.js";import"../Formula/CloseSuggestion.js";import"../Formula/SuggestionsMenu.js";import"../CommentCard/CommentCard.js";import"@material-ui/icons/AlternateEmail";import"../AttachFileButton/AttachFileButton.scss.js";import"../CommentInputNext/CommentInputNext.js";import"../UserMention/utils/index.js";import"react-s3-uploader/s3upload";import"../CommentComposer/CommentMetaLine.scss.js";import"../CommentComposer/ChatChannelSelector.scss.js";import"../CommentComposer/ShareToChatRow.scss.js";import"../CommentComposer/CommentComposer.scss.js";import"../AttachmentPreview/AttachmentPreview.js";import"../AttachmentPreview/AttachmentImage.js";import"../AttachmentPreview/AttachmentPreview.scss.js";import"../CommentPin/CommentPin.js";import"../FeedCard/FeedCard.js";import"../FeedItemCard/FeedItemCard.js";import"../NewCommentCursor/NewCommentCursor.js";import"../LinkedText/LinkedText.js";import"../FeedItem/feedItemTypes/AlertFeedItem.js";import"../FeedItem/feedItemTypes/PostFeedItem.js";import"../FeedItem/feedItemTypes/GeosteeringFeedItem.js";import"../FeedItem/feedItemTypes/DrillingOperationalNoteFeedItem.js";import"../FeedItem/feedItemTypes/DrillingOperationSummaryFeedItem.js";import"../FeedItem/feedItemTypes/DrillingDailyCostFeedItem.js";import"../FeedItem/feedItemTypes/DocumentFeedItem.js";import"../FeedItem/feedItemTypes/DrillerMemoFeedItem.js";import"../FeedItem/feedItemTypes/NptFeedItem.js";import"../FeedItem/feedItemTypes/SurveyStationFeedItem/index.js";import"../FeedItem/feedItemTypes/LessonsLearnedFeedItem/index.js";import"../FeedItem/feedItemTypes/TracesMemoFeedItem.js";import"../FeedItem/feedItemTypes/DepthCommentFeedItem.js";import"../FeedItem/feedItemTypes/CompletionOperationalNoteFeedItem.js";import"../FeedItem/feedItemTypes/CompletionOperationSummaryFeedItem.js";import"../FeedItem/feedItemTypes/CompletionDailyCostFeedItem.js";import"../FeedItem/feedItemTypes/CompletionDocumentFeedItem.js";import"../FeedItem/feedItemTypes/CompletionNptFeedItem.js";import"../FeedItem/feedItemTypes/StageOverviewFeedItem/index.js";import"../FeedItem/feedItemTypes/AppAnnotationFeedItem/index.js";import"../FeedItem/feedItemTypes/WellPlanFeedItem/index.js";import"../FeedItem/feedItemTypes/FluidReportFeedItem.js";import"../FeedItem/feedItemTypes/BhaFeedItem/BhaFeedItem.js";import"../FeedItem/feedItemTypes/DvDCommentFeedItem.js";import"../FeedItem/feedItemTypes/PCCommentFeedItem.js";import"../FeedItem/feedItemTypes/HookloadCommentFeedItem.js";import"../FeedItem/feedItemTypes/NptLessonsCommentFeedItem.js";import"../FeedItem/feedItemTypes/GenericDataCommentFeedItem.js";var A=function(r){var A=r.open,V=r.fileUrl,S=r.fileSize,F=r.fileName,T=r.webviewType,v=void 0===T?"google":T,g=r.onClose,h=t(!0),D=o(h,2),f=D[0],P=D[1],x=t(!1),b=o(x,2),y=b[0],B=b[1],k=s(null),E=s(null),L=j(),w=i((function(){return"office"===v?"https://view.officeapps.live.com/op/embed.aspx?src=".concat(window.encodeURIComponent(V)):"https://docs.google.com/viewer?url=".concat(encodeURIComponent(V),"&embedded=true")}),[V]),M=function(){E.current&&(E.current.src=w(),E.current.contentWindow.location.reload())},H=function(){k.current&&clearInterval(k.current),P(!1)};return n((function(){P(!0),B(!1);var e=S&&S>=1048576?S/1048576*1e4:1e4;return k&&A&&(clearInterval(k.current),k.current=setInterval(M,e)),function(){clearInterval(k.current)}}),[V,A]),u(m,{open:A,onClose:g,onContextMenu:function(e){return e.stopPropagation()},children:C("div",{className:L.cDocsViewer,children:[C("div",{className:L.cDocsViewerToolbar,children:[u(c,{children:F}),C("div",{children:[u(a,{size:"small",className:L.cDocsViewerToolbarIconButton,children:u("a",{download:!0,href:V,target:"_blank",rel:"noopener noreferrer",children:u(d,{fontSize:"small"})})}),u(a,{size:"small",onClick:g,className:L.cDocsViewerToolbarIconButton,children:u(l,{fontSize:"small"})})]})]}),f&&u("div",{className:L.cDocsViewerFrame,children:u(I,{white:!1})}),y?u("div",{className:L.cDocsViewerFrame,children:u(c,{variant:"body2",className:L.cDocsViewerFrameFailed,children:"Loading failed"})}):u("iframe",{className:p(L.cDocsViewerFrame,e({},L.cDocsViewerFrameHidden,f)),title:V,src:w(),onLoad:H,onError:function(){H(),B(!0)},ref:E})]})})};A.propTypes={open:r.bool.isRequired,fileUrl:r.string.isRequired,webviewType:r.oneOf(["google","office"]),fileName:r.string,fileSize:r.number,onClose:r.func.isRequired,classes:r.shape({}).isRequired};export{A as default};
2
2
  //# sourceMappingURL=DocumentViewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentViewer.js","sources":["../../../src/components/DocumentViewer/DocumentViewer.js"],"sourcesContent":["import { createRef, useCallback, useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { Typography, Modal, IconButton } from '@material-ui/core';\nimport CloseIcon from '@material-ui/icons/Close';\nimport GetAppIcon from '@material-ui/icons/GetApp';\n\nimport { useStyles } from './styles.js';\n\nimport { LoadingIndicator } from '~/components';\n\nconst REQUEST_TIMEOUT = 10000;\nconst BYTES_IN_MEGABYTE = 1048576;\n\nconst DocumentViewer = ({ open, fileUrl, fileSize, fileName, webviewType = 'google', onClose }) => {\n const [isLoading, setIsLoading] = useState(true);\n const [isLoadingFailed, setIsLoadingFailed] = useState(false);\n const timeoutRef = createRef(null);\n const iframeRef = createRef(null);\n const styles = useStyles();\n\n const getIframeLink = useCallback(() => {\n return webviewType === 'office'\n ? `https://view.officeapps.live.com/op/embed.aspx?src=${window.encodeURIComponent(fileUrl)}`\n : `https://docs.google.com/viewer?url=${encodeURIComponent(fileUrl)}&embedded=true`;\n }, [fileUrl]);\n\n const reloadFrame = () => {\n if (iframeRef.current) {\n iframeRef.current.src = getIframeLink();\n iframeRef.current.contentWindow.location.reload();\n }\n };\n\n const handleFrameLoad = () => {\n if (timeoutRef.current) {\n clearInterval(timeoutRef.current);\n }\n setIsLoading(false);\n };\n\n const handleFrameError = () => {\n handleFrameLoad();\n setIsLoadingFailed(true);\n };\n\n useEffect(() => {\n setIsLoading(true);\n setIsLoadingFailed(false);\n const timeOut =\n fileSize && fileSize >= BYTES_IN_MEGABYTE\n ? (fileSize / BYTES_IN_MEGABYTE) * REQUEST_TIMEOUT\n : REQUEST_TIMEOUT;\n\n if (timeoutRef && open) {\n clearInterval(timeoutRef.current);\n timeoutRef.current = setInterval(reloadFrame, timeOut);\n }\n\n return () => {\n clearInterval(timeoutRef.current);\n };\n }, [fileUrl, open]);\n\n return (\n <Modal open={open} onClose={onClose} onContextMenu={e => e.stopPropagation()}>\n <div className={styles.cDocsViewer}>\n <div className={styles.cDocsViewerToolbar}>\n <Typography>{fileName}</Typography>\n <div>\n <IconButton size=\"small\" className={styles.cDocsViewerToolbarIconButton}>\n <a download href={fileUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n <GetAppIcon fontSize=\"small\" />\n </a>\n </IconButton>\n <IconButton\n size=\"small\"\n onClick={onClose}\n className={styles.cDocsViewerToolbarIconButton}\n >\n <CloseIcon fontSize=\"small\" />\n </IconButton>\n </div>\n </div>\n\n {isLoading && (\n <div className={styles.cDocsViewerFrame}>\n <LoadingIndicator white={false} />\n </div>\n )}\n {isLoadingFailed ? (\n <div className={styles.cDocsViewerFrame}>\n <Typography variant=\"body2\" className={styles.cDocsViewerFrameFailed}>\n Loading failed\n </Typography>\n </div>\n ) : (\n <iframe\n className={classNames(styles.cDocsViewerFrame, {\n [styles.cDocsViewerFrameHidden]: isLoading,\n })}\n title={fileUrl}\n src={getIframeLink()}\n onLoad={handleFrameLoad}\n onError={handleFrameError}\n ref={iframeRef}\n />\n )}\n </div>\n </Modal>\n );\n};\n\nDocumentViewer.propTypes = {\n open: PropTypes.bool.isRequired,\n fileUrl: PropTypes.string.isRequired,\n webviewType: PropTypes.oneOf(['google', 'office']),\n fileName: PropTypes.string,\n fileSize: PropTypes.number,\n onClose: PropTypes.func.isRequired,\n classes: PropTypes.shape({}).isRequired,\n};\n\nexport default DocumentViewer;\n"],"names":["DocumentViewer","_ref","open","fileUrl","fileSize","fileName","_ref$webviewType","webviewType","onClose","useState","_useState2","_slicedToArray","_useState","isLoading","setIsLoading","_useState4","_useState3","isLoadingFailed","setIsLoadingFailed","timeoutRef","createRef","iframeRef","styles","useStyles","getIframeLink","useCallback","concat","window","encodeURIComponent","reloadFrame","current","src","contentWindow","location","reload","handleFrameLoad","clearInterval","useEffect","timeOut","setInterval","_jsx","Modal","onContextMenu","e","stopPropagation","children","_jsxs","className","cDocsViewer","cDocsViewerToolbar","Typography","IconButton","size","cDocsViewerToolbarIconButton","download","href","target","rel","GetAppIcon","fontSize","onClick","CloseIcon","cDocsViewerFrame","LoadingIndicator","white","variant","cDocsViewerFrameFailed","classNames","cDocsViewerFrameHidden","title","onLoad","onError","ref","propTypes","PropTypes","bool","isRequired","string","oneOf","number","func","classes","shape"],"mappings":"801BAWA,IAGMA,EAAiB,SAA4EC,GAAA,IAAzEC,IAAAA,KAAMC,IAAAA,QAASC,IAAAA,SAAUC,IAAAA,SAAQC,EAAAL,EAAEM,YAAAA,aAAc,SAAQD,EAAEE,IAAAA,QACjDC,EAAAA,GAAS,GAAKC,EAAAC,EAAAC,EAA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EAAU,CACTC,KAAK,QACLQ,QAASpD,EACTuC,UAAWzB,EAAO+B,6BAA6BR,SAE/CL,EAACqB,EAAS,CAACF,SAAS,kBAKzB9C,GACC2B,EAAA,MAAA,CAAKO,UAAWzB,EAAOwC,iBAAiBjB,SACtCL,EAACuB,EAAgB,CAACC,OAAO,MAG5B/C,EACCuB,EAAA,MAAA,CAAKO,UAAWzB,EAAOwC,iBAAiBjB,SACtCL,EAACU,EAAU,CAACe,QAAQ,QAAQlB,UAAWzB,EAAO4C,uBAAuBrB,SAAA,qBAKvEL,EAAA,SAAA,CACEO,UAAWoB,EAAW7C,EAAOwC,iBAC1BxC,EAAAA,CAAAA,EAAAA,EAAO8C,uBAAyBvD,IAEnCwD,MAAOlE,EACP4B,IAAKP,IACL8C,OAAQnC,EACRoC,QA/De,WACvBpC,IACAjB,GAAmB,IA8DXsD,IAAKnD,QAMjB,EAEArB,EAAeyE,UAAY,CACzBvE,KAAMwE,EAAUC,KAAKC,WACrBzE,QAASuE,EAAUG,OAAOD,WAC1BrE,YAAamE,EAAUI,MAAM,CAAC,SAAU,WACxCzE,SAAUqE,EAAUG,OACpBzE,SAAUsE,EAAUK,OACpBvE,QAASkE,EAAUM,KAAKJ,WACxBK,QAASP,EAAUQ,MAAM,CAAA,GAAIN"}
1
+ {"version":3,"file":"DocumentViewer.js","sources":["../../../src/components/DocumentViewer/DocumentViewer.js"],"sourcesContent":["import { createRef, useCallback, useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { Typography, Modal, IconButton } from '@material-ui/core';\nimport CloseIcon from '@material-ui/icons/Close';\nimport GetAppIcon from '@material-ui/icons/GetApp';\n\nimport { useStyles } from './styles.js';\n\nimport { LoadingIndicator } from '~/components';\n\nconst REQUEST_TIMEOUT = 10000;\nconst BYTES_IN_MEGABYTE = 1048576;\n\nconst DocumentViewer = ({ open, fileUrl, fileSize, fileName, webviewType = 'google', onClose }) => {\n const [isLoading, setIsLoading] = useState(true);\n const [isLoadingFailed, setIsLoadingFailed] = useState(false);\n const timeoutRef = createRef(null);\n const iframeRef = createRef(null);\n const styles = useStyles();\n\n const getIframeLink = useCallback(() => {\n return webviewType === 'office'\n ? `https://view.officeapps.live.com/op/embed.aspx?src=${window.encodeURIComponent(fileUrl)}`\n : `https://docs.google.com/viewer?url=${encodeURIComponent(fileUrl)}&embedded=true`;\n }, [fileUrl]);\n\n const reloadFrame = () => {\n if (iframeRef.current) {\n iframeRef.current.src = getIframeLink();\n iframeRef.current.contentWindow.location.reload();\n }\n };\n\n const handleFrameLoad = () => {\n if (timeoutRef.current) {\n clearInterval(timeoutRef.current);\n }\n setIsLoading(false);\n };\n\n const handleFrameError = () => {\n handleFrameLoad();\n setIsLoadingFailed(true);\n };\n\n useEffect(() => {\n setIsLoading(true);\n setIsLoadingFailed(false);\n const timeOut =\n fileSize && fileSize >= BYTES_IN_MEGABYTE\n ? (fileSize / BYTES_IN_MEGABYTE) * REQUEST_TIMEOUT\n : REQUEST_TIMEOUT;\n\n if (timeoutRef && open) {\n clearInterval(timeoutRef.current);\n timeoutRef.current = setInterval(reloadFrame, timeOut);\n }\n\n return () => {\n clearInterval(timeoutRef.current);\n };\n }, [fileUrl, open]);\n\n return (\n <Modal open={open} onClose={onClose} onContextMenu={e => e.stopPropagation()}>\n <div className={styles.cDocsViewer}>\n <div className={styles.cDocsViewerToolbar}>\n <Typography>{fileName}</Typography>\n <div>\n <IconButton size=\"small\" className={styles.cDocsViewerToolbarIconButton}>\n <a download href={fileUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n <GetAppIcon fontSize=\"small\" />\n </a>\n </IconButton>\n <IconButton\n size=\"small\"\n onClick={onClose}\n className={styles.cDocsViewerToolbarIconButton}\n >\n <CloseIcon fontSize=\"small\" />\n </IconButton>\n </div>\n </div>\n\n {isLoading && (\n <div className={styles.cDocsViewerFrame}>\n <LoadingIndicator white={false} />\n </div>\n )}\n {isLoadingFailed ? (\n <div className={styles.cDocsViewerFrame}>\n <Typography variant=\"body2\" className={styles.cDocsViewerFrameFailed}>\n Loading failed\n </Typography>\n </div>\n ) : (\n <iframe\n className={classNames(styles.cDocsViewerFrame, {\n [styles.cDocsViewerFrameHidden]: isLoading,\n })}\n title={fileUrl}\n src={getIframeLink()}\n onLoad={handleFrameLoad}\n onError={handleFrameError}\n ref={iframeRef}\n />\n )}\n </div>\n </Modal>\n );\n};\n\nDocumentViewer.propTypes = {\n open: PropTypes.bool.isRequired,\n fileUrl: PropTypes.string.isRequired,\n webviewType: PropTypes.oneOf(['google', 'office']),\n fileName: PropTypes.string,\n fileSize: PropTypes.number,\n onClose: PropTypes.func.isRequired,\n classes: PropTypes.shape({}).isRequired,\n};\n\nexport default DocumentViewer;\n"],"names":["DocumentViewer","_ref","open","fileUrl","fileSize","fileName","_ref$webviewType","webviewType","onClose","useState","_useState2","_slicedToArray","_useState","isLoading","setIsLoading","_useState4","_useState3","isLoadingFailed","setIsLoadingFailed","timeoutRef","createRef","iframeRef","styles","useStyles","getIframeLink","useCallback","concat","window","encodeURIComponent","reloadFrame","current","src","contentWindow","location","reload","handleFrameLoad","clearInterval","useEffect","timeOut","setInterval","_jsx","Modal","onContextMenu","e","stopPropagation","children","_jsxs","className","cDocsViewer","cDocsViewerToolbar","Typography","IconButton","size","cDocsViewerToolbarIconButton","download","href","target","rel","GetAppIcon","fontSize","onClick","CloseIcon","cDocsViewerFrame","LoadingIndicator","white","variant","cDocsViewerFrameFailed","classNames","cDocsViewerFrameHidden","title","onLoad","onError","ref","propTypes","PropTypes","bool","isRequired","string","oneOf","number","func","classes","shape"],"mappings":"gl2BAWA,IAGMA,EAAiB,SAA4EC,GAAA,IAAzEC,IAAAA,KAAMC,IAAAA,QAASC,IAAAA,SAAUC,IAAAA,SAAQC,EAAAL,EAAEM,YAAAA,aAAc,SAAQD,EAAEE,IAAAA,QACjDC,EAAAA,GAAS,GAAKC,EAAAC,EAAAC,EAAA,GAAzCC,EAASH,EAAA,GAAEI,EAAYJ,EAAA,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zB,EAAO+B,6BAA6BR,SAE/CL,EAACqB,EAAS,CAACF,SAAS,kBAKzB9C,GACC2B,EAAA,MAAA,CAAKO,UAAWzB,EAAOwC,iBAAiBjB,SACtCL,EAACuB,EAAgB,CAACC,OAAO,MAG5B/C,EACCuB,EAAA,MAAA,CAAKO,UAAWzB,EAAOwC,iBAAiBjB,SACtCL,EAACU,EAAU,CAACe,QAAQ,QAAQlB,UAAWzB,EAAO4C,uBAAuBrB,SAAA,qBAKvEL,EAAA,SAAA,CACEO,UAAWoB,EAAW7C,EAAOwC,iBAC1BxC,EAAAA,CAAAA,EAAAA,EAAO8C,uBAAyBvD,IAEnCwD,MAAOlE,EACP4B,IAAKP,IACL8C,OAAQnC,EACRoC,QA/De,WACvBpC,IACAjB,GAAmB,IA8DXsD,IAAKnD,QAMjB,EAEArB,EAAeyE,UAAY,CACzBvE,KAAMwE,EAAUC,KAAKC,WACrBzE,QAASuE,EAAUG,OAAOD,WAC1BrE,YAAamE,EAAUI,MAAM,CAAC,SAAU,WACxCzE,SAAUqE,EAAUG,OACpBzE,SAAUsE,EAAUK,OACpBvE,QAASkE,EAAUM,KAAKJ,WACxBK,QAASP,EAAUQ,MAAM,CAAA,GAAIN"}
@@ -106,10 +106,10 @@ export declare const BHA_COMPONENT_TYPES: ({
106
106
  })[];
107
107
  })[];
108
108
  export declare const BHA_GENERAL_FIELD_TYPES: ({
109
+ unit?: undefined;
109
110
  name: string;
110
111
  label: string;
111
112
  cond?: undefined;
112
- unit?: undefined;
113
113
  col_size?: undefined;
114
114
  family?: undefined;
115
115
  } | {
@@ -134,8 +134,8 @@ export declare const BHA_GENERAL_FIELD_TYPES: ({
134
134
  col_size: number;
135
135
  family?: undefined;
136
136
  } | {
137
- cond?: undefined;
138
137
  unit?: undefined;
138
+ cond?: undefined;
139
139
  name: string;
140
140
  label: string;
141
141
  col_size: number;