@arcgis/core 4.33.0-next.20250528 → 4.33.0-next.20250529

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 (218) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{feaf79b69d2e2a1f2aa2.js → 06877ea5b9df7de89aff.js} +1 -1
  3. package/assets/esri/core/workers/chunks/09907c9ff597df9bc954.js +1 -0
  4. package/assets/esri/core/workers/chunks/{0716b21b1cfb8df066fa.js → 0dbb350ce651bc236ec8.js} +1 -1
  5. package/assets/esri/core/workers/chunks/0ed4ec00ef16aa58a33d.js +1 -0
  6. package/assets/esri/core/workers/chunks/109e5635c1b9a0929d16.js +1 -0
  7. package/assets/esri/core/workers/chunks/1573c017fd9fc0fe7527.js +1 -0
  8. package/assets/esri/core/workers/chunks/{0624ae07d3af8d5f1ac8.js → 15b3eb60f86954783fab.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{b845586219f284a215b2.js → 1db026cc25338dbc208e.js} +1 -1
  10. package/assets/esri/core/workers/chunks/21de4516bf5c9630edfd.js +1 -0
  11. package/assets/esri/core/workers/chunks/2254989ca3ff3960f2fe.js +1 -0
  12. package/assets/esri/core/workers/chunks/2dbd18df5c691c8d0a61.js +1 -0
  13. package/assets/esri/core/workers/chunks/2e1ceff3f88a6c78dfa2.js +1 -0
  14. package/assets/esri/core/workers/chunks/{847e88e1d6da1e74cdc8.js → 2ecc1057d53e0b4a60b7.js} +1 -1
  15. package/assets/esri/core/workers/chunks/3025e420e13e2bc8c0a1.js +1 -0
  16. package/assets/esri/core/workers/chunks/32537e2b014bc3d82f5c.js +346 -0
  17. package/assets/esri/core/workers/chunks/34f55bb89ddf26b10260.js +1 -0
  18. package/assets/esri/core/workers/chunks/355ab428a04ee9fcf888.js +1 -0
  19. package/assets/esri/core/workers/chunks/3a6ddff13bd47ed11798.js +1 -0
  20. package/assets/esri/core/workers/chunks/3a74654fa539f78ceb86.js +1 -0
  21. package/assets/esri/core/workers/chunks/3bec10a4f01757590c1c.js +1 -0
  22. package/assets/esri/core/workers/chunks/427318722815bef1496b.js +1 -0
  23. package/assets/esri/core/workers/chunks/4c3bd6cc0badb78c7112.js +1 -0
  24. package/assets/esri/core/workers/chunks/500fb5f615f0c1db1b66.js +1 -0
  25. package/assets/esri/core/workers/chunks/5222523fff30d07f88de.js +1 -0
  26. package/assets/esri/core/workers/chunks/539541dec5fcf3b657aa.js +1 -0
  27. package/assets/esri/core/workers/chunks/53e8c061f36516c3c3e4.js +1 -0
  28. package/assets/esri/core/workers/chunks/{ca76950d81ab4ebb65e1.js → 58f403f956b7b3467344.js} +1 -1
  29. package/assets/esri/core/workers/chunks/5a01bd7a9ee24be7bac4.js +1 -0
  30. package/assets/esri/core/workers/chunks/5bfcb3d87380e7f85b08.js +1 -0
  31. package/assets/esri/core/workers/chunks/{4dd0a5f327fa5fc7249d.js → 5ef1095842e21090f1f4.js} +1 -1
  32. package/assets/esri/core/workers/chunks/604d7250ed5e1edd59ac.js +1 -0
  33. package/assets/esri/core/workers/chunks/614bc3f05873b37af091.js +1 -0
  34. package/assets/esri/core/workers/chunks/6194636638b0439fccd8.js +1 -0
  35. package/assets/esri/core/workers/chunks/66e4cb2479bed1384ed5.js +1 -0
  36. package/assets/esri/core/workers/chunks/6b0ae9ccdd1acef5b5b4.js +1 -0
  37. package/assets/esri/core/workers/chunks/7112b092d98172b7db8b.js +1 -0
  38. package/assets/esri/core/workers/chunks/72ea996b03932c0f004f.js +1 -0
  39. package/assets/esri/core/workers/chunks/74d18c22fa1c178bd9df.js +1 -0
  40. package/assets/esri/core/workers/chunks/766e08d0c56b2b31b63b.js +1 -0
  41. package/assets/esri/core/workers/chunks/{cdb022ffffc6554de83a.js → 77dbb1d5d5e1a6ced932.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{bd7b54db7fd278b15500.js → 7a2189614f2dad49ffcd.js} +1 -1
  43. package/assets/esri/core/workers/chunks/7a55e9cf27089ee1ef1f.js +1 -0
  44. package/assets/esri/core/workers/chunks/7ae88c141a5d85e5bb88.js +1 -0
  45. package/assets/esri/core/workers/chunks/7aef81778155be373d3e.js +1 -0
  46. package/assets/esri/core/workers/chunks/7e1906d35a764f7f10b0.js +1 -0
  47. package/assets/esri/core/workers/chunks/80777a9db53bee2ad8a8.js +1 -0
  48. package/assets/esri/core/workers/chunks/8249b5de5c15461a6787.js +1 -0
  49. package/assets/esri/core/workers/chunks/8385c13ac10e595374cb.js +1 -0
  50. package/assets/esri/core/workers/chunks/83db8bd42f94f97c7cf1.js +1 -0
  51. package/assets/esri/core/workers/chunks/88b1214c284c2ec7d51b.js +1 -0
  52. package/assets/esri/core/workers/chunks/8b86c75426c55b29ebed.js +1 -0
  53. package/assets/esri/core/workers/chunks/8c4b26d86483646c70d2.js +1 -0
  54. package/assets/esri/core/workers/chunks/9cb242dfc3765b590f51.js +1 -0
  55. package/assets/esri/core/workers/chunks/9f0f1472f36b42c507d1.js +1 -0
  56. package/assets/esri/core/workers/chunks/9fe62638dc7dce466612.js +1 -0
  57. package/assets/esri/core/workers/chunks/a2e9141ff4efd13413a1.js +66 -0
  58. package/assets/esri/core/workers/chunks/b534a8d70018ce16400b.js +1 -0
  59. package/assets/esri/core/workers/chunks/b763292829aa4d3fab60.js +1 -0
  60. package/assets/esri/core/workers/chunks/{54ea93f416ab52b413c1.js → b9f93c233c55bb528412.js} +1 -1
  61. package/assets/esri/core/workers/chunks/c3d95f7f4370486eed2c.js +1 -0
  62. package/assets/esri/core/workers/chunks/{6993a59cbb78bc26f029.js → c45a314ace9725aa250e.js} +1 -1
  63. package/assets/esri/core/workers/chunks/c96fed4889712f5a9135.js +1 -0
  64. package/assets/esri/core/workers/chunks/c9fbada1e84981784f6c.js +1 -0
  65. package/assets/esri/core/workers/chunks/cefcecbeef4f0a46f58c.js +1 -0
  66. package/assets/esri/core/workers/chunks/d2317b87aa2ac3ad97a6.js +1 -0
  67. package/assets/esri/core/workers/chunks/{0bbb38f59f37c51c72f0.js → d45a4e5806a80b69ceec.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{7a23dc625a812a562c21.js → d5f770302dc686e55ba7.js} +1 -1
  69. package/assets/esri/core/workers/chunks/dc14507cfc052faa5890.js +1 -0
  70. package/assets/esri/core/workers/chunks/e7a440476cd1eb4c6547.js +1 -0
  71. package/assets/esri/core/workers/chunks/ede9738ac20e7dd5ce63.js +1 -0
  72. package/assets/esri/core/workers/chunks/eec034d88db320880133.js +1 -0
  73. package/assets/esri/core/workers/chunks/f0e7ca92f6d4d994337f.js +1 -0
  74. package/assets/esri/core/workers/chunks/f1e87720b425d7fb348a.js +1 -0
  75. package/assets/esri/core/workers/chunks/fd207a40faf882d3b2a3.js +1 -0
  76. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  77. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  78. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  79. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  80. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  81. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  82. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  83. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  84. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  85. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  86. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  87. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  88. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  89. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  90. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  91. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  92. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  93. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  94. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  95. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  96. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  97. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  98. package/assets/esri/widgets/Editor/t9n/Editor_no.json +1 -1
  99. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  100. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  101. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  102. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  103. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  104. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  105. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  106. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  107. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  108. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  109. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  110. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  111. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  112. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  113. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  114. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  115. package/chunks/aiServices.js +1 -1
  116. package/interfaces.d.ts +33 -42
  117. package/layers/BuildingSceneLayer.js +1 -1
  118. package/layers/VideoLayer.js +1 -1
  119. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  120. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  121. package/layers/mixins/ImageryTileMixin.js +1 -1
  122. package/layers/mixins/operationalLayerModuleMap.js +1 -1
  123. package/layers/mixins/operationalLayers.js +1 -1
  124. package/layers/support/BuildingSummaryStatistics.js +1 -1
  125. package/layers/support/TelemetryDisplay.js +1 -1
  126. package/layers/support/TitleCreator.js +1 -1
  127. package/layers/support/featurePopupQueryUtils.js +5 -0
  128. package/layers/support/fieldUtils.js +1 -1
  129. package/layers/support/layersCreator.js +1 -1
  130. package/layers/support/multiLayerServiceUtils.js +5 -0
  131. package/package.json +1 -1
  132. package/portal/support/portalLayers.js +1 -1
  133. package/support/revision.js +1 -1
  134. package/symbols/cim/utils.js +1 -1
  135. package/symbols/support/cimSymbolUtils.js +1 -1
  136. package/symbols/support/previewCIMSymbol.js +1 -1
  137. package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
  138. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  139. package/views/3d/layers/I3SMeshView3D.js +1 -1
  140. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  141. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  142. package/views/3d/layers/support/DefinitionExpressionSceneLayerView.js +1 -1
  143. package/views/3d/layers/support/PopupSceneLayerView.js +1 -1
  144. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  145. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  146. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +3 -3
  147. package/views/SelectionManager.js +1 -1
  148. package/views/layers/FeatureLayerView.js +1 -1
  149. package/webdoc/support/writeUtils.js +1 -1
  150. package/widgets/Editor/workflowUtils.js +1 -1
  151. package/widgets/Feature/support/featureUtils.js +1 -1
  152. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  153. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  154. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  155. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  156. package/widgets/OrientedImageryViewer/components/SequentialNavigationUI.js +1 -1
  157. package/widgets/OrientedImageryViewer/navigation/queries.js +1 -1
  158. package/widgets/OrientedImageryViewer/videoViewerUtils.js +5 -0
  159. package/widgets/OrientedImageryViewer.js +1 -1
  160. package/assets/esri/core/workers/chunks/03db109e9b695528c35d.js +0 -1
  161. package/assets/esri/core/workers/chunks/09da6b3085fc84cd69d5.js +0 -1
  162. package/assets/esri/core/workers/chunks/09f76ca9b47b465c934f.js +0 -1
  163. package/assets/esri/core/workers/chunks/0a770f283eb77c8dc97a.js +0 -1
  164. package/assets/esri/core/workers/chunks/0b70b2ee62904318a12c.js +0 -1
  165. package/assets/esri/core/workers/chunks/0c2dccec20c0994366fe.js +0 -1
  166. package/assets/esri/core/workers/chunks/0d78fc2c2bc1152f84db.js +0 -1
  167. package/assets/esri/core/workers/chunks/17e43a050fbf8dc87588.js +0 -1
  168. package/assets/esri/core/workers/chunks/1d7f2abfccc54659d6f2.js +0 -1
  169. package/assets/esri/core/workers/chunks/1ee6e9a88f0676032e91.js +0 -1
  170. package/assets/esri/core/workers/chunks/1f9c6fbcd4d0eae1e574.js +0 -1
  171. package/assets/esri/core/workers/chunks/2cf82d3645c75d311e99.js +0 -1
  172. package/assets/esri/core/workers/chunks/2d90806faa4269828948.js +0 -1
  173. package/assets/esri/core/workers/chunks/3027eb0c20e996ad374a.js +0 -1
  174. package/assets/esri/core/workers/chunks/3bf1cf6c3cba172e2f6d.js +0 -1
  175. package/assets/esri/core/workers/chunks/3d7eedb787c1e3b9fbfc.js +0 -1
  176. package/assets/esri/core/workers/chunks/3fe7be535affae31de7e.js +0 -1
  177. package/assets/esri/core/workers/chunks/41cbba9b286cf5558a9c.js +0 -1
  178. package/assets/esri/core/workers/chunks/42bb9bb6fe44a47d9b81.js +0 -1
  179. package/assets/esri/core/workers/chunks/465f2db4ab8aa9c9f907.js +0 -1
  180. package/assets/esri/core/workers/chunks/4ca0738ed38c15b68a77.js +0 -1
  181. package/assets/esri/core/workers/chunks/515e3295495d0958db7e.js +0 -1
  182. package/assets/esri/core/workers/chunks/51ba7345c31e6eb79060.js +0 -1
  183. package/assets/esri/core/workers/chunks/52a57106a41b8c9483d7.js +0 -1
  184. package/assets/esri/core/workers/chunks/536d7986ebb710a8a452.js +0 -1
  185. package/assets/esri/core/workers/chunks/56d2a20c1b143697aa19.js +0 -1
  186. package/assets/esri/core/workers/chunks/5890740d5a761b038560.js +0 -1
  187. package/assets/esri/core/workers/chunks/5dbd8d81d94cfda5bb32.js +0 -1
  188. package/assets/esri/core/workers/chunks/5e1f7fe6bbc5754efee1.js +0 -1
  189. package/assets/esri/core/workers/chunks/61f9747c960d959b571b.js +0 -346
  190. package/assets/esri/core/workers/chunks/6408b7845858cf18102f.js +0 -1
  191. package/assets/esri/core/workers/chunks/74c0db9e3a62e9839b23.js +0 -1
  192. package/assets/esri/core/workers/chunks/7b12607633bbdc318936.js +0 -1
  193. package/assets/esri/core/workers/chunks/86023cc5ccbc7ac43479.js +0 -1
  194. package/assets/esri/core/workers/chunks/87eca6de502d18d8b7eb.js +0 -1
  195. package/assets/esri/core/workers/chunks/8aa8f9986b966ccb64e2.js +0 -1
  196. package/assets/esri/core/workers/chunks/8d14e957219364a81d5f.js +0 -66
  197. package/assets/esri/core/workers/chunks/937b653b10e8704b38bf.js +0 -1
  198. package/assets/esri/core/workers/chunks/98ef17d15517368d2383.js +0 -1
  199. package/assets/esri/core/workers/chunks/9cac00d4bfac14aaae12.js +0 -1
  200. package/assets/esri/core/workers/chunks/a0c35521e677459f6fa3.js +0 -1
  201. package/assets/esri/core/workers/chunks/a32dcd5bc4680374d30c.js +0 -1
  202. package/assets/esri/core/workers/chunks/aaa6d45316a7d3466d0f.js +0 -1
  203. package/assets/esri/core/workers/chunks/ae733c963d61065faa54.js +0 -1
  204. package/assets/esri/core/workers/chunks/b2a6afa0cd537805b4b8.js +0 -1
  205. package/assets/esri/core/workers/chunks/bf9b6b74654d303a6dae.js +0 -1
  206. package/assets/esri/core/workers/chunks/c6580fdcdc33153008b0.js +0 -1
  207. package/assets/esri/core/workers/chunks/cc4fe89e4f604e3c52ae.js +0 -1
  208. package/assets/esri/core/workers/chunks/cc9dd8924bfeb8bcd278.js +0 -1
  209. package/assets/esri/core/workers/chunks/d3c0d7799c92c6f0e7d3.js +0 -1
  210. package/assets/esri/core/workers/chunks/d52f5214a0330ed2e05e.js +0 -1
  211. package/assets/esri/core/workers/chunks/dbe10c20df7e0e563a0b.js +0 -1
  212. package/assets/esri/core/workers/chunks/df7ca2fe12e22ccfde17.js +0 -1
  213. package/assets/esri/core/workers/chunks/df933eac03dc63064723.js +0 -1
  214. package/assets/esri/core/workers/chunks/ee6240636d04d7d37b7b.js +0 -1
  215. package/assets/esri/core/workers/chunks/f00f8609bf0d14b488b8.js +0 -1
  216. package/assets/esri/core/workers/chunks/f1c6df5cf2ccb6ac47a1.js +0 -1
  217. package/assets/esri/core/workers/chunks/f3d97a4c4f433adbdab5.js +0 -1
  218. package/assets/esri/core/workers/chunks/fc0a3db3d6d26c763fb9.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as r,formatDate as n}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/loadArcade.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),b=/href=(""|'')/gi,g=/(\{([^{\r\n]+)\})/g,h=/'/g,I=/^\s*expression\//i,w=/(\n)/gi,T=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,N=/^(?:mailto:|tel:)/,j="relationships/",Z=r("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:r}){try{return"function"==typeof t?t(r):await t}catch(n){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:n,graphic:r.graphic,value:t})}}function x(e=""){if(e)return!N.test(e.trim().toLowerCase())}function E(e){return!!e&&I.test(e)}function v(e,t){if(!t||!E(t)||!e)return;const r=t.replace(I,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===r))}function A(e,t){const r=v(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function C(e,t){const r=t.get(e.toLowerCase());return`{${r?.fieldName||e}}`}function U(e){return e.replaceAll(b,"")}function M(e,t){const r=k(t,e);return r?r.name:e}function R(e,t){return e&&e.map((e=>M(e,t)))}function k(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function $(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?z({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function z({formattedAttributes:e,template:r,fieldInfoMap:n}){return $(U(t(t(r,(e=>C(e,n))),e)))}function O(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(h,i);t[e]=o}}function G(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>O(e,r,t))),r}function S(e,r,n){const i=(r=$(r))&&"{"!==r[0];return t(e,G(n,i||!1))}function Q(e,t){return e.replaceAll(g,((e,r,n)=>{const i=k(t,n);return i?`{${i.name}}`:r}))}function P(e,t,r){const n=Q(e,r);return n?n.replaceAll(F,((e,r,n)=>S(e,r||n,t))):n}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-group"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function V(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function W(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=ee(r,n),d=k(u,n);if(c&&!a(n)){const t=d?.type,r=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||r)return f(e,{format:r,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(n)&&p?X(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?le(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function X(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?Y(e,",",", ",t):e.includes(";")?Y(e,";","; ",t):e.includes(" ")?Y(e," "," ",t):i(Number(e),o(t))}function Y(e,t,r,n){return e.trim().split(t).map((e=>i(Number(e),o(n)))).join(r)}function ee(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function te({fieldName:e,graphic:t,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function re({fieldName:e,value:t,graphic:r,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function ne(e,t,r,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,r,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:n(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:n(d,f),user:e}}return null}function ie(e,t){const r=new Map;if(!e)return r;for(const n of e){if(!n.fieldName)continue;const e=M(n.fieldName,t);n.fieldName=e,r.set(e.toLowerCase(),n)}return r}function oe(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e?.fieldInfos;r&&t.push(...r)}})),t):t}function ae(e){return e.replaceAll(T,(e=>`&#${e.charCodeAt(0)};`))}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=re({fieldName:r,value:t,graphic:a,layer:o});if(s)return s;const d=te({fieldName:r,graphic:a,layer:o});if(d)return d;if(i.get(r.toLowerCase()))return W(t,{fieldInfos:n||Array.from(i.values()),fieldName:r,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(r);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):le(t)}function se({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>be({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:u,graphic:n,timeZone:a})})),l}async function fe(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=r.createQuery();f.objectIds=o,f.outFields=i?.length?i:[r.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await r.queryFeatures(f,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function de({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=r.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(r.fieldsIndex),f=l(s,e),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await ce(t);if(f&&!d)return;const p=await fe({layer:r,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:n},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function pe(e=""){return!!e&&e.includes(j)}function ye(e){return e?`${j}${e.layerId}/${e.fieldName}`:""}function me({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&r&&Object.keys(t.attributes).forEach((l=>{const u=ye({layerId:r.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ue({fieldName:u,fieldInfos:n,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function be({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;ge(n)||ge(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},Ie=({query:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},we=({queryPayload:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,r){return e&&t&&r?"sublayer"===t.type?je({layers:t.layer?.allSublayers,map:e,relatedLayer:t,relationship:r})||je({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:r}):je({layers:e.allLayers,map:e,relatedLayer:t,relationship:r})||je({layers:e.allTables,map:e,relatedLayer:t,relationship:r}):null}function Fe(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find((e=>e.isUtilityLayer(t))):null}function Ne(e,t){return e?.allTables.find((e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url))}function je({map:e,relationship:t,relationship:{relatedTableId:r},relatedLayer:n,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const r=je({layers:o.sublayers,map:e,relatedLayer:n,relationship:t})||je({layers:o.subtables,map:e,relatedLayer:n,relationship:t});if(r)return r;continue}if(!J(o))continue;if("sublayer"===n.type){if(o!==n&&o.id===r)return o.isTable?Ne(e,o):o;continue}const i="scene"===n.type&&n.associatedLayer?n.associatedLayer.url:n.url;if(!i)return null;if("sublayer"!==o.type){if(o!==n&&o.url===i&&o.layerId===r)return o}else if(o!==n&&o.layer?.url===i&&o.id===r)return o.isTable?Ne(e,o):o}return null}export{le as applyTextFormattingHTML,ie as createFieldInfoMap,Te as findRelatedLayer,Fe as findUtilityNetwork,Q as fixTokens,se as formatAttributes,ne as formatEditInfo,W as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,A as getFieldInfoLabel,M as getFixedFieldName,R as getFixedFieldNames,L as getSourceLayer,q as graphicCallback,ae as htmlEntities,K as isAssociatedFeatureSupportedLayer,E as isExpressionField,H as isFeatureSupportedLayer,V as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,pe as isRelatedField,Ie as preLayerQueryCallback,we as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,x as shouldOpenInNewTab,z as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
5
+ import has from"../../../core/has.js";import e from"../../../core/Logger.js";import{replace as t}from"../../../core/string.js";import{convertDateFormatToIntlOptions as r,formatDate as n}from"../../../intl/date.js";import{formatNumber as i,convertNumberFormatToIntlOptions as o}from"../../../intl/number.js";import{isRasterPixelValueField as a,featureHasFields as l,isTimeOnlyField as u}from"../../../layers/support/fieldUtils.js";import{getEffectiveLayerCapabilities as s}from"../../../layers/support/layerUtils.js";import{formatAnyDate as f,isAnyDateField as c}from"../../../smartMapping/support/utils.js";import{loadArcade as d}from"../../../support/loadArcade.js";import{getTimeZoneFormattingOptions as p}from"../../../time/timeZoneUtils.js";const y="esri.widgets.Feature.support.featureUtils",m=()=>e.getLogger(y),b=/href=(""|'')/gi,g=/(\{([^{\r\n]+)\})/g,h=/'/g,I=/^\s*expression\//i,w=/(\n)/gi,T=/[\u00A0-\u9999<>&]/gim,F=/href\s*=\s*(?:"([^"]+)"|'([^']+)')/gi,N=/^(?:mailto:|tel:)/,j="relationships/",Z=r("short-date-short-time");function L(e){if(null!=e)return(e.sourceLayer||e.layer)??void 0}async function q({type:e,value:t,event:r}){try{return"function"==typeof t?t(r):await t}catch(n){return void m().error("error",`An error occurred when calling the "${e}" function`,{error:n,graphic:r.graphic,value:t})}}function x(e=""){if(e)return!N.test(e.trim().toLowerCase())}function E(e){return!!e&&I.test(e)}function v(e,t){if(!t||!E(t)||!e)return;const r=t.replace(I,"").toLowerCase();return e.find((({name:e})=>e.toLowerCase()===r))}function A(e,t){const r=v(t,e?.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function C(e,t){const r=t.get(e.toLowerCase());return`{${r?.fieldName||e}}`}function U(e){return e.replaceAll(b,"")}function M(e,t){const r=k(t,e);return r?r.name:e}function R(e,t){return e&&e.map((e=>M(e,t)))}function k(e,t){return e&&"function"==typeof e.getField&&t?e.getField(t)??null:null}function $(e){return`${e}`.trim()}function D({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?z({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function z({formattedAttributes:e,template:r,fieldInfoMap:n}){return $(U(t(t(r,(e=>C(e,n))),e)))}function O(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replaceAll(h,i);t[e]=o}}function G(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>O(e,r,t))),r}function S(e,r,n){const i=(r=$(r))&&"{"!==r[0];return t(e,G(n,i||!1))}function Q(e,t){return e.replaceAll(g,((e,r,n)=>{const i=k(t,n);return i?`{${i.name}}`:r}))}function P(e,t,r){const n=Q(e,r);return n?n.replaceAll(F,((e,r,n)=>S(e,r||n,t))):n}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function H(e){return null!=e&&"object"==typeof e&&"fieldsIndex"in e&&"geometryType"in e&&"getField"in e&&"load"in e&&"loaded"in e&&"objectIdField"in e&&"spatialReference"in e&&"type"in e&&("feature"===e.type||"scene"===e.type||"subtype-group"===e.type||"subtype-sublayer"===e.type||"sublayer"===e.type)&&"when"in e}function B(e){return null!=e&&"object"==typeof e&&"createQuery"in e&&"queryFeatureCount"in e&&"queryObjectIds"in e&&"queryRelatedFeatures"in e&&"queryRelatedFeaturesCount"in e&&"relationships"in e}function J(e){return H(e)&&B(e)}function K(e){return!(!(e&&"object"==typeof e&&"createQuery"in e&&"getField"in e&&"queryFeatureCount"in e&&"queryFeatures"in e&&"queryObjectIds"in e&&"capabilities"in e&&"fields"in e&&"fieldsIndex"in e&&"type"in e)||"feature"!==e.type&&"subtype-group"!==e.type&&"subtype-sublayer"!==e.type&&"sublayer"!==e.type||!("when"in e))&&("subtype-sublayer"===e.type&&"parent"in e&&e.parent&&"object"==typeof e.parent?"globalIdField"in e.parent:"globalIdField"in e)}function V(e){return!!e&&"object"==typeof e&&"sourceLayer"in e&&J(e.sourceLayer)}function W(e,t){const{fieldInfos:r,fieldName:n,preventPlacesFormatting:l,layer:u,timeZone:s}=t,c=ee(r,n),d=k(u,n);if(c&&!a(n)){const t=d?.type,r=c.format?.dateFormat;if("date"===t||"date-only"===t||"time-only"===t||"timestamp-offset"===t||r)return f(e,{format:r,fieldType:t,timeZoneOptions:{layerTimeZone:u&&"preferredTimeZone"in u?u.preferredTimeZone:null,viewTimeZone:s,datesInUnknownTimezone:!(!u||!("datesInUnknownTimezone"in u))&&!!u.datesInUnknownTimezone}})}const p=c?.format;return"string"==typeof e&&a(n)&&p?X(e,p):"string"==typeof(e=_(e,p))||null==e||null==p?le(e):i(e,l?{...o(p),minimumFractionDigits:0,maximumFractionDigits:20}:o(p))}function X(e,t){return e=e.trim(),/\d{2}-\d{2}/.test(e)?e:e.includes(",")?Y(e,",",", ",t):e.includes(";")?Y(e,";","; ",t):e.includes(" ")?Y(e," "," ",t):i(Number(e),o(t))}function Y(e,t,r,n){return e.trim().split(t).map((e=>i(Number(e),o(n)))).join(r)}function ee(e,t){if(e?.length&&t)return e.find((e=>e.fieldName?.toLowerCase()===t.toLowerCase()))}function te({fieldName:e,graphic:t,layer:r}){if(pe(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function re({fieldName:e,value:t,graphic:r,layer:n}){if(pe(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=r&&n.getFieldDomain(e,{feature:r,excludeImpliedDomains:has("esri-widget-legacy-field-domain-calculation")});return i&&"coded-value"===i.type?i.getName(t):null}function ne(e,t,r,i){const{creatorField:o,creationDateField:a,editorField:l,editDateField:u}=e;if(!t)return;const s=p(i&&"preferredTimeZone"in i?i.preferredTimeZone:null,!(!i||!("datesInUnknownTimezone"in i))&&!!i.datesInUnknownTimezone,r,Z,"date"),f={...Z,...s},c=t[u];if("number"==typeof c){const e=t[l];return{type:"edit",date:n(c,f),user:e}}const d=t[a];if("number"==typeof d){const e=t[o];return{type:"create",date:n(d,f),user:e}}return null}function ie(e,t){const r=new Map;if(!e)return r;for(const n of e){if(!n.fieldName)continue;const e=M(n.fieldName,t);n.fieldName=e,r.set(e.toLowerCase(),n)}return r}function oe(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e?.fieldInfos;r&&t.push(...r)}})),t):t}function ae(e){return e.replaceAll(T,(e=>`&#${e.charCodeAt(0)};`))}function le(e){return"string"==typeof e?e.replaceAll(w,'<br class="esri-text-new-line" />'):e}function ue(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:i,layer:o,graphic:a,timeZone:l}=e;if(null==t)return"";const s=re({fieldName:r,value:t,graphic:a,layer:o});if(s)return s;const d=te({fieldName:r,graphic:a,layer:o});if(d)return d;if(i.get(r.toLowerCase()))return W(t,{fieldInfos:n||Array.from(i.values()),fieldName:r,layer:o,timeZone:l});const p=o?.fieldsIndex?.get(r);return p&&(c(p)||u(p))?f(t,{fieldType:p.type,timeZoneOptions:{layerTimeZone:o&&"preferredTimeZone"in o?o.preferredTimeZone:null,viewTimeZone:l,datesInUnknownTimezone:!(!o||!("datesInUnknownTimezone"in o))&&!!o.datesInUnknownTimezone}}):le(t)}function se({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o,timeZone:a}){const l={};return o?.forEach((t=>be({attributes:l,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r,timeZone:a}))),t&&Object.keys(t).forEach((o=>{const u=t[o];l[o]=ue({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:u,graphic:n,timeZone:a})})),l}async function fe(e,t){const{layer:r,graphic:n,outFields:i,objectIds:o,returnGeometry:a,spatialReference:l}=e,u=o[0];if("number"!=typeof u&&"string"!=typeof u){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:r,graphic:n,objectId:u,requiredFields:i};return m().warn(e,t),null}if(!s(r)?.operations?.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:r,graphic:n,requiredFields:i,returnGeometry:a};return m().warn(e,t),null}const f=r.createQuery();f.objectIds=o,f.outFields=i?.length?i:[r.objectIdField],f.returnGeometry=!!a,f.returnZ=!!a,f.returnM=!!a,f.outSpatialReference=l;return(await r.queryFeatures(f,t)).features[0]}async function ce(e){if(!e.expressionInfos?.length)return!1;const t=await d(),{arcadeUtils:{hasGeometryFunctions:r}}=t;return r(e)}async function de({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=r.objectIdField,a=e.attributes[o];if(null==a)return;const u=[a],s=await t.getRequiredFields(r.fieldsIndex),f=l(e,s),c=f?[]:s.includes(o)?s:[...s,o],d=t.returnGeometry||await ce(t);if(f&&!d)return;const p=await fe({layer:r,graphic:e,outFields:c,objectIds:u,returnGeometry:d,spatialReference:n},i);p&&(p.geometry&&(e.geometry=p.geometry),p.attributes&&(e.attributes={...e.attributes,...p.attributes}))}function pe(e=""){return!!e&&e.includes(j)}function ye(e){return e?`${j}${e.layerId}/${e.fieldName}`:""}function me({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o,timeZone:a}){e&&t&&r&&Object.keys(t.attributes).forEach((l=>{const u=ye({layerId:r.relation.id.toString(),fieldName:l}),s=t.attributes[l];e[u]=ue({fieldName:u,fieldInfos:n,fieldInfoMap:i,layer:o,value:s,graphic:t,timeZone:a})}))}function be({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}){e&&t&&(t.relatedFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}))),t.relatedStatsFeatures?.forEach((a=>me({attributes:e,graphic:a,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i,timeZone:o}))))}const ge=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},he=({layer:e,method:t,query:r,definitionExpression:n})=>{if(!e.capabilities?.query?.supportsCacheHint||"attachments"===t)return;const i=null!=r.where?r.where:null,o=null!=r.geometry?r.geometry:null;ge(n)||ge(i)||"extent"===o?.type||"tile"===r.resultType||(r.cacheHint=!0)},Ie=({query:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})},we=({queryPayload:e,layer:t,method:r})=>{he({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression??""}`})};function Te(e,t,r){return e&&t&&r?"sublayer"===t.type?je({layers:t.layer?.allSublayers,map:e,relatedLayer:t,relationship:r})||je({layers:t.layer?.subtables,map:e,relatedLayer:t,relationship:r}):je({layers:e.allLayers,map:e,relatedLayer:t,relationship:r})||je({layers:e.allTables,map:e,relatedLayer:t,relationship:r}):null}function Fe(e,t){return e&&"utilityNetworks"in e&&t?e.utilityNetworks?.find((e=>e.isUtilityLayer(t))):null}function Ne(e,t){return e?.allTables.find((e=>"feature"===e.type&&e.layerId===t.id&&e.url===t.layer?.url))}function je({map:e,relationship:t,relationship:{relatedTableId:r},relatedLayer:n,layers:i}){if(!i)return null;for(const o of i){if("map-image"===o.type){const r=je({layers:o.sublayers,map:e,relatedLayer:n,relationship:t})||je({layers:o.subtables,map:e,relatedLayer:n,relationship:t});if(r)return r;continue}if(!J(o))continue;if("sublayer"===n.type){if(o!==n&&o.id===r)return o.isTable?Ne(e,o):o;continue}const i="scene"===n.type&&n.associatedLayer?n.associatedLayer.url:n.url;if(!i)return null;if("sublayer"!==o.type){if(o!==n&&o.url===i&&o.layerId===r)return o}else if(o!==n&&o.layer?.url===i&&o.id===r)return o.isTable?Ne(e,o):o}return null}export{le as applyTextFormattingHTML,ie as createFieldInfoMap,Te as findRelatedLayer,Fe as findUtilityNetwork,Q as fixTokens,se as formatAttributes,ne as formatEditInfo,W as formatValueToFieldInfo,oe as getAllFieldInfos,ee as getFieldInfo,A as getFieldInfoLabel,M as getFixedFieldName,R as getFixedFieldNames,L as getSourceLayer,q as graphicCallback,ae as htmlEntities,K as isAssociatedFeatureSupportedLayer,E as isExpressionField,H as isFeatureSupportedLayer,V as isGraphicForRelatableFeatureSupportedLayer,J as isRelatableFeatureSupportedLayer,B as isRelatableLayer,pe as isRelatedField,Ie as preLayerQueryCallback,we as preRequestCallback,fe as querySourceLayer,de as queryUpdatedFeature,x as shouldOpenInNewTab,z as substituteAttributes,D as substituteFieldsInLinksAndAttributes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as i}from"../../../core/events.js";import{assertIsSome as r}from"../../../core/maybe.js";import{on as o,watch as n}from"../../../core/reactiveUtils.js";import{renderingSanitizer as l}from"../../../core/sanitizerUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as u}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as g}from"../../support/decorators/messageBundle.js";import{tsx as m}from"../../support/jsxFactory.js";const c="esri-grid",p="compact column-borders",_={base:c,content:`${c}__content`,grid:`${c}__grid`,noDataMessage:`${c}__no-data-message`},f={sort:["Enter"," "]};let v=class extends a{constructor(e,t){super(e,t),this._columnElements=[],this._grid=null,this._temporaryHighlightId=null,this.itemIdPath="objectId",this.messages=null,this.selectionColumnEnabled=!0,this.viewModel=new h,this._onSelectedItemsChange=this._onSelectedItemsChange.bind(this)}initialize(){this.addHandles([this.columns.on("before-changes",(()=>this.renderNow())),this.columns.on("change",(()=>this.onColumnChange())),o((()=>this.highlightIds),"before-add",(({target:e})=>{!this.multipleSelectionEnabled&&e.length&&e.removeAll()})),this.rowHighlightIds.on("change",(()=>this.generateCellPartNames())),n((()=>this.effectiveSize),(()=>this._updateGridSize())),n((()=>this.isEditing),(()=>{this.generateCellPartNames(),this.requestContentUpdate()})),n((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),o((()=>this._table),"scroll",(()=>this.viewModel.closeColumnMenus())),i(window,"resize",(()=>this._updateColumnBorderStyles())),o((()=>this._table),"scrollend",(()=>{this.paginationEnabled||(this.pageIndex=this.getVirtualPageIndex()),this._updateColumnBorderStyles()})),n((()=>this.multipleSelectionEnabled),(e=>{!e&&this.highlightIds.length>1&&this.highlightIds.removeAll()}))])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}get _columnRendering(){return this.columnPerformanceModeEnabled?"lazy":"eager"}get _selectedItems(){const{highlightIds:e,store:t}=this;return e.toArray().map((e=>t?.getItemByObjectId(e)??{objectId:e}))}get _noDataMessage(){return l.sanitize(this.noDataMessage)}get _table(){return this._grid?.$?.table}get cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get groupColumns(){return this.viewModel.groupColumns}get hasInvalidColumnConfiguration(){return this.viewModel.hasInvalidColumnConfiguration}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get temporaryHighlightId(){return this._temporaryHighlightId}get isEditing(){return this.viewModel.isEditing}get isReady(){return!!this._grid}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get noDataMessage(){return this.viewModel.noDataMessage}set noDataMessage(e){this.viewModel.noDataMessage=e}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get multipleSortPriority(){return this.viewModel.multipleSortPriority}set multipleSortPriority(e){this.viewModel.multipleSortPriority=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e&&e.path)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}get state(){return this.viewModel.state}addSorter(e){this._grid?.__updateSorter(e,!1,!1),this.notifyChange("sortOrders")}getColumnProps(e,t){const{id:i}=this,{autoWidth:r,direction:o,fieldName:n,flexGrow:l,frozen:s,frozenToEnd:d,hidden:a,label:h,resizable:u,textAlign:g,width:m}=e,c=`${i}_${n}_${t}`,{renderFunction:p,footerRenderFunction:_,headerRenderFunction:f}=e,v=_?(e,t)=>_({root:e,column:t}):void 0,y=f?(e,t)=>f({root:e,column:t}):void 0,C=p?(e,t,i)=>p({root:e,column:t,rowData:i}):void 0;let w="";return e.direction&&(w+=" direction"),e.invalid&&(w+=" invalid"),{footerRenderer:v,headerRenderer:y,renderer:C,autoWidth:r,direction:o,flexGrow:l,frozen:s,frozenToEnd:d,headerPartName:w,key:c,resizable:u,bind:this,"data-fieldName":n,header:h,hidden:this.hasInvalidColumnConfiguration||a,path:n,"text-align":g,width:"number"==typeof m?`${m}px`:m,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){return this.viewModel.findColumn(e)}generateCellPartNames(){this._grid?.generateCellPartNames()}getFirstVisibleRowIndex(){return this._grid?._firstVisibleIndex||0}getVirtualPageIndex(){return Math.floor(this.getFirstVisibleRowIndex()/this.pageSize)}getLastVisibleRowIndex(){return this._grid?._lastVisibleIndex||0}getVisibleItemsCount(){return this._grid?._visibleItemsCount||0}getRowContainingNode(e){try{return this._grid?._getRowContainingNode(e)}catch{return null}}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hasSorter(e){return this._grid?._sorters?.includes(e)||!1}hideColumn(e){this.viewModel.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache(),this._temporaryHighlightId=null}requestContentUpdate(){this._grid?.requestContentUpdate(),this._temporaryHighlightId=null}selectRows(e){const{itemIdPath:t}=this,i=e?.filter((e=>!this.highlightIds.includes(e[t]))),r=i.map((e=>e[t]));r.length&&(this.multipleSelectionEnabled||(this.highlightIds.removeAll(),r.splice(1)),this.highlightIds.addMany(r))}deselectRows(e){const{itemIdPath:t}=this,i=e?.map((e=>e[t]))||[];i.length&&this.highlightIds.removeMany(i)}showColumn(e){this.viewModel.showColumn(e)}sort({path:e,direction:t}){this.viewModel.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){0!==this.size&&(this._grid?.isConnected&&this._grid?.scrollToIndex(e),this._temporaryHighlightId=null)}scrollToTop(){this.scrollToIndex(0)}scrollToBottom(){this.scrollToIndex(1/0)}scrollLeft(e){const{_table:t}=this;t&&(t.scrollLeft=e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}onColumnChange(){this._columnElements.forEach((e=>this._applyRenderersToColumnElement(e))),this.requestContentUpdate()}render(){return m("div",{bind:this,class:this.classes(_.base,u.widget)},m("div",{bind:this,class:_.content},this._renderGrid()))}_renderGrid(){return m("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellPartNameGenerator:this.cellPartNameGenerator,class:_.grid,columnRendering:this._columnRendering,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,multiSortPriority:this.multipleSortPriority,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:this._selectedItems,size:this.effectiveSize},this._renderAllColumns(),this._renderEmptyState())}_renderAllColumns(){return"disabled"!==this.state&&this.columns.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,autoWidth:!1,bind:this,dragSelect:!0,frozen:!0,hidden:this.hasInvalidColumnConfiguration||!this.selectionColumnEnabled,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):m("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const i=this.getColumnProps(e,t);if(i.hidden||!e.columns)return null;const r=e.columns.filter((({hidden:e})=>!e));return r.length?m("vaadin-grid-column-group",{...i},r.map((e=>m("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_renderEmptyState(){const e=this.viewModel;if("loaded"===e.state&&!e.isQueryingOrSyncing)return m("div",{class:_.noDataMessage,slot:"empty-state"},this._noDataMessage??this.messages.noDataFound)}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",p),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()})),t.__updateSorter=(e,i,r)=>{const o=t._sorters,n=!o.includes(e),{multiSort:l,multiSortOnShiftClick:s,multiSortPriority:d}=t,a=o.filter((t=>t!==e)),h=l&&(!s||!r)||s&&i;e._order=null,e.direction?h?null!=e._initialOrder?(n?o[e._initialOrder]=e:o.splice(e._initialOrder,0,e),e._initialOrder=null):"append"===d&&n?t._sorters=[...a,e]:"prepend"===d&&(t._sorters=[e,...a]):(e.direction||s)&&(t._sorters=e.direction?[e]:[],a.forEach((e=>{e._order=null,e.direction=null}))):n||(t._sorters=[...a])},t.__removeSorters=e=>{if(0===e.length)return;const i=new Set(e.filter((e=>!e.direction)));t._sorters=t._sorters.filter((e=>!i.has(e))),t.__applySorters()}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing],\n #items [part~="row"][editing][selected] {\n z-index: 2;\n }\n\n #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n\n [frozen], [frozen-to-end] {\n z-index: 4;\n }\n\n [last-frozen] {\n overflow: visible;\n }\n\n [part~=\'cell\'] ::slotted(vaadin-grid-cell-content) {\n align-items: center;\n box-sizing: border-box !important;\n height: 100%;\n line-height: 2em;\n min-height: 40px;\n }\n\n #items [part~="text-wrap"] {\n text-wrap: wrap;\n }\n ',e.appendChild(t))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_updateGridSize(){this._grid&&(this._grid.size=this.effectiveSize,this.scheduleRender())}_addGridEventListeners(){const e=this._grid;r(e),this.addHandles([i(e,["click","dblclick","keydown","pointerover","pointerout"],(e=>this._onGridInteraction(e))),i(e,["pointerover","pointerout","cell-focus"],(e=>this._onTransientGridInteraction(e))),i(e,"selected-items-changed",this._onSelectedItemsChange),i(e,"sorter-changed",(()=>{this.notifyChange("sortOrders"),this._updateColumnBorderStyles()})),i(e,"column-resize",(e=>{const t=e.detail.resizedColumn,i=t.getAttribute("data-fieldName"),r=this.findColumn(i);r?.set({width:t.width}),this._updateColumnBorderStyles()})),i(e,"column-reorder",(()=>this._onColumnOrderChange()))])}_onGridInteraction(e){const t=this._grid;if(r(t),("pointerover"===e.type||"pointerout"===e.type)&&e.relatedTarget!==t){const{target:t,relatedTarget:i}=e;if(!this._isGridCellContentNode(t)||!this._isGridCellContentNode(i))return}let i=null;try{i=t.getEventContext(e)}catch(a){}if(!i)return;const{column:o,index:n,item:l,section:s}=i;if(!s)return;if("header"===s&&"keydown"===e.type&&o?.path){const t=e.key;f.sort.includes(t)&&this.findColumn(o.path)?.sort()}const d=`cell-${e.type}`;this.emit(d,{type:d,context:i,index:n,item:l,native:e,path:o?.path??void 0})}_onTransientGridInteraction(e){if("pointerout"===e.type)return void(this._temporaryHighlightId=null);const t=this._grid;if(t)try{const{item:i}=t.getEventContext(e);this._temporaryHighlightId=i?.objectId}catch{this._temporaryHighlightId=null}}_isGridCellContentNode(e){return!!(e&&e instanceof HTMLElement&&"vaadin-grid-cell-content"===e.localName)}_onColumnOrderChange(){const e=this._grid;r(e);const t=e._getColumnsInOrder(0),i=[],o=(this.viewModel.groupColumns.length?e._getColumnsInOrder(1):t).map((e=>e.getAttribute("data-fieldName")));t?.forEach((e=>{const t=e.getAttribute("data-fieldName");if(null!=t){const e=this.findColumn(t);i.push(t),e&&"columns"in e&&e.columns?.length&&e.columns.sort(((e,t)=>o.indexOf(e.fieldName)>o.indexOf(t.fieldName)?1:-1))}})),this.columns.sort(((e,t)=>i.indexOf(e.fieldName)>i.indexOf(t.fieldName)?1:-1)),this.notifyChange("sortOrders"),this.emit("column-reorder",{type:"column-reorder"})}_clearSelection(){this.highlightIds.removeAll(),this._temporaryHighlightId=null}_onSelectedItemsChange(e){const{highlightIds:t,itemIdPath:i}=this,r=e.detail.value.map((e=>e[i])),o=r.filter((e=>!t.includes(e)));if(!this.multipleSelectionEnabled&&o.length&&t.length)t.removeAll(),t.add(o[0]);else{const e=t.filter((e=>!r.includes(e)));t.removeMany(e),t.addMany(o)}}_applyRenderersToColumnElement(e){const t=e?.path,i=null!=t?this.findColumn(t):void 0;if(i)try{const{renderFunction:t,footerRenderFunction:r,headerRenderFunction:o}=i;t&&"renderer"in e&&(e.renderer=(e,i,r)=>t({root:e,column:i,rowData:r})),r&&(e.footerRenderer=(e,t)=>r({root:e,column:t})),o&&(e.headerRenderer=(e,t)=>o({root:e,column:t}))}catch(r){}}_updateColumnBorderStyles(){this._grid?._updateFirstAndLastColumn()}};e([s()],v.prototype,"_columnElements",void 0),e([s()],v.prototype,"_columnRendering",null),e([s()],v.prototype,"_selectedItems",null),e([s()],v.prototype,"_grid",void 0),e([s()],v.prototype,"_noDataMessage",null),e([s()],v.prototype,"_table",null),e([s()],v.prototype,"_temporaryHighlightId",void 0),e([s()],v.prototype,"cellPartNameGenerator",null),e([s()],v.prototype,"columns",null),e([s()],v.prototype,"columnPerformanceModeEnabled",null),e([s()],v.prototype,"columnReorderingEnabled",null),e([s()],v.prototype,"dataProvider",null),e([s()],v.prototype,"editingEnabled",null),e([s()],v.prototype,"effectiveSize",null),e([s()],v.prototype,"groupColumns",null),e([s()],v.prototype,"hasInvalidColumnConfiguration",null),e([s()],v.prototype,"highlightIds",null),e([s()],v.prototype,"temporaryHighlightId",null),e([s()],v.prototype,"isEditing",null),e([s()],v.prototype,"isReady",null),e([s()],v.prototype,"itemIdPath",void 0),e([s()],v.prototype,"label",null),e([s(),g("esri/widgets/FeatureTable/t9n/FeatureTable")],v.prototype,"messages",void 0),e([s()],v.prototype,"multipleSelectionEnabled",null),e([s()],v.prototype,"multiSortEnabled",null),e([s()],v.prototype,"noDataMessage",null),e([s()],v.prototype,"pageIndex",null),e([s()],v.prototype,"multipleSortPriority",null),e([s()],v.prototype,"pageSize",null),e([s()],v.prototype,"paginationEnabled",null),e([s()],v.prototype,"rowDetailsRenderer",null),e([s()],v.prototype,"rowHighlightIds",null),e([s()],v.prototype,"selectionColumnEnabled",void 0),e([s()],v.prototype,"size",null),e([s({readOnly:!0})],v.prototype,"sortOrders",null),e([s()],v.prototype,"store",null),e([s()],v.prototype,"state",null),e([s()],v.prototype,"viewModel",void 0),v=e([d("esri.widgets.FeatureTable.Grid.Grid")],v);const y=v;export{y as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"@vaadin/grid/vaadin-grid.js";import"@vaadin/grid/vaadin-grid-column-group.js";import"@vaadin/grid/vaadin-grid-selection-column.js";import"@vaadin/grid/vaadin-grid-sorter.js";import{isSome as t}from"../../../core/arrayUtils.js";import{on as i}from"../../../core/events.js";import{assertIsSome as r}from"../../../core/maybe.js";import{on as o,watch as n}from"../../../core/reactiveUtils.js";import{renderingSanitizer as l}from"../../../core/sanitizerUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import a from"../../Widget.js";import h from"./GridViewModel.js";import{globalCss as u}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as g}from"../../support/decorators/messageBundle.js";import{tsx as m}from"../../support/jsxFactory.js";const c="esri-grid",p="compact column-borders",_={base:c,content:`${c}__content`,grid:`${c}__grid`,noDataMessage:`${c}__no-data-message`},f={sort:["Enter"," "]};let v=class extends a{constructor(e,t){super(e,t),this._columnElements=[],this._grid=null,this._temporaryHighlightId=null,this.itemIdPath="objectId",this.messages=null,this.selectionColumnEnabled=!0,this.viewModel=new h,this._onSelectedItemsChange=this._onSelectedItemsChange.bind(this)}initialize(){this.addHandles([this.columns.on("before-changes",(()=>this.renderNow())),this.columns.on("change",(()=>this.onColumnChange())),o((()=>this.highlightIds),"before-add",(({target:e})=>{!this.multipleSelectionEnabled&&e.length&&e.removeAll()})),this.rowHighlightIds.on("change",(()=>this.generateCellPartNames())),n((()=>this.effectiveSize),(()=>this._updateGridSize())),n((()=>this.isEditing),(()=>{this.generateCellPartNames(),this.requestContentUpdate()})),n((()=>this.store?.state),((e,t)=>{"ready"!==e||"loaded"!==t&&"error"!==t||this.refreshPageCache()})),o((()=>this._table),"scroll",(()=>this.viewModel.closeColumnMenus())),i(window,"resize",(()=>this._updateColumnBorderStyles())),o((()=>this._table),"scrollend",(()=>{this.paginationEnabled||(this.pageIndex=this.getVirtualPageIndex()),this._updateColumnBorderStyles()})),n((()=>this.multipleSelectionEnabled),(e=>{!e&&this.highlightIds.length>1&&this.highlightIds.removeAll()}))])}destroy(){this.resetColumns(),this.columns.destroyed||this.columns.destroy()}resetColumns(){this.columns.drain((e=>!e.destroyed&&e.destroy()))}get _columnRendering(){return this.columnPerformanceModeEnabled?"lazy":"eager"}get _selectedItems(){const{highlightIds:e,store:t}=this;return e.toArray().map((e=>t?.getItemByObjectId(e)??{objectId:e}))}get _gridIsDisabled(){return 0===this.viewModel.allVisibleColumns.length||this.hasInvalidColumnConfiguration}get _noDataMessage(){return l.sanitize(this.noDataMessage)}get _table(){return this._grid?.$?.table}get cellPartNameGenerator(){return this.viewModel.cellPartNameGenerator}set cellPartNameGenerator(e){this.viewModel.cellPartNameGenerator=e}get columns(){return this.viewModel.columns}set columns(e){this.viewModel.columns=e}get columnPerformanceModeEnabled(){return this.viewModel.columnPerformanceModeEnabled}set columnPerformanceModeEnabled(e){this.viewModel.columnPerformanceModeEnabled=e}get columnReorderingEnabled(){return this.viewModel.columnReorderingEnabled}set columnReorderingEnabled(e){this.viewModel.columnReorderingEnabled=e}get dataProvider(){return this.viewModel.dataProvider}set dataProvider(e){this.viewModel.dataProvider=e}get editingEnabled(){return this.viewModel.editingEnabled}set editingEnabled(e){this.viewModel.editingEnabled=e}get effectiveSize(){return this.viewModel.effectiveSize}get groupColumns(){return this.viewModel.groupColumns}get hasInvalidColumnConfiguration(){return this.viewModel.hasInvalidColumnConfiguration}get highlightIds(){return this.viewModel.highlightIds}set highlightIds(e){this.viewModel.highlightIds=e}get temporaryHighlightId(){return this._temporaryHighlightId}get isEditing(){return this.viewModel.isEditing}get isReady(){return!!this._grid}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get multipleSelectionEnabled(){return this.viewModel.multipleSelectionEnabled}set multipleSelectionEnabled(e){this.viewModel.multipleSelectionEnabled=e}get multiSortEnabled(){return this.viewModel.multiSortEnabled}set multiSortEnabled(e){this.viewModel.multiSortEnabled=e}get noDataMessage(){return this.viewModel.noDataMessage}set noDataMessage(e){this.viewModel.noDataMessage=e}get pageIndex(){return this.viewModel.pageIndex}set pageIndex(e){this.viewModel.pageIndex=e}get multipleSortPriority(){return this.viewModel.multipleSortPriority}set multipleSortPriority(e){this.viewModel.multipleSortPriority=e}get pageSize(){return this.viewModel.pageSize}set pageSize(e){this.viewModel.pageSize=e}get paginationEnabled(){return this.viewModel.paginationEnabled}set paginationEnabled(e){this.viewModel.paginationEnabled=e}get rowDetailsRenderer(){return this.viewModel.rowDetailsRenderer}set rowDetailsRenderer(e){this.viewModel.rowDetailsRenderer=e}get rowHighlightIds(){return this.viewModel.rowHighlightIds}set rowHighlightIds(e){this.viewModel.rowHighlightIds=e}get size(){return this.viewModel.size}get sortOrders(){return this._grid?._sorters?this._grid._sorters.filter((e=>!!e&&e.path)).map((({direction:e,path:t})=>({direction:e,path:t}))):[]}get store(){return this.viewModel.store}set store(e){this.viewModel.store=e}get state(){return this.viewModel.state}addSorter(e){this._grid?.__updateSorter(e,!1,!1),this.notifyChange("sortOrders")}getColumnProps(e,t){const{id:i}=this,{autoWidth:r,direction:o,fieldName:n,flexGrow:l,frozen:s,frozenToEnd:d,hidden:a,label:h,resizable:u,textAlign:g,width:m}=e,c=`${i}_${n}_${t}`,{renderFunction:p,footerRenderFunction:_,headerRenderFunction:f}=e,v=_?(e,t)=>_({root:e,column:t}):void 0,y=f?(e,t)=>f({root:e,column:t}):void 0,C=p?(e,t,i)=>p({root:e,column:t,rowData:i}):void 0;let w="";return e.direction&&(w+=" direction"),e.invalid&&(w+=" invalid"),{footerRenderer:v,headerRenderer:y,renderer:C,autoWidth:r,direction:o,flexGrow:l,frozen:s,frozenToEnd:d,headerPartName:w,key:c,resizable:u,bind:this,"data-fieldName":n,header:h,hidden:this.hasInvalidColumnConfiguration||a,path:n,"text-align":g,width:"number"==typeof m?`${m}px`:m,afterCreate:this._afterColumnCreate,afterRemoved:this._afterColumnRemoved}}clearSelection(){this._clearSelection(),this.scheduleRender()}clearSort(){let e=!1;if(this._grid){if(this._grid._sorters?.length&&(this._grid._sorters.forEach((e=>{e._order=null,e.direction=null})),e=!0),this.columns.length){this.columns.some((e=>!!e.direction))&&(this.columns.forEach((e=>e.direction=null)),e=!0)}e&&(this.notifyChange("sortOrders"),this.scheduleRender())}}findColumn(e){return this.viewModel.findColumn(e)}generateCellPartNames(){this._grid?.generateCellPartNames()}getFirstVisibleRowIndex(){return this._grid?._firstVisibleIndex||0}getVirtualPageIndex(){return Math.floor(this.getFirstVisibleRowIndex()/this.pageSize)}getLastVisibleRowIndex(){return this._grid?._lastVisibleIndex||0}getVisibleItemsCount(){return this._grid?._visibleItemsCount||0}getRowContainingNode(e){try{return this._grid?._getRowContainingNode(e)}catch{return null}}getSlotElementByName(e){return this._grid?.shadowRoot?.querySelector(`slot[name='${e}']`)??null}hasSorter(e){return this._grid?._sorters?.includes(e)||!1}hideColumn(e){this.viewModel.hideColumn(e)}recalculateColumnWidths(){this._grid?.recalculateColumnWidths()}async reset(){this._clearSelection(),await(this.store?.reset()),this.scrollToTop()}refreshPageCache(){this._grid?.clearCache(),this._temporaryHighlightId=null}requestContentUpdate(){this._grid?.requestContentUpdate(),this._temporaryHighlightId=null}selectRows(e){const{itemIdPath:t}=this,i=e?.filter((e=>!this.highlightIds.includes(e[t]))),r=i.map((e=>e[t]));r.length&&(this.multipleSelectionEnabled||(this.highlightIds.removeAll(),r.splice(1)),this.highlightIds.addMany(r))}deselectRows(e){const{itemIdPath:t}=this,i=e?.map((e=>e[t]))||[];i.length&&this.highlightIds.removeMany(i)}showColumn(e){this.viewModel.showColumn(e)}sort({path:e,direction:t}){this.viewModel.sortColumn(e,t),this.notifyChange("sortOrders")}scrollToIndex(e){0!==this.size&&(this._grid?.isConnected&&this._grid?.scrollToIndex(e),this._temporaryHighlightId=null)}scrollToTop(){this.scrollToIndex(0)}scrollToBottom(){this.scrollToIndex(1/0)}scrollLeft(e){const{_table:t}=this;t&&(t.scrollLeft=e)}toggleColumnVisibility(e){this.viewModel.toggleColumnVisibility(e)}onColumnChange(){this._columnElements.forEach((e=>this._applyRenderersToColumnElement(e))),this.requestContentUpdate()}render(){return m("div",{bind:this,class:this.classes(_.base,u.widget)},m("div",{bind:this,class:_.content},this._renderGrid()))}_renderGrid(){return m("vaadin-grid",{afterCreate:this._afterGridCreate,afterUpdate:this._afterGridUpdate,bind:this,cellPartNameGenerator:this.cellPartNameGenerator,class:_.grid,columnRendering:this._columnRendering,columnReorderingAllowed:this.columnReorderingEnabled,dataProvider:this.dataProvider,disabled:this._gridIsDisabled,id:`${this.id}_grid`,itemIdPath:this.itemIdPath,multiSort:this.multiSortEnabled,multiSortPriority:this.multipleSortPriority,pageSize:this.pageSize,ref:"grid",rowDetailsRenderer:this.rowDetailsRenderer,selectedItems:this._selectedItems,size:this.effectiveSize},this._renderAllColumns(),this._renderEmptyState())}_renderAllColumns(){return"disabled"!==this.state&&this.columns.length?[this._renderSelectionColumn(),this._renderColumns()]:null}_renderSelectionColumn(){return m("vaadin-grid-selection-column",{_selectAllHidden:!0,autoWidth:!1,bind:this,dragSelect:!0,frozen:!0,hidden:this.hasInvalidColumnConfiguration||!this.selectionColumnEnabled,selectAll:!1,sortable:!1,textAlign:"center"})}_renderColumns(){return Array.from(this.columns,((e,t)=>"columns"in e?this._renderGroupColumn(e,t):m("vaadin-grid-column",{...this.getColumnProps(e,t)}))).filter(t)}_renderGroupColumn(e,t){const i=this.getColumnProps(e,t);if(i.hidden||!e.columns)return null;const r=e.columns.filter((({hidden:e})=>!e));return r.length?m("vaadin-grid-column-group",{...i},r.map((e=>m("vaadin-grid-column",{...this.getColumnProps(e,t)})))):null}_renderEmptyState(){const e=this.viewModel;if("loaded"===e.state&&!e.isQueryingOrSyncing)return m("div",{class:_.noDataMessage,slot:"empty-state"},this._noDataMessage??this.messages.noDataFound)}_afterGridCreate(e){const t=this._grid=e;t.setAttribute("theme",p),customElements.whenDefined("vaadin-grid").then((()=>{this._appendStyles(),this._addGridEventListeners()})),t.__updateSorter=(e,i,r)=>{const o=t._sorters,n=!o.includes(e),{multiSort:l,multiSortOnShiftClick:s,multiSortPriority:d}=t,a=o.filter((t=>t!==e)),h=l&&(!s||!r)||s&&i;e._order=null,e.direction?h?null!=e._initialOrder?(n?o[e._initialOrder]=e:o.splice(e._initialOrder,0,e),e._initialOrder=null):"append"===d&&n?t._sorters=[...a,e]:"prepend"===d&&(t._sorters=[e,...a]):(e.direction||s)&&(t._sorters=e.direction?[e]:[],a.forEach((e=>{e._order=null,e.direction=null}))):n||(t._sorters=[...a])},t.__removeSorters=e=>{if(0===e.length)return;const i=new Set(e.filter((e=>!e.direction)));t._sorters=t._sorters.filter((e=>!i.has(e))),t.__applySorters()}}_appendStyles(){const e=this._grid?.shadowRoot,t=document.createElement("style");e&&(t.textContent='\n #items [part~="row"][editing],\n #items [part~="row"][editing][selected] {\n z-index: 2;\n }\n\n #items [part~="editing"],\n #items [part~="editing"][selected] {\n z-index: 3;\n }\n\n [frozen], [frozen-to-end] {\n z-index: 4;\n }\n\n [last-frozen] {\n overflow: visible;\n }\n\n [part~=\'cell\'] ::slotted(vaadin-grid-cell-content) {\n align-items: center;\n box-sizing: border-box !important;\n height: 100%;\n line-height: 2em;\n min-height: 40px;\n }\n\n #items [part~="text-wrap"] {\n text-wrap: wrap;\n }\n ',e.appendChild(t))}_afterGridUpdate(e){this._grid||(this._grid=e)}_afterColumnCreate(e){this._columnElements.push(e)}_afterColumnRemoved(e){const t=this._columnElements.indexOf(e,0);t>-1&&this._columnElements.splice(t,1)}_updateGridSize(){this._grid&&(this._grid.size=this.effectiveSize,this.scheduleRender())}_addGridEventListeners(){const e=this._grid;r(e),this.addHandles([i(e,["click","dblclick","keydown","pointerover","pointerout"],(e=>this._onGridInteraction(e))),i(e,["pointerover","pointerout","cell-focus"],(e=>this._onTransientGridInteraction(e))),i(e,"selected-items-changed",this._onSelectedItemsChange),i(e,"sorter-changed",(()=>{this.notifyChange("sortOrders"),this._updateColumnBorderStyles()})),i(e,"column-resize",(e=>{const t=e.detail.resizedColumn,i=t.getAttribute("data-fieldName"),r=this.findColumn(i);r?.set({width:t.width}),this._updateColumnBorderStyles()})),i(e,"column-reorder",(()=>this._onColumnOrderChange()))])}_onGridInteraction(e){const t=this._grid;if(r(t),("pointerover"===e.type||"pointerout"===e.type)&&e.relatedTarget!==t){const{target:t,relatedTarget:i}=e;if(!this._isGridCellContentNode(t)||!this._isGridCellContentNode(i))return}let i=null;try{i=t.getEventContext(e)}catch(a){}if(!i)return;const{column:o,index:n,item:l,section:s}=i;if(!s)return;if("header"===s&&"keydown"===e.type&&o?.path){const t=e.key;f.sort.includes(t)&&this.findColumn(o.path)?.sort()}const d=`cell-${e.type}`;this.emit(d,{type:d,context:i,index:n,item:l,native:e,path:o?.path??void 0})}_onTransientGridInteraction(e){if("pointerout"===e.type)return void(this._temporaryHighlightId=null);const t=this._grid;if(t)try{const{item:i}=t.getEventContext(e);this._temporaryHighlightId=i?.objectId}catch{this._temporaryHighlightId=null}}_isGridCellContentNode(e){return!!(e&&e instanceof HTMLElement&&"vaadin-grid-cell-content"===e.localName)}_onColumnOrderChange(){const e=this._grid;r(e);const t=e._getColumnsInOrder(0),i=[],o=(this.viewModel.groupColumns.length?e._getColumnsInOrder(1):t).map((e=>e.getAttribute("data-fieldName")));t?.forEach((e=>{const t=e.getAttribute("data-fieldName");if(null!=t){const e=this.findColumn(t);i.push(t),e&&"columns"in e&&e.columns?.length&&e.columns.sort(((e,t)=>o.indexOf(e.fieldName)>o.indexOf(t.fieldName)?1:-1))}})),this.columns.sort(((e,t)=>i.indexOf(e.fieldName)>i.indexOf(t.fieldName)?1:-1)),this.notifyChange("sortOrders"),this.emit("column-reorder",{type:"column-reorder"})}_clearSelection(){this.highlightIds.removeAll(),this._temporaryHighlightId=null}_onSelectedItemsChange(e){const{highlightIds:t,itemIdPath:i}=this,r=e.detail.value.map((e=>e[i])),o=r.filter((e=>!t.includes(e)));if(!this.multipleSelectionEnabled&&o.length&&t.length)t.removeAll(),t.add(o[0]);else{const e=t.filter((e=>!r.includes(e)));t.removeMany(e),t.addMany(o)}}_applyRenderersToColumnElement(e){const t=e?.path,i=null!=t?this.findColumn(t):void 0;if(i)try{const{renderFunction:t,footerRenderFunction:r,headerRenderFunction:o}=i;t&&"renderer"in e&&(e.renderer=(e,i,r)=>t({root:e,column:i,rowData:r})),r&&(e.footerRenderer=(e,t)=>r({root:e,column:t})),o&&(e.headerRenderer=(e,t)=>o({root:e,column:t}))}catch(r){}}_updateColumnBorderStyles(){this._grid?._updateFirstAndLastColumn()}};e([s()],v.prototype,"_columnElements",void 0),e([s()],v.prototype,"_columnRendering",null),e([s()],v.prototype,"_selectedItems",null),e([s()],v.prototype,"_grid",void 0),e([s()],v.prototype,"_gridIsDisabled",null),e([s()],v.prototype,"_noDataMessage",null),e([s()],v.prototype,"_table",null),e([s()],v.prototype,"_temporaryHighlightId",void 0),e([s()],v.prototype,"cellPartNameGenerator",null),e([s()],v.prototype,"columns",null),e([s()],v.prototype,"columnPerformanceModeEnabled",null),e([s()],v.prototype,"columnReorderingEnabled",null),e([s()],v.prototype,"dataProvider",null),e([s()],v.prototype,"editingEnabled",null),e([s()],v.prototype,"effectiveSize",null),e([s()],v.prototype,"groupColumns",null),e([s()],v.prototype,"hasInvalidColumnConfiguration",null),e([s()],v.prototype,"highlightIds",null),e([s()],v.prototype,"temporaryHighlightId",null),e([s()],v.prototype,"isEditing",null),e([s()],v.prototype,"isReady",null),e([s()],v.prototype,"itemIdPath",void 0),e([s()],v.prototype,"label",null),e([s(),g("esri/widgets/FeatureTable/t9n/FeatureTable")],v.prototype,"messages",void 0),e([s()],v.prototype,"multipleSelectionEnabled",null),e([s()],v.prototype,"multiSortEnabled",null),e([s()],v.prototype,"noDataMessage",null),e([s()],v.prototype,"pageIndex",null),e([s()],v.prototype,"multipleSortPriority",null),e([s()],v.prototype,"pageSize",null),e([s()],v.prototype,"paginationEnabled",null),e([s()],v.prototype,"rowDetailsRenderer",null),e([s()],v.prototype,"rowHighlightIds",null),e([s()],v.prototype,"selectionColumnEnabled",void 0),e([s()],v.prototype,"size",null),e([s({readOnly:!0})],v.prototype,"sortOrders",null),e([s()],v.prototype,"store",null),e([s()],v.prototype,"state",null),e([s()],v.prototype,"viewModel",void 0),v=e([d("esri.widgets.FeatureTable.Grid.Grid")],v);const y=v;export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import c from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import{equalsShallow as u}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as m}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as p}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as F,on as b,watch as M,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as k}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as V}from"../../core/accessorSupport/decorators/subclass.js";import{distance as A}from"../../core/libs/gl-matrix-2/math/vec2.js";import{isSerializable as C}from"../../core/support/jsonUtils.js";import{UpdatingHandles as G}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as R}from"../../geometry/geometryEngineAsync.js";import O from"../../geometry/Multipoint.js";import T from"../../geometry/Point.js";import j from"../../geometry/Polygon.js";import B from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projectionUtils.js";import E from"../../geometry/SpatialReference.js";import{isClockwise as z}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as H}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import U from"../../layers/MediaLayer.js";import{searchImages as N,getSortedLayerFeatures as W}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as q}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as $,computePolygonForInspection as J,resizePolygon as Z,checkIfPolygonContainsSelectedPoint as K}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as Q,isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as ce,getUpdateElevationProps as le,isElevationSampler as ue,getImageToWorldPanoramicProperties as he,pointToArray as me,transformGraphicCoordinatesToPixel as de,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as fe}from"../../layers/support/floorFilterUtils.js";import we from"../../layers/support/VideoElement.js";import Fe from"../../symbols/SimpleLineSymbol.js";import be from"../../views/MapView.js";import Me from"../../views/draw/Draw.js";import{scale as _e}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Pe}from"../../views/input/InputManager.js";import Ie from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ke,videoExtent as Se,invalidCameraHeading as Ve,sectorsInOrder as Ae,sectorsRadii as Ce,sampleExtent as Ge}from"./constants.js";import{configureSketchTool as Le,extractFieldsFromDataCaptureLayer as Re,isValidDataCaptureLayer as Oe,constructGraphicFromImageGeometry as Te}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{formatPixels as xe,heightMeasurementPanoramic as Ee,heightMeasurement2D as ze,calculateHeightAccuracyPanoramic as He,calculateHeightAccuracy as De,pixelAreaMeasurement2D as Ue,pixelAreaMeasurementPanoramic as Ne,pixelDistanceMeasurement2D as We,pixelDistanceMeasurementPanoramic as qe,generateCombinations as $e,getRootOfSumOfSquaredErrors as Je,generateCombinationsPanoramic as Ze,calculateLocationAccuracyFromDeviations as Ke,calculateReferenceImagePointPanoramic as Qe,calculateAnglePano as Xe,calculateTempImagePoint as Ye,calculateAngle as et,computeTriangulatedAreaMeasurement as tt,computeTriangulatedDistanceMeasurement as at,getModeCorrectedPoint as it,calculateCorrectedPixel as rt,calculateHeightFromTemporaryDistance as st,computeTriangulatedVector as ot,computeTriangulatedPoint as nt}from"./imageMeasurementUtils.js";import{crossSymbol as ct,crossSymbol3D as lt,measurementPolygonSymbol as ut,polylineSymbolPanoramic as ht,measurementPolylineSymbol as mt,sourcePointSymbol as dt,diamondSymbol as pt,diamondSymbol3D as gt,locationSymbol as yt,locationSymbol3D as vt,activeSourcePointSymbol as ft}from"./symbols.js";import{isNoAttachmentError as wt,getContentType as Ft,isTifOrMrf as bt,filterOILLayerView as Mt,assignElevationSampleToFeatures as _t,calculateDirection as Pt,calculateSegment as It,isSceneView as kt,isGraphic as St}from"./utils.js";import Vt from"./components/ImageViewer.js";import At from"./components/NavigationNode.js";import Ct from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as Gt,NoFeatureFoundWithObjectIdError as Lt}from"./navigation/errors.js";import{queryFeatureByObjectIds as Rt}from"./navigation/queries.js";import Ot from"../Sketch/SketchViewModel.js";const Tt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles"},jt=new Set(["JPG","JPEG"]),Bt=/\.(\w+)$/,xt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Et=class extends(c.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.allLayerFeatures=[],this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ke,this.cameraPitchThreshold=ke,this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),h.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),h.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new Vt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle=!1,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t)=>{"default"===this.mode&&"image-loaded"!==this.state||"video"===this.mode&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new be({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Vt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._correctedLocationPointOnImage=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new Ie,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new G,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const a=this.additionalFeatures.find((({attributes:t})=>t.objectId===e));if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(h.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find((({feature:{attributes:{objectId:t}}})=>t===e)),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new Gt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find((({attributes:t})=>`${t.objectId}`==`${e}`)),F((()=>"image-loaded"===this.state),t)),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,c=new t({geometry:n,attributes:o.toJSON(),layer:r});v(e),await s.openPopup({features:[c],location:o.location.clone()})}))},this.updateSuitabilities=(e,t=!0)=>{e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const a=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(Tt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,Pe.WIDGET),Tt.click)},this._createImageClickHandle=()=>{this.removeHandles(Tt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;a.clickAction="pixel-location";const c=l((()=>{a.clickAction=n}));let u=null;const h=b((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),u?.abort(),u=r((async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:x(e,t)}));v(a),this.plotReferencePointOnGround(r)}))}));this.addHandles([h,c],Tt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(Tt.triangularImageClick);const e=this.imageMeasurementViewer?.imageSize;this.triangularMeasurementActive&&"none"!==this.mode&&e&&this.currentBestFeature&&this.addHandles(this.imageMeasurementViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),Tt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(Tt.triangularImageClick);const{imageLocationToolState:e,mode:t,imageMeasurementViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;a.clickAction="pixel-location";let s=null;const o=b((()=>a),"pixel-location",(e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r((async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.currentBestFeatureMeasurementImage.geometry.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)})))}));this.addHandles(o,Tt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(Tt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const c=b((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),this.groundCoordinates=r,this.triangularMeasurementActive&&r&&this._triangulatedLocationWorkflow(r);const n=await this.calculateLocationAccuracy(e,r,t,a);v(a),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(c,Tt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t}=this;if(!t)return;const a=e.results.find((({graphic:{attributes:e}})=>e&&!e[`${t.imageReferenceField}`]&&!e[`${t.imageGeometryField}`]));if(!a)return;const i=a.graphic.attributes[t.objectIdField];await this.showImageByObjectId(i)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:u,cameraOrientation:m,location:d}=r,p=(c??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?H(d):new T(d);let f=s;if(je(s))try{f=await Be(a,u,e)}catch(w){if(y(w))return;return wt(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[a.objectIdField]:u,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${u}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:c}=new URL(o);let l=s?n.match(Bt)?.[1]:e.datasetFormat;if(!l)try{l=await Ft(o,{...t.options})}catch(u){y(u)||h.getLogger(this).error("#getContentType()",u)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(jt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let c=i??0;"number"==typeof n?c=n-c:s&&e&&(c=await se(s,e)-c),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=c,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:u,cameraOrientation:m,location:d}=r,p=(c??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?H(d):new T(d);let f=s;if(je(s))try{f=await Be(a,u,e)}catch(w){if(y(w))return;return wt(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[a.objectIdField]:u,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${u}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await f(a),!e)return;const i=new T({...C(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:ct}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new T(n,E.WebMercator),symbol:lt}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([M((()=>this.view),(()=>{this.load()}),_),M((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),M((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),M((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),M((()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage]),(()=>{this._createTriangularImageClickHandle()}),_),M((()=>[this.state,this.imageLocationToolState,this.view]),((e,t)=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()}),_),M((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),M((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),M((()=>this.currentBestFeature),(async(e,t)=>{d(this._featureChangedTask),this._featureChangedTask=r((async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),M((()=>this.currentBestFeatureMeasurementImage),(async(e,t)=>{d(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r((async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()}))}),_),M((()=>this.triangularMeasurementActive),(async(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics())})),M((()=>this.mode),(e=>{switch(this.removeHandles(Tt.interactionHandles),e){case"default":this.addHandles(M((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles);break;case"video":this.addHandles(M((()=>{const{footprintExtent:e}=this;if(e)return Se}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles);break;case"panoramic":this.addHandles(M((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:i,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[i,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),d(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,u)}),Tt.interactionHandles)}}),_),M((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)}),_),M((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)})),M((()=>this.activeViewer),(e=>{this.removeHandles(Tt.hittestHandles),e&&this.addHandles(b((()=>e),"hittest-response",this._handleImageHitTestResponse),Tt.hittestHandles)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",m(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",m(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find((t=>t.id===e?.attributes.objectId))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return bt(t)||je(t)}get imageLoaded(){return o(h.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Ve}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Mt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?fe(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";if(e.orientedImageryType?.includes("video"))return"video";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",m(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return bt(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new D({elevationInfo:{mode:"absolute-height"}});case"default":return new D;default:return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}beforeLoad(){this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,c=i?.attributes,l=s?.orientationAccuracy;if(!c||!n||!e||e.length<2||!l)return;const u="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ce(c,n[0],n[1]),h=e.at(0),m=e.at(-1);if(!(u&&h&&m&&l&&o))return;const d=[m,h],p=xe(d,!1),g="panoramic"===t?await Ee(d,u,l,i,!0,!1):await ze(d,u,l,!0,a);if(!g)return;const y="panoramic"===t?await He(l,p,u,g,i,!0):await De(l,p,u,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),i?"default"===t?await Ue(e,i,!0):await Ne(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),s?"default"===t?await We([e.at(0),e.at(-1)],s,!0):await qe([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;let c=null;if(this.triangularMeasurementActive&&this.currentBestFeatureMeasurementImage&&this.imageMeasurementViewer?c=await this.getMeasurementProperties(this.currentBestFeatureMeasurementImage,this.imageMeasurementViewer):(c=await this.getMeasurementProperties(),v(a)),!c)return null;const l="area"===t?await Ue(e,c,!0):await We([e.at(0),e.at(-1)],c,!0);v(a);const{updateElevationProps:u,...h}=c,m=$e(h,o);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const r="area"===t?await Ue(e,i,!0):await We([e.at(0),e.at(-1)],i,!0);if(v(a),r&&l){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-l.area):null}return Math.abs(r-l)}return null})),p=await Promise.all(d);v(a);const g=p.filter((e=>null!==e));return 0===g.length?null:Je(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,c=o?.every((e=>0===e))||!o?.length;if(!s||c)return null;const l="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(v(i),!l)return null;const{updateElevationProps:u,...h}=l,m="default"===a?$e(h,o):Ze(h,o);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async r=>{const{updateElevationProps:s,...o}=r;let c="default"===a?await ee(e,o,s):await te(e,o,s);return v(i),n&&!c.spatialReference.equals(n)&&(c=await x(c,n),v(i)),c&&t?[Math.abs(c.x-t.x),Math.abs(c.y-t.y),c.z&&t.z?Math.abs(c.z-t.z):0]:null})),p=await Promise.all(d);if(v(i),!p?.length)return null;const g=p.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,f,w]=Ke(g);return{x:y,y:f,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.orientationAccuracy,c=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||c||"panoramic"!==o)return null;const l=await this.getMeasurementPropertiesPanoramic();if(v(a),!l)return null;const u="area"===t?await Ne(e,l,!0):await qe([e.at(0),e.at(-1)],l,!0);v(a);const{updateElevationProps:h,...m}=l,d=Ze(m,n);if(!d?.length)return null;const p=d.map((e=>({...e,updateElevationProps:h}))).map((async i=>{const r="area"===t?await Ne(e,i,!0):await qe([e.at(0),e.at(-1)],i,!0);if(v(a),r&&u){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-u.area):null}return Math.abs(r-u)}return null})),g=await Promise.all(p);v(a);const y=g.filter((e=>null!==e));return 0===y.length?null:Je(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=xe([e],"panoramic"!==t),c="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ce(o,s[0],s[1]);if("panoramic"===t){if(!c)return;const e=await Qe(n,c,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=Xe(n,e),r=A([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const l=await Ye(n,c,a);if(!l)return;const u=et(n,l),h=A([n.x,n.y],[l.x,l.y]);return u&&h?{measurementAngle:u,tempDistance:h}:void 0}async calculateTriangulatedMeasurements(e){switch(this.measureType){case"distance":{this.triangulatedDistanceMeasurement=await at(this.measurementVectors);const t=await this.calculateAccuracy(e,"distance");if(t&&this.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this.triangulatedDistanceMeasurement.distance);this.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(this.currentBestFeatureMeasurementImage?.geometry.spatialReference){const t=await tt(this.measurementVectors,this.currentBestFeatureMeasurementImage.geometry.spatialReference);this.triangulatedAreaMeasurement=t,this.triangulatedAreaAccuracy=await this.calculateAccuracy(e,"area")??this.triangulatedAreaAccuracy}}}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw xt();Le(i,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw xt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw xt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw xt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw xt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw xt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw xt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach((e=>{const{layer:{coveragePercent:o},attributes:n}=e;let c;const l=k(e.geometry.spatialReference);n.cameraHeight/=l,n.farDistance/=l,n.nearDistance/=l,Q(n.elevationSource)&&(n.elevationSource.constantElevation/=l);const{polygon:u,frustum:h}=$(n);if(c=u.clone(),n.isInspection&&(c=J(n)),o&&(c=Z(c,o)),a||!t||K(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,l=t.clone();l.z=o,l.imageID=a,this.pointSources.push(l),c!==Ve&&(i.push(u),h&&r.push(h))}})),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,E.WebMercator):Promise.resolve(n)).then((e=>(n=e,le((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ue(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=he(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,E.WebMercator):Promise.resolve(n)).then((e=>(n=e,le((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ue(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=it(e.vertices.at(-1),r,o);if(i.length<1||!n||!a||!t||"none"===r)return;const c=rt(i[0],n,t);if(!c?.length)return;this.heightMeasurementPixels.push(c),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const l=st(this.heightMeasurementPixels,a);l&&(this.heightMeasurementResult=l)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=it(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){h.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),_t(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,a?.loadBestImage)}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=ut(o),this.sketch.polylineSymbol="panoramic"===s?ht:mt(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new Me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[e],spatialReference:a});else{const i=new B({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:mt(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[l],spatialReference:e});else{const a=new B({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:ht}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=e.map((e=>[e[0]-.5,-.5-e[1]])),o=this.view?.spatialReference,n=[];for(let c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await x(a,o)),n.push(a)}return ot(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:c}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:u}=$(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${i.attributes.objectId}`,I(s.definitionExpression,c)),geometry:u,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n=dt.clone();return n.outline=new Fe({color:[0,0,0],width:1}),new t({attributes:a,symbol:n,geometry:s})})));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:c,layer:l}=this,u=r?.imageSize;if(!u||!o||"none"===n||"video"===n||c.includes("loading")||!l)return;const{polygon:m}=$(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Re(e,l.imageGeometryField,l.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:d}=await e.queryFeatures({geometry:m,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(d.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:c}=i,l=c,{imageGeometryField:m,oiObjectIdField:d}=this;if(m&&d&&Oe(e,m,d)&&`${s[d]}`==`${o.attributes.objectId}`)try{return Te(s,m,e,a,u,n,r)}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(l?.type){case"point":{const i=await this.getPixels(l,{feature:o,imageSize:u,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:c}=l,h=i.map((e=>e.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))))),m=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me))))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({rings:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,h=i.map((e=>e.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))))),m=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me))))));return new t({attributes:s,layer:e,symbol:r,geometry:new B({paths:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,h=i.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),m=await this.getPixels(h,{feature:o,imageSize:u,mode:n}).then((e=>e.map(me)));return new t({attributes:s,layer:e,symbol:r,geometry:new O({points:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}async getPixels(e,t){const{imageSize:a,mode:i}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new T({x:e.x-.5,y:.5-e.y,spatialReference:E.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new T(n,E.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:c,elevation:l,cameraHeight:u}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await x(h,E.WebMercator));const m=await le(l??(c.z??0)-u,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;if("elevationSample"in m&&ue(m.elevationSample)&&(a.elevationSample=m.elevationSample),"default"===i){const t=ce(o,r[0],r[1]);d=await ee(Array.isArray(e)?e:[e],{...t,cameraLocation:h},m)}else{const t=he(o,r[0],r[1]);d=await te(Array.isArray(e)?e:[e],{...t,cameraLocation:h},m)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter((e=>this._sectorData?.[e]?.length))}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new T({...e.toJSON()}),symbol:pt}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=C(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new T({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:pt}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new T(n,E.WebMercator),symbol:gt}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[e.globalIdField]=i),t.success.push(n)),t}),{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const c=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,u=n!==l,h=u?await import("./transformers.js"):null,m=h?.default[l],d=u?m?.(i):i;if(d)switch(d.type){case"point":return t.geometry=await this.getMapPoint(de(s,d,o),{feature:a,imageSize:o,mode:s}),c||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(d.rings.map((async e=>this.getMapPoint(e.map((([e,t,a])=>de(s,{x:e,y:t,z:a},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map((e=>e.map(me)))}),t}case"polyline":{const e=await Promise.all(d.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>de(s,{x:e,y:t,z:a},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new B({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,paths:e.map((e=>e.map(me)))}),t}}}))),l=c.filter(i);return r.applyEdits({addFeatures:l}).then((e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map((e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:i}}))}async searchBestImage(e,t){try{const a=await N(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),h.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const u=await this.loadSketch(t),h=await this.loadDataCaptureAdapter(t);v(t),u.layer.addMany(c),u.layer.blendMode="source-atop",h.savedGraphics.addMany(c);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const a=this.overlayedMapFeatures.get(e);a&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:a}=e;let i=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!i&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,a);if(o)return v(a),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=ot(e,a);i&&this.measurementVectors.push(i);const r=await nt(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),h.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map(((e,t)=>({...e,featureIndex:t})));n.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const c=n.map((({distance:e})=>e)),l=Math.max(...c),u=a.reduce(((e,t)=>Math.max(e,t.attributes.location.z??0)),-1/0);n.forEach((e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Ce[2],c=It(t,l),h=Pt(i);if(!this._sectorData)return;const m=Ce[3]+n*Math.sin(i*Math.PI/180),d=Ce[3]+n*Math.cos(i*Math.PI/180);let p;const g=a.at(s),y=(g.attributes.location.z??0)/u*Ce[2],v=g===r,{cameraPitch:f}=g.attributes,w=f<5;if(v&&w)p=-90;else{const e=m-Ce[3],t=d-Ce[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),p=i}const F=""===c?h:`${c}_${h}`;v&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=w?null:{x:m,y:d,direction:h}),o[`${g.attributes.objectId}`]=F;const b=this._sectorData[F];b.add({angle:i,featureIndex:s,x:m,y:d,z:y,objectID:g.attributes.objectId,sector:F,featureIndexInSector:b.length})}))}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&(this.imageMeasurementViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.imageMeasurementViewer.imageRenderer))}_initializeSketchTriangular(){this.sketchTriangular=new Ot({view:this.imageMeasurementViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1}})}_initializeSketchTriangularGraphicsLayer(){this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer)}_initializeVideo(){if(this.videoElement)return;this.videoElement=new we({video:this.layer?.imagePathPrefix,georeference:new ve({extent:new L(Ge)})});const e=new U({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.videoViewModel=new Ct({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=C(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new T({spatialReference:E.WebMercator,...i}),symbol:yt}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new T({spatialReference:E.WebMercator,...i}),symbol:yt}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new T(n,E.WebMercator),symbol:vt}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await R(e);if(this._updateFootprintWithFeatures(t,i),this.view?.supportsGround)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||h.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return q({features:e,selectedPoint:t,camera:kt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),l=c.spatialReference.isGeographic?H(c):c,u=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:k(l.spatialReference),m={layerInstanceOrURL:e,point:l,queryParams:{where:u,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(m,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await Rt(e,t,a,i);if(v(i),!r?.features?.length)throw new Lt(t);const s=Y($(r.features[0].attributes).polygon.centroid),o=k(s.spatialReference);this.selectedPoint=s;const n={layerInstanceOrURL:e,point:s,queryParams:{where:I("1=1",I(e.definitionExpression,a)),maximumDistance:e.maximumDistance?e.maximumDistance/o:void 0}};return await this.searchBestImage(n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&(e.imageRenderer.cursor=this._previousCursor),t&&(t.imageRenderer.cursor=this._previousCursor)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair"),t&&a&&(t.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_triangulatedLocationWorkflow(e){if(this.currentBestFeature&&e){const{currentBestFeature:t}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const a=ot(e,t);if(!a)return;this.measurementVectors.push(a),this.plotReferenceLocationPoint(e),this._createTriangularImageLocationHandle()}}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=ue(a),s=await le((e[0].attributes.location.z??0)-e[0].attributes.cameraHeight,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[o,...n]=await ae([t,...e.map((e=>e.attributes.geometry.clone()))],s);v(i),t.elevation=o.z,e.forEach(((e,t)=>{e.attributes.elevation=n[t].z}))}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map((e=>new At({geometry:e.geometry,attributes:e.attributes})))),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoViewModel?.playVideoFromSelectedLocation(e[0]))}_updateFootprintWithFeatures(e,t){const a=[];for(const{geometry:i}of e)t.contains(i)||a.push([i.x,i.y]);a.sort(((e,t)=>+z([e,t]))),t.addRing(a),this.footprintExtent=_e(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:ft,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:dt,visible:s}));if("video"===o&&n&&!this.allLayerFeatures.length){const e=await W(n,i.geometry.spatialReference);e.features?.length&&(this.allLayerFeatures=e.features)}}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Ce[3],i=e.y-Ce[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}plotReferenceLocationPoint(e){if(this.currentBestFeatureMeasurementImage){const t=this.imageMeasurementViewer.imageSize[0],a=this.imageMeasurementViewer.imageSize[1],i=pe(this.currentBestFeatureMeasurementImage.attributes,t,a),r=ge(e,i);this.plotLocationPointOnImage(r,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||h.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!a)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:c},elevationSample:l}=this.currentBestFeature;let u=r.clone();const h=await le(n??(r.z??0)-c,{elevationSample:l,elevationSource:s});this.currentBestFeature.elevationSample=h.elevationSample;const m=Array.isArray(e)?e:[e];let d,p=await Promise.all(m.map((e=>new Promise((t=>{if(!e.hasZ)return t(ae(e,h));t(e)})))));if(r.spatialReference.isGeographic&&(u=await x(u,E.WebMercator,t)),p=await Promise.all(p.map((async e=>u.spatialReference.equals(e.spatialReference)?e:await x(e,u.spatialReference,t)))),v(t),"panoramic"===this.mode)d=ye(p,{imageHeight:i[1],imageWidth:i[0],cameraHeading:o,cameraLocation:u});else{const e=pe(this.currentBestFeature.attributes,i[0],i[1]);d=ge(p,{...e,cameraLocation:u})}return Array.isArray(e)?d:d[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:c,_adapter:l,mode:u}=this,{attributes:{objectId:h},elevationSample:m}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),c){const e=[...a,...i,s].filter(St);c.supportsGround&&m&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,m),"panoramic"===u&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],m)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:ct.clone(),attributes:{imageID:h}}))),this._overlays.graphics.addMany(e)}}else if(c){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,c?.supportsGround&&m&&l?.updateGroundElevation&&"panoramic"===u&&l.updateGroundElevation([e],m),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],Et.prototype,"activeLayer",null),e([S({readOnly:!0})],Et.prototype,"activeViewer",null),e([S()],Et.prototype,"accuracyParametersMissing",null),e([S()],Et.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],Et.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],Et.prototype,"additionalFootprints",void 0),e([S()],Et.prototype,"areaMeasurementResult",void 0),e([S()],Et.prototype,"areaMeasurementAccuracy",void 0),e([S()],Et.prototype,"allLayerFeatures",void 0),e([S()],Et.prototype,"bestFeatureAngle",void 0),e([S()],Et.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],Et.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],Et.prototype,"brightness",null),e([S()],Et.prototype,"cameraHeadingThreshold",void 0),e([S()],Et.prototype,"cameraPitchThreshold",void 0),e([S()],Et.prototype,"videoViewModel",void 0),e([S()],Et.prototype,"collectionId",void 0),e([S({type:Number})],Et.prototype,"contrast",null),e([S()],Et.prototype,"conversionProps",void 0),e([S()],Et.prototype,"coverageFrustums",void 0),e([S()],Et.prototype,"coveragePolygons",void 0),e([S()],Et.prototype,"currentBestFeature",void 0),e([S()],Et.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],Et.prototype,"currentBestFeatureLocation",void 0),e([S()],Et.prototype,"currentCoverageVisible",void 0),e([S()],Et.prototype,"currentNode",null),e([S()],Et.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],Et.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],Et.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],Et.prototype,"disabled",void 0),e([S()],Et.prototype,"displayMessage",void 0),e([S()],Et.prototype,"displayNewMeasurementButton",void 0),e([S()],Et.prototype,"distanceMeasurementResult",void 0),e([S()],Et.prototype,"distanceAccuracyArray",void 0),e([S()],Et.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],Et.prototype,"featureCount",null),e([S()],Et.prototype,"features",void 0),e([S()],Et.prototype,"groundCoordinates",void 0),e([S()],Et.prototype,"groundCoordinatesAccuracy",void 0),e([S()],Et.prototype,"heightMeasurementPixels",void 0),e([S()],Et.prototype,"heightGraphic",void 0),e([S()],Et.prototype,"heightMeasurementResult",void 0),e([S()],Et.prototype,"heightMeasurementAccuracy",void 0),e([S()],Et.prototype,"measurementAngle",void 0),e([S()],Et.prototype,"tempDistance",void 0),e([S({readOnly:!0})],Et.prototype,"imageGalleryEnabled",null),e([S()],Et.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],Et.prototype,"imageLoaded",null),e([S()],Et.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],Et.prototype,"invalidCameraHeading",null),e([S()],Et.prototype,"imagePointsInView",null),e([S()],Et.prototype,"imageMeasurementViewer",void 0),e([S()],Et.prototype,"isAdditionalCoverageVisible",void 0),e([S()],Et.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],Et.prototype,"measurementVectors",void 0),e([S()],Et.prototype,"layer",void 0),e([S()],Et.prototype,"layerView",null),e([S({readOnly:!0})],Et.prototype,"layerFloorFilterClause",null),e([S({type:Number})],Et.prototype,"localPort",void 0),e([S()],Et.prototype,"mapImageConversionToolState",void 0),e([S()],Et.prototype,"measureType",void 0),e([S()],Et.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],Et.prototype,"mode",null),e([S()],Et.prototype,"navigationMode",void 0),e([S()],Et.prototype,"navigatorCurrentBestFeature",void 0),e([S()],Et.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],Et.prototype,"overlayedCameraLocations",void 0),e([S()],Et.prototype,"overlayedMapFeatures",void 0),e([S()],Et.prototype,"pixelCoordinates",void 0),e([S()],Et.prototype,"preserveAngle",void 0),e([S()],Et.prototype,"pointSources",void 0),e([S({readOnly:!0})],Et.prototype,"popupEnabled",null),e([S()],Et.prototype,"previousFeatureAngle",void 0),e([S()],Et.prototype,"referencePoint",null),e([S({readOnly:!0})],Et.prototype,"sectorData",null),e([S()],Et.prototype,"selectedPoint",void 0),e([S({type:Number})],Et.prototype,"sharpness",null),e([S()],Et.prototype,"shouldShowSelectedImage",void 0),e([S()],Et.prototype,"sketch",void 0),e([S()],Et.prototype,"sketchTriangular",void 0),e([S()],Et.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],Et.prototype,"draw",void 0),e([S()],Et.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],Et.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],Et.prototype,"state",null),e([S({readOnly:!0})],Et.prototype,"thumbnails",null),e([S()],Et.prototype,"triangularMeasurementActive",void 0),e([S()],Et.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],Et.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],Et.prototype,"triangulatedAreaMeasurement",void 0),e([S()],Et.prototype,"triangulatedAreaAccuracy",void 0),e([S()],Et.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],Et.prototype,"triangulatedPoint",void 0),e([S()],Et.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],Et.prototype,"updateFootprint",void 0),e([S()],Et.prototype,"updateFootprintPanorama",void 0),e([S()],Et.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],Et.prototype,"view",null),e([S()],Et.prototype,"videoElement",void 0),e([S()],Et.prototype,"videoLayer",void 0),e([S()],Et.prototype,"videoMapView",void 0),e([S()],Et.prototype,"_adapter",void 0),e([S()],Et.prototype,"_sketchGraphicsLayer",null),e([S()],Et.prototype,"_highlightedFeatureHandle",void 0),e([S()],Et.prototype,"_imageViewer",void 0),e([S()],Et.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],Et.prototype,"_locationPointOnImage",void 0),e([S()],Et.prototype,"_correctedLocationPointOnImage",void 0),e([S()],Et.prototype,"_overlays",void 0),e([S({readOnly:!0})],Et.prototype,"_overlaysView",null),e([S()],Et.prototype,"_panoramicViewer",void 0),e([S()],Et.prototype,"_previousCursor",void 0),e([S()],Et.prototype,"_referencePointOnGround",void 0),e([S()],Et.prototype,"_referencePointOnImage",void 0),e([S()],Et.prototype,"_sectorData",void 0),e([S()],Et.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],Et.prototype,"_updatingHandles",void 0),e([S()],Et.prototype,"footprintExtent",void 0),e([S()],Et.prototype,"_featureChangedTask",void 0),Et=e([V("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Et);const zt=Et;export{zt as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as m}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as p}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as F,on as b,watch as M,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as k}from"../../core/unitUtils.js";import{property as V}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import{distance as A}from"../../core/libs/gl-matrix-2/math/vec2.js";import{isSerializable as C}from"../../core/support/jsonUtils.js";import{UpdatingHandles as L}from"../../core/support/UpdatingHandles.js";import G from"../../geometry/Extent.js";import{union as R}from"../../geometry/geometryEngineAsync.js";import O from"../../geometry/Multipoint.js";import T from"../../geometry/Point.js";import j from"../../geometry/Polygon.js";import B from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projectionUtils.js";import E from"../../geometry/SpatialReference.js";import{isClockwise as H}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import U from"../../layers/MediaLayer.js";import{searchImages as N,getSortedLayerFeatures as W}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as q}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as $,computePolygonForInspection as J,resizePolygon as Z,checkIfPolygonContainsSelectedPoint as K}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as Q,isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as le,getUpdateElevationProps as ce,isElevationSampler as he,getImageToWorldPanoramicProperties as ue,pointToArray as me,transformGraphicCoordinatesToPixel as de,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as fe}from"../../layers/support/floorFilterUtils.js";import we from"../../layers/support/VideoElement.js";import Fe from"../../symbols/SimpleLineSymbol.js";import be from"../../views/MapView.js";import Me from"../../views/draw/Draw.js";import{scale as _e}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Pe}from"../../views/input/InputManager.js";import Ie from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as ke,videoExtent as Ve,invalidCameraHeading as Se,sectorsInOrder as Ae,sectorsRadii as Ce,sampleExtent as Le}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Re,isValidDataCaptureLayer as Oe,constructGraphicFromImageGeometry as Te}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{formatPixels as xe,heightMeasurementPanoramic as Ee,heightMeasurement2D as He,calculateHeightAccuracyPanoramic as ze,calculateHeightAccuracy as De,pixelAreaMeasurement2D as Ue,pixelAreaMeasurementPanoramic as Ne,pixelDistanceMeasurement2D as We,pixelDistanceMeasurementPanoramic as qe,generateCombinations as $e,getRootOfSumOfSquaredErrors as Je,generateCombinationsPanoramic as Ze,calculateLocationAccuracyFromDeviations as Ke,calculateReferenceImagePointPanoramic as Qe,calculateAnglePano as Xe,calculateTempImagePoint as Ye,calculateAngle as et,computeTriangulatedAreaMeasurement as tt,computeTriangulatedDistanceMeasurement as at,getModeCorrectedPoint as it,calculateCorrectedPixel as rt,calculateHeightFromTemporaryDistance as st,computeTriangulatedVector as ot,computeTriangulatedPoint as nt}from"./imageMeasurementUtils.js";import{crossSymbol as lt,crossSymbol3D as ct,measurementPolygonSymbol as ht,polylineSymbolPanoramic as ut,measurementPolylineSymbol as mt,sourcePointSymbol as dt,diamondSymbol as pt,diamondSymbol3D as gt,locationSymbol as yt,locationSymbol3D as vt,activeSourcePointSymbol as ft}from"./symbols.js";import{isNoAttachmentError as wt,getContentType as Ft,isTifOrMrf as bt,filterOILLayerView as Mt,assignElevationSampleToFeatures as _t,calculateDirection as Pt,calculateSegment as It,isSceneView as kt,isGraphic as Vt}from"./utils.js";import{disableVideoZoomAndPan as St}from"./videoViewerUtils.js";import At from"./components/ImageViewer.js";import Ct from"./components/NavigationNode.js";import Lt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as Gt,NoFeatureFoundWithObjectIdError as Rt}from"./navigation/errors.js";import{queryFeatureByObjectIds as Ot}from"./navigation/queries.js";import Tt from"../Sketch/SketchViewModel.js";const jt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles"},Bt=new Set(["JPG","JPEG"]),xt=/\.(\w+)$/,Et=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Ht=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.allLayerFeatures=[],this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=ke,this.cameraPitchThreshold=ke,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new At,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle=!1,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t)=>{"default"===this.mode&&"image-loaded"!==this.state||"video"===this.mode&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new be({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new At,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._correctedLocationPointOnImage=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new Ie,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new L,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const a=this.additionalFeatures.find((({attributes:t})=>t.objectId===e));if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.getSectorFeatureById=e=>this._suitabilities?.find((({feature:{attributes:{objectId:t}}})=>t===e)),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new Gt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find((({attributes:t})=>`${t.objectId}`==`${e}`)),F((()=>"image-loaded"===this.state),t)),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,l=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this.updateSuitabilities=(e,t=!0)=>{e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const a=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(jt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,Pe.WIDGET),jt.click)},this._createImageClickHandle=()=>{this.removeHandles(jt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const l=c((()=>{this.clickAction=n}));let h=null;const u=b((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r((async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:x(e,t)}));v(a),this.plotReferencePointOnGround(r)}))}));this.addHandles([u,l],jt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(jt.triangularImageClick);const e=this.imageMeasurementViewer?.imageSize;this.triangularMeasurementActive&&"none"!==this.mode&&e&&this.currentBestFeature&&this.addHandles(this.imageMeasurementViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),jt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(jt.triangularImageClick);const{imageLocationToolState:e,mode:t,imageMeasurementViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=b((()=>a),"pixel-location",(e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r((async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.currentBestFeatureMeasurementImage.geometry.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)})))}));this.addHandles(o,jt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(jt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const l=b((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),this.groundCoordinates=r,this.triangularMeasurementActive&&r&&this._triangulatedLocationWorkflow(r);const n=await this.calculateLocationAccuracy(e,r,t,a);v(a),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(l,jt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t}=this;if(!t)return;const a=e.results.find((({graphic:{attributes:e}})=>e&&!e[`${t.imageReferenceField}`]&&!e[`${t.imageGeometryField}`]));if(!a)return;const i=a.graphic.attributes[t.objectIdField];await this.showImageByObjectId(i)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:m,location:d}=r,p=(l??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?z(d):new T(d);let f=s;if(je(s))try{f=await Be(a,h,e)}catch(w){if(y(w))return;return wt(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(xt)?.[1]:e.datasetFormat;if(!c)try{c=await Ft(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,c,o,l,i,r):await this._setImageSource(this._imageViewer,c,o,l,i,r);break;case"panoramic":if(Bt.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await se(s,e)-l),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:m,location:d}=r,p=(l??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?z(d):new T(d);let f=s;if(je(s))try{f=await Be(a,h,e)}catch(w){if(y(w))return;return wt(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await f(a),!e)return;const i=new T({...C(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:lt}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new T(n,E.WebMercator),symbol:ct}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([M((()=>this.view),(()=>{this.load()}),_),M((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),M((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),M((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),M((()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage]),(()=>{this._createTriangularImageClickHandle()}),_),M((()=>[this.state,this.imageLocationToolState,this.view]),((e,t)=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()}),_),M((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),M((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),M((()=>this.currentBestFeature),(async(e,t)=>{d(this._featureChangedTask),this._featureChangedTask=r((async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),M((()=>this.currentBestFeatureMeasurementImage),(async(e,t)=>{d(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r((async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()}))}),_),M((()=>this.triangularMeasurementActive),(async(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics())})),M((()=>this.mode),(e=>{switch(this.removeHandles(jt.interactionHandles),e){case"default":this.addHandles(M((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,h)}),jt.interactionHandles);break;case"video":this.addHandles(M((()=>{const{footprintExtent:e}=this;if(e)return Ve}),(e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,h)}),jt.interactionHandles);break;case"panoramic":this.addHandles(M((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:i,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[i,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),d(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,h)}),jt.interactionHandles)}}),_),M((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)}),_),M((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)})),M((()=>this.activeViewer),(e=>{this.removeHandles(jt.hittestHandles),e&&this.addHandles(b((()=>e),"hittest-response",this._handleImageHitTestResponse),jt.hittestHandles)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",m(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",m(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find((t=>t.id===e?.attributes.objectId))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return bt(t)||je(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Se}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Mt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?fe(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";if(e.orientedImageryType?.includes("video"))return"video";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",m(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return bt(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new D({elevationInfo:{mode:"absolute-height"}});case"default":return new D;default:return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}beforeLoad(){this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=i?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():le(l,n[0],n[1]),u=e.at(0),m=e.at(-1);if(!(h&&u&&m&&c&&o))return;const d=[m,u],p=xe(d,!1),g="panoramic"===t?await Ee(d,h,c,i,!0,!1):await He(d,h,c,!0,a);if(!g)return;const y="panoramic"===t?await ze(c,p,h,g,i,!0):await De(c,p,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),i?"default"===t?await Ue(e,i,!0):await Ne(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),s?"default"===t?await We([e.at(0),e.at(-1)],s,!0):await qe([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;let l=null;if(this.triangularMeasurementActive&&this.currentBestFeatureMeasurementImage&&this.imageMeasurementViewer?l=await this.getMeasurementProperties(this.currentBestFeatureMeasurementImage,this.imageMeasurementViewer):(l=await this.getMeasurementProperties(),v(a)),!l)return null;const c="area"===t?await Ue(e,l,!0):await We([e.at(0),e.at(-1)],l,!0);v(a);const{updateElevationProps:h,...u}=l,m=$e(u,o);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:h}))).map((async i=>{const r="area"===t?await Ue(e,i,!0):await We([e.at(0),e.at(-1)],i,!0);if(v(a),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),p=await Promise.all(d);v(a);const g=p.filter((e=>null!==e));return 0===g.length?null:Je(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,l=o?.every((e=>0===e))||!o?.length;if(!s||l)return null;const c="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(v(i),!c)return null;const{updateElevationProps:h,...u}=c,m="default"===a?$e(u,o):Ze(u,o);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:h}))).map((async r=>{const{updateElevationProps:s,...o}=r;let l="default"===a?await ee(e,o,s):await te(e,o,s);return v(i),n&&!l.spatialReference.equals(n)&&(l=await x(l,n),v(i)),l&&t?[Math.abs(l.x-t.x),Math.abs(l.y-t.y),l.z&&t.z?Math.abs(l.z-t.z):0]:null})),p=await Promise.all(d);if(v(i),!p?.length)return null;const g=p.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,f,w]=Ke(g);return{x:y,y:f,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(v(a),!c)return null;const h="area"===t?await Ne(e,c,!0):await qe([e.at(0),e.at(-1)],c,!0);v(a);const{updateElevationProps:u,...m}=c,d=Ze(m,n);if(!d?.length)return null;const p=d.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const r="area"===t?await Ne(e,i,!0):await qe([e.at(0),e.at(-1)],i,!0);if(v(a),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(p);v(a);const y=g.filter((e=>null!==e));return 0===y.length?null:Je(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=xe([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():le(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Qe(n,l,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=Xe(n,e),r=A([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await Ye(n,l,a);if(!c)return;const h=et(n,c),u=A([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}async calculateTriangulatedMeasurements(e){switch(this.measureType){case"distance":{this.triangulatedDistanceMeasurement=await at(this.measurementVectors);const t=await this.calculateAccuracy(e,"distance");if(t&&this.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this.triangulatedDistanceMeasurement.distance);this.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(this.currentBestFeatureMeasurementImage?.geometry.spatialReference){const t=await tt(this.measurementVectors,this.currentBestFeatureMeasurementImage.geometry.spatialReference);this.triangulatedAreaMeasurement=t,this.triangulatedAreaAccuracy=await this.calculateAccuracy(e,"area")??this.triangulatedAreaAccuracy}}}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw Et();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw Et();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Et();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Et();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Et();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Et();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Et();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach((e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const c=k(e.geometry.spatialReference);n.cameraHeight/=c,n.farDistance/=c,n.nearDistance/=c,Q(n.elevationSource)&&(n.elevationSource.constantElevation/=c);const{polygon:h,frustum:u}=$(n);if(l=h.clone(),n.isInspection&&(l=J(n)),o&&(l=Z(l,o)),a||!t||K(l,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:l}=n,c=t.clone();c.z=o,c.imageID=a,this.pointSources.push(c),l!==Se&&(i.push(h),u&&r.push(u))}})),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=le(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,E.WebMercator):Promise.resolve(n)).then((e=>(n=e,ce((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ue(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,E.WebMercator):Promise.resolve(n)).then((e=>(n=e,ce((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=it(e.vertices.at(-1),r,o);if(i.length<1||!n||!a||!t||"none"===r)return;const l=rt(i[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=st(this.heightMeasurementPixels,a);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=it(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),_t(r,n);const l=this._processSuitableFeatures(r,t);this.updateSuitabilities(l,a?.loadBestImage)}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=ht(o),this.sketch.polylineSymbol="panoramic"===s?ut:mt(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new Me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[e],spatialReference:a});else{const i=new B({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:mt(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:l}=oe(r,a[0],a[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[c],spatialReference:e});else{const a=new B({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:ut}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=e.map((e=>[e[0]-.5,-.5-e[1]])),o=this.view?.spatialReference,n=[];for(let l=0;l<s.length;l++){const e={x:s[l][0],y:s[l][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await x(a,o)),n.push(a)}return ot(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:l}=this,c=a?.imageSize;if(!c||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=$(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${i.attributes.objectId}`,I(s.definitionExpression,l)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:c,mode:o}),n=dt.clone();return n.outline=new Fe({color:[0,0,0],width:1}),new t({attributes:a,symbol:n,geometry:s})})));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||l.includes("loading")||!c)return;const{polygon:m}=$(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Re(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:d}=await e.queryFeatures({geometry:m,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(d.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i,c=l,{imageGeometryField:m,oiObjectIdField:d}=this;if(m&&d&&Oe(e,m,d)&&`${s[d]}`==`${o.attributes.objectId}`)try{return Te(s,m,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const i=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:l}))))),m=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(me))))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({rings:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:l}))))),m=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(me))))));return new t({attributes:s,layer:e,symbol:r,geometry:new B({paths:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=c,u=i.map((([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:l}))),m=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then((e=>e.map(me)));return new t({attributes:s,layer:e,symbol:r,geometry:new O({points:m,spatialReference:E.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}async getPixels(e,t){const{imageSize:a,mode:i}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new T({x:e.x-.5,y:.5-e.y,spatialReference:E.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new T(n,E.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await x(u,E.WebMercator));const m=await ce(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;if("elevationSample"in m&&he(m.elevationSample)&&(a.elevationSample=m.elevationSample),"default"===i){const t=le(o,r[0],r[1]);d=await ee(Array.isArray(e)?e:[e],{...t,cameraLocation:u},m)}else{const t=ue(o,r[0],r[1]);d=await te(Array.isArray(e)?e:[e],{...t,cameraLocation:u},m)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Ae.filter((e=>this._sectorData?.[e]?.length))}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new T({...e.toJSON()}),symbol:pt}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=C(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new T({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:pt}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new T(n,E.WebMercator),symbol:gt}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(a&&(l[e.objectIdField]=a),i&&e.globalIdField&&(l[e.globalIdField]=i),t.success.push(n)),t}),{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,m=u?.default[c],d=h?m?.(i):i;if(d)switch(d.type){case"point":return t.geometry=await this.getMapPoint(de(s,d,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(d.rings.map((async e=>this.getMapPoint(e.map((([e,t,a])=>de(s,{x:e,y:t,z:a},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(me)))}),t}case"polyline":{const e=await Promise.all(d.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>de(s,{x:e,y:t,z:a},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new B({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(me)))}),t}}}))),c=l.filter(i);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let a=0;const i=l.map((e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:i}}))}async searchBestImage(e,t){try{const a=await N(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const a=this.overlayedMapFeatures.get(e);a&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:a}=e;let i=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!i&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,a);if(o)return v(a),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=ot(e,a);i&&this.measurementVectors.push(i);const r=await nt(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const u of Ae)this._sectorData[u]=new s;const n=e.map(((e,t)=>({...e,featureIndex:t})));n.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const l=n.map((({distance:e})=>e)),c=Math.max(...l),h=a.reduce(((e,t)=>Math.max(e,t.attributes.location.z??0)),-1/0);n.forEach((e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/c*Ce[2],l=It(t,c),u=Pt(i);if(!this._sectorData)return;const m=Ce[3]+n*Math.sin(i*Math.PI/180),d=Ce[3]+n*Math.cos(i*Math.PI/180);let p;const g=a.at(s),y=(g.attributes.location.z??0)/h*Ce[2],v=g===r,{cameraPitch:f}=g.attributes,w=f<5;if(v&&w)p=-90;else{const e=m-Ce[3],t=d-Ce[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),p=i}const F=""===l?u:`${l}_${u}`;v&&(p===this.bestFeatureAngle?this.previousFeatureAngle=p:this.bestFeatureAngle=p,this.navigatorCurrentBestFeature=w?null:{x:m,y:d,direction:u}),o[`${g.attributes.objectId}`]=F;const b=this._sectorData[F];b.add({angle:i,featureIndex:s,x:m,y:d,z:y,objectID:g.attributes.objectId,sector:F,featureIndexInSector:b.length})}))}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&(this.imageMeasurementViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.imageMeasurementViewer.imageRenderer))}_initializeSketchTriangular(){this.sketchTriangular=new Tt({view:this.imageMeasurementViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1}})}_initializeSketchTriangularGraphicsLayer(){this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer)}_initializeVideo(){if(this.videoElement)return;this.removeHandles(jt.videoPlayerHandles),this.videoElement=new we({video:this.layer?.imagePathPrefix,georeference:new ve({extent:new G(Le)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new U({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(St(this.videoMapView),jt.videoPlayerHandles),this.videoViewModel=new Lt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=C(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new T({spatialReference:E.WebMercator,...i}),symbol:yt}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new T({spatialReference:E.WebMercator,...i}),symbol:yt}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new T(n,E.WebMercator),symbol:vt}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await R(e);if(this._updateFootprintWithFeatures(t,i),this.view?.supportsGround)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return q({features:e,selectedPoint:t,camera:kt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=l.spatialReference.isGeographic?z(l):l,h=I("1=1",I(e.definitionExpression,n)),u=c.spatialReference.isGeographic?1:k(c.spatialReference),m={layerInstanceOrURL:e,point:c,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(m,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await Ot(e,t,a,i);if(v(i),!r?.features?.length)throw new Rt(t);const s=Y($(r.features[0].attributes).polygon.centroid),o=k(s.spatialReference);this.selectedPoint=s;const n={layerInstanceOrURL:e,point:s,queryParams:{where:I("1=1",I(e.definitionExpression,a)),maximumDistance:e.maximumDistance?e.maximumDistance/o:void 0}};return await this.searchBestImage(n,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&(e.imageRenderer.cursor=this._previousCursor),t&&(t.imageRenderer.cursor=this._previousCursor)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair"),t&&a&&(t.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_triangulatedLocationWorkflow(e){if(this.currentBestFeature&&e){const{currentBestFeature:t}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const a=ot(e,t);if(!a)return;this.measurementVectors.push(a),this.plotReferenceLocationPoint(e),this._createTriangularImageLocationHandle()}}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=he(a),s=await ce((e[0].attributes.location.z??0)-e[0].attributes.cameraHeight,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[o,...n]=await ae([t,...e.map((e=>e.attributes.geometry.clone()))],s);v(i),t.elevation=o.z,e.forEach(((e,t)=>{e.attributes.elevation=n[t].z}))}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map((e=>new Ct({geometry:e.geometry,attributes:e.attributes})))),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0]))}_updateFootprintWithFeatures(e,t){const a=[];for(const{geometry:i}of e)t.contains(i)||a.push([i.x,i.y]);a.sort(((e,t)=>+H([e,t]))),t.addRing(a),this.footprintExtent=_e(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:ft,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:dt,visible:s}));if("video"===o&&n&&!this.allLayerFeatures.length){const e=await W(n,i.geometry.spatialReference);e.features?.length&&(this.allLayerFeatures=e.features)}}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Ce[3],i=e.y-Ce[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}plotReferenceLocationPoint(e){if(this.currentBestFeatureMeasurementImage){const t=this.imageMeasurementViewer.imageSize[0],a=this.imageMeasurementViewer.imageSize[1],i=pe(this.currentBestFeatureMeasurementImage.attributes,t,a),r=ge(e,i);this.plotLocationPointOnImage(r,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!a)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await ce(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const m=Array.isArray(e)?e:[e];let d,p=await Promise.all(m.map((e=>new Promise((t=>{if(!e.hasZ)return t(ae(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,E.WebMercator,t)),p=await Promise.all(p.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),v(t),"panoramic"===this.mode)d=ye(p,{imageHeight:i[1],imageWidth:i[0],cameraHeading:o,cameraLocation:h});else{const e=pe(this.currentBestFeature.attributes,i[0],i[1]);d=ge(p,{...e,cameraLocation:h})}return Array.isArray(e)?d:d[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:m}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...a,...i,s].filter(Vt);l.supportsGround&&m&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,m),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],m)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:lt.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&m&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],m),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([V()],Ht.prototype,"activeLayer",null),e([V({readOnly:!0})],Ht.prototype,"activeViewer",null),e([V()],Ht.prototype,"accuracyParametersMissing",null),e([V()],Ht.prototype,"additionalFeatures",void 0),e([V({type:s.ofType(t)})],Ht.prototype,"additionalCameraLocations",void 0),e([V({type:s.ofType(t)})],Ht.prototype,"additionalFootprints",void 0),e([V()],Ht.prototype,"areaMeasurementResult",void 0),e([V()],Ht.prototype,"areaMeasurementAccuracy",void 0),e([V()],Ht.prototype,"allLayerFeatures",void 0),e([V()],Ht.prototype,"bestFeatureAngle",void 0),e([V()],Ht.prototype,"bestFeatureCurrentFootprint",void 0),e([V({type:t})],Ht.prototype,"bestFeatureFootprint",void 0),e([V({type:Number})],Ht.prototype,"brightness",null),e([V()],Ht.prototype,"cameraHeadingThreshold",void 0),e([V()],Ht.prototype,"cameraPitchThreshold",void 0),e([V()],Ht.prototype,"clickAction",void 0),e([V()],Ht.prototype,"videoViewModel",void 0),e([V()],Ht.prototype,"collectionId",void 0),e([V({type:Number})],Ht.prototype,"contrast",null),e([V()],Ht.prototype,"conversionProps",void 0),e([V()],Ht.prototype,"coverageFrustums",void 0),e([V()],Ht.prototype,"coveragePolygons",void 0),e([V()],Ht.prototype,"currentBestFeature",void 0),e([V()],Ht.prototype,"currentBestFeatureMeasurementImage",void 0),e([V()],Ht.prototype,"currentBestFeatureLocation",void 0),e([V()],Ht.prototype,"currentCoverageVisible",void 0),e([V()],Ht.prototype,"currentNode",null),e([V()],Ht.prototype,"navigationNodes",void 0),e([V({json:{write:!1}})],Ht.prototype,"determineWorkflowForFeature",void 0),e([V({json:{write:!1}})],Ht.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([V()],Ht.prototype,"disabled",void 0),e([V()],Ht.prototype,"displayMessage",void 0),e([V()],Ht.prototype,"displayNewMeasurementButton",void 0),e([V()],Ht.prototype,"distanceMeasurementResult",void 0),e([V()],Ht.prototype,"distanceAccuracyArray",void 0),e([V()],Ht.prototype,"dataCaptureLayer",void 0),e([V({readOnly:!0})],Ht.prototype,"featureCount",null),e([V()],Ht.prototype,"features",void 0),e([V()],Ht.prototype,"groundCoordinates",void 0),e([V()],Ht.prototype,"groundCoordinatesAccuracy",void 0),e([V()],Ht.prototype,"heightMeasurementPixels",void 0),e([V()],Ht.prototype,"heightGraphic",void 0),e([V()],Ht.prototype,"heightMeasurementResult",void 0),e([V()],Ht.prototype,"heightMeasurementAccuracy",void 0),e([V()],Ht.prototype,"measurementAngle",void 0),e([V()],Ht.prototype,"tempDistance",void 0),e([V({readOnly:!0})],Ht.prototype,"imageGalleryEnabled",null),e([V()],Ht.prototype,"imageGeometryField",void 0),e([V({readOnly:!0})],Ht.prototype,"imageLoaded",null),e([V()],Ht.prototype,"imageLocationToolState",void 0),e([V({readOnly:!0})],Ht.prototype,"invalidCameraHeading",null),e([V()],Ht.prototype,"imagePointsInView",null),e([V()],Ht.prototype,"imageMeasurementViewer",void 0),e([V()],Ht.prototype,"isAdditionalCoverageVisible",void 0),e([V()],Ht.prototype,"isAdditionalPointSourcesVisible",void 0),e([V()],Ht.prototype,"measurementVectors",void 0),e([V()],Ht.prototype,"layer",void 0),e([V()],Ht.prototype,"layerView",null),e([V({readOnly:!0})],Ht.prototype,"layerFloorFilterClause",null),e([V({type:Number})],Ht.prototype,"localPort",void 0),e([V()],Ht.prototype,"mapImageConversionToolState",void 0),e([V()],Ht.prototype,"measureType",void 0),e([V()],Ht.prototype,"measurementGraphic",void 0),e([V({readOnly:!0,value:"none"})],Ht.prototype,"mode",null),e([V()],Ht.prototype,"navigationMode",void 0),e([V()],Ht.prototype,"navigatorCurrentBestFeature",void 0),e([V()],Ht.prototype,"oiObjectIdField",void 0),e([V({type:s.ofType(t)})],Ht.prototype,"overlayedCameraLocations",void 0),e([V()],Ht.prototype,"overlayedMapFeatures",void 0),e([V()],Ht.prototype,"pixelCoordinates",void 0),e([V()],Ht.prototype,"preserveAngle",void 0),e([V()],Ht.prototype,"pointSources",void 0),e([V({readOnly:!0})],Ht.prototype,"popupEnabled",null),e([V()],Ht.prototype,"previousFeatureAngle",void 0),e([V()],Ht.prototype,"referencePoint",null),e([V({readOnly:!0})],Ht.prototype,"sectorData",null),e([V()],Ht.prototype,"selectedPoint",void 0),e([V({type:Number})],Ht.prototype,"sharpness",null),e([V()],Ht.prototype,"shouldShowSelectedImage",void 0),e([V()],Ht.prototype,"sketch",void 0),e([V()],Ht.prototype,"sketchTriangular",void 0),e([V()],Ht.prototype,"sketchTriangularGraphicsLayer",void 0),e([V()],Ht.prototype,"draw",void 0),e([V()],Ht.prototype,"sketchAdapter",void 0),e([V({readOnly:!0})],Ht.prototype,"sketchGraphicsLayer",null),e([V({readOnly:!0})],Ht.prototype,"state",null),e([V({readOnly:!0})],Ht.prototype,"thumbnails",null),e([V()],Ht.prototype,"triangularMeasurementActive",void 0),e([V()],Ht.prototype,"triangulatedDistanceMeasurement",void 0),e([V()],Ht.prototype,"triangulatedDistanceAccuracy",void 0),e([V()],Ht.prototype,"triangulatedAreaMeasurement",void 0),e([V()],Ht.prototype,"triangulatedAreaAccuracy",void 0),e([V()],Ht.prototype,"triangulatedMeasurementGraphic",void 0),e([V()],Ht.prototype,"triangulatedPoint",void 0),e([V()],Ht.prototype,"triangulatedMeasurementAdapter",void 0),e([V()],Ht.prototype,"updateFootprint",void 0),e([V()],Ht.prototype,"updateFootprintPanorama",void 0),e([V()],Ht.prototype,"updatingTriangularMeasurementState",void 0),e([V({value:null})],Ht.prototype,"view",null),e([V()],Ht.prototype,"videoElement",void 0),e([V()],Ht.prototype,"videoLayer",void 0),e([V()],Ht.prototype,"videoMapView",void 0),e([V()],Ht.prototype,"_adapter",void 0),e([V()],Ht.prototype,"_sketchGraphicsLayer",null),e([V()],Ht.prototype,"_highlightedFeatureHandle",void 0),e([V()],Ht.prototype,"_imageViewer",void 0),e([V()],Ht.prototype,"_initialCurrentCoverageUpdate",void 0),e([V()],Ht.prototype,"_locationPointOnImage",void 0),e([V()],Ht.prototype,"_correctedLocationPointOnImage",void 0),e([V()],Ht.prototype,"_overlays",void 0),e([V({readOnly:!0})],Ht.prototype,"_overlaysView",null),e([V()],Ht.prototype,"_panoramicViewer",void 0),e([V()],Ht.prototype,"_previousCursor",void 0),e([V()],Ht.prototype,"_referencePointOnGround",void 0),e([V()],Ht.prototype,"_referencePointOnImage",void 0),e([V()],Ht.prototype,"_sectorData",void 0),e([V()],Ht.prototype,"_featureToSector",void 0),e([V({readOnly:!0})],Ht.prototype,"_updatingHandles",void 0),e([V()],Ht.prototype,"footprintExtent",void 0),e([V()],Ht.prototype,"_featureChangedTask",void 0),Ht=e([S("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Ht);const zt=Ht;export{zt as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Promise.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{computeTriangulatedVector as i,computeTriangulatedAreaMeasurement as o,computeTriangulatedDistanceMeasurement as c}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as n}from"../../mixins/TriangulatedSketchHandlerMixin.js";let u=[],m=class extends(n(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if("distance"===t){const t=e.graphics[0].geometry;u=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;u=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?this._updateTriangularMeasurements(u):await this.viewModel.processMeasurementVectors(u))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:r,view:o}=this.viewModel,c=a?.imageSize;if(!e||!t||!c)return;const n=e.map((e=>[e[0]-.5,-.5-e[1]])),u=o?.spatialReference,m=[];for(let i=0;i<n.length;i++){const e={x:n[i][0],y:n[i][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:c,mode:r});u&&!a.spatialReference.equals(u)&&(a=await s(a,u)),m.push(a)}return i(m,t)}async _updateTriangularMeasurements(e){const{measureType:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:r,updatingTriangularMeasurementState:s}=this.viewModel;if(!a||!r||!s||2!==this.viewModel.measurementVectors?.length)return;this.viewModel.measurementVectors.splice(-1);const i=await this._computeMeasurementVector(e,r);if(i&&this.viewModel.measurementVectors.push(i),2===this.viewModel.measurementVectors.length){switch(t){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await c(this.viewModel.measurementVectors);const t=await this.viewModel.calculateAccuracy(e,"distance");if(t&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(r?.geometry.spatialReference){const t=await o(this.viewModel.measurementVectors,r.geometry.spatialReference);this.viewModel.triangulatedAreaMeasurement=t,this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracy(e,"area")??this.viewModel.triangulatedAreaAccuracy}}this.viewModel.updatingTriangularMeasurementState=!1}}};e([a()],m.prototype,"type",void 0),m=e([r("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],m);const l=m;export{l as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Promise.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as r}from"../../../../geometry/projectionUtils.js";import{computeTriangulatedVector as i,computeTriangulatedAreaMeasurement as o,computeTriangulatedDistanceMeasurement as n}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as c}from"../../mixins/TriangulatedSketchHandlerMixin.js";let m=[],u=class extends(c(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if("distance"===t){const t=e.graphics[0].geometry;m=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;m=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?this._updateTriangularMeasurements(m):await this.viewModel.processMeasurementVectors(m))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:s,view:o}=this.viewModel,n=a?.imageSize;if(!e||!t||!n)return;const c=e.map((e=>[e[0]-.5,-.5-e[1]])),m=o?.spatialReference,u=[];for(let i=0;i<c.length;i++){const e={x:c[i][0],y:c[i][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:n,mode:s});m&&!a.spatialReference.equals(m)&&(a=await r(a,m)),u.push(a)}return i(u,t)}async _updateTriangularMeasurements(e){const{measureType:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:s,updatingTriangularMeasurementState:r}=this.viewModel;if(!a||!s||!r||2!==this.viewModel.measurementVectors?.length)return;this.viewModel.measurementVectors.splice(-1);const i=await this._computeMeasurementVector(e,s);if(i&&this.viewModel.measurementVectors.push(i),2===this.viewModel.measurementVectors.length){switch(t){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await n(this.viewModel.measurementVectors);const t=await this.viewModel.calculateAccuracy(e,"distance");if(t&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(s?.geometry.spatialReference){const e=await o(this.viewModel.measurementVectors,s.geometry.spatialReference);this.viewModel.triangulatedAreaMeasurement=e}}this.viewModel.updatingTriangularMeasurementState=!1}}};e([a()],u.prototype,"type",void 0),u=e([s("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],u);const l=u;export{l as default};